mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] usb: xhci: dbc: Don't decrement runtime PM counter if DBC is not started
@ 2018-06-25  5:20 Kai-Heng Feng
  2018-06-25  8:25 ` Mathias Nyman
  0 siblings, 1 reply; 2+ messages in thread
From: Kai-Heng Feng @ 2018-06-25  5:20 UTC (permalink / raw)
  To: mathias.nyman; +Cc: gregkh, linux-usb, linux-kernel, Kai-Heng Feng

pm_runtime_put_sync() gets called everytime in xhci_dbc_stop().

If dbc is not started, this makes the runtime PM counter incorrectly
becomes 0, and calls autosuspend function. Then we'll keep seeing this:
[54664.762220] xhci_hcd 0000:00:14.0: Root hub is not suspended

So only calls pm_runtime_put_sync() when dbc was started.

Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
---
 drivers/usb/host/xhci-dbgcap.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/host/xhci-dbgcap.c b/drivers/usb/host/xhci-dbgcap.c
index 1fbfd89d0a0f..387f124a8334 100644
--- a/drivers/usb/host/xhci-dbgcap.c
+++ b/drivers/usb/host/xhci-dbgcap.c
@@ -508,16 +508,18 @@ static int xhci_do_dbc_start(struct xhci_hcd *xhci)
 	return 0;
 }
 
-static void xhci_do_dbc_stop(struct xhci_hcd *xhci)
+static int xhci_do_dbc_stop(struct xhci_hcd *xhci)
 {
 	struct xhci_dbc		*dbc = xhci->dbc;
 
 	if (dbc->state == DS_DISABLED)
-		return;
+		return -1;
 
 	writel(0, &dbc->regs->control);
 	xhci_dbc_mem_cleanup(xhci);
 	dbc->state = DS_DISABLED;
+
+	return 0;
 }
 
 static int xhci_dbc_start(struct xhci_hcd *xhci)
@@ -544,6 +546,7 @@ static int xhci_dbc_start(struct xhci_hcd *xhci)
 
 static void xhci_dbc_stop(struct xhci_hcd *xhci)
 {
+	int ret;
 	unsigned long		flags;
 	struct xhci_dbc		*dbc = xhci->dbc;
 	struct dbc_port		*port = &dbc->port;
@@ -556,10 +559,11 @@ static void xhci_dbc_stop(struct xhci_hcd *xhci)
 		xhci_dbc_tty_unregister_device(xhci);
 
 	spin_lock_irqsave(&dbc->lock, flags);
-	xhci_do_dbc_stop(xhci);
+	ret = xhci_do_dbc_stop(xhci);
 	spin_unlock_irqrestore(&dbc->lock, flags);
 
-	pm_runtime_put_sync(xhci_to_hcd(xhci)->self.controller);
+	if (!ret)
+		pm_runtime_put_sync(xhci_to_hcd(xhci)->self.controller);
 }
 
 static void
-- 
2.17.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] usb: xhci: dbc: Don't decrement runtime PM counter if DBC is not started
  2018-06-25  5:20 [PATCH] usb: xhci: dbc: Don't decrement runtime PM counter if DBC is not started Kai-Heng Feng
@ 2018-06-25  8:25 ` Mathias Nyman
  0 siblings, 0 replies; 2+ messages in thread
From: Mathias Nyman @ 2018-06-25  8:25 UTC (permalink / raw)
  To: Kai-Heng Feng, mathias.nyman; +Cc: gregkh, linux-usb, linux-kernel

On 25.06.2018 08:20, Kai-Heng Feng wrote:
> pm_runtime_put_sync() gets called everytime in xhci_dbc_stop().
> 
> If dbc is not started, this makes the runtime PM counter incorrectly
> becomes 0, and calls autosuspend function. Then we'll keep seeing this:
> [54664.762220] xhci_hcd 0000:00:14.0: Root hub is not suspended
> 
> So only calls pm_runtime_put_sync() when dbc was started.
> 
> Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>

Thanks, nice catch.
Adding to queue

-Mathias


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-06-25  8:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-25  5:20 [PATCH] usb: xhci: dbc: Don't decrement runtime PM counter if DBC is not started Kai-Heng Feng
2018-06-25  8:25 ` Mathias Nyman

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®