From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mx.groups.io with SMTP id smtpd.web10.10730.1581106877963024359 for ; Fri, 07 Feb 2020 12:21:18 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.136, mailfrom: ashraf.javeed@intel.com) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Feb 2020 12:21:17 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,414,1574150400"; d="scan'208";a="379502062" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by orsmga004.jf.intel.com with ESMTP; 07 Feb 2020 12:21:17 -0800 Received: from BGSMSX108.gar.corp.intel.com (10.223.4.192) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.439.0; Fri, 7 Feb 2020 12:21:16 -0800 Received: from bgsmsx101.gar.corp.intel.com ([169.254.1.155]) by BGSMSX108.gar.corp.intel.com ([169.254.8.91]) with mapi id 14.03.0439.000; Sat, 8 Feb 2020 01:50:52 +0530 From: "Javeed, Ashraf" To: "devel@edk2.groups.io" , "Javeed, Ashraf" CC: "Wang, Jian J" , "Wu, Hao A" , "Ni, Ray" Subject: Re: [edk2-devel] [edk2-staging/UEFI_PCI_ENHANCE-2 PATCH 04/12] PciBusDxe: New PCI Express feature Max_Read_Req_Size Thread-Topic: [edk2-devel] [edk2-staging/UEFI_PCI_ENHANCE-2 PATCH 04/12] PciBusDxe: New PCI Express feature Max_Read_Req_Size Thread-Index: AQHV3fIWgBbQuDTIukuxAnYW5ev0LagQLCmQ Date: Fri, 7 Feb 2020 20:20:51 +0000 Message-ID: <95C5C2B113DE604FB208120C742E9824579AAFAB@BGSMSX101.gar.corp.intel.com> References: <20200207200447.10536-1-ashraf.javeed@intel.com> <15F13782B6D7AE2E.15938@groups.io> In-Reply-To: <15F13782B6D7AE2E.15938@groups.io> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiZTEzNTRjODgtY2JmNC00ZWIzLWFlZTAtMDIwNmUzYzU0MmRmIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiS3ZiMWZQZVpRV1wvWnE2blhoNWtvMnE5Zk8wRUhTK0FaZTFVb3hOWm5udng5S3JjVmpFSzBWeWpkQjFNNnhvVTEifQ== x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.2.0.6 dlp-reaction: no-action x-originating-ip: [10.223.10.10] MIME-Version: 1.0 Return-Path: ashraf.javeed@intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable This patch can also be viewed in the following repo:- https://github.com/ashrafj/edk2-staging/commit/91e85bdb96600e72d5d7ab4d170= 089abcf1fe4fb Thanks Ashraf > -----Original Message----- > From: devel@edk2.groups.io On Behalf Of Javeed, > Ashraf > Sent: Saturday, February 8, 2020 1:35 AM > To: devel@edk2.groups.io > Cc: Wang, Jian J ; Wu, Hao A = ; > Ni, Ray > Subject: [edk2-devel] [edk2-staging/UEFI_PCI_ENHANCE-2 PATCH 04/12] > PciBusDxe: New PCI Express feature Max_Read_Req_Size >=20 > BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2194 >=20 > The code changes are made to enable the configuration of PCI Express fea= ture > Max_Read_Req_Size (MRRS), which defines the memory read request size for > the PCI transactions, as per the PCI Base Specification 4 Revision 1. >=20 > The code changes are made to configure a common value that is applicable= to > all the child nodes originating from the root bridge device instance, ba= sed on > following 3 criteria:- > (1) if platform defines MRRS device policy for any one PCI device in the > tree than align all the devices in the PCI tree to that same value > (2) if platform does not provide device policy for any of the devices in > the PCI tree than setup the MRRS value equivalent to MPS value for > all PCI devices to meet the criteria for the isochronous traffic > (3) if platform does not provide device policy for any of the devices an= d > it has not selected the MPS to be configured either; than the config= - > uration of the MRRS is performed based on highest common value of th= e > MPS advertized in the PCI device capability registers of the devices >=20 > This programming of MRRS gets the device-specific platform policy using = the > new PCI Express Platform Protocol interface, defined in the below featur= e > request:- https://bugzilla.tianocore.org/show_bug.cgi?id=3D1954 >=20 > Signed-off-by: Ashraf Javeed > Cc: Jian J Wang > Cc: Hao A Wu > Cc: Ray Ni > --- > MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.h | 1 + > MdeModulePkg/Bus/Pci/PciBusDxe/PciExpressFeatures.c | 190 > +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > MdeModulePkg/Bus/Pci/PciBusDxe/PciExpressFeatures.h | 45 > +++++++++++++++++++++++++++++++++++++++++++++ > MdeModulePkg/Bus/Pci/PciBusDxe/PciFeatureSupport.c | 20 > +++++++++++++++++++- > MdeModulePkg/Bus/Pci/PciBusDxe/PciFeatureSupport.h | 9 +++++++++ > MdeModulePkg/Bus/Pci/PciBusDxe/PciPlatformSupport.c | 81 > +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > ++++++++++++++++ > MdeModulePkg/Bus/Pci/PciBusDxe/PciPlatformSupport.h | 15 > +++++++++++++++ > 7 files changed, 360 insertions(+), 1 deletion(-) >=20 > diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.h > b/MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.h > index 5dc5f61..77b44c0 100644 > --- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.h > +++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.h > @@ -288,6 +288,7 @@ struct _PCI_IO_DEVICE { > // > UINT16 BridgeIoAlignment; > UINT8 SetupMPS; > + UINT8 SetupMRRS; > }; >=20 > #define PCI_IO_DEVICE_FROM_PCI_IO_THIS(a) \ diff --git > a/MdeModulePkg/Bus/Pci/PciBusDxe/PciExpressFeatures.c > b/MdeModulePkg/Bus/Pci/PciBusDxe/PciExpressFeatures.c > index 6084446..2810158 100644 > --- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciExpressFeatures.c > +++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciExpressFeatures.c > @@ -191,3 +191,193 @@ ProgramMaxPayloadSize ( > return Status; > } >=20 > +EFI_STATUS > +ConditionalCasMaxReadReqSize ( > + IN PCI_IO_DEVICE *PciDevice, > + IN PCI_EXPRESS_FEATURES_CONFIGURATION_TABLE > +*PciExpressConfigurationTable > + ) > +{ > + // > + // align the Max_Read_Request_Size of the PCI tree based on 3 conditi= ons: > + // first, if user defines MRRS for any one PCI device in the tree > +than align > + // all the devices in the PCI tree. > + // second, if user override is not define for this PCI tree than > +setup the MRRS > + // based on MPS value of the tree to meet the criteria for the > +isochronous > + // traffic. > + // third, if no user override, or platform firmware policy has not > +selected > + // this PCI bus driver to configure the MPS; than configure the MRRS > +to a > + // highest common value of PCI device capability for the MPS found > +among all > + // the PCI devices in this tree > + // > + if (PciExpressConfigurationTable) { > + if (PciExpressConfigurationTable->Lock_Max_Read_Request_Size) { > + PciDevice->SetupMRRS =3D PciExpressConfigurationTable- > >Max_Read_Request_Size; > + } else { > + if (mPciExpressPlatformPolicy.Mps) { > + PciDevice->SetupMRRS =3D PciDevice->SetupMPS; > + } else { > + PciDevice->SetupMRRS =3D MIN ( > + PciDevice->SetupMRRS, > + PciExpressConfigurationTable->Max_Read_= Request_Size > + ); > + } > + PciExpressConfigurationTable->Max_Read_Request_Size =3D PciDevice= - > >SetupMRRS; > + } > + } > + DEBUG (( DEBUG_INFO, "MRRS: %d,", PciDevice->SetupMRRS)); > + > + return EFI_SUCCESS; > +} > + > +/** > + The main routine which process the PCI feature Max_Read_Req_Size as > +per the > + device-specific platform policy, as well as in complaince with the > +PCI Base > + specification Revision 4, that aligns the value for the entire PCI > +heirarchy > + starting from its physical PCI Root port / Bridge device. > + > + @param PciDevice A pointer to the PCI_IO_DEVICE. > + @param PciExpressConfigurationTable pointer to > + PCI_EXPRESS_FEATURES_CONFIGURATION_TABLE > + > + @retval EFI_SUCCESS processing of PCI feature > Max_Read_Req_Size > + is successful. > +**/ > +EFI_STATUS > +SetupMaxReadReqSize ( > + IN PCI_IO_DEVICE *PciDevice, > + IN PCI_EXPRESS_FEATURES_CONFIGURATION_TABLE > +*PciExpressConfigurationTable > + ) > +{ > + PCI_REG_PCIE_DEVICE_CAPABILITY PciDeviceCap; > + UINT8 MrrsValue; > + > + PciDeviceCap.Uint32 =3D > + PciDevice->PciExpressCapabilityStructure.DeviceCapability.Uint32; > + > + if (PciDevice->SetupMRRS =3D=3D EFI_PCI_EXPRESS_MAX_READ_REQ_SIZE_AUT= O) > { > + // > + // The maximum read request size is not the data packet size of the= TLP, > + // but the memory read request size, and set to the function as a r= equestor > + // to not exceed this limit. > + // However, for the PCI device capable of isochronous traffic; this= memory > read > + // request size should not extend beyond the Max_Payload_Size. Thus= , in > case if > + // device policy return by platform indicates to set as per device = capability > + // than set as per Max_Payload_Size configuration value > + // > + if (mPciExpressPlatformPolicy.Mps) { > + MrrsValue =3D PciDevice->SetupMPS; > + } else { > + // > + // in case this driver is not required to configure the Max_Paylo= ad_Size > + // than consider programming HCF of the device capability's > Max_Payload_Size > + // in this PCI hierarchy; thus making this an implementation spec= ific feature > + // which the platform should avoid. For better results, the platf= orm should > + // make both the Max_Payload_Size & Max_Read_Request_Size to be > configured > + // by this driver > + // > + MrrsValue =3D (UINT8)PciDeviceCap.Bits.MaxPayloadSize; > + } > + } else { > + // > + // override as per platform based device policy > + // > + MrrsValue =3D SetDevicePolicyPciExpressMrrs (PciDevice->SetupMRRS); > + // > + // align this device's Max_Read_Request_Size value to the entire PC= I tree > + // > + if (PciExpressConfigurationTable) { > + if (!PciExpressConfigurationTable->Lock_Max_Read_Request_Size) { > + PciExpressConfigurationTable->Lock_Max_Read_Request_Size =3D TR= UE; > + PciExpressConfigurationTable->Max_Read_Request_Size =3D MrrsVal= ue; > + } else { > + // > + // in case of another user enforced value of MRRS within the sa= me tree, > + // pick the smallest between the locked value and this value; t= o set > + // across entire PCI tree nodes > + // > + MrrsValue =3D MIN ( > + MrrsValue, > + PciExpressConfigurationTable->Max_Read_Request_Si= ze > + ); > + PciExpressConfigurationTable->Max_Read_Request_Size =3D MrrsVal= ue; > + } > + } > + } > + // > + // align this device's Max_Read_Request_Size to derived configuration > + value // PciDevice->SetupMRRS =3D MrrsValue; > + > + return ConditionalCasMaxReadReqSize ( > + PciDevice, > + PciExpressConfigurationTable > + ); > +} > + > + > +/** > + Overrides the PCI Device Control register Max_Read_Req_Size register > +field; if > + the hardware value is different than the intended value. > + > + @param PciDevice A pointer to the PCI_IO_DEVICE instance= . > + > + @retval EFI_SUCCESS The data was read from or written to th= e PCI > controller. > + @retval EFI_UNSUPPORTED The address range specified by Offset, = Width, > and Count is not > + valid for the PCI configuration header = of the PCI controller. > + @retval EFI_INVALID_PARAMETER Buffer is NULL or Width is invalid. > + > +**/ > +EFI_STATUS > +ProgramMaxReadReqSize ( > + IN PCI_IO_DEVICE *PciDevice, > + IN VOID *PciExFeatureConfiguration > + ) > +{ > + PCI_REG_PCIE_DEVICE_CONTROL PcieDev; > + UINT32 Offset; > + EFI_STATUS Status; > + EFI_TPL OldTpl; > + > + PcieDev.Uint16 =3D 0; > + Offset =3D PciDevice->PciExpressCapabilityOffset + > + OFFSET_OF (PCI_CAPABILITY_PCIEXP, DeviceControl); > + Status =3D PciDevice->PciIo.Pci.Read ( > + &PciDevice->PciIo, > + EfiPciIoWidthUint16, > + Offset, > + 1, > + &PcieDev.Uint16 > + ); > + ASSERT (Status =3D=3D EFI_SUCCESS); > + > + if (PcieDev.Bits.MaxReadRequestSize !=3D PciDevice->SetupMRRS) { > + PcieDev.Bits.MaxReadRequestSize =3D PciDevice->SetupMRRS; > + DEBUG (( DEBUG_INFO, "MRRS: %d,", PciDevice->SetupMRRS)); > + > + // > + // Raise TPL to high level to disable timer interrupt while the wri= te operation > completes > + // > + OldTpl =3D gBS->RaiseTPL (TPL_HIGH_LEVEL); > + > + Status =3D PciDevice->PciIo.Pci.Write ( > + &PciDevice->PciIo, > + EfiPciIoWidthUint16, > + Offset, > + 1, > + &PcieDev.Uint16 > + ); > + // > + // Restore TPL to its original level > + // > + gBS->RestoreTPL (OldTpl); > + > + if (!EFI_ERROR(Status)) { > + PciDevice->PciExpressCapabilityStructure.DeviceControl.Uint16 =3D > PcieDev.Uint16; > + } else { > + ReportPciWriteError (PciDevice->BusNumber, PciDevice->DeviceNumbe= r, > PciDevice->FunctionNumber, Offset); > + } > + } else { > + DEBUG (( DEBUG_INFO, "No MRRS=3D%d,", PciDevice->SetupMRRS)); } > + > + return Status; > +} > + > diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciExpressFeatures.h > b/MdeModulePkg/Bus/Pci/PciBusDxe/PciExpressFeatures.h > index 460437b..b43fba7 100644 > --- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciExpressFeatures.h > +++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciExpressFeatures.h > @@ -52,4 +52,49 @@ ProgramMaxPayloadSize ( > IN VOID *PciExFeatureConfiguration > ); >=20 > + > +EFI_STATUS > +ConditionalCasMaxReadReqSize ( > + IN PCI_IO_DEVICE *PciDevice, > + IN PCI_EXPRESS_FEATURES_CONFIGURATION_TABLE > +*PciFeaturesConfigurationTable > + ); > + > +/** > + The main routine which process the PCI feature Max_Read_Req_Size as > +per the > + device-specific platform policy, as well as in complaince with the > +PCI Base > + specification Revision 4, that aligns the value for the entire PCI > +heirarchy > + starting from its physical PCI Root port / Bridge device. > + > + @param PciDevice A pointer to the PCI_IO_DEVICE. > + @param PciConfigPhase for the PCI feature configurati= on phases: > + PciExpressFeatureSetupPhase & > + PciExpressFeatureEntendedSetupPhase > + @param PciFeaturesConfigurationTable pointer to > + PCI_EXPRESS_FEATURES_CONFIGURATION_TABLE > + > + @retval EFI_SUCCESS processing of PCI feature > Max_Read_Req_Size > + is successful. > +**/ > +EFI_STATUS > +SetupMaxReadReqSize ( > + IN PCI_IO_DEVICE *PciDevice, > + IN PCI_EXPRESS_FEATURES_CONFIGURATION_TABLE > +*PciFeaturesConfigurationTable > + ); > + > +/** > + Overrides the PCI Device Control register Max_Read_Req_Size register > +field; if > + the hardware value is different than the intended value. > + > + @param PciDevice A pointer to the PCI_IO_DEVICE instance= . > + > + @retval EFI_SUCCESS The data was read from or written to th= e PCI > controller. > + @retval EFI_UNSUPPORTED The address range specified by Offset, = Width, > and Count is not > + valid for the PCI configuration header = of the PCI controller. > + @retval EFI_INVALID_PARAMETER Buffer is NULL or Width is invalid. > + > +**/ > +EFI_STATUS > +ProgramMaxReadReqSize ( > + IN PCI_IO_DEVICE *PciDevice, > + IN VOID *PciExFeatureConfiguration > + ); > + > #endif > diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciFeatureSupport.c > b/MdeModulePkg/Bus/Pci/PciBusDxe/PciFeatureSupport.c > index aae6139..1caf1f4 100644 > --- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciFeatureSupport.c > +++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciFeatureSupport.c > @@ -34,7 +34,7 @@ EFI_PCI_EXPRESS_PLATFORM_POLICY > mPciExpressPlatformPolicy =3D { > // > // support for PCI Express feature - Max. Read Request Size > // > - FALSE, > + TRUE, > // > // support for PCI Express feature - Extended Tag > // > @@ -104,6 +104,15 @@ PCI_EXPRESS_FEATURE_INITIALIZATION_POINT > mPciExpressFeatureInitializationList[] > }, > { > PciExpressFeatureProgramPhase, PciExpressMps, > ProgramMaxPayloadSize > + }, > + { > + PciExpressFeatureSetupPhase, PciExpressMrrs, > SetupMaxReadReqSize > + }, > + { > + PciExpressFeatureEntendedSetupPhase, PciExpressMrrs, > ConditionalCasMaxReadReqSize > + }, > + { > + PciExpressFeatureProgramPhase, PciExpressMrrs, > ProgramMaxReadReqSize > } > }; >=20 > @@ -607,6 +616,15 @@ CreatePciRootBridgeDeviceNode ( > // start by assuming 4096B as the default value for the Max. Payloa= d Size > // > PciConfigTable->Max_Payload_Size =3D > PCIE_MAX_PAYLOAD_SIZE_4096B; > + // > + // start by assuming 4096B as the default value for the Max. Read R= equest > Size > + // > + PciConfigTable->Max_Read_Request_Size =3D > PCIE_MAX_READ_REQ_SIZE_4096B; > + // > + // start by assuming the Max. Read Request Size need not be common = for all > + // the devices in the PCI tree > + // > + PciConfigTable->Lock_Max_Read_Request_Size =3D FALSE; > } >=20 > RootBridgeNode->PciExFeaturesConfigurationTable =3D PciConfigTable; = diff -- > git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciFeatureSupport.h > b/MdeModulePkg/Bus/Pci/PciBusDxe/PciFeatureSupport.h > index 4ecbefc..a1fc39c 100644 > --- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciFeatureSupport.h > +++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciFeatureSupport.h > @@ -71,6 +71,15 @@ struct > _PCI_EXPRESS_FEATURES_CONFIGURATION_TABLE { > // size among all the PCI devices in the PCI hierarchy > // > UINT8 Max_Payload_Size; > + // > + // to configure the PCI feature maximum read request size to maintain > + the memory // requester size among all the PCI devices in the PCI > + hierarchy // > + UINT8 Max_Read_Request_Size; > + // > + // lock the Max_Read_Request_Size for the entire PCI tree of a root > + port // > + BOOLEAN Lock_Max_Read_Request_Size; > }; >=20 > // > diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciPlatformSupport.c > b/MdeModulePkg/Bus/Pci/PciBusDxe/PciPlatformSupport.c > index 3e9d4c5..f74e566 100644 > --- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciPlatformSupport.c > +++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciPlatformSupport.c > @@ -115,6 +115,40 @@ SetDevicePolicyPciExpressMps ( > } > } >=20 > +/** > + Routine to translate the given device-specific platform policy from > +type > + EFI_PCI_EXPRESS_MAX_READ_REQ_SIZE to HW-specific value, as per PCI > +Base Specification > + Revision 4.0; for the PCI feature Max_Read_Req_Size. > + > + @param MRRS Input device-specific policy should be in terms of ty= pe > + EFI_PCI_EXPRESS_MAX_READ_REQ_SIZE > + > + @retval Range values for the Max_Read_Req_Size as defined in = the PCI > + Base Specification 4.0 **/ > +UINT8 > +SetDevicePolicyPciExpressMrrs ( > + IN UINT8 MRRS > +) > +{ > + switch (MRRS) { > + case EFI_PCI_EXPRESS_MAX_READ_REQ_SIZE_128B: > + return PCIE_MAX_READ_REQ_SIZE_128B; > + case EFI_PCI_EXPRESS_MAX_READ_REQ_SIZE_256B: > + return PCIE_MAX_READ_REQ_SIZE_256B; > + case EFI_PCI_EXPRESS_MAX_READ_REQ_SIZE_512B: > + return PCIE_MAX_READ_REQ_SIZE_512B; > + case EFI_PCI_EXPRESS_MAX_READ_REQ_SIZE_1024B: > + return PCIE_MAX_READ_REQ_SIZE_1024B; > + case EFI_PCI_EXPRESS_MAX_READ_REQ_SIZE_2048B: > + return PCIE_MAX_READ_REQ_SIZE_2048B; > + case EFI_PCI_EXPRESS_MAX_READ_REQ_SIZE_4096B: > + return PCIE_MAX_READ_REQ_SIZE_4096B; > + default: > + return PCIE_MAX_READ_REQ_SIZE_128B; > + } > +} > + > /** > Generic routine to setup the PCI features as per its predetermined de= faults. > **/ > @@ -130,6 +164,12 @@ SetupDefaultPciExpressDevicePolicy ( > PciDevice->SetupMPS =3D EFI_PCI_EXPRESS_NOT_APPLICABLE; > } >=20 > + if (mPciExpressPlatformPolicy.Mrrs) { > + PciDevice->SetupMRRS =3D EFI_PCI_EXPRESS_MAX_READ_REQ_SIZE_AUTO; > + } else { > + PciDevice->SetupMRRS =3D EFI_PCI_EXPRESS_NOT_APPLICABLE; } > + > } >=20 > /** > @@ -211,6 +251,14 @@ GetPciExpressDevicePolicy ( > PciDevice->SetupMPS =3D EFI_PCI_EXPRESS_NOT_APPLICABLE; > } >=20 > + // > + // set device specific policy for Max_Read_Req_Size > + // > + if (mPciExpressPlatformPolicy.Mrrs) { > + PciDevice->SetupMRRS =3D PciExpressDevicePolicy.DeviceCtlMRRS; > + } else { > + PciDevice->SetupMRRS =3D EFI_PCI_EXPRESS_NOT_APPLICABLE; > + } >=20 > DEBUG (( > DEBUG_INFO, > @@ -327,6 +375,28 @@ GetPciExpressMps ( > return EFI_PCI_EXPRESS_NOT_APPLICABLE; } >=20 > +EFI_PCI_EXPRESS_MAX_READ_REQ_SIZE > +GetPciExpressMrrs ( > + IN UINT8 Mrrs > + ) > +{ > + switch (Mrrs) { > + case PCIE_MAX_READ_REQ_SIZE_128B: > + return EFI_PCI_EXPRESS_MAX_READ_REQ_SIZE_128B; > + case PCIE_MAX_READ_REQ_SIZE_256B: > + return EFI_PCI_EXPRESS_MAX_READ_REQ_SIZE_256B; > + case PCIE_MAX_READ_REQ_SIZE_512B: > + return EFI_PCI_EXPRESS_MAX_READ_REQ_SIZE_512B; > + case PCIE_MAX_READ_REQ_SIZE_1024B: > + return EFI_PCI_EXPRESS_MAX_READ_REQ_SIZE_1024B; > + case PCIE_MAX_READ_REQ_SIZE_2048B: > + return EFI_PCI_EXPRESS_MAX_READ_REQ_SIZE_2048B; > + case PCIE_MAX_READ_REQ_SIZE_4096B: > + return EFI_PCI_EXPRESS_MAX_READ_REQ_SIZE_4096B; > + } > + return EFI_PCI_EXPRESS_NOT_APPLICABLE; } > + >=20 > /** > Notifies the platform about the current PCI Express state of the devi= ce. > @@ -358,6 +428,17 @@ PciExpressPlatformNotifyDeviceState ( > PciExDeviceConfiguration.DeviceCtlMPS =3D > EFI_PCI_EXPRESS_NOT_APPLICABLE; > } >=20 > + // > + // get the device-specific state for the PCIe Max_Read_Req_Size > + feature // if (mPciExpressPlatformPolicy.Mrrs) { > + PciExDeviceConfiguration.DeviceCtlMRRS =3D GetPciExpressMrrs ( > + (UINT8)PciDevice- > >PciExpressCapabilityStructure.DeviceControl.Bits.MaxReadRequestSize > + ); } else { > + PciExDeviceConfiguration.DeviceCtlMRRS =3D > + EFI_PCI_EXPRESS_NOT_APPLICABLE; } > + > if (mPciExPlatformProtocol !=3D NULL) { > return mPciExPlatformProtocol->NotifyDeviceState ( > mPciExPlatformProtocol, diff --git > a/MdeModulePkg/Bus/Pci/PciBusDxe/PciPlatformSupport.h > b/MdeModulePkg/Bus/Pci/PciBusDxe/PciPlatformSupport.h > index 5ae6386..4653c79 100644 > --- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciPlatformSupport.h > +++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciPlatformSupport.h > @@ -101,4 +101,19 @@ SetDevicePolicyPciExpressMps ( > IN UINT8 MPS > ); >=20 > +/** > + Routine to translate the given device-specific platform policy from > +type > + EFI_PCI_CONF_MAX_READ_REQ_SIZE to HW-specific value, as per PCI Base > +Specification > + Revision 4.0; for the PCI feature Max_Read_Req_Size. > + > + @param MRRS Input device-specific policy should be in terms of ty= pe > + EFI_PCI_CONF_MAX_READ_REQ_SIZE > + > + @retval Range values for the Max_Read_Req_Size as defined in = the PCI > + Base Specification 4.0 **/ > +UINT8 > +SetDevicePolicyPciExpressMrrs ( > + IN UINT8 MRRS > +); > #endif > -- > 2.21.0.windows.1 >=20 >=20 >=20