From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795974939; b=D9r5hp+61IpTdnD7yloL4xLbPyjBTK+9PltBCPL5sH6bbTeunmPR5Tds/VCRBM/L8I63 UN80OopEPmk7iQmKmMhIOLTi1VDwT6sqMTqaT53I5iI+sXt6skggrumjBKf870zYlo5tR sgCH3OonF/08ZHrx+HVAAD11bdiqv7bHiGCe9e8bwfX+M5Jf/vWGfa9CI4maNGpKfIR1E pPVStYZox4YHKvgwP+KL7G1vfDXJ33ZCY8zQEmNw1bhTRtNu5MDkdE2ykVxHK/G0ycDT4 Qq59aiXVBP36ieAWqCa+4mQO+dXZWtMJrXba7WqwSykxxmaFZbPW8T+59RRNm80Ps0Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795974939; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=K9lnpjvEhCa9jOLx9Dz0cSUUjIJ3gM/tdUR3TKxNGbI=; b=x6yExZenswBZi7+SURXPNeZNsUokuk8tsSMJsZtHxYFV8G23lMn2MAZOxoZobjWbHHdf aGes1T4f/u7w/zD0FrGg+euKpHIpyev0+z2fG5pDSgVuFcBMO6cIJAxR0kG8kZbrl4PF1 sg37GnT+X18q8dJl4mqPjBmbez65S6oKK0u5OEZhmVHZ96u5kKeuRW+95yEF3LsoGOq+L 6RFVCl826TRgZQkvSVv6swSnUEN1U1AG3c5FAIaqgrmL/w9VCFujAlYBnVB/2w8rftxWW rqKn2s9VK9DfPTs+BAmATjZeKzZ8NWlXpG6aKseWHJHs+u3Ncs+6oSgu6yczrwhUDIQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Ti9SoZfi; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 58972606A31C for ; Sun, 29 Nov 2026 17:55:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Ti9SoZfi Received: by smtp.kernel.org (Postfix) with ESMTPSA id B76E21F00896; Sun, 29 Nov 2026 17:55:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795974939; bh=K9lnpjvEhCa9jOLx9Dz0cSUUjIJ3gM/tdUR3TKxNGbI=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=Ti9SoZfiEzMbGFAw3uhE7GGRqdQRF9ouOwpafb6mEPqVQwDwZ46wSPVBCcHwnrXEP Zg3K1K1U25/t7lvI6YTEW2rGmn5YrZnQM610Cr6Cq4RF++cIo//6LZ62ssZxi63mhq 0UgV8obIgYIIvFUQsnaERJMFwr4LuEICrt5IjfRdfSWzrD+5uVMGPrFKcH4PbTo2Rq YDzWByItAJx1X4pwm0JGDScyAqjSOv4lcPrFw4mCGNDQCMENStJVpdDPJSH/8Reifb Bs1RCrNLpaS/G3mhr/dQp2eTwTsYjJtk/XQSM1ed73smy7qwA+IQBDStK4G+aZo5qA 4B7+lAp8Pu6Dw== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v2 2/3] phy: renesas: Add Renesas Multi-Protocol PHY driver for R-Car X5H Reply-To: sashiko-reviews@lists.linux.dev To: "Marek Vasut" , linux-phy@lists.infradead.org Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org, vkoul@kernel.org, neil.armstrong@linaro.org, olteanv@gmail.com, wsa+renesas@sang-engineering.com In-Reply-To: <20261129173739.282027-2-marek.vasut+renesas@mailbox.org> References: <20261129173739.282027-1-marek.vasut+renesas@mailbox.org> <20261129173739.282027-2-marek.vasut+renesas@mailbox.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Sun, 29 Nov 2026 17:55:38 +0000 X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 14 potential issues to consider: - [High] phy: renesas: missing select REGMAP_MMIO for PHY_RCAR_GEN5_MPPHY - [High] phy: renesas: incomplete regmap tables and stale regcache across resets - [High] phy: renesas: PCIe controller and channel index mismatch in mp_phy_init() - [High] phy: renesas: wrong channel index in x8 FW loop in mp_phy_power_on_pcie4() - [High] phy: renesas: bitwise AND instead of OR in mp_phy_read_poll_pcie4() - [High] phy: renesas: premature PHY provider registration in mp_phy_probe() - [High] phy: renesas: clearing chan->initialized in mp_phy_suspend() leaks PM domain - [Medium] phy: renesas: off-by-one and signed channel ID check in mp_phy_xlate() - [Medium] phy: renesas: broken runtime PM and clock error handling in probe and resume - [Medium] phy: renesas: missing clock, reset, and runtime PM teardown on driver unbind - [Medium] phy: renesas: overwriting phy->id in mp_phy_probe() corrupts phy_ida - [Low] phy: renesas: wrong mask in FIELD_PREP() in mp_phy_power_on() - [Low] phy: renesas: unused-function warnings in mp_phy_pm_ops when !CONFIG_PM - [Low] phy: renesas: oversized firmware bound in mp_phy_request_fw() overflows ch3 -- commit 7a3af8e0050098fb98215040a4c7c63a6a7ca531 Author: Thanh Quan phy: renesas: Add Renesas Multi-Protocol PHY driver for R-Car X5H This commit adds the Multi-Protocol PHY driver for the Renesas R-Car X5H (R8A78000) SoC, multiplexing PCIe4, USB 3.2, and Ethernet PCS inputs onto four PHY IO blocks. > diff --git a/drivers/phy/renesas/Kconfig b/drivers/phy/renesas/Kconfig > index 90a9ca2db7fc7..ac903b29cacbc 100644 > --- a/drivers/phy/renesas/Kconfig > +++ b/drivers/phy/renesas/Kconfig > @@ -43,6 +43,13 @@ config PHY_RCAR_GEN3_USB3 > help > Support for USB 3.0 PHY found on Renesas R-Car generation 3 SoCs. > =20 > +config PHY_RCAR_GEN5_MPPHY > + tristate "Renesas R-Car generation 5 Multi-Protocol PHY driver" > + depends on ARCH_RENESAS || COMPILE_TEST > + select GENERIC_PHY > + help > + Support for Multi-Protocol PHY found on Renesas R-Car generation 5 So= Cs. [Severity: High] Should PHY_RCAR_GEN5_MPPHY select REGMAP_MMIO? mp_phy_probe() calls devm_regmap_init_mmio(), so building without CONFIG_REGMAP_MMIO (or with CONFIG_PHY_RCAR_GEN5_MPPHY=3Dy and CONFIG_REGMAP_MMIO=3Dm) fails at link ti= me with an undefined reference to __devm_regmap_init_mmio_clk, and with CONFIG_REGMAP disabled devm_regmap_init_mmio() returns ERR_PTR(-EINVAL). > diff --git a/drivers/phy/renesas/phy-rcar-gen5-mpphy.c b/drivers/phy/rene= sas/phy-rcar-gen5-mpphy.c > new file mode 100644 > index 0000000000000..81071e5e753f3 > --- /dev/null > +++ b/drivers/phy/renesas/phy-rcar-gen5-mpphy.c [ ... ] > +#define MPPHY_PX_RD_RANGE(n) \ > + regmap_reg_range(MPPHY_PXCNTXT1(n), MPPHY_PXCNTXT1(n)), \ > + regmap_reg_range(MPPHY_PXREFCLK(n), MPPHY_PXREFCLK(n)), \ > + regmap_reg_range(MPPHY_PXRXREQ1(n), MPPHY_PXRXREQ1(n)), \ > + regmap_reg_range(MPPHY_PXRXCNT(n), MPPHY_PXRXCNT(n)), \ > + regmap_reg_range(MPPHY_PXSRAMCNT(n), MPPHY_PXTXREQ(n)) > + > +static const struct regmap_range mp_phy_readable_range[] =3D { > + regmap_reg_range(MPPHY_CMNCNT1, MPPHY_CMNCNT2), > + MPPHY_PX_RD_RANGE(0), MPPHY_PX_RD_RANGE(1), > + MPPHY_PX_RD_RANGE(2), MPPHY_PX_RD_RANGE(3), > + regmap_reg_range(MPPHY_PCS0REG1, MPPHY_PCS0REG1), > + regmap_reg_range(MPPHY_PCS0REG5, MPPHY_PCS0REG5), > + regmap_reg_range(TCA_OFFSET(0) + TCA_INTR_EN, TCA_OFFSET(0) + TCA_INTR_= STS), > + regmap_reg_range(TCA_OFFSET(0) + TCA_TCPC, TCA_OFFSET(0) + TCA_TCPC), > + regmap_reg_range(TCA_OFFSET(0) + TCA_PSTATE_1, TCA_OFFSET(0) + TCA_PSTA= TE_1), > + regmap_reg_range(TCA_OFFSET(1) + TCA_INTR_EN, TCA_OFFSET(1) + TCA_INTR_= STS), > + regmap_reg_range(TCA_OFFSET(1) + TCA_TCPC, TCA_OFFSET(1) + TCA_TCPC), > + regmap_reg_range(TCA_OFFSET(1) + TCA_PSTATE_1, TCA_OFFSET(1) + TCA_PSTA= TE_1), > +}; > + > +static const struct regmap_access_table mp_phy_readable_table =3D { > + .yes_ranges =3D mp_phy_readable_range, > + .n_yes_ranges =3D ARRAY_SIZE(mp_phy_readable_range), > +}; > + > +#define MPPHY_PX_WR_RANGE(n) \ > + regmap_reg_range(MPPHY_PXCNTXT1(n), MPPHY_PXCNTXT1(n)), \ > + regmap_reg_range(MPPHY_PXREFCLK(n), MPPHY_PXREFCLK(n)), \ > + regmap_reg_range(MPPHY_PXRXCNT(n), MPPHY_PXRXCNT(n)), \ > + regmap_reg_range(MPPHY_PXSRAMCNT(n), MPPHY_PXTXREQ(n)) > + > +static const struct regmap_range mp_phy_writeable_range[] =3D { > + regmap_reg_range(MPPHY_FW_BASE, MPPHY_FW_BASE + 4 * MPPHY_FW_CH_OFFSET), > + regmap_reg_range(MPPHY_CMNCNT1, MPPHY_CMNCNT2), > + MPPHY_PX_WR_RANGE(0), MPPHY_PX_WR_RANGE(1), > + MPPHY_PX_WR_RANGE(2), MPPHY_PX_WR_RANGE(3), > + regmap_reg_range(MPPHY_PCS0REG1, MPPHY_PCS0REG1), > + regmap_reg_range(MPPHY_PCS0REG5, MPPHY_PCS0REG5), > + regmap_reg_range(TCA_OFFSET(0) + TCA_INTR_EN, TCA_OFFSET(0) + TCA_INTR_= EN), > + regmap_reg_range(TCA_OFFSET(0) + TCA_TCPC, TCA_OFFSET(0) + TCA_TCPC), > + regmap_reg_range(TCA_OFFSET(0) + TCA_PSTATE_1, TCA_OFFSET(0) + TCA_PSTA= TE_1), > + regmap_reg_range(TCA_OFFSET(1) + TCA_INTR_EN, TCA_OFFSET(1) + TCA_INTR_= EN), > + regmap_reg_range(TCA_OFFSET(1) + TCA_TCPC, TCA_OFFSET(1) + TCA_TCPC), > + regmap_reg_range(TCA_OFFSET(1) + TCA_PSTATE_1, TCA_OFFSET(1) + TCA_PSTA= TE_1), > +}; > + > +static const struct regmap_access_table mp_phy_writeable_table =3D { > + .yes_ranges =3D mp_phy_writeable_range, > + .n_yes_ranges =3D ARRAY_SIZE(mp_phy_writeable_range), > +}; > + > +#define MPPHY_PX_VL_RANGE(n) \ > + regmap_reg_range(MPPHY_PXRXREQ1(n), MPPHY_PXRXREQ1(n)), \ > + regmap_reg_range(MPPHY_PXSRAMCNT(n), MPPHY_PXTXREQ(n)) > + > +static const struct regmap_range mp_phy_volatile_range[] =3D { > + MPPHY_PX_VL_RANGE(0), MPPHY_PX_VL_RANGE(1), > + MPPHY_PX_VL_RANGE(2), MPPHY_PX_VL_RANGE(3), > + regmap_reg_range(TCA_OFFSET(0) + TCA_INTR_STS, TCA_OFFSET(0) + TCA_INTR= _STS), > + regmap_reg_range(TCA_OFFSET(1) + TCA_PSTATE_1, TCA_OFFSET(1) + TCA_PSTA= TE_1), > +}; > + > +static const struct regmap_access_table mp_phy_volatile_table =3D { > + .yes_ranges =3D mp_phy_volatile_range, > + .n_yes_ranges =3D ARRAY_SIZE(mp_phy_volatile_range), > +}; > + > +static const struct regmap_config mp_phy_regmap_config =3D { > + .fast_io =3D true, > + .reg_bits =3D 32, > + .val_bits =3D 32, > + .reg_stride =3D 4, > + .max_register =3D TCA_OFFSET(1) + TCA_PSTATE_1, > + .name =3D "mpphy", > + .rd_table =3D &mp_phy_readable_table, > + .wr_table =3D &mp_phy_writeable_table, > + .volatile_table =3D &mp_phy_volatile_table, > + .cache_type =3D REGCACHE_MAPLE, > +}; [Severity: High] Do the regmap access tables and REGCACHE_MAPLE configuration cause register accesses to fail with -EIO or return stale cached values? MPPHY_PX_RD_RANGE(n) and MPPHY_PX_WR_RANGE(n) omit MPPHY_PXCNTXT2(n) (+0x8), MPPHY_PXTEST(n) (+0xc), and MPPHY_CHAN_BASE(n) + 0x10c, so regmap_set_bits() and regmap_clear_bits() on MPPHY_PXCNTXT2(ch) in mp_phy_init_pcie4_ch_req() and MPPHY_PXTEST(i) in mp_phy_resume(), as well as regmap_write() to MPPHY_CHAN_BASE(i) + 0x10c, fail in regmap range checks with -EIO without touching hardware. mp_phy_writeable_range also omits TCA_OFFSET(0..1) + TCA_INTR_STS, so regmap_set_bits(priv->map, TCA_OFFSET(phy->id) + TCA_INTR_STS, 0x1503) in mp_phy_power_on() fails with -EIO and never clears the interrupt status (and clearing write-1-to-clear status bits needs regmap_write() or regmap_write_bits() rather than regmap_set_bits()). mp_phy_volatile_range omits TCA_OFFSET(0) + TCA_PSTATE_1 and TCA_OFFSET(1) + TCA_INTR_STS, so with REGCACHE_MAPLE enabled, mp_phy_reg_wait() on those registers reads the cached initial value on every poll iteration instead of re-reading hardware. Finally, when mp_phy_resume_early() and mp_phy_resume() pulse reset_core and reset_phy, the hardware registers are reset but REGCACHE_MAPLE is never invalidated, causing subsequent regmap_set_bits() and regmap_clear_bits() on non-volatile registers to compare against stale pre-reset cached values and skip writing to hardware. [ ... ] > +static int mp_phy_init_pcie4(struct phy *phy) > +{ > + struct mp_phy_priv *priv =3D phy_get_drvdata(phy); > + > + if (priv->num_lanes[phy->id] =3D=3D 2) { > + if (phy->id =3D=3D 0) { > + mp_phy_init_pcie4_ch_req(priv, 0, 0, 0x2020201, 0x80004); > + mp_phy_init_pcie4_ch_clk(priv, 0, 0); > + mp_phy_init_pcie4_ch_rst(priv, 0, 0); > + } else if (phy->id =3D=3D 1) { > + mp_phy_init_pcie4_ch_req(priv, 2, 2, 0x2020202, 0x8); > + mp_phy_init_pcie4_ch_clk(priv, 2, 2); > + mp_phy_init_pcie4_ch_rst(priv, 2, 2); > + } > + } else if (priv->num_lanes[phy->id] =3D=3D 4) { > + if (phy->id =3D=3D 0) { > + mp_phy_init_pcie4_ch_req(priv, 0, 1, 0x2020201, 0x80008); > + mp_phy_init_pcie4_ch_clk(priv, 0, 1); > + /* No reset pulse here. */ > + } else if (phy->id =3D=3D 1) { > + mp_phy_init_pcie4_ch_req(priv, 2, 3, 0x2020202, 0x8); > + mp_phy_init_pcie4_ch_clk(priv, 2, 3); > + mp_phy_init_pcie4_ch_rst(priv, 2, 3); > + } > + } else if (priv->num_lanes[phy->id] =3D=3D 8) { > + mp_phy_init_pcie4_ch_req(priv, 0, 0, 0x2020201, 0x8); > + mp_phy_init_pcie4_ch_req(priv, 1, 3, 0x2020202, 0x8); > + /* No clk settings here. */ > + mp_phy_init_pcie4_ch_rst(priv, 0, 3); > + } > + > + return 0; > +} [Severity: High] Does the PCIe code mix up the 4 MPPHY channel indices (0..3) with the 2 PCIe controller indices (0..1)? In mp_phy_parse_dt(), priv->chan[0..3] and priv->pd_list->pd_devs[0..3] are indexed by MPPHY channel, where PCIe.0 starts at channel 0 and PCIe.1 always starts at channel 2 (channel 1 is either the second half of PCIe.0 or ETH.1). However, priv->num_lanes[MPPHY_NUM_PCIE] has only 2 elements, and mp_phy_init_pcie4(), mp_phy_read_poll_pcie4(), and mp_phy_power_on_pcie4() index priv->num_lanes[phy->id], check phy->id =3D= =3D 1 for PCIe.1, and compute the channel as (2 * phy->id) + i. When PCIe.1 uses channel 2 (phy->id =3D=3D 2), priv->num_lanes[phy->id] rea= ds out of bounds past priv->num_lanes[], mp_phy_init_pcie4() does nothing because phy->id is neither 0 nor 1, mp_phy_power_on_pcie4() computes id =3D 4 + i and accesses priv->chan[id] out of bounds, and mp_phy_read_poll_pcie4() can evaluate uninitialized rx_ack and tx_ack. Conversely, if PCIe.1 uses phy->id =3D=3D 1, priv->chan[1].protocol_id is PHY_MODE_ETHERNET whenever channel 1 is ETH.1, and mp_phy_init() powers on mpp1 instead of mpp2/mpp3. In addition, for x4 (2-channel) and x8 (4-channel) PCIe links, mp_phy_init() and mp_phy_exit() only power on and off the single power domain pd_devs[phy->id], leaving the companion channels' power domains (mpp1..mpp3) off while their registers and SRAM are accessed. [ ... ] > +static int mp_phy_read_poll_pcie4(struct phy *phy) > +{ > + struct mp_phy_priv *priv =3D phy_get_drvdata(phy); > + u32 rx_ack, tx_ack; > + > + if (priv->num_lanes[phy->id] =3D=3D 2) { > + tx_ack =3D readl(priv->base + MPPHY_PXTXREQ(2 * phy->id)); > + rx_ack =3D readl(priv->base + MPPHY_PXRXREQ1(2 * phy->id)); > + } else if (priv->num_lanes[phy->id] =3D=3D 4) { > + tx_ack =3D readl(priv->base + MPPHY_PXTXREQ(2 * phy->id)) & > + readl(priv->base + MPPHY_PXTXREQ((2 * phy->id) + 1)); > + rx_ack =3D readl(priv->base + MPPHY_PXRXREQ1(2 * phy->id)) & > + readl(priv->base + MPPHY_PXRXREQ1((2 * phy->id) + 1)); > + } else if (priv->num_lanes[phy->id] =3D=3D 8) { > + tx_ack =3D readl(priv->base + MPPHY_PXTXREQ(0)) & > + readl(priv->base + MPPHY_PXTXREQ(1)) & > + readl(priv->base + MPPHY_PXTXREQ(2)) & > + readl(priv->base + MPPHY_PXTXREQ(3)); > + rx_ack =3D readl(priv->base + MPPHY_PXRXREQ1(0)) & > + readl(priv->base + MPPHY_PXRXREQ1(1)) & > + readl(priv->base + MPPHY_PXRXREQ1(2)) & > + readl(priv->base + MPPHY_PXRXREQ1(3)); > + } > + > + return !(tx_ack & BIT(9)) && !(rx_ack & BIT(1)); > +} [Severity: High] Should the 4-lane and 8-lane branches in mp_phy_read_poll_pcie4() combine the per-channel registers with bitwise OR (|) instead of bitwise AND (&)? Because the return check waits for BIT(9) and BIT(1) to clear to 0, ANDing the channels causes the poll to succeed as soon as any single channel clears those bits while the other channels are still busy. > +static int mp_phy_power_on_pcie4(struct phy *phy) > +{ > + struct mp_phy_priv *priv =3D phy_get_drvdata(phy); > + int i, id, ret; > + u32 status; > + > + if (priv->num_lanes[phy->id] =3D=3D 2 || priv->num_lanes[phy->id] =3D= =3D 4) { > + for (i =3D 0; i < priv->num_lanes[phy->id] / 2; i++) { > + id =3D (2 * phy->id) + i; > + ret =3D mp_phy_update_firmware_sram(priv->chan[id].phy); > + if (ret) > + return ret; > + } > + > + for (i =3D 0; i < priv->num_lanes[phy->id] / 2; i++) { > + id =3D (2 * phy->id) + i; > + ret =3D mp_phy_reg_wait(priv, MPPHY_PXSRAMCNT(id), > + SRAM_INIT_DONE, SRAM_INIT_DONE); > + if (ret) > + return ret; > + } > + > + for (i =3D 0; i < priv->num_lanes[phy->id] / 2; i++) { > + id =3D (2 * phy->id) + i; > + ret =3D mp_phy_reg_wait(priv, MPPHY_PXRXREQ1(id), 0x2, 0); > + if (ret) > + return ret; > + } > + } else if (priv->num_lanes[phy->id] =3D=3D 8) { > + for (i =3D 0; i < 4; i++) { > + ret =3D mp_phy_update_firmware_sram(priv->chan[phy->id].phy); > + if (ret) > + return ret; > + } [Severity: High] In the 8-lane branch, should this pass priv->chan[i].phy instead of priv->chan[phy->id].phy to mp_phy_update_firmware_sram()? Passing priv->chan[phy->id].phy loads firmware into channel 0 four times and leaves channels 1, 2, and 3 without firmware or SRAM_EXT_LD_DONE set. [ ... ] > +static int mp_phy_power_on(struct phy *phy) > +{ [ ... ] > + regmap_set_bits(priv->map, TCA_OFFSET(phy->id) + TCA_INTR_STS, 0x1503); > + regmap_set_bits(priv->map, TCA_OFFSET(phy->id) + TCA_TCPC, > + TCA_TCPC_VALID | > + FIELD_PREP(TCA_TCPC_MUX_CONTRL_USB_CONN, > + TCA_TCPC_MUX_CONTRL_USB_CONN)); [Severity: Low] Should the first argument to FIELD_PREP() be the field mask TCA_TCPC_MUX_CONTRL rather than the value TCA_TCPC_MUX_CONTRL_USB_CONN, and should this use regmap_update_bits() so bits [2:1] of TCA_TCPC_MUX_CONTRL are cleared if previously set? [ ... ] > +static int mp_phy_suspend(struct device *dev) > +{ > + struct mp_phy_priv *priv =3D dev_get_drvdata(dev); > + int i, ret; > + > + for (i =3D 0; i < MPPHY_NUM_CHANNELS; i++) > + priv->chan[i].initialized =3D false; [Severity: High] Does clearing priv->chan[i].initialized in mp_phy_suspend() leak the per-channel power domain runtime PM reference and break post-resume mp_phy_power_on()? mp_phy_init() acquires a runtime PM reference on priv->pd_list->pd_devs[phy->id], and mp_phy_exit() returns early without calling pm_runtime_put_sync() when !chan->initialized. Once mp_phy_suspend() clears chan->initialized, a later phy_exit() permanently leaks the pd_devs[phy->id] usage count; and if a consumer keeps the PHY initialized across suspend/resume (so phy->init_count remains non-zero in phy-core), subsequent phy_power_on() calls fail with -EINVAL because chan->initialized is false. [ ... ] > +static int mp_phy_resume_early(struct device *dev) > +{ > + struct mp_phy_priv *priv =3D dev_get_drvdata(dev); > + int ret; > + > + ret =3D clk_prepare_enable(priv->clk_core); > + if (ret) > + return dev_err_probe(dev, ret, "Failed to enable PHY core clock\n"); > + > + ret =3D reset_control_reset(priv->reset_core); > + if (ret) > + return dev_err_probe(dev, ret, "Failed to deassert PHY core reset\n"); > + > + return pm_runtime_force_resume(dev); > +} > + > +static int mp_phy_resume(struct device *dev) > +{ > + struct mp_phy_priv *priv =3D dev_get_drvdata(dev); > + int i, ret; > + > + ret =3D clk_bulk_prepare_enable(priv->num_clks, priv->clk_phy); > + if (ret) > + return dev_err_probe(dev, ret, "Failed to enable PHY clocks\n"); > + > + ret =3D reset_control_bulk_reset(ARRAY_SIZE(priv->reset_phy), priv->res= et_phy); > + if (ret) > + return dev_err_probe(dev, ret, "Failed to deassert PHY resets\n"); [Severity: Medium] Do mp_phy_resume_early() and mp_phy_resume() leak prepared and enabled clocks on error, and how are runtime PM errors handled in mp_phy_probe() and mp_phy_init()? In mp_phy_resume_early(), if reset_control_reset() or pm_runtime_force_resume() fails (and pm_runtime_force_resume() returns -ENXIO unconditionally when !CONFIG_PM_SLEEP), priv->clk_core is left prepared and enabled. Similarly, in mp_phy_resume(), if reset_control_bulk_reset() fails, priv->clk_phy is not disabled and unprepared. In addition, mp_phy_probe() checks if (ret) on pm_runtime_get_sync(dev), which treats a positive 1 return value as an error, and neither mp_phy_probe() nor mp_phy_init() calls pm_runtime_put_noidle() when pm_runtime_get_sync() returns a negative error, leaking the runtime PM usage count. [ ... ] > +static struct phy *mp_phy_xlate(struct device *dev, > + const struct of_phandle_args *args) > +{ > + struct mp_phy_priv *priv =3D dev_get_drvdata(dev); > + int id; > + > + if (args->args_count !=3D 2) { > + dev_err(dev, "Invalid args_count: %d\n", args->args_count); > + return ERR_PTR(-EINVAL); > + } > + > + id =3D args->args[0]; > + > + if (id > MPPHY_NUM_CHANNELS) { > + dev_err(dev, "Invalid channel ID: %d\n", id); > + return ERR_PTR(-EINVAL); > + } > + > + return priv->chan[id].phy; > +} [Severity: Medium] Can mp_phy_xlate() read priv->chan[id] out of bounds when id =3D=3D MPPHY_NUM_CHANNELS (4) or when id is negative? priv->chan has MPPHY_NUM_CHANNELS elements (valid indices 0..3), so the check should use an unsigned u32 id with id >=3D MPPHY_NUM_CHANNELS. [ ... ] > +static int mp_phy_request_fw(struct platform_device *pdev, struct mp_phy= _priv *priv) > +{ [ ... ] > + /* Firmware blob size must be even. */ > + if (priv->fw->size > MPPHY_FW_CH_OFFSET) { > + return dev_err_probe(dev, -EINVAL, "Firmware blob size %zu too large!\= n", > + priv->fw->size); > + } [Severity: Low] Can a firmware blob between 0x10000 and MPPHY_FW_CH_OFFSET (0x20000) bytes overflow channel 3's firmware area into the control registers? Channel 3's firmware region starts at MPPHY_FW_BASE + 3 * MPPHY_FW_CH_OFFSET (0x70000) and the common control registers begin at MPPHY_CMNCNT1 (0x80000), leaving 0x10000 bytes for channel 3. > +static int mp_phy_probe(struct platform_device *pdev) > +{ [ ... ] > + provider =3D devm_of_phy_provider_register(dev, mp_phy_xlate); > + if (IS_ERR(provider)) > + return dev_err_probe(dev, PTR_ERR(provider), > + "Failed to register PHY provider\n"); > + > + for (i =3D 0; i < MPPHY_NUM_CHANNELS; i++) { > + priv->chan[i].phy =3D devm_phy_create(dev, NULL, &mp_phy_ops); > + if (IS_ERR(priv->chan[i].phy)) { > + return dev_err_probe(dev, PTR_ERR(priv->chan[i].phy), > + "Failed to create PHY %d\n", i); > + } > + > + priv->chan[i].phy->id =3D i; > + phy_set_drvdata(priv->chan[i].phy, priv); > + } [Severity: High] Does calling devm_of_phy_provider_register() before devm_phy_create() and before enabling clocks, resets, and runtime PM expose uninitialized PHYs to concurrent consumers? Because mp_phy_driver uses PROBE_PREFER_ASYNCHRONOUS, a consumer calling of_phy_get() after devm_of_phy_provider_register() but before devm_phy_create() receives NULL from mp_phy_xlate(), which of_phy_get() dereferences at phy->ops->owner; if the consumer calls phy_init() before mp_phy_resume_early() and pm_runtime_get_sync() complete below, it accesses registers while clocks are off and resets are asserted. Also, because devm_phy_create() runs before runtime PM is enabled on dev, phy_create() sees pm_runtime_enabled(dev) =3D=3D false and skips enabling runtime PM on &phy->dev, and devres teardown will destroy the PHYs before unregistering the PHY provider. [Severity: Medium] Does overwriting priv->chan[i].phy->id =3D i corrupt phy_ida in the PHY core? phy_create() allocates phy->id from phy_ida and phy_release() frees it with ida_free(&phy_ida, phy->id), so overwriting phy->id with 0..3 leaks the allocated IDA IDs and frees IDs 0..3 belonging to other PHYs on probe failure or driver unbind. > + > + ret =3D mp_phy_resume_early(dev); > + if (ret) > + return dev_err_probe(dev, ret, "Failed to resume PHY\n"); > + > + ret =3D pm_runtime_get_sync(dev); > + if (ret) { > + dev_err_probe(dev, ret, "Failed to get runtime PM\n"); > + goto err_resume; > + } > + > + return 0; > + > +err_resume: > + mp_phy_suspend_late(dev); > + return ret; > +} [Severity: Medium] Are the clocks, resets, and runtime PM state enabled in mp_phy_probe() ever cleaned up when the driver is unbound? mp_phy_driver has no .remove callback and registers no devm action to balance pm_runtime_get_sync() and mp_phy_resume_early(), leaving runtime PM active, resets deasserted, and priv->clk_phy and priv->clk_core prepared and enabled on unbind. > + > +static const struct dev_pm_ops mp_phy_pm_ops =3D { > + SET_RUNTIME_PM_OPS(mp_phy_suspend, mp_phy_resume, NULL) > + SET_LATE_SYSTEM_SLEEP_PM_OPS(mp_phy_suspend_late, mp_phy_resume_early) > +}; > + > +static const struct of_device_id mp_phy_of_match[] =3D { > + { .compatible =3D "renesas,rcar-gen5-mpphy" }, > + { /* sentinel */ } > +}; > +MODULE_DEVICE_TABLE(of, mp_phy_of_match); > + > +static struct platform_driver mp_phy_driver =3D { > + .probe =3D mp_phy_probe, > + .driver =3D { > + .name =3D "renesas-mpphy", > + .of_match_table =3D mp_phy_of_match, > + .pm =3D &mp_phy_pm_ops, > + .probe_type =3D PROBE_PREFER_ASYNCHRONOUS, > + }, > +}; [Severity: Low] When CONFIG_PM is disabled (for example under COMPILE_TEST), SET_RUNTIME_PM_OPS() compiles out and leaves mp_phy_suspend() and mp_phy_resume() unused, triggering -Wunused-function warnings. Using RUNTIME_PM_OPS(), LATE_SYSTEM_SLEEP_PM_OPS(), and .pm =3D pm_ptr(&mp_phy_pm_ops) avoids this. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261129173739.2820= 27-1-marek.vasut+renesas@mailbox.org?part=3D2