Linux-PHY Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Vladimir Oltean" <vladimir.oltean@nxp.com>
Cc: vkoul@kernel.org, neil.armstrong@linaro.org, conor+dt@kernel.org,
	robh@kernel.org, olteanv@gmail.com,
	linux-phy@lists.infradead.org, devicetree@vger.kernel.org
Subject: Re: [PATCH v4 phy-next 15/16] phy: lynx-10g: new driver
Date: Mon, 08 Jun 2026 22:33:31 +0000	[thread overview]
Message-ID: <20260608223331.B4C631F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260608221710.1572971-16-vladimir.oltean@nxp.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] The driver incorrectly uses 0 as a sentinel value in `lane->default_pccr[mode]`, treating a valid backed-up PCCR configuration of 0 as uninitialized data and unintentionally falling back to a hardcoded PCS muxing configuration.
--

commit 0fcab57e2d19361e4720b40d6690e12c5a5bfd0b
Author: Vladimir Oltean <vladimir.oltean@nxp.com>

phy: lynx-10g: new driver

Introduce a driver for the networking lanes of the 10G Lynx SerDes
block, present on the majority of Layerscape and QorIQ (Freescale/NXP)
SoCs. It provides the generic PHY framework to allow network MACs to
reconfigure the SerDes for different link modes based on connected modules.

> diff --git a/drivers/phy/freescale/phy-fsl-lynx-10g.c b/drivers/phy/freescale/phy-fsl-lynx-10g.c
> new file mode 100644
> index 0000000000000..7dd5d94b51cf2
> --- /dev/null
> +++ b/drivers/phy/freescale/phy-fsl-lynx-10g.c
> @@ -0,0 +1,1278 @@
[ ... ]
> +static void lynx_10g_backup_pccr_val(struct lynx_lane *lane)
> +{
> +	u32 val;
> +	int err;
> +
> +	if (lane->mode == LANE_MODE_UNKNOWN)
> +		return;
> +
> +	err = lynx_pccr_read(lane, lane->mode, &val);
> +	if (err) {
> +		dev_warn(&lane->phy->dev,
> +			 "The driver doesn't know how to access the PCCR for lane mode %s\n",
> +			 lynx_lane_mode_str(lane->mode));
> +		lane->mode = LANE_MODE_UNKNOWN;
> +		return;
> +	}
> +
> +	lane->default_pccr[lane->mode] = val;
> +
> +	switch (lane->mode) {
> +	case LANE_MODE_1000BASEX_SGMII:
> +	case LANE_MODE_2500BASEX:
> +		lane->default_pccr[LANE_MODE_1000BASEX_SGMII] = val & ~PCCR8_SGMIIa_KX;
> +		lane->default_pccr[LANE_MODE_2500BASEX] = val & ~PCCR8_SGMIIa_KX;
> +		break;
> +	default:
> +		break;
> +	}
> +}

[Severity: High]
Since the PCCR8_SGMIIa_KX bit is explicitly cleared here, could this result in
a backed-up value of exactly 0 if no other configuration bits were originally
set?

[ ... ]
> +static int lynx_10g_lane_enable_pcvt(struct lynx_lane *lane,
> +				     enum lynx_lane_mode mode)
> +{
> +	struct lynx_priv *priv = lane->priv;
> +	u32 val;
> +	int err;
> +
> +	spin_lock(&priv->pcc_lock);
> +
> +	switch (mode) {
> +	case LANE_MODE_1000BASEX_SGMII:
> +	case LANE_MODE_2500BASEX:
> +		err = lynx_pcvt_rmw(lane, mode, CR(1), SGMIIaCR1_SGPCS_EN,
> +				    SGMIIaCR1_SGPCS_EN);
> +		if (err)
> +			goto out;
> +
> +		lynx_pcvt_rmw(lane, mode, CR(0), SGMIIaCR0_RST_SGM_OFF,
> +			      SGMIIaCR0_RST_SGM | SGMIIaCR0_PD_SGM);
> +		break;
> +	case LANE_MODE_QSGMII:
> +		err = lynx_pcvt_rmw(lane, mode, CR(0), QSGMIIaCR0_RST_QSGM_OFF,
> +				    QSGMIIaCR0_RST_QSGM | QSGMIIaCR0_PD_QSGM);
> +		if (err)
> +			goto out;
> +		break;
> +	default:
> +		err = 0;
> +	}
> +
> +	if (lane->default_pccr[mode]) {
> +		err = lynx_pccr_write(lane, mode, lane->default_pccr[mode]);
> +		goto out;
> +	}

[Severity: High]
If the valid backed-up PCCR configuration is 0, will this condition evaluate
to false and skip the restoration?

It seems a configuration value of 0 is a valid state for the PCCR register,
but this check relies on 0 as a sentinel value for uninitialized data. Could
this inadvertently cause the driver to apply the hardcoded default values
below, breaking the initial muxing configured by the RCW?

> +
> +	val = 0;
> +
> +	switch (mode) {
> +	case LANE_MODE_1000BASEX_SGMII:
> +	case LANE_MODE_2500BASEX:
> +		val |= PCCR8_SGMIIa_CFG;
> +		break;

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260608221710.1572971-1-vladimir.oltean@nxp.com?part=15

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

  reply	other threads:[~2026-06-08 22:33 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-08 22:16 [PATCH v4 phy-next 00/16] New Generic PHY driver for Lynx 10G SerDes Vladimir Oltean
2026-06-08 22:16 ` [PATCH v4 phy-next 01/16] phy: lynx-28g: avoid returning NULL in of_xlate() function Vladimir Oltean
2026-06-08 22:26   ` sashiko-bot
2026-06-08 22:16 ` [PATCH v4 phy-next 02/16] phy: lynx-28g: reject probing on devices with unsupported OF nodes Vladimir Oltean
2026-06-08 22:16 ` [PATCH v4 phy-next 03/16] phy: lynx-28g: move lane mode helpers to new core module Vladimir Oltean
2026-06-08 22:24   ` sashiko-bot
2026-06-08 22:16 ` [PATCH v4 phy-next 04/16] phy: lynx-28g: move data structures to core Vladimir Oltean
2026-06-08 22:16 ` [PATCH v4 phy-next 05/16] phy: lynx-28g: common lynx_pll_get() Vladimir Oltean
2026-06-08 22:17 ` [PATCH v4 phy-next 06/16] phy: lynx-28g: generalize protocol converter accessors Vladimir Oltean
2026-06-08 22:17 ` [PATCH v4 phy-next 07/16] phy: lynx-28g: provide default lynx_lane_supports_mode() implementation Vladimir Oltean
2026-06-08 22:17 ` [PATCH v4 phy-next 08/16] phy: lynx-28g: move struct lynx_info definitions downwards Vladimir Oltean
2026-06-08 22:17 ` [PATCH v4 phy-next 09/16] phy: lynx-28g: make lynx_28g_pll_read_configuration() callable per PLL Vladimir Oltean
2026-06-08 22:17 ` [PATCH v4 phy-next 10/16] phy: lynx-28g: common probe() and remove() Vladimir Oltean
2026-06-08 22:17 ` [PATCH v4 phy-next 11/16] phy: lynx-28g: add support for big endian register maps Vladimir Oltean
2026-06-08 22:17 ` [PATCH v4 phy-next 12/16] phy: lynx-28g: optimize read-modify-write operation Vladimir Oltean
2026-06-08 22:17 ` [PATCH v4 phy-next 13/16] phy: lynx-28g: improve phy_validate() procedure Vladimir Oltean
2026-06-08 22:17 ` [PATCH v4 phy-next 14/16] dt-bindings: phy: lynx-10g: initial document Vladimir Oltean
2026-06-08 22:27   ` sashiko-bot
2026-06-08 22:17 ` [PATCH v4 phy-next 15/16] phy: lynx-10g: new driver Vladimir Oltean
2026-06-08 22:33   ` sashiko-bot [this message]
2026-06-08 22:17 ` [PATCH v4 phy-next 16/16] MAINTAINERS: expand Lynx 28G entry to cover Lynx 10G SerDes Vladimir Oltean

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=20260608223331.B4C631F00893@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-phy@lists.infradead.org \
    --cc=neil.armstrong@linaro.org \
    --cc=olteanv@gmail.com \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=vkoul@kernel.org \
    --cc=vladimir.oltean@nxp.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