Commit 1900c962 authored by Thomas Gleixner's avatar Thomas Gleixner

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: default avatarThomas Gleixner <tglx@linutronix.de>
Reviewed-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: default avatarJason Gunthorpe <jgg@nvidia.com>
Acked-by: default avatarSinan Kaya <okaya@kernel.org>
Acked-by: default avatarVinod Koul <vkoul@kernel.org>
Link: https://lore.kernel.org/r/20211210221815.329792721@linutronix.de
parent 89e0032e
...@@ -678,11 +678,13 @@ static void hidma_free_msis(struct hidma_dev *dmadev) ...@@ -678,11 +678,13 @@ static void hidma_free_msis(struct hidma_dev *dmadev)
{ {
#ifdef CONFIG_GENERIC_MSI_IRQ_DOMAIN #ifdef CONFIG_GENERIC_MSI_IRQ_DOMAIN
struct device *dev = dmadev->ddev.dev; struct device *dev = dmadev->ddev.dev;
struct msi_desc *desc; int i, virq;
/* free allocated MSI interrupts above */ for (i = 0; i < HIDMA_MSI_INTS; i++) {
for_each_msi_entry(desc, dev) virq = msi_get_virq(dev, i);
devm_free_irq(dev, desc->irq, &dmadev->lldev); if (virq)
devm_free_irq(dev, virq, &dmadev->lldev);
}
platform_msi_domain_free_irqs(dev); platform_msi_domain_free_irqs(dev);
#endif #endif
...@@ -692,45 +694,37 @@ static int hidma_request_msi(struct hidma_dev *dmadev, ...@@ -692,45 +694,37 @@ static int hidma_request_msi(struct hidma_dev *dmadev,
struct platform_device *pdev) struct platform_device *pdev)
{ {
#ifdef CONFIG_GENERIC_MSI_IRQ_DOMAIN #ifdef CONFIG_GENERIC_MSI_IRQ_DOMAIN
int rc; int rc, i, virq;
struct msi_desc *desc;
struct msi_desc *failed_desc = NULL;
rc = platform_msi_domain_alloc_irqs(&pdev->dev, HIDMA_MSI_INTS, rc = platform_msi_domain_alloc_irqs(&pdev->dev, HIDMA_MSI_INTS,
hidma_write_msi_msg); hidma_write_msi_msg);
if (rc) if (rc)
return rc; return rc;
for_each_msi_entry(desc, &pdev->dev) { for (i = 0; i < HIDMA_MSI_INTS; i++) {
if (!desc->msi_index) virq = msi_get_virq(&pdev->dev, i);
dmadev->msi_virqbase = desc->irq; rc = devm_request_irq(&pdev->dev, virq,
rc = devm_request_irq(&pdev->dev, desc->irq,
hidma_chirq_handler_msi, hidma_chirq_handler_msi,
0, "qcom-hidma-msi", 0, "qcom-hidma-msi",
&dmadev->lldev); &dmadev->lldev);
if (rc) { if (rc)
failed_desc = desc;
break; break;
} if (!i)
dmadev->msi_virqbase = virq;
} }
if (rc) { if (rc) {
/* free allocated MSI interrupts above */ /* free allocated MSI interrupts above */
for_each_msi_entry(desc, &pdev->dev) { for (--i; i >= 0; i--) {
if (desc == failed_desc) virq = msi_get_virq(&pdev->dev, i);
break; devm_free_irq(&pdev->dev, virq, &dmadev->lldev);
devm_free_irq(&pdev->dev, desc->irq,
&dmadev->lldev);
} }
dev_warn(&pdev->dev,
"failed to request MSI irq, falling back to wired IRQ\n");
} else { } else {
/* Add callback to free MSIs on teardown */ /* Add callback to free MSIs on teardown */
hidma_ll_setup_irq(dmadev->lldev, true); hidma_ll_setup_irq(dmadev->lldev, true);
} }
if (rc)
dev_warn(&pdev->dev,
"failed to request MSI irq, falling back to wired IRQ\n");
return rc; return rc;
#else #else
return -EINVAL; return -EINVAL;
......
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