From nobody Thu Sep 19 02:07:05 2024 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; dkim=fail; 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 Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 15492710637861008.3330828889464; Mon, 4 Feb 2019 01:04:23 -0800 (PST) Received: from localhost ([127.0.0.1]:38912 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gqaAr-0001pt-QH for importer@patchew.org; Mon, 04 Feb 2019 04:04:17 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38145) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gqa8O-0000OB-I4 for qemu-devel@nongnu.org; Mon, 04 Feb 2019 04:01:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gqa8L-0007B1-Us for qemu-devel@nongnu.org; Mon, 04 Feb 2019 04:01:44 -0500 Received: from ozlabs.org ([203.11.71.1]:49261) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gqa8K-00073W-Ri; Mon, 04 Feb 2019 04:01:41 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 43tMC52n17z9sML; Mon, 4 Feb 2019 20:01:37 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1549270897; bh=G34xGfy24BUfigv3pWhElc0yUdcDJOd5QYSs3yYg0YQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FvABM1+86MLI9XNFYTYE99SQDcH7BuWFhBbBB4Wb5lNBZ6ZtK/i4tzIEWsG1zvm6q P8VsGZ9r6ckIPUwCRbgOLVHNEsbp+nqcDFG9gHRvsJbi0m2Uw1Q1a1Kus1vK/EzpRE owzTY9XBh4nByGg6KjPPczIdA4s0Xwtysc64cFuc= From: David Gibson To: peter.maydell@linaro.org Date: Mon, 4 Feb 2019 20:01:01 +1100 Message-Id: <20190204090124.26191-15-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190204090124.26191-1-david@gibson.dropbear.id.au> References: <20190204090124.26191-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 203.11.71.1 Subject: [Qemu-devel] [PULL 14/37] spapr/pci: Fix primary bus number for PCI bridges 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, David Hildenbrand , Alexey Kardashevskiy , qemu-devel@nongnu.org, groug@kaod.org, spopovyc@redhat.com, qemu-ppc@nongnu.org, clg@kaod.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: David Hildenbrand While looking at the s390x implementation, looks like spapr has a similar BUG when building the topology. The primary bus number corresponds always to the bus number of the bus the bridge is attached to. Right now, if we have two bridges attached to the same bus (e.g. root bus) this is however not the case. The first bridge will have primary bus 0, the second bridge primary bus 1, which is wrong. Fix the assignment. While at it, drop setting the PCI_SUBORDINATE_BUS temporarily to 0xff. Setting it temporarily to that value (as discussed e.g. in [1]), is only relevant for a running system that probes the buses. The value is effectively unused for us just doing a DFS. [1] http://www.science.unitn.it/~fiorella/guidelinux/tlk/node76.html Signed-off-by: David Hildenbrand Reviewed-by: Alexey Kardashevskiy Signed-off-by: David Gibson --- hw/ppc/spapr_pci.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index b74f2632ec..5cdc98513d 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -2030,8 +2030,6 @@ static void spapr_phb_pci_enumerate_bridge(PCIBus *bu= s, PCIDevice *pdev, void *opaque) { unsigned int *bus_no =3D opaque; - unsigned int primary =3D *bus_no; - unsigned int subordinate =3D 0xff; PCIBus *sec_bus =3D NULL; =20 if ((pci_default_read_config(pdev, PCI_HEADER_TYPE, 1) !=3D @@ -2040,7 +2038,7 @@ static void spapr_phb_pci_enumerate_bridge(PCIBus *bu= s, PCIDevice *pdev, } =20 (*bus_no)++; - pci_default_write_config(pdev, PCI_PRIMARY_BUS, primary, 1); + pci_default_write_config(pdev, PCI_PRIMARY_BUS, pci_dev_bus_num(pdev),= 1); pci_default_write_config(pdev, PCI_SECONDARY_BUS, *bus_no, 1); pci_default_write_config(pdev, PCI_SUBORDINATE_BUS, *bus_no, 1); =20 @@ -2049,7 +2047,6 @@ static void spapr_phb_pci_enumerate_bridge(PCIBus *bu= s, PCIDevice *pdev, return; } =20 - pci_default_write_config(pdev, PCI_SUBORDINATE_BUS, subordinate, 1); pci_for_each_device(sec_bus, pci_bus_num(sec_bus), spapr_phb_pci_enumerate_bridge, bus_no); pci_default_write_config(pdev, PCI_SUBORDINATE_BUS, *bus_no, 1); --=20 2.20.1