Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/x86 fix "intrctl list" panic when ACPI is disabled.
details: https://anonhg.NetBSD.org/src/rev/03ee7322950f
branches: trunk
changeset: 358502:03ee7322950f
user: knakahara <knakahara%NetBSD.org@localhost>
date: Thu Jan 04 01:01:59 2018 +0000
description:
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 | 13 +---
3 files changed, 77 insertions(+), 34 deletions(-)
diffs (209 lines):
diff -r d8775eca5528 -r 03ee7322950f sys/arch/x86/include/intr.h
--- a/sys/arch/x86/include/intr.h Thu Jan 04 00:09:12 2018 +0000
+++ b/sys/arch/x86/include/intr.h Thu Jan 04 01:01:59 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: intr.h,v 1.52 2017/11/04 14:56:48 cherry Exp $ */
+/* $NetBSD: intr.h,v 1.53 2018/01/04 01:01:59 knakahara Exp $ */
/*-
* Copyright (c) 1998, 2001, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -222,6 +222,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 d8775eca5528 -r 03ee7322950f sys/arch/x86/pci/pci_intr_machdep.c
--- a/sys/arch/x86/pci/pci_intr_machdep.c Thu Jan 04 00:09:12 2018 +0000
+++ b/sys/arch/x86/pci/pci_intr_machdep.c Thu Jan 04 01:01:59 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pci_intr_machdep.c,v 1.41 2017/07/28 14:26:50 maxv Exp $ */
+/* $NetBSD: pci_intr_machdep.c,v 1.42 2018/01/04 01:01:59 knakahara 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.41 2017/07/28 14:26:50 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_intr_machdep.c,v 1.42 2018/01/04 01:01:59 knakahara Exp $");
#include <sys/types.h>
#include <sys/param.h>
@@ -273,15 +273,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;
@@ -301,25 +328,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);
@@ -376,6 +391,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)
{
@@ -406,8 +446,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 d8775eca5528 -r 03ee7322950f sys/arch/x86/x86/intr.c
--- a/sys/arch/x86/x86/intr.c Thu Jan 04 00:09:12 2018 +0000
+++ b/sys/arch/x86/x86/intr.c Thu Jan 04 01:01:59 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: intr.c,v 1.113 2017/12/13 16:30:18 bouyer Exp $ */
+/* $NetBSD: intr.c,v 1.114 2018/01/04 01:01:59 knakahara 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.113 2017/12/13 16:30:18 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.114 2018/01/04 01:01:59 knakahara Exp $");
#include "opt_intrdebug.h"
#include "opt_multiprocessor.h"
@@ -253,9 +253,6 @@
static void intr_redistribute_xc_s2(void *, void *);
static bool intr_redistribute(struct cpu_info *);
-#if !defined(XEN)
-static const char *create_intrid(int, struct pic *, int, char *, size_t);
-#endif /* XEN */
static struct intrsource *intr_get_io_intrsource(const char *);
static void intr_free_io_intrsource_direct(struct intrsource *);
#if !defined(XEN)
@@ -495,8 +492,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 = 0;
@@ -958,7 +955,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