From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by mx.groups.io with SMTP id smtpd.web08.34080.1634546570720655918 for ; Mon, 18 Oct 2021 01:42:50 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.43, mailfrom: w.sheng@intel.com) X-IronPort-AV: E=McAfee;i="6200,9189,10140"; a="314397232" X-IronPort-AV: E=Sophos;i="5.85,381,1624345200"; d="scan'208";a="314397232" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Oct 2021 01:42:49 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,381,1624345200"; d="scan'208";a="629092498" Received: from shwdesssddpdwei.ccr.corp.intel.com ([10.239.157.43]) by fmsmga001.fm.intel.com with ESMTP; 18 Oct 2021 01:42:47 -0700 From: "Sheng Wei" To: devel@edk2.groups.io Cc: Robert Kowalewski , Jenny Huang , Ray Ni , Rangasai V Chaganty , Albecki Mateusz Subject: [PATCH v2] IntelSiliconPkg/IntelVTdDxe: Support Multi PCI Root Bus Date: Mon, 18 Oct 2021 16:42:44 +0800 Message-Id: <20211018084244.15316-1-w.sheng@intel.com> X-Mailer: git-send-email 2.16.2.windows.1 Some system may has multi PCI root bus. It needs to use function PciHostBridgeGetRootBridges () to get the root bus count. Then, scan each root bus to get all devices. REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3695 Signed-off-by: Robert Kowalewski Signed-off-by: Sheng Wei Cc: Jenny Huang Cc: Ray Ni Cc: Rangasai V Chaganty Cc: Robert Kowalewski Cc: Albecki Mateusz --- .../Feature/VTd/IntelVTdDxe/DmaProtection.h | 1 + .../Feature/VTd/IntelVTdDxe/DmarAcpiTable.c | 17 ++++++++++++++--- .../Feature/VTd/IntelVTdDxe/IntelVTdDxe.inf | 1 + 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Silicon/Intel/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/DmaProtection.h b/Silicon/Intel/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/DmaProtection.h index a24fbc37..97061de5 100644 --- a/Silicon/Intel/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/DmaProtection.h +++ b/Silicon/Intel/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/DmaProtection.h @@ -23,6 +23,7 @@ #include #include #include +#include #include #include diff --git a/Silicon/Intel/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/DmarAcpiTable.c b/Silicon/Intel/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/DmarAcpiTable.c index 2d9b4374..e717aeb2 100644 --- a/Silicon/Intel/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/DmarAcpiTable.c +++ b/Silicon/Intel/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/DmarAcpiTable.c @@ -682,6 +682,9 @@ ProcessDhrd ( UINT8 SecondaryBusNumber; EFI_STATUS Status; VTD_SOURCE_ID SourceId; + PCI_ROOT_BRIDGE *RootBridges; + UINTN RootBridgeCount; + UINTN Index; mVtdUnitInformation[VtdIndex].VtdUnitBaseAddress = (UINTN)DmarDrhd->RegisterBaseAddress; DEBUG ((DEBUG_INFO," VTD (%d) BaseAddress - 0x%016lx\n", VtdIndex, DmarDrhd->RegisterBaseAddress)); @@ -692,9 +695,17 @@ ProcessDhrd ( mVtdUnitInformation[VtdIndex].PciDeviceInfo.IncludeAllFlag = TRUE; DEBUG ((DEBUG_INFO," ProcessDhrd: with INCLUDE ALL\n")); - Status = ScanPciBus((VOID *)VtdIndex, DmarDrhd->SegmentNumber, 0, ScanBusCallbackRegisterPciDevice); - if (EFI_ERROR (Status)) { - return Status; + RootBridges = PciHostBridgeGetRootBridges (&RootBridgeCount); + if ((RootBridges == NULL) || (RootBridgeCount == 0)) { + return EFI_UNSUPPORTED; + } + DEBUG ((DEBUG_INFO,"Find %d root bridges\n", RootBridgeCount)); + for (Index = 0; Index < RootBridgeCount; Index++) { + DEBUG ((DEBUG_INFO,"Scan root bridges : %d, Segment : %d, Bus : 0x%02X\n", Index, RootBridges[Index].Segment, RootBridges[Index].Bus.Base)); + Status = ScanPciBus((VOID *)VtdIndex, (UINT16) RootBridges[Index].Segment, (UINT8) RootBridges[Index].Bus.Base, ScanBusCallbackRegisterPciDevice); + if (EFI_ERROR (Status)) { + return Status; + } } } else { mVtdUnitInformation[VtdIndex].PciDeviceInfo.IncludeAllFlag = FALSE; diff --git a/Silicon/Intel/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/IntelVTdDxe.inf b/Silicon/Intel/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/IntelVTdDxe.inf index 220636ad..25ff86f4 100644 --- a/Silicon/Intel/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/IntelVTdDxe.inf +++ b/Silicon/Intel/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/IntelVTdDxe.inf @@ -55,6 +55,7 @@ PerformanceLib PrintLib ReportStatusCodeLib + PciHostBridgeLib [Guids] gEfiEventExitBootServicesGuid ## CONSUMES ## Event -- 2.16.2.windows.1