Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Marek Vasut" <marek.vasut+renesas@mailbox.org>
Cc: robh@kernel.org, conor+dt@kernel.org, devicetree@vger.kernel.org,
	wsa+renesas@sang-engineering.com, linux-pci@vger.kernel.org
Subject: Re: [PATCH v4 6/6] PCI: dwc: rcar-gen4: Add support for R-Car X5H PCIe4
Date: Sat, 05 Sep 2026 21:40:16 +0000	[thread overview]
Message-ID: <20260905214016.86BFB1F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260905212649.360498-7-marek.vasut+renesas@mailbox.org>

Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] Incorrect PHY power-on sequencing and unchecked return value in rcar_gen5_pcie_ltssm_control().
- [High] The driver fails to configure the dw-edma core for HDMA on Gen5, breaking the commit's claim of HDMA support.
- [Medium] Missing assertion of DW_PCIE_PWR_RST on the error path of rcar_gen5_pcie_init() leaks hardware reset state.
--

commit 33f1bd3dbda597464a41cce7e19a3d761ff8b7c8
Author: Marek Vasut <marek.vasut+renesas@mailbox.org>

PCI: dwc: rcar-gen4: Add support for R-Car X5H PCIe4

This patch adds support for the R8A78000 (R-Car X5H) PCIe4 controller,
differentiating it with the "renesas,rcar-gen5-pcie4" compatible string.
It implements Gen5-specific initialization, deinitialization, link speed,
and LTSSM control callbacks, and handles a separate PHY driver instance.

> The R-Car X5H PCIe4 controller embeds HDMA instead of EDMA embedded
> in the R-Car Gen4 PCIe controller, "dw-edma" driver supports both
> DMA variants.

[Severity: High]
Does the driver actually configure the dw-edma core for HDMA on Gen5 hardware?

Looking at rcar_gen4_pcie_alloc() elsewhere in the same file, the DMA mode
appears to be unconditionally hardcoded:

rcar_gen4_pcie_alloc() {
    ...
    rcar->dw.edma.mf = EDMA_MF_EDMA_UNROLL;
    ...
}

Since this mapping format is never updated for Gen5 controllers (e.g., to
EDMA_MF_HDMA_NATIVE or EDMA_MF_HDMA_COMPAT), will the dw-edma driver attempt
to program EDMA registers and descriptors instead of HDMA, causing DMA
operations to fail on Gen5?

> diff --git a/drivers/pci/controller/dwc/pcie-rcar-gen4.c b/drivers/pci/controller/dwc/pcie-rcar-gen4.c
> --- a/drivers/pci/controller/dwc/pcie-rcar-gen4.c
> +++ b/drivers/pci/controller/dwc/pcie-rcar-gen4.c
[ ... ]
> @@ -285,6 +322,49 @@ static int rcar_gen4_v4h_v4m_pcie_init(struct rcar_gen4_pcie *rcar)
[ ... ]
> +static int rcar_gen5_pcie_init(struct rcar_gen4_pcie *rcar)
> +{
[ ... ]
> +	/* R-Car Gen4 and Gen5 common initialization. */
> +	ret = rcar_gen4_pcie_common_init(rcar);
> +	if (ret)
> +		return ret;
> +
> +	/* R-Car Gen5 specific additional initialization. */
> +	ret = phy_init(rcar->phy);
> +	if (ret)
> +		goto err_unprepare;
[ ... ]
> +err_unprepare:
> +	clk_bulk_disable_unprepare(DW_PCIE_NUM_CORE_CLKS, dw->core_clks);
> +
> +	return ret;
> +}

[Severity: Medium]
Does this error path leak the hardware reset state?

rcar_gen4_pcie_common_init() successfully deasserts the DW_PCIE_PWR_RST
reset control before returning. If phy_init() subsequently fails, the
code jumps to err_unprepare, which disables the core clocks but leaves
the reset deasserted.

Should this error path also include a call to reset_control_assert() to
balance the state?

[ ... ]
> @@ -807,6 +897,28 @@ static int r8a779f0_pcie_ltssm_control(struct rcar_gen4_pcie *rcar, bool enable)
[ ... ]
> +static int rcar_gen5_pcie_ltssm_control(struct rcar_gen4_pcie *rcar, bool enable)
> +{
> +	u32 val;
> +
> +	val = readl(rcar->base + PCIERSTCTRL1);
> +	if (enable) {
> +		val |= APP_LTSSM_ENABLE;
> +		val &= ~APP_HOLD_PHY_RST;
> +	} else {
> +		val &= ~APP_LTSSM_ENABLE;
> +		val |= APP_HOLD_PHY_RST;
> +	}
> +	writel(val, rcar->base + PCIERSTCTRL1);
> +
> +	if (enable)
> +		phy_power_on(rcar->phy);
> +	else
> +		phy_power_off(rcar->phy);
> +
> +	return 0;
> +}

[Severity: High]
Does this sequence start link training before the PHY is properly powered
on and stabilized?

By writing APP_LTSSM_ENABLE to PCIERSTCTRL1 before calling phy_power_on(),
the controller might attempt training with an unpowered PHY.

Also, is it safe to ignore the return value of phy_power_on() here? If the
PHY fails to power on, the function still returns 0, leaving the controller
in a broken state with an unpowered PHY.

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

      reply	other threads:[~2026-09-05 21:40 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-05 21:26 [PATCH v4 0/6] PCI: dwc: rcar-gen4: Add support for R-Car X5H PCIe4 Marek Vasut
2026-09-05 21:26 ` [PATCH v4 1/6] dt-bindings: PCI: rcar-gen4-pci-host: Add R-Car X5H PCIe4 compatible Marek Vasut
2026-09-05 21:36   ` sashiko-bot
2026-09-05 21:26 ` [PATCH v4 2/6] PCI: dwc: rcar-gen4: Rework rcar_gen4_pcie_drvdata .additional_common_init into .init Marek Vasut
2026-09-05 21:33   ` sashiko-bot
2026-09-05 21:26 ` [PATCH v4 3/6] PCI: dwc: rcar-gen4: Add .deinit callback Marek Vasut
2026-09-05 21:38   ` sashiko-bot
2026-09-05 21:26 ` [PATCH v4 4/6] PCI: dwc: rcar-gen4: Split .start_link into ltssm_control and speed_control Marek Vasut
2026-09-05 21:32   ` sashiko-bot
2026-09-05 21:26 ` [PATCH v4 5/6] PCI: dwc: rcar-gen4: Handle PERST via reset subsystem Marek Vasut
2026-09-05 21:38   ` sashiko-bot
2026-09-05 21:26 ` [PATCH v4 6/6] PCI: dwc: rcar-gen4: Add support for R-Car X5H PCIe4 Marek Vasut
2026-09-05 21:40   ` sashiko-bot [this message]

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=20260905214016.86BFB1F00A3A@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