Module Name: src Committed By: snj Date: Sat Jan 13 21:50:31 UTC 2018
Modified Files: src/sys/arch/x86/include [netbsd-8]: intr.h src/sys/arch/x86/pci [netbsd-8]: pci_intr_machdep.c src/sys/arch/x86/x86 [netbsd-8]: intr.c Log Message: Pull up following revision(s) (requested by knakahara in ticket #493): sys/arch/x86/include/intr.h: revision 1.53 sys/arch/x86/pci/pci_intr_machdep.c: revision 1.42 sys/arch/x86/x86/intr.c: revision 1.114 via patch fix "intrctl list" panic when ACPI is disabled. reviewed by cherry@n.o and tested by msaitoh@n.o, thanks. To generate a diff of this commit: cvs rdiff -u -r1.50 -r1.50.2.1 src/sys/arch/x86/include/intr.h cvs rdiff -u -r1.40 -r1.40.2.1 src/sys/arch/x86/pci/pci_intr_machdep.c cvs rdiff -u -r1.101 -r1.101.2.1 src/sys/arch/x86/x86/intr.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/x86/include/intr.h diff -u src/sys/arch/x86/include/intr.h:1.50 src/sys/arch/x86/include/intr.h:1.50.2.1 --- src/sys/arch/x86/include/intr.h:1.50 Tue May 23 08:54:39 2017 +++ src/sys/arch/x86/include/intr.h Sat Jan 13 21:50:31 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: intr.h,v 1.50 2017/05/23 08:54:39 nonaka Exp $ */ +/* $NetBSD: intr.h,v 1.50.2.1 2018/01/13 21:50:31 snj Exp $ */ /*- * Copyright (c) 1998, 2001, 2006, 2007, 2008 The NetBSD Foundation, Inc. @@ -199,6 +199,9 @@ int intr_find_mpmapping(int, int, intr_h struct pic *intr_findpic(int); void intr_printconfig(void); +#if !defined(XEN) +const char *intr_create_intrid(int, struct pic *, int, char *, size_t); +#endif /* XEN */ struct intrsource *intr_allocate_io_intrsource(const char *); void intr_free_io_intrsource(const char *); Index: src/sys/arch/x86/pci/pci_intr_machdep.c diff -u src/sys/arch/x86/pci/pci_intr_machdep.c:1.40 src/sys/arch/x86/pci/pci_intr_machdep.c:1.40.2.1 --- src/sys/arch/x86/pci/pci_intr_machdep.c:1.40 Thu Jun 1 02:45:08 2017 +++ src/sys/arch/x86/pci/pci_intr_machdep.c Sat Jan 13 21:50:31 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: pci_intr_machdep.c,v 1.40 2017/06/01 02:45:08 chs Exp $ */ +/* $NetBSD: pci_intr_machdep.c,v 1.40.2.1 2018/01/13 21:50:31 snj Exp $ */ /*- * Copyright (c) 1997, 1998, 2009 The NetBSD Foundation, Inc. @@ -73,7 +73,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: pci_intr_machdep.c,v 1.40 2017/06/01 02:45:08 chs Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pci_intr_machdep.c,v 1.40.2.1 2018/01/13 21:50:31 snj Exp $"); #include <sys/types.h> #include <sys/param.h> @@ -274,15 +274,42 @@ pci_intr_setattr(pci_chipset_tag_t pc, p } } +static int +pci_intr_find_intx_irq(pci_intr_handle_t ih, int *irq, struct pic **pic, + int *pin) +{ + + KASSERT(irq != NULL); + KASSERT(pic != NULL); + KASSERT(pin != NULL); + + *pic = &i8259_pic; + *pin = *irq = APIC_IRQ_LEGACY_IRQ(ih); + +#if NIOAPIC > 0 + if (ih & APIC_INT_VIA_APIC) { + struct ioapic_softc *ioapic; + + ioapic = ioapic_find(APIC_IRQ_APIC(ih)); + if (ioapic == NULL) + return ENOENT; + *pic = &ioapic->sc_pic; + *pin = APIC_IRQ_PIN(ih); + *irq = APIC_IRQ_LEGACY_IRQ(ih); + if (*irq < 0 || *irq >= NUM_LEGACY_IRQS) + *irq = -1; + } +#endif + + return 0; +} + static void * pci_intr_establish_xname_internal(pci_chipset_tag_t pc, pci_intr_handle_t ih, int level, int (*func)(void *), void *arg, const char *xname) { int pin, irq; struct pic *pic; -#if NIOAPIC > 0 - struct ioapic_softc *ioapic; -#endif bool mpsafe; pci_chipset_tag_t ipc; @@ -302,25 +329,13 @@ pci_intr_establish_xname_internal(pci_ch xname); } - pic = &i8259_pic; - pin = irq = APIC_IRQ_LEGACY_IRQ(ih); - mpsafe = ((ih & MPSAFE_MASK) != 0); - -#if NIOAPIC > 0 - if (ih & APIC_INT_VIA_APIC) { - ioapic = ioapic_find(APIC_IRQ_APIC(ih)); - if (ioapic == NULL) { - aprint_normal("pci_intr_establish: bad ioapic %d\n", - APIC_IRQ_APIC(ih)); - return NULL; - } - pic = &ioapic->sc_pic; - pin = APIC_IRQ_PIN(ih); - irq = APIC_IRQ_LEGACY_IRQ(ih); - if (irq < 0 || irq >= NUM_LEGACY_IRQS) - irq = -1; + if (pci_intr_find_intx_irq(ih, &irq, &pic, &pin)) { + aprint_normal("%s: bad pic %d\n", __func__, + APIC_IRQ_APIC(ih)); + return NULL; } -#endif + + mpsafe = ((ih & MPSAFE_MASK) != 0); return intr_establish_xname(irq, pic, pin, IST_LEVEL, level, func, arg, mpsafe, xname); @@ -377,6 +392,31 @@ pci_intr_type(pci_chipset_tag_t pc, pci_ } } +static const char * +x86_pci_intx_create_intrid(pci_chipset_tag_t pc, pci_intr_handle_t ih, char *buf, + size_t len) +{ +#if !defined(XEN) + int pin, irq; + struct pic *pic; + + KASSERT(!INT_VIA_MSI(ih)); + + pic = &i8259_pic; + pin = irq = APIC_IRQ_LEGACY_IRQ(ih); + + if (pci_intr_find_intx_irq(ih, &irq, &pic, &pin)) { + aprint_normal("%s: bad pic %d\n", __func__, + APIC_IRQ_APIC(ih)); + return NULL; + } + + return intr_create_intrid(irq, pic, pin, buf, len); +#else + return pci_intr_string(pc, ih, buf, len); +#endif /* !XEN */ +} + static void x86_pci_intx_release(pci_chipset_tag_t pc, pci_intr_handle_t *pih) { @@ -407,8 +447,11 @@ pci_intx_alloc(const struct pci_attach_a goto error; } - intrstr = pci_intr_string(pa->pa_pc, *handle, - intrstr_buf, sizeof(intrstr_buf)); + /* + * must be the same intrstr as intr_establish_xname() + */ + intrstr = x86_pci_intx_create_intrid(pa->pa_pc, *handle, intrstr_buf, + sizeof(intrstr_buf)); mutex_enter(&cpu_lock); isp = intr_allocate_io_intrsource(intrstr); mutex_exit(&cpu_lock); Index: src/sys/arch/x86/x86/intr.c diff -u src/sys/arch/x86/x86/intr.c:1.101 src/sys/arch/x86/x86/intr.c:1.101.2.1 --- src/sys/arch/x86/x86/intr.c:1.101 Thu Jun 1 02:45:08 2017 +++ src/sys/arch/x86/x86/intr.c Sat Jan 13 21:50:31 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: intr.c,v 1.101 2017/06/01 02:45:08 chs Exp $ */ +/* $NetBSD: intr.c,v 1.101.2.1 2018/01/13 21:50:31 snj Exp $ */ /*- * Copyright (c) 2007, 2008, 2009 The NetBSD Foundation, Inc. @@ -133,7 +133,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.101 2017/06/01 02:45:08 chs Exp $"); +__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.101.2.1 2018/01/13 21:50:31 snj Exp $"); #include "opt_intrdebug.h" #include "opt_multiprocessor.h" @@ -241,8 +241,6 @@ static void intr_redistribute_xc_s1(void static void intr_redistribute_xc_s2(void *, void *); static bool intr_redistribute(struct cpu_info *); -static const char *create_intrid(int, struct pic *, int, char *, size_t); - static struct intrsource *intr_get_io_intrsource(const char *); static void intr_free_io_intrsource_direct(struct intrsource *); static int intr_num_handlers(struct intrsource *); @@ -479,8 +477,8 @@ intr_scan_bus(int bus, int pin, intr_han * Create an interrupt id such as "ioapic0 pin 9". This interrupt id is used * by MI code and intrctl(8). */ -static const char * -create_intrid(int legacy_irq, struct pic *pic, int pin, char *buf, size_t len) +const char * +intr_create_intrid(int legacy_irq, struct pic *pic, int pin, char *buf, size_t len) { int ih; @@ -924,7 +922,7 @@ intr_establish_xname(int legacy_irq, str "non-legacy IRQ on i8259"); ih = kmem_alloc(sizeof(*ih), KM_SLEEP); - intrstr = create_intrid(legacy_irq, pic, pin, intrstr_buf, + intrstr = intr_create_intrid(legacy_irq, pic, pin, intrstr_buf, sizeof(intrstr_buf)); KASSERT(intrstr != NULL);