Module Name: src Committed By: thorpej Date: Sun Jul 4 22:36:43 UTC 2021
Modified Files: src/sys/arch/alpha/common: shared_intr.c src/sys/arch/alpha/include: intr.h pci_machdep.h src/sys/arch/alpha/jensenio: jensenio_intr.c src/sys/arch/alpha/pci: pci_1000.c pci_1000a.c pci_2100_a500.c pci_550.c pci_6600.c pci_eb164.c pci_eb64plus.c pci_eb66.c pci_kn20aa.c pci_kn300.c pci_machdep.c sio_pic.c Log Message: Reduce code duplication when setting up the interrupt handler data structures: - alpha_shared_intr_alloc() no longer takes a "string length" argument, and just uses kmem_asprintf() to create an "irq %u" string by default. This is suitable for nearly every caller. - Add a alpha_shared_intr_set_string() that allows callers to override the default IRQ description string. - Related: make alpha_shared_intr_string() return a const char *, since no callers should need to modify the string directly now. - Re-factor PCI shared interrupt structure allocation / initialization into a new alpha_pci_intr_alloc(), which is suitable for nearly every Alpha PCI platform. Callers are expected to first have initialized the interrupt hardware to the quiescent state. Adjust various call sites of above functions to account for changes, even if they are not able to use the newly re-factored code. To generate a diff of this commit: cvs rdiff -u -r1.28 -r1.29 src/sys/arch/alpha/common/shared_intr.c cvs rdiff -u -r1.83 -r1.84 src/sys/arch/alpha/include/intr.h cvs rdiff -u -r1.23 -r1.24 src/sys/arch/alpha/include/pci_machdep.h cvs rdiff -u -r1.15 -r1.16 src/sys/arch/alpha/jensenio/jensenio_intr.c cvs rdiff -u -r1.29 -r1.30 src/sys/arch/alpha/pci/pci_1000.c cvs rdiff -u -r1.31 -r1.32 src/sys/arch/alpha/pci/pci_1000a.c \ src/sys/arch/alpha/pci/pci_6600.c src/sys/arch/alpha/pci/pci_machdep.c cvs rdiff -u -r1.16 -r1.17 src/sys/arch/alpha/pci/pci_2100_a500.c cvs rdiff -u -r1.40 -r1.41 src/sys/arch/alpha/pci/pci_550.c cvs rdiff -u -r1.48 -r1.49 src/sys/arch/alpha/pci/pci_eb164.c cvs rdiff -u -r1.27 -r1.28 src/sys/arch/alpha/pci/pci_eb64plus.c \ src/sys/arch/alpha/pci/pci_eb66.c cvs rdiff -u -r1.57 -r1.58 src/sys/arch/alpha/pci/pci_kn20aa.c cvs rdiff -u -r1.41 -r1.42 src/sys/arch/alpha/pci/pci_kn300.c cvs rdiff -u -r1.50 -r1.51 src/sys/arch/alpha/pci/sio_pic.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/alpha/common/shared_intr.c diff -u src/sys/arch/alpha/common/shared_intr.c:1.28 src/sys/arch/alpha/common/shared_intr.c:1.29 --- src/sys/arch/alpha/common/shared_intr.c:1.28 Fri Jun 25 18:08:34 2021 +++ src/sys/arch/alpha/common/shared_intr.c Sun Jul 4 22:36:43 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: shared_intr.c,v 1.28 2021/06/25 18:08:34 thorpej Exp $ */ +/* $NetBSD: shared_intr.c,v 1.29 2021/07/04 22:36:43 thorpej Exp $ */ /* * Copyright (c) 2020 The NetBSD Foundation, Inc. @@ -62,7 +62,7 @@ #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */ -__KERNEL_RCSID(0, "$NetBSD: shared_intr.c,v 1.28 2021/06/25 18:08:34 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: shared_intr.c,v 1.29 2021/07/04 22:36:43 thorpej Exp $"); #include <sys/param.h> #include <sys/kernel.h> @@ -96,25 +96,23 @@ intr_typename(int type) } struct alpha_shared_intr * -alpha_shared_intr_alloc(unsigned int n, unsigned int namesize) +alpha_shared_intr_alloc(unsigned int n) { struct alpha_shared_intr *intr; unsigned int i; + KASSERT(n != 0); + intr = kmem_alloc(n * sizeof(*intr), KM_SLEEP); for (i = 0; i < n; i++) { TAILQ_INIT(&intr[i].intr_q); intr[i].intr_sharetype = IST_NONE; intr[i].intr_dfltsharetype = IST_NONE; intr[i].intr_nstrays = 0; - intr[i].intr_maxstrays = 5; + intr[i].intr_maxstrays = 0; intr[i].intr_private = NULL; intr[i].intr_cpu = NULL; - if (namesize != 0) { - intr[i].intr_string = kmem_zalloc(namesize, KM_SLEEP); - } else { - intr[i].intr_string = NULL; - } + intr[i].intr_string = kmem_asprintf("irq %u", i); } return (intr); @@ -492,7 +490,16 @@ alpha_shared_intr_evcnt(struct alpha_sha return (&intr[num].intr_evcnt); } -char * +void +alpha_shared_intr_set_string(struct alpha_shared_intr *intr, + unsigned int num, char *str) +{ + char *ostr = intr[num].intr_string; + intr[num].intr_string = str; + kmem_strfree(ostr); +} + +const char * alpha_shared_intr_string(struct alpha_shared_intr *intr, unsigned int num) { Index: src/sys/arch/alpha/include/intr.h diff -u src/sys/arch/alpha/include/intr.h:1.83 src/sys/arch/alpha/include/intr.h:1.84 --- src/sys/arch/alpha/include/intr.h:1.83 Sat Oct 10 03:05:04 2020 +++ src/sys/arch/alpha/include/intr.h Sun Jul 4 22:36:43 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: intr.h,v 1.83 2020/10/10 03:05:04 thorpej Exp $ */ +/* $NetBSD: intr.h,v 1.84 2021/07/04 22:36:43 thorpej Exp $ */ /*- * Copyright (c) 2000, 2001, 2002 The NetBSD Foundation, Inc. @@ -227,7 +227,7 @@ struct alpha_shared_intr { ((asi)[num].intr_maxstrays != 0 && \ (asi)[num].intr_nstrays == (asi)[num].intr_maxstrays) -struct alpha_shared_intr *alpha_shared_intr_alloc(unsigned int, unsigned int); +struct alpha_shared_intr *alpha_shared_intr_alloc(unsigned int); int alpha_shared_intr_dispatch(struct alpha_shared_intr *, unsigned int); struct alpha_shared_intrhand * @@ -262,7 +262,9 @@ void alpha_shared_intr_set_cpu(struct al struct cpu_info * alpha_shared_intr_get_cpu(struct alpha_shared_intr *, unsigned int); -char *alpha_shared_intr_string(struct alpha_shared_intr *, +void alpha_shared_intr_set_string(struct alpha_shared_intr *, + unsigned int, char *); +const char *alpha_shared_intr_string(struct alpha_shared_intr *, unsigned int); struct evcnt *alpha_shared_intr_evcnt(struct alpha_shared_intr *, unsigned int); Index: src/sys/arch/alpha/include/pci_machdep.h diff -u src/sys/arch/alpha/include/pci_machdep.h:1.23 src/sys/arch/alpha/include/pci_machdep.h:1.24 --- src/sys/arch/alpha/include/pci_machdep.h:1.23 Sat Jun 19 16:59:07 2021 +++ src/sys/arch/alpha/include/pci_machdep.h Sun Jul 4 22:36:43 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: pci_machdep.h,v 1.23 2021/06/19 16:59:07 thorpej Exp $ */ +/* $NetBSD: pci_machdep.h,v 1.24 2021/07/04 22:36:43 thorpej Exp $ */ /* * Copyright (c) 1996 Carnegie-Mellon University. @@ -136,6 +136,7 @@ void device_pci_register(device_t, void void alpha_pci_intr_init(void *, bus_space_tag_t, bus_space_tag_t, pci_chipset_tag_t); +void alpha_pci_intr_alloc(pci_chipset_tag_t, unsigned int); int alpha_pci_generic_intr_map(const struct pci_attach_args *, pci_intr_handle_t *); Index: src/sys/arch/alpha/jensenio/jensenio_intr.c diff -u src/sys/arch/alpha/jensenio/jensenio_intr.c:1.15 src/sys/arch/alpha/jensenio/jensenio_intr.c:1.16 --- src/sys/arch/alpha/jensenio/jensenio_intr.c:1.15 Fri Jun 25 18:08:34 2021 +++ src/sys/arch/alpha/jensenio/jensenio_intr.c Sun Jul 4 22:36:43 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: jensenio_intr.c,v 1.15 2021/06/25 18:08:34 thorpej Exp $ */ +/* $NetBSD: jensenio_intr.c,v 1.16 2021/07/04 22:36:43 thorpej Exp $ */ /*- * Copyright (c) 1999, 2000 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */ -__KERNEL_RCSID(0, "$NetBSD: jensenio_intr.c,v 1.15 2021/06/25 18:08:34 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: jensenio_intr.c,v 1.16 2021/07/04 22:36:43 thorpej Exp $"); #include <sys/types.h> #include <sys/param.h> @@ -66,7 +66,6 @@ static void jensenio_eisa_intr_disestab static int jensenio_eisa_intr_alloc(void *, int, int, int *); #define JENSEN_MAX_IRQ 16 -#define JENSEN_MAX_IRQ_STR 16 static struct alpha_shared_intr *jensenio_eisa_intr; @@ -111,27 +110,23 @@ jensenio_intr_init(struct jensenio_confi { eisa_chipset_tag_t ec = &jcp->jc_ec; isa_chipset_tag_t ic = &jcp->jc_ic; - char *cp; + struct evcnt *ev; + const char *cp; int i; pic_iot = &jcp->jc_eisa_iot; jensenio_pic_init(); - jensenio_eisa_intr = alpha_shared_intr_alloc(JENSEN_MAX_IRQ, - JENSEN_MAX_IRQ_STR); + jensenio_eisa_intr = alpha_shared_intr_alloc(JENSEN_MAX_IRQ); for (i = 0; i < JENSEN_MAX_IRQ; i++) { alpha_shared_intr_set_dfltsharetype(jensenio_eisa_intr, i, jensenio_intr_deftype[i]); - /* Don't bother with stray interrupts. */ - alpha_shared_intr_set_maxstrays(jensenio_eisa_intr, - i, 0); + ev = alpha_shared_intr_evcnt(jensenio_eisa_intr, i); cp = alpha_shared_intr_string(jensenio_eisa_intr, i); - snprintf(cp, JENSEN_MAX_IRQ_STR, "irq %d", i); - evcnt_attach_dynamic(alpha_shared_intr_evcnt( - jensenio_eisa_intr, i), EVCNT_TYPE_INTR, - NULL, "eisa", cp); + + evcnt_attach_dynamic(ev, EVCNT_TYPE_INTR, NULL, "eisa", cp); } /* Index: src/sys/arch/alpha/pci/pci_1000.c diff -u src/sys/arch/alpha/pci/pci_1000.c:1.29 src/sys/arch/alpha/pci/pci_1000.c:1.30 --- src/sys/arch/alpha/pci/pci_1000.c:1.29 Fri Jun 25 18:08:34 2021 +++ src/sys/arch/alpha/pci/pci_1000.c Sun Jul 4 22:36:43 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: pci_1000.c,v 1.29 2021/06/25 18:08:34 thorpej Exp $ */ +/* $NetBSD: pci_1000.c,v 1.30 2021/07/04 22:36:43 thorpej Exp $ */ /* * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -60,7 +60,7 @@ #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */ -__KERNEL_RCSID(0, "$NetBSD: pci_1000.c,v 1.29 2021/06/25 18:08:34 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pci_1000.c,v 1.30 2021/07/04 22:36:43 thorpej Exp $"); #include <sys/types.h> #include <sys/param.h> @@ -99,8 +99,6 @@ static void pci_1000_pickintr(void *core, bus_space_tag_t iot, bus_space_tag_t memt, pci_chipset_tag_t pc) { - char *cp; - int i; another_mystery_icu_iot = iot; @@ -116,9 +114,6 @@ pci_1000_pickintr(void *core, bus_space_ pc->pc_pciide_compat_intr_establish = NULL; -#define PCI_1000_IRQ_STR 8 - pc->pc_shared_intrs = - alpha_shared_intr_alloc(PCI_NIRQ, PCI_1000_IRQ_STR); pc->pc_intr_desc = "dec 1000"; pc->pc_vecbase = 0x900; pc->pc_nirq = PCI_NIRQ; @@ -126,18 +121,10 @@ pci_1000_pickintr(void *core, bus_space_ pc->pc_intr_enable = dec_1000_enable_intr; pc->pc_intr_disable = dec_1000_disable_intr; - for (i = 0; i < PCI_NIRQ; i++) { - alpha_shared_intr_set_maxstrays(pc->pc_shared_intrs, i, - PCI_STRAY_MAX); - - cp = alpha_shared_intr_string(pc->pc_shared_intrs, i); - snprintf(cp, PCI_1000_IRQ_STR, "irq %d", i); - evcnt_attach_dynamic(alpha_shared_intr_evcnt( - pc->pc_shared_intrs, i), EVCNT_TYPE_INTR, NULL, - pc->pc_intr_desc, cp); - } - pci_1000_imi(); + + alpha_pci_intr_alloc(pc, PCI_STRAY_MAX); + #if NSIO > 0 || NPCEB > 0 sio_intr_setup(pc, iot); #endif Index: src/sys/arch/alpha/pci/pci_1000a.c diff -u src/sys/arch/alpha/pci/pci_1000a.c:1.31 src/sys/arch/alpha/pci/pci_1000a.c:1.32 --- src/sys/arch/alpha/pci/pci_1000a.c:1.31 Fri Jun 25 18:08:34 2021 +++ src/sys/arch/alpha/pci/pci_1000a.c Sun Jul 4 22:36:43 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: pci_1000a.c,v 1.31 2021/06/25 18:08:34 thorpej Exp $ */ +/* $NetBSD: pci_1000a.c,v 1.32 2021/07/04 22:36:43 thorpej Exp $ */ /* * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -60,7 +60,7 @@ #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */ -__KERNEL_RCSID(0, "$NetBSD: pci_1000a.c,v 1.31 2021/06/25 18:08:34 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pci_1000a.c,v 1.32 2021/07/04 22:36:43 thorpej Exp $"); #include <sys/types.h> #include <sys/param.h> @@ -102,8 +102,6 @@ static void pci_1000a_pickintr(void *core, bus_space_tag_t iot, bus_space_tag_t memt, pci_chipset_tag_t pc) { - char *cp; - int i; mystery_icu_iot = iot; @@ -120,9 +118,6 @@ pci_1000a_pickintr(void *core, bus_space pc->pc_pciide_compat_intr_establish = NULL; -#define PCI_1000A_IRQ_STR 8 - pc->pc_shared_intrs = alpha_shared_intr_alloc(PCI_NIRQ, - PCI_1000A_IRQ_STR); pc->pc_intr_desc = "dec 1000a"; pc->pc_vecbase = 0x900; pc->pc_nirq = PCI_NIRQ; @@ -130,18 +125,10 @@ pci_1000a_pickintr(void *core, bus_space pc->pc_intr_enable = dec_1000a_enable_intr; pc->pc_intr_disable = dec_1000a_disable_intr; - for (i = 0; i < PCI_NIRQ; i++) { - alpha_shared_intr_set_maxstrays(pc->pc_shared_intrs, i, - PCI_STRAY_MAX); - - cp = alpha_shared_intr_string(pc->pc_shared_intrs, i); - snprintf(cp, PCI_1000A_IRQ_STR, "irq %d", i); - evcnt_attach_dynamic(alpha_shared_intr_evcnt( - pc->pc_shared_intrs, i), EVCNT_TYPE_INTR, NULL, - pc->pc_intr_desc, cp); - } - pci_1000a_imi(); + + alpha_pci_intr_alloc(pc, PCI_STRAY_MAX); + #if NSIO > 0 || NPCEB > 0 sio_intr_setup(pc, iot); #endif Index: src/sys/arch/alpha/pci/pci_6600.c diff -u src/sys/arch/alpha/pci/pci_6600.c:1.31 src/sys/arch/alpha/pci/pci_6600.c:1.32 --- src/sys/arch/alpha/pci/pci_6600.c:1.31 Fri Jun 25 18:08:34 2021 +++ src/sys/arch/alpha/pci/pci_6600.c Sun Jul 4 22:36:43 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: pci_6600.c,v 1.31 2021/06/25 18:08:34 thorpej Exp $ */ +/* $NetBSD: pci_6600.c,v 1.32 2021/07/04 22:36:43 thorpej Exp $ */ /*- * Copyright (c) 1999 by Ross Harvey. All rights reserved. @@ -33,7 +33,7 @@ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: pci_6600.c,v 1.31 2021/06/25 18:08:34 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pci_6600.c,v 1.32 2021/07/04 22:36:43 thorpej Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -96,6 +96,7 @@ static void dec_6600_intr_enable(pci_chi static void dec_6600_intr_disable(pci_chipset_tag_t, int irq); static void dec_6600_intr_set_affinity(pci_chipset_tag_t, int, struct cpu_info *); +static void dec_6600_intr_program(pci_chipset_tag_t); static void dec_6600_intr_redistribute(void); @@ -110,8 +111,6 @@ static void pci_6600_pickintr(void *core, bus_space_tag_t iot, bus_space_tag_t memt, pci_chipset_tag_t pc) { - char *cp; - int i; struct cpu_info *ci; CPU_INFO_ITERATOR cii; @@ -153,21 +152,11 @@ pci_6600_pickintr(void *core, bus_space_ __BITS(0,63); pc->pc_pciide_compat_intr_establish = dec_6600_pciide_compat_intr_establish; -#define PCI_6600_IRQ_STR 8 - pc->pc_shared_intrs = alpha_shared_intr_alloc(PCI_NIRQ, - PCI_6600_IRQ_STR); - for (i = 0; i < PCI_NIRQ; i++) { - alpha_shared_intr_set_maxstrays(pc->pc_shared_intrs, i, - PCI_STRAY_MAX); - alpha_shared_intr_set_private(pc->pc_shared_intrs, i, - sioprimary); - - cp = alpha_shared_intr_string(pc->pc_shared_intrs, i); - snprintf(cp, PCI_6600_IRQ_STR, "irq %d", i); - evcnt_attach_dynamic(alpha_shared_intr_evcnt( - pc->pc_shared_intrs, i), EVCNT_TYPE_INTR, NULL, - pc->pc_intr_desc, cp); - } + + KASSERT(dec_6600_intr_enables == 0); + dec_6600_intr_program(pc); + + alpha_pci_intr_alloc(pc, PCI_STRAY_MAX); #if NSIO sio_intr_setup(pc, iot); Index: src/sys/arch/alpha/pci/pci_machdep.c diff -u src/sys/arch/alpha/pci/pci_machdep.c:1.31 src/sys/arch/alpha/pci/pci_machdep.c:1.32 --- src/sys/arch/alpha/pci/pci_machdep.c:1.31 Fri Jun 25 18:08:34 2021 +++ src/sys/arch/alpha/pci/pci_machdep.c Sun Jul 4 22:36:43 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: pci_machdep.c,v 1.31 2021/06/25 18:08:34 thorpej Exp $ */ +/* $NetBSD: pci_machdep.c,v 1.32 2021/07/04 22:36:43 thorpej Exp $ */ /*- * Copyright (c) 2020 The NetBSD Foundation, Inc. @@ -62,7 +62,7 @@ #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */ -__KERNEL_RCSID(0, "$NetBSD: pci_machdep.c,v 1.31 2021/06/25 18:08:34 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pci_machdep.c,v 1.32 2021/07/04 22:36:43 thorpej Exp $"); #include <sys/types.h> #include <sys/param.h> @@ -176,6 +176,29 @@ alpha_pci_intr_init(void *core, bus_spac panic("%s: unknown systype %d", __func__, cputype); } +void +alpha_pci_intr_alloc(pci_chipset_tag_t pc, unsigned int maxstrays) +{ + unsigned int i; + struct evcnt *ev; + const char *cp; + + pc->pc_shared_intrs = alpha_shared_intr_alloc(pc->pc_nirq); + + for (i = 0; i < pc->pc_nirq; i++) { + alpha_shared_intr_set_maxstrays(pc->pc_shared_intrs, i, + maxstrays); + alpha_shared_intr_set_private(pc->pc_shared_intrs, i, + pc->pc_intr_v); + + ev = alpha_shared_intr_evcnt(pc->pc_shared_intrs, i); + cp = alpha_shared_intr_string(pc->pc_shared_intrs, i); + + evcnt_attach_dynamic(ev, EVCNT_TYPE_INTR, NULL, + pc->pc_intr_desc, cp); + } +} + int alpha_pci_generic_intr_map(const struct pci_attach_args * const pa, pci_intr_handle_t * const ihp) Index: src/sys/arch/alpha/pci/pci_2100_a500.c diff -u src/sys/arch/alpha/pci/pci_2100_a500.c:1.16 src/sys/arch/alpha/pci/pci_2100_a500.c:1.17 --- src/sys/arch/alpha/pci/pci_2100_a500.c:1.16 Fri Jun 25 18:08:34 2021 +++ src/sys/arch/alpha/pci/pci_2100_a500.c Sun Jul 4 22:36:43 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: pci_2100_a500.c,v 1.16 2021/06/25 18:08:34 thorpej Exp $ */ +/* $NetBSD: pci_2100_a500.c,v 1.17 2021/07/04 22:36:43 thorpej Exp $ */ /*- * Copyright (c) 1999 The NetBSD Foundation, Inc. @@ -31,13 +31,14 @@ #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */ -__KERNEL_RCSID(0, "$NetBSD: pci_2100_a500.c,v 1.16 2021/06/25 18:08:34 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pci_2100_a500.c,v 1.17 2021/07/04 22:36:43 thorpej Exp $"); #include <sys/types.h> #include <sys/param.h> #include <sys/time.h> #include <sys/systm.h> #include <sys/errno.h> +#include <sys/kmem.h> #include <sys/malloc.h> #include <sys/device.h> #include <sys/cpu.h> @@ -188,6 +189,7 @@ pci_2100_a500_pickintr(void *core, bus_s pci_chipset_tag_t pc) { struct ttwoga_config *tcp = core; + struct evcnt *ev; char *cp; int i; @@ -202,29 +204,30 @@ pci_2100_a500_pickintr(void *core, bus_s /* Not supported on T2. */ pc->pc_pciide_compat_intr_establish = NULL; -#define PCI_2100_IRQ_STR 8 - pc->pc_shared_intrs = alpha_shared_intr_alloc(SABLE_MAX_IRQ, - PCI_2100_IRQ_STR); - pc->pc_intr_desc = "T2"; - /* 64 16-byte vectors per hose. */ pc->pc_vecbase = 0x800 + ((64 * 16) * tcp->tc_hose); pc->pc_nirq = SABLE_MAX_IRQ; - for (i = 0; i < SABLE_MAX_IRQ; i++) { - alpha_shared_intr_set_dfltsharetype(pc->pc_shared_intrs, - i, tcp->tc_hose == 0 ? - dec_2100_a500_intr_deftype[i] : IST_LEVEL); - alpha_shared_intr_set_maxstrays(pc->pc_shared_intrs, - i, PCI_STRAY_MAX); - - cp = alpha_shared_intr_string(pc->pc_shared_intrs, i); - snprintf(cp, PCI_2100_IRQ_STR, "irq %d", T2_IRQ_IS_EISA(i) ? - i - T2_IRQ_EISA_START : i); - evcnt_attach_dynamic(alpha_shared_intr_evcnt( - pc->pc_shared_intrs, i), EVCNT_TYPE_INTR, NULL, - T2_IRQ_IS_EISA(i) ? "eisa" : "T2", cp); + pc->pc_shared_intrs = alpha_shared_intr_alloc(pc->pc_nirq); + + for (i = 0; i < pc->pc_nirq; i++) { + alpha_shared_intr_set_maxstrays(pc->pc_shared_intrs, i, + PCI_STRAY_MAX); + alpha_shared_intr_set_private(pc->pc_shared_intrs, i, + pc->pc_intr_v); + alpha_shared_intr_set_dfltsharetype(pc->pc_shared_intrs, i, + tcp->tc_hose == 0 ? dec_2100_a500_intr_deftype[i] + : IST_LEVEL); + + ev = alpha_shared_intr_evcnt(pc->pc_shared_intrs, i); + cp = kmem_asprintf("irq %d", + T2_IRQ_IS_EISA(i) ? i - T2_IRQ_EISA_START : i); + + alpha_shared_intr_set_string(pc->pc_shared_intrs, i, cp); + + evcnt_attach_dynamic(ev, EVCNT_TYPE_INTR, NULL, + T2_IRQ_IS_EISA(i) ? "eisa" : pc->pc_intr_desc, cp); } /* Index: src/sys/arch/alpha/pci/pci_550.c diff -u src/sys/arch/alpha/pci/pci_550.c:1.40 src/sys/arch/alpha/pci/pci_550.c:1.41 --- src/sys/arch/alpha/pci/pci_550.c:1.40 Fri Jun 25 18:08:34 2021 +++ src/sys/arch/alpha/pci/pci_550.c Sun Jul 4 22:36:43 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: pci_550.c,v 1.40 2021/06/25 18:08:34 thorpej Exp $ */ +/* $NetBSD: pci_550.c,v 1.41 2021/07/04 22:36:43 thorpej Exp $ */ /*- * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc. @@ -59,7 +59,7 @@ #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */ -__KERNEL_RCSID(0, "$NetBSD: pci_550.c,v 1.40 2021/06/25 18:08:34 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pci_550.c,v 1.41 2021/07/04 22:36:43 thorpej Exp $"); #include <sys/types.h> #include <sys/param.h> @@ -121,7 +121,6 @@ static void pci_550_pickintr(void *core, bus_space_tag_t iot, bus_space_tag_t memt, pci_chipset_tag_t pc) { - char *cp; int i; pc->pc_intr_v = core; @@ -134,17 +133,6 @@ pci_550_pickintr(void *core, bus_space_t pc->pc_pciide_compat_intr_establish = sio_pciide_compat_intr_establish; - /* - * DEC 550's interrupts are enabled via the Pyxis interrupt - * mask register. Nothing to map. - */ - - for (i = 0; i < DEC_550_MAX_IRQ; i++) - dec_550_intr_disable(pc, i); - -#define PCI_550_IRQ_STR 8 - pc->pc_shared_intrs = alpha_shared_intr_alloc(DEC_550_MAX_IRQ, - PCI_550_IRQ_STR); pc->pc_intr_desc = "dec 550"; pc->pc_vecbase = 0x900; pc->pc_nirq = DEC_550_MAX_IRQ; @@ -153,17 +141,11 @@ pci_550_pickintr(void *core, bus_space_t pc->pc_intr_disable = dec_550_intr_disable; for (i = 0; i < DEC_550_MAX_IRQ; i++) { - alpha_shared_intr_set_maxstrays(pc->pc_shared_intrs, i, - PCI_STRAY_MAX); - alpha_shared_intr_set_private(pc->pc_shared_intrs, i, core); - - cp = alpha_shared_intr_string(pc->pc_shared_intrs, i); - snprintf(cp, PCI_550_IRQ_STR, "irq %d", i); - evcnt_attach_dynamic(alpha_shared_intr_evcnt( - pc->pc_shared_intrs, i), EVCNT_TYPE_INTR, NULL, - pc->pc_intr_desc, cp); + dec_550_intr_disable(pc, i); } + alpha_pci_intr_alloc(pc, PCI_STRAY_MAX); + #if NSIO sio_intr_setup(pc, iot); #endif Index: src/sys/arch/alpha/pci/pci_eb164.c diff -u src/sys/arch/alpha/pci/pci_eb164.c:1.48 src/sys/arch/alpha/pci/pci_eb164.c:1.49 --- src/sys/arch/alpha/pci/pci_eb164.c:1.48 Fri Jun 25 18:08:34 2021 +++ src/sys/arch/alpha/pci/pci_eb164.c Sun Jul 4 22:36:43 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: pci_eb164.c,v 1.48 2021/06/25 18:08:34 thorpej Exp $ */ +/* $NetBSD: pci_eb164.c,v 1.49 2021/07/04 22:36:43 thorpej Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -59,7 +59,7 @@ #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */ -__KERNEL_RCSID(0, "$NetBSD: pci_eb164.c,v 1.48 2021/06/25 18:08:34 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pci_eb164.c,v 1.49 2021/07/04 22:36:43 thorpej Exp $"); #include <sys/types.h> #include <sys/param.h> @@ -105,7 +105,6 @@ pci_eb164_pickintr(void *core, bus_space pci_chipset_tag_t pc) { struct cia_config *ccp = core; - char *cp; int i; pc->pc_intr_v = core; @@ -122,12 +121,7 @@ pci_eb164_pickintr(void *core, bus_space if (bus_space_map(eb164_intrgate_iot, 0x804, 3, 0, &eb164_intrgate_ioh) != 0) panic("pci_eb164_pickintr: couldn't map interrupt PLD"); - for (i = 0; i < EB164_MAX_IRQ; i++) - eb164_intr_disable(pc, i); -#define PCI_EB164_IRQ_STR 8 - pc->pc_shared_intrs = alpha_shared_intr_alloc(EB164_MAX_IRQ, - PCI_EB164_IRQ_STR); pc->pc_intr_desc = "eb164"; pc->pc_vecbase = 0x900; pc->pc_nirq = EB164_MAX_IRQ; @@ -136,21 +130,16 @@ pci_eb164_pickintr(void *core, bus_space pc->pc_intr_disable = eb164_intr_disable; for (i = 0; i < EB164_MAX_IRQ; i++) { - /* - * Systems with a Pyxis seem to have problems with - * stray interrupts, so just ignore them. Sigh, - * I hate buggy hardware. - */ - alpha_shared_intr_set_maxstrays(pc->pc_shared_intrs, i, - (ccp->cc_flags & CCF_ISPYXIS) ? 0 : PCI_STRAY_MAX); - - cp = alpha_shared_intr_string(pc->pc_shared_intrs, i); - snprintf(cp, PCI_EB164_IRQ_STR, "irq %d", i); - evcnt_attach_dynamic(alpha_shared_intr_evcnt( - pc->pc_shared_intrs, i), EVCNT_TYPE_INTR, NULL, - pc->pc_intr_desc, cp); + eb164_intr_disable(pc, i); } + /* + * Systems with a Pyxis seem to have problems with + * stray interrupts, so just ignore them. + */ + alpha_pci_intr_alloc(pc, + (ccp->cc_flags & CCF_ISPYXIS) ? 0 : PCI_STRAY_MAX); + #if NSIO sio_intr_setup(pc, iot); eb164_intr_enable(pc, EB164_SIO_IRQ); Index: src/sys/arch/alpha/pci/pci_eb64plus.c diff -u src/sys/arch/alpha/pci/pci_eb64plus.c:1.27 src/sys/arch/alpha/pci/pci_eb64plus.c:1.28 --- src/sys/arch/alpha/pci/pci_eb64plus.c:1.27 Fri Jun 25 18:08:34 2021 +++ src/sys/arch/alpha/pci/pci_eb64plus.c Sun Jul 4 22:36:43 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: pci_eb64plus.c,v 1.27 2021/06/25 18:08:34 thorpej Exp $ */ +/* $NetBSD: pci_eb64plus.c,v 1.28 2021/07/04 22:36:43 thorpej Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -59,7 +59,7 @@ #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */ -__KERNEL_RCSID(0, "$NetBSD: pci_eb64plus.c,v 1.27 2021/06/25 18:08:34 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pci_eb64plus.c,v 1.28 2021/07/04 22:36:43 thorpej Exp $"); #include <sys/types.h> #include <sys/param.h> @@ -98,7 +98,6 @@ static void pci_eb64plus_pickintr(void *core, bus_space_tag_t iot, bus_space_tag_t memt, pci_chipset_tag_t pc) { - char *cp; int i; pc->pc_intr_v = core; @@ -115,12 +114,7 @@ pci_eb64plus_pickintr(void *core, bus_sp if (bus_space_map(eb64plus_intrgate_iot, 0x804, 3, 0, &eb64plus_intrgate_ioh) != 0) panic("pci_eb64plus_pickintr: couldn't map interrupt PLD"); - for (i = 0; i < EB64PLUS_MAX_IRQ; i++) - eb64plus_intr_disable(pc, i); -#define PCI_EB64PLUS_IRQ_STR 8 - pc->pc_shared_intrs = alpha_shared_intr_alloc(EB64PLUS_MAX_IRQ, - PCI_EB64PLUS_IRQ_STR); pc->pc_intr_desc = "eb64+"; pc->pc_vecbase = 0x900; pc->pc_nirq = EB64PLUS_MAX_IRQ; @@ -129,16 +123,11 @@ pci_eb64plus_pickintr(void *core, bus_sp pc->pc_intr_disable = eb64plus_intr_disable; for (i = 0; i < EB64PLUS_MAX_IRQ; i++) { - alpha_shared_intr_set_maxstrays(pc->pc_shared_intrs, i, - PCI_STRAY_MAX); - - cp = alpha_shared_intr_string(pc->pc_shared_intrs, i); - snprintf(cp, PCI_EB64PLUS_IRQ_STR, "irq %d", i); - evcnt_attach_dynamic(alpha_shared_intr_evcnt( - pc->pc_shared_intrs, i), EVCNT_TYPE_INTR, NULL, - pc->pc_intr_desc, cp); + eb64plus_intr_disable(pc, i); } + alpha_pci_intr_alloc(pc, PCI_STRAY_MAX); + #if NSIO sio_intr_setup(pc, iot); #endif Index: src/sys/arch/alpha/pci/pci_eb66.c diff -u src/sys/arch/alpha/pci/pci_eb66.c:1.27 src/sys/arch/alpha/pci/pci_eb66.c:1.28 --- src/sys/arch/alpha/pci/pci_eb66.c:1.27 Fri Jun 25 18:08:34 2021 +++ src/sys/arch/alpha/pci/pci_eb66.c Sun Jul 4 22:36:43 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: pci_eb66.c,v 1.27 2021/06/25 18:08:34 thorpej Exp $ */ +/* $NetBSD: pci_eb66.c,v 1.28 2021/07/04 22:36:43 thorpej Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -59,7 +59,7 @@ #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */ -__KERNEL_RCSID(0, "$NetBSD: pci_eb66.c,v 1.27 2021/06/25 18:08:34 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pci_eb66.c,v 1.28 2021/07/04 22:36:43 thorpej Exp $"); #include <sys/types.h> #include <sys/param.h> @@ -98,7 +98,6 @@ static void pci_eb66_pickintr(void *core, bus_space_tag_t iot, bus_space_tag_t memt, pci_chipset_tag_t pc) { - char *cp; int i; pc->pc_intr_v = core; @@ -115,12 +114,7 @@ pci_eb66_pickintr(void *core, bus_space_ if (bus_space_map(eb66_intrgate_iot, 0x804, 3, 0, &eb66_intrgate_ioh) != 0) panic("pci_eb66_pickintr: couldn't map interrupt PLD"); - for (i = 0; i < EB66_MAX_IRQ; i++) - eb66_intr_disable(pc, i); -#define PCI_EB66_IRQ_STR 8 - pc->pc_shared_intrs = alpha_shared_intr_alloc(EB66_MAX_IRQ, - PCI_EB66_IRQ_STR); pc->pc_intr_desc = "eb66"; pc->pc_vecbase = 0x900; pc->pc_nirq = EB66_MAX_IRQ; @@ -129,16 +123,11 @@ pci_eb66_pickintr(void *core, bus_space_ pc->pc_intr_disable = eb66_intr_disable; for (i = 0; i < EB66_MAX_IRQ; i++) { - alpha_shared_intr_set_maxstrays(pc->pc_shared_intrs, i, - PCI_STRAY_MAX); - - cp = alpha_shared_intr_string(pc->pc_shared_intrs, i); - snprintf(cp, PCI_EB66_IRQ_STR, "irq %d", i); - evcnt_attach_dynamic(alpha_shared_intr_evcnt( - pc->pc_shared_intrs, i), EVCNT_TYPE_INTR, NULL, - pc->pc_intr_desc, cp); + eb66_intr_disable(pc, i); } + alpha_pci_intr_alloc(pc, PCI_STRAY_MAX); + #if NSIO sio_intr_setup(pc, iot); #endif Index: src/sys/arch/alpha/pci/pci_kn20aa.c diff -u src/sys/arch/alpha/pci/pci_kn20aa.c:1.57 src/sys/arch/alpha/pci/pci_kn20aa.c:1.58 --- src/sys/arch/alpha/pci/pci_kn20aa.c:1.57 Fri Jun 25 18:08:34 2021 +++ src/sys/arch/alpha/pci/pci_kn20aa.c Sun Jul 4 22:36:43 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: pci_kn20aa.c,v 1.57 2021/06/25 18:08:34 thorpej Exp $ */ +/* $NetBSD: pci_kn20aa.c,v 1.58 2021/07/04 22:36:43 thorpej Exp $ */ /* * Copyright (c) 1995, 1996 Carnegie-Mellon University. @@ -29,7 +29,7 @@ #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */ -__KERNEL_RCSID(0, "$NetBSD: pci_kn20aa.c,v 1.57 2021/06/25 18:08:34 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pci_kn20aa.c,v 1.58 2021/07/04 22:36:43 thorpej Exp $"); #include <sys/types.h> #include <sys/param.h> @@ -69,7 +69,6 @@ pci_kn20aa_pickintr(void *core, bus_spac pci_chipset_tag_t pc) { int i; - char *cp; pc->pc_intr_v = core; pc->pc_intr_map = dec_kn20aa_intr_map; @@ -81,9 +80,6 @@ pci_kn20aa_pickintr(void *core, bus_spac /* Not supported on KN20AA. */ pc->pc_pciide_compat_intr_establish = NULL; -#define PCI_KN20AA_IRQ_STR 8 - pc->pc_shared_intrs = alpha_shared_intr_alloc(KN20AA_MAX_IRQ, - PCI_KN20AA_IRQ_STR); pc->pc_intr_desc = "kn20aa"; pc->pc_vecbase = 0x900; pc->pc_nirq = KN20AA_MAX_IRQ; @@ -92,16 +88,11 @@ pci_kn20aa_pickintr(void *core, bus_spac pc->pc_intr_disable = kn20aa_disable_intr; for (i = 0; i < KN20AA_MAX_IRQ; i++) { - alpha_shared_intr_set_maxstrays(pc->pc_shared_intrs, i, - PCI_STRAY_MAX); - - cp = alpha_shared_intr_string(pc->pc_shared_intrs, i); - snprintf(cp, PCI_KN20AA_IRQ_STR, "irq %d", i); - evcnt_attach_dynamic(alpha_shared_intr_evcnt( - pc->pc_shared_intrs, i), EVCNT_TYPE_INTR, NULL, - pc->pc_intr_desc, cp); + kn20aa_disable_intr(pc, i); } + alpha_pci_intr_alloc(pc, PCI_STRAY_MAX); + #if NSIO > 0 || NPCEB > 0 sio_intr_setup(pc, iot); kn20aa_enable_intr(pc, KN20AA_PCEB_IRQ); Index: src/sys/arch/alpha/pci/pci_kn300.c diff -u src/sys/arch/alpha/pci/pci_kn300.c:1.41 src/sys/arch/alpha/pci/pci_kn300.c:1.42 --- src/sys/arch/alpha/pci/pci_kn300.c:1.41 Fri Jun 25 18:08:34 2021 +++ src/sys/arch/alpha/pci/pci_kn300.c Sun Jul 4 22:36:43 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: pci_kn300.c,v 1.41 2021/06/25 18:08:34 thorpej Exp $ */ +/* $NetBSD: pci_kn300.c,v 1.42 2021/07/04 22:36:43 thorpej Exp $ */ /* * Copyright (c) 1998 by Matthew Jacob @@ -32,7 +32,7 @@ #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */ -__KERNEL_RCSID(0, "$NetBSD: pci_kn300.c,v 1.41 2021/06/25 18:08:34 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pci_kn300.c,v 1.42 2021/07/04 22:36:43 thorpej Exp $"); #include <sys/types.h> #include <sys/param.h> @@ -71,6 +71,7 @@ static void *dec_kn300_intr_establish(pc static void dec_kn300_intr_disestablish(pci_chipset_tag_t, void *); #define KN300_PCEB_IRQ 16 +#define KN300_STRAY_MAX 25 #define NPIN 4 #define NIRQ (MAX_MC_BUS * MCPCIA_PER_MCBUS * MCPCIA_MAXSLOT * NPIN) @@ -89,21 +90,23 @@ pci_kn300_pickintr(void *core, bus_space pci_chipset_tag_t pc) { struct mcpcia_config *ccp = core; - char *cp; + struct evcnt *ev; + const char *cp; if (kn300_pci_intr == NULL) { int g; -#define PCI_KN300_IRQ_STR 16 - kn300_pci_intr = alpha_shared_intr_alloc(NIRQ, - PCI_KN300_IRQ_STR); + kn300_pci_intr = alpha_shared_intr_alloc(NIRQ); for (g = 0; g < NIRQ; g++) { - alpha_shared_intr_set_maxstrays(kn300_pci_intr, g, 25); + alpha_shared_intr_set_maxstrays(kn300_pci_intr, g, + KN300_STRAY_MAX); + + ev = alpha_shared_intr_evcnt(kn300_pci_intr, g); cp = alpha_shared_intr_string(kn300_pci_intr, g); - snprintf(cp, PCI_KN300_IRQ_STR, "irq %d", g); - evcnt_attach_dynamic(alpha_shared_intr_evcnt( - kn300_pci_intr, g), EVCNT_TYPE_INTR, NULL, + + evcnt_attach_dynamic(ev, EVCNT_TYPE_INTR, NULL, "kn300", cp); + savirqs[g] = (char) -1; } } Index: src/sys/arch/alpha/pci/sio_pic.c diff -u src/sys/arch/alpha/pci/sio_pic.c:1.50 src/sys/arch/alpha/pci/sio_pic.c:1.51 --- src/sys/arch/alpha/pci/sio_pic.c:1.50 Fri Jun 25 18:08:34 2021 +++ src/sys/arch/alpha/pci/sio_pic.c Sun Jul 4 22:36:43 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: sio_pic.c,v 1.50 2021/06/25 18:08:34 thorpej Exp $ */ +/* $NetBSD: sio_pic.c,v 1.51 2021/07/04 22:36:43 thorpej Exp $ */ /*- * Copyright (c) 1998, 2000, 2020 The NetBSD Foundation, Inc. @@ -59,7 +59,7 @@ #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */ -__KERNEL_RCSID(0, "$NetBSD: sio_pic.c,v 1.50 2021/06/25 18:08:34 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sio_pic.c,v 1.51 2021/07/04 22:36:43 thorpej Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -322,7 +322,8 @@ sio_setirqstat(int irq, int enabled, int void sio_intr_setup(pci_chipset_tag_t pc, bus_space_tag_t iot) { - char *cp; + struct evcnt *ev; + const char *cp; int i; sio_iot = iot; @@ -349,8 +350,7 @@ sio_intr_setup(pci_chipset_tag_t pc, bus shutdownhook_establish(sio_intr_shutdown, 0); #endif -#define PCI_SIO_IRQ_STR 8 - sio_intr = alpha_shared_intr_alloc(ICU_LEN, PCI_SIO_IRQ_STR); + sio_intr = alpha_shared_intr_alloc(ICU_LEN); /* * set up initial values for interrupt enables. @@ -358,10 +358,10 @@ sio_intr_setup(pci_chipset_tag_t pc, bus for (i = 0; i < ICU_LEN; i++) { alpha_shared_intr_set_maxstrays(sio_intr, i, STRAY_MAX); + ev = alpha_shared_intr_evcnt(sio_intr, i); cp = alpha_shared_intr_string(sio_intr, i); - snprintf(cp, PCI_SIO_IRQ_STR, "irq %d", i); - evcnt_attach_dynamic(alpha_shared_intr_evcnt(sio_intr, i), - EVCNT_TYPE_INTR, NULL, "isa", cp); + + evcnt_attach_dynamic(ev, EVCNT_TYPE_INTR, NULL, "isa", cp); switch (i) { case 0: