[PATCH v2] PCI: rzg3s-host: Treat link-down as -ENODEV instead of error

John Madieu posted 1 patch 2 months, 1 week ago
drivers/pci/controller/pcie-rzg3s-host.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
[PATCH v2] PCI: rzg3s-host: Treat link-down as -ENODEV instead of error
Posted by John Madieu 2 months, 1 week ago
rzg3s_pcie_host_init() failing to establish a PCIe link does not
necessarily indicate a hardware or driver error; it may simply mean no
card is inserted. Demote the message from dev_err_probe() to dev_info()
and return -ENODEV so the driver defers gracefully rather than printing
a spurious error.

Signed-off-by: John Madieu <john.madieu.xa@bp.renesas.com>
---

Changes in v2:
 - Dropped Rb tag from Geert as patch structure changed
 - Moved link-down handling into rzg3s_pcie_host_init() instead of
   masking all errors in rzg3s_pcie_host_setup() (Claudiu)
 - Kept dev_err_probe() for real init failures, only suppress for
   -ENODEV (link down)

v1:
  - https://lore.kernel.org/all/20260401143347.8463-1-john.madieu.xa@bp.renesas.com/

 drivers/pci/controller/pcie-rzg3s-host.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/pci/controller/pcie-rzg3s-host.c b/drivers/pci/controller/pcie-rzg3s-host.c
index d86e7516dcc2..0acc21981ee9 100644
--- a/drivers/pci/controller/pcie-rzg3s-host.c
+++ b/drivers/pci/controller/pcie-rzg3s-host.c
@@ -1384,8 +1384,11 @@ static int rzg3s_pcie_host_init(struct rzg3s_pcie_host *host)
 				 PCIE_LINK_WAIT_SLEEP_MS * MILLI,
 				 PCIE_LINK_WAIT_SLEEP_MS * MILLI *
 				 PCIE_LINK_WAIT_MAX_RETRIES);
-	if (ret)
+	if (ret) {
+		dev_info(host->dev, "PCIe link down!\n");
+		ret = -ENODEV;
 		goto config_deinit_post;
+	}
 
 	val = readl_relaxed(host->axi + RZG3S_PCI_PCSTAT2);
 	dev_info(host->dev, "PCIe link status [0x%x]\n", val);
@@ -1655,7 +1658,9 @@ rzg3s_pcie_host_setup(struct rzg3s_pcie_host *host,
 
 	ret = rzg3s_pcie_host_init(host);
 	if (ret) {
-		dev_err_probe(dev, ret, "Failed to initialize the HW!\n");
+		if (ret != -ENODEV)
+			dev_err_probe(dev, ret, "Failed to initialize the HW!\n");
+
 		goto teardown_irqdomain;
 	}
 
-- 
2.25.1
Re: [PATCH v2] PCI: rzg3s-host: Treat link-down as -ENODEV instead of error
Posted by Manivannan Sadhasivam 2 months, 1 week ago
On Thu, Apr 02, 2026 at 08:23:53PM +0200, John Madieu wrote:
> rzg3s_pcie_host_init() failing to establish a PCIe link does not
> necessarily indicate a hardware or driver error; it may simply mean no
> card is inserted. Demote the message from dev_err_probe() to dev_info()
> and return -ENODEV so the driver defers gracefully rather than printing
> a spurious error.
> 
> Signed-off-by: John Madieu <john.madieu.xa@bp.renesas.com>
> ---
> 
> Changes in v2:
>  - Dropped Rb tag from Geert as patch structure changed
>  - Moved link-down handling into rzg3s_pcie_host_init() instead of
>    masking all errors in rzg3s_pcie_host_setup() (Claudiu)
>  - Kept dev_err_probe() for real init failures, only suppress for
>    -ENODEV (link down)
> 
> v1:
>   - https://lore.kernel.org/all/20260401143347.8463-1-john.madieu.xa@bp.renesas.com/
> 
>  drivers/pci/controller/pcie-rzg3s-host.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/pci/controller/pcie-rzg3s-host.c b/drivers/pci/controller/pcie-rzg3s-host.c
> index d86e7516dcc2..0acc21981ee9 100644
> --- a/drivers/pci/controller/pcie-rzg3s-host.c
> +++ b/drivers/pci/controller/pcie-rzg3s-host.c
> @@ -1384,8 +1384,11 @@ static int rzg3s_pcie_host_init(struct rzg3s_pcie_host *host)
>  				 PCIE_LINK_WAIT_SLEEP_MS * MILLI,
>  				 PCIE_LINK_WAIT_SLEEP_MS * MILLI *
>  				 PCIE_LINK_WAIT_MAX_RETRIES);
> -	if (ret)
> +	if (ret) {
> +		dev_info(host->dev, "PCIe link down!\n");
> +		ret = -ENODEV;
>  		goto config_deinit_post;
> +	}
>  
>  	val = readl_relaxed(host->axi + RZG3S_PCI_PCSTAT2);
>  	dev_info(host->dev, "PCIe link status [0x%x]\n", val);
> @@ -1655,7 +1658,9 @@ rzg3s_pcie_host_setup(struct rzg3s_pcie_host *host,
>  
>  	ret = rzg3s_pcie_host_init(host);
>  	if (ret) {
> -		dev_err_probe(dev, ret, "Failed to initialize the HW!\n");
> +		if (ret != -ENODEV)
> +			dev_err_probe(dev, ret, "Failed to initialize the HW!\n");

Well, probe() should not fail in the case of LDn unless the controller doesn't
support hotplug.

- Mani

-- 
மணிவண்ணன் சதாசிவம்