Skip to content

Commit ca5b0b7

Browse files
SiFiveHollandKAGA-KOKO
authored andcommitted
irqchip/riscv-intc: Fix use of AIA interrupts 32-63 on riscv32
riscv_intc_custom_base is initialized to BITS_PER_LONG, so the second check passes even though AIA provides 64 interrupts. Adjust the condition to only check the custom range for interrupts outside the standard range, and adjust the standard range when AIA is available. Fixes: 3c46fc5 ("irqchip/riscv-intc: Add support for RISC-V AIA") Fixes: 678c607 ("irqchip/riscv-intc: Fix low-level interrupt handler setup for AIA") Signed-off-by: Samuel Holland <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Reviewed-by: Anup Patel <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 4527e83 commit ca5b0b7

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

drivers/irqchip/irq-riscv-intc.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,9 @@ static int riscv_intc_domain_alloc(struct irq_domain *domain,
149149
* Only allow hwirq for which we have corresponding standard or
150150
* custom interrupt enable register.
151151
*/
152-
if ((hwirq >= riscv_intc_nr_irqs && hwirq < riscv_intc_custom_base) ||
153-
(hwirq >= riscv_intc_custom_base + riscv_intc_custom_nr_irqs))
152+
if (hwirq >= riscv_intc_nr_irqs &&
153+
(hwirq < riscv_intc_custom_base ||
154+
hwirq >= riscv_intc_custom_base + riscv_intc_custom_nr_irqs))
154155
return -EINVAL;
155156

156157
for (i = 0; i < nr_irqs; i++) {
@@ -183,10 +184,12 @@ static int __init riscv_intc_init_common(struct fwnode_handle *fn, struct irq_ch
183184
return -ENXIO;
184185
}
185186

186-
if (riscv_isa_extension_available(NULL, SxAIA))
187+
if (riscv_isa_extension_available(NULL, SxAIA)) {
188+
riscv_intc_nr_irqs = 64;
187189
rc = set_handle_irq(&riscv_intc_aia_irq);
188-
else
190+
} else {
189191
rc = set_handle_irq(&riscv_intc_irq);
192+
}
190193
if (rc) {
191194
pr_err("failed to set irq handler\n");
192195
return rc;
@@ -195,7 +198,7 @@ static int __init riscv_intc_init_common(struct fwnode_handle *fn, struct irq_ch
195198
riscv_set_intc_hwnode_fn(riscv_intc_hwnode);
196199

197200
pr_info("%d local interrupts mapped%s\n",
198-
riscv_isa_extension_available(NULL, SxAIA) ? 64 : riscv_intc_nr_irqs,
201+
riscv_intc_nr_irqs,
199202
riscv_isa_extension_available(NULL, SxAIA) ? " using AIA" : "");
200203
if (riscv_intc_custom_nr_irqs)
201204
pr_info("%d custom local interrupts mapped\n", riscv_intc_custom_nr_irqs);

0 commit comments

Comments
 (0)