From nobody Mon Apr 29 00:40:05 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1486534638601924.4747906749741; Tue, 7 Feb 2017 22:17:18 -0800 (PST) Received: from localhost ([::1]:57900 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cbLZ6-0000zU-G1 for importer@patchew.org; Wed, 08 Feb 2017 01:17:16 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57259) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cbLY6-0000cM-8t for qemu-devel@nongnu.org; Wed, 08 Feb 2017 01:16:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cbLY5-0006cg-1J for qemu-devel@nongnu.org; Wed, 08 Feb 2017 01:16:14 -0500 Received: from ozlabs.org ([2401:3900:2:1::2]:49315) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cbLY4-0006bT-It; Wed, 08 Feb 2017 01:16:12 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 3vJ9v96m6kz9s7n; Wed, 8 Feb 2017 17:16:05 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1486534565; bh=TPLNz4JWFSQkrgNleIuONMeuIq7uDD6frroOrn3DqP4=; h=From:To:Cc:Subject:Date:From; b=MfAwQO/Eo/Mz4dIiVcwr9Mcc/TqT1uGcK/oyY3c6TDoBAcJ3tS0kPzxe+AqTHEux6 QD70HeT9UdVPv6B64eLyYs4ehb5OagtqrhKSqdGbT6rGa10TOHdAFrCovqk8Oodk7r CUZPOsKPkJOtAizWqlRIlum9fhitV0AzLezvtm3o= From: David Gibson To: marcel@redhat.com, abologna@redhat.com Date: Wed, 8 Feb 2017 17:16:02 +1100 Message-Id: <20170208061602.17666-1-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.9.3 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 Subject: [Qemu-devel] [RFC] virtio-pci: Allow PCIe virtio devices on root bus 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: lvivier@redhat.com, thuth@redhat.com, mst@redhat.com, qemu-devel@nongnu.org, qemu-ppc@nongnu.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Marcel, Your original patch adding PCIe support to virtio-pci.c has the limitation noted below that PCIe won't be enabled if the device is on the root bus (rather than under a root or downstream port). As reasoned below, I think removing the check is correct, even for x86 (though it would rarely be useful there). But I could well have missed something. Let me know if so... Virtio devices can appear as either vanilla PCI or PCI-Express devices depending on the bus they're connected to. At the moment it will only appear as vanilla PCI if connected to the root bus of a PCIe host bridge. Presumably this is to reflect the fact that PCIe devices usually need to be connected to a root (or further downstream) port rather than directly on the root bus. However, due to the odd requirements of the PAPR spec on = the 'pseries' machine type, it's normal for PCIe devices to appear on the root bus without root ports. Further, even on x86, there's no inherent reason we couldn't present a virtio device as an "integrated device" (typically used for things built into the PCI chipset), and those devices *do* typically appear on the root bus. pcie_endpoint_cap_init() already automatically adjusts to advertise as an integrated device rather than a "normal" PCIe endpoint when attached to a root bus. So we can remove the check for root bus within virtio and allow (at the user's discretion) a PCIe virtio bus to be attached to a root bus. Signed-off-by: David Gibson --- hw/virtio/virtio-pci.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index 5ce42af..caea44c 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -1737,8 +1737,7 @@ static void virtio_pci_realize(PCIDevice *pci_dev, Er= ror **errp) { VirtIOPCIProxy *proxy =3D VIRTIO_PCI(pci_dev); VirtioPCIClass *k =3D VIRTIO_PCI_GET_CLASS(pci_dev); - bool pcie_port =3D pci_bus_is_express(pci_dev->bus) && - !pci_bus_is_root(pci_dev->bus); + bool pcie_port =3D pci_bus_is_express(pci_dev->bus); =20 if (!kvm_has_many_ioeventfds()) { proxy->flags &=3D ~VIRTIO_PCI_FLAG_USE_IOEVENTFD; --=20 2.9.3