Source-Changes-HG archive

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

[src/trunk]: src/sys/arch Remove the xen specific interrupt type for the x86 ...



details:   https://anonhg.NetBSD.org/src/rev/86b6ee66ab8b
branches:  trunk
changeset: 825470:86b6ee66ab8b
user:      cherry <cherry%NetBSD.org@localhost>
date:      Sun Jul 16 06:14:23 2017 +0000

description:
Remove the xen specific interrupt type for the x86 intr_handle_t
For this to work, we use the evtchn.c:get_pirq_to_evtchn() glue
function to make things easier.

diffstat:

 sys/arch/x86/isa/isa_machdep.c      |  34 ++++++++++++++++++++--
 sys/arch/xen/include/intr.h         |   4 +-
 sys/arch/xen/include/pci_machdep.h  |   4 +-
 sys/arch/xen/x86/intr.c             |  16 +++++++---
 sys/arch/xen/xen/isa_machdep.c      |  20 ++++++------
 sys/arch/xen/xen/pci_intr_machdep.c |  55 +++++++++++++++++++-----------------
 sys/arch/xen/xen/pciback.c          |   8 ++--
 sys/arch/xen/xen/pciide_machdep.c   |  24 ++++++++--------
 8 files changed, 101 insertions(+), 64 deletions(-)

diffs (truncated from 498 to 300 lines):

diff -r 8886ee5e9f3f -r 86b6ee66ab8b sys/arch/x86/isa/isa_machdep.c
--- a/sys/arch/x86/isa/isa_machdep.c    Sun Jul 16 05:03:36 2017 +0000
+++ b/sys/arch/x86/isa/isa_machdep.c    Sun Jul 16 06:14:23 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: isa_machdep.c,v 1.34 2016/10/15 16:46:14 jdolecek Exp $        */
+/*     $NetBSD: isa_machdep.c,v 1.35 2017/07/16 06:14:23 cherry Exp $  */
 
 /*-
  * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@@ -65,7 +65,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: isa_machdep.c,v 1.34 2016/10/15 16:46:14 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: isa_machdep.c,v 1.35 2017/07/16 06:14:23 cherry Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -212,7 +212,7 @@
        int pin;
 #if NIOAPIC > 0
        intr_handle_t mpih;
-       struct ioapic_softc *ioapic;
+       struct ioapic_softc *ioapic = NULL;
 #endif
 
        pin = irq;
@@ -237,20 +237,48 @@
                        printf("isa_intr_establish: no MP mapping found\n");
        }
 #endif
+#if defined(XEN)
+       KASSERT(APIC_IRQ_ISLEGACY(irq));
+
+       int evtch;
+       char evname[16];
+
+       mpih |= APIC_IRQ_LEGACY_IRQ(irq);
+
+       evtch = xen_intr_map((int *)&mpih, type); /* XXX: legacy - xen just tosses irq back at us */
+       if (evtch == -1)
+               return NULL;
+#if NIOAPIC > 0
+       if (ioapic)
+               snprintf(evname, sizeof(evname), "%s pin %d",
+                   device_xname(ioapic->sc_dev), pin);
+       else
+#endif
+               snprintf(evname, sizeof(evname), "irq%d", irq);
+
+       aprint_debug("irq: %d requested on pic: %s.\n", irq, pic->pic_name);
+
+       return (void *)pirq_establish(irq, evtch, ih_fun, ih_arg, level,
+           evname);
+#else /* defined(XEN) */
        return intr_establish_xname(irq, pic, pin, type, level, ih_fun, ih_arg,
            false, xname);
+#endif
+
 }
 
 /* Deregister an interrupt handler. */
 void
 isa_intr_disestablish(isa_chipset_tag_t ic, void *arg)
 {
+#if !defined(XEN)
        struct intrhand *ih = arg;
 
        if (!LEGAL_IRQ(ih->ih_pin))
                panic("intr_disestablish: bogus irq");
 
        intr_disestablish(ih);
+#endif 
 }
 
 void
diff -r 8886ee5e9f3f -r 86b6ee66ab8b sys/arch/xen/include/intr.h
--- a/sys/arch/xen/include/intr.h       Sun Jul 16 05:03:36 2017 +0000
+++ b/sys/arch/xen/include/intr.h       Sun Jul 16 06:14:23 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: intr.h,v 1.40 2017/05/23 08:54:39 nonaka Exp $ */
+/*     $NetBSD: intr.h,v 1.41 2017/07/16 06:14:24 cherry Exp $ */
 /*     NetBSD intr.h,v 1.15 2004/10/31 10:39:34 yamt Exp       */
 
 /*-
@@ -175,7 +175,7 @@
 #ifdef INTRDEBUG
 void intr_printconfig(void);
 #endif
-int intr_find_mpmapping(int, int, struct xen_intr_handle *);
+int intr_find_mpmapping(int, int, intr_handle_t *);
 struct pic *intr_findpic(int);
 void intr_add_pcibus(struct pcibus_attach_args *);
 
diff -r 8886ee5e9f3f -r 86b6ee66ab8b sys/arch/xen/include/pci_machdep.h
--- a/sys/arch/xen/include/pci_machdep.h        Sun Jul 16 05:03:36 2017 +0000
+++ b/sys/arch/xen/include/pci_machdep.h        Sun Jul 16 06:14:23 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pci_machdep.h,v 1.18 2011/04/04 20:37:55 dyoung Exp $ */
+/* $NetBSD: pci_machdep.h,v 1.19 2017/07/16 06:14:24 cherry Exp $ */
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -60,7 +60,7 @@
 /*
  * Types provided to machine-independent PCI code
  */
-typedef struct xen_intr_handle pci_intr_handle_t;
+typedef intr_handle_t pci_intr_handle_t;
 
 #include <x86/pci_machdep_common.h>
 
diff -r 8886ee5e9f3f -r 86b6ee66ab8b sys/arch/xen/x86/intr.c
--- a/sys/arch/xen/x86/intr.c   Sun Jul 16 05:03:36 2017 +0000
+++ b/sys/arch/xen/x86/intr.c   Sun Jul 16 06:14:23 2017 +0000
@@ -103,7 +103,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.31 2017/05/23 08:54:39 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.32 2017/07/16 06:14:24 cherry Exp $");
 
 #include "opt_multiprocessor.h"
 #include "opt_xen.h"
@@ -125,6 +125,7 @@
 #include <machine/i8259.h>
 #include <machine/pio.h>
 #include <xen/evtchn.h>
+#include <xen/intr.h>
 
 #include "acpica.h"
 #include "ioapic.h"
@@ -319,7 +320,9 @@
 LIST_HEAD(, intr_extra_bus) intr_extra_buses =
     LIST_HEAD_INITIALIZER(intr_extra_buses);
 
-static int intr_scan_bus(int, int, struct xen_intr_handle *);
+#if NPCI > 0
+static int intr_scan_bus(int, int, intr_handle_t *);
+#endif
 
 void
 intr_add_pcibus(struct pcibus_attach_args *pba)
@@ -364,8 +367,9 @@
        return ENOENT;
 }
 
+/* XXX: Unify with x86/intr.c */
 int
-intr_find_mpmapping(int bus, int pin, struct xen_intr_handle *handle)
+intr_find_mpmapping(int bus, int pin, intr_handle_t *handle)
 {
 #if NPCI > 0
        int dev, func;
@@ -391,8 +395,9 @@
 #endif
 }
 
+#if NPCI > 0
 static int
-intr_scan_bus(int bus, int pin, struct xen_intr_handle *handle)
+intr_scan_bus(int bus, int pin, intr_handle_t *handle)
 {
        struct mp_intr_map *mip, *intrs;
 
@@ -410,12 +415,13 @@
                                if (mpacpi_findintr_linkdev(mip) != 0)
                                        continue;
 #endif
-                       handle->pirq = mip->ioapic_ih;
+                       *handle = mip->ioapic_ih;
                        return 0;
                }
        }
        return ENOENT;
 }
+#endif /* NPCI > 0 */
 #endif /* NIOAPIC > 0 || NACPICA > 0 */
 #endif /* NPCI > 0 || NISA > 0 */
 
diff -r 8886ee5e9f3f -r 86b6ee66ab8b sys/arch/xen/xen/isa_machdep.c
--- a/sys/arch/xen/xen/isa_machdep.c    Sun Jul 16 05:03:36 2017 +0000
+++ b/sys/arch/xen/xen/isa_machdep.c    Sun Jul 16 06:14:23 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: isa_machdep.c,v 1.26 2011/09/01 15:10:31 christos Exp $        */
+/*     $NetBSD: isa_machdep.c,v 1.27 2017/07/16 06:14:24 cherry Exp $  */
 /*     NetBSD isa_machdep.c,v 1.11 2004/06/20 18:04:08 thorpej Exp     */
 
 /*-
@@ -66,7 +66,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: isa_machdep.c,v 1.26 2011/09/01 15:10:31 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: isa_machdep.c,v 1.27 2017/07/16 06:14:24 cherry Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -131,23 +131,23 @@
 {
        int evtch;
        char evname[16];
-       struct xen_intr_handle ih;
+       intr_handle_t ih;
 #if NIOAPIC > 0
        struct ioapic_softc *pic = NULL;
 #endif
 
-       ih.pirq = 0;
+       ih = 0;
 
 #if NIOAPIC > 0
        if (mp_busses != NULL) {
                if (intr_find_mpmapping(mp_isa_bus, irq, &ih) == 0 ||
                    intr_find_mpmapping(mp_eisa_bus, irq, &ih) == 0) {
-                       if (!APIC_IRQ_ISLEGACY(ih.pirq)) {
-                               pic = ioapic_find(APIC_IRQ_APIC(ih.pirq));
+                       if (!APIC_IRQ_ISLEGACY(ih)) {
+                               pic = ioapic_find(APIC_IRQ_APIC(ih));
                                if (pic == NULL) {
                                        printf("isa_intr_establish: "
                                            "unknown apic %d\n",
-                                           APIC_IRQ_APIC(ih.pirq));
+                                           APIC_IRQ_APIC(ih));
                                        return NULL;
                                }
                        }
@@ -155,15 +155,15 @@
                        printf("isa_intr_establish: no MP mapping found\n");
        }
 #endif
-       ih.pirq |= (irq & 0xff);
+       ih |= (irq & 0xff);
 
-       evtch = xen_intr_map(&ih.pirq, type);
+       evtch = xen_intr_map((int *)&ih, type);
        if (evtch == -1)
                return NULL;
 #if NIOAPIC > 0
        if (pic)
                snprintf(evname, sizeof(evname), "%s pin %d",
-                   device_xname(pic->sc_dev), APIC_IRQ_PIN(ih.pirq));
+                   device_xname(pic->sc_dev), APIC_IRQ_PIN(ih));
        else
 #endif
                snprintf(evname, sizeof(evname), "irq%d", irq);
diff -r 8886ee5e9f3f -r 86b6ee66ab8b sys/arch/xen/xen/pci_intr_machdep.c
--- a/sys/arch/xen/xen/pci_intr_machdep.c       Sun Jul 16 05:03:36 2017 +0000
+++ b/sys/arch/xen/xen/pci_intr_machdep.c       Sun Jul 16 06:14:23 2017 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: pci_intr_machdep.c,v 1.17 2015/03/14 10:49:36 bouyer Exp $      */
+/*      $NetBSD: pci_intr_machdep.c,v 1.18 2017/07/16 06:14:24 cherry Exp $      */
 
 /*
  * Copyright (c) 2005 Manuel Bouyer.
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pci_intr_machdep.c,v 1.17 2015/03/14 10:49:36 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_intr_machdep.c,v 1.18 2017/07/16 06:14:24 cherry Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -66,6 +66,7 @@
 {
        int pin;
        int line;
+       int evtch;
 
 #if NIOAPIC > 0
        int rawpin = pa->pa_rawintrpin;
@@ -85,17 +86,17 @@
                printf("pci_intr_map: bad interrupt pin %d\n", pin);
                goto bad;
        }
-       ihp->pirq = 0;
+       *ihp = 0;
 
 #if NIOAPIC > 0
        pci_decompose_tag(pc, pa->pa_tag, &bus, &dev, &func);
        if (mp_busses != NULL) {
                if (intr_find_mpmapping(bus, (dev<<2)|(rawpin-1), ihp) == 0) {
-                       if (ihp->pirq & APIC_INT_VIA_APIC) {
+                       if (*ihp & APIC_INT_VIA_APIC) {
                                /* make sure a new IRQ will be allocated */
-                               ihp->pirq &= ~0xff;
+                               *ihp &= ~0xff;
                        } else {
-                               ihp->pirq |= line;
+                               *ihp |= line;
                        }
                        goto end;
                }
@@ -124,8 +125,8 @@
 #if NIOAPIC > 0
        if (mp_busses != NULL) {
                if (intr_find_mpmapping(mp_isa_bus, line, ihp) == 0) {
-                       if ((ihp->pirq & 0xff) == 0)
-                               ihp->pirq |= line;



Home | Main Index | Thread Index | Old Index