]> git.baikalelectronics.ru Git - kernel.git/commitdiff
bus: fsl-mc: fsl-mc-allocator: Rework MSI handling
authorThomas Gleixner <tglx@linutronix.de>
Fri, 10 Dec 2021 22:19:34 +0000 (23:19 +0100)
committerThomas Gleixner <tglx@linutronix.de>
Thu, 16 Dec 2021 21:16:41 +0000 (22:16 +0100)
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: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Link: https://lore.kernel.org/r/20211210221815.207838579@linutronix.de
drivers/bus/fsl-mc/dprc-driver.c
drivers/bus/fsl-mc/fsl-mc-allocator.c
drivers/bus/fsl-mc/fsl-mc-msi.c
drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
drivers/net/ethernet/freescale/dpaa2/dpaa2-ptp.c
drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
drivers/soc/fsl/dpio/dpio-driver.c
drivers/vfio/fsl-mc/vfio_fsl_mc_intr.c
include/linux/fsl/mc.h

index 315e830b6ecda26cb96bc392af26566452cd7302..5e70f9775a0e3509b96d506737a24b8342ba3dc0 100644 (file)
@@ -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_bus *mc_bus = to_fsl_mc_bus(mc_dev);
        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",
                irq_num, smp_processor_id());
@@ -409,7 +409,7 @@ static irqreturn_t dprc_irq0_handler_thread(int irq_num, void *arg)
                return IRQ_HANDLED;
 
        mutex_lock(&mc_bus->scan_mutex);
-       if (!msi_desc || msi_desc->irq != (u32)irq_num)
+       if (irq != (u32)irq_num)
                goto out;
 
        status = 0;
@@ -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
         */
        error = devm_request_threaded_irq(&mc_dev->dev,
-                                         irq->msi_desc->irq,
+                                         irq->virq,
                                          dprc_irq0_handler,
                                          dprc_irq0_handler_thread,
                                          IRQF_NO_SUSPEND | IRQF_ONESHOT,
@@ -771,7 +771,7 @@ static void dprc_teardown_irq(struct fsl_mc_device *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);
 }
index 3370b63bad5f3afcc9dfa520a59db2f21adf0b09..dced427ca8ba1cd11d0adc066a056e93f150b602 100644 (file)
@@ -350,7 +350,6 @@ int fsl_mc_populate_irq_pool(struct fsl_mc_device *mc_bus_dev,
                             unsigned int irq_count)
 {
        unsigned int i;
-       struct msi_desc *msi_desc;
        struct fsl_mc_device_irq *irq_resources;
        struct fsl_mc_device_irq *mc_dev_irq;
        int error;
@@ -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.data = mc_dev_irq;
                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);
                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->free_count = irq_count;
        mc_bus->irq_resources = irq_resources;
index 2ffb70550a39869173c68332c8cf9851f156d325..4823947d7d6f5a89635015f92c144870577af77e 100644 (file)
@@ -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,
-                                  struct fsl_mc_device_irq *mc_dev_irq)
+                                  struct fsl_mc_device_irq *mc_dev_irq,
+                                  struct msi_desc *msi_desc)
 {
        int error;
        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;
 
        /*
@@ -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:
         */
-       __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)
index 8e643567abce2a0673eb32eb3e55d3cc6c15b1bd..2c53f957e37388573b5bbf70d6547fb44311a68d 100644 (file)
@@ -4246,7 +4246,7 @@ static int dpaa2_eth_setup_irqs(struct fsl_mc_device *ls_dev)
        }
 
        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,
                                        IRQF_NO_SUSPEND | IRQF_ONESHOT,
                                        dev_name(&ls_dev->dev), &ls_dev->dev);
@@ -4273,7 +4273,7 @@ static int dpaa2_eth_setup_irqs(struct fsl_mc_device *ls_dev)
        return 0;
 
 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:
        fsl_mc_free_irqs(ls_dev);
 
index 32b5faa87bb8dbcef676f744adf0f4f4ece4ba61..5f5f8c53c4a0f0d9653865373cb09c7b61e3bc96 100644 (file)
@@ -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)
 {
        struct device *dev = &mc_dev->dev;
-       struct fsl_mc_device_irq *irq;
        struct ptp_qoriq *ptp_qoriq;
        struct device_node *node;
        void __iomem *base;
@@ -177,8 +176,7 @@ static int dpaa2_ptp_probe(struct fsl_mc_device *mc_dev)
                goto err_unmap;
        }
 
-       irq = mc_dev->irqs[0];
-       ptp_qoriq->irq = irq->msi_desc->irq;
+       ptp_qoriq->irq = mc_dev->irqs[0]->virq;
 
        err = request_threaded_irq(ptp_qoriq->irq, NULL,
                                   dpaa2_ptp_irq_handler_thread,
index d039457928b0dd2adea8cb0d4703dcb6aaf2f9f6..084cc4d2d8761e5efca4f01fb3f6b5e46f96f02f 100644 (file)
@@ -1553,8 +1553,7 @@ static int dpaa2_switch_setup_irqs(struct fsl_mc_device *sw_dev)
 
        irq = sw_dev->irqs[DPSW_IRQ_INDEX_IF];
 
-       err = devm_request_threaded_irq(dev, irq->msi_desc->irq,
-                                       NULL,
+       err = devm_request_threaded_irq(dev, irq->virq, NULL,
                                        dpaa2_switch_irq0_handler_thread,
                                        IRQF_NO_SUSPEND | IRQF_ONESHOT,
                                        dev_name(dev), dev);
@@ -1580,7 +1579,7 @@ static int dpaa2_switch_setup_irqs(struct fsl_mc_device *sw_dev)
        return 0;
 
 free_devm_irq:
-       devm_free_irq(dev, irq->msi_desc->irq, dev);
+       devm_free_irq(dev, irq->virq, dev);
 free_irq:
        fsl_mc_free_irqs(sw_dev);
        return err;
index dd948889eeab8b93ceca8aeacebfd72f5123456e..5a2edc48dd79763182bc5c4009dc1928945a48be 100644 (file)
@@ -88,7 +88,7 @@ static void unregister_dpio_irq_handlers(struct fsl_mc_device *dpio_dev)
        irq = dpio_dev->irqs[0];
 
        /* 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)
@@ -98,7 +98,7 @@ static int register_dpio_irq_handlers(struct fsl_mc_device *dpio_dev, int cpu)
 
        irq = dpio_dev->irqs[0];
        error = devm_request_irq(&dpio_dev->dev,
-                                irq->msi_desc->irq,
+                                irq->virq,
                                 dpio_irq_handler,
                                 0,
                                 dev_name(&dpio_dev->dev),
@@ -111,10 +111,10 @@ static int register_dpio_irq_handlers(struct fsl_mc_device *dpio_dev, int cpu)
        }
 
        /* 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,
                        "irq_set_affinity failed irq %d cpu %d\n",
-                       irq->msi_desc->irq, cpu);
+                       irq->virq, cpu);
 
        return 0;
 }
index 77e584093a233d995a033f54776c68f81e4492bb..7b428eac3d3e5bb84df8f2269100ef5df79ebb50 100644 (file)
@@ -67,7 +67,7 @@ static int vfio_set_trigger(struct vfio_fsl_mc_device *vdev,
        int hwirq;
        int ret;
 
-       hwirq = vdev->mc_dev->irqs[index]->msi_desc->irq;
+       hwirq = vdev->mc_dev->irqs[index]->virq;
        if (irq->trigger) {
                free_irq(hwirq, irq);
                kfree(irq->name);
@@ -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);
        }
 
-       hwirq = vdev->mc_dev->irqs[index]->msi_desc->irq;
+       hwirq = vdev->mc_dev->irqs[index]->virq;
 
        irq = &vdev->mc_irqs[index];
 
index e026f6c48b490dc533a03a1aedd6850c2af12e38..7b6c42bfb660fc200a37586577428917d1fda070 100644 (file)
@@ -91,13 +91,13 @@ struct fsl_mc_resource {
 
 /**
  * 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
  * @dev_irq_index: device-relative IRQ index
  * @resource: MC generic resource associated with the interrupt
  */
 struct fsl_mc_device_irq {
-       struct msi_desc *msi_desc;
+       unsigned int virq;
        struct fsl_mc_device *mc_dev;
        u8 dev_irq_index;
        struct fsl_mc_resource resource;