Skip to contentSkip to conversation

PCI: rcar: Rename rcar_pcie_parse_request_of_pci_ranges()

PATCH In review Marek Vasut 5 participants 22 messages May 21, 2018 – May 24, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/4 PCI: rcar: Rename rcar_pcie_parse_request_of_pci_ranges()

The function name is just too confusing, rename it, no functional change. Rename the function to rcar_pcie_alloc_and_parse_pci_resource_list() as it's matching failpath function is pci_free_resource_list() so the names align much better and the new name also describes what the function does much better.

Cc Geert Uytterhoeven <[email protected]>
Cc Phil Edworthy <[email protected]>
Cc Simon Horman <[email protected]>
Cc Wolfram Sang <[email protected]>
---
 drivers/pci/host/pcie-rcar.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/pci/host/pcie-rcar.c +2 -2
index e403c5206b24..dbc80e457f95 100644
@@ -1051,7 +1051,7 @@ static const struct of_device_id rcar_pcie_of_match[] = {
 	{},
 };
 
-static int rcar_pcie_parse_request_of_pci_ranges(struct rcar_pcie *pci)
+static int rcar_pcie_alloc_and_parse_pci_resource_list(struct rcar_pcie *pci)
 {
 	int err;
 	struct device *dev = pci->dev;
@@ -1108,7 +1108,7 @@ static int rcar_pcie_probe(struct platform_device *pdev)
 
 	INIT_LIST_HEAD(&pcie->resources);
 
-	err = rcar_pcie_parse_request_of_pci_ranges(pcie);
+	err = rcar_pcie_alloc_and_parse_pci_resource_list(pcie);
 	if (err)
 		goto err_free_bridge;
 
Signature · 1 line
2.16.2
#1 lore raw

PATCH 2/4 PCI: rcar: Pull bus clock enable/disable from rcar_pcie_get_resources()

The rcar_pcie_get_resources() is another misnomer with a side effect. The function does not only get resources, but also enables/disables bus clock. This is forgotten in the probe() function though and if anything in probe() fails after rcar_pcie_get_resources() is called, the bus clock are never disabled.

This patch pulls the clock handling out of the rcar_pcie_get_resources() and enables clock after all the resources were requested. Moreover, this patch also always disables the clock in case of failure.

Cc Geert Uytterhoeven <[email protected]>
Cc Phil Edworthy <[email protected]>
Cc Simon Horman <[email protected]>
Cc Wolfram Sang <[email protected]>
---
 drivers/pci/host/pcie-rcar.c | 31 +++++++++++++++----------------
 1 file changed, 15 insertions(+), 16 deletions(-)
drivers/pci/host/pcie-rcar.c +15 -16
index dbc80e457f95..eac4b71d9c60 100644
@@ -919,32 +919,22 @@ static int rcar_pcie_get_resources(struct rcar_pcie *pcie)
 		dev_err(dev, "cannot get pcie bus clock\n");
 		return PTR_ERR(pcie->bus_clk);
 	}
-	err = clk_prepare_enable(pcie->bus_clk);
-	if (err)
-		return err;
 
 	i = irq_of_parse_and_map(dev->of_node, 0);
 	if (!i) {
 		dev_err(dev, "cannot get platform resources for msi interrupt\n");
-		err = -ENOENT;
-		goto err_map_reg;
+		return -ENOENT;
 	}
 	pcie->msi.irq1 = i;
 
 	i = irq_of_parse_and_map(dev->of_node, 1);
 	if (!i) {
 		dev_err(dev, "cannot get platform resources for msi interrupt\n");
-		err = -ENOENT;
-		goto err_map_reg;
+		return -ENOENT;
 	}
 	pcie->msi.irq2 = i;
 
 	return 0;
-
-err_map_reg:
-	clk_disable_unprepare(pcie->bus_clk);
-
-	return err;
 }
 
 static int rcar_pcie_inbound_ranges(struct rcar_pcie *pcie,
@@ -1125,9 +1115,15 @@ static int rcar_pcie_probe(struct platform_device *pdev)
 		goto err_pm_put;
 	}
 
+	err = clk_prepare_enable(pcie->bus_clk);
+	if (err) {
+		dev_err(dev, "failed to enable bus clock: %d\n", err);
+		goto err_pm_put;
+	}
+
 	err = rcar_pcie_parse_map_dma_ranges(pcie, dev->of_node);
 	if (err)
-		goto err_pm_put;
+		goto err_clk_disable;
 
 	/* Failure to get a link might just be that no cards are inserted */
 	hw_init_fn = of_device_get_match_data(dev);
@@ -1135,7 +1131,7 @@ static int rcar_pcie_probe(struct platform_device *pdev)
 	if (err) {
 		dev_info(dev, "PCIe link down\n");
 		err = -ENODEV;
-		goto err_pm_put;
+		goto err_clk_disable;
 	}
 
 	data = rcar_pci_read_reg(pcie, MACSR);
@@ -1147,16 +1143,19 @@ static int rcar_pcie_probe(struct platform_device *pdev)
 			dev_err(dev,
 				"failed to enable MSI support: %d\n",
 				err);
-			goto err_pm_put;
+			goto err_clk_disable;
 		}
 	}
 
 	err = rcar_pcie_enable(pcie);
 	if (err)
-		goto err_pm_put;
+		goto err_clk_disable;
 
 	return 0;
 
+err_clk_disable:
+	clk_disable_unprepare(pcie->bus_clk);
+
 err_pm_put:
 	pm_runtime_put(dev);
 
Signature · 1 line
2.16.2
Reviewed-by on v1 2/4
#2 lore raw

Re: [PATCH 2/4] PCI: rcar: Pull bus clock enable/disable from rcar_pcie_get_resources()

Quoted 10 lines · Marek Vasut

The rcar_pcie_get_resources() is another misnomer with a side effect. The function does not only get resources, but also enables/disables bus clock. This is forgotten in the probe() function though and if anything in probe() fails after rcar_pcie_get_resources() is called, the bus clock are never disabled.

This patch pulls the clock handling out of the rcar_pcie_get_resources() and enables clock after all the resources were requested. Moreover, this patch also always disables the clock in case of failure.

Quoted 6 lines
Cc Geert Uytterhoeven <[email protected]>
Cc Phil Edworthy <[email protected]>
Cc Simon Horman <[email protected]>
Cc Wolfram Sang <[email protected]>
Reviewed-by on v1 2/4
#3 lore raw

Re: [PATCH 2/4] PCI: rcar: Pull bus clock enable/disable from rcar_pcie_get_resources()

In reply to Marek Vasut

Hi Marek,

Quoted 11 lines · Marek Vasut

The rcar_pcie_get_resources() is another misnomer with a side effect. The function does not only get resources, but also enables/disables bus clock. This is forgotten in the probe() function though and if anything in probe() fails after rcar_pcie_get_resources() is called, the bus clock are never disabled.

This patch pulls the clock handling out of the rcar_pcie_get_resources() and enables clock after all the resources were requested. Moreover, this patch also always disables the clock in case of failure.

Thanks for your patch!

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
#4 lore raw

PATCH 3/4 PCI: rcar: Add missing irq_dispose_mapping() into failpath

In reply to Marek Vasut

The rcar_pcie_get_resources() is another misnomer with a side effect. The function does not only get resources, but also maps MSI IRQs via irq_of_parse_and_map(). In case anything fails afterward, the IRQ mapping must be disposed through irq_dispose_mapping() which is not done.

This patch handles irq_of_parse_and_map() failures in by disposing of the mapping in rcar_pcie_get_resources() as well as in probe.

Cc Geert Uytterhoeven <[email protected]>
Cc Phil Edworthy <[email protected]>
Cc Simon Horman <[email protected]>
Cc Wolfram Sang <[email protected]>
---
 drivers/pci/host/pcie-rcar.c | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)
drivers/pci/host/pcie-rcar.c +14 -3
index eac4b71d9c60..3cc84f7e05f7 100644
@@ -923,18 +923,25 @@ static int rcar_pcie_get_resources(struct rcar_pcie *pcie)
 	i = irq_of_parse_and_map(dev->of_node, 0);
 	if (!i) {
 		dev_err(dev, "cannot get platform resources for msi interrupt\n");
-		return -ENOENT;
+		err = -ENOENT;
+		goto err_irq1;
 	}
 	pcie->msi.irq1 = i;
 
 	i = irq_of_parse_and_map(dev->of_node, 1);
 	if (!i) {
 		dev_err(dev, "cannot get platform resources for msi interrupt\n");
-		return -ENOENT;
+		err = -ENOENT;
+		goto err_irq2;
 	}
 	pcie->msi.irq2 = i;
 
 	return 0;
+
+err_irq2:
+	irq_dispose_mapping(pcie->msi.irq1);
+err_irq1:
+	return err;
 }
 
 static int rcar_pcie_inbound_ranges(struct rcar_pcie *pcie,
@@ -1118,7 +1125,7 @@ static int rcar_pcie_probe(struct platform_device *pdev)
 	err = clk_prepare_enable(pcie->bus_clk);
 	if (err) {
 		dev_err(dev, "failed to enable bus clock: %d\n", err);
-		goto err_pm_put;
+		goto err_unmap_msi_irqs;
 	}
 
 	err = rcar_pcie_parse_map_dma_ranges(pcie, dev->of_node);
@@ -1156,6 +1163,10 @@ static int rcar_pcie_probe(struct platform_device *pdev)
 err_clk_disable:
 	clk_disable_unprepare(pcie->bus_clk);
 
+err_unmap_msi_irqs:
+	irq_dispose_mapping(pcie->msi.irq2);
+	irq_dispose_mapping(pcie->msi.irq1);
+
 err_pm_put:
 	pm_runtime_put(dev);
 
Signature · 1 line
2.16.2
Reviewed-by on v1 3/4
#5 lore raw

Re: [PATCH 3/4] PCI: rcar: Add missing irq_dispose_mapping() into failpath

Quoted 15 lines · Marek Vasut

The rcar_pcie_get_resources() is another misnomer with a side effect. The function does not only get resources, but also maps MSI IRQs via irq_of_parse_and_map(). In case anything fails afterward, the IRQ mapping must be disposed through irq_dispose_mapping() which is not done.

This patch handles irq_of_parse_and_map() failures in by disposing of the mapping in rcar_pcie_get_resources() as well as in probe.

Cc Geert Uytterhoeven <[email protected]>
Cc Phil Edworthy <[email protected]>
Cc Simon Horman <[email protected]>
Cc Wolfram Sang <[email protected]>
Quoted 3 lines
---
 drivers/pci/host/pcie-rcar.c | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)
Reviewed-by on v1 3/4
#6 lore raw

Re: [PATCH 3/4] PCI: rcar: Add missing irq_dispose_mapping() into failpath

In reply to Marek Vasut

Hi Marek,

Quoted 10 lines · Marek Vasut

The rcar_pcie_get_resources() is another misnomer with a side effect. The function does not only get resources, but also maps MSI IRQs via irq_of_parse_and_map(). In case anything fails afterward, the IRQ mapping must be disposed through irq_dispose_mapping() which is not done.

This patch handles irq_of_parse_and_map() failures in by disposing of the mapping in rcar_pcie_get_resources() as well as in probe.

drivers/pci/host/pcie-rcar.c static int rcar_pcie_get_resources(struct rcar_pcie *pcie) · line 927

Quoted 9 lines
drivers/pci/host/pcie-rcar.c +2 -1
@@ -923,18 +923,25 @@ static int rcar_pcie_get_resources(struct rcar_pcie *pcie)
        i = irq_of_parse_and_map(dev->of_node, 0);
        if (!i) {
                dev_err(dev, "cannot get platform resources for msi interrupt\n");
-               return -ENOENT;
+               err = -ENOENT;
+               goto err_irq1;

You could have kept the return here.

Quoted 11 lines
drivers/pci/host/pcie-rcar.c +2 -1
        }
        pcie->msi.irq1 = i;
 
        i = irq_of_parse_and_map(dev->of_node, 1);
        if (!i) {
                dev_err(dev, "cannot get platform resources for msi interrupt\n");
-               return -ENOENT;
+               err = -ENOENT;
+               goto err_irq2;
        }
        pcie->msi.irq2 = i;

drivers/pci/host/pcie-rcar.c static int rcar_pcie_get_resources(struct rcar_pcie *pcie) · line 947

Quoted 10 lines
drivers/pci/host/pcie-rcar.c +5 -0
 
        return 0;
+
+err_irq2:
+       irq_dispose_mapping(pcie->msi.irq1);
+err_irq1:
+       return err;
 }
 
 static int rcar_pcie_inbound_ranges(struct rcar_pcie *pcie,

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
#7 lore raw

Re: [PATCH 3/4] PCI: rcar: Add missing irq_dispose_mapping() into failpath

Quoted 1 line · Geert Uytterhoeven

Hi Marek,

Hi,

Quoted 14 lines · Marek Vasut
Quoted 10 lines

The rcar_pcie_get_resources() is another misnomer with a side effect. The function does not only get resources, but also maps MSI IRQs via irq_of_parse_and_map(). In case anything fails afterward, the IRQ mapping must be disposed through irq_dispose_mapping() which is not done.

This patch handles irq_of_parse_and_map() failures in by disposing of the mapping in rcar_pcie_get_resources() as well as in probe.

Quoted 11 lines

drivers/pci/host/pcie-rcar.c static int rcar_pcie_get_resources(struct rcar_pcie *pcie) · line 927

Quoted 9 lines
drivers/pci/host/pcie-rcar.c +2 -1
@@ -923,18 +923,25 @@ static int rcar_pcie_get_resources(struct rcar_pcie *pcie)
        i = irq_of_parse_and_map(dev->of_node, 0);
        if (!i) {
                dev_err(dev, "cannot get platform resources for msi interrupt\n");
-               return -ENOENT;
+               err = -ENOENT;
+               goto err_irq1;

You could have kept the return here.

I like the symmetry ;-)

[...]

Signature · 2 lines
Best regards,
Marek Vasut
#8 lore raw

PATCH 4/4 PCI: rcar: Teardown MSI setup if rcar_pcie_enable() fails

In reply to Marek Vasut

If the rcar_pcie_enable() fails and MSIs are enabled, the setup done in rcar_pcie_enable_msi() is never undone. Add a function to tear down the MSI setup by disabling the MSI handling in the PCIe block, deallocating the pages requested for the MSIs and zapping the IRQ mapping.

Cc Geert Uytterhoeven <[email protected]>
Cc Phil Edworthy <[email protected]>
Cc Simon Horman <[email protected]>
Cc Wolfram Sang <[email protected]>
---
 drivers/pci/host/pcie-rcar.c | 28 +++++++++++++++++++++++++++-
 1 file changed, 27 insertions(+), 1 deletion(-)
drivers/pci/host/pcie-rcar.c +27 -1
index 3cc84f7e05f7..5c365f743df5 100644
@@ -900,6 +900,28 @@ static int rcar_pcie_enable_msi(struct rcar_pcie *pcie)
 	return err;
 }
 
+static void rcar_pcie_teardown_msi(struct rcar_pcie *pcie)
+{
+	struct rcar_msi *msi = &pcie->msi;
+	int irq, i;
+
+	/* Disable all MSI interrupts */
+	rcar_pci_write_reg(pcie, 0, PCIEMSIIER);
+
+	/* Disable address decoding of the MSI interrupt, MSIFE */
+	rcar_pci_write_reg(pcie, 0, PCIEMSIALR);
+
+	free_pages(msi->pages, 0);
+
+	for (i = 0; i < INT_PCI_MSI_NR; i++) {
+		irq = irq_find_mapping(msi->domain, i);
+		if (irq > 0)
+			irq_dispose_mapping(irq);
+	}
+
+	irq_domain_remove(msi->domain);
+}
+
 static int rcar_pcie_get_resources(struct rcar_pcie *pcie)
 {
 	struct device *dev = pcie->dev;
@@ -1156,10 +1178,14 @@ static int rcar_pcie_probe(struct platform_device *pdev)
 
 	err = rcar_pcie_enable(pcie);
 	if (err)
-		goto err_clk_disable;
+		goto err_msi_teardown;
 
 	return 0;
 
+err_msi_teardown:
+	if (IS_ENABLED(CONFIG_PCI_MSI))
+		rcar_pcie_teardown_msi(pcie);
+
 err_clk_disable:
 	clk_disable_unprepare(pcie->bus_clk);
 
Signature · 1 line
2.16.2
Reviewed-by on v1 4/4
#9 lore raw

Re: [PATCH 4/4] PCI: rcar: Teardown MSI setup if rcar_pcie_enable() fails

Quoted 11 lines · Marek Vasut

If the rcar_pcie_enable() fails and MSIs are enabled, the setup done in rcar_pcie_enable_msi() is never undone. Add a function to tear down the MSI setup by disabling the MSI handling in the PCIe block, deallocating the pages requested for the MSIs and zapping the IRQ mapping.

Cc Geert Uytterhoeven <[email protected]>
Cc Phil Edworthy <[email protected]>
Cc Simon Horman <[email protected]>
Cc Wolfram Sang <[email protected]>
Quoted 3 lines
---
 drivers/pci/host/pcie-rcar.c | 28 +++++++++++++++++++++++++++-
 1 file changed, 27 insertions(+), 1 deletion(-)
Reviewed-by on v1 4/4
#10 lore raw

Re: [PATCH 4/4] PCI: rcar: Teardown MSI setup if rcar_pcie_enable() fails

In reply to Marek Vasut

Hi Marek,

Quoted 6 lines · Marek Vasut

If the rcar_pcie_enable() fails and MSIs are enabled, the setup done in rcar_pcie_enable_msi() is never undone. Add a function to tear down the MSI setup by disabling the MSI handling in the PCIe block, deallocating the pages requested for the MSIs and zapping the IRQ mapping.

Quoted 14 lines
drivers/pci/host/pcie-rcar.c +8 -0
@@ -900,6 +900,28 @@ static int rcar_pcie_enable_msi(struct rcar_pcie *pcie)
        return err;
 }
 
+static void rcar_pcie_teardown_msi(struct rcar_pcie *pcie)
+{
+       struct rcar_msi *msi = &pcie->msi;
+       int irq, i;
+
+       /* Disable all MSI interrupts */
+       rcar_pci_write_reg(pcie, 0, PCIEMSIIER);
+

drivers/pci/host/pcie-rcar.c static int rcar_pcie_enable_msi(struct rcar_pcie *pcie) · line 920

Quoted 10 lines
drivers/pci/host/pcie-rcar.c +10 -0
+       /* Disable address decoding of the MSI interrupt, MSIFE */
+       rcar_pci_write_reg(pcie, 0, PCIEMSIALR);
+
+       free_pages(msi->pages, 0);
+
+       for (i = 0; i < INT_PCI_MSI_NR; i++) {
+               irq = irq_find_mapping(msi->domain, i);
+               if (irq > 0)
+                       irq_dispose_mapping(irq);
+       }

Note that similar calls to irq_dispose_mapping() should be added to the failure path of rcar_pcie_enable_msi(), too.

drivers/pci/host/pcie-rcar.c static int rcar_pcie_enable_msi(struct rcar_pcie *pcie) · line 923

Quoted 3 lines
drivers/pci/host/pcie-rcar.c +3 -0
+
+       irq_domain_remove(msi->domain);
+}

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
#11 lore raw

Re: [PATCH 4/4] PCI: rcar: Teardown MSI setup if rcar_pcie_enable() fails

Quoted 32 lines · Geert Uytterhoeven

Hi Marek,

Quoted 6 lines · Marek Vasut

If the rcar_pcie_enable() fails and MSIs are enabled, the setup done in rcar_pcie_enable_msi() is never undone. Add a function to tear down the MSI setup by disabling the MSI handling in the PCIe block, deallocating the pages requested for the MSIs and zapping the IRQ mapping.

Quoted 19 lines
drivers/pci/host/pcie-rcar.c +13 -0
@@ -900,6 +900,28 @@ static int rcar_pcie_enable_msi(struct rcar_pcie *pcie)
        return err;
 }
 
+static void rcar_pcie_teardown_msi(struct rcar_pcie *pcie)
+{
+       struct rcar_msi *msi = &pcie->msi;
+       int irq, i;
+
+       /* Disable all MSI interrupts */
+       rcar_pci_write_reg(pcie, 0, PCIEMSIIER);
+
+       /* Disable address decoding of the MSI interrupt, MSIFE */
+       rcar_pci_write_reg(pcie, 0, PCIEMSIALR);
+
+       free_pages(msi->pages, 0);
+
Quoted 8 lines

drivers/pci/host/pcie-rcar.c static int rcar_pcie_enable_msi(struct rcar_pcie *pcie) · line 920

Quoted 5 lines
drivers/pci/host/pcie-rcar.c +5 -0
+       for (i = 0; i < INT_PCI_MSI_NR; i++) {
+               irq = irq_find_mapping(msi->domain, i);
+               if (irq > 0)
+                       irq_dispose_mapping(irq);
+       }

Note that similar calls to irq_dispose_mapping() should be added to the failure path of rcar_pcie_enable_msi(), too.

There are no failures happening in rcar_pcie_enable_msi() after the mapping is created, just memory writes, so no. Did I miss something there ?

Signature · 2 lines
Best regards,
Marek Vasut
#12 lore raw

Re: [PATCH 4/4] PCI: rcar: Teardown MSI setup if rcar_pcie_enable() fails

Hi Marek,

Quoted 30 lines · Marek Vasut
Quoted 20 lines · Geert Uytterhoeven
Quoted 19 lines · Marek Vasut
drivers/pci/host/pcie-rcar.c +13 -0
@@ -900,6 +900,28 @@ static int rcar_pcie_enable_msi(struct rcar_pcie *pcie)
        return err;
 }
 
+static void rcar_pcie_teardown_msi(struct rcar_pcie *pcie)
+{
+       struct rcar_msi *msi = &pcie->msi;
+       int irq, i;
+
+       /* Disable all MSI interrupts */
+       rcar_pci_write_reg(pcie, 0, PCIEMSIIER);
+
+       /* Disable address decoding of the MSI interrupt, MSIFE */
+       rcar_pci_write_reg(pcie, 0, PCIEMSIALR);
+
+       free_pages(msi->pages, 0);
+
Quoted 8 lines

drivers/pci/host/pcie-rcar.c static int rcar_pcie_enable_msi(struct rcar_pcie *pcie) · line 920

Quoted 5 lines
drivers/pci/host/pcie-rcar.c +5 -0
+       for (i = 0; i < INT_PCI_MSI_NR; i++) {
+               irq = irq_find_mapping(msi->domain, i);
+               if (irq > 0)
+                       irq_dispose_mapping(irq);
+       }

Note that similar calls to irq_dispose_mapping() should be added to the failure path of rcar_pcie_enable_msi(), too.

Quoted 2 lines

There are no failures happening in rcar_pcie_enable_msi() after the mapping is created, just memory writes, so no. Did I miss something there ?

In my copy, there are two calls to devm_request_irq(). If they fail, the IRQ domain is removed, but the mappings are never disposed of.

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
#13 lore raw

Re: [PATCH 4/4] PCI: rcar: Teardown MSI setup if rcar_pcie_enable() fails

Quoted 33 lines · Geert Uytterhoeven

Hi Marek,

Quoted 30 lines · Marek Vasut
Quoted 28 lines · Geert Uytterhoeven
Quoted 14 lines · Marek Vasut
drivers/pci/host/pcie-rcar.c +8 -0
@@ -900,6 +900,28 @@ static int rcar_pcie_enable_msi(struct rcar_pcie *pcie)
        return err;
 }
 
+static void rcar_pcie_teardown_msi(struct rcar_pcie *pcie)
+{
+       struct rcar_msi *msi = &pcie->msi;
+       int irq, i;
+
+       /* Disable all MSI interrupts */
+       rcar_pci_write_reg(pcie, 0, PCIEMSIIER);
+

drivers/pci/host/pcie-rcar.c static int rcar_pcie_enable_msi(struct rcar_pcie *pcie) · line 920

Quoted 10 lines
drivers/pci/host/pcie-rcar.c +10 -0
+       /* Disable address decoding of the MSI interrupt, MSIFE */
+       rcar_pci_write_reg(pcie, 0, PCIEMSIALR);
+
+       free_pages(msi->pages, 0);
+
+       for (i = 0; i < INT_PCI_MSI_NR; i++) {
+               irq = irq_find_mapping(msi->domain, i);
+               if (irq > 0)
+                       irq_dispose_mapping(irq);
+       }

Note that similar calls to irq_dispose_mapping() should be added to the failure path of rcar_pcie_enable_msi(), too.

Quoted 5 lines
Quoted 2 lines

There are no failures happening in rcar_pcie_enable_msi() after the mapping is created, just memory writes, so no. Did I miss something there ?

In my copy, there are two calls to devm_request_irq(). If they fail, the IRQ domain is removed, but the mappings are never disposed of.

Ah, true, I'll pull out a bit of the rcar_pcie_teardown_msi and call it in the failpath to remove the mapping. Thanks

Signature · 2 lines
Best regards,
Marek Vasut
Reviewed-by on v1 1/4
#14 lore raw
In reply to Marek Vasut
Quoted 6 lines · Marek Vasut

The function name is just too confusing, rename it, no functional change. Rename the function to rcar_pcie_alloc_and_parse_pci_resource_list() as it's matching failpath function is pci_free_resource_list() so the names align much better and the new name also describes what the function does much better.

Quoted 6 lines
Cc Geert Uytterhoeven <[email protected]>
Cc Phil Edworthy <[email protected]>
Cc Simon Horman <[email protected]>
Cc Wolfram Sang <[email protected]>
Reviewed-by on v1 1/4
#15 lore raw
In reply to Marek Vasut
Quoted 7 lines · Marek Vasut

The function name is just too confusing, rename it, no functional change. Rename the function to rcar_pcie_alloc_and_parse_pci_resource_list() as it's matching failpath function is pci_free_resource_list() so the names align much better and the new name also describes what the function does much better.

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
#16 lore raw
In reply to Marek Vasut
Quoted 12 lines · Marek Vasut

The function name is just too confusing, rename it, no functional change. Rename the function to rcar_pcie_alloc_and_parse_pci_resource_list() as it's matching failpath function is pci_free_resource_list() so the names align much better and the new name also describes what the function does much better.

Cc Geert Uytterhoeven <[email protected]>
Cc Phil Edworthy <[email protected]>
Cc Simon Horman <[email protected]>
Cc Wolfram Sang <[email protected]>
Quoted 3 lines
---
 drivers/pci/host/pcie-rcar.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Can you rebase this series against my pci/rcar branch please ?

I will merge it then, thanks.

Lorenzo

Quoted 25 lines
drivers/pci/host/pcie-rcar.c +2 -2
index e403c5206b24..dbc80e457f95 100644
@@ -1051,7 +1051,7 @@ static const struct of_device_id rcar_pcie_of_match[] = {
 	{},
 };
 
-static int rcar_pcie_parse_request_of_pci_ranges(struct rcar_pcie *pci)
+static int rcar_pcie_alloc_and_parse_pci_resource_list(struct rcar_pcie *pci)
 {
 	int err;
 	struct device *dev = pci->dev;
@@ -1108,7 +1108,7 @@ static int rcar_pcie_probe(struct platform_device *pdev)
 
 	INIT_LIST_HEAD(&pcie->resources);
 
-	err = rcar_pcie_parse_request_of_pci_ranges(pcie);
+	err = rcar_pcie_alloc_and_parse_pci_resource_list(pcie);
 	if (err)
 		goto err_free_bridge;
 
Signature · 1 line
2.16.2
#17 lore raw
Quoted 17 lines · Lorenzo Pieralisi
Quoted 12 lines · Marek Vasut

The function name is just too confusing, rename it, no functional change. Rename the function to rcar_pcie_alloc_and_parse_pci_resource_list() as it's matching failpath function is pci_free_resource_list() so the names align much better and the new name also describes what the function does much better.

Cc Geert Uytterhoeven <[email protected]>
Cc Phil Edworthy <[email protected]>
Cc Simon Horman <[email protected]>
Cc Wolfram Sang <[email protected]>
Quoted 3 lines
---
 drivers/pci/host/pcie-rcar.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 3 lines

Can you rebase this series against my pci/rcar branch please ?

I will merge it then, thanks.

Where is that tree/branch located ?

It applies fine on current next 20180517, is there a problem ?

Signature · 2 lines
Best regards,
Marek Vasut
#18 lore raw
Quoted 18 lines · Marek Vasut
Quoted 17 lines · Lorenzo Pieralisi
Quoted 15 lines · Marek Vasut

The function name is just too confusing, rename it, no functional change. Rename the function to rcar_pcie_alloc_and_parse_pci_resource_list() as it's matching failpath function is pci_free_resource_list() so the names align much better and the new name also describes what the function does much better.

Cc Geert Uytterhoeven <[email protected]>
Cc Phil Edworthy <[email protected]>
Cc Simon Horman <[email protected]>
Cc Wolfram Sang <[email protected]>
---
 drivers/pci/host/pcie-rcar.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 7 lines
Quoted 3 lines

Can you rebase this series against my pci/rcar branch please ?

I will merge it then, thanks.

Where is that tree/branch located ?

It applies fine on current next 20180517, is there a problem ?

https://git.kernel.org/pub/scm/linux/kernel/git/lpieralisi/pci.git/log/?h=pci/rcar

I don't think next 20180517 includes Lorenzo's pci/rcar branch, so there might be conflicts. I think Stephen is on vacation until next week, so there isn't a newer -next tree yet.

#19 lore raw
Quoted 21 lines · Bjorn Helgaas
Quoted 20 lines · Marek Vasut
Quoted 19 lines · Lorenzo Pieralisi
Quoted 12 lines · Marek Vasut

The function name is just too confusing, rename it, no functional change. Rename the function to rcar_pcie_alloc_and_parse_pci_resource_list() as it's matching failpath function is pci_free_resource_list() so the names align much better and the new name also describes what the function does much better.

Cc Geert Uytterhoeven <[email protected]>
Cc Phil Edworthy <[email protected]>
Cc Simon Horman <[email protected]>
Cc Wolfram Sang <[email protected]>
Quoted 3 lines
---
 drivers/pci/host/pcie-rcar.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Can you rebase this series against my pci/rcar branch please ?

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

I will merge it then, thanks.

Where is that tree/branch located ?

It applies fine on current next 20180517, is there a problem ?

https://git.kernel.org/pub/scm/linux/kernel/git/lpieralisi/pci.git/log/?h=pci/rcar

OK, 1/4 is dropped, the remaining patches are resubmitted. I added one more (6/6) since the phy patches in that tree added a bug into the fail path, so I fixed that too.

Quoted 3 lines

I don't think next 20180517 includes Lorenzo's pci/rcar branch, so there might be conflicts. I think Stephen is on vacation until next week, so there isn't a newer -next tree yet.

OK

Signature · 2 lines
Best regards,
Marek Vasut
#20 lore raw
Quoted 24 lines · Marek Vasut
Quoted 23 lines · Bjorn Helgaas
Quoted 22 lines · Marek Vasut
Quoted 20 lines · Lorenzo Pieralisi
Quoted 12 lines · Marek Vasut

The function name is just too confusing, rename it, no functional change. Rename the function to rcar_pcie_alloc_and_parse_pci_resource_list() as it's matching failpath function is pci_free_resource_list() so the names align much better and the new name also describes what the function does much better.

Cc Geert Uytterhoeven <[email protected]>
Cc Phil Edworthy <[email protected]>
Cc Simon Horman <[email protected]>
Cc Wolfram Sang <[email protected]>
Quoted 3 lines
---
 drivers/pci/host/pcie-rcar.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Can you rebase this series against my pci/rcar branch please ?

I will merge it then, thanks.

Quoted 8 lines
Quoted 4 lines
Quoted 3 lines

Where is that tree/branch located ?

It applies fine on current next 20180517, is there a problem ?

https://git.kernel.org/pub/scm/linux/kernel/git/lpieralisi/pci.git/log/?h=pci/rcar

OK, 1/4 is dropped, the remaining patches are resubmitted. I added one more (6/6) since the phy patches in that tree added a bug into the fail path, so I fixed that too.

Please CC me if you want me to merge your code, I monitor linux-pci but that would help me, thanks.

You did not add the review tags you received to the new series (also a cover letter - however minimal - and a version number would help), please add them and post a v2 so that I can merge them, I can do that for you but it is good practice for the future.

Thanks,
Lorenzo

Quoted 9 lines
Quoted 3 lines

I don't think next 20180517 includes Lorenzo's pci/rcar branch, so there might be conflicts. I think Stephen is on vacation until next week, so there isn't a newer -next tree yet.

OK

Signature · 2 lines
Best regards,
Marek Vasut
#21 lore raw
Quoted 28 lines · Lorenzo Pieralisi
Quoted 27 lines · Marek Vasut
Quoted 26 lines · Bjorn Helgaas
Quoted 25 lines · Marek Vasut
Quoted 17 lines · Lorenzo Pieralisi
Quoted 12 lines · Marek Vasut

The function name is just too confusing, rename it, no functional change. Rename the function to rcar_pcie_alloc_and_parse_pci_resource_list() as it's matching failpath function is pci_free_resource_list() so the names align much better and the new name also describes what the function does much better.

Cc Geert Uytterhoeven <[email protected]>
Cc Phil Edworthy <[email protected]>
Cc Simon Horman <[email protected]>
Cc Wolfram Sang <[email protected]>
Quoted 3 lines
---
 drivers/pci/host/pcie-rcar.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 3 lines

Can you rebase this series against my pci/rcar branch please ?

I will merge it then, thanks.

Where is that tree/branch located ?

It applies fine on current next 20180517, is there a problem ?

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

https://git.kernel.org/pub/scm/linux/kernel/git/lpieralisi/pci.git/log/?h=pci/rcar

OK, 1/4 is dropped, the remaining patches are resubmitted. I added one more (6/6) since the phy patches in that tree added a bug into the fail path, so I fixed that too.

Please CC me if you want me to merge your code, I monitor linux-pci but that would help me, thanks.

Right

Quoted 1 line

You did not add the review tags you received to the new series

Because I had to rebase the series on top of your tree which contained patches from two months ago which I was not told about which triggered changes in this series, so of course I had to scrub the tags.

Quoted 4 lines

(also a
cover letter - however minimal - and a version number would help), please add them and post a v2 so that I can merge them, I can do that for you but it is good practice for the future.

Sure, I clearly need that practice.

Signature · 2 lines
Best regards,
Marek Vasut