From: Alan Stern <stern@rowland.harvard.edu>
To: Lukas Wunner <lukas@wunner.de>
Cc: Andrew Lunn <andrew@lunn.ch>,
Steve Glendinning <steve.glendinning@shawell.net>,
UNGLinuxDriver@microchip.com, Oliver Neukum <oneukum@suse.com>,
"David S. Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
netdev@vger.kernel.org, linux-usb@vger.kernel.org,
Andre Edich <andre.edich@microchip.com>,
Oleksij Rempel <o.rempel@pengutronix.de>,
Martyn Welch <martyn.welch@collabora.com>,
Gabriel Hojda <ghojda@yo2urs.ro>,
Christoph Fritz <chf.fritz@googlemail.com>,
Lino Sanfilippo <LinoSanfilippo@gmx.de>,
Philipp Rosenberger <p.rosenberger@kunbus.com>,
Heiner Kallweit <hkallweit1@gmail.com>,
Russell King <linux@armlinux.org.uk>
Subject: Re: [PATCH net] usbnet: smsc95xx: Fix deadlock on runtime resume
Date: Wed, 27 Apr 2022 14:19:51 -0400 [thread overview]
Message-ID: <YmmJR8i+bCl8ueSX@rowland.harvard.edu> (raw)
In-Reply-To: <20220427153851.GA15329@wunner.de>
On Wed, Apr 27, 2022 at 05:38:51PM +0200, Lukas Wunner wrote:
> On Wed, Apr 27, 2022 at 05:24:50PM +0200, Andrew Lunn wrote:
> > On Wed, Apr 27, 2022 at 08:41:49AM +0200, Lukas Wunner wrote:
> > > Commit 05b35e7eb9a1 ("smsc95xx: add phylib support") amended
> > > smsc95xx_resume() to call phy_init_hw(). That function waits for the
> > > device to runtime resume even though it is placed in the runtime resume
> > > path, causing a deadlock.
> >
> > You have looked at this code, tried a few different things, so this is
> > probably a dumb question.
> >
> > Do you actually need to call phy_init_hw()?
> >
> > mdio_bus_phy_resume() will call phy_init_hw(). So long as you first
> > resume the MAC and then the PHY, shouldn't this just work?
>
> mdio_bus_phy_resume() is only called for system sleep. But this is about
> *runtime* PM.
>
> mdio_bus_phy_pm_ops does not define runtime PM callbacks. So runtime PM
> is disabled on PHYs, no callback is invoked for them when the MAC runtime
> suspends, hence the onus is on the MAC to runtime suspend the PHY (which
> is a child of the MAC). Same on runtime resume.
>
> Let's say I enable runtime PM on the PHY and use pm_runtime_force_suspend()
> to suspend the PHY from the MAC's ->runtime_suspend callback. At that
> point the MAC already has status RPM_SUSPENDING. Boom, deadlock.
>
> The runtime PM core lacks the capability to declare that children should
> be force runtime suspended before a device can runtime suspend, that's
> the problem.
This might work out if you copy the scheme we use for USB devices and
interfaces.
A USB interface is only a logical part of its parent device, and as such
does not have a separate runtime power state of its own (in USB-2, at
least). Therefore the USB core calls pm_runtime_no_callbacks() for each
interface as it is created, and handles the runtime power management for
the interface (i.e., invoking the interface driver's runtime_suspend and
runtime_resume callbacks) from within the device's runtime PM routines
-- independent of the PM core's notion of what the interface's power
state should be.
Similarly, you could call pm_runtime_no_callbacks() for the PHY when it
is created, and manage the PHY's actual power state from within the
MAC's runtime-PM routines directly (i.e., without going through the PM
core).
Alan Stern
next prev parent reply other threads:[~2022-04-27 18:19 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-27 6:41 [PATCH net] usbnet: smsc95xx: Fix deadlock on runtime resume Lukas Wunner
2022-04-27 14:00 ` Alan Stern
2022-04-27 15:10 ` Lukas Wunner
2022-04-27 15:24 ` Andrew Lunn
2022-04-27 15:38 ` Lukas Wunner
2022-04-27 18:19 ` Alan Stern [this message]
2022-04-27 15:45 ` Lukas Wunner
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=YmmJR8i+bCl8ueSX@rowland.harvard.edu \
--to=stern@rowland.harvard.edu \
--cc=LinoSanfilippo@gmx.de \
--cc=UNGLinuxDriver@microchip.com \
--cc=andre.edich@microchip.com \
--cc=andrew@lunn.ch \
--cc=chf.fritz@googlemail.com \
--cc=davem@davemloft.net \
--cc=ghojda@yo2urs.ro \
--cc=hkallweit1@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=lukas@wunner.de \
--cc=martyn.welch@collabora.com \
--cc=netdev@vger.kernel.org \
--cc=o.rempel@pengutronix.de \
--cc=oneukum@suse.com \
--cc=p.rosenberger@kunbus.com \
--cc=pabeni@redhat.com \
--cc=steve.glendinning@shawell.net \
/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