From nobody Fri May 3 08:05:55 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+82798+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+82798+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1635405229; cv=none; d=zohomail.com; s=zohoarc; b=NTI6aTIKq85pX21r8b/VvfRodwv0YzhiXtBp0EqYrire1ys32LH6G+9ZZWWbGhi7P6gfpLRgNI00UDJzYcZY8xTvuJ1kUjZGbfVA7CZq9Y2qgmp7RBINpDlXk2MPbhV9ZY4M4i09irWODYQAwsQ2oE6dj/R6GrWm++IbhnciGVA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635405229; h=Cc:Date:From:List-Subscribe:List-Id:List-Help:List-Unsubscribe:Message-ID:Reply-To:Sender:Subject:To; bh=UrHqoQ/SxTrD5aW8esnc2i63b8ORIQKczU3rQ3sd6fg=; b=CoMUzHx2p2wpCzo6vFRQg5hYYS+vFNTGMwoAsT0w3nZZ6M6zenrJhrmrRah7ADDq5PKGIPOKnDdxsyRwG/WaJXUCL+/+1+Yg2lNAnZk1Emo3sBan0HdgsAQQUbxxlPO/zPTnTfki/A82vSctD0wkiFiNzxms3bovvWgEu6L5blI= 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+82798+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 1635405229980677.810046228575; Thu, 28 Oct 2021 00:13:49 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id RkplYY1788612xMQEjrVBzeS; Thu, 28 Oct 2021 00:13:49 -0700 X-Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mx.groups.io with SMTP id smtpd.web11.8438.1635405228268341738 for ; Thu, 28 Oct 2021 00:13:48 -0700 X-IronPort-AV: E=McAfee;i="6200,9189,10150"; a="230288881" X-IronPort-AV: E=Sophos;i="5.87,189,1631602800"; d="scan'208";a="230288881" X-Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Oct 2021 00:13:46 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,189,1631602800"; d="scan'208";a="665299474" X-Received: from shwdesssddpdwei.ccr.corp.intel.com ([10.239.157.43]) by orsmga005.jf.intel.com with ESMTP; 28 Oct 2021 00:13:44 -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 v5] IntelSiliconPkg/IntelVTdDxe: Support Multi PCI Root Bus Date: Thu, 28 Oct 2021 15:13:41 +0800 Message-Id: <20211028071341.1052-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: xiTUw7KxyvCns0B89S5moGk5x1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1635405229; bh=jP0pq6qyJTNJRPFKIegDZHM3eo1ZXim3LSWZl4bYLno=; h=Cc:Date:From:Reply-To:Subject:To; b=H6UtNH4Q3WHLtk6F9UGpIWYDxD6jInvN+Uq+bZmwdg5aPrLlSafi0EMA1W2d6J8Amfl 3I2Jx552g0pLdUcXbE/Om0nclIYI/Dm+5RXzBb4Ko2r6AHorea2/24WL8txNfeNPpUTfK ELQxsWxnrUZByhaJW6hniIIym9QEOaWvtzk= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1635405231875100002 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Some system may has multi PCI root bridges. It needs to use PciRootBridgeIo protocol to get the root bridge count. Scan each root bridge to get all PCI 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 Signed-off-by: Sheng Wei --- .../Feature/VTd/IntelVTdDxe/DmaProtection.h | 17 +++++ .../Feature/VTd/IntelVTdDxe/DmarAcpiTable.c | 2 +- .../Feature/VTd/IntelVTdDxe/IntelVTdDxe.inf | 1 + .../Feature/VTd/IntelVTdDxe/PciInfo.c | 73 ++++++++++++++++++= ++++ 4 files changed, 92 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..c4d7f17a 100644 --- a/Silicon/Intel/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/PciInfo.c +++ b/Silicon/Intel/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/PciInfo.c @@ -279,6 +279,79 @@ 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)) { + DEBUG ((DEBUG_ERROR, "Locate PciRootBridgeIo Protocol %r: ", Status)); + 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++; + } + + if (Descriptors->Desc =3D=3D ACPI_END_TAG_DESCRIPTOR) { + continue; + } + + 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 (#82798): https://edk2.groups.io/g/devel/message/82798 Mute This Topic: https://groups.io/mt/86647223/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-