Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-8]: src/sys/arch/x86 Pull up following revision(s) (requested by ...



details:   https://anonhg.NetBSD.org/src/rev/d0f7052dab11
branches:  netbsd-8
changeset: 851291:d0f7052dab11
user:      snj <snj%NetBSD.org@localhost>
date:      Sat Jan 13 21:50:31 2018 +0000

description:
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.

diffstat:

 sys/arch/x86/include/intr.h         |   5 +-
 sys/arch/x86/pci/pci_intr_machdep.c |  93 +++++++++++++++++++++++++++---------
 sys/arch/x86/x86/intr.c             |  12 +--
 3 files changed, 77 insertions(+), 33 deletions(-)

diffs (208 lines):

diff -r ebcd75430aee -r d0f7052dab11 sys/arch/x86/include/intr.h
--- a/sys/arch/x86/include/intr.h       Sat Jan 13 21:44:20 2018 +0000
+++ b/sys/arch/x86/include/intr.h       Sat Jan 13 21:50:31 2018 +0000
@@ -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 @@
 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 *);
 
diff -r ebcd75430aee -r d0f7052dab11 sys/arch/x86/pci/pci_intr_machdep.c
--- a/sys/arch/x86/pci/pci_intr_machdep.c       Sat Jan 13 21:44:20 2018 +0000
+++ b/sys/arch/x86/pci/pci_intr_machdep.c       Sat Jan 13 21:50:31 2018 +0000
@@ -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 @@
        }
 }
 
+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 @@
                            xname);
        }
 
-       pic = &i8259_pic;
-       pin = irq = APIC_IRQ_LEGACY_IRQ(ih);
-       mpsafe = ((ih & MPSAFE_MASK) != 0);
+       if (pci_intr_find_intx_irq(ih, &irq, &pic, &pin)) {
+               aprint_normal("%s: bad pic %d\n", __func__,
+                   APIC_IRQ_APIC(ih));
+               return NULL;
+       }
 
-#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;
-       }
-#endif
+       mpsafe = ((ih & MPSAFE_MASK) != 0);
 
        return intr_establish_xname(irq, pic, pin, IST_LEVEL, level, func, arg,
            mpsafe, xname);
@@ -377,6 +392,31 @@
        }
 }
 
+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 @@
                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);
diff -r ebcd75430aee -r d0f7052dab11 sys/arch/x86/x86/intr.c
--- a/sys/arch/x86/x86/intr.c   Sat Jan 13 21:44:20 2018 +0000
+++ b/sys/arch/x86/x86/intr.c   Sat Jan 13 21:50:31 2018 +0000
@@ -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_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 @@
  * 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 @@
            "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);
 



Home | Main Index | Thread Index | Old Index