public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH v2] MdeModulePkg/Bus: Enable to use device address when programming BARs
@ 2018-05-09 20:25 Roman Bacik
  2018-05-10  3:02 ` Ni, Ruiyu
  0 siblings, 1 reply; 3+ messages in thread
From: Roman Bacik @ 2018-05-09 20:25 UTC (permalink / raw)
  To: edk2-devel; +Cc: Ruiyu Ni, Vladimir Olovyannikov

Some SoCs require to use device address when BARs are programmed:
https://bugzilla.tianocore.org/show_bug.cgi?id=948

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Vladimir Olovyannikov <vladimir.olovyannikov@broadcom.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Roman Bacik <roman.bacik@broadcom.com>
---
 MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf        | 1 +
 MdeModulePkg/Bus/Pci/PciBusDxe/PciResourceSupport.c | 8 +++++---
 MdeModulePkg/MdeModulePkg.dec                       | 3 +++
 MdeModulePkg/MdeModulePkg.dsc                       | 1 +
 4 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf
b/MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf
index 97608bfcf245..1368e5068574 100644
--- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf
+++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf
@@ -110,6 +110,7 @@
   gEfiMdeModulePkgTokenSpaceGuid.PcdAriSupport                  ## CONSUMES
   gEfiMdeModulePkgTokenSpaceGuid.PcdMrIovSupport                ## CONSUMES
   gEfiMdeModulePkgTokenSpaceGuid.PcdPciDisableBusEnumeration    ##
SOMETIMES_CONSUMES
+  gEfiMdeModulePkgTokenSpaceGuid.PcdUseDeviceAddress        ## CONSUMES

 [UserExtensions.TianoCore."ExtraFiles"]
   PciBusDxeExtra.uni
diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciResourceSupport.c
b/MdeModulePkg/Bus/Pci/PciBusDxe/PciResourceSupport.c
index 2f713fcee95e..a23bd1e258ef 100644
--- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciResourceSupport.c
+++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciResourceSupport.c
@@ -1269,6 +1269,7 @@ ProgramBar (
   EFI_PCI_IO_PROTOCOL *PciIo;
   UINT64              Address;
   UINT32              Address32;
+  BOOLEAN             UseDeviceAddress;

   ASSERT (Node->Bar < PCI_MAX_BAR);

@@ -1282,8 +1283,9 @@ ProgramBar (

   Address = 0;
   PciIo   = &(Node->PciDev->PciIo);
+  UseDeviceAddress = FeaturePcdGet (PcdUseDeviceAddress);

-  Address = Base + Node->Offset;
+  Address = UseDeviceAddress? Node->Offset: Base + Node->Offset;

   //
   // Indicate pci bus driver has allocated
@@ -1308,7 +1310,7 @@ ProgramBar (
                  &Address
                  );

-    Node->PciDev->PciBar[Node->Bar].BaseAddress = Address;
+    Node->PciDev->PciBar[Node->Bar].BaseAddress = UseDeviceAddress? Base +
Address: Address;

     break;

@@ -1335,7 +1337,7 @@ ProgramBar (
                  &Address32
                  );

-    Node->PciDev->PciBar[Node->Bar].BaseAddress = Address;
+    Node->PciDev->PciBar[Node->Bar].BaseAddress = UseDeviceAddress? Base +
Address: Address;

     break;

diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
index cc397185f7b9..58425ee0d57f 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -1005,6 +1005,9 @@
   # @Prompt Enable UEFI Stack Guard.
   gEfiMdeModulePkgTokenSpaceGuid.PcdCpuStackGuard|FALSE|BOOLEAN|0x30001055

+  ## Indicates whether the device address should be used for BAR
programming
+  gEfiMdeModulePkgTokenSpaceGuid.PcdUseDeviceAddress|FALSE|
BOOLEAN|0x30001056
+
 [PcdsFixedAtBuild, PcdsPatchableInModule]
   ## Dynamic type PCD can be registered callback function for Pcd setting
action.
   #  PcdMaxPeiPcdCallBackNumberPerPcdEntry indicates the maximum number of
callback function
diff --git a/MdeModulePkg/MdeModulePkg.dsc b/MdeModulePkg/MdeModulePkg.dsc
index ec24a50c7d0a..39b397cb13d9 100644
--- a/MdeModulePkg/MdeModulePkg.dsc
+++ b/MdeModulePkg/MdeModulePkg.dsc
@@ -200,6 +200,7 @@
   gEfiMdeModulePkgTokenSpaceGuid.PcdMaxSizeNonPopulateCapsule|0x0
   gEfiMdeModulePkgTokenSpaceGuid.PcdMaxSizePopulateCapsule|0x0
   gEfiMdeModulePkgTokenSpaceGuid.PcdMaxPeiPerformanceLogEntries|28
+  gEfiMdeModulePkgTokenSpaceGuid.PcdUseDeviceAddress|FALSE

 [PcdsFixedAtBuild.IPF]
   gEfiMdePkgTokenSpaceGuid.PcdIoBlockBaseAddressForIpf|0x0ffffc000000

-- 
1.9.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] MdeModulePkg/Bus: Enable to use device address when programming BARs
  2018-05-09 20:25 [PATCH v2] MdeModulePkg/Bus: Enable to use device address when programming BARs Roman Bacik
@ 2018-05-10  3:02 ` Ni, Ruiyu
  2018-05-10 15:04   ` Roman Bacik
  0 siblings, 1 reply; 3+ messages in thread
From: Ni, Ruiyu @ 2018-05-10  3:02 UTC (permalink / raw)
  To: Roman Bacik, edk2-devel@lists.01.org; +Cc: Vladimir Olovyannikov

Roman,
Can you point to me the spec content which states the “Offset” instead of “Base + Offset” should be written to the BAR?
Does the policy apply to all PCI devices in a system, or certain PCI devices in a system?

Thanks/Ray

From: Roman Bacik <roman.bacik@broadcom.com>
Sent: Thursday, May 10, 2018 4:25 AM
To: edk2-devel@lists.01.org
Cc: Ni, Ruiyu <ruiyu.ni@intel.com>; Vladimir Olovyannikov <vladimir.olovyannikov@broadcom.com>
Subject: [edk2] [PATCH v2] MdeModulePkg/Bus: Enable to use device address when programming BARs

Some SoCs require to use device address when BARs are programmed:
https://bugzilla.tianocore.org/show_bug.cgi?id=948

Cc: Ruiyu Ni <ruiyu.ni@intel.com<mailto:ruiyu.ni@intel.com>>
Cc: Vladimir Olovyannikov <vladimir.olovyannikov@broadcom.com<mailto:vladimir.olovyannikov@broadcom.com>>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Roman Bacik <roman.bacik@broadcom.com<mailto:roman.bacik@broadcom.com>>
---
 MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf        | 1 +
 MdeModulePkg/Bus/Pci/PciBusDxe/PciResourceSupport.c | 8 +++++---
 MdeModulePkg/MdeModulePkg.dec                       | 3 +++
 MdeModulePkg/MdeModulePkg.dsc                       | 1 +
 4 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf b/MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf
index 97608bfcf245..1368e5068574 100644
--- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf
+++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf
@@ -110,6 +110,7 @@
   gEfiMdeModulePkgTokenSpaceGuid.PcdAriSupport                  ## CONSUMES
   gEfiMdeModulePkgTokenSpaceGuid.PcdMrIovSupport                ## CONSUMES
   gEfiMdeModulePkgTokenSpaceGuid.PcdPciDisableBusEnumeration    ## SOMETIMES_CONSUMES
+  gEfiMdeModulePkgTokenSpaceGuid.PcdUseDeviceAddress        ## CONSUMES

 [UserExtensions.TianoCore."ExtraFiles"]
   PciBusDxeExtra.uni
diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciResourceSupport.c b/MdeModulePkg/Bus/Pci/PciBusDxe/PciResourceSupport.c
index 2f713fcee95e..a23bd1e258ef 100644
--- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciResourceSupport.c
+++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciResourceSupport.c
@@ -1269,6 +1269,7 @@ ProgramBar (
   EFI_PCI_IO_PROTOCOL *PciIo;
   UINT64              Address;
   UINT32              Address32;
+  BOOLEAN             UseDeviceAddress;

   ASSERT (Node->Bar < PCI_MAX_BAR);

@@ -1282,8 +1283,9 @@ ProgramBar (

   Address = 0;
   PciIo   = &(Node->PciDev->PciIo);
+  UseDeviceAddress = FeaturePcdGet (PcdUseDeviceAddress);

-  Address = Base + Node->Offset;
+  Address = UseDeviceAddress? Node->Offset: Base + Node->Offset;

   //
   // Indicate pci bus driver has allocated
@@ -1308,7 +1310,7 @@ ProgramBar (
                  &Address
                  );

-    Node->PciDev->PciBar[Node->Bar].BaseAddress = Address;
+    Node->PciDev->PciBar[Node->Bar].BaseAddress = UseDeviceAddress? Base + Address: Address;

     break;

@@ -1335,7 +1337,7 @@ ProgramBar (
                  &Address32
                  );

-    Node->PciDev->PciBar[Node->Bar].BaseAddress = Address;
+    Node->PciDev->PciBar[Node->Bar].BaseAddress = UseDeviceAddress? Base + Address: Address;

     break;

diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
index cc397185f7b9..58425ee0d57f 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -1005,6 +1005,9 @@
   # @Prompt Enable UEFI Stack Guard.
   gEfiMdeModulePkgTokenSpaceGuid.PcdCpuStackGuard|FALSE|BOOLEAN|0x30001055

+  ## Indicates whether the device address should be used for BAR programming
+  gEfiMdeModulePkgTokenSpaceGuid.PcdUseDeviceAddress|FALSE|BOOLEAN|0x30001056
+
 [PcdsFixedAtBuild, PcdsPatchableInModule]
   ## Dynamic type PCD can be registered callback function for Pcd setting action.
   #  PcdMaxPeiPcdCallBackNumberPerPcdEntry indicates the maximum number of callback function
diff --git a/MdeModulePkg/MdeModulePkg.dsc b/MdeModulePkg/MdeModulePkg.dsc
index ec24a50c7d0a..39b397cb13d9 100644
--- a/MdeModulePkg/MdeModulePkg.dsc
+++ b/MdeModulePkg/MdeModulePkg.dsc
@@ -200,6 +200,7 @@
   gEfiMdeModulePkgTokenSpaceGuid.PcdMaxSizeNonPopulateCapsule|0x0
   gEfiMdeModulePkgTokenSpaceGuid.PcdMaxSizePopulateCapsule|0x0
   gEfiMdeModulePkgTokenSpaceGuid.PcdMaxPeiPerformanceLogEntries|28
+  gEfiMdeModulePkgTokenSpaceGuid.PcdUseDeviceAddress|FALSE

 [PcdsFixedAtBuild.IPF]
   gEfiMdePkgTokenSpaceGuid.PcdIoBlockBaseAddressForIpf|0x0ffffc000000
[https://ssl.gstatic.com/ui/v1/icons/mail/images/cleardot.gif]

--
1.9.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] MdeModulePkg/Bus: Enable to use device address when programming BARs
  2018-05-10  3:02 ` Ni, Ruiyu
@ 2018-05-10 15:04   ` Roman Bacik
  0 siblings, 0 replies; 3+ messages in thread
From: Roman Bacik @ 2018-05-10 15:04 UTC (permalink / raw)
  To: Ni, Ruiyu; +Cc: edk2-devel@lists.01.org, Vladimir Olovyannikov

Ray,

Sadly our SoC requires offset instead of base+offset to be used when
programming BARs. Moreover base+offset must be kept for the drivers to
use the correct address. This applies to all PCI devices in the
system. We would really appreciate if such requirement can be
supported.
Thanks,

Roman

On Wed, May 9, 2018 at 8:02 PM, Ni, Ruiyu <ruiyu.ni@intel.com> wrote:
>
> Roman,
>
> Can you point to me the spec content which states the “Offset” instead of “Base + Offset” should be written to the BAR?
>
> Does the policy apply to all PCI devices in a system, or certain PCI devices in a system?
>
>
>
> Thanks/Ray
>
>
>
> From: Roman Bacik <roman.bacik@broadcom.com>
> Sent: Thursday, May 10, 2018 4:25 AM
> To: edk2-devel@lists.01.org
> Cc: Ni, Ruiyu <ruiyu.ni@intel.com>; Vladimir Olovyannikov <vladimir.olovyannikov@broadcom.com>
> Subject: [edk2] [PATCH v2] MdeModulePkg/Bus: Enable to use device address when programming BARs
>
>
>
> Some SoCs require to use device address when BARs are programmed:
> https://bugzilla.tianocore.org/show_bug.cgi?id=948
>
> Cc: Ruiyu Ni <ruiyu.ni@intel.com>
> Cc: Vladimir Olovyannikov <vladimir.olovyannikov@broadcom.com>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Roman Bacik <roman.bacik@broadcom.com>
> ---
>  MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf        | 1 +
>  MdeModulePkg/Bus/Pci/PciBusDxe/PciResourceSupport.c | 8 +++++---
>  MdeModulePkg/MdeModulePkg.dec                       | 3 +++
>  MdeModulePkg/MdeModulePkg.dsc                       | 1 +
>  4 files changed, 10 insertions(+), 3 deletions(-)
>
> diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf b/MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf
> index 97608bfcf245..1368e5068574 100644
> --- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf
> +++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf
> @@ -110,6 +110,7 @@
>    gEfiMdeModulePkgTokenSpaceGuid.PcdAriSupport                  ## CONSUMES
>    gEfiMdeModulePkgTokenSpaceGuid.PcdMrIovSupport                ## CONSUMES
>    gEfiMdeModulePkgTokenSpaceGuid.PcdPciDisableBusEnumeration    ## SOMETIMES_CONSUMES
> +  gEfiMdeModulePkgTokenSpaceGuid.PcdUseDeviceAddress        ## CONSUMES
>
>  [UserExtensions.TianoCore."ExtraFiles"]
>    PciBusDxeExtra.uni
> diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciResourceSupport.c b/MdeModulePkg/Bus/Pci/PciBusDxe/PciResourceSupport.c
> index 2f713fcee95e..a23bd1e258ef 100644
> --- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciResourceSupport.c
> +++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciResourceSupport.c
> @@ -1269,6 +1269,7 @@ ProgramBar (
>    EFI_PCI_IO_PROTOCOL *PciIo;
>    UINT64              Address;
>    UINT32              Address32;
> +  BOOLEAN             UseDeviceAddress;
>
>    ASSERT (Node->Bar < PCI_MAX_BAR);
>
> @@ -1282,8 +1283,9 @@ ProgramBar (
>
>    Address = 0;
>    PciIo   = &(Node->PciDev->PciIo);
> +  UseDeviceAddress = FeaturePcdGet (PcdUseDeviceAddress);
>
> -  Address = Base + Node->Offset;
> +  Address = UseDeviceAddress? Node->Offset: Base + Node->Offset;
>
>    //
>    // Indicate pci bus driver has allocated
> @@ -1308,7 +1310,7 @@ ProgramBar (
>                   &Address
>                   );
>
> -    Node->PciDev->PciBar[Node->Bar].BaseAddress = Address;
> +    Node->PciDev->PciBar[Node->Bar].BaseAddress = UseDeviceAddress? Base + Address: Address;
>
>      break;
>
> @@ -1335,7 +1337,7 @@ ProgramBar (
>                   &Address32
>                   );
>
> -    Node->PciDev->PciBar[Node->Bar].BaseAddress = Address;
> +    Node->PciDev->PciBar[Node->Bar].BaseAddress = UseDeviceAddress? Base + Address: Address;
>
>      break;
>
> diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
> index cc397185f7b9..58425ee0d57f 100644
> --- a/MdeModulePkg/MdeModulePkg.dec
> +++ b/MdeModulePkg/MdeModulePkg.dec
> @@ -1005,6 +1005,9 @@
>    # @Prompt Enable UEFI Stack Guard.
>    gEfiMdeModulePkgTokenSpaceGuid.PcdCpuStackGuard|FALSE|BOOLEAN|0x30001055
>
> +  ## Indicates whether the device address should be used for BAR programming
> +  gEfiMdeModulePkgTokenSpaceGuid.PcdUseDeviceAddress|FALSE|BOOLEAN|0x30001056
> +
>  [PcdsFixedAtBuild, PcdsPatchableInModule]
>    ## Dynamic type PCD can be registered callback function for Pcd setting action.
>    #  PcdMaxPeiPcdCallBackNumberPerPcdEntry indicates the maximum number of callback function
> diff --git a/MdeModulePkg/MdeModulePkg.dsc b/MdeModulePkg/MdeModulePkg.dsc
> index ec24a50c7d0a..39b397cb13d9 100644
> --- a/MdeModulePkg/MdeModulePkg.dsc
> +++ b/MdeModulePkg/MdeModulePkg.dsc
> @@ -200,6 +200,7 @@
>    gEfiMdeModulePkgTokenSpaceGuid.PcdMaxSizeNonPopulateCapsule|0x0
>    gEfiMdeModulePkgTokenSpaceGuid.PcdMaxSizePopulateCapsule|0x0
>    gEfiMdeModulePkgTokenSpaceGuid.PcdMaxPeiPerformanceLogEntries|28
> +  gEfiMdeModulePkgTokenSpaceGuid.PcdUseDeviceAddress|FALSE
>
>  [PcdsFixedAtBuild.IPF]
>    gEfiMdePkgTokenSpaceGuid.PcdIoBlockBaseAddressForIpf|0x0ffffc000000
>
>
> --
> 1.9.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-05-10 15:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-05-09 20:25 [PATCH v2] MdeModulePkg/Bus: Enable to use device address when programming BARs Roman Bacik
2018-05-10  3:02 ` Ni, Ruiyu
2018-05-10 15:04   ` Roman Bacik

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox