<feed xmlns='http://www.w3.org/2005/Atom'>
<title>user/sven/linux.git/drivers/usb/core/driver.c, branch v4.4.153</title>
<subtitle>Linux Kernel
</subtitle>
<id>https://git.stealer.net/cgit.cgi/user/sven/linux.git/atom?h=v4.4.153</id>
<link rel='self' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/atom?h=v4.4.153'/>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/'/>
<updated>2017-05-20T12:26:59Z</updated>
<entry>
<title>usb: hub: Do not attempt to autosuspend disconnected devices</title>
<updated>2017-05-20T12:26:59Z</updated>
<author>
<name>Guenter Roeck</name>
<email>linux@roeck-us.net</email>
</author>
<published>2017-03-20T21:30:50Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=3d3ca81d5e359593f42daf37057818ffb68a6db5'/>
<id>urn:sha1:3d3ca81d5e359593f42daf37057818ffb68a6db5</id>
<content type='text'>
commit f5cccf49428447dfbc9edb7a04bb8fc316269781 upstream.

While running a bind/unbind stress test with the dwc3 usb driver on rk3399,
the following crash was observed.

Unable to handle kernel NULL pointer dereference at virtual address 00000218
pgd = ffffffc00165f000
[00000218] *pgd=000000000174f003, *pud=000000000174f003,
				*pmd=0000000001750003, *pte=00e8000001751713
Internal error: Oops: 96000005 [#1] PREEMPT SMP
Modules linked in: uinput uvcvideo videobuf2_vmalloc cmac
ipt_MASQUERADE nf_nat_masquerade_ipv4 iptable_nat nf_nat_ipv4 nf_nat rfcomm
xt_mark fuse bridge stp llc zram btusb btrtl btbcm btintel bluetooth
ip6table_filter mwifiex_pcie mwifiex cfg80211 cdc_ether usbnet r8152 mii joydev
snd_seq_midi snd_seq_midi_event snd_rawmidi snd_seq snd_seq_device ppp_async
ppp_generic slhc tun
CPU: 1 PID: 29814 Comm: kworker/1:1 Not tainted 4.4.52 #507
Hardware name: Google Kevin (DT)
Workqueue: pm pm_runtime_work
task: ffffffc0ac540000 ti: ffffffc0af4d4000 task.ti: ffffffc0af4d4000
PC is at autosuspend_check+0x74/0x174
LR is at autosuspend_check+0x70/0x174
...
Call trace:
[&lt;ffffffc00080dcc0&gt;] autosuspend_check+0x74/0x174
[&lt;ffffffc000810500&gt;] usb_runtime_idle+0x20/0x40
[&lt;ffffffc000785ae0&gt;] __rpm_callback+0x48/0x7c
[&lt;ffffffc000786af0&gt;] rpm_idle+0x1e8/0x498
[&lt;ffffffc000787cdc&gt;] pm_runtime_work+0x88/0xcc
[&lt;ffffffc000249bb8&gt;] process_one_work+0x390/0x6b8
[&lt;ffffffc00024abcc&gt;] worker_thread+0x480/0x610
[&lt;ffffffc000251a80&gt;] kthread+0x164/0x178
[&lt;ffffffc0002045d0&gt;] ret_from_fork+0x10/0x40

Source:

(gdb) l *0xffffffc00080dcc0
0xffffffc00080dcc0 is in autosuspend_check
(drivers/usb/core/driver.c:1778).
1773		/* We don't need to check interfaces that are
1774		 * disabled for runtime PM.  Either they are unbound
1775		 * or else their drivers don't support autosuspend
1776		 * and so they are permanently active.
1777		 */
1778		if (intf-&gt;dev.power.disable_depth)
1779			continue;
1780		if (atomic_read(&amp;intf-&gt;dev.power.usage_count) &gt; 0)
1781			return -EBUSY;
1782		w |= intf-&gt;needs_remote_wakeup;

Code analysis shows that intf is set to NULL in usb_disable_device() prior
to setting actconfig to NULL. At the same time, usb_runtime_idle() does not
lock the usb device, and neither does any of the functions in the
traceback. This means that there is no protection against a race condition
where usb_disable_device() is removing dev-&gt;actconfig-&gt;interface[] pointers
while those are being accessed from autosuspend_check().

To solve the problem, synchronize and validate device state between
autosuspend_check() and usb_disconnect().

Acked-by: Alan Stern &lt;stern@rowland.harvard.edu&gt;
Signed-off-by: Guenter Roeck &lt;linux@roeck-us.net&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>usb: hub: Fix error loop seen after hub communication errors</title>
<updated>2017-05-20T12:26:59Z</updated>
<author>
<name>Guenter Roeck</name>
<email>linux@roeck-us.net</email>
</author>
<published>2017-03-20T18:16:11Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=0b4dad7c2cf4139989386db0ac0cf86639692fd9'/>
<id>urn:sha1:0b4dad7c2cf4139989386db0ac0cf86639692fd9</id>
<content type='text'>
commit 245b2eecee2aac6fdc77dcafaa73c33f9644c3c7 upstream.

While stress testing a usb controller using a bind/unbind looop, the
following error loop was observed.

usb 7-1.2: new low-speed USB device number 3 using xhci-hcd
usb 7-1.2: hub failed to enable device, error -108
usb 7-1-port2: cannot disable (err = -22)
usb 7-1-port2: couldn't allocate usb_device
usb 7-1-port2: cannot disable (err = -22)
hub 7-1:1.0: hub_ext_port_status failed (err = -22)
hub 7-1:1.0: hub_ext_port_status failed (err = -22)
hub 7-1:1.0: activate --&gt; -22
hub 7-1:1.0: hub_ext_port_status failed (err = -22)
hub 7-1:1.0: hub_ext_port_status failed (err = -22)
hub 7-1:1.0: activate --&gt; -22
hub 7-1:1.0: hub_ext_port_status failed (err = -22)
hub 7-1:1.0: hub_ext_port_status failed (err = -22)
hub 7-1:1.0: activate --&gt; -22
hub 7-1:1.0: hub_ext_port_status failed (err = -22)
hub 7-1:1.0: hub_ext_port_status failed (err = -22)
hub 7-1:1.0: activate --&gt; -22
hub 7-1:1.0: hub_ext_port_status failed (err = -22)
hub 7-1:1.0: hub_ext_port_status failed (err = -22)
hub 7-1:1.0: activate --&gt; -22
hub 7-1:1.0: hub_ext_port_status failed (err = -22)
hub 7-1:1.0: hub_ext_port_status failed (err = -22)
hub 7-1:1.0: activate --&gt; -22
hub 7-1:1.0: hub_ext_port_status failed (err = -22)
hub 7-1:1.0: hub_ext_port_status failed (err = -22)
hub 7-1:1.0: activate --&gt; -22
hub 7-1:1.0: hub_ext_port_status failed (err = -22)
hub 7-1:1.0: hub_ext_port_status failed (err = -22)
hub 7-1:1.0: activate --&gt; -22
hub 7-1:1.0: hub_ext_port_status failed (err = -22)
hub 7-1:1.0: hub_ext_port_status failed (err = -22)
** 57 printk messages dropped ** hub 7-1:1.0: activate --&gt; -22
** 82 printk messages dropped ** hub 7-1:1.0: hub_ext_port_status failed (err = -22)

This continues forever. After adding tracebacks into the code,
the call sequence leading to this is found to be as follows.

[&lt;ffffffc0007fc8e0&gt;] hub_activate+0x368/0x7b8
[&lt;ffffffc0007fceb4&gt;] hub_resume+0x2c/0x3c
[&lt;ffffffc00080b3b8&gt;] usb_resume_interface.isra.6+0x128/0x158
[&lt;ffffffc00080b5d0&gt;] usb_suspend_both+0x1e8/0x288
[&lt;ffffffc00080c9c4&gt;] usb_runtime_suspend+0x3c/0x98
[&lt;ffffffc0007820a0&gt;] __rpm_callback+0x48/0x7c
[&lt;ffffffc00078217c&gt;] rpm_callback+0xa8/0xd4
[&lt;ffffffc000786234&gt;] rpm_suspend+0x84/0x758
[&lt;ffffffc000786ca4&gt;] rpm_idle+0x2c8/0x498
[&lt;ffffffc000786ed4&gt;] __pm_runtime_idle+0x60/0xac
[&lt;ffffffc00080eba8&gt;] usb_autopm_put_interface+0x6c/0x7c
[&lt;ffffffc000803798&gt;] hub_event+0x10ac/0x12ac
[&lt;ffffffc000249bb8&gt;] process_one_work+0x390/0x6b8
[&lt;ffffffc00024abcc&gt;] worker_thread+0x480/0x610
[&lt;ffffffc000251a80&gt;] kthread+0x164/0x178
[&lt;ffffffc0002045d0&gt;] ret_from_fork+0x10/0x40

kick_hub_wq() is called from hub_activate() even after failures to
communicate with the hub. This results in an endless sequence of
hub event -&gt; hub activate -&gt; wq trigger -&gt; hub event -&gt; ...

Provide two solutions for the problem.

- Only trigger the hub event queue if communication with the hub
  is successful.
- After a suspend failure, only resume already suspended interfaces
  if the communication with the device is still possible.

Each of the changes fixes the observed problem. Use both to improve
robustness.

Acked-by: Alan Stern &lt;stern@rowland.harvard.edu&gt;
Signed-off-by: Guenter Roeck &lt;linux@roeck-us.net&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>USB: leave LPM alone if possible when binding/unbinding interface drivers</title>
<updated>2016-06-01T19:15:51Z</updated>
<author>
<name>Alan Stern</name>
<email>stern@rowland.harvard.edu</email>
</author>
<published>2016-04-29T19:25:17Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=15e67f90026240145fc9ffa84ede62ea35de2971'/>
<id>urn:sha1:15e67f90026240145fc9ffa84ede62ea35de2971</id>
<content type='text'>
commit 6fb650d43da3e7054984dc548eaa88765a94d49f upstream.

When a USB driver is bound to an interface (either through probing or
by claiming it) or is unbound from an interface, the USB core always
disables Link Power Management during the transition and then
re-enables it afterward.  The reason is because the driver might want
to prevent hub-initiated link power transitions, in which case the HCD
would have to recalculate the various LPM parameters.  This
recalculation takes place when LPM is re-enabled and the new
parameters are sent to the device and its parent hub.

However, if the driver does not want to prevent hub-initiated link
power transitions then none of this work is necessary.  The parameters
don't need to be recalculated, and LPM doesn't need to be disabled and
re-enabled.

It turns out that disabling and enabling LPM can be time-consuming,
enough so that it interferes with user programs that want to claim and
release interfaces rapidly via usbfs.  Since the usbfs kernel driver
doesn't set the disable_hub_initiated_lpm flag, we can speed things up
and get the user programs to work by leaving LPM alone whenever the
flag isn't set.

And while we're improving the way disable_hub_initiated_lpm gets used,
let's also fix its kerneldoc.

Signed-off-by: Alan Stern &lt;stern@rowland.harvard.edu&gt;
Tested-by: Matthew Giassa &lt;matthew@giassa.net&gt;
CC: Mathias Nyman &lt;mathias.nyman@intel.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>USB: usb_driver_claim_interface: add sanity checking</title>
<updated>2016-04-12T16:08:41Z</updated>
<author>
<name>Oliver Neukum</name>
<email>oneukum@suse.com</email>
</author>
<published>2016-03-16T12:26:17Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=b6c6426252e2653407811f46c883661955b9f5fa'/>
<id>urn:sha1:b6c6426252e2653407811f46c883661955b9f5fa</id>
<content type='text'>
commit 0b818e3956fc1ad976bee791eadcbb3b5fec5bfd upstream.

Attacks that trick drivers into passing a NULL pointer
to usb_driver_claim_interface() using forged descriptors are
known. This thwarts them by sanity checking.

Signed-off-by: Oliver Neukum &lt;ONeukum@suse.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>usb: core: driver: Use kmalloc_array</title>
<updated>2015-10-04T09:47:19Z</updated>
<author>
<name>Muhammad Falak R Wani</name>
<email>falakreyaz@gmail.com</email>
</author>
<published>2015-09-07T16:00:25Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=9766f2517e55338ab546891c4bfff6666ffacaea'/>
<id>urn:sha1:9766f2517e55338ab546891c4bfff6666ffacaea</id>
<content type='text'>
Use kmalloc_array instead of kmalloc to allocate memory for an array.
Also, remove the dev_warn for a memory leak, making the if check more
sleek.

Signed-off-by: Muhammad Falak R Wani &lt;falakreyaz@gmail.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>usb: interface authorization: Control interface probing and claiming</title>
<updated>2015-09-22T19:08:40Z</updated>
<author>
<name>Stefan Koch</name>
<email>stefan.koch10@gmail.com</email>
</author>
<published>2015-08-25T19:10:07Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=8d1f8573a33224dce9b6e3a5085a6857b7572c13'/>
<id>urn:sha1:8d1f8573a33224dce9b6e3a5085a6857b7572c13</id>
<content type='text'>
Driver probings and interface claims get rejected
if an interface is not authorized.

Signed-off-by: Stefan Koch &lt;stefan.koch10@gmail.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>Revert "usb: interface authorization: Control interface probing and claiming"</title>
<updated>2015-08-18T16:58:26Z</updated>
<author>
<name>Greg Kroah-Hartman</name>
<email>gregkh@linuxfoundation.org</email>
</author>
<published>2015-08-18T16:58:26Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=8c2ea97a3a4124628de2ed9a1f891c706788468a'/>
<id>urn:sha1:8c2ea97a3a4124628de2ed9a1f891c706788468a</id>
<content type='text'>
This reverts commit de7718bd9c4d3db96991a98c2a0cb38258a04e47 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>
</entry>
<entry>
<title>usb: interface authorization: Control interface probing and claiming</title>
<updated>2015-08-14T23:55:54Z</updated>
<author>
<name>Stefan Koch</name>
<email>stefan.koch10@gmail.com</email>
</author>
<published>2015-08-08T09:32:52Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=de7718bd9c4d3db96991a98c2a0cb38258a04e47'/>
<id>urn:sha1:de7718bd9c4d3db96991a98c2a0cb38258a04e47</id>
<content type='text'>
Driver probings and interface claims get rejected
if an interface is not authorized.

Signed-off-by: Stefan Koch &lt;skoch@suse.de&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>usb: fix coding style issue</title>
<updated>2015-07-22T21:55:21Z</updated>
<author>
<name>Kris Borer</name>
<email>kborer@gmail.com</email>
</author>
<published>2015-06-16T17:24:53Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=79a02744bc5a2993d6c5b8dd1a790f7ea12f4e0b'/>
<id>urn:sha1:79a02744bc5a2993d6c5b8dd1a790f7ea12f4e0b</id>
<content type='text'>
Fixed coding style issue: newline after declaration

Signed-off-by: Kris Borer &lt;kborer@gmail.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>USB: add flag for HCDs that can't receive wakeup requests (isp1760-hcd)</title>
<updated>2015-01-31T17:05:06Z</updated>
<author>
<name>Alan Stern</name>
<email>stern@rowland.harvard.edu</email>
</author>
<published>2015-01-29T20:05:04Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=074f9dd55f9cab1b82690ed7e44bcf38b9616ce0'/>
<id>urn:sha1:074f9dd55f9cab1b82690ed7e44bcf38b9616ce0</id>
<content type='text'>
Currently the USB stack assumes that all host controller drivers are
capable of receiving wakeup requests from downstream devices.
However, this isn't true for the isp1760-hcd driver, which means that
it isn't safe to do a runtime suspend of any device attached to a
root-hub port if the device requires wakeup.

This patch adds a "cant_recv_wakeups" flag to the usb_hcd structure
and sets the flag in isp1760-hcd.  The core is modified to prevent a
direct child of the root hub from being put into runtime suspend with
wakeup enabled if the flag is set.

Signed-off-by: Alan Stern &lt;stern@rowland.harvard.edu&gt;
Tested-by: Nicolas Pitre &lt;nico@linaro.org&gt;
CC: &lt;stable@vger.kernel.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;greg@kroah.com&gt;
</content>
</entry>
</feed>
