From: Linkui Xiao <xiaolinkui@126.com>
To: James Hilliard <james.hilliard1@gmail.com>,
Linus Walleij <linusw@kernel.org>
Cc: "Russell King" <linux@armlinux.org.uk>,
"Andrew Lunn" <andrew@lunn.ch>,
"Heiner Kallweit" <hkallweit1@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
"Eric Dumazet" <edumazet@google.com>,
"Jakub Kicinski" <kuba@kernel.org>,
"Paolo Abeni" <pabeni@redhat.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>,
"Martin Blumenstingl" <martin.blumenstingl@googlemail.com>,
"Magnus Karlsson" <magnus.karlsson@intel.com>,
"Maciej Fijalkowski" <maciej.fijalkowski@intel.com>,
"Simon Horman" <horms@kernel.org>,
"Björn Töpel" <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>,
"Jose Abreu" <Jose.Abreu@synopsys.com>, "Yao Zi" <me@ziyao.cc>,
"Philipp Zabel" <p.zabel@pengutronix.de>,
"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>,
"Linkui Xiao" <xiaolinkui@kylinos.cn>,
linux-tegra@vger.kernel.org, linux-sunxi@lists.linux.dev,
stable@vger.kernel.org
Subject: Re: [PATCH net-next v5 02/19] net: stmmac: request the MDIO reset GPIO only once
Date: Fri, 9 Oct 2026 17:31:23 +0800 [thread overview]
Message-ID: <544bc0d9-c1c8-461d-aba8-6065409cb53c@126.com> (raw)
In-Reply-To: <CADvTj4pU6EXgx1-dupQoQBm8OrrvAeR5NyCk4of7zya2V=yvEw@mail.gmail.com>
On 2026/9/28 07:49, James Hilliard wrote:
> On Sun, Sep 27, 2026 at 5:35 PM Linus Walleij <linusw@kernel.org> wrote:
>>
>> Hi James,
>>
>> On Sun, Sep 27, 2026 at 11:59 PM James Hilliard
>> <james.hilliard1@gmail.com> wrote:
>>
>>> From: Linkui Xiao <xiaolinkui@kylinos.cn>
>>>
>>> stmmac_mdio_reset() calls devm_gpiod_get_optional() every time it runs.
>>> A GPIO line can only be requested once, so from the second call on
>>> gpiod_request_commit() returns -EBUSY. devm_gpiod_get_optional() only
>>> turns -ENOENT into NULL, hence the error is passed straight back and
>>> stmmac_mdio_reset() bails out before pulsing "snps,reset" and before
>>> running the STE101P MDC workaround.
>>>
>>> The first call, made by of_mdiobus_register(), succeeds, so the failure
>>> is only visible later on: every resume that does not use WoL goes
>>> through stmmac_resume() -> stmmac_mdio_reset(), and that caller ignores
>>> the return value, so the PHY silently stays un-reset.
>>>
>>> The descriptor used to be requested exactly once: stmmac_mdio_reset()
>>> resolved "snps,reset-gpio" itself and cached the GPIO number in
>>> stmmac_mdio_bus_data::reset_gpio, and commit ae26c1c6cb9b ("stmmac: fix
>>> PHY reset during resume") relies on that cache to reuse the line on
>>> every call. commit 7c86f20d15b7 ("net: stmmac: use GPIO descriptors in
>>> stmmac_mdio_reset") replaced it with a devm_gpiod_get_optional() that
>>> caches nothing, so the request is repeated on every call and fails from
>>> the second one on.
>>>
>>> Parse the whole reset description, the GPIO and "snps,reset-delays-us",
>>> in stmmac_mdio_register() at probe time, and keep it in struct
>>> stmmac_priv. This is where devm-gpiod is meant to be used: the line is
>>> acquired with the device and released with it, and any failure to
>>> acquire it is reported during probe instead of being ignored by
>>> stmmac_resume(). stmmac_mdio_reset() then only pulses the cached line,
>>> with the delays that were read once and for all at probe time.
>>>
>>> Cache the request and delays for DT devices regardless of
>>> mdio_bus_data->needs_reset. That flag controls the registration-time
>>> bus reset callback, but system resume calls stmmac_mdio_reset()
>>> directly. The reset routine no longer looks at the device tree: where
>>> the description is absent the cached descriptor is NULL and the delays
>>> are zero, so the pulse remains a no-op.
>>>
>>> Keep acquisition conditional on CONFIG_STMMAC_PLATFORM, matching the
>>> reset callback, so non-platform configurations do not request an unused
>>> GPIO. Also skip acquisition for a disabled MDIO child: registering that
>>> bus returns -ENODEV without calling its reset callback, and the driver
>>> must retain the existing disabled-bus success path even if the unused
>>> GPIO is unavailable. Remove the unnecessary gpio_desc forward declaration.
>>>
>>> Fixes: 7c86f20d15b7 ("net: stmmac: use GPIO descriptors in stmmac_mdio_reset")
>>> Cc: stable@vger.kernel.org
>>> Signed-off-by: Linkui Xiao <xiaolinkui@kylinos.cn>
>>> Co-developed-by: James Hilliard <james.hilliard1@gmail.com>
>>> Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
>>
>> Dostoyevsky commit message, I didn't read it. Ask the agent
>> to be terse.
>
> That commit message style mostly just came from the imported patch,
> I'll change it to be more terse in the next revision:
> https://lore.kernel.org/all/20260921015727.2643540-1-xiaolinkui@126.com/Hi James,
Thanks for picking this up. Agreed the commit message is too long;
I'm fine with you trimming it for the next revision. Linus already
gave his Reviewed-by on the code, so the logic is settled.
Thanks,
Linkui
>
>> I looked at the code and from a GPIO PoV it does the right
>> thing: use 1 as asserted and 0 as de-asserted RESET line.
>>
>> Reviewed-by: Linus Walleij <linusw@kernel.org>
>>
>> Yours,
>> Linus Walleij
next prev parent reply other threads:[~2026-10-09 9:33 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-27 21:59 [PATCH net-next v5 00/19] net: stmmac: preserve datapath state across MTU and resume failures James Hilliard
2026-09-27 21:59 ` [PATCH net-next v5 01/19] net: stmmac: unwind the WoL IRQ after a safety IRQ request failure James Hilliard
2026-09-27 21:59 ` [PATCH net-next v5 02/19] net: stmmac: request the MDIO reset GPIO only once James Hilliard
2026-09-27 23:35 ` Linus Walleij
2026-09-27 23:49 ` James Hilliard
2026-10-09 9:31 ` Linkui Xiao [this message]
2026-09-27 21:59 ` [PATCH net-next v5 03/19] net: phylink: allow stopping a suspended instance James Hilliard
2026-09-27 21:59 ` [PATCH net-next v5 04/19] xsk: freeze deferred pool teardown during system sleep James Hilliard
2026-09-28 12:16 ` Björn Töpel
2026-09-27 21:59 ` [PATCH net-next v5 05/19] net: stmmac: embed struct stmmac_est in stmmac_priv struct James Hilliard
2026-09-27 21:59 ` [PATCH net-next v5 06/19] net: stmmac: pass the desired EST enable state to est_configure() James Hilliard
2026-09-27 21:59 ` [PATCH net-next v5 07/19] net: stmmac: re-apply taprio offload in __stmmac_open() and stmmac_resume() James Hilliard
2026-09-27 21:59 ` [PATCH net-next v5 08/19] net: stmmac: serialize and retain PHC configuration across reset James Hilliard
2026-09-27 21:59 ` [PATCH net-next v5 09/19] net: stmmac: leave the datapath running for normal-size MTU changes James Hilliard
2026-09-27 21:59 ` [PATCH net-next v5 10/19] net: stmmac: fix error path cleanup in DMA descriptor ring allocation James Hilliard
2026-09-27 21:59 ` [PATCH net-next v5 11/19] net: stmmac: complete DMA configuration allocation unwind James Hilliard
2026-09-27 21:59 ` [PATCH net-next v5 12/19] net: stmmac: keep DMA configurations at stable addresses James Hilliard
2026-09-27 21:59 ` [PATCH net-next v5 13/19] net: stmmac: track datapath and power ownership across failed reopening James Hilliard
2026-09-27 21:59 ` [PATCH net-next v5 14/19] net: stmmac: use the tracked datapath restart for XSK pool changes James Hilliard
2026-09-27 21:59 ` [PATCH net-next v5 15/19] net: stmmac: restore TC offloads before restarting DMA James Hilliard
2026-09-28 22:00 ` sashiko-bot
2026-09-27 21:59 ` [PATCH net-next v5 16/19] xsk: allow drivers to retain DMA mappings independently of pools James Hilliard
2026-09-28 12:22 ` Björn Töpel
2026-09-27 21:59 ` [PATCH net-next v5 17/19] net: stmmac: retain DMA memory until hardware shutdown completes James Hilliard
2026-09-28 22:00 ` sashiko-bot
2026-09-27 21:59 ` [PATCH net-next v5 18/19] net: stmmac: prepare device-local DMA interrupt quiescence James Hilliard
2026-09-27 21:59 ` [PATCH net-next v5 19/19] net: stmmac: retain DMA resources across MTU changes James Hilliard
2026-09-27 22:10 ` [PATCH net-next v5 00/19] net: stmmac: preserve datapath state across MTU and resume failures Jakub Kicinski
2026-09-27 23:15 ` James Hilliard
2026-09-28 6:50 ` Maxime Chevallier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=544bc0d9-c1c8-461d-aba8-6065409cb53c@126.com \
--to=xiaolinkui@126.com \
--cc=Joao.Pinto@synopsys.com \
--cc=Jose.Abreu@synopsys.com \
--cc=alastair@d-silva.org \
--cc=alexandre.torgue@foss.st.com \
--cc=andrew+netdev@lunn.ch \
--cc=andrew@lunn.ch \
--cc=ansuelsmth@gmail.com \
--cc=ast@kernel.org \
--cc=bjorn@kernel.org \
--cc=boon.leong.ong@intel.com \
--cc=bpf@vger.kernel.org \
--cc=chenhuacai@kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=dinghui1111@163.com \
--cc=edumazet@google.com \
--cc=fancer.lancer@gmail.com \
--cc=hawk@kernel.org \
--cc=hkallweit1@gmail.com \
--cc=horms@kernel.org \
--cc=james.hilliard1@gmail.com \
--cc=jernej.skrabec@gmail.com \
--cc=john.fastabend@gmail.com \
--cc=jonathanh@nvidia.com \
--cc=kuba@kernel.org \
--cc=linusw@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=linux-sunxi@lists.linux.dev \
--cc=linux-tegra@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=lorenzo.bianconi@oss.qualcomm.com \
--cc=maciej.fijalkowski@intel.com \
--cc=magnus.karlsson@intel.com \
--cc=martin.blumenstingl@googlemail.com \
--cc=maxime.chevallier@bootlin.com \
--cc=mcoquelin.stm32@gmail.com \
--cc=me@ziyao.cc \
--cc=mripard@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=p.zabel@pengutronix.de \
--cc=pabeni@redhat.com \
--cc=quic_jsuraj@quicinc.com \
--cc=richard.genoud@bootlin.com \
--cc=richardcochran@gmail.com \
--cc=rmk+kernel@armlinux.org.uk \
--cc=samuel@sholland.org \
--cc=sdf@fomichev.me \
--cc=stable@vger.kernel.org \
--cc=thierry.reding@kernel.org \
--cc=vladimir.oltean@nxp.com \
--cc=weifeng.voon@intel.com \
--cc=wens@kernel.org \
--cc=xiaolinkui@kylinos.cn \
--cc=yangtiezhu@loongson.cn \
--cc=yoong.siang.song@intel.com \
--cc=zhaojinming@uniontech.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox