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=1796439179; b=VRfextfCJS9QqYP05Nrqo+a15/jtgrIONIe/GtqtMCj5evpbPq6DJnP80F+enipiJvBo Iig5UojI8mDuCk4Bw/yWRkXuviHBHYLLdPnKd/gfzbyuBf6UmjSOiCeYZYUYVCIpoNt5k B/FL2xT9qBODjgyqwMnxIjabbhakOodaGlHFcHRqiJ4WRwE1ZFSTlxW3+IFfR3E5fSwzS u7R6ecB94cnUZ0Ce2EUJXlvUWFb1qkuPCI4fn5TB48CrPKkYbpNxYvkk5bdl23VEhhv6M 8JpjWEWsilqcOetWHtGPYxtVvjqJWb2IAk7bXySXZ0Vw8cbUqeQQiWhmQ1fjatQFbeA== 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== 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 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) 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 Received: by smtp.kernel.org (Postfix) with ESMTPSA id D49451F0092B; Sat, 5 Dec 2026 02:52:57 +0000 (UTC) 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== Subject: Re: [PATCH net-next v4 3/5] net: stmmac: dwmac-sun8i: serialize RX_CTL1 updates From: netdev-bot+sashiko@kernel.org To: james.hilliard1@gmail.com 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 Date: Sat, 05 Dec 2026 02:52:57 +0000 Message-ID: <179643917741.3146.1099493879220373089@kernel.org> In-Reply-To: <20261203-submit-sun8i-rxall-v1-v4-3-af22aec6ae13@gmail.com> References: <20261203-submit-sun8i-rxall-v1-v4-3-af22aec6ae13@gmail.com> X-sashiko-severity: Medium 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 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