linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] PCI: kirin: Return -EPROBE_DEFER in case the gpio isn't ready
@ 2020-09-18 12:38 Bean Huo
  2020-09-21 11:22 ` Lorenzo Pieralisi
  0 siblings, 1 reply; 5+ messages in thread
From: Bean Huo @ 2020-09-18 12:38 UTC (permalink / raw)
  To: songxiaowei, wangbinghui, lorenzo.pieralisi, bhelgaas, linux-pci,
	linux-kernel, beanhuo

From: Bean Huo <beanhuo@micron.com>

PCI driver might be probed before the gpiochip, so, of_get_named_gpio()
can return -EPROBE_DEFER. And let kirin_pcie_probe() directly return
-ENODEV, which will result in the PCIe probe failure and the PCIe
will not be probed again after the gpiochip driver is loaded.

Fix the above issue by letting kirin_pcie_probe() return -EPROBE_DEFER in
such a case.

Fixes: 6e0832fa432e ("PCI: Collect all native drivers under drivers/pci/controller")
Signed-off-by: Bean Huo <beanhuo@micron.com>
---
 drivers/pci/controller/dwc/pcie-kirin.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/pci/controller/dwc/pcie-kirin.c b/drivers/pci/controller/dwc/pcie-kirin.c
index e496f51e0152..74b88d158072 100644
--- a/drivers/pci/controller/dwc/pcie-kirin.c
+++ b/drivers/pci/controller/dwc/pcie-kirin.c
@@ -507,8 +507,12 @@ static int kirin_pcie_probe(struct platform_device *pdev)
 
 	kirin_pcie->gpio_id_reset = of_get_named_gpio(dev->of_node,
 						      "reset-gpios", 0);
-	if (kirin_pcie->gpio_id_reset < 0)
+	if (kirin_pcie->gpio_id_reset == -EPROBE_DEFER) {
+		return -EPROBE_DEFER;
+	} else if (!gpio_is_valid(kirin_pcie->gpio_id_reset)) {
+		dev_err(dev, "unable to get a valid gpio pin\n");
 		return -ENODEV;
+	}
 
 	ret = kirin_pcie_power_on(kirin_pcie);
 	if (ret)
-- 
2.17.1


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

* Re: [PATCH] PCI: kirin: Return -EPROBE_DEFER in case the gpio isn't ready
  2020-09-18 12:38 [PATCH] PCI: kirin: Return -EPROBE_DEFER in case the gpio isn't ready Bean Huo
@ 2020-09-21 11:22 ` Lorenzo Pieralisi
  2020-09-21 11:28   ` Bean Huo
  0 siblings, 1 reply; 5+ messages in thread
From: Lorenzo Pieralisi @ 2020-09-21 11:22 UTC (permalink / raw)
  To: Bean Huo
  Cc: songxiaowei, wangbinghui, bhelgaas, linux-pci, linux-kernel, beanhuo

On Fri, Sep 18, 2020 at 02:38:00PM +0200, Bean Huo wrote:
> From: Bean Huo <beanhuo@micron.com>
> 
> PCI driver might be probed before the gpiochip, so, of_get_named_gpio()
> can return -EPROBE_DEFER. And let kirin_pcie_probe() directly return
> -ENODEV, which will result in the PCIe probe failure and the PCIe
> will not be probed again after the gpiochip driver is loaded.
> 
> Fix the above issue by letting kirin_pcie_probe() return -EPROBE_DEFER in
> such a case.
> 
> Fixes: 6e0832fa432e ("PCI: Collect all native drivers under drivers/pci/controller")

This is certainly not the commit that triggered the issue so I would
remove it. Kirin maintainers are CC'ed, waiting for their ACK.

Lorenzo

> Signed-off-by: Bean Huo <beanhuo@micron.com>
> ---
>  drivers/pci/controller/dwc/pcie-kirin.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/pci/controller/dwc/pcie-kirin.c b/drivers/pci/controller/dwc/pcie-kirin.c
> index e496f51e0152..74b88d158072 100644
> --- a/drivers/pci/controller/dwc/pcie-kirin.c
> +++ b/drivers/pci/controller/dwc/pcie-kirin.c
> @@ -507,8 +507,12 @@ static int kirin_pcie_probe(struct platform_device *pdev)
>  
>  	kirin_pcie->gpio_id_reset = of_get_named_gpio(dev->of_node,
>  						      "reset-gpios", 0);
> -	if (kirin_pcie->gpio_id_reset < 0)
> +	if (kirin_pcie->gpio_id_reset == -EPROBE_DEFER) {
> +		return -EPROBE_DEFER;
> +	} else if (!gpio_is_valid(kirin_pcie->gpio_id_reset)) {
> +		dev_err(dev, "unable to get a valid gpio pin\n");
>  		return -ENODEV;
> +	}
>  
>  	ret = kirin_pcie_power_on(kirin_pcie);
>  	if (ret)
> -- 
> 2.17.1
> 

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

* Re: [PATCH] PCI: kirin: Return -EPROBE_DEFER in case the gpio isn't ready
  2020-09-21 11:22 ` Lorenzo Pieralisi
@ 2020-09-21 11:28   ` Bean Huo
  2020-09-26  7:49     ` Bean Huo
  0 siblings, 1 reply; 5+ messages in thread
From: Bean Huo @ 2020-09-21 11:28 UTC (permalink / raw)
  To: Lorenzo Pieralisi
  Cc: songxiaowei, wangbinghui, bhelgaas, linux-pci, linux-kernel, beanhuo

On Mon, 2020-09-21 at 12:22 +0100, Lorenzo Pieralisi wrote:
> > Fix the above issue by letting kirin_pcie_probe() return
> > -EPROBE_DEFER in
> > such a case.
> > 
> > Fixes: 6e0832fa432e ("PCI: Collect all native drivers under
> > drivers/pci/controller")
> 
> This is certainly not the commit that triggered the issue so I would
> remove it. Kirin maintainers are CC'ed, waiting for their ACK.
> 
> Lorenzo

Hi Lorenzo

Thanks very much for your reply. It is true this is a bug which was
introduced by the origin commit. It is ok  for me to remove this fix
tag.

Thanks, 
Bean


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

* Re: [PATCH] PCI: kirin: Return -EPROBE_DEFER in case the gpio isn't ready
  2020-09-21 11:28   ` Bean Huo
@ 2020-09-26  7:49     ` Bean Huo
  2020-09-28 17:05       ` Lorenzo Pieralisi
  0 siblings, 1 reply; 5+ messages in thread
From: Bean Huo @ 2020-09-26  7:49 UTC (permalink / raw)
  To: Lorenzo Pieralisi, songxiaowei, wangbinghui
  Cc: songxiaowei, wangbinghui, bhelgaas, linux-pci, linux-kernel, beanhuo

seems the Hisilicon PCI driver maintainers are absent, however, we are
still using their old platform based on Kirin.

hi, Lorenzo
is it possible to take this patch without Hisilicon maintainter's ACK?

Thanks,
Bean


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

* Re: [PATCH] PCI: kirin: Return -EPROBE_DEFER in case the gpio isn't ready
  2020-09-26  7:49     ` Bean Huo
@ 2020-09-28 17:05       ` Lorenzo Pieralisi
  0 siblings, 0 replies; 5+ messages in thread
From: Lorenzo Pieralisi @ 2020-09-28 17:05 UTC (permalink / raw)
  To: Bean Huo
  Cc: songxiaowei, wangbinghui, bhelgaas, linux-pci, linux-kernel, beanhuo

On Sat, Sep 26, 2020 at 09:49:56AM +0200, Bean Huo wrote:
> seems the Hisilicon PCI driver maintainers are absent, however, we are
> still using their old platform based on Kirin.
> 
> hi, Lorenzo
> is it possible to take this patch without Hisilicon maintainter's ACK?

I applied it to pci/kirin, tentatively for v5.10.

Lorenzo

> Thanks,
> Bean
> 

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

end of thread, other threads:[~2020-09-28 17:05 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-18 12:38 [PATCH] PCI: kirin: Return -EPROBE_DEFER in case the gpio isn't ready Bean Huo
2020-09-21 11:22 ` Lorenzo Pieralisi
2020-09-21 11:28   ` Bean Huo
2020-09-26  7:49     ` Bean Huo
2020-09-28 17:05       ` Lorenzo Pieralisi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).