Skip to content

Commit 8b7809e

Browse files
vlsunilpalmer-dabbelt
authored andcommitted
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 <[email protected]> Acked-by: Rafael J. Wysocki <[email protected]> Reviewed-by: Andrew Jones <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent a91a9ff commit 8b7809e

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

arch/riscv/include/asm/acpi.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
/* Basic configuration for ACPI */
1616
#ifdef CONFIG_ACPI
1717

18+
typedef u64 phys_cpuid_t;
19+
#define PHYS_CPUID_INVALID INVALID_HARTID
20+
1821
/* ACPI table mapping after acpi_permanent_mmap is set */
1922
void *acpi_os_ioremap(acpi_physical_address phys, acpi_size size);
2023
#define acpi_os_ioremap acpi_os_ioremap

drivers/acpi/processor_core.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,32 @@ static int map_gicc_mpidr(struct acpi_subtable_header *entry,
106106
return -EINVAL;
107107
}
108108

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+
109135
static phys_cpuid_t map_madt_entry(struct acpi_table_madt *madt,
110136
int type, u32 acpi_id)
111137
{
@@ -136,6 +162,9 @@ static phys_cpuid_t map_madt_entry(struct acpi_table_madt *madt,
136162
} else if (header->type == ACPI_MADT_TYPE_GENERIC_INTERRUPT) {
137163
if (!map_gicc_mpidr(header, type, acpi_id, &phys_id))
138164
break;
165+
} else if (header->type == ACPI_MADT_TYPE_RINTC) {
166+
if (!map_rintc_hartid(header, type, acpi_id, &phys_id))
167+
break;
139168
}
140169
entry += header->length;
141170
}

0 commit comments

Comments
 (0)