All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] pci: ftpci100: Make clocks compulsory
@ 2017-06-21  8:57 Linus Walleij
  2017-06-27 21:43 ` Bjorn Helgaas
  0 siblings, 1 reply; 2+ messages in thread
From: Linus Walleij @ 2017-06-21  8:57 UTC (permalink / raw)
  To: Bjorn Helgaas, linux-pci; +Cc: Hans Ulli Kroll, Florian Fainelli, Linus Walleij

This fixes a regression on the FTPCI100 PCI driver.

When the clock controller was augmented to probe clocks
from the platform device except to the most basic clocks
pertaining to timers, clocks may return an error pointer
containing -EPROBE_DEFER.

This hit the PCI driver which would try to continue
without the clocks, but the actual clocks appeared later,
so we did not pick them up properly, and in the end of
the boot, these clocks get gated off if no users register,
so the PCI host became numbed off and silently nonworking.

The clocks for this PCI bus are defined properly for all
platforms implementing it, so we should make them compulsory
before new users arrive so we have our resources under
control.

This makes the driver bail out of probe with any error
code from the clock, including -EPROBE_DEFER so that we
again have a clean boot.

Fixes: cea186ac1e45 ("pci: ftpci100: Add clock handling")
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
ChangeLog v1->v2:
- Inadvertedly managed to switch PTR_ERR() for ERR_PTR()
  in the code, and the compile screamed.
---
 drivers/pci/host/pci-ftpci100.c | 28 ++++++++++++----------------
 1 file changed, 12 insertions(+), 16 deletions(-)

diff --git a/drivers/pci/host/pci-ftpci100.c b/drivers/pci/host/pci-ftpci100.c
index d3bf153a2ab2..db31ab21884e 100644
--- a/drivers/pci/host/pci-ftpci100.c
+++ b/drivers/pci/host/pci-ftpci100.c
@@ -463,24 +463,20 @@ static int faraday_pci_probe(struct platform_device *pdev)
 
 	/* Retrieve and enable optional clocks */
 	clk = devm_clk_get(dev, "PCLK");
-	if (IS_ERR(clk)) {
-		dev_err(dev, "no PCLK available\n");
-	} else {
-		ret = clk_prepare_enable(clk);
-		if (ret) {
-			dev_err(dev, "could not prepare PCLK\n");
-			return ret;
-		}
+	if (IS_ERR(clk))
+		return PTR_ERR(clk);
+	ret = clk_prepare_enable(clk);
+	if (ret) {
+		dev_err(dev, "could not prepare PCLK\n");
+		return ret;
 	}
 	p->bus_clk = devm_clk_get(dev, "PCICLK");
-	if (IS_ERR(p->bus_clk)) {
-		dev_err(dev, "no PCICLK available\n");
-	} else {
-		ret = clk_prepare_enable(p->bus_clk);
-		if (ret) {
-			dev_err(dev, "could not prepare PCICLK\n");
-			return ret;
-		}
+	if (IS_ERR(p->bus_clk))
+		return PTR_ERR(clk);
+	ret = clk_prepare_enable(p->bus_clk);
+	if (ret) {
+		dev_err(dev, "could not prepare PCICLK\n");
+		return ret;
 	}
 
 	regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-- 
2.9.4

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] pci: ftpci100: Make clocks compulsory
  2017-06-21  8:57 [PATCH v2] pci: ftpci100: Make clocks compulsory Linus Walleij
@ 2017-06-27 21:43 ` Bjorn Helgaas
  0 siblings, 0 replies; 2+ messages in thread
From: Bjorn Helgaas @ 2017-06-27 21:43 UTC (permalink / raw)
  To: Linus Walleij; +Cc: Bjorn Helgaas, linux-pci, Hans Ulli Kroll, Florian Fainelli

On Wed, Jun 21, 2017 at 10:57:30AM +0200, Linus Walleij wrote:
> This fixes a regression on the FTPCI100 PCI driver.
> 
> When the clock controller was augmented to probe clocks
> from the platform device except to the most basic clocks
> pertaining to timers, clocks may return an error pointer
> containing -EPROBE_DEFER.
> 
> This hit the PCI driver which would try to continue
> without the clocks, but the actual clocks appeared later,
> so we did not pick them up properly, and in the end of
> the boot, these clocks get gated off if no users register,
> so the PCI host became numbed off and silently nonworking.
> 
> The clocks for this PCI bus are defined properly for all
> platforms implementing it, so we should make them compulsory
> before new users arrive so we have our resources under
> control.
> 
> This makes the driver bail out of probe with any error
> code from the clock, including -EPROBE_DEFER so that we
> again have a clean boot.
> 
> Fixes: cea186ac1e45 ("pci: ftpci100: Add clock handling")
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

I folded this into the "pci: ftpci100: Add clock handling" commit,
thanks!

> ---
> ChangeLog v1->v2:
> - Inadvertedly managed to switch PTR_ERR() for ERR_PTR()
>   in the code, and the compile screamed.
> ---
>  drivers/pci/host/pci-ftpci100.c | 28 ++++++++++++----------------
>  1 file changed, 12 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/pci/host/pci-ftpci100.c b/drivers/pci/host/pci-ftpci100.c
> index d3bf153a2ab2..db31ab21884e 100644
> --- a/drivers/pci/host/pci-ftpci100.c
> +++ b/drivers/pci/host/pci-ftpci100.c
> @@ -463,24 +463,20 @@ static int faraday_pci_probe(struct platform_device *pdev)
>  
>  	/* Retrieve and enable optional clocks */
>  	clk = devm_clk_get(dev, "PCLK");
> -	if (IS_ERR(clk)) {
> -		dev_err(dev, "no PCLK available\n");
> -	} else {
> -		ret = clk_prepare_enable(clk);
> -		if (ret) {
> -			dev_err(dev, "could not prepare PCLK\n");
> -			return ret;
> -		}
> +	if (IS_ERR(clk))
> +		return PTR_ERR(clk);
> +	ret = clk_prepare_enable(clk);
> +	if (ret) {
> +		dev_err(dev, "could not prepare PCLK\n");
> +		return ret;
>  	}
>  	p->bus_clk = devm_clk_get(dev, "PCICLK");
> -	if (IS_ERR(p->bus_clk)) {
> -		dev_err(dev, "no PCICLK available\n");
> -	} else {
> -		ret = clk_prepare_enable(p->bus_clk);
> -		if (ret) {
> -			dev_err(dev, "could not prepare PCICLK\n");
> -			return ret;
> -		}
> +	if (IS_ERR(p->bus_clk))
> +		return PTR_ERR(clk);
> +	ret = clk_prepare_enable(p->bus_clk);
> +	if (ret) {
> +		dev_err(dev, "could not prepare PCICLK\n");
> +		return ret;
>  	}
>  
>  	regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> -- 
> 2.9.4
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-06-27 21:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-21  8:57 [PATCH v2] pci: ftpci100: Make clocks compulsory Linus Walleij
2017-06-27 21:43 ` Bjorn Helgaas

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.