Re: [PATCH] usb: host: xhci: add mutex for non-thread-safe data

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Apr 29, 2015 at 09:18:50AM +0100, Chris Bainbridge wrote:
> Regression in commit 638139eb95d2d241781330a321e88c8dafe46078
> Author: Petr Mladek <pmladek@xxxxxxx>
> Date:   Fri Sep 19 17:32:24 2014 +0200
> 
>     usb: hub: allow to process more usb hub events in parallel
> 
> The regression resulted in intermittent failure to initialise a 10-port
> hub (with three internal VL812 4-port hub controllers) on boot, with a
> failure rate of around 8%, due to multiple race conditions when
> accessing addr_dev and slot_id in struct xhci_hcd.

That would explain why I haven't seen this before 3.18...

> This regression also exposed a problem with xhci_setup_device, which
> "should be protected by the usb_address0_mutex" but no longer is due to
> commit 6fecd4f:
> Author: Todd E Brandt <todd.e.brandt@xxxxxxxxxxxxxxx>
> Date:   Mon May 19 10:55:32 2014 -0700
> 
>     USB: separate usb_address0 mutexes for each bus
> 
> With separate buses (and locks) it is no longer the case that a single
> lock will protect xhci_setup_device from accesses by two parallel
> threads processing events on the two buses.

...even though this one went into 3.16 (and I must just have been lucky
not to hit it with 3.18).

> Fix this by adding a mutex to protect addr_dev and slot_id in struct
> xhci_hcd, and by making the assignment of slot_id atomic.
> 
> Fixes multiple boot errors:
> 
>  [    0.583008] xhci_hcd 0000:00:14.0: Bad Slot ID 2
>  [    0.583009] xhci_hcd 0000:00:14.0: Could not allocate xHCI USB device data structures
>  [    0.583012] usb usb1-port3: couldn't allocate usb_device
> 
> And:
> 
>  [    0.637409] xhci_hcd 0000:00:14.0: Error while assigning device slot ID
>  [    0.637417] xhci_hcd 0000:00:14.0: Max number of devices this xHCI host supports is 32.
>  [    0.637421] usb usb1-port1: couldn't allocate usb_device
> 
> And:
> 
>  [    0.753372] xhci_hcd 0000:00:14.0: ERROR: unexpected setup context command completion code 0x0.
>  [    0.753373] usb 1-3: hub failed to enable device, error -22
>  [    0.753400] xhci_hcd 0000:00:14.0: Error while assigning device slot ID
>  [    0.753402] xhci_hcd 0000:00:14.0: Max number of devices this xHCI host supports is 32.
>  [    0.753403] usb usb1-port3: couldn't allocate usb_device
> 
> And:
> 
> [   11.018386] usb 1-3: device descriptor read/all, error -110
> 
> And:
> 
> [    5.753838] xhci_hcd 0000:00:14.0: Timeout while waiting for setup device command
> 
> Tested with 200 reboots, resulting in no USB hub init related errors.

Great, thanks for looking into this!

Mathias will review your suggested fix.

Thanks,
Johan
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux