Source-Changes-HG archive

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

[src/netbsd-6]: src/sys/arch/xen Pull up following revision(s) (requested by ...



details:   https://anonhg.NetBSD.org/src/rev/4c75bb54b435
branches:  netbsd-6
changeset: 776938:4c75bb54b435
user:      msaitoh <msaitoh%NetBSD.org@localhost>
date:      Tue Apr 14 14:59:11 2015 +0000

description:
Pull up following revision(s) (requested by bouyer in ticket #1278):
        sys/arch/xen/include/evtchn.h: revision 1.23
        sys/arch/xen/xen/evtchn.c: revision 1.71
        sys/arch/xen/xen/pci_intr_machdep.c: revision 1.17
Properly implemement pci_intr_disestablish(9), so that interrupt
handlers stop being called when the device has been detached.
Should fix PR port-xen/47720 (which turns out to not be related to raidframe).
While there fix possible races in event_remove_handler() and pirq_establish().

diffstat:

 sys/arch/xen/include/evtchn.h       |   3 ++-
 sys/arch/xen/xen/evtchn.c           |  27 +++++++++++++++++++--------
 sys/arch/xen/xen/pci_intr_machdep.c |   5 +++--
 3 files changed, 24 insertions(+), 11 deletions(-)

diffs (114 lines):

diff -r 5b83ac4532b6 -r 4c75bb54b435 sys/arch/xen/include/evtchn.h
--- a/sys/arch/xen/include/evtchn.h     Tue Apr 14 13:36:26 2015 +0000
+++ b/sys/arch/xen/include/evtchn.h     Tue Apr 14 14:59:11 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: evtchn.h,v 1.20 2011/09/20 00:12:23 jym Exp $  */
+/*     $NetBSD: evtchn.h,v 1.20.8.1 2015/04/14 14:59:11 msaitoh Exp $  */
 
 /*
  *
@@ -67,5 +67,6 @@
 
 struct pintrhand *pirq_establish(int, int, int (*)(void *), void *, int,
      const char *);
+void pirq_disestablish(struct pintrhand *);
 
 #endif /*  _XEN_EVENTS_H_ */
diff -r 5b83ac4532b6 -r 4c75bb54b435 sys/arch/xen/xen/evtchn.c
--- a/sys/arch/xen/xen/evtchn.c Tue Apr 14 13:36:26 2015 +0000
+++ b/sys/arch/xen/xen/evtchn.c Tue Apr 14 14:59:11 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: evtchn.c,v 1.62.2.1 2013/12/17 22:39:17 riz Exp $      */
+/*     $NetBSD: evtchn.c,v 1.62.2.2 2015/04/14 14:59:11 msaitoh Exp $  */
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -54,7 +54,7 @@
 
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: evtchn.c,v 1.62.2.1 2013/12/17 22:39:17 riz Exp $");
+__KERNEL_RCSID(0, "$NetBSD: evtchn.c,v 1.62.2.2 2015/04/14 14:59:11 msaitoh Exp $");
 
 #include "opt_xen.h"
 #include "isa.h"
@@ -554,16 +554,16 @@
                return NULL;
        }
 
+       ih->pirq = pirq;
+       ih->evtch = evtch;
+       ih->func = func;
+       ih->arg = arg;
+
        if (event_set_handler(evtch, pirq_interrupt, ih, level, evname) != 0) {
                kmem_free(ih, sizeof(struct pintrhand));
                return NULL;
        }
 
-       ih->pirq = pirq;
-       ih->evtch = evtch;
-       ih->func = func;
-       ih->arg = arg;
-
        physdev_op.cmd = PHYSDEVOP_IRQ_STATUS_QUERY;
        physdev_op.u.irq_status_query.irq = pirq;
        if (HYPERVISOR_physdev_op(&physdev_op) < 0)
@@ -579,6 +579,17 @@
        return ih;
 }
 
+void
+pirq_disestablish(struct pintrhand *ih)
+{
+       int error = event_remove_handler(ih->evtch, pirq_interrupt, ih);
+       if (error) {
+               printf("pirq_disestablish(%p): %d\n", ih, error);
+               return;
+       }
+       kmem_free(ih, sizeof(struct pintrhand));
+}
+
 int
 pirq_interrupt(void *arg)
 {
@@ -776,7 +787,6 @@
        }
        ci = ih->ih_cpu;
        *ihp = ih->ih_evt_next;
-       mutex_spin_exit(&evtlock[evtch]);
 
        ipls = ci->ci_isources[ih->ih_level];
        for (ihp = &ipls->ipl_handlers, ih = ipls->ipl_handlers;
@@ -788,6 +798,7 @@
        if (ih == NULL)
                panic("event_remove_handler");
        *ihp = ih->ih_ipl_next;
+       mutex_spin_exit(&evtlock[evtch]);
        kmem_free(ih, sizeof (struct intrhand));
        if (evts->ev_handlers == NULL) {
                xen_atomic_clear_bit(&ci->ci_evtmask[0], evtch);
diff -r 5b83ac4532b6 -r 4c75bb54b435 sys/arch/xen/xen/pci_intr_machdep.c
--- a/sys/arch/xen/xen/pci_intr_machdep.c       Tue Apr 14 13:36:26 2015 +0000
+++ b/sys/arch/xen/xen/pci_intr_machdep.c       Tue Apr 14 14:59:11 2015 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: pci_intr_machdep.c,v 1.15 2011/07/01 18:36:45 dyoung Exp $      */
+/*      $NetBSD: pci_intr_machdep.c,v 1.15.8.1 2015/04/14 14:59:11 msaitoh Exp $      */
 
 /*
  * Copyright (c) 2005 Manuel Bouyer.
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pci_intr_machdep.c,v 1.15 2011/07/01 18:36:45 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_intr_machdep.c,v 1.15.8.1 2015/04/14 14:59:11 msaitoh Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -221,4 +221,5 @@
 void
 pci_intr_disestablish(pci_chipset_tag_t pcitag, void *cookie)
 {
+       pirq_disestablish(cookie);
 }



Home | Main Index | Thread Index | Old Index