From: "Russell King (Oracle)" <linux@armlinux.org.uk>
To: Gatien CHEVALLIER <gatien.chevallier@foss.st.com>
Cc: Andrew Lunn <andrew@lunn.ch>,
Krzysztof Kozlowski <krzk@kernel.org>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Maxime Coquelin <mcoquelin.stm32@gmail.com>,
Alexandre Torgue <alexandre.torgue@foss.st.com>,
Christophe Roullier <christophe.roullier@foss.st.com>,
Heiner Kallweit <hkallweit1@gmail.com>,
Simon Horman <horms@kernel.org>,
Tristram Ha <Tristram.Ha@microchip.com>,
Florian Fainelli <florian.fainelli@broadcom.com>,
netdev@vger.kernel.org, devicetree@vger.kernel.org,
linux-stm32@st-md-mailman.stormreply.com,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next 1/4] dt-bindings: net: document st,phy-wol property
Date: Wed, 23 Jul 2025 10:20:59 +0100 [thread overview]
Message-ID: <aICpe63iqldl9NFd@shell.armlinux.org.uk> (raw)
In-Reply-To: <5a2e0cd8-6d20-4f5a-a3a0-9010305509e3@foss.st.com>
On Wed, Jul 23, 2025 at 10:50:12AM +0200, Gatien CHEVALLIER wrote:
> On 7/22/25 22:20, Russell King (Oracle) wrote:
> > On Tue, Jul 22, 2025 at 03:40:16PM +0200, Andrew Lunn wrote:
> > > I know Russell has also replied about issues with stmmac. Please
> > > consider that when reading what i say... It might be not applicable.
> > >
> > > > Seems like a fair and logical approach. It seems reasonable that the
> > > > MAC driver relies on the get_wol() API to know what's supported.
> > > >
> > > > The tricky thing for the PHY used in this patchset is to get this
> > > > information:
> > > >
> > > > Extract from the documentation of the LAN8742A PHY:
> > > > "The WoL detection can be configured to assert the nINT interrupt pin
> > > > or nPME pin"
> > >
> > > https://www.kernel.org/doc/Documentation/devicetree/bindings/power/wakeup-source.txt
> > >
> > > It is a bit messy, but in the device tree, you could have:
> > >
> > > interrupts = <&sirq 0 IRQ_TYPE_LEVEL_LOW>
> > > <&pmic 42 IRQ_TYPE_LEVEL_LOW>;
> > > interrupt-names = "nINT", "wake";
> > > wakeup-source
> > >
> > > You could also have:
> > >
> > > interrupts = <&sirq 0 IRQ_TYPE_LEVEL_LOW>;
> > > interrupt-names = "wake";
> > > wakeup-source
> > >
> > > In the first example, since there are two interrupts listed, it must
> > > be using the nPME. For the second, since there is only one, it must be
> > > using nINT.
> > >
> > > Where this does not work so well is when you have a board which does
> > > not have nINT wired, but does have nPME. The phylib core will see
> > > there is an interrupt and request it, and disable polling. And then
> > > nothing will work. We might be able to delay solving that until such a
> > > board actually exists?
> >
> > (Officially, I'm still on vacation...)
> >
> > At this point, I'd like to kick off a discussion about PHY-based
> > wakeup that is relevant to this thread.
> >
> > The kernel has device-based wakeup support. We have:
> >
> > - device_set_wakeup_capable(dev, flag) - indicates that the is
> > capable of waking the system depending on the flag.
> >
> > - device_set_wakeup_enable(dev, flag) - indicates whether "dev"
> > has had wake-up enabled or disabled depending on the flag.
> >
> > - dev*_pm_set_wake_irq(dev, irq) - indicates to the wake core that
> > the indicated IRQ is capable of waking the system, and the core
> > will handle enabling/disabling irq wake capabilities on the IRQ
> > as appropriate (dependent on device_set_wakeup_enable()). Other
> > functions are available for wakeup IRQs that are dedicated to
> > only waking up the system (e.g. the WOL_INT pin on AR8031).
> >
> > Issue 1. In stmmac_init_phy(), we have this code:
> >
> > if (!priv->plat->pmt) {
> > struct ethtool_wolinfo wol = { .cmd = ETHTOOL_GWOL };
> >
> > phylink_ethtool_get_wol(priv->phylink, &wol);
> > device_set_wakeup_capable(priv->device, !!wol.supported);
> > device_set_wakeup_enable(priv->device, !!wol.wolopts);
> > }
> >
> > This reads the WoL state from the PHY (a different struct device)
> > and sets the wakeup capability and enable state for the _stmmac_
> > device accordingly, but in the case of PHY based WoL, it's the PHY
> > doing the wakeup, not the MAC. So this seems wrong on the face of
> > it.
>
> 2 cents: Maybe even remove in stmmac_set_wol() if !priv->plat->pmt.
On the face of it, that seems like a sane solution, but sadly we
can't do that. If we did, then at least Jetson Xavier NX would break if
WoL were enabled, because DT describes the PHY interrupt, and currently
the PHY driver switches the interrupt pin from interrupt mode (where it
signals link changes) to PMEB mode (where it only pulses when a wake-up
packet is received) when WoL is enabled at the PHY. This will mean
phylib won't receive link state interrupts anymore, so unplugging/
replugging the cable won't be detected by phylib.
Even my further suggestions do not get us to a state where we can pass
the set_wol() to the PHY, and then work out what the MAC needs to do,
because e.g. in the case of RTL8211F, even if we use the "wakeup-source"
to fix the above, we still have the problem of "is wake-up supported
by the PHY wiring or is it not". We just have not described that in the
DT trees for platforms, so this is basically unknown.
Adding any logic to the kernel to make that decision will cause
regressions - either by making WoL unavailable on platforms where it
previously worked (e.g. because PHY WoL was being used) or the opposite
(where MAC WoL was used but now PHY WoL gets used but isn't wired.)
This is why I say we've boxed ourselves into a corner on this - this is
not phylib maintainers fault, because we can't know everything about
every device out there, and we don't have time to read every damn data
sheet which may or may not be publically available. We have to go by
what submitters provide us, which leads to problems like this.
So, we need flexibility from everyone to try and find a way forward.
We can't have people sticking to ideals - such as DT maintainers being
rigid about "DT describes hardware only". As I've already stated, our
DT currently does *not* describe hardware with respect to PHY wake-up,
and because this has been overlooked, we're now in a mess where there
is *no* easy solutions, and no solution that could be said to purely
describe hardware.
If we didn't have any PHY drivers, and were starting afresh, then we
would have the latitude to come up with something clean. That boat has
long since sailed.
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
next prev parent reply other threads:[~2025-07-23 9:21 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-21 11:14 [PATCH net-next 0/4] net: add WoL from PHY support for stm32mp135f-dk Gatien Chevallier
2025-07-21 11:14 ` [PATCH net-next 1/4] dt-bindings: net: document st,phy-wol property Gatien Chevallier
2025-07-21 11:30 ` Krzysztof Kozlowski
2025-07-21 12:10 ` Gatien CHEVALLIER
2025-07-21 12:16 ` Krzysztof Kozlowski
2025-07-21 12:54 ` Gatien CHEVALLIER
2025-07-21 13:18 ` Andrew Lunn
2025-07-21 15:56 ` Gatien CHEVALLIER
2025-07-21 17:07 ` Andrew Lunn
2025-07-21 18:08 ` Florian Fainelli
2025-07-22 9:08 ` Gatien CHEVALLIER
2025-07-22 13:40 ` Andrew Lunn
2025-07-22 20:20 ` Russell King (Oracle)
2025-07-22 20:30 ` Florian Fainelli
2025-07-22 20:59 ` Andrew Lunn
2025-07-22 21:39 ` Russell King (Oracle)
2025-07-22 22:00 ` Russell King (Oracle)
2025-07-22 22:57 ` Russell King (Oracle)
2025-07-23 14:02 ` Andrew Lunn
2025-07-23 14:23 ` Andrew Lunn
2025-07-23 18:13 ` Florian Fainelli
2025-07-23 8:50 ` Gatien CHEVALLIER
2025-07-23 8:53 ` Gatien CHEVALLIER
2025-07-23 9:25 ` Russell King (Oracle)
2025-07-23 9:20 ` Russell King (Oracle) [this message]
2025-07-23 14:35 ` Gatien CHEVALLIER
2025-07-22 9:13 ` Russell King (Oracle)
2025-07-22 7:32 ` Russell King (Oracle)
2025-07-22 9:10 ` Gatien CHEVALLIER
2025-07-21 11:14 ` [PATCH net-next 2/4] net: stmmac: stm32: add WoL from PHY support Gatien Chevallier
2025-07-21 11:14 ` [PATCH net-next 3/4] net: phy: smsc: fix and improve WoL support Gatien Chevallier
2025-07-21 11:28 ` Russell King (Oracle)
2025-07-21 12:23 ` Gatien CHEVALLIER
2025-07-21 13:26 ` Andrew Lunn
2025-07-21 14:19 ` Gatien CHEVALLIER
2025-07-21 14:23 ` Andrew Lunn
2025-07-21 11:14 ` [PATCH net-next 4/4] arm: dts: st: activate ETH1 WoL from PHY on stm32mp135f-dk Gatien 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=aICpe63iqldl9NFd@shell.armlinux.org.uk \
--to=linux@armlinux.org.uk \
--cc=Tristram.Ha@microchip.com \
--cc=alexandre.torgue@foss.st.com \
--cc=andrew+netdev@lunn.ch \
--cc=andrew@lunn.ch \
--cc=christophe.roullier@foss.st.com \
--cc=conor+dt@kernel.org \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=edumazet@google.com \
--cc=florian.fainelli@broadcom.com \
--cc=gatien.chevallier@foss.st.com \
--cc=hkallweit1@gmail.com \
--cc=horms@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=krzk@kernel.org \
--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=robh@kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).