linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alan Stern <stern@rowland.harvard.edu>
To: "WeitaoWang-oc@zhaoxin.com" <WeitaoWang-oc@zhaoxin.com>
Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org,
	linux-kernel@vger.kernel.org, CobeChen@zhaoxin.com,
	TimGuo@zhaoxin.com, tonywwang@zhaoxin.com,
	weitaowang@zhaoxin.com
Subject: Re: [PATCH] USB:Fix ehci infinite suspend-resume loop issue in zhaoxin
Date: Tue, 5 Apr 2022 12:02:37 -0400	[thread overview]
Message-ID: <YkxoHY2SVomGwGdh@rowland.harvard.edu> (raw)
In-Reply-To: <ac40c227-ea26-bccd-d254-5a2034103184@zhaoxin.com>

On Wed, Mar 16, 2022 at 10:18:39AM +0800, WeitaoWang-oc@zhaoxin.com wrote:
> On 2022/3/15 11:18, Alan Stern wrote:
> > On Tue, Mar 15, 2022 at 08:39:09PM +0800, WeitaoWang-oc@zhaoxin.com wrote:
> > > I have encountered the following situation if EHCI runtime suspend is
> > > enabled by default.

Some things about this still confuse me...

> > > 1.Wake from system to disk and boot OS.
> > 
> > You're talking about resuming after hibernation, right?
> 
> You're right.
> > > 2.EHCI will entry runtime suspend after enumerated by driver during boot
> > > phase of suspend to disk
> > 
> > I'm not sure what you mean by "boot phase of suspend to disk".  This is
> > while the restore kernel is starting up at the beginning of resume from
> > hibernation, right?
> > 
> You understood exactly what I was saying.

Okay, so we're waking up from hibernation.

> > > 3.EHCI will be placed to freeze state and ehci_resume is called after image
> > > is loaded.
> > 
> > ehci_resume is called to leave runtime suspend.  Going into the freeze
> > state doesn't require any changes.

In fact, the resume kernel doesn't call ehci_resume at all.  Here's what 
it does:

	The resume kernel boots;

	If your patch causes STS_PCD to be set at this point, the flag 
	should get cleared shortly afterward by ehci_irq;

	ehci-hcd goes into runtime suspend;

	The kernel reads the system image that was stored earlier when
	hibernation began;

	After the image is loaded, the system goes into the freeze
	state (this does not call any routines in ehci-hcd);

	The resume kernel transfers control to the image kernel;

Now the image kernel is running.  It goes into the restore state, which 
involves calling ehci_resume.  Presumably your patch cases the STS_PCD 
flag to get set at this point.

But that's all!  The system is now back up, out of hibernation, and 
running normally.  There are no more calls to check_root_hub_suspended

> > > 4.If PCD flag is set(caused by patch), then HCD_FLAG_RH_RUNNING will be set.
> > > 
> > > 5.Pci_pm_freeze_noirq is called to check ehci root hub state and return
> > > value is -EBUSY. which will cause
> > >   quiesce phase of suspend to disk fail.
> > 
> > You're talking about check_root_hub_suspended() in hcd-pci.c, right?
> > 
> It's right.

So how can this happen, given that the image kernel doesn't call 
pci_pm_freeze_noirq?

Alan Stern

  parent reply	other threads:[~2022-04-05 23:41 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-14  7:35 [PATCH] USB:Fix ehci infinite suspend-resume loop issue in zhaoxin WeitaoWang-oc
2022-03-14  7:45 ` Greg KH
2022-03-14 14:24 ` Alan Stern
2022-03-15 12:39   ` WeitaoWang-oc
2022-03-15 15:18     ` Alan Stern
2022-03-16  2:18       ` WeitaoWang-oc
2022-03-22 13:52         ` WeitaoWang-oc
2022-04-05 16:02         ` Alan Stern [this message]
2022-04-06  2:38           ` WeitaoWang-oc
2022-04-06 16:20             ` Alan Stern
2022-04-07  6:15               ` WeitaoWang-oc
2022-04-07 14:22                 ` Alan Stern

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=YkxoHY2SVomGwGdh@rowland.harvard.edu \
    --to=stern@rowland.harvard.edu \
    --cc=CobeChen@zhaoxin.com \
    --cc=TimGuo@zhaoxin.com \
    --cc=WeitaoWang-oc@zhaoxin.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=tonywwang@zhaoxin.com \
    --cc=weitaowang@zhaoxin.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 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).