Source-Changes-HG archive

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

[src/trunk]: src/sys/arch add support for kern.intr.list aka intrctl(8) 'list...



details:   https://anonhg.NetBSD.org/src/rev/b9c7cf414239
branches:  trunk
changeset: 323648:b9c7cf414239
user:      jdolecek <jdolecek%NetBSD.org@localhost>
date:      Sun Jun 24 13:35:32 2018 +0000

description:
add support for kern.intr.list aka intrctl(8) 'list' for xen

event_set_handler() and pirq_establish() now have extra intrname
parameter; shared intr_create_intrid() is used to provide the value

xen drivers were changed to pass the specific driver instance
name as the xname, e.g.  'vcpu0 clock' instead just 'clock', or
'xencons0' instead of 'xencons'

associated evcnt is now changed to use intrname - this matches native x86

diffstat:

 sys/arch/x86/include/intr.h        |    4 +-
 sys/arch/x86/isa/isa_machdep.c     |   19 +--
 sys/arch/x86/x86/intr.c            |   43 +++++----
 sys/arch/xen/include/evtchn.h      |    7 +-
 sys/arch/xen/include/intr.h        |    5 +-
 sys/arch/xen/x86/xen_ipi.c         |   17 ++-
 sys/arch/xen/xen/clock.c           |   13 ++-
 sys/arch/xen/xen/evtchn.c          |  158 +++++++++++++++++++++++++++++++++---
 sys/arch/xen/xen/pciback.c         |    6 +-
 sys/arch/xen/xen/xencons.c         |   11 +-
 sys/arch/xen/xenbus/xenbus_comms.c |    6 +-
 11 files changed, 214 insertions(+), 75 deletions(-)

diffs (truncated from 748 to 300 lines):

diff -r 282c21e7a38b -r b9c7cf414239 sys/arch/x86/include/intr.h
--- a/sys/arch/x86/include/intr.h       Sun Jun 24 12:55:36 2018 +0000
+++ b/sys/arch/x86/include/intr.h       Sun Jun 24 13:35:32 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: intr.h,v 1.55 2018/04/04 22:52:58 christos Exp $       */
+/*     $NetBSD: intr.h,v 1.56 2018/06/24 13:35:33 jdolecek Exp $       */
 
 /*-
  * Copyright (c) 1998, 2001, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -222,9 +222,7 @@
 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 282c21e7a38b -r b9c7cf414239 sys/arch/x86/isa/isa_machdep.c
--- a/sys/arch/x86/isa/isa_machdep.c    Sun Jun 24 12:55:36 2018 +0000
+++ b/sys/arch/x86/isa/isa_machdep.c    Sun Jun 24 13:35:32 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: isa_machdep.c,v 1.38 2017/12/13 16:30:18 bouyer Exp $  */
+/*     $NetBSD: isa_machdep.c,v 1.39 2018/06/24 13:35:33 jdolecek 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.38 2017/12/13 16:30:18 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: isa_machdep.c,v 1.39 2018/06/24 13:35:33 jdolecek Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -241,25 +241,22 @@
        KASSERT(APIC_IRQ_ISLEGACY(irq));
 
        int evtch;
-       char evname[16];
+       const char *intrstr;
+       char intrstr_buf[INTRIDBUF];
 
        mpih |= APIC_IRQ_LEGACY_IRQ(irq);
 
        evtch = xen_pirq_alloc(&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);
+
+       intrstr = intr_create_intrid(irq, pic, pin, intrstr_buf,
+           sizeof(intrstr_buf));
 
        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);
+           intrstr, xname);
 #else /* defined(XEN) */
        return intr_establish_xname(irq, pic, pin, type, level, ih_fun, ih_arg,
            false, xname);
diff -r 282c21e7a38b -r b9c7cf414239 sys/arch/x86/x86/intr.c
--- a/sys/arch/x86/x86/intr.c   Sun Jun 24 12:55:36 2018 +0000
+++ b/sys/arch/x86/x86/intr.c   Sun Jun 24 13:35:32 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: intr.c,v 1.125 2018/04/04 22:52:59 christos Exp $      */
+/*     $NetBSD: intr.c,v 1.126 2018/06/24 13:35:33 jdolecek 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.125 2018/04/04 22:52:59 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.126 2018/06/24 13:35:33 jdolecek Exp $");
 
 #include "opt_intrdebug.h"
 #include "opt_multiprocessor.h"
@@ -238,12 +238,13 @@
 
 static void intr_establish_xcall(void *, void *);
 static void intr_disestablish_xcall(void *, void *);
+#endif
 
 static const char *legacy_intr_string(int, char *, size_t, struct pic *);
+
 #if defined(XEN) /* XXX: nuke conditional after integration */
 static const char *xen_intr_string(int, char *, size_t, struct pic *);
 #endif /* XXX: XEN */
-#endif
 
 #if defined(INTRSTACKSIZE)
 static inline bool redzone_const_or_false(bool);
@@ -489,7 +490,6 @@
 }
 #endif
 
-#if !defined(XEN)
 /*
  * Create an interrupt id such as "ioapic0 pin 9". This interrupt id is used
  * by MI code and intrctl(8).
@@ -551,8 +551,6 @@
        return NULL; /* No pic found! */
 }
 
-#endif /* XEN */
-
 /*
  * Find intrsource from io_interrupt_sources list.
  */
@@ -869,6 +867,7 @@
        return NULL;
 }
 #endif
+
 #if !defined(XEN)
 /*
  * Append device name to intrsource. If device A and device B share IRQ number,
@@ -1222,6 +1221,9 @@
     int type, int level, int (*handler)(void *), void *arg,
     bool known_mpsafe, const char *xname)
 {
+       const char *intrstr;
+       char intrstr_buf[INTRIDBUF];
+
        if (pic->pic_type == PIC_XEN) {
                struct intrhand *rih;
 
@@ -1232,7 +1234,10 @@
                 */
                KASSERT(known_mpsafe == (level != IPL_VM));
 
-               event_set_handler(pin, handler, arg, level, xname);
+               intrstr = intr_create_intrid(legacy_irq, pic, pin, intrstr_buf,
+                   sizeof(intrstr_buf));
+
+               event_set_handler(pin, handler, arg, level, intrstr, xname);
 
                rih = kmem_zalloc(sizeof(*rih), cold ? KM_NOSLEEP : KM_SLEEP);
                if (rih == NULL) {
@@ -1260,7 +1265,6 @@
        struct pintrhand *pih;
        intr_handle_t irq;
        int evtchn;
-       char evname[16];
 
        KASSERTMSG(legacy_irq == -1 || (0 <= legacy_irq && legacy_irq < 16),
            "bad legacy IRQ value: %d", legacy_irq);
@@ -1273,19 +1277,19 @@
                irq = APIC_INT_VIA_APIC;
                irq |= pic->pic_apicid << APIC_INT_APIC_SHIFT;
                irq |= pin << APIC_INT_PIN_SHIFT;
-               snprintf(evname, sizeof(evname), "%s pin %d",
-                   pic->pic_name, pin);
 #else /* NIOAPIC */
                return NULL;
 #endif /* NIOAPIC */
        } else {
-               snprintf(evname, sizeof(evname), "irq%d", legacy_irq);
                irq = legacy_irq;
        }
 
+       intrstr = intr_create_intrid(irq, pic, pin, intrstr_buf,
+           sizeof(intrstr_buf));
+
        evtchn = xen_pirq_alloc(&irq, type);
        pih = pirq_establish(irq & 0xff, evtchn, handler, arg, level,
-           evname);
+           intrstr, xname);
        pih->pic_type = pic->pic_type;
        return pih;
 #endif /* NPCI > 0 || NISA > 0 */
@@ -1342,7 +1346,6 @@
 #endif /* XEN */
 }
 
-#if !defined(XEN)
 #if defined(XEN) /* nuke conditional post integration */
 static const char *
 xen_intr_string(int port, char *buf, size_t len, struct pic *pic)
@@ -1356,7 +1359,7 @@
 
        return buf;
 }
-#endif /* XXX: XEN */
+#endif /* XEN */
 
 static const char *
 legacy_intr_string(int ih, char *buf, size_t len, struct pic *pic)
@@ -1377,7 +1380,6 @@
 
        return buf;
 }
-#endif
 
 const char *
 intr_string(intr_handle_t ih, char *buf, size_t len)
@@ -2128,7 +2130,7 @@
 
        return err;
 }
-#endif /* XEN */
+
 static bool
 intr_is_affinity_intrsource(struct intrsource *isp, const kcpuset_t *cpuset)
 {
@@ -2163,7 +2165,6 @@
        return isp->is_handlers;
 }
 
-#if !defined(XEN)
 /*
  * MI interface for subr_interrupt.c
  */
@@ -2209,8 +2210,6 @@
        return count;
 }
 
-#endif /* XEN */
-
 /*
  * MI interface for subr_interrupt.c
  */
@@ -2235,7 +2234,7 @@
        mutex_exit(&cpu_lock);
 }
 
-#if !defined(XEN)
+#endif /* XEN */
 
 /*
  * MI interface for subr_interrupt.c
@@ -2257,6 +2256,8 @@
        mutex_exit(&cpu_lock);
 }
 
+#if !defined(XEN)
+
 /*
  * MI interface for subr_interrupt.c
  */
@@ -2348,7 +2349,6 @@
        mutex_exit(&intr_distribute_lock);
        return error;
 }
-#endif
 
 /*
  * MI interface for subr_interrupt.c
@@ -2403,6 +2403,7 @@
 
        return ii_handler;
 }
+#endif /* !XEN */
 
 /*
  * MI interface for subr_interrupt.c
diff -r 282c21e7a38b -r b9c7cf414239 sys/arch/xen/include/evtchn.h
--- a/sys/arch/xen/include/evtchn.h     Sun Jun 24 12:55:36 2018 +0000
+++ b/sys/arch/xen/include/evtchn.h     Sun Jun 24 13:35:32 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: evtchn.h,v 1.25 2017/11/04 14:56:48 cherry Exp $       */
+/*     $NetBSD: evtchn.h,v 1.26 2018/06/24 13:35:32 jdolecek Exp $     */
 
 /*
  *
@@ -41,7 +41,8 @@
 unsigned int evtchn_do_event(int, struct intrframe *);
 void call_evtchn_do_event(int, struct intrframe *);
 void call_xenevt_event(int);
-int event_set_handler(int, int (*func)(void *), void *, int, const char *);
+int event_set_handler(int, int (*func)(void *), void *, int, const char *,
+    const char *);
 int event_remove_handler(int, int (*func)(void *), void *);
 
 struct cpu_info;
@@ -69,7 +70,7 @@
 };
 
 struct pintrhand *pirq_establish(int, int, int (*)(void *), void *, int,
-     const char *);
+     const char *, const char *);
 void pirq_disestablish(struct pintrhand *);
 
 #endif /*  _XEN_EVENTS_H_ */
diff -r 282c21e7a38b -r b9c7cf414239 sys/arch/xen/include/intr.h
--- a/sys/arch/xen/include/intr.h       Sun Jun 24 12:55:36 2018 +0000
+++ b/sys/arch/xen/include/intr.h       Sun Jun 24 13:35:32 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: intr.h,v 1.45 2017/12/13 16:30:18 bouyer Exp $ */
+/*     $NetBSD: intr.h,v 1.46 2018/06/24 13:35:32 jdolecek Exp $       */



Home | Main Index | Thread Index | Old Index