Skip to contentSkip to conversation

Implement ACPI on aarch64

PATCH Superseded Patrick Rudolph 5 participants 80 messages Sep 18, 2024 – Sep 27, 2024

Subsystems (15)

v4 of 10 Superseded Latest is v10 →

lore
Share & tools
lore
#0 lore raw

v4 cover Implement ACPI on aarch64

Based on the existing work done by Simon Glass this series adds support for booting aarch64 devices using ACPI only.
As first target QEMU SBSA support is added, which relies on ACPI only to boot an OS. As secondary target the Raspberry Pi4 was used, which is broadly available and allows easy testing of the proposed solution.

The series is split into ACPI cleanups and code movements, adding Arm specific ACPI tables and finally SoC and mainboard related changes to boot a Linux on the QEMU SBSA and RPi4. Currently only the mandatory ACPI tables are supported, allowing to boot into Linux without errors.

The QEMU SBSA support is feature complete and provides the same functionality as the EDK2 implementation.

The changes were tested on real hardware as well on QEMU v9.0:

qemu-system-aarch64 -machine sbsa-ref -nographic -cpu cortex-a57 \
                    -pflash secure-world.rom \
                    -pflash unsecure-world.rom

qemu-system-aarch64 -machine raspi4b -kernel u-boot.bin -cpu cortex-a72 \
-smp 4 -m 2G -drive file=raspbian.img,format=raw,index=0 \
-dtb bcm2711-rpi-4-b.dtb -nographic

Tested against FWTS V24.03.00.

Known issues:
- The QEMU rpi4 support is currently limited as it doesn't emulate PCI, USB or ethernet devices!
- The SMP bringup doesn't work on RPi4, but works in QEMU (Possibly cache related).
- PCI on RPI4 isn't working on real hardware since the pcie_brcmstb Linux kernel module doesn't support ACPI yet.

Maximilian Brune (3):
acpi: x86: Move SPCR and DBG2 into common code
acpi: x86: Write FADT in common code
serial: serial_pl01x: Implement .getinfo() for PL01

Patrick Rudolph (30):
acpi: x86: Move MADT to common code
acpi: Fix typo
acpi: Add define for GTDT
arm: acpi: Add generic ACPI methods
acpi: Add fill_madt to acpi_ops
acpi: acpi_table: Bump revisions
acpi: Add ACPITAB for PPTT and GTDT
acpi: acpi_table: Add IORT support
acpi: Move function prototype
acpi_table: Support platforms with unusable RSDT
efi_loader: Allocate and write ACPI tables
acpi: Add processor device
drivers: usb: Add generic XHCI
drivers: ata: Rename ahci_mvebu drivers/cpu: Add generic armv8 cpu driver
arm: gic-v3-its: Rename objects
arm: gic-v3-its: Implement of_xlate
arm: lib: Add GICV2 driver
drivers: misc: irq-uclass: Update irq_get_by_index drivers/arm: Implement acpi_fill_madt
common: Enable BLOBLIST_TABLES on arm
board: emulation: Add QEMU sbsa support
arm: mach-bcm283x: Map the ARM local MMIO as well
arm: bcm283x: Generate ACPI tables
arm: cpu: Add ACPI parking protocol support
armv8: cpu: Enable ACPI parking protocol
arm: mach-bcm283x: Add ARMV8_MULTIENTRY support
arm: mach-bcm283x: Enable ARMV8_MULTIENTRY
bloblist: Fix use of uninitialized variable
configs: Add RPI4 ACPI defconfig

Simon Glass (2):
arm: mach-bcm283x: Bring in some header files from tianocore
board: raspberrypi: Add ASL files from tianocore

 MAINTAINERS                                   |   2 +-
 arch/arm/Kconfig                              |   9 +
 arch/arm/cpu/armv8/Makefile                   |   1 +
 arch/arm/cpu/armv8/acpi_park_v8.S             | 113 ++++
 arch/arm/cpu/armv8/start.S                    |  12 +
 arch/arm/dts/qemu-sbsa.dts                    |  49 ++
 arch/arm/include/asm/acpi_table.h             | 147 +++++
 arch/arm/include/asm/arch-qemu-sbsa/boot0.h   |  33 +
 arch/arm/lib/Makefile                         |   2 +
 arch/arm/lib/acpi_table.c                     | 276 ++++++++
 arch/arm/lib/gic-v2.c                         |  89 +++
 arch/arm/lib/gic-v3-its.c                     | 118 +++-
 arch/arm/mach-bcm283x/Kconfig                 |  18 +-
 arch/arm/mach-bcm283x/Makefile                |   4 +
 arch/arm/mach-bcm283x/bcm2711_acpi.c          | 128 ++++
 .../mach-bcm283x/include/mach/acpi/bcm2711.h  | 152 +++++
 .../mach-bcm283x/include/mach/acpi/bcm2836.h  | 127 ++++
 .../include/mach/acpi/bcm2836_gpio.h          |  19 +
 .../include/mach/acpi/bcm2836_gpu.h           |  47 ++
 .../include/mach/acpi/bcm2836_pwm.h           |  33 +
 .../include/mach/acpi/bcm2836_sdhost.h        |  18 +
 .../include/mach/acpi/bcm2836_sdio.h          |  21 +
 arch/arm/mach-bcm283x/init.c                  |  12 +-
 arch/arm/mach-qemu/Kconfig                    |  36 +-
 arch/sandbox/dts/test.dts                     |   3 +
 arch/sandbox/lib/Makefile                     |   9 +-
 arch/sandbox/lib/acpi_table.c                 |  11 +
 arch/x86/cpu/apollolake/acpi.c                |  20 +-
 arch/x86/cpu/baytrail/acpi.c                  |  17 +-
 arch/x86/cpu/intel_common/acpi.c              |  22 +-
 arch/x86/cpu/quark/acpi.c                     |  19 +-
 arch/x86/cpu/tangier/acpi.c                   |  33 +-
 arch/x86/include/asm/acpi_table.h             |  28 +-
 arch/x86/lib/acpi_table.c                     | 245 +------
 board/emulation/qemu-arm/MAINTAINERS          |   2 +
 board/emulation/qemu-sbsa/Kconfig             |  58 ++
 board/emulation/qemu-sbsa/Makefile            |   8 +
 board/emulation/qemu-sbsa/acpi.c              | 197 ++++++
 board/emulation/qemu-sbsa/dsdt.asl            | 483 ++++++++++++++
 board/emulation/qemu-sbsa/lowlevel_init.S     |  22 +
 board/emulation/qemu-sbsa/qemu-sbsa.c         | 602 ++++++++++++++++++
 board/emulation/qemu-sbsa/qemu-sbsa.env       |  14 +
 board/emulation/qemu-sbsa/qemu-sbsa.h         |  38 ++
 board/emulation/qemu-sbsa/smc.c               |  72 +++
 board/raspberrypi/rpi/.gitignore              |   3 +
 board/raspberrypi/rpi/Makefile                |   2 +
 board/raspberrypi/rpi/acpitables.h            |  90 +++
 board/raspberrypi/rpi/dsdt.asl                | 290 +++++++++
 board/raspberrypi/rpi/emmc.asl                | 136 ++++
 board/raspberrypi/rpi/gpudevs.asl             | 372 +++++++++++
 board/raspberrypi/rpi/pci.asl                 | 177 +++++
 board/raspberrypi/rpi/pep.asl                 |  90 +++
 board/raspberrypi/rpi/rhpx.asl                | 195 ++++++
 board/raspberrypi/rpi/rpi.c                   | 183 ++++++
 board/raspberrypi/rpi/sdhc.asl                | 111 ++++
 board/raspberrypi/rpi/uart.asl                | 208 ++++++
 boot/bootflow.c                               |   8 +-
 common/Kconfig                                |   1 +
 common/bloblist.c                             |   2 +-
 configs/clearfog_defconfig                    |   2 +-
 configs/clearfog_gt_8k_defconfig              |   2 +-
 configs/clearfog_sata_defconfig               |   2 +-
 configs/clearfog_spi_defconfig                |   2 +-
 configs/db-88f6820-gp_defconfig               |   2 +-
 configs/ds116_defconfig                       |   2 +-
 configs/helios4_defconfig                     |   2 +-
 configs/mvebu_crb_cn9130_defconfig            |   2 +-
 configs/mvebu_db-88f3720_defconfig            |   2 +-
 configs/mvebu_db_armada8k_defconfig           |   2 +-
 configs/mvebu_db_cn9130_defconfig             |   2 +-
 configs/mvebu_espressobin-88f3720_defconfig   |   2 +-
 .../mvebu_espressobin_ultra-88f3720_defconfig |   2 +-
 configs/mvebu_mcbin-88f8040_defconfig         |   2 +-
 configs/mvebu_puzzle-m801-88f8040_defconfig   |   2 +-
 configs/n2350_defconfig                       |   2 +-
 configs/octeon_nic23_defconfig                |   2 +-
 configs/qemu-arm-sbsa_defconfig               |  10 +
 configs/rpi_4_acpi_defconfig                  |  70 ++
 configs/turris_omnia_defconfig                |   2 +-
 doc/board/emulation/index.rst                 |   1 +
 doc/board/emulation/qemu-sbsa.rst             |  98 +++
 doc/develop/driver-model/virtio.rst           |   1 +
 drivers/ata/Kconfig                           |  12 +-
 drivers/ata/Makefile                          |   2 +-
 drivers/ata/{ahci_mvebu.c => ahci_generic.c}  |  17 +-
 drivers/core/acpi.c                           |  16 +
 drivers/cpu/Kconfig                           |   7 +
 drivers/cpu/Makefile                          |   2 +
 drivers/cpu/armv8_cpu.c                       | 151 +++++
 drivers/cpu/armv8_cpu.h                       |  31 +
 drivers/cpu/bcm283x_cpu.c                     | 218 +++++++
 drivers/misc/irq-uclass.c                     |  66 +-
 drivers/pci/pcie_brcmstb.c                    | 101 +--
 drivers/serial/serial_pl01x.c                 |  24 +
 drivers/usb/host/Kconfig                      |   8 +
 drivers/usb/host/Makefile                     |   1 +
 drivers/usb/host/xhci-generic.c               |  77 +++
 include/acpi/acpi_table.h                     | 324 +++++++++-
 include/acpi/acpigen.h                        |  12 +
 include/bloblist.h                            |   1 +
 include/configs/qemu-sbsa.h                   | 104 +++
 include/dm/acpi.h                             |  26 +
 include/irq.h                                 |  14 +
 include/serial.h                              |   1 +
 lib/Kconfig                                   |  31 +-
 lib/acpi/acpi_table.c                         | 564 +++++++++++++++-
 lib/acpi/acpigen.c                            |  11 +
 lib/efi_loader/efi_acpi.c                     |  80 ++-
 test/dm/acpi.c                                |  43 ++
 test/dm/irq.c                                 |  15 +
 test/py/tests/test_event_dump.py              |   1 +
 111 files changed, 6871 insertions(+), 542 deletions(-)
 create mode 100644 arch/arm/cpu/armv8/acpi_park_v8.S
 create mode 100644 arch/arm/dts/qemu-sbsa.dts
 create mode 100644 arch/arm/include/asm/arch-qemu-sbsa/boot0.h
 create mode 100644 arch/arm/lib/acpi_table.c
 create mode 100644 arch/arm/lib/gic-v2.c
 create mode 100644 arch/arm/mach-bcm283x/bcm2711_acpi.c
 create mode 100644 arch/arm/mach-bcm283x/include/mach/acpi/bcm2711.h
 create mode 100644 arch/arm/mach-bcm283x/include/mach/acpi/bcm2836.h
 create mode 100644 arch/arm/mach-bcm283x/include/mach/acpi/bcm2836_gpio.h
 create mode 100644 arch/arm/mach-bcm283x/include/mach/acpi/bcm2836_gpu.h
 create mode 100644 arch/arm/mach-bcm283x/include/mach/acpi/bcm2836_pwm.h
 create mode 100644 arch/arm/mach-bcm283x/include/mach/acpi/bcm2836_sdhost.h
 create mode 100644 arch/arm/mach-bcm283x/include/mach/acpi/bcm2836_sdio.h
 create mode 100644 arch/sandbox/lib/acpi_table.c
 create mode 100644 board/emulation/qemu-sbsa/Kconfig
 create mode 100644 board/emulation/qemu-sbsa/Makefile
 create mode 100644 board/emulation/qemu-sbsa/acpi.c
 create mode 100644 board/emulation/qemu-sbsa/dsdt.asl
 create mode 100644 board/emulation/qemu-sbsa/lowlevel_init.S
 create mode 100644 board/emulation/qemu-sbsa/qemu-sbsa.c
 create mode 100644 board/emulation/qemu-sbsa/qemu-sbsa.env
 create mode 100644 board/emulation/qemu-sbsa/qemu-sbsa.h
 create mode 100644 board/emulation/qemu-sbsa/smc.c
 create mode 100644 board/raspberrypi/rpi/.gitignore
 create mode 100644 board/raspberrypi/rpi/acpitables.h
 create mode 100644 board/raspberrypi/rpi/dsdt.asl
 create mode 100644 board/raspberrypi/rpi/emmc.asl
 create mode 100644 board/raspberrypi/rpi/gpudevs.asl
 create mode 100644 board/raspberrypi/rpi/pci.asl
 create mode 100644 board/raspberrypi/rpi/pep.asl
 create mode 100644 board/raspberrypi/rpi/rhpx.asl
 create mode 100644 board/raspberrypi/rpi/sdhc.asl
 create mode 100644 board/raspberrypi/rpi/uart.asl
 create mode 100644 configs/qemu-arm-sbsa_defconfig
 create mode 100644 configs/rpi_4_acpi_defconfig
 create mode 100644 doc/board/emulation/qemu-sbsa.rst
 rename drivers/ata/{ahci_mvebu.c => ahci_generic.c} (71%)
 create mode 100644 drivers/cpu/armv8_cpu.c
 create mode 100644 drivers/cpu/armv8_cpu.h
 create mode 100644 drivers/cpu/bcm283x_cpu.c
 create mode 100644 drivers/usb/host/xhci-generic.c
 create mode 100644 include/configs/qemu-sbsa.h
Signature · 1 line
2.46.0
#1 lore raw

PATCH v4 1/35 acpi: x86: Move SPCR and DBG2 into common code

From: Maximilian Brune <[email protected]>

This moves the SPCR and DBG2 table generation into common code, so that they can be used by architectures other than x86.

---
Changelog v2:
- Do not add new features, just move code and make it compile on 64bit.

---
 arch/x86/include/asm/acpi_table.h |  11 --
 arch/x86/lib/acpi_table.c         | 174 ----------------------------
 include/acpi/acpi_table.h         |  11 ++
 lib/acpi/acpi_table.c             | 184 ++++++++++++++++++++++++++++++
 4 files changed, 195 insertions(+), 185 deletions(-)
arch/x86/include/asm/acpi_table.h +0 -11
index 57e41654ce..e617524617 100644
@@ -45,17 +45,6 @@ int acpi_create_mcfg_mmconfig(struct acpi_mcfg_mmconfig *mmconfig, u32 base,
  */
 int acpi_write_hpet(struct acpi_ctx *ctx);
 
-/**
- * acpi_write_dbg2_pci_uart() - Write out a DBG2 table
- *
- * @ctx: Current ACPI context
- * @dev: Debug UART device to describe
- * @access_size: Access size for UART (e.g. ACPI_ACCESS_SIZE_DWORD_ACCESS)
- * Return: 0 if OK, -ve on error
- */
-int acpi_write_dbg2_pci_uart(struct acpi_ctx *ctx, struct udevice *dev,
-			     uint access_size);
-
 /**
  * acpi_create_gnvs() - Create a GNVS (Global Non Volatile Storage) table
  *
arch/x86/lib/acpi_table.c +0 -174

186 lines not on this page · raw message

include/acpi/acpi_table.h +11 -0
index 15fd61a51d..a372435492 100644
@@ -913,6 +913,17 @@ static inline int acpi_add_fadt(struct acpi_ctx *ctx, struct acpi_fadt *fadt)
 	return 0;
 }
 
+/**
+ * acpi_write_dbg2_pci_uart() - Write out a DBG2 table
+ *
+ * @ctx: Current ACPI context
+ * @dev: Debug UART device to describe
+ * @access_size: Access size for UART (e.g. ACPI_ACCESS_SIZE_DWORD_ACCESS)
+ * Return: 0 if OK, -ve on error
+ */
+int acpi_write_dbg2_pci_uart(struct acpi_ctx *ctx, struct udevice *dev,
+			     uint access_size);
+
 /**
  * acpi_write_rsdp() - Write out an RSDP indicating where the ACPI tables are
  *
lib/acpi/acpi_table.c +184 -0

195 lines not on this page · raw message

Signature · 1 line
2.46.0
#2 lore raw

PATCH v4 2/35 acpi: x86: Write FADT in common code

In reply to Patrick Rudolph

From: Maximilian Brune <[email protected]>

Write the FADT in common code since it's used on all architectures. Since the FADT is mandatory all SoCs or mainboards must implement the introduced function acpi_fill_fadt() and properly update the FADT.

---
Changelog v4:
- Drop __weak attribute

---
 arch/sandbox/lib/acpi_table.c     |  6 +++++
 arch/x86/cpu/apollolake/acpi.c    | 20 ++++------------
 arch/x86/cpu/baytrail/acpi.c      | 17 +-------------
 arch/x86/cpu/quark/acpi.c         | 19 +---------------
 arch/x86/cpu/tangier/acpi.c       | 25 ++------------------
 arch/x86/include/asm/acpi_table.h | 12 ----------
 arch/x86/lib/acpi_table.c         | 23 -------------------
 include/acpi/acpi_table.h         |  9 ++++++++
 lib/acpi/acpi_table.c             | 38 +++++++++++++++++++++++++++++++
 9 files changed, 61 insertions(+), 108 deletions(-)
 create mode 100644 arch/sandbox/lib/acpi_table.c
arch/sandbox/lib/acpi_table.c new file +6 -0
new file mode 100644
index 0000000000..10b7ce441a
@@ -0,0 +1,6 @@
+// SPDX-License-Identifier: GPL-2.0+
+#include <acpi/acpi_table.h>
+
+void acpi_fill_fadt(struct acpi_fadt *fadt)
+{
+}
\ No newline at end of file
arch/x86/cpu/apollolake/acpi.c +4 -16
index 76230aea83..93040e7bb3 100644
@@ -128,8 +128,10 @@ int arch_madt_sci_irq_polarity(int sci)
 	return MP_IRQ_POLARITY_LOW;
 }
 
-void fill_fadt(struct acpi_fadt *fadt)
+void acpi_fill_fadt(struct acpi_fadt *fadt)
 {
+	intel_acpi_fill_fadt(fadt);
+
 	fadt->pm_tmr_blk = IOMAP_ACPI_BASE + PM1_TMR;
 
 	fadt->p_lvl2_lat = ACPI_FADT_C2_NOT_SUPPORTED;
@@ -143,23 +145,9 @@ void fill_fadt(struct acpi_fadt *fadt)
 	fadt->x_pm_tmr_blk.space_id = 1;
 	fadt->x_pm_tmr_blk.bit_width = fadt->pm_tmr_len * 8;
 	fadt->x_pm_tmr_blk.addrl = IOMAP_ACPI_BASE + PM1_TMR;
-}
-
-static int apl_write_fadt(struct acpi_ctx *ctx, const struct acpi_writer *entry)
-{
-	struct acpi_table_header *header;
-	struct acpi_fadt *fadt;
-
-	fadt = ctx->current;
-	acpi_fadt_common(fadt, ctx->facs, ctx->dsdt);
-	intel_acpi_fill_fadt(fadt);
-	fill_fadt(fadt);
-	header = &fadt->header;
-	header->checksum = table_compute_checksum(fadt, header->length);
 
-	return acpi_add_fadt(ctx, fadt);
+	fadt->preferred_pm_profile = ACPI_PM_MOBILE;
 }
-ACPI_WRITER(5fadt, "FADT", apl_write_fadt, 0);
 
 int apl_acpi_fill_dmar(struct acpi_ctx *ctx)
 {
arch/x86/cpu/baytrail/acpi.c +1 -16
index 7821964f1f..7e1c2de3d3 100644
@@ -15,20 +15,13 @@
 #include <asm/arch/iomap.h>
 #include <dm/uclass-internal.h>
 
-static int baytrail_write_fadt(struct acpi_ctx *ctx,
-			       const struct acpi_writer *entry)
+void acpi_fill_fadt(struct acpi_fadt *fadt)
 {
 	struct acpi_table_header *header;
-	struct acpi_fadt *fadt;
 
-	fadt = ctx->current;
 	header = &fadt->header;
 	u16 pmbase = ACPI_BASE_ADDRESS;
 
-	memset(fadt, '\0', sizeof(struct acpi_fadt));
-
-	acpi_fill_header(header, "FACP");
-	header->length = sizeof(struct acpi_fadt);
 	header->revision = 4;
 
 	fadt->preferred_pm_profile = ACPI_PM_MOBILE;
@@ -77,9 +70,6 @@ static int baytrail_write_fadt(struct acpi_ctx *ctx,
 	fadt->reset_reg.addrh = 0;
 	fadt->reset_value = SYS_RST | RST_CPU | FULL_RST;
 
-	fadt->x_firmware_ctrl = map_to_sysmem(ctx->facs);
-	fadt->x_dsdt = map_to_sysmem(ctx->dsdt);
-
 	fadt->x_pm1a_evt_blk.space_id = ACPI_ADDRESS_SPACE_IO;
 	fadt->x_pm1a_evt_blk.bit_width = fadt->pm1_evt_len * 8;
 	fadt->x_pm1a_evt_blk.bit_offset = 0;
@@ -135,12 +125,7 @@ static int baytrail_write_fadt(struct acpi_ctx *ctx,
 	fadt->x_gpe1_blk.access_size = 0;
 	fadt->x_gpe1_blk.addrl = 0x0;
 	fadt->x_gpe1_blk.addrh = 0x0;
-
-	header->checksum = table_compute_checksum(fadt, header->length);
-
-	return acpi_add_fadt(ctx, fadt);
 }
-ACPI_WRITER(5fadt, "FADT", baytrail_write_fadt, 0);
 
 int acpi_create_gnvs(struct acpi_global_nvs *gnvs)
 {
arch/x86/cpu/quark/acpi.c +1 -18
index 80e94600fc..0fe5f2bafb 100644
@@ -11,23 +11,14 @@
 #include <asm/arch/iomap.h>
 #include <linux/string.h>
 
-static int quark_write_fadt(struct acpi_ctx *ctx,
-			    const struct acpi_writer *entry)
+void acpi_fill_fadt(struct acpi_fadt *fadt)
 {
 	u16 pmbase = ACPI_PM1_BASE_ADDRESS;
 	struct acpi_table_header *header;
-	struct acpi_fadt *fadt;
 
-	fadt = ctx->current;
 	header = &fadt->header;
-
-	memset(fadt, '\0', sizeof(struct acpi_fadt));
-
-	acpi_fill_header(header, "FACP");
-	header->length = sizeof(struct acpi_fadt);
 	header->revision = 4;
 
-	fadt->preferred_pm_profile = ACPI_PM_UNSPECIFIED;
 	fadt->sci_int = 9;
 	fadt->smi_cmd = 0;
 	fadt->acpi_enable = 0;
@@ -73,9 +64,6 @@ static int quark_write_fadt(struct acpi_ctx *ctx,
 	fadt->reset_reg.addrh = 0;
 	fadt->reset_value = SYS_RST | RST_CPU | FULL_RST;
 
-	fadt->x_firmware_ctrl = map_to_sysmem(ctx->facs);
-	fadt->x_dsdt = map_to_sysmem(ctx->dsdt);
-
 	fadt->x_pm1a_evt_blk.space_id = ACPI_ADDRESS_SPACE_IO;
 	fadt->x_pm1a_evt_blk.bit_width = fadt->pm1_evt_len * 8;
 	fadt->x_pm1a_evt_blk.bit_offset = 0;
@@ -131,12 +119,7 @@ static int quark_write_fadt(struct acpi_ctx *ctx,
 	fadt->x_gpe1_blk.access_size = 0;
 	fadt->x_gpe1_blk.addrl = 0x0;
 	fadt->x_gpe1_blk.addrh = 0x0;
-
-	header->checksum = table_compute_checksum(fadt, header->length);
-
-	return acpi_add_fadt(ctx, fadt);
 }
-ACPI_WRITER(5fadt, "FADT", quark_write_fadt, 0);
 
 int acpi_create_gnvs(struct acpi_global_nvs *gnvs)
 {
arch/x86/cpu/tangier/acpi.c +2 -23
index d4d0ef6f85..1c73a9dbfe 100644
@@ -16,21 +16,8 @@
 #include <asm/arch/iomap.h>
 #include <dm/uclass-internal.h>
 
-static int tangier_write_fadt(struct acpi_ctx *ctx,
-			      const struct acpi_writer *entry)
+void acpi_fill_fadt(struct acpi_fadt *fadt)
 {
-	struct acpi_table_header *header;
-	struct acpi_fadt *fadt;
-
-	fadt = ctx->current;
-	header = &fadt->header;
-
-	memset(fadt, '\0', sizeof(struct acpi_fadt));
-
-	acpi_fill_header(header, "FACP");
-	header->length = sizeof(struct acpi_fadt);
-	header->revision = 6;
-
 	fadt->preferred_pm_profile = ACPI_PM_UNSPECIFIED;
 
 	fadt->iapc_boot_arch = ACPI_FADT_VGA_NOT_PRESENT |
@@ -40,17 +27,9 @@ static int tangier_write_fadt(struct acpi_ctx *ctx,
 		ACPI_FADT_POWER_BUTTON | ACPI_FADT_SLEEP_BUTTON |
 		ACPI_FADT_SEALED_CASE | ACPI_FADT_HEADLESS |
 		ACPI_FADT_HW_REDUCED_ACPI;
-
+	fadt->header.revision = 6;
 	fadt->minor_revision = 2;
-
-	fadt->x_firmware_ctrl = map_to_sysmem(ctx->facs);
-	fadt->x_dsdt = map_to_sysmem(ctx->dsdt);
-
-	header->checksum = table_compute_checksum(fadt, header->length);
-
-	return acpi_add_fadt(ctx, fadt);
 }
-ACPI_WRITER(5fadt, "FADT", tangier_write_fadt, 0);
 
 u32 acpi_fill_madt(u32 current)
 {
arch/x86/include/asm/acpi_table.h +0 -12
index e617524617..3988898f66 100644
@@ -168,18 +168,6 @@ int acpi_create_dmar_ds_ioapic(struct acpi_ctx *ctx, uint enumeration_id,
 int acpi_create_dmar_ds_msi_hpet(struct acpi_ctx *ctx, uint enumeration_id,
 				 pci_dev_t bdf);
 
-/**
- * acpi_fadt_common() - Handle common parts of filling out an FADT
- *
- * This sets up the Fixed ACPI Description Table
- *
- * @fadt: Pointer to place to put FADT
- * @facs: Pointer to the FACS
- * @dsdt: Pointer to the DSDT
- */
-void acpi_fadt_common(struct acpi_fadt *fadt, struct acpi_facs *facs,
-		      void *dsdt);
-
 /**
  * intel_acpi_fill_fadt() - Set up the contents of the FADT
  *
arch/x86/lib/acpi_table.c +0 -23
index 08fd1e54ce..ff02ce80d1 100644
@@ -381,29 +381,6 @@ int acpi_write_hpet(struct acpi_ctx *ctx)
 	return 0;
 }
 
-void acpi_fadt_common(struct acpi_fadt *fadt, struct acpi_facs *facs,
-		      void *dsdt)
-{
-	struct acpi_table_header *header = &fadt->header;
-
-	memset((void *)fadt, '\0', sizeof(struct acpi_fadt));
-
-	acpi_fill_header(header, "FACP");
-	header->length = sizeof(struct acpi_fadt);
-	header->revision = 4;
-	memcpy(header->oem_id, OEM_ID, 6);
-	memcpy(header->oem_table_id, OEM_TABLE_ID, 8);
-	memcpy(header->creator_id, ASLC_ID, 4);
-
-	fadt->x_firmware_ctrl = map_to_sysmem(facs);
-	fadt->x_dsdt = map_to_sysmem(dsdt);
-
-	fadt->preferred_pm_profile = ACPI_PM_MOBILE;
-
-	/* Use ACPI 3.0 revision */
-	fadt->header.revision = 4;
-}
-
 void acpi_create_dmar_drhd(struct acpi_ctx *ctx, uint flags, uint segment,
 			   u64 bar)
 {
include/acpi/acpi_table.h +9 -0
index a372435492..19cf0fb43c 100644
@@ -954,6 +954,15 @@ void acpi_fill_header(struct acpi_table_header *header, char *signature);
  */
 int acpi_fill_csrt(struct acpi_ctx *ctx);
 
+/**
+ * acpi_fill_fadt() - Fill out the body of the FADT
+ *
+ * Must be implemented in SoC specific code or in mainboard code.
+ *
+ * @fadt: Pointer to FADT to update
+ */
+void acpi_fill_fadt(struct acpi_fadt *fadt);
+
 /**
  * acpi_get_rsdp_addr() - get ACPI RSDP table address
  *
lib/acpi/acpi_table.c +38 -0
index c9ddcca8cb..9eb0b507a0 100644
@@ -202,6 +202,44 @@ int acpi_add_table(struct acpi_ctx *ctx, void *table)
 	return 0;
 }
 
+int acpi_write_fadt(struct acpi_ctx *ctx, const struct acpi_writer *entry)
+{
+	struct acpi_table_header *header;
+	struct acpi_fadt *fadt;
+
+	fadt = ctx->current;
+	header = &fadt->header;
+
+	memset((void *)fadt, '\0', sizeof(struct acpi_fadt));
+
+	acpi_fill_header(header, "FACP");
+	header->length = sizeof(struct acpi_fadt);
+	header->revision = acpi_get_table_revision(ACPITAB_FADT);
+	memcpy(header->oem_id, OEM_ID, 6);
+	memcpy(header->oem_table_id, OEM_TABLE_ID, 8);
+	memcpy(header->creator_id, ASLC_ID, 4);
+	header->creator_revision = 1;
+
+	fadt->x_firmware_ctrl = map_to_sysmem(ctx->facs);
+	fadt->x_dsdt = map_to_sysmem(ctx->dsdt);
+
+	if (fadt->x_firmware_ctrl < 0x100000000ULL)
+		fadt->firmware_ctrl = fadt->x_firmware_ctrl;
+
+	if (fadt->x_dsdt < 0x100000000ULL)
+		fadt->dsdt = fadt->x_dsdt;
+
+	fadt->preferred_pm_profile = ACPI_PM_UNSPECIFIED;
+
+	acpi_fill_fadt(fadt);
+
+	header->checksum = table_compute_checksum(fadt, header->length);
+
+	return acpi_add_fadt(ctx, fadt);
+}
+
+ACPI_WRITER(5fadt, "FADT", acpi_write_fadt, 0);
+
 void acpi_create_dbg2(struct acpi_dbg2_header *dbg2,
 		      int port_type, int port_subtype,
 		      struct acpi_gen_regaddr *address, u32 address_size,
Signature · 1 line
2.46.0
Reviewed-by on v4 2/35
#3 lore raw

Re: [PATCH v4 02/35] acpi: x86: Write FADT in common code

Hi Patrick,

Quoted 14 lines · Patrick Rudolph

From: Maximilian Brune <[email protected]>

Write the FADT in common code since it's used on all architectures. Since the FADT is mandatory all SoCs or mainboards must implement the introduced function acpi_fill_fadt() and properly update the FADT.

---
Changelog v4:
- Drop __weak attribute

Quoted 13 lines
---
 arch/sandbox/lib/acpi_table.c     |  6 +++++
 arch/x86/cpu/apollolake/acpi.c    | 20 ++++------------
 arch/x86/cpu/baytrail/acpi.c      | 17 +-------------
 arch/x86/cpu/quark/acpi.c         | 19 +---------------
 arch/x86/cpu/tangier/acpi.c       | 25 ++------------------
 arch/x86/include/asm/acpi_table.h | 12 ----------
 arch/x86/lib/acpi_table.c         | 23 -------------------
 include/acpi/acpi_table.h         |  9 ++++++++
 lib/acpi/acpi_table.c             | 38 +++++++++++++++++++++++++++++++
 9 files changed, 61 insertions(+), 108 deletions(-)
 create mode 100644 arch/sandbox/lib/acpi_table.c

I was really expecting each file to have its own ACPI_WRITER() decl and then call into common code for the common part. But I suppose this way around is OK.

Regards,
Simon

#4 lore raw

PATCH v4 3/35 acpi: x86: Move MADT to common code

In reply to Patrick Rudolph

Write MADT in common code and let the SoC fill out the body by calling acpi_fill_madt() which must be implemented at SoC level.

---
Changelog v3:
- Pass ACPI context to acpi_fill_madt

---
 arch/sandbox/lib/Makefile         |  9 +++---
 arch/sandbox/lib/acpi_table.c     |  7 ++++-
 arch/x86/cpu/intel_common/acpi.c  | 22 +++++++++-----
 arch/x86/cpu/tangier/acpi.c       |  8 +++++-
 arch/x86/include/asm/acpi_table.h |  3 +-
 arch/x86/lib/acpi_table.c         | 48 +++++++------------------------
 include/acpi/acpi_table.h         | 11 +++++++
 lib/acpi/acpi_table.c             | 31 ++++++++++++++++++++
 8 files changed, 86 insertions(+), 53 deletions(-)
arch/sandbox/lib/Makefile +5 -4
index d7d15a50bb..5d7beb250c 100644
@@ -5,7 +5,8 @@
 # (C) Copyright 2002-2006
 # Wolfgang Denk, DENX Software Engineering, [email protected].
 
-obj-y			+= fdt_fixup.o interrupts.o
-obj-$(CONFIG_PCI)	+= pci_io.o
-obj-$(CONFIG_CMD_BOOTM) += bootm.o
-obj-$(CONFIG_CMD_BOOTZ) += bootm.o
+obj-y				+= fdt_fixup.o interrupts.o
+obj-$(CONFIG_PCI)		+= pci_io.o
+obj-$(CONFIG_CMD_BOOTM)		+= bootm.o
+obj-$(CONFIG_CMD_BOOTZ)		+= bootm.o
+obj-$(CONFIG_$(SPL_)ACPIGEN)	+= acpi_table.o
arch/sandbox/lib/acpi_table.c +6 -1
index 10b7ce441a..90bb96d1e3 100644
@@ -3,4 +3,9 @@
 
 void acpi_fill_fadt(struct acpi_fadt *fadt)
 {
-}
\ No newline at end of file
+}
+
+void *acpi_fill_madt(struct acpi_madt *madt, struct acpi_ctx *ctx)
+{
+	return ctx->current;
+}
arch/x86/cpu/intel_common/acpi.c +15 -7
index 29676b4abf..982149b394 100644
@@ -19,6 +19,7 @@
 #include <asm/global_data.h>
 #include <asm/intel_acpi.h>
 #include <asm/ioapic.h>
+#include <asm/lapic.h>
 #include <asm/mpspec.h>
 #include <asm/smm.h>
 #include <asm/turbo.h>
@@ -80,33 +81,40 @@ static int acpi_sci_irq(void)
 	return sci_irq;
 }
 
-static unsigned long acpi_madt_irq_overrides(unsigned long current)
+static void *acpi_madt_irq_overrides(void *current)
 {
 	int sci = acpi_sci_irq();
 	u16 flags = MP_IRQ_TRIGGER_LEVEL;
 
-	if (sci < 0)
-		return log_msg_ret("sci irq", sci);
+	if (sci < 0) {
+		log_err("sci irq %d", sci);
+		return current;
+	}
 
 	/* INT_SRC_OVR */
-	current += acpi_create_madt_irqoverride((void *)current, 0, 0, 2, 0);
+	current += acpi_create_madt_irqoverride(current, 0, 0, 2, 0);
 
 	flags |= arch_madt_sci_irq_polarity(sci);
 
 	/* SCI */
 	current +=
-	    acpi_create_madt_irqoverride((void *)current, 0, sci, sci, flags);
+	    acpi_create_madt_irqoverride(current, 0, sci, sci, flags);
 
 	return current;
 }
 
-u32 acpi_fill_madt(u32 current)
+void *acpi_fill_madt(struct acpi_madt *madt, struct acpi_ctx *ctx)
 {
+	void *current = ctx->current;
+
+	madt->lapic_addr = LAPIC_DEFAULT_BASE;
+	madt->flags = ACPI_MADT_PCAT_COMPAT;
+
 	/* Local APICs */
 	current += acpi_create_madt_lapics(current);
 
 	/* IOAPIC */
-	current += acpi_create_madt_ioapic((void *)current, 2, IO_APIC_ADDR, 0);
+	current += acpi_create_madt_ioapic(current, 2, IO_APIC_ADDR, 0);
 
 	return acpi_madt_irq_overrides(current);
 }
arch/x86/cpu/tangier/acpi.c +7 -1
index 1c73a9dbfe..3d11787861 100644
@@ -10,6 +10,7 @@
 #include <mapmem.h>
 #include <acpi/acpi_table.h>
 #include <asm/ioapic.h>
+#include <asm/lapic.h>
 #include <asm/mpspec.h>
 #include <asm/tables.h>
 #include <asm/arch/global_nvs.h>
@@ -31,8 +32,13 @@ void acpi_fill_fadt(struct acpi_fadt *fadt)
 	fadt->minor_revision = 2;
 }
 
-u32 acpi_fill_madt(u32 current)
+void *acpi_fill_madt(struct acpi_madt *madt, struct acpi_ctx *ctx)
 {
+	void *current = ctx->current;
+
+	madt->lapic_addr = LAPIC_DEFAULT_BASE;
+	madt->flags = ACPI_MADT_PCAT_COMPAT;
+
 	current += acpi_create_madt_lapics(current);
 
 	current += acpi_create_madt_ioapic((struct acpi_madt_ioapic *)current,
arch/x86/include/asm/acpi_table.h +1 -2
index 3988898f66..3254bbc380 100644
@@ -24,14 +24,13 @@ struct acpi_table_header;
 
 /* These can be used by the target port */
 
-int acpi_create_madt_lapics(u32 current);
+int acpi_create_madt_lapics(void *current);
 int acpi_create_madt_ioapic(struct acpi_madt_ioapic *ioapic, u8 id,
 			    u32 addr, u32 gsi_base);
 int acpi_create_madt_irqoverride(struct acpi_madt_irqoverride *irqoverride,
 				 u8 bus, u8 source, u32 gsirq, u16 flags);
 int acpi_create_madt_lapic_nmi(struct acpi_madt_lapic_nmi *lapic_nmi,
 			       u8 cpu, u16 flags, u8 lint);
-u32 acpi_fill_madt(u32 current);
 int acpi_create_mcfg_mmconfig(struct acpi_mcfg_mmconfig *mmconfig, u32 base,
 			      u16 seg_nr, u8 start, u8 end);
 
arch/x86/lib/acpi_table.c +10 -38

79 lines not on this page · raw message

include/acpi/acpi_table.h +11 -0
index 19cf0fb43c..c356df72ba 100644
@@ -963,6 +963,17 @@ int acpi_fill_csrt(struct acpi_ctx *ctx);
  */
 void acpi_fill_fadt(struct acpi_fadt *fadt);
 
+/**
+ * acpi_fill_madt() - Fill out the body of the MADT
+ *
+ * Must be implemented in SoC specific code.
+ *
+ * @madt: The MADT to update
+ * @ctx: ACPI context to write MADT sub-tables to
+ * @return Pointer to the end of tables, where the next tables can be written
+ */
+void *acpi_fill_madt(struct acpi_madt *madt, struct acpi_ctx *ctx);
+
 /**
  * acpi_get_rsdp_addr() - get ACPI RSDP table address
  *
lib/acpi/acpi_table.c +31 -0
index 9eb0b507a0..639d78125f 100644
@@ -240,6 +240,37 @@ int acpi_write_fadt(struct acpi_ctx *ctx, const struct acpi_writer *entry)
 
 ACPI_WRITER(5fadt, "FADT", acpi_write_fadt, 0);
 
+int acpi_write_madt(struct acpi_ctx *ctx, const struct acpi_writer *entry)
+{
+	struct acpi_table_header *header;
+	struct acpi_madt *madt;
+	void *current;
+
+	madt = ctx->current;
+
+	memset(madt, '\0', sizeof(struct acpi_madt));
+	header = &madt->header;
+
+	/* Fill out header fields */
+	acpi_fill_header(header, "APIC");
+	header->length = sizeof(struct acpi_madt);
+	header->revision = ACPI_MADT_REV_ACPI_3_0;
+
+	acpi_inc(ctx, sizeof(struct acpi_madt));
+	current = acpi_fill_madt(madt, ctx);
+
+	/* (Re)calculate length and checksum */
+	header->length = (uintptr_t)current - (uintptr_t)madt;
+
+	header->checksum = table_compute_checksum((void *)madt, header->length);
+	acpi_add_table(ctx, madt);
+	ctx->current = (void *)madt + madt->header.length;
+
+	return 0;
+}
+
+ACPI_WRITER(5madt, "MADT", acpi_write_madt, 0);
+
 void acpi_create_dbg2(struct acpi_dbg2_header *dbg2,
 		      int port_type, int port_subtype,
 		      struct acpi_gen_regaddr *address, u32 address_size,
Signature · 1 line
2.46.0
#5 lore raw

PATCH v4 4/35 acpi: Fix typo

In reply to Patrick Rudolph

Rename ACPI tables MADR to MADT.

---
 include/acpi/acpi_table.h | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
include/acpi/acpi_table.h +8 -8
index c356df72ba..a1bdab7305 100644
@@ -386,20 +386,20 @@ struct __packed acpi_madt_lapic_nmi {
 	u8 lint;		/* Local APIC LINT# */
 };
 
-/* flags for acpi_madr_gicc flags word */
+/* flags for acpi_madt_gicc flags word */
 enum {
-	ACPI_MADRF_ENABLED	= BIT(0),
-	ACPI_MADRF_PERF		= BIT(1),
-	ACPI_MADRF_VGIC		= BIT(2),
+	ACPI_MADTF_ENABLED	= BIT(0),
+	ACPI_MADTF_PERF		= BIT(1),
+	ACPI_MADTF_VGIC		= BIT(2),
 };
 
 /**
- * struct __packed acpi_madr_gicc - GIC CPU interface (type 0xb)
+ * struct __packed acpi_madt_gicc - GIC CPU interface (type 0xb)
  *
  * This holds information about the Generic Interrupt Controller (GIC) CPU
  * interface. See ACPI Spec v6.3 section 5.2.12.14
  */
-struct acpi_madr_gicc {
+struct acpi_madt_gicc {
 	u8 type;
 	u8 length;
 	u16 reserved;
@@ -421,12 +421,12 @@ struct acpi_madr_gicc {
 } __packed;
 
 /**
- * struct __packed acpi_madr_gicc - GIC distributor (type 0xc)
+ * struct __packed acpi_madt_gicc - GIC distributor (type 0xc)
  *
  * This holds information about the Generic Interrupt Controller (GIC)
  * Distributor interface. See ACPI Spec v6.3 section 5.2.12.15
  */
-struct acpi_madr_gicd {
+struct acpi_madt_gicd {
 	u8 type;
 	u8 length;
 	u16 reserved;
Signature · 1 line
2.46.0
#6 lore raw

PATCH v4 5/35 serial: serial_pl01x: Implement .getinfo() for PL01

In reply to Patrick Rudolph

From: Maximilian Brune <[email protected]>

When ACPI is enabled on arm it will use the getinfo function to fill the SPCR ACPI table.

---
 boot/bootflow.c               |  8 ++++++--
 drivers/serial/serial_pl01x.c | 24 ++++++++++++++++++++++++
 include/serial.h              |  1 +
 3 files changed, 31 insertions(+), 2 deletions(-)
boot/bootflow.c +6 -2
index 59d77d2385..d8807eb109 100644
@@ -936,11 +936,15 @@ int bootflow_cmdline_auto(struct bootflow *bflow, const char *arg)
 		return ret;
 
 	*buf = '\0';
-	if (!strcmp("earlycon", arg)) {
+	if (!strcmp("earlycon", arg) && info.type == SERIAL_CHIP_16550_COMPATIBLE) {
 		snprintf(buf, sizeof(buf),
 			 "uart8250,mmio32,%#lx,%dn8", info.addr,
 			 info.baudrate);
-	} else if (!strcmp("console", arg)) {
+	} else if (!strcmp("earlycon", arg) && info.type == SERIAL_CHIP_PL01X) {
+		snprintf(buf, sizeof(buf),
+			 "pl011,mmio32,%#lx,%dn8", info.addr,
+			 info.baudrate);
+	} else if (!strcmp("console", arg) && info.type == SERIAL_CHIP_16550_COMPATIBLE) {
 		snprintf(buf, sizeof(buf),
 			 "ttyS0,%dn8", info.baudrate);
 	}
drivers/serial/serial_pl01x.c +24 -0
index 80c35963b8..ab67922d18 100644
@@ -19,6 +19,7 @@
 #include <watchdog.h>
 #include <asm/io.h>
 #include <serial.h>
+#include <spl.h>
 #include <dm/device_compat.h>
 #include <dm/platform_data/serial_pl01x.h>
 #include <linux/compiler.h>
@@ -272,6 +273,28 @@ __weak struct serial_device *default_serial_console(void)
 	return &pl01x_serial_drv;
 }
 #else
+
+static int pl01x_serial_getinfo(struct udevice *dev,
+				struct serial_device_info *info)
+{
+	struct pl01x_serial_plat *plat = dev_get_plat(dev);
+
+	/* save code size */
+	if (!spl_in_proper())
+		return -ENOSYS;
+
+	info->type = SERIAL_CHIP_PL01X;
+	info->addr_space = SERIAL_ADDRESS_SPACE_MEMORY;
+	info->addr = plat->base;
+	info->size = 0x1000;
+	info->reg_width = 4;
+	info->reg_shift = 2;
+	info->reg_offset = 0;
+	info->clock = plat->clock;
+
+	return 0;
+}
+
 int pl01x_serial_setbrg(struct udevice *dev, int baudrate)
 {
 	struct pl01x_serial_plat *plat = dev_get_plat(dev);
@@ -341,6 +364,7 @@ static const struct dm_serial_ops pl01x_serial_ops = {
 	.pending = pl01x_serial_pending,
 	.getc = pl01x_serial_getc,
 	.setbrg = pl01x_serial_setbrg,
+	.getinfo = pl01x_serial_getinfo,
 };
 
 #if CONFIG_IS_ENABLED(OF_REAL)
include/serial.h +1 -0
index d129dc3253..d7a9a8cfb8 100644
@@ -124,6 +124,7 @@ enum serial_stop {
 enum serial_chip_type {
 	SERIAL_CHIP_UNKNOWN = -1,
 	SERIAL_CHIP_16550_COMPATIBLE,
+	SERIAL_CHIP_PL01X,
 };
 
 enum adr_space_type {
Signature · 1 line
2.46.0
#7 lore raw

PATCH v4 6/35 acpi: Add define for GTDT

In reply to Patrick Rudolph

Add the interrupt flag used in ACPI GTDT table as define.

---
 include/acpi/acpi_table.h | 2 ++
 1 file changed, 2 insertions(+)
include/acpi/acpi_table.h +2 -0
index a1bdab7305..c6a3e44a95 100644
@@ -707,6 +707,8 @@ struct acpi_gtdt {
 	u32 virt_el2_flags;
 } __packed;
 
+#define GTDT_FLAG_INT_ACTIVE_LOW	BIT(1)
+
 /**
  * struct acpi_bgrt -  Boot Graphics Resource Table (BGRT)
  *
Signature · 1 line
2.46.0
#8 lore raw

PATCH v4 7/35 arm: acpi: Add generic ACPI methods

In reply to Patrick Rudolph

Add generic ACPI code to generate
- MADT GICC
- MADT GICD
- MADT GICR
- MADT GIC ITS
- PPTT processor
- PPTT cache

as commonly used on arm platforms.

---
Changelog v2:
- Add full comments to exported functions

---
 arch/arm/include/asm/acpi_table.h | 115 ++++++++++++++++++++++++++++++
 arch/arm/lib/Makefile             |   1 +
 arch/arm/lib/acpi_table.c         | 114 +++++++++++++++++++++++++++++
 include/acpi/acpi_table.h         |  34 ++++++++-
 4 files changed, 263 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/lib/acpi_table.c
arch/arm/include/asm/acpi_table.h +115 -0
index e69de29bb2..c65eabe837 100644
@@ -0,0 +1,115 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+
+#ifndef __ASM_ACPI_TABLE_H__
+#define __ASM_ACPI_TABLE_H__
+
+#ifndef __ACPI__
+
+#include <acpi/acpi_table.h>
+
+/**
+ * acpi_write_madt_gicc() - Write out a MADT GICC sub-table
+ *
+ * Write out the GIC CPU Interface sub-table.
+ *
+ * @gicc:             Pointer to place to put the sub-table
+ * @cpu_num:          GIC's CPU Interface Number
+ * @perf_gsiv:        The GSIV used for Performance Monitoring Interrupts
+ * @phys_base:        Address at which the processor can access this
+ *                    GIC CPU Interface
+ * @gicv:             Address of the GIC virtual CPU interface registers
+ * @gich:             Address of the GIC virtual interface control block
+ *                    registers
+ * @vgic_maint_irq:   GSIV for Virtual GIC maintenance interrupt
+ * @gicr_base:        Physical address of the associated Redistributor
+ * @mpidr:            MPIDR as defined by ARM architecture
+ * @efficiency:       Describes the relative power efficiency
+ */
+void acpi_write_madt_gicc(struct acpi_madt_gicc *gicc, uint cpu_num,
+			  uint perf_gsiv, ulong phys_base, ulong gicv,
+			  ulong gich, uint vgic_maint_irq, u64 gicr_base,
+			  ulong mpidr, uint efficiency);
+
+/**
+ * acpi_write_madt_gicd() - Write out a MADT GICD sub-table
+ *
+ * Write out the GIC Distributor sub-table.
+ *
+ * @gicd:            Pointer to place to put the sub-table
+ * @gic_id:          This GIC Distributor's hardware ID
+ * @phys_base:       The 64-bit physical address for this Distributor
+ * @gic_version:     GIC version
+ */
+void acpi_write_madt_gicd(struct acpi_madt_gicd *gicd, uint gic_id,
+			  ulong phys_base, uint gic_version);
+
+/**
+ * acpi_write_madt_gicr() - Write out a MADT GICR sub-table
+ *
+ * Write out the GIC Redistributor sub-table.
+ *
+ * @gicr:                            Pointer to place to put the sub-table
+ * @discovery_range_base_address:    Physical address of a page range
+ *                                   containing all GIC Redistributors
+ * @discovery_range_length:          Length of the GIC Redistributor
+ *                                   Discovery page range
+ */
+void acpi_write_madt_gicr(struct acpi_madt_gicr *gicr,
+			  u64 discovery_range_base_address,
+			  u32 discovery_range_length);
+
+/**
+ * acpi_write_madt_its() - Write out a MADT ITS sub-table
+ *
+ * Write out the GIC Interrupt Translation Service sub-table.
+ *
+ * @its:                    Pointer to place to put the sub-table
+ * @its_id:                 Uniqueue GIC ITS ID
+ * @physical_base_address:  Physical address for the Interrupt
+ *                          Translation Service
+ */
+void acpi_write_madt_its(struct acpi_madt_its *its,
+			 u32 its_id,
+			 u64 physical_base_address);
+
+/**
+ * acpi_pptt_add_proc() - Write out a PPTT processor sub-table
+ *
+ * Write out the Processor Properties Topology Table processor sub-table.
+ *
+ * @ctx:                   ACPI context pointer
+ * @flags:                 Processor Structure Flags
+ * @parent:                Reference to parent processor
+ * @proc_id:               ACPI processor ID as defined in MADT
+ * @num_resources:         Number of resource structure references
+ * @resource_list:         References to other PPTT structures
+ * Return: offset from start of PPTT in bytes
+ */
+int acpi_pptt_add_proc(struct acpi_ctx *ctx, const u32 flags, const u32 parent,
+		       const u32 proc_id, const u32 num_resources,
+		       const u32 *resource_list);
+
+/**
+ * acpi_pptt_add_cache() - Write out a PPTT cache sub-table
+ *
+ * Write out the Processor Properties Topology Table cache sub-table.
+ *
+ * @ctx: ACPI context pointer
+ * @flags:                Cache Structure Flags
+ * @next_cache_level:     Reference to next level of cache
+ * @size:                 Size of the cache in bytes
+ * @sets:                 Number of sets in the cache
+ * @assoc:                Integer number of ways
+ * @attributes:           Allocation type, Cache type, policy
+ * @line_size:            Line size in bytes
+ * Return: offset from start of PPTT in bytes
+ */
+int acpi_pptt_add_cache(struct acpi_ctx *ctx, const u32 flags,
+			const u32 next_cache_level, const u32 size,
+			const u32 sets, const u8 assoc, const u8 attributes,
+			const u16 line_size);
+
+#endif /* !__ASSEMBLY__ */
+#endif /* !__ACPI__ */
+
+#endif /* __ASM_ACPI_TABLE_H__ */
arch/arm/lib/Makefile +1 -0
index 67275fba61..a7efed6771 100644
@@ -86,6 +86,7 @@ obj-y	+= psci-dt.o
 obj-$(CONFIG_DEBUG_LL)	+= debug.o
 
 obj-$(CONFIG_BLOBLIST)  += xferlist.o
+obj-$(CONFIG_GENERATE_ACPI_TABLE) += acpi_table.o
 
 # For EABI conformant tool chains, provide eabi_compat()
 ifneq (,$(findstring -mabi=aapcs-linux,$(PLATFORM_CPPFLAGS)))
arch/arm/lib/acpi_table.c new file +114 -0

114 lines not on this page · raw message

include/acpi/acpi_table.h +33 -1
index c6a3e44a95..7d994a985f 100644
@@ -342,7 +342,10 @@ enum acpi_apic_types {
 	ACPI_APIC_LX2APIC,		/* Processor local x2APIC */
 	ACPI_APIC_LX2APIC_NMI,		/* Local x2APIC NMI */
 	ACPI_APIC_GICC,			/* Generic Interrupt Ctlr CPU i/f */
-	ACPI_APIC_GICD			/* Generic Interrupt Ctlr Distributor */
+	ACPI_APIC_GICD,			/* Generic Interrupt Ctlr Distributor */
+	ACPI_APIC_MSI_FRAME,		/* Generic Interrupt MSI Frame */
+	ACPI_APIC_GICR,			/* Generic Interrupt Ctlr Redistributor */
+	ACPI_APIC_ITS,			/* Interrupt Translation Service */
 };
 
 /* MADT: Processor Local APIC Structure */
@@ -437,6 +440,35 @@ struct acpi_madt_gicd {
 	u8 reserved3[3];
 } __packed;
 
+/**
+ * struct __packed acpi_madt_gicr - GIC Redistributor (type 0xe)
+ *
+ * This holds information about the Generic Interrupt Controller (GIC)
+ * Redistributor interface. See ACPI Spec v6.3 section 5.2.12.17
+ */
+struct acpi_madt_gicr {
+	u8 type;
+	u8 length;
+	u16 reserved;
+	u64 discovery_range_base_address;
+	u32 discovery_range_length;
+} __packed;
+
+/**
+ * struct __packed acpi_madt_its - GIC Interrupt Translation Service (type 0xf)
+ *
+ * This holds information about the Interrupt Translation Service (ITS)
+ * Structure. See ACPI Spec v6.3 section 5.2.12.18
+ */
+struct acpi_madt_its {
+	u8 type;
+	u8 length;
+	u16 reserved;
+	u32 gic_its_id;
+	u64 physical_base_address;
+	u32 reserved2;
+} __packed;
+
 /* MCFG (PCI Express MMIO config space BAR description table) */
 struct acpi_mcfg {
 	struct acpi_table_header header;
Signature · 1 line
2.46.0
#9 lore raw

PATCH v4 8/35 acpi: Add fill_madt to acpi_ops

In reply to Patrick Rudolph

Add a new method to acpi_ops to let drivers fill out ACPI MADT. The code is unused for now until drivers implement the new ops.

TEST: Booted on QEMU sbsa using driver model generated MADT.

---
Changelog v4:
- Drop __weak attribute and make driver model mandatory on Arm

---
 arch/arm/lib/acpi_table.c | 13 ++++++++++++
 drivers/core/acpi.c       | 16 +++++++++++++++
 include/dm/acpi.h         | 26 +++++++++++++++++++++++
 lib/acpi/acpi_table.c     |  2 +-
 test/dm/acpi.c            | 43 +++++++++++++++++++++++++++++++++++++++
 5 files changed, 99 insertions(+), 1 deletion(-)
arch/arm/lib/acpi_table.c +13 -0
index db6e40bdef..b264a31cbb 100644
@@ -10,6 +10,8 @@
 #include <acpi/acpigen.h>
 #include <acpi/acpi_device.h>
 #include <acpi/acpi_table.h>
+#include <dm/acpi.h>
+#include <dm/uclass.h>
 #include <string.h>
 
 void acpi_write_madt_gicc(struct acpi_madt_gicc *gicc, uint cpu_num,
@@ -112,3 +114,14 @@ int acpi_pptt_add_cache(struct acpi_ctx *ctx, const u32 flags,
 
 	return offset;
 }
+
+void *acpi_fill_madt(struct acpi_madt *madt, struct acpi_ctx *ctx)
+{
+	uclass_probe_all(UCLASS_CPU);
+	uclass_probe_all(UCLASS_IRQ);
+
+	/* All SoCs must use the driver model */
+	acpi_fill_madt_subtbl(ctx);
+
+	return ctx->current;
+}
drivers/core/acpi.c +16 -0
index 9f78422892..4763963914 100644
@@ -48,6 +48,7 @@ enum method_t {
 	METHOD_FILL_SSDT,
 	METHOD_INJECT_DSDT,
 	METHOD_SETUP_NHLT,
+	METHOD_FILL_MADT,
 };
 
 /* Prototype for all methods */
@@ -282,6 +283,8 @@ acpi_method acpi_get_method(struct udevice *dev, enum method_t method)
 		switch (method) {
 		case METHOD_WRITE_TABLES:
 			return aops->write_tables;
+		case METHOD_FILL_MADT:
+			return aops->fill_madt;
 		case METHOD_FILL_SSDT:
 			return aops->fill_ssdt;
 		case METHOD_INJECT_DSDT:
@@ -328,6 +331,19 @@ int acpi_recurse_method(struct acpi_ctx *ctx, struct udevice *parent,
 	return 0;
 }
 
+int acpi_fill_madt_subtbl(struct acpi_ctx *ctx)
+{
+	int ret;
+
+	log_debug("Writing MADT table\n");
+	ret = acpi_recurse_method(ctx, dm_root(), METHOD_FILL_MADT, TYPE_NONE);
+	log_debug("Writing MADT finished, err=%d\n", ret);
+	if (ret)
+		return log_msg_ret("build", ret);
+
+	return ret;
+}
+
 int acpi_fill_ssdt(struct acpi_ctx *ctx)
 {
 	void *start = ctx->current;
include/dm/acpi.h +26 -0
index 3adfe21767..d6bc0c099a 100644
@@ -146,6 +146,22 @@ struct acpi_ops {
 	 */
 	int (*write_tables)(const struct udevice *dev, struct acpi_ctx *ctx);
 
+	/**
+	 * fill_madt() - Generate MADT sub-tables for a device
+	 *
+	 * This is called to create the MADT table. The method should write out
+	 * whatever sub-table is needed by this device. It will end up in the
+	 * MADT table.
+	 *
+	 * Note that this is called 'fill' because the entire contents of the
+	 * MADT is build by calling this method on all devices.
+	 *
+	 * @dev: Device to write
+	 * @ctx: ACPI context to use
+	 * @return 0 if OK, -ve on error
+	 */
+	int (*fill_madt)(const struct udevice *dev, struct acpi_ctx *ctx);
+
 	/**
 	 * fill_ssdt() - Generate SSDT code for a device
 	 *
@@ -231,6 +247,16 @@ int acpi_copy_name(char *out_name, const char *name);
  */
 int acpi_write_dev_tables(struct acpi_ctx *ctx);
 
+/**
+ * acpi_fill_madt_subtbl() - Generate ACPI tables for MADT
+ *
+ * This is called to create the MADT sub-tables for all devices.
+ *
+ * @ctx: ACPI context to use
+ * Return: 0 if OK, -ve on error
+ */
+int acpi_fill_madt_subtbl(struct acpi_ctx *ctx);
+
 /**
  * acpi_fill_ssdt() - Generate ACPI tables for SSDT
  *
lib/acpi/acpi_table.c +1 -1
index 639d78125f..5b9b4d2f29 100644
@@ -257,11 +257,11 @@ int acpi_write_madt(struct acpi_ctx *ctx, const struct acpi_writer *entry)
 	header->revision = ACPI_MADT_REV_ACPI_3_0;
 
 	acpi_inc(ctx, sizeof(struct acpi_madt));
+	/* TODO: Get rid of acpi_fill_madt and use driver model */
 	current = acpi_fill_madt(madt, ctx);
 
 	/* (Re)calculate length and checksum */
 	header->length = (uintptr_t)current - (uintptr_t)madt;
-
 	header->checksum = table_compute_checksum((void *)madt, header->length);
 	acpi_add_table(ctx, madt);
 	ctx->current = (void *)madt + madt->header.length;
test/dm/acpi.c +43 -0

61 lines not on this page · raw message

Signature · 1 line
2.46.0
Reviewed-by on v4 8/35
#10 lore raw

Re: [PATCH v4 08/35] acpi: Add fill_madt to acpi_ops

Quoted 12 lines · Patrick Rudolph

Add a new method to acpi_ops to let drivers fill out ACPI MADT. The code is unused for now until drivers implement the new ops.

TEST: Booted on QEMU sbsa using driver model generated MADT.

---
Changelog v4:
- Drop __weak attribute and make driver model mandatory on Arm

Quoted 7 lines
---
 arch/arm/lib/acpi_table.c | 13 ++++++++++++
 drivers/core/acpi.c       | 16 +++++++++++++++
 include/dm/acpi.h         | 26 +++++++++++++++++++++++
 lib/acpi/acpi_table.c     |  2 +-
 test/dm/acpi.c            | 43 +++++++++++++++++++++++++++++++++++++++
 5 files changed, 99 insertions(+), 1 deletion(-)
#11 lore raw

PATCH v4 9/35 acpi: acpi_table: Bump revisions

In reply to Patrick Rudolph

The FADT structure found in U-Boot represents FADT revision 6 and the GICC and GICD structures defined in U-Boot are based on ACPI revision 6.3.

Bump the table revision to fix FWTS failures seen on aarch64.

---
 arch/x86/cpu/tangier/acpi.c | 2 --
 include/acpi/acpi_table.h   | 3 ++-
 lib/acpi/acpi_table.c       | 7 ++++---
 3 files changed, 6 insertions(+), 6 deletions(-)
arch/x86/cpu/tangier/acpi.c +0 -2
index 3d11787861..8ea764f7cc 100644
@@ -28,8 +28,6 @@ void acpi_fill_fadt(struct acpi_fadt *fadt)
 		ACPI_FADT_POWER_BUTTON | ACPI_FADT_SLEEP_BUTTON |
 		ACPI_FADT_SEALED_CASE | ACPI_FADT_HEADLESS |
 		ACPI_FADT_HW_REDUCED_ACPI;
-	fadt->header.revision = 6;
-	fadt->minor_revision = 2;
 }
 
 void *acpi_fill_madt(struct acpi_madt *madt, struct acpi_ctx *ctx)
include/acpi/acpi_table.h +2 -1
index 7d994a985f..48f8ce248f 100644
@@ -290,7 +290,8 @@ struct __packed acpi_fadt {
 #define ACPI_MADT_REV_ACPI_3_0		2
 #define ACPI_MADT_REV_ACPI_4_0		3
 #define ACPI_MADT_REV_ACPI_5_0		3
-#define ACPI_MADT_REV_ACPI_6_0		5
+#define ACPI_MADT_REV_ACPI_6_2		4
+#define ACPI_MADT_REV_ACPI_6_3		5
 
 #define ACPI_MCFG_REV_ACPI_3_0		1
 
lib/acpi/acpi_table.c +4 -3
index 5b9b4d2f29..959cac9e2e 100644
@@ -63,9 +63,9 @@ int acpi_get_table_revision(enum acpi_tables table)
 {
 	switch (table) {
 	case ACPITAB_FADT:
-		return ACPI_FADT_REV_ACPI_3_0;
+		return ACPI_FADT_REV_ACPI_6_0;
 	case ACPITAB_MADT:
-		return ACPI_MADT_REV_ACPI_3_0;
+		return ACPI_MADT_REV_ACPI_6_2;
 	case ACPITAB_MCFG:
 		return ACPI_MCFG_REV_ACPI_3_0;
 	case ACPITAB_TCPA:
@@ -219,6 +219,7 @@ int acpi_write_fadt(struct acpi_ctx *ctx, const struct acpi_writer *entry)
 	memcpy(header->oem_table_id, OEM_TABLE_ID, 8);
 	memcpy(header->creator_id, ASLC_ID, 4);
 	header->creator_revision = 1;
+	fadt->minor_revision = 2;
 
 	fadt->x_firmware_ctrl = map_to_sysmem(ctx->facs);
 	fadt->x_dsdt = map_to_sysmem(ctx->dsdt);
@@ -254,7 +255,7 @@ int acpi_write_madt(struct acpi_ctx *ctx, const struct acpi_writer *entry)
 	/* Fill out header fields */
 	acpi_fill_header(header, "APIC");
 	header->length = sizeof(struct acpi_madt);
-	header->revision = ACPI_MADT_REV_ACPI_3_0;
+	header->revision = acpi_get_table_revision(ACPITAB_MADT);
 
 	acpi_inc(ctx, sizeof(struct acpi_madt));
 	/* TODO: Get rid of acpi_fill_madt and use driver model */
Signature · 1 line
2.46.0
#12 lore raw

PATCH v4 10/35 acpi: Add ACPITAB for PPTT and GTDT

In reply to Patrick Rudolph

Return the ACPI table revision in acpi_get_table_revision() for PPTT and GTDT. Match both to ACPI 6.2.

---
 include/acpi/acpi_table.h | 2 ++
 lib/acpi/acpi_table.c     | 4 ++++
 2 files changed, 6 insertions(+)
include/acpi/acpi_table.h +2 -0
index 48f8ce248f..7ee3248ff6 100644
@@ -841,12 +841,14 @@ enum acpi_tables {
 	ACPITAB_ECDT,
 	ACPITAB_FACS,
 	ACPITAB_FADT,
+	ACPITAB_GTDT,
 	ACPITAB_HEST,
 	ACPITAB_HPET,
 	ACPITAB_IVRS,
 	ACPITAB_MADT,
 	ACPITAB_MCFG,
 	ACPITAB_NHLT,
+	ACPITAB_PPTT,
 	ACPITAB_RSDP,
 	ACPITAB_RSDT,
 	ACPITAB_SLIT,
lib/acpi/acpi_table.c +4 -0
index 959cac9e2e..2dc7b998e2 100644
@@ -107,6 +107,10 @@ int acpi_get_table_revision(enum acpi_tables table)
 		return 1;
 	case ACPITAB_SPCR:
 		return 2;
+	case ACPITAB_PPTT: /* ACPI 6.2: 1 */
+		return 1;
+	case ACPITAB_GTDT: /* ACPI 6.2: 2, ACPI 6.3: 3 */
+		return 2;
 	default:
 		return -EINVAL;
 	}
Signature · 1 line
2.46.0
#13 lore raw

PATCH v4 11/35 acpi: acpi_table: Add IORT support

In reply to Patrick Rudolph

The SoC can implement acpi_fill_iort to update the IORT table. Add a helper function to fill out the NAMED_COMPONENT node.

TEST=Run FWTS V24.03.00 on RPi4 and round no problems.

---
 include/acpi/acpi_table.h | 213 ++++++++++++++++++++++++++++++++++++++
 lib/acpi/acpi_table.c     | 213 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 426 insertions(+)
include/acpi/acpi_table.h +213 -0
index 7ee3248ff6..5a30465ad2 100644
@@ -832,6 +832,117 @@ struct acpi_pptt_cache {
 	u16 line_size;
 } __packed;
 
+/** IORT - IO Remapping Table revision 6
+ * Document number: ARM DEN 0049E.e, Sep 2022
+ */
+struct acpi_table_iort {
+	struct acpi_table_header header;
+	u32 node_count;
+	u32 node_offset;
+	u32 reserved;
+} __packed;
+
+/*
+ * IORT subtables
+ */
+struct acpi_iort_node {
+	u8 type;
+	u16 length;
+	u8 revision;
+	u32 identifier;
+	u32 mapping_count;
+	u32 mapping_offset;
+	char node_data[];
+} __packed;
+
+/* Values for subtable Type above */
+enum acpi_iort_node_type {
+	ACPI_IORT_NODE_ITS_GROUP = 0x00,
+	ACPI_IORT_NODE_NAMED_COMPONENT = 0x01,
+	ACPI_IORT_NODE_PCI_ROOT_COMPLEX = 0x02,
+	ACPI_IORT_NODE_SMMU = 0x03,
+	ACPI_IORT_NODE_SMMU_V3 = 0x04,
+	ACPI_IORT_NODE_PMCG = 0x05,
+	ACPI_IORT_NODE_RMR = 0x06,
+};
+
+/* ITS Group revision 1 */
+struct acpi_iort_its_group {
+	u32 its_count;
+	u32 identifiers[];	/* GIC ITS identifier array */
+} __packed;
+
+/* PCI root complex node revision 2 */
+struct acpi_iort_rc {
+	u64 mem_access_properties;
+	u32 ats_attributes;
+	u32 pci_segment_number;
+	u8 memory_address_size_limit;
+	u8 reserved[3];
+} __packed;
+
+/* SMMUv3 revision 5 */
+struct acpi_iort_smmu_v3 {
+	u64 base_address;	/* SMMUv3 base address */
+	u32 flags;
+	u32 reserved;
+	u64 vatos_address;
+	u32 model;
+	u32 event_gsiv;
+	u32 pri_gsiv;
+	u32 gerr_gsiv;
+	u32 sync_gsiv;
+	u32 pxm;
+	u32 id_mapping_index;
+} __packed;
+
+/* Masks for Flags field above */
+#define ACPI_IORT_SMMU_V3_COHACC_OVERRIDE   (1)
+#define ACPI_IORT_SMMU_V3_HTTU_OVERRIDE     (3 << 1)
+#define ACPI_IORT_SMMU_V3_PXM_VALID         (1 << 3)
+#define ACPI_IORT_SMMU_V3_DEVICEID_VALID    (1 << 4)
+
+struct acpi_iort_id_mapping {
+	u32 input_base;		/* Lowest value in input range */
+	u32 id_count;		/* Number of IDs */
+	u32 output_base;	/* Lowest value in output range */
+	u32 output_reference;	/* A reference to the output node */
+	u32 flags;
+} __packed;
+
+/* Masks for Flags field above for IORT subtable */
+#define ACPI_IORT_ID_SINGLE_MAPPING (1)
+
+/* Named Component revision 4 */
+struct acpi_iort_named_component {
+	u32 node_flags;
+	u64 memory_properties;	/* Memory access properties */
+	u8 memory_address_limit;	/* Memory address size limit */
+	char device_name[];	/* Path of namespace object */
+} __packed;
+
+/* Masks for Flags field above */
+#define ACPI_IORT_NC_STALL_SUPPORTED    (1)
+#define ACPI_IORT_NC_PASID_BITS         (31 << 1)
+
+struct acpi_iort_root_complex {
+	u64 memory_properties;	/* Memory access properties */
+	u32 ats_attribute;
+	u32 pci_segment_number;
+	u8 memory_address_limit;/* Memory address size limit */
+	u16 pasid_capabilities;	/* PASID Capabilities */
+	u8 reserved;		/* Reserved, must be zero */
+	u32 flags;		/* Flags */
+} __packed;
+
+/* Masks for ats_attribute field above */
+#define ACPI_IORT_ATS_SUPPORTED         (1)		/* The root complex ATS support */
+#define ACPI_IORT_PRI_SUPPORTED         (1 << 1)	/* The root complex PRI support */
+#define ACPI_IORT_PASID_FWD_SUPPORTED   (1 << 2)	/* The root complex PASID forward support */
+
+/* Masks for pasid_capabilities field above */
+#define ACPI_IORT_PASID_MAX_WIDTH       (0x1F)	/* Bits 0-4 */
+
 /* Tables defined/reserved by ACPI and generated by U-Boot */
 enum acpi_tables {
 	ACPITAB_BERT,
@@ -1000,6 +1111,108 @@ int acpi_fill_csrt(struct acpi_ctx *ctx);
  */
 void acpi_fill_fadt(struct acpi_fadt *fadt);
 
+/**
+ * acpi_fill_iort() - Fill out the body of the IORT table
+ *
+ * Should be implemented in SoC specific code.
+ *
+ * @ctx: ACPI context to write to
+ * @offset: Offset from the start of the IORT
+ */
+int acpi_fill_iort(struct acpi_ctx *ctx);
+
+/**
+ * acpi_iort_add_its_group() - Add ITS group node to IORT table
+ *
+ * Called by SoC specific code within acpi_fill_iort().
+ *
+ * @ctx: ACPI context to write to
+ * @its_count: Elements in identifiers
+ * @identifiers: The array of ITS identifiers. These IDs must match the value
+ *               used in the Multiple APIC Description Table (MADT) GIC ITS
+ *               structure for each relevant ITS unit.
+ * @return Offset of table within parent
+ */
+int acpi_iort_add_its_group(struct acpi_ctx *ctx,
+			    const u32 its_count,
+			    const u32 *identifiers);
+
+/**
+ * acpi_iort_add_named_component() - Add named component to IORT table
+ *
+ * Called by SoC specific code within acpi_fill_iort().
+ *
+ * @ctx: ACPI context to write to
+ * @node_flags: Node flags
+ * @memory_properties: Memory properties
+ * @memory_address_limit: Memory address limit
+ * @device_name: ACPI device path
+ * @return Offset of table within parent
+ */
+int acpi_iort_add_named_component(struct acpi_ctx *ctx,
+				  const u32 node_flags,
+				  const u64 memory_properties,
+				  const u8 memory_address_limit,
+				  const char *device_name);
+
+/**
+ * acpi_iort_add_rc() - Add PCI root complex node to IORT table
+ *
+ * Called by SoC specific code within acpi_fill_iort().
+ *
+ * @ctx: ACPI context to write to
+ * @mem_access_properties: Memory access properties
+ * @ats_attributes: Support for ATS and its ancillary feature
+ * @pci_segment_number: The PCI segment number, as in MCFG
+ * @memory_address_size_limit: The number of address bits, starting from LSB
+ * @num_mappings: Number of elements in map
+ * @map: ID mappings for this node
+ * @return Offset of table within parent
+ */
+int acpi_iort_add_rc(struct acpi_ctx *ctx,
+		     const u64 mem_access_properties,
+		     const u32 ats_attributes,
+		     const u32 pci_segment_number,
+		     const u8 memory_address_size_limit,
+		     const int num_mappings,
+		     const struct acpi_iort_id_mapping *map);
+
+/**
+ * acpi_iort_add_smmu_v3() - Add PCI root complex node to IORT table
+ *
+ * Called by SoC specific code within acpi_fill_iort().
+ *
+ * @ctx: ACPI context to write to
+ * @base_address: Base address of SMMU
+ * @flags: SMMUv3 flags
+ * @vatos_address: Optional, set to zero if not supported
+ * @model: Model ID
+ * @event_gsiv: GSIV of the Event interrupt if SPI based
+ * @pri_gsiv: GSIV of the PRI interrupt if SPI based
+ * @gerr_gsiv: GSIV of the GERR interrupt if GSIV based
+ * @sync_gsiv: TGSIV of the Sync interrupt if GSIV based
+ * @pxm: Proximity Domain
+ * @id_mapping_index: If all the SMMU control interrupts are GSIV based,
+ *                    this field is ignored. Index into the array of ID
+ *                    mapping otherwise.
+ * @num_mappings: Number of elements in map
+ * @map: ID mappings for this node
+ * @return Offset of table within parent
+ */
+int acpi_iort_add_smmu_v3(struct acpi_ctx *ctx,
+			  const u64 base_address,
+			  const u32 flags,
+			  const u64 vatos_address,
+			  const u32 model,
+			  const u32 event_gsiv,
+			  const u32 pri_gsiv,
+			  const u32 gerr_gsiv,
+			  const u32 sync_gsiv,
+			  const u32 pxm,
+			  const u32 id_mapping_index,
+			  const int num_mappings,
+			  const struct acpi_iort_id_mapping *map);
+
 /**
  * acpi_fill_madt() - Fill out the body of the MADT
  *
lib/acpi/acpi_table.c +213 -0

216 lines not on this page · raw message

Signature · 1 line
2.46.0
#14 lore raw

PATCH v4 12/35 acpi: Move function prototype

In reply to Patrick Rudolph

Allow other architectures to use acpi_create_mcfg_mmconfig as well by moving the function prototype to common code.

---
 arch/x86/include/asm/acpi_table.h |  2 --
 include/acpi/acpi_table.h         | 13 +++++++++++++
 2 files changed, 13 insertions(+), 2 deletions(-)
arch/x86/include/asm/acpi_table.h +0 -2
index 3254bbc380..ff60384e62 100644
@@ -31,8 +31,6 @@ int acpi_create_madt_irqoverride(struct acpi_madt_irqoverride *irqoverride,
 				 u8 bus, u8 source, u32 gsirq, u16 flags);
 int acpi_create_madt_lapic_nmi(struct acpi_madt_lapic_nmi *lapic_nmi,
 			       u8 cpu, u16 flags, u8 lint);
-int acpi_create_mcfg_mmconfig(struct acpi_mcfg_mmconfig *mmconfig, u32 base,
-			      u16 seg_nr, u8 start, u8 end);
 
 /**
  * acpi_write_hpet() - Write out a HPET table
include/acpi/acpi_table.h +13 -0
index 5a30465ad2..07c5f65d75 100644
@@ -994,6 +994,19 @@ int acpi_get_table_revision(enum acpi_tables table);
  */
 int acpi_create_dmar(struct acpi_dmar *dmar, enum dmar_flags flags);
 
+/**
+ * acpi_create_mcfg_mmconfig() - Create a MCFG table entry
+ *
+ * @mmconfig: Place to put the table
+ * @base: Base address of the ECAM space
+ * @seg_nr: PCI segment number
+ * @start: PCI bus start number
+ * @end: PCI bus end number
+ * Return: size of data written in bytes
+ */
+int acpi_create_mcfg_mmconfig(struct acpi_mcfg_mmconfig *mmconfig, u32 base,
+			      u16 seg_nr, u8 start, u8 end);
+
 /**
  * acpi_create_dbg2() - Create a DBG2 table
  *
Signature · 1 line
2.46.0
#15 lore raw

PATCH v4 13/35 acpi_table: Support platforms with unusable RSDT

In reply to Patrick Rudolph

Since ACPI 2.0 the RSDT is deprecated and the XSDT should be preferred. Until now the RSDT and XSDT entries were keept in sync as all platforms that installed ACPI tables placed them below 4GiB and thus the address would fit into the 32bit RSDT.

On platforms that do not have usable DRAM below 4GiB, like QEMU sbsa, the RSDT cannot be used. Allow both RSDT and XSDT to be null and only fill those tables that are present in acpi_add_table().

TEST: Fixes a crash on QEMU sbsa and allows to boot on QEMU sbsa.

---
Changelog v4:
- Updated commit message and better explain why this change is needed

---
 lib/acpi/acpi_table.c | 95 ++++++++++++++++++++++++++-----------------
 1 file changed, 57 insertions(+), 38 deletions(-)
lib/acpi/acpi_table.c +57 -38
index 9d9c8befe8..d6357bdc4d 100644
@@ -157,51 +157,70 @@ int acpi_add_table(struct acpi_ctx *ctx, void *table)
 	struct acpi_rsdt *rsdt;
 	struct acpi_xsdt *xsdt;
 
-	/* The RSDT is mandatory while the XSDT is not */
-	rsdt = ctx->rsdt;
-
-	/* This should always be MAX_ACPI_TABLES */
-	entries_num = ARRAY_SIZE(rsdt->entry);
-
-	for (i = 0; i < entries_num; i++) {
-		if (rsdt->entry[i] == 0)
-			break;
-	}
-
-	if (i >= entries_num) {
-		log_err("ACPI: Error: too many tables\n");
-		return -E2BIG;
-	}
+	/* On legacy x86 platforms the RSDT is mandatory while the XSDT is not.
+	 * On other platforms there might be no memory below 4GiB, thus RSDT is NULL.
+	 */
+	if (ctx->rsdt) {
+		rsdt = ctx->rsdt;
 
-	/* Add table to the RSDT */
-	rsdt->entry[i] = nomap_to_sysmem(table);
+		/* This should always be MAX_ACPI_TABLES */
+		entries_num = ARRAY_SIZE(rsdt->entry);
 
-	/* Fix RSDT length or the kernel will assume invalid entries */
-	rsdt->header.length = sizeof(struct acpi_table_header) +
-				(sizeof(u32) * (i + 1));
+		for (i = 0; i < entries_num; i++) {
+			if (rsdt->entry[i] == 0)
+				break;
+		}
 
-	/* Re-calculate checksum */
-	rsdt->header.checksum = 0;
-	rsdt->header.checksum = table_compute_checksum((u8 *)rsdt,
-						       rsdt->header.length);
+		if (i >= entries_num) {
+			log_err("ACPI: Error: too many tables\n");
+			return -E2BIG;
+		}
 
-	/*
-	 * And now the same thing for the XSDT. We use the same index as for
-	 * now we want the XSDT and RSDT to always be in sync in U-Boot
-	 */
-	xsdt = ctx->xsdt;
+		/* Add table to the RSDT */
+		rsdt->entry[i] = nomap_to_sysmem(table);
 
-	/* Add table to the XSDT */
-	xsdt->entry[i] = nomap_to_sysmem(table);
+		/* Fix RSDT length or the kernel will assume invalid entries */
+		rsdt->header.length = sizeof(struct acpi_table_header) +
+					(sizeof(u32) * (i + 1));
 
-	/* Fix XSDT length */
-	xsdt->header.length = sizeof(struct acpi_table_header) +
-				(sizeof(u64) * (i + 1));
+		/* Re-calculate checksum */
+		rsdt->header.checksum = 0;
+		rsdt->header.checksum = table_compute_checksum((u8 *)rsdt,
+							       rsdt->header.length);
+	}
 
-	/* Re-calculate checksum */
-	xsdt->header.checksum = 0;
-	xsdt->header.checksum = table_compute_checksum((u8 *)xsdt,
-						       xsdt->header.length);
+	if (ctx->xsdt) {
+		/*
+		 * And now the same thing for the XSDT. We use the same index as for
+		 * now we want the XSDT and RSDT to always be in sync in U-Boot
+		 */
+		xsdt = ctx->xsdt;
+
+		/* This should always be MAX_ACPI_TABLES */
+		entries_num = ARRAY_SIZE(xsdt->entry);
+
+		for (i = 0; i < entries_num; i++) {
+			if (xsdt->entry[i] == 0)
+				break;
+		}
+
+		if (i >= entries_num) {
+			log_err("ACPI: Error: too many tables\n");
+			return -E2BIG;
+		}
+
+		/* Add table to the XSDT */
+		xsdt->entry[i] = nomap_to_sysmem(table);
+
+		/* Fix XSDT length */
+		xsdt->header.length = sizeof(struct acpi_table_header) +
+					(sizeof(u64) * (i + 1));
+
+		/* Re-calculate checksum */
+		xsdt->header.checksum = 0;
+		xsdt->header.checksum = table_compute_checksum((u8 *)xsdt,
+							       xsdt->header.length);
+	}
 
 	return 0;
 }
Signature · 1 line
2.46.0
#16 lore raw

PATCH v4 14/35 efi_loader: Allocate and write ACPI tables

In reply to Patrick Rudolph

Allocate memory for ACPI tables inside the efi_loader and write out the tables similar to SMBIOS tables. When ACPI is enabled and wasn't installed in other places, install the ACPI table in EFI. Since EFI is necessary to pass the ACPI table location when FDT isn't used, there's no need to install it separately.

When CONFIG_BLOBLIST_TABLES is set the tables will be stored in a bloblist. The tables are still passed to the OS using EFI.

This allows non x86 platforms to boot using ACPI only in case the EFI loader is being used.

TEST: Booted QEMU SBSA (no QFW) using EFI and ACPI only.

---
Changelog v3:
- Drop memalign and use efi_allocate_pages
- Use log_debug instead of debug
- Clarify commit message
- Skip writing ACPI tables on sandbox
- Rename function
- Add function comment

---
 lib/efi_loader/efi_acpi.c        | 80 +++++++++++++++++++++++++++++++-
 test/py/tests/test_event_dump.py |  1 +
 2 files changed, 79 insertions(+), 2 deletions(-)
lib/efi_loader/efi_acpi.c +78 -2
index 67bd7f8ca2..9d38d0060c 100644
@@ -6,15 +6,23 @@
  */
 
 #include <efi_loader.h>
-#include <log.h>
-#include <mapmem.h>
 #include <acpi/acpi_table.h>
 #include <asm/global_data.h>
+#include <asm/io.h>
+#include <bloblist.h>
+#include <linux/sizes.h>
+#include <linux/log2.h>
+#include <log.h>
+#include <malloc.h>
+#include <mapmem.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
 static const efi_guid_t acpi_guid = EFI_ACPI_TABLE_GUID;
 
+enum {
+	TABLE_SIZE	= SZ_64K,
+};
 /*
  * Install the ACPI table as a configuration table.
  *
@@ -47,3 +55,71 @@ efi_status_t efi_acpi_register(void)
 	return efi_install_configuration_table(&acpi_guid,
 					       (void *)(ulong)addr);
 }
+
+/*
+ * Allocate memory for ACPI tables and write ACPI tables to the
+ * allocated buffer.
+ *
+ * Return:	status code
+ */
+static int alloc_write_acpi_tables(void)
+{
+	u64 table_addr, table_end;
+	u64 new_acpi_addr = 0;
+	efi_uintn_t pages;
+	efi_status_t ret;
+	void *addr;
+
+	if (!IS_ENABLED(CONFIG_GENERATE_ACPI_TABLE))
+		return 0;
+
+	if (IS_ENABLED(CONFIG_X86) ||
+	    IS_ENABLED(CONFIG_QFW_ACPI) ||
+	    IS_ENABLED(CONFIG_SANDBOX)) {
+		log_debug("Skipping writing ACPI tables as already done\n");
+		return 0;
+	}
+
+	/* Align the table to a 4KB boundary to keep EFI happy */
+	if (IS_ENABLED(CONFIG_BLOBLIST_TABLES)) {
+		addr = bloblist_add(BLOBLISTT_ACPI_TABLES, TABLE_SIZE,
+				    ilog2(SZ_4K));
+
+		if (!addr)
+			return log_msg_ret("mem", -ENOMEM);
+	} else {
+		pages = efi_size_in_pages(TABLE_SIZE);
+
+		ret = efi_allocate_pages(EFI_ALLOCATE_ANY_PAGES,
+					 EFI_ACPI_RECLAIM_MEMORY,
+					 pages, &new_acpi_addr);
+		if (ret != EFI_SUCCESS)
+			return log_msg_ret("mem", -ENOMEM);
+
+		addr = (void *)(uintptr_t)new_acpi_addr;
+	}
+
+	table_addr = virt_to_phys(addr);
+
+	gd->arch.table_start_high = table_addr;
+
+	table_end = write_acpi_tables(table_addr);
+	if (!table_end) {
+		log_err("Can't create ACPI configuration table\n");
+		return -EINTR;
+	}
+
+	log_debug("- wrote 'acpi' to %llx, end %llx\n", table_addr, table_end);
+	if (table_end - table_addr > TABLE_SIZE) {
+		log_err("Out of space for configuration tables: need %llx, have %x\n",
+			table_end - table_addr, TABLE_SIZE);
+		return log_msg_ret("acpi", -ENOSPC);
+	}
+	gd->arch.table_end_high = table_end;
+
+	log_debug("- done writing tables\n");
+
+	return 0;
+}
+
+EVENT_SPY_SIMPLE(EVT_LAST_STAGE_INIT, alloc_write_acpi_tables);
test/py/tests/test_event_dump.py +1 -0
index e282c67335..459bfa26bb 100644
@@ -18,6 +18,7 @@ def test_event_dump(u_boot_console):
 --------------------  ------------------------------  ------------------------------
 EVT_FT_FIXUP          bootmeth_vbe_ft_fixup           .*boot/vbe_request.c:.*
 EVT_FT_FIXUP          bootmeth_vbe_simple_ft_fixup    .*boot/vbe_simple_os.c:.*
+EVT_LAST_STAGE_INIT   alloc_write_acpi_tables         .*lib/efi_loader/efi_acpi.c:.*
 EVT_LAST_STAGE_INIT   install_smbios_table            .*lib/efi_loader/efi_smbios.c:.*
 EVT_MISC_INIT_F       sandbox_early_getopt_check      .*arch/sandbox/cpu/start.c:.*
 EVT_TEST              h_adder_simple                  .*test/common/event.c:'''
Signature · 1 line
2.46.0
#17 lore raw

Re: [PATCH v4 14/35] efi_loader: Allocate and write ACPI tables

Hi Partick,

I haven't seen any replies in [0]. The same comments apply to this version. Also, the changelog seems like it's the v2 one?

Quoted 146 lines · Patrick Rudolph

Allocate memory for ACPI tables inside the efi_loader and write out the tables similar to SMBIOS tables. When ACPI is enabled and wasn't installed in other places, install the ACPI table in EFI. Since EFI is necessary to pass the ACPI table location when FDT isn't used, there's no need to install it separately.

When CONFIG_BLOBLIST_TABLES is set the tables will be stored in a bloblist. The tables are still passed to the OS using EFI.

This allows non x86 platforms to boot using ACPI only in case the EFI loader is being used.

TEST: Booted QEMU SBSA (no QFW) using EFI and ACPI only.

---
Changelog v3:
- Drop memalign and use efi_allocate_pages
- Use log_debug instead of debug
- Clarify commit message
- Skip writing ACPI tables on sandbox
- Rename function
- Add function comment

---
 lib/efi_loader/efi_acpi.c        | 80 +++++++++++++++++++++++++++++++-
 test/py/tests/test_event_dump.py |  1 +
 2 files changed, 79 insertions(+), 2 deletions(-)
lib/efi_loader/efi_acpi.c +78 -2
index 67bd7f8ca2..9d38d0060c 100644
@@ -6,15 +6,23 @@
  */
 
 #include <efi_loader.h>
-#include <log.h>
-#include <mapmem.h>
 #include <acpi/acpi_table.h>
 #include <asm/global_data.h>
+#include <asm/io.h>
+#include <bloblist.h>
+#include <linux/sizes.h>
+#include <linux/log2.h>
+#include <log.h>
+#include <malloc.h>
+#include <mapmem.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
 static const efi_guid_t acpi_guid = EFI_ACPI_TABLE_GUID;
 
+enum {
+       TABLE_SIZE      = SZ_64K,
+};
 /*
  * Install the ACPI table as a configuration table.
  *
@@ -47,3 +55,71 @@ efi_status_t efi_acpi_register(void)
        return efi_install_configuration_table(&acpi_guid,
                                               (void *)(ulong)addr);
 }
+
+/*
+ * Allocate memory for ACPI tables and write ACPI tables to the
+ * allocated buffer.
+ *
+ * Return:     status code
+ */
+static int alloc_write_acpi_tables(void)
+{
+       u64 table_addr, table_end;
+       u64 new_acpi_addr = 0;
+       efi_uintn_t pages;
+       efi_status_t ret;
+       void *addr;
+
+       if (!IS_ENABLED(CONFIG_GENERATE_ACPI_TABLE))
+               return 0;
+
+       if (IS_ENABLED(CONFIG_X86) ||
+           IS_ENABLED(CONFIG_QFW_ACPI) ||
+           IS_ENABLED(CONFIG_SANDBOX)) {
+               log_debug("Skipping writing ACPI tables as already done\n");
+               return 0;
+       }
+
+       /* Align the table to a 4KB boundary to keep EFI happy */
+       if (IS_ENABLED(CONFIG_BLOBLIST_TABLES)) {
+               addr = bloblist_add(BLOBLISTT_ACPI_TABLES, TABLE_SIZE,
+                                   ilog2(SZ_4K));
+
+               if (!addr)
+                       return log_msg_ret("mem", -ENOMEM);
+       } else {
+               pages = efi_size_in_pages(TABLE_SIZE);
+
+               ret = efi_allocate_pages(EFI_ALLOCATE_ANY_PAGES,
+                                        EFI_ACPI_RECLAIM_MEMORY,
+                                        pages, &new_acpi_addr);
+               if (ret != EFI_SUCCESS)
+                       return log_msg_ret("mem", -ENOMEM);
+
+               addr = (void *)(uintptr_t)new_acpi_addr;
+       }
+
+       table_addr = virt_to_phys(addr);
+
+       gd->arch.table_start_high = table_addr;
+
+       table_end = write_acpi_tables(table_addr);
+       if (!table_end) {
+               log_err("Can't create ACPI configuration table\n");
+               return -EINTR;
+       }
+
+       log_debug("- wrote 'acpi' to %llx, end %llx\n", table_addr, table_end);
+       if (table_end - table_addr > TABLE_SIZE) {
+               log_err("Out of space for configuration tables: need %llx, have %x\n",
+                       table_end - table_addr, TABLE_SIZE);
+               return log_msg_ret("acpi", -ENOSPC);
+       }
+       gd->arch.table_end_high = table_end;
+
+       log_debug("- done writing tables\n");
+
+       return 0;
+}
+
+EVENT_SPY_SIMPLE(EVT_LAST_STAGE_INIT, alloc_write_acpi_tables);
test/py/tests/test_event_dump.py +1 -1
index e282c67335..459bfa26bb 100644
@@ -18,6 +18,7 @@ def test_event_dump(u_boot_console):
 --------------------  ------------------------------  ------------------------------
 EVT_FT_FIXUP          bootmeth_vbe_ft_fixup           .*boot/vbe_request.c:.*
 EVT_FT_FIXUP          bootmeth_vbe_simple_ft_fixup    .*boot/vbe_simple_os.c:.*
+EVT_LAST_STAGE_INIT   alloc_write_acpi_tables         .*lib/efi_loader/efi_acpi.c:.*
 EVT_LAST_STAGE_INIT   install_smbios_table            .*lib/efi_loader/efi_smbios.c:.*
 EVT_MISC_INIT_F       sandbox_early_getopt_check      .*arch/sandbox/cpu/start.c:.*
 EVT_TEST              h_adder_simple                  .*test/common/event.c:'''
--
Quoted 2 lines

2.46.0

[0] https://lore.kernel.org/u-boot/CAC_iWjLfbXHFd7zs0xsVamXua8GXsAbhBstgTQEQN1+t8Fr2QA@mail.gmail.com/

Thanks
/Ilias

#18 lore raw

Re: [PATCH v4 14/35] efi_loader: Allocate and write ACPI tables

In reply to Patrick Rudolph

Hi Patrick,

Quoted 99 lines · Patrick Rudolph

Allocate memory for ACPI tables inside the efi_loader and write out the tables similar to SMBIOS tables. When ACPI is enabled and wasn't installed in other places, install the ACPI table in EFI. Since EFI is necessary to pass the ACPI table location when FDT isn't used, there's no need to install it separately.

When CONFIG_BLOBLIST_TABLES is set the tables will be stored in a bloblist. The tables are still passed to the OS using EFI.

This allows non x86 platforms to boot using ACPI only in case the EFI loader is being used.

TEST: Booted QEMU SBSA (no QFW) using EFI and ACPI only.

---
Changelog v3:
- Drop memalign and use efi_allocate_pages
- Use log_debug instead of debug
- Clarify commit message
- Skip writing ACPI tables on sandbox
- Rename function
- Add function comment

---
 lib/efi_loader/efi_acpi.c        | 80 +++++++++++++++++++++++++++++++-
 test/py/tests/test_event_dump.py |  1 +
 2 files changed, 79 insertions(+), 2 deletions(-)
lib/efi_loader/efi_acpi.c +44 -2
index 67bd7f8ca2..9d38d0060c 100644
@@ -6,15 +6,23 @@
  */
 
 #include <efi_loader.h>
-#include <log.h>
-#include <mapmem.h>
 #include <acpi/acpi_table.h>
 #include <asm/global_data.h>
+#include <asm/io.h>
+#include <bloblist.h>
+#include <linux/sizes.h>
+#include <linux/log2.h>
+#include <log.h>
+#include <malloc.h>
+#include <mapmem.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
 static const efi_guid_t acpi_guid = EFI_ACPI_TABLE_GUID;
 
+enum {
+       TABLE_SIZE      = SZ_64K,
+};
 /*
  * Install the ACPI table as a configuration table.
  *
@@ -47,3 +55,71 @@ efi_status_t efi_acpi_register(void)
        return efi_install_configuration_table(&acpi_guid,
                                               (void *)(ulong)addr);
 }
+
+/*
+ * Allocate memory for ACPI tables and write ACPI tables to the
+ * allocated buffer.
+ *
+ * Return:     status code
+ */
+static int alloc_write_acpi_tables(void)
+{
+       u64 table_addr, table_end;
+       u64 new_acpi_addr = 0;
+       efi_uintn_t pages;
+       efi_status_t ret;
+       void *addr;
+
+       if (!IS_ENABLED(CONFIG_GENERATE_ACPI_TABLE))
+               return 0;
+
+       if (IS_ENABLED(CONFIG_X86) ||
+           IS_ENABLED(CONFIG_QFW_ACPI) ||
+           IS_ENABLED(CONFIG_SANDBOX)) {
+               log_debug("Skipping writing ACPI tables as already done\n");
+               return 0;
+       }
+
+       /* Align the table to a 4KB boundary to keep EFI happy */
+       if (IS_ENABLED(CONFIG_BLOBLIST_TABLES)) {
+               addr = bloblist_add(BLOBLISTT_ACPI_TABLES, TABLE_SIZE,
+                                   ilog2(SZ_4K));
+
+               if (!addr)
+                       return log_msg_ret("mem", -ENOMEM);
+       } else {
+               pages = efi_size_in_pages(TABLE_SIZE);

lib/efi_loader/efi_acpi.c efi_status_t efi_acpi_register(void) · line 101

Quoted 10 lines
lib/efi_loader/efi_acpi.c +10 -0
+
+               ret = efi_allocate_pages(EFI_ALLOCATE_ANY_PAGES,
+                                        EFI_ACPI_RECLAIM_MEMORY,
+                                        pages, &new_acpi_addr);
+               if (ret != EFI_SUCCESS)
+                       return log_msg_ret("mem", -ENOMEM);
+
+               addr = (void *)(uintptr_t)new_acpi_addr;
+       }
+

The tables should be written regardless of whether EFI_LOADER is enabled.

Can we drop this else clause? We should always use the bloblist.

We should use efi_add_memory_map() to add to the memory map.

Quoted 37 lines
lib/efi_loader/efi_acpi.c +24 -0
+       table_addr = virt_to_phys(addr);
+
+       gd->arch.table_start_high = table_addr;
+
+       table_end = write_acpi_tables(table_addr);
+       if (!table_end) {
+               log_err("Can't create ACPI configuration table\n");
+               return -EINTR;
+       }
+
+       log_debug("- wrote 'acpi' to %llx, end %llx\n", table_addr, table_end);
+       if (table_end - table_addr > TABLE_SIZE) {
+               log_err("Out of space for configuration tables: need %llx, have %x\n",
+                       table_end - table_addr, TABLE_SIZE);
+               return log_msg_ret("acpi", -ENOSPC);
+       }
+       gd->arch.table_end_high = table_end;
+
+       log_debug("- done writing tables\n");
+
+       return 0;
+}
+
+EVENT_SPY_SIMPLE(EVT_LAST_STAGE_INIT, alloc_write_acpi_tables);
test/py/tests/test_event_dump.py +1 -1
index e282c67335..459bfa26bb 100644
@@ -18,6 +18,7 @@ def test_event_dump(u_boot_console):
 --------------------  ------------------------------  ------------------------------
 EVT_FT_FIXUP          bootmeth_vbe_ft_fixup           .*boot/vbe_request.c:.*
 EVT_FT_FIXUP          bootmeth_vbe_simple_ft_fixup    .*boot/vbe_simple_os.c:.*
+EVT_LAST_STAGE_INIT   alloc_write_acpi_tables         .*lib/efi_loader/efi_acpi.c:.*
 EVT_LAST_STAGE_INIT   install_smbios_table            .*lib/efi_loader/efi_smbios.c:.*
 EVT_MISC_INIT_F       sandbox_early_getopt_check      .*arch/sandbox/cpu/start.c:.*
 EVT_TEST              h_adder_simple                  .*test/common/event.c:'''
--
Quoted 2 lines

2.46.0

REgards,
Simon

#19 lore raw

Re: [PATCH v4 14/35] efi_loader: Allocate and write ACPI tables

Hi Simon,

Quoted 108 lines · Simon Glass

Hi Patrick,

Quoted 103 lines · Patrick Rudolph

Allocate memory for ACPI tables inside the efi_loader and write out the tables similar to SMBIOS tables. When ACPI is enabled and wasn't installed in other places, install the ACPI table in EFI. Since EFI is necessary to pass the ACPI table location when FDT isn't used, there's no need to install it separately.

When CONFIG_BLOBLIST_TABLES is set the tables will be stored in a bloblist. The tables are still passed to the OS using EFI.

This allows non x86 platforms to boot using ACPI only in case the EFI loader is being used.

TEST: Booted QEMU SBSA (no QFW) using EFI and ACPI only.

---
Changelog v3:
- Drop memalign and use efi_allocate_pages
- Use log_debug instead of debug
- Clarify commit message
- Skip writing ACPI tables on sandbox
- Rename function
- Add function comment

---
 lib/efi_loader/efi_acpi.c        | 80 +++++++++++++++++++++++++++++++-
 test/py/tests/test_event_dump.py |  1 +
 2 files changed, 79 insertions(+), 2 deletions(-)
lib/efi_loader/efi_acpi.c +48 -2
index 67bd7f8ca2..9d38d0060c 100644
@@ -6,15 +6,23 @@
  */
 
 #include <efi_loader.h>
-#include <log.h>
-#include <mapmem.h>
 #include <acpi/acpi_table.h>
 #include <asm/global_data.h>
+#include <asm/io.h>
+#include <bloblist.h>
+#include <linux/sizes.h>
+#include <linux/log2.h>
+#include <log.h>
+#include <malloc.h>
+#include <mapmem.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
 static const efi_guid_t acpi_guid = EFI_ACPI_TABLE_GUID;
 
+enum {
+       TABLE_SIZE      = SZ_64K,
+};
 /*
  * Install the ACPI table as a configuration table.
  *
@@ -47,3 +55,71 @@ efi_status_t efi_acpi_register(void)
        return efi_install_configuration_table(&acpi_guid,
                                               (void *)(ulong)addr);
 }
+
+/*
+ * Allocate memory for ACPI tables and write ACPI tables to the
+ * allocated buffer.
+ *
+ * Return:     status code
+ */
+static int alloc_write_acpi_tables(void)
+{
+       u64 table_addr, table_end;
+       u64 new_acpi_addr = 0;
+       efi_uintn_t pages;
+       efi_status_t ret;
+       void *addr;
+
+       if (!IS_ENABLED(CONFIG_GENERATE_ACPI_TABLE))
+               return 0;
+
+       if (IS_ENABLED(CONFIG_X86) ||
+           IS_ENABLED(CONFIG_QFW_ACPI) ||
+           IS_ENABLED(CONFIG_SANDBOX)) {
+               log_debug("Skipping writing ACPI tables as already done\n");
+               return 0;
+       }
+
+       /* Align the table to a 4KB boundary to keep EFI happy */
+       if (IS_ENABLED(CONFIG_BLOBLIST_TABLES)) {
+               addr = bloblist_add(BLOBLISTT_ACPI_TABLES, TABLE_SIZE,
+                                   ilog2(SZ_4K));
+
+               if (!addr)
+                       return log_msg_ret("mem", -ENOMEM);
+       } else {
+               pages = efi_size_in_pages(TABLE_SIZE);
+
+               ret = efi_allocate_pages(EFI_ALLOCATE_ANY_PAGES,
+                                        EFI_ACPI_RECLAIM_MEMORY,
+                                        pages, &new_acpi_addr);
Quoted 8 lines

lib/efi_loader/efi_acpi.c efi_status_t efi_acpi_register(void) · line 101

Quoted 6 lines
lib/efi_loader/efi_acpi.c +6 -0
+               if (ret != EFI_SUCCESS)
+                       return log_msg_ret("mem", -ENOMEM);
+
+               addr = (void *)(uintptr_t)new_acpi_addr;
+       }
+

The tables should be written regardless of whether EFI_LOADER is enabled.

*Why*? How do you expect to hand them over to the OS?

Quoted 2 lines

Can we drop this else clause? We should always use the bloblist.

Both Heinrich and I said the exact opposite. Unless there's a perfectly good reason why we should keep them in bloblist memory, I'd like us to do that

Thanks
/Ilias

Quoted 45 lines

We should use efi_add_memory_map() to add to the memory map.

Quoted 37 lines
lib/efi_loader/efi_acpi.c +24 -0
+       table_addr = virt_to_phys(addr);
+
+       gd->arch.table_start_high = table_addr;
+
+       table_end = write_acpi_tables(table_addr);
+       if (!table_end) {
+               log_err("Can't create ACPI configuration table\n");
+               return -EINTR;
+       }
+
+       log_debug("- wrote 'acpi' to %llx, end %llx\n", table_addr, table_end);
+       if (table_end - table_addr > TABLE_SIZE) {
+               log_err("Out of space for configuration tables: need %llx, have %x\n",
+                       table_end - table_addr, TABLE_SIZE);
+               return log_msg_ret("acpi", -ENOSPC);
+       }
+       gd->arch.table_end_high = table_end;
+
+       log_debug("- done writing tables\n");
+
+       return 0;
+}
+
+EVENT_SPY_SIMPLE(EVT_LAST_STAGE_INIT, alloc_write_acpi_tables);
test/py/tests/test_event_dump.py +1 -1
index e282c67335..459bfa26bb 100644
@@ -18,6 +18,7 @@ def test_event_dump(u_boot_console):
 --------------------  ------------------------------  ------------------------------
 EVT_FT_FIXUP          bootmeth_vbe_ft_fixup           .*boot/vbe_request.c:.*
 EVT_FT_FIXUP          bootmeth_vbe_simple_ft_fixup    .*boot/vbe_simple_os.c:.*
+EVT_LAST_STAGE_INIT   alloc_write_acpi_tables         .*lib/efi_loader/efi_acpi.c:.*
 EVT_LAST_STAGE_INIT   install_smbios_table            .*lib/efi_loader/efi_smbios.c:.*
 EVT_MISC_INIT_F       sandbox_early_getopt_check      .*arch/sandbox/cpu/start.c:.*
 EVT_TEST              h_adder_simple                  .*test/common/event.c:'''
--
Quoted 2 lines

2.46.0

REgards,
Simon

#20 lore raw

Re: [PATCH v4 14/35] efi_loader: Allocate and write ACPI tables

Hi Ilias,

Quoted 122 lines · Ilias Apalodimas

Hi Simon,

Quoted 108 lines · Simon Glass

Hi Patrick,

Quoted 103 lines · Patrick Rudolph

Allocate memory for ACPI tables inside the efi_loader and write out the tables similar to SMBIOS tables. When ACPI is enabled and wasn't installed in other places, install the ACPI table in EFI. Since EFI is necessary to pass the ACPI table location when FDT isn't used, there's no need to install it separately.

When CONFIG_BLOBLIST_TABLES is set the tables will be stored in a bloblist. The tables are still passed to the OS using EFI.

This allows non x86 platforms to boot using ACPI only in case the EFI loader is being used.

TEST: Booted QEMU SBSA (no QFW) using EFI and ACPI only.

---
Changelog v3:
- Drop memalign and use efi_allocate_pages
- Use log_debug instead of debug
- Clarify commit message
- Skip writing ACPI tables on sandbox
- Rename function
- Add function comment

---
 lib/efi_loader/efi_acpi.c        | 80 +++++++++++++++++++++++++++++++-
 test/py/tests/test_event_dump.py |  1 +
 2 files changed, 79 insertions(+), 2 deletions(-)
lib/efi_loader/efi_acpi.c +48 -2
index 67bd7f8ca2..9d38d0060c 100644
@@ -6,15 +6,23 @@
  */
 
 #include <efi_loader.h>
-#include <log.h>
-#include <mapmem.h>
 #include <acpi/acpi_table.h>
 #include <asm/global_data.h>
+#include <asm/io.h>
+#include <bloblist.h>
+#include <linux/sizes.h>
+#include <linux/log2.h>
+#include <log.h>
+#include <malloc.h>
+#include <mapmem.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
 static const efi_guid_t acpi_guid = EFI_ACPI_TABLE_GUID;
 
+enum {
+       TABLE_SIZE      = SZ_64K,
+};
 /*
  * Install the ACPI table as a configuration table.
  *
@@ -47,3 +55,71 @@ efi_status_t efi_acpi_register(void)
        return efi_install_configuration_table(&acpi_guid,
                                               (void *)(ulong)addr);
 }
+
+/*
+ * Allocate memory for ACPI tables and write ACPI tables to the
+ * allocated buffer.
+ *
+ * Return:     status code
+ */
+static int alloc_write_acpi_tables(void)
+{
+       u64 table_addr, table_end;
+       u64 new_acpi_addr = 0;
+       efi_uintn_t pages;
+       efi_status_t ret;
+       void *addr;
+
+       if (!IS_ENABLED(CONFIG_GENERATE_ACPI_TABLE))
+               return 0;
+
+       if (IS_ENABLED(CONFIG_X86) ||
+           IS_ENABLED(CONFIG_QFW_ACPI) ||
+           IS_ENABLED(CONFIG_SANDBOX)) {
+               log_debug("Skipping writing ACPI tables as already done\n");
+               return 0;
+       }
+
+       /* Align the table to a 4KB boundary to keep EFI happy */
+       if (IS_ENABLED(CONFIG_BLOBLIST_TABLES)) {
+               addr = bloblist_add(BLOBLISTT_ACPI_TABLES, TABLE_SIZE,
+                                   ilog2(SZ_4K));
+
+               if (!addr)
+                       return log_msg_ret("mem", -ENOMEM);
+       } else {
+               pages = efi_size_in_pages(TABLE_SIZE);
+
+               ret = efi_allocate_pages(EFI_ALLOCATE_ANY_PAGES,
+                                        EFI_ACPI_RECLAIM_MEMORY,
+                                        pages, &new_acpi_addr);
Quoted 8 lines

lib/efi_loader/efi_acpi.c efi_status_t efi_acpi_register(void) · line 101

Quoted 6 lines
lib/efi_loader/efi_acpi.c +6 -0
+               if (ret != EFI_SUCCESS)
+                       return log_msg_ret("mem", -ENOMEM);
+
+               addr = (void *)(uintptr_t)new_acpi_addr;
+       }
+

The tables should be written regardless of whether EFI_LOADER is enabled.

Quoted 1 line

*Why*? How do you expect to hand them over to the OS?

Why - because boards which need ACPI tables to boot should generate them; also this happens when U-Boot starts up, in last_stage_init() How - it isn't possible, but eventually I suppose it will be, once we have a use case for booting with ACPI but without EFI

Quoted 7 lines
Quoted 3 lines

Can we drop this else clause? We should always use the bloblist.

Both Heinrich and I said the exact opposite. Unless there's a perfectly good reason why we should keep them in bloblist memory, I'd like us to do that

The main reason is that we should not be putting things in memory between the start of RAM and the bottom of the U-Boot area. That region of memory is supposed to be for loading images. Most boards hard-code the image-load addresses in environment variables. But even if they didn't, we should not be using that memory for U-Boot data.

Another reason is that the bloblist is designed for this, for keeping tables in a small, contiguous area of memory, so that when passed to Linux they are not spread all over the place.

Regards,
Simon

Quoted 48 lines

Thanks
/Ilias

Quoted 45 lines

We should use efi_add_memory_map() to add to the memory map.

Quoted 37 lines
lib/efi_loader/efi_acpi.c +24 -0
+       table_addr = virt_to_phys(addr);
+
+       gd->arch.table_start_high = table_addr;
+
+       table_end = write_acpi_tables(table_addr);
+       if (!table_end) {
+               log_err("Can't create ACPI configuration table\n");
+               return -EINTR;
+       }
+
+       log_debug("- wrote 'acpi' to %llx, end %llx\n", table_addr, table_end);
+       if (table_end - table_addr > TABLE_SIZE) {
+               log_err("Out of space for configuration tables: need %llx, have %x\n",
+                       table_end - table_addr, TABLE_SIZE);
+               return log_msg_ret("acpi", -ENOSPC);
+       }
+       gd->arch.table_end_high = table_end;
+
+       log_debug("- done writing tables\n");
+
+       return 0;
+}
+
+EVENT_SPY_SIMPLE(EVT_LAST_STAGE_INIT, alloc_write_acpi_tables);
test/py/tests/test_event_dump.py +1 -1
index e282c67335..459bfa26bb 100644
@@ -18,6 +18,7 @@ def test_event_dump(u_boot_console):
 --------------------  ------------------------------  ------------------------------
 EVT_FT_FIXUP          bootmeth_vbe_ft_fixup           .*boot/vbe_request.c:.*
 EVT_FT_FIXUP          bootmeth_vbe_simple_ft_fixup    .*boot/vbe_simple_os.c:.*
+EVT_LAST_STAGE_INIT   alloc_write_acpi_tables         .*lib/efi_loader/efi_acpi.c:.*
 EVT_LAST_STAGE_INIT   install_smbios_table            .*lib/efi_loader/efi_smbios.c:.*
 EVT_MISC_INIT_F       sandbox_early_getopt_check      .*arch/sandbox/cpu/start.c:.*
 EVT_TEST              h_adder_simple                  .*test/common/event.c:'''
--
Quoted 2 lines

2.46.0

REgards,
Simon

#21 lore raw

Re: [PATCH v4 14/35] efi_loader: Allocate and write ACPI tables

Hi Simon,

Quoted 3 lines · Simon Glass

Hi Ilias,

[...]

Quoted 18 lines
Quoted 18 lines
Quoted 17 lines
Quoted 5 lines
lib/efi_loader/efi_acpi.c +5 -0
+
+               if (!addr)
+                       return log_msg_ret("mem", -ENOMEM);
+       } else {
+               pages = efi_size_in_pages(TABLE_SIZE);

lib/efi_loader/efi_acpi.c efi_status_t efi_acpi_register(void) · line 101

Quoted 10 lines
lib/efi_loader/efi_acpi.c +10 -0
+
+               ret = efi_allocate_pages(EFI_ALLOCATE_ANY_PAGES,
+                                        EFI_ACPI_RECLAIM_MEMORY,
+                                        pages, &new_acpi_addr);
+               if (ret != EFI_SUCCESS)
+                       return log_msg_ret("mem", -ENOMEM);
+
+               addr = (void *)(uintptr_t)new_acpi_addr;
+       }
+

The tables should be written regardless of whether EFI_LOADER is enabled.

Quoted 4 lines
Quoted 1 line

*Why*? How do you expect to hand them over to the OS?

Why - because boards which need ACPI tables to boot should generate them;

Noone argued that.

Quoted 3 lines

also this happens when U-Boot starts up, in last_stage_init() How - it isn't possible, but eventually I suppose it will be, once we have a use case for booting with ACPI but without EFI

Are you aware of such an OS? If not, we can accept the patches when we have a reason.
I remember patches being hard NAK'ed on using DTs to pass the ACPI table address in the past.

Quoted 9 lines
Quoted 8 lines
Quoted 4 lines

Can we drop this else clause? We should always use the bloblist.

Both Heinrich and I said the exact opposite. Unless there's a perfectly good reason why we should keep them in bloblist memory, I'd like us to do that

Quoted 5 lines

The main reason is that we should not be putting things in memory between the start of RAM and the bottom of the U-Boot area. That region of memory is supposed to be for loading images. Most boards hard-code the image-load addresses in environment variables. But even if they didn't, we should not be using that memory for U-Boot data.

EFI allows you to request a specific address to use. We can choose one that fits the requirements

Quoted 4 lines

Another reason is that the bloblist is designed for this, for keeping tables in a small, contiguous area of memory, so that when passed to Linux they are not spread all over the place.

Linux does not and will not read tables from a bloblist though

Thanks
/Ilias

Quoted 53 lines

Regards,
Simon

Quoted 48 lines

Thanks
/Ilias

Quoted 45 lines

We should use efi_add_memory_map() to add to the memory map.

Quoted 37 lines
lib/efi_loader/efi_acpi.c +24 -0
+       table_addr = virt_to_phys(addr);
+
+       gd->arch.table_start_high = table_addr;
+
+       table_end = write_acpi_tables(table_addr);
+       if (!table_end) {
+               log_err("Can't create ACPI configuration table\n");
+               return -EINTR;
+       }
+
+       log_debug("- wrote 'acpi' to %llx, end %llx\n", table_addr, table_end);
+       if (table_end - table_addr > TABLE_SIZE) {
+               log_err("Out of space for configuration tables: need %llx, have %x\n",
+                       table_end - table_addr, TABLE_SIZE);
+               return log_msg_ret("acpi", -ENOSPC);
+       }
+       gd->arch.table_end_high = table_end;
+
+       log_debug("- done writing tables\n");
+
+       return 0;
+}
+
+EVENT_SPY_SIMPLE(EVT_LAST_STAGE_INIT, alloc_write_acpi_tables);
test/py/tests/test_event_dump.py +1 -1
index e282c67335..459bfa26bb 100644
@@ -18,6 +18,7 @@ def test_event_dump(u_boot_console):
 --------------------  ------------------------------  ------------------------------
 EVT_FT_FIXUP          bootmeth_vbe_ft_fixup           .*boot/vbe_request.c:.*
 EVT_FT_FIXUP          bootmeth_vbe_simple_ft_fixup    .*boot/vbe_simple_os.c:.*
+EVT_LAST_STAGE_INIT   alloc_write_acpi_tables         .*lib/efi_loader/efi_acpi.c:.*
 EVT_LAST_STAGE_INIT   install_smbios_table            .*lib/efi_loader/efi_smbios.c:.*
 EVT_MISC_INIT_F       sandbox_early_getopt_check      .*arch/sandbox/cpu/start.c:.*
 EVT_TEST              h_adder_simple                  .*test/common/event.c:'''
--
Quoted 2 lines

2.46.0

REgards,
Simon

#22 lore raw

Re: [PATCH v4 14/35] efi_loader: Allocate and write ACPI tables

Quoted 63 lines · Ilias Apalodimas

Hi Simon,

Quoted 3 lines · Simon Glass

Hi Ilias,

[...]

Quoted 18 lines
Quoted 18 lines
Quoted 17 lines
Quoted 5 lines
lib/efi_loader/efi_acpi.c +5 -0
+
+               if (!addr)
+                       return log_msg_ret("mem", -ENOMEM);
+       } else {
+               pages = efi_size_in_pages(TABLE_SIZE);

lib/efi_loader/efi_acpi.c efi_status_t efi_acpi_register(void) · line 101

Quoted 10 lines
lib/efi_loader/efi_acpi.c +10 -0
+
+               ret = efi_allocate_pages(EFI_ALLOCATE_ANY_PAGES,
+                                        EFI_ACPI_RECLAIM_MEMORY,
+                                        pages, &new_acpi_addr);
+               if (ret != EFI_SUCCESS)
+                       return log_msg_ret("mem", -ENOMEM);
+
+               addr = (void *)(uintptr_t)new_acpi_addr;
+       }
+

The tables should be written regardless of whether EFI_LOADER is enabled.

Quoted 4 lines
Quoted 1 line

*Why*? How do you expect to hand them over to the OS?

Why - because boards which need ACPI tables to boot should generate them;

Noone argued that.

Quoted 3 lines

also this happens when U-Boot starts up, in last_stage_init() How - it isn't possible, but eventually I suppose it will be, once we have a use case for booting with ACPI but without EFI

Are you aware of such an OS? If not, we can accept the patches when we have a reason.
I remember patches being hard NAK'ed on using DTs to pass the ACPI table address in the past.

Quoted 9 lines
Quoted 8 lines
Quoted 4 lines

Can we drop this else clause? We should always use the bloblist.

Both Heinrich and I said the exact opposite. Unless there's a perfectly good reason why we should keep them in bloblist memory, I'd like us to do that

Quoted 5 lines

The main reason is that we should not be putting things in memory between the start of RAM and the bottom of the U-Boot area. That region of memory is supposed to be for loading images. Most boards hard-code the image-load addresses in environment variables. But even if they didn't, we should not be using that memory for U-Boot data.

EFI allows you to request a specific address to use. We can choose one that fits the requirements

Quoted 1 line
Quoted 5 lines
Quoted 3 lines

Another reason is that the bloblist is designed for this, for keeping tables in a small, contiguous area of memory, so that when passed to Linux they are not spread all over the place.

Linux does not and will not read tables from a bloblist though

Also it's ACPI_RECLAIM memory. The OS doesn't really care if it's scattered or not. It is up to the OS to reuse it.

/Ilias

Quoted 59 lines

Thanks
/Ilias

Quoted 53 lines

Regards,
Simon

Quoted 48 lines

Thanks
/Ilias

Quoted 45 lines

We should use efi_add_memory_map() to add to the memory map.

Quoted 37 lines
lib/efi_loader/efi_acpi.c +24 -0
+       table_addr = virt_to_phys(addr);
+
+       gd->arch.table_start_high = table_addr;
+
+       table_end = write_acpi_tables(table_addr);
+       if (!table_end) {
+               log_err("Can't create ACPI configuration table\n");
+               return -EINTR;
+       }
+
+       log_debug("- wrote 'acpi' to %llx, end %llx\n", table_addr, table_end);
+       if (table_end - table_addr > TABLE_SIZE) {
+               log_err("Out of space for configuration tables: need %llx, have %x\n",
+                       table_end - table_addr, TABLE_SIZE);
+               return log_msg_ret("acpi", -ENOSPC);
+       }
+       gd->arch.table_end_high = table_end;
+
+       log_debug("- done writing tables\n");
+
+       return 0;
+}
+
+EVENT_SPY_SIMPLE(EVT_LAST_STAGE_INIT, alloc_write_acpi_tables);
test/py/tests/test_event_dump.py +1 -1
index e282c67335..459bfa26bb 100644
@@ -18,6 +18,7 @@ def test_event_dump(u_boot_console):
 --------------------  ------------------------------  ------------------------------
 EVT_FT_FIXUP          bootmeth_vbe_ft_fixup           .*boot/vbe_request.c:.*
 EVT_FT_FIXUP          bootmeth_vbe_simple_ft_fixup    .*boot/vbe_simple_os.c:.*
+EVT_LAST_STAGE_INIT   alloc_write_acpi_tables         .*lib/efi_loader/efi_acpi.c:.*
 EVT_LAST_STAGE_INIT   install_smbios_table            .*lib/efi_loader/efi_smbios.c:.*
 EVT_MISC_INIT_F       sandbox_early_getopt_check      .*arch/sandbox/cpu/start.c:.*
 EVT_TEST              h_adder_simple                  .*test/common/event.c:'''
--
Quoted 2 lines

2.46.0

REgards,
Simon

#23 lore raw

Re: [PATCH v4 14/35] efi_loader: Allocate and write ACPI tables

In reply to Ilias Apalodimas

Hi Ilias,

Quoted 33 lines · Ilias Apalodimas

Hi Simon,

Quoted 3 lines · Simon Glass

Hi Ilias,

[...]

Quoted 18 lines
Quoted 18 lines
Quoted 17 lines
Quoted 5 lines
lib/efi_loader/efi_acpi.c +5 -0
+
+               if (!addr)
+                       return log_msg_ret("mem", -ENOMEM);
+       } else {
+               pages = efi_size_in_pages(TABLE_SIZE);

lib/efi_loader/efi_acpi.c efi_status_t efi_acpi_register(void) · line 101

Quoted 10 lines
lib/efi_loader/efi_acpi.c +10 -0
+
+               ret = efi_allocate_pages(EFI_ALLOCATE_ANY_PAGES,
+                                        EFI_ACPI_RECLAIM_MEMORY,
+                                        pages, &new_acpi_addr);
+               if (ret != EFI_SUCCESS)
+                       return log_msg_ret("mem", -ENOMEM);
+
+               addr = (void *)(uintptr_t)new_acpi_addr;
+       }
+

The tables should be written regardless of whether EFI_LOADER is enabled.

Quoted 4 lines
Quoted 1 line

*Why*? How do you expect to hand them over to the OS?

Why - because boards which need ACPI tables to boot should generate them;

Quoted 8 lines

Noone argued that.

Quoted 3 lines

also this happens when U-Boot starts up, in last_stage_init() How - it isn't possible, but eventually I suppose it will be, once we have a use case for booting with ACPI but without EFI

Are you aware of such an OS? If not, we can accept the patches when we have a reason.

Which patches? This is how it works today. We set up the tables in last_stage_init(), so they can be examined while in U-Boot.

It is the patches to change this which I object to.

Quoted 2 lines

I remember patches being hard NAK'ed on using DTs to pass the ACPI table address in the past.

Yes, I believe Bytedance carries a patch locally for that :-)

Quoted 10 lines
Quoted 10 lines
Quoted 9 lines
Quoted 5 lines

Can we drop this else clause? We should always use the bloblist.

Both Heinrich and I said the exact opposite. Unless there's a perfectly good reason why we should keep them in bloblist memory, I'd like us to do that

Quoted 8 lines
Quoted 5 lines

The main reason is that we should not be putting things in memory between the start of RAM and the bottom of the U-Boot area. That region of memory is supposed to be for loading images. Most boards hard-code the image-load addresses in environment variables. But even if they didn't, we should not be using that memory for U-Boot data.

EFI allows you to request a specific address to use. We can choose one that fits the requirements

So long as it is in U-Boot's space, that is fine. I just sent a patch about relocation which covers this. It occured to me that this feature of U-Boot, which I have always assumed was common knowledge, may have not been noticed.

Quoted 6 lines
Quoted 4 lines

Another reason is that the bloblist is designed for this, for keeping tables in a small, contiguous area of memory, so that when passed to Linux they are not spread all over the place.

Linux does not and will not read tables from a bloblist though

Indeed. There really isn't any point, anyway, since there are other ways of passing the tables along...except for ACPI with FDT but that isn't a valid use case for Linux so far.

Regards,
Simon

[..]

#24 lore raw

Re: [PATCH v4 14/35] efi_loader: Allocate and write ACPI tables

Hi Simon,

Quoted 44 lines · Simon Glass

Hi Ilias,

Quoted 39 lines · Ilias Apalodimas

Hi Simon,

Quoted 3 lines · Simon Glass

Hi Ilias,

[...]

Quoted 18 lines
Quoted 18 lines
Quoted 17 lines
Quoted 5 lines
lib/efi_loader/efi_acpi.c +5 -0
+
+               if (!addr)
+                       return log_msg_ret("mem", -ENOMEM);
+       } else {
+               pages = efi_size_in_pages(TABLE_SIZE);

lib/efi_loader/efi_acpi.c efi_status_t efi_acpi_register(void) · line 101

Quoted 10 lines
lib/efi_loader/efi_acpi.c +10 -0
+
+               ret = efi_allocate_pages(EFI_ALLOCATE_ANY_PAGES,
+                                        EFI_ACPI_RECLAIM_MEMORY,
+                                        pages, &new_acpi_addr);
+               if (ret != EFI_SUCCESS)
+                       return log_msg_ret("mem", -ENOMEM);
+
+               addr = (void *)(uintptr_t)new_acpi_addr;
+       }
+

The tables should be written regardless of whether EFI_LOADER is enabled.

Quoted 4 lines
Quoted 1 line

*Why*? How do you expect to hand them over to the OS?

Why - because boards which need ACPI tables to boot should generate them;

Noone argued that.

Quoted 3 lines

also this happens when U-Boot starts up, in last_stage_init() How - it isn't possible, but eventually I suppose it will be, once we have a use case for booting with ACPI but without EFI

Quoted 5 lines
Quoted 2 lines

Are you aware of such an OS? If not, we can accept the patches when we have a reason.

Which patches? This is how it works today. We set up the tables in last_stage_init(), so they can be examined while in U-Boot.

What I mean, is that until we have a valid use case to store the ACPI in a bloblist, I prefer them being allocated with proper EFI memory backing

Quoted 7 lines

It is the patches to change this which I object to.

Quoted 2 lines

I remember patches being hard NAK'ed on using DTs to pass the ACPI table address in the past.

Yes, I believe Bytedance carries a patch locally for that :-)

Exactly

Quoted 30 lines
Quoted 11 lines
Quoted 11 lines
Quoted 10 lines
Quoted 6 lines

Can we drop this else clause? We should always use the bloblist.

Both Heinrich and I said the exact opposite. Unless there's a perfectly good reason why we should keep them in bloblist memory, I'd like us to do that

Quoted 8 lines
Quoted 5 lines

The main reason is that we should not be putting things in memory between the start of RAM and the bottom of the U-Boot area. That region of memory is supposed to be for loading images. Most boards hard-code the image-load addresses in environment variables. But even if they didn't, we should not be using that memory for U-Boot data.

EFI allows you to request a specific address to use. We can choose one that fits the requirements

So long as it is in U-Boot's space, that is fine. I just sent a patch about relocation which covers this. It occured to me that this feature of U-Boot, which I have always assumed was common knowledge, may have not been noticed.

Quoted 5 lines
Quoted 4 lines

Another reason is that the bloblist is designed for this, for keeping tables in a small, contiguous area of memory, so that when passed to Linux they are not spread all over the place.

Quoted 5 lines
Quoted 1 line

Linux does not and will not read tables from a bloblist though

Indeed. There really isn't any point, anyway, since there are other ways of passing the tables along...except for ACPI with FDT but that isn't a valid use case for Linux so far.

What we are trying to do with EFI is to stay as close to the spec and the current OS implementations as possible. So again, please allocate EFI memory for the ACPI tables. The patches to convert it to bloblist allocating them are minimal, so we can do it, once there's an actuall need for it.

Thanks
/Ilias

Quoted 5 lines

Regards,
Simon

[..]

#25 lore raw

Re: [PATCH v4 14/35] efi_loader: Allocate and write ACPI tables

Hi Ilias,

Quoted 51 lines · Ilias Apalodimas

Hi Simon,

Quoted 47 lines · Simon Glass

Hi Ilias,

Quoted 41 lines · Ilias Apalodimas

Hi Simon,

Quoted 3 lines · Simon Glass

Hi Ilias,

[...]

Quoted 18 lines
Quoted 18 lines
Quoted 17 lines
Quoted 5 lines
(quoted diff) +5 -0
+
+               if (!addr)
+                       return log_msg_ret("mem", -ENOMEM);
+       } else {
+               pages = efi_size_in_pages(TABLE_SIZE);

Review

Quoted 10 lines
(quoted diff) +10 -0
+
+               ret = efi_allocate_pages(EFI_ALLOCATE_ANY_PAGES,
+                                        EFI_ACPI_RECLAIM_MEMORY,
+                                        pages, &new_acpi_addr);
+               if (ret != EFI_SUCCESS)
+                       return log_msg_ret("mem", -ENOMEM);
+
+               addr = (void *)(uintptr_t)new_acpi_addr;
+       }
+

The tables should be written regardless of whether EFI_LOADER is enabled.

Quoted 4 lines
Quoted 1 line

*Why*? How do you expect to hand them over to the OS?

Why - because boards which need ACPI tables to boot should generate them;

Noone argued that.

Quoted 3 lines

also this happens when U-Boot starts up, in last_stage_init() How - it isn't possible, but eventually I suppose it will be, once we have a use case for booting with ACPI but without EFI

Are you aware of such an OS? If not, we can accept the patches when we have a reason.

Quoted 6 lines
Quoted 2 lines

Which patches? This is how it works today. We set up the tables in last_stage_init(), so they can be examined while in U-Boot.

What I mean, is that until we have a valid use case to store the ACPI in a bloblist, I prefer them being allocated with proper EFI memory backing

I'm going to assert prior art here. If ARM is to have ACPI in U-Boot, it should follow the most recent x86 approach and store it in the bloblist. That is what the blloblist is for. It also avoids using memory below the U-Boot area, which is not allowed.

Quoted 47 lines
Quoted 8 lines

It is the patches to change this which I object to.

Quoted 2 lines

I remember patches being hard NAK'ed on using DTs to pass the ACPI table address in the past.

Yes, I believe Bytedance carries a patch locally for that :-)

Exactly

Quoted 30 lines
Quoted 11 lines
Quoted 11 lines
Quoted 10 lines
Quoted 6 lines

Can we drop this else clause? We should always use the bloblist.

Both Heinrich and I said the exact opposite. Unless there's a perfectly good reason why we should keep them in bloblist memory, I'd like us to do that

Quoted 8 lines
Quoted 5 lines

The main reason is that we should not be putting things in memory between the start of RAM and the bottom of the U-Boot area. That region of memory is supposed to be for loading images. Most boards hard-code the image-load addresses in environment variables. But even if they didn't, we should not be using that memory for U-Boot data.

EFI allows you to request a specific address to use. We can choose one that fits the requirements

So long as it is in U-Boot's space, that is fine. I just sent a patch about relocation which covers this. It occured to me that this feature of U-Boot, which I have always assumed was common knowledge, may have not been noticed.

Quoted 5 lines
Quoted 4 lines

Another reason is that the bloblist is designed for this, for keeping tables in a small, contiguous area of memory, so that when passed to Linux they are not spread all over the place.

Quoted 5 lines
Quoted 1 line

Linux does not and will not read tables from a bloblist though

Indeed. There really isn't any point, anyway, since there are other ways of passing the tables along...except for ACPI with FDT but that isn't a valid use case for Linux so far.

Quoted 5 lines

What we are trying to do with EFI is to stay as close to the spec and the current OS implementations as possible. So again, please allocate EFI memory for the ACPI tables. The patches to convert it to bloblist allocating them are minimal, so we can do it, once there's an actuall need for it.

As it stands today, efi_acpi_register() does not do an EFI allocation, it just adds the existing allocation to the EFI tables. This works fine for x86 - see arch/x86/lib/tables.c - so I would like ARM to do the same. The need for it is (as above) that we should ensure that memory usage is within the U-Boot area. This is something which bloblist handles automatically. It is also nice to see all the tables in one place with 'bloblist list'

Regards,
Simon

#26 lore raw

Re: [PATCH v4 14/35] efi_loader: Allocate and write ACPI tables

Hi Simon,

Quoted 121 lines · Simon Glass

Hi Ilias,

Quoted 51 lines · Ilias Apalodimas

Hi Simon,

Quoted 47 lines · Simon Glass

Hi Ilias,

Quoted 41 lines · Ilias Apalodimas

Hi Simon,

Quoted 3 lines · Simon Glass

Hi Ilias,

[...]

Quoted 18 lines
Quoted 18 lines
Quoted 17 lines
Quoted 5 lines
(quoted diff) +5 -0
+
+               if (!addr)
+                       return log_msg_ret("mem", -ENOMEM);
+       } else {
+               pages = efi_size_in_pages(TABLE_SIZE);

Review

Quoted 10 lines
(quoted diff) +10 -0
+
+               ret = efi_allocate_pages(EFI_ALLOCATE_ANY_PAGES,
+                                        EFI_ACPI_RECLAIM_MEMORY,
+                                        pages, &new_acpi_addr);
+               if (ret != EFI_SUCCESS)
+                       return log_msg_ret("mem", -ENOMEM);
+
+               addr = (void *)(uintptr_t)new_acpi_addr;
+       }
+

The tables should be written regardless of whether EFI_LOADER is enabled.

Quoted 4 lines
Quoted 1 line

*Why*? How do you expect to hand them over to the OS?

Why - because boards which need ACPI tables to boot should generate them;

Noone argued that.

Quoted 3 lines

also this happens when U-Boot starts up, in last_stage_init() How - it isn't possible, but eventually I suppose it will be, once we have a use case for booting with ACPI but without EFI

Are you aware of such an OS? If not, we can accept the patches when we have a reason.

Quoted 6 lines
Quoted 2 lines

Which patches? This is how it works today. We set up the tables in last_stage_init(), so they can be examined while in U-Boot.

What I mean, is that until we have a valid use case to store the ACPI in a bloblist, I prefer them being allocated with proper EFI memory backing

I'm going to assert prior art here. If ARM is to have ACPI in U-Boot, it should follow the most recent x86 approach and store it in the bloblist. That is what the blloblist is for. It also avoids using memory below the U-Boot area, which is not allowed.

Quoted 47 lines
Quoted 8 lines

It is the patches to change this which I object to.

Quoted 2 lines

I remember patches being hard NAK'ed on using DTs to pass the ACPI table address in the past.

Yes, I believe Bytedance carries a patch locally for that :-)

Exactly

Quoted 30 lines
Quoted 11 lines
Quoted 11 lines
Quoted 10 lines
Quoted 6 lines

Can we drop this else clause? We should always use the bloblist.

Both Heinrich and I said the exact opposite. Unless there's a perfectly good reason why we should keep them in bloblist memory, I'd like us to do that

Quoted 8 lines
Quoted 5 lines

The main reason is that we should not be putting things in memory between the start of RAM and the bottom of the U-Boot area. That region of memory is supposed to be for loading images. Most boards hard-code the image-load addresses in environment variables. But even if they didn't, we should not be using that memory for U-Boot data.

EFI allows you to request a specific address to use. We can choose one that fits the requirements

So long as it is in U-Boot's space, that is fine. I just sent a patch about relocation which covers this. It occured to me that this feature of U-Boot, which I have always assumed was common knowledge, may have not been noticed.

Quoted 5 lines
Quoted 4 lines

Another reason is that the bloblist is designed for this, for keeping tables in a small, contiguous area of memory, so that when passed to Linux they are not spread all over the place.

Quoted 5 lines
Quoted 1 line

Linux does not and will not read tables from a bloblist though

Indeed. There really isn't any point, anyway, since there are other ways of passing the tables along...except for ACPI with FDT but that isn't a valid use case for Linux so far.

Quoted 5 lines

What we are trying to do with EFI is to stay as close to the spec and the current OS implementations as possible. So again, please allocate EFI memory for the ACPI tables. The patches to convert it to bloblist allocating them are minimal, so we can do it, once there's an actuall need for it.

Quoted 8 lines

As it stands today, efi_acpi_register() does not do an EFI allocation, it just adds the existing allocation to the EFI tables. This works fine for x86 - see arch/x86/lib/tables.c - so I would like ARM to do the same. The need for it is (as above) that we should ensure that memory usage is within the U-Boot area. This is something which bloblist handles automatically. It is also nice to see all the tables in one place with 'bloblist list'

So what's the consent and the next step here?
Is the current code OK as is, as it works with both BLOBLIST and without? Should I drop support for one or the other?

Quoted 2 lines

Regards,
Simon

#27 lore raw

Re: [PATCH v4 14/35] efi_loader: Allocate and write ACPI tables

Hi Patrick,

Quoted 133 lines · Patrick Rudolph

Hi Simon,

Quoted 121 lines · Simon Glass

Hi Ilias,

Quoted 51 lines · Ilias Apalodimas

Hi Simon,

Quoted 47 lines · Simon Glass

Hi Ilias,

Quoted 41 lines · Ilias Apalodimas

Hi Simon,

Quoted 3 lines · Simon Glass

Hi Ilias,

[...]

Quoted 18 lines
Quoted 18 lines
Quoted 17 lines
Quoted 5 lines
(quoted diff) +5 -0
+
+               if (!addr)
+                       return log_msg_ret("mem", -ENOMEM);
+       } else {
+               pages = efi_size_in_pages(TABLE_SIZE);

Review

Quoted 10 lines
(quoted diff) +10 -0
+
+               ret = efi_allocate_pages(EFI_ALLOCATE_ANY_PAGES,
+                                        EFI_ACPI_RECLAIM_MEMORY,
+                                        pages, &new_acpi_addr);
+               if (ret != EFI_SUCCESS)
+                       return log_msg_ret("mem", -ENOMEM);
+
+               addr = (void *)(uintptr_t)new_acpi_addr;
+       }
+

The tables should be written regardless of whether EFI_LOADER is enabled.

Quoted 4 lines
Quoted 1 line

*Why*? How do you expect to hand them over to the OS?

Why - because boards which need ACPI tables to boot should generate them;

Noone argued that.

Quoted 3 lines

also this happens when U-Boot starts up, in last_stage_init() How - it isn't possible, but eventually I suppose it will be, once we have a use case for booting with ACPI but without EFI

Are you aware of such an OS? If not, we can accept the patches when we have a reason.

Quoted 6 lines
Quoted 2 lines

Which patches? This is how it works today. We set up the tables in last_stage_init(), so they can be examined while in U-Boot.

What I mean, is that until we have a valid use case to store the ACPI in a bloblist, I prefer them being allocated with proper EFI memory backing

I'm going to assert prior art here. If ARM is to have ACPI in U-Boot, it should follow the most recent x86 approach and store it in the bloblist. That is what the blloblist is for. It also avoids using memory below the U-Boot area, which is not allowed.

Quoted 47 lines
Quoted 8 lines

It is the patches to change this which I object to.

Quoted 2 lines

I remember patches being hard NAK'ed on using DTs to pass the ACPI table address in the past.

Yes, I believe Bytedance carries a patch locally for that :-)

Exactly

Quoted 30 lines
Quoted 11 lines
Quoted 11 lines
Quoted 10 lines
Quoted 6 lines

Can we drop this else clause? We should always use the bloblist.

Both Heinrich and I said the exact opposite. Unless there's a perfectly good reason why we should keep them in bloblist memory, I'd like us to do that

Quoted 8 lines
Quoted 5 lines

The main reason is that we should not be putting things in memory between the start of RAM and the bottom of the U-Boot area. That region of memory is supposed to be for loading images. Most boards hard-code the image-load addresses in environment variables. But even if they didn't, we should not be using that memory for U-Boot data.

EFI allows you to request a specific address to use. We can choose one that fits the requirements

So long as it is in U-Boot's space, that is fine. I just sent a patch about relocation which covers this. It occured to me that this feature of U-Boot, which I have always assumed was common knowledge, may have not been noticed.

Quoted 5 lines
Quoted 4 lines

Another reason is that the bloblist is designed for this, for keeping tables in a small, contiguous area of memory, so that when passed to Linux they are not spread all over the place.

Quoted 5 lines
Quoted 1 line

Linux does not and will not read tables from a bloblist though

Indeed. There really isn't any point, anyway, since there are other ways of passing the tables along...except for ACPI with FDT but that isn't a valid use case for Linux so far.

Quoted 5 lines

What we are trying to do with EFI is to stay as close to the spec and the current OS implementations as possible. So again, please allocate EFI memory for the ACPI tables. The patches to convert it to bloblist allocating them are minimal, so we can do it, once there's an actuall need for it.

Quoted 8 lines

As it stands today, efi_acpi_register() does not do an EFI allocation, it just adds the existing allocation to the EFI tables. This works fine for x86 - see arch/x86/lib/tables.c - so I would like ARM to do the same. The need for it is (as above) that we should ensure that memory usage is within the U-Boot area. This is something which bloblist handles automatically. It is also nice to see all the tables in one place with 'bloblist list'

Quoted 3 lines

So what's the consent and the next step here?
Is the current code OK as is, as it works with both BLOBLIST and without? Should I drop support for one or the other?

Just BLOBLIST. The EFI allocation is done using efi_acpi.c which you can check to make sure it is working.

Using efi_allocate_pages() before the app starts is not good.

Regards,
Simon

#28 lore raw

Re: [PATCH v4 14/35] efi_loader: Allocate and write ACPI tables

Quoted 138 lines · Simon Glass

Hi Patrick,

Quoted 133 lines · Patrick Rudolph

Hi Simon,

Quoted 129 lines · Simon Glass

Hi Ilias,

Quoted 51 lines · Ilias Apalodimas

Hi Simon,

Quoted 47 lines · Simon Glass

Hi Ilias,

Quoted 41 lines · Ilias Apalodimas

Hi Simon,

Quoted 3 lines · Simon Glass

Hi Ilias,

[...]

Quoted 18 lines
Quoted 18 lines
Quoted 17 lines
Quoted 5 lines
(quoted diff) +5 -0
+
+               if (!addr)
+                       return log_msg_ret("mem", -ENOMEM);
+       } else {
+               pages = efi_size_in_pages(TABLE_SIZE);

Review

Quoted 10 lines
(quoted diff) +10 -0
+
+               ret = efi_allocate_pages(EFI_ALLOCATE_ANY_PAGES,
+                                        EFI_ACPI_RECLAIM_MEMORY,
+                                        pages, &new_acpi_addr);
+               if (ret != EFI_SUCCESS)
+                       return log_msg_ret("mem", -ENOMEM);
+
+               addr = (void *)(uintptr_t)new_acpi_addr;
+       }
+

The tables should be written regardless of whether EFI_LOADER is enabled.

Quoted 4 lines
Quoted 1 line

*Why*? How do you expect to hand them over to the OS?

Why - because boards which need ACPI tables to boot should generate them;

Noone argued that.

Quoted 3 lines

also this happens when U-Boot starts up, in last_stage_init() How - it isn't possible, but eventually I suppose it will be, once we have a use case for booting with ACPI but without EFI

Are you aware of such an OS? If not, we can accept the patches when we have a reason.

Quoted 6 lines
Quoted 2 lines

Which patches? This is how it works today. We set up the tables in last_stage_init(), so they can be examined while in U-Boot.

What I mean, is that until we have a valid use case to store the ACPI in a bloblist, I prefer them being allocated with proper EFI memory backing

I'm going to assert prior art here. If ARM is to have ACPI in U-Boot, it should follow the most recent x86 approach and store it in the bloblist. That is what the blloblist is for. It also avoids using memory below the U-Boot area, which is not allowed.

Quoted 47 lines
Quoted 8 lines

It is the patches to change this which I object to.

Quoted 2 lines

I remember patches being hard NAK'ed on using DTs to pass the ACPI table address in the past.

Yes, I believe Bytedance carries a patch locally for that :-)

Exactly

Quoted 30 lines
Quoted 11 lines
Quoted 11 lines
Quoted 10 lines
Quoted 6 lines

Can we drop this else clause? We should always use the bloblist.

Both Heinrich and I said the exact opposite. Unless there's a perfectly good reason why we should keep them in bloblist memory, I'd like us to do that

Quoted 8 lines
Quoted 5 lines

The main reason is that we should not be putting things in memory between the start of RAM and the bottom of the U-Boot area. That region of memory is supposed to be for loading images. Most boards hard-code the image-load addresses in environment variables. But even if they didn't, we should not be using that memory for U-Boot data.

EFI allows you to request a specific address to use. We can choose one that fits the requirements

So long as it is in U-Boot's space, that is fine. I just sent a patch about relocation which covers this. It occured to me that this feature of U-Boot, which I have always assumed was common knowledge, may have not been noticed.

Quoted 5 lines
Quoted 4 lines

Another reason is that the bloblist is designed for this, for keeping tables in a small, contiguous area of memory, so that when passed to Linux they are not spread all over the place.

Quoted 5 lines
Quoted 1 line

Linux does not and will not read tables from a bloblist though

Indeed. There really isn't any point, anyway, since there are other ways of passing the tables along...except for ACPI with FDT but that isn't a valid use case for Linux so far.

Quoted 5 lines

What we are trying to do with EFI is to stay as close to the spec and the current OS implementations as possible. So again, please allocate EFI memory for the ACPI tables. The patches to convert it to bloblist allocating them are minimal, so we can do it, once there's an actuall need for it.

As it stands today, efi_acpi_register() does not do an EFI allocation, it just adds the existing allocation to the EFI tables. This works fine for x86 - see arch/x86/lib/tables.c - so I would like ARM to do the same. The need for it is (as above) that we should ensure that memory usage is within the U-Boot area. This is something which bloblist handles automatically. It is also nice to see all the tables in one place with 'bloblist list'

Quoted 8 lines
Quoted 3 lines

So what's the consent and the next step here?
Is the current code OK as is, as it works with both BLOBLIST and without? Should I drop support for one or the other?

Just BLOBLIST. The EFI allocation is done using efi_acpi.c which you can check to make sure it is working.

Using efi_allocate_pages() before the app starts is not good.

Simon, please stop trying to enforce decisions on subsystems you don't maintain. I am pretty sure both Heinrich and I said no to this.

Thanks
/Ilias

Quoted 3 lines

Regards,
Simon

#29 lore raw

Re: [PATCH v4 14/35] efi_loader: Allocate and write ACPI tables

Hi Ilias,

Quoted 144 lines · Ilias Apalodimas
Quoted 142 lines · Simon Glass

Hi Patrick,

Quoted 136 lines · Patrick Rudolph

Hi Simon,

Quoted 121 lines · Simon Glass

Hi Ilias,

Quoted 51 lines · Ilias Apalodimas

Hi Simon,

Quoted 47 lines · Simon Glass

Hi Ilias,

Quoted 41 lines · Ilias Apalodimas

Hi Simon,

Quoted 3 lines · Simon Glass

Hi Ilias,

[...]

Quoted 18 lines
Quoted 18 lines
Quoted 17 lines
Quoted 5 lines
(quoted diff) +5 -0
+
+               if (!addr)
+                       return log_msg_ret("mem", -ENOMEM);
+       } else {
+               pages = efi_size_in_pages(TABLE_SIZE);

Review

Quoted 10 lines
(quoted diff) +10 -0
+
+               ret = efi_allocate_pages(EFI_ALLOCATE_ANY_PAGES,
+                                        EFI_ACPI_RECLAIM_MEMORY,
+                                        pages, &new_acpi_addr);
+               if (ret != EFI_SUCCESS)
+                       return log_msg_ret("mem", -ENOMEM);
+
+               addr = (void *)(uintptr_t)new_acpi_addr;
+       }
+

The tables should be written regardless of whether EFI_LOADER is enabled.

Quoted 4 lines
Quoted 1 line

*Why*? How do you expect to hand them over to the OS?

Why - because boards which need ACPI tables to boot should generate them;

Noone argued that.

Quoted 3 lines

also this happens when U-Boot starts up, in last_stage_init() How - it isn't possible, but eventually I suppose it will be, once we have a use case for booting with ACPI but without EFI

Are you aware of such an OS? If not, we can accept the patches when we have a reason.

Quoted 6 lines
Quoted 2 lines

Which patches? This is how it works today. We set up the tables in last_stage_init(), so they can be examined while in U-Boot.

What I mean, is that until we have a valid use case to store the ACPI in a bloblist, I prefer them being allocated with proper EFI memory backing

I'm going to assert prior art here. If ARM is to have ACPI in U-Boot, it should follow the most recent x86 approach and store it in the bloblist. That is what the blloblist is for. It also avoids using memory below the U-Boot area, which is not allowed.

Quoted 47 lines
Quoted 8 lines

It is the patches to change this which I object to.

Quoted 2 lines

I remember patches being hard NAK'ed on using DTs to pass the ACPI table address in the past.

Yes, I believe Bytedance carries a patch locally for that :-)

Exactly

Quoted 30 lines
Quoted 11 lines
Quoted 11 lines
Quoted 10 lines
Quoted 6 lines

Can we drop this else clause? We should always use the bloblist.

Both Heinrich and I said the exact opposite. Unless there's a perfectly good reason why we should keep them in bloblist memory, I'd like us to do that

Quoted 8 lines
Quoted 5 lines

The main reason is that we should not be putting things in memory between the start of RAM and the bottom of the U-Boot area. That region of memory is supposed to be for loading images. Most boards hard-code the image-load addresses in environment variables. But even if they didn't, we should not be using that memory for U-Boot data.

EFI allows you to request a specific address to use. We can choose one that fits the requirements

So long as it is in U-Boot's space, that is fine. I just sent a patch about relocation which covers this. It occured to me that this feature of U-Boot, which I have always assumed was common knowledge, may have not been noticed.

Quoted 5 lines
Quoted 4 lines

Another reason is that the bloblist is designed for this, for keeping tables in a small, contiguous area of memory, so that when passed to Linux they are not spread all over the place.

Quoted 5 lines
Quoted 1 line

Linux does not and will not read tables from a bloblist though

Indeed. There really isn't any point, anyway, since there are other ways of passing the tables along...except for ACPI with FDT but that isn't a valid use case for Linux so far.

Quoted 5 lines

What we are trying to do with EFI is to stay as close to the spec and the current OS implementations as possible. So again, please allocate EFI memory for the ACPI tables. The patches to convert it to bloblist allocating them are minimal, so we can do it, once there's an actuall need for it.

Quoted 8 lines

As it stands today, efi_acpi_register() does not do an EFI allocation, it just adds the existing allocation to the EFI tables. This works fine for x86 - see arch/x86/lib/tables.c - so I would like ARM to do the same. The need for it is (as above) that we should ensure that memory usage is within the U-Boot area. This is something which bloblist handles automatically. It is also nice to see all the tables in one place with 'bloblist list'

So what's the consent and the next step here?
Is the current code OK as is, as it works with both BLOBLIST and without? Should I drop support for one or the other?

Quoted 7 lines
Quoted 4 lines

Just BLOBLIST. The EFI allocation is done using efi_acpi.c which you can check to make sure it is working.

Using efi_allocate_pages() before the app starts is not good.

Simon, please stop trying to enforce decisions on subsystems you don't maintain. I am pretty sure both Heinrich and I said no to this.

I am the ACPI maintainer, and x86 maintainer long before ACPI came in for ARM (which I originally hacked together, as you know). I also wrote bloblist, including the header file which says:

* 6. Bloblist is designed to be passed to Linux as reserved memory. While linux
* doesn't understand the bloblist header, it can be passed the indivdual blobs.
* For example, ACPI tables can reside in a blob and the address of those is
* passed to Linux, without Linux ever being away of the existence of a
* bloblist. Having all the blobs contiguous in memory simplifies the
* reserved-memory space.

This decision has serious impacts on memory management in U-Boot. It also bears on the complexity of memory, how bootstd works, board scripts and the like. We should discuss this and figure out a path forward.

Regards,
Simon

#30 lore raw

Re: [PATCH v4 14/35] efi_loader: Allocate and write ACPI tables

Quoted 152 lines · Simon Glass

Hi Ilias,

Quoted 147 lines · Ilias Apalodimas
Quoted 145 lines · Simon Glass

Hi Patrick,

Quoted 133 lines · Patrick Rudolph

Hi Simon,

Quoted 121 lines · Simon Glass

Hi Ilias,

Quoted 51 lines · Ilias Apalodimas

Hi Simon,

Quoted 47 lines · Simon Glass

Hi Ilias,

Quoted 41 lines · Ilias Apalodimas

Hi Simon,

Quoted 3 lines · Simon Glass

Hi Ilias,

[...]

Quoted 18 lines
Quoted 18 lines
Quoted 17 lines
Quoted 5 lines
(quoted diff) +5 -0
+
+               if (!addr)
+                       return log_msg_ret("mem", -ENOMEM);
+       } else {
+               pages = efi_size_in_pages(TABLE_SIZE);

Review

Quoted 10 lines
(quoted diff) +10 -0
+
+               ret = efi_allocate_pages(EFI_ALLOCATE_ANY_PAGES,
+                                        EFI_ACPI_RECLAIM_MEMORY,
+                                        pages, &new_acpi_addr);
+               if (ret != EFI_SUCCESS)
+                       return log_msg_ret("mem", -ENOMEM);
+
+               addr = (void *)(uintptr_t)new_acpi_addr;
+       }
+

The tables should be written regardless of whether EFI_LOADER is enabled.

Quoted 4 lines
Quoted 1 line

*Why*? How do you expect to hand them over to the OS?

Why - because boards which need ACPI tables to boot should generate them;

Noone argued that.

Quoted 3 lines

also this happens when U-Boot starts up, in last_stage_init() How - it isn't possible, but eventually I suppose it will be, once we have a use case for booting with ACPI but without EFI

Are you aware of such an OS? If not, we can accept the patches when we have a reason.

Quoted 6 lines
Quoted 2 lines

Which patches? This is how it works today. We set up the tables in last_stage_init(), so they can be examined while in U-Boot.

What I mean, is that until we have a valid use case to store the ACPI in a bloblist, I prefer them being allocated with proper EFI memory backing

I'm going to assert prior art here. If ARM is to have ACPI in U-Boot, it should follow the most recent x86 approach and store it in the bloblist. That is what the blloblist is for. It also avoids using memory below the U-Boot area, which is not allowed.

Quoted 47 lines
Quoted 8 lines

It is the patches to change this which I object to.

Quoted 2 lines

I remember patches being hard NAK'ed on using DTs to pass the ACPI table address in the past.

Yes, I believe Bytedance carries a patch locally for that :-)

Exactly

Quoted 30 lines
Quoted 11 lines
Quoted 11 lines
Quoted 10 lines
Quoted 6 lines

Can we drop this else clause? We should always use the bloblist.

Both Heinrich and I said the exact opposite. Unless there's a perfectly good reason why we should keep them in bloblist memory, I'd like us to do that

Quoted 8 lines
Quoted 5 lines

The main reason is that we should not be putting things in memory between the start of RAM and the bottom of the U-Boot area. That region of memory is supposed to be for loading images. Most boards hard-code the image-load addresses in environment variables. But even if they didn't, we should not be using that memory for U-Boot data.

EFI allows you to request a specific address to use. We can choose one that fits the requirements

So long as it is in U-Boot's space, that is fine. I just sent a patch about relocation which covers this. It occured to me that this feature of U-Boot, which I have always assumed was common knowledge, may have not been noticed.

Quoted 5 lines
Quoted 4 lines

Another reason is that the bloblist is designed for this, for keeping tables in a small, contiguous area of memory, so that when passed to Linux they are not spread all over the place.

Quoted 5 lines
Quoted 1 line

Linux does not and will not read tables from a bloblist though

Indeed. There really isn't any point, anyway, since there are other ways of passing the tables along...except for ACPI with FDT but that isn't a valid use case for Linux so far.

Quoted 5 lines

What we are trying to do with EFI is to stay as close to the spec and the current OS implementations as possible. So again, please allocate EFI memory for the ACPI tables. The patches to convert it to bloblist allocating them are minimal, so we can do it, once there's an actuall need for it.

Quoted 8 lines

As it stands today, efi_acpi_register() does not do an EFI allocation, it just adds the existing allocation to the EFI tables. This works fine for x86 - see arch/x86/lib/tables.c - so I would like ARM to do the same. The need for it is (as above) that we should ensure that memory usage is within the U-Boot area. This is something which bloblist handles automatically. It is also nice to see all the tables in one place with 'bloblist list'

Quoted 3 lines

So what's the consent and the next step here?
Is the current code OK as is, as it works with both BLOBLIST and without? Should I drop support for one or the other?

Just BLOBLIST. The EFI allocation is done using efi_acpi.c which you can check to make sure it is working.

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

Using efi_allocate_pages() before the app starts is not good.

Simon, please stop trying to enforce decisions on subsystems you don't maintain. I am pretty sure both Heinrich and I said no to this.

I am the ACPI maintainer, and x86 maintainer long before ACPI came in for ARM (which I originally hacked together, as you know). I also wrote bloblist, including the header file which says:

That's not the EFI subsystem though. And last time I checked where the ACPI tables are allocated makes no difference as long as they are installed on a config table.

Quoted 4 lines

* 6. Bloblist is designed to be passed to Linux as reserved memory.
While linux
* doesn't understand the bloblist header, it can be passed the indivdual blobs.

And as I already said, *when* bloblist is consumed by any OS and you have a valid use case other than "I can do bloblist list and I like it", you can change 3 lines of code and allocate the ACPI table there.

Quoted 4 lines

* For example, ACPI tables can reside in a blob and the address of those is
* passed to Linux, without Linux ever being away of the existence of a
* bloblist. Having all the blobs contiguous in memory simplifies the
* reserved-memory space.

No, it doesn't because all of the other tables are currently allocated by the EFI subsystem. So it actually fragments it. Apart from that You dont really know what the OS is going to do with that memory. It depends on the EFI memory type and OS decisions.

Quoted 5 lines

This decision has serious impacts on memory management in U-Boot. It also bears on the complexity of memory, how bootstd works, board scripts and the like. We should discuss this and figure out a path forward.

It has close to zero impact because *all* of the EFI memory lives in top memory. So apart from the EFI_BOUNCE_BUFFER perhaps, I don't see why the impact is """serious""".
EFI allocates memory which does not affect U-Boot of file loading apart from the max size allowed. Now with LMB it is marked as reserved. So why is this any different from any other LMB reservation? It's memory used by someone that you aren't allowed to use, just like we reserve U-Boot memory. If there's a bug in reservations, by all means, let's fix it.

Thanks
/Ilias

Quoted 3 lines

Regards,
Simon

#31 lore raw

Re: [PATCH v4 14/35] efi_loader: Allocate and write ACPI tables

Hi Ilias,

Quoted 159 lines · Ilias Apalodimas
Quoted 157 lines · Simon Glass

Hi Ilias,

Quoted 151 lines · Ilias Apalodimas
Quoted 138 lines · Simon Glass

Hi Patrick,

Quoted 133 lines · Patrick Rudolph

Hi Simon,

Quoted 129 lines · Simon Glass

Hi Ilias,

Quoted 51 lines · Ilias Apalodimas

Hi Simon,

Quoted 47 lines · Simon Glass

Hi Ilias,

Quoted 41 lines · Ilias Apalodimas

Hi Simon,

Quoted 3 lines · Simon Glass

Hi Ilias,

[...]

Quoted 18 lines
Quoted 18 lines
Quoted 17 lines
Quoted 15 lines

+
+ if (!addr)
+ return log_msg_ret("mem", -ENOMEM);
+ } else {
+ pages = efi_size_in_pages(TABLE_SIZE);
+
+ ret = efi_allocate_pages(EFI_ALLOCATE_ANY_PAGES,
+ EFI_ACPI_RECLAIM_MEMORY,
+ pages, &new_acpi_addr);
+ if (ret != EFI_SUCCESS)
+ return log_msg_ret("mem", -ENOMEM);
+
+ addr = (void *)(uintptr_t)new_acpi_addr;
+ }
+

The tables should be written regardless of whether EFI_LOADER is enabled.

Quoted 4 lines
Quoted 1 line

*Why*? How do you expect to hand them over to the OS?

Why - because boards which need ACPI tables to boot should generate them;

Noone argued that.

Quoted 3 lines

also this happens when U-Boot starts up, in last_stage_init() How - it isn't possible, but eventually I suppose it will be, once we have a use case for booting with ACPI but without EFI

Are you aware of such an OS? If not, we can accept the patches when we have a reason.

Quoted 6 lines
Quoted 2 lines

Which patches? This is how it works today. We set up the tables in last_stage_init(), so they can be examined while in U-Boot.

What I mean, is that until we have a valid use case to store the ACPI in a bloblist, I prefer them being allocated with proper EFI memory backing

I'm going to assert prior art here. If ARM is to have ACPI in U-Boot, it should follow the most recent x86 approach and store it in the bloblist. That is what the blloblist is for. It also avoids using memory below the U-Boot area, which is not allowed.

Quoted 47 lines
Quoted 8 lines

It is the patches to change this which I object to.

Quoted 2 lines

I remember patches being hard NAK'ed on using DTs to pass the ACPI table address in the past.

Yes, I believe Bytedance carries a patch locally for that :-)

Exactly

Quoted 30 lines
Quoted 11 lines
Quoted 11 lines
Quoted 10 lines
Quoted 6 lines

Can we drop this else clause? We should always use the bloblist.

Both Heinrich and I said the exact opposite. Unless there's a perfectly good reason why we should keep them in bloblist memory, I'd like us to do that

Quoted 8 lines
Quoted 5 lines

The main reason is that we should not be putting things in memory between the start of RAM and the bottom of the U-Boot area. That region of memory is supposed to be for loading images. Most boards hard-code the image-load addresses in environment variables. But even if they didn't, we should not be using that memory for U-Boot data.

EFI allows you to request a specific address to use. We can choose one that fits the requirements

So long as it is in U-Boot's space, that is fine. I just sent a patch about relocation which covers this. It occured to me that this feature of U-Boot, which I have always assumed was common knowledge, may have not been noticed.

Quoted 5 lines
Quoted 4 lines

Another reason is that the bloblist is designed for this, for keeping tables in a small, contiguous area of memory, so that when passed to Linux they are not spread all over the place.

Quoted 5 lines
Quoted 1 line

Linux does not and will not read tables from a bloblist though

Indeed. There really isn't any point, anyway, since there are other ways of passing the tables along...except for ACPI with FDT but that isn't a valid use case for Linux so far.

Quoted 5 lines

What we are trying to do with EFI is to stay as close to the spec and the current OS implementations as possible. So again, please allocate EFI memory for the ACPI tables. The patches to convert it to bloblist allocating them are minimal, so we can do it, once there's an actuall need for it.

As it stands today, efi_acpi_register() does not do an EFI allocation, it just adds the existing allocation to the EFI tables. This works fine for x86 - see arch/x86/lib/tables.c - so I would like ARM to do the same. The need for it is (as above) that we should ensure that memory usage is within the U-Boot area. This is something which bloblist handles automatically. It is also nice to see all the tables in one place with 'bloblist list'

Quoted 8 lines
Quoted 3 lines

So what's the consent and the next step here?
Is the current code OK as is, as it works with both BLOBLIST and without? Should I drop support for one or the other?

Just BLOBLIST. The EFI allocation is done using efi_acpi.c which you can check to make sure it is working.

Using efi_allocate_pages() before the app starts is not good.

Simon, please stop trying to enforce decisions on subsystems you don't maintain. I am pretty sure both Heinrich and I said no to this.

Quoted 7 lines
Quoted 3 lines

I am the ACPI maintainer, and x86 maintainer long before ACPI came in for ARM (which I originally hacked together, as you know). I also wrote bloblist, including the header file which says:

That's not the EFI subsystem though. And last time I checked where the ACPI tables are allocated makes no difference as long as they are installed on a config table.

With my maintainer hat on, ACPI tables go in a bloblist.

The difference it makes is that the tables end up in the U-Boot memory-area.

Quoted 9 lines
Quoted 5 lines

* 6. Bloblist is designed to be passed to Linux as reserved memory.
While linux
* doesn't understand the bloblist header, it can be passed the indivdual blobs.

And as I already said, *when* bloblist is consumed by any OS and you have a valid use case other than "I can do bloblist list and I like it", you can change 3 lines of code and allocate the ACPI table there.

Bloblist is not intended to be consumed by an OS. It is a firmware construct, a way for U-Boot to arrange things in such a way that they can be located and updated at runtime. What objection do you actually have to using bloblist for tables?

Quoted 10 lines
Quoted 5 lines

* For example, ACPI tables can reside in a blob and the address of those is
* passed to Linux, without Linux ever being away of the existence of a
* bloblist. Having all the blobs contiguous in memory simplifies the
* reserved-memory space.

No, it doesn't because all of the other tables are currently allocated by the EFI subsystem. So it actually fragments it. Apart from that You dont really know what the OS is going to do with that memory. It depends on the EFI memory type and OS decisions.

The ACPI table is not allocated by the EFI subsystem. Neither is SMBIOS, which currently uses malloc() but should move into a bloblist too. The system table is in U-Boot's data region. Much of EFI's data and all the driver model stuff is in the malloc() region.

Quoted 7 lines
Quoted 6 lines

This decision has serious impacts on memory management in U-Boot. It also bears on the complexity of memory, how bootstd works, board scripts and the like. We should discuss this and figure out a path forward.

Quoted 9 lines

It has close to zero impact because *all* of the EFI memory lives in top memory. So apart from the EFI_BOUNCE_BUFFER perhaps, I don't see why the impact is """serious""".
EFI allocates memory which does not affect U-Boot of file loading apart from the max size allowed. Now with LMB it is marked as reserved. So why is this any different from any other LMB reservation? It's memory used by someone that you aren't allowed to use, just like we reserve U-Boot memory. If there's a bug in reservations, by all means, let's fix it.

I think you are saying that because only a small amount of memory is affected it doesn't matter much. Well, I suppose so. But if it doesn't matter, why is Sughosh spending all this time solving the problem? Also with [1] I definitely saw it allocating stuff where it should not. If it has so little impact, why are we still discussing it? Also, my efforts seem to have uncovered latent bugs, where EFI tests fail if there is not a large margin after each allocation. That should be cause for concern. We would not put up with that elsewhere in U-Boot.

I am not trying to mess with EFI in U-Boot, if that is what you are worried about. Actually I haven't been paying it enough attention as it is in good hands...but I need to put more time into it. As a subsystem it is here for the long haul and it needs to interoperate properly. I was at a conference last week where there was a talk about U-Boot as an EFI app with a pass-through (i.e. not calling exit-boot-services) to Linux's EFI stub. There is a lot of activity in this area. EFI is an important piece of technology in the industry. But this is U-Boot, and we just need to design things properly. I have quietly commented on some of my concerns (e.g. efi_set_bootdev()) but have not put time into fixing them.

There is no need for the 6-8 tidy allocations, which are done before the app starts, to be allocated in the wrong place, with a small impact. We can just do it in malloc(). Let's just fix it.

There is no need for the tables to be allocated in an EFI-specific way, or using lmb. We have bloblist for that purpose. What's the concern?

Regards,
Simon

[1] https://patchwork.ozlabs.org/project/uboot/patch/[email protected]/

#32 lore raw

Re: [PATCH v4 14/35] efi_loader: Allocate and write ACPI tables

[...]

Quoted 33 lines
Quoted 15 lines
Quoted 15 lines
Quoted 14 lines
Quoted 11 lines
Quoted 6 lines
Quoted 2 lines

in one place with 'bloblist list'

So what's the consent and the next step here?
Is the current code OK as is, as it works with both BLOBLIST and without? Should I drop support for one or the other?

Just BLOBLIST. The EFI allocation is done using efi_acpi.c which you can check to make sure it is working.

Using efi_allocate_pages() before the app starts is not good.

Simon, please stop trying to enforce decisions on subsystems you don't maintain. I am pretty sure both Heinrich and I said no to this.

Quoted 7 lines
Quoted 3 lines

I am the ACPI maintainer, and x86 maintainer long before ACPI came in for ARM (which I originally hacked together, as you know). I also wrote bloblist, including the header file which says:

That's not the EFI subsystem though. And last time I checked where the ACPI tables are allocated makes no difference as long as they are installed on a config table.

With my maintainer hat on, ACPI tables go in a bloblist.

The difference it makes is that the tables end up in the U-Boot memory-area.

Quoted 6 lines
Quoted 5 lines

* 6. Bloblist is designed to be passed to Linux as reserved memory.
While linux
* doesn't understand the bloblist header, it can be passed the indivdual blobs.

Quoted 8 lines
Quoted 3 lines

And as I already said, *when* bloblist is consumed by any OS and you have a valid use case other than "I can do bloblist list and I like it", you can change 3 lines of code and allocate the ACPI table there.

Bloblist is not intended to be consumed by an OS. It is a firmware construct, a way for U-Boot to arrange things in such a way that they can be located and updated at runtime. What objection do you actually have to using bloblist for tables?

That bloblist, is currently used for the firmware handoff protocol. And that protocol *ends* when U-Boot launches, so I don't see why adding anything there that's not defined makes any sense.

Quoted 7 lines
Quoted 7 lines
Quoted 6 lines

* For example, ACPI tables can reside in a blob and the address of those is
* passed to Linux, without Linux ever being away of the existence of a
* bloblist. Having all the blobs contiguous in memory simplifies the
* reserved-memory space.

Quoted 8 lines
Quoted 4 lines

No, it doesn't because all of the other tables are currently allocated by the EFI subsystem. So it actually fragments it. Apart from that You dont really know what the OS is going to do with that memory. It depends on the EFI memory type and OS decisions.

The ACPI table is not allocated by the EFI subsystem. Neither is SMBIOS, which currently uses malloc() but should move into a bloblist too.

SMBIOS is different. it's not tightly linked to EFI. But we mark that region properly in memory as well.

Quoted 2 lines

The system table is in U-Boot's data region. Much of EFI's data and all the driver model stuff is in the malloc() region.

You keep saying "much of EFI data" and I keep repeating that whatever is *not* needed by the EFI spec, internal allocations, lists, etc we use malloc. Whatever is described in the EFI spec, we use efi_allocate_XXXXXX()

Quoted 18 lines
Quoted 8 lines
Quoted 7 lines

This decision has serious impacts on memory management in U-Boot. It also bears on the complexity of memory, how bootstd works, board scripts and the like. We should discuss this and figure out a path forward.

Quoted 9 lines

It has close to zero impact because *all* of the EFI memory lives in top memory. So apart from the EFI_BOUNCE_BUFFER perhaps, I don't see why the impact is """serious""".
EFI allocates memory which does not affect U-Boot of file loading apart from the max size allowed. Now with LMB it is marked as reserved. So why is this any different from any other LMB reservation? It's memory used by someone that you aren't allowed to use, just like we reserve U-Boot memory. If there's a bug in reservations, by all means, let's fix it.

Quoted 2 lines

I think you are saying that because only a small amount of memory is affected it doesn't matter much.

No, I am saying this because you need to allocate the memory regardless if you want to support EFI. So as long as it's not in the middle of the memory space, not allowing you to load stuff, it makes little difference.

Quoted 2 lines

Well, I suppose so. But if it doesn't
matter, why is Sughosh spending all this time solving the problem?

First of all, we got multiple asks from Tom saying LMB wasn't doing all that it should for a long time and needed fixing regardless. LMB prior to the patches was calling efi_get_memory_map_alloc() on the reserve function and be aware of EFI mappings, but that wasn't the best solution. With the lmb created on the fly we also had to call that function every time before LMB could decide what memory is free.

Quoted 2 lines

Also with [1] I definitely saw it allocating stuff where it should not. If it has so little impact, why are we still discussing it?

So why is this a problem if LMB now says "you are going to overwrite system memory"?
Also, how are you loading the kernel and initrd? To boot with EFI? Can you send me a reproducer?
What I imagine is happening is that you deliberately choose a high address, which somehow gets overwritten. But with LMB in place this goes away.

Quoted 10 lines

Also,
my efforts seem to have uncovered latent bugs, where EFI tests fail if there is not a large margin after each allocation. That should be cause for concern. We would not put up with that elsewhere in U-Boot.

I am not trying to mess with EFI in U-Boot, if that is what you are worried about. Actually I haven't been paying it enough attention as it is in good hands...but I need to put more time into it. As a subsystem it is here for the long haul and it needs to interoperate properly.

Unfortunately, it doesn't have to merely interpolate. There are some spec requirements we can't twist around because we used to do things differently 8 years ago. The clear answer here, is disable EFI for anyone that thinks it's so intrusive. And report breakages so we can fix them.

Quoted 7 lines

I was at a conference last week where there was a talk about U-Boot as an EFI app with a pass-through (i.e. not calling exit-boot-services) to Linux's EFI stub. There is a lot of activity in this area. EFI is an important piece of technology in the industry. But this is U-Boot, and we just need to design things properly. I have quietly commented on some of my concerns (e.g. efi_set_bootdev()) but have not put time into fixing them.

Me neither, but hopefully once the LWIP and mbedTLS are merged, we will have time to fix a few things.

Quoted 4 lines

There is no need for the 6-8 tidy allocations, which are done before the app starts, to be allocated in the wrong place, with a small impact. We can just do it in malloc(). Let's just fix it.

I won't repeat why this is problematic, I've explained more than once. On top of that this is opportunistic, the way we run things e.g the cmd subsystem, efi will be initialized regardless. An app might as well return, so without a clear use case of breakage I don't think we should change that.

Quoted 3 lines

There is no need for the tables to be allocated in an EFI-specific way, or using lmb.

Neither is for bloblist

Quoted 2 lines

We have bloblist for that purpose. What's the
concern?

That it's easier and cleanr for me to review and maintain code that's as close to the spec as possible. And I see no reasons to use bloblist. Or at least none that are so important.

Thanks
/Ilias

Quoted 5 lines

Regards,
Simon

[1] https://patchwork.ozlabs.org/project/uboot/patch/[email protected]/

#33 lore raw

Re: [PATCH v4 14/35] efi_loader: Allocate and write ACPI tables

Quoted 112 lines · Ilias Apalodimas

[...]

Quoted 33 lines
Quoted 15 lines
Quoted 15 lines
Quoted 14 lines
Quoted 11 lines
Quoted 6 lines
Quoted 2 lines

in one place with 'bloblist list'

So what's the consent and the next step here?
Is the current code OK as is, as it works with both BLOBLIST and without? Should I drop support for one or the other?

Just BLOBLIST. The EFI allocation is done using efi_acpi.c which you can check to make sure it is working.

Using efi_allocate_pages() before the app starts is not good.

Simon, please stop trying to enforce decisions on subsystems you don't maintain. I am pretty sure both Heinrich and I said no to this.

Quoted 7 lines
Quoted 3 lines

I am the ACPI maintainer, and x86 maintainer long before ACPI came in for ARM (which I originally hacked together, as you know). I also wrote bloblist, including the header file which says:

That's not the EFI subsystem though. And last time I checked where the ACPI tables are allocated makes no difference as long as they are installed on a config table.

With my maintainer hat on, ACPI tables go in a bloblist.

The difference it makes is that the tables end up in the U-Boot memory-area.

Quoted 6 lines
Quoted 5 lines

* 6. Bloblist is designed to be passed to Linux as reserved memory.
While linux
* doesn't understand the bloblist header, it can be passed the indivdual blobs.

Quoted 8 lines
Quoted 3 lines

And as I already said, *when* bloblist is consumed by any OS and you have a valid use case other than "I can do bloblist list and I like it", you can change 3 lines of code and allocate the ACPI table there.

Bloblist is not intended to be consumed by an OS. It is a firmware construct, a way for U-Boot to arrange things in such a way that they can be located and updated at runtime. What objection do you actually have to using bloblist for tables?

That bloblist, is currently used for the firmware handoff protocol. And that protocol *ends* when U-Boot launches, so I don't see why adding anything there that's not defined makes any sense.

Quoted 7 lines
Quoted 7 lines
Quoted 6 lines

* For example, ACPI tables can reside in a blob and the address of those is
* passed to Linux, without Linux ever being away of the existence of a
* bloblist. Having all the blobs contiguous in memory simplifies the
* reserved-memory space.

Quoted 8 lines
Quoted 4 lines

No, it doesn't because all of the other tables are currently allocated by the EFI subsystem. So it actually fragments it. Apart from that You dont really know what the OS is going to do with that memory. It depends on the EFI memory type and OS decisions.

The ACPI table is not allocated by the EFI subsystem. Neither is SMBIOS, which currently uses malloc() but should move into a bloblist too.

SMBIOS is different. it's not tightly linked to EFI. But we mark that region properly in memory as well.

Quoted 2 lines

The system table is in U-Boot's data region. Much of EFI's data and all the driver model stuff is in the malloc() region.

You keep saying "much of EFI data" and I keep repeating that whatever is *not* needed by the EFI spec, internal allocations, lists, etc we use malloc. Whatever is described in the EFI spec, we use efi_allocate_XXXXXX()

Quoted 18 lines
Quoted 8 lines
Quoted 7 lines

This decision has serious impacts on memory management in U-Boot. It also bears on the complexity of memory, how bootstd works, board scripts and the like. We should discuss this and figure out a path forward.

Quoted 9 lines

It has close to zero impact because *all* of the EFI memory lives in top memory. So apart from the EFI_BOUNCE_BUFFER perhaps, I don't see why the impact is """serious""".
EFI allocates memory which does not affect U-Boot of file loading apart from the max size allowed. Now with LMB it is marked as reserved. So why is this any different from any other LMB reservation? It's memory used by someone that you aren't allowed to use, just like we reserve U-Boot memory. If there's a bug in reservations, by all means, let's fix it.

Quoted 2 lines

I think you are saying that because only a small amount of memory is affected it doesn't matter much.

No, I am saying this because you need to allocate the memory regardless if you want to support EFI. So as long as it's not in the middle of the memory space, not allowing you to load stuff, it makes little difference.

Quoted 2 lines

Well, I suppose so. But if it doesn't
matter, why is Sughosh spending all this time solving the problem?

First of all, we got multiple asks from Tom saying LMB wasn't doing all that it should for a long time and needed fixing regardless. LMB prior to the patches was calling efi_get_memory_map_alloc() on the reserve function and be aware of EFI mappings, but that wasn't the best solution. With the lmb created on the fly we also had to call that function every time before LMB could decide what memory is free.

Quoted 5 lines
Quoted 2 lines

Also with [1] I definitely saw it allocating stuff where it should not. If it has so little impact, why are we still discussing it?

So why is this a problem if LMB now says "you are going to overwrite system memory"?

Just to make things a bit more clear here, since I don't have a reproducer. I assume you place the initrd within the memory space of the bounce buffer. At some point, if that buffer gets used, the initrd will corrupt. But with the new patches, you won't be able to load anything on a region that's reserved.

Quoted 65 lines

Also, how are you loading the kernel and initrd? To boot with EFI? Can you send me a reproducer?
What I imagine is happening is that you deliberately choose a high address, which somehow gets overwritten. But with LMB in place this goes away.

Quoted 10 lines

Also,
my efforts seem to have uncovered latent bugs, where EFI tests fail if there is not a large margin after each allocation. That should be cause for concern. We would not put up with that elsewhere in U-Boot.

I am not trying to mess with EFI in U-Boot, if that is what you are worried about. Actually I haven't been paying it enough attention as it is in good hands...but I need to put more time into it. As a subsystem it is here for the long haul and it needs to interoperate properly.

Unfortunately, it doesn't have to merely interpolate. There are some spec requirements we can't twist around because we used to do things differently 8 years ago. The clear answer here, is disable EFI for anyone that thinks it's so intrusive. And report breakages so we can fix them.

Quoted 7 lines

I was at a conference last week where there was a talk about U-Boot as an EFI app with a pass-through (i.e. not calling exit-boot-services) to Linux's EFI stub. There is a lot of activity in this area. EFI is an important piece of technology in the industry. But this is U-Boot, and we just need to design things properly. I have quietly commented on some of my concerns (e.g. efi_set_bootdev()) but have not put time into fixing them.

Me neither, but hopefully once the LWIP and mbedTLS are merged, we will have time to fix a few things.

Quoted 4 lines

There is no need for the 6-8 tidy allocations, which are done before the app starts, to be allocated in the wrong place, with a small impact. We can just do it in malloc(). Let's just fix it.

I won't repeat why this is problematic, I've explained more than once. On top of that this is opportunistic, the way we run things e.g the cmd subsystem, efi will be initialized regardless. An app might as well return, so without a clear use case of breakage I don't think we should change that.

Quoted 3 lines

There is no need for the tables to be allocated in an EFI-specific way, or using lmb.

Neither is for bloblist

Quoted 2 lines

We have bloblist for that purpose. What's the
concern?

That it's easier and cleanr for me to review and maintain code that's as close to the spec as possible. And I see no reasons to use bloblist. Or at least none that are so important.

Thanks
/Ilias

Quoted 5 lines

Regards,
Simon

[1] https://patchwork.ozlabs.org/project/uboot/patch/[email protected]/

#34 lore raw

Re: [PATCH v4 14/35] efi_loader: Allocate and write ACPI tables

In reply to Ilias Apalodimas

On Fri, Sep 27, 2024 at 04:14:55PM +0300, Ilias Apalodimas wrote:

[snip]

Quoted 9 lines
Quoted 2 lines

Well, I suppose so. But if it doesn't
matter, why is Sughosh spending all this time solving the problem?

First of all, we got multiple asks from Tom saying LMB wasn't doing all that it should for a long time and needed fixing regardless. LMB prior to the patches was calling efi_get_memory_map_alloc() on the reserve function and be aware of EFI mappings, but that wasn't the best solution. With the lmb created on the fly we also had to call that function every time before LMB could decide what memory is free.

On this point, to be clear, I asked Heinrich to tie EFI and LMB together because I had missed that it wasn't doing anything before and wanted to avoid a round of CVE assignments over "you can use EFI to overwrite U-Boot" similar to the CVEs that caused us to start abusing the old LMB mechanism too. Nobody liked that original change and it was intended to be reworked.

Signature · 1 line
Tom
#35 lore raw

Re: [PATCH v4 14/35] efi_loader: Allocate and write ACPI tables

In reply to Ilias Apalodimas

Hi Ilias,

Quoted 166 lines · Ilias Apalodimas

[...]

Quoted 33 lines
Quoted 15 lines
Quoted 15 lines
Quoted 14 lines
Quoted 11 lines
Quoted 6 lines
Quoted 2 lines

in one place with 'bloblist list'

So what's the consent and the next step here?
Is the current code OK as is, as it works with both BLOBLIST and without? Should I drop support for one or the other?

Just BLOBLIST. The EFI allocation is done using efi_acpi.c which you can check to make sure it is working.

Using efi_allocate_pages() before the app starts is not good.

Simon, please stop trying to enforce decisions on subsystems you don't maintain. I am pretty sure both Heinrich and I said no to this.

Quoted 7 lines
Quoted 3 lines

I am the ACPI maintainer, and x86 maintainer long before ACPI came in for ARM (which I originally hacked together, as you know). I also wrote bloblist, including the header file which says:

That's not the EFI subsystem though. And last time I checked where the ACPI tables are allocated makes no difference as long as they are installed on a config table.

With my maintainer hat on, ACPI tables go in a bloblist.

The difference it makes is that the tables end up in the U-Boot memory-area.

Quoted 6 lines
Quoted 5 lines

* 6. Bloblist is designed to be passed to Linux as reserved memory.
While linux
* doesn't understand the bloblist header, it can be passed the indivdual blobs.

Quoted 8 lines
Quoted 3 lines

And as I already said, *when* bloblist is consumed by any OS and you have a valid use case other than "I can do bloblist list and I like it", you can change 3 lines of code and allocate the ACPI table there.

Bloblist is not intended to be consumed by an OS. It is a firmware construct, a way for U-Boot to arrange things in such a way that they can be located and updated at runtime. What objection do you actually have to using bloblist for tables?

That bloblist, is currently used for the firmware handoff protocol. And that protocol *ends* when U-Boot launches, so I don't see why adding anything there that's not defined makes any sense.

Quoted 7 lines
Quoted 7 lines
Quoted 6 lines

* For example, ACPI tables can reside in a blob and the address of those is
* passed to Linux, without Linux ever being away of the existence of a
* bloblist. Having all the blobs contiguous in memory simplifies the
* reserved-memory space.

Quoted 8 lines
Quoted 4 lines

No, it doesn't because all of the other tables are currently allocated by the EFI subsystem. So it actually fragments it. Apart from that You dont really know what the OS is going to do with that memory. It depends on the EFI memory type and OS decisions.

The ACPI table is not allocated by the EFI subsystem. Neither is SMBIOS, which currently uses malloc() but should move into a bloblist too.

SMBIOS is different. it's not tightly linked to EFI. But we mark that region properly in memory as well.

Quoted 2 lines

The system table is in U-Boot's data region. Much of EFI's data and all the driver model stuff is in the malloc() region.

You keep saying "much of EFI data" and I keep repeating that whatever is *not* needed by the EFI spec, internal allocations, lists, etc we use malloc. Whatever is described in the EFI spec, we use efi_allocate_XXXXXX()

Quoted 18 lines
Quoted 8 lines
Quoted 7 lines

This decision has serious impacts on memory management in U-Boot. It also bears on the complexity of memory, how bootstd works, board scripts and the like. We should discuss this and figure out a path forward.

Quoted 9 lines

It has close to zero impact because *all* of the EFI memory lives in top memory. So apart from the EFI_BOUNCE_BUFFER perhaps, I don't see why the impact is """serious""".
EFI allocates memory which does not affect U-Boot of file loading apart from the max size allowed. Now with LMB it is marked as reserved. So why is this any different from any other LMB reservation? It's memory used by someone that you aren't allowed to use, just like we reserve U-Boot memory. If there's a bug in reservations, by all means, let's fix it.

Quoted 2 lines

I think you are saying that because only a small amount of memory is affected it doesn't matter much.

No, I am saying this because you need to allocate the memory regardless if you want to support EFI. So as long as it's not in the middle of the memory space, not allowing you to load stuff, it makes little difference.

Quoted 2 lines

Well, I suppose so. But if it doesn't
matter, why is Sughosh spending all this time solving the problem?

First of all, we got multiple asks from Tom saying LMB wasn't doing all that it should for a long time and needed fixing regardless. LMB prior to the patches was calling efi_get_memory_map_alloc() on the reserve function and be aware of EFI mappings, but that wasn't the best solution. With the lmb created on the fly we also had to call that function every time before LMB could decide what memory is free.

Quoted 2 lines

Also with [1] I definitely saw it allocating stuff where it should not. If it has so little impact, why are we still discussing it?

So why is this a problem if LMB now says "you are going to overwrite system memory"?
Also, how are you loading the kernel and initrd? To boot with EFI? Can you send me a reproducer?
What I imagine is happening is that you deliberately choose a high address, which somehow gets overwritten. But with LMB in place this goes away.

Quoted 10 lines

Also,
my efforts seem to have uncovered latent bugs, where EFI tests fail if there is not a large margin after each allocation. That should be cause for concern. We would not put up with that elsewhere in U-Boot.

I am not trying to mess with EFI in U-Boot, if that is what you are worried about. Actually I haven't been paying it enough attention as it is in good hands...but I need to put more time into it. As a subsystem it is here for the long haul and it needs to interoperate properly.

Unfortunately, it doesn't have to merely interpolate. There are some spec requirements we can't twist around because we used to do things differently 8 years ago. The clear answer here, is disable EFI for anyone that thinks it's so intrusive. And report breakages so we can fix them.

Quoted 7 lines

I was at a conference last week where there was a talk about U-Boot as an EFI app with a pass-through (i.e. not calling exit-boot-services) to Linux's EFI stub. There is a lot of activity in this area. EFI is an important piece of technology in the industry. But this is U-Boot, and we just need to design things properly. I have quietly commented on some of my concerns (e.g. efi_set_bootdev()) but have not put time into fixing them.

Me neither, but hopefully once the LWIP and mbedTLS are merged, we will have time to fix a few things.

Quoted 4 lines

There is no need for the 6-8 tidy allocations, which are done before the app starts, to be allocated in the wrong place, with a small impact. We can just do it in malloc(). Let's just fix it.

I won't repeat why this is problematic, I've explained more than once. On top of that this is opportunistic, the way we run things e.g the cmd subsystem, efi will be initialized regardless. An app might as well return, so without a clear use case of breakage I don't think we should change that.

Quoted 3 lines

There is no need for the tables to be allocated in an EFI-specific way, or using lmb.

Quoted 8 lines

Neither is for bloblist

Quoted 2 lines

We have bloblist for that purpose. What's the
concern?

That it's easier and cleanr for me to review and maintain code that's as close to the spec as possible. And I see no reasons to use bloblist. Or at least none that are so important.

Hmmm, I hope you agree that we are not making a lot of progress here. So let's arrange a call and see if we can discuss these two issues:

- tables in bloblist
- use of efi-allocate-pages before the app starts

I'm sure we won't resolve them in one call, but perhaps we can find some common ground.

In the meantime, it would certainly help if the EFI-test series could be applied. If not, let's add that to the agenda too.

Regards,
Simon

Quoted 1 line
Quoted 1 line

[1] https://patchwork.ozlabs.org/project/uboot/patch/[email protected]/

#36 lore raw

Re: [PATCH v4 14/35] efi_loader: Allocate and write ACPI tables

In reply to Simon Glass

Hi Simon,

Quoted 59 lines · Simon Glass

Hi Ilias,

Quoted 54 lines · Ilias Apalodimas

Hi Simon,

Quoted 49 lines · Simon Glass

Hi Ilias,

Quoted 33 lines · Ilias Apalodimas

Hi Simon,

Quoted 3 lines · Simon Glass

Hi Ilias,

[...]

Quoted 18 lines
Quoted 18 lines
Quoted 17 lines
Quoted 5 lines
(quoted diff) +5 -0
+
+               if (!addr)
+                       return log_msg_ret("mem", -ENOMEM);
+       } else {
+               pages = efi_size_in_pages(TABLE_SIZE);

Review

Quoted 10 lines
(quoted diff) +10 -0
+
+               ret = efi_allocate_pages(EFI_ALLOCATE_ANY_PAGES,
+                                        EFI_ACPI_RECLAIM_MEMORY,
+                                        pages, &new_acpi_addr);
+               if (ret != EFI_SUCCESS)
+                       return log_msg_ret("mem", -ENOMEM);
+
+               addr = (void *)(uintptr_t)new_acpi_addr;
+       }
+

The tables should be written regardless of whether EFI_LOADER is enabled.

Quoted 4 lines
Quoted 1 line

*Why*? How do you expect to hand them over to the OS?

Why - because boards which need ACPI tables to boot should generate them;

Quoted 8 lines

Noone argued that.

Quoted 3 lines

also this happens when U-Boot starts up, in last_stage_init() How - it isn't possible, but eventually I suppose it will be, once we have a use case for booting with ACPI but without EFI

Are you aware of such an OS? If not, we can accept the patches when we have a reason.

Which patches? This is how it works today. We set up the tables in last_stage_init(), so they can be examined while in U-Boot.

Quoted 8 lines
Quoted 3 lines

What I mean, is that until we have a valid use case to store the ACPI in a bloblist, I prefer them being allocated with proper EFI memory backing

I'm going to assert prior art here. If ARM is to have ACPI in U-Boot, it should follow the most recent x86 approach and store it in the bloblist. That is what the blloblist is for. It also avoids using memory below the U-Boot area, which is not allowed.

By prior art you mean [0], which was none of the EFI maintainers got involved?

Quoted 54 lines
Quoted 48 lines
Quoted 9 lines

It is the patches to change this which I object to.

Quoted 2 lines

I remember patches being hard NAK'ed on using DTs to pass the ACPI table address in the past.

Yes, I believe Bytedance carries a patch locally for that :-)

Exactly

Quoted 30 lines
Quoted 11 lines
Quoted 11 lines
Quoted 10 lines
Quoted 6 lines

Can we drop this else clause? We should always use the bloblist.

Both Heinrich and I said the exact opposite. Unless there's a perfectly good reason why we should keep them in bloblist memory, I'd like us to do that

Quoted 8 lines
Quoted 5 lines

The main reason is that we should not be putting things in memory between the start of RAM and the bottom of the U-Boot area. That region of memory is supposed to be for loading images. Most boards hard-code the image-load addresses in environment variables. But even if they didn't, we should not be using that memory for U-Boot data.

EFI allows you to request a specific address to use. We can choose one that fits the requirements

So long as it is in U-Boot's space, that is fine. I just sent a patch about relocation which covers this. It occured to me that this feature of U-Boot, which I have always assumed was common knowledge, may have not been noticed.

Quoted 5 lines
Quoted 4 lines

Another reason is that the bloblist is designed for this, for keeping tables in a small, contiguous area of memory, so that when passed to Linux they are not spread all over the place.

Quoted 5 lines
Quoted 1 line

Linux does not and will not read tables from a bloblist though

Indeed. There really isn't any point, anyway, since there are other ways of passing the tables along...except for ACPI with FDT but that isn't a valid use case for Linux so far.

Quoted 5 lines

What we are trying to do with EFI is to stay as close to the spec and the current OS implementations as possible. So again, please allocate EFI memory for the ACPI tables. The patches to convert it to bloblist allocating them are minimal, so we can do it, once there's an actuall need for it.

Quoted 3 lines

As it stands today, efi_acpi_register() does not do an EFI allocation, it just adds the existing allocation to the EFI tables. This works fine for x86 - see arch/x86/lib/tables.c -

Yes and I've already mentioned that in my original response.

Quoted 5 lines

so I would like ARM to do
the same. The need for it is (as above) that we should ensure that memory usage is within the U-Boot area. This is something which bloblist handles automatically. It is also nice to see all the tables in one place with 'bloblist list'

Unless bloblist is not compiled.... in which case you still need to malloc and align.
I am just putting this out there, because your next email is going to be "oh look bloblist is mandatory now".
For the last time, bloblist make zero sense to allocate data that arent going to be handed across loaders.

Patrick, my suggestion is to either use efi_allocate_pages() as you do or malloc a properly aligned buffer since we set the memory type in efi_acpi_register().
IIRC the reason we set that in efi_acpi_register() is for QEMU which hands us over ACPI tables, so we can't do much. I would personally prefer efi allocated memory.

Thanks
/Ilias

Quoted 3 lines

Regards,
Simon

[0] https://lore.kernel.org/u-boot/[email protected]/

#37 lore raw

Re: [PATCH v4 14/35] efi_loader: Allocate and write ACPI tables

Hi Ilias,

Quoted 67 lines · Ilias Apalodimas

Hi Simon,

Quoted 63 lines · Simon Glass

Hi Ilias,

Quoted 57 lines · Ilias Apalodimas

Hi Simon,

Quoted 44 lines · Simon Glass

Hi Ilias,

Quoted 39 lines · Ilias Apalodimas

Hi Simon,

Quoted 3 lines · Simon Glass

Hi Ilias,

[...]

Quoted 18 lines
Quoted 18 lines
Quoted 17 lines
Quoted 5 lines
(quoted diff) +5 -0
+
+               if (!addr)
+                       return log_msg_ret("mem", -ENOMEM);
+       } else {
+               pages = efi_size_in_pages(TABLE_SIZE);

Review

Quoted 10 lines
(quoted diff) +10 -0
+
+               ret = efi_allocate_pages(EFI_ALLOCATE_ANY_PAGES,
+                                        EFI_ACPI_RECLAIM_MEMORY,
+                                        pages, &new_acpi_addr);
+               if (ret != EFI_SUCCESS)
+                       return log_msg_ret("mem", -ENOMEM);
+
+               addr = (void *)(uintptr_t)new_acpi_addr;
+       }
+

The tables should be written regardless of whether EFI_LOADER is enabled.

Quoted 4 lines
Quoted 1 line

*Why*? How do you expect to hand them over to the OS?

Why - because boards which need ACPI tables to boot should generate them;

Noone argued that.

Quoted 3 lines

also this happens when U-Boot starts up, in last_stage_init() How - it isn't possible, but eventually I suppose it will be, once we have a use case for booting with ACPI but without EFI

Quoted 5 lines
Quoted 2 lines

Are you aware of such an OS? If not, we can accept the patches when we have a reason.

Which patches? This is how it works today. We set up the tables in last_stage_init(), so they can be examined while in U-Boot.

What I mean, is that until we have a valid use case to store the ACPI in a bloblist, I prefer them being allocated with proper EFI memory backing

Quoted 6 lines
Quoted 4 lines

I'm going to assert prior art here. If ARM is to have ACPI in U-Boot, it should follow the most recent x86 approach and store it in the bloblist. That is what the blloblist is for. It also avoids using memory below the U-Boot area, which is not allowed.

By prior art you mean [0], which was none of the EFI maintainers got involved?

Yes. I should point out that I wrote the original EFI app support and am maintainer for that. I also reviewed the original EFI_LOADER support over quite a few revisions. I have a pretty-good understanding of the implementation and issues.

Quoted 55 lines
Quoted 55 lines
Quoted 54 lines
Quoted 10 lines

It is the patches to change this which I object to.

Quoted 2 lines

I remember patches being hard NAK'ed on using DTs to pass the ACPI table address in the past.

Yes, I believe Bytedance carries a patch locally for that :-)

Exactly

Quoted 30 lines
Quoted 11 lines
Quoted 11 lines
Quoted 10 lines
Quoted 6 lines

Can we drop this else clause? We should always use the bloblist.

Both Heinrich and I said the exact opposite. Unless there's a perfectly good reason why we should keep them in bloblist memory, I'd like us to do that

Quoted 8 lines
Quoted 5 lines

The main reason is that we should not be putting things in memory between the start of RAM and the bottom of the U-Boot area. That region of memory is supposed to be for loading images. Most boards hard-code the image-load addresses in environment variables. But even if they didn't, we should not be using that memory for U-Boot data.

EFI allows you to request a specific address to use. We can choose one that fits the requirements

So long as it is in U-Boot's space, that is fine. I just sent a patch about relocation which covers this. It occured to me that this feature of U-Boot, which I have always assumed was common knowledge, may have not been noticed.

Quoted 5 lines
Quoted 4 lines

Another reason is that the bloblist is designed for this, for keeping tables in a small, contiguous area of memory, so that when passed to Linux they are not spread all over the place.

Quoted 5 lines
Quoted 1 line

Linux does not and will not read tables from a bloblist though

Indeed. There really isn't any point, anyway, since there are other ways of passing the tables along...except for ACPI with FDT but that isn't a valid use case for Linux so far.

What we are trying to do with EFI is to stay as close to the spec and the current OS implementations as possible. So again, please allocate EFI memory for the ACPI tables. The patches to convert it to bloblist allocating them are minimal, so we can do it, once there's an actuall need for it.

Quoted 5 lines
Quoted 3 lines

As it stands today, efi_acpi_register() does not do an EFI allocation, it just adds the existing allocation to the EFI tables. This works fine for x86 - see arch/x86/lib/tables.c -

Yes and I've already mentioned that in my original response.

OK good.

Quoted 9 lines
Quoted 6 lines

so I would like ARM to do
the same. The need for it is (as above) that we should ensure that memory usage is within the U-Boot area. This is something which bloblist handles automatically. It is also nice to see all the tables in one place with 'bloblist list'

Unless bloblist is not compiled.... in which case you still need to malloc and align.

For Arm, ACPI depends on BLOBLIST. It is also required on recent x86 platforms.

Quoted 4 lines

I am just putting this out there, because your next email is going to be "oh look bloblist is mandatory now".
For the last time, bloblist make zero sense to allocate data that arent going to be handed across loaders.

Sorry, I don't agree. It makes a lot of sense, since it keeps the tables together, and keeps them within the memory space that U-Boot uses for itself.

I have suggested we arrange a meeting to discuss this and I am still happy to do so.

Quoted 4 lines

Patrick, my suggestion is to either use efi_allocate_pages() as you do or malloc a properly aligned buffer since we set the memory type in efi_acpi_register().

I don't expect to change my mind on this. The efi_allocate_pages() call should not be used before the app starts. That is the error which has laid latent for years without anyone knowing. I still haven't seen a clear acknowledgement of a problem, from the EFI folks. This is not just about images and lmb, it is about following U-Boot's memory practices.

Quoted 3 lines

IIRC the reason we set that in efi_acpi_register() is for QEMU which hands us over ACPI tables, so we can't do much. I would personally prefer efi allocated memory.

It is used on x86 as well, e.g. chromebook_coral. Also QEMU tables are munged somewhat during the copy, so I believe we can place them where we wish. That probably needs a clean-up too. Bear in mind though, that the tables are sometimes placed at f0000 on x86, i.e. below any memory used by U-Boot itself.

Regards,
Simon

#38 lore raw

PATCH v4 15/35 acpi: Add processor device

In reply to Patrick Rudolph

Add a new method to write the processor device identified by _HID ACPI0007, that is preferred over the Processor OpCode since ACPI 6.0.

Fixes booting arm using ACPI only since the Processor OpCode isn't found valid by the Linux kernel.

---
 include/acpi/acpigen.h | 12 ++++++++++++
 lib/acpi/acpigen.c     | 11 +++++++++++
 2 files changed, 23 insertions(+)
include/acpi/acpigen.h +12 -0
index 3aa94d70b9..16df85b9c1 100644
@@ -833,6 +833,7 @@ void acpigen_write_dsm_end(struct acpi_ctx *ctx);
  *
  * This emits a Processor package header with the required information. The
  * caller must complete the information and call acpigen_pop_len() at the end
+ * Deprecated since ACPI 6.0.
  *
  * @ctx: ACPI context pointer
  * @cpuindex: CPU number
@@ -842,6 +843,17 @@ void acpigen_write_dsm_end(struct acpi_ctx *ctx);
 void acpigen_write_processor(struct acpi_ctx *ctx, uint cpuindex,
 			     u32 pblock_addr, uint pblock_len);
 
+/**
+ * acpigen_write_processor_device() - Write a Processor device
+ *
+ * Write a device with _HID ACPI0007 identifying a processor.
+ * Replacement for the Processor OpCode.
+ *
+ * @ctx: ACPI context pointer
+ * @cpuindex: CPU number
+ */
+void acpigen_write_processor_device(struct acpi_ctx *ctx, uint cpuindex);
+
 /**
  * acpigen_write_processor_package() - Write a package containing the processors
  *
lib/acpi/acpigen.c +11 -0
index b95cabb914..427ebc2104 100644
@@ -361,6 +361,17 @@ void acpigen_write_processor(struct acpi_ctx *ctx, uint cpuindex,
 	acpigen_emit_byte(ctx, pblock_len);
 }
 
+void acpigen_write_processor_device(struct acpi_ctx *ctx, uint cpuindex)
+{
+	char pscope[16];
+
+	snprintf(pscope, sizeof(pscope), ACPI_CPU_STRING, cpuindex);
+	acpigen_write_device(ctx, pscope);
+	acpigen_write_name_string(ctx, "_HID", "ACPI0007");
+	acpigen_write_name_integer(ctx, "_UID", cpuindex);
+	acpigen_pop_len(ctx); /* Device */
+}
+
 void acpigen_write_processor_package(struct acpi_ctx *ctx,
 				     const char *const name,
 				     const uint first_core,
Signature · 1 line
2.46.0
#39 lore raw

PATCH v4 16/35 drivers: usb: Add generic XHCI

In reply to Patrick Rudolph

Add support for the generic XHCI driver that contains no SoC specific code. It can be used on platforms that simply work out of the box, like on emulated platforms.

TEST: Booted on QEMU sbsa machine using the generic xhci driver.

---
Changelog v3:
- Drop weak board_xhci_enable()
Changelog v4:
- Use dev_dbg() instead of debug()

---
 drivers/usb/host/Kconfig        |  8 ++++
 drivers/usb/host/Makefile       |  1 +
 drivers/usb/host/xhci-generic.c | 77 +++++++++++++++++++++++++++++++++
 3 files changed, 86 insertions(+)
 create mode 100644 drivers/usb/host/xhci-generic.c
drivers/usb/host/Kconfig +8 -0
index 6e10b629a3..bb5893d56d 100644
@@ -68,6 +68,14 @@ config USB_XHCI_MVEBU
 	  SoCs, which includes Armada8K, Armada3700 and other Armada
 	  family SoCs.
 
+config USB_XHCI_GENERIC
+	bool "Generic SoC USB 3.0 support"
+	depends on OF_CONTROL
+	default n
+	help
+	  Choose this option to add support for USB 3.0 driver for SoCs
+	  that do not need platform specific code, like on emulated targets.
+
 config USB_XHCI_OCTEON
 	bool "Support for Marvell Octeon family on-chip xHCI USB controller"
 	depends on ARCH_OCTEON
drivers/usb/host/Makefile +1 -0
index 8dad36f936..9e880195ec 100644
@@ -50,6 +50,7 @@ obj-$(CONFIG_USB_XHCI_EXYNOS) += xhci-exynos5.o
 obj-$(CONFIG_USB_XHCI_FSL) += xhci-fsl.o
 obj-$(CONFIG_USB_XHCI_MTK) += xhci-mtk.o
 obj-$(CONFIG_USB_XHCI_MVEBU) += xhci-mvebu.o
+obj-$(CONFIG_USB_XHCI_GENERIC) += xhci-generic.o
 obj-$(CONFIG_USB_XHCI_OMAP) += xhci-omap.o
 obj-$(CONFIG_USB_XHCI_PCI) += xhci-pci.o
 obj-$(CONFIG_USB_XHCI_RCAR) += xhci-rcar.o
drivers/usb/host/xhci-generic.c new file +77 -0

77 lines not on this page · raw message

Signature · 1 line
2.46.0
#40 lore raw

PATCH v4 17/35 drivers: ata: Rename ahci_mvebu

In reply to Patrick Rudolph

Rename 'ahci_mvebu' to 'ahci_generic' and select it by default. The AHCI driver contains no SoC specific code and only expects the base address to be passed, thus rename it to ahci_generic and add the DT compatible string "generic-ahci".

Update existing defconfigs to use the new Kconfig name as well.

TEST: Booted on QEMU sbsa using the generic-ahci node.

---
 MAINTAINERS                                     |  2 +-
 configs/clearfog_defconfig                      |  2 +-
 configs/clearfog_gt_8k_defconfig                |  2 +-
 configs/clearfog_sata_defconfig                 |  2 +-
 configs/clearfog_spi_defconfig                  |  2 +-
 configs/db-88f6820-gp_defconfig                 |  2 +-
 configs/ds116_defconfig                         |  2 +-
 configs/helios4_defconfig                       |  2 +-
 configs/mvebu_crb_cn9130_defconfig              |  2 +-
 configs/mvebu_db-88f3720_defconfig              |  2 +-
 configs/mvebu_db_armada8k_defconfig             |  2 +-
 configs/mvebu_db_cn9130_defconfig               |  2 +-
 configs/mvebu_espressobin-88f3720_defconfig     |  2 +-
 .../mvebu_espressobin_ultra-88f3720_defconfig   |  2 +-
 configs/mvebu_mcbin-88f8040_defconfig           |  2 +-
 configs/mvebu_puzzle-m801-88f8040_defconfig     |  2 +-
 configs/n2350_defconfig                         |  2 +-
 configs/octeon_nic23_defconfig                  |  2 +-
 configs/turris_omnia_defconfig                  |  2 +-
 drivers/ata/Kconfig                             | 12 +++++++-----
 drivers/ata/Makefile                            |  2 +-
 drivers/ata/{ahci_mvebu.c => ahci_generic.c}    | 17 +++++++++--------
 22 files changed, 36 insertions(+), 33 deletions(-)
 rename drivers/ata/{ahci_mvebu.c => ahci_generic.c} (71%)
MAINTAINERS +1 -1
index 2050ae24df..d3a0469ca1 100644
@@ -356,7 +356,7 @@ S:	Maintained
 T:	git https://source.denx.de/u-boot/custodians/u-boot-marvell.git
 F:	arch/arm/mach-kirkwood/
 F:	arch/arm/mach-mvebu/
-F:	drivers/ata/ahci_mvebu.c
+F:	drivers/ata/ahci_generic.c
 F:	drivers/clk/mvebu/
 F:	drivers/ddr/marvell/
 F:	drivers/gpio/mvebu_gpio.c
configs/clearfog_defconfig +1 -1
index 62dbf2aa48..9cb4753685 100644
@@ -52,7 +52,7 @@ CONFIG_ARP_TIMEOUT=200
 CONFIG_NET_RETRY_COUNT=50
 CONFIG_NET_RANDOM_ETHADDR=y
 CONFIG_SPL_OF_TRANSLATE=y
-CONFIG_AHCI_MVEBU=y
+CONFIG_AHCI_GENERIC=y
 CONFIG_DM_PCA953X=y
 CONFIG_DM_I2C=y
 CONFIG_SYS_I2C_MVTWSI=y
configs/clearfog_gt_8k_defconfig +1 -1
index df7e04a75b..66eb5e2407 100644
@@ -46,7 +46,7 @@ CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_ARP_TIMEOUT=200
 CONFIG_NET_RETRY_COUNT=50
 CONFIG_NET_RANDOM_ETHADDR=y
-CONFIG_AHCI_MVEBU=y
+CONFIG_AHCI_GENERIC=y
 CONFIG_LBA48=y
 CONFIG_SYS_64BIT_LBA=y
 CONFIG_DM_I2C=y
configs/clearfog_sata_defconfig +1 -1
index 41382f995d..b1e1fc75dd 100644
@@ -52,7 +52,7 @@ CONFIG_ARP_TIMEOUT=200
 CONFIG_NET_RETRY_COUNT=50
 CONFIG_NET_RANDOM_ETHADDR=y
 CONFIG_SPL_OF_TRANSLATE=y
-CONFIG_AHCI_MVEBU=y
+CONFIG_AHCI_GENERIC=y
 CONFIG_DM_PCA953X=y
 CONFIG_DM_I2C=y
 CONFIG_SYS_I2C_MVTWSI=y
configs/clearfog_spi_defconfig +1 -1
index f345b12e6c..64f862d298 100644
@@ -52,7 +52,7 @@ CONFIG_ARP_TIMEOUT=200
 CONFIG_NET_RETRY_COUNT=50
 CONFIG_NET_RANDOM_ETHADDR=y
 CONFIG_SPL_OF_TRANSLATE=y
-CONFIG_AHCI_MVEBU=y
+CONFIG_AHCI_GENERIC=y
 CONFIG_DM_PCA953X=y
 CONFIG_DM_I2C=y
 CONFIG_SYS_I2C_MVTWSI=y
configs/db-88f6820-gp_defconfig +1 -1
index ee8cb8ae66..16417a4e12 100644
@@ -58,7 +58,7 @@ CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_ARP_TIMEOUT=200
 CONFIG_NET_RETRY_COUNT=50
 CONFIG_SPL_OF_TRANSLATE=y
-CONFIG_AHCI_MVEBU=y
+CONFIG_AHCI_GENERIC=y
 CONFIG_SYS_I2C_LEGACY=y
 CONFIG_SPL_SYS_I2C_LEGACY=y
 CONFIG_SYS_I2C_MVTWSI=y
configs/ds116_defconfig +1 -1
index 1173e3a0f6..d687be2d5b 100644
@@ -65,7 +65,7 @@ CONFIG_NET_RETRY_COUNT=50
 CONFIG_NET_RANDOM_ETHADDR=y
 CONFIG_NETCONSOLE=y
 CONFIG_SPL_OF_TRANSLATE=y
-CONFIG_AHCI_MVEBU=y
+CONFIG_AHCI_GENERIC=y
 CONFIG_LBA48=y
 CONFIG_SYS_64BIT_LBA=y
 CONFIG_DM_I2C=y
configs/helios4_defconfig +1 -1
index 29b6230e90..c0ae1de264 100644
@@ -52,7 +52,7 @@ CONFIG_ARP_TIMEOUT=200
 CONFIG_NET_RETRY_COUNT=50
 CONFIG_NET_RANDOM_ETHADDR=y
 CONFIG_SPL_OF_TRANSLATE=y
-CONFIG_AHCI_MVEBU=y
+CONFIG_AHCI_GENERIC=y
 CONFIG_DM_PCA953X=y
 CONFIG_DM_I2C=y
 CONFIG_SYS_I2C_MVTWSI=y
configs/mvebu_crb_cn9130_defconfig +1 -1
index 4d5f575b03..d253fe88d6 100644
@@ -46,7 +46,7 @@ CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_SYS_MMC_ENV_DEV=1
 CONFIG_ARP_TIMEOUT=200
 CONFIG_NET_RETRY_COUNT=50
-CONFIG_AHCI_MVEBU=y
+CONFIG_AHCI_GENERIC=y
 CONFIG_LBA48=y
 CONFIG_SYS_64BIT_LBA=y
 CONFIG_DM_I2C=y
configs/mvebu_db-88f3720_defconfig +1 -1
index b955abb31e..1e9332c845 100644
@@ -43,7 +43,7 @@ CONFIG_ENV_IS_IN_SPI_FLASH=y
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_ARP_TIMEOUT=200
 CONFIG_NET_RETRY_COUNT=50
-CONFIG_AHCI_MVEBU=y
+CONFIG_AHCI_GENERIC=y
 CONFIG_LBA48=y
 CONFIG_SYS_64BIT_LBA=y
 CONFIG_CLK=y
configs/mvebu_db_armada8k_defconfig +1 -1
index 6913796c01..a9b76a3843 100644
@@ -42,7 +42,7 @@ CONFIG_ENV_IS_IN_SPI_FLASH=y
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_ARP_TIMEOUT=200
 CONFIG_NET_RETRY_COUNT=50
-CONFIG_AHCI_MVEBU=y
+CONFIG_AHCI_GENERIC=y
 CONFIG_LBA48=y
 CONFIG_SYS_64BIT_LBA=y
 CONFIG_DM_I2C=y
configs/mvebu_db_cn9130_defconfig +1 -1
index 9133e25b24..2c345f7436 100644
@@ -47,7 +47,7 @@ CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_SYS_MMC_ENV_DEV=1
 CONFIG_ARP_TIMEOUT=200
 CONFIG_NET_RETRY_COUNT=50
-CONFIG_AHCI_MVEBU=y
+CONFIG_AHCI_GENERIC=y
 CONFIG_LBA48=y
 CONFIG_SYS_64BIT_LBA=y
 CONFIG_DM_GPIO_LOOKUP_LABEL=y
configs/mvebu_espressobin-88f3720_defconfig +1 -1
index 7ecf5ab0d6..c7015c9b13 100644
@@ -54,7 +54,7 @@ CONFIG_ARP_TIMEOUT=200
 CONFIG_NET_RETRY_COUNT=50
 CONFIG_NET_RANDOM_ETHADDR=y
 CONFIG_AHCI_PCI=y
-CONFIG_AHCI_MVEBU=y
+CONFIG_AHCI_GENERIC=y
 CONFIG_LBA48=y
 CONFIG_SYS_64BIT_LBA=y
 CONFIG_CLK=y
configs/mvebu_espressobin_ultra-88f3720_defconfig +1 -1
index 974b6df165..0a4329d786 100644
@@ -53,7 +53,7 @@ CONFIG_ARP_TIMEOUT=200
 CONFIG_NET_RETRY_COUNT=50
 CONFIG_NET_RANDOM_ETHADDR=y
 CONFIG_AHCI_PCI=y
-CONFIG_AHCI_MVEBU=y
+CONFIG_AHCI_GENERIC=y
 CONFIG_LBA48=y
 CONFIG_SYS_64BIT_LBA=y
 CONFIG_CLK=y
configs/mvebu_mcbin-88f8040_defconfig +1 -1
index eef612a261..8bb26bd3d6 100644
@@ -46,7 +46,7 @@ CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_ARP_TIMEOUT=200
 CONFIG_NET_RETRY_COUNT=50
 CONFIG_NET_RANDOM_ETHADDR=y
-CONFIG_AHCI_MVEBU=y
+CONFIG_AHCI_GENERIC=y
 CONFIG_LBA48=y
 CONFIG_SYS_64BIT_LBA=y
 CONFIG_DM_I2C=y
configs/mvebu_puzzle-m801-88f8040_defconfig +1 -1
index b00e92908b..db7881c3fc 100644
@@ -49,7 +49,7 @@ CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_ARP_TIMEOUT=200
 CONFIG_NET_RETRY_COUNT=50
 CONFIG_NET_RANDOM_ETHADDR=y
-CONFIG_AHCI_MVEBU=y
+CONFIG_AHCI_GENERIC=y
 CONFIG_LBA48=y
 CONFIG_SYS_64BIT_LBA=y
 CONFIG_DM_PCA953X=y
configs/n2350_defconfig +1 -1
index e7d7deabfe..b6fc333906 100644
@@ -65,7 +65,7 @@ CONFIG_NET_RETRY_COUNT=50
 CONFIG_NET_RANDOM_ETHADDR=y
 CONFIG_NETCONSOLE=y
 CONFIG_SPL_OF_TRANSLATE=y
-CONFIG_AHCI_MVEBU=y
+CONFIG_AHCI_GENERIC=y
 CONFIG_LBA48=y
 CONFIG_SYS_64BIT_LBA=y
 CONFIG_DM_I2C=y
configs/octeon_nic23_defconfig +1 -1
index 5a8db5a087..d19d459555 100644
@@ -46,7 +46,7 @@ CONFIG_EFI_PARTITION=y
 CONFIG_ENV_IS_IN_SPI_FLASH=y
 CONFIG_TFTP_TSIZE=y
 CONFIG_SATA=y
-CONFIG_AHCI_MVEBU=y
+CONFIG_AHCI_GENERIC=y
 CONFIG_LBA48=y
 CONFIG_SYS_64BIT_LBA=y
 CONFIG_CLK=y
configs/turris_omnia_defconfig +1 -1
index 93f0bc53f9..85c71f2eef 100644
@@ -90,7 +90,7 @@ CONFIG_NET_RETRY_COUNT=50
 CONFIG_NETCONSOLE=y
 CONFIG_SPL_OF_TRANSLATE=y
 CONFIG_AHCI_PCI=y
-CONFIG_AHCI_MVEBU=y
+CONFIG_AHCI_GENERIC=y
 CONFIG_DM_PCA953X=y
 CONFIG_MMC_SDHCI=y
 CONFIG_MMC_SDHCI_MV=y
drivers/ata/Kconfig +7 -5
index 6cca561f97..4fbb63a148 100644
@@ -78,14 +78,16 @@ config MTK_AHCI
 	  Enable this driver to support Sata devices through
 	  Mediatek AHCI controller (e.g. MT7622).
 
-config AHCI_MVEBU
-	bool "Marvell EBU AHCI SATA support"
-	depends on ARCH_MVEBU || ARCH_OCTEON
+config AHCI_GENERIC
+	bool "Generic AHCI SATA support"
+	depends on OF_CONTROL
 	select SCSI_AHCI
 	select SCSI
 	help
-	  This option enables support for the Marvell EBU SoC's
-	  onboard AHCI SATA.
+	  This option enables support for generic onboard AHCI SATA controller
+	  that do not need platform specific quirks, like emulated devices,
+	  Marvell EBU SoC's onboard AHCI SATA controllers or Cavium's Octeon
+	  7130 AHCI controllers.
 
 	  If unsure, say N.
 
drivers/ata/Makefile +1 -1
index af6f0bf278..507bf84c14 100644
@@ -14,6 +14,6 @@ obj-$(CONFIG_SATA) += sata.o sata_bootdev.o
 obj-$(CONFIG_SATA_CEVA) += sata_ceva.o
 obj-$(CONFIG_SATA_MV) += sata_mv.o
 obj-$(CONFIG_SATA_SIL) += sata_sil.o
-obj-$(CONFIG_AHCI_MVEBU) += ahci_mvebu.o
+obj-$(CONFIG_AHCI_GENERIC) += ahci_generic.o
 obj-$(CONFIG_SUNXI_AHCI) += ahci_sunxi.o
 obj-$(CONFIG_MTK_AHCI) += mtk_ahci.o
drivers/ata/ahci_generic.c renamed from drivers/ata/ahci_mvebu.c +9 -8
similarity index 71%
rename from drivers/ata/ahci_mvebu.c
rename to drivers/ata/ahci_generic.c
index f6e2d6bee4..6e5a6cbafd 100644
@@ -16,7 +16,7 @@ __weak int board_ahci_enable(void)
 	return 0;
 }
 
-static int mvebu_ahci_bind(struct udevice *dev)
+static int generic_ahci_bind(struct udevice *dev)
 {
 	struct udevice *scsi_dev;
 	int ret;
@@ -30,7 +30,7 @@ static int mvebu_ahci_bind(struct udevice *dev)
 	return 0;
 }
 
-static int mvebu_ahci_probe(struct udevice *dev)
+static int generic_ahci_probe(struct udevice *dev)
 {
 	/*
 	 * Board specific SATA / AHCI enable code, e.g. enable the
@@ -43,18 +43,19 @@ static int mvebu_ahci_probe(struct udevice *dev)
 	return 0;
 }
 
-static const struct udevice_id mvebu_ahci_ids[] = {
+static const struct udevice_id generic_ahci_ids[] = {
 	{ .compatible = "marvell,armada-380-ahci" },
 	{ .compatible = "marvell,armada-3700-ahci" },
 	{ .compatible = "marvell,armada-8k-ahci" },
 	{ .compatible = "cavium,octeon-7130-ahci" },
+	{ .compatible = "generic-ahci" },
 	{ }
 };
 
-U_BOOT_DRIVER(ahci_mvebu_drv) = {
-	.name		= "ahci_mvebu",
+U_BOOT_DRIVER(ahci_generic_drv) = {
+	.name		= "ahci_generic",
 	.id		= UCLASS_AHCI,
-	.of_match	= mvebu_ahci_ids,
-	.bind		= mvebu_ahci_bind,
-	.probe		= mvebu_ahci_probe,
+	.of_match	= generic_ahci_ids,
+	.bind		= generic_ahci_bind,
+	.probe		= generic_ahci_probe,
 };
Signature · 1 line
2.46.0
#41 lore raw

PATCH v4 18/35 drivers/cpu: Add generic armv8 cpu driver

In reply to Patrick Rudolph

Add a generic driver that binds to armv8 CPU nodes. The generic driver allows
- to enumerate CPUs present in a system, even when no other driver binds it
- generates ACPI SSDT code for each CPU
- Fill the ACPI MADT table (implemented in a follow up patch)

The newly introduced code could also be reused on other CPU drivers that are compatible with armv8.

TEST: Booted on QEMU sbsa and verify the driver binds to CPU nodes.
Confirmed with FWTS that all ACPI processor devices are present.

---
Changelog v4:
- Export armv8_cpu_fill_ssdt to use it in other CPU drivers

---
 drivers/cpu/Kconfig     |  6 ++++
 drivers/cpu/Makefile    |  2 ++
 drivers/cpu/armv8_cpu.c | 73 +++++++++++++++++++++++++++++++++++++++++
 drivers/cpu/armv8_cpu.h | 21 ++++++++++++
 4 files changed, 102 insertions(+)
 create mode 100644 drivers/cpu/armv8_cpu.c
 create mode 100644 drivers/cpu/armv8_cpu.h
drivers/cpu/Kconfig +6 -0
index 5c06cd9f60..9c0df331d7 100644
@@ -26,6 +26,12 @@ config CPU_RISCV
 	help
 	  Support CPU cores for RISC-V architecture.
 
+config CPU_ARMV8
+	bool "Enable generic ARMv8 CPU driver"
+	depends on CPU && ARM64
+	help
+	  Support CPU cores for armv8 architecture.
+
 config CPU_MICROBLAZE
 	bool "Enable Microblaze CPU driver"
 	depends on CPU && MICROBLAZE
drivers/cpu/Makefile +2 -0
index bc75d9b974..773395693a 100644
@@ -6,10 +6,12 @@
 
 obj-$(CONFIG_CPU) += cpu-uclass.o
 
+
 obj-$(CONFIG_ARCH_BMIPS) += bmips_cpu.o
 obj-$(CONFIG_ARCH_IMX8) += imx8_cpu.o
 obj-$(CONFIG_ARCH_AT91) += at91_cpu.o
 obj-$(CONFIG_ARCH_MEDIATEK) += mtk_cpu.o
+obj-$(CONFIG_CPU_ARMV8) += armv8_cpu.o
 obj-$(CONFIG_CPU_IMX) += imx8_cpu.o
 obj-$(CONFIG_CPU_MPC83XX) += mpc83xx_cpu.o
 obj-$(CONFIG_CPU_RISCV) += riscv_cpu.o
drivers/cpu/armv8_cpu.c new file +73 -0

73 lines not on this page · raw message

drivers/cpu/armv8_cpu.h new file +21 -0
new file mode 100644
index 0000000000..2c4b0252cf
@@ -0,0 +1,21 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2024 9elements GmbH
+ */
+#include <dm/acpi.h>
+#include <dm/device.h>
+
+#ifndef _ARMV8_CPU_H_
+#define _ARMV8_CPU_H_
+
+/**
+ * armv8_cpu_fill_ssdt() - Fill the SSDT
+ * Parses the FDT and writes the SSDT nodes.
+ *
+ * @dev: cpu device to generate ACPI tables for
+ * @ctx: ACPI context pointer
+ * @return:	0 if OK, or a negative error code.
+ */
+int armv8_cpu_fill_ssdt(const struct udevice *dev, struct acpi_ctx *ctx);
+
+#endif
\ No newline at end of file
Signature · 1 line
2.46.0
Reviewed-by on v4 18/35
#42 lore raw

Re: [PATCH v4 18/35] drivers/cpu: Add generic armv8 cpu driver

Quoted 19 lines · Patrick Rudolph

Add a generic driver that binds to armv8 CPU nodes. The generic driver allows
- to enumerate CPUs present in a system, even when no other driver binds it
- generates ACPI SSDT code for each CPU
- Fill the ACPI MADT table (implemented in a follow up patch)

The newly introduced code could also be reused on other CPU drivers that are compatible with armv8.

TEST: Booted on QEMU sbsa and verify the driver binds to CPU nodes.
Confirmed with FWTS that all ACPI processor devices are present.

---
Changelog v4:
- Export armv8_cpu_fill_ssdt to use it in other CPU drivers

Quoted 8 lines
---
 drivers/cpu/Kconfig     |  6 ++++
 drivers/cpu/Makefile    |  2 ++
 drivers/cpu/armv8_cpu.c | 73 +++++++++++++++++++++++++++++++++++++++++
 drivers/cpu/armv8_cpu.h | 21 ++++++++++++
 4 files changed, 102 insertions(+)
 create mode 100644 drivers/cpu/armv8_cpu.c
 create mode 100644 drivers/cpu/armv8_cpu.h
#43 lore raw

PATCH v4 19/35 arm: gic-v3-its: Rename objects

In reply to Patrick Rudolph

The code accesses the gic-v3 node, but not the gic-v3-its node, thus rename the objects to clarify which node it operates on.

The following commit will make use of the gic-v3-its node for real.

---
 arch/arm/lib/gic-v3-its.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
arch/arm/lib/gic-v3-its.c +5 -5
index 2cc0a32f9d..22fa46a341 100644
@@ -35,10 +35,10 @@ static int gic_v3_its_get_gic_addr(struct gic_v3_its_priv *priv)
 	int ret;
 
 	ret = uclass_get_device_by_driver(UCLASS_IRQ,
-					  DM_DRIVER_GET(arm_gic_v3_its), &dev);
+					  DM_DRIVER_GET(arm_gic_v3), &dev);
 	if (ret) {
 		pr_err("%s: failed to get %s irq device\n", __func__,
-		       DM_DRIVER_GET(arm_gic_v3_its)->name);
+		       DM_DRIVER_GET(arm_gic_v3)->name);
 		return ret;
 	}
 
@@ -158,13 +158,13 @@ int gic_lpi_tables_init(u64 base, u32 num_redist)
 	return 0;
 }
 
-static const struct udevice_id gic_v3_its_ids[] = {
+static const struct udevice_id gic_v3_ids[] = {
 	{ .compatible = "arm,gic-v3" },
 	{}
 };
 
-U_BOOT_DRIVER(arm_gic_v3_its) = {
+U_BOOT_DRIVER(arm_gic_v3) = {
 	.name		= "gic-v3",
 	.id		= UCLASS_IRQ,
-	.of_match	= gic_v3_its_ids,
+	.of_match	= gic_v3_ids,
 };
Signature · 1 line
2.46.0
#44 lore raw

PATCH v4 20/35 arm: gic-v3-its: Implement of_xlate

In reply to Patrick Rudolph

Translate IRQs by implementing of_xlate() as required by irq_get_by_index() to parse interrupt properties.

TEST: Booted on qemu sbsa-ref that has a GICV3.

---
 arch/arm/lib/gic-v3-its.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
arch/arm/lib/gic-v3-its.c +21 -0
index 22fa46a341..54dbff434c 100644
@@ -7,6 +7,7 @@
 #include <asm/gic.h>
 #include <asm/gic-v3.h>
 #include <asm/io.h>
+#include <irq.h>
 #include <linux/bitops.h>
 #include <linux/printk.h>
 #include <linux/sizes.h>
@@ -163,8 +164,28 @@ static const struct udevice_id gic_v3_ids[] = {
 	{}
 };
 
+static int arm_gic_v3_of_xlate(struct irq *irq, struct ofnode_phandle_args *args)
+{
+	if (args->args_count > 2) {
+		log_debug("Invalid args_count: %d\n", args->args_count);
+		return -EINVAL;
+	}
+
+	if (args->args_count > 0)
+		irq->id = args->args[0];
+	if (args->args_count > 1)
+		irq->flags = args->args[1];
+
+	return 0;
+}
+
+static const struct irq_ops arm_gic_v3_ops = {
+	.of_xlate		=  arm_gic_v3_of_xlate,
+};
+
 U_BOOT_DRIVER(arm_gic_v3) = {
 	.name		= "gic-v3",
 	.id		= UCLASS_IRQ,
 	.of_match	= gic_v3_ids,
+	.ops		= &arm_gic_v3_ops,
 };
Signature · 1 line
2.46.0
Reviewed-by on v4 20/35
#45 lore raw

Re: [PATCH v4 20/35] arm: gic-v3-its: Implement of_xlate

Quoted 11 lines · Patrick Rudolph

Translate IRQs by implementing of_xlate() as required by irq_get_by_index() to parse interrupt properties.

TEST: Booted on qemu sbsa-ref that has a GICV3.

---
 arch/arm/lib/gic-v3-its.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
#46 lore raw

PATCH v4 21/35 arm: lib: Add GICV2 driver

In reply to Patrick Rudolph

Add a generic GICV2 driver that:
- parses the DT and generates the ACPI MADT subtables
- implement of_xlate() and allows irq_get_by_index() to return the correct interrupt mappings

TEST: Booted on QEMU raspb4 using GICV2 driver model generated MADT.

---
 arch/arm/Kconfig      |  7 ++++
 arch/arm/lib/Makefile |  1 +
 arch/arm/lib/gic-v2.c | 89 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 97 insertions(+)
 create mode 100644 arch/arm/lib/gic-v2.c
arch/arm/Kconfig +7 -0
index ba0359fed5..50327f5349 100644
@@ -113,6 +113,13 @@ config GICV2
 config GICV3
 	bool
 
+config DRIVER_GICV2
+	bool "ARM GICV2 driver"
+	select IRQ
+	help
+	  ARM GICV2 driver.
+	  Basic support for parsing the GICV2 node and generate ACPI tables.
+
 config GIC_V3_ITS
 	bool "ARM GICV3 ITS"
 	select IRQ
arch/arm/lib/Makefile +1 -0
index a7efed6771..cf76051450 100644
@@ -68,6 +68,7 @@ obj-$(CONFIG_FSL_LAYERSCAPE) += ccn504.o
 ifneq ($(CONFIG_GICV2)$(CONFIG_GICV3),)
 obj-y	+= gic_64.o
 endif
+obj-$(CONFIG_DRIVER_GICV2)	+= gic-v2.o
 obj-$(CONFIG_GIC_V3_ITS)	+= gic-v3-its.o
 obj-y	+= interrupts_64.o
 else
arch/arm/lib/gic-v2.c new file +89 -0

89 lines not on this page · raw message

Signature · 1 line
2.46.0
Reviewed-by on v4 21/35
#47 lore raw

Re: [PATCH v4 21/35] arm: lib: Add GICV2 driver

Quoted 8 lines · Patrick Rudolph

Add a generic GICV2 driver that:
- parses the DT and generates the ACPI MADT subtables
- implement of_xlate() and allows irq_get_by_index() to return the correct interrupt mappings

TEST: Booted on QEMU raspb4 using GICV2 driver model generated MADT.

Quoted 7 lines
---
 arch/arm/Kconfig      |  7 ++++
 arch/arm/lib/Makefile |  1 +
 arch/arm/lib/gic-v2.c | 89 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 97 insertions(+)
 create mode 100644 arch/arm/lib/gic-v2.c
Quoted 6 lines
arch/arm/Kconfig +0 -0
index ba0359fed5..50327f5349 100644

arch/arm/Kconfig config GICV2 · line 121

Quoted 9 lines
arch/arm/Kconfig +6 -0
@@ -113,6 +113,13 @@ config GICV2
 config GICV3
        bool
 
+config DRIVER_GICV2
+       bool "ARM GICV2 driver"
+       select IRQ
+       help
+         ARM GICV2 driver.
+         Basic support for parsing the GICV2 node and generate ACPI tables.

s/for parsing/to parse/

or change generate to generating

Quoted 22 lines
arch/arm/Kconfig +1 -0
+
 config GIC_V3_ITS
        bool "ARM GICV3 ITS"
        select IRQ
arch/arm/lib/Makefile +1 -0
index a7efed6771..cf76051450 100644
@@ -68,6 +68,7 @@ obj-$(CONFIG_FSL_LAYERSCAPE) += ccn504.o
 ifneq ($(CONFIG_GICV2)$(CONFIG_GICV3),)
 obj-y  += gic_64.o
 endif
+obj-$(CONFIG_DRIVER_GICV2)     += gic-v2.o
 obj-$(CONFIG_GIC_V3_ITS)       += gic-v3-its.o
 obj-y  += interrupts_64.o
 else
arch/arm/lib/gic-v2.c new file +0 -0
new file mode 100644
index 0000000000..c9f9f441eb

arch/arm/lib/gic-v2.c line 9

Quoted 9 lines
arch/arm/lib/gic-v2.c new file +9 -0
@@ -0,0 +1,89 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2019 Broadcom.
+ */
+#include <asm/gic.h>
+#include <asm/acpi_table.h>
+#include <cpu_func.h>
+#include <dm/acpi.h>
+#include <dt-bindings/interrupt-controller/arm-gic.h>

Please check header-file order in all your patches.

Quoted 81 lines
arch/arm/lib/gic-v2.c new file +80 -1
+#include <dm.h>
+#include <irq.h>
+
+#ifdef CONFIG_ACPIGEN
+/**
+ * acpi_gicv2_fill_madt() - Fill out the body of the MADT
+ *
+ * Write GICD and GICR tables based on collected devicetree data.
+ *
+ * @dev: Device to write ACPI tables for
+ * @ctx: ACPI context to write MADT sub-tables to
+ * Return: 0 if OK
+ */
+static int acpi_gicv2_fill_madt(const struct udevice *dev, struct acpi_ctx *ctx)
+{
+       struct acpi_madt_gicd *gicd;
+       fdt_addr_t addr;
+
+       addr = dev_read_addr_index(dev, 0);
+       if (addr == FDT_ADDR_T_NONE) {
+               pr_err("%s: failed to get GICD address\n", __func__);
+               return -EINVAL;
+       }
+
+       gicd = ctx->current;
+       acpi_write_madt_gicd(gicd, dev_seq(dev), addr, 2);
+       acpi_inc(ctx, gicd->length);
+
+       return 0;
+}
+
+static struct acpi_ops gic_v2_acpi_ops = {
+       .fill_madt      = acpi_gicv2_fill_madt,
+};
+#endif
+
+static const struct udevice_id gic_v2_ids[] = {
+       { .compatible = "arm,arm11mp-gic" },
+       { .compatible = "arm,cortex-a15-gic" },
+       { .compatible = "arm,cortex-a7-gic" },
+       { .compatible = "arm,cortex-a5-gic" },
+       { .compatible = "arm,cortex-a9-gic" },
+       { .compatible = "arm,eb11mp-gic" },
+       { .compatible = "arm,gic-400" },
+       { .compatible = "arm,pl390" },
+       { .compatible = "arm,tc11mp-gic" },
+       { .compatible = "qcom,msm-8660-qgic" },
+       { .compatible = "qcom,msm-qgic2" },
+       {}
+};
+
+static int arm_gic_v2_of_xlate(struct irq *irq, struct ofnode_phandle_args *args)
+{
+       if (args->args_count != 3) {
+               log_debug("Invalid args_count: %d\n", args->args_count);
+               return -EINVAL;
+       }
+
+       /* ARM Generic Interrupt Controller v1 and v2 */
+       if (args->args[0] == GIC_PPI)
+               irq->id = args->args[1] + 16;
+       else
+               irq->id = args->args[1];
+
+       irq->flags = args->args[2];
+
+       return 0;
+}
+
+static const struct irq_ops arm_gic_v2_ops = {
+       .of_xlate               =  arm_gic_v2_of_xlate,
+};
+
+U_BOOT_DRIVER(arm_gic_v2) = {
+       .name           = "gic-v2",
+       .id             = UCLASS_IRQ,
+       .of_match       = gic_v2_ids,
+       .ops            = &arm_gic_v2_ops,
+       ACPI_OPS_PTR(&gic_v2_acpi_ops)
+};
--
Quoted 2 lines

2.46.0

Regards,
Simon

#48 lore raw

PATCH v4 22/35 drivers: misc: irq-uclass: Update irq_get_by_index

In reply to Patrick Rudolph

Support reading the "interrupts" property from the devicetree in case the "interrupts-extended" property isn't found. As the "interrupts" property is commonly used, this allows to parse all existing FDT and makes irq_get_by_index() more useful.

The "interrupts" property doesn't contain a phandle as "interrupts-extended" does, so implement a new method to locate the interrupt-parent called irq_get_interrupt_parent().

TEST: Read the interrupts from the GIC node for ACPI MADT generation.

---
 arch/sandbox/dts/test.dts |  3 ++
 drivers/misc/irq-uclass.c | 66 ++++++++++++++++++++++++++++++++++++++-
 include/irq.h             | 14 +++++++++
 test/dm/irq.c             | 15 +++++++++
 4 files changed, 97 insertions(+), 1 deletion(-)
arch/sandbox/dts/test.dts +3 -0
index 5fb5eac862..d578ba07f6 100644
@@ -522,6 +522,9 @@
 	};
 
 	f-test {
+		#interrupt-cells = <2>;
+		interrupt-parent = <&irq>;
+		interrupts = <4 0>;
 		compatible = "denx,u-boot-fdt-test";
 	};
 
drivers/misc/irq-uclass.c +65 -1

81 lines not on this page · raw message

include/irq.h +14 -0
index 5638c10128..0fbc1a5f48 100644
@@ -200,6 +200,20 @@ int irq_restore_polarities(struct udevice *dev);
  */
 int irq_read_and_clear(struct irq *irq);
 
+/**
+ * irq_get_interrupt_parent() - returns the interrupt parent
+ *
+ * Walks the devicetree and returns the interrupt parent's ofnode
+ * for the specified device.
+ *
+ * @dev: device
+ * @interrupt_parent: The interrupt parent's ofnode'
+ * Return: 0 success, or error value
+ *
+ */
+int irq_get_interrupt_parent(const struct udevice *dev,
+			     struct udevice **interrupt_parent);
+
 struct phandle_2_arg;
 /**
  * irq_get_by_phandle() - Get an irq by its phandle information (of-platadata)
test/dm/irq.c +15 -0
index d22772ab76..1cbf524f67 100644
@@ -76,6 +76,21 @@ static int dm_test_request(struct unit_test_state *uts)
 }
 DM_TEST(dm_test_request, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
 
+/* Test of irq_get_by_index() */
+static int dm_test_irq_get_by_index(struct unit_test_state *uts)
+{
+	struct udevice *dev;
+	struct irq irq;
+
+	ut_assertok(uclass_get_device_by_name(UCLASS_TEST_FDT, "f-test",
+					      &dev));
+	ut_assertok(irq_get_by_index(dev, 0, &irq));
+	ut_asserteq(4, irq.id);
+
+	return 0;
+}
+DM_TEST(dm_test_irq_get_by_index, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
+
 /* Test of irq_get_acpi() */
 static int dm_test_irq_get_acpi(struct unit_test_state *uts)
 {
Signature · 1 line
2.46.0
#49 lore raw

Re: [PATCH v4 22/35] drivers: misc: irq-uclass: Update irq_get_by_index

Hi Patrick,

Quoted 12 lines · Patrick Rudolph

Support reading the "interrupts" property from the devicetree in case the "interrupts-extended" property isn't found. As the "interrupts" property is commonly used, this allows to parse all existing FDT and makes irq_get_by_index() more useful.

The "interrupts" property doesn't contain a phandle as "interrupts-extended" does, so implement a new method to locate the interrupt-parent called irq_get_interrupt_parent().

TEST: Read the interrupts from the GIC node for ACPI MADT generation.

Quoted 7 lines
---
 arch/sandbox/dts/test.dts |  3 ++
 drivers/misc/irq-uclass.c | 66 ++++++++++++++++++++++++++++++++++++++-
 include/irq.h             | 14 +++++++++
 test/dm/irq.c             | 15 +++++++++
 4 files changed, 97 insertions(+), 1 deletion(-)

Is this a new patch? I don't see a change log so I am wondering if I already reviewed it?

Regards,
Simon

#50 lore raw

Re: [PATCH v4 22/35] drivers: misc: irq-uclass: Update irq_get_by_index

Quoted 25 lines · Simon Glass

Hi Patrick,

Quoted 12 lines · Patrick Rudolph

Support reading the "interrupts" property from the devicetree in case the "interrupts-extended" property isn't found. As the "interrupts" property is commonly used, this allows to parse all existing FDT and makes irq_get_by_index() more useful.

The "interrupts" property doesn't contain a phandle as "interrupts-extended" does, so implement a new method to locate the interrupt-parent called irq_get_interrupt_parent().

TEST: Read the interrupts from the GIC node for ACPI MADT generation.

Quoted 7 lines
---
 arch/sandbox/dts/test.dts |  3 ++
 drivers/misc/irq-uclass.c | 66 ++++++++++++++++++++++++++++++++++++++-
 include/irq.h             | 14 +++++++++
 test/dm/irq.c             | 15 +++++++++
 4 files changed, 97 insertions(+), 1 deletion(-)
Quoted 3 lines

Is this a new patch? I don't see a change log so I am wondering if I already reviewed it?

It's a new patch. I had to extend irq_get_by_index() as it is used to parse the DT while
generating MADT subtables solely from DT.

Quoted 2 lines

Regards,
Simon

Reviewed-by
#51 lore raw

Re: [PATCH v4 22/35] drivers: misc: irq-uclass: Update irq_get_by_index

Quoted 27 lines · Patrick Rudolph
Quoted 25 lines · Simon Glass

Hi Patrick,

Quoted 19 lines · Patrick Rudolph

Support reading the "interrupts" property from the devicetree in case the "interrupts-extended" property isn't found. As the "interrupts" property is commonly used, this allows to parse all existing FDT and makes irq_get_by_index() more useful.

The "interrupts" property doesn't contain a phandle as "interrupts-extended" does, so implement a new method to locate the interrupt-parent called irq_get_interrupt_parent().

TEST: Read the interrupts from the GIC node for ACPI MADT generation.

---
 arch/sandbox/dts/test.dts |  3 ++
 drivers/misc/irq-uclass.c | 66 ++++++++++++++++++++++++++++++++++++++-
 include/irq.h             | 14 +++++++++
 test/dm/irq.c             | 15 +++++++++
 4 files changed, 97 insertions(+), 1 deletion(-)
Quoted 6 lines
Quoted 3 lines

Is this a new patch? I don't see a change log so I am wondering if I already reviewed it?

It's a new patch. I had to extend irq_get_by_index() as it is used to parse the DT while
generating MADT subtables solely from DT.

OK thanks

#52 lore raw

PATCH v4 23/35 drivers/arm: Implement acpi_fill_madt

In reply to Patrick Rudolph

Fill the MADT table in the GICV3 driver and armv8 CPU driver to drop SoC specific code. While the GIC only needs devicetree data, the CPU driver needs additional information stored in the cpu_plat struct.

While on it update the only board making use of the existing drivers and writing ACPI MADT in mainboard code.

TEST: Booted on QEMU sbsa-ref using GICV3 driver model generated MADT.
Booted on QEMU raspb4 using GICV2 driver model generated MADT.

---
Changelog v4:
- Read everything from the DT
- Export armv8_cpu_fill_madt() to use it in other CPU drivers
- Depend on IRQ

---
 arch/arm/lib/gic-v3-its.c | 89 ++++++++++++++++++++++++++++++++++++++-
 drivers/cpu/Kconfig       |  1 +
 drivers/cpu/armv8_cpu.c   | 80 ++++++++++++++++++++++++++++++++++-
 drivers/cpu/armv8_cpu.h   | 10 +++++
 4 files changed, 178 insertions(+), 2 deletions(-)
arch/arm/lib/gic-v3-its.c +88 -1
index 54dbff434c..f733ca36d3 100644
@@ -7,6 +7,8 @@
 #include <asm/gic.h>
 #include <asm/gic-v3.h>
 #include <asm/io.h>
+#include <asm/acpi_table.h>
+#include <dm/acpi.h>
 #include <irq.h>
 #include <linux/bitops.h>
 #include <linux/printk.h>
@@ -27,12 +29,14 @@ static u32 lpi_id_bits;
 struct gic_v3_its_priv {
 	ulong gicd_base;
 	ulong gicr_base;
+	ulong gicr_length;
 };
 
 static int gic_v3_its_get_gic_addr(struct gic_v3_its_priv *priv)
 {
 	struct udevice *dev;
 	fdt_addr_t addr;
+	fdt_size_t size;
 	int ret;
 
 	ret = uclass_get_device_by_driver(UCLASS_IRQ,
@@ -50,12 +54,13 @@ static int gic_v3_its_get_gic_addr(struct gic_v3_its_priv *priv)
 	}
 	priv->gicd_base = addr;
 
-	addr = dev_read_addr_index(dev, 1);
+	addr = dev_read_addr_size_index(dev, 1, &size);
 	if (addr == FDT_ADDR_T_NONE) {
 		pr_err("%s: failed to get GICR address\n", __func__);
 		return -EINVAL;
 	}
 	priv->gicr_base = addr;
+	priv->gicr_length = size;
 
 	return 0;
 }
@@ -159,6 +164,42 @@ int gic_lpi_tables_init(u64 base, u32 num_redist)
 	return 0;
 }
 
+#ifdef CONFIG_ACPIGEN
+/**
+ * acpi_gicv3_fill_madt() - Fill out the body of the MADT
+ *
+ * Write GICD and GICR tables based on collected devicetree data.
+ *
+ * @dev: Device to write ACPI tables for
+ * @ctx: ACPI context to write MADT sub-tables to
+ * Return: 0 if OK
+ */
+static int acpi_gicv3_fill_madt(const struct udevice *dev, struct acpi_ctx *ctx)
+{
+	struct acpi_madt_gicd *gicd;
+	struct acpi_madt_gicr *gicr;
+
+	struct gic_v3_its_priv priv;
+
+	if (gic_v3_its_get_gic_addr(&priv))
+		return -EINVAL;
+
+	gicd = ctx->current;
+	acpi_write_madt_gicd(gicd, dev_seq(dev), priv.gicd_base, 3);
+	acpi_inc(ctx, gicd->length);
+
+	gicr = ctx->current;
+	acpi_write_madt_gicr(gicr, priv.gicr_base, priv.gicr_length);
+	acpi_inc(ctx, gicr->length);
+
+	return 0;
+}
+
+struct acpi_ops gic_v3_acpi_ops = {
+	.fill_madt	= acpi_gicv3_fill_madt,
+};
+#endif
+
 static const struct udevice_id gic_v3_ids[] = {
 	{ .compatible = "arm,gic-v3" },
 	{}
@@ -188,4 +229,50 @@ U_BOOT_DRIVER(arm_gic_v3) = {
 	.id		= UCLASS_IRQ,
 	.of_match	= gic_v3_ids,
 	.ops		= &arm_gic_v3_ops,
+	ACPI_OPS_PTR(&gic_v3_acpi_ops)
+};
+
+#ifdef CONFIG_ACPIGEN
+/**
+ * acpi_gic_its_fill_madt() - Fill out the body of the MADT
+ *
+ * Write ITS tables based on collected devicetree data.
+ *
+ * @dev: Device to write ACPI tables for
+ * @ctx: ACPI context to write MADT sub-tables to
+ * Return: 0 if OK
+ */
+static int acpi_gic_its_fill_madt(const struct udevice *dev, struct acpi_ctx *ctx)
+{
+	struct acpi_madt_its *its;
+	fdt_addr_t addr;
+
+	addr = dev_read_addr_index(dev, 0);
+	if (addr == FDT_ADDR_T_NONE) {
+		pr_err("%s: failed to get GIC ITS address\n", __func__);
+		return -EINVAL;
+	}
+
+	its = ctx->current;
+	acpi_write_madt_its(its, dev_seq(dev), addr);
+	acpi_inc(ctx, its->length);
+
+	return 0;
+}
+
+struct acpi_ops gic_v3_its_acpi_ops = {
+	.fill_madt	= acpi_gic_its_fill_madt,
+};
+#endif
+
+static const struct udevice_id gic_v3_its_ids[] = {
+	{ .compatible = "arm,gic-v3-its" },
+	{}
+};
+
+U_BOOT_DRIVER(arm_gic_v3_its) = {
+	.name		= "gic-v3-its",
+	.id		= UCLASS_IRQ,
+	.of_match	= gic_v3_its_ids,
+	ACPI_OPS_PTR(&gic_v3_its_acpi_ops)
 };
drivers/cpu/Kconfig +1 -0
index 9c0df331d7..4cc3679c00 100644
@@ -29,6 +29,7 @@ config CPU_RISCV
 config CPU_ARMV8
 	bool "Enable generic ARMv8 CPU driver"
 	depends on CPU && ARM64
+	select IRQ
 	help
 	  Support CPU cores for armv8 architecture.
 
drivers/cpu/armv8_cpu.c +79 -1

97 lines not on this page · raw message

drivers/cpu/armv8_cpu.h +10 -0
index 2c4b0252cf..48c705e98d 100644
@@ -18,4 +18,14 @@
  */
 int armv8_cpu_fill_ssdt(const struct udevice *dev, struct acpi_ctx *ctx);
 
+/**
+ * armv8_cpu_fill_madt() - Fill the MADT
+ * Parses the FDT and writes the MADT subtables.
+ *
+ * @dev: cpu device to generate ACPI tables for
+ * @ctx: ACPI context pointer
+ * @return:	0 if OK, or a negative error code.
+ */
+int armv8_cpu_fill_madt(const struct udevice *dev, struct acpi_ctx *ctx);
+
 #endif
\ No newline at end of file
Signature · 1 line
2.46.0
Reviewed-by on v4 23/35
#53 lore raw

Re: [PATCH v4 23/35] drivers/arm: Implement acpi_fill_madt

Quoted 20 lines · Patrick Rudolph

Fill the MADT table in the GICV3 driver and armv8 CPU driver to drop SoC specific code. While the GIC only needs devicetree data, the CPU driver needs additional information stored in the cpu_plat struct.

While on it update the only board making use of the existing drivers and writing ACPI MADT in mainboard code.

TEST: Booted on QEMU sbsa-ref using GICV3 driver model generated MADT.
Booted on QEMU raspb4 using GICV2 driver model generated MADT.

---
Changelog v4:
- Read everything from the DT
- Export armv8_cpu_fill_madt() to use it in other CPU drivers
- Depend on IRQ

Quoted 7 lines
---
 arch/arm/lib/gic-v3-its.c | 89 ++++++++++++++++++++++++++++++++++++++-
 drivers/cpu/Kconfig       |  1 +
 drivers/cpu/armv8_cpu.c   | 80 ++++++++++++++++++++++++++++++++++-
 drivers/cpu/armv8_cpu.h   | 10 +++++
 4 files changed, 178 insertions(+), 2 deletions(-)

I'm still not sure why you are using u64 instead of ulong?

#54 lore raw

Re: [PATCH v4 23/35] drivers/arm: Implement acpi_fill_madt

Quoted 31 lines · Simon Glass
Quoted 20 lines · Patrick Rudolph

Fill the MADT table in the GICV3 driver and armv8 CPU driver to drop SoC specific code. While the GIC only needs devicetree data, the CPU driver needs additional information stored in the cpu_plat struct.

While on it update the only board making use of the existing drivers and writing ACPI MADT in mainboard code.

TEST: Booted on QEMU sbsa-ref using GICV3 driver model generated MADT.
Booted on QEMU raspb4 using GICV2 driver model generated MADT.

---
Changelog v4:
- Read everything from the DT
- Export armv8_cpu_fill_madt() to use it in other CPU drivers
- Depend on IRQ

Quoted 7 lines
---
 arch/arm/lib/gic-v3-its.c | 89 ++++++++++++++++++++++++++++++++++++++-
 drivers/cpu/Kconfig       |  1 +
 drivers/cpu/armv8_cpu.c   | 80 ++++++++++++++++++++++++++++++++++-
 drivers/cpu/armv8_cpu.h   | 10 +++++
 4 files changed, 178 insertions(+), 2 deletions(-)
Quoted 3 lines

I'm still not sure why you are using u64 instead of ulong?

u64 is the type defined in the ACPI spec for the fields within the ACPI MADT table.
It's also valid for 32-bit systems, even though this code is supposed to run on 64-bit only.

#55 lore raw

PATCH v4 24/35 common: Enable BLOBLIST_TABLES on arm

In reply to Patrick Rudolph

Allow to use BLOBLIST_TABLES on arm to store ACPI or other tables.

---
 common/Kconfig |  1 +
 lib/Kconfig    | 15 +++++++++------
 2 files changed, 10 insertions(+), 6 deletions(-)
common/Kconfig +1 -0
index e1b8557e0c..09ead61817 100644
@@ -1076,6 +1076,7 @@ config BLOBLIST_SIZE_RELOC
 	hex "Size of bloblist after relocation"
 	default BLOBLIST_SIZE if BLOBLIST_FIXED || BLOBLIST_ALLOC
 	default 0x0 if BLOBLIST_PASSAGE
+	default 0x20000 if (ARM && EFI_LOADER && GENERATE_ACPI_TABLE)
 	help
 	  Sets the size of the bloblist in bytes after relocation. Since U-Boot
 	  has a lot more memory available then, it is possible to use a larger
lib/Kconfig +9 -6
index 2059219a12..ea444354eb 100644
@@ -983,12 +983,15 @@ menu "System tables"
 
 config BLOBLIST_TABLES
 	bool "Put tables in a bloblist"
-	depends on X86 && BLOBLIST
-	help
-	  Normally tables are placed at address 0xf0000 and can be up to 64KB
-	  long. With this option, tables are instead placed in the bloblist
-	  with a pointer from 0xf0000. The size can then be larger and the
-	  tables can be placed high in memory.
+	depends on BLOBLIST
+	default y if (ARM && EFI_LOADER && GENERATE_ACPI_TABLE)
+	default n
+	help
+	  On x86 normally tables are placed at address 0xf0000 and can be up
+	  to 64KB long. With this option, tables are instead placed in the
+	  bloblist with a pointer from 0xf0000. The size can then be larger
+	  and the tables can be placed high in memory.
+	  On other architectures the tables are always placed in high memory.
 
 config GENERATE_SMBIOS_TABLE
 	bool "Generate an SMBIOS (System Management BIOS) table"
Signature · 1 line
2.46.0
Reviewed-by on v4 24/35
#56 lore raw

Re: [PATCH v4 24/35] common: Enable BLOBLIST_TABLES on arm

Quoted 10 lines · Patrick Rudolph

Allow to use BLOBLIST_TABLES on arm to store ACPI or other tables.

---
 common/Kconfig |  1 +
 lib/Kconfig    | 15 +++++++++------
 2 files changed, 10 insertions(+), 6 deletions(-)
Quoted 41 lines
common/Kconfig +1 -0
index e1b8557e0c..09ead61817 100644
@@ -1076,6 +1076,7 @@ config BLOBLIST_SIZE_RELOC
        hex "Size of bloblist after relocation"
        default BLOBLIST_SIZE if BLOBLIST_FIXED || BLOBLIST_ALLOC
        default 0x0 if BLOBLIST_PASSAGE
+       default 0x20000 if (ARM && EFI_LOADER && GENERATE_ACPI_TABLE)
        help
          Sets the size of the bloblist in bytes after relocation. Since U-Boot
          has a lot more memory available then, it is possible to use a larger
lib/Kconfig +9 -7
index 2059219a12..ea444354eb 100644
@@ -983,12 +983,15 @@ menu "System tables"
 
 config BLOBLIST_TABLES
        bool "Put tables in a bloblist"
-       depends on X86 && BLOBLIST
-       help
-         Normally tables are placed at address 0xf0000 and can be up to 64KB
-         long. With this option, tables are instead placed in the bloblist
-         with a pointer from 0xf0000. The size can then be larger and the
-         tables can be placed high in memory.
+       depends on BLOBLIST
+       default y if (ARM && EFI_LOADER && GENERATE_ACPI_TABLE)
+       default n
+       help
+         On x86 normally tables are placed at address 0xf0000 and can be up
+         to 64KB long. With this option, tables are instead placed in the
+         bloblist with a pointer from 0xf0000. The size can then be larger
+         and the tables can be placed high in memory.
+         On other architectures the tables are always placed in high memory.
 
 config GENERATE_SMBIOS_TABLE
        bool "Generate an SMBIOS (System Management BIOS) table"
--

2.46.0

#57 lore raw

PATCH v4 25/35 board: emulation: Add QEMU sbsa support

In reply to Patrick Rudolph

Add support for Arm sbsa [1] v0.3+ that is supported by QEMU [2].

Unlike other Arm based platforms the machine only provides a minimal FDT that contains number of CPUs, ammount of memory and machine-version. The boot firmware has to provide ACPI tables to the OS.

Add a minimal amount of devicetree nodes to make the board useable within U-Boot, provide documentation how to use, enable binman to fabricate both ROMs that are required to boot and add ACPI tables to make it full compatible to the EDK2 reference implementation.

The board was tested using Fedora 40 Aarch64 Workstation. It's able to boot from USB and AHCI or network.

Tested and found working:
- serial
- PCI
- xHCI
- Bochs display
- AHCI
- network using e1000e
- CPU init
- Booting Fedora 40

1: Server Base System Architecture (SBSA)
2: https://www.qemu.org/docs/master/system/arm/sbsa.html

Cc Peter Robinson <[email protected]>
Cc Simon Glass <[email protected]>
Cc Tom Rini <[email protected]>

---
Changelog v3:
- Add GIC and GIC-ITS to devicetree
- Select GICv3 driver
- Drop acpi_fill_madt and use driver model instead Changelog v4:
- Drop CPU platform code
- Enhance the DT to allow MADT generation from DT

---
 arch/arm/Kconfig                            |   1 +
 arch/arm/dts/qemu-sbsa.dts                  |  49 ++
 arch/arm/include/asm/arch-qemu-sbsa/boot0.h |  33 ++
 arch/arm/mach-qemu/Kconfig                  |  36 +-
 board/emulation/qemu-arm/MAINTAINERS        |   2 +
 board/emulation/qemu-sbsa/Kconfig           |  58 ++
 board/emulation/qemu-sbsa/Makefile          |   8 +
 board/emulation/qemu-sbsa/acpi.c            | 197 +++++++
 board/emulation/qemu-sbsa/dsdt.asl          | 483 ++++++++++++++++
 board/emulation/qemu-sbsa/lowlevel_init.S   |  22 +
 board/emulation/qemu-sbsa/qemu-sbsa.c       | 602 ++++++++++++++++++++
 board/emulation/qemu-sbsa/qemu-sbsa.env     |  14 +
 board/emulation/qemu-sbsa/qemu-sbsa.h       |  38 ++
 board/emulation/qemu-sbsa/smc.c             |  72 +++
 configs/qemu-arm-sbsa_defconfig             |  10 +
 doc/board/emulation/index.rst               |   1 +
 doc/board/emulation/qemu-sbsa.rst           |  98 ++++
 doc/develop/driver-model/virtio.rst         |   1 +
 include/configs/qemu-sbsa.h                 | 104 ++++
 19 files changed, 1823 insertions(+), 6 deletions(-)
 create mode 100644 arch/arm/dts/qemu-sbsa.dts
 create mode 100644 arch/arm/include/asm/arch-qemu-sbsa/boot0.h
 create mode 100644 board/emulation/qemu-sbsa/Kconfig
 create mode 100644 board/emulation/qemu-sbsa/Makefile
 create mode 100644 board/emulation/qemu-sbsa/acpi.c
 create mode 100644 board/emulation/qemu-sbsa/dsdt.asl
 create mode 100644 board/emulation/qemu-sbsa/lowlevel_init.S
 create mode 100644 board/emulation/qemu-sbsa/qemu-sbsa.c
 create mode 100644 board/emulation/qemu-sbsa/qemu-sbsa.env
 create mode 100644 board/emulation/qemu-sbsa/qemu-sbsa.h
 create mode 100644 board/emulation/qemu-sbsa/smc.c
 create mode 100644 configs/qemu-arm-sbsa_defconfig
 create mode 100644 doc/board/emulation/qemu-sbsa.rst
 create mode 100644 include/configs/qemu-sbsa.h
arch/arm/Kconfig +1 -0
index 50327f5349..e85a7131d3 100644
@@ -2367,6 +2367,7 @@ source "board/broadcom/bcmns3/Kconfig"
 source "board/cavium/thunderx/Kconfig"
 source "board/eets/pdu001/Kconfig"
 source "board/emulation/qemu-arm/Kconfig"
+source "board/emulation/qemu-sbsa/Kconfig"
 source "board/freescale/ls2080aqds/Kconfig"
 source "board/freescale/ls2080ardb/Kconfig"
 source "board/freescale/ls1088a/Kconfig"
arch/arm/dts/qemu-sbsa.dts new file +49 -0

49 lines not on this page · raw message

arch/arm/include/asm/arch-qemu-sbsa/boot0.h new file +33 -0
new file mode 100644
index 0000000000..1ca75145d2
@@ -0,0 +1,33 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * sbsa-ref starts U-Boot in XIP memory. Need to relocate U-Boot
+ * to DRAM which is already up. Instead of using SPL this simple loader
+ * is being used.
+ */
+relocate_check:
+	/* x0 contains the pointer to FDT provided by ATF */
+	adr	x1, _start		/* x1 <- Runtime value of _start */
+	ldr	x2, _TEXT_BASE		/* x2 <- Linked value of _start */
+	subs	x9, x1, x2		/* x9 <- Run-vs-link offset */
+	beq	reset
+
+	adrp	x1, __image_copy_start		/* x2 <- address bits [31:12] */
+	add	x1, x1, :lo12:__image_copy_start/* x2 <- address bits [11:00] */
+	adrp	x3, __image_copy_end		/* x3 <- address bits [31:12] */
+	add	x3, x3, :lo12:__image_copy_end	/* x3 <- address bits [11:00] */
+
+copy_loop:
+	ldp	x10, x11, [x1], #16	/* copy from source address [x1] */
+	stp	x10, x11, [x2], #16	/* copy to   target address [x2] */
+	cmp	x1, x3			/* until source end address [x3] */
+	b.lo	copy_loop
+
+	isb
+	ldr	x2, _TEXT_BASE		/* x2 <- Linked value of _start */
+	br	x2			/* Jump to linked address */
+	/* Never reaches this point */
+1:
+	wfi
+	b 1b
+
+relocate_done:
\ No newline at end of file
arch/arm/mach-qemu/Kconfig +30 -6
index 186c3582eb..9c06c6a3a5 100644
@@ -3,12 +3,6 @@ if ARCH_QEMU
 config SYS_VENDOR
 	default "emulation"
 
-config SYS_BOARD
-	default "qemu-arm"
-
-config SYS_CONFIG_NAME
-	default "qemu-arm"
-
 choice
 	prompt "QEMU ARM architecture"
 	default TARGET_QEMU_ARM_64BIT
@@ -25,6 +19,36 @@ config TARGET_QEMU_ARM_64BIT
 	select ARM64
 	select BOARD_LATE_INIT
 
+config TARGET_QEMU_ARM_SBSA
+	bool "SBSA Reference"
+	select ARM64
+	select BINMAN
+	select BOARD_LATE_INIT
+	select ENABLE_ARM_SOC_BOOT0_HOOK
+	select MISC_INIT_R
 endchoice
 
+if TARGET_QEMU_ARM_32BIT || TARGET_QEMU_ARM_64BIT
+
+config SYS_BOARD
+	default "qemu-arm"
+
+config SYS_CONFIG_NAME
+	default "qemu-arm"
+
+endif
+
+if TARGET_QEMU_ARM_SBSA
+
+config SYS_BOARD
+	default "qemu-sbsa"
+
+config SYS_CONFIG_NAME
+	default "qemu-sbsa"
+
+config SYS_SOC
+	default "qemu-sbsa"
+
+endif
+
 endif
board/emulation/qemu-arm/MAINTAINERS +2 -0
index 5154262f29..7bc0ee698c 100644
@@ -4,5 +4,7 @@ S:	Maintained
 F:	board/emulation/qemu-arm/
 F:	board/emulation/common/
 F:	include/configs/qemu-arm.h
+F:	include/configs/qemu-sbsa.h
 F:	configs/qemu_arm_defconfig
 F:	configs/qemu_arm64_defconfig
+F:	configs/qemu-arm-sbsa_defconfig
board/emulation/qemu-sbsa/Kconfig new file +58 -0

58 lines not on this page · raw message

board/emulation/qemu-sbsa/Makefile new file +8 -0
new file mode 100644
index 0000000000..bacae320e7
@@ -0,0 +1,8 @@
+# SPDX-License-Identifier: GPL-2.0+
+
+obj-y	+= qemu-sbsa.o
+obj-y	+= lowlevel_init.o
+obj-y	+= smc.o
+
+obj-$(CONFIG_GENERATE_ACPI_TABLE) += dsdt_generated.o
+obj-$(CONFIG_GENERATE_ACPI_TABLE) += acpi.o
board/emulation/qemu-sbsa/acpi.c new file +197 -0

197 lines not on this page · raw message

board/emulation/qemu-sbsa/dsdt.asl new file +483 -0

483 lines not on this page · raw message

board/emulation/qemu-sbsa/lowlevel_init.S new file +22 -0
new file mode 100644
index 0000000000..c997721af9
@@ -0,0 +1,22 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * (C) Copyright 2016
+ * Cédric Schieli <[email protected]>
+ */
+
+#include <config.h>
+
+/*
+ * Routine: save_boot_params (called after reset from start.S)
+ * Description: save ATAG/FDT address provided by the firmware at boot time
+ */
+
+.global save_boot_params
+save_boot_params:
+	/* The firmware provided ATAG/FDT address can be found in r2/x0 */
+	adr	x8, fw_dtb_pointer
+	str	x0, [x8]
+
+
+	/* Returns */
+	b	save_boot_params_ret
board/emulation/qemu-sbsa/qemu-sbsa.c new file +602 -0

602 lines not on this page · raw message

board/emulation/qemu-sbsa/qemu-sbsa.env new file +14 -0
new file mode 100644
index 0000000000..88fdb0ec1c
@@ -0,0 +1,14 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+
+/* environment for qemu-arm and qemu-arm64 */
+
+stdin=serial,usbkbd
+stdout=serial,vidconsole
+stderr=serial,vidconsole
+fdt_high=0xffffffffffffffff
+initrd_high=0xffffffffffffffff
+scriptaddr=0x100000300000
+pxefile_addr_r=0x10000400000
+kernel_addr_r=0x10000200000
+ramdisk_addr_r=0x10001000000
+boot_targets=qfw usb scsi virtio nvme dhcp
board/emulation/qemu-sbsa/qemu-sbsa.h new file +38 -0
new file mode 100644
index 0000000000..391a70bdc4
@@ -0,0 +1,38 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (c) 2024 9elements GmbH
+ */
+
+/**
+ * smc_get_mpidr() - Call into SMC and get the MPIDR for given CPU
+ *
+ * @id:		CPU index
+ * @mpidr:	Pointer where to place the MPIDR
+ * @return 0 if OK, other -ve on error
+ */
+int smc_get_mpidr(unsigned long id, u64 *mpidr);
+
+/**
+ * smc_get_gic_dist_base() - Call into SMC and get GIC dist base address
+ *
+ * @mpidr:	Pointer where to place the base address
+ * @return 0 if OK, other -ve on error
+ */
+int smc_get_gic_dist_base(u64 *base);
+
+/**
+ * smc_get_gic_redist_base() - Call into SMC and get the GIC redistributor
+ *                             base address
+ *
+ * @mpidr:	Pointer where to place the base address
+ * @return 0 if OK, other -ve on error
+ */
+int smc_get_gic_redist_base(u64 *base);
+
+/**
+ * smc_get_gic_its_base() - Call into SMC and get the ITS base address
+ *
+ * @mpidr:	Pointer where to place the base address
+ * @return 0 if OK, other -ve on error
+ */
+int smc_get_gic_its_base(u64 *base);
board/emulation/qemu-sbsa/smc.c new file +72 -0

72 lines not on this page · raw message

configs/qemu-arm-sbsa_defconfig new file +10 -0
new file mode 100644
index 0000000000..a58c3dec4c
@@ -0,0 +1,10 @@
+CONFIG_ARM=y
+CONFIG_ARCH_QEMU=y
+CONFIG_TARGET_QEMU_ARM_SBSA=y
+CONFIG_USE_BOOTCOMMAND=y
+CONFIG_BOOTCOMMAND="bootflow scan"
+CONFIG_EFI_PARTITION=y
+CONFIG_PARTITION_TYPE_GUID=y
+CONFIG_EFI_MEDIA=y
+CONFIG_FS_FAT=y
+CONFIG_EFI_VARIABLE_NO_STORE=y
doc/board/emulation/index.rst +1 -0
index 98a0b26ad2..0419d72415 100644
@@ -13,5 +13,6 @@ Emulation
    qemu-mips
    qemu-ppce500
    qemu-riscv
+   qemu-sbsa
    qemu-x86
    qemu-xtensa
doc/board/emulation/qemu-sbsa.rst new file +98 -0

98 lines not on this page · raw message

doc/develop/driver-model/virtio.rst +1 -0
index 8ac9c94caf..31b94d0467 100644
@@ -34,6 +34,7 @@ The following QEMU targets are supported.
 
   - qemu_arm_defconfig
   - qemu_arm64_defconfig
+  - qemu-arm-sbsa_defconfig
   - qemu-riscv32_defconfig
   - qemu-riscv64_defconfig
   - qemu-x86_defconfig
include/configs/qemu-sbsa.h new file +104 -0

104 lines not on this page · raw message

Signature · 1 line
2.46.0
#58 lore raw

Re: [PATCH v4 25/35] board: emulation: Add QEMU sbsa support

Hi Patrick,

Quoted 67 lines · Patrick Rudolph

Add support for Arm sbsa [1] v0.3+ that is supported by QEMU [2].

Unlike other Arm based platforms the machine only provides a minimal FDT that contains number of CPUs, ammount of memory and machine-version. The boot firmware has to provide ACPI tables to the OS.

Add a minimal amount of devicetree nodes to make the board useable within U-Boot, provide documentation how to use, enable binman to fabricate both ROMs that are required to boot and add ACPI tables to make it full compatible to the EDK2 reference implementation.

The board was tested using Fedora 40 Aarch64 Workstation. It's able to boot from USB and AHCI or network.

Tested and found working:
- serial
- PCI
- xHCI
- Bochs display
- AHCI
- network using e1000e
- CPU init
- Booting Fedora 40

1: Server Base System Architecture (SBSA)
2: https://www.qemu.org/docs/master/system/arm/sbsa.html

Cc Peter Robinson <[email protected]>
Cc Simon Glass <[email protected]>
Cc Tom Rini <[email protected]>

---
Changelog v3:
- Add GIC and GIC-ITS to devicetree
- Select GICv3 driver
- Drop acpi_fill_madt and use driver model instead Changelog v4:
- Drop CPU platform code
- Enhance the DT to allow MADT generation from DT

---
 arch/arm/Kconfig                            |   1 +
 arch/arm/dts/qemu-sbsa.dts                  |  49 ++
 arch/arm/include/asm/arch-qemu-sbsa/boot0.h |  33 ++
 arch/arm/mach-qemu/Kconfig                  |  36 +-
 board/emulation/qemu-arm/MAINTAINERS        |   2 +
 board/emulation/qemu-sbsa/Kconfig           |  58 ++
 board/emulation/qemu-sbsa/Makefile          |   8 +
 board/emulation/qemu-sbsa/acpi.c            | 197 +++++++
 board/emulation/qemu-sbsa/dsdt.asl          | 483 ++++++++++++++++
 board/emulation/qemu-sbsa/lowlevel_init.S   |  22 +
 board/emulation/qemu-sbsa/qemu-sbsa.c       | 602 ++++++++++++++++++++
 board/emulation/qemu-sbsa/qemu-sbsa.env     |  14 +
 board/emulation/qemu-sbsa/qemu-sbsa.h       |  38 ++
 board/emulation/qemu-sbsa/smc.c             |  72 +++
 configs/qemu-arm-sbsa_defconfig             |  10 +
 doc/board/emulation/index.rst               |   1 +
 doc/board/emulation/qemu-sbsa.rst           |  98 ++++
 doc/develop/driver-model/virtio.rst         |   1 +
 include/configs/qemu-sbsa.h                 | 104 ++++
 19 files changed, 1823 insertions(+), 6 deletions(-)
 create mode 100644 arch/arm/dts/qemu-sbsa.dts
 create mode 100644 arch/arm/include/asm/arch-qemu-sbsa/boot0.h
 create mode 100644 board/emulation/qemu-sbsa/Kconfig
 create mode 100644 board/emulation/qemu-sbsa/Makefile
 create mode 100644 board/emulation/qemu-sbsa/acpi.c
 create mode 100644 board/emulation/qemu-sbsa/dsdt.asl
Quoted 8 lines
 create mode 100644 board/emulation/qemu-sbsa/lowlevel_init.S
 create mode 100644 board/emulation/qemu-sbsa/qemu-sbsa.c
 create mode 100644 board/emulation/qemu-sbsa/qemu-sbsa.env
 create mode 100644 board/emulation/qemu-sbsa/qemu-sbsa.h
 create mode 100644 board/emulation/qemu-sbsa/smc.c
 create mode 100644 configs/qemu-arm-sbsa_defconfig
 create mode 100644 doc/board/emulation/qemu-sbsa.rst
 create mode 100644 include/configs/qemu-sbsa.h

This is quite strange. Why not use the correct DT with the required properties?

Please use lower-case hex.

Can you not use the ofnode API?

Regards,
Simon

#59 lore raw

PATCH v4 26/35 arm: mach-bcm283x: Map the ARM local MMIO as well

In reply to Patrick Rudolph

Cover the "ARM local MMIO" range as well in the default MMU mapping in order to allow future code to access the GIC-400 without crashing. For now the GIC is not touched in u-boot, thus this change is a noop.

See [1](BCM2711 ARM Peripherals) for reference.

TEST: Enabled CONFIG_GICV2 and accessed the GIC in C code without crash.

1: https://datasheets.raspberrypi.com/bcm2711/bcm2711-peripherals.pdf

Cc Matthias Brugger <[email protected]>
Cc Peter Robinson <[email protected]>
---
 arch/arm/mach-bcm283x/init.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/mach-bcm283x/init.c +1 -1
index 1b459707bc..7a1de22e0a 100644
@@ -50,7 +50,7 @@ static struct mm_region bcm2711_mem_map[MEM_MAP_MAX_ENTRIES] = {
 	}, {
 		.virt = 0xfc000000UL,
 		.phys = 0xfc000000UL,
-		.size = 0x03800000UL,
+		.size = 0x04000000UL,
 		.attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
 			 PTE_BLOCK_NON_SHARE |
 			 PTE_BLOCK_PXN | PTE_BLOCK_UXN
Signature · 1 line
2.46.0
Reviewed-by on v4 26/35
#60 lore raw

Re: [PATCH v4 26/35] arm: mach-bcm283x: Map the ARM local MMIO as well

Quoted 4 lines · Patrick Rudolph

Cover the "ARM local MMIO" range as well in the default MMU mapping in order to allow future code to access the GIC-400 without crashing. For now the GIC is not touched in u-boot, thus this change is a noop.

U-Boot

Quoted 5 lines

See [1](BCM2711 ARM Peripherals) for reference.

TEST: Enabled CONFIG_GICV2 and accessed the GIC in C code without crash.

Quoted 9 lines

1: https://datasheets.raspberrypi.com/bcm2711/bcm2711-peripherals.pdf

Cc Matthias Brugger <[email protected]>
Cc Peter Robinson <[email protected]>
---
 arch/arm/mach-bcm283x/init.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 16 lines
arch/arm/mach-bcm283x/init.c +1 -2
index 1b459707bc..7a1de22e0a 100644
@@ -50,7 +50,7 @@ static struct mm_region bcm2711_mem_map[MEM_MAP_MAX_ENTRIES] = {
        }, {
                .virt = 0xfc000000UL,
                .phys = 0xfc000000UL,
-               .size = 0x03800000UL,
+               .size = 0x04000000UL,
                .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
                         PTE_BLOCK_NON_SHARE |
                         PTE_BLOCK_PXN | PTE_BLOCK_UXN
--

2.46.0

Acked-by on v4 26/35
#61 lore raw

Re: [PATCH v4 26/35] arm: mach-bcm283x: Map the ARM local MMIO as well

In reply to Patrick Rudolph
Quoted 6 lines · Patrick Rudolph

Cover the "ARM local MMIO" range as well in the default MMU mapping in order to allow future code to access the GIC-400 without crashing. For now the GIC is not touched in u-boot, thus this change is a noop.

See [1](BCM2711 ARM Peripherals) for reference.

Quoted 7 lines

TEST: Enabled CONFIG_GICV2 and accessed the GIC in C code without crash.

1: https://datasheets.raspberrypi.com/bcm2711/bcm2711-peripherals.pdf

Cc Matthias Brugger <[email protected]>
Cc Peter Robinson <[email protected]>
Quoted 17 lines
---
  arch/arm/mach-bcm283x/init.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/mach-bcm283x/init.c +1 -1
index 1b459707bc..7a1de22e0a 100644
@@ -50,7 +50,7 @@ static struct mm_region bcm2711_mem_map[MEM_MAP_MAX_ENTRIES] = {
  	}, {
  		.virt = 0xfc000000UL,
  		.phys = 0xfc000000UL,
-		.size = 0x03800000UL,
+		.size = 0x04000000UL,
  		.attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
  			 PTE_BLOCK_NON_SHARE |
  			 PTE_BLOCK_PXN | PTE_BLOCK_UXN
#62 lore raw

PATCH v4 27/35 arm: mach-bcm283x: Bring in some header files from tianocore

In reply to Patrick Rudolph

From: Simon Glass <[email protected]>>

These header files presumably duplicate things already in the U-Boot devicetree. For now, bring them in to get the ASL code and ACPI table code to compile.

---
 .../mach-bcm283x/include/mach/acpi/bcm2711.h  | 152 ++++++++++++++++++
 .../mach-bcm283x/include/mach/acpi/bcm2836.h  | 127 +++++++++++++++
 .../include/mach/acpi/bcm2836_gpio.h          |  19 +++
 .../include/mach/acpi/bcm2836_gpu.h           |  47 ++++++
 .../include/mach/acpi/bcm2836_pwm.h           |  33 ++++
 .../include/mach/acpi/bcm2836_sdhost.h        |  18 +++
 .../include/mach/acpi/bcm2836_sdio.h          |  21 +++
 drivers/pci/pcie_brcmstb.c                    | 101 ++----------
 8 files changed, 427 insertions(+), 91 deletions(-)
 create mode 100644 arch/arm/mach-bcm283x/include/mach/acpi/bcm2711.h
 create mode 100644 arch/arm/mach-bcm283x/include/mach/acpi/bcm2836.h
 create mode 100644 arch/arm/mach-bcm283x/include/mach/acpi/bcm2836_gpio.h
 create mode 100644 arch/arm/mach-bcm283x/include/mach/acpi/bcm2836_gpu.h
 create mode 100644 arch/arm/mach-bcm283x/include/mach/acpi/bcm2836_pwm.h
 create mode 100644 arch/arm/mach-bcm283x/include/mach/acpi/bcm2836_sdhost.h
 create mode 100644 arch/arm/mach-bcm283x/include/mach/acpi/bcm2836_sdio.h
arch/arm/mach-bcm283x/include/mach/acpi/bcm2711.h new file +152 -0
new file mode 100644
index 0000000000..a86875b183
@@ -0,0 +1,152 @@
+/* SPDX-License-Identifier: BSD-2-Clause-Patent */
+/**
+ *
+ *  Copyright (c) 2019, Jeremy Linton
+ *  Copyright (c) 2019, Pete Batard <[email protected]>.
+ *
+ **/
+
+#ifndef BCM2711_H__
+#define BCM2711_H__
+
+#define BCM2711_SOC_REGISTERS              0xfc000000
+#define BCM2711_SOC_REGISTER_LENGTH        0x02000000
+
+#define BCM2711_ARM_LOCAL_REGISTERS        0xfe000000
+#define BCM2711_ARM_LOCAL_REGISTER_LENGTH  0x02000000
+
+/* arm local addresses */
+#define BCM2711_ARMC_OFFSET                0x0000b000
+#define BCM2711_ARMC_BASE_ADDRESS          (BCM2711_ARM_LOCAL_REGISTERS + BCM2711_ARMC_OFFSET)
+#define BCM2711_ARMC_LENGTH                0x00000400
+
+#define BCM2711_ARM_LOCAL_OFFSET           0x01800000
+#define BCM2711_ARM_LOCAL_BASE_ADDRESS     (BCM2711_ARM_LOCAL_REGISTERS + BCM2711_ARM_LOCAL_OFFSET)
+#define BCM2711_ARM_LOCAL_LENGTH           0x00000080
+
+#define BCM2711_GIC400_OFFSET              0x01840000
+#define BCM2711_GIC400_BASE_ADDRESS        (BCM2711_ARM_LOCAL_REGISTERS + BCM2711_GIC400_OFFSET)
+#define BCM2711_GIC400_LENGTH              0x00008000
+
+/* Generic PCI addresses */
+#define PCIE_TOP_OF_MEM_WIN                0xf8000000
+#define PCIE_CPU_MMIO_WINDOW               0x600000000
+#define PCIE_BRIDGE_MMIO_LEN               0x3ffffff
+
+/* PCI root bridge control registers location */
+#define PCIE_REG_BASE                      0xfd500000
+#define PCIE_REG_LIMIT                     0x9310
+
+/* PCI root bridge control registers */
+#define BRCM_PCIE_CAP_REGS                        0x00ac
+#define PCIE_RC_CFG_VENDOR_VENDOR_SPECIFIC_REG1   0x0188
+#define  VENDOR_SPECIFIC_REG1_LITTLE_ENDIAN          0x0
+#define PCIE_RC_CFG_PRIV1_ID_VAL3                 0x043c
+#define PCIE_RC_CFG_PRIV1_LINK_CAPABILITY         0x04dc
+#define  LINK_CAPABILITY_ASPM_SUPPORT_MASK         0xc00
+
+#define PCIE_RC_DL_MDIO_ADDR                      0x1100
+#define PCIE_RC_DL_MDIO_WR_DATA                   0x1104
+#define PCIE_RC_DL_MDIO_RD_DATA                   0x1108
+
+#define PCIE_MISC_MISC_CTRL                       0x4008
+#define  MISC_CTRL_SCB_ACCESS_EN_MASK             0x1000
+#define  MISC_CTRL_CFG_READ_UR_MODE_MASK          0x2000
+#define  MISC_CTRL_MAX_BURST_SIZE_MASK            0x300000
+#define  MISC_CTRL_MAX_BURST_SIZE_128             0x0
+#define  MISC_CTRL_SCB0_SIZE_MASK                 0xf8000000
+
+#define PCIE_MISC_CPU_2_PCIE_MEM_WIN0_LO          0x400c
+#define PCIE_MISC_CPU_2_PCIE_MEM_WIN0_HI          0x4010
+#define PCIE_MEM_WIN0_LO(win)	\
+		PCIE_MISC_CPU_2_PCIE_MEM_WIN0_LO + ((win) * 4)
+
+#define PCIE_MEM_WIN0_HI(win)	\
+		PCIE_MISC_CPU_2_PCIE_MEM_WIN0_HI + ((win) * 4)
+#define PCIE_MISC_RC_BAR1_CONFIG_LO               0x402c
+#define  RC_BAR1_CONFIG_LO_SIZE_MASK                0x1f
+#define PCIE_MISC_RC_BAR2_CONFIG_LO               0x4034
+#define  RC_BAR2_CONFIG_LO_SIZE_MASK                0x1f
+#define PCIE_MISC_RC_BAR2_CONFIG_HI               0x4038
+#define PCIE_MISC_RC_BAR3_CONFIG_LO               0x403c
+#define  RC_BAR3_CONFIG_LO_SIZE_MASK                0x1f
+#define PCIE_MISC_PCIE_STATUS                     0x4068
+#define  STATUS_PCIE_PORT_MASK                      0x80
+#define  STATUS_PCIE_PORT_SHIFT                        7
+#define  STATUS_PCIE_DL_ACTIVE_MASK                 0x20
+#define  STATUS_PCIE_DL_ACTIVE_SHIFT                   5
+#define  STATUS_PCIE_PHYLINKUP_MASK                 0x10
+#define  STATUS_PCIE_PHYLINKUP_SHIFT                   4
+#define PCIE_MISC_REVISION                        0x406c
+#define PCIE_MISC_CPU_2_PCIE_MEM_WIN0_BASE_LIMIT  0x4070
+#define  MEM_WIN0_BASE_LIMIT_LIMIT_MASK           0xfff00000
+#define  MEM_WIN0_BASE_LIMIT_BASE_MASK            0xfff0
+#define  MEM_WIN0_BASE_LIMIT_BASE_HI_SHIFT        12
+#define PCIE_MEM_WIN0_BASE_LIMIT(win)	\
+	 PCIE_MISC_CPU_2_PCIE_MEM_WIN0_BASE_LIMIT + ((win) * 4)
+#define PCIE_MISC_CPU_2_PCIE_MEM_WIN0_BASE_HI     0x4080
+#define  MEM_WIN0_BASE_HI_BASE_MASK               0xff
+#define PCIE_MEM_WIN0_BASE_HI(win)	\
+	 PCIE_MISC_CPU_2_PCIE_MEM_WIN0_BASE_HI + ((win) * 8)
+#define PCIE_MISC_CPU_2_PCIE_MEM_WIN0_LIMIT_HI    0x4084
+#define  PCIE_MEM_WIN0_LIMIT_HI_LIMIT_MASK        0xff
+#define PCIE_MEM_WIN0_LIMIT_HI(win)	\
+	 PCIE_MISC_CPU_2_PCIE_MEM_WIN0_LIMIT_HI + ((win) * 8)
+
+#define PCIE_MISC_HARD_PCIE_HARD_DEBUG            0x4204
+#define  PCIE_HARD_DEBUG_SERDES_IDDQ_MASK         0x08000000
+
+#define PCIE_INTR2_CPU_STATUS                 0x4300
+#define PCIE_INTR2_CPU_SET                    0x4304
+#define PCIE_INTR2_CPU_CLR                    0x4308
+#define PCIE_INTR2_CPU_MASK_STATUS            0x430c
+#define PCIE_INTR2_CPU_MASK_SET               0x4310
+#define PCIE_INTR2_CPU_MASK_CLR               0x4314
+
+#define PCIE_MSI_INTR2_CLR                    0x4508
+#define PCIE_MSI_INTR2_MASK_SET               0x4510
+
+#define PCIE_RGR1_SW_INIT_1                   0x9210
+#define PCIE_EXT_CFG_INDEX                    0x9000
+/* A small window pointing at the ECAM of the device selected by CFG_INDEX */
+#define PCIE_EXT_CFG_DATA                     0x8000
+
+#define PCIE_RC_CFG_VENDOR_VENDOR_SPECIFIC_REG1_ENDIAN_MODE_BAR2_MASK 0xc
+#define PCIE_RC_CFG_PRIV1_ID_VAL3_CLASS_CODE_MASK                     0xffffff
+
+#define PCIE_MISC_MISC_CTRL_SCB_ACCESS_EN_MASK                  0x1000
+#define PCIE_MISC_MISC_CTRL_CFG_READ_UR_MODE_MASK               0x2000
+#define PCIE_MISC_MISC_CTRL_MAX_BURST_SIZE_MASK                 0x300000
+#define PCIE_MISC_MISC_CTRL_SCB0_SIZE_MASK                      0xf8000000
+#define PCIE_MISC_MISC_CTRL_SCB1_SIZE_MASK                      0x7c00000
+#define PCIE_MISC_MISC_CTRL_SCB2_SIZE_MASK                      0x1f
+#define PCIE_MISC_RC_BAR2_CONFIG_LO_SIZE_MASK                   0x1f
+
+#define PCIE_RGR1_SW_INIT_1_INIT_MASK                           0x2
+#define PCIE_RGR1_SW_INIT_1_PERST_MASK                          0x1
+
+#define PCIE_MISC_HARD_PCIE_HARD_DEBUG_SERDES_IDDQ_MASK         0x08000000
+
+#define PCIE_MISC_HARD_PCIE_HARD_DEBUG_CLKREQ_DEBUG_ENABLE_MASK 0x2
+
+#define PCIE_MISC_CPU_2_PCIE_MEM_WIN0_BASE_LIMIT_LIMIT_MASK     0xfff00000
+#define PCIE_MISC_CPU_2_PCIE_MEM_WIN0_BASE_LIMIT_BASE_MASK      0xfff0
+#define PCIE_MISC_CPU_2_PCIE_MEM_WIN0_BASE_HI_BASE_MASK         0xff
+#define PCIE_MISC_CPU_2_PCIE_MEM_WIN0_LIMIT_HI_LIMIT_MASK       0xff
+#define PCIE_MISC_CPU_2_PCIE_MEM_WIN0_MASK_BITS                 0xc
+
+#define PCIE_MISC_REVISION_MAJMIN_MASK                          0xffff
+
+#define BURST_SIZE_128          0
+#define BURST_SIZE_256          1
+#define BURST_SIZE_512          2
+
+#define BCM2711_THERM_SENSOR_OFFSET           0x015d2200
+#define BCM2711_THERM_SENSOR_BASE_ADDRESS     (BCM2711_SOC_REGISTERS + BCM2711_THERM_SENSOR_OFFSET)
+#define BCM2711_THERM_SENSOR_LENGTH           0x00000008
+
+#define BCM2711_GENET_BASE_OFFSET             0x01580000
+#define BCM2711_GENET_BASE_ADDRESS            (BCM2711_SOC_REGISTERS + BCM2711_GENET_BASE_OFFSET)
+#define BCM2711_GENET_LENGTH                  0x10000
+
+#endif /* BCM2711_H__ */
arch/arm/mach-bcm283x/include/mach/acpi/bcm2836.h new file +127 -0

127 lines not on this page · raw message

arch/arm/mach-bcm283x/include/mach/acpi/bcm2836_gpio.h new file +19 -0
new file mode 100644
index 0000000000..c5b858b412
@@ -0,0 +1,19 @@
+/* SPDX-License-Identifier: BSD-2-Clause-Patent */
+/**
+ *
+ *  Copyright (c) 2020, Pete Batard <[email protected]>
+ *  Copyright (c) 2018, Andrei Warkentin <[email protected]>
+ *  Copyright (c) Microsoft Corporation. All rights reserved.
+ *
+ **/
+
+#include <asm/arch/acpi/bcm2836.h>
+
+#ifndef __BCM2836_GPIO_H__
+#define __BCM2836_GPIO_H__
+
+#define GPIO_OFFSET        0x00200000
+#define GPIO_BASE_ADDRESS  (BCM2836_SOC_REGISTERS + GPIO_OFFSET)
+#define GPIO_LENGTH        0x000000B4
+
+#endif /* __BCM2836_GPIO_H__ */
arch/arm/mach-bcm283x/include/mach/acpi/bcm2836_gpu.h new file +47 -0

47 lines not on this page · raw message

arch/arm/mach-bcm283x/include/mach/acpi/bcm2836_pwm.h new file +33 -0
new file mode 100644
index 0000000000..78a8486673
@@ -0,0 +1,33 @@
+/* SPDX-License-Identifier: BSD-2-Clause-Patent */
+/**
+ *
+ *  Copyright (c) 2020, Pete Batard <[email protected]>
+ *
+ **/
+
+#include <asm/arch/acpi/bcm2836.h>
+
+#ifndef __BCM2836_PWM_H__
+#define __BCM2836_PWM_H__
+
+/* PWM controller constants */
+
+#define BCM2836_PWM_DMA_OFFSET                 0x00007B00
+#define BCM2836_PWM_DMA_BASE_ADDRESS           (BCM2836_SOC_REGISTERS + BCM2836_PWM_DMA_OFFSET)
+#define BCM2836_PWM_DMA_LENGTH                 0x00000100
+
+#define BCM2836_PWM_CLK_OFFSET                 0x001010A0
+#define BCM2836_PWM_CLK_BASE_ADDRESS           (BCM2836_SOC_REGISTERS + BCM2836_PWM_CLK_OFFSET)
+#define BCM2836_PWM_CLK_LENGTH                 0x00000008
+
+#define BCM2836_PWM_CTRL_OFFSET                0x0020C000
+#define BCM2836_PWM_CTRL_BASE_ADDRESS          (BCM2836_SOC_REGISTERS + BCM2836_PWM_CTRL_OFFSET)
+#define BCM2836_PWM_CTRL_LENGTH                0x00000028
+
+#define BCM2836_PWM_BUS_BASE_ADDRESS           0x7E20C000
+#define BCM2836_PWM_BUS_LENGTH                 0x00000028
+
+#define BCM2836_PWM_CTRL_UNCACHED_BASE_ADDRESS 0xFF20C000
+#define BCM2836_PWM_CTRL_UNCACHED_LENGTH       0x00000028
+
+#endif /* __BCM2836_PWM_H__ */
arch/arm/mach-bcm283x/include/mach/acpi/bcm2836_sdhost.h new file +18 -0
new file mode 100644
index 0000000000..9b1afe8440
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: BSD-2-Clause-Patent */
+/**
+ *
+ *  Copyright (c) 2017, Andrei Warkentin <[email protected]>
+ *  Copyright (c) Microsoft Corporation. All rights reserved.
+ *
+ **/
+
+#include <asm/arch/acpi/bcm2836.h>
+
+#ifndef __BCM2836_SDHOST_H__
+#define __BCM2836_SDHOST_H__
+
+#define SDHOST_OFFSET               0x00202000
+#define SDHOST_BASE_ADDRESS         (BCM2836_SOC_REGISTERS + SDHOST_OFFSET)
+#define SDHOST_LENGTH               0x00000100
+
+#endif /*__BCM2836_SDHOST_H__ */
arch/arm/mach-bcm283x/include/mach/acpi/bcm2836_sdio.h new file +21 -0
new file mode 100644
index 0000000000..48d073d434
@@ -0,0 +1,21 @@
+/* SPDX-License-Identifier: BSD-2-Clause-Patent */
+/**
+ *
+ *  Copyright (c) Microsoft Corporation. All rights reserved.
+ *
+ **/
+
+#include <asm/arch/acpi/bcm2836.h>
+
+#ifndef __BCM2836_SDIO_H__
+#define __BCM2836_SDIO_H__
+
+// MMC/SD/SDIO1 register definitions.
+#define MMCHS1_OFFSET     0x00300000
+#define MMCHS2_OFFSET     0x00340000
+#define MMCHS1_BASE       (BCM2836_SOC_REGISTERS + MMCHS1_OFFSET)
+#define MMCHS2_BASE       (BCM2836_SOC_REGISTERS + MMCHS2_OFFSET)
+#define MMCHS1_LENGTH     0x00000100
+#define MMCHS2_LENGTH     0x00000100
+
+#endif /* __BCM2836_SDIO_H__ */
drivers/pci/pcie_brcmstb.c +10 -91

161 lines not on this page · raw message

Signature · 1 line
2.46.0
Acked-by on v4 27/35
#63 lore raw

Re: [PATCH v4 27/35] arm: mach-bcm283x: Bring in some header files from tianocore

Quoted 6 lines · Patrick Rudolph

From: Simon Glass <[email protected]>>

These header files presumably duplicate things already in the U-Boot devicetree. For now, bring them in to get the ASL code and ACPI table code to compile.

Quoted 6 lines
Quoted 651 lines
---
  .../mach-bcm283x/include/mach/acpi/bcm2711.h  | 152 ++++++++++++++++++
  .../mach-bcm283x/include/mach/acpi/bcm2836.h  | 127 +++++++++++++++
  .../include/mach/acpi/bcm2836_gpio.h          |  19 +++
  .../include/mach/acpi/bcm2836_gpu.h           |  47 ++++++
  .../include/mach/acpi/bcm2836_pwm.h           |  33 ++++
  .../include/mach/acpi/bcm2836_sdhost.h        |  18 +++
  .../include/mach/acpi/bcm2836_sdio.h          |  21 +++
  drivers/pci/pcie_brcmstb.c                    | 101 ++----------
  8 files changed, 427 insertions(+), 91 deletions(-)

create mode 100644 arch/arm/mach-bcm283x/include/mach/acpi/bcm2711.h create mode 100644 arch/arm/mach-bcm283x/include/mach/acpi/bcm2836.h create mode 100644 arch/arm/mach-bcm283x/include/mach/acpi/bcm2836_gpio.h create mode 100644 arch/arm/mach-bcm283x/include/mach/acpi/bcm2836_gpu.h create mode 100644 arch/arm/mach-bcm283x/include/mach/acpi/bcm2836_pwm.h create mode 100644 arch/arm/mach-bcm283x/include/mach/acpi/bcm2836_sdhost.h create mode 100644 arch/arm/mach-bcm283x/include/mach/acpi/bcm2836_sdio.h

arch/arm/mach-bcm283x/include/mach/acpi/bcm2711.h new file +152 -0
new file mode 100644
index 0000000000..a86875b183
@@ -0,0 +1,152 @@
+/* SPDX-License-Identifier: BSD-2-Clause-Patent */
+/**
+ *
+ *  Copyright (c) 2019, Jeremy Linton
+ *  Copyright (c) 2019, Pete Batard <[email protected]>.
+ *
+ **/
+
+#ifndef BCM2711_H__
+#define BCM2711_H__
+
+#define BCM2711_SOC_REGISTERS              0xfc000000
+#define BCM2711_SOC_REGISTER_LENGTH        0x02000000
+
+#define BCM2711_ARM_LOCAL_REGISTERS        0xfe000000
+#define BCM2711_ARM_LOCAL_REGISTER_LENGTH  0x02000000
+
+/* arm local addresses */
+#define BCM2711_ARMC_OFFSET                0x0000b000
+#define BCM2711_ARMC_BASE_ADDRESS          (BCM2711_ARM_LOCAL_REGISTERS + BCM2711_ARMC_OFFSET)
+#define BCM2711_ARMC_LENGTH                0x00000400
+
+#define BCM2711_ARM_LOCAL_OFFSET           0x01800000
+#define BCM2711_ARM_LOCAL_BASE_ADDRESS     (BCM2711_ARM_LOCAL_REGISTERS + BCM2711_ARM_LOCAL_OFFSET)
+#define BCM2711_ARM_LOCAL_LENGTH           0x00000080
+
+#define BCM2711_GIC400_OFFSET              0x01840000
+#define BCM2711_GIC400_BASE_ADDRESS        (BCM2711_ARM_LOCAL_REGISTERS + BCM2711_GIC400_OFFSET)
+#define BCM2711_GIC400_LENGTH              0x00008000
+
+/* Generic PCI addresses */
+#define PCIE_TOP_OF_MEM_WIN                0xf8000000
+#define PCIE_CPU_MMIO_WINDOW               0x600000000
+#define PCIE_BRIDGE_MMIO_LEN               0x3ffffff
+
+/* PCI root bridge control registers location */
+#define PCIE_REG_BASE                      0xfd500000
+#define PCIE_REG_LIMIT                     0x9310
+
+/* PCI root bridge control registers */
+#define BRCM_PCIE_CAP_REGS                        0x00ac
+#define PCIE_RC_CFG_VENDOR_VENDOR_SPECIFIC_REG1   0x0188
+#define  VENDOR_SPECIFIC_REG1_LITTLE_ENDIAN          0x0
+#define PCIE_RC_CFG_PRIV1_ID_VAL3                 0x043c
+#define PCIE_RC_CFG_PRIV1_LINK_CAPABILITY         0x04dc
+#define  LINK_CAPABILITY_ASPM_SUPPORT_MASK         0xc00
+
+#define PCIE_RC_DL_MDIO_ADDR                      0x1100
+#define PCIE_RC_DL_MDIO_WR_DATA                   0x1104
+#define PCIE_RC_DL_MDIO_RD_DATA                   0x1108
+
+#define PCIE_MISC_MISC_CTRL                       0x4008
+#define  MISC_CTRL_SCB_ACCESS_EN_MASK             0x1000
+#define  MISC_CTRL_CFG_READ_UR_MODE_MASK          0x2000
+#define  MISC_CTRL_MAX_BURST_SIZE_MASK            0x300000
+#define  MISC_CTRL_MAX_BURST_SIZE_128             0x0
+#define  MISC_CTRL_SCB0_SIZE_MASK                 0xf8000000
+
+#define PCIE_MISC_CPU_2_PCIE_MEM_WIN0_LO          0x400c
+#define PCIE_MISC_CPU_2_PCIE_MEM_WIN0_HI          0x4010
+#define PCIE_MEM_WIN0_LO(win)	\
+		PCIE_MISC_CPU_2_PCIE_MEM_WIN0_LO + ((win) * 4)
+
+#define PCIE_MEM_WIN0_HI(win)	\
+		PCIE_MISC_CPU_2_PCIE_MEM_WIN0_HI + ((win) * 4)
+#define PCIE_MISC_RC_BAR1_CONFIG_LO               0x402c
+#define  RC_BAR1_CONFIG_LO_SIZE_MASK                0x1f
+#define PCIE_MISC_RC_BAR2_CONFIG_LO               0x4034
+#define  RC_BAR2_CONFIG_LO_SIZE_MASK                0x1f
+#define PCIE_MISC_RC_BAR2_CONFIG_HI               0x4038
+#define PCIE_MISC_RC_BAR3_CONFIG_LO               0x403c
+#define  RC_BAR3_CONFIG_LO_SIZE_MASK                0x1f
+#define PCIE_MISC_PCIE_STATUS                     0x4068
+#define  STATUS_PCIE_PORT_MASK                      0x80
+#define  STATUS_PCIE_PORT_SHIFT                        7
+#define  STATUS_PCIE_DL_ACTIVE_MASK                 0x20
+#define  STATUS_PCIE_DL_ACTIVE_SHIFT                   5
+#define  STATUS_PCIE_PHYLINKUP_MASK                 0x10
+#define  STATUS_PCIE_PHYLINKUP_SHIFT                   4
+#define PCIE_MISC_REVISION                        0x406c
+#define PCIE_MISC_CPU_2_PCIE_MEM_WIN0_BASE_LIMIT  0x4070
+#define  MEM_WIN0_BASE_LIMIT_LIMIT_MASK           0xfff00000
+#define  MEM_WIN0_BASE_LIMIT_BASE_MASK            0xfff0
+#define  MEM_WIN0_BASE_LIMIT_BASE_HI_SHIFT        12
+#define PCIE_MEM_WIN0_BASE_LIMIT(win)	\
+	 PCIE_MISC_CPU_2_PCIE_MEM_WIN0_BASE_LIMIT + ((win) * 4)
+#define PCIE_MISC_CPU_2_PCIE_MEM_WIN0_BASE_HI     0x4080
+#define  MEM_WIN0_BASE_HI_BASE_MASK               0xff
+#define PCIE_MEM_WIN0_BASE_HI(win)	\
+	 PCIE_MISC_CPU_2_PCIE_MEM_WIN0_BASE_HI + ((win) * 8)
+#define PCIE_MISC_CPU_2_PCIE_MEM_WIN0_LIMIT_HI    0x4084
+#define  PCIE_MEM_WIN0_LIMIT_HI_LIMIT_MASK        0xff
+#define PCIE_MEM_WIN0_LIMIT_HI(win)	\
+	 PCIE_MISC_CPU_2_PCIE_MEM_WIN0_LIMIT_HI + ((win) * 8)
+
+#define PCIE_MISC_HARD_PCIE_HARD_DEBUG            0x4204
+#define  PCIE_HARD_DEBUG_SERDES_IDDQ_MASK         0x08000000
+
+#define PCIE_INTR2_CPU_STATUS                 0x4300
+#define PCIE_INTR2_CPU_SET                    0x4304
+#define PCIE_INTR2_CPU_CLR                    0x4308
+#define PCIE_INTR2_CPU_MASK_STATUS            0x430c
+#define PCIE_INTR2_CPU_MASK_SET               0x4310
+#define PCIE_INTR2_CPU_MASK_CLR               0x4314
+
+#define PCIE_MSI_INTR2_CLR                    0x4508
+#define PCIE_MSI_INTR2_MASK_SET               0x4510
+
+#define PCIE_RGR1_SW_INIT_1                   0x9210
+#define PCIE_EXT_CFG_INDEX                    0x9000
+/* A small window pointing at the ECAM of the device selected by CFG_INDEX */
+#define PCIE_EXT_CFG_DATA                     0x8000
+
+#define PCIE_RC_CFG_VENDOR_VENDOR_SPECIFIC_REG1_ENDIAN_MODE_BAR2_MASK 0xc
+#define PCIE_RC_CFG_PRIV1_ID_VAL3_CLASS_CODE_MASK                     0xffffff
+
+#define PCIE_MISC_MISC_CTRL_SCB_ACCESS_EN_MASK                  0x1000
+#define PCIE_MISC_MISC_CTRL_CFG_READ_UR_MODE_MASK               0x2000
+#define PCIE_MISC_MISC_CTRL_MAX_BURST_SIZE_MASK                 0x300000
+#define PCIE_MISC_MISC_CTRL_SCB0_SIZE_MASK                      0xf8000000
+#define PCIE_MISC_MISC_CTRL_SCB1_SIZE_MASK                      0x7c00000
+#define PCIE_MISC_MISC_CTRL_SCB2_SIZE_MASK                      0x1f
+#define PCIE_MISC_RC_BAR2_CONFIG_LO_SIZE_MASK                   0x1f
+
+#define PCIE_RGR1_SW_INIT_1_INIT_MASK                           0x2
+#define PCIE_RGR1_SW_INIT_1_PERST_MASK                          0x1
+
+#define PCIE_MISC_HARD_PCIE_HARD_DEBUG_SERDES_IDDQ_MASK         0x08000000
+
+#define PCIE_MISC_HARD_PCIE_HARD_DEBUG_CLKREQ_DEBUG_ENABLE_MASK 0x2
+
+#define PCIE_MISC_CPU_2_PCIE_MEM_WIN0_BASE_LIMIT_LIMIT_MASK     0xfff00000
+#define PCIE_MISC_CPU_2_PCIE_MEM_WIN0_BASE_LIMIT_BASE_MASK      0xfff0
+#define PCIE_MISC_CPU_2_PCIE_MEM_WIN0_BASE_HI_BASE_MASK         0xff
+#define PCIE_MISC_CPU_2_PCIE_MEM_WIN0_LIMIT_HI_LIMIT_MASK       0xff
+#define PCIE_MISC_CPU_2_PCIE_MEM_WIN0_MASK_BITS                 0xc
+
+#define PCIE_MISC_REVISION_MAJMIN_MASK                          0xffff
+
+#define BURST_SIZE_128          0
+#define BURST_SIZE_256          1
+#define BURST_SIZE_512          2
+
+#define BCM2711_THERM_SENSOR_OFFSET           0x015d2200
+#define BCM2711_THERM_SENSOR_BASE_ADDRESS     (BCM2711_SOC_REGISTERS + BCM2711_THERM_SENSOR_OFFSET)
+#define BCM2711_THERM_SENSOR_LENGTH           0x00000008
+
+#define BCM2711_GENET_BASE_OFFSET             0x01580000
+#define BCM2711_GENET_BASE_ADDRESS            (BCM2711_SOC_REGISTERS + BCM2711_GENET_BASE_OFFSET)
+#define BCM2711_GENET_LENGTH                  0x10000
+
+#endif /* BCM2711_H__ */
arch/arm/mach-bcm283x/include/mach/acpi/bcm2836.h new file +127 -0
new file mode 100644
index 0000000000..64cec36a94
@@ -0,0 +1,127 @@
+/* SPDX-License-Identifier: BSD-2-Clause-Patent */
+/**
+ *
+ *  Copyright (c) 2019, ARM Limited. All rights reserved.
+ *  Copyright (c) 2017, Andrei Warkentin <[email protected]>
+ *  Copyright (c) 2016, Linaro Limited. All rights reserved.
+ *
+ **/
+
+#ifndef __BCM2836_H__
+#define __BCM2836_H__
+
+/*
+ * Both "core" and SoC perpherals (1M each).
+ */
+#define BCM2836_SOC_REGISTERS                 0xfe000000
+#define BCM2836_SOC_REGISTER_LENGTH           0x02000000
+
+/*
+ * Offset between the CPU's view and the VC's view of system memory.
+ */
+#define BCM2836_DMA_DEVICE_OFFSET             0xc0000000
+
+/* watchdog constants */
+#define BCM2836_WDOG_OFFSET                   0x00100000
+#define BCM2836_WDOG_BASE_ADDRESS             (BCM2836_SOC_REGISTERS + BCM2836_WDOG_OFFSET)
+#define BCM2836_WDOG_PASSWORD                 0x5a000000
+#define BCM2836_WDOG_RSTC_OFFSET              0x0000001c
+#define BCM2836_WDOG_WDOG_OFFSET              0x00000024
+#define BCM2836_WDOG_RSTC_WRCFG_MASK          0x00000030
+#define BCM2836_WDOG_RSTC_WRCFG_FULL_RESET    0x00000020
+
+/* clock manager constants */
+#define BCM2836_CM_OFFSET                     0x00101000
+#define BCM2836_CM_BASE                       (BCM2836_SOC_REGISTERS + BCM2836_CM_OFFSET)
+#define BCM2836_CM_GEN_CLOCK_CONTROL          0x0000
+#define BCM2836_CM_GEN_CLOCK_DIVISOR          0x0004
+#define BCM2836_CM_VPU_CLOCK_CONTROL          0x0008
+#define BCM2836_CM_VPU_CLOCK_DIVISOR          0x000c
+#define BCM2836_CM_SYSTEM_CLOCK_CONTROL       0x0010
+#define BCM2836_CM_SYSTEM_CLOCK_DIVISOR       0x0014
+#define BCM2836_CM_H264_CLOCK_CONTROL         0x0028
+#define BCM2836_CM_H264_CLOCK_DIVISOR         0x002c
+#define BCM2836_CM_PWM_CLOCK_CONTROL          0x00a0
+#define BCM2836_CM_PWM_CLOCK_DIVISOR          0x00a4
+#define BCM2836_CM_UART_CLOCK_CONTROL         0x00f0
+#define BCM2836_CM_UART_CLOCK_DIVISOR         0x00f4
+#define BCM2836_CM_SDC_CLOCK_CONTROL          0x01a8
+#define BCM2836_CM_SDC_CLOCK_DIVISOR          0x01ac
+#define BCM2836_CM_ARM_CLOCK_CONTROL          0x01b0
+#define BCM2836_CM_ARM_CLOCK_DIVISOR          0x01b4
+#define BCM2836_CM_EMMC_CLOCK_CONTROL         0x01c0
+#define BCM2836_CM_EMMC_CLOCK_DIVISOR         0x01c4
+
+/* mailbox interface constants */
+#define BCM2836_MBOX_OFFSET                   0x0000b880
+#define BCM2836_MBOX_BASE_ADDRESS             (BCM2836_SOC_REGISTERS + BCM2836_MBOX_OFFSET)
+#define BCM2836_MBOX_LENGTH                   0x00000024
+#define BCM2836_MBOX_READ_OFFSET              0x00000000
+#define BCM2836_MBOX_STATUS_OFFSET            0x00000018
+#define BCM2836_MBOX_CONFIG_OFFSET            0x0000001c
+#define BCM2836_MBOX_WRITE_OFFSET             0x00000020
+
+#define BCM2836_MBOX_STATUS_FULL              0x1f
+#define BCM2836_MBOX_STATUS_EMPTY             0x1e
+
+#define BCM2836_MBOX_NUM_CHANNELS             16
+
+/* interrupt controller constants */
+#define BCM2836_INTC_TIMER_CONTROL_OFFSET     0x00000040
+#define BCM2836_INTC_TIMER_PENDING_OFFSET     0x00000060
+
+/* usb constants */
+#define BCM2836_USB_OFFSET                    0x00980000
+#define BCM2836_USB_BASE_ADDRESS              (BCM2836_SOC_REGISTERS + BCM2836_USB_OFFSET)
+#define BCM2836_USB_LENGTH                    0x00010000
+
+/* serial based protocol constants */
+#define BCM2836_PL011_UART_OFFSET             0x00201000
+#define BCM2836_PL011_UART_BASE_ADDRESS       (BCM2836_SOC_REGISTERS + BCM2836_PL011_UART_OFFSET)
+#define BCM2836_PL011_UART_LENGTH             0x00001000
+
+#define BCM2836_MINI_UART_OFFSET              0x00215000
+#define BCM2836_MINI_UART_BASE_ADDRESS        (BCM2836_SOC_REGISTERS + BCM2836_MINI_UART_OFFSET)
+#define BCM2836_MINI_UART_LENGTH              0x00000070
+
+#define BCM2836_I2C0_OFFSET                   0x00205000
+#define BCM2836_I2C0_BASE_ADDRESS             (BCM2836_SOC_REGISTERS + BCM2836_I2C0_OFFSET)
+#define BCM2836_I2C0_LENGTH                   0x00000020
+
+#define BCM2836_I2C1_OFFSET                   0x00804000
+#define BCM2836_I2C1_BASE_ADDRESS             (BCM2836_SOC_REGISTERS + BCM2836_I2C1_OFFSET)
+#define BCM2836_I2C1_LENGTH                   0x00000020
+
+#define BCM2836_I2C2_OFFSET                   0x00805000
+#define BCM2836_I2C2_BASE_ADDRESS             (BCM2836_SOC_REGISTERS + BCM2836_I2C2_OFFSET)
+#define BCM2836_I2C2_LENGTH                   0x00000020
+
+#define BCM2836_SPI0_OFFSET                   0x00204000
+#define BCM2836_SPI0_BASE_ADDRESS             (BCM2836_SOC_REGISTERS + BCM2836_SPI0_OFFSET)
+#define BCM2836_SPI0_LENGTH                   0x00000020
+
+#define BCM2836_SPI1_OFFSET                   0x00215080
+#define BCM2836_SPI1_LENGTH                   0x00000040
+#define BCM2836_SPI1_BASE_ADDRESS             (BCM2836_SOC_REGISTERS + BCM2836_SPI1_OFFSET)
+
+#define BCM2836_SPI2_OFFSET                   0x002150C0
+#define BCM2836_SPI2_LENGTH                   0x00000040
+#define BCM2836_SPI2_BASE_ADDRESS             (BCM2836_SOC_REGISTERS + BCM2836_SPI2_OFFSET)
+
+#define BCM2836_SYSTEM_TIMER_OFFSET           0x00003000
+#define BCM2836_SYSTEM_TIMER_LENGTH           0x00000020
+#define BCM2836_SYSTEM_TIMER_ADDRESS          (BCM2836_SOC_REGISTERS + BCM2836_SYSTEM_TIMER_OFFSET)
+
+/* dma constants */
+#define BCM2836_DMA0_OFFSET                   0x00007000
+#define BCM2836_DMA0_BASE_ADDRESS             (BCM2836_SOC_REGISTERS + BCM2836_DMA0_OFFSET)
+
+#define BCM2836_DMA15_OFFSET                  0x00E05000
+#define BCM2836_DMA15_BASE_ADDRESS            (BCM2836_SOC_REGISTERS + BCM2836_DMA15_OFFSET)
+
+#define BCM2836_DMA_CTRL_OFFSET               0x00007FE0
+#define BCM2836_DMA_CTRL_BASE_ADDRESS         (BCM2836_SOC_REGISTERS + BCM2836_DMA_CTRL_OFFSET)
+
+#define BCM2836_DMA_CHANNEL_LENGTH            0x00000100
+
+#endif /*__BCM2836_H__ */
arch/arm/mach-bcm283x/include/mach/acpi/bcm2836_gpio.h new file +19 -0
new file mode 100644
index 0000000000..c5b858b412
@@ -0,0 +1,19 @@
+/* SPDX-License-Identifier: BSD-2-Clause-Patent */
+/**
+ *
+ *  Copyright (c) 2020, Pete Batard <[email protected]>
+ *  Copyright (c) 2018, Andrei Warkentin <[email protected]>
+ *  Copyright (c) Microsoft Corporation. All rights reserved.
+ *
+ **/
+
+#include <asm/arch/acpi/bcm2836.h>
+
+#ifndef __BCM2836_GPIO_H__
+#define __BCM2836_GPIO_H__
+
+#define GPIO_OFFSET        0x00200000
+#define GPIO_BASE_ADDRESS  (BCM2836_SOC_REGISTERS + GPIO_OFFSET)
+#define GPIO_LENGTH        0x000000B4
+
+#endif /* __BCM2836_GPIO_H__ */
arch/arm/mach-bcm283x/include/mach/acpi/bcm2836_gpu.h new file +47 -0
new file mode 100644
index 0000000000..5857d7581a
@@ -0,0 +1,47 @@
+/* SPDX-License-Identifier: BSD-2-Clause-Patent */
+/**
+ *
+ *  Copyright (c) 2020, Pete Batard <[email protected]>
+ *
+ **/
+
+#include <asm/arch/acpi/bcm2836.h>
+
+#ifndef __BCM2836_GPU_H__
+#define __BCM2836_GPU_H__
+
+/* VideoCore constants */
+
+#define BCM2836_VCHIQ_OFFSET                  0x0000B840
+#define BCM2836_VCHIQ_BASE_ADDRESS            (BCM2836_SOC_REGISTERS + BCM2836_VCHIQ_OFFSET)
+#define BCM2836_VCHIQ_LENGTH                  0x00000010
+
+#define BCM2836_V3D_BUS_OFFSET                0x00C00000
+#define BCM2836_V3D_BUS_BASE_ADDRESS          (BCM2836_SOC_REGISTERS + BCM2836_V3D_BUS_OFFSET)
+#define BCM2836_V3D_BUS_LENGTH                0x00001000
+
+#define BCM2836_HVS_OFFSET                    0x00400000
+#define BCM2836_HVS_BASE_ADDRESS              (BCM2836_SOC_REGISTERS + BCM2836_HVS_OFFSET)
+#define BCM2836_HVS_LENGTH                    0x00006000
+
+#define BCM2836_PV0_OFFSET                    0x00206000
+#define BCM2836_PV0_BASE_ADDRESS              (BCM2836_SOC_REGISTERS + BCM2836_PV0_OFFSET)
+#define BCM2836_PV0_LENGTH                    0x00000100
+
+#define BCM2836_PV1_OFFSET                    0x00207000
+#define BCM2836_PV1_BASE_ADDRESS              (BCM2836_SOC_REGISTERS + BCM2836_PV1_OFFSET)
+#define BCM2836_PV1_LENGTH                    0x00000100
+
+#define BCM2836_PV2_OFFSET                    0x00807000
+#define BCM2836_PV2_BASE_ADDRESS              (BCM2836_SOC_REGISTERS + BCM2836_PV2_OFFSET)
+#define BCM2836_PV2_LENGTH                    0x00000100
+
+#define BCM2836_HDMI0_OFFSET                  0x00902000
+#define BCM2836_HDMI0_BASE_ADDRESS            (BCM2836_SOC_REGISTERS + BCM2836_HDMI0_OFFSET)
+#define BCM2836_HDMI0_LENGTH                  0x00000600
+
+#define BCM2836_HDMI1_OFFSET                  0x00808000
+#define BCM2836_HDMI1_BASE_ADDRESS            (BCM2836_SOC_REGISTERS + BCM2836_HDMI1_OFFSET)
+#define BCM2836_HDMI1_LENGTH                  0x00000100
+
+#endif /* __BCM2836_MISC_H__ */
arch/arm/mach-bcm283x/include/mach/acpi/bcm2836_pwm.h new file +33 -0
new file mode 100644
index 0000000000..78a8486673
@@ -0,0 +1,33 @@
+/* SPDX-License-Identifier: BSD-2-Clause-Patent */
+/**
+ *
+ *  Copyright (c) 2020, Pete Batard <[email protected]>
+ *
+ **/
+
+#include <asm/arch/acpi/bcm2836.h>
+
+#ifndef __BCM2836_PWM_H__
+#define __BCM2836_PWM_H__
+
+/* PWM controller constants */
+
+#define BCM2836_PWM_DMA_OFFSET                 0x00007B00
+#define BCM2836_PWM_DMA_BASE_ADDRESS           (BCM2836_SOC_REGISTERS + BCM2836_PWM_DMA_OFFSET)
+#define BCM2836_PWM_DMA_LENGTH                 0x00000100
+
+#define BCM2836_PWM_CLK_OFFSET                 0x001010A0
+#define BCM2836_PWM_CLK_BASE_ADDRESS           (BCM2836_SOC_REGISTERS + BCM2836_PWM_CLK_OFFSET)
+#define BCM2836_PWM_CLK_LENGTH                 0x00000008
+
+#define BCM2836_PWM_CTRL_OFFSET                0x0020C000
+#define BCM2836_PWM_CTRL_BASE_ADDRESS          (BCM2836_SOC_REGISTERS + BCM2836_PWM_CTRL_OFFSET)
+#define BCM2836_PWM_CTRL_LENGTH                0x00000028
+
+#define BCM2836_PWM_BUS_BASE_ADDRESS           0x7E20C000
+#define BCM2836_PWM_BUS_LENGTH                 0x00000028
+
+#define BCM2836_PWM_CTRL_UNCACHED_BASE_ADDRESS 0xFF20C000
+#define BCM2836_PWM_CTRL_UNCACHED_LENGTH       0x00000028
+
+#endif /* __BCM2836_PWM_H__ */
arch/arm/mach-bcm283x/include/mach/acpi/bcm2836_sdhost.h new file +18 -0
new file mode 100644
index 0000000000..9b1afe8440
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: BSD-2-Clause-Patent */
+/**
+ *
+ *  Copyright (c) 2017, Andrei Warkentin <[email protected]>
+ *  Copyright (c) Microsoft Corporation. All rights reserved.
+ *
+ **/
+
+#include <asm/arch/acpi/bcm2836.h>
+
+#ifndef __BCM2836_SDHOST_H__
+#define __BCM2836_SDHOST_H__
+
+#define SDHOST_OFFSET               0x00202000
+#define SDHOST_BASE_ADDRESS         (BCM2836_SOC_REGISTERS + SDHOST_OFFSET)
+#define SDHOST_LENGTH               0x00000100
+
+#endif /*__BCM2836_SDHOST_H__ */
arch/arm/mach-bcm283x/include/mach/acpi/bcm2836_sdio.h new file +21 -0
new file mode 100644
index 0000000000..48d073d434
@@ -0,0 +1,21 @@
+/* SPDX-License-Identifier: BSD-2-Clause-Patent */
+/**
+ *
+ *  Copyright (c) Microsoft Corporation. All rights reserved.
+ *
+ **/
+
+#include <asm/arch/acpi/bcm2836.h>
+
+#ifndef __BCM2836_SDIO_H__
+#define __BCM2836_SDIO_H__
+
+// MMC/SD/SDIO1 register definitions.
+#define MMCHS1_OFFSET     0x00300000
+#define MMCHS2_OFFSET     0x00340000
+#define MMCHS1_BASE       (BCM2836_SOC_REGISTERS + MMCHS1_OFFSET)
+#define MMCHS2_BASE       (BCM2836_SOC_REGISTERS + MMCHS2_OFFSET)
+#define MMCHS1_LENGTH     0x00000100
+#define MMCHS2_LENGTH     0x00000100
+
+#endif /* __BCM2836_SDIO_H__ */
drivers/pci/pcie_brcmstb.c +10 -91
index f978c64365..f089c48f02 100644
@@ -12,6 +12,7 @@
   * Copyright (C) 2020 Nicolas Saenz Julienne <[email protected]>
   */
 
+#include <asm/arch/acpi/bcm2711.h>
  #include <errno.h>
  #include <dm.h>
  #include <dm/ofnode.h>
@@ -21,88 +22,6 @@
  #include <linux/log2.h>
  #include <linux/iopoll.h>
 
-/* Offset of the mandatory PCIe capability config registers */
-#define BRCM_PCIE_CAP_REGS				0x00ac
-
-/* The PCIe controller register offsets */
-#define PCIE_RC_CFG_VENDOR_SPECIFIC_REG1		0x0188
-#define  VENDOR_SPECIFIC_REG1_ENDIAN_MODE_BAR2_MASK	0xc
-#define  VENDOR_SPECIFIC_REG1_LITTLE_ENDIAN		0x0
-
-#define PCIE_RC_CFG_PRIV1_ID_VAL3			0x043c
-#define  CFG_PRIV1_ID_VAL3_CLASS_CODE_MASK		0xffffff
-
-#define PCIE_RC_CFG_PRIV1_LINK_CAPABILITY			0x04dc
-#define  PCIE_RC_CFG_PRIV1_LINK_CAPABILITY_ASPM_SUPPORT_MASK	0xc00
-
-#define PCIE_RC_DL_MDIO_ADDR				0x1100
-#define PCIE_RC_DL_MDIO_WR_DATA				0x1104
-#define PCIE_RC_DL_MDIO_RD_DATA				0x1108
-
-#define PCIE_MISC_MISC_CTRL				0x4008
-#define  MISC_CTRL_SCB_ACCESS_EN_MASK			0x1000
-#define  MISC_CTRL_CFG_READ_UR_MODE_MASK		0x2000
-#define  MISC_CTRL_MAX_BURST_SIZE_MASK			0x300000
-#define  MISC_CTRL_MAX_BURST_SIZE_128			0x0
-#define  MISC_CTRL_SCB0_SIZE_MASK			0xf8000000
-
-#define PCIE_MISC_CPU_2_PCIE_MEM_WIN0_LO		0x400c
-#define PCIE_MEM_WIN0_LO(win)	\
-		PCIE_MISC_CPU_2_PCIE_MEM_WIN0_LO + ((win) * 4)
-
-#define PCIE_MISC_CPU_2_PCIE_MEM_WIN0_HI		0x4010
-#define PCIE_MEM_WIN0_HI(win)	\
-		PCIE_MISC_CPU_2_PCIE_MEM_WIN0_HI + ((win) * 4)
-
-#define PCIE_MISC_RC_BAR1_CONFIG_LO			0x402c
-#define  RC_BAR1_CONFIG_LO_SIZE_MASK			0x1f
-
-#define PCIE_MISC_RC_BAR2_CONFIG_LO			0x4034
-#define  RC_BAR2_CONFIG_LO_SIZE_MASK			0x1f
-#define PCIE_MISC_RC_BAR2_CONFIG_HI			0x4038
-
-#define PCIE_MISC_RC_BAR3_CONFIG_LO			0x403c
-#define  RC_BAR3_CONFIG_LO_SIZE_MASK			0x1f
-
-#define PCIE_MISC_PCIE_STATUS				0x4068
-#define  STATUS_PCIE_PORT_MASK				0x80
-#define  STATUS_PCIE_PORT_SHIFT				7
-#define  STATUS_PCIE_DL_ACTIVE_MASK			0x20
-#define  STATUS_PCIE_DL_ACTIVE_SHIFT			5
-#define  STATUS_PCIE_PHYLINKUP_MASK			0x10
-#define  STATUS_PCIE_PHYLINKUP_SHIFT			4
-
-#define PCIE_MISC_CPU_2_PCIE_MEM_WIN0_BASE_LIMIT	0x4070
-#define  MEM_WIN0_BASE_LIMIT_LIMIT_MASK			0xfff00000
-#define  MEM_WIN0_BASE_LIMIT_BASE_MASK			0xfff0
-#define  MEM_WIN0_BASE_LIMIT_BASE_HI_SHIFT		12
-#define PCIE_MEM_WIN0_BASE_LIMIT(win)	\
-	 PCIE_MISC_CPU_2_PCIE_MEM_WIN0_BASE_LIMIT + ((win) * 4)
-
-#define PCIE_MISC_CPU_2_PCIE_MEM_WIN0_BASE_HI		0x4080
-#define  MEM_WIN0_BASE_HI_BASE_MASK			0xff
-#define PCIE_MEM_WIN0_BASE_HI(win)	\
-	 PCIE_MISC_CPU_2_PCIE_MEM_WIN0_BASE_HI + ((win) * 8)
-
-#define PCIE_MISC_CPU_2_PCIE_MEM_WIN0_LIMIT_HI		0x4084
-#define  PCIE_MEM_WIN0_LIMIT_HI_LIMIT_MASK		0xff
-#define PCIE_MEM_WIN0_LIMIT_HI(win)	\
-	 PCIE_MISC_CPU_2_PCIE_MEM_WIN0_LIMIT_HI + ((win) * 8)
-
-#define PCIE_MISC_HARD_PCIE_HARD_DEBUG			0x4204
-#define  PCIE_HARD_DEBUG_SERDES_IDDQ_MASK		0x08000000
-
-#define PCIE_MSI_INTR2_CLR				0x4508
-#define PCIE_MSI_INTR2_MASK_SET				0x4510
-
-#define PCIE_EXT_CFG_DATA				0x8000
-
-#define PCIE_EXT_CFG_INDEX				0x9000
-
-#define PCIE_RGR1_SW_INIT_1				0x9210
-#define  RGR1_SW_INIT_1_PERST_MASK			0x1
-#define  RGR1_SW_INIT_1_INIT_MASK			0x2
-
  /* PCIe parameters */
  #define BRCM_NUM_PCIE_OUT_WINS				4
 
@@ -447,7 +366,7 @@ static int brcm_pcie_probe(struct udevice *dev)
  	 * This will need to be changed when support for other SoCs is added.
  	 */
  	setbits_le32(base + PCIE_RGR1_SW_INIT_1,
-		     RGR1_SW_INIT_1_INIT_MASK | RGR1_SW_INIT_1_PERST_MASK);
+		     PCIE_RGR1_SW_INIT_1_INIT_MASK | PCIE_RGR1_SW_INIT_1_PERST_MASK);
  	/*
  	 * The delay is a safety precaution to preclude the reset signal
  	 * from looking like a glitch.
@@ -455,7 +374,7 @@ static int brcm_pcie_probe(struct udevice *dev)
  	udelay(100);
 
  	/* Take the bridge out of reset */
-	clrbits_le32(base + PCIE_RGR1_SW_INIT_1, RGR1_SW_INIT_1_INIT_MASK);
+	clrbits_le32(base + PCIE_RGR1_SW_INIT_1, PCIE_RGR1_SW_INIT_1_INIT_MASK);
 
  	clrbits_le32(base + PCIE_MISC_HARD_PCIE_HARD_DEBUG,
  		     PCIE_HARD_DEBUG_SERDES_IDDQ_MASK);
@@ -508,7 +427,7 @@ static int brcm_pcie_probe(struct udevice *dev)
 
  	/* Unassert the fundamental reset */
  	clrbits_le32(pcie->base + PCIE_RGR1_SW_INIT_1,
-		     RGR1_SW_INIT_1_PERST_MASK);
+		     PCIE_RGR1_SW_INIT_1_PERST_MASK);
 
  	/*
  	 * Wait for 100ms after PERST# deassertion; see PCIe CEM specification
@@ -552,7 +471,7 @@ static int brcm_pcie_probe(struct udevice *dev)
  	 * a PCIe-PCIe bridge (the default setting is to be EP mode).
  	 */
  	clrsetbits_le32(base + PCIE_RC_CFG_PRIV1_ID_VAL3,
-			CFG_PRIV1_ID_VAL3_CLASS_CODE_MASK, 0x060400);
+			PCIE_RC_CFG_PRIV1_ID_VAL3_CLASS_CODE_MASK, 0x060400);
 
  	if (pcie->ssc) {
  		ret = brcm_pcie_set_ssc(pcie->base);
@@ -570,8 +489,8 @@ static int brcm_pcie_probe(struct udevice *dev)
  	       nlw, ssc_good ? "(SSC)" : "(!SSC)");
 
  	/* PCIe->SCB endian mode for BAR */
-	clrsetbits_le32(base + PCIE_RC_CFG_VENDOR_SPECIFIC_REG1,
-			VENDOR_SPECIFIC_REG1_ENDIAN_MODE_BAR2_MASK,
+	clrsetbits_le32(base + PCIE_RC_CFG_VENDOR_VENDOR_SPECIFIC_REG1,
+			PCIE_RC_CFG_VENDOR_VENDOR_SPECIFIC_REG1_ENDIAN_MODE_BAR2_MASK,
  			VENDOR_SPECIFIC_REG1_LITTLE_ENDIAN);
 
  	/*
@@ -584,7 +503,7 @@ static int brcm_pcie_probe(struct udevice *dev)
  	 * let's instead just unadvertise ASPM support.
  	 */
  	clrbits_le32(base + PCIE_RC_CFG_PRIV1_LINK_CAPABILITY,
-		     PCIE_RC_CFG_PRIV1_LINK_CAPABILITY_ASPM_SUPPORT_MASK);
+		     LINK_CAPABILITY_ASPM_SUPPORT_MASK);
 
  	return 0;
  }
@@ -595,14 +514,14 @@ static int brcm_pcie_remove(struct udevice *dev)
  	void __iomem *base = pcie->base;
 
  	/* Assert fundamental reset */
-	setbits_le32(base + PCIE_RGR1_SW_INIT_1, RGR1_SW_INIT_1_PERST_MASK);
+	setbits_le32(base + PCIE_RGR1_SW_INIT_1, PCIE_RGR1_SW_INIT_1_PERST_MASK);
 
  	/* Turn off SerDes */
  	setbits_le32(base + PCIE_MISC_HARD_PCIE_HARD_DEBUG,
  		     PCIE_HARD_DEBUG_SERDES_IDDQ_MASK);
 
  	/* Shutdown bridge */
-	setbits_le32(base + PCIE_RGR1_SW_INIT_1, RGR1_SW_INIT_1_INIT_MASK);
+	setbits_le32(base + PCIE_RGR1_SW_INIT_1, PCIE_RGR1_SW_INIT_1_INIT_MASK);
 
  	return 0;
  }
#64 lore raw

PATCH v4 28/35 arm: bcm283x: Generate ACPI tables

In reply to Patrick Rudolph

Generate SoC specific ACPI tables for BCM2711:
- FADT
- PPTT
- GTDT

Board specific tables like DSDT and SSDT are added in a separate patch.

MADT is already properly generated from the FDT.

When ACPI is enabled for a different SoC compliation will fail by design, indicating the required functions that needs to be implemented. When ACPI is not enabled the added code does nothing, keeping existing behaviour.

TEST: Booted on RPi4 with only ACPI enabled, providing no FDT to the OS.

Cc Simon Glass <[email protected]>
Cc Matthias Brugger <[email protected]>
Cc Peter Robinson <[email protected]>
Cc Tom Rini <[email protected]>

---
Changelog v2:
- Drop duplicated code to generate ACPI tables. Is now part of efi loader. Changelog v4:
- Drop acpi_fill_madt() as it's now generated by drivers

---
 arch/arm/mach-bcm283x/Makefile       |   4 +
 arch/arm/mach-bcm283x/bcm2711_acpi.c | 128 +++++++++++++++++++++++++++
 2 files changed, 132 insertions(+)
 create mode 100644 arch/arm/mach-bcm283x/bcm2711_acpi.c
arch/arm/mach-bcm283x/Makefile +4 -0
index 7cd068832f..38e320307d 100644
@@ -4,3 +4,7 @@
 
 obj-$(CONFIG_BCM2835) += lowlevel_init.o
 obj-y	+= init.o reset.o mbox.o msg.o phys2bus.o
+
+ifeq ($(CONFIG_GENERATE_ACPI_TABLE),y)
+obj-$(CONFIG_BCM2711) += bcm2711_acpi.o
+endif
\ No newline at end of file
arch/arm/mach-bcm283x/bcm2711_acpi.c new file +128 -0

128 lines not on this page · raw message

Signature · 1 line
2.46.0
Reviewed-by on v4 28/35
#65 lore raw

Re: [PATCH v4 28/35] arm: bcm283x: Generate ACPI tables

Quoted 27 lines · Patrick Rudolph

Generate SoC specific ACPI tables for BCM2711:
- FADT
- PPTT
- GTDT

Board specific tables like DSDT and SSDT are added in a separate patch.

MADT is already properly generated from the FDT.

When ACPI is enabled for a different SoC compliation will fail by design, indicating the required functions that needs to be implemented. When ACPI is not enabled the added code does nothing, keeping existing behaviour.

TEST: Booted on RPi4 with only ACPI enabled, providing no FDT to the OS.

Cc Simon Glass <[email protected]>
Cc Matthias Brugger <[email protected]>
Cc Peter Robinson <[email protected]>
Cc Tom Rini <[email protected]>

---
Changelog v2:
- Drop duplicated code to generate ACPI tables. Is now part of efi loader. Changelog v4:
- Drop acpi_fill_madt() as it's now generated by drivers

Quoted 5 lines
---
 arch/arm/mach-bcm283x/Makefile       |   4 +
 arch/arm/mach-bcm283x/bcm2711_acpi.c | 128 +++++++++++++++++++++++++++
 2 files changed, 132 insertions(+)
 create mode 100644 arch/arm/mach-bcm283x/bcm2711_acpi.c
#66 lore raw

PATCH v4 29/35 board: raspberrypi: Add ASL files from tianocore

In reply to Patrick Rudolph

From: Simon Glass <[email protected]>

Add the necessary DSDT files copied from tianocore to boot the RPi4. In addition generate a board specific SSDT to dynamically enable/disable ACPI devices based on FDT. This is required to support the various variants and boot options. It also allows to test the code on QEMU 9.0 without modifications, since it doesn't emulate PCIe yet.

---
 board/raspberrypi/rpi/.gitignore   |   3 +
 board/raspberrypi/rpi/Makefile     |   2 +
 board/raspberrypi/rpi/acpitables.h |  90 +++++++
 board/raspberrypi/rpi/dsdt.asl     | 290 ++++++++++++++++++++++
 board/raspberrypi/rpi/emmc.asl     | 136 +++++++++++
 board/raspberrypi/rpi/gpudevs.asl  | 372 +++++++++++++++++++++++++++++
 board/raspberrypi/rpi/pci.asl      | 177 ++++++++++++++
 board/raspberrypi/rpi/pep.asl      |  90 +++++++
 board/raspberrypi/rpi/rhpx.asl     | 195 +++++++++++++++
 board/raspberrypi/rpi/rpi.c        | 183 ++++++++++++++
 board/raspberrypi/rpi/sdhc.asl     | 111 +++++++++
 board/raspberrypi/rpi/uart.asl     | 208 ++++++++++++++++
 12 files changed, 1857 insertions(+)
 create mode 100644 board/raspberrypi/rpi/.gitignore
 create mode 100644 board/raspberrypi/rpi/acpitables.h
 create mode 100644 board/raspberrypi/rpi/dsdt.asl
 create mode 100644 board/raspberrypi/rpi/emmc.asl
 create mode 100644 board/raspberrypi/rpi/gpudevs.asl
 create mode 100644 board/raspberrypi/rpi/pci.asl
 create mode 100644 board/raspberrypi/rpi/pep.asl
 create mode 100644 board/raspberrypi/rpi/rhpx.asl
 create mode 100644 board/raspberrypi/rpi/sdhc.asl
 create mode 100644 board/raspberrypi/rpi/uart.asl
board/raspberrypi/rpi/.gitignore new file +3 -0
new file mode 100644
index 0000000000..39e46ba0ae
@@ -0,0 +1,3 @@
+dsdt_generated.aml
+dsdt_generated.asl.tmp
+dsdt_generated.c
board/raspberrypi/rpi/Makefile +2 -0
index b1186cdf10..bb1b7cc630 100644
@@ -4,3 +4,5 @@
 
 obj-y	:= rpi.o
 obj-y	+= lowlevel_init.o
+
+obj-$(CONFIG_GENERATE_ACPI_TABLE) += dsdt_generated.o
board/raspberrypi/rpi/acpitables.h new file +90 -0

90 lines not on this page · raw message

board/raspberrypi/rpi/dsdt.asl new file +290 -0

290 lines not on this page · raw message

board/raspberrypi/rpi/emmc.asl new file +136 -0

136 lines not on this page · raw message

board/raspberrypi/rpi/gpudevs.asl new file +372 -0

373 lines not on this page · raw message

board/raspberrypi/rpi/pci.asl new file +177 -0

178 lines not on this page · raw message

board/raspberrypi/rpi/pep.asl new file +90 -0

90 lines not on this page · raw message

board/raspberrypi/rpi/rhpx.asl new file +195 -0

195 lines not on this page · raw message

board/raspberrypi/rpi/rpi.c +183 -0

192 lines not on this page · raw message

board/raspberrypi/rpi/sdhc.asl new file +111 -0

112 lines not on this page · raw message

board/raspberrypi/rpi/uart.asl new file +208 -0

208 lines not on this page · raw message

Signature · 1 line
2.46.0
#67 lore raw

PATCH v4 30/35 arm: cpu: Add ACPI parking protocol support

In reply to Patrick Rudolph

On Arm platforms that use ACPI they cannot rely on the "spin-table" CPU bringup usually defined in the FDT. Thus implement the 'ACPI Multi-processor Startup for ARM Platforms', also referred to as 'ACPI parking protocol'.

The ACPI parking protocol works similar to the spin-table mechanism, but the specification also covers lots of shortcomings of the spin-table implementations.

Every CPU defined in the ACPI MADT table has it's own 4K page where the spinloop code and the OS mailbox resides. When selected the U-Boot board code must make sure that the secondary CPUs enter u-boot after relocation as well, so that they can enter the spinloop code residing in the ACPI parking protocol pages.

The OS will then write to the mailbox and generate an IPI to release the CPUs from the spinloop code.

For now it's only implemented on ARMv8, but can easily be extended to other platforms, like ARMv7.

TEST: Boots all CPUs on qemu-system-aarch64 -machine raspi4b

---
Changelog v2:
- Use shorter function names
- Drop the use of atomics, they do not work on real hardware
- Rewrite code and verify on real hardware that CPUs are spinning inside their parking protocol spin-loop code
Changelog v4:
- Shorten names
- Fix coding style
- Drop extern from the headers

---
 arch/arm/cpu/armv8/Makefile       |   1 +
 arch/arm/cpu/armv8/acpi_park_v8.S | 113 ++++++++++++++++++++++
 arch/arm/include/asm/acpi_table.h |  32 +++++++
 arch/arm/lib/acpi_table.c         | 149 ++++++++++++++++++++++++++++++
 include/acpi/acpi_table.h         |  10 ++
 include/bloblist.h                |   1 +
 lib/Kconfig                       |  16 ++++
 lib/acpi/acpi_table.c             |   4 +
 8 files changed, 326 insertions(+)
 create mode 100644 arch/arm/cpu/armv8/acpi_park_v8.S
arch/arm/cpu/armv8/Makefile +1 -0
index bba4f570db..4f4368ff8c 100644
@@ -29,6 +29,7 @@ obj-$(CONFIG_ARM_SMCCC)		+= smccc-call.o
 
 ifndef CONFIG_SPL_BUILD
 obj-$(CONFIG_ARMV8_SPIN_TABLE) += spin_table.o spin_table_v8.o
+obj-$(CONFIG_ACPI_PARKING_PROTOCOL) += acpi_park_v8.o
 else
 obj-$(CONFIG_ARCH_SUNXI) += fel_utils.o
 endif
arch/arm/cpu/armv8/acpi_park_v8.S new file +113 -0

113 lines not on this page · raw message

arch/arm/include/asm/acpi_table.h +32 -0
index c65eabe837..7386f55ad3 100644
@@ -4,6 +4,7 @@
 #define __ASM_ACPI_TABLE_H__
 
 #ifndef __ACPI__
+#ifndef __ASSEMBLY__
 
 #include <acpi/acpi_table.h>
 
@@ -109,7 +110,38 @@ int acpi_pptt_add_cache(struct acpi_ctx *ctx, const u32 flags,
 			const u32 sets, const u8 assoc, const u8 attributes,
 			const u16 line_size);
 
+/* Multi-processor Startup for ARM Platforms */
+/**
+ * struct acpi_pp_page - MP startup handshake mailbox
+ *
+ * Defines a 4096 byte memory region that is used for starting secondary CPUs on
+ * an Arm system that follows the "Multi-processor Startup for ARM Platforms" spec.
+ *
+ * @cpu_id:           MPIDR as returned by the Multiprocessor Affinity Register.
+ *                    On 32bit Arm systems the upper bits are unused.
+ * @jumping_address:  On 32bit Arm systems the address must be below 4 GiB
+ * @os_reserved:      Reserved for OS use. Firmware must not access this memory.
+ * @spinning_code:    Reserved for firmware use. OS must not access this memory.
+ *                    The spinning code will be installed by firmware and the secondary
+ *                    CPUs will enter it before the control is handed over to the OS.
+ */
+struct acpi_pp_page {
+	u64 cpu_id;
+	u64 jumping_address;
+	u8 os_reserved[2032];
+	u8 spinning_code[2048];
+} __packed;
+
 #endif /* !__ASSEMBLY__ */
 #endif /* !__ACPI__ */
 
+/* Multi-processor Startup for ARM Platforms defines */
+#define ACPI_PP_CPU_ID_INVALID		0xffffffff
+#define ACPI_PP_JMP_ADR_INVALID		0
+#define ACPI_PP_PAGE_SIZE		4096
+#define ACPI_PP_CPU_ID_OFFSET		0
+#define ACPI_PP_CPU_JMP_OFFSET		8
+#define ACPI_PP_CPU_CODE_OFFSET		2048
+#define ACPI_PP_VERSION			1
+
 #endif /* __ASM_ACPI_TABLE_H__ */
arch/arm/lib/acpi_table.c +149 -0

161 lines not on this page · raw message

include/acpi/acpi_table.h +10 -0
index 07c5f65d75..b8b1f1338c 100644
@@ -1237,6 +1237,16 @@ int acpi_iort_add_smmu_v3(struct acpi_ctx *ctx,
  */
 void *acpi_fill_madt(struct acpi_madt *madt, struct acpi_ctx *ctx);
 
+/**
+ * acpi_write_park() - Installs the ACPI parking protocol.
+ *
+ * Sets up the ACPI parking protocol and installs the spinning code for
+ * secondary CPUs.
+ *
+ * @madt: The MADT to update
+ */
+void acpi_write_park(struct acpi_madt *madt);
+
 /**
  * acpi_get_rsdp_addr() - get ACPI RSDP table address
  *
include/bloblist.h +1 -0
index b0706b5637..ff32d3fecf 100644
@@ -110,6 +110,7 @@ enum bloblist_tag_t {
 	BLOBLISTT_ACPI_TABLES = 4,
 	BLOBLISTT_TPM_EVLOG = 5,
 	BLOBLISTT_TPM_CRB_BASE = 6,
+	BLOBLISTT_ACPI_PP = 7,
 
 	/* Standard area to allocate blobs used across firmware components */
 	BLOBLISTT_AREA_FIRMWARE = 0x10,
lib/Kconfig +16 -0
index ea444354eb..f4d587136c 100644
@@ -314,6 +314,22 @@ config GENERATE_ACPI_TABLE
 	  by the operating system. It defines platform-independent interfaces
 	  for configuration and power management monitoring.
 
+config ACPI_PARKING_PROTOCOL
+	bool "Support ACPI parking protocol method"
+	depends on GENERATE_ACPI_TABLE
+	depends on ARMV8_MULTIENTRY
+	depends on BLOBLIST_TABLES
+	default y if !SEC_FIRMWARE_ARMV8_PSCI && !ARMV8_PSCI
+	help
+	  Say Y here to support "ACPI parking protocol" enable method
+	  for booting Linux.
+
+	  To use this feature, you must do:
+	    - Bring secondary CPUs into U-Boot proper in a board-specific
+	      manner.  This must be done *after* relocation.  Otherwise, the
+	      secondary CPUs will spin in unprotected memory-area because the
+	      master CPU protects the relocated spin code.
+
 config SPL_TINY_MEMSET
 	bool "Use a very small memset() in SPL"
 	depends on SPL
lib/acpi/acpi_table.c +4 -0
index d6357bdc4d..3a1b18f93b 100644
@@ -286,6 +286,10 @@ int acpi_write_madt(struct acpi_ctx *ctx, const struct acpi_writer *entry)
 
 	/* (Re)calculate length and checksum */
 	header->length = (uintptr_t)current - (uintptr_t)madt;
+
+	if (IS_ENABLED(CONFIG_ACPI_PARKING_PROTOCOL))
+		acpi_write_park(madt);
+
 	header->checksum = table_compute_checksum((void *)madt, header->length);
 	acpi_add_table(ctx, madt);
 	ctx->current = (void *)madt + madt->header.length;
Signature · 1 line
2.46.0
#68 lore raw

Re: [PATCH v4 30/35] arm: cpu: Add ACPI parking protocol support

Quoted 46 lines · Patrick Rudolph

On Arm platforms that use ACPI they cannot rely on the "spin-table" CPU bringup usually defined in the FDT. Thus implement the 'ACPI Multi-processor Startup for ARM Platforms', also referred to as 'ACPI parking protocol'.

The ACPI parking protocol works similar to the spin-table mechanism, but the specification also covers lots of shortcomings of the spin-table implementations.

Every CPU defined in the ACPI MADT table has it's own 4K page where the spinloop code and the OS mailbox resides. When selected the U-Boot board code must make sure that the secondary CPUs enter u-boot after relocation as well, so that they can enter the spinloop code residing in the ACPI parking protocol pages.

The OS will then write to the mailbox and generate an IPI to release the CPUs from the spinloop code.

For now it's only implemented on ARMv8, but can easily be extended to other platforms, like ARMv7.

TEST: Boots all CPUs on qemu-system-aarch64 -machine raspi4b

---
Changelog v2:
- Use shorter function names
- Drop the use of atomics, they do not work on real hardware
- Rewrite code and verify on real hardware that CPUs are spinning inside their parking protocol spin-loop code
Changelog v4:
- Shorten names
- Fix coding style
- Drop extern from the headers

---
 arch/arm/cpu/armv8/Makefile       |   1 +
 arch/arm/cpu/armv8/acpi_park_v8.S | 113 ++++++++++++++++++++++
 arch/arm/include/asm/acpi_table.h |  32 +++++++
 arch/arm/lib/acpi_table.c         | 149 ++++++++++++++++++++++++++++++
 include/acpi/acpi_table.h         |  10 ++
 include/bloblist.h                |   1 +
 lib/Kconfig                       |  16 ++++
 lib/acpi/acpi_table.c             |   4 +
#69 lore raw

Re: [PATCH v4 30/35] arm: cpu: Add ACPI parking protocol support

Hi Simon,

Quoted 41 lines · Simon Glass
Quoted 38 lines · Patrick Rudolph

On Arm platforms that use ACPI they cannot rely on the "spin-table" CPU bringup usually defined in the FDT. Thus implement the 'ACPI Multi-processor Startup for ARM Platforms', also referred to as 'ACPI parking protocol'.

The ACPI parking protocol works similar to the spin-table mechanism, but the specification also covers lots of shortcomings of the spin-table implementations.

Every CPU defined in the ACPI MADT table has it's own 4K page where the spinloop code and the OS mailbox resides. When selected the U-Boot board code must make sure that the secondary CPUs enter u-boot after relocation as well, so that they can enter the spinloop code residing in the ACPI parking protocol pages.

The OS will then write to the mailbox and generate an IPI to release the CPUs from the spinloop code.

For now it's only implemented on ARMv8, but can easily be extended to other platforms, like ARMv7.

TEST: Boots all CPUs on qemu-system-aarch64 -machine raspi4b

---
Changelog v2:
- Use shorter function names
- Drop the use of atomics, they do not work on real hardware
- Rewrite code and verify on real hardware that CPUs are spinning inside their parking protocol spin-loop code
Changelog v4:
- Shorten names
- Fix coding style
- Drop extern from the headers
---

Quoted 8 lines
Quoted 8 lines
 arch/arm/cpu/armv8/Makefile       |   1 +
 arch/arm/cpu/armv8/acpi_park_v8.S | 113 ++++++++++++++++++++++
 arch/arm/include/asm/acpi_table.h |  32 +++++++
 arch/arm/lib/acpi_table.c         | 149 ++++++++++++++++++++++++++++++
 include/acpi/acpi_table.h         |  10 ++
 include/bloblist.h                |   1 +
 lib/Kconfig                       |  16 ++++
 lib/acpi/acpi_table.c             |   4 +

There's something missing here...
Is it reviewed by you?

#70 lore raw

PATCH v4 31/35 armv8: cpu: Enable ACPI parking protocol

In reply to Patrick Rudolph

Update the generic entry point code to support the ACPI parking protocol. The ACPI parking protocol can be used when PSCI is not available to bring up secondary CPU cores.

When enabled secondary CPUs will enter U-Boot proper and spin in their own 4KiB reserved memory page, which also acts as mailbox with the OS to release the CPU.

TEST: Boots all CPUs on qemu-system-aarch64 -machine raspi4b

---
 arch/arm/cpu/armv8/start.S | 12 ++++++++++++
 1 file changed, 12 insertions(+)
arch/arm/cpu/armv8/start.S +12 -0
index 7461280261..544a4a5364 100644
@@ -178,6 +178,18 @@ pie_fixup_done:
 	branch_if_master x0, master_cpu
 	b	spin_table_secondary_jump
 	/* never return */
+#elif defined(CONFIG_ACPI_PARKING_PROTOCOL) && !defined(CONFIG_SPL_BUILD)
+	branch_if_master x0, master_cpu
+	/*
+	 * Waits for ACPI parking protocol memory to be allocated and the spin-table
+	 * code to be written. Once ready the secondary CPUs will jump and spin in
+	 * their own 4KiB memory region, which is also used as mailbox, until released
+	 * by the OS.
+	 * The mechanism is similar to the DT enable-method = "spin-table", but works
+	 * with ACPI enabled platforms.
+	 */
+	b	acpi_pp_secondary_jump
+	/* never return */
 #elif defined(CONFIG_ARMV8_MULTIENTRY)
 	branch_if_master x0, master_cpu
 
Signature · 1 line
2.46.0
Reviewed-by on v4 31/35
#71 lore raw

Re: [PATCH v4 31/35] armv8: cpu: Enable ACPI parking protocol

Quoted 9 lines · Patrick Rudolph

Update the generic entry point code to support the ACPI parking protocol. The ACPI parking protocol can be used when PSCI is not available to bring up secondary CPU cores.

When enabled secondary CPUs will enter U-Boot proper and spin in their own 4KiB reserved memory page, which also acts as mailbox with the OS to release the CPU.

Quoted 7 lines

TEST: Boots all CPUs on qemu-system-aarch64 -machine raspi4b

---
 arch/arm/cpu/armv8/start.S | 12 ++++++++++++
 1 file changed, 12 insertions(+)
Quoted 26 lines
arch/arm/cpu/armv8/start.S +12 -1
index 7461280261..544a4a5364 100644
@@ -178,6 +178,18 @@ pie_fixup_done:
        branch_if_master x0, master_cpu
        b       spin_table_secondary_jump
        /* never return */
+#elif defined(CONFIG_ACPI_PARKING_PROTOCOL) && !defined(CONFIG_SPL_BUILD)
+       branch_if_master x0, master_cpu
+       /*
+        * Waits for ACPI parking protocol memory to be allocated and the spin-table
+        * code to be written. Once ready the secondary CPUs will jump and spin in
+        * their own 4KiB memory region, which is also used as mailbox, until released
+        * by the OS.
+        * The mechanism is similar to the DT enable-method = "spin-table", but works
+        * with ACPI enabled platforms.
+        */
+       b       acpi_pp_secondary_jump
+       /* never return */
 #elif defined(CONFIG_ARMV8_MULTIENTRY)
        branch_if_master x0, master_cpu
 
--

2.46.0

#72 lore raw

PATCH v4 32/35 arm: mach-bcm283x: Add ARMV8_MULTIENTRY support

In reply to Patrick Rudolph

When ACPI is enabled over FDT the APs cannot be brought out of reset by the OS using the "FDT spin-table" mechanism, as no FDT is provided to the OS. The APs must be released out of reset in u-boot and then brought up in an ACPI compliant fashion.

When ARMV8_MULTIENTRY is specified, the APs are released from reset and will enter U-Boot after it has been relocated as well.

By default ARMV8_MULTIENTRY is not selected, keeping existing behaviour.

TEST: All APs enter U-Boot when run on qemu-system-aarch64 and on
real hardware.

Cc Matthias Brugger <[email protected]>
Cc Peter Robinson <[email protected]>
Cc Tom Rini <[email protected]>

---
Changelog v2:
- Drop CPU code from board
- Add CPU driver to release APs from reset
Changelog v4:
- Use the generic armv8 CPU driver
- Probe all CPUs
- Release secondary CPUs in the probe function
- Use of_to_plat() to parse DT
- Drop udelay()
- Select the GICv2 driver

---
 arch/arm/Kconfig              |   1 +
 arch/arm/mach-bcm283x/Kconfig |   7 +-
 arch/arm/mach-bcm283x/init.c  |  10 ++
 drivers/cpu/Makefile          |   2 +-
 drivers/cpu/bcm283x_cpu.c     | 218 ++++++++++++++++++++++++++++++++++
 5 files changed, 236 insertions(+), 2 deletions(-)
 create mode 100644 drivers/cpu/bcm283x_cpu.c
arch/arm/Kconfig +1 -0
index e85a7131d3..72702cd99c 100644
@@ -651,6 +651,7 @@ config ARCH_ORION5X
 
 config ARCH_BCM283X
 	bool "Broadcom BCM283X family"
+	select CPU
 	select DM
 	select DM_GPIO
 	select DM_SERIAL
arch/arm/mach-bcm283x/Kconfig +6 -1
index b3287ce8bc..fad900d965 100644
@@ -12,6 +12,7 @@ config BCM2836
 config BCM2837
 	bool "Broadcom BCM2837 SoC support"
 	depends on ARCH_BCM283X
+	select ARCH_EARLY_INIT_R
 
 config BCM2837_32B
 	bool "Broadcom BCM2837 SoC 32-bit support"
@@ -24,11 +25,14 @@ config BCM2837_64B
 	bool "Broadcom BCM2837 SoC 64-bit support"
 	depends on ARCH_BCM283X
 	select BCM2837
+	select DRIVER_GICV2
 	select ARM64
+	select CPU_ARMV8
 
 config BCM2711
 	bool "Broadcom BCM2711 SoC support"
 	depends on ARCH_BCM283X
+	select ARCH_EARLY_INIT_R
 
 config BCM2711_32B
 	bool "Broadcom BCM2711 SoC 32-bit support"
@@ -42,11 +46,12 @@ config BCM2711_64B
 	bool "Broadcom BCM2711 SoC 64-bit support"
 	depends on ARCH_BCM283X
 	select BCM2711
+	select DRIVER_GICV2
 	select ARM64
+	select CPU_ARMV8
 
 menu "Broadcom BCM283X family"
 	depends on ARCH_BCM283X
-
 choice
 	prompt "Broadcom BCM283X board select"
 	optional
arch/arm/mach-bcm283x/init.c +10 -0
index 7a1de22e0a..c59e557432 100644
@@ -9,6 +9,7 @@
 #include <cpu_func.h>
 #include <init.h>
 #include <dm/device.h>
+#include <dm/uclass.h>
 #include <fdt_support.h>
 #include <asm/global_data.h>
 
@@ -199,6 +200,15 @@ int mach_cpu_init(void)
 					       "brcm,bcm2712-pm");
 	if (offset > soc)
 		rpi_wdog_base = fdt_get_base_address(gd->fdt_blob, offset);
+	return 0;
+}
+
+int arch_early_init_r(void)
+{
+	/* The older RPis do not have a CPU driver yet,
+	 * thus do not check for errors here...
+	 */
+	uclass_probe_all(UCLASS_CPU);
 
 	return 0;
 }
drivers/cpu/Makefile +1 -1
index 773395693a..eaf494706e 100644
@@ -6,7 +6,7 @@
 
 obj-$(CONFIG_CPU) += cpu-uclass.o
 
-
+obj-$(CONFIG_ARCH_BCM283X) += bcm283x_cpu.o
 obj-$(CONFIG_ARCH_BMIPS) += bmips_cpu.o
 obj-$(CONFIG_ARCH_IMX8) += imx8_cpu.o
 obj-$(CONFIG_ARCH_AT91) += at91_cpu.o
drivers/cpu/bcm283x_cpu.c new file +218 -0

218 lines not on this page · raw message

Signature · 1 line
2.46.0
Reviewed-by on v4 32/35
#73 lore raw

Re: [PATCH v4 32/35] arm: mach-bcm283x: Add ARMV8_MULTIENTRY support

Hi Patrick,

Quoted 29 lines · Patrick Rudolph

When ACPI is enabled over FDT the APs cannot be brought out of reset by the OS using the "FDT spin-table" mechanism, as no FDT is provided to the OS. The APs must be released out of reset in u-boot and then brought up in an ACPI compliant fashion.

When ARMV8_MULTIENTRY is specified, the APs are released from reset and will enter U-Boot after it has been relocated as well.

By default ARMV8_MULTIENTRY is not selected, keeping existing behaviour.

TEST: All APs enter U-Boot when run on qemu-system-aarch64 and on
real hardware.

Cc Matthias Brugger <[email protected]>
Cc Peter Robinson <[email protected]>
Cc Tom Rini <[email protected]>

---
Changelog v2:
- Drop CPU code from board
- Add CPU driver to release APs from reset
Changelog v4:
- Use the generic armv8 CPU driver
- Probe all CPUs
- Release secondary CPUs in the probe function
- Use of_to_plat() to parse DT
- Drop udelay()
- Select the GICv2 driver

Quoted 8 lines
---
 arch/arm/Kconfig              |   1 +
 arch/arm/mach-bcm283x/Kconfig |   7 +-
 arch/arm/mach-bcm283x/init.c  |  10 ++
 drivers/cpu/Makefile          |   2 +-
 drivers/cpu/bcm283x_cpu.c     | 218 ++++++++++++++++++++++++++++++++++
 5 files changed, 236 insertions(+), 2 deletions(-)
 create mode 100644 drivers/cpu/bcm283x_cpu.c

With nits below

Quoted 59 lines
arch/arm/Kconfig +1 -0
index e85a7131d3..72702cd99c 100644
@@ -651,6 +651,7 @@ config ARCH_ORION5X
 
 config ARCH_BCM283X
        bool "Broadcom BCM283X family"
+       select CPU
        select DM
        select DM_GPIO
        select DM_SERIAL
arch/arm/mach-bcm283x/Kconfig +6 -1
index b3287ce8bc..fad900d965 100644
@@ -12,6 +12,7 @@ config BCM2836
 config BCM2837
        bool "Broadcom BCM2837 SoC support"
        depends on ARCH_BCM283X
+       select ARCH_EARLY_INIT_R
 
 config BCM2837_32B
        bool "Broadcom BCM2837 SoC 32-bit support"
@@ -24,11 +25,14 @@ config BCM2837_64B
        bool "Broadcom BCM2837 SoC 64-bit support"
        depends on ARCH_BCM283X
        select BCM2837
+       select DRIVER_GICV2
        select ARM64
+       select CPU_ARMV8
 
 config BCM2711
        bool "Broadcom BCM2711 SoC support"
        depends on ARCH_BCM283X
+       select ARCH_EARLY_INIT_R
 
 config BCM2711_32B
        bool "Broadcom BCM2711 SoC 32-bit support"
@@ -42,11 +46,12 @@ config BCM2711_64B
        bool "Broadcom BCM2711 SoC 64-bit support"
        depends on ARCH_BCM283X
        select BCM2711
+       select DRIVER_GICV2
        select ARM64
+       select CPU_ARMV8
 
 menu "Broadcom BCM283X family"
        depends on ARCH_BCM283X
-
 choice
        prompt "Broadcom BCM283X board select"
        optional
arch/arm/mach-bcm283x/init.c +0 -0
index 7a1de22e0a..c59e557432 100644

arch/arm/mach-bcm283x/init.c line 14

Quoted 6 lines
arch/arm/mach-bcm283x/init.c +1 -0
@@ -9,6 +9,7 @@
 #include <cpu_func.h>
 #include <init.h>
 #include <dm/device.h>
+#include <dm/uclass.h>
 #include <fdt_support.h>
 #include <asm/global_data.h>

All patches need to check header order, as noted before.

arch/arm/mach-bcm283x/init.c int mach_cpu_init(void) · line 208

Quoted 11 lines
arch/arm/mach-bcm283x/init.c +6 -0
@@ -199,6 +200,15 @@ int mach_cpu_init(void)
                                               "brcm,bcm2712-pm");
        if (offset > soc)
                rpi_wdog_base = fdt_get_base_address(gd->fdt_blob, offset);
+       return 0;
+}
+
+int arch_early_init_r(void)
+{
+       /* The older RPis do not have a CPU driver yet,\

/*
* The older...

Also please drop \

arch/arm/mach-bcm283x/init.c int mach_cpu_init(void) · line 211

Quoted 3 lines
arch/arm/mach-bcm283x/init.c +3 -0
+        * thus do not check for errors here...
+        */
+       uclass_probe_all(UCLASS_CPU);

So should you check the compatible to know whether to check for errors?

Quoted 86 lines
arch/arm/mach-bcm283x/init.c +0 -0
        return 0;
 }
drivers/cpu/Makefile +1 -1
index 773395693a..eaf494706e 100644
@@ -6,7 +6,7 @@
 
 obj-$(CONFIG_CPU) += cpu-uclass.o
 
-
+obj-$(CONFIG_ARCH_BCM283X) += bcm283x_cpu.o
 obj-$(CONFIG_ARCH_BMIPS) += bmips_cpu.o
 obj-$(CONFIG_ARCH_IMX8) += imx8_cpu.o
 obj-$(CONFIG_ARCH_AT91) += at91_cpu.o
drivers/cpu/bcm283x_cpu.c new file +64 -0
new file mode 100644
index 0000000000..5ed75b3754
@@ -0,0 +1,218 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2024 9elements GmbH
+ */
+
+#include <acpi/acpigen.h>
+#include <asm/cache.h>
+#include <asm/io.h>
+#include <asm/global_data.h>
+#include <asm/system.h>
+#include <asm/armv8/cpu.h>
+#include <asm-generic/sections.h>
+#include <cpu.h>
+#include <cpu_func.h>
+#include <dm.h>
+#include <fdt_support.h>
+#include <linux/bitops.h>
+#include <linux/clk-provider.h>
+#include <linux/delay.h>
+#include "armv8_cpu.h"
+
+DECLARE_GLOBAL_DATA_PTR;
+
+struct bcm_plat {
+       u64 release_addr;
+};
+
+static int cpu_bcm_get_desc(const struct udevice *dev, char *buf, int size)
+{
+       struct cpu_plat *plat = dev_get_parent_plat(dev);
+       const char *name;
+       int ret;
+
+       if (size < 32)
+               return -ENOSPC;
+
+       if (device_is_compatible(dev, "arm,cortex-a53"))
+               name = "A53";
+       else if (device_is_compatible(dev, "arm,cortex-a72"))
+               name = "A72";
+       else
+               name = "?";
+
+       ret = snprintf(buf, size, "Broadcom Cortex-%s at %u MHz\n",
+                      name, plat->timebase_freq);
+
+       return 0;
+}
+
+static int cpu_bcm_get_info(const struct udevice *dev, struct cpu_info *info)
+{
+       struct cpu_plat *plat = dev_get_parent_plat(dev);
+
+       info->cpu_freq = plat->timebase_freq * 1000;
+       info->features = BIT(CPU_FEAT_L1_CACHE) | BIT(CPU_FEAT_MMU);
+
+       return 0;
+}
+
+static int cpu_bcm_get_count(const struct udevice *dev)
+{
+       return uclass_id_count(UCLASS_CPU);
+}
+

drivers/cpu/bcm283x_cpu.c line 74

Quoted 10 lines
drivers/cpu/bcm283x_cpu.c new file +10 -0
+static int cpu_bcm_get_vendor(const struct udevice *dev,  char *buf, int size)
+{
+       snprintf(buf, size, "Broadcom");
+
+       return 0;
+}
+
+static int cpu_bcm_is_current(struct udevice *dev)
+{
+#ifdef CONFIG_ARM64

Can you use if (IS_ENABLED(CONFIG_ARM64)) ?

Quoted 13 lines
drivers/cpu/bcm283x_cpu.c new file +13 -0
+       struct cpu_plat *plat = dev_get_parent_plat(dev);
+
+       if (plat->cpu_id == (read_mpidr() & 0xffff))
+               return 1;
+#endif
+
+       return 0;
+}
+
+/**
+ * bcm_cpu_on - Releases the secondary CPU from it's spintable
+ *
+ * Write the CPU's spintable mailbox and let the CPU enter U-Boot.

drivers/cpu/bcm283x_cpu.c line 97

Quoted 10 lines
drivers/cpu/bcm283x_cpu.c new file +10 -0
+ *
+ * @dev: Device to start
+ * @return: zero on success or error code on failure.
+ */
+static int bcm_cpu_on(struct udevice *dev)
+{
+       struct bcm_plat *plat = dev_get_plat(dev);
+       ulong *start_address;
+
+       if (!plat || plat->release_addr == ~0ULL)

plat cannot be NULL, right?

Quoted 74 lines
drivers/cpu/bcm283x_cpu.c new file +74 -0
+               return -ENODATA;
+
+       start_address = map_physmem(plat->release_addr, sizeof(uintptr_t), MAP_NOCACHE);
+
+       /* Point secondary CPU to U-Boot entry */
+       *start_address = (uintptr_t)_start;
+
+       /* Make sure the other CPUs see the written start address */
+       if (!CONFIG_IS_ENABLED(SYS_DCACHE_OFF))
+               flush_dcache_all();
+
+       /* Send an event to wake up the secondary CPU. */
+       asm("dsb        ishst\n"
+           "sev");
+
+       unmap_physmem(start_address, MAP_NOCACHE);
+
+       return 0;
+}
+
+static const struct cpu_ops cpu_bcm_ops = {
+       .get_desc       = cpu_bcm_get_desc,
+       .get_info       = cpu_bcm_get_info,
+       .get_count      = cpu_bcm_get_count,
+       .get_vendor     = cpu_bcm_get_vendor,
+       .is_current     = cpu_bcm_is_current,
+};
+
+static const struct udevice_id cpu_bcm_ids[] = {
+       { .compatible = "arm,cortex-a53" },     /* RPi 3 */
+       { .compatible = "arm,cortex-a72" },     /* RPi 4 */
+       { }
+};
+
+static int bcm_cpu_bind(struct udevice *dev)
+{
+       struct cpu_plat *plat = dev_get_parent_plat(dev);
+
+       plat->cpu_id = dev_read_addr(dev);
+
+       return 0;
+}
+
+/**
+ * bcm_cpu_of_to_plat - Gather spin-table release address
+ *
+ * Read the spin-table release address to allow all seconary CPUs to enter
+ * U-Boot when necessary.
+ *
+ * @dev: Device to start
+ */
+static int bcm_cpu_of_to_plat(struct udevice *dev)
+{
+       struct bcm_plat *plat = dev_get_plat(dev);
+       const char *prop;
+
+       if (CONFIG_IS_ENABLED(ARMV8_MULTIENTRY)) {
+               plat->release_addr = ~0ULL;
+
+               prop = dev_read_string(dev, "enable-method");
+               if (!prop || strcmp(prop, "spin-table"))
+                       return -ENODEV;
+
+               plat->release_addr = dev_read_u64_default(dev, "cpu-release-addr", ~0ULL);
+
+               if (plat->release_addr == ~0ULL)
+                       return -ENODEV;
+       }
+
+       return 0;
+}
+
+static int bcm_cpu_probe(struct udevice *dev)
+{

drivers/cpu/bcm283x_cpu.c line 181

Quoted 10 lines
drivers/cpu/bcm283x_cpu.c new file +10 -0
+       struct cpu_plat *plat = dev_get_parent_plat(dev);
+       struct clk clk;
+       int ret;
+
+       /* Get a clock if it exists */
+       ret = clk_get_by_index(dev, 0, &clk);
+       if (!ret) {
+               ret = clk_enable(&clk);
+               if (ret && (ret != -ENOSYS || ret != -EOPNOTSUPP))
+                       return ret;

I don't think you need those internal brackets

Quoted 25 lines
drivers/cpu/bcm283x_cpu.c new file +25 -0
+               ret = clk_get_rate(&clk);
+               if (IS_ERR_VALUE(ret))
+                       return ret;
+               plat->timebase_freq = ret;
+       }
+
+       /*
+        * The armstub holds the secondary CPUs in a spinloop. When
+        * ARMV8_MULTIENTRY is enabled release the secondary CPUs and
+        * let them enter U-Boot as well.
+        */
+       if (CONFIG_IS_ENABLED(ARMV8_MULTIENTRY)) {
+               ret = bcm_cpu_on(dev);
+               if (ret)
+                       return ret;
+       }
+
+       return ret;
+}
+
+struct acpi_ops bcm283x_cpu_acpi_ops = {
+       .fill_ssdt      = armv8_cpu_fill_ssdt,
+       .fill_madt      = armv8_cpu_fill_madt,
+};
+

drivers/cpu/bcm283x_cpu.c line 216

Quoted 10 lines
drivers/cpu/bcm283x_cpu.c new file +10 -0
+U_BOOT_DRIVER(cpu_bcm_drv) = {
+       .name           = "bcm283x_cpu",
+       .id             = UCLASS_CPU,
+       .of_match       = cpu_bcm_ids,
+       .ops            = &cpu_bcm_ops,
+       .probe          = bcm_cpu_probe,
+       .bind           = bcm_cpu_bind,
+       .of_to_plat     = bcm_cpu_of_to_plat,
+       .plat_auto      = sizeof(struct bcm_plat),
+       .flags          = 0,

Drop that line, as 0 is the default

Quoted 5 lines
drivers/cpu/bcm283x_cpu.c new file +2 -1
+       ACPI_OPS_PTR(&bcm283x_cpu_acpi_ops)
+};
--

2.46.0

Regards,
Simon

#74 lore raw

Re: [PATCH v4 32/35] arm: mach-bcm283x: Add ARMV8_MULTIENTRY support

Quoted 130 lines · Simon Glass

Hi Patrick,

Quoted 29 lines · Patrick Rudolph

When ACPI is enabled over FDT the APs cannot be brought out of reset by the OS using the "FDT spin-table" mechanism, as no FDT is provided to the OS. The APs must be released out of reset in u-boot and then brought up in an ACPI compliant fashion.

When ARMV8_MULTIENTRY is specified, the APs are released from reset and will enter U-Boot after it has been relocated as well.

By default ARMV8_MULTIENTRY is not selected, keeping existing behaviour.

TEST: All APs enter U-Boot when run on qemu-system-aarch64 and on
real hardware.

Cc Matthias Brugger <[email protected]>
Cc Peter Robinson <[email protected]>
Cc Tom Rini <[email protected]>

---
Changelog v2:
- Drop CPU code from board
- Add CPU driver to release APs from reset
Changelog v4:
- Use the generic armv8 CPU driver
- Probe all CPUs
- Release secondary CPUs in the probe function
- Use of_to_plat() to parse DT
- Drop udelay()
- Select the GICv2 driver

Quoted 8 lines
---
 arch/arm/Kconfig              |   1 +
 arch/arm/mach-bcm283x/Kconfig |   7 +-
 arch/arm/mach-bcm283x/init.c  |  10 ++
 drivers/cpu/Makefile          |   2 +-
 drivers/cpu/bcm283x_cpu.c     | 218 ++++++++++++++++++++++++++++++++++
 5 files changed, 236 insertions(+), 2 deletions(-)
 create mode 100644 drivers/cpu/bcm283x_cpu.c

With nits below

Quoted 59 lines
arch/arm/Kconfig +1 -0
index e85a7131d3..72702cd99c 100644
@@ -651,6 +651,7 @@ config ARCH_ORION5X
 
 config ARCH_BCM283X
        bool "Broadcom BCM283X family"
+       select CPU
        select DM
        select DM_GPIO
        select DM_SERIAL
arch/arm/mach-bcm283x/Kconfig +6 -1
index b3287ce8bc..fad900d965 100644
@@ -12,6 +12,7 @@ config BCM2836
 config BCM2837
        bool "Broadcom BCM2837 SoC support"
        depends on ARCH_BCM283X
+       select ARCH_EARLY_INIT_R
 
 config BCM2837_32B
        bool "Broadcom BCM2837 SoC 32-bit support"
@@ -24,11 +25,14 @@ config BCM2837_64B
        bool "Broadcom BCM2837 SoC 64-bit support"
        depends on ARCH_BCM283X
        select BCM2837
+       select DRIVER_GICV2
        select ARM64
+       select CPU_ARMV8
 
 config BCM2711
        bool "Broadcom BCM2711 SoC support"
        depends on ARCH_BCM283X
+       select ARCH_EARLY_INIT_R
 
 config BCM2711_32B
        bool "Broadcom BCM2711 SoC 32-bit support"
@@ -42,11 +46,12 @@ config BCM2711_64B
        bool "Broadcom BCM2711 SoC 64-bit support"
        depends on ARCH_BCM283X
        select BCM2711
+       select DRIVER_GICV2
        select ARM64
+       select CPU_ARMV8
 
 menu "Broadcom BCM283X family"
        depends on ARCH_BCM283X
-
 choice
        prompt "Broadcom BCM283X board select"
        optional
arch/arm/mach-bcm283x/init.c +0 -0
index 7a1de22e0a..c59e557432 100644

arch/arm/mach-bcm283x/init.c line 14

Quoted 6 lines
arch/arm/mach-bcm283x/init.c +1 -0
@@ -9,6 +9,7 @@
 #include <cpu_func.h>
 #include <init.h>
 #include <dm/device.h>
+#include <dm/uclass.h>
 #include <fdt_support.h>
 #include <asm/global_data.h>

All patches need to check header order, as noted before.

arch/arm/mach-bcm283x/init.c int mach_cpu_init(void) · line 208

Quoted 11 lines
arch/arm/mach-bcm283x/init.c +6 -0
@@ -199,6 +200,15 @@ int mach_cpu_init(void)
                                               "brcm,bcm2712-pm");
        if (offset > soc)
                rpi_wdog_base = fdt_get_base_address(gd->fdt_blob, offset);
+       return 0;
+}
+
+int arch_early_init_r(void)
+{
+       /* The older RPis do not have a CPU driver yet,\

/*
* The older...

Quoted 8 lines

Also please drop \

arch/arm/mach-bcm283x/init.c int mach_cpu_init(void) · line 211

Quoted 3 lines
arch/arm/mach-bcm283x/init.c +3 -0
+        * thus do not check for errors here...
+        */
+       uclass_probe_all(UCLASS_CPU);

So should you check the compatible to know whether to check for errors?

It might be possible to drop arch_early_init_r here as it's also called in acpi_fill_madt().
acpi_fill_madt() is within U-Boot relocated, so should work fine.

Quoted 90 lines
Quoted 90 lines
arch/arm/mach-bcm283x/init.c +0 -0
        return 0;
 }
drivers/cpu/Makefile +1 -1
index 773395693a..eaf494706e 100644
@@ -6,7 +6,7 @@
 
 obj-$(CONFIG_CPU) += cpu-uclass.o
 
-
+obj-$(CONFIG_ARCH_BCM283X) += bcm283x_cpu.o
 obj-$(CONFIG_ARCH_BMIPS) += bmips_cpu.o
 obj-$(CONFIG_ARCH_IMX8) += imx8_cpu.o
 obj-$(CONFIG_ARCH_AT91) += at91_cpu.o
drivers/cpu/bcm283x_cpu.c new file +68 -0
new file mode 100644
index 0000000000..5ed75b3754
@@ -0,0 +1,218 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2024 9elements GmbH
+ */
+
+#include <acpi/acpigen.h>
+#include <asm/cache.h>
+#include <asm/io.h>
+#include <asm/global_data.h>
+#include <asm/system.h>
+#include <asm/armv8/cpu.h>
+#include <asm-generic/sections.h>
+#include <cpu.h>
+#include <cpu_func.h>
+#include <dm.h>
+#include <fdt_support.h>
+#include <linux/bitops.h>
+#include <linux/clk-provider.h>
+#include <linux/delay.h>
+#include "armv8_cpu.h"
+
+DECLARE_GLOBAL_DATA_PTR;
+
+struct bcm_plat {
+       u64 release_addr;
+};
+
+static int cpu_bcm_get_desc(const struct udevice *dev, char *buf, int size)
+{
+       struct cpu_plat *plat = dev_get_parent_plat(dev);
+       const char *name;
+       int ret;
+
+       if (size < 32)
+               return -ENOSPC;
+
+       if (device_is_compatible(dev, "arm,cortex-a53"))
+               name = "A53";
+       else if (device_is_compatible(dev, "arm,cortex-a72"))
+               name = "A72";
+       else
+               name = "?";
+
+       ret = snprintf(buf, size, "Broadcom Cortex-%s at %u MHz\n",
+                      name, plat->timebase_freq);
+
+       return 0;
+}
+
+static int cpu_bcm_get_info(const struct udevice *dev, struct cpu_info *info)
+{
+       struct cpu_plat *plat = dev_get_parent_plat(dev);
+
+       info->cpu_freq = plat->timebase_freq * 1000;
+       info->features = BIT(CPU_FEAT_L1_CACHE) | BIT(CPU_FEAT_MMU);
+
+       return 0;
+}
+
+static int cpu_bcm_get_count(const struct udevice *dev)
+{
+       return uclass_id_count(UCLASS_CPU);
+}
+
+static int cpu_bcm_get_vendor(const struct udevice *dev,  char *buf, int size)
+{
+       snprintf(buf, size, "Broadcom");
+
Quoted 8 lines

drivers/cpu/bcm283x_cpu.c line 74

Quoted 6 lines
drivers/cpu/bcm283x_cpu.c new file +6 -0
+       return 0;
+}
+
+static int cpu_bcm_is_current(struct udevice *dev)
+{
+#ifdef CONFIG_ARM64

Can you use if (IS_ENABLED(CONFIG_ARM64)) ?

No, since read_mpidr() has no function prototype when !IS_ENABLED(CONFIG_ARM64). Though when added to the header file, the preprocessor could be dropped here.

Quoted 160 lines
Quoted 14 lines
drivers/cpu/bcm283x_cpu.c new file +13 -0
+       struct cpu_plat *plat = dev_get_parent_plat(dev);
+
+       if (plat->cpu_id == (read_mpidr() & 0xffff))
+               return 1;
+#endif
+
+       return 0;
+}
+
+/**
+ * bcm_cpu_on - Releases the secondary CPU from it's spintable
+ *
+ * Write the CPU's spintable mailbox and let the CPU enter U-Boot.

drivers/cpu/bcm283x_cpu.c line 97

Quoted 10 lines
drivers/cpu/bcm283x_cpu.c new file +10 -0
+ *
+ * @dev: Device to start
+ * @return: zero on success or error code on failure.
+ */
+static int bcm_cpu_on(struct udevice *dev)
+{
+       struct bcm_plat *plat = dev_get_plat(dev);
+       ulong *start_address;
+
+       if (!plat || plat->release_addr == ~0ULL)

plat cannot be NULL, right?

Quoted 74 lines
drivers/cpu/bcm283x_cpu.c new file +74 -0
+               return -ENODATA;
+
+       start_address = map_physmem(plat->release_addr, sizeof(uintptr_t), MAP_NOCACHE);
+
+       /* Point secondary CPU to U-Boot entry */
+       *start_address = (uintptr_t)_start;
+
+       /* Make sure the other CPUs see the written start address */
+       if (!CONFIG_IS_ENABLED(SYS_DCACHE_OFF))
+               flush_dcache_all();
+
+       /* Send an event to wake up the secondary CPU. */
+       asm("dsb        ishst\n"
+           "sev");
+
+       unmap_physmem(start_address, MAP_NOCACHE);
+
+       return 0;
+}
+
+static const struct cpu_ops cpu_bcm_ops = {
+       .get_desc       = cpu_bcm_get_desc,
+       .get_info       = cpu_bcm_get_info,
+       .get_count      = cpu_bcm_get_count,
+       .get_vendor     = cpu_bcm_get_vendor,
+       .is_current     = cpu_bcm_is_current,
+};
+
+static const struct udevice_id cpu_bcm_ids[] = {
+       { .compatible = "arm,cortex-a53" },     /* RPi 3 */
+       { .compatible = "arm,cortex-a72" },     /* RPi 4 */
+       { }
+};
+
+static int bcm_cpu_bind(struct udevice *dev)
+{
+       struct cpu_plat *plat = dev_get_parent_plat(dev);
+
+       plat->cpu_id = dev_read_addr(dev);
+
+       return 0;
+}
+
+/**
+ * bcm_cpu_of_to_plat - Gather spin-table release address
+ *
+ * Read the spin-table release address to allow all seconary CPUs to enter
+ * U-Boot when necessary.
+ *
+ * @dev: Device to start
+ */
+static int bcm_cpu_of_to_plat(struct udevice *dev)
+{
+       struct bcm_plat *plat = dev_get_plat(dev);
+       const char *prop;
+
+       if (CONFIG_IS_ENABLED(ARMV8_MULTIENTRY)) {
+               plat->release_addr = ~0ULL;
+
+               prop = dev_read_string(dev, "enable-method");
+               if (!prop || strcmp(prop, "spin-table"))
+                       return -ENODEV;
+
+               plat->release_addr = dev_read_u64_default(dev, "cpu-release-addr", ~0ULL);
+
+               if (plat->release_addr == ~0ULL)
+                       return -ENODEV;
+       }
+
+       return 0;
+}
+
+static int bcm_cpu_probe(struct udevice *dev)
+{

drivers/cpu/bcm283x_cpu.c line 181

Quoted 10 lines
drivers/cpu/bcm283x_cpu.c new file +10 -0
+       struct cpu_plat *plat = dev_get_parent_plat(dev);
+       struct clk clk;
+       int ret;
+
+       /* Get a clock if it exists */
+       ret = clk_get_by_index(dev, 0, &clk);
+       if (!ret) {
+               ret = clk_enable(&clk);
+               if (ret && (ret != -ENOSYS || ret != -EOPNOTSUPP))
+                       return ret;

I don't think you need those internal brackets

Quoted 25 lines
drivers/cpu/bcm283x_cpu.c new file +25 -0
+               ret = clk_get_rate(&clk);
+               if (IS_ERR_VALUE(ret))
+                       return ret;
+               plat->timebase_freq = ret;
+       }
+
+       /*
+        * The armstub holds the secondary CPUs in a spinloop. When
+        * ARMV8_MULTIENTRY is enabled release the secondary CPUs and
+        * let them enter U-Boot as well.
+        */
+       if (CONFIG_IS_ENABLED(ARMV8_MULTIENTRY)) {
+               ret = bcm_cpu_on(dev);
+               if (ret)
+                       return ret;
+       }
+
+       return ret;
+}
+
+struct acpi_ops bcm283x_cpu_acpi_ops = {
+       .fill_ssdt      = armv8_cpu_fill_ssdt,
+       .fill_madt      = armv8_cpu_fill_madt,
+};
+

drivers/cpu/bcm283x_cpu.c line 216

Quoted 10 lines
drivers/cpu/bcm283x_cpu.c new file +10 -0
+U_BOOT_DRIVER(cpu_bcm_drv) = {
+       .name           = "bcm283x_cpu",
+       .id             = UCLASS_CPU,
+       .of_match       = cpu_bcm_ids,
+       .ops            = &cpu_bcm_ops,
+       .probe          = bcm_cpu_probe,
+       .bind           = bcm_cpu_bind,
+       .of_to_plat     = bcm_cpu_of_to_plat,
+       .plat_auto      = sizeof(struct bcm_plat),
+       .flags          = 0,

Drop that line, as 0 is the default

Quoted 5 lines
drivers/cpu/bcm283x_cpu.c new file +2 -1
+       ACPI_OPS_PTR(&bcm283x_cpu_acpi_ops)
+};
--

2.46.0

Regards,
Simon

#75 lore raw

PATCH v4 33/35 arm: mach-bcm283x: Enable ARMV8_MULTIENTRY

In reply to Patrick Rudolph

On FDT platforms the APs are brought out of reset using the spin-table as defined in the DT. On ACPI enabled platforms there's no FDT, thus enable the ARMV8_MULTIENTRY and BLOBLIST to use the ACPI parking protocol instead.

TEST: - APs enter Linux when run on qemu-system-aarch64 -machine raspi4b
- APs on real hardware do not enter Linux, but continue spinning in
their ACPI parking protocol spinloop. To be investigated.

Cc Matthias Brugger <[email protected]>
Cc Peter Robinson <[email protected]>
Cc Tom Rini <[email protected]>
---
 arch/arm/mach-bcm283x/Kconfig | 11 +++++++++++
 1 file changed, 11 insertions(+)
arch/arm/mach-bcm283x/Kconfig +11 -0
index fad900d965..b7f337ef49 100644
@@ -28,6 +28,10 @@ config BCM2837_64B
 	select DRIVER_GICV2
 	select ARM64
 	select CPU_ARMV8
+	select ARMV8_MULTIENTRY if GENERATE_ACPI_TABLE
+	select BLOBLIST if GENERATE_ACPI_TABLE
+	select BLOBLIST_ALLOC if GENERATE_ACPI_TABLE
+	select BLOBLIST_TABLES if GENERATE_ACPI_TABLE
 
 config BCM2711
 	bool "Broadcom BCM2711 SoC support"
@@ -49,6 +53,10 @@ config BCM2711_64B
 	select DRIVER_GICV2
 	select ARM64
 	select CPU_ARMV8
+	select ARMV8_MULTIENTRY if GENERATE_ACPI_TABLE
+	select BLOBLIST if GENERATE_ACPI_TABLE
+	select BLOBLIST_ALLOC if GENERATE_ACPI_TABLE
+	select BLOBLIST_TABLES if GENERATE_ACPI_TABLE
 
 menu "Broadcom BCM283X family"
 	depends on ARCH_BCM283X
@@ -215,6 +223,9 @@ config SYS_SOC
 config SYS_CONFIG_NAME
 	default "rpi"
 
+config BLOBLIST_SIZE_RELOC
+	default 0x20000
+
 source "board/raspberrypi/rpi/Kconfig"
 
 endmenu
Signature · 1 line
2.46.0
#76 lore raw

PATCH v4 34/35 bloblist: Fix use of uninitialized variable

In reply to Patrick Rudolph

Initialize addr to zero which allows to build on the CI which is more strict.

---
 common/bloblist.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
common/bloblist.c +1 -1
index 2008ab4d25..cf1a3b8b62 100644
@@ -499,7 +499,7 @@ int bloblist_init(void)
 {
 	bool fixed = IS_ENABLED(CONFIG_BLOBLIST_FIXED);
 	int ret = -ENOENT;
-	ulong addr, size;
+	ulong addr = 0, size;
 	/*
 	 * If U-Boot is not in the first phase, an existing bloblist must be
 	 * at a fixed address.
Signature · 1 line
2.46.0
Reviewed-by on v4 34/35
#77 lore raw

Re: [PATCH v4 34/35] bloblist: Fix use of uninitialized variable

Quoted 9 lines · Patrick Rudolph

Initialize addr to zero which allows to build on the CI which is more strict.

---
 common/bloblist.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New patch, I believe

Quoted 16 lines
common/bloblist.c +1 -2
index 2008ab4d25..cf1a3b8b62 100644
@@ -499,7 +499,7 @@ int bloblist_init(void)
 {
        bool fixed = IS_ENABLED(CONFIG_BLOBLIST_FIXED);
        int ret = -ENOENT;
-       ulong addr, size;
+       ulong addr = 0, size;
        /*
         * If U-Boot is not in the first phase, an existing bloblist must be
         * at a fixed address.
--

2.46.0

#78 lore raw

PATCH v4 35/35 configs: Add RPI4 ACPI defconfig

In reply to Patrick Rudolph

Allows to build the RPi4 with ACPI enabled.

TEST: - Boots on qemu-system-aarch64 -machine raspi4b
- Boots on real hardware with arm_64bit=1 in config.txt

Cc Simon Glass <[email protected]>
Cc Matthias Brugger <[email protected]>
Cc Peter Robinson <[email protected]>

---
Changelog v4:
- Enable BLOBLISTS

---
 configs/rpi_4_acpi_defconfig | 70 ++++++++++++++++++++++++++++++++++++
 1 file changed, 70 insertions(+)
 create mode 100644 configs/rpi_4_acpi_defconfig
configs/rpi_4_acpi_defconfig new file +70 -0
new file mode 100644
index 0000000000..552c5eb8ee
@@ -0,0 +1,70 @@
+CONFIG_ARM=y
+CONFIG_ARCH_BCM283X=y
+CONFIG_TEXT_BASE=0x00080000
+CONFIG_TARGET_RPI_4=y
+CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
+CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x7fffe30
+CONFIG_ENV_SIZE=0x4000
+CONFIG_DEFAULT_DEVICE_TREE="bcm2711-rpi-4-b"
+CONFIG_OF_LIBFDT_OVERLAY=y
+CONFIG_DM_RESET=y
+CONFIG_SYS_LOAD_ADDR=0x1000000
+CONFIG_PCI=y
+CONFIG_BOOTSTD_DEFAULTS=y
+CONFIG_OF_BOARD_SETUP=y
+CONFIG_FDT_SIMPLEFB=y
+CONFIG_USE_PREBOOT=y
+CONFIG_PREBOOT="pci enum; usb start;"
+CONFIG_SYS_PBSIZE=1049
+# CONFIG_DISPLAY_CPUINFO is not set
+# CONFIG_DISPLAY_BOARDINFO is not set
+CONFIG_MISC_INIT_R=y
+CONFIG_BLOBLIST_ALLOC=y
+CONFIG_SYS_PROMPT="U-Boot> "
+CONFIG_CMD_DFU=y
+CONFIG_CMD_GPIO=y
+CONFIG_CMD_MMC=y
+CONFIG_CMD_PCI=y
+CONFIG_CMD_USB=y
+CONFIG_CMD_FS_UUID=y
+CONFIG_ENV_FAT_DEVICE_AND_PART="0:1"
+CONFIG_SYS_RELOC_GD_ENV_ADDR=y
+CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
+CONFIG_TFTP_TSIZE=y
+CONFIG_DM_DMA=y
+CONFIG_DFU_MMC=y
+CONFIG_SYS_DFU_DATA_BUF_SIZE=0x100000
+CONFIG_SYS_DFU_MAX_FILE_SIZE=0x200000
+CONFIG_BCM2835_GPIO=y
+CONFIG_MMC_SDHCI=y
+CONFIG_MMC_SDHCI_SDMA=y
+CONFIG_MMC_SDHCI_BCM2835=y
+CONFIG_BCMGENET=y
+CONFIG_PCI_BRCMSTB=y
+CONFIG_PINCTRL=y
+# CONFIG_PINCTRL_GENERIC is not set
+CONFIG_DM_RNG=y
+CONFIG_RNG_IPROC200=y
+# CONFIG_REQUIRE_SERIAL_CONSOLE is not set
+CONFIG_SYSINFO=y
+CONFIG_SYSINFO_SMBIOS=y
+CONFIG_USB=y
+CONFIG_DM_USB_GADGET=y
+CONFIG_USB_XHCI_HCD=y
+CONFIG_USB_XHCI_PCI=y
+CONFIG_USB_KEYBOARD=y
+CONFIG_USB_GADGET=y
+CONFIG_USB_GADGET_MANUFACTURER="FSL"
+CONFIG_USB_GADGET_VENDOR_NUM=0x0525
+CONFIG_USB_GADGET_PRODUCT_NUM=0xa4a5
+CONFIG_USB_GADGET_DWC2_OTG=y
+CONFIG_USB_GADGET_DOWNLOAD=y
+CONFIG_VIDEO=y
+# CONFIG_VIDEO_BPP8 is not set
+# CONFIG_VIDEO_BPP16 is not set
+CONFIG_SYS_WHITE_ON_BLACK=y
+CONFIG_VIDEO_BCM2835=y
+CONFIG_CONSOLE_SCROLL_LINES=10
+CONFIG_PHYS_TO_BUS=y
+CONFIG_ACPI=y
+CONFIG_GENERATE_ACPI_TABLE=y
Signature · 1 line
2.46.0
Reviewed-by on v4 35/35
#79 lore raw

Re: [PATCH v4 35/35] configs: Add RPI4 ACPI defconfig

Quoted 10 lines · Patrick Rudolph

Allows to build the RPi4 with ACPI enabled.

TEST: - Boots on qemu-system-aarch64 -machine raspi4b
- Boots on real hardware with arm_64bit=1 in config.txt

Cc Simon Glass <[email protected]>
Cc Matthias Brugger <[email protected]>
Cc Peter Robinson <[email protected]>
Quoted 7 lines

---
Changelog v4:
- Enable BLOBLISTS

---
 configs/rpi_4_acpi_defconfig | 70 ++++++++++++++++++++++++++++++++++++
 1 file changed, 70 insertions(+)
 create mode 100644 configs/rpi_4_acpi_defconfig