Module Name: src
Committed By: msaitoh
Date: Tue Apr 14 14:59:11 UTC 2015
Modified Files:
src/sys/arch/xen/include [netbsd-6]: evtchn.h
src/sys/arch/xen/xen [netbsd-6]: evtchn.c pci_intr_machdep.c
Log Message:
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().
To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.20.8.1 src/sys/arch/xen/include/evtchn.h
cvs rdiff -u -r1.62.2.1 -r1.62.2.2 src/sys/arch/xen/xen/evtchn.c
cvs rdiff -u -r1.15 -r1.15.8.1 src/sys/arch/xen/xen/pci_intr_machdep.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/xen/include/evtchn.h
diff -u src/sys/arch/xen/include/evtchn.h:1.20 src/sys/arch/xen/include/evtchn.h:1.20.8.1
--- src/sys/arch/xen/include/evtchn.h:1.20 Tue Sep 20 00:12:23 2011
+++ src/sys/arch/xen/include/evtchn.h Tue Apr 14 14:59:11 2015
@@ -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 {
struct pintrhand *pirq_establish(int, int, int (*)(void *), void *, int,
const char *);
+void pirq_disestablish(struct pintrhand *);
#endif /* _XEN_EVENTS_H_ */
Index: src/sys/arch/xen/xen/evtchn.c
diff -u src/sys/arch/xen/xen/evtchn.c:1.62.2.1 src/sys/arch/xen/xen/evtchn.c:1.62.2.2
--- src/sys/arch/xen/xen/evtchn.c:1.62.2.1 Tue Dec 17 22:39:17 2013
+++ src/sys/arch/xen/xen/evtchn.c Tue Apr 14 14:59:11 2015
@@ -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 @@ pirq_establish(int pirq, int evtch, int
return NULL;
}
- 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;
+ if (event_set_handler(evtch, pirq_interrupt, ih, level, evname) != 0) {
+ kmem_free(ih, sizeof(struct pintrhand));
+ return NULL;
+ }
+
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 @@ pirq_establish(int pirq, int evtch, int
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 @@ event_remove_handler(int evtch, int (*fu
}
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 @@ event_remove_handler(int evtch, int (*fu
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);
Index: src/sys/arch/xen/xen/pci_intr_machdep.c
diff -u src/sys/arch/xen/xen/pci_intr_machdep.c:1.15 src/sys/arch/xen/xen/pci_intr_machdep.c:1.15.8.1
--- src/sys/arch/xen/xen/pci_intr_machdep.c:1.15 Fri Jul 1 18:36:45 2011
+++ src/sys/arch/xen/xen/pci_intr_machdep.c Tue Apr 14 14:59:11 2015
@@ -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 @@ pci_intr_establish(pci_chipset_tag_t pci
void
pci_intr_disestablish(pci_chipset_tag_t pcitag, void *cookie)
{
+ pirq_disestablish(cookie);
}