Skip to content

Commit f6fcf03

Browse files
bibo-maorafaeljw
authored andcommitted
ACPI: processor: LoongArch: Get physical ID from MADT
With ACPI Spec 6.5 chapter 5.2.12.20, each processor in LoongArch systems has a Core Programmable Interrupt Controller in MADT. The value of its type is 0x11 in the spec and defined as enum variable ACPI_MADT_TYPE_CORE_PIC in the Linux kernel. Physical IDs can be retrieved from MADT for LoongArch systems during initialization and they can be retrieved from the _MAT output for hotplug CPUs. Add physical CPU ID enumeration for LoongArch systems. Signed-off-by: Bibo Mao <maobibo@loongson.cn> [ rjw: Subject and changelog edits ] Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 003e069 commit f6fcf03

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

drivers/acpi/processor_core.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,30 @@ static int map_rintc_hartid(struct acpi_subtable_header *entry,
132132
return -EINVAL;
133133
}
134134

135+
/*
136+
* Retrieve LoongArch CPU physical id
137+
*/
138+
static int map_core_pic_id(struct acpi_subtable_header *entry,
139+
int device_declaration, u32 acpi_id, phys_cpuid_t *phys_id)
140+
{
141+
struct acpi_madt_core_pic *core_pic =
142+
container_of(entry, struct acpi_madt_core_pic, header);
143+
144+
if (!(core_pic->flags & ACPI_MADT_ENABLED))
145+
return -ENODEV;
146+
147+
/* device_declaration means Device object in DSDT, in LoongArch
148+
* system, logical processor acpi_id is required in _UID property
149+
* of DSDT table, so we should check device_declaration here
150+
*/
151+
if (device_declaration && (core_pic->processor_id == acpi_id)) {
152+
*phys_id = core_pic->core_id;
153+
return 0;
154+
}
155+
156+
return -EINVAL;
157+
}
158+
135159
static phys_cpuid_t map_madt_entry(struct acpi_table_madt *madt,
136160
int type, u32 acpi_id)
137161
{
@@ -165,6 +189,9 @@ static phys_cpuid_t map_madt_entry(struct acpi_table_madt *madt,
165189
} else if (header->type == ACPI_MADT_TYPE_RINTC) {
166190
if (!map_rintc_hartid(header, type, acpi_id, &phys_id))
167191
break;
192+
} else if (header->type == ACPI_MADT_TYPE_CORE_PIC) {
193+
if (!map_core_pic_id(header, type, acpi_id, &phys_id))
194+
break;
168195
}
169196
entry += header->length;
170197
}
@@ -216,6 +243,8 @@ static phys_cpuid_t map_mat_entry(acpi_handle handle, int type, u32 acpi_id)
216243
map_x2apic_id(header, type, acpi_id, &phys_id);
217244
else if (header->type == ACPI_MADT_TYPE_GENERIC_INTERRUPT)
218245
map_gicc_mpidr(header, type, acpi_id, &phys_id);
246+
else if (header->type == ACPI_MADT_TYPE_CORE_PIC)
247+
map_core_pic_id(header, type, acpi_id, &phys_id);
219248

220249
exit:
221250
kfree(buffer.pointer);

0 commit comments

Comments
 (0)