Linux-PHY Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Navid Ghahremani" <ghahramani.navid@gmail.com>
Cc: linux-phy@lists.infradead.org, vkoul@kernel.org,
	neil.armstrong@linaro.org, olteanv@gmail.com
Subject: Re: [PATCH v2 11/24] phy: zte: Add ZTE ZX279128S PCIe PHY driver
Date: Thu, 15 Oct 2026 07:24:40 +0000	[thread overview]
Message-ID: <sashiko-outbox-172405@kernel.org> (raw)
In-Reply-To: <20261014072109.1759502-12-ghahramani.navid@gmail.com>

Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [Medium] phy: missing error path cleanup in zx_pcie_phy_init()
- [Low] phy: incomplete hardware teardown on error in zx_pcie_phy_exit()
- [Low] kconfig: PHY_ZX279128S_PCIE selects MFD_SYSCON without HAS_IOMEM
--

commit 9afe9a48cb2bc29d0bfd7f5b0a437a5d1621c1b4
Author: Navid Ghahremani <ghahramani.navid@gmail.com>

phy: zte: Add ZTE ZX279128S PCIe PHY driver

Add a generic PHY driver for the PCIe SerDes PHY inside the Top CRM
block of the ZTE ZX279128S SoC. This driver encapsulates PLL power
and analog SerDes calibration for the two PCIe ports.

> diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
> index 19f3b7d12b7d4..3518d384be854 100644
> --- a/drivers/phy/Kconfig
> +++ b/drivers/phy/Kconfig
[ ... ]
> @@ -91,6 +91,18 @@ config PHY_ECONET_PCIE
>  	  callback for PCIe GEN1 and GEN2 ports. This PHY is found on
>  	  EcoNet SoCs including EN751221 and EN7528.
>  
> +config PHY_ZX279128S_PCIE
> +	tristate "ZTE ZX279128S PCIe PHY driver"
> +	depends on ARCH_ZTE || COMPILE_TEST
> +	depends on OF
> +	select GENERIC_PHY
> +	select MFD_SYSCON

[Severity: Low]
Does selecting MFD_SYSCON here without a HAS_IOMEM dependency cause an unmet
direct dependency warning? Because this driver supports COMPILE_TEST, it could
be built on architectures without HAS_IOMEM (like UML), where MFD_SYSCON
cannot be naturally enabled.

> +	help
> +	  Enable support for the PCIe SerDes PHY found inside the Top CRM
> +	  of ZTE ZX279128S SoCs. This driver configures PLL power and analog
[ ... ]
> diff --git a/drivers/phy/phy-zx279128s-pcie.c b/drivers/phy/phy-zx279128s-pcie.c
> new file mode 100644
> index 0000000000000..33bf0eaac8f74
> --- /dev/null
> +++ b/drivers/phy/phy-zx279128s-pcie.c
[ ... ]
> +static int zx_pcie_phy_init(struct phy *phy)
> +{
> +	struct zx_pcie_phy *zphy = phy_get_drvdata(phy);
> +	const struct zx_pcie_phy_port *port = zphy->port;
> +	int i, ret;
> +
> +	for (i = 0; i < ARRAY_SIZE(port->phy_on); i++) {
> +		ret = regmap_write_bits(zphy->regmap, CRM1_PHY_CTRL,
> +					port->phy_on[i], port->phy_on[i]);
> +		if (ret)
> +			return ret;

[Severity: Medium]
Can this leave the PHY blocks in an inconsistent state? If regmap_write_bits()
fails on a later iteration (for example, when i > 0), this loop returns
immediately and leaves the hardware resources from previous iterations powered
on.

Since the PHY framework's phy_init() does not invoke the phy_exit() callback
if initialization fails, the driver likely needs to manually unwind the power
bits before returning the error.

> +		fsleep(50);
> +
> +		if (i == 0 && port->has_cal) {
> +			ret = regmap_write(zphy->regmap, CRM1_PHY1_CAL1, 0x00202d5a);
> +			if (ret)
> +				return ret;

[Severity: Medium]
Similarly, if either of these calibration writes fail, we return without
clearing the CRM1_PHY_CTRL bits that were already successfully set. Should
there be an error path here that unwinds the state?

> +			ret = regmap_write(zphy->regmap, CRM1_PHY1_CAL0, 0x0046c24a);
> +			if (ret)
> +				return ret;
> +		}
> +	}
[ ... ]
> +static int zx_pcie_phy_exit(struct phy *phy)
> +{
> +	struct zx_pcie_phy *zphy = phy_get_drvdata(phy);
> +	const struct zx_pcie_phy_port *port = zphy->port;
> +	int i, ret;
> +
> +	for (i = ARRAY_SIZE(port->phy_on) - 1; i >= 0; i--) {
> +		ret = regmap_write_bits(zphy->regmap, CRM1_PHY_CTRL,
> +					port->phy_on[i], 0);
> +		if (ret)
> +			return ret;

[Severity: Low]
Does this early return leave the hardware partially active on teardown? If
regmap_write_bits() fails while clearing one of the bits, we abort the loop
early.

It might be safer to record the error but continue unwinding the remaining
bits to ensure the fullest possible teardown.

> +	}
> +
> +	return 0;
> +}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261014072109.1759502-1-ghahramani.navid@gmail.com?part=11

-- 
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy

      reply	other threads:[~2026-10-15  7:24 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20261014072109.1759502-1-ghahramani.navid@gmail.com>
2026-10-14  7:20 ` [PATCH v2 10/24] dt-bindings: phy: Add ZTE ZX279128S PCIe PHY binding Navid Ghahremani
2026-10-15  7:24   ` sashiko-bot
2026-10-15  9:29   ` Krzysztof Kozlowski
2026-10-14  7:20 ` [PATCH v2 11/24] phy: zte: Add ZTE ZX279128S PCIe PHY driver Navid Ghahremani
2026-10-15  7:24   ` 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=sashiko-outbox-172405@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=ghahramani.navid@gmail.com \
    --cc=linux-phy@lists.infradead.org \
    --cc=neil.armstrong@linaro.org \
    --cc=olteanv@gmail.com \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=vkoul@kernel.org \
    /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