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=1796439556; b=15Otkr/H2CmxA61JxzK9wf1o2HouLvqjnnqnTyKhIucbDqcEOZwO/12+2Sg1kYpyviF9 h2ArKM/gmp2baxNrn4P/3ch3o3B3J/IiRL3sbdvnshwUAI0xsgWDdEBkgPLUQ+CxQqkp5 XHlaRMvDHNhn3dedK/0hiC8A6zyju1oowo0v4KAziwcVrOy39KjH7LOwx89/30e06ci3P BNQb+sRTqxwmQL0oKGrZFXudV/ZyG32AIVw8DVuMwEO6nB5CR3sHZ5E764xiAwDxsXga1 0Z3L0vF9GZBf1hMKspPhOPBJlw8lkskPPRV3hj3w5A0GwE5HY0hbV4wnA1WftKL9qjA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796439556; 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=npe10QCFpajcqSgLyK781ke54hZ8ShjxTLZEBoRjDVI=; b=38gxIP8wIeTILyeE3ZkmMx1k13GQEdVDcvGHWz+mvnqrQBaDgZVbem8OFfuRMIZD3pXj +W/QYuvqYwRKQDx4/eVewRLyVqjmAdtC3RVX5Ou5xMD49E5JL1MQMxnxzevie5INieo5L tT1lMglwqRMBRBgoeIA9D6W0MqTI6vWlvOUJSOZg+oTcYZLaz1hpkioRDb/TjOpD0AAfr ZklP2TrfjWyc4TkRcerZ5bI+K7qH3Z0HYUSD2bE8P5YnnOCPgIg2x7Bo2LU3/m6a2vvU5 RAFuO0uOJ2bnKY0gXf91IzWmc5PjUtrmIZ7XfLpZHXOJXKdl4L18dtPK3QPgLdOrgyQ== 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=DYpWGtWE; 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 1E7AA606A32D; Sat, 5 Dec 2026 02:59:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=DYpWGtWE Received: by smtp.kernel.org (Postfix) with ESMTPSA id EA7D51F00936; Sat, 5 Dec 2026 02:59:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796439555; bh=npe10QCFpajcqSgLyK781ke54hZ8ShjxTLZEBoRjDVI=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=DYpWGtWEy96fXz8foXlBlHJt4mwRlMam2BGA22EVwoUNGW1nRAGxVZ5CRGbLXr798 YPTKuken+Ssc2HXz7n9iDu2YKUIAtDPr/ICBLXVOUaBZ5oeAEKBQOg/h0PV19F/1wi NVtXizo55uB8s4Ct/C2OGUYIjCNSj1RL9YhqqOQ/OQ/P+I7tBf+ZbKoW1q7gU1kOEH XLs5fQxEYta8oT3Xh3ejFAGtiwV3jrw7xG4R2wuX24PqosMakknQwRERt0Gs2sie7v b7KMDMs83JxO0pduVQG4CnR3s4/LoD62wPjee1zcuR8cuAelWMyZFlwpEfAo7Lp9dR mZJDPD3GS92GQ== Subject: Re: [PATCH net-next v6 2/4] r8169: hold MDIO bus lock while loading firmware From: netdev-bot+sashiko@kernel.org To: javen_xu@realsil.com.cn Cc: andrew@lunn.ch, hkallweit1@gmail.com, linux@armlinux.org.uk, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, nb@tipi-net.de, maxime.chevallier@bootlin.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, daniel@makrotopia.org, vladimir.oltean@nxp.com Date: Sat, 05 Dec 2026 02:59:14 +0000 Message-ID: <179643955446.3146.5909024155497379151@kernel.org> In-Reply-To: <20261204021116.66-3-javen_xu@realsil.com.cn> References: <20261204021116.66-3-javen_xu@realsil.com.cn> X-sashiko-severity: Low Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: linux-kernel@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 more severe issue(s) in other patches of this series. This mail is only an FYI, in case you want to address the nit picks below when you respin. Low priority / nit picks for your consideration: - [Low] The patch "r8169: hold MDIO bus lock while loading firmware" fixes a race that is already in mainline, but the commit message… -- r8169: hold MDIO bus lock while loading firmware This patch takes the MDIO bus lock around rtl_fw_write_firmware() in r8169_apply_firmware(). The firmware loader accesses PHY registers directly and bypasses phylib. The lock is skipped on PHY-less parts where tp->phydev is NULL. > diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c > index f151ab6813932..b9068957ffa4f 100644 > --- a/drivers/net/ethernet/realtek/r8169_main.c > +++ b/drivers/net/ethernet/realtek/r8169_main.c > @@ -2686,9 +2686,14 @@ void r8169_apply_firmware(struct rtl8169_private *tp) > > /* TODO: release firmware if rtl_fw_write_firmware signals failure. */ > if (tp->rtl_fw) { > + /* Keep phylib users (hwmon) off the bus meanwhile. */ > + if (tp->phydev) > + phy_lock_mdio_bus(tp->phydev); > rtl_fw_write_firmware(tp, tp->rtl_fw); [Severity: Low] Can this race already be hit in mainline? If so, should the commit carry a Fixes: tag? The "Realtek Internal NBASE-T PHY" entry uses rtl822x_probe(). When CONFIG_REALTEK_PHY_HWMON is enabled, that function registers a hwmon device for the internal PHY: drivers/net/phy/realtek/realtek_main.c:rtl822x_probe() { ... if (IS_ENABLED(CONFIG_REALTEK_PHY_HWMON) && phydev->phy_id != RTL_GENERIC_PHYID) return rtl822x_hwmon_init(phydev); ... } That code came in with: 33700ca45b7d ("net: phy: realtek: add hwmon support for temp sensor on RTL822x") A hwmon sysfs read takes only the MDIO bus lock, not RTNL: rtl822x_hwmon_read() phy_read_mmd(phydev, MDIO_MMD_VEND2, ...) r8169_mdio_read_reg_c45() r8168_phy_ocp_read() r8168_phy_ocp_read() writes the address to GPHY_OCP and then reads the data back from the same register. Before this patch, rtl_fw_write_firmware() drove GPHY_OCP through r8168g_mdio_read() and r8168g_mdio_write() without holding that lock. It runs during ifup, reset work and resume. If a sensor read overlaps the firmware load, could the PHY_READ, PHY_DATA_OR/AND and PHY_WRITE_PREVIOUS sequences read from or write to the wrong PHY register? Could hwmon also report a wrong temperature? The new comment names hwmon as the competing user. The commit message does not say that the race exists today or what users see when it hits. The later patches in the series do not add a Fixes: tag either, so kernels that already have the hwmon support (v6.14 and later) would not pick this up. Would a tag like this be appropriate? Fixes: 33700ca45b7d ("net: phy: realtek: add hwmon support for temp sensor on RTL822x") Could this also go to net on its own, instead of as part of the RTL8127a PTP series? > /* At least one firmware doesn't reset tp->ocp_base. */ > tp->ocp_base = OCP_STD_PHY_BASE; > + if (tp->phydev) > + phy_unlock_mdio_bus(tp->phydev); [ ... ] -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261204021116.66-1-javen_xu%40realsil.com.cn