diff mbox series

[edk2,RFC,v3,3/3] MdeModulePkg/PciBus: return CPU address for GetBarAttributes

Message ID 1519376008-110662-4-git-send-email-heyi.guo@linaro.org
State Superseded
Headers show
Series Add translation support to generic PciHostBridge | expand

Commit Message

gary guo Feb. 23, 2018, 8:53 a.m. UTC
According to UEFI spec 2.7, PciIo->GetBarAttributes should return host
address (CPU view ddress) rather than device address (PCI view
address), and
device address = host address + address translation offset,
so we subtract translation from device address before returning.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Heyi Guo <heyi.guo@linaro.org>

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
---
 MdeModulePkg/Bus/Pci/PciBusDxe/PciIo.c | 4 ++++
 1 file changed, 4 insertions(+)

-- 
2.7.4

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

Comments

Laszlo Ersek Feb. 23, 2018, 3:08 p.m. UTC | #1
On 02/23/18 09:53, Heyi Guo wrote:
> According to UEFI spec 2.7, PciIo->GetBarAttributes should return host

> address (CPU view ddress) rather than device address (PCI view

> address), and

> device address = host address + address translation offset,

> so we subtract translation from device address before returning.

> 

> Contributed-under: TianoCore Contribution Agreement 1.1

> Signed-off-by: Heyi Guo <heyi.guo@linaro.org>

> Cc: Ruiyu Ni <ruiyu.ni@intel.com>

> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>

> Cc: Star Zeng <star.zeng@intel.com>

> Cc: Eric Dong <eric.dong@intel.com>

> Cc: Laszlo Ersek <lersek@redhat.com>

> Cc: Michael D Kinney <michael.d.kinney@intel.com>

> ---

>  MdeModulePkg/Bus/Pci/PciBusDxe/PciIo.c | 4 ++++

>  1 file changed, 4 insertions(+)

> 

> diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciIo.c b/MdeModulePkg/Bus/Pci/PciBusDxe/PciIo.c

> index fef3ece..62179eb 100644

> --- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciIo.c

> +++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciIo.c

> @@ -1972,6 +1972,10 @@ PciIoGetBarAttributes (

>          return EFI_UNSUPPORTED;

>        }

>      }

> +

> +    // According to UEFI spec 2.7, we need return host address for

> +    // PciIo->GetBarAttributes, and host address = device address - translation.

> +    Descriptor->AddrRangeMin -= Descriptor->AddrTranslationOffset;

>    }

>  

>    return EFI_SUCCESS;

> 


Patches #2 and #3 look OK to me, but I feel I don't know enough to give
an R-b with a good conscience.

Thanks
Laszlo
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
diff mbox series

Patch

diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciIo.c b/MdeModulePkg/Bus/Pci/PciBusDxe/PciIo.c
index fef3ece..62179eb 100644
--- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciIo.c
+++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciIo.c
@@ -1972,6 +1972,10 @@  PciIoGetBarAttributes (
         return EFI_UNSUPPORTED;
       }
     }
+
+    // According to UEFI spec 2.7, we need return host address for
+    // PciIo->GetBarAttributes, and host address = device address - translation.
+    Descriptor->AddrRangeMin -= Descriptor->AddrTranslationOffset;
   }
 
   return EFI_SUCCESS;