public inbox for linux-pm@vger.kernel.org
 help / color / mirror / Atom feed
From: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>,
	Thinh Nguyen <Thinh.Nguyen@synopsys.com>,
	ryan zhou <ryanzhou54@gmail.com>, Roy Luo <royluo@google.com>,
	"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
	"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-pm@vger.kernel.org" <linux-pm@vger.kernel.org>
Subject: Re: [PATCH] drvier: usb: dwc3: Fix runtime PM trying to activate child device xxx.dwc3 but parent is not active
Date: Fri, 12 Sep 2025 22:23:29 +0000	[thread overview]
Message-ID: <20250912222321.ct5ezgvsgyvos2ah@synopsys.com> (raw)
In-Reply-To: <385dccf3-234a-4f83-9610-81ac30bf1466@rowland.harvard.edu>

On Thu, Sep 04, 2025, Alan Stern wrote:
> On Thu, Sep 04, 2025 at 07:34:22PM +0200, Rafael J. Wysocki wrote:
> > On Thu, Sep 4, 2025 at 4:19 PM Alan Stern <stern@rowland.harvard.edu> wrote:
> > >
> > > On Thu, Sep 04, 2025 at 04:08:47PM +0200, Rafael J. Wysocki wrote:
> 
> > > > Say this is not the case and say that the device is runtime-suspended
> > > > to start with.  Then the "suspend" callback has two choices: either
> > > > (1) it can runtime-resume the device before doing anything to it,
> > > > which will also cause the device's parent and suppliers to
> > > > runtime-resume, or (2) it can update the device's state without
> > > > resuming it.
> > > >
> > > > If it chooses (1), then "resume" is straightforward.  If it chooses
> > > > (2), "resume" may just reverse the changes made by "suspend" and
> > > > declare that the device is runtime-suspended.  And if it really really
> > > > wants to resume the device then, why not call runtime_resume() on it?
> > >
> > > That's what I meant by needing "cooperation from the driver".  The
> > > driver's ->resume callback needs to do this check to see which pathway
> > > to follow: (1) or (2).
> > 
> > Unless "suspend" always does the same thing, so it always does (1) or
> > it always does (2).
> > 
> > In that case, "resume" will know what to do without checking.
> 
> It still has to check whether the device is runtime suspended.
> 
> > I'd like to mention that if "suspend" chooses (2), it may need to
> > resume the suspended parent or suppliers to be able to access the
> > device even though the device itself won't be resumed.  I'm not sure
> > if (2) is really attractive then, though.
> 
> True.
> 
> > Also, in the example we've been considering so far, the assumption is
> > that B can just stay in runtime suspend, so why would it need to be
> > resumed by "resume"?  And if there is a specific reason for resuming
> > it, "resume" can just call runtime_resume() on it AFAICS.
> 
> So it appears to boil down to this, as far as ->resume is concerned: At 
> the start of the callback routine, there should be something like:
> 
> 	if (pm_runtime_suspended(dev)) {
> 		if (the device needs to be woken up) {
> 			pm_runtime_resume(dev);
> 			... whatever else is needed ...
> 		}
> 		return 0;
> 	}
> 
> If ->suspend is clever, it can clear or set the SMART_SUSPEND flag 
> according to whether the device will need to be woken up.  Then the 
> second conditional above will always be true whenever the callback runs, 
> so the test can be skipped.
> 

So, can this solution be the default behavior in the PM core? That it
would initiate pm_runtime_resume by default?

Seems you want this to be handled in the device driver and not PM core
right? ie. the condition "the device needs to be woken up" will not be a
PM user flag/config but the device driver needs to check that itself.

BR,
Thinh

  parent reply	other threads:[~2025-09-12 22:23 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20250826150826.11096-1-ryanzhou54@gmail.com>
     [not found] ` <CA+zupgwnbt=5Oh28Chco=YNt9WwKzi2J+0hQ04nqyZG_7WUAYg@mail.gmail.com>
     [not found]   ` <CAPwe5RMpdG1ziRAwDhqkxuzHX0x=SdFQRFUbPCVuir1OgE90YQ@mail.gmail.com>
2025-08-27 14:52     ` [PATCH] drvier: usb: dwc3: Fix runtime PM trying to activate child device xxx.dwc3 but parent is not active Alan Stern
2025-08-27 18:56       ` Rafael J. Wysocki
2025-08-29  0:43         ` Thinh Nguyen
2025-08-29  1:25           ` Alan Stern
2025-08-29 19:07             ` Thinh Nguyen
2025-08-29 19:26               ` Rafael J. Wysocki
2025-08-29 20:13                 ` Thinh Nguyen
2025-08-30  0:46                   ` Alan Stern
2025-08-30  1:14                     ` Thinh Nguyen
2025-08-29 19:23             ` Rafael J. Wysocki
2025-08-29 19:58               ` Alan Stern
2025-09-01 19:41                 ` Rafael J. Wysocki
2025-09-01 20:40                   ` Rafael J. Wysocki
2025-09-02  2:41                     ` Alan Stern
2025-09-03 11:51                       ` ryan zhou
2025-09-03 19:30                       ` Rafael J. Wysocki
2025-09-03 21:54                         ` Alan Stern
2025-09-04 14:08                           ` Rafael J. Wysocki
2025-09-04 14:19                             ` Alan Stern
2025-09-04 14:33                               ` Rafael J. Wysocki
2025-09-04 17:34                               ` Rafael J. Wysocki
2025-09-04 18:54                                 ` Alan Stern
2025-09-09 16:19                                   ` [PATCH v2] " Ryan Zhou
2025-09-09 16:25                                     ` Greg KH
2025-09-10 12:26                                       ` [PATCH v3] " Ryan Zhou
2025-09-10 12:56                                       ` [PATCH v2] " ryan zhou
2025-09-10 13:07                                         ` Greg KH
2025-09-11 13:25                                           ` ryan zhou
2025-09-11  1:32                                     ` Thinh Nguyen
2025-09-11 10:52                                       ` Xu Yang
2025-09-11 11:35                                         ` Rafael J. Wysocki
2025-09-11 13:56                                           ` ryan zhou
2025-09-11 13:58                                             ` Rafael J. Wysocki
2025-09-12  7:51                                           ` Xu Yang
2025-09-12 21:38                                             ` Thinh Nguyen
2025-09-11 13:51                                         ` ryan zhou
2025-09-12  7:49                                           ` Xu Yang
2025-09-11 13:40                                       ` ryan zhou
2025-09-12 21:36                                         ` Thinh Nguyen
2025-09-12 22:23                                   ` Thinh Nguyen [this message]
2025-09-13 12:43                                     ` [PATCH] " Rafael J. Wysocki

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=20250912222321.ct5ezgvsgyvos2ah@synopsys.com \
    --to=thinh.nguyen@synopsys.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=rafael@kernel.org \
    --cc=royluo@google.com \
    --cc=ryanzhou54@gmail.com \
    --cc=stern@rowland.harvard.edu \
    /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