From: miod Date: Fri, 29 Mar 2024 21:29:33 +0000 (+0000) Subject: Drop the first argument of intr_establish(). X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=8a1e8ccaf72b414f303ec266a1bf09741dab5c4c;p=openbsd Drop the first argument of intr_establish(). Instead, require all callers to put the right value in the ih_pil field, and have intr_establish() trust them rather than assigning this field again from its first argument. ok claudio@ kettenis@ --- diff --git a/sys/arch/sparc64/dev/ebus_mainbus.c b/sys/arch/sparc64/dev/ebus_mainbus.c index 7e011b9d5b6..6b1728b589f 100644 --- a/sys/arch/sparc64/dev/ebus_mainbus.c +++ b/sys/arch/sparc64/dev/ebus_mainbus.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ebus_mainbus.c,v 1.12 2021/10/24 17:05:03 mpi Exp $ */ +/* $OpenBSD: ebus_mainbus.c,v 1.13 2024/03/29 21:29:33 miod Exp $ */ /* * Copyright (c) 2007 Mark Kettenis @@ -274,7 +274,7 @@ ebus_mainbus_intr_establish(bus_space_tag_t t, bus_space_tag_t t0, int ihandle, if (ih == NULL) return (NULL); - intr_establish(ih->ih_pil, ih); + intr_establish(ih); ih->ih_ack = ebus_mainbus_intr_ack; err = hv_intr_settarget(sysino, ih->ih_cpu->ci_upaid); @@ -322,7 +322,7 @@ ebus_mainbus_intr_establish(bus_space_tag_t t, bus_space_tag_t t0, int ihandle, if (ih == NULL) return (NULL); - intr_establish(ih->ih_pil, ih); + intr_establish(ih); if (intrmapptr != NULL) { u_int64_t intrmap; diff --git a/sys/arch/sparc64/dev/fhc.c b/sys/arch/sparc64/dev/fhc.c index 23b77c0e277..6b967a095be 100644 --- a/sys/arch/sparc64/dev/fhc.c +++ b/sys/arch/sparc64/dev/fhc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fhc.c,v 1.21 2017/09/08 05:36:52 deraadt Exp $ */ +/* $OpenBSD: fhc.c,v 1.22 2024/03/29 21:29:33 miod Exp $ */ /* * Copyright (c) 2004 Jason L. Wright (jason@thought.net) @@ -273,7 +273,7 @@ fhc_intr_establish(bus_space_tag_t t, bus_space_tag_t t0, int ihandle, if (ih == NULL) return (NULL); - intr_establish(ih->ih_pil, ih); + intr_establish(ih); if (intrmapptr != NULL) { u_int64_t r; diff --git a/sys/arch/sparc64/dev/psycho.c b/sys/arch/sparc64/dev/psycho.c index f3c5b29a30a..377eefc6f60 100644 --- a/sys/arch/sparc64/dev/psycho.c +++ b/sys/arch/sparc64/dev/psycho.c @@ -1,4 +1,4 @@ -/* $OpenBSD: psycho.c,v 1.83 2023/04/11 00:45:08 jsg Exp $ */ +/* $OpenBSD: psycho.c,v 1.84 2024/03/29 21:29:33 miod Exp $ */ /* $NetBSD: psycho.c,v 1.39 2001/10/07 20:30:41 eeh Exp $ */ /* @@ -681,7 +681,7 @@ psycho_set_intr(struct psycho_softc *sc, int ipl, void *handler, ih->ih_map = mapper; ih->ih_clr = clearer; ih->ih_fun = handler; - ih->ih_pil = (1 << ipl); + ih->ih_pil = ipl; ih->ih_number = INTVEC(*(ih->ih_map)); snprintf(ih->ih_name, sizeof(ih->ih_name), "%s:%s", sc->sc_dev.dv_xname, suffix); @@ -691,7 +691,7 @@ psycho_set_intr(struct psycho_softc *sc, int ipl, void *handler, ih->ih_fun, ih->ih_arg, sc->sc_dev.dv_xname, ih->ih_number, ih->ih_pil)); - intr_establish(ipl, ih); + intr_establish(ih); } /* @@ -1286,7 +1286,7 @@ found: if (flags & BUS_INTR_ESTABLISH_MPSAFE) ih->ih_mpsafe = 1; - intr_establish(ih->ih_pil, ih); + intr_establish(ih); /* * Enable the interrupt now we have the handler installed. diff --git a/sys/arch/sparc64/dev/pyro.c b/sys/arch/sparc64/dev/pyro.c index af48a1f0b88..5f99b0e61ad 100644 --- a/sys/arch/sparc64/dev/pyro.c +++ b/sys/arch/sparc64/dev/pyro.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pyro.c,v 1.37 2024/03/29 21:18:19 miod Exp $ */ +/* $OpenBSD: pyro.c,v 1.38 2024/03/29 21:29:33 miod Exp $ */ /* * Copyright (c) 2002 Jason L. Wright (jason@thought.net) @@ -786,7 +786,7 @@ pyro_intr_establish_cpu(bus_space_tag_t t, bus_space_tag_t t0, int ihandle, if (flags & BUS_INTR_ESTABLISH_MPSAFE) ih->ih_mpsafe = 1; - intr_establish(ih->ih_pil, ih); + intr_establish(ih); if (intrmapptr != NULL) { u_int64_t intrmap; diff --git a/sys/arch/sparc64/dev/sbus.c b/sys/arch/sparc64/dev/sbus.c index 49f222e5179..ddb77a6c26b 100644 --- a/sys/arch/sparc64/dev/sbus.c +++ b/sys/arch/sparc64/dev/sbus.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sbus.c,v 1.46 2021/10/24 17:05:04 mpi Exp $ */ +/* $OpenBSD: sbus.c,v 1.47 2024/03/29 21:29:33 miod Exp $ */ /* $NetBSD: sbus.c,v 1.46 2001/10/07 20:30:41 eeh Exp $ */ /*- @@ -291,7 +291,7 @@ sbus_mb_attach(struct device *parent, struct device *self, void *aux) struct mainbus_attach_args *ma = aux; int node = ma->ma_node; struct intrhand *ih; - int ipl, error; + int error; struct sysioreg *sysio; char buf[32]; char *name; @@ -363,11 +363,10 @@ sbus_mb_attach(struct device *parent, struct device *self, void *aux) ih->ih_map = &sysio->therm_int_map; ih->ih_clr = NULL; /* &sysio->therm_clr_int; */ ih->ih_fun = sbus_overtemp; - ipl = 1; - ih->ih_pil = (1 << ipl); + ih->ih_pil = 1; ih->ih_number = INTVEC(*(ih->ih_map)); strlcpy(ih->ih_name, sc->sc_dev.dv_xname, sizeof(ih->ih_name)); - intr_establish(ipl, ih); + intr_establish(ih); *(ih->ih_map) |= INTMAP_V; /* @@ -757,7 +756,7 @@ sbus_intr_establish(bus_space_tag_t t, bus_space_tag_t t0, int pri, int level, if (ih == NULL) return (ih); - intr_establish(ih->ih_pil, ih); + intr_establish(ih); return (ih); } diff --git a/sys/arch/sparc64/dev/schizo.c b/sys/arch/sparc64/dev/schizo.c index 3152e77cada..2b4a3af4fb5 100644 --- a/sys/arch/sparc64/dev/schizo.c +++ b/sys/arch/sparc64/dev/schizo.c @@ -1,4 +1,4 @@ -/* $OpenBSD: schizo.c,v 1.69 2019/06/25 22:30:56 dlg Exp $ */ +/* $OpenBSD: schizo.c,v 1.70 2024/03/29 21:29:33 miod Exp $ */ /* * Copyright (c) 2002 Jason L. Wright (jason@thought.net) @@ -561,7 +561,7 @@ schizo_set_intr(struct schizo_softc *sc, struct schizo_pbm *pbm, int ipl, return; } - intr_establish(ih->ih_pil, ih); + intr_establish(ih); } bus_space_tag_t @@ -806,7 +806,7 @@ schizo_intr_establish(bus_space_tag_t t, bus_space_tag_t t0, int ihandle, if (flags & BUS_INTR_ESTABLISH_MPSAFE) ih->ih_mpsafe = 1; - intr_establish(ih->ih_pil, ih); + intr_establish(ih); if (intrmapptr != NULL) { u_int64_t intrmap; diff --git a/sys/arch/sparc64/dev/vbus.c b/sys/arch/sparc64/dev/vbus.c index 983fbac3aaf..44840a391b8 100644 --- a/sys/arch/sparc64/dev/vbus.c +++ b/sys/arch/sparc64/dev/vbus.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vbus.c,v 1.12 2021/10/24 17:05:04 mpi Exp $ */ +/* $OpenBSD: vbus.c,v 1.13 2024/03/29 21:29:33 miod Exp $ */ /* * Copyright (c) 2008 Mark Kettenis * @@ -244,7 +244,7 @@ vbus_intr_establish(bus_space_tag_t t, bus_space_tag_t t0, int ihandle, if (err != H_EOK) return (NULL); - intr_establish(ih->ih_pil, ih); + intr_establish(ih); ih->ih_ack = vbus_intr_ack; err = sun4v_intr_settarget(devhandle, sysino, ih->ih_cpu->ci_upaid); diff --git a/sys/arch/sparc64/dev/vpci.c b/sys/arch/sparc64/dev/vpci.c index 14f3c5c0d10..afaae203209 100644 --- a/sys/arch/sparc64/dev/vpci.c +++ b/sys/arch/sparc64/dev/vpci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vpci.c,v 1.34 2024/03/29 21:18:19 miod Exp $ */ +/* $OpenBSD: vpci.c,v 1.35 2024/03/29 21:29:33 miod Exp $ */ /* * Copyright (c) 2008 Mark Kettenis * @@ -695,7 +695,7 @@ vpci_intr_establish_cpu(bus_space_tag_t t, bus_space_tag_t t0, int ihandle, return (NULL); ih->ih_cpu = cpu; - intr_establish(ih->ih_pil, ih); + intr_establish(ih); ih->ih_ack = vpci_intr_ack; err = sun4v_intr_settarget(devhandle, sysino, ih->ih_cpu->ci_upaid); diff --git a/sys/arch/sparc64/include/intr.h b/sys/arch/sparc64/include/intr.h index b12fd0a396e..e8bdfdb2237 100644 --- a/sys/arch/sparc64/include/intr.h +++ b/sys/arch/sparc64/include/intr.h @@ -1,4 +1,4 @@ -/* $OpenBSD: intr.h,v 1.24 2024/03/29 21:18:19 miod Exp $ */ +/* $OpenBSD: intr.h,v 1.25 2024/03/29 21:29:34 miod Exp $ */ /* $NetBSD: intr.h,v 1.8 2001/01/14 23:50:30 thorpej Exp $ */ /*- @@ -63,7 +63,7 @@ struct intrhand { extern struct intrhand *intrlev[MAXINTNUM]; -void intr_establish(int, struct intrhand *); +void intr_establish(struct intrhand *); /* XXX - arbitrary numbers; no interpretation is defined yet */ #define IPL_NONE 0 /* nothing */ diff --git a/sys/arch/sparc64/sparc64/clock.c b/sys/arch/sparc64/sparc64/clock.c index 1cab29fa0bf..56dafd92b26 100644 --- a/sys/arch/sparc64/sparc64/clock.c +++ b/sys/arch/sparc64/sparc64/clock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: clock.c,v 1.85 2024/03/29 21:26:38 miod Exp $ */ +/* $OpenBSD: clock.c,v 1.86 2024/03/29 21:29:34 miod Exp $ */ /* $NetBSD: clock.c,v 1.41 2001/07/24 19:29:25 eeh Exp $ */ /* @@ -171,7 +171,12 @@ const struct intrclock stick_intrclock = { void sparc64_raise_clockintr(void); -static struct intrhand level0 = { tickintr }; +static struct intrhand level10 = { + .ih_fun = tickintr, + .ih_number = 1, + .ih_pil = 10, + .ih_name = "clock" +}; /* * clock (eeprom) attaches at the sbus or the ebus (PCI) @@ -516,41 +521,36 @@ cpu_initclocks(void) struct cpu_info *ci; - /* We don't have a counter-timer -- use %tick */ - level0.ih_clr = 0; - /* * Establish a level 10 interrupt handler * * We will have a conflict with the softint handler, * so we set the ih_number to 1. */ - level0.ih_number = 1; - strlcpy(level0.ih_name, "clock", sizeof(level0.ih_name)); - intr_establish(10, &level0); - evcount_percpu(&level0.ih_count); + intr_establish(&level10); + evcount_percpu(&level10.ih_count); if (sys_tick_rate > 0) { sys_tick_nsec_cycle_ratio = sys_tick_rate * (1ULL << 32) / 1000000000; sys_tick_nsec_max = UINT64_MAX / sys_tick_nsec_cycle_ratio; if (impl == IMPL_HUMMINGBIRD) { - level0.ih_fun = stickintr; + level10.ih_fun = stickintr; cpu_start_clock = stick_start; } else { - level0.ih_fun = sys_tickintr; + level10.ih_fun = sys_tickintr; cpu_start_clock = sys_tick_start; } } else { tick_nsec_cycle_ratio = cpu_clockrate * (1ULL << 32) / 1000000000; tick_nsec_max = UINT64_MAX / tick_nsec_cycle_ratio; - level0.ih_fun = tickintr; + level10.ih_fun = tickintr; cpu_start_clock = tick_start; } for (ci = cpus; ci != NULL; ci = ci->ci_next) - memcpy(&ci->ci_tickintr, &level0, sizeof(level0)); + memcpy(&ci->ci_tickintr, &level10, sizeof(level10)); } void @@ -576,7 +576,7 @@ int tickintr(void *cap) { clockintr_dispatch(cap); - evcount_inc(&level0.ih_count); + evcount_inc(&level10.ih_count); return (1); } @@ -584,7 +584,7 @@ int sys_tickintr(void *cap) { clockintr_dispatch(cap); - evcount_inc(&level0.ih_count); + evcount_inc(&level10.ih_count); return (1); } @@ -592,7 +592,7 @@ int stickintr(void *cap) { clockintr_dispatch(cap); - evcount_inc(&level0.ih_count); + evcount_inc(&level10.ih_count); return (1); } diff --git a/sys/arch/sparc64/sparc64/intr.c b/sys/arch/sparc64/sparc64/intr.c index 812ad901e3b..b7b71ec8cdd 100644 --- a/sys/arch/sparc64/sparc64/intr.c +++ b/sys/arch/sparc64/sparc64/intr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: intr.c,v 1.66 2024/03/29 21:18:19 miod Exp $ */ +/* $OpenBSD: intr.c,v 1.67 2024/03/29 21:29:34 miod Exp $ */ /* $NetBSD: intr.c,v 1.39 2001/07/19 23:38:11 eeh Exp $ */ /* @@ -132,10 +132,10 @@ intr_ack(struct intrhand *ih) } /* - * Attach an interrupt handler to the vector chain for the given level. + * Attach an interrupt handler to the vector chain. */ void -intr_establish(int level, struct intrhand *ih) +intr_establish(struct intrhand *ih) { struct intrhand *q; u_int64_t m, id; @@ -143,12 +143,7 @@ intr_establish(int level, struct intrhand *ih) s = splhigh(); - /* - * This is O(N^2) for long chains, but chains are never long - * and we do want to preserve order. - */ - ih->ih_pil = level; /* XXXX caller should have done this before */ - ih->ih_pending = 0; /* XXXX caller should have done this before */ + ih->ih_pending = NULL; ih->ih_next = NULL; if (ih->ih_cpu == NULL) ih->ih_cpu = curcpu(); @@ -294,7 +289,7 @@ softintr_establish(int level, void (*fun)(void *), void *arg) ih->ih_fun = (int (*)(void *))fun; /* XXX */ ih->ih_arg = arg; ih->ih_pil = level; - ih->ih_pending = 0; + ih->ih_pending = NULL; ih->ih_ack = NULL; ih->ih_clr = NULL; return (ih); diff --git a/sys/arch/sparc64/sparc64/machdep.c b/sys/arch/sparc64/sparc64/machdep.c index 68cadc29a41..20680bb4d87 100644 --- a/sys/arch/sparc64/sparc64/machdep.c +++ b/sys/arch/sparc64/sparc64/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.215 2024/03/29 21:27:53 miod Exp $ */ +/* $OpenBSD: machdep.c,v 1.216 2024/03/29 21:29:34 miod Exp $ */ /* $NetBSD: machdep.c,v 1.108 2001/07/24 19:30:14 eeh Exp $ */ /*- @@ -1694,7 +1694,7 @@ sparc_mainbus_intr_establish(bus_space_tag_t t, bus_space_tag_t t0, int number, if (ih == NULL) return (NULL); - intr_establish(ih->ih_pil, ih); + intr_establish(ih); return (ih); }