Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ACPI: processor_core: RISC-V: Enable mapping processor to the hartid

processor_core needs arch-specific functions to map the ACPI ID
to the physical ID. In RISC-V platforms, hartid is the physical id
and RINTC structure in MADT provides this mapping. Add arch-specific
function to get this mapping from RINTC.

Signed-off-by: Sunil V L <sunilvl@ventanamicro.com>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
Link: https://lore.kernel.org/r/20230515054928.2079268-8-sunilvl@ventanamicro.com
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>

authored by

Sunil V L and committed by
Palmer Dabbelt
8b7809e2 a91a9ffb

+32
+3
arch/riscv/include/asm/acpi.h
··· 15 15 /* Basic configuration for ACPI */ 16 16 #ifdef CONFIG_ACPI 17 17 18 + typedef u64 phys_cpuid_t; 19 + #define PHYS_CPUID_INVALID INVALID_HARTID 20 + 18 21 /* ACPI table mapping after acpi_permanent_mmap is set */ 19 22 void *acpi_os_ioremap(acpi_physical_address phys, acpi_size size); 20 23 #define acpi_os_ioremap acpi_os_ioremap
+29
drivers/acpi/processor_core.c
··· 106 106 return -EINVAL; 107 107 } 108 108 109 + /* 110 + * Retrieve the RISC-V hartid for the processor 111 + */ 112 + static int map_rintc_hartid(struct acpi_subtable_header *entry, 113 + int device_declaration, u32 acpi_id, 114 + phys_cpuid_t *hartid) 115 + { 116 + struct acpi_madt_rintc *rintc = 117 + container_of(entry, struct acpi_madt_rintc, header); 118 + 119 + if (!(rintc->flags & ACPI_MADT_ENABLED)) 120 + return -ENODEV; 121 + 122 + /* device_declaration means Device object in DSDT, in the 123 + * RISC-V, logical processors are required to 124 + * have a Processor Device object in the DSDT, so we should 125 + * check device_declaration here 126 + */ 127 + if (device_declaration && rintc->uid == acpi_id) { 128 + *hartid = rintc->hart_id; 129 + return 0; 130 + } 131 + 132 + return -EINVAL; 133 + } 134 + 109 135 static phys_cpuid_t map_madt_entry(struct acpi_table_madt *madt, 110 136 int type, u32 acpi_id) 111 137 { ··· 161 135 break; 162 136 } else if (header->type == ACPI_MADT_TYPE_GENERIC_INTERRUPT) { 163 137 if (!map_gicc_mpidr(header, type, acpi_id, &phys_id)) 138 + break; 139 + } else if (header->type == ACPI_MADT_TYPE_RINTC) { 140 + if (!map_rintc_hartid(header, type, acpi_id, &phys_id)) 164 141 break; 165 142 } 166 143 entry += header->length;