aboutsummaryrefslogtreecommitdiff
path: root/sys/x86/xen
diff options
context:
space:
mode:
authorElliott Mitchell <ehem+freebsd@m5p.com>2021-04-06 08:30:49 +0000
committerRoger Pau Monné <royger@FreeBSD.org>2021-07-28 15:27:03 +0000
commit5ca00e0c985f85a241bbb263c66225a8e9c54ae2 (patch)
tree2bb93756027daefc96b014afda148046214de29e /sys/x86/xen
parentd3705b5a7faca20247b17ceacc7fdf7a8c5f4839 (diff)
downloadsrc-5ca00e0c985f85a241bbb263c66225a8e9c54ae2.tar.gz
src-5ca00e0c985f85a241bbb263c66225a8e9c54ae2.zip
xen/intr: use struct xenisrc * as xen_intr_handle_t
Since xen_intr_handle_t is meant to be an opaque handle and the only use is retrieving the associated struct xenisrc *, directly use it as the opaque handler. Also add a wrapper function for converting the other direction. If some other value becomes appropriate in the future, these two functions will be the only spots needing modification. Reviewed by: mhorne, royger Differential Revision: https://reviews.freebsd.org/D29500
Diffstat (limited to 'sys/x86/xen')
-rw-r--r--sys/x86/xen/xen_intr.c76
1 files changed, 41 insertions, 35 deletions
diff --git a/sys/x86/xen/xen_intr.c b/sys/x86/xen/xen_intr.c
index c729ffddb345..ebbae25c2d9e 100644
--- a/sys/x86/xen/xen_intr.c
+++ b/sys/x86/xen/xen_intr.c
@@ -168,6 +168,38 @@ static u_int xen_intr_auto_vector_count;
static struct xenisrc *xen_intr_port_to_isrc[NR_EVENT_CHANNELS];
/*------------------------- Private Functions --------------------------------*/
+
+/**
+ * Retrieve a handle for a Xen interrupt source.
+ *
+ * \param isrc A valid Xen interrupt source structure.
+ *
+ * \returns A handle suitable for use with xen_intr_isrc_from_handle()
+ * to retrieve the original Xen interrupt source structure.
+ */
+
+static inline xen_intr_handle_t
+xen_intr_handle_from_isrc(struct xenisrc *isrc)
+{
+ return (isrc);
+}
+
+/**
+ * Lookup a Xen interrupt source object given an interrupt binding handle.
+ *
+ * \param handle A handle initialized by a previous call to
+ * xen_intr_bind_isrc().
+ *
+ * \returns A pointer to the Xen interrupt source object associated
+ * with the given interrupt handle. NULL if no association
+ * currently exists.
+ */
+static inline struct xenisrc *
+xen_intr_isrc_from_handle(xen_intr_handle_t handle)
+{
+ return ((struct xenisrc *)handle);
+}
+
/**
* Disable signal delivery for an event channel port on the
* specified CPU.
@@ -393,8 +425,8 @@ xen_intr_bind_isrc(struct xenisrc **isrcp, evtchn_port_t local_port,
refcount_init(&isrc->xi_refcount, 1);
mtx_unlock(&xen_intr_isrc_lock);
- /* Assign the opaque handler (the event channel port) */
- *port_handlep = &isrc->xi_vector;
+ /* Assign the opaque handler */
+ *port_handlep = xen_intr_handle_from_isrc(isrc);
#ifdef SMP
if (type == EVTCHN_TYPE_PORT) {
@@ -428,32 +460,6 @@ xen_intr_bind_isrc(struct xenisrc **isrcp, evtchn_port_t local_port,
}
/**
- * Lookup a Xen interrupt source object given an interrupt binding handle.
- *
- * \param handle A handle initialized by a previous call to
- * xen_intr_bind_isrc().
- *
- * \returns A pointer to the Xen interrupt source object associated
- * with the given interrupt handle. NULL if no association
- * currently exists.
- */
-static struct xenisrc *
-xen_intr_isrc(xen_intr_handle_t handle)
-{
- int vector;
-
- if (handle == NULL)
- return (NULL);
-
- vector = *(int *)handle;
- KASSERT(vector >= first_evtchn_irq &&
- vector < (first_evtchn_irq + xen_intr_auto_vector_count),
- ("Xen interrupt vector is out of range"));
-
- return ((struct xenisrc *)intr_lookup_source(vector));
-}
-
-/**
* Determine the event channel ports at the given section of the
* event port bitmap which have pending events for the given cpu.
*
@@ -1195,7 +1201,7 @@ xen_intr_describe(xen_intr_handle_t port_handle, const char *fmt, ...)
struct xenisrc *isrc;
va_list ap;
- isrc = xen_intr_isrc(port_handle);
+ isrc = xen_intr_isrc_from_handle(port_handle);
if (isrc == NULL)
return (EINVAL);
@@ -1213,7 +1219,7 @@ xen_intr_unbind(xen_intr_handle_t *port_handlep)
KASSERT(port_handlep != NULL,
("NULL xen_intr_handle_t passed to xen_intr_unbind"));
- isrc = xen_intr_isrc(*port_handlep);
+ isrc = xen_intr_isrc_from_handle(*port_handlep);
*port_handlep = NULL;
if (isrc == NULL)
return;
@@ -1235,7 +1241,7 @@ xen_intr_signal(xen_intr_handle_t handle)
{
struct xenisrc *isrc;
- isrc = xen_intr_isrc(handle);
+ isrc = xen_intr_isrc_from_handle(handle);
if (isrc != NULL) {
KASSERT(isrc->xi_type == EVTCHN_TYPE_PORT ||
isrc->xi_type == EVTCHN_TYPE_IPI,
@@ -1250,7 +1256,7 @@ xen_intr_port(xen_intr_handle_t handle)
{
struct xenisrc *isrc;
- isrc = xen_intr_isrc(handle);
+ isrc = xen_intr_isrc_from_handle(handle);
if (isrc == NULL)
return (0);
@@ -1265,7 +1271,7 @@ xen_intr_add_handler(const char *name, driver_filter_t filter,
struct xenisrc *isrc;
int error;
- isrc = xen_intr_isrc(handle);
+ isrc = xen_intr_isrc_from_handle(handle);
if (isrc == NULL || isrc->xi_cookie != NULL)
return (EINVAL);
@@ -1299,8 +1305,8 @@ xen_intr_get_evtchn_from_port(evtchn_port_t port, xen_intr_handle_t *handlep)
refcount_acquire(&xen_intr_port_to_isrc[port]->xi_refcount);
mtx_unlock(&xen_intr_isrc_lock);
- /* Assign the opaque handler (the event channel port) */
- *handlep = &xen_intr_port_to_isrc[port]->xi_vector;
+ /* Assign the opaque handler */
+ *handlep = xen_intr_handle_from_isrc(xen_intr_port_to_isrc[port]);
return (0);
}