Article View: linux.kernel.netdev
Article #24111Re: [PATCH net-next v4 1/3] r8169: hold MDIO bus lock while loading firmware
From: netdev-bot+sashiko
Date: Sun, 29 Nov 2026 09:50
Date: Sun, 29 Nov 2026 09:50
89 lines
11145 bytes
11145 bytes
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 commit message presents this patch as groundwork for the PTP
patches later in the series.
--
r8169: hold MDIO bus lock while loading firmware
This patch takes the MDIO bus lock around rtl_fw_write_firmware() in
r8169_apply_firmware(). Other phylib users then cannot interleave their
PHY accesses with the firmware sequence. The lock is skipped when there
is no phydev, and tp->ocp_base is restored before the lock is dropped.
> diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c
> index f151ab6813932..b289ff6c30645 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, PTP) off the bus meanwhile. */
> + if (tp->phydev)
> + phy_lock_mdio_bus(tp->phydev);
> rtl_fw_write_firmware(tp, tp->rtl_fw);
[Severity: Low]
The commit message doesn't say so, but does this also fix a race that
mainline users can already hit?
Since commit 33700ca45b7d ("net: phy: realtek: add hwmon support for temp
sensor on RTL822x"), rtl822x_probe() registers a hwmon device for the
internal NBASE-T PHY. Any user can read its sysfs attributes. A
temperature read takes only the MDIO bus lock:
rtl822x_hwmon_read()
phy_read_mmd(phydev, MDIO_MMD_VEND2, RTL822X_VND2_TSRR) <- bus lock
rtl822x_read_mmd()
rtlgen_read_vend2()
__mdiobus_c45_read()
r8169_mdio_read_reg_c45()
r8168_phy_ocp_read()
r8168_phy_ocp_read() writes the GPHY_OCP command register and polls it,
and it takes no driver lock of its own:
RTL_W32(tp, GPHY_OCP, reg << 15);
return rtl_loop_wait_high(tp, &rtl_ocp_gphy_cond, 25, 10) ?
(RTL_R32(tp, GPHY_OCP) & 0xffff) : -ETIMEDOUT;
Before this patch, rtl_fw_write_firmware() reached the same GPHY_OCP
sequence without the bus lock:
rtl_readphy()/rtl_writephy()
r8168g_mdio_read()/r8168g_mdio_write()
r8168_phy_ocp_read()/r8168_phy_ocp_write()
Firmware loads during open, resume or reset:
rtl8169_init_phy()->r8169_hw_phy_config()->r8169_apply_firmware()
If a hwmon read runs during a firmware load, can the two command/poll
sequences overlap? A firmware PHY write could then be lost or go to the
wrong register.
Paged C22 accesses that write register 0x1f also change tp->ocp_base,
and the firmware sequence depends on that value.
If so, could the commit message describe this race and add a Fixes: tag
so that stable kernels get the fix? For example:
Fixes: 33700ca45b7d ("net: phy: realtek: add hwmon support for temp sensor on RTL822x")
> /* 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/20261125090217.1198-1-javen_xu%40realsil.com.cn
Technical Details
Message-ID:
<179594581133.3146.17688187445404564252@kernel.org>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-373441-linux-kernel-netdev=dewy.ruReferences:
<20261125090217.1198-2-javen_xu@realsil.com.cn>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-373441-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net-next v4 1/3] r8169: hold MDIO bus lock while loading firmware Date: Sun, 29 Nov 2026 09:50:11 +0000 Organization: Usenet Network Message-ID: <179594581133.3146.17688187445404564252@kernel.org> References: <20261125090217.1198-2-javen_xu@realsil.com.cn> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="1143684"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:QtbTEvsPQIbvtM50ZV1Hl9v6BbE= sha256:eKgK6oWZ+psbe9Ofhbz6yJNX+CYc/metHOr2OwhArPY= sha1:KxBuojFTLkJPpPn0jczt46jUI58= sha256:SAtX5GMM3Ga2Rwq7TEd4AIYAHKE3suf540FrVL0BXvE= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id E2D08125F96; Sun, 29 Nov 2026 12:50:32 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.4 X-Spam-Status: No, score=-3.4 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id W-FnOpjLZfFv; Sun, 29 Nov 2026 12:50:25 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-373441-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id C4BBE125F97; Sun, 29 Nov 2026 12:50:15 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id EAD93258D5; Sun, 29 Nov 2026 09:50:13 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1795945813; b=P4OCv2WfhNE9SLVMdjUKhP4YMn7ZqT25AHRoU12i0ITX1bCEJbpuqwG49tPUERF8rpI8 iYFJAnSV0dYUz4hymTYej1FKTpKkadfPDc3PzpBAXNPfC+OjNhWnX1cQ6+vUBYM4NFfiG 0yYQ0lRH8jordXef25fXRyM8xzInp0XlLEKTlrwMdAx6e2JJAI5r7uP6lAdbT+Zf2uTaW YDVJUffl+m4vNMGqWfSNpnPnBGGh3NDsv/+CK0BY0BW4Li4shdFvJeIoMBbEraMN5ZSG7 PuQoxvtKDkJfSA5fXadRK1Nzc1EnWxQ8a6XNwdlAR9a8nMt3BONxsHLHke69p2+7zqg== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795945813; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=fRArdfr5rX6KSINAZs0WRlFfpGIk9GvnpoOEks9K+Lc=; b=3a4BwDQp0+35ImjI9AOX4hAQX1ady8qD+zYvD0NrzFNjrUM6s2AgEeh0o1woxVssju7j mqn0EJfQY2hNw7RMhisSKfIxBaT8QXUEfjgMqafpdRZaii6Fk/PJ45XP7jpD9aX7LcxaZ vJKb8BrjkEv3tuftbXv91odH3o/mQPRlo9S9HzZ/43sWWCN36jZvaohSYSPSOjqcRTwFX I96jhTxHvVYziKwXWQ+YIlJiHqBJN35Ug6iIVtdBX0bJeB5Alu/UyBvXC5Pssjwn8Xoe8 m+GgRS58lPX9gmDGsZa6cGMh2cY3v4YGl7JGlVJgCxzbXye+8XXCC7wlx6N/KMpm7Gg== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=djXSBCJX; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C2F32606A32A; Sun, 29 Nov 2026 09:50:13 +0000 (UTC) X-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=djXSBCJX X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795945813; b=mslh2td1EVHmKfU/nyA/vR1IcPhHlmA0x55/lTbSWPmJUCaMAh6iZoQmmUcMROKd/U4L JZzav8mdPLa7ZpBwjnnE9fVOh5PXzWx3IdSzm1Ol2U1U9whIkzH3xZnduf5/JfqWdcGpi ljtRfR1uWiajhNiZKfU0ajwThWQs2qygXIWQnJULA2RPjRFkh0iIjzjiEIQ8x0Y+tKFZk EY5cbhdRCT1vzjnWS17dAm2m4AetmxESwrWlBhpHYIk4xaVoSCEhl5ChGsPOXGxaZtXnf X65rmwBcbY4Vi0WegXQGQj4kaHGwZn3mmmgGxEphho7SyzRm+qdfrQbuPLmzZwLPllA== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795945813; 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=fRArdfr5rX6KSINAZs0WRlFfpGIk9GvnpoOEks9K+Lc=; b=a3T2R6SKlaqJV0NdqqXdXE8BMeSDeZ482IZpY5HJ8hJ6xS60RvaqPjAbkcDk/nlEVBKP 3SOg/8vl7qJ5gevFiQ5xUo9qnUTrq9TrN1K1jBJqdscUG1T1BksLbCLvfOo6ZbbBMCoki yfugdksUDtupNZB7hwVEvjARcVT9jgYsULnfALZU1f4EyGXCs7yxxEJJapLk36nMudFce kZYHXJa0zG894p1d80VufeDn2W5U7asicup3jji+Zm45Ci/9RHi0yLUFhUnXNVLXPuNM+ Qhf+scXQK538U7BSX9jkUNTRaCO3qjKAcUJmbmzE3UQUIOpYv+JwcOtX3MZNeCKjo+Q== X-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=djXSBCJX; arc=none smtp.remote-ip=100.103.45.18 X-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 E113B606A31C; Sun, 29 Nov 2026 09:50:12 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id D4E1B1F00897; Sun, 29 Nov 2026 09:50:11 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795945812; bh=fRArdfr5rX6KSINAZs0WRlFfpGIk9GvnpoOEks9K+Lc=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=djXSBCJX3WDR4yT/mdSqL3xGcvsROqKTjBEi1kC+ZAdg7GLoUGQ6rnID8Nef10jG+ Mkut8L8Ya5iZmvA2gwM1PRUsZ+xlvvocjOzXfgMtl62zOheg8klztFWQoY4DS1Pasj XVVSbOk7S7g8j/ClSUq+3PR2FFORfvoTk5kFDiyfe+InWw0WS3j0v+IQa0BiNfDteb EjsHgrM1ILrvb4ENMW8KxPXH070Ef0QlAu3es4GlG8Ya78l8ue/CH+qsSjN7KV6oD1 r84DSVDfkILrPDdzsooTW/gtytKAYlEteoXBDt/RCP2kpdjcMUP3YjEr2Vi3lpYGeX /gg03hmdq1uyg== X-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 X-In-Reply-To: <20261125090217.1198-2-javen_xu@realsil.com.cn> X-sashiko-severity: Low X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list