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, 15 Mar 2022 11:18:17 -0400 [thread overview]
Message-ID: <YjCuOXRFZ8CjK9SD@rowland.harvard.edu> (raw)
In-Reply-To: <320584eb-ef89-3759-509c-e7e9cb10f983@zhaoxin.com>
On Tue, Mar 15, 2022 at 08:39:09PM +0800, WeitaoWang-oc@zhaoxin.com wrote:
> On 2022/3/14 10:24, Alan Stern wrote:
> > > + t1 = ehci_readl(ehci, &ehci->regs->status);
> > > + ehci_writel(ehci, t1 & STS_PCD, &ehci->regs->status);
> > > + ehci_readl(ehci, &ehci->regs->status);
> >
> > You should not clear the STS_PCD bit. What if some other port had a
> > status change at the same time? Then because you cleared the
> > port-change-detect bit, the system would not realize that the other port
> > needed to be handled.
>
> I really didn't think about this case.
>
> > Leaving the STS_PCD bit turned on will cause the driver to do a little
> > extra work, but it shouldn't cause any harm.
> >
> I have encountered the following situation if EHCI runtime suspend is
> enabled by default.
>
>
>
> 1.Wake from system to disk and boot OS.
You're talking about resuming after hibernation, 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?
> 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.
> 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?
You know, I'm not at all certain that the callbacks for freeze and
freeze_noirq should ever return anything other than 0. It's okay for
them to call check_root_hub_suspended(), but they should ignore its
return value.
Can you check if the patch below helps?
Alan Stern
Index: usb-devel/drivers/usb/core/hcd-pci.c
===================================================================
--- usb-devel.orig/drivers/usb/core/hcd-pci.c
+++ usb-devel/drivers/usb/core/hcd-pci.c
@@ -575,6 +575,12 @@ static int hcd_pci_resume(struct device
return resume_common(dev, PM_EVENT_RESUME);
}
+static int hcd_pci_freeze_check(struct device *dev)
+{
+ (void) check_root_hub_suspended(dev);
+ return 0;
+}
+
static int hcd_pci_restore(struct device *dev)
{
return resume_common(dev, PM_EVENT_RESTORE);
@@ -586,6 +592,7 @@ static int hcd_pci_restore(struct device
#define hcd_pci_suspend_noirq NULL
#define hcd_pci_resume_noirq NULL
#define hcd_pci_resume NULL
+#define hcd_pci_freeze_check NULL
#define hcd_pci_restore NULL
#endif /* CONFIG_PM_SLEEP */
@@ -616,8 +623,8 @@ const struct dev_pm_ops usb_hcd_pci_pm_o
.suspend_noirq = hcd_pci_suspend_noirq,
.resume_noirq = hcd_pci_resume_noirq,
.resume = hcd_pci_resume,
- .freeze = check_root_hub_suspended,
- .freeze_noirq = check_root_hub_suspended,
+ .freeze = hcd_pci_freeze_check,
+ .freeze_noirq = hcd_pci_freeze_check,
.thaw_noirq = NULL,
.thaw = NULL,
.poweroff = hcd_pci_suspend,
next prev parent reply other threads:[~2022-03-15 15:18 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-14 7:35 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 [this message]
2022-03-16 2:18 ` WeitaoWang-oc
2022-03-22 13:52 ` WeitaoWang-oc
2022-04-05 16:02 ` Alan Stern
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=YjCuOXRFZ8CjK9SD@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
all inboxes | Powered by JetHome®