| Message ID | 20260926-submit-stmmac-reset-fixes-v1-v4-2-ec1c0250b3c9@gmail.com (mailing list archive) |
|---|---|
| State | New |
| Headers |
Return-Path: <linux-sunxi+bounces-26268-sunxi=pue.re@lists.linux.dev>
X-Original-To: noreply@patchwork.local
Delivered-To: noreply@patchwork.local
Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74])
by mxe881.netcup.net (Postfix) with ESMTPS id 162351C5FAD
for <noreply@patchwork.local>; Sat, 26 Sep 2026 17:50:43 +0200 (CEST)
Authentication-Results: mxe881;
dkim=pass header.d=gmail.com;
spf=pass (sender IP is 172.232.135.74)
smtp.mailfrom=linux-sunxi+bounces-26268-noreply=patchwork.local@lists.linux.dev
smtp.helo=sto.lore.kernel.org
Received-SPF: pass (mxe881: domain of lists.linux.dev designates
172.232.135.74 as permitted sender) client-ip=172.232.135.74;
envelope-from=linux-sunxi+bounces-26268-noreply=patchwork.local@lists.linux.dev;
helo=sto.lore.kernel.org;
Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org
[100.90.174.1])
by sto.lore.kernel.org (Postfix) with ESMTP id D2ED360A0E5
for <noreply@patchwork.local>; Sat, 26 Sep 2026 15:49:49 +0000 (UTC)
Received: from localhost.localdomain (localhost.localdomain [127.0.0.1])
by smtp.subspace.kernel.org (Postfix) with ESMTP id 25F2E36A36C;
Sat, 26 Sep 2026 15:49:34 +0000 (UTC)
Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com
header.b="Y+NFjYTo"
X-Original-To: linux-sunxi@lists.linux.dev
Received: from mail-oo2-f36.google.com (mail-oo2-f36.google.com
[74.125.231.164])
(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
(No client certificate requested)
by smtp.subspace.kernel.org (Postfix) with ESMTPS id 285C73451C1
for <linux-sunxi@lists.linux.dev>; Sat, 26 Sep 2026 15:49:25 +0000 (UTC)
Authentication-Results: smtp.subspace.kernel.org;
arc=none smtp.client-ip=74.125.231.164
ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;
t=1790437774; cv=none;
b=j6M0biS0hvIcDZGNihsi55g3KVVz0C+CP2teNW4GgmvoLNjdzxLDVDTjUBEtdqEcTDYVXlY2nxoov8p/eIOHyiiWJzVDvkakisX4tG89rkyGyAnd1mnxEFz97UDeT6fGUnTLeIuIM9J6R30Nb7W2Api+zBlQERJ0kgsU0egyz/g=
ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org;
s=arc-20240116; t=1790437774; c=relaxed/simple;
bh=U0usEgD6eBVSyAl+4wuE0PhgO7aYIcSIWGg7AGP8BEg=;
h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References:
In-Reply-To:To:Cc;
b=REFQcx1+ga3y0A27AgnSDYz+a9BLaxECfvQKeUVPpfZ79aJpbd5qUcQT/d6tIrG5jSPw1eKGvvM8/5GFJNM2rRUze415FrbqPHs5x1cyL57oS2IJL+u3kUxmmvpTAMNmoqrfgiiy5ciMjMZL6t7siy08Pq7uoihUmML2oN0WWk0=
ARC-Authentication-Results: i=1; smtp.subspace.kernel.org;
dmarc=pass (p=none dis=none) header.from=gmail.com;
spf=pass smtp.mailfrom=gmail.com;
dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com
header.b=Y+NFjYTo; arc=none smtp.client-ip=74.125.231.164
Authentication-Results: smtp.subspace.kernel.org;
dmarc=pass (p=none dis=none) header.from=gmail.com
Authentication-Results: smtp.subspace.kernel.org;
spf=pass smtp.mailfrom=gmail.com
Received: by mail-oo2-f36.google.com with SMTP id
006d021491bc7-6d77b3455bbso209411eaf.0
for <linux-sunxi@lists.linux.dev>;
Sat, 26 Sep 2026 08:49:25 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20251104; t=1790437763; x=1791042563;
darn=lists.linux.dev;
h=cc:to:in-reply-to:references:message-id:content-transfer-encoding
:content-type:mime-version:subject:date:from:from:to:cc:subject:date
:message-id:reply-to:content-type;
bh=B0ScVIX3sPn/yQi4OeJT/F76Vd8VPP2euaNmJMN8ERw=;
b=Y+NFjYToQ8FUXSLrtY6k56IV5OdHwPHMUAAVpAfZsnx1LMY6jpx/SG6k0HDIe1UZpP
u/1sKpn90KcbNaiuBSPpSnqvknfDwoOr48FUK8SUEn1GgNkzmyrMKD9SRMbu9B8nKsuM
VO+aLbitoIGqciAG25ag8mpux8o4z0LZqDhH/vofwITpUG26mZuE0Xazzusy9PmadeiM
HUg7WTyKQNKLj2tetF8RaIYlkJokSp8qvt0HmEIooIjBws7U+bCtNvmVFfMK2K+5DA3D
G63IuEHZToTJvmooFRhoQjb+f5Cjr1XggNJnZZnXtj0Dp0RhxjebsdVRd+ruz1TU3mWa
IfWw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1790437763; x=1791042563;
h=cc:to:in-reply-to:references:message-id:content-transfer-encoding
:content-type:mime-version:subject:date:from:x-gm-gg
:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to
:content-type;
bh=B0ScVIX3sPn/yQi4OeJT/F76Vd8VPP2euaNmJMN8ERw=;
b=IYVGZHeKx3SrYkq5M4egBeii3FCIPZrV4X67M0NoEXJ1UOMHisbo4szQMiSaberKjR
3XdwccwAJB2D6O5+jl2DOJ8jtqfQHCra4En9BvN3CJO1Chfsv+Te2sksS9yBCcRuN+9j
sHc7jAsshJ0p+gXJjYRFhFYd8sgQMRaaYvFbtO1vp6Pq28tJ7fyKx9nYkhvdF7Fi5JHv
MWP0DXBgae0f/taK8chaGB6Upst2gSk1SMb6bfRcEY/u8wo3fWqlTYLRgBo67IztLYT7
ZBSv3MFS9e+WAYLYaNZlUVv9Ztz5+lI7zIFEG+szFvUlE4LkBhJAwj1ph6xePaZN92ER
uLKA==
X-Forwarded-Encrypted: i=1;
AKwUvBxiSkzqhgbNETC8jVrjaeTWqGF+42S5F7kgcsQOr4NEFR5dAnpIJQ4mj9MZ4CHCd6nS+YFqWLf3daN9vw==@lists.linux.dev
X-Gm-Message-State: AFuF++kNyRO3eHDqPD4590UjCb7s8NGpRvSB6QtViDqvmWc+bxgG3KxZ
LYxPCZ4cC7W54Hyc7L5arUBJWk7sgAzbTvQC9rPvHfvDEhHckuMKnZtz
X-Gm-Gg: AYBFou3otFf5t9KcuHjhCkXxFqQy/ltSbaTn6oR7VSKJhkRpS0b4ihfvxbW3gyrfcmX
3+2Q62f9BOA5ugoOfsWKgv33un4nJ7LiKuhC6xbyKrIqIH2ZJ5RYlB0W9S5TzM5ReDkd6LOsbLQ
khNQzvfiTEnrRvNHQTZirwu5EBBIjtEFW075fo81Vv4+UjApxqjoW/wbPyllp7tgymV+3CVf+Sh
lH1zzY2+rVhzywe1n6kWBTMQGm6EHwxXsXhmRs5gM1xGCbTPeWHh9uYccfpxXfC3JSKDyLi9yvy
H/IK+qMIvOXTqDHDO5Lto169ypKxpC4akK0RTxW36+vAHtguZjLT0Run4gU5hTWcgu9FuZrwbnz
2gtH9vF8KFNNksACdilRm2azeOAf7DvaTBpDdQyrFcmtJszLBcjPm549TEq0tp8skIoVaiNnSxj
GLSmeITz9be2DnYHelJCwt4hYTBaj0JbKGc/jZoKnEXVyArsW+yKbv7LU4ixEnutQzQFPzAcmaU
QcgIeGOYclZ10aO2m1ooLr3a/LN3UDj6LmDxjK3dEx+DRCl9MgLfjJZ8IraWoZ8ikJH830z1XVY
bvL4nxRMhh5F2D2eId3CtE4A+TV0mPI4lXTrNzvsL/5qCEVbqCn/DaabtrDe4T96iYVksOlgelX
HFjQN9RyslYlrwqRcdFyg
X-Received: by 2002:a05:6820:1ca6:b0:6d3:402e:1fca with SMTP id
006d021491bc7-6d43ebf0448mr8754440eaf.9.1790437762887;
Sat, 26 Sep 2026 08:49:22 -0700 (PDT)
Received: from [127.0.1.1] (174-29-1-49.hlrn.qwest.net. [174.29.1.49])
by smtp.gmail.com with ESMTPSA id
46e09a7af769-818e98b16d4sm5442366a34.26.2026.09.26.08.49.20
(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
Sat, 26 Sep 2026 08:49:22 -0700 (PDT)
From: James Hilliard <james.hilliard1@gmail.com>
Date: Sat, 26 Sep 2026 09:48:57 -0600
Subject: [PATCH net v4 02/15] net: stmmac: reuse the MDIO reset GPIO on
resume
Precedence: bulk
X-Mailing-List: linux-sunxi@lists.linux.dev
List-Id: <linux-sunxi.lists.linux.dev>
List-Subscribe: <mailto:linux-sunxi+subscribe@lists.linux.dev>
List-Unsubscribe: <mailto:linux-sunxi+unsubscribe@lists.linux.dev>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
Message-Id:
<20260926-submit-stmmac-reset-fixes-v1-v4-2-ec1c0250b3c9@gmail.com>
References:
<20260926-submit-stmmac-reset-fixes-v1-v4-0-ec1c0250b3c9@gmail.com>
In-Reply-To:
<20260926-submit-stmmac-reset-fixes-v1-v4-0-ec1c0250b3c9@gmail.com>
To: Russell King <linux@armlinux.org.uk>, Andrew Lunn <andrew@lunn.ch>,
Heiner Kallweit <hkallweit1@gmail.com>,
"David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>,
Paolo Abeni <pabeni@redhat.com>, Joakim Zhang <qiangqing.zhang@nxp.com>,
"Russell King (Oracle)" <rmk+kernel@armlinux.org.uk>,
Maxime Chevallier <maxime.chevallier@bootlin.com>,
Andrew Lunn <andrew+netdev@lunn.ch>,
Maxime Coquelin <mcoquelin.stm32@gmail.com>,
Alexandre Torgue <alexandre.torgue@foss.st.com>,
Christian Marangi <ansuelsmth@gmail.com>,
Tiezhu Yang <yangtiezhu@loongson.cn>, Huacai Chen <chenhuacai@kernel.org>,
Alexei Starovoitov <ast@kernel.org>, Daniel Borkmann <daniel@iogearbox.net>,
Jesper Dangaard Brouer <hawk@kernel.org>,
John Fastabend <john.fastabend@gmail.com>,
Stanislav Fomichev <sdf@fomichev.me>, Serge Semin <fancer.lancer@gmail.com>,
Suraj Jaiswal <quic_jsuraj@quicinc.com>,
Richard Cochran <richardcochran@gmail.com>,
Joao Pinto <Joao.Pinto@synopsys.com>,
Vladimir Oltean <vladimir.oltean@nxp.com>,
Ong Boon Leong <boon.leong.ong@intel.com>,
Voon Weifeng <weifeng.voon@intel.com>, "Song,
Yoong Siang" <yoong.siang.song@intel.com>, Linus Walleij <linusw@kernel.org>,
Martin Blumenstingl <martin.blumenstingl@googlemail.com>,
Magnus Karlsson <magnus.karlsson@intel.com>,
Maciej Fijalkowski <maciej.fijalkowski@intel.com>,
Simon Horman <horms@kernel.org>,
=?utf-8?b?QmrDtnJuIFTDtnBlbA==?= <bjorn@kernel.org>,
Thierry Reding <thierry.reding@kernel.org>,
Jonathan Hunter <jonathanh@nvidia.com>, Chen-Yu Tsai <wens@kernel.org>,
Jernej Skrabec <jernej.skrabec@gmail.com>,
Samuel Holland <samuel@sholland.org>, Eric Dumazet <edumazet@kernel.org>
Cc: Richard Genoud <richard.genoud@bootlin.com>,
Alastair D'Silva <alastair@d-silva.org>, Maxime Ripard <mripard@kernel.org>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-stm32@st-md-mailman.stormreply.com,
linux-arm-kernel@lists.infradead.org, bpf@vger.kernel.org,
ZhaoJinming <zhaojinming@uniontech.com>,
Lorenzo Bianconi <lorenzo.bianconi@oss.qualcomm.com>,
Ding Hui <dinghui1111@163.com>, James Hilliard <james.hilliard1@gmail.com>,
linux-tegra@vger.kernel.org, linux-sunxi@lists.linux.dev
X-Mailer: b4 0.15.2
X-MORS-Enabled: yes
X-MORS-DOMAIN: patchwork.local
X-MORS-HOSTING: hosting172546
X-MORS-USER: hosting172546
X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?=
|
| Series |
net: stmmac: preserve datapath state across MTU and resume failures
|
|
Commit Message
James Hilliard
Sept. 26, 2026, 3:48 p.m. UTC
MDIO bus registration acquires the optional snps,reset GPIO through
devres. A later bus reset must reuse that descriptor: requesting the
same exclusive GPIO again returns -EBUSY while devres still owns it.
Cache the successfully acquired descriptor for subsequent resets.
Propagate acquisition errors without caching an error pointer.
Fixes: 7c86f20d15b7 ("net: stmmac: use GPIO descriptors in stmmac_mdio_reset")
Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
---
drivers/net/ethernet/stmicro/stmmac/stmmac.h | 1 +
drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c | 18 ++++++++++++------
2 files changed, 13 insertions(+), 6 deletions(-)
Comments
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider. Critical: 0 · High: 1 · Medium: 0 · 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). - [High] Once the cached descriptor is used, stmmac_mdio_reset() really does pulse the snps,reset PHY reset line on every system resume… - [Low] The commit message explains the mechanism (the second exclusive request of snps,reset returns -EBUSY) but not what users see. -- net: stmmac: reuse the MDIO reset GPIO on resume MDIO bus registration acquires the snps,reset GPIO. This commit caches that descriptor in priv->mdio_reset_gpio, so later calls to stmmac_mdio_reset(), such as the one on resume, reuse it. Without the cache, those calls request the exclusive line again and fail with -EBUSY. > MDIO bus registration acquires the optional snps,reset GPIO through > devres. A later bus reset must reuse that descriptor: requesting the > same exclusive GPIO again returns -EBUSY while devres still owns it. [Severity: Low] This isn't a bug, but could the commit message describe the effect that users see? stmmac_resume() ignores the return value of stmmac_mdio_reset(). Before this patch, on OF boards with a snps,reset GPIO, every resume without MAC WoL silently skipped two things: the PHY reset pulse and the STE101P dummy MDC write: writel(0, priv->ioaddr + mii_address); Nothing was logged when this happened. The message also doesn't say that this change turns the PHY hard reset on resume back on. That reset has not run since 7c86f20d15b7. Without a symptom or behaviour change in the message, stable backporters following the Fixes: tag have nothing to match against bug reports. > diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c > index afe98ff5bdcb0..07d5eab05996b 100644 > --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c > +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c > @@ -386,14 +386,20 @@ int stmmac_mdio_reset(struct mii_bus *bus) > > #ifdef CONFIG_OF > if (priv->device->of_node) { > - struct gpio_desc *reset_gpio; > + struct gpio_desc *reset_gpio = priv->mdio_reset_gpio; > u32 delays[3] = { 0, 0, 0 }; > > - reset_gpio = devm_gpiod_get_optional(priv->device, > - "snps,reset", > - GPIOD_OUT_LOW); > - if (IS_ERR(reset_gpio)) > - return PTR_ERR(reset_gpio); > + /* The bus reset also runs on resume. Devres retains the GPIO > + * until unbind, so do not request an already owned line again. > + */ > + if (!reset_gpio) { > + reset_gpio = devm_gpiod_get_optional(priv->device, > + "snps,reset", > + GPIOD_OUT_LOW); > + if (IS_ERR(reset_gpio)) > + return PTR_ERR(reset_gpio); > + priv->mdio_reset_gpio = reset_gpio; > + } [Severity: High] With the descriptor cached, stmmac_mdio_reset() now really pulses the snps,reset line on every system resume where MAC WoL is off. Does anything re-initialise the PHY after that? Before this patch, the second devm_gpiod_get_optional() on the exclusive line failed in gpiod_request_commit() with -EBUSY. The resume path ignores that error: stmmac_resume() } else { pinctrl_pm_select_default_state(priv->device); /* reset the phy so that it's ready */ if (priv->mii) stmmac_mdio_reset(priv->mii); } So no PHY hard reset has run on resume since 7c86f20d15b7. Before that commit the reset did run, but mdio_bus_phy_resume()->phy_init_hw() followed it. Today stmmac_phylink_setup() sets config->mac_managed_pm = true, and phylink copies that into phydev->mac_managed_pm. As a result, mdio_bus_phy_resume() returns early: mdio_bus_phy_resume() if (phydev->mac_managed_pm) return 0; ... ret = phy_init_hw(phydev); The MAC-managed path only runs phylink_prepare_resume()->phy_resume() and phylink_resume()->phylink_start()->phy_start()->__phy_resume(). Neither of these replays config_init() or config_intr(). Wouldn't that leave the PHY at its power-on or strap defaults while phylib believes it is still configured? The config_init() settings would be lost: RGMII delays or skews, clock-out, LEDs, vendor quirks, and the autonomous EEE disable. For an interrupt-driven PHY, the reset also clears the interrupt enable register. phy_start() restarts aneg, sees link down and moves to PHY_NOLINK, and it does not poll after that. Could link-up then never be reported, so the interface stays down until the admin runs a down/up cycle? PHY-based WoL seems to be affected too. phylink_ethtool_set_wol() removes the modes the PHY handles from the MAC mask: wolopts &= ~w.wolopts; With PHY WoL, priv->wolopts is therefore 0, so resume takes the reset branch. Won't the reset pulse erase the PHY's WoL enables, so the next suspend is not armed for wake? Resume now also blocks for the snps,reset-delays-us msleep() calls. When those delays are 0, the DMA reset in stmmac_hw_setup() needs the PHY RX clock, and it runs right after reset deassert. This also looks unresolved at the end of the series. After "net: stmmac: track datapath and power ownership across failed reopening", stmmac_resume_hw() still calls stmmac_mdio_reset(). stmmac_resume() still only calls phylink_prepare_resume() and phylink_resume() after it, and no phy_init_hw() call was added in stmmac or phylink. This patch carries a Fixes: tag, so it will reach stable. Should the resume path either re-initialise the PHY after the reset, or skip the reset pulse on resume? [ ... ]
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/ethernet/stmicro/stmmac/stmmac.h index 7582fca63741..c7c876408d85 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h @@ -287,6 +287,7 @@ struct stmmac_priv { unsigned int pause_time; struct mii_bus *mii; + struct gpio_desc *mdio_reset_gpio; struct stmmac_pcs *integrated_pcs; diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c index afe98ff5bdcb..07d5eab05996 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c @@ -386,14 +386,20 @@ int stmmac_mdio_reset(struct mii_bus *bus) #ifdef CONFIG_OF if (priv->device->of_node) { - struct gpio_desc *reset_gpio; + struct gpio_desc *reset_gpio = priv->mdio_reset_gpio; u32 delays[3] = { 0, 0, 0 }; - reset_gpio = devm_gpiod_get_optional(priv->device, - "snps,reset", - GPIOD_OUT_LOW); - if (IS_ERR(reset_gpio)) - return PTR_ERR(reset_gpio); + /* The bus reset also runs on resume. Devres retains the GPIO + * until unbind, so do not request an already owned line again. + */ + if (!reset_gpio) { + reset_gpio = devm_gpiod_get_optional(priv->device, + "snps,reset", + GPIOD_OUT_LOW); + if (IS_ERR(reset_gpio)) + return PTR_ERR(reset_gpio); + priv->mdio_reset_gpio = reset_gpio; + } device_property_read_u32_array(priv->device, "snps,reset-delays-us",