Skip to content

Commit

Permalink
intrng: fix INTR_ROOT_* constants
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ehem committed Nov 4, 2024
1 parent 9306543 commit 50aa4b7
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 17 deletions.
3 changes: 3 additions & 0 deletions sys/arm/include/intr.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@
#include <dev/ofw/openfirm.h>
#endif

#define INTR_ROOT_IRQ 0
#define INTR_ROOT_COUNT 1

#ifndef NIRQ
#define NIRQ 1024 /* XXX - It should be an option. */
#endif
Expand Down
3 changes: 2 additions & 1 deletion sys/arm64/include/intr.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
19 changes: 5 additions & 14 deletions sys/kern/subr_intr.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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;
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions sys/riscv/include/intr.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions sys/sys/intr.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 50aa4b7

Please sign in to comment.