Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Marek Vasut" <marek.vasut+renesas@mailbox.org>
Cc: conor+dt@kernel.org, devicetree@vger.kernel.org, robh@kernel.org,
	linux-pci@vger.kernel.org, wsa+renesas@sang-engineering.com
Subject: Re: [RFC][PATCH] PCI: rcar-gen4: Add missing PM ops
Date: Sun, 06 Sep 2026 17:47:42 +0000	[thread overview]
Message-ID: <20260906174742.B85CD1F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260906173234.522400-1-marek.vasut+renesas@mailbox.org>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Unconditional calls to host-specific suspend/resume functions crash when the controller operates in Endpoint (EP) mode.
- [High] Suspend/resume deadlock and unsafe GFP_KERNEL allocation via request_firmware() in the resume_noirq path.
--

commit 5af3966526dc17abac6d2f1a9c20afb491499031
Author: Marek Vasut <marek.vasut+renesas@mailbox.org>

PCI: rcar-gen4: Add missing PM ops

The commit adds suspend/resume PM ops to fix an issue where the controller
loses state during suspend on R-Car V4M. It registers generic suspend and
resume handlers to gracefully tear down and restart the PCIe link across
all R-Car Gen4 platforms.

> diff --git a/drivers/pci/controller/dwc/pcie-rcar-gen4.c b/drivers/pci/controller/dwc/pcie-rcar-gen4.c
> index fbe465a29068f..8c3e41e9a8ba1 100644
> --- a/drivers/pci/controller/dwc/pcie-rcar-gen4.c
> +++ b/drivers/pci/controller/dwc/pcie-rcar-gen4.c
> @@ -849,6 +849,22 @@ static int rcar_gen4_pcie_ltssm_control(struct rcar_gen4_pcie *rcar, bool enable
>  	return 0;
>  }
>  
> +static int rcar_gen4_pcie_suspend_noirq(struct device *dev)
> +{
> +	struct rcar_gen4_pcie *rcar = dev_get_drvdata(dev);
> +	struct dw_pcie *dw = &rcar->dw;
> +
> +	return dw_pcie_suspend_noirq(dw);

[Severity: High]
Does this crash when the controller operates in Endpoint mode?

Since the driver registers rcar_gen4_pcie_pm_ops for all matched devices,
including those in Endpoint mode (e.g., "renesas,rcar-gen4-pcie-ep"), this
unconditionally routes the suspend operation to the host-specific
dw_pcie_suspend_noirq() without verifying the controller mode.

In Endpoint mode, dw_pcie_host_init() is never called, leaving the Root
Port (pci->pp) structures uninitialized. If dw_pcie_suspend_noirq() is
called in Endpoint mode, it will dereference pci->pp.bridge which is
strictly NULL:

drivers/pci/controller/dwc/pcie-designware-host.c:dw_pcie_suspend_noirq() {
    ...
	if (!pci_host_common_d3cold_possible(pci->pp.bridge, &pme_capable))
		return 0;
    ...
}

It will also dereference pci->pp.ops during the link-down fallback path:

drivers/pci/controller/dwc/pcie-designware-host.c:dw_pcie_suspend_noirq() {
    ...
stop_link:
    ...
	if (pci->pp.ops->deinit)
		pci->pp.ops->deinit(&pci->pp);
    ...
}

> +}
> +
> +static int rcar_gen4_pcie_resume_noirq(struct device *dev)
> +{
> +	struct rcar_gen4_pcie *rcar = dev_get_drvdata(dev);
> +	struct dw_pcie *dw = &rcar->dw;
> +
> +	return dw_pcie_resume_noirq(dw);

[Severity: High]
Can this cause a suspend/resume deadlock due to unsafe GFP_KERNEL allocations?

When dw_pcie_resume_noirq() is called, it restarts the link which
ultimately invokes request_firmware() in the resume_noirq phase:

dw_pcie_resume_noirq()
  dw_pcie_start_link()
    rcar_gen4_pcie_start_link()
      rcar_gen4_pcie_ltssm_control()
        rcar_gen4_pcie_download_phy_firmware()
          request_firmware(&fw, RCAR_GEN4_PCIE_FIRMWARE_NAME, dw->dev);

Executing request_firmware() in a noirq phase is strictly unsafe because
device interrupts (including those for storage controllers) are disabled.
If the firmware is not cached, the request will hang indefinitely waiting
for filesystem I/O that cannot complete without interrupts. Even if
cached, request_firmware() allocates memory using GFP_KERNEL, which can
trigger page reclaim and block on disk I/O, similarly deadlocking the
system.

> +}
> +
>  static struct rcar_gen4_pcie_drvdata drvdata_r8a779f0_pcie = {
>  	.ltssm_control = r8a779f0_pcie_ltssm_control,
>  	.mode = DW_PCIE_RC_TYPE,

[ ... ]

> @@ -892,10 +908,14 @@ static const struct of_device_id rcar_gen4_pcie_of_match[] = {
>  };
>  MODULE_DEVICE_TABLE(of, rcar_gen4_pcie_of_match);
>  
> +DEFINE_NOIRQ_DEV_PM_OPS(rcar_gen4_pcie_pm_ops,
> +			rcar_gen4_pcie_suspend_noirq, rcar_gen4_pcie_resume_noirq);
> +
>  static struct platform_driver rcar_gen4_pcie_driver = {
>  	.driver = {
>  		.name = "pcie-rcar-gen4",
>  		.of_match_table = rcar_gen4_pcie_of_match,
> +		.pm = &rcar_gen4_pcie_pm_ops,
>  		.probe_type = PROBE_PREFER_ASYNCHRONOUS,
>  	},
>  	.probe = rcar_gen4_pcie_probe,

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260906173234.522400-1-marek.vasut+renesas@mailbox.org?part=1

  reply	other threads:[~2026-09-06 17:47 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-06 17:31 [RFC][PATCH] PCI: rcar-gen4: Add missing PM ops Marek Vasut
2026-09-06 17:47 ` sashiko-bot [this message]
2026-09-07 10:26 ` Geert Uytterhoeven
2026-09-07 12:01   ` Marek Vasut
2026-09-07 13:46   ` Koichiro Den
2026-09-07 15:40     ` Marek Vasut

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=20260906174742.B85CD1F00A3A@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=marek.vasut+renesas@mailbox.org \
    --cc=robh@kernel.org \
    --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