From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795943415; b=b1hwT+5olh5b5PK5XI7sssAZQ8BH0rHO/edMyqBZ1SHr30fMBs6/RmL/N6nPLHSH3R3l jcItlNGCCU8IjkgfE5SIlnIVyWEap1t2hSrCW/PFmm9PeDXTs+WI0HgaVvRB/5NsXyD0M U2iZtmO2iT9tAudHIwHjgTCvhHgi+pWATCn8FbwzfHV8Mc/2yMdBKcpmQzmIOJpp0Go5S LPkcHD65nR3rpqHwnVdkojQgGwfZzicmiuGRJ7tAdoG/8DaYwRjIToJPhlcwu2fb0wiLH JroaCS1jlnFxAw6G5pa06cyiNBKpVW9D4gPuXKreoBNVlZsVQlTNHjKSOojfVyF8RAA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795943415; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=n0lw3/WmK69kymQ3ocGh/9cZq9bgYshVue1jd8rY/0s=; b=OPU22uGcr61/f9isYi6sQ4wj2vRQTeO1PI2DlHEkKBdIw5Ttww/2CeDCZz2yzImOYS/J zPv1YMjPmg28JZGijVj2VdjdfwV42TXls/9GOvKJGpMzU1XZ6S1mboDAk6GGGFYPstNGG oV8L0en/lqOXhNMK6LPYmgodHgBW3Y6mkzytIfbtJgEdk3IVRxK2Hta22nFhxFIb8f2yX K48p8XwuOlFARkCr4YFaOQuerqwARE1a1NcWObtNrlM3UdKGtd2hiSZEDa9tHuFt6tflg O/bwehH70qdlaN8GW70xOnD9h9BuzsqvdoYEkhzNQcgypz1b2NlTWsEHDzVYhUcXkpA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=NbCU97Jk; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ACD0F606A31C for ; Sun, 29 Nov 2026 09:10:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=NbCU97Jk Received: by smtp.kernel.org (Postfix) with ESMTPSA id C5E081F00898; Sun, 29 Nov 2026 09:10:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795943415; bh=n0lw3/WmK69kymQ3ocGh/9cZq9bgYshVue1jd8rY/0s=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=NbCU97JkOx1Bz1A5k4e5wdeZAJdxMrq6JVAOLBDS/TNO1uyHQMrPQ9k5Wo2VgR95A UVfjuuS6ClEKdNdkSBRFLq7sYyXJs4PYImqpR/GiSjcmvtR03K46J4Ot3qC1tOCW5l KKO+DWJTGoNjS4Hr/XwYi43BZOk3iSppsZnAkn7XrK5M+APUkNMm73Kbg7uwBhYHqm HZc2yl0b0H7IcoyVAeLWGiZU+ODlhWH9SFyeG3UmaJr6VVBf0Qm/dWmzJ/GDJTDY5g wYSQGIMU9KgvlRuJf+CdzfhcvhrWczUcbzFyhQErq4hJw5DlcbZSPsq1HmpQMe9BsF ijxEAOGVAn3wg== Subject: Re: [PATCH] net: phy: motorcomm: add downshift tunable support for YT8531/YT8531S 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 Date: Sun, 29 Nov 2026 09:10:14 +0000 Message-ID: <179594341431.3146.13055685725510422390@kernel.org> In-Reply-To: <20261125085509.1844883-1-mjkchengke@163.com> References: <20261125085509.1844883-1-mjkchengke@163.com> X-sashiko-severity: High Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 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