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 a struct pic * member to struct intrhand.



details:   https://anonhg.NetBSD.org/src/rev/ae16a64ef9d5
branches:  bouyer-xenpvh
changeset: 930978:ae16a64ef9d5
user:      bouyer <bouyer%NetBSD.org@localhost>
date:      Sun Apr 19 11:40:30 2020 +0000

description:
Add a struct pic * member to struct intrhand.
This will be used for interrupt_get_count()
For Xen remplace pic_type with a pointer to the pic, and add a pointer
to intrhand, in struct pintrhand
Make event_set_handler return the pointer to struct intrhand.
Don't allocate a fake intrhand in xen_intr_establish_xname(), use the
one returned by event_set_handler().

diffstat:

 sys/arch/x86/include/intr.h     |  16 ++--------------
 sys/arch/x86/x86/intr.c         |   7 +++++--
 sys/arch/x86/x86/x86_softintr.c |   9 +++++++--
 sys/arch/xen/include/evtchn.h   |   5 +++--
 sys/arch/xen/x86/xen_intr.c     |  30 ++++++++----------------------
 sys/arch/xen/xen/evtchn.c       |  10 ++++++----
 6 files changed, 31 insertions(+), 46 deletions(-)

diffs (266 lines):

diff -r 0dc950b4beed -r ae16a64ef9d5 sys/arch/x86/include/intr.h
--- a/sys/arch/x86/include/intr.h       Sat Apr 18 20:36:31 2020 +0000
+++ b/sys/arch/x86/include/intr.h       Sun Apr 19 11:40:30 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: intr.h,v 1.61.6.3 2020/04/16 08:46:35 bouyer Exp $     */
+/*     $NetBSD: intr.h,v 1.61.6.4 2020/04/19 11:40:30 bouyer Exp $     */
 
 /*-
  * Copyright (c) 1998, 2001, 2006, 2007, 2008, 2019 The NetBSD Foundation, Inc.
@@ -130,19 +130,7 @@
  */
 
 struct intrhand {
-#if defined(XEN)
-       /*
-        * Note: This is transitional and will go away.
-        * The only current consumer is xen_intr_disestablish()
-        *
-        * We ought to use a union here, but too much effort.
-        * We use this field to tear down the cookie handed to us
-        * via x86/intr.c:intr_disestablish();
-        * Interestingly, the intr_establish_xname() function returns
-        * a "void *" - so we abuse this for now.
-        */
-       int     pic_type; /* Overloading wrt struct pintrhand */
-#endif
+       struct pic *ih_pic;
        int     (*ih_fun)(void *);
        void    *ih_arg;
        int     ih_level;
diff -r 0dc950b4beed -r ae16a64ef9d5 sys/arch/x86/x86/intr.c
--- a/sys/arch/x86/x86/intr.c   Sat Apr 18 20:36:31 2020 +0000
+++ b/sys/arch/x86/x86/intr.c   Sun Apr 19 11:40:30 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: intr.c,v 1.150.6.3 2020/04/16 09:45:57 bouyer Exp $    */
+/*     $NetBSD: intr.c,v 1.150.6.4 2020/04/19 11:40:30 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.3 2020/04/16 09:45:57 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.150.6.4 2020/04/19 11:40:30 bouyer Exp $");
 
 #include "opt_intrdebug.h"
 #include "opt_multiprocessor.h"
@@ -880,6 +880,7 @@
                /* nothing */;
        }
 
+       ih->ih_pic = pic;
        ih->ih_fun = ih->ih_realfun = handler;
        ih->ih_arg = ih->ih_realarg = arg;
        ih->ih_prevp = p;
@@ -1302,6 +1303,7 @@
        isp = kmem_zalloc(sizeof(*isp), KM_SLEEP);
        isp->is_recurse = Xrecurse_lapic_ltimer;
        isp->is_resume = Xresume_lapic_ltimer;
+       fake_timer_intrhand.ih_pic = &local_pic;
        fake_timer_intrhand.ih_level = IPL_CLOCK;
        isp->is_handlers = &fake_timer_intrhand;
        isp->is_pic = &local_pic;
@@ -1315,6 +1317,7 @@
        isp = kmem_zalloc(sizeof(*isp), KM_SLEEP);
        isp->is_recurse = Xrecurse_lapic_ipi;
        isp->is_resume = Xresume_lapic_ipi;
+       fake_ipi_intrhand.ih_pic = &local_pic;
        fake_ipi_intrhand.ih_level = IPL_HIGH;
        isp->is_handlers = &fake_ipi_intrhand;
        isp->is_pic = &local_pic;
diff -r 0dc950b4beed -r ae16a64ef9d5 sys/arch/x86/x86/x86_softintr.c
--- a/sys/arch/x86/x86/x86_softintr.c   Sat Apr 18 20:36:31 2020 +0000
+++ b/sys/arch/x86/x86/x86_softintr.c   Sun Apr 19 11:40:30 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: x86_softintr.c,v 1.1.2.1 2020/04/11 18:26:07 bouyer Exp $      */
+/*     $NetBSD: x86_softintr.c,v 1.1.2.2 2020/04/19 11:40:30 bouyer Exp $      */
 
 /*
  * Copyright (c) 2007, 2008, 2009, 2019 The NetBSD Foundation, Inc.
@@ -133,7 +133,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: x86_softintr.c,v 1.1.2.1 2020/04/11 18:26:07 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: x86_softintr.c,v 1.1.2.2 2020/04/19 11:40:30 bouyer Exp $");
 
 #include <sys/kmem.h>
 #include <sys/proc.h>
@@ -226,6 +226,7 @@
        isp = kmem_zalloc(sizeof(*isp), KM_SLEEP);
        isp->is_recurse = Xrecurse_preempt;
        isp->is_resume = Xresume_preempt;
+       fake_preempt_intrhand.ih_pic = &softintr_pic;
        fake_preempt_intrhand.ih_level = IPL_PREEMPT;
        isp->is_handlers = &fake_preempt_intrhand;
        isp->is_pic = &softintr_pic;
@@ -256,21 +257,25 @@
        switch (level) {
        case SOFTINT_BIO:
                sir = SIR_BIO;
+               fake_softbio_intrhand.ih_pic = &softintr_pic;
                fake_softbio_intrhand.ih_level = IPL_SOFTBIO;
                isp->is_handlers = &fake_softbio_intrhand;
                break;
        case SOFTINT_NET:
                sir = SIR_NET;
+               fake_softnet_intrhand.ih_pic = &softintr_pic;
                fake_softnet_intrhand.ih_level = IPL_SOFTNET;
                isp->is_handlers = &fake_softnet_intrhand;
                break;
        case SOFTINT_SERIAL:
                sir = SIR_SERIAL;
+               fake_softserial_intrhand.ih_pic = &softintr_pic;
                fake_softserial_intrhand.ih_level = IPL_SOFTSERIAL;
                isp->is_handlers = &fake_softserial_intrhand;
                break;
        case SOFTINT_CLOCK:
                sir = SIR_CLOCK;
+               fake_softclock_intrhand.ih_pic = &softintr_pic;
                fake_softclock_intrhand.ih_level = IPL_SOFTCLOCK;
                isp->is_handlers = &fake_softclock_intrhand;
                break;
diff -r 0dc950b4beed -r ae16a64ef9d5 sys/arch/xen/include/evtchn.h
--- a/sys/arch/xen/include/evtchn.h     Sat Apr 18 20:36:31 2020 +0000
+++ b/sys/arch/xen/include/evtchn.h     Sun Apr 19 11:40:30 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: evtchn.h,v 1.28 2020/04/06 19:26:00 jdolecek Exp $     */
+/*     $NetBSD: evtchn.h,v 1.28.2.1 2020/04/19 11:40:30 bouyer Exp $   */
 
 /*
  *
@@ -62,7 +62,8 @@
 
 struct pintrhand {
        /* See comments in x86/include/intr.h:struct intrhand {} */
-       int pic_type;
+       struct pic *pic;
+       struct intrhand *ih;
        int pirq;
        int evtch;
        int (*func)(void *);
diff -r 0dc950b4beed -r ae16a64ef9d5 sys/arch/xen/x86/xen_intr.c
--- a/sys/arch/xen/x86/xen_intr.c       Sat Apr 18 20:36:31 2020 +0000
+++ b/sys/arch/xen/x86/xen_intr.c       Sun Apr 19 11:40:30 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: xen_intr.c,v 1.21.2.5 2020/04/16 08:46:35 bouyer Exp $ */
+/*     $NetBSD: xen_intr.c,v 1.21.2.6 2020/04/19 11:40:30 bouyer Exp $ */
 
 /*-
  * Copyright (c) 1998, 2001 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: xen_intr.c,v 1.21.2.5 2020/04/16 08:46:35 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xen_intr.c,v 1.21.2.6 2020/04/19 11:40:30 bouyer Exp $");
 
 #include "opt_multiprocessor.h"
 
@@ -138,28 +138,14 @@
                intrstr = intr_create_intrid(legacy_irq, pic, pin, intrstr_buf,
                    sizeof(intrstr_buf));
 
-               event_set_handler(pin, handler, arg, level, intrstr, xname,
-                   known_mpsafe);
+               rih = event_set_handler(pin, handler, arg, level,
+                   intrstr, xname, known_mpsafe);
 
-               rih = kmem_zalloc(sizeof(*rih), cold ? KM_NOSLEEP : KM_SLEEP);
                if (rih == NULL) {
-                       printf("%s: can't allocate handler info\n", __func__);
+                       printf("%s: can't establish interrupt", __func__);
                        return NULL;
                }
 
-               /*
-                * XXX:
-                * This is just a copy for API conformance.
-                * The real ih is lost in the innards of
-                * event_set_handler(); where the details of
-                * biglock_wrapper etc are taken care of.
-                * All that goes away when we nuke event_set_handler()
-                * et. al. and unify with x86/intr.c
-                */
-               rih->ih_pin = pin; /* port */
-               rih->ih_fun = rih->ih_realfun = handler;
-               rih->ih_arg = rih->ih_realarg = arg;
-               rih->pic_type = pic->pic_type;
                return rih;
        }       /* Else we assume pintr */
 
@@ -201,7 +187,7 @@
 
        pih = pirq_establish(gsi, evtchn, handler, arg, level,
                             intrstr, xname, known_mpsafe);
-       pih->pic_type = pic->pic_type;
+       pih->pic = pic;
        return pih;
 #endif /* NPCI > 0 || NISA > 0 */
 
@@ -236,10 +222,10 @@
 xen_intr_disestablish(struct intrhand *ih)
 {
 
-       if (ih->pic_type == PIC_XEN) {
+       if (ih->ih_pic->pic_type == PIC_XEN) {
                event_remove_handler(ih->ih_pin, ih->ih_realfun,
                    ih->ih_realarg);
-               kmem_free(ih, sizeof(*ih));
+               /* event_remove_handler frees ih */
                return;
        }
 #if defined(DOM0OPS)
diff -r 0dc950b4beed -r ae16a64ef9d5 sys/arch/xen/xen/evtchn.c
--- a/sys/arch/xen/xen/evtchn.c Sat Apr 18 20:36:31 2020 +0000
+++ b/sys/arch/xen/xen/evtchn.c Sun Apr 19 11:40:30 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: evtchn.c,v 1.88.2.6 2020/04/18 20:36:31 bouyer Exp $   */
+/*     $NetBSD: evtchn.c,v 1.88.2.7 2020/04/19 11:40:30 bouyer Exp $   */
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -54,7 +54,7 @@
 
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: evtchn.c,v 1.88.2.6 2020/04/18 20:36:31 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: evtchn.c,v 1.88.2.7 2020/04/19 11:40:30 bouyer Exp $");
 
 #include "opt_xen.h"
 #include "isa.h"
@@ -800,7 +800,7 @@
        mutex_spin_exit(&evtlock[evtch]);
 }
 
-int
+struct intrhand *
 event_set_handler(int evtch, int (*func)(void *), void *arg, int level,
     const char *intrname, const char *xname, bool mpsafe)
 {
@@ -827,12 +827,14 @@
                panic("can't allocate fixed interrupt source");
 
 
+       ih->ih_pic = &xen_pic;
        ih->ih_level = level;
        ih->ih_fun = ih->ih_realfun = func;
        ih->ih_arg = ih->ih_realarg = arg;
        ih->ih_evt_next = NULL;
        ih->ih_next = NULL;
        ih->ih_cpu = ci;
+       ih->ih_pin = evtch;
 #ifdef MULTIPROCESSOR
        if (!mpsafe) {
                ih->ih_fun = xen_intr_biglock_wrapper;
@@ -894,7 +896,7 @@
        intr_calculatemasks(evts, evtch, ci);
        splx(s);
 
-       return 0;
+       return ih;
 }
 
 void



Home | Main Index | Thread Index | Old Index