svn commit: r185988 - user/dfr/xenhvm/6/sys/dev/xen/xenpci

Doug Rabson dfr at FreeBSD.org
Fri Dec 12 06:06:21 PST 2008


Author: dfr
Date: Fri Dec 12 14:06:21 2008
New Revision: 185988
URL: http://svn.freebsd.org/changeset/base/185988

Log:
  Mark the evtchn interrupt as MPSAFE and respect the INTR_MPSAFE flags passed
  when binding event channels to handlers. Add svn:keywords to the files in
  sys/dev/xen/xenpci.

Modified:
  user/dfr/xenhvm/6/sys/dev/xen/xenpci/evtchn.c   (contents, props changed)
  user/dfr/xenhvm/6/sys/dev/xen/xenpci/machine_reboot.c   (contents, props changed)
  user/dfr/xenhvm/6/sys/dev/xen/xenpci/xenpci.c   (props changed)
  user/dfr/xenhvm/6/sys/dev/xen/xenpci/xenpcivar.h   (props changed)

Modified: user/dfr/xenhvm/6/sys/dev/xen/xenpci/evtchn.c
==============================================================================
--- user/dfr/xenhvm/6/sys/dev/xen/xenpci/evtchn.c	Fri Dec 12 14:03:04 2008	(r185987)
+++ user/dfr/xenhvm/6/sys/dev/xen/xenpci/evtchn.c	Fri Dec 12 14:06:21 2008	(r185988)
@@ -29,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: user/dfr/xenhvm/6/sys/xen/evtchn/evtchn.c 184235 2008-10-25 00:25:25Z kmacy $");
+__FBSDID("$FreeBSD$");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -70,6 +70,7 @@ static struct {
 	int close:1; /* close on unbind_from_irqhandler()? */
 	int inuse:1;
 	int in_handler:1;
+	int mpsafe:1;
 } irq_evtchn[256];
 static int evtchn_to_irq[NR_EVENT_CHANNELS] = {
 	[0 ...  NR_EVENT_CHANNELS-1] = -1 };
@@ -167,6 +168,7 @@ bind_listening_port_to_irqhandler(unsign
 	irq_evtchn[irq].arg     = arg;
 	irq_evtchn[irq].evtchn  = alloc_unbound.port;
 	irq_evtchn[irq].close   = 1;
+	irq_evtchn[irq].mpsafe  = (irqflags & INTR_MPSAFE) != 0;
 
 	evtchn_to_irq[alloc_unbound.port] = irq;
 
@@ -196,6 +198,7 @@ bind_caller_port_to_irqhandler(unsigned 
 	irq_evtchn[irq].arg     = arg;
 	irq_evtchn[irq].evtchn  = caller_port;
 	irq_evtchn[irq].close   = 0;
+	irq_evtchn[irq].mpsafe  = (irqflags & INTR_MPSAFE) != 0;
 
 	evtchn_to_irq[caller_port] = irq;
 
@@ -262,7 +265,7 @@ evtchn_interrupt(void *arg)
 	int cpu = 0; /*smp_processor_id();*/
 	driver_intr_t *handler;
 	void *handler_arg;
-	int irq;
+	int irq, handler_mpsafe;
 	shared_info_t *s = HYPERVISOR_shared_info;
 	vcpu_info_t *v = &s->vcpu_info[cpu];
 	struct pcpu *pc = pcpu_find(cpu);
@@ -317,6 +320,7 @@ evtchn_interrupt(void *arg)
 			mtx_lock(&irq_evtchn[irq].lock);
 			handler = irq_evtchn[irq].handler;
 			handler_arg = irq_evtchn[irq].arg;
+			handler_mpsafe = irq_evtchn[irq].mpsafe;
 			if (unlikely(handler == NULL)) {
 				printf("Xen IRQ%d (port %d) has no handler!\n",
 				       irq, port);
@@ -327,7 +331,11 @@ evtchn_interrupt(void *arg)
 			mtx_unlock(&irq_evtchn[irq].lock);
 
 			//local_irq_enable();
+			if (!handler_mpsafe)
+				mtx_lock(&Giant);
 			handler(handler_arg);
+			if (!handler_mpsafe)
+				mtx_unlock(&Giant);
 			//local_irq_disable();
 
 			mtx_lock(&irq_evtchn[irq].lock);
@@ -399,7 +407,7 @@ xenpci_irq_init(device_t device, struct 
 	}
 
 	error = BUS_SETUP_INTR(device_get_parent(device), device,
-	    scp->res_irq, INTR_TYPE_MISC, evtchn_interrupt, NULL,
+	    scp->res_irq, INTR_MPSAFE|INTR_TYPE_MISC, evtchn_interrupt, NULL,
 	    &scp->intr_cookie);
 	if (error)
 		return (error);

Modified: user/dfr/xenhvm/6/sys/dev/xen/xenpci/machine_reboot.c
==============================================================================
--- user/dfr/xenhvm/6/sys/dev/xen/xenpci/machine_reboot.c	Fri Dec 12 14:03:04 2008	(r185987)
+++ user/dfr/xenhvm/6/sys/dev/xen/xenpci/machine_reboot.c	Fri Dec 12 14:06:21 2008	(r185988)
@@ -1,5 +1,5 @@
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: user/dfr/xenhvm/6/sys/xen/evtchn/evtchn.c 184235 2008-10-25 00:25:25Z kmacy $");
+__FBSDID("$FreeBSD$");
 
 #include <sys/param.h>
 #include <sys/systm.h>


More information about the svn-src-user mailing list