Re: [PATCH 4/5] usb: xhci: stop everything on the first call to xhci_stop

From: Roger Quadros
Date: Thu Aug 20 2015 - 02:42:18 EST




On 18/08/15 15:14, Mathias Nyman wrote:
> 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@xxxxxx>
>> ---
>> 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.

Yes, that was my intention :)

cheers,
-roger
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/