From nobody Sun May 5 17:17:34 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+82451+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+82451+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1634818301; cv=none; d=zohomail.com; s=zohoarc; b=gsBzLrTwvM9O/xR7msOWM3Pmx1tfDWq6MbjlabFSDSRULk+KeT+m3t3qsCO9cfNMn62RuPt5XV8zekgw1wO1KirNbLNWUDbmip8ZY+6yxILMVGgRN2oayHqmTMJuo9jdE7Q8tPoI13yo2Pwa2vmskZN/rWeP4U53bF1XpC7a/Xo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1634818301; h=Cc:Date:From:List-Subscribe:List-Id:List-Help:List-Unsubscribe:Message-ID:Reply-To:Sender:Subject:To; bh=EtR+RUnlX+zCdjAmO80jK2kLJb75cFoDbBgq66sEgWM=; b=mVbzENSXJ57rkmDENhjPQaTr+wSxBam2bRcB091q8bhAllK+TnTbhck1g5fkpDHkpoQwnB8LR7p9vy2A68nGIGvyeClnWr7J02pg/S8xubAyFrUh4RiJ1m9lVJwYfKWOQ7UNNq7oM23Z6AJNyKqIGHWGWNz6yT7TmOUBZchAiJI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+82451+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1634818301197427.09318631640315; Thu, 21 Oct 2021 05:11:41 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id OC8eYY1788612x4AYWMzcc1w; Thu, 21 Oct 2021 05:11:40 -0700 X-Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by mx.groups.io with SMTP id smtpd.web12.8357.1634818299883453680 for ; Thu, 21 Oct 2021 05:11:39 -0700 X-IronPort-AV: E=McAfee;i="6200,9189,10143"; a="226475910" X-IronPort-AV: E=Sophos;i="5.87,169,1631602800"; d="scan'208";a="226475910" X-Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Oct 2021 05:11:37 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,169,1631602800"; d="scan'208";a="495123953" X-Received: from shwdesssddpdwei.ccr.corp.intel.com ([10.239.157.43]) by orsmga008.jf.intel.com with ESMTP; 21 Oct 2021 05:11:34 -0700 From: "Sheng Wei" To: devel@edk2.groups.io Cc: Robert Kowalewski , Jenny Huang , Ray Ni , Rangasai V Chaganty , Albecki Mateusz , Kolakowski Jacek Subject: [edk2-devel] [PATCH v3] IntelSiliconPkg/IntelVTdDxe: Support Multi PCI Root Bus Date: Thu, 21 Oct 2021 20:11:29 +0800 Message-Id: <20211021121129.16184-1-w.sheng@intel.com> Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,w.sheng@intel.com X-Gm-Message-State: mSLdXYwWGjr1IE2A7XAzQRmyx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1634818300; bh=HTP3qWOY9f5fA7/lvN2DsZox/AoGClSV3rH6KKkQq8U=; h=Cc:Date:From:Reply-To:Subject:To; b=AewRZXEa4jzHkWzxQi2PWL7AygWlo0D+l+GXeSN5u1GrxfNvD7FU+7KIHlCnqSeHC8X GxWDk1fhG+vANrMAeuwnhkdPMPcouLUNHxzI4PQF7oWSzOQRd+GP2RjnUbHc0RnIvlV3k kGQUsqYHAlbig3vwRM+0vxczvJGmJtxTKc0= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1634818302425100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Some system may has multi PCI root bus. It needs to use PciRootBridgeIo protocol to get the root bus count. Scan each root bus to get all devices. REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3695 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 Cc: Kolakowski Jacek Reviewed-by: Jenny Huang --- .../Feature/VTd/IntelVTdDxe/DmaProtection.h | 17 +++++ .../Feature/VTd/IntelVTdDxe/DmarAcpiTable.c | 2 +- .../Feature/VTd/IntelVTdDxe/IntelVTdDxe.inf | 1 + .../Feature/VTd/IntelVTdDxe/PciInfo.c | 72 ++++++++++++++++++= ++++ 4 files changed, 91 insertions(+), 1 deletion(-) diff --git a/Silicon/Intel/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/DmaProte= ction.h b/Silicon/Intel/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/DmaProtecti= on.h index a24fbc37..7dd29a24 100644 --- a/Silicon/Intel/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/DmaProtection.h +++ b/Silicon/Intel/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/DmaProtection.h @@ -33,6 +33,7 @@ #include #include #include +#include =20 #include #include @@ -341,6 +342,22 @@ ScanPciBus ( IN SCAN_BUS_FUNC_CALLBACK_FUNC Callback ); =20 +/** + Scan PCI bus and invoke callback function for each PCI devices under all= root bus. + + @param[in] Context The context of the callback function. + @param[in] Segment The segment of the source. + @param[in] Callback The callback function in PCI scan. + + @retval EFI_SUCCESS The PCI devices under the bus are scaned. +**/ +EFI_STATUS +ScanAllPciBus ( + IN VOID *Context, + IN UINT16 Segment, + IN SCAN_BUS_FUNC_CALLBACK_FUNC Callback + ); + /** Dump the PCI device information managed by this VTd engine. =20 diff --git a/Silicon/Intel/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/DmarAcpi= Table.c b/Silicon/Intel/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/DmarAcpiTab= le.c index 2d9b4374..1ee290b7 100644 --- a/Silicon/Intel/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/DmarAcpiTable.c +++ b/Silicon/Intel/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/DmarAcpiTable.c @@ -692,7 +692,7 @@ ProcessDhrd ( mVtdUnitInformation[VtdIndex].PciDeviceInfo.IncludeAllFlag =3D TRUE; DEBUG ((DEBUG_INFO," ProcessDhrd: with INCLUDE ALL\n")); =20 - Status =3D ScanPciBus((VOID *)VtdIndex, DmarDrhd->SegmentNumber, 0, Sc= anBusCallbackRegisterPciDevice); + Status =3D ScanAllPciBus((VOID *)VtdIndex, DmarDrhd->SegmentNumber, Sc= anBusCallbackRegisterPciDevice); if (EFI_ERROR (Status)) { return Status; } diff --git a/Silicon/Intel/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/IntelVTd= Dxe.inf b/Silicon/Intel/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/IntelVTdDxe= .inf index 220636ad..387f90e3 100644 --- a/Silicon/Intel/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/IntelVTdDxe.inf +++ b/Silicon/Intel/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/IntelVTdDxe.inf @@ -70,6 +70,7 @@ gEfiPciIoProtocolGuid ## CONSUMES gEfiPciEnumerationCompleteProtocolGuid ## CONSUMES gEdkiiPlatformVTdPolicyProtocolGuid ## SOMETIMES_CONSUMES + gEfiPciRootBridgeIoProtocolGuid ## CONSUMES =20 [Pcd] gIntelSiliconPkgTokenSpaceGuid.PcdVTdPolicyPropertyMask ## CONSUMES diff --git a/Silicon/Intel/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/PciInfo.= c b/Silicon/Intel/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/PciInfo.c index 4af376b3..cffb9f61 100644 --- a/Silicon/Intel/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/PciInfo.c +++ b/Silicon/Intel/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/PciInfo.c @@ -279,6 +279,78 @@ ScanPciBus ( return EFI_SUCCESS; } =20 +/** + Scan PCI bus and invoke callback function for each PCI devices under all= root bus. + + @param[in] Context The context of the callback function. + @param[in] Segment The segment of the source. + @param[in] Callback The callback function in PCI scan. + + @retval EFI_SUCCESS The PCI devices under the bus are scaned. +**/ +EFI_STATUS +ScanAllPciBus ( + IN VOID *Context, + IN UINT16 Segment, + IN SCAN_BUS_FUNC_CALLBACK_FUNC Callback + ) +{ + EFI_STATUS Status; + UINTN Index; + UINTN HandleCount; + EFI_HANDLE *HandleBuffer; + EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *PciRootBridgeIo; + EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *Descriptors; + + DEBUG ((DEBUG_INFO, "ScanAllPciBus ()\n")); + + Status =3D gBS->LocateHandleBuffer ( + ByProtocol, + &gEfiPciRootBridgeIoProtocolGuid, + NULL, + &HandleCount, + &HandleBuffer + ); + if (EFI_ERROR (Status)) { + // + // If PciRootBridgeIo protocol is not support, scan PCI device from ro= ot bus 0x00. + // + Status =3D ScanPciBus(Context, Segment, 0x00, Callback); + return Status; + } + + DEBUG ((DEBUG_INFO,"Find %d root bridges\n", HandleCount)); + + for (Index =3D 0; Index < HandleCount; Index++) { + Status =3D gBS->HandleProtocol ( + HandleBuffer[Index], + &gEfiPciRootBridgeIoProtocolGuid, + (VOID **) &PciRootBridgeIo + ); + ASSERT_EFI_ERROR (Status); + + Status =3D PciRootBridgeIo->Configuration (PciRootBridgeIo, (VOID **) = &Descriptors); + ASSERT_EFI_ERROR (Status); + + while (Descriptors->Desc !=3D ACPI_END_TAG_DESCRIPTOR) { + if (Descriptors->ResType =3D=3D ACPI_ADDRESS_SPACE_TYPE_BUS) { + break; + } + Descriptors++; + } + + DEBUG ((DEBUG_INFO,"Scan root bridges : %d, Segment : %d, Bus : 0x%02X= \n", Index, PciRootBridgeIo->SegmentNumber, Descriptors->AddrRangeMin)); + Status =3D ScanPciBus(Context, (UINT16) PciRootBridgeIo->SegmentNumber= , (UINT8) Descriptors->AddrRangeMin, Callback); + if (EFI_ERROR (Status)) { + break; + } + } + + FreePool(HandleBuffer); + + return Status; +} + /** Dump the PCI device information managed by this VTd engine. =20 --=20 2.16.2.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#82451): https://edk2.groups.io/g/devel/message/82451 Mute This Topic: https://groups.io/mt/86487827/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-