linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] usb: host: xhci: wait CNR when doing xhci resume
@ 2019-09-06  5:36 Rick Tseng
  2019-09-12  8:10 ` Mathias Nyman
  0 siblings, 1 reply; 2+ messages in thread
From: Rick Tseng @ 2019-09-06  5:36 UTC (permalink / raw)
  To: mathias.nyman, gregkh; +Cc: linux-usb, Rick Tseng

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 | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 03d1e55..6c7102c 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -1108,6 +1108,15 @@ 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.
+		 */
+		if (xhci_handshake(&xhci->op_regs->status,
+				   STS_CNR, 0, 10 * 1000 * 1000)) {
+			xhci_warn(xhci, "WARN: xHC timeout for CNR clear\n");
+			spin_unlock_irq(&xhci->lock);
+			return -ETIMEDOUT;
+		}
 		/* step 1: restore register */
 		xhci_restore_registers(xhci);
 		/* step 2: initialize command ring buffer */
-- 
2.1.4


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

* Re: [PATCH v2] usb: host: xhci: wait CNR when doing xhci resume
  2019-09-06  5:36 [PATCH v2] usb: host: xhci: wait CNR when doing xhci resume Rick Tseng
@ 2019-09-12  8:10 ` Mathias Nyman
  0 siblings, 0 replies; 2+ messages in thread
From: Mathias Nyman @ 2019-09-12  8:10 UTC (permalink / raw)
  To: Rick Tseng, mathias.nyman, gregkh; +Cc: linux-usb

On 6.9.2019 8.36, 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>
> ---
>   drivers/usb/host/xhci.c | 9 +++++++++
>   1 file changed, 9 insertions(+)
> 
> diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
> index 03d1e55..6c7102c 100644
> --- a/drivers/usb/host/xhci.c
> +++ b/drivers/usb/host/xhci.c
> @@ -1108,6 +1108,15 @@ 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.
> +		 */
> +		if (xhci_handshake(&xhci->op_regs->status,
> +				   STS_CNR, 0, 10 * 1000 * 1000)) {
> +			xhci_warn(xhci, "WARN: xHC timeout for CNR clear\n");
> +			spin_unlock_irq(&xhci->lock);
> +			return -ETIMEDOUT;
> +		}

xhci_handshake() can return -ENODEV in case controller is not reachable (still in PCI D3).
Would be better to just show and return what xhci_handshake() returns.
I know there are places where the existing code doesn't do this, but it would be
better to add it for new code

ret = xhci_handshake(CNR bit clear)
if (ret) {
	xhci_warn(xhci, "Controller not ready at resume %d\n", ret);
	unlock()
	return ret
}

-Mathias


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

end of thread, other threads:[~2019-09-12  8:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-06  5:36 [PATCH v2] usb: host: xhci: wait CNR when doing xhci resume Rick Tseng
2019-09-12  8:10 ` Mathias Nyman

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).