diff options
Diffstat (limited to 'sys/xen/evtchn/evtchn.c')
-rw-r--r-- | sys/xen/evtchn/evtchn.c | 118 |
1 files changed, 72 insertions, 46 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); } |