Skip to content

Commit f8bba14

Browse files
vlsunilrafaeljw
authored andcommitted
ACPI: RISC-V: Implement function to reorder irqchip probe entries
On RISC-V platforms, the RINTC structures should be probed before any other interrupt controller structures and IMSIC before APLIC. This order is established by using MADT sub table types which are ordered in the incremental order from the RINTC. So, add the architecture function for RISC-V to reorder the interrupt controller probing as per the hierarchy like below. ACPI_MADT_TYPE_RINTC = 24, ACPI_MADT_TYPE_IMSIC = 25, ACPI_MADT_TYPE_APLIC = 26, ACPI_MADT_TYPE_PLIC = 27 This means processing all RINTC structures (in the order of appearance in MADT), followed by IMSIC strucutre and then all APLIC/PLIC structures. Signed-off-by: Sunil V L <[email protected]> Tested-by: Björn Töpel <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 01415e7 commit f8bba14

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

drivers/acpi/riscv/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# SPDX-License-Identifier: GPL-2.0-only
2-
obj-y += rhct.o init.o
2+
obj-y += rhct.o init.o irq.o
33
obj-$(CONFIG_ACPI_PROCESSOR_IDLE) += cpuidle.o
44
obj-$(CONFIG_ACPI_CPPC_LIB) += cppc.o

drivers/acpi/riscv/irq.c

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// SPDX-License-Identifier: GPL-2.0-only
2+
/*
3+
* Copyright (C) 2023-2024, Ventana Micro Systems Inc
4+
* Author: Sunil V L <[email protected]>
5+
*/
6+
7+
#include <linux/acpi.h>
8+
#include <linux/sort.h>
9+
10+
static int irqchip_cmp_func(const void *in0, const void *in1)
11+
{
12+
struct acpi_probe_entry *elem0 = (struct acpi_probe_entry *)in0;
13+
struct acpi_probe_entry *elem1 = (struct acpi_probe_entry *)in1;
14+
15+
return (elem0->type > elem1->type) - (elem0->type < elem1->type);
16+
}
17+
18+
/*
19+
* On RISC-V, RINTC structures in MADT should be probed before any other
20+
* interrupt controller structures and IMSIC before APLIC. The interrupt
21+
* controller subtypes in MADT of ACPI spec for RISC-V are defined in
22+
* the incremental order like RINTC(24)->IMSIC(25)->APLIC(26)->PLIC(27).
23+
* Hence, simply sorting the subtypes in incremental order will
24+
* establish the required order.
25+
*/
26+
void arch_sort_irqchip_probe(struct acpi_probe_entry *ap_head, int nr)
27+
{
28+
struct acpi_probe_entry *ape = ap_head;
29+
30+
if (nr == 1 || !ACPI_COMPARE_NAMESEG(ACPI_SIG_MADT, ape->id))
31+
return;
32+
sort(ape, nr, sizeof(*ape), irqchip_cmp_func, NULL);
33+
}

0 commit comments

Comments
 (0)