Linux PCI subsystem development
 help / color / mirror / Atom feed
* [PATCH v1] PCI: xgene: Use managed clock for PCIe controller
@ 2026-08-02 22:11 Yuho Choi
  2026-08-02 22:19 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: Yuho Choi @ 2026-08-02 22:11 UTC (permalink / raw)
  To: toan, lpieralisi, kwilczynski, mani, bhelgaas
  Cc: robh, linux-pci, linux-arm-kernel, linux-kernel, Yuho Choi

xgene_pcie_init_port() obtains and enables the controller clock manually.
When xgene_pcie_setup() or pci_host_probe() fails, probe returns without
disabling, unpreparing, or releasing the clock. A failed enable also leaves
the clk_get() reference unreleased.

Use devm_clk_get_enabled() so the clock is unwound automatically on probe
failure and device removal.

Fixes: 5f6b6ccdbe1c ("PCI: xgene: Add APM X-Gene PCIe driver")
Signed-off-by: Yuho Choi <dbgh9129@gmail.com>
---
 drivers/pci/controller/pci-xgene.c | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/drivers/pci/controller/pci-xgene.c b/drivers/pci/controller/pci-xgene.c
index b95afa35201d..4fe3581b9372 100644
--- a/drivers/pci/controller/pci-xgene.c
+++ b/drivers/pci/controller/pci-xgene.c
@@ -321,18 +321,11 @@ static void xgene_pcie_linkup(struct xgene_pcie *port,
 static int xgene_pcie_init_port(struct xgene_pcie *port)
 {
 	struct device *dev = port->dev;
-	int rc;
 
-	port->clk = clk_get(dev, NULL);
+	port->clk = devm_clk_get_enabled(dev, NULL);
 	if (IS_ERR(port->clk)) {
 		dev_err(dev, "clock not available\n");
-		return -ENODEV;
-	}
-
-	rc = clk_prepare_enable(port->clk);
-	if (rc) {
-		dev_err(dev, "clock enable failed\n");
-		return rc;
+		return PTR_ERR(port->clk);
 	}
 
 	return 0;
-- 
2.43.0


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

* Re: [PATCH v1] PCI: xgene: Use managed clock for PCIe controller
  2026-08-02 22:11 [PATCH v1] PCI: xgene: Use managed clock for PCIe controller Yuho Choi
@ 2026-08-02 22:19 ` sashiko-bot
  0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-08-02 22:19 UTC (permalink / raw)
  To: Yuho Choi; +Cc: linux-pci

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Spurious error messages logged when `devm_clk_get_enabled()` returns `-EPROBE_DEFER`.
--

--- Patch [1]: [PATCH v1] PCI: xgene: Use managed clock for PCIe controller ---
commit 0cead2017a15cf2ef3dd587c853cc1410cad1d70
Author: Yuho Choi <dbgh9129@gmail.com>

PCI: xgene: Use managed clock for PCIe controller

This commit simplifies the xgene PCIe port initialization by replacing
manual clock retrieval and enablement with devm_clk_get_enabled(). This
automatically handles unwinding the clock on probe failure and device removal.

> diff --git a/drivers/pci/controller/pci-xgene.c b/drivers/pci/controller/pci-xgene.c
> --- a/drivers/pci/controller/pci-xgene.c
> +++ b/drivers/pci/controller/pci-xgene.c
> @@ -321,18 +321,11 @@ static void xgene_pcie_linkup(struct xgene_pcie *port,
>  static int xgene_pcie_init_port(struct xgene_pcie *port)
>  {
>  	struct device *dev = port->dev;
> -	int rc;
>  
> -	port->clk = clk_get(dev, NULL);
> +	port->clk = devm_clk_get_enabled(dev, NULL);
>  	if (IS_ERR(port->clk)) {
>  		dev_err(dev, "clock not available\n");
> -		return -ENODEV;
> -	}
> -
> -	rc = clk_prepare_enable(port->clk);
> -	if (rc) {
> -		dev_err(dev, "clock enable failed\n");
> -		return rc;
> +		return PTR_ERR(port->clk);

[Severity: Medium]
Does this unconditional dev_err() cause log spam during boot if
devm_clk_get_enabled() returns -EPROBE_DEFER?

Could dev_err_probe() be used here instead?

>  	}
>  
>  	return 0;

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260802221146.573233-1-dbgh9129@gmail.com?part=1

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

end of thread, other threads:[~2026-08-02 22:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-02 22:11 [PATCH v1] PCI: xgene: Use managed clock for PCIe controller Yuho Choi
2026-08-02 22:19 ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox