Commit d86a6d47 authored by Thomas Gleixner's avatar Thomas Gleixner

bus: fsl-mc: fsl-mc-allocator: Rework MSI handling

Storing a pointer to the MSI descriptor just to track the Linux interrupt
number is daft. Just store the interrupt number and be done with it.
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Reviewed-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: default avatarJason Gunthorpe <jgg@nvidia.com>
Link: https://lore.kernel.org/r/20211210221815.207838579@linutronix.de
parent d722e9a5
...@@ -400,7 +400,7 @@ static irqreturn_t dprc_irq0_handler_thread(int irq_num, void *arg) ...@@ -400,7 +400,7 @@ static irqreturn_t dprc_irq0_handler_thread(int irq_num, void *arg)
struct fsl_mc_device *mc_dev = to_fsl_mc_device(dev); struct fsl_mc_device *mc_dev = to_fsl_mc_device(dev);
struct fsl_mc_bus *mc_bus = to_fsl_mc_bus(mc_dev); struct fsl_mc_bus *mc_bus = to_fsl_mc_bus(mc_dev);
struct fsl_mc_io *mc_io = mc_dev->mc_io; struct fsl_mc_io *mc_io = mc_dev->mc_io;
struct msi_desc *msi_desc = mc_dev->irqs[0]->msi_desc; int irq = mc_dev->irqs[0]->virq;
dev_dbg(dev, "DPRC IRQ %d triggered on CPU %u\n", dev_dbg(dev, "DPRC IRQ %d triggered on CPU %u\n",
irq_num, smp_processor_id()); irq_num, smp_processor_id());
...@@ -409,7 +409,7 @@ static irqreturn_t dprc_irq0_handler_thread(int irq_num, void *arg) ...@@ -409,7 +409,7 @@ static irqreturn_t dprc_irq0_handler_thread(int irq_num, void *arg)
return IRQ_HANDLED; return IRQ_HANDLED;
mutex_lock(&mc_bus->scan_mutex); mutex_lock(&mc_bus->scan_mutex);
if (!msi_desc || msi_desc->irq != (u32)irq_num) if (irq != (u32)irq_num)
goto out; goto out;
status = 0; status = 0;
...@@ -521,7 +521,7 @@ static int register_dprc_irq_handler(struct fsl_mc_device *mc_dev) ...@@ -521,7 +521,7 @@ static int register_dprc_irq_handler(struct fsl_mc_device *mc_dev)
* function that programs the MSI physically in the device * function that programs the MSI physically in the device
*/ */
error = devm_request_threaded_irq(&mc_dev->dev, error = devm_request_threaded_irq(&mc_dev->dev,
irq->msi_desc->irq, irq->virq,
dprc_irq0_handler, dprc_irq0_handler,
dprc_irq0_handler_thread, dprc_irq0_handler_thread,
IRQF_NO_SUSPEND | IRQF_ONESHOT, IRQF_NO_SUSPEND | IRQF_ONESHOT,
...@@ -771,7 +771,7 @@ static void dprc_teardown_irq(struct fsl_mc_device *mc_dev) ...@@ -771,7 +771,7 @@ static void dprc_teardown_irq(struct fsl_mc_device *mc_dev)
(void)disable_dprc_irq(mc_dev); (void)disable_dprc_irq(mc_dev);
devm_free_irq(&mc_dev->dev, irq->msi_desc->irq, &mc_dev->dev); devm_free_irq(&mc_dev->dev, irq->virq, &mc_dev->dev);
fsl_mc_free_irqs(mc_dev); fsl_mc_free_irqs(mc_dev);
} }
......
...@@ -350,7 +350,6 @@ int fsl_mc_populate_irq_pool(struct fsl_mc_device *mc_bus_dev, ...@@ -350,7 +350,6 @@ int fsl_mc_populate_irq_pool(struct fsl_mc_device *mc_bus_dev,
unsigned int irq_count) unsigned int irq_count)
{ {
unsigned int i; unsigned int i;
struct msi_desc *msi_desc;
struct fsl_mc_device_irq *irq_resources; struct fsl_mc_device_irq *irq_resources;
struct fsl_mc_device_irq *mc_dev_irq; struct fsl_mc_device_irq *mc_dev_irq;
int error; int error;
...@@ -388,16 +387,12 @@ int fsl_mc_populate_irq_pool(struct fsl_mc_device *mc_bus_dev, ...@@ -388,16 +387,12 @@ int fsl_mc_populate_irq_pool(struct fsl_mc_device *mc_bus_dev,
mc_dev_irq->resource.type = res_pool->type; mc_dev_irq->resource.type = res_pool->type;
mc_dev_irq->resource.data = mc_dev_irq; mc_dev_irq->resource.data = mc_dev_irq;
mc_dev_irq->resource.parent_pool = res_pool; mc_dev_irq->resource.parent_pool = res_pool;
mc_dev_irq->virq = msi_get_virq(&mc_bus_dev->dev, i);
mc_dev_irq->resource.id = mc_dev_irq->virq;
INIT_LIST_HEAD(&mc_dev_irq->resource.node); INIT_LIST_HEAD(&mc_dev_irq->resource.node);
list_add_tail(&mc_dev_irq->resource.node, &res_pool->free_list); list_add_tail(&mc_dev_irq->resource.node, &res_pool->free_list);
} }
for_each_msi_entry(msi_desc, &mc_bus_dev->dev) {
mc_dev_irq = &irq_resources[msi_desc->msi_index];
mc_dev_irq->msi_desc = msi_desc;
mc_dev_irq->resource.id = msi_desc->irq;
}
res_pool->max_count = irq_count; res_pool->max_count = irq_count;
res_pool->free_count = irq_count; res_pool->free_count = irq_count;
mc_bus->irq_resources = irq_resources; mc_bus->irq_resources = irq_resources;
......
...@@ -58,11 +58,11 @@ static void fsl_mc_msi_update_dom_ops(struct msi_domain_info *info) ...@@ -58,11 +58,11 @@ static void fsl_mc_msi_update_dom_ops(struct msi_domain_info *info)
} }
static void __fsl_mc_msi_write_msg(struct fsl_mc_device *mc_bus_dev, static void __fsl_mc_msi_write_msg(struct fsl_mc_device *mc_bus_dev,
struct fsl_mc_device_irq *mc_dev_irq) struct fsl_mc_device_irq *mc_dev_irq,
struct msi_desc *msi_desc)
{ {
int error; int error;
struct fsl_mc_device *owner_mc_dev = mc_dev_irq->mc_dev; struct fsl_mc_device *owner_mc_dev = mc_dev_irq->mc_dev;
struct msi_desc *msi_desc = mc_dev_irq->msi_desc;
struct dprc_irq_cfg irq_cfg; struct dprc_irq_cfg irq_cfg;
/* /*
...@@ -129,7 +129,7 @@ static void fsl_mc_msi_write_msg(struct irq_data *irq_data, ...@@ -129,7 +129,7 @@ static void fsl_mc_msi_write_msg(struct irq_data *irq_data,
/* /*
* Program the MSI (paddr, value) pair in the device: * Program the MSI (paddr, value) pair in the device:
*/ */
__fsl_mc_msi_write_msg(mc_bus_dev, mc_dev_irq); __fsl_mc_msi_write_msg(mc_bus_dev, mc_dev_irq, msi_desc);
} }
static void fsl_mc_msi_update_chip_ops(struct msi_domain_info *info) static void fsl_mc_msi_update_chip_ops(struct msi_domain_info *info)
......
...@@ -4246,7 +4246,7 @@ static int dpaa2_eth_setup_irqs(struct fsl_mc_device *ls_dev) ...@@ -4246,7 +4246,7 @@ static int dpaa2_eth_setup_irqs(struct fsl_mc_device *ls_dev)
} }
irq = ls_dev->irqs[0]; irq = ls_dev->irqs[0];
err = devm_request_threaded_irq(&ls_dev->dev, irq->msi_desc->irq, err = devm_request_threaded_irq(&ls_dev->dev, irq->virq,
NULL, dpni_irq0_handler_thread, NULL, dpni_irq0_handler_thread,
IRQF_NO_SUSPEND | IRQF_ONESHOT, IRQF_NO_SUSPEND | IRQF_ONESHOT,
dev_name(&ls_dev->dev), &ls_dev->dev); dev_name(&ls_dev->dev), &ls_dev->dev);
...@@ -4273,7 +4273,7 @@ static int dpaa2_eth_setup_irqs(struct fsl_mc_device *ls_dev) ...@@ -4273,7 +4273,7 @@ static int dpaa2_eth_setup_irqs(struct fsl_mc_device *ls_dev)
return 0; return 0;
free_irq: free_irq:
devm_free_irq(&ls_dev->dev, irq->msi_desc->irq, &ls_dev->dev); devm_free_irq(&ls_dev->dev, irq->virq, &ls_dev->dev);
free_mc_irq: free_mc_irq:
fsl_mc_free_irqs(ls_dev); fsl_mc_free_irqs(ls_dev);
......
...@@ -129,7 +129,6 @@ static irqreturn_t dpaa2_ptp_irq_handler_thread(int irq, void *priv) ...@@ -129,7 +129,6 @@ static irqreturn_t dpaa2_ptp_irq_handler_thread(int irq, void *priv)
static int dpaa2_ptp_probe(struct fsl_mc_device *mc_dev) static int dpaa2_ptp_probe(struct fsl_mc_device *mc_dev)
{ {
struct device *dev = &mc_dev->dev; struct device *dev = &mc_dev->dev;
struct fsl_mc_device_irq *irq;
struct ptp_qoriq *ptp_qoriq; struct ptp_qoriq *ptp_qoriq;
struct device_node *node; struct device_node *node;
void __iomem *base; void __iomem *base;
...@@ -177,8 +176,7 @@ static int dpaa2_ptp_probe(struct fsl_mc_device *mc_dev) ...@@ -177,8 +176,7 @@ static int dpaa2_ptp_probe(struct fsl_mc_device *mc_dev)
goto err_unmap; goto err_unmap;
} }
irq = mc_dev->irqs[0]; ptp_qoriq->irq = mc_dev->irqs[0]->virq;
ptp_qoriq->irq = irq->msi_desc->irq;
err = request_threaded_irq(ptp_qoriq->irq, NULL, err = request_threaded_irq(ptp_qoriq->irq, NULL,
dpaa2_ptp_irq_handler_thread, dpaa2_ptp_irq_handler_thread,
......
...@@ -1553,8 +1553,7 @@ static int dpaa2_switch_setup_irqs(struct fsl_mc_device *sw_dev) ...@@ -1553,8 +1553,7 @@ static int dpaa2_switch_setup_irqs(struct fsl_mc_device *sw_dev)
irq = sw_dev->irqs[DPSW_IRQ_INDEX_IF]; irq = sw_dev->irqs[DPSW_IRQ_INDEX_IF];
err = devm_request_threaded_irq(dev, irq->msi_desc->irq, err = devm_request_threaded_irq(dev, irq->virq, NULL,
NULL,
dpaa2_switch_irq0_handler_thread, dpaa2_switch_irq0_handler_thread,
IRQF_NO_SUSPEND | IRQF_ONESHOT, IRQF_NO_SUSPEND | IRQF_ONESHOT,
dev_name(dev), dev); dev_name(dev), dev);
...@@ -1580,7 +1579,7 @@ static int dpaa2_switch_setup_irqs(struct fsl_mc_device *sw_dev) ...@@ -1580,7 +1579,7 @@ static int dpaa2_switch_setup_irqs(struct fsl_mc_device *sw_dev)
return 0; return 0;
free_devm_irq: free_devm_irq:
devm_free_irq(dev, irq->msi_desc->irq, dev); devm_free_irq(dev, irq->virq, dev);
free_irq: free_irq:
fsl_mc_free_irqs(sw_dev); fsl_mc_free_irqs(sw_dev);
return err; return err;
......
...@@ -88,7 +88,7 @@ static void unregister_dpio_irq_handlers(struct fsl_mc_device *dpio_dev) ...@@ -88,7 +88,7 @@ static void unregister_dpio_irq_handlers(struct fsl_mc_device *dpio_dev)
irq = dpio_dev->irqs[0]; irq = dpio_dev->irqs[0];
/* clear the affinity hint */ /* clear the affinity hint */
irq_set_affinity_hint(irq->msi_desc->irq, NULL); irq_set_affinity_hint(irq->virq, NULL);
} }
static int register_dpio_irq_handlers(struct fsl_mc_device *dpio_dev, int cpu) static int register_dpio_irq_handlers(struct fsl_mc_device *dpio_dev, int cpu)
...@@ -98,7 +98,7 @@ static int register_dpio_irq_handlers(struct fsl_mc_device *dpio_dev, int cpu) ...@@ -98,7 +98,7 @@ static int register_dpio_irq_handlers(struct fsl_mc_device *dpio_dev, int cpu)
irq = dpio_dev->irqs[0]; irq = dpio_dev->irqs[0];
error = devm_request_irq(&dpio_dev->dev, error = devm_request_irq(&dpio_dev->dev,
irq->msi_desc->irq, irq->virq,
dpio_irq_handler, dpio_irq_handler,
0, 0,
dev_name(&dpio_dev->dev), dev_name(&dpio_dev->dev),
...@@ -111,10 +111,10 @@ static int register_dpio_irq_handlers(struct fsl_mc_device *dpio_dev, int cpu) ...@@ -111,10 +111,10 @@ static int register_dpio_irq_handlers(struct fsl_mc_device *dpio_dev, int cpu)
} }
/* set the affinity hint */ /* set the affinity hint */
if (irq_set_affinity_hint(irq->msi_desc->irq, cpumask_of(cpu))) if (irq_set_affinity_hint(irq->virq, cpumask_of(cpu)))
dev_err(&dpio_dev->dev, dev_err(&dpio_dev->dev,
"irq_set_affinity failed irq %d cpu %d\n", "irq_set_affinity failed irq %d cpu %d\n",
irq->msi_desc->irq, cpu); irq->virq, cpu);
return 0; return 0;
} }
......
...@@ -67,7 +67,7 @@ static int vfio_set_trigger(struct vfio_fsl_mc_device *vdev, ...@@ -67,7 +67,7 @@ static int vfio_set_trigger(struct vfio_fsl_mc_device *vdev,
int hwirq; int hwirq;
int ret; int ret;
hwirq = vdev->mc_dev->irqs[index]->msi_desc->irq; hwirq = vdev->mc_dev->irqs[index]->virq;
if (irq->trigger) { if (irq->trigger) {
free_irq(hwirq, irq); free_irq(hwirq, irq);
kfree(irq->name); kfree(irq->name);
...@@ -137,7 +137,7 @@ static int vfio_fsl_mc_set_irq_trigger(struct vfio_fsl_mc_device *vdev, ...@@ -137,7 +137,7 @@ static int vfio_fsl_mc_set_irq_trigger(struct vfio_fsl_mc_device *vdev,
return vfio_set_trigger(vdev, index, fd); return vfio_set_trigger(vdev, index, fd);
} }
hwirq = vdev->mc_dev->irqs[index]->msi_desc->irq; hwirq = vdev->mc_dev->irqs[index]->virq;
irq = &vdev->mc_irqs[index]; irq = &vdev->mc_irqs[index];
......
...@@ -91,13 +91,13 @@ struct fsl_mc_resource { ...@@ -91,13 +91,13 @@ struct fsl_mc_resource {
/** /**
* struct fsl_mc_device_irq - MC object device message-based interrupt * struct fsl_mc_device_irq - MC object device message-based interrupt
* @msi_desc: pointer to MSI descriptor allocated by fsl_mc_msi_alloc_descs() * @virq: Linux virtual interrupt number
* @mc_dev: MC object device that owns this interrupt * @mc_dev: MC object device that owns this interrupt
* @dev_irq_index: device-relative IRQ index * @dev_irq_index: device-relative IRQ index
* @resource: MC generic resource associated with the interrupt * @resource: MC generic resource associated with the interrupt
*/ */
struct fsl_mc_device_irq { struct fsl_mc_device_irq {
struct msi_desc *msi_desc; unsigned int virq;
struct fsl_mc_device *mc_dev; struct fsl_mc_device *mc_dev;
u8 dev_irq_index; u8 dev_irq_index;
struct fsl_mc_resource resource; struct fsl_mc_resource resource;
......
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