From 50aa4b7818add2a19bdba8fd24195d2fda198f2d Mon Sep 17 00:00:00 2001 From: Elliott Mitchell Date: Fri, 9 Aug 2024 08:30:15 -0700 Subject: [PATCH] intrng: fix INTR_ROOT_* constants Switch to INTR_ROOT_COUNT as this better matches the purpose of the value. Remove the default from the core. Better to require the architectures to declare the type since they will routinely deviate and a default chosen now will likely be suboptimal. --- sys/arm/include/intr.h | 3 +++ sys/arm64/include/intr.h | 3 ++- sys/kern/subr_intr.c | 19 +++++-------------- sys/riscv/include/intr.h | 3 +++ sys/sys/intr.h | 2 -- 5 files changed, 13 insertions(+), 17 deletions(-) diff --git a/sys/arm/include/intr.h b/sys/arm/include/intr.h index e64edd47dad2f..1e41a312bf387 100644 --- a/sys/arm/include/intr.h +++ b/sys/arm/include/intr.h @@ -43,6 +43,9 @@ #include #endif +#define INTR_ROOT_IRQ 0 +#define INTR_ROOT_COUNT 1 + #ifndef NIRQ #define NIRQ 1024 /* XXX - It should be an option. */ #endif diff --git a/sys/arm64/include/intr.h b/sys/arm64/include/intr.h index 38cba6ae8b0d7..e6d8054758c41 100644 --- a/sys/arm64/include/intr.h +++ b/sys/arm64/include/intr.h @@ -46,7 +46,8 @@ arm_irq_memory_barrier(uintptr_t irq) #define ACPI_GPIO_XREF 3 #endif +#define INTR_ROOT_IRQ 0 #define INTR_ROOT_FIQ 1 -#define INTR_ROOT_NUM 2 +#define INTR_ROOT_COUNT 2 #endif /* _MACHINE_INTR_H */ diff --git a/sys/kern/subr_intr.c b/sys/kern/subr_intr.c index b8d85bf20f289..b7cb088f58c71 100644 --- a/sys/kern/subr_intr.c +++ b/sys/kern/subr_intr.c @@ -89,15 +89,6 @@ #define INTRNAME_LEN (2*MAXCOMLEN + 1) -/* - * Archs may define multiple roots with INTR_ROOT_NUM to support different kinds - * of interrupts (e.g. arm64 FIQs which use a different exception vector than - * IRQs). - */ -#if !defined(INTR_ROOT_NUM) -#define INTR_ROOT_NUM 1 -#endif - #ifdef DEBUG #define debugf(fmt, args...) do { printf("%s(): ", __func__); \ printf(fmt,##args); } while (0) @@ -115,7 +106,7 @@ struct intr_irq_root { void *arg; }; -static struct intr_irq_root intr_irq_roots[INTR_ROOT_NUM]; +static struct intr_irq_root intr_irq_roots[INTR_ROOT_COUNT]; struct intr_pic_child { SLIST_ENTRY(intr_pic_child) pc_next; @@ -343,7 +334,7 @@ intr_irq_handler(struct trapframe *tf, uint32_t rootnum) struct thread * td; struct intr_irq_root *root; - KASSERT(rootnum < INTR_ROOT_NUM, + KASSERT(rootnum < INTR_ROOT_COUNT, ("%s: invalid interrupt root %d", __func__, rootnum)); root = &intr_irq_roots[rootnum]; @@ -497,7 +488,7 @@ isrc_free_irq(struct intr_irqsrc *isrc) device_t intr_irq_root_device(uint32_t rootnum) { - KASSERT(rootnum < INTR_ROOT_NUM, + KASSERT(rootnum < INTR_ROOT_COUNT, ("%s: invalid interrupt root %d", __func__, rootnum)); return (intr_irq_roots[rootnum].dev); } @@ -925,7 +916,7 @@ intr_pic_claim_root(device_t dev, intptr_t xref, intr_irq_filter_t *filter, * Note that we further suppose that there is not threaded interrupt * routine (handler) on the root. See intr_irq_handler(). */ - KASSERT(rootnum < INTR_ROOT_NUM, + KASSERT(rootnum < INTR_ROOT_COUNT, ("%s: invalid interrupt root %d", __func__, rootnum)); root = &intr_irq_roots[rootnum]; if (root->dev != NULL) { @@ -1586,7 +1577,7 @@ intr_pic_init_secondary(void) * QQQ: Only root PICs are aware of other CPUs ??? */ //mtx_lock(&isrc_table_lock); - for (rootnum = 0; rootnum < INTR_ROOT_NUM; rootnum++) { + for (rootnum = 0; rootnum < INTR_ROOT_COUNT; rootnum++) { dev = intr_irq_roots[rootnum].dev; if (dev != NULL) { PIC_INIT_SECONDARY(dev, rootnum); diff --git a/sys/riscv/include/intr.h b/sys/riscv/include/intr.h index 657781efb6206..c966043196ca5 100644 --- a/sys/riscv/include/intr.h +++ b/sys/riscv/include/intr.h @@ -35,6 +35,9 @@ #ifndef _MACHINE_INTR_MACHDEP_H_ #define _MACHINE_INTR_MACHDEP_H_ +#define INTR_ROOT_IRQ 0 +#define INTR_ROOT_COUNT 1 + #ifndef NIRQ #define NIRQ 1024 #endif diff --git a/sys/sys/intr.h b/sys/sys/intr.h index f11e96777927a..a1aaede7271e2 100644 --- a/sys/sys/intr.h +++ b/sys/sys/intr.h @@ -39,8 +39,6 @@ #define INTR_IRQ_INVALID 0xFFFFFFFF -#define INTR_ROOT_IRQ 0 - enum intr_map_data_type { INTR_MAP_DATA_ACPI = 0, INTR_MAP_DATA_FDT,