From nobody Tue Nov 11 15:35:42 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1564416008; cv=none; d=zoho.com; s=zohoarc; b=R78ZWUUFUCmEnhHGtg0CEYqaTf9QC9rPA/1Q0kFIqANHwngshkDoWBzriY9q2VvobIT5KpybxLkpAk0b3LSL6vMs3UQu2laky42gj9YAUDejgyLpS5mPy6sxnABvbbzhn4ZedMPzRRK6dD5TFwDb4ji3oY7Rqh9Wis9DNPSwuJY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564416008; h=Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To:ARC-Authentication-Results; bh=MDzvyagY97Zs0y9Dl7GO6pJFhrrtz4rrwzxG/CM5SsE=; b=nouj87XX0Z+h0UX7pfi0/FCBJ7WmCXxpJFzClZohOHgrpJ074Drp9ld7oYr5DTjKWJ7ziMQ/TjKTzxLwF8b7s2zoaqyezqyDLzmuRlMxABwgsPcU+mVaND0VA/+nWn/6tHEQcAAb1kIOHVDxXwQoneUIkgVSuXrzkeHBwREAFK0= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1564416008608100.30492703741788; Mon, 29 Jul 2019 09:00:08 -0700 (PDT) Received: from localhost ([::1]:54586 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hs84D-0000aj-MH for importer@patchew.org; Mon, 29 Jul 2019 12:00:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53738) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hs83S-00008r-Ca for qemu-devel@nongnu.org; Mon, 29 Jul 2019 11:59:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hs83R-0002HV-27 for qemu-devel@nongnu.org; Mon, 29 Jul 2019 11:59:18 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57916) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hs83Q-0002Gk-Qe for qemu-devel@nongnu.org; Mon, 29 Jul 2019 11:59:17 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A65B830C133F for ; Mon, 29 Jul 2019 15:59:15 +0000 (UTC) Received: from dgilbert-t580.localhost (ovpn-117-222.ams2.redhat.com [10.36.117.222]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5B30E60BE5; Mon, 29 Jul 2019 15:59:12 +0000 (UTC) From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org, berrange@redhat.com, cohuck@redhat.com, mst@redhat.com Date: Mon, 29 Jul 2019 16:59:09 +0100 Message-Id: <20190729155909.22804-1-dgilbert@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Mon, 29 Jul 2019 15:59:15 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [for 4.1 PATCH] Revert "hw: report invalid disable-legacy|modern usage for virtio-1-only devs" X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: "Dr. David Alan Gilbert" This reverts commit f2784eed306449c3d04a71a05ed6463b8289aedf since that accidentally removes the PCIe capabilities from virtio devices because virtio_pci_dc_realize is called before the new 'mode' flag is set. I keep the expanded hw_compat entry because we've lost the ability to do 'optional'. Signed-off-by: Dr. David Alan Gilbert Reviewed-by: Cornelia Huck --- hw/display/virtio-gpu-pci.c | 4 +--- hw/display/virtio-vga.c | 4 +--- hw/virtio/virtio-crypto-pci.c | 4 +--- hw/virtio/virtio-input-pci.c | 4 +--- hw/virtio/virtio-pci.c | 26 ++++++++++---------------- hw/virtio/virtio-pci.h | 31 ++++++------------------------- 6 files changed, 20 insertions(+), 53 deletions(-) diff --git a/hw/display/virtio-gpu-pci.c b/hw/display/virtio-gpu-pci.c index d6f01b4a98..e4c7eb6193 100644 --- a/hw/display/virtio-gpu-pci.c +++ b/hw/display/virtio-gpu-pci.c @@ -33,9 +33,7 @@ static void virtio_gpu_pci_base_realize(VirtIOPCIProxy *v= pci_dev, Error **errp) Error *local_error =3D NULL; =20 qdev_set_parent_bus(vdev, BUS(&vpci_dev->bus)); - if (!virtio_pci_force_virtio_1(vpci_dev, errp)) { - return; - } + virtio_pci_force_virtio_1(vpci_dev); object_property_set_bool(OBJECT(vdev), true, "realized", &local_error); =20 if (local_error) { diff --git a/hw/display/virtio-vga.c b/hw/display/virtio-vga.c index 416e7fec87..79a145e284 100644 --- a/hw/display/virtio-vga.c +++ b/hw/display/virtio-vga.c @@ -137,9 +137,7 @@ static void virtio_vga_base_realize(VirtIOPCIProxy *vpc= i_dev, Error **errp) =20 /* init virtio bits */ qdev_set_parent_bus(DEVICE(g), BUS(&vpci_dev->bus)); - if (!virtio_pci_force_virtio_1(vpci_dev, errp)) { - return; - } + virtio_pci_force_virtio_1(vpci_dev); object_property_set_bool(OBJECT(g), true, "realized", &err); if (err) { error_propagate(errp, err); diff --git a/hw/virtio/virtio-crypto-pci.c b/hw/virtio/virtio-crypto-pci.c index c8a2317a10..91d4446080 100644 --- a/hw/virtio/virtio-crypto-pci.c +++ b/hw/virtio/virtio-crypto-pci.c @@ -53,9 +53,7 @@ static void virtio_crypto_pci_realize(VirtIOPCIProxy *vpc= i_dev, Error **errp) } =20 qdev_set_parent_bus(vdev, BUS(&vpci_dev->bus)); - if (!virtio_pci_force_virtio_1(vpci_dev, errp)) { - return; - } + virtio_pci_force_virtio_1(vpci_dev); object_property_set_bool(OBJECT(vdev), true, "realized", errp); object_property_set_link(OBJECT(vcrypto), OBJECT(vcrypto->vdev.conf.cryptodev), "cryptodev", diff --git a/hw/virtio/virtio-input-pci.c b/hw/virtio/virtio-input-pci.c index 1c40292abc..ad7774e93e 100644 --- a/hw/virtio/virtio-input-pci.c +++ b/hw/virtio/virtio-input-pci.c @@ -49,9 +49,7 @@ static void virtio_input_pci_realize(VirtIOPCIProxy *vpci= _dev, Error **errp) DeviceState *vdev =3D DEVICE(&vinput->vdev); =20 qdev_set_parent_bus(vdev, BUS(&vpci_dev->bus)); - if (!virtio_pci_force_virtio_1(vpci_dev, errp)) { - return; - } + virtio_pci_force_virtio_1(vpci_dev); object_property_set_bool(OBJECT(vdev), true, "realized", errp); } =20 diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index ce928f2429..f6d2223e78 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -1723,22 +1723,16 @@ static void virtio_pci_realize(PCIDevice *pci_dev, = Error **errp) /* PCI BAR regions must be powers of 2 */ pow2ceil(proxy->notify.offset + proxy->notify.size)= ); =20 - if ((proxy->disable_legacy =3D=3D ON_OFF_AUTO_ON) || - ((proxy->disable_legacy =3D=3D ON_OFF_AUTO_AUTO) && pcie_port)) { - if (proxy->disable_modern) { - error_setg(errp, "device cannot work as neither modern nor " - "legacy mode is enabled"); - error_append_hint(errp, "Set either disable-modern or " - "disable-legacy to off\n"); - return; - } - proxy->mode =3D VIRTIO_PCI_MODE_MODERN; - } else { - if (proxy->disable_modern) { - proxy->mode =3D VIRTIO_PCI_MODE_LEGACY; - } else { - proxy->mode =3D VIRTIO_PCI_MODE_TRANSITIONAL; - } + if (proxy->disable_legacy =3D=3D ON_OFF_AUTO_AUTO) { + proxy->disable_legacy =3D pcie_port ? ON_OFF_AUTO_ON : ON_OFF_AUTO= _OFF; + } + + if (!virtio_pci_modern(proxy) && !virtio_pci_legacy(proxy)) { + error_setg(errp, "device cannot work as neither modern nor legacy = mode" + " is enabled"); + error_append_hint(errp, "Set either disable-modern or disable-lega= cy" + " to off\n"); + return; } =20 if (pcie_port && pci_is_express(pci_dev)) { diff --git a/hw/virtio/virtio-pci.h b/hw/virtio/virtio-pci.h index 619d9098c1..292275acb1 100644 --- a/hw/virtio/virtio-pci.h +++ b/hw/virtio/virtio-pci.h @@ -15,7 +15,6 @@ #ifndef QEMU_VIRTIO_PCI_H #define QEMU_VIRTIO_PCI_H =20 -#include "qapi/error.h" #include "hw/pci/msi.h" #include "hw/virtio/virtio-bus.h" =20 @@ -119,12 +118,6 @@ typedef struct VirtIOPCIQueue { uint32_t used[2]; } VirtIOPCIQueue; =20 -typedef enum { - VIRTIO_PCI_MODE_LEGACY, - VIRTIO_PCI_MODE_TRANSITIONAL, - VIRTIO_PCI_MODE_MODERN, -} VirtIOPCIMode; - struct VirtIOPCIProxy { PCIDevice pci_dev; MemoryRegion bar; @@ -149,7 +142,6 @@ struct VirtIOPCIProxy { bool disable_modern; bool ignore_backend_features; OnOffAuto disable_legacy; - VirtIOPCIMode mode; uint32_t class_code; uint32_t nvectors; uint32_t dfselect; @@ -164,34 +156,23 @@ struct VirtIOPCIProxy { =20 static inline bool virtio_pci_modern(VirtIOPCIProxy *proxy) { - return proxy->mode !=3D VIRTIO_PCI_MODE_LEGACY; + return !proxy->disable_modern; } =20 static inline bool virtio_pci_legacy(VirtIOPCIProxy *proxy) { - return proxy->mode !=3D VIRTIO_PCI_MODE_MODERN; + return proxy->disable_legacy =3D=3D ON_OFF_AUTO_OFF; } =20 -static inline bool virtio_pci_force_virtio_1(VirtIOPCIProxy *proxy, - Error **errp) +static inline void virtio_pci_force_virtio_1(VirtIOPCIProxy *proxy) { - if (proxy->disable_legacy =3D=3D ON_OFF_AUTO_OFF) { - error_setg(errp, "Unable to set disable-legacy=3Doff on a virtio-1= .0 " - "only device"); - return false; - } - if (proxy->disable_modern =3D=3D true) { - error_setg(errp, "Unable to set disable-modern=3Don on a virtio-1.= 0 " - "only device"); - return false; - } - proxy->mode =3D VIRTIO_PCI_MODE_MODERN; - return true; + proxy->disable_modern =3D false; + proxy->disable_legacy =3D ON_OFF_AUTO_ON; } =20 static inline void virtio_pci_disable_modern(VirtIOPCIProxy *proxy) { - proxy->mode =3D VIRTIO_PCI_MODE_LEGACY; + proxy->disable_modern =3D true; } =20 /* --=20 2.21.0