Re: [PATCH net-next v29 RESEND 3/3] net: phy: Add driver for Motorcomm Quad 2.5GbE phy
From: netdev-bot+sashiko
Date: Thu Dec 03 2026 - 06:49:46 EST
Thank you for your contribution! Sashiko AI review found 10 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 5 · Low: 5
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-UTP and pair-shared register writes does
not match the kernel-doc.
- [Medium] priv->sds_initialized and priv->utp_shared_initialized[] live
in the phy_package shared priv and are cleared only in…
- [Medium] yt8824_sds_isolate_and_softreset_paged() and
yt8824_extern_sds_softreset() poll BMCR_RESET with…
- [Medium] yt8824_power_on(), yt8824_power_down() and yt8824_soft_reset()
wrap UTP power and reset transitions in PMA TESTMODE_1 and, in QXGMII…
- [Medium] yt8824_config_utp_top_ext_init_paged() asserts the TX channel
resets for both UTPs of a pair (U0/U1 CSR_RESETB_TX = 0, starting at…
- [Low] The commit message for a roughly 2100-line driver addition leaves
out several behaviours and constraints a maintainer needs.
- [Low] Two comments in the probe path describe retry behaviour the code
does not have.
- [Low] yt8824_utp_shared_group() works out the UTP pair from the
absolute phydev->mdio.addr against hardcoded bases (0 for QXGMII, 4…
- [Low] Some comments in struct yt8824_shared_priv do not match the code.
- [Low] yt8824_phy_package_probe_once() calls
mutex_init(&priv->shared_lock) on package-shared memory, and nothing…
--
net: phy: Add driver for Motorcomm Quad 2.5GbE phy
This adds YT8824 quad-port 2.5G PHY support to the Motorcomm PHY driver.
It uses the phy_package helpers to coordinate the top extended register
space shared by all ports. It also makes MOTORCOMM_PHY select
PHY_PACKAGE.
> 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 could the commit message say more about what is
being added? These points are not mentioned:
- There are two package modes, chosen by the motorcomm,package-mode DT
property: internal, with members at MDIO addresses 4..7, and
10g-qxgmii, with members at 0..3.
- The driver only works with DT. yt8824_probe() calls
devm_of_phy_package_join(), which returns -EINVAL when there is no
of_node or no ethernet-phy-package parent. On a non-DT system the
probe fails and genphy gets bound instead.
- yt8824_soft_reset(), yt8824_suspend() and yt8824_resume() wrap each
transition in PMA test mode 1 and a SerDes isolate/softreset. The code
only says "NOTE: need WA like softreset". What hardware problem does
this workaround address?
- MOTORCOMM_PHY now does select PHY_PACKAGE for every Motorcomm PHY
user.
- The driver depends on genphy_c45_pma_test_mode().
> 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 {
> + phy_interface_t package_mode;
[ ... ]
> + /*
> + * 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[],
and the field is named utp_shared_initialized[].
The UTP0/UTP1 and UTP2/UTP3 membership is also only right for
10g-qxgmii. In internal mode, yt8824_utp_shared_group() maps the groups
to UTP4/UTP5 and UTP6/UTP7:
if (priv->package_mode == PHY_INTERFACE_MODE_INTERNAL)
base = 4;
The same applies to the "UTP Top Extended0 (shared by UTP0, UTP1)" lines
in the YT8824 register overview comment.
[ ... ]
> @@ -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)
> +{
> + int old_page = YT8824_RSSR_UTP_SPACE;
> + int val = 0;
> + int ret = -1;
> +
> + old_page = phy_select_page(phydev, YT8824_RSSR_SERDES_SPACE);
[ ... ]
> + /* 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);
> + if (val < 0)
> + ret = val;
[Severity: Medium]
Does this keep the bus-wide mdio_lock held for a long time?
phy_select_page() takes the MDIO bus lock through phy_save_page(), and
the lock stays held until phy_restore_page(). Because sleep_before_read
is true and the sleep is 50 ms, each call keeps the bus locked for at
least 50 ms and for up to about 600 ms.
yt8824_extern_sds_softreset() polls the same way. Each port goes through
several of these waits across config_init, soft_reset, suspend, resume
and the restore paths. For that whole time the other YT8824 ports, and
any other PHY or switch on the bus, cannot use MDIO.
The sibling ports are already serialized by priv->shared_lock. Is it
still necessary to hold mdio_lock across the sleep to protect the
space-select bit?
[ ... ]
> +static int yt8824_utp_shared_group(struct yt8824_shared_priv *priv, int addr)
> +{
> + int base;
[ ... ]
> + if (priv->package_mode == PHY_INTERFACE_MODE_INTERNAL)
> + base = 4;
> + else
> + base = 0;
> +
> + if (addr < base || addr >= base + YT8824_UTP_SHARED_GROUPS * 2)
> + return -EINVAL;
> +
> + return (addr - base) / 2;
[Severity: Low]
Should this use the package base address rather than the absolute
phydev->mdio.addr? The top-ext accesses in ytphy_read_top_ext() and
ytphy_write_top_ext() go through __phy_package_read() and
__phy_package_write(), so they are relative to the package base_addr
from the DT reg property. This grouping instead assumes the members are
always at 0..3 or 4..7.
The motorcomm,yt8824.yaml binding is inconsistent in the same way. Its
description of reg in external mode says "the base MDIO address of the
four member PHYs plus 4, where base is typically 0x0", but the schema
pins reg to const 4 for 10g-qxgmii.
Consider a second YT8824 on the same bus with members at 8..11 and
reg = <12>. Here this returns -EINVAL, and
yt8824_config_utp_top_ext_init_paged() fails. As a result
yt8824_config_init() fails for every port, after the SerDes and per-UTP
sequences have already been written.
A schema-valid DT does not hit this today. Should the code and the
binding text be brought into agreement?
> +/**
> + * 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].
[ ... ]
> + if (priv->utp_shared_initialized[grp])
> return 0;
[Severity: Medium]
Can these flags become stale after a hardware reset?
priv->utp_shared_initialized[] and priv->sds_initialized are cleared
only in yt8824_phy_package_probe_once(). The chip can still be reset
while the driver stays bound:
phy_detach()
phy_detach_internal()
phy_device_reset(phydev, 1)
On the next attach, phy_init_hw() deasserts reset and calls
yt8824_config_init(). This check then returns early. So does the one in
yt8824_extern_config_sds_init_paged():
if (priv->sds_initialized)
return 0;
Several steps get skipped as a result: the shared PLL/DAC bias
programming, the TX reset release, the efuse-derived SerDes trims and
the calibration restart. The per-port registers are reprogrammed.
This can happen when the PHY node has reset-gpios, for example with a
MAC that calls phylink_disconnect_phy() from ndo_stop. It can also
happen if power is lost during suspend.
[ ... ]
> + /* write protecting */
> + mask = YT8824_WRITE_PROTECT;
> + ctrl = YT8824_WRITE_PROTECT;
> + ret = ytphy_modify_ext_with_lock(phydev,
> + YT8824_WRITE_PROTECT_CAL_REG,
> + mask, ctrl);
> + if (ret < 0)
> + goto err_restore;
[Severity: Medium]
The kernel-doc above says this function does the odd-preamble enable.
That write is actually in yt8824_config_utp_init_paged(), which runs for
every port with no group guard:
/* 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);
YT8824_IF_CTRL_REG is 0xa003, which is in the shared top-ext space.
The opposite also happens. YT8824_WRITE_PROTECT_CAL_REG is 0x1. The
yt8824_config_utp_init_paged() kernel-doc says that range is private
per-UTP ext space, yet the register is written only here, behind the
utp_shared_initialized[grp] check. Does the second UTP of each pair end
up without its write-protect bit set?
The yt8824_config_utp_init_paged() kernel-doc also says shared registers
are configured "according to the UTP index". That function has no
index-dependent logic.
[ ... ]
> + ctrl = FIELD_PREP(YT8824_U0_CSR_RESETB_TX_CH0, 0);
> + ctrl |= FIELD_PREP(YT8824_U0_CSR_RESETB_TX_CH1, 0);
> + ctrl |= FIELD_PREP(YT8824_U0_CSR_RESETB_TX_CH2, 0);
> + ctrl |= FIELD_PREP(YT8824_U0_CSR_RESETB_TX_CH3, 0);
> + mask = YT8824_U0_CSR_RESETB_TX_CH0 | YT8824_U0_CSR_RESETB_TX_CH1 |
> + YT8824_U0_CSR_RESETB_TX_CH2 | YT8824_U0_CSR_RESETB_TX_CH3;
> + ret = ytphy_modify_ext_with_lock(phydev, YT8824_U0_CSR_RESET_REG,
> + mask, ctrl);
> + if (ret < 0)
> + goto err_restore;
[ ... ]
> + priv->utp_shared_initialized[grp] = true;
> + return 0;
> +
> +err_restore:
> + return ret;
[Severity: Medium]
Suppose one of the writes after the TX resets are asserted fails. The
function jumps to err_restore, which only returns. Doesn't that leave
both UTPs of the pair with their transmitters held in reset (U0/U1
CSR_RESETB_TX cleared) and the shared PLL/DAC bias only partly
programmed?
utp_shared_initialized[grp] is not set, so a later successful
config_init on either port would recover. Until that happens, the
sibling port's TX stays in reset even if that port was already
configured.
[ ... ]
> +static int yt8824_config_utp_init_paged(struct phy_device *phydev)
[ ... ]
> + ret = phy_modify(phydev, MII_BMCR, BMCR_PDOWN, BMCR_PDOWN);
> + if (ret < 0)
> + goto err_restore;
[ ... ]
> + /* reset */
> + ret = genphy_c45_pma_test_mode(phydev, MDIO_PMA_10GBT_TESTMODE_1);
> + if (ret < 0)
> + goto err_restore_normal;
> +
> + ret = phy_modify(phydev, MII_BMCR, BMCR_PDOWN, 0);
> + if (ret < 0)
> + goto err_restore_normal;
> + ret = phy_modify(phydev, MII_BMCR, BMCR_RESET | BMCR_ANENABLE,
> + BMCR_RESET | BMCR_ANENABLE);
[Severity: Medium]
yt8824_power_on(), yt8824_power_down() and yt8824_soft_reset() wrap UTP
power and reset transitions in PMA test mode 1. For 10g-qxgmii they also
wrap them in yt8824_sds_isolate_paged() and
yt8824_sds_isolate_and_softreset_paged() ("NOTE: need WA like
softreset").
This function sets BMCR_PDOWN with no test mode and no SerDes isolate.
The later power-up and BMCR_RESET run under TESTMODE_1, but they still
skip the SerDes isolate and softreset. That is true even in 10g-qxgmii
mode, where one lane carries all four ports. Is skipping the workaround
here intentional?
The yt8824_soft_reset() call at the end of yt8824_config_init() applies
the full sequence again. Could these earlier transitions still disturb
the shared lane before that runs?
[ ... ]
> + /*
> + * Validate the DT first and keep the parsed value in a local
> + * variable. Do not touch the shared state until validation has
> + * succeeded, so a failure leaves the package untouched and a
> + * sibling PHY can retry.
> + */
[ ... ]
> + /* Validation succeeded, initialize the shared state. */
> + mutex_init(&priv->shared_lock);
[Severity: Low]
This isn't a bug, but this mutex has no matching mutex_destroy(). When
the last port leaves, phy_package_leave() just calls
kfree(shared->priv), and the driver has no .remove. With
CONFIG_DEBUG_MUTEXES, the lock's debug state is never torn down before
the memory is freed.
[ ... ]
> + /* Ensure other PHY probes wait for shared mutex initialization. */
> + phy_package_lock(phydev);
> + if (phy_package_probe_once(phydev)) {
> + ret = yt8824_phy_package_probe_once(phydev);
> + shared_priv->package_validated = ret ? ret : 1;
> + } else {
> + /*
> + * Another port has already consumed the once bit. Do not assume
> + * its DT validation succeeded; check the result it recorded.
> + */
> + ret = shared_priv->package_validated;
> + if (ret == 0) {
> + /*
> + * Unreachable in practice: once bit consumed but no
> + * result recorded yet. Retry probe instead of
> + * proceeding silently.
> + */
> + ret = -EAGAIN;
[Severity: Low]
This isn't a bug, but the comments here describe retry behaviour that
the code does not have.
The driver core only re-probes on -EPROBE_DEFER, so -EAGAIN makes the
probe fail permanently instead of retrying. This branch also cannot be
reached, because package_validated is always set under
phy_package_lock() before the lock is dropped.
The comment in yt8824_phy_package_probe_once() says a failure "leaves
the package untouched and a sibling PHY can retry". But a sibling that
joined before the failed port left takes the else branch here and just
returns the stored error. Validation only runs again if the shared
struct has been freed and allocated again.
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261202105259.3767612-1-kyle.switch%40motor-comm.com