Searched refs:vrh (Results 1 - 7 of 7) sorted by relevance

/linux-4.4.14/drivers/vhost/
H A Dvringh.c31 static inline int __vringh_get_head(const struct vringh *vrh, __vringh_get_head() argument
32 int (*getu16)(const struct vringh *vrh, __vringh_get_head()
39 err = getu16(vrh, &avail_idx, &vrh->vring.avail->idx); __vringh_get_head()
42 &vrh->vring.avail->idx); __vringh_get_head()
47 return vrh->vring.num; __vringh_get_head()
50 virtio_rmb(vrh->weak_barriers); __vringh_get_head()
52 i = *last_avail_idx & (vrh->vring.num - 1); __vringh_get_head()
54 err = getu16(vrh, &head, &vrh->vring.avail->ring[i]); __vringh_get_head()
57 *last_avail_idx, &vrh->vring.avail->ring[i]); __vringh_get_head()
61 if (head >= vrh->vring.num) { __vringh_get_head()
63 head, vrh->vring.num); __vringh_get_head()
106 static inline bool range_check(struct vringh *vrh, u64 addr, size_t *len, range_check() argument
112 if (!getrange(vrh, addr, range)) range_check()
140 static inline bool no_range_check(struct vringh *vrh, u64 addr, size_t *len, no_range_check() argument
149 static int move_to_indirect(const struct vringh *vrh, move_to_indirect() argument
162 len = vringh32_to_cpu(vrh, desc->len); move_to_indirect()
169 if (desc->flags & cpu_to_vringh16(vrh, VRING_DESC_F_NEXT)) move_to_indirect()
170 *up_next = vringh16_to_cpu(vrh, desc->next); move_to_indirect()
207 static u16 __cold return_from_indirect(const struct vringh *vrh, int *up_next, return_from_indirect() argument
213 *descs = vrh->vring.desc; return_from_indirect()
214 *desc_max = vrh->vring.num; return_from_indirect()
218 static int slow_copy(struct vringh *vrh, void *dst, const void *src, slow_copy() argument
219 bool (*rcheck)(struct vringh *vrh, u64 addr, size_t *len, slow_copy()
221 bool (*getrange)(struct vringh *vrh, slow_copy()
224 bool (*getrange)(struct vringh *vrh, slow_copy()
239 if (!rcheck(vrh, addr, &part, range, getrange)) slow_copy()
254 __vringh_iov(struct vringh *vrh, u16 i, __vringh_iov() argument
257 bool (*rcheck)(struct vringh *vrh, u64 addr, size_t *len, __vringh_iov()
271 descs = vrh->vring.desc; __vringh_iov()
272 desc_max = vrh->vring.num; __vringh_iov()
289 err = slow_copy(vrh, &desc, &descs[i], rcheck, getrange, __vringh_iov()
297 cpu_to_vringh16(vrh, VRING_DESC_F_INDIRECT))) { __vringh_iov()
298 u64 a = vringh64_to_cpu(vrh, desc.addr); __vringh_iov()
301 len = vringh32_to_cpu(vrh, desc.len); __vringh_iov()
302 if (!rcheck(vrh, a, &len, &range, getrange)) { __vringh_iov()
307 if (unlikely(len != vringh32_to_cpu(vrh, desc.len))) { __vringh_iov()
314 err = move_to_indirect(vrh, &up_next, &i, addr, &desc, __vringh_iov()
321 if (count++ == vrh->vring.num) { __vringh_iov()
327 if (desc.flags & cpu_to_vringh16(vrh, VRING_DESC_F_WRITE)) __vringh_iov()
348 len = vringh32_to_cpu(vrh, desc.len); __vringh_iov()
349 if (!rcheck(vrh, vringh64_to_cpu(vrh, desc.addr), &len, &range, __vringh_iov()
354 addr = (void *)(unsigned long)(vringh64_to_cpu(vrh, desc.addr) + __vringh_iov()
367 if (unlikely(len != vringh32_to_cpu(vrh, desc.len))) { __vringh_iov()
368 desc.len = cpu_to_vringh32(vrh, __vringh_iov()
369 vringh32_to_cpu(vrh, desc.len) - len); __vringh_iov()
370 desc.addr = cpu_to_vringh64(vrh, __vringh_iov()
371 vringh64_to_cpu(vrh, desc.addr) + len); __vringh_iov()
375 if (desc.flags & cpu_to_vringh16(vrh, VRING_DESC_F_NEXT)) { __vringh_iov()
376 i = vringh16_to_cpu(vrh, desc.next); __vringh_iov()
380 i = return_from_indirect(vrh, &up_next, __vringh_iov()
400 static inline int __vringh_complete(struct vringh *vrh, __vringh_complete() argument
403 int (*putu16)(const struct vringh *vrh, __vringh_complete()
413 used_ring = vrh->vring.used; __vringh_complete()
414 used_idx = vrh->last_used_idx + vrh->completed; __vringh_complete()
416 off = used_idx % vrh->vring.num; __vringh_complete()
419 if (num_used > 1 && unlikely(off + num_used >= vrh->vring.num)) { __vringh_complete()
420 u16 part = vrh->vring.num - off; __vringh_complete()
435 virtio_wmb(vrh->weak_barriers); __vringh_complete()
437 err = putu16(vrh, &vrh->vring.used->idx, used_idx + num_used); __vringh_complete()
440 &vrh->vring.used->idx); __vringh_complete()
444 vrh->completed += num_used; __vringh_complete()
449 static inline int __vringh_need_notify(struct vringh *vrh, __vringh_need_notify() argument
450 int (*getu16)(const struct vringh *vrh, __vringh_need_notify()
461 virtio_mb(vrh->weak_barriers); __vringh_need_notify()
464 if (!vrh->event_indices) { __vringh_need_notify()
466 err = getu16(vrh, &flags, &vrh->vring.avail->flags); __vringh_need_notify()
469 &vrh->vring.avail->flags); __vringh_need_notify()
476 err = getu16(vrh, &used_event, &vring_used_event(&vrh->vring)); __vringh_need_notify()
479 &vring_used_event(&vrh->vring)); __vringh_need_notify()
484 if (unlikely(vrh->completed > 0xffff)) __vringh_need_notify()
488 vrh->last_used_idx + vrh->completed, __vringh_need_notify()
489 vrh->last_used_idx); __vringh_need_notify()
491 vrh->last_used_idx += vrh->completed; __vringh_need_notify()
492 vrh->completed = 0; __vringh_need_notify()
496 static inline bool __vringh_notify_enable(struct vringh *vrh, __vringh_notify_enable() argument
497 int (*getu16)(const struct vringh *vrh, __vringh_notify_enable()
499 int (*putu16)(const struct vringh *vrh, __vringh_notify_enable()
504 if (!vrh->event_indices) { __vringh_notify_enable()
506 if (putu16(vrh, &vrh->vring.used->flags, 0) != 0) { __vringh_notify_enable()
508 &vrh->vring.used->flags); __vringh_notify_enable()
512 if (putu16(vrh, &vring_avail_event(&vrh->vring), __vringh_notify_enable()
513 vrh->last_avail_idx) != 0) { __vringh_notify_enable()
515 &vring_avail_event(&vrh->vring)); __vringh_notify_enable()
522 virtio_mb(vrh->weak_barriers); __vringh_notify_enable()
524 if (getu16(vrh, &avail, &vrh->vring.avail->idx) != 0) { __vringh_notify_enable()
526 &vrh->vring.avail->idx); __vringh_notify_enable()
533 return avail == vrh->last_avail_idx; __vringh_notify_enable()
536 static inline void __vringh_notify_disable(struct vringh *vrh, __vringh_notify_disable() argument
537 int (*putu16)(const struct vringh *vrh, __vringh_notify_disable()
540 if (!vrh->event_indices) { __vringh_notify_disable()
542 if (putu16(vrh, &vrh->vring.used->flags, __vringh_notify_disable()
545 &vrh->vring.used->flags); __vringh_notify_disable()
551 static inline int getu16_user(const struct vringh *vrh, u16 *val, const __virtio16 *p) getu16_user() argument
555 *val = vringh16_to_cpu(vrh, v); getu16_user()
559 static inline int putu16_user(const struct vringh *vrh, __virtio16 *p, u16 val) putu16_user() argument
561 __virtio16 v = cpu_to_vringh16(vrh, val); putu16_user()
593 * @vrh: the vringh to initialize.
604 int vringh_init_user(struct vringh *vrh, u64 features, vringh_init_user() argument
616 vrh->little_endian = (features & (1ULL << VIRTIO_F_VERSION_1)); vringh_init_user()
617 vrh->event_indices = (features & (1 << VIRTIO_RING_F_EVENT_IDX)); vringh_init_user()
618 vrh->weak_barriers = weak_barriers; vringh_init_user()
619 vrh->completed = 0; vringh_init_user()
620 vrh->last_avail_idx = 0; vringh_init_user()
621 vrh->last_used_idx = 0; vringh_init_user()
622 vrh->vring.num = num; vringh_init_user()
624 vrh->vring.desc = (__force struct vring_desc *)desc; vringh_init_user()
625 vrh->vring.avail = (__force struct vring_avail *)avail; vringh_init_user()
626 vrh->vring.used = (__force struct vring_used *)used; vringh_init_user()
633 * @vrh: the userspace vring.
643 * *head will be vrh->vring.num. You may be able to ignore an invalid
648 int vringh_getdesc_user(struct vringh *vrh, vringh_getdesc_user() argument
651 bool (*getrange)(struct vringh *vrh, vringh_getdesc_user()
657 *head = vrh->vring.num; vringh_getdesc_user()
658 err = __vringh_get_head(vrh, getu16_user, &vrh->last_avail_idx); vringh_getdesc_user()
663 if (err == vrh->vring.num) vringh_getdesc_user()
687 err = __vringh_iov(vrh, *head, (struct vringh_kiov *)riov, vringh_getdesc_user()
730 * @vrh: the vring.
736 void vringh_abandon_user(struct vringh *vrh, unsigned int num) vringh_abandon_user() argument
740 vrh->last_avail_idx -= num; vringh_abandon_user()
746 * @vrh: the vring.
753 int vringh_complete_user(struct vringh *vrh, u16 head, u32 len) vringh_complete_user() argument
757 used.id = cpu_to_vringh32(vrh, head); vringh_complete_user()
758 used.len = cpu_to_vringh32(vrh, len); vringh_complete_user()
759 return __vringh_complete(vrh, &used, 1, putu16_user, putused_user); vringh_complete_user()
765 * @vrh: the vring.
772 int vringh_complete_multi_user(struct vringh *vrh, vringh_complete_multi_user() argument
776 return __vringh_complete(vrh, used, num_used, vringh_complete_multi_user()
783 * @vrh: the vring.
788 bool vringh_notify_enable_user(struct vringh *vrh) vringh_notify_enable_user() argument
790 return __vringh_notify_enable(vrh, getu16_user, putu16_user); vringh_notify_enable_user()
796 * @vrh: the vring.
801 void vringh_notify_disable_user(struct vringh *vrh) vringh_notify_disable_user() argument
803 __vringh_notify_disable(vrh, putu16_user); vringh_notify_disable_user()
809 * @vrh: the vring we've called vringh_complete_user() on.
813 int vringh_need_notify_user(struct vringh *vrh) vringh_need_notify_user() argument
815 return __vringh_need_notify(vrh, getu16_user); vringh_need_notify_user()
820 static inline int getu16_kern(const struct vringh *vrh, getu16_kern() argument
823 *val = vringh16_to_cpu(vrh, ACCESS_ONCE(*p)); getu16_kern()
827 static inline int putu16_kern(const struct vringh *vrh, __virtio16 *p, u16 val) putu16_kern() argument
829 ACCESS_ONCE(*p) = cpu_to_vringh16(vrh, val); putu16_kern()
855 * @vrh: the vringh to initialize.
865 int vringh_init_kern(struct vringh *vrh, u64 features, vringh_init_kern() argument
877 vrh->little_endian = (features & (1ULL << VIRTIO_F_VERSION_1)); vringh_init_kern()
878 vrh->event_indices = (features & (1 << VIRTIO_RING_F_EVENT_IDX)); vringh_init_kern()
879 vrh->weak_barriers = weak_barriers; vringh_init_kern()
880 vrh->completed = 0; vringh_init_kern()
881 vrh->last_avail_idx = 0; vringh_init_kern()
882 vrh->last_used_idx = 0; vringh_init_kern()
883 vrh->vring.num = num; vringh_init_kern()
884 vrh->vring.desc = desc; vringh_init_kern()
885 vrh->vring.avail = avail; vringh_init_kern()
886 vrh->vring.used = used; vringh_init_kern()
893 * @vrh: the kernelspace vring.
903 * *head will be vrh->vring.num. You may be able to ignore an invalid
908 int vringh_getdesc_kern(struct vringh *vrh, vringh_getdesc_kern() argument
916 err = __vringh_get_head(vrh, getu16_kern, &vrh->last_avail_idx); vringh_getdesc_kern()
921 if (err == vrh->vring.num) vringh_getdesc_kern()
925 err = __vringh_iov(vrh, *head, riov, wiov, no_range_check, NULL, vringh_getdesc_kern()
965 * @vrh: the vring.
971 void vringh_abandon_kern(struct vringh *vrh, unsigned int num) vringh_abandon_kern() argument
975 vrh->last_avail_idx -= num; vringh_abandon_kern()
981 * @vrh: the vring.
988 int vringh_complete_kern(struct vringh *vrh, u16 head, u32 len) vringh_complete_kern() argument
992 used.id = cpu_to_vringh32(vrh, head); vringh_complete_kern()
993 used.len = cpu_to_vringh32(vrh, len); vringh_complete_kern()
995 return __vringh_complete(vrh, &used, 1, putu16_kern, putused_kern); vringh_complete_kern()
1001 * @vrh: the vring.
1006 bool vringh_notify_enable_kern(struct vringh *vrh) vringh_notify_enable_kern() argument
1008 return __vringh_notify_enable(vrh, getu16_kern, putu16_kern); vringh_notify_enable_kern()
1014 * @vrh: the vring.
1019 void vringh_notify_disable_kern(struct vringh *vrh) vringh_notify_disable_kern() argument
1021 __vringh_notify_disable(vrh, putu16_kern); vringh_notify_disable_kern()
1027 * @vrh: the vring we've called vringh_complete_kern() on.
1031 int vringh_need_notify_kern(struct vringh *vrh) vringh_need_notify_kern() argument
1033 return __vringh_need_notify(vrh, getu16_kern); vringh_need_notify_kern()
/linux-4.4.14/include/linux/
H A Dvringh.h112 int vringh_init_user(struct vringh *vrh, u64 features,
144 int vringh_getdesc_user(struct vringh *vrh,
147 bool (*getrange)(struct vringh *vrh,
159 int vringh_complete_user(struct vringh *vrh, u16 head, u32 len);
160 int vringh_complete_multi_user(struct vringh *vrh,
165 void vringh_abandon_user(struct vringh *vrh, unsigned int num);
168 int vringh_need_notify_user(struct vringh *vrh);
170 bool vringh_notify_enable_user(struct vringh *vrh);
171 void vringh_notify_disable_user(struct vringh *vrh);
174 int vringh_init_kern(struct vringh *vrh, u64 features,
205 int vringh_getdesc_kern(struct vringh *vrh,
214 void vringh_abandon_kern(struct vringh *vrh, unsigned int num);
215 int vringh_complete_kern(struct vringh *vrh, u16 head, u32 len);
217 bool vringh_notify_enable_kern(struct vringh *vrh);
218 void vringh_notify_disable_kern(struct vringh *vrh);
220 int vringh_need_notify_kern(struct vringh *vrh);
223 static inline void vringh_notify(struct vringh *vrh) vringh_notify() argument
225 if (vrh->notify) vringh_notify()
226 vrh->notify(vrh); vringh_notify()
229 static inline bool vringh_is_little_endian(const struct vringh *vrh) vringh_is_little_endian() argument
231 return vrh->little_endian || vringh_is_little_endian()
235 static inline u16 vringh16_to_cpu(const struct vringh *vrh, __virtio16 val) vringh16_to_cpu() argument
237 return __virtio16_to_cpu(vringh_is_little_endian(vrh), val); vringh16_to_cpu()
240 static inline __virtio16 cpu_to_vringh16(const struct vringh *vrh, u16 val) cpu_to_vringh16() argument
242 return __cpu_to_virtio16(vringh_is_little_endian(vrh), val); cpu_to_vringh16()
245 static inline u32 vringh32_to_cpu(const struct vringh *vrh, __virtio32 val) vringh32_to_cpu() argument
247 return __virtio32_to_cpu(vringh_is_little_endian(vrh), val); vringh32_to_cpu()
250 static inline __virtio32 cpu_to_vringh32(const struct vringh *vrh, u32 val) cpu_to_vringh32() argument
252 return __cpu_to_virtio32(vringh_is_little_endian(vrh), val); cpu_to_vringh32()
255 static inline u64 vringh64_to_cpu(const struct vringh *vrh, __virtio64 val) vringh64_to_cpu() argument
257 return __virtio64_to_cpu(vringh_is_little_endian(vrh), val); vringh64_to_cpu()
260 static inline __virtio64 cpu_to_vringh64(const struct vringh *vrh, u64 val) cpu_to_vringh64() argument
262 return __cpu_to_virtio64(vringh_is_little_endian(vrh), val); cpu_to_vringh64()
/linux-4.4.14/drivers/misc/mic/host/
H A Dmic_debugfs.c218 struct vringh *vrh = &mvr->vrh; mic_vdev_info_show() local
219 int num = vrh->vring.num; mic_vdev_info_show()
222 desc = vrh->vring.desc; mic_vdev_info_show()
227 seq_printf(s, "vrh i %d weak_barriers %d", mic_vdev_info_show()
228 i, vrh->weak_barriers); mic_vdev_info_show()
230 vrh->last_avail_idx, vrh->last_used_idx); mic_vdev_info_show()
231 seq_printf(s, " completed %d\n", vrh->completed); mic_vdev_info_show()
239 avail = vrh->vring.avail; mic_vdev_info_show()
241 vringh16_to_cpu(vrh, avail->flags), mic_vdev_info_show()
242 vringh16_to_cpu(vrh, avail->idx) & (num - 1)); mic_vdev_info_show()
244 vringh16_to_cpu(vrh, avail->flags), mic_vdev_info_show()
245 vringh16_to_cpu(vrh, avail->idx)); mic_vdev_info_show()
249 used = vrh->vring.used; mic_vdev_info_show()
251 vringh16_to_cpu(vrh, used->flags), mic_vdev_info_show()
252 vringh16_to_cpu(vrh, used->idx) & (num - 1)); mic_vdev_info_show()
254 vringh16_to_cpu(vrh, used->flags), mic_vdev_info_show()
255 vringh16_to_cpu(vrh, used->idx)); mic_vdev_info_show()
258 j, vringh32_to_cpu(vrh, mic_vdev_info_show()
260 vringh32_to_cpu(vrh, mic_vdev_info_show()
H A Dmic_virtio.c180 static void mic_notify(struct vringh *vrh) mic_notify() argument
182 struct mic_vringh *mvrh = container_of(vrh, struct mic_vringh, vrh); mic_notify()
266 struct vringh *vrh = &mvr->vrh; _mic_virtio_copy() local
274 ret = vringh_getdesc_kern(vrh, riov, wiov, _mic_virtio_copy()
334 vringh_complete_kern(vrh, *head, total); _mic_virtio_copy()
336 if (vringh_need_notify_kern(vrh) > 0) _mic_virtio_copy()
337 vringh_notify(vrh); _mic_virtio_copy()
341 vr->info->avail_idx = vrh->last_avail_idx; _mic_virtio_copy()
395 mvdev->mvr[i].vrh.vring.used = mic_virtio_init_post()
426 struct vringh *vrh = &mvdev->mvr[i].vrh; mic_virtio_device_reset() local
428 vrh->completed = 0; mic_virtio_device_reset()
429 vrh->last_avail_idx = 0; mic_virtio_device_reset()
430 vrh->last_used_idx = 0; mic_virtio_device_reset()
675 ret = vringh_init_kern(&mvr->vrh, mic_virtio_add_device()
687 mvr->vrh.notify = mic_notify; mic_virtio_add_device()
H A Dmic_virtio.h46 * @vrh: The host VRINGH used for accessing the card vrings.
58 struct vringh vrh; member in struct:mic_vringh
/linux-4.4.14/tools/virtio/
H A Dvringh_test.c36 static bool getrange_iov(struct vringh *vrh, u64 addr, struct vringh_range *r) getrange_iov() argument
50 static bool getrange_slow(struct vringh *vrh, u64 addr, struct vringh_range *r) getrange_slow() argument
110 static inline int vringh_get_head(struct vringh *vrh, u16 *head) vringh_get_head() argument
115 err = get_user(avail_idx, &vrh->vring.avail->idx); vringh_get_head()
119 if (vrh->last_avail_idx == avail_idx) vringh_get_head()
123 virtio_rmb(vrh->weak_barriers); vringh_get_head()
125 i = vrh->last_avail_idx & (vrh->vring.num - 1); vringh_get_head()
127 err = get_user(*head, &vrh->vring.avail->ring[i]); vringh_get_head()
131 vrh->last_avail_idx++; vringh_get_head()
136 bool (*getrange)(struct vringh *vrh, parallel_test()
172 struct vringh vrh; parallel_test() local
187 vring_init(&vrh.vring, RINGSIZE, host_map, ALIGN); parallel_test()
188 vringh_init_user(&vrh, features, RINGSIZE, true, parallel_test()
189 vrh.vring.desc, vrh.vring.avail, vrh.vring.used); parallel_test()
201 err = vringh_get_head(&vrh, &head); parallel_test()
204 err = vringh_need_notify_user(&vrh); parallel_test()
225 err = vringh_getdesc_user(&vrh, &riov, &wiov, parallel_test()
229 err = vringh_need_notify_user(&vrh); parallel_test()
238 if (!vringh_notify_enable_user(&vrh)) parallel_test()
245 vringh_notify_disable_user(&vrh); parallel_test()
272 err = vringh_complete_user(&vrh, head, written); parallel_test()
277 err = vringh_need_notify_user(&vrh); parallel_test()
439 struct vringh vrh; main() local
449 bool (*getrange)(struct vringh *vrh, u64 addr, struct vringh_range *r); main()
488 vring_init(&vrh.vring, RINGSIZE, __user_addr_min, ALIGN); main()
489 vringh_init_user(&vrh, vdev.features, RINGSIZE, true, main()
490 vrh.vring.desc, vrh.vring.avail, vrh.vring.used); main()
493 err = vringh_getdesc_user(&vrh, &riov, &wiov, getrange, &head); main()
517 err = vringh_getdesc_user(&vrh, &riov, &wiov, getrange, &head); main()
552 err = vringh_complete_user(&vrh, head, err); main()
586 err = vringh_getdesc_user(&vrh, &riov, &wiov, getrange, &head); main()
616 err = vringh_complete_multi_user(&vrh, used, 1); main()
639 err = vringh_getdesc_user(&vrh, &riov, &wiov, getrange, &head); main()
646 assert(vrh.vring.used->idx % RINGSIZE != 0); main()
647 err = vringh_complete_multi_user(&vrh, used, RINGSIZE); main()
723 err = vringh_getdesc_user(&vrh, &riov, &wiov, getrange, &head); main()
135 parallel_test(u64 features, bool (*getrange)(struct vringh *vrh, u64 addr, struct vringh_range *r), bool fast_vringh) parallel_test() argument
/linux-4.4.14/drivers/staging/fbtft/
H A Dfb_ili9325.c44 static unsigned vrh = 0x0d; /* VREG1OUT=Vci*1.85 */ variable
45 module_param(vrh, uint, 0);
46 MODULE_PARM_DESC(vrh,
105 vrh &= 0x0f; init_display()
135 write_reg(par, 0x0012, vrh); /* Internal reference voltage= Vci; */ init_display()

Completed in 428 milliseconds