* [PATCH] virtio_ring: sparse warning fixup
@ 2020-07-10 10:49 Michael S. Tsirkin
2020-07-13 3:34 ` Jason Wang
0 siblings, 1 reply; 2+ messages in thread
From: Michael S. Tsirkin @ 2020-07-10 10:49 UTC (permalink / raw)
To: linux-kernel; +Cc: Jason Wang, virtualization
virtio_store_mb was built with split ring in mind so it accepts
__virtio16 arguments. Packed ring uses __le16 values, so sparse
complains. It's just a store with some barriers so let's convert it to
a macro, we don't loose too much type safety by doing that.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
include/linux/virtio_ring.h | 19 +++++++++----------
1 file changed, 9 insertions(+), 10 deletions(-)
diff --git a/include/linux/virtio_ring.h b/include/linux/virtio_ring.h
index 3dc70adfe5f5..b485b13fa50b 100644
--- a/include/linux/virtio_ring.h
+++ b/include/linux/virtio_ring.h
@@ -46,16 +46,15 @@ static inline void virtio_wmb(bool weak_barriers)
dma_wmb();
}
-static inline void virtio_store_mb(bool weak_barriers,
- __virtio16 *p, __virtio16 v)
-{
- if (weak_barriers) {
- virt_store_mb(*p, v);
- } else {
- WRITE_ONCE(*p, v);
- mb();
- }
-}
+#define virtio_store_mb(weak_barriers, p, v) \
+do { \
+ if (weak_barriers) { \
+ virt_store_mb(*p, v); \
+ } else { \
+ WRITE_ONCE(*p, v); \
+ mb(); \
+ } \
+} while (0) \
struct virtio_device;
struct virtqueue;
--
MST
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] virtio_ring: sparse warning fixup
2020-07-10 10:49 [PATCH] virtio_ring: sparse warning fixup Michael S. Tsirkin
@ 2020-07-13 3:34 ` Jason Wang
0 siblings, 0 replies; 2+ messages in thread
From: Jason Wang @ 2020-07-13 3:34 UTC (permalink / raw)
To: Michael S. Tsirkin, linux-kernel; +Cc: virtualization
On 2020/7/10 下午6:49, Michael S. Tsirkin wrote:
> virtio_store_mb was built with split ring in mind so it accepts
> __virtio16 arguments. Packed ring uses __le16 values, so sparse
> complains. It's just a store with some barriers so let's convert it to
> a macro, we don't loose too much type safety by doing that.
>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---
> include/linux/virtio_ring.h | 19 +++++++++----------
> 1 file changed, 9 insertions(+), 10 deletions(-)
>
> diff --git a/include/linux/virtio_ring.h b/include/linux/virtio_ring.h
> index 3dc70adfe5f5..b485b13fa50b 100644
> --- a/include/linux/virtio_ring.h
> +++ b/include/linux/virtio_ring.h
> @@ -46,16 +46,15 @@ static inline void virtio_wmb(bool weak_barriers)
> dma_wmb();
> }
>
> -static inline void virtio_store_mb(bool weak_barriers,
> - __virtio16 *p, __virtio16 v)
> -{
> - if (weak_barriers) {
> - virt_store_mb(*p, v);
> - } else {
> - WRITE_ONCE(*p, v);
> - mb();
> - }
> -}
> +#define virtio_store_mb(weak_barriers, p, v) \
> +do { \
> + if (weak_barriers) { \
> + virt_store_mb(*p, v); \
> + } else { \
> + WRITE_ONCE(*p, v); \
> + mb(); \
> + } \
> +} while (0) \
>
> struct virtio_device;
> struct virtqueue;
Acked-by: Jason Wang <jasowang@redhat.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-07-13 3:35 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-10 10:49 [PATCH] virtio_ring: sparse warning fixup Michael S. Tsirkin
2020-07-13 3:34 ` Jason Wang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).