From nobody Sat May 4 17:28:52 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail(p=none dis=none) header.from=intel.com Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 152704617067895.95905078964995; Tue, 22 May 2018 20:29:30 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 83146207E36C1; Tue, 22 May 2018 20:29:29 -0700 (PDT) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 9525B20348605 for ; Tue, 22 May 2018 20:29:27 -0700 (PDT) Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 May 2018 20:29:27 -0700 Received: from ray-dev.ccr.corp.intel.com ([10.239.9.4]) by orsmga008.jf.intel.com with ESMTP; 22 May 2018 20:29:24 -0700 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.115; helo=mga14.intel.com; envelope-from=ruiyu.ni@intel.com; receiver=edk2-devel@lists.01.org X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,431,1520924400"; d="scan'208";a="43471543" From: Ruiyu Ni To: edk2-devel@lists.01.org Date: Wed, 23 May 2018 11:29:31 +0800 Message-Id: <20180523032931.183708-1-ruiyu.ni@intel.com> X-Mailer: git-send-email 2.16.1.windows.1 Subject: [edk2] [PATCH] MdeModulePkg/PciBus: Use actual max bus # for subordinary bus # X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Star Zeng MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Current code assumes the max bus(0xFF) is under this P2P bridge and temporarily set it as subordinate bus. It may cause silicon hangs during PCI enumeration in some specific case. Instead, it should get the max bus number from the bus number resources returned from PCI_HOST_BRIDGE_RESOURCE_ALLOCATION.StartBusEnumeration() and set it as subordinate bus. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ruiyu Ni Cc: Star Zeng --- MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c | 39 +++++++++++++++++++++++++++++= +++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c b/MdeModulePkg/Bus/Pci= /PciBusDxe/PciLib.c index 976496379a..729e86b55e 100644 --- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c +++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c @@ -29,6 +29,43 @@ CHAR16 *mBarTypeStr[] =3D { L"Unknow" }; =20 +/** + Retrieve the max bus number that is assigned to the Root Bridge hierarch= y. + It can support the case that there are multiple bus ranges. + + @param Bridge Bridge device instance. + + @retval The max bus number that is assigned to this Roo= t Bridge hierarchy. + +**/ +UINT16 +PciGetMaxBusNumber ( + IN PCI_IO_DEVICE *Bridge + ) +{ + PCI_IO_DEVICE *RootBridge; + EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *BusNumberRanges; + UINT64 MaxNumberInRange; + + // + // Get PCI Root Bridge device + // + RootBridge =3D Bridge; + while (RootBridge->Parent !=3D NULL) { + RootBridge =3D RootBridge->Parent; + } + MaxNumberInRange =3D 0; + // + // Get next available PCI bus number + // + BusNumberRanges =3D RootBridge->BusNumberRanges; + while (BusNumberRanges->Desc !=3D ACPI_END_TAG_DESCRIPTOR) { + MaxNumberInRange =3D BusNumberRanges->AddrRangeMin + BusNumberRanges->= AddrLen - 1; + BusNumberRanges++; + } + return (UINT16) MaxNumberInRange; +} + /** Retrieve the PCI Card device BAR information via PciIo interface. =20 @@ -1193,7 +1230,7 @@ PciScanBus ( // Temporarily initialize SubBusNumber to maximum bus number to = ensure the // PCI configuration transaction to go through any PPB // - Register =3D 0xFF; + Register =3D PciGetMaxBusNumber (Bridge); Address =3D EFI_PCI_ADDRESS (StartBusNumber, Device, Func, PCI= _BRIDGE_SUBORDINATE_BUS_REGISTER_OFFSET); Status =3D PciRootBridgeIo->Pci.Write ( PciRootBridgeIo, --=20 2.16.1.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel