mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jason Wang <jasowang@redhat.com>
To: "Michael S. Tsirkin" <mst@redhat.com>, linux-kernel@vger.kernel.org
Cc: virtualization@lists.linux-foundation.org
Subject: Re: [PATCH] virtio_ring: sparse warning fixup
Date: Mon, 13 Jul 2020 11:34:54 +0800	[thread overview]
Message-ID: <64117f46-6cad-afd0-7753-1636d6474731@redhat.com> (raw)
In-Reply-To: <20200710104900.406084-1-mst@redhat.com>


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>



      reply	other threads:[~2020-07-13  3:35 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-10 10:49 Michael S. Tsirkin
2020-07-13  3:34 ` Jason Wang [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=64117f46-6cad-afd0-7753-1636d6474731@redhat.com \
    --to=jasowang@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mst@redhat.com \
    --cc=virtualization@lists.linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®