From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 41474606A32D for ; Sat, 5 Dec 2026 02:53:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=BovwyX3/; 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 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:MIME-Version: Content-Transfer-Encoding:Content-Type:References:In-Reply-To:Message-ID:Date :Cc:To:From:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Unsubscribe-Post:List-Owner; bh=45m12jDL+mgV6UuKKAKRqlBh+CZqAjYfPKTPgMm9RtE=; b=BovwyX3/vVSNjt//s8B4tRZEoP q6EMDRi8H8AgbzTSMZvFjpGi5p6kCvFgKv8ZeQ8EE2sbM/xRf1GneF7xveYgCp1Sy3mJ9OM9v2f8E BENZ6SWr7IaEfWMLjZ4vdOEm59hgMurGqjnJ37oXvuY0+K2KZJlFAWKSWkJT/GZz3ostbKnFZ5jrl L2PCSF1eqk+CVeyPO5Vkzobx39jZdNbK4RztGebAkXHb+y+X+C8CvI8GAOh1GvbuoUjkHBjkCXw9T T4wBr/v5Kat5836D/iOZzqUiYrqWiSPsIUoWqhiz2qY+5sgD1H0gMqDZNVJEXh1WqBr2pufO26kn0 DTIggX1g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZftg-00000001vCi-3Fxr; Sat, 05 Dec 2026 02:53:13 +0000 Received: from sea.source.kernel.org ([2600:3c0a:e001:78e:0:1991:8:25]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZftT-00000001vBw-2WcD for linux-arm-kernel@lists.infradead.org; Sat, 05 Dec 2026 02:53:03 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id F02F440AF0; Sat, 5 Dec 2026 02:52:58 +0000 (UTC) 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-Archived-By: MIME-Version: 1.0 X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" X-Spam-Status: No, score=-11.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 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