Netdev List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: kyle.switch@motor-comm.com
Cc: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com,
	kuba@kernel.org, pabeni@redhat.com, robh@kernel.org,
	krzk+dt@kernel.org, conor+dt@kernel.org, andrew@lunn.ch,
	hkallweit1@gmail.com, linux@armlinux.org.uk,
	Frank.Sae@motor-comm.com, netdev@vger.kernel.org,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	ming.xu@motor-comm.com, xiaolin.xu@motor-comm.com,
	jianmin.wang@motor-comm.com
Subject: Re: [PATCH net-next V29 3/3] net: phy: Add driver for Motorcomm Quad 2.5GbE phy
Date: Fri, 04 Dec 2026 03:46:56 +0000	[thread overview]
Message-ID: <179635601653.3146.8403231642790506920@kernel.org> (raw)
In-Reply-To: <20261201094405.3036391-4-kyle.switch@motor-comm.com>

Thank you for your contribution! Sashiko AI review found 6 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 2 · Low: 4

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [Medium] The split between per-port and shared registers in the YT8824
  UTP init code contradicts the patch's own documented layout.
- [Medium] The package-wide one-shot flags `priv->sds_initialized` and
  `priv->utp_shared_initialized[]` are cleared only in…
- [Low] The commit message is one sentence for about 2100 added lines.
- [Low] The comment on struct yt8824_shared_priv::utp_shared_initialized
  describes its elements as 'utp_top_ext_init_done[0]: UTP0/UTP1 shared'…
- [Low] yt8824_sds_isolate_and_softreset_paged() and
  yt8824_extern_sds_softreset() take the bus-wide mdio_lock in…
- [Low] The external SerDes init sequence in
  yt8824_extern_config_sds_init_paged() has reset and calibration steps…

--

net: phy: Add driver for Motorcomm Quad 2.5GbE phy

This adds support for the Motorcomm YT8824 quad-port 2.5G PHY to the
existing motorcomm driver. Shared top-extended registers are accessed
through the phy_package helpers. A package-wide mutex serializes the
per-port UTP/SERDES space switching, and a DT property selects one of
two package modes (internal and 10G-QXGMII).

> Add support for Motorcomm YT8824 quad-port 2.5G PHY to the existing
> motorcomm driver, using the phy_package helpers for the shared top
> extended register space.

[Severity: Low]
This isn't a bug, but the commit message is one sentence for roughly
2100 added lines. Could it describe a few design points that are hard
to see from the diff?

A new vendor DT property, motorcomm,package-mode, selects one of two
package modes. In the internal (switch-embedded) mode the ports are
assumed to be at MDIO addresses 4..7. The other mode is standalone
10G-QXGMII.

The UTP/SERDES register space select bit is package-global.
yt8824_read_page() and yt8824_write_page() go through
__phy_package_read() and __phy_package_write() at offset 0. A
phy_select_page() on one port therefore switches the space for all four
ports, which is why the private shared_lock exists.

yt8824_phy_package_probe_once() returns -EINVAL when the package node
lacks motorcomm,package-mode. Probing therefore depends on a DT binding
that the commit message doesn't mention.

> diff --git a/drivers/net/phy/motorcomm.c b/drivers/net/phy/motorcomm.c
> index a87e83fdf590c..56f644388b0de 100644
> --- a/drivers/net/phy/motorcomm.c
> +++ b/drivers/net/phy/motorcomm.c

[ ... ]

> @@ -415,6 +657,34 @@ struct yt8521_priv {
>  	u8 reg_page;
>  };
>  
> +struct yt8824_shared_priv {

[ ... ]

> +	/*
> +	 * UTP top ext register space starts at 0xa000. Adjacent UTP pairs share
> +	 * one instance (UTP0/UTP1, UTP2/UTP3), so shared registers are
> +	 * configured only once per group; this flag tracks whether the group's
> +	 * shared registers have been initialized.
> +	 * utp_top_ext_init_done[0]: UTP0/UTP1 shared.
> +	 * utp_top_ext_init_done[1]: UTP2/UTP3 shared.
> +	 */
> +	bool utp_shared_initialized[2];

[Severity: Low]
This isn't a bug, but the comment refers to utp_top_ext_init_done[],
which doesn't exist. The field is utp_shared_initialized[].

The UTP0/UTP1 and UTP2/UTP3 mapping is also only right for the external
mode. In internal mode yt8824_utp_shared_group() uses base = 4, so the
groups are UTP4/UTP5 and UTP6/UTP7.

[ ... ]

> @@ -649,2595 +983,4350 @@ static int ytphy_set_wol(struct phy_device *phydev, struct ethtool_wolinfo *wol)

[ ... ]

> +static int yt8824_sds_isolate_and_softreset_paged(struct phy_device *phydev)
> +{

[ ... ]

> +	old_page = phy_select_page(phydev, YT8824_RSSR_SERDES_SPACE);
> +	if (old_page < 0)
>  		goto err_restore_page;
>  

[ ... ]

> +	/* For operations on the SerDes address space, the lock must be held
> +	 * throughout the entire process to prevent other PHY operations from
> +	 * mistakenly switching the address space to UTP, since the four PHYs
> +	 * share the bit that switches the address space.
> +	 */
> +	ret = read_poll_timeout(__phy_read, val,
> +				(val < 0) || !(val & BMCR_RESET), 50000, 600000,
> +				true, phydev, MII_BMCR);

[Severity: Low]
phy_select_page() takes the bus-wide mdio_lock, and it is held until
phy_restore_page(). With sleep_before_read set to true and a 50 ms sleep
interval, doesn't each call keep the whole MDIO bus locked for at least
50 ms, and up to 600 ms?

yt8824_extern_sds_softreset() has the same poll. These helpers run per
port from yt8824_soft_reset(), yt8824_config_init(), yt8824_suspend(),
yt8824_resume() and the yt8824_restore_working_status() error path.

In external mode a single phy_init_hw() runs soft_reset, then
config_init (extern_sds_softreset plus another soft_reset). That is at
least about 150 ms of bus lockout per port, or around 600 ms for the
package. Other PHYs or switches on the same bus stall during that time.

yt8521_modify_bmcr_paged() polls every 1 ms and stops as soon as
BMCR_RESET clears. Could a shorter sleep interval, or sleep_before_read
set to false, be used here?

[ ... ]

> +/**
> + * yt8824_config_utp_top_ext_init_paged() - config phy8824 shared UTP top ext
> + * @phydev: target phy_device struct
> + *
> + * Programs the UTP top extended register space shared by adjacent UTP
> + * pairs (UTP0/UTP1, UTP2/UTP3): write protection, PLL calibration,
> + * P0/P1 DAC bias, P01 PLL enable, U0/U1 CSR TX resets and odd-preamble
> + * enable. Runs once per shared group, guarded by
> + * priv->utp_shared_initialized[grp].
> + *
> + * Per-UTP private registers live in yt8824_config_utp_init_paged().
> + *
> + * Returns: 0 or negative errno code
> + */
> +static int yt8824_config_utp_top_ext_init_paged(struct phy_device *phydev)
>  {

[ ... ]

> +	if (priv->utp_shared_initialized[grp])
>  		return 0;

[ ... ]

> +	/* write protecting */
> +	mask = YT8824_WRITE_PROTECT;
> +	ctrl = YT8824_WRITE_PROTECT;
> +	ret = ytphy_modify_ext_with_lock(phydev,
> +					 YT8824_WRITE_PROTECT_CAL_REG,
> +					 mask, ctrl);

[ ... ]

> +/**
> + * yt8824_config_utp_init_paged() - config phy8824 utp init
> + * @phydev: target phy_device struct
> + *
> + * UTP ext register space starts at 0x0 and is private to each UTP.
> + * UTP top ext register space starts at 0xa000 and is shared by
> + * adjacent UTP pairs: UTP0/UTP1 share one address space, and
> + * UTP2/UTP3 share another.
> + *
> + * For shared registers, this function configures them according to the
> + * UTP index so that configuring a common register does not inadvertently
> + * affect the other ports sharing the same address space.
> + *
> + * Returns: 0 or negative errno code
> + */
> +static int yt8824_config_utp_init_paged(struct phy_device *phydev)

[ ... ]

> +	/* enable nibble */
> +	ctrl = FIELD_PREP(YT8824_U0_U1_ENABLE_ODD_PREAMBLE, 3);
> +	mask = YT8824_U0_U1_ENABLE_ODD_PREAMBLE;
> +	ret = ytphy_modify_ext_with_lock(phydev,
> +					 YT8824_IF_CTRL_REG,
> +					 mask, ctrl);

[Severity: Medium]
The kernel-doc of yt8824_config_utp_init_paged() says the ext space from
0x0 is private to each UTP, and the space from 0xa000 is shared by a UTP
pair. The code doesn't seem to follow that split.

yt8824_config_utp_top_ext_init_paged() runs only once per pair because
of the utp_shared_initialized[grp] check. Its first write goes to
YT8824_WRITE_PROTECT_CAL_REG (0x1), which is in the private range. That
write goes to the calling port's own MDIO address.

Does the second UTP of each pair ever get YT8824_WRITE_PROTECT set?

yt8824_config_utp_init_paged() runs on every port. It writes the shared
YT8824_IF_CTRL_REG (0xa003) with a fixed value covering both U0 and U1.
Its kernel-doc says shared registers are configured according to the
UTP index, but nothing in the function looks at phydev->mdio.addr or the
group.

The kernel-doc of yt8824_config_utp_top_ext_init_paged() also lists
odd-preamble enable, but its body never writes 0xa003. It does write
YT8824_DAC_CFG_REG (0xa2fa), which the doc doesn't mention.

Should 0x1 be written per port and 0xa003 moved into the once-per-pair
function? If the current split is intended, could the comments be
corrected instead?

[ ... ]

> +static int yt8824_extern_config_sds_init_paged(struct phy_device *phydev)
> +{
> +	struct yt8824_shared_priv *priv = phy_package_get_priv(phydev);
> +	int old_page = YT8824_RSSR_UTP_SPACE;
> +	int val_1, val_2, val_3, tmp;
> +	int ctrl = 0;
> +	int mask = 0;
> +	int ret = -1;
> +
> +	/* return directly if sds already initialized. */
> +	if (priv->sds_initialized)
> +		return 0;

[Severity: Medium]
sds_initialized and utp_shared_initialized[] are only cleared in
yt8824_phy_package_probe_once(). That runs once for the lifetime of the
shared package object.

What happens when config_init runs again after the chip has lost its
configuration?

On resume and hibernation restore the path is
mdio_bus_phy_resume()->phy_init_hw()->yt8824_config_init().

phy_detach() also asserts the reset line through
phy_device_reset(phydev, 1). The next attach calls phy_init_hw() again,
while the sibling ports keep the package priv alive.

In those cases this check returns early, so none of these are
reapplied:

  - the SerDes PLL/efuse trims
  - the CDR/AFE/DFE settings
  - the calibration restart

yt8824_config_utp_top_ext_init_paged() skips the shared PLL, DAC bias,
efuse bypass and U0/U1 TX reset settings the same way.

Would the hardware then run on power-on defaults while config_init
still reports success?

[ ... ]

> +	ctrl = FIELD_PREP(YT8824_CSR_PCS_GLB_RST_BYPASS, 1);
> +	ctrl |= FIELD_PREP(YT8824_CSR_SG_MODE_RST_BYPASS, 1);
> +	ctrl |= FIELD_PREP(YT8824_CSR_US_GLB_RESET_N, 0);
> +	ctrl |= FIELD_PREP(YT8824_CSR_PCS_BEF_TRAINING_DONE_RST_BYPASS, 1);

[ ... ]

> +	/* restart calibration */
> +	ctrl = FIELD_PREP(YT8824_CUR_TX_SEQ, 0x5);
> +	ctrl |= FIELD_PREP(YT8824_CUR_RX_SEQ, 0x6);
> +	ctrl |= FIELD_PREP(YT8824_CALIB_SEQ_FINISH, 1);
> +	ctrl |= FIELD_PREP(YT8824_CALIB_SEQ_SW_RST, 1);

[ ... ]

> +	/* restart to calibration */
> +	ret = ytphy_write_ext(phydev, YT8824_RESTART_CAL_CTRL_REG, 0x0040);
> +	if (ret < 0)
> +		goto err_restore_page;
> +
> +	ret = ytphy_write_ext(phydev, YT8824_RESTART_CAL_CTRL_REG, 0x0);
> +	if (ret < 0)
> +		goto err_restore_page;

[Severity: Low]
Can the reset and calibration handling here be confirmed or documented?

The name YT8824_CSR_US_GLB_RESET_N suggests an active-low bit. It is
written as 0 and never set back to 1.

YT8824_CALIB_SEQ_SW_RST is left at 1. YT8824_CALIB_SEQ_FINISH sounds
like a status bit, but it is written with 1 instead of being polled.

YT8824_RESTART_CAL_CTRL_REG is pulsed 0x40 then 0, and the function
returns without waiting for calibration to finish. yt8824_config_init()
then calls yt8824_extern_sds_softreset() straight away, which issues
BMCR_RESET on the SerDes:

	ret = yt8824_extern_config_sds_init_paged(phydev);
	...
	ret = yt8824_extern_sds_softreset(phydev);

Elsewhere the driver pulses resets explicitly (PLL_DAC_RST 0->1,
RESETB_TX 0->1). If these bits mean what their names suggest, could the
SerDes be left in global reset or soft calibration reset? Could the
channel reset also cut the calibration short?

A comment explaining the sequence, or a completion poll, would help.

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261201094405.3036391-1-kyle.switch%40motor-comm.com

  reply	other threads:[~2026-12-04  3:46 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-01  9:44 [PATCH net-next V29 1/3] dt-bindings: net: Document Motorcomm YT8824 PHY package Kyle Switch
2026-12-01  9:44 ` Kyle Switch
2026-12-01  9:44 ` [PATCH net-next V29 2/3] net: phy: Add support for Template Control register for PMA Kyle Switch
2026-12-04  3:46   ` netdev-bot+sashiko
2026-12-01  9:44 ` [PATCH net-next V29 3/3] net: phy: Add driver for Motorcomm Quad 2.5GbE phy Kyle Switch
2026-12-04  3:46   ` netdev-bot+sashiko [this message]
2026-12-04  3:46 ` [PATCH net-next V29 1/3] dt-bindings: net: Document Motorcomm YT8824 PHY package netdev-bot+sashiko

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=179635601653.3146.8403231642790506920@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=Frank.Sae@motor-comm.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=andrew@lunn.ch \
    --cc=conor+dt@kernel.org \
    --cc=davem@davemloft.net \
    --cc=devicetree@vger.kernel.org \
    --cc=edumazet@google.com \
    --cc=hkallweit1@gmail.com \
    --cc=jianmin.wang@motor-comm.com \
    --cc=krzk+dt@kernel.org \
    --cc=kuba@kernel.org \
    --cc=kyle.switch@motor-comm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=ming.xu@motor-comm.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=robh@kernel.org \
    --cc=xiaolin.xu@motor-comm.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