diff mbox series

[v3] usb: host: xhci: wait CNR when doing xhci resume

Message ID 1568799691-3853-1-git-send-email-rtseng@nvidia.com (mailing list archive)
State New, archived
Headers show
Series [v3] usb: host: xhci: wait CNR when doing xhci resume | expand

Commit Message

Rick Tseng Sept. 18, 2019, 9:41 a.m. UTC
NVIDIA 3.1 xHCI card would lose power when moving power state into D3Cold.
Thus we need to wait CNR bit to clear when xhci resmue as xhci init.

Signed-off-by: Rick Tseng <rtseng@nvidia.com>
---
 drivers/usb/host/xhci.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

Comments

Mathias Nyman Sept. 23, 2019, 3:06 p.m. UTC | #1
On 18.9.2019 12.41, Rick Tseng wrote:
> NVIDIA 3.1 xHCI card would lose power when moving power state into D3Cold.
> Thus we need to wait CNR bit to clear when xhci resmue as xhci init.
> 
> Signed-off-by: Rick Tseng <rtseng@nvidia.com>

Thanks, added to queue.
Did minor changes to commit message and comment

-Mathias
diff mbox series

Patch

diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 03d1e55..aee1fc5 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -1108,6 +1108,17 @@  int xhci_resume(struct xhci_hcd *xhci, bool hibernated)
 		hibernated = true;
 
 	if (!hibernated) {
+		/* Some xHC would lose power during suspend, so wait for
+		 * controller ready from resume as xHC init.
+		 */
+		retval = xhci_handshake(&xhci->op_regs->status,
+					STS_CNR, 0, 10 * 1000 * 1000);
+		if (retval) {
+			xhci_warn(xhci, "Controller not ready at resume %d\n",
+				  retval);
+			spin_unlock_irq(&xhci->lock);
+			return retval;
+		}
 		/* step 1: restore register */
 		xhci_restore_registers(xhci);
 		/* step 2: initialize command ring buffer */