From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web12.13965.1602404474224385779 for ; Sun, 11 Oct 2020 01:21:14 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: arm.com, ip: 217.140.110.172, mailfrom: ard.biesheuvel@arm.com) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 9401AD6E; Sun, 11 Oct 2020 01:21:11 -0700 (PDT) Received: from e123331-lin.nice.arm.com (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id DF81C3F66B; Sun, 11 Oct 2020 01:21:09 -0700 (PDT) From: "Ard Biesheuvel" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Samer El-Haj-Mahmoud , Jeremy Linton , Pete Batard , Andrei Warkentin , Leif Lindholm Subject: [PATCH edk2-platforms 1/1] Platform/RaspberryPi/AcpiTables: add a IORT ACPI table to limit XHCI DMA Date: Sun, 11 Oct 2020 10:20:57 +0200 Message-Id: <20201011082057.20662-1-ard.biesheuvel@arm.com> X-Mailer: git-send-email 2.17.1 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 Cc: Jeremy Linton Cc: Pete Batard Cc: Andrei Warkentin Cc: Leif Lindholm Signed-off-by: Ard Biesheuvel --- 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.
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include + +#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