Page MenuHomeFreeBSD

D31188.id98342.diff
No OneTemporary

D31188.id98342.diff

Index: sys/xen/xen_intr.c
===================================================================
--- sys/xen/xen_intr.c
+++ sys/xen/xen_intr.c
@@ -239,7 +239,7 @@
* \return A pointer to a free Xen interrupt source object or NULL.
*/
static struct xenisrc *
-xen_intr_find_unused_isrc(enum evtchn_type type)
+xen_intr_find_unused_isrc(void)
{
u_int isrc_idx;
@@ -251,11 +251,9 @@
vector = first_evtchn_irq + isrc_idx;
isrc = (struct xenisrc *)intr_lookup_source(vector);
- if (isrc != NULL
- && isrc->xi_type == EVTCHN_TYPE_UNBOUND) {
+ if (isrc != NULL && isrc->xi_type == EVTCHN_TYPE_UNBOUND) {
KASSERT(!xen_arch_intr_has_handlers(isrc),
("Free evtchn still has handlers"));
- isrc->xi_type = type;
return (isrc);
}
}
@@ -271,18 +269,18 @@
* object or NULL.
*/
static struct xenisrc *
-xen_intr_alloc_isrc(enum evtchn_type type)
+xen_intr_alloc_isrc(const struct xenisrc *const params)
{
static int warned;
struct xenisrc *isrc;
unsigned int vector;
mtx_lock(&xen_intr_x86_lock);
- isrc = xen_intr_find_unused_isrc(type);
+ isrc = xen_intr_find_unused_isrc();
if (isrc != NULL) {
mtx_unlock(&xen_intr_x86_lock);
- return (isrc);
+ goto out;
}
if (xen_intr_auto_vector_count >= NR_EVENT_CHANNELS) {
@@ -304,12 +302,15 @@
isrc = malloc(sizeof(*isrc), M_XENINTR, M_WAITOK | M_ZERO);
isrc->xi_arch.xai_intsrc.is_pic = &xen_intr_pic;
isrc->xi_arch.xai_vector = vector;
- isrc->xi_type = type;
if (intr_register_source(&isrc->xi_arch.xai_intsrc) != 0) {
free(isrc, M_XENINTR);
return (NULL);
}
+out: ;
+ CTASSERT(offsetof(struct xenisrc, xi_arch) == 0);
+ memcpy(&isrc->xi_arch + 1, &params->xi_arch + 1,
+ sizeof(struct xenisrc) - sizeof(xen_arch_isrc_t));
return (isrc);
}
@@ -385,10 +386,9 @@
* \returns 0 on success, otherwise an errno.
*/
static int
-xen_intr_bind_isrc(struct xenisrc **isrcp, evtchn_port_t local_port,
- enum evtchn_type type, const char *intr_owner, driver_filter_t filter,
- driver_intr_t handler, void *arg, enum intr_type flags,
- xen_intr_handle_t *port_handlep)
+xen_intr_bind_isrc(struct xenisrc **isrcp, const struct xenisrc *params,
+ const char *intr_owner, driver_filter_t filter, driver_intr_t handler,
+ void *arg, enum intr_type flags, xen_intr_handle_t *port_handlep)
{
struct xenisrc *isrc;
int error;
@@ -399,11 +399,10 @@
return (EINVAL);
}
- isrc = xen_intr_alloc_isrc(type);
+ isrc = xen_intr_alloc_isrc(params);
if (isrc == NULL)
return (ENOSPC);
mtx_lock(&xen_intr_isrc_lock);
- isrc->xi_port = local_port;
xen_intr_port_to_isrc[isrc->xi_port] = isrc;
refcount_init(&isrc->xi_refcount, 1);
mtx_unlock(&xen_intr_isrc_lock);
@@ -412,7 +411,7 @@
*port_handlep = xen_intr_handle_from_isrc(isrc);
#ifdef SMP
- if (type == EVTCHN_TYPE_PORT) {
+ if (params->xi_type == EVTCHN_TYPE_PORT) {
/*
* By default all interrupts are assigned to vCPU#0
* unless specified otherwise, so shuffle them to balance
@@ -928,20 +927,18 @@
enum intr_type flags, xen_intr_handle_t *port_handlep)
{
struct xenisrc *isrc;
- int error;
-
- error = xen_intr_bind_isrc(&isrc, local_port, EVTCHN_TYPE_PORT,
- device_get_nameunit(dev), filter, handler, arg, flags,
- port_handlep);
- if (error != 0)
- return (error);
+ struct xenisrc params = {
+ .xi_type = EVTCHN_TYPE_PORT,
+ .xi_port = local_port,
+ /*
+ * The Event Channel API didn't open this port, so it is not
+ * responsible for closing it automatically on unbind.
+ */
+ .xi_close = 0,
+ };
- /*
- * The Event Channel API didn't open this port, so it is not
- * responsible for closing it automatically on unbind.
- */
- isrc->xi_close = 0;
- return (0);
+ return (xen_intr_bind_isrc(&isrc, &params, device_get_nameunit(dev),
+ filter, handler, arg, flags, port_handlep));
}
int
@@ -950,6 +947,9 @@
enum intr_type flags, xen_intr_handle_t *port_handlep)
{
struct xenisrc *isrc;
+ struct xenisrc params = {
+ .xi_type = EVTCHN_TYPE_PORT,
+ };
struct evtchn_alloc_unbound alloc_unbound;
int error;
@@ -965,11 +965,11 @@
return (-error);
}
- error = xen_intr_bind_isrc(&isrc, alloc_unbound.port, EVTCHN_TYPE_PORT,
- device_get_nameunit(dev), filter, handler, arg, flags,
- port_handlep);
+ params.xi_port = alloc_unbound.port;
+ error = xen_intr_bind_isrc(&isrc, &params, device_get_nameunit(dev),
+ filter, handler, arg, flags, port_handlep);
if (error != 0) {
- evtchn_close_t close = { .port = alloc_unbound.port };
+ evtchn_close_t close = { .port = params.xi_port };
if (HYPERVISOR_event_channel_op(EVTCHNOP_close, &close))
panic("EVTCHNOP_close failed");
return (error);
@@ -985,6 +985,9 @@
void *arg, enum intr_type flags, xen_intr_handle_t *port_handlep)
{
struct xenisrc *isrc;
+ struct xenisrc params = {
+ .xi_type = EVTCHN_TYPE_PORT,
+ };
struct evtchn_bind_interdomain bind_interdomain;
int error;
@@ -1000,11 +1003,11 @@
return (-error);
}
- error = xen_intr_bind_isrc(&isrc, bind_interdomain.local_port,
- EVTCHN_TYPE_PORT, device_get_nameunit(dev), filter, handler, arg,
- flags, port_handlep);
+ params.xi_port = bind_interdomain.local_port;
+ error = xen_intr_bind_isrc(&isrc, &params, device_get_nameunit(dev),
+ filter, handler, arg, flags, port_handlep);
if (error) {
- evtchn_close_t close = { .port = bind_interdomain.local_port };
+ evtchn_close_t close = { .port = params.xi_port };
if (HYPERVISOR_event_channel_op(EVTCHNOP_close, &close))
panic("EVTCHNOP_close failed");
return (error);
@@ -1025,6 +1028,10 @@
{
u_int vcpu_id = PCPU_ID_GET(cpu);
struct xenisrc *isrc;
+ struct xenisrc params = {
+ .xi_type = EVTCHN_TYPE_VIRQ,
+ .xi_virq = virq,
+ };
struct evtchn_bind_virq bind_virq = { .virq = virq, .vcpu = vcpu_id };
int error;
@@ -1038,9 +1045,9 @@
return (-error);
}
- error = xen_intr_bind_isrc(&isrc, bind_virq.port, EVTCHN_TYPE_VIRQ,
- device_get_nameunit(dev), filter, handler, arg, flags,
- port_handlep);
+ params.xi_port = bind_virq.port;
+ error = xen_intr_bind_isrc(&isrc, &params, device_get_nameunit(dev),
+ filter, handler, arg, flags, port_handlep);
#ifdef SMP
if (error == 0)
@@ -1048,7 +1055,7 @@
#endif
if (error != 0) {
- evtchn_close_t close = { .port = bind_virq.port };
+ evtchn_close_t close = { .port = params.xi_port };
xen_intr_unbind(*port_handlep);
if (HYPERVISOR_event_channel_op(EVTCHNOP_close, &close))
@@ -1073,7 +1080,6 @@
* responsible for closing it automatically on unbind.
*/
isrc->xi_close = 1;
- isrc->xi_virq = virq;
return (0);
}
@@ -1085,6 +1091,9 @@
#ifdef SMP
u_int vcpu_id = PCPU_ID_GET(cpu);
struct xenisrc *isrc;
+ struct xenisrc params = {
+ .xi_type = EVTCHN_TYPE_IPI,
+ };
struct evtchn_bind_ipi bind_ipi = { .vcpu = vcpu_id };
/* Same size as the one used by intr_handler->ih_name. */
char name[MAXCOMLEN + 1];
@@ -1100,12 +1109,13 @@
return (-error);
}
+ params.xi_port = bind_ipi.port;
snprintf(name, sizeof(name), "cpu%u", cpu);
- error = xen_intr_bind_isrc(&isrc, bind_ipi.port, EVTCHN_TYPE_IPI,
- name, filter, NULL, NULL, flags, port_handlep);
+ error = xen_intr_bind_isrc(&isrc, &params, name, filter, NULL, NULL,
+ flags, port_handlep);
if (error != 0) {
- evtchn_close_t close = { .port = bind_ipi.port };
+ evtchn_close_t close = { .port = params.xi_port };
xen_intr_unbind(*port_handlep);
if (HYPERVISOR_event_channel_op(EVTCHNOP_close, &close))

File Metadata

Mime Type
text/plain
Expires
Sun, Apr 12, 2:22 AM (11 h, 32 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
31323449
Default Alt Text
D31188.id98342.diff (7 KB)

Event Timeline