Commit eee413e6 authored by Parav Pandit's avatar Parav Pandit Committed by Alex Williamson

vfio-mdev/mtty: Simplify interrupt generation

While generating interrupt, mdev_state is already available for which
interrupt is generated.
Instead of doing indirect way from state->device->uuid-> to searching
state linearly in linked list on every interrupt generation,
directly use the available state.

Hence, simplify the code to use mdev_state and remove unused helper
function with that.
Reviewed-by: default avatarCornelia Huck <cohuck@redhat.com>
Signed-off-by: default avatarParav Pandit <parav@mellanox.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarAlex Williamson <alex.williamson@redhat.com>
parent d1abaeb3
...@@ -152,20 +152,9 @@ static const struct file_operations vd_fops = { ...@@ -152,20 +152,9 @@ static const struct file_operations vd_fops = {
/* function prototypes */ /* function prototypes */
static int mtty_trigger_interrupt(const guid_t *uuid); static int mtty_trigger_interrupt(struct mdev_state *mdev_state);
/* Helper functions */ /* Helper functions */
static struct mdev_state *find_mdev_state_by_uuid(const guid_t *uuid)
{
struct mdev_state *mds;
list_for_each_entry(mds, &mdev_devices_list, next) {
if (guid_equal(mdev_uuid(mds->mdev), uuid))
return mds;
}
return NULL;
}
static void dump_buffer(u8 *buf, uint32_t count) static void dump_buffer(u8 *buf, uint32_t count)
{ {
...@@ -337,8 +326,7 @@ static void handle_bar_write(unsigned int index, struct mdev_state *mdev_state, ...@@ -337,8 +326,7 @@ static void handle_bar_write(unsigned int index, struct mdev_state *mdev_state,
pr_err("Serial port %d: Fifo level trigger\n", pr_err("Serial port %d: Fifo level trigger\n",
index); index);
#endif #endif
mtty_trigger_interrupt( mtty_trigger_interrupt(mdev_state);
mdev_uuid(mdev_state->mdev));
} }
} else { } else {
#if defined(DEBUG_INTR) #if defined(DEBUG_INTR)
...@@ -352,8 +340,7 @@ static void handle_bar_write(unsigned int index, struct mdev_state *mdev_state, ...@@ -352,8 +340,7 @@ static void handle_bar_write(unsigned int index, struct mdev_state *mdev_state,
*/ */
if (mdev_state->s[index].uart_reg[UART_IER] & if (mdev_state->s[index].uart_reg[UART_IER] &
UART_IER_RLSI) UART_IER_RLSI)
mtty_trigger_interrupt( mtty_trigger_interrupt(mdev_state);
mdev_uuid(mdev_state->mdev));
} }
mutex_unlock(&mdev_state->rxtx_lock); mutex_unlock(&mdev_state->rxtx_lock);
break; break;
...@@ -372,8 +359,7 @@ static void handle_bar_write(unsigned int index, struct mdev_state *mdev_state, ...@@ -372,8 +359,7 @@ static void handle_bar_write(unsigned int index, struct mdev_state *mdev_state,
pr_err("Serial port %d: IER_THRI write\n", pr_err("Serial port %d: IER_THRI write\n",
index); index);
#endif #endif
mtty_trigger_interrupt( mtty_trigger_interrupt(mdev_state);
mdev_uuid(mdev_state->mdev));
} }
mutex_unlock(&mdev_state->rxtx_lock); mutex_unlock(&mdev_state->rxtx_lock);
...@@ -444,7 +430,7 @@ static void handle_bar_write(unsigned int index, struct mdev_state *mdev_state, ...@@ -444,7 +430,7 @@ static void handle_bar_write(unsigned int index, struct mdev_state *mdev_state,
#if defined(DEBUG_INTR) #if defined(DEBUG_INTR)
pr_err("Serial port %d: MCR_OUT2 write\n", index); pr_err("Serial port %d: MCR_OUT2 write\n", index);
#endif #endif
mtty_trigger_interrupt(mdev_uuid(mdev_state->mdev)); mtty_trigger_interrupt(mdev_state);
} }
if ((mdev_state->s[index].uart_reg[UART_IER] & UART_IER_MSI) && if ((mdev_state->s[index].uart_reg[UART_IER] & UART_IER_MSI) &&
...@@ -452,7 +438,7 @@ static void handle_bar_write(unsigned int index, struct mdev_state *mdev_state, ...@@ -452,7 +438,7 @@ static void handle_bar_write(unsigned int index, struct mdev_state *mdev_state,
#if defined(DEBUG_INTR) #if defined(DEBUG_INTR)
pr_err("Serial port %d: MCR RTS/DTR write\n", index); pr_err("Serial port %d: MCR RTS/DTR write\n", index);
#endif #endif
mtty_trigger_interrupt(mdev_uuid(mdev_state->mdev)); mtty_trigger_interrupt(mdev_state);
} }
break; break;
...@@ -503,8 +489,7 @@ static void handle_bar_read(unsigned int index, struct mdev_state *mdev_state, ...@@ -503,8 +489,7 @@ static void handle_bar_read(unsigned int index, struct mdev_state *mdev_state,
#endif #endif
if (mdev_state->s[index].uart_reg[UART_IER] & if (mdev_state->s[index].uart_reg[UART_IER] &
UART_IER_THRI) UART_IER_THRI)
mtty_trigger_interrupt( mtty_trigger_interrupt(mdev_state);
mdev_uuid(mdev_state->mdev));
} }
mutex_unlock(&mdev_state->rxtx_lock); mutex_unlock(&mdev_state->rxtx_lock);
...@@ -1028,17 +1013,9 @@ static int mtty_set_irqs(struct mdev_device *mdev, uint32_t flags, ...@@ -1028,17 +1013,9 @@ static int mtty_set_irqs(struct mdev_device *mdev, uint32_t flags,
return ret; return ret;
} }
static int mtty_trigger_interrupt(const guid_t *uuid) static int mtty_trigger_interrupt(struct mdev_state *mdev_state)
{ {
int ret = -1; int ret = -1;
struct mdev_state *mdev_state;
mdev_state = find_mdev_state_by_uuid(uuid);
if (!mdev_state) {
pr_info("%s: mdev not found\n", __func__);
return -EINVAL;
}
if ((mdev_state->irq_index == VFIO_PCI_MSI_IRQ_INDEX) && if ((mdev_state->irq_index == VFIO_PCI_MSI_IRQ_INDEX) &&
(!mdev_state->msi_evtfd)) (!mdev_state->msi_evtfd))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment