git: 487788a69fa2 - main - intrng: fix INTR_ROOT_* constants

From: Mitchell Horne <mhorne_at_FreeBSD.org>
Date: Mon, 16 Dec 2024 19:12:11 UTC
The branch main has been updated by mhorne:

URL: https://cgit.FreeBSD.org/src/commit/?id=487788a69fa2bd57ee04f38c3ad6e995a62d8e00

commit 487788a69fa2bd57ee04f38c3ad6e995a62d8e00
Author:     Elliott Mitchell <ehem+freebsd@m5p.com>
AuthorDate: 2024-08-09 15:30:15 +0000
Commit:     Mitchell Horne <mhorne@FreeBSD.org>
CommitDate: 2024-12-16 19:11:52 +0000

    intrng: fix INTR_ROOT_* constants
    
    Switch to INTR_ROOT_COUNT as this name better describes its purpose.
    
    Remove the default INTR_ROOT_IRQ from the core.  Define it (redundantly)
    in each architecture's header, but now placed alongside its sibling
    values (if defined by the platform, e.g. arm64 INTR_ROOT_FIQ).
    
    Reviewed by:    mhorne
    Pull Request:   https://github.com/freebsd/freebsd-src/pull/1280
---
 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 5facd5dbccdb..71e853c93ce2 100644
--- a/sys/arm/include/intr.h
+++ b/sys/arm/include/intr.h
@@ -51,4 +51,7 @@ void arm_irq_memory_barrier(uintptr_t);
 #define	NIRQ		1024	/* XXX - It should be an option. */
 #endif
 
+#define	INTR_ROOT_IRQ	0
+#define	INTR_ROOT_COUNT	1
+
 #endif	/* _MACHINE_INTR_H */
diff --git a/sys/arm64/include/intr.h b/sys/arm64/include/intr.h
index 56bce911cd32..ef7fe56e3a13 100644
--- a/sys/arm64/include/intr.h
+++ b/sys/arm64/include/intr.h
@@ -48,7 +48,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 b8d85bf20f28..b7cb088f58c7 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 ea98f0632108..da5d420f7e6d 100644
--- a/sys/riscv/include/intr.h
+++ b/sys/riscv/include/intr.h
@@ -56,4 +56,7 @@ enum {
 };
 #endif /* !LOCORE */
 
+#define	INTR_ROOT_IRQ	0
+#define	INTR_ROOT_COUNT	1
+
 #endif /* !_MACHINE_INTR_MACHDEP_H_ */
diff --git a/sys/sys/intr.h b/sys/sys/intr.h
index d60eac937d93..77daf5a35f32 100644
--- a/sys/sys/intr.h
+++ b/sys/sys/intr.h
@@ -37,8 +37,6 @@
 
 #define	INTR_IRQ_INVALID	0xFFFFFFFF
 
-#define INTR_ROOT_IRQ	0
-
 #ifndef LOCORE
 
 enum intr_map_data_type {