From patchwork Wed Jun 29 15:50:48 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?SsO8cmdlbiBHcm/Dnw==?= X-Patchwork-Id: 9205685 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 21E946075F for ; Wed, 29 Jun 2016 15:51:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 13A3A28672 for ; Wed, 29 Jun 2016 15:51:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 07F2228674; Wed, 29 Jun 2016 15:51:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 66F6428672 for ; Wed, 29 Jun 2016 15:51:14 +0000 (UTC) Received: from localhost ([::1]:44567 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bIHlh-0000sX-Te for patchwork-qemu-devel@patchwork.kernel.org; Wed, 29 Jun 2016 11:51:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33844) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bIHlP-0000sH-Re for qemu-devel@nongnu.org; Wed, 29 Jun 2016 11:50:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bIHlM-00046b-J0 for qemu-devel@nongnu.org; Wed, 29 Jun 2016 11:50:55 -0400 Received: from mx2.suse.de ([195.135.220.15]:58665) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bIHlM-00046L-CI for qemu-devel@nongnu.org; Wed, 29 Jun 2016 11:50:52 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id C393FAC35; Wed, 29 Jun 2016 15:50:50 +0000 (UTC) From: Juergen Gross To: qemu-devel@nongnu.org, xen-devel@lists.xensource.com Date: Wed, 29 Jun 2016 17:50:48 +0200 Message-Id: <1467215448-29216-1-git-send-email-jgross@suse.com> X-Mailer: git-send-email 2.6.6 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] X-Received-From: 195.135.220.15 Subject: [Qemu-devel] [PATCH v2] xen: use native disk xenbus protocol if possible X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: anthony.perard@citrix.com, Juergen Gross , sstabellini@kernel.org, kraxel@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP The qdisk implementation is using the native xenbus protocol only in case of no protocol specified at all. As using the explicit 32- or 64-bit protocol is slower than the native one due to copying requests not by memcpy but element for element, this is not optimal. Correct this by using the native protocol in case word sizes of frontend and backend match. Signed-off-by: Juergen Gross Reviewed-by: Anthony PERARD --- V2: use native protocol in case of unknown protocol specified as requested by Anthony Perard --- hw/block/xen_disk.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/hw/block/xen_disk.c b/hw/block/xen_disk.c index 90aca73..d0aae67 100644 --- a/hw/block/xen_disk.c +++ b/hw/block/xen_disk.c @@ -975,14 +975,16 @@ static int blk_connect(struct XenDevice *xendev) blkdev->feature_persistent = !!pers; } - blkdev->protocol = BLKIF_PROTOCOL_NATIVE; - if (blkdev->xendev.protocol) { - if (strcmp(blkdev->xendev.protocol, XEN_IO_PROTO_ABI_X86_32) == 0) { - blkdev->protocol = BLKIF_PROTOCOL_X86_32; - } - if (strcmp(blkdev->xendev.protocol, XEN_IO_PROTO_ABI_X86_64) == 0) { - blkdev->protocol = BLKIF_PROTOCOL_X86_64; - } + if (!blkdev->xendev.protocol) { + blkdev->protocol = BLKIF_PROTOCOL_NATIVE; + } else if (strcmp(blkdev->xendev.protocol, XEN_IO_PROTO_ABI_NATIVE) == 0) { + blkdev->protocol = BLKIF_PROTOCOL_NATIVE; + } else if (strcmp(blkdev->xendev.protocol, XEN_IO_PROTO_ABI_X86_32) == 0) { + blkdev->protocol = BLKIF_PROTOCOL_X86_32; + } else if (strcmp(blkdev->xendev.protocol, XEN_IO_PROTO_ABI_X86_64) == 0) { + blkdev->protocol = BLKIF_PROTOCOL_X86_64; + } else { + blkdev->protocol = BLKIF_PROTOCOL_NATIVE; } blkdev->sring = xengnttab_map_grant_ref(blkdev->xendev.gnttabdev,