* [PATCH v4 0/6] PCI: rcar: Failpath fixes
@ 2018-05-24 14:36 Marek Vasut
2018-05-24 14:36 ` [PATCH v4 1/6] PCI: rcar: Pull bus clock enable/disable from rcar_pcie_get_resources() Marek Vasut
` (7 more replies)
0 siblings, 8 replies; 24+ messages in thread
From: Marek Vasut @ 2018-05-24 14:36 UTC (permalink / raw)
To: linux-pci
Cc: Marek Vasut, Geert Uytterhoeven, Lorenzo Pieralisi,
Phil Edworthy, Simon Horman, Wolfram Sang, linux-renesas-soc
Multiple minor failpath fixes for the R-Car PCIe driver.
V4: Sync up the version numbers
Rebase on top of Lorenzo's tree
Add new patch fixing bug in the PHY code
Marek Vasut (6):
PCI: rcar: Pull bus clock enable/disable from
rcar_pcie_get_resources()
PCI: rcar: Add missing irq_dispose_mapping() into failpath
PCI: rcar: Teardown MSI setup if rcar_pcie_enable() fails
PCI: rcar: Poll more often in rcar_pcie_wait_for_dl()
PCI: rcar: Remove IRQ mappings in rcar_pcie_enable_msi failpath
PCI: rcar: Shut the PHY down in failpath
drivers/pci/host/pcie-rcar.c | 82 +++++++++++++++++++++++++++++++++++---------
1 file changed, 66 insertions(+), 16 deletions(-)
Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Geert Uytterhoeven <geert+renesas@glider.be>
Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: Phil Edworthy <phil.edworthy@renesas.com>
Cc: Simon Horman <horms+renesas@verge.net.au>
Cc: Wolfram Sang <wsa@the-dreams.de>
Cc: linux-renesas-soc@vger.kernel.org
--
2.16.2
^ permalink raw reply [flat|nested] 24+ messages in thread
* [PATCH v4 1/6] PCI: rcar: Pull bus clock enable/disable from rcar_pcie_get_resources()
2018-05-24 14:36 [PATCH v4 0/6] PCI: rcar: Failpath fixes Marek Vasut
@ 2018-05-24 14:36 ` Marek Vasut
2018-05-28 8:51 ` Simon Horman
2018-05-24 14:36 ` [PATCH v4 2/6] PCI: rcar: Add missing irq_dispose_mapping() into failpath Marek Vasut
` (6 subsequent siblings)
7 siblings, 1 reply; 24+ messages in thread
From: Marek Vasut @ 2018-05-24 14:36 UTC (permalink / raw)
To: linux-pci
Cc: Marek Vasut, Geert Uytterhoeven, Lorenzo Pieralisi,
Phil Edworthy, Simon Horman, Wolfram Sang, linux-renesas-soc
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.
Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Geert Uytterhoeven <geert+renesas@glider.be>
Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: Phil Edworthy <phil.edworthy@renesas.com>
Cc: Simon Horman <horms+renesas@verge.net.au>
Cc: Wolfram Sang <wsa@the-dreams.de>
Cc: linux-renesas-soc@vger.kernel.org
---
V2: No change
V3: No change
V4: Rebase on top of Lorenzo's pci/rcar, fix up the rebase breakage
induced by patches therein
---
drivers/pci/host/pcie-rcar.c | 33 ++++++++++++++++-----------------
1 file changed, 16 insertions(+), 17 deletions(-)
diff --git a/drivers/pci/host/pcie-rcar.c b/drivers/pci/host/pcie-rcar.c
index 8d161563bce8..0879880f7975 100644
--- a/drivers/pci/host/pcie-rcar.c
+++ b/drivers/pci/host/pcie-rcar.c
@@ -946,32 +946,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,
@@ -1115,22 +1105,28 @@ 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;
phy_init_fn = of_device_get_match_data(dev);
err = phy_init_fn(pcie);
if (err) {
dev_err(dev, "failed to init PCIe PHY\n");
- goto err_pm_put;
+ goto err_clk_disable;
}
/* Failure to get a link might just be that no cards are inserted */
if (rcar_pcie_hw_init(pcie)) {
dev_info(dev, "PCIe link down\n");
err = -ENODEV;
- goto err_pm_put;
+ goto err_clk_disable;
}
data = rcar_pci_read_reg(pcie, MACSR);
@@ -1142,16 +1138,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);
--
2.16.2
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH v4 2/6] PCI: rcar: Add missing irq_dispose_mapping() into failpath
2018-05-24 14:36 [PATCH v4 0/6] PCI: rcar: Failpath fixes Marek Vasut
2018-05-24 14:36 ` [PATCH v4 1/6] PCI: rcar: Pull bus clock enable/disable from rcar_pcie_get_resources() Marek Vasut
@ 2018-05-24 14:36 ` Marek Vasut
2018-05-28 8:51 ` Simon Horman
2018-05-24 14:36 ` [PATCH v4 3/6] PCI: rcar: Teardown MSI setup if rcar_pcie_enable() fails Marek Vasut
` (5 subsequent siblings)
7 siblings, 1 reply; 24+ messages in thread
From: Marek Vasut @ 2018-05-24 14:36 UTC (permalink / raw)
To: linux-pci
Cc: Marek Vasut, Geert Uytterhoeven, Lorenzo Pieralisi,
Phil Edworthy, Simon Horman, Wolfram Sang, linux-renesas-soc
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.
Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Geert Uytterhoeven <geert+renesas@glider.be>
Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: Phil Edworthy <phil.edworthy@renesas.com>
Cc: Simon Horman <horms+renesas@verge.net.au>
Cc: Wolfram Sang <wsa@the-dreams.de>
Cc: linux-renesas-soc@vger.kernel.org
---
V2: No change
V3: No change
V4: Rebase on top of Lorenzo's pci/rcar, fix up the rebase breakage
induced by patches therein
---
drivers/pci/host/pcie-rcar.c | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/drivers/pci/host/pcie-rcar.c b/drivers/pci/host/pcie-rcar.c
index 0879880f7975..6bb1cdec26be 100644
--- a/drivers/pci/host/pcie-rcar.c
+++ b/drivers/pci/host/pcie-rcar.c
@@ -950,18 +950,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,
@@ -1108,7 +1115,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);
@@ -1151,6 +1158,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);
--
2.16.2
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH v4 3/6] PCI: rcar: Teardown MSI setup if rcar_pcie_enable() fails
2018-05-24 14:36 [PATCH v4 0/6] PCI: rcar: Failpath fixes Marek Vasut
2018-05-24 14:36 ` [PATCH v4 1/6] PCI: rcar: Pull bus clock enable/disable from rcar_pcie_get_resources() Marek Vasut
2018-05-24 14:36 ` [PATCH v4 2/6] PCI: rcar: Add missing irq_dispose_mapping() into failpath Marek Vasut
@ 2018-05-24 14:36 ` Marek Vasut
2018-05-28 8:52 ` Simon Horman
2018-05-24 14:36 ` [PATCH v4 4/6] PCI: rcar: Poll more often in rcar_pcie_wait_for_dl() Marek Vasut
` (4 subsequent siblings)
7 siblings, 1 reply; 24+ messages in thread
From: Marek Vasut @ 2018-05-24 14:36 UTC (permalink / raw)
To: linux-pci
Cc: Marek Vasut, Geert Uytterhoeven, Lorenzo Pieralisi,
Phil Edworthy, Simon Horman, Wolfram Sang, linux-renesas-soc
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.
Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Geert Uytterhoeven <geert+renesas@glider.be>
Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: Phil Edworthy <phil.edworthy@renesas.com>
Cc: Simon Horman <horms+renesas@verge.net.au>
Cc: Wolfram Sang <wsa@the-dreams.de>
Cc: linux-renesas-soc@vger.kernel.org
---
V2: No change
V3: No change
V4: Rebase on top of Lorenzo's pci/rcar, fix up the rebase breakage
induced by patches therein
---
drivers/pci/host/pcie-rcar.c | 28 +++++++++++++++++++++++++++-
1 file changed, 27 insertions(+), 1 deletion(-)
diff --git a/drivers/pci/host/pcie-rcar.c b/drivers/pci/host/pcie-rcar.c
index 6bb1cdec26be..d6a7e8482dcf 100644
--- a/drivers/pci/host/pcie-rcar.c
+++ b/drivers/pci/host/pcie-rcar.c
@@ -923,6 +923,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;
@@ -1151,10 +1173,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);
--
2.16.2
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH v4 4/6] PCI: rcar: Poll more often in rcar_pcie_wait_for_dl()
2018-05-24 14:36 [PATCH v4 0/6] PCI: rcar: Failpath fixes Marek Vasut
` (2 preceding siblings ...)
2018-05-24 14:36 ` [PATCH v4 3/6] PCI: rcar: Teardown MSI setup if rcar_pcie_enable() fails Marek Vasut
@ 2018-05-24 14:36 ` Marek Vasut
2018-05-28 8:53 ` Simon Horman
2018-05-24 14:36 ` [PATCH v4 5/6] PCI: rcar: Remove IRQ mappings in rcar_pcie_enable_msi failpath Marek Vasut
` (3 subsequent siblings)
7 siblings, 1 reply; 24+ messages in thread
From: Marek Vasut @ 2018-05-24 14:36 UTC (permalink / raw)
To: linux-pci
Cc: Marek Vasut, Geert Uytterhoeven, Lorenzo Pieralisi,
Phil Edworthy, Simon Horman, Wolfram Sang, linux-renesas-soc
The data link active signal usually takes ~20 uSec to be asserted,
poll the bit more often to avoid useless delays in this function.
Use udelay() instead of usleep() for such a small delay as suggested
by the timer documentation and because this will be used in atomic
context later on when the suspend/resume patches land.
Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Geert Uytterhoeven <geert+renesas@glider.be>
Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: Phil Edworthy <phil.edworthy@renesas.com>
Cc: Simon Horman <horms+renesas@verge.net.au>
Cc: Wolfram Sang <wsa@the-dreams.de>
Cc: linux-renesas-soc@vger.kernel.org
---
V2: s/content/context in commit message
V3: Add cpu_relax()
V4: Rebase on top of Lorenzo's pci/rcar, fix up the rebase breakage
induced by patches therein
---
drivers/pci/host/pcie-rcar.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/pci/host/pcie-rcar.c b/drivers/pci/host/pcie-rcar.c
index d6a7e8482dcf..4843a4dc6059 100644
--- a/drivers/pci/host/pcie-rcar.c
+++ b/drivers/pci/host/pcie-rcar.c
@@ -546,13 +546,14 @@ static int rcar_pcie_wait_for_phyrdy(struct rcar_pcie *pcie)
static int rcar_pcie_wait_for_dl(struct rcar_pcie *pcie)
{
- unsigned int timeout = 10;
+ unsigned int timeout = 10000;
while (timeout--) {
if ((rcar_pci_read_reg(pcie, PCIETSTR) & DATA_LINK_ACTIVE))
return 0;
- msleep(5);
+ udelay(5);
+ cpu_relax();
}
return -ETIMEDOUT;
--
2.16.2
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH v4 5/6] PCI: rcar: Remove IRQ mappings in rcar_pcie_enable_msi failpath
2018-05-24 14:36 [PATCH v4 0/6] PCI: rcar: Failpath fixes Marek Vasut
` (3 preceding siblings ...)
2018-05-24 14:36 ` [PATCH v4 4/6] PCI: rcar: Poll more often in rcar_pcie_wait_for_dl() Marek Vasut
@ 2018-05-24 14:36 ` Marek Vasut
2018-05-28 8:53 ` Simon Horman
2018-05-24 14:36 ` [PATCH v4 6/6] PCI: rcar: Shut the PHY down in failpath Marek Vasut
` (2 subsequent siblings)
7 siblings, 1 reply; 24+ messages in thread
From: Marek Vasut @ 2018-05-24 14:36 UTC (permalink / raw)
To: linux-pci
Cc: Marek Vasut, Geert Uytterhoeven, Lorenzo Pieralisi,
Phil Edworthy, Simon Horman, Wolfram Sang, linux-renesas-soc
The rcar_pcie_enable_msi() creates IRQ mappings using irq_create_mapping()
before requesting the IRQs using devm_request_irq(). If devm_request_irq()
fails for some reason, rcar_pcie_enable_msi() does not remove the mapping.
Pull out the code for disposing IRQ mappings from rcar_pcie_teardown_msi()
into a separate function and call it from both rcar_pcie_teardown_msi()
and rcar_pcie_enable_msi() failpath to remove the mappings correctly.
Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Reported-by: Geert Uytterhoeven <geert+renesas@glider.be>
Cc: Geert Uytterhoeven <geert+renesas@glider.be>
Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: Phil Edworthy <phil.edworthy@renesas.com>
Cc: Simon Horman <horms+renesas@verge.net.au>
Cc: Wolfram Sang <wsa@the-dreams.de>
Cc: linux-renesas-soc@vger.kernel.org
---
V2: No change
V3: No change
V4: Rebase on top of Lorenzo's pci/rcar, fix up the rebase breakage
induced by patches therein
---
drivers/pci/host/pcie-rcar.c | 25 ++++++++++++++++---------
1 file changed, 16 insertions(+), 9 deletions(-)
diff --git a/drivers/pci/host/pcie-rcar.c b/drivers/pci/host/pcie-rcar.c
index 4843a4dc6059..636c3c5095d2 100644
--- a/drivers/pci/host/pcie-rcar.c
+++ b/drivers/pci/host/pcie-rcar.c
@@ -866,6 +866,20 @@ static const struct irq_domain_ops msi_domain_ops = {
.map = rcar_msi_map,
};
+static void rcar_pcie_unmap_msi(struct rcar_pcie *pcie)
+{
+ struct rcar_msi *msi = &pcie->msi;
+ int i, irq;
+
+ 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_enable_msi(struct rcar_pcie *pcie)
{
struct device *dev = pcie->dev;
@@ -920,14 +934,13 @@ static int rcar_pcie_enable_msi(struct rcar_pcie *pcie)
return 0;
err:
- irq_domain_remove(msi->domain);
+ rcar_pcie_unmap_msi(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);
@@ -937,13 +950,7 @@ static void rcar_pcie_teardown_msi(struct rcar_pcie *pcie)
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);
+ rcar_pcie_unmap_msi(pcie);
}
static int rcar_pcie_get_resources(struct rcar_pcie *pcie)
--
2.16.2
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH v4 6/6] PCI: rcar: Shut the PHY down in failpath
2018-05-24 14:36 [PATCH v4 0/6] PCI: rcar: Failpath fixes Marek Vasut
` (4 preceding siblings ...)
2018-05-24 14:36 ` [PATCH v4 5/6] PCI: rcar: Remove IRQ mappings in rcar_pcie_enable_msi failpath Marek Vasut
@ 2018-05-24 14:36 ` Marek Vasut
2018-05-25 10:09 ` Geert Uytterhoeven
` (2 more replies)
2018-05-25 9:35 ` [PATCH v4 0/6] PCI: rcar: Failpath fixes Lorenzo Pieralisi
2018-05-25 16:43 ` Lorenzo Pieralisi
7 siblings, 3 replies; 24+ messages in thread
From: Marek Vasut @ 2018-05-24 14:36 UTC (permalink / raw)
To: linux-pci
Cc: Marek Vasut, Geert Uytterhoeven, Lorenzo Pieralisi,
Phil Edworthy, Simon Horman, Wolfram Sang, linux-renesas-soc
If anything fails past phy_init_fn() and the system is a Gen3 with
a PHY, the PHY will be left on and inited. This is caused by the
phy_init_fn, which is in fact a pointer to rcar_pcie_phy_init_gen3()
function, which starts the PHY, yet has no counterpart in the failpath.
Add that counterpart.
Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Geert Uytterhoeven <geert+renesas@glider.be>
Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: Phil Edworthy <phil.edworthy@renesas.com>
Cc: Simon Horman <horms+renesas@verge.net.au>
Cc: Wolfram Sang <wsa@the-dreams.de>
Cc: linux-renesas-soc@vger.kernel.org
Fixes: 517ca93a7159 ("PCI: rcar: Add R-Car gen3 PHY support")
---
V4: New patch
---
drivers/pci/host/pcie-rcar.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/drivers/pci/host/pcie-rcar.c b/drivers/pci/host/pcie-rcar.c
index 636c3c5095d2..695781934f0a 100644
--- a/drivers/pci/host/pcie-rcar.c
+++ b/drivers/pci/host/pcie-rcar.c
@@ -1163,7 +1163,7 @@ static int rcar_pcie_probe(struct platform_device *pdev)
if (rcar_pcie_hw_init(pcie)) {
dev_info(dev, "PCIe link down\n");
err = -ENODEV;
- goto err_clk_disable;
+ goto err_phy_shutdown;
}
data = rcar_pci_read_reg(pcie, MACSR);
@@ -1175,7 +1175,7 @@ static int rcar_pcie_probe(struct platform_device *pdev)
dev_err(dev,
"failed to enable MSI support: %d\n",
err);
- goto err_clk_disable;
+ goto err_phy_shutdown;
}
}
@@ -1189,6 +1189,12 @@ static int rcar_pcie_probe(struct platform_device *pdev)
if (IS_ENABLED(CONFIG_PCI_MSI))
rcar_pcie_teardown_msi(pcie);
+err_phy_shutdown:
+ if (pcie->phy) {
+ phy_power_off(pcie->phy);
+ phy_exit(pcie->phy);
+ }
+
err_clk_disable:
clk_disable_unprepare(pcie->bus_clk);
--
2.16.2
^ permalink raw reply related [flat|nested] 24+ messages in thread
* Re: [PATCH v4 0/6] PCI: rcar: Failpath fixes
2018-05-24 14:36 [PATCH v4 0/6] PCI: rcar: Failpath fixes Marek Vasut
` (5 preceding siblings ...)
2018-05-24 14:36 ` [PATCH v4 6/6] PCI: rcar: Shut the PHY down in failpath Marek Vasut
@ 2018-05-25 9:35 ` Lorenzo Pieralisi
2018-05-25 9:39 ` Geert Uytterhoeven
2018-05-25 16:43 ` Lorenzo Pieralisi
7 siblings, 1 reply; 24+ messages in thread
From: Lorenzo Pieralisi @ 2018-05-25 9:35 UTC (permalink / raw)
To: Marek Vasut, Geert Uytterhoeven, Simon Horman
Cc: linux-pci, Marek Vasut, Phil Edworthy, Wolfram Sang, linux-renesas-soc
Geert, Simon,
Can I retain your review tags on this series so that I can queue
the patches ? I already added them apart from the last patch that
is new, please let me know asap.
Thanks,
Lorenzo
On Thu, May 24, 2018 at 04:36:18PM +0200, Marek Vasut wrote:
> Multiple minor failpath fixes for the R-Car PCIe driver.
>
> V4: Sync up the version numbers
> Rebase on top of Lorenzo's tree
> Add new patch fixing bug in the PHY code
>
> Marek Vasut (6):
> PCI: rcar: Pull bus clock enable/disable from
> rcar_pcie_get_resources()
> PCI: rcar: Add missing irq_dispose_mapping() into failpath
> PCI: rcar: Teardown MSI setup if rcar_pcie_enable() fails
> PCI: rcar: Poll more often in rcar_pcie_wait_for_dl()
> PCI: rcar: Remove IRQ mappings in rcar_pcie_enable_msi failpath
> PCI: rcar: Shut the PHY down in failpath
>
> drivers/pci/host/pcie-rcar.c | 82 +++++++++++++++++++++++++++++++++++---------
> 1 file changed, 66 insertions(+), 16 deletions(-)
>
> Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
> Cc: Geert Uytterhoeven <geert+renesas@glider.be>
> Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
> Cc: Phil Edworthy <phil.edworthy@renesas.com>
> Cc: Simon Horman <horms+renesas@verge.net.au>
> Cc: Wolfram Sang <wsa@the-dreams.de>
> Cc: linux-renesas-soc@vger.kernel.org
>
> --
> 2.16.2
>
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH v4 0/6] PCI: rcar: Failpath fixes
2018-05-25 9:35 ` [PATCH v4 0/6] PCI: rcar: Failpath fixes Lorenzo Pieralisi
@ 2018-05-25 9:39 ` Geert Uytterhoeven
2018-05-25 9:56 ` Lorenzo Pieralisi
0 siblings, 1 reply; 24+ messages in thread
From: Geert Uytterhoeven @ 2018-05-25 9:39 UTC (permalink / raw)
To: Lorenzo Pieralisi
Cc: Marek Vasut, Geert Uytterhoeven, Simon Horman, linux-pci,
Marek Vasut, Phil Edworthy, Wolfram Sang, Linux-Renesas
Hi Lorenzo,
On Fri, May 25, 2018 at 11:35 AM, Lorenzo Pieralisi
<lorenzo.pieralisi@arm.com> wrote:
> Can I retain your review tags on this series so that I can queue
> the patches ? I already added them apart from the last patch that
> is new, please let me know asap.
Yes, please.
Thanks!
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
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
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH v4 0/6] PCI: rcar: Failpath fixes
2018-05-25 9:39 ` Geert Uytterhoeven
@ 2018-05-25 9:56 ` Lorenzo Pieralisi
2018-05-25 10:01 ` Geert Uytterhoeven
0 siblings, 1 reply; 24+ messages in thread
From: Lorenzo Pieralisi @ 2018-05-25 9:56 UTC (permalink / raw)
To: Geert Uytterhoeven
Cc: Marek Vasut, Geert Uytterhoeven, Simon Horman, linux-pci,
Marek Vasut, Phil Edworthy, Wolfram Sang, Linux-Renesas
On Fri, May 25, 2018 at 11:39:08AM +0200, Geert Uytterhoeven wrote:
> Hi Lorenzo,
>
> On Fri, May 25, 2018 at 11:35 AM, Lorenzo Pieralisi
> <lorenzo.pieralisi@arm.com> wrote:
> > Can I retain your review tags on this series so that I can queue
> > the patches ? I already added them apart from the last patch that
> > is new, please let me know asap.
>
> Yes, please.
I assume that's valid also for the last patch, I need Simon's ACK
to proceed too.
Lorenzo
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH v4 0/6] PCI: rcar: Failpath fixes
2018-05-25 9:56 ` Lorenzo Pieralisi
@ 2018-05-25 10:01 ` Geert Uytterhoeven
0 siblings, 0 replies; 24+ messages in thread
From: Geert Uytterhoeven @ 2018-05-25 10:01 UTC (permalink / raw)
To: Lorenzo Pieralisi
Cc: Marek Vasut, Geert Uytterhoeven, Simon Horman, linux-pci,
Marek Vasut, Phil Edworthy, Wolfram Sang, Linux-Renesas
Hi Lorenzo,
On Fri, May 25, 2018 at 11:56 AM, Lorenzo Pieralisi
<lorenzo.pieralisi@arm.com> wrote:
> On Fri, May 25, 2018 at 11:39:08AM +0200, Geert Uytterhoeven wrote:
>> On Fri, May 25, 2018 at 11:35 AM, Lorenzo Pieralisi
>> <lorenzo.pieralisi@arm.com> wrote:
>> > Can I retain your review tags on this series so that I can queue
>> > the patches ? I already added them apart from the last patch that
>> > is new, please let me know asap.
>>
>> Yes, please.
>
> I assume that's valid also for the last patch, I need Simon's ACK
> to proceed too.
I haven't reviewed the last patch yet.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
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
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH v4 6/6] PCI: rcar: Shut the PHY down in failpath
2018-05-24 14:36 ` [PATCH v4 6/6] PCI: rcar: Shut the PHY down in failpath Marek Vasut
@ 2018-05-25 10:09 ` Geert Uytterhoeven
2018-05-25 18:34 ` Marek Vasut
2018-05-28 8:48 ` Simon Horman
2018-06-29 13:38 ` Lorenzo Pieralisi
2 siblings, 1 reply; 24+ messages in thread
From: Geert Uytterhoeven @ 2018-05-25 10:09 UTC (permalink / raw)
To: Marek Vasut
Cc: linux-pci, Marek Vasut, Geert Uytterhoeven, Lorenzo Pieralisi,
Phil Edworthy, Simon Horman, Wolfram Sang, Linux-Renesas
On Thu, May 24, 2018 at 4:36 PM, Marek Vasut <marek.vasut@gmail.com> wrote:
> If anything fails past phy_init_fn() and the system is a Gen3 with
> a PHY, the PHY will be left on and inited. This is caused by the
> phy_init_fn, which is in fact a pointer to rcar_pcie_phy_init_gen3()
> function, which starts the PHY, yet has no counterpart in the failpath.
> Add that counterpart.
>
> Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Note that there's another unhandled failure mode: rcar_pcie_phy_init_gen3()
doesn't call phy_exit() if phy_power_on() fails.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
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
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH v4 0/6] PCI: rcar: Failpath fixes
2018-05-24 14:36 [PATCH v4 0/6] PCI: rcar: Failpath fixes Marek Vasut
` (6 preceding siblings ...)
2018-05-25 9:35 ` [PATCH v4 0/6] PCI: rcar: Failpath fixes Lorenzo Pieralisi
@ 2018-05-25 16:43 ` Lorenzo Pieralisi
2018-05-25 17:10 ` Marek Vasut
2018-05-28 8:54 ` Simon Horman
7 siblings, 2 replies; 24+ messages in thread
From: Lorenzo Pieralisi @ 2018-05-25 16:43 UTC (permalink / raw)
To: Marek Vasut
Cc: linux-pci, Marek Vasut, Geert Uytterhoeven, Phil Edworthy,
Simon Horman, Wolfram Sang, linux-renesas-soc
On Thu, May 24, 2018 at 04:36:18PM +0200, Marek Vasut wrote:
> Multiple minor failpath fixes for the R-Car PCIe driver.
>
> V4: Sync up the version numbers
> Rebase on top of Lorenzo's tree
> Add new patch fixing bug in the PHY code
>
> Marek Vasut (6):
> PCI: rcar: Pull bus clock enable/disable from
> rcar_pcie_get_resources()
> PCI: rcar: Add missing irq_dispose_mapping() into failpath
> PCI: rcar: Teardown MSI setup if rcar_pcie_enable() fails
> PCI: rcar: Poll more often in rcar_pcie_wait_for_dl()
> PCI: rcar: Remove IRQ mappings in rcar_pcie_enable_msi failpath
> PCI: rcar: Shut the PHY down in failpath
>
> drivers/pci/host/pcie-rcar.c | 82 +++++++++++++++++++++++++++++++++++---------
> 1 file changed, 66 insertions(+), 16 deletions(-)
Marek,
I have applied patches [1-5] to pci/rcar for v4.18, I could not
apply patch 6 since it is missing Simon's ACK (please have a look
at what I queued to check it is OK).
Bjorn will be merging the branch into -next shortly, I do not know if
there is room for adding additional patches on top of it, as I mentioned
on linux-pci I will be offline for two weeks so it is possible that
what's in pci/rcar at present will be what gets into v4.18, apologies,
that's all I can do.
Lorenzo
> Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
> Cc: Geert Uytterhoeven <geert+renesas@glider.be>
> Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
> Cc: Phil Edworthy <phil.edworthy@renesas.com>
> Cc: Simon Horman <horms+renesas@verge.net.au>
> Cc: Wolfram Sang <wsa@the-dreams.de>
> Cc: linux-renesas-soc@vger.kernel.org
>
> --
> 2.16.2
>
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH v4 0/6] PCI: rcar: Failpath fixes
2018-05-25 16:43 ` Lorenzo Pieralisi
@ 2018-05-25 17:10 ` Marek Vasut
2018-05-28 8:54 ` Simon Horman
1 sibling, 0 replies; 24+ messages in thread
From: Marek Vasut @ 2018-05-25 17:10 UTC (permalink / raw)
To: Lorenzo Pieralisi
Cc: linux-pci, Marek Vasut, Geert Uytterhoeven, Phil Edworthy,
Simon Horman, Wolfram Sang, linux-renesas-soc
On 05/25/2018 06:43 PM, Lorenzo Pieralisi wrote:
> On Thu, May 24, 2018 at 04:36:18PM +0200, Marek Vasut wrote:
>> Multiple minor failpath fixes for the R-Car PCIe driver.
>>
>> V4: Sync up the version numbers
>> Rebase on top of Lorenzo's tree
>> Add new patch fixing bug in the PHY code
>>
>> Marek Vasut (6):
>> PCI: rcar: Pull bus clock enable/disable from
>> rcar_pcie_get_resources()
>> PCI: rcar: Add missing irq_dispose_mapping() into failpath
>> PCI: rcar: Teardown MSI setup if rcar_pcie_enable() fails
>> PCI: rcar: Poll more often in rcar_pcie_wait_for_dl()
>> PCI: rcar: Remove IRQ mappings in rcar_pcie_enable_msi failpath
>> PCI: rcar: Shut the PHY down in failpath
>>
>> drivers/pci/host/pcie-rcar.c | 82 +++++++++++++++++++++++++++++++++++---------
>> 1 file changed, 66 insertions(+), 16 deletions(-)
>
> Marek,
>
> I have applied patches [1-5] to pci/rcar for v4.18, I could not
> apply patch 6 since it is missing Simon's ACK (please have a look
> at what I queued to check it is OK).
>
> Bjorn will be merging the branch into -next shortly, I do not know if
> there is room for adding additional patches on top of it, as I mentioned
> on linux-pci I will be offline for two weeks so it is possible that
> what's in pci/rcar at present will be what gets into v4.18, apologies,
> that's all I can do.
Fine. Yes, there's another patch coming for the PHY stuff from Sergej.
--
Best regards,
Marek Vasut
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH v4 6/6] PCI: rcar: Shut the PHY down in failpath
2018-05-25 10:09 ` Geert Uytterhoeven
@ 2018-05-25 18:34 ` Marek Vasut
0 siblings, 0 replies; 24+ messages in thread
From: Marek Vasut @ 2018-05-25 18:34 UTC (permalink / raw)
To: Geert Uytterhoeven
Cc: linux-pci, Marek Vasut, Geert Uytterhoeven, Lorenzo Pieralisi,
Phil Edworthy, Simon Horman, Wolfram Sang, Linux-Renesas
On 05/25/2018 12:09 PM, Geert Uytterhoeven wrote:
> On Thu, May 24, 2018 at 4:36 PM, Marek Vasut <marek.vasut@gmail.com> wrote:
>> If anything fails past phy_init_fn() and the system is a Gen3 with
>> a PHY, the PHY will be left on and inited. This is caused by the
>> phy_init_fn, which is in fact a pointer to rcar_pcie_phy_init_gen3()
>> function, which starts the PHY, yet has no counterpart in the failpath.
>> Add that counterpart.
>>
>> Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
>
> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
>
> Note that there's another unhandled failure mode: rcar_pcie_phy_init_gen3()
> doesn't call phy_exit() if phy_power_on() fails.
Should be fixed by subsequent patch, thanks.
--
Best regards,
Marek Vasut
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH v4 6/6] PCI: rcar: Shut the PHY down in failpath
2018-05-24 14:36 ` [PATCH v4 6/6] PCI: rcar: Shut the PHY down in failpath Marek Vasut
2018-05-25 10:09 ` Geert Uytterhoeven
@ 2018-05-28 8:48 ` Simon Horman
2018-06-01 23:30 ` Marek Vasut
2018-06-29 13:38 ` Lorenzo Pieralisi
2 siblings, 1 reply; 24+ messages in thread
From: Simon Horman @ 2018-05-28 8:48 UTC (permalink / raw)
To: Marek Vasut
Cc: linux-pci, Marek Vasut, Geert Uytterhoeven, Lorenzo Pieralisi,
Phil Edworthy, Wolfram Sang, linux-renesas-soc
On Thu, May 24, 2018 at 04:36:24PM +0200, Marek Vasut wrote:
> If anything fails past phy_init_fn() and the system is a Gen3 with
> a PHY, the PHY will be left on and inited. This is caused by the
> phy_init_fn, which is in fact a pointer to rcar_pcie_phy_init_gen3()
> function, which starts the PHY, yet has no counterpart in the failpath.
> Add that counterpart.
>
> Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
> Cc: Geert Uytterhoeven <geert+renesas@glider.be>
> Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
> Cc: Phil Edworthy <phil.edworthy@renesas.com>
> Cc: Simon Horman <horms+renesas@verge.net.au>
> Cc: Wolfram Sang <wsa@the-dreams.de>
> Cc: linux-renesas-soc@vger.kernel.org
> Fixes: 517ca93a7159 ("PCI: rcar: Add R-Car gen3 PHY support")
Acked-by: Simon Horman <horms+renesas@verge.net.au>
> ---
> V4: New patch
> ---
> drivers/pci/host/pcie-rcar.c | 10 ++++++++--
> 1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/pci/host/pcie-rcar.c b/drivers/pci/host/pcie-rcar.c
> index 636c3c5095d2..695781934f0a 100644
> --- a/drivers/pci/host/pcie-rcar.c
> +++ b/drivers/pci/host/pcie-rcar.c
> @@ -1163,7 +1163,7 @@ static int rcar_pcie_probe(struct platform_device *pdev)
> if (rcar_pcie_hw_init(pcie)) {
> dev_info(dev, "PCIe link down\n");
> err = -ENODEV;
> - goto err_clk_disable;
> + goto err_phy_shutdown;
> }
>
> data = rcar_pci_read_reg(pcie, MACSR);
> @@ -1175,7 +1175,7 @@ static int rcar_pcie_probe(struct platform_device *pdev)
> dev_err(dev,
> "failed to enable MSI support: %d\n",
> err);
> - goto err_clk_disable;
> + goto err_phy_shutdown;
> }
> }
>
> @@ -1189,6 +1189,12 @@ static int rcar_pcie_probe(struct platform_device *pdev)
> if (IS_ENABLED(CONFIG_PCI_MSI))
> rcar_pcie_teardown_msi(pcie);
>
> +err_phy_shutdown:
> + if (pcie->phy) {
> + phy_power_off(pcie->phy);
> + phy_exit(pcie->phy);
> + }
> +
> err_clk_disable:
> clk_disable_unprepare(pcie->bus_clk);
>
> --
> 2.16.2
>
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH v4 1/6] PCI: rcar: Pull bus clock enable/disable from rcar_pcie_get_resources()
2018-05-24 14:36 ` [PATCH v4 1/6] PCI: rcar: Pull bus clock enable/disable from rcar_pcie_get_resources() Marek Vasut
@ 2018-05-28 8:51 ` Simon Horman
0 siblings, 0 replies; 24+ messages in thread
From: Simon Horman @ 2018-05-28 8:51 UTC (permalink / raw)
To: Marek Vasut
Cc: linux-pci, Marek Vasut, Geert Uytterhoeven, Lorenzo Pieralisi,
Phil Edworthy, Wolfram Sang, linux-renesas-soc
On Thu, May 24, 2018 at 04:36:19PM +0200, Marek Vasut wrote:
> 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.
>
> Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
> Cc: Geert Uytterhoeven <geert+renesas@glider.be>
> Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
> Cc: Phil Edworthy <phil.edworthy@renesas.com>
> Cc: Simon Horman <horms+renesas@verge.net.au>
> Cc: Wolfram Sang <wsa@the-dreams.de>
> Cc: linux-renesas-soc@vger.kernel.org
> ---
> V2: No change
> V3: No change
> V4: Rebase on top of Lorenzo's pci/rcar, fix up the rebase breakage
> induced by patches therein
Acked-by: Simon Horman <horms+renesas@verge.net.au>
> ---
> drivers/pci/host/pcie-rcar.c | 33 ++++++++++++++++-----------------
> 1 file changed, 16 insertions(+), 17 deletions(-)
>
> diff --git a/drivers/pci/host/pcie-rcar.c b/drivers/pci/host/pcie-rcar.c
> index 8d161563bce8..0879880f7975 100644
> --- a/drivers/pci/host/pcie-rcar.c
> +++ b/drivers/pci/host/pcie-rcar.c
> @@ -946,32 +946,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,
> @@ -1115,22 +1105,28 @@ 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;
>
> phy_init_fn = of_device_get_match_data(dev);
> err = phy_init_fn(pcie);
> if (err) {
> dev_err(dev, "failed to init PCIe PHY\n");
> - goto err_pm_put;
> + goto err_clk_disable;
> }
>
> /* Failure to get a link might just be that no cards are inserted */
> if (rcar_pcie_hw_init(pcie)) {
> dev_info(dev, "PCIe link down\n");
> err = -ENODEV;
> - goto err_pm_put;
> + goto err_clk_disable;
> }
>
> data = rcar_pci_read_reg(pcie, MACSR);
> @@ -1142,16 +1138,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);
>
> --
> 2.16.2
>
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH v4 2/6] PCI: rcar: Add missing irq_dispose_mapping() into failpath
2018-05-24 14:36 ` [PATCH v4 2/6] PCI: rcar: Add missing irq_dispose_mapping() into failpath Marek Vasut
@ 2018-05-28 8:51 ` Simon Horman
0 siblings, 0 replies; 24+ messages in thread
From: Simon Horman @ 2018-05-28 8:51 UTC (permalink / raw)
To: Marek Vasut
Cc: linux-pci, Marek Vasut, Geert Uytterhoeven, Lorenzo Pieralisi,
Phil Edworthy, Wolfram Sang, linux-renesas-soc
On Thu, May 24, 2018 at 04:36:20PM +0200, Marek Vasut wrote:
> 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.
>
> Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
> Cc: Geert Uytterhoeven <geert+renesas@glider.be>
> Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
> Cc: Phil Edworthy <phil.edworthy@renesas.com>
> Cc: Simon Horman <horms+renesas@verge.net.au>
> Cc: Wolfram Sang <wsa@the-dreams.de>
> Cc: linux-renesas-soc@vger.kernel.org
Acked-by: Simon Horman <horms+renesas@verge.net.au>
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH v4 3/6] PCI: rcar: Teardown MSI setup if rcar_pcie_enable() fails
2018-05-24 14:36 ` [PATCH v4 3/6] PCI: rcar: Teardown MSI setup if rcar_pcie_enable() fails Marek Vasut
@ 2018-05-28 8:52 ` Simon Horman
0 siblings, 0 replies; 24+ messages in thread
From: Simon Horman @ 2018-05-28 8:52 UTC (permalink / raw)
To: Marek Vasut
Cc: linux-pci, Marek Vasut, Geert Uytterhoeven, Lorenzo Pieralisi,
Phil Edworthy, Wolfram Sang, linux-renesas-soc
On Thu, May 24, 2018 at 04:36:21PM +0200, Marek Vasut wrote:
> 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.
>
> Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
> Cc: Geert Uytterhoeven <geert+renesas@glider.be>
> Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
> Cc: Phil Edworthy <phil.edworthy@renesas.com>
> Cc: Simon Horman <horms+renesas@verge.net.au>
> Cc: Wolfram Sang <wsa@the-dreams.de>
> Cc: linux-renesas-soc@vger.kernel.org
Reviewed-by: Simon Horman <horms+renesas@verge.net.au>
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH v4 4/6] PCI: rcar: Poll more often in rcar_pcie_wait_for_dl()
2018-05-24 14:36 ` [PATCH v4 4/6] PCI: rcar: Poll more often in rcar_pcie_wait_for_dl() Marek Vasut
@ 2018-05-28 8:53 ` Simon Horman
0 siblings, 0 replies; 24+ messages in thread
From: Simon Horman @ 2018-05-28 8:53 UTC (permalink / raw)
To: Marek Vasut
Cc: linux-pci, Marek Vasut, Geert Uytterhoeven, Lorenzo Pieralisi,
Phil Edworthy, Wolfram Sang, linux-renesas-soc
On Thu, May 24, 2018 at 04:36:22PM +0200, Marek Vasut wrote:
> The data link active signal usually takes ~20 uSec to be asserted,
> poll the bit more often to avoid useless delays in this function.
> Use udelay() instead of usleep() for such a small delay as suggested
> by the timer documentation and because this will be used in atomic
> context later on when the suspend/resume patches land.
>
> Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
> Cc: Geert Uytterhoeven <geert+renesas@glider.be>
> Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
> Cc: Phil Edworthy <phil.edworthy@renesas.com>
> Cc: Simon Horman <horms+renesas@verge.net.au>
> Cc: Wolfram Sang <wsa@the-dreams.de>
> Cc: linux-renesas-soc@vger.kernel.org
Acked-by: Simon Horman <horms+renesas@verge.net.au>
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH v4 5/6] PCI: rcar: Remove IRQ mappings in rcar_pcie_enable_msi failpath
2018-05-24 14:36 ` [PATCH v4 5/6] PCI: rcar: Remove IRQ mappings in rcar_pcie_enable_msi failpath Marek Vasut
@ 2018-05-28 8:53 ` Simon Horman
0 siblings, 0 replies; 24+ messages in thread
From: Simon Horman @ 2018-05-28 8:53 UTC (permalink / raw)
To: Marek Vasut
Cc: linux-pci, Marek Vasut, Geert Uytterhoeven, Lorenzo Pieralisi,
Phil Edworthy, Wolfram Sang, linux-renesas-soc
On Thu, May 24, 2018 at 04:36:23PM +0200, Marek Vasut wrote:
> The rcar_pcie_enable_msi() creates IRQ mappings using irq_create_mapping()
> before requesting the IRQs using devm_request_irq(). If devm_request_irq()
> fails for some reason, rcar_pcie_enable_msi() does not remove the mapping.
>
> Pull out the code for disposing IRQ mappings from rcar_pcie_teardown_msi()
> into a separate function and call it from both rcar_pcie_teardown_msi()
> and rcar_pcie_enable_msi() failpath to remove the mappings correctly.
>
> Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
> Reported-by: Geert Uytterhoeven <geert+renesas@glider.be>
> Cc: Geert Uytterhoeven <geert+renesas@glider.be>
> Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
> Cc: Phil Edworthy <phil.edworthy@renesas.com>
> Cc: Simon Horman <horms+renesas@verge.net.au>
> Cc: Wolfram Sang <wsa@the-dreams.de>
> Cc: linux-renesas-soc@vger.kernel.org
Acked-by: Simon Horman <horms+renesas@verge.net.au>
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH v4 0/6] PCI: rcar: Failpath fixes
2018-05-25 16:43 ` Lorenzo Pieralisi
2018-05-25 17:10 ` Marek Vasut
@ 2018-05-28 8:54 ` Simon Horman
1 sibling, 0 replies; 24+ messages in thread
From: Simon Horman @ 2018-05-28 8:54 UTC (permalink / raw)
To: Lorenzo Pieralisi
Cc: Marek Vasut, linux-pci, Marek Vasut, Geert Uytterhoeven,
Phil Edworthy, Wolfram Sang, linux-renesas-soc
On Fri, May 25, 2018 at 05:43:13PM +0100, Lorenzo Pieralisi wrote:
> On Thu, May 24, 2018 at 04:36:18PM +0200, Marek Vasut wrote:
> > Multiple minor failpath fixes for the R-Car PCIe driver.
> >
> > V4: Sync up the version numbers
> > Rebase on top of Lorenzo's tree
> > Add new patch fixing bug in the PHY code
> >
> > Marek Vasut (6):
> > PCI: rcar: Pull bus clock enable/disable from
> > rcar_pcie_get_resources()
> > PCI: rcar: Add missing irq_dispose_mapping() into failpath
> > PCI: rcar: Teardown MSI setup if rcar_pcie_enable() fails
> > PCI: rcar: Poll more often in rcar_pcie_wait_for_dl()
> > PCI: rcar: Remove IRQ mappings in rcar_pcie_enable_msi failpath
> > PCI: rcar: Shut the PHY down in failpath
> >
> > drivers/pci/host/pcie-rcar.c | 82 +++++++++++++++++++++++++++++++++++---------
> > 1 file changed, 66 insertions(+), 16 deletions(-)
>
> Marek,
>
> I have applied patches [1-5] to pci/rcar for v4.18, I could not
> apply patch 6 since it is missing Simon's ACK (please have a look
> at what I queued to check it is OK).
Sorry for the delay. You should have that now.
If not, for the entire series:
Acked-by: Simon Horman <horms+renesas@verge.net.au>
>
> Bjorn will be merging the branch into -next shortly, I do not know if
> there is room for adding additional patches on top of it, as I mentioned
> on linux-pci I will be offline for two weeks so it is possible that
> what's in pci/rcar at present will be what gets into v4.18, apologies,
> that's all I can do.
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH v4 6/6] PCI: rcar: Shut the PHY down in failpath
2018-05-28 8:48 ` Simon Horman
@ 2018-06-01 23:30 ` Marek Vasut
0 siblings, 0 replies; 24+ messages in thread
From: Marek Vasut @ 2018-06-01 23:30 UTC (permalink / raw)
To: Simon Horman
Cc: linux-pci, Marek Vasut, Geert Uytterhoeven, Lorenzo Pieralisi,
Phil Edworthy, Wolfram Sang, linux-renesas-soc, Bjorn Helgaas
On 05/28/2018 10:48 AM, Simon Horman wrote:
> On Thu, May 24, 2018 at 04:36:24PM +0200, Marek Vasut wrote:
>> If anything fails past phy_init_fn() and the system is a Gen3 with
>> a PHY, the PHY will be left on and inited. This is caused by the
>> phy_init_fn, which is in fact a pointer to rcar_pcie_phy_init_gen3()
>> function, which starts the PHY, yet has no counterpart in the failpath.
>> Add that counterpart.
>>
>> Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
>> Cc: Geert Uytterhoeven <geert+renesas@glider.be>
>> Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
>> Cc: Phil Edworthy <phil.edworthy@renesas.com>
>> Cc: Simon Horman <horms+renesas@verge.net.au>
>> Cc: Wolfram Sang <wsa@the-dreams.de>
>> Cc: linux-renesas-soc@vger.kernel.org
>> Fixes: 517ca93a7159 ("PCI: rcar: Add R-Car gen3 PHY support")
>
> Acked-by: Simon Horman <horms+renesas@verge.net.au>
While I see the first 5 in today's next, I don't see this one there, so
it'd be nice to add it too.
--
Best regards,
Marek Vasut
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH v4 6/6] PCI: rcar: Shut the PHY down in failpath
2018-05-24 14:36 ` [PATCH v4 6/6] PCI: rcar: Shut the PHY down in failpath Marek Vasut
2018-05-25 10:09 ` Geert Uytterhoeven
2018-05-28 8:48 ` Simon Horman
@ 2018-06-29 13:38 ` Lorenzo Pieralisi
2 siblings, 0 replies; 24+ messages in thread
From: Lorenzo Pieralisi @ 2018-06-29 13:38 UTC (permalink / raw)
To: Marek Vasut
Cc: linux-pci, Marek Vasut, Geert Uytterhoeven, Phil Edworthy,
Simon Horman, Wolfram Sang, linux-renesas-soc
On Thu, May 24, 2018 at 04:36:24PM +0200, Marek Vasut wrote:
> If anything fails past phy_init_fn() and the system is a Gen3 with
> a PHY, the PHY will be left on and inited. This is caused by the
> phy_init_fn, which is in fact a pointer to rcar_pcie_phy_init_gen3()
> function, which starts the PHY, yet has no counterpart in the failpath.
> Add that counterpart.
>
> Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
> Cc: Geert Uytterhoeven <geert+renesas@glider.be>
> Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
> Cc: Phil Edworthy <phil.edworthy@renesas.com>
> Cc: Simon Horman <horms+renesas@verge.net.au>
> Cc: Wolfram Sang <wsa@the-dreams.de>
> Cc: linux-renesas-soc@vger.kernel.org
> Fixes: 517ca93a7159 ("PCI: rcar: Add R-Car gen3 PHY support")
> ---
> V4: New patch
> ---
> drivers/pci/host/pcie-rcar.c | 10 ++++++++--
> 1 file changed, 8 insertions(+), 2 deletions(-)
Applied to pci/controller-fixes to be tentatively merged at -rc4,
thanks.
Lorenzo
> diff --git a/drivers/pci/host/pcie-rcar.c b/drivers/pci/host/pcie-rcar.c
> index 636c3c5095d2..695781934f0a 100644
> --- a/drivers/pci/host/pcie-rcar.c
> +++ b/drivers/pci/host/pcie-rcar.c
> @@ -1163,7 +1163,7 @@ static int rcar_pcie_probe(struct platform_device *pdev)
> if (rcar_pcie_hw_init(pcie)) {
> dev_info(dev, "PCIe link down\n");
> err = -ENODEV;
> - goto err_clk_disable;
> + goto err_phy_shutdown;
> }
>
> data = rcar_pci_read_reg(pcie, MACSR);
> @@ -1175,7 +1175,7 @@ static int rcar_pcie_probe(struct platform_device *pdev)
> dev_err(dev,
> "failed to enable MSI support: %d\n",
> err);
> - goto err_clk_disable;
> + goto err_phy_shutdown;
> }
> }
>
> @@ -1189,6 +1189,12 @@ static int rcar_pcie_probe(struct platform_device *pdev)
> if (IS_ENABLED(CONFIG_PCI_MSI))
> rcar_pcie_teardown_msi(pcie);
>
> +err_phy_shutdown:
> + if (pcie->phy) {
> + phy_power_off(pcie->phy);
> + phy_exit(pcie->phy);
> + }
> +
> err_clk_disable:
> clk_disable_unprepare(pcie->bus_clk);
>
> --
> 2.16.2
>
^ permalink raw reply [flat|nested] 24+ messages in thread
end of thread, other threads:[~2018-06-29 13:36 UTC | newest]
Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-24 14:36 [PATCH v4 0/6] PCI: rcar: Failpath fixes Marek Vasut
2018-05-24 14:36 ` [PATCH v4 1/6] PCI: rcar: Pull bus clock enable/disable from rcar_pcie_get_resources() Marek Vasut
2018-05-28 8:51 ` Simon Horman
2018-05-24 14:36 ` [PATCH v4 2/6] PCI: rcar: Add missing irq_dispose_mapping() into failpath Marek Vasut
2018-05-28 8:51 ` Simon Horman
2018-05-24 14:36 ` [PATCH v4 3/6] PCI: rcar: Teardown MSI setup if rcar_pcie_enable() fails Marek Vasut
2018-05-28 8:52 ` Simon Horman
2018-05-24 14:36 ` [PATCH v4 4/6] PCI: rcar: Poll more often in rcar_pcie_wait_for_dl() Marek Vasut
2018-05-28 8:53 ` Simon Horman
2018-05-24 14:36 ` [PATCH v4 5/6] PCI: rcar: Remove IRQ mappings in rcar_pcie_enable_msi failpath Marek Vasut
2018-05-28 8:53 ` Simon Horman
2018-05-24 14:36 ` [PATCH v4 6/6] PCI: rcar: Shut the PHY down in failpath Marek Vasut
2018-05-25 10:09 ` Geert Uytterhoeven
2018-05-25 18:34 ` Marek Vasut
2018-05-28 8:48 ` Simon Horman
2018-06-01 23:30 ` Marek Vasut
2018-06-29 13:38 ` Lorenzo Pieralisi
2018-05-25 9:35 ` [PATCH v4 0/6] PCI: rcar: Failpath fixes Lorenzo Pieralisi
2018-05-25 9:39 ` Geert Uytterhoeven
2018-05-25 9:56 ` Lorenzo Pieralisi
2018-05-25 10:01 ` Geert Uytterhoeven
2018-05-25 16:43 ` Lorenzo Pieralisi
2018-05-25 17:10 ` Marek Vasut
2018-05-28 8:54 ` Simon Horman
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.