public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH edk2-platforms 1/1] Platform/RaspberryPi/AcpiTables: add a IORT ACPI table to limit XHCI DMA
@ 2020-10-11  8:20 Ard Biesheuvel
  2020-10-11 17:25 ` Andrei Warkentin
  0 siblings, 1 reply; 4+ messages in thread
From: Ard Biesheuvel @ 2020-10-11  8:20 UTC (permalink / raw)
  To: devel
  Cc: Ard Biesheuvel, Samer El-Haj-Mahmoud, Jeremy Linton, Pete Batard,
	Andrei Warkentin, Leif Lindholm

Add an IORT table that will limit XHCI DMA to 2 GB, by setting the
DMA width to 31 bits. This is needed for Linux/arm64, which can
only reliably deal with devices that are unable to perform DMA to
the entire 32-bit address range if it can discover their existence
early during boot, and this is before the ACPI interpreter is up
and running (which rules out calling the _DMA method of the XHC0
object)

Cc: Samer El-Haj-Mahmoud <Samer.El-Haj-Mahmoud@arm.com>
Cc: Jeremy Linton <jeremy.linton@arm.com>
Cc: Pete Batard <pete@akeo.ie>
Cc: Andrei Warkentin <awarkentin@vmware.com>
Cc: Leif Lindholm <leif@nuviainc.com>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@arm.com>
---
Related discussions here:

https://lore.kernel.org/linux-arm-kernel/20201001161740.29064-1-nsaenzjulienne@suse.de/
https://lore.kernel.org/linux-acpi/20201010093153.30177-1-ardb@kernel.org/

On Linux, a _DMA method supersedes the IORT, and so the 3 GB limit will
be used at runtime. IOW, streaming DMA will be permitted to the entire
3 GB region, but if shared buffers or bounce buffers are needed, they
will be allocated from the first 2 GB of DRAM.

We may need to offer some guidance on this in the IORT spec, i.e., which
value takes precedence if the IORT and the _DMA method disagree.

 Platform/RaspberryPi/AcpiTables/AcpiTables.inf |  1 +
 Platform/RaspberryPi/AcpiTables/Iort.aslc      | 58 ++++++++++++++++++++
 2 files changed, 59 insertions(+)

diff --git a/Platform/RaspberryPi/AcpiTables/AcpiTables.inf b/Platform/RaspberryPi/AcpiTables/AcpiTables.inf
index c40c32e16ff7..d2cce074e56c 100644
--- a/Platform/RaspberryPi/AcpiTables/AcpiTables.inf
+++ b/Platform/RaspberryPi/AcpiTables/AcpiTables.inf
@@ -29,6 +29,7 @@ [Sources]
   Fadt.aslc
   Dbg2.aslc
   Gtdt.aslc
+  Iort.aslc
   Dsdt.asl
   Csrt.aslc
   Spcr.aslc
diff --git a/Platform/RaspberryPi/AcpiTables/Iort.aslc b/Platform/RaspberryPi/AcpiTables/Iort.aslc
new file mode 100644
index 000000000000..1351e8f7b262
--- /dev/null
+++ b/Platform/RaspberryPi/AcpiTables/Iort.aslc
@@ -0,0 +1,58 @@
+/** @file
+
+  Copyright (c) 2020, Arm, Ltd. All rights reserved.<BR>
+
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <IndustryStandard/IoRemappingTable.h>
+
+#include "AcpiTables.h"
+
+#pragma pack(1)
+
+typedef struct {
+  EFI_ACPI_6_0_IO_REMAPPING_NAMED_COMP_NODE Node;
+  CONST CHAR8                               Name[16];
+} RPI4_NC_NODE;
+
+typedef struct {
+  EFI_ACPI_6_0_IO_REMAPPING_TABLE      Iort;
+  RPI4_NC_NODE                         NamedCompNode;
+} RPI4_IO_REMAPPING_STRUCTURE;
+
+STATIC RPI4_IO_REMAPPING_STRUCTURE Iort = {
+  {
+    ACPI_HEADER (EFI_ACPI_6_0_IO_REMAPPING_TABLE_SIGNATURE,
+                 RPI4_IO_REMAPPING_STRUCTURE,
+                 EFI_ACPI_IO_REMAPPING_TABLE_REVISION),
+    1,                                              // NumNodes
+    sizeof (EFI_ACPI_6_0_IO_REMAPPING_TABLE),       // NodeOffset
+    0                                               // Reserved
+  }, {
+    // XHCI named component node
+    {
+      {
+        EFI_ACPI_IORT_TYPE_NAMED_COMP,
+        sizeof (RPI4_NC_NODE),
+        0x0,
+        0x0,
+        0x0,
+        0x0,
+      },
+      0x0,
+      0x0,
+      0x0,
+      0x0,
+      0x0,
+      31,
+    }, {
+      "\\_SB_.SCB0.XHC0"
+    }
+  }
+};
+
+#pragma pack()
+
+VOID* CONST ReferenceAcpiTable = &Iort;
-- 
2.17.1


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

end of thread, other threads:[~2020-10-12 17:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-10-11  8:20 [PATCH edk2-platforms 1/1] Platform/RaspberryPi/AcpiTables: add a IORT ACPI table to limit XHCI DMA Ard Biesheuvel
2020-10-11 17:25 ` Andrei Warkentin
2020-10-11 17:56   ` Ard Biesheuvel
2020-10-12 17:31   ` Ard Biesheuvel

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