Lines Matching refs:n
43 static void handle_vq(struct vhost_test *n) in handle_vq() argument
45 struct vhost_virtqueue *vq = &n->vqs[VHOST_TEST_VQ]; in handle_vq()
58 vhost_disable_notify(&n->dev, vq); in handle_vq()
70 if (unlikely(vhost_enable_notify(&n->dev, vq))) { in handle_vq()
71 vhost_disable_notify(&n->dev, vq); in handle_vq()
87 vhost_add_used_and_signal(&n->dev, vq, head, 0); in handle_vq()
100 struct vhost_test *n = container_of(vq->dev, struct vhost_test, dev); in handle_vq_kick() local
102 handle_vq(n); in handle_vq_kick()
107 struct vhost_test *n = kmalloc(sizeof *n, GFP_KERNEL); in vhost_test_open() local
111 if (!n) in vhost_test_open()
115 kfree(n); in vhost_test_open()
119 dev = &n->dev; in vhost_test_open()
120 vqs[VHOST_TEST_VQ] = &n->vqs[VHOST_TEST_VQ]; in vhost_test_open()
121 n->vqs[VHOST_TEST_VQ].handle_kick = handle_vq_kick; in vhost_test_open()
125 f->private_data = n; in vhost_test_open()
130 static void *vhost_test_stop_vq(struct vhost_test *n, in vhost_test_stop_vq() argument
142 static void vhost_test_stop(struct vhost_test *n, void **privatep) in vhost_test_stop() argument
144 *privatep = vhost_test_stop_vq(n, n->vqs + VHOST_TEST_VQ); in vhost_test_stop()
147 static void vhost_test_flush(struct vhost_test *n) in vhost_test_flush() argument
149 vhost_dev_flush(&n->dev); in vhost_test_flush()
154 struct vhost_test *n = f->private_data; in vhost_test_release() local
157 vhost_test_stop(n, &private); in vhost_test_release()
158 vhost_test_flush(n); in vhost_test_release()
159 vhost_dev_stop(&n->dev); in vhost_test_release()
160 vhost_dev_cleanup(&n->dev); in vhost_test_release()
161 kfree(n->dev.vqs); in vhost_test_release()
162 kfree(n); in vhost_test_release()
166 static long vhost_test_run(struct vhost_test *n, int test) in vhost_test_run() argument
175 mutex_lock(&n->dev.mutex); in vhost_test_run()
176 r = vhost_dev_check_owner(&n->dev); in vhost_test_run()
180 for (index = 0; index < n->dev.nvqs; ++index) { in vhost_test_run()
182 if (!vhost_vq_access_ok(&n->vqs[index])) { in vhost_test_run()
188 for (index = 0; index < n->dev.nvqs; ++index) { in vhost_test_run()
189 vq = n->vqs + index; in vhost_test_run()
191 priv = test ? n : NULL; in vhost_test_run()
197 r = vhost_vq_init_access(&n->vqs[index]); in vhost_test_run()
205 vhost_test_flush(n); in vhost_test_run()
209 mutex_unlock(&n->dev.mutex); in vhost_test_run()
213 mutex_unlock(&n->dev.mutex); in vhost_test_run()
217 static long vhost_test_reset_owner(struct vhost_test *n) in vhost_test_reset_owner() argument
223 mutex_lock(&n->dev.mutex); in vhost_test_reset_owner()
224 err = vhost_dev_check_owner(&n->dev); in vhost_test_reset_owner()
232 vhost_test_stop(n, &priv); in vhost_test_reset_owner()
233 vhost_test_flush(n); in vhost_test_reset_owner()
234 vhost_dev_stop(&n->dev); in vhost_test_reset_owner()
235 vhost_dev_reset_owner(&n->dev, umem); in vhost_test_reset_owner()
237 mutex_unlock(&n->dev.mutex); in vhost_test_reset_owner()
241 static int vhost_test_set_features(struct vhost_test *n, u64 features) in vhost_test_set_features() argument
245 mutex_lock(&n->dev.mutex); in vhost_test_set_features()
247 !vhost_log_access_ok(&n->dev)) { in vhost_test_set_features()
248 mutex_unlock(&n->dev.mutex); in vhost_test_set_features()
251 vq = &n->vqs[VHOST_TEST_VQ]; in vhost_test_set_features()
255 mutex_unlock(&n->dev.mutex); in vhost_test_set_features()
259 static long vhost_test_set_backend(struct vhost_test *n, unsigned index, int fd) in vhost_test_set_backend() argument
267 mutex_lock(&n->dev.mutex); in vhost_test_set_backend()
268 r = vhost_dev_check_owner(&n->dev); in vhost_test_set_backend()
276 vq = &n->vqs[index]; in vhost_test_set_backend()
298 vhost_test_flush(n); in vhost_test_set_backend()
301 mutex_unlock(&n->dev.mutex); in vhost_test_set_backend()
307 mutex_unlock(&n->dev.mutex); in vhost_test_set_backend()
315 struct vhost_test *n = f->private_data; in vhost_test_ioctl() local
325 return vhost_test_run(n, test); in vhost_test_ioctl()
329 return vhost_test_set_backend(n, backend.index, backend.fd); in vhost_test_ioctl()
340 return vhost_test_set_features(n, features); in vhost_test_ioctl()
342 return vhost_test_reset_owner(n); in vhost_test_ioctl()
344 mutex_lock(&n->dev.mutex); in vhost_test_ioctl()
345 r = vhost_dev_ioctl(&n->dev, ioctl, argp); in vhost_test_ioctl()
347 r = vhost_vring_ioctl(&n->dev, ioctl, argp); in vhost_test_ioctl()
348 vhost_test_flush(n); in vhost_test_ioctl()
349 mutex_unlock(&n->dev.mutex); in vhost_test_ioctl()