From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web11.9891.1590140185020524077 for ; Fri, 22 May 2020 02:36:25 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: arm.com, ip: 217.140.110.172, mailfrom: ard.biesheuvel@arm.com) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id BB68F31B; Fri, 22 May 2020 02:36:24 -0700 (PDT) Received: from [192.168.1.81] (unknown [10.37.8.250]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 516013F305; Fri, 22 May 2020 02:36:21 -0700 (PDT) Subject: Re: [PATCH edk2-platforms 10/16] Silicon/NXP: PciSegmentLib: Add ECAM config support for PCIe LS Controller To: Wasim Khan , devel@edk2.groups.io, meenakshi.aggarwal@nxp.com, vabhav.sharma@nxp.com, V.Sethi@nxp.com, leif@nuviainc.com, jon@solid-run.com Cc: Wasim Khan References: <1590102139-16588-1-git-send-email-wasim.khan@oss.nxp.com> <1590102139-16588-11-git-send-email-wasim.khan@oss.nxp.com> From: "Ard Biesheuvel" Message-ID: <255bb5ca-a094-fc99-a327-c902a6258286@arm.com> Date: Fri, 22 May 2020 11:36:17 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: <1590102139-16588-11-git-send-email-wasim.khan@oss.nxp.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit On 5/22/20 1:02 AM, Wasim Khan wrote: > From: Wasim Khan > > PCIe Layerscape controller can be enabled for ECAM style > configuration access using CFG SHIFT Feature. > > Check for PcdPciCfgShiftEnable to decide the configuration access > scheme to be used with PCIe LS controller. > > Signed-off-by: Wasim Khan > --- > Silicon/NXP/Library/PciSegmentLib/PciSegmentLib.inf | 3 +++ > Silicon/NXP/Library/PciSegmentLib/PciSegmentLib.c | 20 ++++++++++++++++---- > 2 files changed, 19 insertions(+), 4 deletions(-) > > diff --git a/Silicon/NXP/Library/PciSegmentLib/PciSegmentLib.inf b/Silicon/NXP/Library/PciSegmentLib/PciSegmentLib.inf > index a36e79239b33..936213dc8a9d 100755 > --- a/Silicon/NXP/Library/PciSegmentLib/PciSegmentLib.inf > +++ b/Silicon/NXP/Library/PciSegmentLib/PciSegmentLib.inf > @@ -30,3 +30,6 @@ [LibraryClasses] > > [FixedPcd] > gNxpQoriqLsTokenSpaceGuid.PcdPciExp1BaseAddr > + > +[Pcd] > + gNxpQoriqLsTokenSpaceGuid.PcdPciCfgShiftEnable > diff --git a/Silicon/NXP/Library/PciSegmentLib/PciSegmentLib.c b/Silicon/NXP/Library/PciSegmentLib/PciSegmentLib.c > index ecd36971b753..552a425c6832 100755 > --- a/Silicon/NXP/Library/PciSegmentLib/PciSegmentLib.c > +++ b/Silicon/NXP/Library/PciSegmentLib/PciSegmentLib.c > @@ -34,6 +34,8 @@ typedef enum { > #define ASSERT_INVALID_PCI_SEGMENT_ADDRESS(A,M) \ > ASSERT (((A) & (0xffff0000f0000000ULL | (M))) == 0) > > +static BOOLEAN CfgShiftEnable; > + This is a compile time constant, right? Please try to avoid using runtime read/write variables in that case, since it defeats the compiler's ability to remove code that is never executed. > STATIC > UINT64 > PciLsCfgTarget ( > @@ -88,11 +90,20 @@ PciLsGetConfigBase ( > { > UINT32 CfgAddr; > > - CfgAddr = (UINT16)Offset; > - if (Bus) { > - return PciLsCfgTarget (PCI_SEG0_DBI_BASE + PCI_DBI_SIZE_DIFF * Segment, Address, Segment, Bus, Offset); > + if (CfgShiftEnable) { > + CfgAddr = (UINT32)Address; > + if (Bus) { > + return PCI_SEG0_MMIO_MEMBASE + PCI_BASE_DIFF * Segment + CfgAddr; > + } else { > + return PCI_SEG0_DBI_BASE + PCI_DBI_SIZE_DIFF * Segment + CfgAddr; > + } > } else { > - return PCI_SEG0_DBI_BASE + PCI_DBI_SIZE_DIFF * Segment + CfgAddr; > + CfgAddr = (UINT16)Offset; > + if (Bus) { > + return PciLsCfgTarget (PCI_SEG0_DBI_BASE + PCI_DBI_SIZE_DIFF * Segment, Address, Segment, Bus, Offset); > + } else { > + return PCI_SEG0_DBI_BASE + PCI_DBI_SIZE_DIFF * Segment + CfgAddr; > + } > } > } > > @@ -608,5 +619,6 @@ PciSegLibInit ( > IN EFI_SYSTEM_TABLE *SystemTable > ) > { > + CfgShiftEnable = CFG_SHIFT_ENABLE; > return EFI_SUCCESS; > } >