From patchwork Tue Jun 30 08:39:09 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 489577 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 E7D061402A3 for ; Tue, 30 Jun 2015 18:49:30 +1000 (AEST) Received: from localhost ([::1]:45783 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z9rEP-0001xE-65 for incoming@patchwork.ozlabs.org; Tue, 30 Jun 2015 04:49:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40451) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z9r4h-0001dk-BW for qemu-devel@nongnu.org; Tue, 30 Jun 2015 04:39:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z9r4c-0000id-MM for qemu-devel@nongnu.org; Tue, 30 Jun 2015 04:39:27 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36059) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z9r4c-0000i6-H9 for qemu-devel@nongnu.org; Tue, 30 Jun 2015 04:39:22 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 28F9736B372; Tue, 30 Jun 2015 08:39:22 +0000 (UTC) Received: from nilsson.home.kraxel.org (ovpn-116-37.ams2.redhat.com [10.36.116.37]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t5U8dLs7028063; Tue, 30 Jun 2015 04:39:21 -0400 Received: by nilsson.home.kraxel.org (Postfix, from userid 500) id D138A81DC1; Tue, 30 Jun 2015 10:39:17 +0200 (CEST) From: Gerd Hoffmann To: seabios@seabios.org Date: Tue, 30 Jun 2015 10:39:09 +0200 Message-Id: <1435653553-7728-19-git-send-email-kraxel@redhat.com> In-Reply-To: <1435653553-7728-1-git-send-email-kraxel@redhat.com> References: <1435653553-7728-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Gerd Hoffmann , qemu-devel@nongnu.org, "Michael S. Tsirkin" Subject: [Qemu-devel] [PATCH v2 18/22] virtio-scsi: fix initialization for version 1.0 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 Signed-off-by: Gerd Hoffmann --- src/hw/virtio-scsi.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/hw/virtio-scsi.c b/src/hw/virtio-scsi.c index b208d49..3ee0f49 100644 --- a/src/hw/virtio-scsi.c +++ b/src/hw/virtio-scsi.c @@ -146,14 +146,35 @@ init_virtio_scsi(struct pci_device *pci) pci_bdf_to_dev(bdf)); struct vring_virtqueue *vq = NULL; struct vp_device *vp = vp_init_simple(pci); + u8 status = VIRTIO_CONFIG_S_ACKNOWLEDGE | VIRTIO_CONFIG_S_DRIVER; + + if (vp->use_modern) { + u64 features = vp_get_features(vp); + u64 version1 = 1ull << VIRTIO_F_VERSION_1; + if (!(features & version1)) { + dprintf(1, "modern device without virtio_1 feature bit: %x:%x\n", + pci_bdf_to_bus(bdf), pci_bdf_to_dev(bdf)); + goto fail; + } + + vp_set_features(vp, version1); + status |= VIRTIO_CONFIG_S_FEATURES_OK; + vp_set_status(vp, status); + if (!(vp_get_status(vp) & VIRTIO_CONFIG_S_FEATURES_OK)) { + dprintf(1, "device didn't accept features: %x:%x\n", + pci_bdf_to_bus(bdf), pci_bdf_to_dev(bdf)); + goto fail; + } + } + if (vp_find_vq(vp, 2, &vq) < 0 ) { dprintf(1, "fail to find vq for virtio-scsi %x:%x\n", pci_bdf_to_bus(bdf), pci_bdf_to_dev(bdf)); goto fail; } - vp_set_status(vp, VIRTIO_CONFIG_S_ACKNOWLEDGE | - VIRTIO_CONFIG_S_DRIVER | VIRTIO_CONFIG_S_DRIVER_OK); + status |= VIRTIO_CONFIG_S_DRIVER_OK; + vp_set_status(vp, status); int i, tot; for (tot = 0, i = 0; i < 256; i++)