summaryrefslogtreecommitdiffstats
path: root/sys/xen/evtchn
diff options
context:
space:
mode:
authorkmacy <kmacy@FreeBSD.org>2008-12-29 06:31:03 +0000
committerkmacy <kmacy@FreeBSD.org>2008-12-29 06:31:03 +0000
commit9198d09682e0ff9e4b99c1a500c60ec311f33516 (patch)
tree78f4ff4cfc0d598fd6e8ccc01fa628fc8ded089f /sys/xen/evtchn
parente46dfc4a1843e8da9da2fceed45ebc43d45d62b1 (diff)
downloadFreeBSD-src-9198d09682e0ff9e4b99c1a500c60ec311f33516.zip
FreeBSD-src-9198d09682e0ff9e4b99c1a500c60ec311f33516.tar.gz
merge 186535, 186537, and 186538 from releng_7_xen
Log: - merge in latest xenbus from dfr's xenhvm - fix race condition in xs_read_reply by converting tsleep to mtx_sleep Log: unmask evtchn in bind_{virq, ipi}_to_irq Log: - remove code for handling case of not being able to sleep - eliminate tsleep - make sleeps atomic
Diffstat (limited to 'sys/xen/evtchn')
-rw-r--r--sys/xen/evtchn/evtchn.c118
-rw-r--r--sys/xen/evtchn/evtchn_dev.c6
2 files changed, 75 insertions, 49 deletions
diff --git a/sys/xen/evtchn/evtchn.c b/sys/xen/evtchn/evtchn.c
index b28315c..884270c 100644
--- a/sys/xen/evtchn/evtchn.c
+++ b/sys/xen/evtchn/evtchn.c
@@ -23,10 +23,10 @@ __FBSDID("$FreeBSD$");
#include <machine/cpufunc.h>
#include <machine/intr_machdep.h>
#include <machine/xen/xen-os.h>
-#include <machine/xen/xen_intr.h>
+#include <xen/xen_intr.h>
#include <machine/xen/synch_bitops.h>
-#include <machine/xen/evtchn.h>
-#include <machine/xen/hypervisor.h>
+#include <xen/evtchn.h>
+#include <xen/hypervisor.h>
#include <sys/smp.h>
@@ -76,6 +76,7 @@ static struct mtx irq_mapping_update_lock;
static struct xenpic *xp;
struct xenpic_intsrc {
struct intsrc xp_intsrc;
+ void *xp_cookie;
uint8_t xp_vector;
boolean_t xp_masked;
};
@@ -295,6 +296,7 @@ bind_caller_port_to_irq(unsigned int caller_port)
}
irq_bindcount[irq]++;
+ unmask_evtchn(caller_port);
out:
mtx_unlock_spin(&irq_mapping_update_lock);
@@ -320,6 +322,7 @@ bind_local_port_to_irq(unsigned int local_port)
evtchn_to_irq[local_port] = irq;
irq_info[irq] = mk_irq_info(IRQT_LOCAL_PORT, 0, local_port);
irq_bindcount[irq]++;
+ unmask_evtchn(local_port);
out:
mtx_unlock_spin(&irq_mapping_update_lock);
@@ -361,7 +364,7 @@ static int
bind_virq_to_irq(unsigned int virq, unsigned int cpu)
{
struct evtchn_bind_virq bind_virq;
- int evtchn, irq;
+ int evtchn = 0, irq;
mtx_lock_spin(&irq_mapping_update_lock);
@@ -385,6 +388,7 @@ bind_virq_to_irq(unsigned int virq, unsigned int cpu)
}
irq_bindcount[irq]++;
+ unmask_evtchn(evtchn);
out:
mtx_unlock_spin(&irq_mapping_update_lock);
@@ -398,8 +402,9 @@ int
bind_ipi_to_irq(unsigned int ipi, unsigned int cpu)
{
struct evtchn_bind_ipi bind_ipi;
- int evtchn, irq;
-
+ int irq;
+ int evtchn = 0;
+
mtx_lock_spin(&irq_mapping_update_lock);
if ((irq = per_cpu(ipi_to_irq, cpu)[ipi]) == -1) {
@@ -418,6 +423,7 @@ bind_ipi_to_irq(unsigned int ipi, unsigned int cpu)
bind_evtchn_to_cpu(evtchn, cpu);
}
irq_bindcount[irq]++;
+ unmask_evtchn(evtchn);
out:
mtx_unlock_spin(&irq_mapping_update_lock);
@@ -465,20 +471,25 @@ bind_caller_port_to_irqhandler(unsigned int caller_port,
driver_intr_t handler,
void *arg,
unsigned long irqflags,
- void **cookiep)
+ unsigned int *irqp)
{
unsigned int irq;
- int retval;
+ int error;
irq = bind_caller_port_to_irq(caller_port);
intr_register_source(&xp->xp_pins[irq].xp_intsrc);
- retval = intr_add_handler(devname, irq, NULL, handler, arg, irqflags, cookiep);
- if (retval != 0) {
+ error = intr_add_handler(devname, irq, NULL, handler, arg, irqflags,
+ &xp->xp_pins[irq].xp_cookie);
+
+ if (error) {
unbind_from_irq(irq);
- return -retval;
+ return (error);
}
- return irq;
+ if (irqp)
+ *irqp = irq;
+
+ return (0);
}
int
@@ -488,43 +499,50 @@ bind_listening_port_to_irqhandler(
driver_intr_t handler,
void *arg,
unsigned long irqflags,
- void **cookiep)
+ unsigned int *irqp)
{
unsigned int irq;
- int retval;
+ int error;
irq = bind_listening_port_to_irq(remote_domain);
intr_register_source(&xp->xp_pins[irq].xp_intsrc);
- retval = intr_add_handler(devname, irq, NULL, handler, arg, irqflags, cookiep);
- if (retval != 0) {
+ error = intr_add_handler(devname, irq, NULL, handler, arg, irqflags,
+ &xp->xp_pins[irq].xp_cookie);
+ if (error) {
unbind_from_irq(irq);
- return -retval;
+ return (error);
}
-
- return irq;
+ if (irqp)
+ *irqp = irq;
+
+ return (0);
}
int
bind_interdomain_evtchn_to_irqhandler(
- unsigned int remote_domain,
- unsigned int remote_port,
- const char *devname,
- driver_filter_t filter,
- driver_intr_t handler,
- unsigned long irqflags)
+ unsigned int remote_domain,
+ unsigned int remote_port,
+ const char *devname,
+ driver_filter_t filter,
+ driver_intr_t handler,
+ unsigned long irqflags,
+ unsigned int *irqp)
{
unsigned int irq;
- int retval;
+ int error;
irq = bind_interdomain_evtchn_to_irq(remote_domain, remote_port);
intr_register_source(&xp->xp_pins[irq].xp_intsrc);
- retval = intr_add_handler(devname, irq, filter, handler, NULL, irqflags, NULL);
- if (retval != 0) {
+ error = intr_add_handler(devname, irq, filter, handler, NULL,
+ irqflags, &xp->xp_pins[irq].xp_cookie);
+ if (error) {
unbind_from_irq(irq);
- return -retval;
+ return (error);
}
- return irq;
+ if (irqp)
+ *irqp = irq;
+ return (0);
}
int
@@ -533,20 +551,25 @@ bind_virq_to_irqhandler(unsigned int virq,
const char *devname,
driver_filter_t filter,
driver_intr_t handler,
- unsigned long irqflags)
+ void *arg,
+ unsigned long irqflags,
+ unsigned int *irqp)
{
unsigned int irq;
- int retval;
+ int error;
irq = bind_virq_to_irq(virq, cpu);
intr_register_source(&xp->xp_pins[irq].xp_intsrc);
- retval = intr_add_handler(devname, irq, filter, handler, NULL, irqflags, NULL);
- if (retval != 0) {
+ error = intr_add_handler(devname, irq, filter, handler,
+ arg, irqflags, &xp->xp_pins[irq].xp_cookie);
+ if (error) {
unbind_from_irq(irq);
- return -retval;
+ return (error);
}
- return irq;
+ if (irqp)
+ *irqp = irq;
+ return (0);
}
int
@@ -554,27 +577,30 @@ bind_ipi_to_irqhandler(unsigned int ipi,
unsigned int cpu,
const char *devname,
driver_filter_t filter,
- unsigned long irqflags)
+ unsigned long irqflags,
+ unsigned int *irqp)
{
- int irq, retval;
+ unsigned int irq;
+ int error;
irq = bind_ipi_to_irq(ipi, cpu);
intr_register_source(&xp->xp_pins[irq].xp_intsrc);
- retval = intr_add_handler(devname, irq, filter, NULL,
- NULL, irqflags, NULL);
- if (retval != 0) {
+ error = intr_add_handler(devname, irq, filter, NULL,
+ NULL, irqflags, &xp->xp_pins[irq].xp_cookie);
+ if (error) {
unbind_from_irq(irq);
- return -retval;
+ return (error);
}
- return irq;
+ if (irqp)
+ *irqp = irq;
+ return (0);
}
void
-unbind_from_irqhandler(unsigned int irq, void *dev_id)
+unbind_from_irqhandler(unsigned int irq)
{
- if (dev_id)
- intr_remove_handler(dev_id); /* XXX */
+ intr_remove_handler(xp->xp_pins[irq].xp_cookie);
unbind_from_irq(irq);
}
diff --git a/sys/xen/evtchn/evtchn_dev.c b/sys/xen/evtchn/evtchn_dev.c
index 111b066..ea12860 100644
--- a/sys/xen/evtchn/evtchn_dev.c
+++ b/sys/xen/evtchn/evtchn_dev.c
@@ -26,13 +26,13 @@ __FBSDID("$FreeBSD$");
#include <machine/cpufunc.h>
#include <machine/intr_machdep.h>
#include <machine/xen/xen-os.h>
-#include <machine/xen/xen_intr.h>
+#include <xen/xen_intr.h>
#include <machine/bus.h>
#include <sys/rman.h>
#include <machine/resource.h>
#include <machine/xen/synch_bitops.h>
-#include <machine/xen/hypervisor.h>
-#include <machine/xen/evtchn.h>
+#include <xen/hypervisor.h>
+#include <xen/evtchn.h>
typedef struct evtchn_sotfc {
OpenPOWER on IntegriCloud