Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753521AbbK3JjF (ORCPT ); Mon, 30 Nov 2015 04:39:05 -0500 Received: from e06smtp07.uk.ibm.com ([195.75.94.103]:44840 "EHLO e06smtp07.uk.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753275AbbK3JiZ (ORCPT ); Mon, 30 Nov 2015 04:38:25 -0500 X-IBM-Helo: d06dlp02.portsmouth.uk.ibm.com X-IBM-MailFrom: gkurz@linux.vnet.ibm.com X-IBM-RcptTo: linux-kernel@vger.kernel.org Date: Mon, 30 Nov 2015 10:38:11 +0100 From: Greg Kurz To: "Michael S. Tsirkin" Cc: linux-kernel@vger.kernel.org, Cornelia Huck , Rusty Russell , virtualization@lists.linux-foundation.org Subject: Re: [PATCH] tools/virtio: fix byteswap logic Message-ID: <20151130103811.7f63ff27@bahia.local> In-Reply-To: <1448872410-11553-1-git-send-email-mst@redhat.com> References: <1448872410-11553-1-git-send-email-mst@redhat.com> Organization: IBM X-Mailer: Claws Mail 3.12.0 (GTK+ 2.24.28; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15113009-0029-0000-0000-000004FEA813 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3016 Lines: 80 On Mon, 30 Nov 2015 10:33:34 +0200 "Michael S. Tsirkin" wrote: > commit cf561f0d2eb74574ad9985a2feab134267a9d298 ("virtio: introduce > virtio_is_little_endian() helper") changed byteswap logic to > skip feature bit checks for LE platforms, but didn't > update tools/virtio, so vring_bench started failing. > Oops... yet another oversight... > Update the copy under tools/virtio/ (TODO: find a way to avoid this code > duplication). > > Cc: Greg Kurz > Signed-off-by: Michael S. Tsirkin > --- Reviewed-by: Greg Kurz > tools/virtio/linux/virtio_config.h | 20 +++++++++++++------- > 1 file changed, 13 insertions(+), 7 deletions(-) > > diff --git a/tools/virtio/linux/virtio_config.h b/tools/virtio/linux/virtio_config.h > index 806d683..57a6964 100644 > --- a/tools/virtio/linux/virtio_config.h > +++ b/tools/virtio/linux/virtio_config.h > @@ -40,33 +40,39 @@ static inline void __virtio_clear_bit(struct virtio_device *vdev, > #define virtio_has_feature(dev, feature) \ > (__virtio_test_bit((dev), feature)) > > +static inline bool virtio_is_little_endian(struct virtio_device *vdev) > +{ > + return virtio_has_feature(vdev, VIRTIO_F_VERSION_1) || > + virtio_legacy_is_little_endian(); > +} > + > +/* Memory accessors */ > static inline u16 virtio16_to_cpu(struct virtio_device *vdev, __virtio16 val) > { > - return __virtio16_to_cpu(virtio_has_feature(vdev, VIRTIO_F_VERSION_1), val); > + return __virtio16_to_cpu(virtio_is_little_endian(vdev), val); > } > > static inline __virtio16 cpu_to_virtio16(struct virtio_device *vdev, u16 val) > { > - return __cpu_to_virtio16(virtio_has_feature(vdev, VIRTIO_F_VERSION_1), val); > + return __cpu_to_virtio16(virtio_is_little_endian(vdev), val); > } > > static inline u32 virtio32_to_cpu(struct virtio_device *vdev, __virtio32 val) > { > - return __virtio32_to_cpu(virtio_has_feature(vdev, VIRTIO_F_VERSION_1), val); > + return __virtio32_to_cpu(virtio_is_little_endian(vdev), val); > } > > static inline __virtio32 cpu_to_virtio32(struct virtio_device *vdev, u32 val) > { > - return __cpu_to_virtio32(virtio_has_feature(vdev, VIRTIO_F_VERSION_1), val); > + return __cpu_to_virtio32(virtio_is_little_endian(vdev), val); > } > > static inline u64 virtio64_to_cpu(struct virtio_device *vdev, __virtio64 val) > { > - return __virtio64_to_cpu(virtio_has_feature(vdev, VIRTIO_F_VERSION_1), val); > + return __virtio64_to_cpu(virtio_is_little_endian(vdev), val); > } > > static inline __virtio64 cpu_to_virtio64(struct virtio_device *vdev, u64 val) > { > - return __cpu_to_virtio64(virtio_has_feature(vdev, VIRTIO_F_VERSION_1), val); > + return __cpu_to_virtio64(virtio_is_little_endian(vdev), val); > } > - -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/