mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/3] PCI: rzg3s: Fix issues in cleanup paths
@ 2026-07-15 22:30 Prabhakar
  2026-07-15 22:30 ` [PATCH 1/3] PCI: rzg3s: Disable refclk on probe failure Prabhakar
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Prabhakar @ 2026-07-15 22:30 UTC (permalink / raw)
  To: Claudiu Beznea, Manivannan Sadhasivam, Krzysztof Wilczyński,
	Lorenzo Pieralisi, Rob Herring, Bjorn Helgaas
  Cc: linux-pci, linux-renesas-soc, linux-kernel, Prabhakar, Biju Das,
	Fabrizio Castro, Lad Prabhakar

From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>

Hi all,

This series fixes a few issues in the cleanup paths of the Renesas RZ/G3S
PCIe host controller driver. The fixes include:
- Disabling the PCIe reference clock on probe failure.
- Propagating the original error code from platform_get_irq_byname() to
allow probe deferral.
- Unwinding chained handler registration on error in
rzg3s_pcie_init_irqdomain() and clearing chained handlers in
rzg3s_pcie_teardown_irqdomain() to avoid leaving stale handler and data
pointers attached to the parent interrupts.

Note:
- This patch applies on top of pci-next (commit - 5d9f1dd3b3e7).
- There is a patch [0] inflight for this driver which doesn't apply
  on pci-next. As there is a conflict between the two, the patch [0]
  will be rebased on top of this series and v3 will be sent out for review.

[0] https://lore.kernel.org/all/20260630141720.3938514-1-john.madieu.xa@bp.renesas.com/

Cheers,
Prabhakar

Lad Prabhakar (3):
  PCI: rzg3s: Disable refclk on probe failure
  PCI: rzg3s: Propagate platform_get_irq_byname() errors
  PCI: rzg3s: Fix IRQ domain initialization error handling

 drivers/pci/controller/pcie-rzg3s-host.c | 38 +++++++++++++++++-------
 1 file changed, 28 insertions(+), 10 deletions(-)

-- 
2.54.0


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

* [PATCH 1/3] PCI: rzg3s: Disable refclk on probe failure
  2026-07-15 22:30 [PATCH 0/3] PCI: rzg3s: Fix issues in cleanup paths Prabhakar
@ 2026-07-15 22:30 ` Prabhakar
  2026-07-23 17:16   ` claudiu beznea
  2026-07-15 22:30 ` [PATCH 2/3] PCI: rzg3s: Propagate platform_get_irq_byname() errors Prabhakar
  2026-07-15 22:30 ` [PATCH 3/3] PCI: rzg3s: Fix IRQ domain initialization error handling Prabhakar
  2 siblings, 1 reply; 8+ messages in thread
From: Prabhakar @ 2026-07-15 22:30 UTC (permalink / raw)
  To: Claudiu Beznea, Manivannan Sadhasivam, Krzysztof Wilczyński,
	Lorenzo Pieralisi, Rob Herring, Bjorn Helgaas
  Cc: linux-pci, linux-renesas-soc, linux-kernel, Prabhakar, Biju Das,
	Fabrizio Castro, Lad Prabhakar, stable

From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>

rzg3s_pcie_host_init_port() enables the PCIe reference clock using
clk_prepare_enable(), but if rzg3s_pcie_probe() subsequently fails, for
example because pci_host_probe() returns an error, the probe error path
only releases the clock handle with clk_put().

Balance clk_prepare_enable() by calling clk_disable_unprepare() in the
probe cleanup path before releasing the clock, ensuring the reference
clock is properly disabled on probe failure.

Fixes: 7ef502fb35b28 ("PCI: Add Renesas RZ/G3S host controller driver")
Cc: stable@vger.kernel.org
Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
---
 drivers/pci/controller/pcie-rzg3s-host.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/pci/controller/pcie-rzg3s-host.c b/drivers/pci/controller/pcie-rzg3s-host.c
index a1a78bdb7af1..01488660ab08 100644
--- a/drivers/pci/controller/pcie-rzg3s-host.c
+++ b/drivers/pci/controller/pcie-rzg3s-host.c
@@ -1897,6 +1897,7 @@ static int rzg3s_pcie_probe(struct platform_device *pdev)
 	return 0;
 
 host_probe_teardown:
+	clk_disable_unprepare(host->port.refclk);
 	rzg3s_pcie_teardown_irqdomain(host);
 	host->data->config_deinit(host);
 rpm_put:
-- 
2.54.0


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

* [PATCH 2/3] PCI: rzg3s: Propagate platform_get_irq_byname() errors
  2026-07-15 22:30 [PATCH 0/3] PCI: rzg3s: Fix issues in cleanup paths Prabhakar
  2026-07-15 22:30 ` [PATCH 1/3] PCI: rzg3s: Disable refclk on probe failure Prabhakar
@ 2026-07-15 22:30 ` Prabhakar
  2026-07-23 17:17   ` claudiu beznea
  2026-07-15 22:30 ` [PATCH 3/3] PCI: rzg3s: Fix IRQ domain initialization error handling Prabhakar
  2 siblings, 1 reply; 8+ messages in thread
From: Prabhakar @ 2026-07-15 22:30 UTC (permalink / raw)
  To: Claudiu Beznea, Manivannan Sadhasivam, Krzysztof Wilczyński,
	Lorenzo Pieralisi, Rob Herring, Bjorn Helgaas
  Cc: linux-pci, linux-renesas-soc, linux-kernel, Prabhakar, Biju Das,
	Fabrizio Castro, Lad Prabhakar, stable

From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>

platform_get_irq_byname() may return specific error codes such as
-EPROBE_DEFER, but rzg3s_pcie_init_irqdomain() replaces all failures
with -EINVAL.

This breaks probe deferral by preventing the driver core from retrying
probe once the interrupt provider becomes available.

Propagate the original error code instead.

Fixes: 7ef502fb35b28 ("PCI: Add Renesas RZ/G3S host controller driver")
Cc: stable@vger.kernel.org
Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
---
 drivers/pci/controller/pcie-rzg3s-host.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/pci/controller/pcie-rzg3s-host.c b/drivers/pci/controller/pcie-rzg3s-host.c
index 01488660ab08..f51b5d7c1998 100644
--- a/drivers/pci/controller/pcie-rzg3s-host.c
+++ b/drivers/pci/controller/pcie-rzg3s-host.c
@@ -1019,7 +1019,7 @@ static int rzg3s_pcie_init_irqdomain(struct rzg3s_pcie_host *host)
 
 		irq = platform_get_irq_byname(pdev, irq_name);
 		if (irq < 0)
-			return dev_err_probe(dev, -EINVAL,
+			return dev_err_probe(dev, irq,
 					     "Failed to parse and map INT%c IRQ\n",
 					     'A' + i);
 
-- 
2.54.0


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

* [PATCH 3/3] PCI: rzg3s: Fix IRQ domain initialization error handling
  2026-07-15 22:30 [PATCH 0/3] PCI: rzg3s: Fix issues in cleanup paths Prabhakar
  2026-07-15 22:30 ` [PATCH 1/3] PCI: rzg3s: Disable refclk on probe failure Prabhakar
  2026-07-15 22:30 ` [PATCH 2/3] PCI: rzg3s: Propagate platform_get_irq_byname() errors Prabhakar
@ 2026-07-15 22:30 ` Prabhakar
  2026-07-23 17:11   ` claudiu beznea
  2 siblings, 1 reply; 8+ messages in thread
From: Prabhakar @ 2026-07-15 22:30 UTC (permalink / raw)
  To: Claudiu Beznea, Manivannan Sadhasivam, Krzysztof Wilczyński,
	Lorenzo Pieralisi, Rob Herring, Bjorn Helgaas
  Cc: linux-pci, linux-renesas-soc, linux-kernel, Prabhakar, Biju Das,
	Fabrizio Castro, Lad Prabhakar, stable

From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>

rzg3s_pcie_init_irqdomain() installs chained handlers for the INTx
parent interrupts before creating the INTx irqdomain and initializing
MSI support.

If any subsequent step fails, such as obtaining an INTx IRQ,
creating the irqdomain, or initializing MSI, the error path returns
without removing any chained handlers that were already installed.
This leaves stale handler and data pointers attached to the parent
interrupts.

Fix the error path by unwinding the chained handler registration before
returning. Also clear the chained handlers during
rzg3s_pcie_teardown_irqdomain() so that teardown fully mirrors the
initialization sequence.

Fixes: 7ef502fb35b28 ("PCI: Add Renesas RZ/G3S host controller driver")
Cc: stable@vger.kernel.org
Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
---
 drivers/pci/controller/pcie-rzg3s-host.c | 37 +++++++++++++++++-------
 1 file changed, 27 insertions(+), 10 deletions(-)

diff --git a/drivers/pci/controller/pcie-rzg3s-host.c b/drivers/pci/controller/pcie-rzg3s-host.c
index f51b5d7c1998..5aeb030d43c8 100644
--- a/drivers/pci/controller/pcie-rzg3s-host.c
+++ b/drivers/pci/controller/pcie-rzg3s-host.c
@@ -1006,22 +1006,30 @@ static const struct irq_domain_ops rzg3s_pcie_intx_domain_ops = {
 	.xlate = irq_domain_xlate_onetwocell,
 };
 
+static void rzg3s_pcie_clear_intx_handlers(struct rzg3s_pcie_host *host, int count)
+{
+	while (--count >= 0)
+		irq_set_chained_handler_and_data(host->intx_irqs[count], NULL, NULL);
+}
+
 static int rzg3s_pcie_init_irqdomain(struct rzg3s_pcie_host *host)
 {
 	struct device *dev = host->dev;
 	struct platform_device *pdev = to_platform_device(dev);
+	int i, ret;
 
-	for (int i = 0; i < PCI_NUM_INTX; i++) {
+	for (i = 0; i < PCI_NUM_INTX; i++) {
 		char irq_name[5] = {0};
 		int irq;
 
 		scnprintf(irq_name, ARRAY_SIZE(irq_name), "int%c", 'a' + i);
 
 		irq = platform_get_irq_byname(pdev, irq_name);
-		if (irq < 0)
-			return dev_err_probe(dev, irq,
-					     "Failed to parse and map INT%c IRQ\n",
-					     'A' + i);
+		if (irq < 0) {
+			ret = irq;
+			dev_err_probe(dev, ret, "Failed to parse and map INT%c IRQ\n", 'A' + i);
+			goto err_cleanup_intx;
+		}
 
 		host->intx_irqs[i] = irq;
 		irq_set_chained_handler_and_data(irq,
@@ -1033,21 +1041,28 @@ static int rzg3s_pcie_init_irqdomain(struct rzg3s_pcie_host *host)
 						     PCI_NUM_INTX,
 						     &rzg3s_pcie_intx_domain_ops,
 						     host);
-	if (!host->intx_domain)
-		return dev_err_probe(dev, -EINVAL,
-				     "Failed to add irq domain for INTx IRQs\n");
+	if (!host->intx_domain) {
+		ret = -EINVAL;
+		dev_err_probe(dev, ret, "Failed to add irq domain for INTx IRQs\n");
+		goto err_cleanup_intx;
+	}
 	irq_domain_update_bus_token(host->intx_domain, DOMAIN_BUS_WIRED);
 
 	if (IS_ENABLED(CONFIG_PCI_MSI)) {
-		int ret = rzg3s_pcie_init_msi(host);
+		ret = rzg3s_pcie_init_msi(host);
 
 		if (ret) {
 			irq_domain_remove(host->intx_domain);
-			return ret;
+			goto err_cleanup_intx;
 		}
 	}
 
 	return 0;
+
+err_cleanup_intx:
+	rzg3s_pcie_clear_intx_handlers(host, i);
+
+	return ret;
 }
 
 static void rzg3s_pcie_teardown_irqdomain(struct rzg3s_pcie_host *host)
@@ -1055,6 +1070,8 @@ static void rzg3s_pcie_teardown_irqdomain(struct rzg3s_pcie_host *host)
 	if (IS_ENABLED(CONFIG_PCI_MSI))
 		rzg3s_pcie_teardown_msi(host);
 
+	rzg3s_pcie_clear_intx_handlers(host, PCI_NUM_INTX);
+
 	irq_domain_remove(host->intx_domain);
 }
 
-- 
2.54.0


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

* Re: [PATCH 3/3] PCI: rzg3s: Fix IRQ domain initialization error handling
  2026-07-15 22:30 ` [PATCH 3/3] PCI: rzg3s: Fix IRQ domain initialization error handling Prabhakar
@ 2026-07-23 17:11   ` claudiu beznea
  2026-07-27  9:08     ` Lad, Prabhakar
  0 siblings, 1 reply; 8+ messages in thread
From: claudiu beznea @ 2026-07-23 17:11 UTC (permalink / raw)
  To: Prabhakar, Claudiu Beznea, Manivannan Sadhasivam,
	Krzysztof Wilczyński, Lorenzo Pieralisi, Rob Herring,
	Bjorn Helgaas
  Cc: linux-pci, linux-renesas-soc, linux-kernel, Prabhakar, Biju Das,
	Fabrizio Castro, Lad Prabhakar, stable

Hi, Prabhakar,

On 7/16/26 01:30, Prabhakar wrote:
> From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> 
> rzg3s_pcie_init_irqdomain() installs chained handlers for the INTx
> parent interrupts before creating the INTx irqdomain and initializing
> MSI support.
> 
> If any subsequent step fails, such as obtaining an INTx IRQ,
> creating the irqdomain, or initializing MSI, the error path returns
> without removing any chained handlers that were already installed.
> This leaves stale handler and data pointers attached to the parent
> interrupts.
> 
> Fix the error path by unwinding the chained handler registration before
> returning. Also clear the chained handlers during
> rzg3s_pcie_teardown_irqdomain() so that teardown fully mirrors the
> initialization sequence.
> 
> Fixes: 7ef502fb35b28 ("PCI: Add Renesas RZ/G3S host controller driver")
> Cc: stable@vger.kernel.org
> Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> ---
>   drivers/pci/controller/pcie-rzg3s-host.c | 37 +++++++++++++++++-------
>   1 file changed, 27 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/pci/controller/pcie-rzg3s-host.c b/drivers/pci/controller/pcie-rzg3s-host.c
> index f51b5d7c1998..5aeb030d43c8 100644
> --- a/drivers/pci/controller/pcie-rzg3s-host.c
> +++ b/drivers/pci/controller/pcie-rzg3s-host.c
> @@ -1006,22 +1006,30 @@ static const struct irq_domain_ops rzg3s_pcie_intx_domain_ops = {
>   	.xlate = irq_domain_xlate_onetwocell,
>   };
>   
> +static void rzg3s_pcie_clear_intx_handlers(struct rzg3s_pcie_host *host, int count)
> +{
> +	while (--count >= 0)
> +		irq_set_chained_handler_and_data(host->intx_irqs[count], NULL, NULL);
> +}

On PCI subsystem lines are still wrapped at 80 chars length. Could you please 
update it, adding also {} around multi-line blocks as the rest of the code in 
this file is doing, e.g.:

static void rzg3s_pcie_clear_intx_handlers(struct rzg3s_pcie_host *host,
					   int count)
{
	while (--count >= 0) {
		irq_set_chained_handler_and_data(host->intx_irqs[count], NULL,
						 NULL);
	}
}

> +
>   static int rzg3s_pcie_init_irqdomain(struct rzg3s_pcie_host *host)
>   {
>   	struct device *dev = host->dev;
>   	struct platform_device *pdev = to_platform_device(dev);
> +	int i, ret;
>   
> -	for (int i = 0; i < PCI_NUM_INTX; i++) {
> +	for (i = 0; i < PCI_NUM_INTX; i++) {
>   		char irq_name[5] = {0};
>   		int irq;
>   
>   		scnprintf(irq_name, ARRAY_SIZE(irq_name), "int%c", 'a' + i);
>   
>   		irq = platform_get_irq_byname(pdev, irq_name);
> -		if (irq < 0)
> -			return dev_err_probe(dev, irq,
> -					     "Failed to parse and map INT%c IRQ\n",
> -					     'A' + i);
> +		if (irq < 0) {
> +			ret = irq;
> +			dev_err_probe(dev, ret, "Failed to parse and map INT%c IRQ\n", 'A' + i);
> +			goto err_cleanup_intx;
> +		}
>   
>   		host->intx_irqs[i] = irq;
>   		irq_set_chained_handler_and_data(irq,
> @@ -1033,21 +1041,28 @@ static int rzg3s_pcie_init_irqdomain(struct rzg3s_pcie_host *host)
>   						     PCI_NUM_INTX,
>   						     &rzg3s_pcie_intx_domain_ops,
>   						     host);
> -	if (!host->intx_domain)
> -		return dev_err_probe(dev, -EINVAL,
> -				     "Failed to add irq domain for INTx IRQs\n");
> +	if (!host->intx_domain) {
> +		ret = -EINVAL;
> +		dev_err_probe(dev, ret, "Failed to add irq domain for INTx IRQs\n");
> +		goto err_cleanup_intx;
> +	}
>   	irq_domain_update_bus_token(host->intx_domain, DOMAIN_BUS_WIRED);
>   
>   	if (IS_ENABLED(CONFIG_PCI_MSI)) {
> -		int ret = rzg3s_pcie_init_msi(host);
> +		ret = rzg3s_pcie_init_msi(host);
>   
>   		if (ret) {
>   			irq_domain_remove(host->intx_domain);

Could you please drop this ^ from here and (see below)...

> -			return ret;
> +			goto err_cleanup_intx;
>   		}
>   	}
>   
>   	return 0;
> +
> +err_cleanup_intx:

Add it here? To have everything grouped together. I am also working on fixing 
the hotplug support and having it like this would be useful. I can do it myself 
in a separate patch, but I think, logically, it belongs to this patch.

Thank you,
Claudiu

> +	rzg3s_pcie_clear_intx_handlers(host, i);
> +
> +	return ret;
>   }
>   
>   static void rzg3s_pcie_teardown_irqdomain(struct rzg3s_pcie_host *host)
> @@ -1055,6 +1070,8 @@ static void rzg3s_pcie_teardown_irqdomain(struct rzg3s_pcie_host *host)
>   	if (IS_ENABLED(CONFIG_PCI_MSI))
>   		rzg3s_pcie_teardown_msi(host);
>   
> +	rzg3s_pcie_clear_intx_handlers(host, PCI_NUM_INTX);
> +
>   	irq_domain_remove(host->intx_domain);
>   }
>   


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

* Re: [PATCH 1/3] PCI: rzg3s: Disable refclk on probe failure
  2026-07-15 22:30 ` [PATCH 1/3] PCI: rzg3s: Disable refclk on probe failure Prabhakar
@ 2026-07-23 17:16   ` claudiu beznea
  0 siblings, 0 replies; 8+ messages in thread
From: claudiu beznea @ 2026-07-23 17:16 UTC (permalink / raw)
  To: Prabhakar, Claudiu Beznea, Manivannan Sadhasivam,
	Krzysztof Wilczyński, Lorenzo Pieralisi, Rob Herring,
	Bjorn Helgaas
  Cc: linux-pci, linux-renesas-soc, linux-kernel, Prabhakar, Biju Das,
	Fabrizio Castro, Lad Prabhakar, stable



On 7/16/26 01:30, Prabhakar wrote:
> From: Lad Prabhakar<prabhakar.mahadev-lad.rj@bp.renesas.com>
> 
> rzg3s_pcie_host_init_port() enables the PCIe reference clock using
> clk_prepare_enable(), but if rzg3s_pcie_probe() subsequently fails, for
> example because pci_host_probe() returns an error, the probe error path
> only releases the clock handle with clk_put().
> 
> Balance clk_prepare_enable() by calling clk_disable_unprepare() in the
> probe cleanup path before releasing the clock, ensuring the reference
> clock is properly disabled on probe failure.
> 
> Fixes: 7ef502fb35b28 ("PCI: Add Renesas RZ/G3S host controller driver")
> Cc:stable@vger.kernel.org
> Signed-off-by: Lad Prabhakar<prabhakar.mahadev-lad.rj@bp.renesas.com>

Reviewed-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>

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

* Re: [PATCH 2/3] PCI: rzg3s: Propagate platform_get_irq_byname() errors
  2026-07-15 22:30 ` [PATCH 2/3] PCI: rzg3s: Propagate platform_get_irq_byname() errors Prabhakar
@ 2026-07-23 17:17   ` claudiu beznea
  0 siblings, 0 replies; 8+ messages in thread
From: claudiu beznea @ 2026-07-23 17:17 UTC (permalink / raw)
  To: Prabhakar, Claudiu Beznea, Manivannan Sadhasivam,
	Krzysztof Wilczyński, Lorenzo Pieralisi, Rob Herring,
	Bjorn Helgaas
  Cc: linux-pci, linux-renesas-soc, linux-kernel, Prabhakar, Biju Das,
	Fabrizio Castro, Lad Prabhakar, stable



On 7/16/26 01:30, Prabhakar wrote:
> From: Lad Prabhakar<prabhakar.mahadev-lad.rj@bp.renesas.com>
> 
> platform_get_irq_byname() may return specific error codes such as
> -EPROBE_DEFER, but rzg3s_pcie_init_irqdomain() replaces all failures
> with -EINVAL.
> 
> This breaks probe deferral by preventing the driver core from retrying
> probe once the interrupt provider becomes available.
> 
> Propagate the original error code instead.
> 
> Fixes: 7ef502fb35b28 ("PCI: Add Renesas RZ/G3S host controller driver")
> Cc:stable@vger.kernel.org
> Signed-off-by: Lad Prabhakar<prabhakar.mahadev-lad.rj@bp.renesas.com>

Reviewed-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>

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

* Re: [PATCH 3/3] PCI: rzg3s: Fix IRQ domain initialization error handling
  2026-07-23 17:11   ` claudiu beznea
@ 2026-07-27  9:08     ` Lad, Prabhakar
  0 siblings, 0 replies; 8+ messages in thread
From: Lad, Prabhakar @ 2026-07-27  9:08 UTC (permalink / raw)
  To: claudiu beznea
  Cc: Claudiu Beznea, Manivannan Sadhasivam, Krzysztof Wilczyński,
	Lorenzo Pieralisi, Rob Herring, Bjorn Helgaas, linux-pci,
	linux-renesas-soc, linux-kernel, Prabhakar, Biju Das,
	Fabrizio Castro, Lad Prabhakar, stable

Hi Claudiu,

Thank you for the review.

On Thu, Jul 23, 2026 at 6:11 PM claudiu beznea <claudiu.beznea@tuxon.dev> wrote:
>
> Hi, Prabhakar,
>
> On 7/16/26 01:30, Prabhakar wrote:
> > From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> >
> > rzg3s_pcie_init_irqdomain() installs chained handlers for the INTx
> > parent interrupts before creating the INTx irqdomain and initializing
> > MSI support.
> >
> > If any subsequent step fails, such as obtaining an INTx IRQ,
> > creating the irqdomain, or initializing MSI, the error path returns
> > without removing any chained handlers that were already installed.
> > This leaves stale handler and data pointers attached to the parent
> > interrupts.
> >
> > Fix the error path by unwinding the chained handler registration before
> > returning. Also clear the chained handlers during
> > rzg3s_pcie_teardown_irqdomain() so that teardown fully mirrors the
> > initialization sequence.
> >
> > Fixes: 7ef502fb35b28 ("PCI: Add Renesas RZ/G3S host controller driver")
> > Cc: stable@vger.kernel.org
> > Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> > ---
> >   drivers/pci/controller/pcie-rzg3s-host.c | 37 +++++++++++++++++-------
> >   1 file changed, 27 insertions(+), 10 deletions(-)
> >
> > diff --git a/drivers/pci/controller/pcie-rzg3s-host.c b/drivers/pci/controller/pcie-rzg3s-host.c
> > index f51b5d7c1998..5aeb030d43c8 100644
> > --- a/drivers/pci/controller/pcie-rzg3s-host.c
> > +++ b/drivers/pci/controller/pcie-rzg3s-host.c
> > @@ -1006,22 +1006,30 @@ static const struct irq_domain_ops rzg3s_pcie_intx_domain_ops = {
> >       .xlate = irq_domain_xlate_onetwocell,
> >   };
> >
> > +static void rzg3s_pcie_clear_intx_handlers(struct rzg3s_pcie_host *host, int count)
> > +{
> > +     while (--count >= 0)
> > +             irq_set_chained_handler_and_data(host->intx_irqs[count], NULL, NULL);
> > +}
>
> On PCI subsystem lines are still wrapped at 80 chars length. Could you please
> update it, adding also {} around multi-line blocks as the rest of the code in
> this file is doing, e.g.:
>
> static void rzg3s_pcie_clear_intx_handlers(struct rzg3s_pcie_host *host,
>                                            int count)
> {
>         while (--count >= 0) {
>                 irq_set_chained_handler_and_data(host->intx_irqs[count], NULL,
>                                                  NULL);
>         }
> }
>
Ok.

> > +
> >   static int rzg3s_pcie_init_irqdomain(struct rzg3s_pcie_host *host)
> >   {
> >       struct device *dev = host->dev;
> >       struct platform_device *pdev = to_platform_device(dev);
> > +     int i, ret;
> >
> > -     for (int i = 0; i < PCI_NUM_INTX; i++) {
> > +     for (i = 0; i < PCI_NUM_INTX; i++) {
> >               char irq_name[5] = {0};
> >               int irq;
> >
> >               scnprintf(irq_name, ARRAY_SIZE(irq_name), "int%c", 'a' + i);
> >
> >               irq = platform_get_irq_byname(pdev, irq_name);
> > -             if (irq < 0)
> > -                     return dev_err_probe(dev, irq,
> > -                                          "Failed to parse and map INT%c IRQ\n",
> > -                                          'A' + i);
> > +             if (irq < 0) {
> > +                     ret = irq;
> > +                     dev_err_probe(dev, ret, "Failed to parse and map INT%c IRQ\n", 'A' + i);
> > +                     goto err_cleanup_intx;
> > +             }
> >
> >               host->intx_irqs[i] = irq;
> >               irq_set_chained_handler_and_data(irq,
> > @@ -1033,21 +1041,28 @@ static int rzg3s_pcie_init_irqdomain(struct rzg3s_pcie_host *host)
> >                                                    PCI_NUM_INTX,
> >                                                    &rzg3s_pcie_intx_domain_ops,
> >                                                    host);
> > -     if (!host->intx_domain)
> > -             return dev_err_probe(dev, -EINVAL,
> > -                                  "Failed to add irq domain for INTx IRQs\n");
> > +     if (!host->intx_domain) {
> > +             ret = -EINVAL;
> > +             dev_err_probe(dev, ret, "Failed to add irq domain for INTx IRQs\n");
> > +             goto err_cleanup_intx;
> > +     }
> >       irq_domain_update_bus_token(host->intx_domain, DOMAIN_BUS_WIRED);
> >
> >       if (IS_ENABLED(CONFIG_PCI_MSI)) {
> > -             int ret = rzg3s_pcie_init_msi(host);
> > +             ret = rzg3s_pcie_init_msi(host);
> >
> >               if (ret) {
> >                       irq_domain_remove(host->intx_domain);
>
> Could you please drop this ^ from here and (see below)...
>
> > -                     return ret;
> > +                     goto err_cleanup_intx;
> >               }
> >       }
> >
> >       return 0;
> > +
> > +err_cleanup_intx:
>
> Add it here? To have everything grouped together. I am also working on fixing
> the hotplug support and having it like this would be useful. I can do it myself
> in a separate patch, but I think, logically, it belongs to this patch.
>
Ok, In that case I will need to add a check for host->intx_domain !=
NULL before calling irq_domain_remove().

Cheers,
Prabhakar

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

end of thread, other threads:[~2026-07-27  9:09 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-15 22:30 [PATCH 0/3] PCI: rzg3s: Fix issues in cleanup paths Prabhakar
2026-07-15 22:30 ` [PATCH 1/3] PCI: rzg3s: Disable refclk on probe failure Prabhakar
2026-07-23 17:16   ` claudiu beznea
2026-07-15 22:30 ` [PATCH 2/3] PCI: rzg3s: Propagate platform_get_irq_byname() errors Prabhakar
2026-07-23 17:17   ` claudiu beznea
2026-07-15 22:30 ` [PATCH 3/3] PCI: rzg3s: Fix IRQ domain initialization error handling Prabhakar
2026-07-23 17:11   ` claudiu beznea
2026-07-27  9:08     ` Lad, Prabhakar

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

all inboxes | Powered by JetHome®