public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Mathias Nyman <mathias.nyman@intel.com>
To: Roger Quadros <rogerq@ti.com>
Cc: balbi@ti.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 4/5] usb: xhci: stop everything on the first call to xhci_stop
Date: Tue, 18 Aug 2015 15:14:14 +0300	[thread overview]
Message-ID: <55D32196.2010704@intel.com> (raw)
In-Reply-To: <1439894354-6160-5-git-send-email-rogerq@ti.com>

On 18.08.2015 13:39, Roger Quadros wrote:
> xhci_stop will be called twice, once for the shared hcd
> and again for the primary hcd.
>
> We stop the XHCI controller in any case so clean up
> everything on the first call else we can timeout
> waiting for pending requests to complete.
>
> Signed-off-by: Roger Quadros <rogerq@ti.com>
> ---
>   drivers/usb/host/xhci.c | 20 +++++---------------
>   1 file changed, 5 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
> index d5f44b1..9a7f12c 100644
> --- a/drivers/usb/host/xhci.c
> +++ b/drivers/usb/host/xhci.c
> @@ -655,15 +655,6 @@ int xhci_run(struct usb_hcd *hcd)
>   }
>   EXPORT_SYMBOL_GPL(xhci_run);
>
> -static void xhci_only_stop_hcd(struct usb_hcd *hcd)
> -{
> -	struct xhci_hcd *xhci = hcd_to_xhci(hcd);
> -
> -	spin_lock_irq(&xhci->lock);
> -	xhci_halt(xhci);
> -	spin_unlock_irq(&xhci->lock);
> -}
> -
>   /*
>    * Stop xHCI driver.
>    *
> @@ -678,15 +669,14 @@ void xhci_stop(struct usb_hcd *hcd)
>   	u32 temp;
>   	struct xhci_hcd *xhci = hcd_to_xhci(hcd);
>
> -	mutex_lock(&xhci->mutex);
> -
> -	if (!usb_hcd_is_primary_hcd(hcd)) {
> -		xhci_only_stop_hcd(xhci->shared_hcd);
> -		mutex_unlock(&xhci->mutex);
> +	if (xhci->xhc_state & XHCI_STATE_HALTED)
>   		return;
> -	}
>
> +	mutex_lock(&xhci->mutex);
>   	spin_lock_irq(&xhci->lock);
> +	xhci->xhc_state |= XHCI_STATE_HALTED;
> +	xhci->cmd_ring_state = CMD_RING_STATE_STOPPED;
> +

The XHCI_STATE_HALTED and CMD_RING_STATE_STOPPED states will be set in xhci_halt() right
after this.
Well, or,  it actually sets them after waiting for the controller to really halt.

I guess setting them here helps the second call to hcd_stop() to return early, not taking the mutex and
trying to stop controller once again.

Applied
-Mathias

  reply	other threads:[~2015-08-18 12:12 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-18 10:39 [PATCH 0/5] usb: xhci: Fix breakage on dual-role case Roger Quadros
2015-08-18 10:39 ` [PATCH 1/5] usb: xhci: lock mutex on xhci_stop Roger Quadros
2015-08-18 11:39   ` Mathias Nyman
2015-08-18 10:39 ` [PATCH 2/5] usb: hcd: Initialize hcd->flags to 0 Roger Quadros
2015-08-18 10:39 ` [PATCH 3/5] usb: xhci: Clear XHCI_STATE_DYING on start Roger Quadros
2015-08-18 11:43   ` Mathias Nyman
2015-08-18 10:39 ` [PATCH 4/5] usb: xhci: stop everything on the first call to xhci_stop Roger Quadros
2015-08-18 12:14   ` Mathias Nyman [this message]
2015-08-20  6:42     ` Roger Quadros
2015-08-18 10:39 ` [PATCH 5/5] usb: xhci: exit early in xhci_setup_device() if we're halted or dying Roger Quadros
2015-08-18 12:17   ` Mathias Nyman
2015-08-20  7:09 ` [PATCH 0/5] usb: xhci: Fix breakage on dual-role case Roger Quadros
2015-08-27 11:18   ` Mathias Nyman

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=55D32196.2010704@intel.com \
    --to=mathias.nyman@intel.com \
    --cc=balbi@ti.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=rogerq@ti.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