All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Laurent Vivier <laurent@vivier.eu>
Cc: linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org
Subject: Re: [PATCH] virtio-mmio: read[wl]()/write[wl] are already little-endian
Date: Thu, 11 Mar 2021 10:44:47 -0500	[thread overview]
Message-ID: <20210311104414-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <20210309224313.956065-1-laurent@vivier.eu>

On Tue, Mar 09, 2021 at 11:43:13PM +0100, Laurent Vivier wrote:
> read[wl]()/write[wl] already access memory in little-endian mode.

But then they convert it to CPU right? We just convert it back ...

> No need to convert the value with cpu_to_leXX()/leXX_to_cpu()
> 
> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
> ---
>  drivers/virtio/virtio_mmio.c | 16 ++++++++--------
>  1 file changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/virtio/virtio_mmio.c b/drivers/virtio/virtio_mmio.c
> index a286d22b6551..3f6a5588f77d 100644
> --- a/drivers/virtio/virtio_mmio.c
> +++ b/drivers/virtio/virtio_mmio.c
> @@ -168,17 +168,17 @@ static void vm_get(struct virtio_device *vdev, unsigned offset,
>  		memcpy(buf, &b, sizeof b);
>  		break;
>  	case 2:
> -		w = cpu_to_le16(readw(base + offset));
> +		w = readw(base + offset);
>  		memcpy(buf, &w, sizeof w);
>  		break;
>  	case 4:
> -		l = cpu_to_le32(readl(base + offset));
> +		l = readl(base + offset);
>  		memcpy(buf, &l, sizeof l);
>  		break;
>  	case 8:
> -		l = cpu_to_le32(readl(base + offset));
> +		l = readl(base + offset);
>  		memcpy(buf, &l, sizeof l);
> -		l = cpu_to_le32(ioread32(base + offset + sizeof l));
> +		l = ioread32(base + offset + sizeof l);
>  		memcpy(buf + sizeof l, &l, sizeof l);
>  		break;
>  	default:
> @@ -212,17 +212,17 @@ static void vm_set(struct virtio_device *vdev, unsigned offset,
>  		break;
>  	case 2:
>  		memcpy(&w, buf, sizeof w);
> -		writew(le16_to_cpu(w), base + offset);
> +		writew(w, base + offset);
>  		break;
>  	case 4:
>  		memcpy(&l, buf, sizeof l);
> -		writel(le32_to_cpu(l), base + offset);
> +		writel(l, base + offset);
>  		break;
>  	case 8:
>  		memcpy(&l, buf, sizeof l);
> -		writel(le32_to_cpu(l), base + offset);
> +		writel(l, base + offset);
>  		memcpy(&l, buf + sizeof l, sizeof l);
> -		writel(le32_to_cpu(l), base + offset + sizeof l);
> +		writel(l, base + offset + sizeof l);
>  		break;
>  	default:
>  		BUG();
> -- 
> 2.29.2

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

WARNING: multiple messages have this Message-ID (diff)
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Laurent Vivier <laurent@vivier.eu>
Cc: linux-kernel@vger.kernel.org,
	virtualization@lists.linux-foundation.org,
	Jason Wang <jasowang@redhat.com>
Subject: Re: [PATCH] virtio-mmio: read[wl]()/write[wl] are already little-endian
Date: Thu, 11 Mar 2021 10:44:47 -0500	[thread overview]
Message-ID: <20210311104414-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <20210309224313.956065-1-laurent@vivier.eu>

On Tue, Mar 09, 2021 at 11:43:13PM +0100, Laurent Vivier wrote:
> read[wl]()/write[wl] already access memory in little-endian mode.

But then they convert it to CPU right? We just convert it back ...

> No need to convert the value with cpu_to_leXX()/leXX_to_cpu()
> 
> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
> ---
>  drivers/virtio/virtio_mmio.c | 16 ++++++++--------
>  1 file changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/virtio/virtio_mmio.c b/drivers/virtio/virtio_mmio.c
> index a286d22b6551..3f6a5588f77d 100644
> --- a/drivers/virtio/virtio_mmio.c
> +++ b/drivers/virtio/virtio_mmio.c
> @@ -168,17 +168,17 @@ static void vm_get(struct virtio_device *vdev, unsigned offset,
>  		memcpy(buf, &b, sizeof b);
>  		break;
>  	case 2:
> -		w = cpu_to_le16(readw(base + offset));
> +		w = readw(base + offset);
>  		memcpy(buf, &w, sizeof w);
>  		break;
>  	case 4:
> -		l = cpu_to_le32(readl(base + offset));
> +		l = readl(base + offset);
>  		memcpy(buf, &l, sizeof l);
>  		break;
>  	case 8:
> -		l = cpu_to_le32(readl(base + offset));
> +		l = readl(base + offset);
>  		memcpy(buf, &l, sizeof l);
> -		l = cpu_to_le32(ioread32(base + offset + sizeof l));
> +		l = ioread32(base + offset + sizeof l);
>  		memcpy(buf + sizeof l, &l, sizeof l);
>  		break;
>  	default:
> @@ -212,17 +212,17 @@ static void vm_set(struct virtio_device *vdev, unsigned offset,
>  		break;
>  	case 2:
>  		memcpy(&w, buf, sizeof w);
> -		writew(le16_to_cpu(w), base + offset);
> +		writew(w, base + offset);
>  		break;
>  	case 4:
>  		memcpy(&l, buf, sizeof l);
> -		writel(le32_to_cpu(l), base + offset);
> +		writel(l, base + offset);
>  		break;
>  	case 8:
>  		memcpy(&l, buf, sizeof l);
> -		writel(le32_to_cpu(l), base + offset);
> +		writel(l, base + offset);
>  		memcpy(&l, buf + sizeof l, sizeof l);
> -		writel(le32_to_cpu(l), base + offset + sizeof l);
> +		writel(l, base + offset + sizeof l);
>  		break;
>  	default:
>  		BUG();
> -- 
> 2.29.2


  parent reply	other threads:[~2021-03-11 15:45 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-09 22:43 [PATCH] virtio-mmio: read[wl]()/write[wl] are already little-endian Laurent Vivier
2021-03-10  3:08 ` kernel test robot
2021-03-10  3:08   ` kernel test robot
2021-03-10  3:08   ` kernel test robot
2021-03-11 15:44 ` Michael S. Tsirkin [this message]
2021-03-11 15:44   ` Michael S. Tsirkin
2021-03-11 15:55   ` Laurent Vivier
2021-03-13 17:10   ` Laurent Vivier
2021-03-14  8:26     ` Michael S. Tsirkin
2021-03-14  8:26       ` Michael S. Tsirkin

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=20210311104414-mutt-send-email-mst@kernel.org \
    --to=mst@redhat.com \
    --cc=laurent@vivier.eu \
    --cc=linux-kernel@vger.kernel.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.