Source-Changes-HG archive

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

[src/trunk]: src/sys Add kernel code to support intrctl(8).



details:   https://anonhg.NetBSD.org/src/rev/08d15db99cfa
branches:  trunk
changeset: 339907:08d15db99cfa
user:      knakahara <knakahara%NetBSD.org@localhost>
date:      Mon Aug 17 06:16:02 2015 +0000

description:
Add kernel code to support intrctl(8).

diffstat:

 sys/arch/x86/include/intr.h               |    7 +-
 sys/arch/x86/include/intr_distribute.h    |    3 +-
 sys/arch/x86/include/pci_machdep_common.h |    3 +-
 sys/arch/x86/pci/pci_intr_machdep.c       |   35 +-
 sys/arch/x86/pci/pci_msi_machdep.c        |   19 +-
 sys/arch/x86/pci/pci_msi_machdep.h        |    6 +-
 sys/arch/x86/x86/intr.c                   |  300 ++++++++++++++++-
 sys/conf/files                            |    5 +-
 sys/dev/pci/if_wm.c                       |   24 +-
 sys/dev/pci/ixgbe/ixgbe.c                 |    6 +-
 sys/dev/pci/ixgbe/ixgbe.h                 |    3 +-
 sys/dev/pci/ixgbe/ixv.c                   |    6 +-
 sys/dev/pci/ixgbe/ixv.h                   |    3 +-
 sys/dev/pci/pci_stub.c                    |   14 +-
 sys/dev/pci/pcivar.h                      |    4 +-
 sys/kern/files.kern                       |    3 +-
 sys/kern/kern_stub.c                      |   13 +-
 sys/kern/subr_interrupt.c                 |  513 ++++++++++++++++++++++++++++++
 sys/secmodel/suser/secmodel_suser.c       |   18 +-
 sys/sys/Makefile                          |    4 +-
 sys/sys/interrupt.h                       |   56 +++
 sys/sys/intr.h                            |    3 +-
 sys/sys/intrio.h                          |   68 +++
 sys/sys/kauth.h                           |    4 +-
 24 files changed, 1045 insertions(+), 75 deletions(-)

diffs (truncated from 1678 to 300 lines):

diff -r 58fe7563d438 -r 08d15db99cfa sys/arch/x86/include/intr.h
--- a/sys/arch/x86/include/intr.h       Sun Aug 16 19:22:33 2015 +0000
+++ b/sys/arch/x86/include/intr.h       Mon Aug 17 06:16:02 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: intr.h,v 1.47 2015/04/27 06:51:40 knakahara Exp $      */
+/*     $NetBSD: intr.h,v 1.48 2015/08/17 06:16:02 knakahara Exp $      */
 
 /*-
  * Copyright (c) 1998, 2001, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -86,13 +86,14 @@
        void *is_recurse;               /* entry for spllower */
        void *is_resume;                /* entry for doreti */
        lwp_t *is_lwp;                  /* for soft interrupts */
-       struct evcnt is_evcnt;          /* interrupt counter */
+       struct evcnt is_evcnt;          /* interrupt counter per cpu */
        int is_flags;                   /* see below */
        int is_type;                    /* level, edge */
        int is_idtvec;
        int is_minlevel;
        char is_evname[32];             /* event counter name */
        char is_intrid[INTRIDBUF];      /* intrid created by create_intrid() */
+       char is_xname[INTRDEVNAMEBUF];  /* device names */
        cpuid_t is_active_cpu;          /* active cpuid */
        struct percpu_evcnt *is_saved_evcnt;    /* interrupt count of deactivated cpus */
        SIMPLEQ_ENTRY(intrsource) is_list;      /* link of intrsources */
@@ -185,6 +186,8 @@
 
 void intr_default_setup(void);
 void x86_nmi(void);
+void *intr_establish_xname(int, struct pic *, int, int, int, int (*)(void *),
+                          void *, bool, const char *);
 void *intr_establish(int, struct pic *, int, int, int, int (*)(void *), void *, bool);
 void intr_disestablish(struct intrhand *);
 void intr_add_pcibus(struct pcibus_attach_args *);
diff -r 58fe7563d438 -r 08d15db99cfa sys/arch/x86/include/intr_distribute.h
--- a/sys/arch/x86/include/intr_distribute.h    Sun Aug 16 19:22:33 2015 +0000
+++ b/sys/arch/x86/include/intr_distribute.h    Mon Aug 17 06:16:02 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: intr_distribute.h,v 1.1 2015/04/27 06:42:52 knakahara Exp $    */
+/*     $NetBSD: intr_distribute.h,v 1.2 2015/08/17 06:16:02 knakahara Exp $    */
 
 /*
  * Copyright (c) 2015 Internet Initiative Japan Inc.
@@ -34,6 +34,7 @@
 #include <sys/kcpuset.h>
 
 int intr_distribute(struct intrhand *, const kcpuset_t *, kcpuset_t *);
+int intr_distribute_handler(const char *, const kcpuset_t *, kcpuset_t *);
 
 #endif /* _KERNEL */
 
diff -r 58fe7563d438 -r 08d15db99cfa sys/arch/x86/include/pci_machdep_common.h
--- a/sys/arch/x86/include/pci_machdep_common.h Sun Aug 16 19:22:33 2015 +0000
+++ b/sys/arch/x86/include/pci_machdep_common.h Mon Aug 17 06:16:02 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pci_machdep_common.h,v 1.20 2015/08/13 04:39:33 msaitoh Exp $  */
+/*     $NetBSD: pci_machdep_common.h,v 1.21 2015/08/17 06:16:02 knakahara Exp $        */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All rights reserved.
@@ -118,7 +118,6 @@
 void           *pci_intr_establish(pci_chipset_tag_t, pci_intr_handle_t,
                    int, int (*)(void *), void *);
 void           pci_intr_disestablish(pci_chipset_tag_t, void *);
-int            pci_intr_distribute(void *, const kcpuset_t *, kcpuset_t *);
 
 typedef enum {
        PCI_INTR_TYPE_INTX = 0,
diff -r 58fe7563d438 -r 08d15db99cfa sys/arch/x86/pci/pci_intr_machdep.c
--- a/sys/arch/x86/pci/pci_intr_machdep.c       Sun Aug 16 19:22:33 2015 +0000
+++ b/sys/arch/x86/pci/pci_intr_machdep.c       Mon Aug 17 06:16:02 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pci_intr_machdep.c,v 1.36 2015/08/13 04:39:33 msaitoh Exp $    */
+/*     $NetBSD: pci_intr_machdep.c,v 1.37 2015/08/17 06:16:03 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.36 2015/08/13 04:39:33 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_intr_machdep.c,v 1.37 2015/08/17 06:16:03 knakahara Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -275,8 +275,8 @@
 }
 
 void *
-pci_intr_establish(pci_chipset_tag_t pc, pci_intr_handle_t ih,
-    int level, int (*func)(void *), void *arg)
+pci_intr_establish_xname(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;
@@ -295,9 +295,11 @@
 
        if (INT_VIA_MSI(ih)) {
                if (MSI_INT_IS_MSIX(ih))
-                       return x86_pci_msix_establish(pc, ih, level, func, arg);
+                       return x86_pci_msix_establish(pc, ih, level, func, arg,
+                           xname);
                else
-                       return x86_pci_msi_establish(pc, ih, level, func, arg);
+                       return x86_pci_msi_establish(pc, ih, level, func, arg,
+                           xname);
        }
 
        pic = &i8259_pic;
@@ -320,8 +322,16 @@
        }
 #endif
 
-       return intr_establish(irq, pic, pin, IST_LEVEL, level, func, arg,
-           mpsafe);
+       return intr_establish_xname(irq, pic, pin, IST_LEVEL, level, func, arg,
+           mpsafe, xname);
+}
+
+void *
+pci_intr_establish(pci_chipset_tag_t pc, pci_intr_handle_t ih,
+    int level, int (*func)(void *), void *arg)
+{
+
+       return pci_intr_establish_xname(pc, ih, level, func, arg, "unknown");
 }
 
 void
@@ -340,15 +350,6 @@
        intr_disestablish(cookie);
 }
 
-int
-pci_intr_distribute(void *cookie, const kcpuset_t *newset, kcpuset_t *oldset)
-{
-
-       /* XXX Is pc_ov->ov_intr_distribute required? */
-
-       return intr_distribute(cookie, newset, oldset);
-}
-
 #if NIOAPIC > 0
 pci_intr_type_t
 pci_intr_type(pci_intr_handle_t ih)
diff -r 58fe7563d438 -r 08d15db99cfa sys/arch/x86/pci/pci_msi_machdep.c
--- a/sys/arch/x86/pci/pci_msi_machdep.c        Sun Aug 16 19:22:33 2015 +0000
+++ b/sys/arch/x86/pci/pci_msi_machdep.c        Mon Aug 17 06:16:02 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pci_msi_machdep.c,v 1.8 2015/08/13 04:39:33 msaitoh Exp $      */
+/*     $NetBSD: pci_msi_machdep.c,v 1.9 2015/08/17 06:16:03 knakahara Exp $    */
 
 /*
  * Copyright (c) 2015 Internet Initiative Japan Inc.
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pci_msi_machdep.c,v 1.8 2015/08/13 04:39:33 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_msi_machdep.c,v 1.9 2015/08/17 06:16:03 knakahara Exp $");
 
 #include "opt_intrdebug.h"
 
@@ -208,7 +208,8 @@
 
 static void *
 pci_msi_common_establish(pci_chipset_tag_t pc, pci_intr_handle_t ih,
-    int level, int (*func)(void *), void *arg, struct pic *pic)
+    int level, int (*func)(void *), void *arg, struct pic *pic,
+    const char *xname)
 {
        int irq, pin;
        bool mpsafe;
@@ -219,8 +220,8 @@
        pin = MSI_INT_VEC(ih);
        mpsafe = ((ih & MPSAFE_MASK) != 0);
 
-       return intr_establish(irq, pic, pin, IST_EDGE, level, func, arg,
-           mpsafe);
+       return intr_establish_xname(irq, pic, pin, IST_EDGE, level, func, arg,
+           mpsafe, xname);
 }
 
 static void
@@ -396,7 +397,7 @@
  */
 void *
 x86_pci_msi_establish(pci_chipset_tag_t pc, pci_intr_handle_t ih,
-    int level, int (*func)(void *), void *arg)
+    int level, int (*func)(void *), void *arg, const char *xname)
 {
        struct pic *pic;
 
@@ -406,7 +407,7 @@
                return NULL;
        }
 
-       return pci_msi_common_establish(pc, ih, level, func, arg, pic);
+       return pci_msi_common_establish(pc, ih, level, func, arg, pic, xname);
 }
 
 /*
@@ -441,7 +442,7 @@
  */
 void *
 x86_pci_msix_establish(pci_chipset_tag_t pc, pci_intr_handle_t ih,
-    int level, int (*func)(void *), void *arg)
+    int level, int (*func)(void *), void *arg, const char *xname)
 {
        struct pic *pic;
 
@@ -451,7 +452,7 @@
                return NULL;
        }
 
-       return pci_msi_common_establish(pc, ih, level, func, arg, pic);
+       return pci_msi_common_establish(pc, ih, level, func, arg, pic, xname);
 }
 
 /*
diff -r 58fe7563d438 -r 08d15db99cfa sys/arch/x86/pci/pci_msi_machdep.h
--- a/sys/arch/x86/pci/pci_msi_machdep.h        Sun Aug 16 19:22:33 2015 +0000
+++ b/sys/arch/x86/pci/pci_msi_machdep.h        Mon Aug 17 06:16:02 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pci_msi_machdep.h,v 1.2 2015/05/15 08:36:41 knakahara Exp $    */
+/*     $NetBSD: pci_msi_machdep.h,v 1.3 2015/08/17 06:16:03 knakahara Exp $    */
 
 /*
  * Copyright (c) 2015 Internet Initiative Japan Inc.
@@ -34,13 +34,13 @@
 void           x86_pci_msi_release(pci_chipset_tag_t, pci_intr_handle_t *,
                    int);
 void           *x86_pci_msi_establish(pci_chipset_tag_t, pci_intr_handle_t,
-                   int, int (*)(void *), void *);
+                   int, int (*)(void *), void *, const char *);
 void           x86_pci_msi_disestablish(pci_chipset_tag_t, void *);
 
 void           x86_pci_msix_release(pci_chipset_tag_t, pci_intr_handle_t *,
                    int);
 void           *x86_pci_msix_establish(pci_chipset_tag_t, pci_intr_handle_t,
-                   int, int (*)(void *), void *);
+                   int, int (*)(void *), void *, const char *xname);
 void           x86_pci_msix_disestablish(pci_chipset_tag_t, void *);
 
 #endif /* _X86_PCI_PCI_MSI_MACHDEP_H_ */
diff -r 58fe7563d438 -r 08d15db99cfa sys/arch/x86/x86/intr.c
--- a/sys/arch/x86/x86/intr.c   Sun Aug 16 19:22:33 2015 +0000
+++ b/sys/arch/x86/x86/intr.c   Mon Aug 17 06:16:02 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: intr.c,v 1.86 2015/06/23 10:00:13 msaitoh Exp $        */
+/*     $NetBSD: intr.c,v 1.87 2015/08/17 06:16:03 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.86 2015/06/23 10:00:13 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.87 2015/08/17 06:16:03 knakahara Exp $");
 
 #include "opt_intrdebug.h"
 #include "opt_multiprocessor.h"
@@ -151,6 +151,10 @@
 #include <sys/cpu.h>
 #include <sys/atomic.h>
 #include <sys/xcall.h>
+#include <sys/interrupt.h>
+
+#include <sys/kauth.h>
+#include <sys/conf.h>
 
 #include <uvm/uvm_extern.h>
 
@@ -224,6 +228,8 @@
 static void intr_establish_xcall(void *, void *);
 static void intr_disestablish_xcall(void *, void *);
 
+static const char *legacy_intr_string(int, char *, size_t, struct pic *);
+
 static inline bool redzone_const_or_false(bool);
 static inline int redzone_const_or_zero(int);
 
@@ -829,6 +835,19 @@
 }
 
 /*
+ * Append device name to intrsource. If device A and device B share IRQ number,
+ * the device name of the interrupt id is "device A, device B".
+ */
+static void
+intr_append_intrsource_xname(struct intrsource *isp, const char *xname)
+{
+
+       if (isp->is_xname[0] != '\0')
+               strlcat(isp->is_xname, ", ", sizeof(isp->is_xname));
+       strlcat(isp->is_xname, xname, sizeof(isp->is_xname));
+}
+



Home | Main Index | Thread Index | Old Index