From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail05.groups.io (mail05.groups.io [45.79.224.7]) by spool.mail.gandi.net (Postfix) with ESMTPS id 904DEAC1AE7 for ; Wed, 23 Oct 2024 17:00:11 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=ai+J6RGuodFUblg4JWYsYE1Ke69NDraZW2fDO/wF1F0=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Resent-Date:Resent-From:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20240830; t=1729702811; v=1; x=1729962010; b=llES9VtIX7gIoL+jZ5tCvwyT/MwvN/2ojnmpHmsKbjZkzFmsrdXOBLiKDIFdMvDEFACqeGrW iaMzpdH1IUJfkbTALwGMJigjJrTgn0wka7g0VCXiTzCa8l2BlS8SnNGqPeNMsM1P/+jgMY3n1MJ Re2zSEaZmab6TQhKiegK5AvkVgqkWtHdsQBXCCBXtcDTmP0LkRsQ6zVh9zQfIW425MzzhMayytf urmKrGDbDWPprIutpYJWfeVzJSgtywLZca/J+z2cpv+NoUUjcmR5kIwsnNVwh7rNrcEmZ06Fjzz 97MVqd/JbswqXuQ7pFi15iPXKga8kmtN0v3mKRg5cWY3g== X-Received: by 127.0.0.2 with SMTP id UBbLYY7687511xO9XUxquzxf; Wed, 23 Oct 2024 10:00:10 -0700 X-Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.20]) by mx.groups.io with SMTP id smtpd.web10.16868.1729060153561682878 for ; Tue, 15 Oct 2024 23:29:14 -0700 X-CSE-ConnectionGUID: lnOI5dNnQcCi7X4bME8EDw== X-CSE-MsgGUID: vV+xaerATJGyC+AqeV0uiw== X-IronPort-AV: E=McAfee;i="6700,10204,11222"; a="28278913" X-IronPort-AV: E=Sophos;i="6.11,199,1725346800"; d="scan'208";a="28278913" X-Received: from fmviesa001.fm.intel.com ([10.60.135.141]) by orvoesa112.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Oct 2024 23:29:14 -0700 X-CSE-ConnectionGUID: q94TDYSISzChYoPRzNGd3A== X-CSE-MsgGUID: /QMvI1gXSRyYW6ZesliIsA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,207,1725346800"; d="scan'208";a="108869963" X-Received: from shwdeopenlab108.ccr.corp.intel.com ([10.239.55.64]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Oct 2024 23:29:13 -0700 From: Foster Nong To: devel@edk2.groups.io Cc: Foster Nong , Michael D Kinney , Liming Gao , Ray Ni Subject: [edk2-devel] [PATCH V1 2/2] MdeModulePkg:New Pcd to platform constrain BarSize Date: Wed, 16 Oct 2024 14:28:42 +0800 Message-Id: <20241016062842.2128-2-foster.nong@intel.com> In-Reply-To: <20241016062842.2128-1-foster.nong@intel.com> References: <20241016062842.2128-1-foster.nong@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Resent-Date: Wed, 23 Oct 2024 10:00:06 -0700 Resent-From: foster.nong@intel.com Reply-To: devel@edk2.groups.io,foster.nong@intel.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: v7TpLpK435T6cfG1rlBnq4eKx7686176AA= Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20240830 header.b=llES9VtI; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=intel.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 45.79.224.7 as permitted sender) smtp.mailfrom=bounce@groups.io REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4868 1. Define a new dynamic PCD in MdeModulePkg gEfiMdeModulePkgTokenSpaceGuid.PcdPcieResizableMaxBarSize 2. Modify PciProgramResizableBar() to implement configure BAR Size within platform constrain provided in PcdPcieResizableMaxBarSize Signed-off-by: Foster Nong Cc: Michael D Kinney Cc: Liming Gao Cc: Ray Ni --- MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf | 1 + MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c | 19 ++++++++++++++++--- MdeModulePkg/MdeModulePkg.dec | 5 +++++ 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf b/MdeModulePkg/Bu= s/Pci/PciBusDxe/PciBusDxe.inf index e317169d9c..f038b6eef2 100644 --- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf +++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf @@ -107,6 +107,7 @@ gEfiMdeModulePkgTokenSpaceGuid.PcdMrIovSupport ## CONSUME= S=0D gEfiMdeModulePkgTokenSpaceGuid.PcdPciDisableBusEnumeration ## SOMETIM= ES_CONSUMES=0D gEfiMdeModulePkgTokenSpaceGuid.PcdPcieResizableBarSupport ## CONSUME= S=0D + gEfiMdeModulePkgTokenSpaceGuid.PcdPcieResizableMaxBarSize ## CONSUME= S=0D =0D [UserExtensions.TianoCore."ExtraFiles"]=0D PciBusDxeExtra.uni=0D diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c b/MdeModulePkg/Bus/Pci= /PciBusDxe/PciLib.c index f15dd6468d..d9729a0f42 100644 --- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c +++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c @@ -1797,6 +1797,7 @@ PciProgramResizableBar ( {=0D EFI_PCI_IO_PROTOCOL *PciIo;=0D UINT64 Capabilities;=0D + UINT64 CapabilitiesMask;= =0D UINT32 Index;=0D UINT32 Offset;=0D INTN Bit;=0D @@ -1804,12 +1805,17 @@ PciProgramResizableBar ( PCI_EXPRESS_EXTENDED_CAPABILITIES_RESIZABLE_BAR_ENTRY Entries[PCI_MAX_B= AR];=0D =0D ASSERT (PciIoDevice->ResizableBarOffset !=3D 0);=0D -=0D + //=0D + // PCIE SPEC v6.0 section 7.8.6.3 Resizable BAR Control Register=0D + // Bits[13:8] BAR Size define 43(8 EB) as maximum=0D + //=0D + CapabilitiesMask =3D LShiftU64 (1, MIN (PcdGet8 (PcdPcieResizableMaxBarS= ize), 43) + 1) - 1;=0D DEBUG ((=0D DEBUG_INFO,=0D - " Programs Resizable BAR register, offset: 0x%08x, number: %d\n",=0D + " Programs Resizable BAR register, offset: 0x%08x, number: %d, PcdPc= ieResizableMaxBarSize: %d\n",=0D PciIoDevice->ResizableBarOffset,=0D - PciIoDevice->ResizableBarNumber=0D + PciIoDevice->ResizableBarNumber,=0D + PcdGet8 (PcdPcieResizableMaxBarSize)=0D ));=0D if (PciIoDevice->ResizableBarNumber > PCI_MAX_BAR || PciIoDevice->Resiza= bleBarNumber =3D=3D 0) {=0D DEBUG ((DEBUG_ERROR, "ERROR: Resizable BAR register ResizableBarNumber= =3D0x%X is illegal\n", PciIoDevice->ResizableBarNumber));=0D @@ -1851,10 +1857,17 @@ PciProgramResizableBar ( // Bit 0 is set: supports operating with the BAR sized to 1 MB=0D // Bit 1 is set: supports operating with the BAR sized to 2 MB=0D // Bit n is set: supports operating with the BAR sized to (2^n) MB=0D + // Platform may impose limitation on the BAR size it supports using Pc= dPcieResizableMaxBarSize.=0D //=0D Capabilities =3D LShiftU64 (Entries[Index].ResizableBarControl.Bits.Ba= rSizeCapability, 28)=0D | Entries[Index].ResizableBarCapability.Bits.BarSizeCap= ability;=0D + Capabilities &=3D CapabilitiesMask;=0D =0D + if (Capabilities =3D=3D 0) {=0D + DEBUG ((DEBUG_ERROR, " WARNING: Resizable BAR Entry[%d] skip, Capabi= lities=3D0x%llx CapabilitiesMask=3D0x%llx\n",=0D + Index, Entries[Index].ResizableBarCapability.Bi= ts.BarSizeCapability, CapabilitiesMask));=0D + continue;=0D + }=0D if (ResizableBarOp =3D=3D PciResizableBarMax) {=0D Bit =3D HighBitSet64 (Capabilities);=0D } else {=0D diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec index 1324b6d100..59fa506bd8 100644 --- a/MdeModulePkg/MdeModulePkg.dec +++ b/MdeModulePkg/MdeModulePkg.dec @@ -2264,6 +2264,11 @@ # @Prompt The value is use for Usb Network rate limiting supported.=0D gEfiMdeModulePkgTokenSpaceGuid.PcdUsbNetworkRateLimitingFactor|100|UINT3= 2|0x10000028=0D =0D + # This PCD set maximum size of all PCIE Resizable BARs=0D + # The max size equals to (2^PcdPcieResizableMaxBarSize) MB=0D + # @Prompt Maximum size of PCIE Resizable BARs=0D + gEfiMdeModulePkgTokenSpaceGuid.PcdPcieResizableMaxBarSize|0x2B|UINT8|0x0= 0030009=0D +=0D [PcdsPatchableInModule]=0D ## Specify memory size with page number for PEI code when=0D # Loading Module at Fixed Address feature is enabled.=0D --=20 2.37.1.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#120665): https://edk2.groups.io/g/devel/message/120665 Mute This Topic: https://groups.io/mt/109174500/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-