* [PATCH] PCI: kirin: Fix an error path in kirin_pcie_probe()
@ 2023-10-30 8:21 Christophe JAILLET
2023-10-30 23:32 ` Serge Semin
2023-10-31 8:35 ` Manivannan Sadhasivam
0 siblings, 2 replies; 3+ messages in thread
From: Christophe JAILLET @ 2023-10-30 8:21 UTC (permalink / raw)
To: Xiaowei Song, Binghui Wang, Lorenzo Pieralisi,
Krzysztof Wilczyński, Rob Herring, Bjorn Helgaas, Jingoo Han
Cc: linux-kernel, kernel-janitors, Christophe JAILLET, linux-pci
If an error occurs after a successful kirin_pcie_power_on(),
kirin_pcie_power_off() should be called, as already done in the remove
function.
Fixes: fc5165db245a ("PCI: kirin: Add HiSilicon Kirin SoC PCIe controller driver")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
Not sure of the Fixes tag.
---
drivers/pci/controller/dwc/pcie-kirin.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/drivers/pci/controller/dwc/pcie-kirin.c b/drivers/pci/controller/dwc/pcie-kirin.c
index 2ee146767971..0b93de9d2d06 100644
--- a/drivers/pci/controller/dwc/pcie-kirin.c
+++ b/drivers/pci/controller/dwc/pcie-kirin.c
@@ -813,7 +813,15 @@ static int kirin_pcie_probe(struct platform_device *pdev)
if (ret)
return ret;
- return dw_pcie_host_init(&pci->pp);
+ ret = dw_pcie_host_init(&pci->pp);
+ if (ret)
+ goto err_power_off;
+
+ return 0;
+
+err_power_off:
+ kirin_pcie_power_off(kirin_pcie);
+ return ret;
}
static struct platform_driver kirin_pcie_driver = {
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] PCI: kirin: Fix an error path in kirin_pcie_probe()
2023-10-30 8:21 [PATCH] PCI: kirin: Fix an error path in kirin_pcie_probe() Christophe JAILLET
@ 2023-10-30 23:32 ` Serge Semin
2023-10-31 8:35 ` Manivannan Sadhasivam
1 sibling, 0 replies; 3+ messages in thread
From: Serge Semin @ 2023-10-30 23:32 UTC (permalink / raw)
To: Christophe JAILLET
Cc: Xiaowei Song, Binghui Wang, Lorenzo Pieralisi,
Krzysztof Wilczyński, Rob Herring, Bjorn Helgaas, Jingoo Han,
linux-kernel, kernel-janitors, linux-pci
On Mon, Oct 30, 2023 at 09:21:16AM +0100, Christophe JAILLET wrote:
> If an error occurs after a successful kirin_pcie_power_on(),
> kirin_pcie_power_off() should be called, as already done in the remove
> function.
>
> Fixes: fc5165db245a ("PCI: kirin: Add HiSilicon Kirin SoC PCIe controller driver")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> Not sure of the Fixes tag.
> ---
> drivers/pci/controller/dwc/pcie-kirin.c | 10 +++++++++-
> 1 file changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/pci/controller/dwc/pcie-kirin.c b/drivers/pci/controller/dwc/pcie-kirin.c
> index 2ee146767971..0b93de9d2d06 100644
> --- a/drivers/pci/controller/dwc/pcie-kirin.c
> +++ b/drivers/pci/controller/dwc/pcie-kirin.c
> @@ -813,7 +813,15 @@ static int kirin_pcie_probe(struct platform_device *pdev)
> if (ret)
> return ret;
>
> - return dw_pcie_host_init(&pci->pp);
> + ret = dw_pcie_host_init(&pci->pp);
> + if (ret)
> + goto err_power_off;
> +
> + return 0;
> +
> +err_power_off:
> + kirin_pcie_power_off(kirin_pcie);
> + return ret;
From the current driver implementation point of view this looks
correct. So
Reviewed-by: Serge Semin <fancer.lancer@gmail.com>
But the design of the power on/off procedures seems very unfortunate:
1. Calling antagonist from the respective protagonist is a bad
solution for maintainability, because shall you need to add something
to the protagonist you'll need to somehow take into account that it is
reverted in the antagonist only if it was executed, which in its
turn will get to be impossible if there are several conditional
steps need to be implemented.
2. There is a logical split up between the hi3660 and other
controllers. Wherein the hi3660-specific code is implemented as a set
of various coherent functions, meanwhile the code for the other
controllers is placed directly to the kirin_pcie_power_on() and
kirin_pcie_power_off() functions. It looks clumsy and hard-readable.
3. kirin_pcie->gpio_id_dwc_perst is requested and switched to output,
but is never freed and got back to input or level zero.
-Serge(y)
> }
>
> static struct platform_driver kirin_pcie_driver = {
> --
> 2.34.1
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] PCI: kirin: Fix an error path in kirin_pcie_probe()
2023-10-30 8:21 [PATCH] PCI: kirin: Fix an error path in kirin_pcie_probe() Christophe JAILLET
2023-10-30 23:32 ` Serge Semin
@ 2023-10-31 8:35 ` Manivannan Sadhasivam
1 sibling, 0 replies; 3+ messages in thread
From: Manivannan Sadhasivam @ 2023-10-31 8:35 UTC (permalink / raw)
To: Christophe JAILLET
Cc: Xiaowei Song, Binghui Wang, Lorenzo Pieralisi,
Krzysztof Wilczyński, Rob Herring, Bjorn Helgaas, Jingoo Han,
linux-kernel, kernel-janitors, linux-pci
On Mon, Oct 30, 2023 at 09:21:16AM +0100, Christophe JAILLET wrote:
> If an error occurs after a successful kirin_pcie_power_on(),
> kirin_pcie_power_off() should be called, as already done in the remove
> function.
>
PERST# assert (gpio_id_dwc_perst) is missing from kirin_pcie_power_off(). So
first you need to add that in a separate patch and then this patch can come
next.
Also, this driver is using legacy GPIO APIs and needs cleanup too (Kudos if you
are willing to do that).
- Mani
> Fixes: fc5165db245a ("PCI: kirin: Add HiSilicon Kirin SoC PCIe controller driver")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> Not sure of the Fixes tag.
> ---
> drivers/pci/controller/dwc/pcie-kirin.c | 10 +++++++++-
> 1 file changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/pci/controller/dwc/pcie-kirin.c b/drivers/pci/controller/dwc/pcie-kirin.c
> index 2ee146767971..0b93de9d2d06 100644
> --- a/drivers/pci/controller/dwc/pcie-kirin.c
> +++ b/drivers/pci/controller/dwc/pcie-kirin.c
> @@ -813,7 +813,15 @@ static int kirin_pcie_probe(struct platform_device *pdev)
> if (ret)
> return ret;
>
> - return dw_pcie_host_init(&pci->pp);
> + ret = dw_pcie_host_init(&pci->pp);
> + if (ret)
> + goto err_power_off;
> +
> + return 0;
> +
> +err_power_off:
> + kirin_pcie_power_off(kirin_pcie);
> + return ret;
> }
>
> static struct platform_driver kirin_pcie_driver = {
> --
> 2.34.1
>
--
மணிவண்ணன் சதாசிவம்
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-10-31 8:37 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-30 8:21 [PATCH] PCI: kirin: Fix an error path in kirin_pcie_probe() Christophe JAILLET
2023-10-30 23:32 ` Serge Semin
2023-10-31 8:35 ` Manivannan Sadhasivam
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox