Linux PCI subsystem development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: Prabhakar <prabhakar.csengg@gmail.com>
Cc: wsa+renesas@sang-engineering.com, linux-pci@vger.kernel.org
Subject: Re: [PATCH 1/3] PCI: rzg3s: Disable refclk on probe failure
Date: Wed, 15 Jul 2026 22:43:48 +0000	[thread overview]
Message-ID: <20260715224349.134DF1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260715223019.3002237-2-prabhakar.mahadev-lad.rj@bp.renesas.com>

Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:

New issues:
- [Medium] The patch violates hardware teardown order by disabling the PCIe reference clock before asserting controller resets.

Pre-existing issues:
- [Critical] Missing IRQ cleanup for chained INTx handlers on probe failure leads to use-after-free.
- [High] MMIO register access after PM runtime clock gating in suspend path causes system hang.
--

--- Patch [1]: [PATCH 1/3] PCI: rzg3s: Disable refclk on probe failure ---
commit 0d4ef239e6084c21b4710c1db03e3a6365363533
Author: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Subject: PCI: rzg3s: Disable refclk on probe failure

This commit disables the PCIe reference clock when the probe function fails.
It adds a call to clk_disable_unprepare in the error path, ensuring the
clock is balanced if initialization fails.

Cc: stable@vger.kernel.org

> diff --git a/drivers/pci/controller/pcie-rzg3s-host.c b/drivers/pci/controller/pcie-rzg3s-host.c
> index 66f687304c1cb..bd6471a7fb7a1 100644
> --- a/drivers/pci/controller/pcie-rzg3s-host.c
> +++ b/drivers/pci/controller/pcie-rzg3s-host.c
> @@ -1762,6 +1762,7 @@ static int rzg3s_pcie_probe(struct platform_device *pdev)
>  	return 0;
>  
>  host_probe_teardown:
> +	clk_disable_unprepare(host->port.refclk);

[Severity: Medium]
Does this new addition violate the hardware teardown order by disabling the
reference clock before asserting controller resets?

During setup, the reference clock is enabled prior to calling
config_post_init() which deasserts resets. In this new error path,
clk_disable_unprepare() is called before host->data->config_deinit(host).

Could disabling the clock while the core is out of reset leave the state
machine hanging or undefined? Should the clock disable be moved after the
config_deinit() call to maintain strict LIFO initialization order?

>  	rzg3s_pcie_teardown_irqdomain(host);

[Severity: Critical]
This is a pre-existing issue, but does the teardown function fail to clean
up chained handlers on probe failure?

Looking at rzg3s_pcie_teardown_irqdomain(), it removes the IRQ domain but
does not unregister the chained INTx hardware handlers:

drivers/pci/controller/pcie-rzg3s-host.c:rzg3s_pcie_teardown_irqdomain() {
        if (IS_ENABLED(CONFIG_PCI_MSI))
                rzg3s_pcie_teardown_msi(host);

        irq_domain_remove(host->intx_domain);
}

If pci_host_probe() fails and the devres mechanism frees the host structure,
could a shared or spurious INTx interrupt firing later cause
rzg3s_pcie_intx_irq_handler() to dereference the freed host pointer? Should
this call irq_set_chained_handler_and_data(irq, NULL, NULL) to prevent a
use-after-free?

>  	host->data->config_deinit(host);
>  rpm_put:

[Severity: High]
This is a pre-existing issue, but can the suspend path cause a system hang
due to MMIO access after PM runtime clock gating?

In rzg3s_pcie_suspend_noirq(), the driver disables the device PM domain
clocks before calling the hardware de-initialization routine:

drivers/pci/controller/pcie-rzg3s-host.c:rzg3s_pcie_suspend_noirq() {
        ...
        ret = pm_runtime_put_sync(dev);
        if (ret)
                return ret;

        clk_disable_unprepare(port->refclk);

        /* SoC-specific de-initialization */
        ret = data->config_deinit(host);
        ...
}

For the RZ/G3E SoC, the de-initialization callback performs an MMIO write:

drivers/pci/controller/pcie-rzg3s-host.c:rzg3e_pcie_config_deinit() {
        writel_relaxed(0, host->axi + RZG3S_PCI_RESET);
        return 0;
}

Will accessing this MMIO region while the bus clock is gated trigger a fatal
bus fault on ARM64 during system suspend? Should the de-initialization
happen before pm_runtime_put_sync() is called?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260715223019.3002237-1-prabhakar.mahadev-lad.rj@bp.renesas.com?part=1

  reply	other threads:[~2026-07-15 22:43 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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:43   ` sashiko-bot [this message]
2026-07-15 22:30 ` [PATCH 2/3] PCI: rzg3s: Propagate platform_get_irq_byname() errors Prabhakar
2026-07-15 22:45   ` sashiko-bot
2026-07-15 22:30 ` [PATCH 3/3] PCI: rzg3s: Fix IRQ domain initialization error handling Prabhakar
2026-07-15 22:39   ` sashiko-bot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260715224349.134DF1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=prabhakar.csengg@gmail.com \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=wsa+renesas@sang-engineering.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox