Skip to content

Commit a98a0f0

Browse files
vlsunilKAGA-KOKO
authored andcommitted
irqchip/riscv-intc: Fix SMP=n boot with ACPI
When CONFIG_SMP is disabled, the static array rintc_acpi_data with size NR_CPUS is not sufficient to hold all RINTC structures passed from the firmware. All RINTC structures are required to configure IMSIC/APLIC/PLIC properly irrespective of SMP in the OS. So, allocate dynamic memory based on the number of RINTC structures in MADT to fix this issue. Fixes: f8619b6 ("irqchip/riscv-intc: Add ACPI support for AIA") Reported-by: Björn Töpel <bjorn@kernel.org> Signed-off-by: Sunil V L <sunilvl@ventanamicro.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Tested-by: Alexandre Ghiti <alexghiti@rivosinc.com> Reviewed-by: Anup Patel <anup@brainfault.org> Link: https://lore.kernel.org/all/20241014065739.656959-1-sunilvl@ventanamicro.com Closes: https://github.com/linux-riscv/linux-riscv/actions/runs/11280997511/job/31375229012
1 parent 6b1e065 commit a98a0f0

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

drivers/irqchip/irq-riscv-intc.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ struct rintc_data {
265265
};
266266

267267
static u32 nr_rintc;
268-
static struct rintc_data *rintc_acpi_data[NR_CPUS];
268+
static struct rintc_data **rintc_acpi_data;
269269

270270
#define for_each_matching_plic(_plic_id) \
271271
unsigned int _plic; \
@@ -329,13 +329,30 @@ int acpi_rintc_get_imsic_mmio_info(u32 index, struct resource *res)
329329
return 0;
330330
}
331331

332+
static int __init riscv_intc_acpi_match(union acpi_subtable_headers *header,
333+
const unsigned long end)
334+
{
335+
return 0;
336+
}
337+
332338
static int __init riscv_intc_acpi_init(union acpi_subtable_headers *header,
333339
const unsigned long end)
334340
{
335341
struct acpi_madt_rintc *rintc;
336342
struct fwnode_handle *fn;
343+
int count;
337344
int rc;
338345

346+
if (!rintc_acpi_data) {
347+
count = acpi_table_parse_madt(ACPI_MADT_TYPE_RINTC, riscv_intc_acpi_match, 0);
348+
if (count <= 0)
349+
return -EINVAL;
350+
351+
rintc_acpi_data = kcalloc(count, sizeof(*rintc_acpi_data), GFP_KERNEL);
352+
if (!rintc_acpi_data)
353+
return -ENOMEM;
354+
}
355+
339356
rintc = (struct acpi_madt_rintc *)header;
340357
rintc_acpi_data[nr_rintc] = kzalloc(sizeof(*rintc_acpi_data[0]), GFP_KERNEL);
341358
if (!rintc_acpi_data[nr_rintc])

0 commit comments

Comments
 (0)