2021-02-14 13:23:44

by Dejin Zheng

[permalink] [raw]
Subject: [PATCH 0/3] Add missing call to 'pci_free_irq_vectors()'

This patchset just for add missing call to 'pci_free_irq_vectors()' in
the error handling path of the probe function, or in the remove function.

Dejin Zheng (3):
dmaengine: hsu: Add missing call to 'pci_free_irq_vectors()' in probe
and remove functions
dmaengine: dw-edma: Add missing call to 'pci_free_irq_vectors()' in
probe function
dmaengine: hisilicon: Add missing call to 'pci_free_irq_vectors()' in
probe function

drivers/dma/dw-edma/dw-edma-pcie.c | 15 +++++++++++----
drivers/dma/hisi_dma.c | 14 ++++++++++----
drivers/dma/hsu/pci.c | 5 ++++-
3 files changed, 25 insertions(+), 9 deletions(-)

--
2.25.0


2021-02-14 13:24:02

by Dejin Zheng

[permalink] [raw]
Subject: [PATCH 1/3] dmaengine: hsu: Add missing call to 'pci_free_irq_vectors()' in probe and remove functions

Call to 'pci_free_irq_vectors()' are missing both in the error handling
path of the probe function, and in the remove function.
Add them.

Fixes: e9bb8a9df316a2 ("dmaengine: hsu: pci: switch to new API for IRQ allocation")
Signed-off-by: Dejin Zheng <[email protected]>
---
drivers/dma/hsu/pci.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/dma/hsu/pci.c b/drivers/dma/hsu/pci.c
index 9045a6f7f589..b335e2ef795b 100644
--- a/drivers/dma/hsu/pci.c
+++ b/drivers/dma/hsu/pci.c
@@ -89,7 +89,7 @@ static int hsu_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)

ret = hsu_dma_probe(chip);
if (ret)
- return ret;
+ goto err_irq_vectors;

ret = request_irq(chip->irq, hsu_pci_irq, 0, "hsu_dma_pci", chip);
if (ret)
@@ -112,6 +112,8 @@ static int hsu_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)

err_register_irq:
hsu_dma_remove(chip);
+err_irq_vectors:
+ pci_free_irq_vectors(pdev);
return ret;
}

@@ -121,6 +123,7 @@ static void hsu_pci_remove(struct pci_dev *pdev)

free_irq(chip->irq, chip);
hsu_dma_remove(chip);
+ pci_free_irq_vectors(pdev);
}

static const struct pci_device_id hsu_pci_id_table[] = {
--
2.25.0

2021-02-14 13:24:28

by Dejin Zheng

[permalink] [raw]
Subject: [PATCH 2/3] dmaengine: dw-edma: Add missing call to 'pci_free_irq_vectors()' in probe function

Call to 'pci_free_irq_vectors()' is missing in the error handling path
of the probe function, So add it.

Fixes: 41aaff2a2ac01c5 ("dmaengine: Add Synopsys eDMA IP PCIe glue-logic")
Signed-off-by: Dejin Zheng <[email protected]>
---
drivers/dma/dw-edma/dw-edma-pcie.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/drivers/dma/dw-edma/dw-edma-pcie.c b/drivers/dma/dw-edma/dw-edma-pcie.c
index 1eafc602e17e..c1e796bd3ee9 100644
--- a/drivers/dma/dw-edma/dw-edma-pcie.c
+++ b/drivers/dma/dw-edma/dw-edma-pcie.c
@@ -185,24 +185,31 @@ static int dw_edma_pcie_probe(struct pci_dev *pdev,
/* Validating if PCI interrupts were enabled */
if (!pci_dev_msi_enabled(pdev)) {
pci_err(pdev, "enable interrupt failed\n");
- return -EPERM;
+ err = -EPERM;
+ goto err_free_irq;
}

dw->irq = devm_kcalloc(dev, nr_irqs, sizeof(*dw->irq), GFP_KERNEL);
- if (!dw->irq)
- return -ENOMEM;
+ if (!dw->irq) {
+ err = -ENOMEM;
+ goto err_free_irq;
+ }

/* Starting eDMA driver */
err = dw_edma_probe(chip);
if (err) {
pci_err(pdev, "eDMA probe failed\n");
- return err;
+ goto err_free_irq;
}

/* Saving data structure reference */
pci_set_drvdata(pdev, chip);

return 0;
+
+err_free_irq:
+ pci_free_irq_vectors(pdev);
+ return err;
}

static void dw_edma_pcie_remove(struct pci_dev *pdev)
--
2.25.0

2021-02-14 13:25:06

by Dejin Zheng

[permalink] [raw]
Subject: [PATCH 3/3] dmaengine: hisilicon: Add missing call to 'pci_free_irq_vectors()' in probe function

Call to 'pci_free_irq_vectors()' is missing in the error handling path
of the probe function, So add it.

Fixes: e9f08b65250d73ab ("dmaengine: hisilicon: Add Kunpeng DMA engine support")
Signed-off-by: Dejin Zheng <[email protected]>
---
drivers/dma/hisi_dma.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/dma/hisi_dma.c b/drivers/dma/hisi_dma.c
index a259ee010e9b..9e894d7f5dab 100644
--- a/drivers/dma/hisi_dma.c
+++ b/drivers/dma/hisi_dma.c
@@ -553,7 +553,7 @@ static int hisi_dma_probe(struct pci_dev *pdev, const struct pci_device_id *id)

ret = devm_add_action_or_reset(dev, hisi_dma_free_irq_vectors, pdev);
if (ret)
- return ret;
+ goto err_free_irq;

dma_dev = &hdma_dev->dma_dev;
dma_cap_set(DMA_MEMCPY, dma_dev->cap_mask);
@@ -572,18 +572,24 @@ static int hisi_dma_probe(struct pci_dev *pdev, const struct pci_device_id *id)
ret = hisi_dma_enable_hw_channels(hdma_dev);
if (ret < 0) {
dev_err(dev, "failed to enable hw channel!\n");
- return ret;
+ goto err_free_irq;
}

ret = devm_add_action_or_reset(dev, hisi_dma_disable_hw_channels,
hdma_dev);
if (ret)
- return ret;
+ goto err_free_irq;

ret = dmaenginem_async_device_register(dma_dev);
- if (ret < 0)
+ if (ret < 0) {
dev_err(dev, "failed to register device!\n");
+ goto err_free_irq;
+ }
+
+ return ret;

+err_free_irq:
+ pci_free_irq_vectors(pdev);
return ret;
}

--
2.25.0

2021-02-15 09:50:23

by Gustavo Pimentel

[permalink] [raw]
Subject: RE: [PATCH 2/3] dmaengine: dw-edma: Add missing call to 'pci_free_irq_vectors()' in probe function

On Sun, Feb 14, 2021 at 13:21:52, Dejin Zheng <[email protected]>
wrote:

> Call to 'pci_free_irq_vectors()' is missing in the error handling path
> of the probe function, So add it.
>
> Fixes: 41aaff2a2ac01c5 ("dmaengine: Add Synopsys eDMA IP PCIe glue-logic")
> Signed-off-by: Dejin Zheng <[email protected]>
> ---
> drivers/dma/dw-edma/dw-edma-pcie.c | 15 +++++++++++----
> 1 file changed, 11 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/dma/dw-edma/dw-edma-pcie.c b/drivers/dma/dw-edma/dw-edma-pcie.c
> index 1eafc602e17e..c1e796bd3ee9 100644
> --- a/drivers/dma/dw-edma/dw-edma-pcie.c
> +++ b/drivers/dma/dw-edma/dw-edma-pcie.c
> @@ -185,24 +185,31 @@ static int dw_edma_pcie_probe(struct pci_dev *pdev,
> /* Validating if PCI interrupts were enabled */
> if (!pci_dev_msi_enabled(pdev)) {
> pci_err(pdev, "enable interrupt failed\n");
> - return -EPERM;
> + err = -EPERM;
> + goto err_free_irq;
> }
>
> dw->irq = devm_kcalloc(dev, nr_irqs, sizeof(*dw->irq), GFP_KERNEL);
> - if (!dw->irq)
> - return -ENOMEM;
> + if (!dw->irq) {
> + err = -ENOMEM;
> + goto err_free_irq;
> + }
>
> /* Starting eDMA driver */
> err = dw_edma_probe(chip);
> if (err) {
> pci_err(pdev, "eDMA probe failed\n");
> - return err;
> + goto err_free_irq;
> }
>
> /* Saving data structure reference */
> pci_set_drvdata(pdev, chip);
>
> return 0;
> +
> +err_free_irq:
> + pci_free_irq_vectors(pdev);
> + return err;
> }
>
> static void dw_edma_pcie_remove(struct pci_dev *pdev)
> --
> 2.25.0

Acked-by: Gustavo Pimentel <[email protected]>


2021-02-15 12:50:35

by Dejin Zheng

[permalink] [raw]
Subject: Re: [PATCH 2/3] dmaengine: dw-edma: Add missing call to 'pci_free_irq_vectors()' in probe function

On Mon, Feb 15, 2021 at 09:45:07AM +0000, Gustavo Pimentel wrote:
> On Sun, Feb 14, 2021 at 13:21:52, Dejin Zheng <[email protected]>
> wrote:
>
> > Call to 'pci_free_irq_vectors()' is missing in the error handling path
> > of the probe function, So add it.
> >
> > Fixes: 41aaff2a2ac01c5 ("dmaengine: Add Synopsys eDMA IP PCIe glue-logic")
> > Signed-off-by: Dejin Zheng <[email protected]>
> > ---
> > drivers/dma/dw-edma/dw-edma-pcie.c | 15 +++++++++++----
> > 1 file changed, 11 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/dma/dw-edma/dw-edma-pcie.c b/drivers/dma/dw-edma/dw-edma-pcie.c
> > index 1eafc602e17e..c1e796bd3ee9 100644
> > --- a/drivers/dma/dw-edma/dw-edma-pcie.c
> > +++ b/drivers/dma/dw-edma/dw-edma-pcie.c
> > @@ -185,24 +185,31 @@ static int dw_edma_pcie_probe(struct pci_dev *pdev,
> > /* Validating if PCI interrupts were enabled */
> > if (!pci_dev_msi_enabled(pdev)) {
> > pci_err(pdev, "enable interrupt failed\n");
> > - return -EPERM;
> > + err = -EPERM;
> > + goto err_free_irq;
> > }
> >
> > dw->irq = devm_kcalloc(dev, nr_irqs, sizeof(*dw->irq), GFP_KERNEL);
> > - if (!dw->irq)
> > - return -ENOMEM;
> > + if (!dw->irq) {
> > + err = -ENOMEM;
> > + goto err_free_irq;
> > + }
> >
> > /* Starting eDMA driver */
> > err = dw_edma_probe(chip);
> > if (err) {
> > pci_err(pdev, "eDMA probe failed\n");
> > - return err;
> > + goto err_free_irq;
> > }
> >
> > /* Saving data structure reference */
> > pci_set_drvdata(pdev, chip);
> >
> > return 0;
> > +
> > +err_free_irq:
> > + pci_free_irq_vectors(pdev);
> > + return err;
> > }
> >
> > static void dw_edma_pcie_remove(struct pci_dev *pdev)
> > --
> > 2.25.0
>
> Acked-by: Gustavo Pimentel <[email protected]>
>
>
Gustavo, Thanks!

Dejin

2021-02-15 13:30:32

by Andy Shevchenko

[permalink] [raw]
Subject: Re: [PATCH 1/3] dmaengine: hsu: Add missing call to 'pci_free_irq_vectors()' in probe and remove functions

On Sun, Feb 14, 2021 at 3:22 PM Dejin Zheng <[email protected]> wrote:
>
> Call to 'pci_free_irq_vectors()' are missing both in the error handling
> path of the probe function, and in the remove function.
> Add them.

> Fixes: e9bb8a9df316a2 ("dmaengine: hsu: pci: switch to new API for IRQ allocation")

Same as per others. This does not fix anything, because there is no issue.
If you want to have it better, introduce a pcim_alloc_irq_vectors() to
show that it's managed.


--
With Best Regards,
Andy Shevchenko