From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=185.246.85.4 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796237032; b=b/TFCwoYx2TPxC9BII/PdOC0/nOpths4FFNxtT4sPMxpqgujKMf3KQeDjql6cuQsB+j8 9gR7NEmYktjjV5+w6AVe0mcZRIG6ZOEBTZh97CCcGopHMLLa+/bNxO00JT5zic1zNIqxG f3cgr5L1VcZmDNBTXn8m73wyICauVXigaLIW644tT1/IZEuyA/xywwjGK3mT4ELggPaGk nP6iz14beLQbeUUGQlRPg3d4j4pbXDf5jAVy8OOC/h9aJIwzhYqpA/OrOPXBNcr3Nc8R6 28mFuRpvYynuy//pqBv5m33sZ6XqEJAiRArqA48GHPXE0P777afVneZA7XonYZlf8EA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796237032; h=DMARC-Filter:Received:Received:Received:DKIM-Signature:Message-ID: Date:MIME-Version:User-Agent:Subject:To:Cc:References:From: Content-Language:In-Reply-To:Content-Type:Content-Transfer-Encoding: X-Last-TLS-Session-Version; bh=Nm8CWd7rwGHMWBqA0coxvPZ4wG9YjEuVWhZ1Gz3xLRA=; b=C5sN1ZfHDJILf90uEfvoyxwPifUhN9P5HPWRhJRA+4u5hdFaqQQi75tH10EJbbzDS3j2 lzNcQN+rVORyFvyVVMjwalZ/+3d7vLDCTz5/VUl1HkuwjGpD7iucZKi3+oWeI67gI6zR3 J4Pfz5CDOI7rDmyTEX/fBJD1WqGfjXFXK9VC2ImH8E+fhV8sAG66ne5yjsBK2v/+T0nvM CoN2Q/gu17HwuNpsluH4BR465d77/ZeOdqVXdyCgKFu6L75YCSTUOGbOCZHN75BmNJ/at TLE1uAPpjxfWsU+AT104+Nq5HPQL1P3ezQ39/IHLYGd/cQTsVdX3P6pBBwHA1ZkJW8w== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass header.d=bootlin.com header.i=@bootlin.com header.a=rsa-sha256 header.s=dkim header.b=k36U0Yzg; arc=none smtp.remote-ip=185.246.85.4 Received: from smtpout-03.galae.net (smtpout-03.galae.net [185.246.85.4]) (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 71C4460A2613 for ; Wed, 2 Dec 2026 18:43:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 71C4460A2613 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.a=rsa-sha256 header.s=dkim header.b=k36U0Yzg 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-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list 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 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;