public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH] MdeModulePkg/PciBusDxe: GetBarAttributes() returns Host address
@ 2017-09-11  5:01 Ruiyu Ni
  2017-09-11  6:46 ` Laszlo Ersek
  0 siblings, 1 reply; 9+ messages in thread
From: Ruiyu Ni @ 2017-09-11  5:01 UTC (permalink / raw)
  To: edk2-devel
  Cc: Ard Biesheuvel, Benjamin Herrenschmidt, Andrew Fish, Dong Wei,
	Laszlo Ersek, Bartosz Szczepanek

Per the UEFI Spec, GetBarAttributes() should return the Host address.
But current implementation returns the address read from the BAR,
which is the Device address.
Per the description of AddressTranslationOffset in ACPI spec:
"For bridges that translate addresses across the bridge, this is the
offset that must be added to the address on the secondary side to
obtain the address on the primary side."
HostAddress = DeviceAddress + AddressTranslationOffset.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Benjamin Herrenschmidt <benh@au1.ibm.com>
Cc: Andrew Fish <afish@apple.com>
Cc: Dong Wei <Dong.Wei@arm.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Bartosz Szczepanek <bsz@semihalf.com>
---
 MdeModulePkg/Bus/Pci/PciBusDxe/PciIo.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciIo.c b/MdeModulePkg/Bus/Pci/PciBusDxe/PciIo.c
index cc7125e4fc..852d35d710 100644
--- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciIo.c
+++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciIo.c
@@ -1955,7 +1955,7 @@ PciIoGetBarAttributes (
     End->Checksum = 0;
 
     //
-    // Get the Address Translation Offset
+    // Get the Address Translation Offset and convert the Device address to Host address.
     //
     if (Descriptor->ResType == ACPI_ADDRESS_SPACE_TYPE_MEM) {
       Descriptor->AddrTranslationOffset = GetMmioAddressTranslationOffset (
@@ -1967,6 +1967,7 @@ PciIoGetBarAttributes (
         FreePool (Descriptor);
         return EFI_UNSUPPORTED;
       }
+      Descriptor->AddrRangeMin += Descriptor->AddrTranslationOffset;
     }
   }
 
-- 
2.12.2.windows.2



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

end of thread, other threads:[~2017-09-13  3:04 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-11  5:01 [PATCH] MdeModulePkg/PciBusDxe: GetBarAttributes() returns Host address Ruiyu Ni
2017-09-11  6:46 ` Laszlo Ersek
2017-09-12  4:32   ` Ard Biesheuvel
2017-09-12  5:01   ` Ni, Ruiyu
2017-09-12  6:44     ` Ard Biesheuvel
2017-09-12  8:40       ` Laszlo Ersek
2017-09-12 15:49         ` Ard Biesheuvel
2017-09-12 16:15           ` Laszlo Ersek
     [not found]             ` <1505259457.12628.157.camel@au1.ibm.com>
2017-09-13  3:07               ` Ni, Ruiyu

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