From nobody Fri Nov 7 11:18:15 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1548231929015584.3983443345352; Wed, 23 Jan 2019 00:25:29 -0800 (PST) Received: from localhost ([127.0.0.1]:58086 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gmDqh-0003uZ-T8 for importer@patchew.org; Wed, 23 Jan 2019 03:25:27 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54934) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gmDpp-0003T3-Jj for qemu-devel@nongnu.org; Wed, 23 Jan 2019 03:24:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gmDpn-0006SM-F4 for qemu-devel@nongnu.org; Wed, 23 Jan 2019 03:24:33 -0500 Received: from mx1.redhat.com ([209.132.183.28]:51400) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gmDpn-0006Rn-9K; Wed, 23 Jan 2019 03:24:31 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 834DD9E62D; Wed, 23 Jan 2019 08:24:29 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-3.ams2.redhat.com [10.36.117.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0B4685D6A9; Wed, 23 Jan 2019 08:24:25 +0000 (UTC) From: David Hildenbrand To: qemu-devel@nongnu.org Date: Wed, 23 Jan 2019 09:24:25 +0100 Message-Id: <20190123082425.10643-1-david@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 23 Jan 2019 08:24:30 +0000 (UTC) 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] [PATCH v1] 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: David Hildenbrand , qemu-ppc@nongnu.org, Nikunj A Dadhania , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 Note: Is hotplug of bridges supported? I can't find where the topology is fixed up when hotplugging a PCI bridge. (e.g. bus numbers assigned and PCI_SUBORDINATE_BUS of path to the root updated). But maybe we are excluding bridges or this is not necessary for some reason. Signed-off-by: David Hildenbrand Reviewed-by: Alexey Kardashevskiy --- 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.17.2