Article View: linux.kernel.netdev
Article #27216Re: [PATCH net-next v4 3/5] net: stmmac: dwmac-sun8i: serialize RX_CTL1 updates
From: netdev-bot+sashiko
Date: Sat, 05 Dec 2026 02:52
Date: Sat, 05 Dec 2026 02:52
148 lines
13590 bytes
13590 bytes
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 ยท High: 0 ยท 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).
- [Medium] The commit message says it closes the case where "a link-up
event can race with RX queue reconfiguration on sun8i".
- [Low] The subject and commit message describe a sun8i-only RX_CTL1 fix.
--
net: stmmac: dwmac-sun8i: serialize RX_CTL1 updates
This commit adds sun8i_dwmac_update_rx_ctl1(), which does the RX_CTL1
read-modify-write under a spinlock. The RX DMA start/stop, RX operation
mode and flow-control callbacks are converted to use it. It also renames
mac_device_info::irq_ctrl_lock to reg_lock and updates the generic
stmmac users of that lock.
> diff --git a/drivers/net/ethernet/stmicro/stmmac/common.h b/drivers/net/ethernet/stmicro/stmmac/common.h
> index 95d272e87524e..08de79107c503 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/common.h
> +++ b/drivers/net/ethernet/stmicro/stmmac/common.h
> @@ -655,10 +655,8 @@ struct mac_device_info {
> bool additional_32_addr;
> bool additional_64_addr;
>
> - /* This spinlock protects read-modify-write of the interrupt
> - * mask/enable registers.
> - */
> - spinlock_t irq_ctrl_lock;
> + /* Serializes updates to shared MAC control registers. */
> + spinlock_t reg_lock;
> };
[Severity: Low]
This isn't a bug, but the commit message doesn't mention this rename. It
says:
Use the per-MAC register lock for live changes to RX_CTL1.
That reads as if reg_lock already exists. In fact the patch renames the
generic irq_ctrl_lock to reg_lock and widens its documented purpose.
The rename touches code outside sun8i: dwmac1000_irq_modify(),
dwmac4_irq_modify(), dwxgmac2_irq_modify(), stmmac_fpe_configure_pmac()
and stmmac_hwif_init().
The rename has no functional effect. Still, it is extra core churn in a
Fixes-tagged dwmac-sun8i patch.
Could the lock be reused under its current irq_ctrl_lock name? If the
rename is wanted, could it go in a separate preparatory patch, or at
least be described in the commit message?
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
> index 8377dc7985377..ada927fe943fb 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
[ ... ]
> @@ -771,16 +769,13 @@ static void sun8i_dwmac_flow_ctrl(struct mac_device_info *hw,
> v &= ~EMAC_RX_FLOW_CTL_EN;
> writel(v, ioaddr + EMAC_RX_CTL0);
>
> - v = readl(ioaddr + EMAC_RX_CTL1);
> - v &= ~(EMAC_RX_FIFO_FLOW_CTL | EMAC_RX_FLOW_CTL_TH_ACT |
> - EMAC_RX_FLOW_CTL_TH_DEACT);
> + v = 0;
> if (fc & FLOW_TX)
> - v |= EMAC_RX_FIFO_FLOW_CTL |
> - FIELD_PREP(EMAC_RX_FLOW_CTL_TH_ACT,
> - EMAC_RX_FLOW_CTL_TH_2K) |
> - FIELD_PREP(EMAC_RX_FLOW_CTL_TH_DEACT,
> - EMAC_RX_FLOW_CTL_TH_4K);
> - writel(v, ioaddr + EMAC_RX_CTL1);
> + v = EMAC_RX_FIFO_FLOW_CTL |
> + FIELD_PREP(EMAC_RX_FLOW_CTL_TH_ACT, EMAC_RX_FLOW_CTL_TH_2K) |
> + FIELD_PREP(EMAC_RX_FLOW_CTL_TH_DEACT, EMAC_RX_FLOW_CTL_TH_4K);
> + sun8i_dwmac_update_rx_ctl1(hw, EMAC_RX_FIFO_FLOW_CTL | EMAC_RX_FLOW_CTL_TH_ACT |
> + EMAC_RX_FLOW_CTL_TH_DEACT, v);
[Severity: Medium]
RX_CTL1 is now updated under reg_lock here. The RX_CTL0
read-modify-write just above it is still unlocked, though. Could the
link-up vs. RX reconfiguration race from the commit message lose the
EMAC_RX_FLOW_CTL_EN update?
sun8i_dwmac_set_mac() also does an unlocked read-modify-write of
RX_CTL0:
drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c:sun8i_dwmac_set_mac() {
...
r = readl(ioaddr + EMAC_RX_CTL0);
if (enable) {
t |= EMAC_TX_TRANSMITTER_EN;
r |= EMAC_RX_RECEIVER_EN | EMAC_RX_DO_CRC;
...
writel(r, ioaddr + EMAC_RX_CTL0);
}
The link-up path runs from phylink_resolve(). It holds phydev->lock and
pl->state_mutex, but not rtnl:
phylink_resolve()
stmmac_mac_link_up()
stmmac_mac_flow_ctrl()
sun8i_dwmac_flow_ctrl()
The XDP reconfiguration path runs under rtnl only and does not stop
phylink:
stmmac_xdp_set_prog()
stmmac_xdp_release()
stmmac_mac_set(priv, priv->ioaddr, false)
stmmac_xdp_open()
stmmac_mac_set(priv, priv->ioaddr, true)
sun8i_dwmac_set_mac()
Consider this order:
1. sun8i_dwmac_set_mac(), called from stmmac_xdp_open(), reads RX_CTL0.
2. sun8i_dwmac_flow_ctrl() writes the newly negotiated
EMAC_RX_FLOW_CTL_EN.
3. sun8i_dwmac_set_mac() writes back its stale value.
The RX pause setting is then lost. The later sun8i_dwmac_set_mac(true)
call from link-up keeps the stale bit, so it would stay wrong until the
next link-up.
The RX_CTL0 read-modify-write in sun8i_dwmac_flow_ctrl() already existed
before the commit in the Fixes tag. However, the commit message says the
phylink flow-control callback now updates only its own fields under the
lock.
Would it make sense to also take reg_lock for RX_CTL0 in
sun8i_dwmac_flow_ctrl() and sun8i_dwmac_set_mac()?
--
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261203-submit-sun8i-rxall-v1-v4-0-af22aec6ae13%40gmail.com
Technical Details
Message-ID:
<179643917741.3146.1099493879220373089@kernel.org>Path:
mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377801-linux-kernel-netdev=dewy.ruReferences:
<20261203-submit-sun8i-rxall-v1-v4-3-af22aec6ae13@gmail.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377801-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net-next v4 3/5] net: stmmac: dwmac-sun8i: serialize RX_CTL1 updates Date: Sat, 05 Dec 2026 02:52:57 +0000 Organization: Usenet Network Message-ID: <179643917741.3146.1099493879220373089@kernel.org> References: <20261203-submit-sun8i-rxall-v1-v4-3-af22aec6ae13@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="2938969"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:K87vwFs53GwCZJTSbbyVQWIggAw= sha256:nxyOtP+j+witI/AQUU+X1SEGoz/5/e5MifWda9Aesto= sha1:z3C80t6UC0RBCArV+yznXLQsjTI= sha256:XPvx+pIy8C0TIMIOEbe0HE6cJJ7AaGdCUl6fK3vTE7E= 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 17F52117D50; Sat, 5 Dec 2026 05:53:17 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.641 X-Spam-Status: No, score=-3.641 tagged_above=-9999 required=6.31 tests=[DKIMWL_WL_HIGH=-0.142, 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 sBKX1hmUe_Oh; Sat, 5 Dec 2026 05:53:13 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-377801-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 sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74]) by mail.dewy.ru (Postfix) with ESMTPS id A54BA117D49; Sat, 5 Dec 2026 05:53:04 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sto.lore.kernel.org (Postfix) with ESMTP id 7F9FD606B7A; Sat, 5 Dec 2026 02:53:03 +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=1796439180; b=JKiWS/3FXDYXLk55nfFxDF8NRMLjtGVwTd8jK5tsVDdI9oBH6oE+1geMtYAcJO+CN55/ r0JX0qtdRClk8GKohZfQs60MsQVrp2G8az09pKFfSXuFvcGCl48LiK9pp9y1I7HjHMmea ELfpp2k1QBQJwXsIG7KNMIQ/texK6jnnRe3b034n2zris3Uwr7bcnMZxztXfnXDoMHpyx h8asomf3EKjbPLvtLBslAzloz3OXFNmNZZmHg0s2VaUlD0LNWWNcqe6yj5q51urFLE7H0 aajKRaEsHbO6BCJ4FLPz9cufueHQyX0c94eWYG6F1KHxOTivSWwoXLHWIaAGpEjgkTw== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796439180; 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=45m12jDL+mgV6UuKKAKRqlBh+CZqAjYfPKTPgMm9RtE=; b=SBBREviAbvxlNNRe1KVCR0R2+Dxv9lBGLp0SdcH0pDfdfQqktoZnIVgfmJEUmDwb3T5J xN/ZoVJcnXdh0Ju91n2GHknCo2uUfVgz+0scKcqiQj3pBAafnikBcb33zkmAyLkEgO/jA LA/oGrTlbTfXyTGyu2fdoInf6tvch3IoNmnmSBTd4dtaECi5IGAszE/B+QFNqy/ZM6kg/ 5JAJjRWxGSGstb4osxjacWeZi+n/xZUXs7X+KXfgoFMC3OuV80M6+hl763sUlD++LRi+3 AuhGqAq2QyQqg19O3SfzMjMDR9+zsiWrz5pufZGtCJ4lMPdr99tQoTJHLYt+bEJBnog== 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=B+c+Isk9; 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 DDEB8606A681; Sat, 5 Dec 2026 02:52:59 +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=B+c+Isk9 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=1796439179; b=VRfextfCJS9QqYP05Nrqo+a15/jtgrIONIe/GtqtMCj5evpbPq6DJnP80F+enipiJvBo Iig5UojI8mDuCk4Bw/yWRkXuviHBHYLLdPnKd/gfzbyuBf6UmjSOiCeYZYUYVCIpoNt5k B/FL2xT9qBODjgyqwMnxIjabbhakOodaGlHFcHRqiJ4WRwE1ZFSTlxW3+IFfR3E5fSwzS u7R6ecB94cnUZ0Ce2EUJXlvUWFb1qkuPCI4fn5TB48CrPKkYbpNxYvkk5bdl23VEhhv6M 8JpjWEWsilqcOetWHtGPYxtVvjqJWb2IAk7bXySXZ0Vw8cbUqeQQiWhmQ1fjatQFbeA== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796439179; 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=45m12jDL+mgV6UuKKAKRqlBh+CZqAjYfPKTPgMm9RtE=; b=ue6ZsfPT5W329Ksa1XDYjbvkR4idsSo0nD2iXMv5CSbfzbnP48dATRw6PGrHa1YfGKOm SLCMoU7fj0ta4LIw8Z9geBXSwZYQs0OBMnUtMPhSQAmHOaMRHyE+zQgs3fMBJguZSbyVX a/ZL1T1nkFn+OLWXlTVjERv/kh51gD8hrQcKXG0lTYkhSf+5AJ8Sx7kGRZBDac/iv64ul 7SYtwCCLCrET4idYcqB48J3kIk0KtSMid9H9YmlS9wO7vVofTH/50n3dflArlf5zsf01Y q9Pvh5OzA4Ya8e7zMXulvlcNun0cXP4YD4BUUIi/mcKNuCieEebfeyDlgVYim4C3sew== 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=B+c+Isk9; 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 07077606A339; Sat, 5 Dec 2026 02:52:59 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id D49451F0092B; Sat, 5 Dec 2026 02:52:57 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796439178; bh=45m12jDL+mgV6UuKKAKRqlBh+CZqAjYfPKTPgMm9RtE=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=B+c+Isk9/559H9e1dLLoc9pN6UuGNAHp/PSb52IYwfoeu8iLtn0d9OFjvm8s/hhdY /rVhJXDUDk7dPudp5Z2veu1pkfBaRb+QCTIe0TOOkwRLs9HYwxwjRKm4eQZQTpq6qN /62vUDwWRJHGETfT1mV2Jn6C6iFpSB9UpHxkPcsLH+2r0v44m93v00rWQBFVEFtdXN CAsKcmwQsbKcM0n/ZNH8i6AEWHjbAdJW++WuI6+2urH3f3ew7/g7myNUJXx3Ki5pc/ tiGCsQbdcF8OXVCklAEKdD0ZL/S58EoxtycNTmwCq6c2b33JT8EsTUFFrADsnPubLW ig70E36lN4M8A== X-Cc: netdev@vger.kernel.org, maxime.chevallier@bootlin.com, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org, pabeni@redhat.com, mcoquelin.stm32@gmail.com, alexandre.torgue@foss.st.com, wens@kernel.org, jernej.skrabec@gmail.com, samuel@sholland.org, clabbe.montjoie@gmail.com, willemb@google.com, nbb@tipi-net.de, kuba@kernel.org, o.rempel@pengutronix.de, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev X-In-Reply-To: <20261203-submit-sun8i-rxall-v1-v4-3-af22aec6ae13@gmail.com> X-sashiko-severity: Medium 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