From: Maxime Chevallier <maxime.chevallier@bootlin.com>
To: Linkui Xiao <xiaolinkui@126.com>,
andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com,
kuba@kernel.org, pabeni@redhat.com, mcoquelin.stm32@gmail.com,
alexandre.torgue@foss.st.com
Cc: netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, Linkui Xiao <xiaolinkui@kylinos.cn>,
stable@vger.kernel.org
Subject: Re: [PATCH net] net: stmmac: request the MDIO reset GPIO only once
Date: Thu, 17 Sep 2026 18:10:03 +0200 [thread overview]
Message-ID: <ff811e9f-4d4b-4b26-a0b5-84cb2eb52618@bootlin.com> (raw)
In-Reply-To: <20260917125457.1353718-1-xiaolinkui@126.com>
Hello,
> @@ -389,11 +389,21 @@ int stmmac_mdio_reset(struct mii_bus *bus)
> struct gpio_desc *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);
> + /* Request the reset line only once and reuse the descriptor
> + * afterwards. A second request of the very same line makes
> + * gpiolib fail with -EBUSY, which devm_gpiod_get_optional()
> + * passes through because it only filters out -ENOENT. The
> + * reset would then abort early and leave the PHY un-reset.
> + */
> + if (!priv->mdio_reset_gpio) {
> + priv->mdio_reset_gpio =
> + devm_gpiod_get_optional(priv->device,
> + "snps,reset",
> + GPIOD_OUT_LOW);
> + if (IS_ERR(priv->mdio_reset_gpio))
> + return PTR_ERR(priv->mdio_reset_gpio);
> + }
> + reset_gpio = priv->mdio_reset_gpio;
The problem is real, but this isn't the correct approach to solve that.
Instead of requesting the reset gpio on-the-fly at reset time (good example
of when not to use devm_xxx) , let's request the gpio at probe time.
I suggest you move the devm_gpiod_get_optional() in stmmac_mdio_register(),
which is called at probe time. Here, it makes sense to use devm_xxx.
Thanks :)
Maxime
next prev parent reply other threads:[~2026-09-17 16:10 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-17 12:54 Linkui Xiao
2026-09-17 16:10 ` Maxime Chevallier [this message]
2026-09-18 8:41 ` Linkui Xiao
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=ff811e9f-4d4b-4b26-a0b5-84cb2eb52618@bootlin.com \
--to=maxime.chevallier@bootlin.com \
--cc=alexandre.torgue@foss.st.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=mcoquelin.stm32@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=stable@vger.kernel.org \
--cc=xiaolinkui@126.com \
--cc=xiaolinkui@kylinos.cn \
/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
all inboxes | Powered by JetHome®