Skip to content

Commit 1900c96

Browse files
committed
dmaengine: qcom_hidma: Cleanup MSI handling
There is no reason to walk the MSI descriptors to retrieve the interrupt number for a device. Use msi_get_virq() instead. Signed-off-by: Thomas Gleixner <[email protected]> Reviewed-by: Greg Kroah-Hartman <[email protected]> Reviewed-by: Jason Gunthorpe <[email protected]> Acked-by: Sinan Kaya <[email protected]> Acked-by: Vinod Koul <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 89e0032 commit 1900c96

File tree

1 file changed

+18
-24
lines changed

1 file changed

+18
-24
lines changed

drivers/dma/qcom/hidma.c

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -678,11 +678,13 @@ static void hidma_free_msis(struct hidma_dev *dmadev)
678678
{
679679
#ifdef CONFIG_GENERIC_MSI_IRQ_DOMAIN
680680
struct device *dev = dmadev->ddev.dev;
681-
struct msi_desc *desc;
681+
int i, virq;
682682

683-
/* free allocated MSI interrupts above */
684-
for_each_msi_entry(desc, dev)
685-
devm_free_irq(dev, desc->irq, &dmadev->lldev);
683+
for (i = 0; i < HIDMA_MSI_INTS; i++) {
684+
virq = msi_get_virq(dev, i);
685+
if (virq)
686+
devm_free_irq(dev, virq, &dmadev->lldev);
687+
}
686688

687689
platform_msi_domain_free_irqs(dev);
688690
#endif
@@ -692,45 +694,37 @@ static int hidma_request_msi(struct hidma_dev *dmadev,
692694
struct platform_device *pdev)
693695
{
694696
#ifdef CONFIG_GENERIC_MSI_IRQ_DOMAIN
695-
int rc;
696-
struct msi_desc *desc;
697-
struct msi_desc *failed_desc = NULL;
697+
int rc, i, virq;
698698

699699
rc = platform_msi_domain_alloc_irqs(&pdev->dev, HIDMA_MSI_INTS,
700700
hidma_write_msi_msg);
701701
if (rc)
702702
return rc;
703703

704-
for_each_msi_entry(desc, &pdev->dev) {
705-
if (!desc->msi_index)
706-
dmadev->msi_virqbase = desc->irq;
707-
708-
rc = devm_request_irq(&pdev->dev, desc->irq,
704+
for (i = 0; i < HIDMA_MSI_INTS; i++) {
705+
virq = msi_get_virq(&pdev->dev, i);
706+
rc = devm_request_irq(&pdev->dev, virq,
709707
hidma_chirq_handler_msi,
710708
0, "qcom-hidma-msi",
711709
&dmadev->lldev);
712-
if (rc) {
713-
failed_desc = desc;
710+
if (rc)
714711
break;
715-
}
712+
if (!i)
713+
dmadev->msi_virqbase = virq;
716714
}
717715

718716
if (rc) {
719717
/* free allocated MSI interrupts above */
720-
for_each_msi_entry(desc, &pdev->dev) {
721-
if (desc == failed_desc)
722-
break;
723-
devm_free_irq(&pdev->dev, desc->irq,
724-
&dmadev->lldev);
718+
for (--i; i >= 0; i--) {
719+
virq = msi_get_virq(&pdev->dev, i);
720+
devm_free_irq(&pdev->dev, virq, &dmadev->lldev);
725721
}
722+
dev_warn(&pdev->dev,
723+
"failed to request MSI irq, falling back to wired IRQ\n");
726724
} else {
727725
/* Add callback to free MSIs on teardown */
728726
hidma_ll_setup_irq(dmadev->lldev, true);
729-
730727
}
731-
if (rc)
732-
dev_warn(&pdev->dev,
733-
"failed to request MSI irq, falling back to wired IRQ\n");
734728
return rc;
735729
#else
736730
return -EINVAL;

0 commit comments

Comments
 (0)