Index: sys/xen/xen_intr.c =================================================================== --- sys/xen/xen_intr.c +++ sys/xen/xen_intr.c @@ -992,6 +992,7 @@ struct xenisrc params = { .xi_type = EVTCHN_TYPE_PORT, .xi_cpu = ~0U, + .xi_close = 1, }; struct evtchn_alloc_unbound alloc_unbound; int error; @@ -1009,17 +1010,8 @@ } params.xi_port = alloc_unbound.port; - error = xen_intr_bind_isrc(&isrc, ¶ms, device_get_nameunit(dev), - filter, handler, arg, flags, port_handlep); - if (error != 0) { - evtchn_close_t close = { .port = params.xi_port }; - if (HYPERVISOR_event_channel_op(EVTCHNOP_close, &close)) - panic("EVTCHNOP_close failed"); - return (error); - } - - isrc->xi_close = 1; - return (0); + return (xen_intr_bind_isrc(&isrc, ¶ms, device_get_nameunit(dev), + filter, handler, arg, flags, port_handlep)); } int @@ -1031,6 +1023,11 @@ struct xenisrc params = { .xi_type = EVTCHN_TYPE_PORT, .xi_cpu = ~0U, + /* + * The Event Channel API opened this port, so it is + * responsible for closing it automatically on unbind. + */ + .xi_close = 1, }; struct evtchn_bind_interdomain bind_interdomain; int error; @@ -1048,21 +1045,8 @@ } params.xi_port = bind_interdomain.local_port; - error = xen_intr_bind_isrc(&isrc, ¶ms, device_get_nameunit(dev), - filter, handler, arg, flags, port_handlep); - if (error) { - evtchn_close_t close = { .port = params.xi_port }; - if (HYPERVISOR_event_channel_op(EVTCHNOP_close, &close)) - panic("EVTCHNOP_close failed"); - return (error); - } - - /* - * The Event Channel API opened this port, so it is - * responsible for closing it automatically on unbind. - */ - isrc->xi_close = 1; - return (0); + return (xen_intr_bind_isrc(&isrc, ¶ms, device_get_nameunit(dev), + filter, handler, arg, flags, port_handlep)); } int @@ -1076,6 +1060,11 @@ .xi_type = EVTCHN_TYPE_VIRQ, .xi_cpu = cpu, .xi_virq = virq, + /* + * The Event Channel API opened this port, so it is + * responsible for closing it automatically on unbind. + */ + .xi_close = 1, }; struct evtchn_bind_virq bind_virq = { .virq = virq, .vcpu = vcpu_id }; int error; @@ -1091,25 +1080,8 @@ } params.xi_port = bind_virq.port; - error = xen_intr_bind_isrc(&isrc, ¶ms, device_get_nameunit(dev), - filter, handler, arg, flags, port_handlep); - - if (error != 0) { - evtchn_close_t close = { .port = params.xi_port }; - - xen_intr_unbind(*port_handlep); - if (HYPERVISOR_event_channel_op(EVTCHNOP_close, &close)) - panic("EVTCHNOP_close failed"); - return (error); - } - - /* - * The Event Channel API opened this port, so it is - * responsible for closing it automatically on unbind. - */ - isrc->xi_close = 1; - - return (0); + return (xen_intr_bind_isrc(&isrc, ¶ms, device_get_nameunit(dev), + filter, handler, arg, flags, port_handlep)); } int @@ -1122,6 +1094,11 @@ struct xenisrc params = { .xi_type = EVTCHN_TYPE_IPI, .xi_cpu = cpu, + /* + * The Event Channel API opened this port, so it is + * responsible for closing it automatically on unbind. + */ + .xi_close = 1, }; struct evtchn_bind_ipi bind_ipi = { .vcpu = vcpu_id }; /* Same size as the one used by intr_handler->ih_name. */ @@ -1141,23 +1118,8 @@ params.xi_port = bind_ipi.port; snprintf(name, sizeof(name), "cpu%u", cpu); - error = xen_intr_bind_isrc(&isrc, ¶ms, name, filter, NULL, NULL, - flags, port_handlep); - if (error != 0) { - evtchn_close_t close = { .port = params.xi_port }; - - xen_intr_unbind(*port_handlep); - if (HYPERVISOR_event_channel_op(EVTCHNOP_close, &close)) - panic("EVTCHNOP_close failed"); - return (error); - } - - /* - * The Event Channel API opened this port, so it is - * responsible for closing it automatically on unbind. - */ - isrc->xi_close = 1; - return (0); + return (xen_intr_bind_isrc(&isrc, ¶ms, name, filter, NULL, NULL, + flags, port_handlep)); #else return (EOPNOTSUPP); #endif