All of lore.kernel.org
 help / color / mirror / Atom feed
From: Brian Norris <briannorris@chromium.org>
To: "Rafael J. Wysocki (Intel)" <rafael@kernel.org>
Cc: Ulf Hansson <ulf.hansson@oss.qualcomm.com>,
	Linux PM <linux-pm@vger.kernel.org>,
	Alan Stern <stern@rowland.harvard.edu>,
	Sakari Ailus <sakari.ailus@linux.intel.com>,
	Linux Driver Core Development <driver-core@lists.linux.dev>,
	Javen Xu <javen_xu@realsil.com.cn>, Andrew Lunn <andrew@lunn.ch>
Subject: Re: [PATCH v2 2/2] PM: runtime: Call rpm_idle() in rpm_resume() for active devices
Date: Mon, 30 Nov 2026 16:37:23 -0800	[thread overview]
Message-ID: <aw4WwwCvh_cbkKpu@google.com> (raw)
In-Reply-To: <CAJZ5v0hXKK0ACrA43hpQQ=d+WP5BDNECzctxUxMQyPbrE=yAqw@mail.gmail.com>

+ CC Javen Xu, Andrew Lunn for r8169

On Mon, Nov 30, 2026 at 08:25:22PM +0100, Rafael J. Wysocki (Intel) wrote:
> On Mon, Nov 30, 2026 at 6:24 PM Rafael J. Wysocki (Intel)
> <rafael@kernel.org> wrote:
> >
> > On Mon, Nov 30, 2026 at 6:08 PM Ulf Hansson
> > <ulf.hansson@oss.qualcomm.com> wrote:
> > >
> > > On Mon, Nov 30, 2026 at 4:08 PM Rafael J. Wysocki <rafael@kernel.org> wrote:

> > > > Address this by rearranging rpm_resume() to call rpm_idle() also if the
> > > > device was already active and drop the direct last_busy update carried
> > > > out in that case as it is not necessary any more because rpm_idle()
> > > > updates last_busy.  Also make the rpm_resume() kerneldoc comment match
> > > > the new code flow.
> > >
> > > While I in principle agree with the change, I am slightly worried
> > > about users that call pm_runtime_resume() and who call pm_runtime_get*
> > > quite soon after. I can tell if this is a common behaviour, but I am
> > > sure I have seen something like that.

This can also be pm_request_resume(), for the record.

> 
> Out of curiosity, where have you seen it?
> 
> There are not too many direct callers of pm_runtime_resume() in the
> tree and the majority of them don't do anything like this AFAICS.

I'm not quite sure about the particular pattern Ulf mentions, but I see
lots of sketchy code the more I look.

e.g., the dedicated wakeirq stuff here makes me scratch my head some:

  56f487c78015 PM / Runtime: Update last_busy in rpm_resume
  4990d4fe327b PM / Wakeirq: Add automated device wake IRQ handling

Commit 56f487c78015 seems to suggest it's relying on a non-zero
autosuspend delay to avoid problems. (Very sketchy IMO.) I can't tell if
those are actual functional problems, or if that was just a suboptimal
behavior / performance problem.

Or maybe some Intel soundwire / intel_component_probe() (with
comments!)? And there's a lot of similar-looking code elsewhere in
sound/.

t7xx_mode_store() (drivers/net/wwan/t7xx/t7xx_pci.c) looks buggy too.

I think those tend to use autosuspend delays. But see below.

> > Did you check?
> >
> > I don't know how many of them there are, if that's what you're asking,
> > but they should at least use an autosuspend delay.

Even autosuspend delay is risky, as that's just asking for a race
condition. Any such users need refcounts, or proper failsafes in
.runtime_idle()/.runtime_suspend(). And it's quite subtle to get the
non-refcount approaches correct.

There are some strange ones that I pointed out here:

https://lore.kernel.org/all/aweHkBnEGG5f8veE@google.com/

    drivers/net/ethernet/intel/e1000e/netdev.c
    drivers/net/ethernet/intel/igb/igb_main.c
    drivers/net/ethernet/intel/igc/igc_main.c

I think they're functionally correct (due to .runtime_idle()
safeguards), even if strange.

But drivers/net/ethernet/realtek/r8169_main.c is a similar one, that I
believe is functionally wrong today, and possibly made worse with your
patch.

Specifically, see:

  phylink_link_up -> rtl_mac_link_up() -> pm_request_resume()

In that context, netif_carrier_on() has not yet run, and so
rtl8169_runtime_idle() may still rearm its suspend timer
(pm_schedule_suspend()). Because rtl8169_runtime_suspend() does *not*
recheck netif_carrier_ok(), this means that 10 seconds later, we may
runtime-suspend an active link.

I believe this technically regressed with commit 8a3c76523e44 ("r8169:
add support for phylink"), where the calling conditions for
pm_request_resume() changed.

I'm no netdev / phylink expert, but it feels like maybe the driver
should be doing get()/put() in .mac_link_{up,down}(), rather than
relying only on carefully crafted .runtime_idle() + pm_request_resume().

> > Also note that if the initial pm_runtime_resume() resumes the device
> > and there is no autosuspend delay, it will suspend immediately even
> > without this change.
> >
> > > Anyway, for these cases we may end up doing an unnecessary round of
> > > suspend/resume of the device. Maybe not a big deal, but something that
> > > could have a negative impact on probing/boot.

If it's "only" unnecessary suspend/resume, I think we could live with
it, or patch them up later. I'm a bit more worried about all the
functional bugs hiding around the tree.

> > If this adversely affects anyone, I'd like to understand why and help
> > them to do the right thing because they are probably doing something
> > super-fragile that works incidentally.
> >
> > To me, consistency in the core is more important than preserving the
> > existing behavior to support such fragile cases.

I agree, I think anything that's noticing this change is at best fragile
and probably buggy. It's probably worth making sure we don't completely
break obvious stuff, but I don't think we can maintain every fragile
thing that exists today.

Brian

  reply	other threads:[~2026-12-01  0:37 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-30 15:01 [PATCH v2 0/2] PM: runtime: Consolidation of last_busy updates and calling rpm_idle() in rpm_resume() Rafael J. Wysocki
2026-11-30 15:04 ` [PATCH v2 1/2] PM: runtime: Drop redundant last_busy update from rpm_resume() Rafael J. Wysocki
2026-11-30 17:09   ` Ulf Hansson
2026-11-30 15:07 ` [PATCH v2 2/2] PM: runtime: Call rpm_idle() in rpm_resume() for active devices Rafael J. Wysocki
2026-11-30 17:08   ` Ulf Hansson
2026-11-30 17:24     ` Rafael J. Wysocki (Intel)
2026-11-30 19:25       ` Rafael J. Wysocki (Intel)
2026-12-01  0:37         ` Brian Norris [this message]
2026-12-01 14:08           ` Rafael J. Wysocki (Intel)
2026-12-01 20:13             ` Brian Norris
2026-12-01  9:16       ` Ulf Hansson
2026-12-01 13:36         ` Rafael J. Wysocki (Intel)
2026-12-01 15:15   ` Ulf Hansson
2026-12-01 23:46 ` [PATCH v2 0/2] PM: runtime: Consolidation of last_busy updates and calling rpm_idle() in rpm_resume() Brian Norris

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=aw4WwwCvh_cbkKpu@google.com \
    --to=briannorris@chromium.org \
    --cc=andrew@lunn.ch \
    --cc=driver-core@lists.linux.dev \
    --cc=javen_xu@realsil.com.cn \
    --cc=linux-pm@vger.kernel.org \
    --cc=rafael@kernel.org \
    --cc=sakari.ailus@linux.intel.com \
    --cc=stern@rowland.harvard.edu \
    --cc=ulf.hansson@oss.qualcomm.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.