<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux-toradex.git/include/linux/usb/hcd.h, branch v4.11-rc3</title>
<subtitle>Linux kernel for Apalis and Colibri modules</subtitle>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/'/>
<entry>
<title>usb: hcd.h: construct hub class request constants from simpler constants</title>
<updated>2016-12-05T15:37:10+00:00</updated>
<author>
<name>Tal Shorer</name>
<email>tal.shorer@gmail.com</email>
</author>
<published>2016-11-18T12:17:26+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=b9c2a2a39898d55b9fe13aa1fe15891e37bc9087'/>
<id>b9c2a2a39898d55b9fe13aa1fe15891e37bc9087</id>
<content type='text'>
Currently, each hub class request constant is defined by a line like:
#define ClearHubFeature		(0x2000 | USB_REQ_CLEAR_FEATURE)

The "magic" number for the high byte is one of 0x20, 0xa0, 0x23, 0xa3.
The 0x80 bit that changes inditace USB_DIR_IN, and the 0x03 that
pops up is the difference between USB_RECIP_DEVICE (0x00) and
USB_RECIP_OTHER (0x03). The constant 0x20 bit is USB_TYPE_CLASS.

This patch eliminates those magic numbers by defining a macro to help
construct these hub class request from simpler constants.
Note that USB_RT_HUB is defined as (USB_TYPE_CLASS | USB_RECIP_DEVICE)
and that USB_RT_PORT is defined as (USB_TYPE_CLASS | USB_RECIP_OTHER).

Signed-off-by: Tal Shorer &lt;tal.shorer@gmail.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Currently, each hub class request constant is defined by a line like:
#define ClearHubFeature		(0x2000 | USB_REQ_CLEAR_FEATURE)

The "magic" number for the high byte is one of 0x20, 0xa0, 0x23, 0xa3.
The 0x80 bit that changes inditace USB_DIR_IN, and the 0x03 that
pops up is the difference between USB_RECIP_DEVICE (0x00) and
USB_RECIP_OTHER (0x03). The constant 0x20 bit is USB_TYPE_CLASS.

This patch eliminates those magic numbers by defining a macro to help
construct these hub class request from simpler constants.
Note that USB_RT_HUB is defined as (USB_TYPE_CLASS | USB_RECIP_DEVICE)
and that USB_RT_PORT is defined as (USB_TYPE_CLASS | USB_RECIP_OTHER).

Signed-off-by: Tal Shorer &lt;tal.shorer@gmail.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>usb: core: hub: hub_port_init lock controller instead of bus</title>
<updated>2016-04-28T19:40:46+00:00</updated>
<author>
<name>Chris Bainbridge</name>
<email>chris.bainbridge@gmail.com</email>
</author>
<published>2016-04-25T12:48:38+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=feb26ac31a2a5cb88d86680d9a94916a6343e9e6'/>
<id>feb26ac31a2a5cb88d86680d9a94916a6343e9e6</id>
<content type='text'>
The XHCI controller presents two USB buses to the system - one for USB2
and one for USB3. The hub init code (hub_port_init) is reentrant but
only locks one bus per thread, leading to a race condition failure when
two threads attempt to simultaneously initialise a USB2 and USB3 device:

[    8.034843] xhci_hcd 0000:00:14.0: Timeout while waiting for setup device command
[   13.183701] usb 3-3: device descriptor read/all, error -110

On a test system this failure occurred on 6% of all boots.

The call traces at the point of failure are:

Call Trace:
 [&lt;ffffffff81b9bab7&gt;] schedule+0x37/0x90
 [&lt;ffffffff817da7cd&gt;] usb_kill_urb+0x8d/0xd0
 [&lt;ffffffff8111e5e0&gt;] ? wake_up_atomic_t+0x30/0x30
 [&lt;ffffffff817dafbe&gt;] usb_start_wait_urb+0xbe/0x150
 [&lt;ffffffff817db10c&gt;] usb_control_msg+0xbc/0xf0
 [&lt;ffffffff817d07de&gt;] hub_port_init+0x51e/0xb70
 [&lt;ffffffff817d4697&gt;] hub_event+0x817/0x1570
 [&lt;ffffffff810f3e6f&gt;] process_one_work+0x1ff/0x620
 [&lt;ffffffff810f3dcf&gt;] ? process_one_work+0x15f/0x620
 [&lt;ffffffff810f4684&gt;] worker_thread+0x64/0x4b0
 [&lt;ffffffff810f4620&gt;] ? rescuer_thread+0x390/0x390
 [&lt;ffffffff810fa7f5&gt;] kthread+0x105/0x120
 [&lt;ffffffff810fa6f0&gt;] ? kthread_create_on_node+0x200/0x200
 [&lt;ffffffff81ba183f&gt;] ret_from_fork+0x3f/0x70
 [&lt;ffffffff810fa6f0&gt;] ? kthread_create_on_node+0x200/0x200

Call Trace:
 [&lt;ffffffff817fd36d&gt;] xhci_setup_device+0x53d/0xa40
 [&lt;ffffffff817fd87e&gt;] xhci_address_device+0xe/0x10
 [&lt;ffffffff817d047f&gt;] hub_port_init+0x1bf/0xb70
 [&lt;ffffffff811247ed&gt;] ? trace_hardirqs_on+0xd/0x10
 [&lt;ffffffff817d4697&gt;] hub_event+0x817/0x1570
 [&lt;ffffffff810f3e6f&gt;] process_one_work+0x1ff/0x620
 [&lt;ffffffff810f3dcf&gt;] ? process_one_work+0x15f/0x620
 [&lt;ffffffff810f4684&gt;] worker_thread+0x64/0x4b0
 [&lt;ffffffff810f4620&gt;] ? rescuer_thread+0x390/0x390
 [&lt;ffffffff810fa7f5&gt;] kthread+0x105/0x120
 [&lt;ffffffff810fa6f0&gt;] ? kthread_create_on_node+0x200/0x200
 [&lt;ffffffff81ba183f&gt;] ret_from_fork+0x3f/0x70
 [&lt;ffffffff810fa6f0&gt;] ? kthread_create_on_node+0x200/0x200

Which results from the two call chains:

hub_port_init
 usb_get_device_descriptor
  usb_get_descriptor
   usb_control_msg
    usb_internal_control_msg
     usb_start_wait_urb
      usb_submit_urb / wait_for_completion_timeout / usb_kill_urb

hub_port_init
 hub_set_address
  xhci_address_device
   xhci_setup_device

Mathias Nyman explains the current behaviour violates the XHCI spec:

 hub_port_reset() will end up moving the corresponding xhci device slot
 to default state.

 As hub_port_reset() is called several times in hub_port_init() it
 sounds reasonable that we could end up with two threads having their
 xhci device slots in default state at the same time, which according to
 xhci 4.5.3 specs still is a big no no:

 "Note: Software shall not transition more than one Device Slot to the
  Default State at a time"

 So both threads fail at their next task after this.
 One fails to read the descriptor, and the other fails addressing the
 device.

Fix this in hub_port_init by locking the USB controller (instead of an
individual bus) to prevent simultaneous initialisation of both buses.

Fixes: 638139eb95d2 ("usb: hub: allow to process more usb hub events in parallel")
Link: https://lkml.org/lkml/2016/2/8/312
Link: https://lkml.org/lkml/2016/2/4/748
Signed-off-by: Chris Bainbridge &lt;chris.bainbridge@gmail.com&gt;
Cc: stable &lt;stable@vger.kernel.org&gt;
Acked-by: Mathias Nyman &lt;mathias.nyman@linux.intel.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The XHCI controller presents two USB buses to the system - one for USB2
and one for USB3. The hub init code (hub_port_init) is reentrant but
only locks one bus per thread, leading to a race condition failure when
two threads attempt to simultaneously initialise a USB2 and USB3 device:

[    8.034843] xhci_hcd 0000:00:14.0: Timeout while waiting for setup device command
[   13.183701] usb 3-3: device descriptor read/all, error -110

On a test system this failure occurred on 6% of all boots.

The call traces at the point of failure are:

Call Trace:
 [&lt;ffffffff81b9bab7&gt;] schedule+0x37/0x90
 [&lt;ffffffff817da7cd&gt;] usb_kill_urb+0x8d/0xd0
 [&lt;ffffffff8111e5e0&gt;] ? wake_up_atomic_t+0x30/0x30
 [&lt;ffffffff817dafbe&gt;] usb_start_wait_urb+0xbe/0x150
 [&lt;ffffffff817db10c&gt;] usb_control_msg+0xbc/0xf0
 [&lt;ffffffff817d07de&gt;] hub_port_init+0x51e/0xb70
 [&lt;ffffffff817d4697&gt;] hub_event+0x817/0x1570
 [&lt;ffffffff810f3e6f&gt;] process_one_work+0x1ff/0x620
 [&lt;ffffffff810f3dcf&gt;] ? process_one_work+0x15f/0x620
 [&lt;ffffffff810f4684&gt;] worker_thread+0x64/0x4b0
 [&lt;ffffffff810f4620&gt;] ? rescuer_thread+0x390/0x390
 [&lt;ffffffff810fa7f5&gt;] kthread+0x105/0x120
 [&lt;ffffffff810fa6f0&gt;] ? kthread_create_on_node+0x200/0x200
 [&lt;ffffffff81ba183f&gt;] ret_from_fork+0x3f/0x70
 [&lt;ffffffff810fa6f0&gt;] ? kthread_create_on_node+0x200/0x200

Call Trace:
 [&lt;ffffffff817fd36d&gt;] xhci_setup_device+0x53d/0xa40
 [&lt;ffffffff817fd87e&gt;] xhci_address_device+0xe/0x10
 [&lt;ffffffff817d047f&gt;] hub_port_init+0x1bf/0xb70
 [&lt;ffffffff811247ed&gt;] ? trace_hardirqs_on+0xd/0x10
 [&lt;ffffffff817d4697&gt;] hub_event+0x817/0x1570
 [&lt;ffffffff810f3e6f&gt;] process_one_work+0x1ff/0x620
 [&lt;ffffffff810f3dcf&gt;] ? process_one_work+0x15f/0x620
 [&lt;ffffffff810f4684&gt;] worker_thread+0x64/0x4b0
 [&lt;ffffffff810f4620&gt;] ? rescuer_thread+0x390/0x390
 [&lt;ffffffff810fa7f5&gt;] kthread+0x105/0x120
 [&lt;ffffffff810fa6f0&gt;] ? kthread_create_on_node+0x200/0x200
 [&lt;ffffffff81ba183f&gt;] ret_from_fork+0x3f/0x70
 [&lt;ffffffff810fa6f0&gt;] ? kthread_create_on_node+0x200/0x200

Which results from the two call chains:

hub_port_init
 usb_get_device_descriptor
  usb_get_descriptor
   usb_control_msg
    usb_internal_control_msg
     usb_start_wait_urb
      usb_submit_urb / wait_for_completion_timeout / usb_kill_urb

hub_port_init
 hub_set_address
  xhci_address_device
   xhci_setup_device

Mathias Nyman explains the current behaviour violates the XHCI spec:

 hub_port_reset() will end up moving the corresponding xhci device slot
 to default state.

 As hub_port_reset() is called several times in hub_port_init() it
 sounds reasonable that we could end up with two threads having their
 xhci device slots in default state at the same time, which according to
 xhci 4.5.3 specs still is a big no no:

 "Note: Software shall not transition more than one Device Slot to the
  Default State at a time"

 So both threads fail at their next task after this.
 One fails to read the descriptor, and the other fails addressing the
 device.

Fix this in hub_port_init by locking the USB controller (instead of an
individual bus) to prevent simultaneous initialisation of both buses.

Fixes: 638139eb95d2 ("usb: hub: allow to process more usb hub events in parallel")
Link: https://lkml.org/lkml/2016/2/8/312
Link: https://lkml.org/lkml/2016/2/4/748
Signed-off-by: Chris Bainbridge &lt;chris.bainbridge@gmail.com&gt;
Cc: stable &lt;stable@vger.kernel.org&gt;
Acked-by: Mathias Nyman &lt;mathias.nyman@linux.intel.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>usb: core: rename mutex usb_bus_list_lock to usb_bus_idr_lock</title>
<updated>2016-02-07T05:55:57+00:00</updated>
<author>
<name>Heiner Kallweit</name>
<email>hkallweit1@gmail.com</email>
</author>
<published>2016-02-03T22:35:23+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=a4b5d606b957c6a58e991de63fe999492de1ab92'/>
<id>a4b5d606b957c6a58e991de63fe999492de1ab92</id>
<content type='text'>
Now that usb_bus_list has been removed and switched to idr
rename the related mutex accordingly.

Signed-off-by: Heiner Kallweit &lt;hkallweit1@gmail.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Now that usb_bus_list has been removed and switched to idr
rename the related mutex accordingly.

Signed-off-by: Heiner Kallweit &lt;hkallweit1@gmail.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>usb: core: switch bus numbering to using idr</title>
<updated>2016-02-03T21:26:30+00:00</updated>
<author>
<name>Heiner Kallweit</name>
<email>hkallweit1@gmail.com</email>
</author>
<published>2016-01-25T19:30:30+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=5363de75307e333d89df7531f9dd8310d973ecdb'/>
<id>5363de75307e333d89df7531f9dd8310d973ecdb</id>
<content type='text'>
USB bus numbering is based on directly dealing with bitmaps and
defines a separate list of busses.
This can be simplified and unified by using existing idr functionality.

Signed-off-by: Heiner Kallweit &lt;hkallweit1@gmail.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
USB bus numbering is based on directly dealing with bitmaps and
defines a separate list of busses.
This can be simplified and unified by using existing idr functionality.

Signed-off-by: Heiner Kallweit &lt;hkallweit1@gmail.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>USB: constify usb_mon_operations structure</title>
<updated>2015-12-01T22:36:29+00:00</updated>
<author>
<name>Julia Lawall</name>
<email>julia.lawall@lip6.fr</email>
</author>
<published>2015-11-28T15:07:10+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=6fb8ac81cb3125aafc7136f2ef0145da792bab94'/>
<id>6fb8ac81cb3125aafc7136f2ef0145da792bab94</id>
<content type='text'>
The usb_mon_operations structure is never modified, so declare it as const.

Done with the help of Coccinelle.

Signed-off-by: Julia Lawall &lt;Julia.Lawall@lip6.fr&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The usb_mon_operations structure is never modified, so declare it as const.

Done with the help of Coccinelle.

Signed-off-by: Julia Lawall &lt;Julia.Lawall@lip6.fr&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>usb: define HCD_USB31 speed option for hosts that support USB 3.1 features</title>
<updated>2015-10-04T09:34:17+00:00</updated>
<author>
<name>Mathias Nyman</name>
<email>mathias.nyman@linux.intel.com</email>
</author>
<published>2015-10-01T15:40:37+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=7117522520b9101af7a0602d6b0d1e67d689fc6b'/>
<id>7117522520b9101af7a0602d6b0d1e67d689fc6b</id>
<content type='text'>
Hosts that support USB 3.1 Enhaned SuperSpeed can set their speed to
HCD_USB31 to let usb core and host drivers know that the controller
supports new USB 3.1 features.

make sure usb core handle HCD_USB31 hosts correctly, for now similar
to HCD_USB3.

Signed-off-by: Mathias Nyman &lt;mathias.nyman@linux.intel.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Hosts that support USB 3.1 Enhaned SuperSpeed can set their speed to
HCD_USB31 to let usb core and host drivers know that the controller
supports new USB 3.1 features.

make sure usb core handle HCD_USB31 hosts correctly, for now similar
to HCD_USB3.

Signed-off-by: Mathias Nyman &lt;mathias.nyman@linux.intel.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>usb: interface authorization: Use a flag for the default device authorization</title>
<updated>2015-09-22T19:08:40+00:00</updated>
<author>
<name>Stefan Koch</name>
<email>stefan.koch10@gmail.com</email>
</author>
<published>2015-08-25T19:10:11+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=ff8e2c560eca32043ed097099debac488a4bd99f'/>
<id>ff8e2c560eca32043ed097099debac488a4bd99f</id>
<content type='text'>
With this patch a flag instead of a variable
is used for the default device authorization.

Signed-off-by: Stefan Koch &lt;stefan.koch10@gmail.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
With this patch a flag instead of a variable
is used for the default device authorization.

Signed-off-by: Stefan Koch &lt;stefan.koch10@gmail.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>usb: interface authorization: Introduces the default interface authorization</title>
<updated>2015-09-22T19:08:40+00:00</updated>
<author>
<name>Stefan Koch</name>
<email>stefan.koch10@gmail.com</email>
</author>
<published>2015-08-25T19:10:06+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=6b2bd3c8c69c4817a9a2feb4597021d486c105f4'/>
<id>6b2bd3c8c69c4817a9a2feb4597021d486c105f4</id>
<content type='text'>
Interfaces are allowed per default.
This can disabled or enabled (again) by writing 0 or 1 to
/sys/bus/usb/devices/usbX/interface_authorized_default

Signed-off-by: Stefan Koch &lt;stefan.koch10@gmail.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Interfaces are allowed per default.
This can disabled or enabled (again) by writing 0 or 1 to
/sys/bus/usb/devices/usbX/interface_authorized_default

Signed-off-by: Stefan Koch &lt;stefan.koch10@gmail.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Revert "usb: interface authorization: Introduces the default interface authorization"</title>
<updated>2015-08-18T16:58:45+00:00</updated>
<author>
<name>Greg Kroah-Hartman</name>
<email>gregkh@linuxfoundation.org</email>
</author>
<published>2015-08-18T16:58:45+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=12e1a6a0f16168346cb8f33aff135ed523a9f097'/>
<id>12e1a6a0f16168346cb8f33aff135ed523a9f097</id>
<content type='text'>
This reverts commit 1d958bef45030acfc5578263e9de3bb07032b8da as the
signed-off-by address is invalid.

Cc: Stefan Koch &lt;stefan.koch10@gmail.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This reverts commit 1d958bef45030acfc5578263e9de3bb07032b8da as the
signed-off-by address is invalid.

Cc: Stefan Koch &lt;stefan.koch10@gmail.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Revert "usb: interface authorization: Use a flag for the default device authorization"</title>
<updated>2015-08-18T16:56:04+00:00</updated>
<author>
<name>Greg Kroah-Hartman</name>
<email>gregkh@linuxfoundation.org</email>
</author>
<published>2015-08-18T16:56:04+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=a1b93ab71587b8b44d45d114937cb4e75f9a5f27'/>
<id>a1b93ab71587b8b44d45d114937cb4e75f9a5f27</id>
<content type='text'>
This reverts commit 3cf1fc80655d3af7083ea4b3615e5f8532543be7 as the
signed-off-by address is invalid.

Cc: Stefan Koch &lt;stefan.koch10@gmail.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This reverts commit 3cf1fc80655d3af7083ea4b3615e5f8532543be7 as the
signed-off-by address is invalid.

Cc: Stefan Koch &lt;stefan.koch10@gmail.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</pre>
</div>
</content>
</entry>
</feed>
