From: netdev-bot+sashiko@kernel.org
To: mjkchengke@163.com
Cc: Frank.Sae@motor-comm.com, netdev@vger.kernel.org, andrew@lunn.ch,
hkallweit1@gmail.com, linux@armlinux.org.uk, davem@davemloft.net,
edumazet@google.com, kuba@kernel.org, pabeni@redhat.com
Subject: Re: [PATCH] net: phy: motorcomm: add downshift tunable support for YT8531/YT8531S
Date: Sun, 29 Nov 2026 09:10:14 +0000 [thread overview]
Message-ID: <179594341431.3146.13055685725510422390@kernel.org> (raw)
In-Reply-To: <20261125085509.1844883-1-mjkchengke@163.com>
Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.
Critical: 0 · High: 1 · Medium: 1 · Low: 1
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).
- [High] The patch adds .get_tunable/.set_tunable to the PHY_ID_YT8531
entry of motorcomm_phy_drvs[].
- [Medium] yt8531_set_downshift() commits the SADCR change by writing
BMCR_RESET to the UTP-space BMCR with yt8521_modify_bmcr_paged(phydev,…
- [Low] In yt8521_modify_bmcr_paged(), if BMCR_RESET has not self-cleared
after the ~500 iterations of usleep_range(1000,1100), the loop exits…
--
net: phy: motorcomm: add downshift tunable support for YT8531/YT8531S
This commit exposes the YT8531/YT8531S Speed Auto Downgrade feature as the
ETHTOOL_PHY_DOWNSHIFT tunable. The retry limit is written to the Speed Auto
Downgrade Control Register in the UTP space. It is then committed with a
UTP-space BMCR software reset through yt8521_modify_bmcr_paged().
> diff --git a/drivers/net/phy/motorcomm.c b/drivers/net/phy/motorcomm.c
> index a87e83fdf590c..08bf8441fbd4e 100644
> --- a/drivers/net/phy/motorcomm.c
> +++ b/drivers/net/phy/motorcomm.c
[ ... ]
> @@ -1205,6 +1208,96 @@ static int yt8521_probe(struct phy_device *phydev)
[ ... ]
> +static int yt8531_set_downshift(struct phy_device *phydev, u8 cnt)
> +{
[ ... ]
> + /* The SADCR change is only committed by a UTP-space software reset.
> + * genphy_soft_reset() resets the BMCR of the currently selected
> + * register space only, and YT8531S powers up with the fiber space
> + * selected, so reset the UTP space explicitly. Both helpers manage
> + * their own paged access window.
> + */
> + err = phy_modify_paged(phydev, YT8521_RSSR_UTP_SPACE,
> + YTPHY_SPEED_AUTO_DOWNGRADE_CONTROL_REG,
> + mask, set);
> + if (err < 0)
> + return err;
> +
> + return yt8521_modify_bmcr_paged(phydev, YT8521_RSSR_UTP_SPACE,
> + 0, BMCR_RESET);
[Severity: Medium]
Can this reset leave the copper side out of sync with what phylib thinks
the PHY is doing?
Under Clause 22, a BMCR reset puts the control register back to its
defaults: autoneg enabled, default speed/duplex, power down cleared.
genphy_soft_reset() handles this after the reset:
drivers/net/phy/phy_device.c:genphy_soft_reset() {
...
phydev->suspended = 0;
ret = phy_poll_reset(phydev);
if (ret)
return ret;
/* BMCR may be reset to defaults */
if (phydev->autoneg == AUTONEG_DISABLE)
ret = genphy_setup_forced(phydev);
...
}
Here only the BMCR_RESET bit is polled. set_phy_tunable() only calls
drv->set_tunable under phydev->lock and does not re-run config_aneg.
Assuming the UTP BMCR reset behaves like a standard Clause 22 reset,
suppose the link was forced with "ethtool -s ethX autoneg off speed 100
duplex full" and the downshift tunable is set afterwards. Would the PHY go
back to autonegotiation while phylib still treats the link as forced?
Against a forced link partner, that could cause a duplex mismatch or no
link at all.
The suspend case is similar. After phy_stop(), the state machine calls
phy_suspend()->yt8521_suspend(), which sets BMCR_PDOWN in the UTP space.
If the tunable is changed while the interface is down, would PDOWN be
cleared and the copper side powered back up while phydev->suspended is
still set?
[Severity: Low]
What does the caller see if BMCR_RESET never self-clears? In
yt8521_modify_bmcr_paged(), the poll loop exits with ret still holding the
last BMCR value it read:
if (set == BMCR_RESET) {
while (max_cnt--) {
usleep_range(1000, 1100);
ret = __phy_read(phydev, MII_BMCR);
if (ret < 0)
goto err_restore_page;
if (!(ret & BMCR_RESET))
return phy_restore_page(phydev, old_page, 0);
}
}
err_restore_page:
return phy_restore_page(phydev, old_page, ret);
phy_restore_page() returns a non-negative ret unchanged. The existing
caller, yt8521_modify_utp_fiber_bmcr(), turns that into 0. Here the
positive value goes straight back through set_phy_tunable() as the ioctl
return value.
ethtool only treats err < 0 as an error, so would a reset timeout be
reported as success? Would returning -ETIMEDOUT on that path make more
sense?
[ ... ]
> @@ -3280,6 +3373,8 @@ static struct phy_driver motorcomm_phy_drvs[] = {
> },
> {
> PHY_ID_MATCH_EXACT(PHY_ID_YT8531),
> + .get_tunable = yt8531_get_tunable,
> + .set_tunable = yt8531_set_tunable,
> .name = "YT8531 Gigabit Ethernet",
> .probe = yt8531_probe,
> .config_init = yt8531_config_init,
[Severity: High]
Does the downshift tunable work at all on the YT8531? This entry has no
.read_page or .write_page callback, but both new callbacks use the paged
helpers:
yt8531_get_tunable()
yt8531_get_downshift()
phy_read_paged()
phy_select_page()
phy_save_page()
__phy_read_page()
drivers/net/phy/phy-core.c:__phy_read_page() {
if (WARN_ONCE(!phydev->drv->read_page, "read_page callback not available, PHY driver not loaded?\n"))
return -EOPNOTSUPP;
...
}
The set path has the same problem. phy_modify_paged() and
yt8521_modify_bmcr_paged() both go through phy_select_page().
So on a YT8531 (non-S), every get or set would return -EOPNOTSUPP, and the
first call would print a WARN splat. The comment in
yt8531_set_downshift() says "Both helpers manage their own paged access
window", which does not seem to hold for this entry. The commit message
also mentions testing only on a YT8531S.
ETHTOOL_PHY_GTUNABLE is also on the list that skips the CAP_NET_ADMIN check
in __dev_ethtool(). That means an unprivileged "ethtool --get-phy-tunable
ethX downshift" can trigger the WARN, and on a panic_on_warn system that
panics the machine.
There are two possible fixes. If the 0xA000 space select register is
valid on the YT8531, the entry could get .read_page/.write_page.
Otherwise, the UTP-only YT8531 could use plain
phy_read()/phy_modify()/genphy_soft_reset() instead.
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261125085509.1844883-1-mjkchengke%40163.com
prev parent reply other threads:[~2026-11-29 9:10 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 8:55 [PATCH] net: phy: motorcomm: add downshift tunable support for YT8531/YT8531S ck
2026-11-25 9:16 ` [PATCH v2 1/2] net: phy: motorcomm: return -ETIMEDOUT on BMCR reset timeout ck
2026-11-25 9:16 ` [PATCH v2 2/2] net: phy: motorcomm: add downshift tunable support for YT8531S ck
2026-11-25 9:23 ` [PATCH v2 1/2] net: phy: motorcomm: return -ETIMEDOUT on BMCR reset timeout netdev-bot+sinfo
2026-11-25 9:56 ` chengke
2026-11-29 9:10 ` netdev-bot+sashiko [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=179594341431.3146.13055685725510422390@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=Frank.Sae@motor-comm.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hkallweit1@gmail.com \
--cc=kuba@kernel.org \
--cc=linux@armlinux.org.uk \
--cc=mjkchengke@163.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.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