From patchwork Thu Jan 7 11:32:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kurz X-Patchwork-Id: 564243 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id B75F01402E2 for ; Thu, 7 Jan 2016 22:34:18 +1100 (AEDT) Received: from localhost ([::1]:57956 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aH8pc-0008Ol-Kn for incoming@patchwork.ozlabs.org; Thu, 07 Jan 2016 06:34:16 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34110) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aH8nz-00057f-Dt for qemu-devel@nongnu.org; Thu, 07 Jan 2016 06:32:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aH8nw-0007RJ-7A for qemu-devel@nongnu.org; Thu, 07 Jan 2016 06:32:35 -0500 Received: from e06smtp17.uk.ibm.com ([195.75.94.113]:33470) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aH8nv-0007R9-V4 for qemu-devel@nongnu.org; Thu, 07 Jan 2016 06:32:32 -0500 Received: from localhost by e06smtp17.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 7 Jan 2016 11:32:30 -0000 Received: from d06dlp01.portsmouth.uk.ibm.com (9.149.20.13) by e06smtp17.uk.ibm.com (192.168.101.147) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 7 Jan 2016 11:32:28 -0000 X-IBM-Helo: d06dlp01.portsmouth.uk.ibm.com X-IBM-MailFrom: gkurz@linux.vnet.ibm.com X-IBM-RcptTo: qemu-devel@nongnu.org Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by d06dlp01.portsmouth.uk.ibm.com (Postfix) with ESMTP id E4BEF17D805A for ; Thu, 7 Jan 2016 11:33:12 +0000 (GMT) Received: from d06av02.portsmouth.uk.ibm.com (d06av02.portsmouth.uk.ibm.com [9.149.37.228]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u07BWRVu64225458 for ; Thu, 7 Jan 2016 11:32:27 GMT Received: from d06av02.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av02.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id u07BWRlQ012119 for ; Thu, 7 Jan 2016 04:32:27 -0700 Received: from smtp.lab.toulouse-stg.fr.ibm.com (srv01.lab.toulouse-stg.fr.ibm.com [9.101.4.1]) by d06av02.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id u07BWRSD012114; Thu, 7 Jan 2016 04:32:27 -0700 Received: from bahia.huguette.org (icon-9-164-177-24.megacenter.de.ibm.com [9.164.177.24]) by smtp.lab.toulouse-stg.fr.ibm.com (Postfix) with ESMTP id B144C22001B; Thu, 7 Jan 2016 12:32:26 +0100 (CET) From: Greg Kurz To: "Michael S. Tsirkin" Date: Thu, 07 Jan 2016 12:32:26 +0100 Message-ID: <20160107113226.10897.23886.stgit@bahia.huguette.org> In-Reply-To: <20160107110747.10897.41118.stgit@bahia.huguette.org> References: <20160107110747.10897.41118.stgit@bahia.huguette.org> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16010711-0005-0000-0000-000009EEA4BF X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 195.75.94.113 Cc: qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH 5/6] vhost: move virtio 1.0 check to cross-endian helper X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Indeed vhost doesn't need to ask for vring endian fixing if the device is virtio 1.0, since it is already handled by the in-kernel vhost driver. This patch simply consolidates the logic into the existing helper. Signed-off-by: Greg Kurz Reviewed-by: Cornelia Huck --- hw/virtio/vhost.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 2e1e792d599e..aef750df22ad 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -750,6 +750,9 @@ static void vhost_log_stop(MemoryListener *listener, static inline bool vhost_needs_vring_endian(VirtIODevice *vdev) { + if (virtio_vdev_has_feature(vdev, VIRTIO_F_VERSION_1)) { + return false; + } #ifdef TARGET_IS_BIENDIAN #ifdef HOST_WORDS_BIGENDIAN return !virtio_is_big_endian(vdev); @@ -811,8 +814,7 @@ static int vhost_virtqueue_start(struct vhost_dev *dev, return -errno; } - if (!virtio_vdev_has_feature(vdev, VIRTIO_F_VERSION_1) && - vhost_needs_vring_endian(vdev)) { + if (vhost_needs_vring_endian(vdev)) { r = vhost_virtqueue_set_vring_endian_legacy(dev, virtio_is_big_endian(vdev), vhost_vq_index); @@ -908,8 +910,7 @@ static void vhost_virtqueue_stop(struct vhost_dev *dev, /* In the cross-endian case, we need to reset the vring endianness to * native as legacy devices expect so by default. */ - if (!virtio_vdev_has_feature(vdev, VIRTIO_F_VERSION_1) && - vhost_needs_vring_endian(vdev)) { + if (vhost_needs_vring_endian(vdev)) { r = vhost_virtqueue_set_vring_endian_legacy(dev, !virtio_is_big_endian(vdev), vhost_vq_index);