linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mathias Nyman <mathias.nyman@linux.intel.com>
To: Rick Tseng <rtseng@nvidia.com>,
	mathias.nyman@intel.com, gregkh@linuxfoundation.org
Cc: linux-usb@vger.kernel.org
Subject: Re: [PATCH v2] usb: host: xhci: wait CNR when doing xhci resume
Date: Thu, 12 Sep 2019 11:10:06 +0300	[thread overview]
Message-ID: <2c771924-920f-c81a-b69b-806df8687838@linux.intel.com> (raw)
In-Reply-To: <1567748218-6656-1-git-send-email-rtseng@nvidia.com>

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


      reply	other threads:[~2019-09-12  8:08 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

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=2c771924-920f-c81a-b69b-806df8687838@linux.intel.com \
    --to=mathias.nyman@linux.intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mathias.nyman@intel.com \
    --cc=rtseng@nvidia.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).