[edk2-devel] [PATCH 5/5] Platform/RaspberryPi: Update PCIe MMIO window for DT

Jeremy Linton posted 5 patches 2 years, 10 months ago
There is a newer version of this series
[edk2-devel] [PATCH 5/5] Platform/RaspberryPi: Update PCIe MMIO window for DT
Posted by Jeremy Linton 2 years, 10 months ago
Since we are updating the DT memory map and telling it how
we have configured the PCIe, there isn't a reason for moving the
MMIO window. In fact this appears to fix OpenBSD+DT as well as
it makes the linux XHCI reset sequence happier.

Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
---
 Platform/RaspberryPi/Drivers/FdtDxe/FdtDxe.c | 24 ++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/Platform/RaspberryPi/Drivers/FdtDxe/FdtDxe.c b/Platform/RaspberryPi/Drivers/FdtDxe/FdtDxe.c
index dd4fc0a05e..e6942df6a3 100644
--- a/Platform/RaspberryPi/Drivers/FdtDxe/FdtDxe.c
+++ b/Platform/RaspberryPi/Drivers/FdtDxe/FdtDxe.c
@@ -375,6 +375,30 @@ SyncPcie (
     return EFI_NOT_FOUND;
   }
 
+  // move the MMIO window too
+  DmaRanges[0] = cpu_to_fdt32 (0x02000000); //non prefech 32-bit
+  DmaRanges[1] = cpu_to_fdt32 (0x00000000); //bus addr @ 0x0f8000000
+  DmaRanges[2] = cpu_to_fdt32 (0xf8000000);
+  DmaRanges[3] = cpu_to_fdt32 (0x00000006); //cpu addr @ 0x600000000
+  DmaRanges[4] = cpu_to_fdt32 (0x00000000);
+  DmaRanges[5] = cpu_to_fdt32 (0x00000000);
+  DmaRanges[6] = cpu_to_fdt32 (0x04000000); // len = 0x4000 0000
+
+  DEBUG ((DEBUG_INFO, "%a: Updating PCIe ranges\n",  __func__));
+
+  /*
+   * Match dma-ranges with the EDK2+ACPI setup we are using.  This works
+   * around a failure in Linux and OpenBSD to reset the PCIe/XHCI correctly
+   * when in DT mode.
+   */
+  Retval = fdt_setprop (mFdtImage, Node, "ranges",
+                        DmaRanges,  sizeof DmaRanges);
+  if (Retval != 0) {
+    DEBUG ((DEBUG_ERROR, "%a: failed to locate PCIe MMIO 'ranges' property (%d)\n",
+      __func__, Retval));
+    return EFI_NOT_FOUND;
+  }
+
   if (PcdGet32 (PcdXhciReload) != 1) {
     return EFI_SUCCESS;
   }
-- 
2.43.0



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#113548): https://edk2.groups.io/g/devel/message/113548
Mute This Topic: https://groups.io/mt/103652857/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-
Re: [edk2-devel] [PATCH 5/5] Platform/RaspberryPi: Update PCIe MMIO window for DT
Posted by Ard Biesheuvel 2 years, 10 months ago
On Thu, 11 Jan 2024 at 00:52, Jeremy Linton <jeremy.linton@arm.com> wrote:
>
> Since we are updating the DT memory map and telling it how
> we have configured the PCIe, there isn't a reason for moving the
> MMIO window. In fact this appears to fix OpenBSD+DT as well as
> it makes the linux XHCI reset sequence happier.
>
> Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
> ---
>  Platform/RaspberryPi/Drivers/FdtDxe/FdtDxe.c | 24 ++++++++++++++++++++
>  1 file changed, 24 insertions(+)
>
> diff --git a/Platform/RaspberryPi/Drivers/FdtDxe/FdtDxe.c b/Platform/RaspberryPi/Drivers/FdtDxe/FdtDxe.c
> index dd4fc0a05e..e6942df6a3 100644
> --- a/Platform/RaspberryPi/Drivers/FdtDxe/FdtDxe.c
> +++ b/Platform/RaspberryPi/Drivers/FdtDxe/FdtDxe.c
> @@ -375,6 +375,30 @@ SyncPcie (
>      return EFI_NOT_FOUND;
>    }
>
> +  // move the MMIO window too
> +  DmaRanges[0] = cpu_to_fdt32 (0x02000000); //non prefech 32-bit
> +  DmaRanges[1] = cpu_to_fdt32 (0x00000000); //bus addr @ 0x0f8000000
> +  DmaRanges[2] = cpu_to_fdt32 (0xf8000000);
> +  DmaRanges[3] = cpu_to_fdt32 (0x00000006); //cpu addr @ 0x600000000
> +  DmaRanges[4] = cpu_to_fdt32 (0x00000000);
> +  DmaRanges[5] = cpu_to_fdt32 (0x00000000);
> +  DmaRanges[6] = cpu_to_fdt32 (0x04000000); // len = 0x4000 0000
> +

Is there any way we can use symbolic constants here?

> +  DEBUG ((DEBUG_INFO, "%a: Updating PCIe ranges\n",  __func__));
> +
> +  /*
> +   * Match dma-ranges with the EDK2+ACPI setup we are using.  This works
> +   * around a failure in Linux and OpenBSD to reset the PCIe/XHCI correctly
> +   * when in DT mode.
> +   */

Please sync the comment with the code.

> +  Retval = fdt_setprop (mFdtImage, Node, "ranges",
> +                        DmaRanges,  sizeof DmaRanges);
> +  if (Retval != 0) {
> +    DEBUG ((DEBUG_ERROR, "%a: failed to locate PCIe MMIO 'ranges' property (%d)\n",
> +      __func__, Retval));
> +    return EFI_NOT_FOUND;
> +  }
> +
>    if (PcdGet32 (PcdXhciReload) != 1) {
>      return EFI_SUCCESS;
>    }
> --
> 2.43.0
>


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#113591): https://edk2.groups.io/g/devel/message/113591
Mute This Topic: https://groups.io/mt/103652857/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-