Linux-PHY Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Vladimir Oltean <vladimir.oltean@nxp.com>
To: sashiko-reviews@lists.linux.dev
Cc: conor+dt@kernel.org, devicetree@vger.kernel.org,
	vkoul@kernel.org, neil.armstrong@linaro.org,
	linux-phy@lists.infradead.org, robh@kernel.org,
	olteanv@gmail.com
Subject: Re: [PATCH v2 phy-next 14/15] phy: lynx-10g: new driver
Date: Wed, 3 Jun 2026 14:53:54 +0300	[thread overview]
Message-ID: <20260603115354.l356gejs6ysqf4s2@skbuf> (raw)
In-Reply-To: <20260529182118.007AC1F00893@smtp.kernel.org>

On Fri, May 29, 2026 at 06:21:17PM +0000, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
> 
> New issues:
> - [High] Incorrect restoration of the PCCR mux configuration because `0` is treated as uninitialized.
> - [High] Potential timing violation when bringing lanes out of reset and power down simultaneously.
> 
> Pre-existing issues:
> - [High] lynx_xlate can return a NULL pointer for unprobed PHY lanes, leading to a NULL pointer dereference in the PHY core framework.
> --
> 
> commit 851e6824db7b03958722b9808f3549609168de99
> 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.
> 
> > diff --git a/drivers/phy/freescale/phy-fsl-lynx-10g.c b/drivers/phy/freescale/phy-fsl-lynx-10g.c
> > index 0000000000000..9b04d6a4b825a
> > --- /dev/null
> > +++ b/drivers/phy/freescale/phy-fsl-lynx-10g.c
> [ ... ]
> > +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);
> [ ... ]
> > +	if (lane->default_pccr[mode]) {
> [Severity: High]
> Can this condition incorrectly fall through to hardcoded defaults if a valid
> mux configuration of 0 is backed up?
> 
> Since default_pccr is zero-initialized by devm_kcalloc(), a backed-up value
> of 0 evaluates to false. This skips the restoration and allows the driver to
> apply hardcoded defaults later, which could permanently reroute the hardware
> lanes and break the network interface.

No it cannot. default_pccr[mode] == 0 is not a valid mux configuration,
it universally means the protocol converter is disabled.

> > +		err = lynx_pccr_write(lane, mode, lane->default_pccr[mode]);
> > +		goto out;
> > +	}
> > +
> > +	val = 0;
> [ ... ]
> > +static int lynx_10g_power_on(struct phy *phy)
> > +{
> > +	struct lynx_lane *lane = phy_get_drvdata(phy);
> > +
> > +	if (lane->powered_up)
> > +		return 0;
> > +
> > +	/* The RM says to wait for at least 120ns between per lane setting have
> > +	 * been changed and the lane being taken out of reset
> > +	 */
> > +	usleep_range(1, 2);
> > +
> > +	lynx_lane_rmw(lane, LNaGCR0, LNaGCR0_RRST_OFF | LNaGCR0_TRST_OFF,
> > +		      LNaGCR0_RRST | LNaGCR0_TRST |
> > +		      LNaGCR0_RX_PD | LNaGCR0_TX_PD);
> [Severity: High]
> Does this code violate typical PHY hardware sequencing by clearing both the
> power-down bits and digital reset bits simultaneously?
> 
> Releasing the digital reset at the same time as activating the analog
> components doesn't leave time for the analog circuitry to stabilize. The
> prior usleep_range() occurs before power-up is initiated, which might not
> prevent hardware lockups or unreliable behavior on link up.

This is actually a great comment. Re-reading the hardware documentation,
the power up sequence is indeed messed up. Will fix for v3.

> > +
> > +	lane->powered_up = true;
> > +
> > +	return 0;
> > +}
> [ ... ]
> > +static int lynx_10g_probe(struct platform_device *pdev)
> > +{
> > +	return lynx_probe(pdev, of_device_get_match_data(&pdev->dev),
> > +			  &lynx_10g_ops);
> > +}
> [Severity: High]
> This is a pre-existing issue, but does the core PHY framework crash if
> lynx_xlate() returns a NULL pointer for an unprobed PHY lane?
> 
> If a PHY lane is requested via device tree but the driver did not probe it,
> priv->lane[idx].phy will be NULL. If lynx_xlate() returns this NULL pointer,
> the core PHY framework interprets it as a successful retrieval of an optional
> PHY and might attempt to dereference it. Would it be safer to explicitly
> return ERR_PTR(-ENODEV) in lynx_xlate() when the phy pointer is NULL?

Will fix in v3.

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

  reply	other threads:[~2026-06-03 11:54 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-29 17:14 [PATCH v2 phy-next 00/15] New Generic PHY driver for Lynx 10G SerDes Vladimir Oltean
2026-05-29 17:14 ` [PATCH v2 phy-next 01/15] phy: lynx-28g: reject probing on devices with unsupported OF nodes Vladimir Oltean
2026-05-29 17:35   ` sashiko-bot
2026-06-02 14:52     ` Vladimir Oltean
2026-05-29 17:14 ` [PATCH v2 phy-next 02/15] phy: lynx-28g: move lane mode helpers to new core module Vladimir Oltean
2026-05-29 17:27   ` sashiko-bot
2026-06-02 14:38     ` Vladimir Oltean
2026-05-29 17:14 ` [PATCH v2 phy-next 03/15] phy: lynx-28g: move data structures to core Vladimir Oltean
2026-05-29 17:14 ` [PATCH v2 phy-next 04/15] phy: lynx-28g: common lynx_pll_get() Vladimir Oltean
2026-05-29 17:14 ` [PATCH v2 phy-next 05/15] phy: lynx-28g: generalize protocol converter accessors Vladimir Oltean
2026-05-29 17:15 ` [PATCH v2 phy-next 06/15] phy: lynx-28g: provide default lynx_lane_supports_mode() implementation Vladimir Oltean
2026-05-29 17:15 ` [PATCH v2 phy-next 07/15] phy: lynx-28g: move struct lynx_info definitions downwards Vladimir Oltean
2026-05-29 17:15 ` [PATCH v2 phy-next 08/15] phy: lynx-28g: make lynx_28g_pll_read_configuration() callable per PLL Vladimir Oltean
2026-05-29 17:15 ` [PATCH v2 phy-next 09/15] phy: lynx-28g: common probe() and remove() Vladimir Oltean
2026-05-29 17:15 ` [PATCH v2 phy-next 10/15] phy: lynx-28g: add support for big endian register maps Vladimir Oltean
2026-05-29 17:15 ` [PATCH v2 phy-next 11/15] phy: lynx-28g: optimize read-modify-write operation Vladimir Oltean
2026-05-29 17:15 ` [PATCH v2 phy-next 12/15] phy: lynx-28g: improve phy_validate() procedure Vladimir Oltean
2026-05-29 17:15 ` [PATCH v2 phy-next 13/15] dt-bindings: phy: lynx-10g: initial document Vladimir Oltean
2026-06-01  6:34   ` Alexander Stein
2026-06-02  9:03     ` Vladimir Oltean
2026-06-03  6:14       ` Alexander Stein
2026-06-02 17:10   ` Conor Dooley
2026-06-03 11:56     ` Vladimir Oltean
2026-06-03 15:09       ` Conor Dooley
2026-06-03 15:39         ` Vladimir Oltean
2026-05-29 17:15 ` [PATCH v2 phy-next 14/15] phy: lynx-10g: new driver Vladimir Oltean
2026-05-29 18:21   ` sashiko-bot
2026-06-03 11:53     ` Vladimir Oltean [this message]
2026-05-29 17:15 ` [PATCH v2 phy-next 15/15] 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=20260603115354.l356gejs6ysqf4s2@skbuf \
    --to=vladimir.oltean@nxp.com \
    --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 \
    /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