Source-Changes-HG archive

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

[src/bouyer-xenpvh]: src/sys/arch Add per-PIC callbacks for interrupt_get_dev...



details:   https://anonhg.NetBSD.org/src/rev/465335e7d185
branches:  bouyer-xenpvh
changeset: 930999:465335e7d185
user:      bouyer <bouyer%NetBSD.org@localhost>
date:      Sun Apr 19 19:39:10 2020 +0000

description:
Add per-PIC callbacks for interrupt_get_devname(), interrupt_get_assigned()
and interrupt_get_count(). Implement Xen-specific callbacks for
PIC_XEN and use the x86 one for others.
In event_set_handler(), call intr_allocate_io_intrsource() so that
events appears in interrupt list (intrctl list).

diffstat:

 sys/arch/x86/include/intr.h  |    7 ++-
 sys/arch/x86/include/pic.h   |    6 ++-
 sys/arch/x86/pci/msipic.c    |   10 +++-
 sys/arch/x86/x86/i8259.c     |    7 ++-
 sys/arch/x86/x86/intr.c      |  102 +++++++++++++++++++++++++++++-------------
 sys/arch/x86/x86/ioapic.c    |    7 ++-
 sys/arch/x86/x86/lapic.c     |    7 ++-
 sys/arch/xen/include/intr.h  |    7 +-
 sys/arch/xen/x86/xen_intr.c  |   10 ++--
 sys/arch/xen/xen/evtchn.c    |   72 +++++++++++++++++++++---------
 sys/arch/xen/xen/xen_clock.c |    6 +-
 11 files changed, 165 insertions(+), 76 deletions(-)

diffs (truncated from 606 to 300 lines):

diff -r ae16a64ef9d5 -r 465335e7d185 sys/arch/x86/include/intr.h
--- a/sys/arch/x86/include/intr.h       Sun Apr 19 11:40:30 2020 +0000
+++ b/sys/arch/x86/include/intr.h       Sun Apr 19 19:39:10 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: intr.h,v 1.61.6.4 2020/04/19 11:40:30 bouyer Exp $     */
+/*     $NetBSD: intr.h,v 1.61.6.5 2020/04/19 19:39:10 bouyer Exp $     */
 
 /*-
  * Copyright (c) 1998, 2001, 2006, 2007, 2008, 2019 The NetBSD Foundation, Inc.
@@ -39,6 +39,7 @@
 
 #ifdef _KERNEL
 #include <sys/types.h>
+#include <sys/kcpuset.h>
 #else
 #include <stdbool.h>
 #endif
@@ -237,6 +238,10 @@
 void x86_broadcast_ipi(int);
 void x86_ipi_handler(void);
 
+void x86_intr_get_devname(const char *, char *, size_t);
+void x86_intr_get_assigned(const char *, kcpuset_t *);
+uint64_t x86_intr_get_count(const char *, u_int);
+
 #ifndef XENPV
 extern void (* const ipifunc[X86_NIPI])(struct cpu_info *);
 #endif
diff -r ae16a64ef9d5 -r 465335e7d185 sys/arch/x86/include/pic.h
--- a/sys/arch/x86/include/pic.h        Sun Apr 19 11:40:30 2020 +0000
+++ b/sys/arch/x86/include/pic.h        Sun Apr 19 19:39:10 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pic.h,v 1.9 2017/11/04 10:26:14 cherry Exp $   */
+/*     $NetBSD: pic.h,v 1.9.14.1 2020/04/19 19:39:10 bouyer Exp $      */
 
 #ifndef _X86_PIC_H
 #define _X86_PIC_H
@@ -23,6 +23,10 @@
        struct intrstub *pic_edge_stubs;
        struct ioapic_softc *pic_ioapic; /* if pic_type == PIC_IOAPIC */
        struct msipic *pic_msipic; /* if (pic_type == PIC_MSI) || (pic_type == PIC_MSIX) */
+       /* interface for subr_interrupt.c */
+       void (*pic_intr_get_devname)(const char *, char *, size_t);
+       void (*pic_intr_get_assigned)(const char *, kcpuset_t *);
+       uint64_t (*pic_intr_get_count)(const char *, u_int);
 };
 
 /*
diff -r ae16a64ef9d5 -r 465335e7d185 sys/arch/x86/pci/msipic.c
--- a/sys/arch/x86/pci/msipic.c Sun Apr 19 11:40:30 2020 +0000
+++ b/sys/arch/x86/pci/msipic.c Sun Apr 19 19:39:10 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: msipic.c,v 1.20 2019/12/02 03:06:51 msaitoh Exp $      */
+/*     $NetBSD: msipic.c,v 1.20.6.1 2020/04/19 19:39:10 bouyer Exp $   */
 
 /*
  * Copyright (c) 2015 Internet Initiative Japan Inc.
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: msipic.c,v 1.20 2019/12/02 03:06:51 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: msipic.c,v 1.20.6.1 2020/04/19 19:39:10 bouyer Exp $");
 
 #include "opt_intrdebug.h"
 
@@ -436,6 +436,9 @@
        .pic_hwunmask = msi_hwunmask,
        .pic_addroute = msi_addroute,
        .pic_delroute = msi_delroute,
+       .pic_intr_get_devname = x86_intr_get_devname,
+       .pic_intr_get_assigned = x86_intr_get_assigned,
+       .pic_intr_get_count = x86_intr_get_count,
 };
 
 /*
@@ -611,6 +614,9 @@
        .pic_hwunmask = msix_hwunmask,
        .pic_addroute = msix_addroute,
        .pic_delroute = msix_delroute,
+       .pic_intr_get_devname = x86_intr_get_devname,
+       .pic_intr_get_assigned = x86_intr_get_assigned,
+       .pic_intr_get_count = x86_intr_get_count,
 };
 
 struct pic *
diff -r ae16a64ef9d5 -r 465335e7d185 sys/arch/x86/x86/i8259.c
--- a/sys/arch/x86/x86/i8259.c  Sun Apr 19 11:40:30 2020 +0000
+++ b/sys/arch/x86/x86/i8259.c  Sun Apr 19 19:39:10 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: i8259.c,v 1.23.10.1 2020/04/12 17:25:52 bouyer Exp $   */
+/*     $NetBSD: i8259.c,v 1.23.10.2 2020/04/19 19:39:10 bouyer Exp $   */
 
 /*
  * Copyright 2002 (c) Wasabi Systems, Inc.
@@ -70,7 +70,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: i8259.c,v 1.23.10.1 2020/04/12 17:25:52 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i8259.c,v 1.23.10.2 2020/04/19 19:39:10 bouyer Exp $");
 
 #include <sys/param.h> 
 #include <sys/systm.h>
@@ -118,6 +118,9 @@
        .pic_delroute = i8259_setup,
        .pic_level_stubs = legacy_stubs,
        .pic_edge_stubs = legacy_stubs,
+       .pic_intr_get_devname = x86_intr_get_devname,
+       .pic_intr_get_assigned = x86_intr_get_assigned,
+       .pic_intr_get_count = x86_intr_get_count,
 };
 
 void
diff -r ae16a64ef9d5 -r 465335e7d185 sys/arch/x86/x86/intr.c
--- a/sys/arch/x86/x86/intr.c   Sun Apr 19 11:40:30 2020 +0000
+++ b/sys/arch/x86/x86/intr.c   Sun Apr 19 19:39:10 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: intr.c,v 1.150.6.4 2020/04/19 11:40:30 bouyer Exp $    */
+/*     $NetBSD: intr.c,v 1.150.6.5 2020/04/19 19:39:10 bouyer Exp $    */
 
 /*
  * Copyright (c) 2007, 2008, 2009, 2019 The NetBSD Foundation, Inc.
@@ -133,7 +133,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.150.6.4 2020/04/19 11:40:30 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.150.6.5 2020/04/19 19:39:10 bouyer Exp $");
 
 #include "opt_intrdebug.h"
 #include "opt_multiprocessor.h"
@@ -1962,11 +1962,8 @@
        return isp->is_handlers;
 }
 
-/*
- * MI interface for subr_interrupt.c
- */
 uint64_t
-interrupt_get_count(const char *intrid, u_int cpu_idx)
+x86_intr_get_count(const char *intrid, u_int cpu_idx)
 {
        struct cpu_info *ci;
        struct intrsource *isp;
@@ -1976,11 +1973,10 @@
        int i, slot;
        uint64_t count = 0;
 
+       KASSERT(mutex_owned(&cpu_lock));
        ci = cpu_lookup(cpu_idx);
        cpuid = ci->ci_cpuid;
 
-       mutex_enter(&cpu_lock);
-
        ih = intr_get_handler(intrid);
        if (ih == NULL) {
                count = 0;
@@ -2003,6 +1999,59 @@
        }
 
  out:
+       return count;
+}
+
+void
+x86_intr_get_assigned(const char *intrid, kcpuset_t *cpuset)
+{
+       struct cpu_info *ci;
+       struct intrhand *ih;
+
+       KASSERT(mutex_owned(&cpu_lock));
+       kcpuset_zero(cpuset);
+
+       ih = intr_get_handler(intrid);
+       if (ih == NULL)
+               return;
+
+       ci = ih->ih_cpu;
+       kcpuset_set(cpuset, cpu_index(ci));
+}
+
+void
+x86_intr_get_devname(const char *intrid, char *buf, size_t len)
+{
+       struct intrsource *isp;
+       struct intrhand *ih;
+       int slot;
+
+       KASSERT(mutex_owned(&cpu_lock));
+
+       ih = intr_get_handler(intrid);
+       if (ih == NULL) {
+               buf[0] = '\0';
+               return;
+       }
+       slot = ih->ih_slot;
+       isp = ih->ih_cpu->ci_isources[slot];
+       strlcpy(buf, isp->is_xname, len);
+
+}
+
+/*
+ * MI interface for subr_interrupt.c
+ */
+uint64_t
+interrupt_get_count(const char *intrid, u_int cpu_idx)
+{
+       struct intrsource *isp;
+       uint64_t count = 0;
+
+       mutex_enter(&cpu_lock);
+       isp = intr_get_io_intrsource(intrid);
+       if (isp != NULL)
+               count = isp->is_pic->pic_intr_get_count(intrid, cpu_idx);
        mutex_exit(&cpu_lock);
        return count;
 }
@@ -2013,21 +2062,12 @@
 void
 interrupt_get_assigned(const char *intrid, kcpuset_t *cpuset)
 {
-       struct cpu_info *ci;
-       struct intrhand *ih;
-
-       kcpuset_zero(cpuset);
+       struct intrsource *isp;
 
        mutex_enter(&cpu_lock);
-
-       ih = intr_get_handler(intrid);
-       if (ih == NULL)
-               goto out;
-
-       ci = ih->ih_cpu;
-       kcpuset_set(cpuset, cpu_index(ci));
-
- out:
+       isp = intr_get_io_intrsource(intrid);
+       if (isp != NULL) 
+               isp->is_pic->pic_intr_get_assigned(intrid, cpuset);
        mutex_exit(&cpu_lock);
 }
 
@@ -2058,21 +2098,17 @@
 interrupt_get_devname(const char *intrid, char *buf, size_t len)
 {
        struct intrsource *isp;
-       struct intrhand *ih;
-       int slot;
 
        mutex_enter(&cpu_lock);
-
-       ih = intr_get_handler(intrid);
-       if (ih == NULL) {
-               buf[0] = '\0';
-               goto out;
+       isp = intr_get_io_intrsource(intrid);
+       if (isp != NULL) {
+               if (isp->is_pic->pic_intr_get_devname == NULL) {
+                       printf("NULL get_devname intrid %s pic %s\n",
+                           intrid, isp->is_pic->pic_name);
+               } else {
+                       isp->is_pic->pic_intr_get_devname(intrid, buf, len);
+               }
        }
-       slot = ih->ih_slot;
-       isp = ih->ih_cpu->ci_isources[slot];
-       strlcpy(buf, isp->is_xname, len);
-
- out:
        mutex_exit(&cpu_lock);
 }
 
diff -r ae16a64ef9d5 -r 465335e7d185 sys/arch/x86/x86/ioapic.c
--- a/sys/arch/x86/x86/ioapic.c Sun Apr 19 11:40:30 2020 +0000
+++ b/sys/arch/x86/x86/ioapic.c Sun Apr 19 19:39:10 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ioapic.c,v 1.63 2019/06/19 06:32:46 msaitoh Exp $      */
+/*     $NetBSD: ioapic.c,v 1.63.8.1 2020/04/19 19:39:10 bouyer Exp $   */
 
 /*-
  * Copyright (c) 2000, 2009 The NetBSD Foundation, Inc.
@@ -64,7 +64,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ioapic.c,v 1.63 2019/06/19 06:32:46 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ioapic.c,v 1.63.8.1 2020/04/19 19:39:10 bouyer Exp $");
 
 #include "opt_ddb.h"
 
@@ -301,6 +301,9 @@
        sc->sc_pic.pic_trymask = ioapic_trymask;
        sc->sc_pic.pic_edge_stubs = ioapic_edge_stubs;
        sc->sc_pic.pic_level_stubs = ioapic_level_stubs;
+       sc->sc_pic.pic_intr_get_devname = x86_intr_get_devname;
+       sc->sc_pic.pic_intr_get_assigned = x86_intr_get_assigned;
+       sc->sc_pic.pic_intr_get_count = x86_intr_get_count;
 



Home | Main Index | Thread Index | Old Index