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_vq(struct vhost_test *n, int index) in vhost_test_flush_vq() argument
149 vhost_poll_flush(&n->vqs[index].poll); in vhost_test_flush_vq()
152 static void vhost_test_flush(struct vhost_test *n) in vhost_test_flush() argument
154 vhost_test_flush_vq(n, VHOST_TEST_VQ); in vhost_test_flush()
159 struct vhost_test *n = f->private_data; in vhost_test_release() local
162 vhost_test_stop(n, &private); in vhost_test_release()
163 vhost_test_flush(n); in vhost_test_release()
164 vhost_dev_stop(&n->dev); in vhost_test_release()
165 vhost_dev_cleanup(&n->dev); in vhost_test_release()
168 vhost_test_flush(n); in vhost_test_release()
169 kfree(n); in vhost_test_release()
173 static long vhost_test_run(struct vhost_test *n, int test) in vhost_test_run() argument
182 mutex_lock(&n->dev.mutex); in vhost_test_run()
183 r = vhost_dev_check_owner(&n->dev); in vhost_test_run()
187 for (index = 0; index < n->dev.nvqs; ++index) { in vhost_test_run()
189 if (!vhost_vq_access_ok(&n->vqs[index])) { in vhost_test_run()
195 for (index = 0; index < n->dev.nvqs; ++index) { in vhost_test_run()
196 vq = n->vqs + index; in vhost_test_run()
198 priv = test ? n : NULL; in vhost_test_run()
204 r = vhost_vq_init_access(&n->vqs[index]); in vhost_test_run()
212 vhost_test_flush_vq(n, index); in vhost_test_run()
216 mutex_unlock(&n->dev.mutex); in vhost_test_run()
220 mutex_unlock(&n->dev.mutex); in vhost_test_run()
224 static long vhost_test_reset_owner(struct vhost_test *n) in vhost_test_reset_owner() argument
230 mutex_lock(&n->dev.mutex); in vhost_test_reset_owner()
231 err = vhost_dev_check_owner(&n->dev); in vhost_test_reset_owner()
239 vhost_test_stop(n, &priv); in vhost_test_reset_owner()
240 vhost_test_flush(n); in vhost_test_reset_owner()
241 vhost_dev_stop(&n->dev); in vhost_test_reset_owner()
242 vhost_dev_reset_owner(&n->dev, umem); in vhost_test_reset_owner()
244 mutex_unlock(&n->dev.mutex); in vhost_test_reset_owner()
248 static int vhost_test_set_features(struct vhost_test *n, u64 features) in vhost_test_set_features() argument
252 mutex_lock(&n->dev.mutex); in vhost_test_set_features()
254 !vhost_log_access_ok(&n->dev)) { in vhost_test_set_features()
255 mutex_unlock(&n->dev.mutex); in vhost_test_set_features()
258 vq = &n->vqs[VHOST_TEST_VQ]; in vhost_test_set_features()
262 mutex_unlock(&n->dev.mutex); in vhost_test_set_features()
266 static long vhost_test_set_backend(struct vhost_test *n, unsigned index, int fd) in vhost_test_set_backend() argument
274 mutex_lock(&n->dev.mutex); in vhost_test_set_backend()
275 r = vhost_dev_check_owner(&n->dev); in vhost_test_set_backend()
283 vq = &n->vqs[index]; in vhost_test_set_backend()
305 vhost_test_flush_vq(n, index); in vhost_test_set_backend()
308 mutex_unlock(&n->dev.mutex); in vhost_test_set_backend()
314 mutex_unlock(&n->dev.mutex); in vhost_test_set_backend()
322 struct vhost_test *n = f->private_data; in vhost_test_ioctl() local
332 return vhost_test_run(n, test); in vhost_test_ioctl()
336 return vhost_test_set_backend(n, backend.index, backend.fd); in vhost_test_ioctl()
350 return vhost_test_set_features(n, features); in vhost_test_ioctl()
352 return vhost_test_reset_owner(n); in vhost_test_ioctl()
354 mutex_lock(&n->dev.mutex); in vhost_test_ioctl()
355 r = vhost_dev_ioctl(&n->dev, ioctl, argp); in vhost_test_ioctl()
357 r = vhost_vring_ioctl(&n->dev, ioctl, argp); in vhost_test_ioctl()
358 vhost_test_flush(n); in vhost_test_ioctl()
359 mutex_unlock(&n->dev.mutex); in vhost_test_ioctl()