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 27B07606A6AD for ; Wed, 2 Dec 2026 18:44:01 +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=GpM+Q9Yp; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.a=rsa-sha256 header.s=dkim header.b=k36U0Yzg 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:Content-Transfer-Encoding: Content-Type:In-Reply-To:From:References:Cc:To:Subject:MIME-Version:Date: Message-ID: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=Nm8CWd7rwGHMWBqA0coxvPZ4wG9YjEuVWhZ1Gz3xLRA=; b=GpM+Q9YpDsIVbE K0v/6adZP7W6OSalaL8v2EVQr0AX6mFhvfNa0GIEMpCZ3B3dGcLltffwX4Rqm6/XZhblYHrGwrdBQ 8q9uToNX8gkQfxKZUKjbQ4hVTeozihvfyRmiNsejNoCYINGPL7dOMlkDJ8GOLkMW9Cmplhjm77d1J fZ47NwP6BczKDnKRyDb8fgm+tFaz7Xqg/3VS+auAc4b4t7zXV48cvjWeczW1UAMiHwVORkJtB+N4V gEvIu2Rb3hmZN+wIqGyrmgcOG32q1kC1QiuAzgf2vxjVmAXtiypjTLgtgA3iminGKrk8vaveOE6YS coU7e33RxlbIovp4OEkw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xYpIx-0000000CZq2-1sYS; Wed, 02 Dec 2026 18:43:47 +0000 Received: from smtpout-03.galae.net ([185.246.85.4]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xYpIv-0000000CZph-2pIm for linux-arm-kernel@lists.infradead.org; Wed, 02 Dec 2026 18:43:46 +0000 Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id 134D94E4184E; Wed, 2 Dec 2026 18:43:44 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id BB2166075F; Wed, 2 Dec 2026 18:43:43 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id B9C7A11EA1D21; Wed, 02 Dec 2026 19:43:34 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1796237018; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:content-language:in-reply-to:references; bh=Nm8CWd7rwGHMWBqA0coxvPZ4wG9YjEuVWhZ1Gz3xLRA=; b=k36U0YzgnOblHk3oHkU0q4RP8YWX5dIAuo4uX6s8Ilu3WC4Ab0/lo3f4yyXNFxxeFxPzuj A3o+V163LHKqjGZ0zqmQEkSvGFcr7w6sdANMLqvKH/aqQFVUlSuJSQzhrIWknnd+vSGqSX N7BPaPL5vjHAZ4JiSXCGRsh15pkGnq7AQvWp4bnB+AwMvFb0hPN8OYsYiwZdBRRrvVtGRm 93Y9wolEsoeZiCP7WXHRRm+jUQMg0EQ0oZKxByH1uSkYV9PHpOHIqacOwUP+hWAaOf/zom b7xigduRx1Qs1aJf2PyPWtZVIkilpgg77WPgseQOAjOFqnsWH0yJj3wN51GE9A== Message-ID: <0418f4e8-47d1-4d18-b9dc-627e098818b3@bootlin.com> Date: Wed, 2 Dec 2026 19:43:33 +0100 X-Archived-By: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH net] net: stmmac: hold the MDIO bus lock during the MAC soft reset To: Savvas Etairidis , netdev@vger.kernel.org Cc: Andrew Lunn , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Alexandre Torgue , linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, saet@hms.se, Andre Pribil , Bela Scholtes , Michail Georgios Etairidis References: <20261202170439.2911343-1-setairidis@gmail.com> From: Maxime Chevallier Content-Language: en-US In-Reply-To: <20261202170439.2911343-1-setairidis@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Last-TLS-Session-Version: TLSv1.3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20261202_104345_887363_D2B725BB X-CRM114-Status: GOOD ( 22.22 ) X-Spam-Score: -2.1 (--) 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=-17.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 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 Hi, On 12/2/26 18:04, Savvas Etairidis wrote: > From: Savvas Etairidis > > The MAC soft reset in stmmac_init_dma_engine() stops the MDIO master. > If an MDIO transaction is in flight at that moment, it is cut off in > the middle of a frame. On a Realtek switch managed over MDIO (SMI), > this was seen to store a value in the wrong register (0x00bb written to > 0x08a2) or leave the switch not answering. > > Take the MDIO bus lock around the reset with stmmac_mdio_lock(), as > dwmac-dwc-qos-eth already does for its pad calibration, so that no > transaction can be running while the reset happens. Every MDIO > transaction holds this lock for the whole frame. > > On two boards, forced MAC resets triggered the corruption within 250 > resets without the lock. With the lock, 36000 forced resets caused > none. > > stmmac_init_dma_engine() is only called from __stmmac_open() and > stmmac_resume(), neither of which holds the bus lock. > > This patch was developed with the help of an AI coding assistant > (Claude Code). It wrote the change and the changelog. I reviewed > both and tested the fix on 6.6.162 hardware (36000 forced MAC resets > with the lock, none failing). > > Fixes: 47dd7a540b8a ("net: add support for STMicroelectronics Ethernet controllers.") > Signed-off-by: Savvas Etairidis I've browsed the docs, this seems to be indeed required. I think this makes sense, Reviewed-by: Maxime Chevallier (out of curiosity, how did you hit that ? it seems fairly rare no ?) Maxime > --- > drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c > index a685ce4638f6..1011e08f20c8 100644 > --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c > +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c > @@ -3331,7 +3331,10 @@ static int stmmac_init_dma_engine(struct stmmac_priv *priv) > if (ret) > return ret; > > + /* The soft reset stops the MDIO master, so keep the bus idle. */ > + stmmac_mdio_lock(priv); > ret = stmmac_reset(priv); > + stmmac_mdio_unlock(priv); > if (ret) { > netdev_err(priv->dev, "Failed to reset the dma\n"); > return ret;