Commit Graph

13374 Commits

Author SHA1 Message Date
Johan Hovold
2a8cdfde92 USB: cdc-acm: add quirk for control-line state requests
Add new quirk for devices that cannot handle control-line state
requests.

Note that we currently send these requests to all devices, regardless of
whether they claim to support it, but that errors are only logged if
support is claimed.

Since commit 0943d8ead3 ("USB: cdc-acm: use tty-port dtr_rts"), which
only changed the timings for these requests slightly, this has been
reported to cause occasional firmware crashes on Simtec Electronics
Entropy Key devices after re-enumeration. Enable the quirk for this
device.

Reported-by: Nix <nix@esperi.org.uk>
Tested-by: Nix <nix@esperi.org.uk>
Cc: stable <stable@vger.kernel.org>	# v3.16
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-06 12:25:40 -08:00
Greg Kroah-Hartman
e5452dd4cb usb: fixes for v3.18-rc4
A single fix this for dwc2 this time. Because of
 excessive debugging messages, dwc2 would sometimes
 fail enumeration. The fix is simple, just converting
 a dev_info() into dev_dbg().
 
 Signed-off-by: Felipe Balbi <balbi@ti.com>
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1
 
 iQIcBAABAgAGBQJUW7HpAAoJEIaOsuA1yqREZKkP/j7o3Cyvkr7bW7I5N2mNNo3R
 58hC+u8LcGMn3Q8YGoDGkVxGtM2OmXkorqAvWoEaM21LVHjl06zwAngoKNL/1Qm+
 UPg4zvXGsKGqj+4cDb+SOKnIfNeMWHdwd0BmlSxrb+CnIQOxB7629R1XbhsWvZhS
 Sf0h5p6zCUSC9A3poYeYtq7e/0yDBG345It9NzQgsXs1AqzTrcAgt1D9yyRSmRuZ
 ADVgJrKto4gBBGK3jRhFzBBfdoUYHeL9mwXVogKUoOR+VLqfC0VmrwfKYqBx5kXW
 2l2vIAv0mHWi/zBN1hfAcc53i1tOo0inxJnUep1Jfl8c/A8eb64lUPUCwoR22j3X
 a3IC7LDHn+qO+Bx+DLvnKkapYtWjre9t+vglY16HH0QpE8ldqr/HOE5CAQP6EXRJ
 nYLpVI0NDDwQGo16cs74jdRa/bUzT2OE2yh+Q78Nx8BrE87DsRh8jsniFnQ9coMP
 Dxn0RKIRg6KpWHOl2qi77uSRf9XO4oG+tcgqvoU3UzD+fREGHHLD9Q46+caDhDkp
 uX0kw5tIifUvdhFBJK/ev/R7yljOcd+91zfgeZjyBG0ZgcHRW3iod6NhJ/mmDcmo
 n8c3TUMO9tTQvozp5KTx5/aPlkGVvva41Rkpg/6UBDuoiMhZithvYwvG1Wj0YSj9
 SV1i9kNe+F1fybwfx+k9
 =egWd
 -----END PGP SIGNATURE-----

Merge tag 'fixes-for-v3.18-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb into usb-linus

Felipe writes:

usb: fixes for v3.18-rc4

A single fix this for dwc2 this time. Because of
excessive debugging messages, dwc2 would sometimes
fail enumeration. The fix is simple, just converting
a dev_info() into dev_dbg().

Signed-off-by: Felipe Balbi <balbi@ti.com>
2014-11-06 12:24:03 -08:00
Greg Kroah-Hartman
5002921407 USB-serial fixes for v3.18-rc4
Two fixes of non-atomic allocations in write paths.
 
 Signed-off-by: Johan Hovold <johan@kernel.org>
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2
 
 iQIcBAABAgAGBQJUW65SAAoJEEEN5E/e4bSVgf4QAK3o9qhiLD01fK8kIpRbh8jB
 joRKQRY6X+cOp6twlZrZChtqCkbMHtoZHvmhxRhkD8oj/qE1AeYhdUyq71aVm64R
 GMJDmFawEkPHuvIZ/dlzzuhrbugZf6TBtjFBfVzHtpyMm0wJu8ogtml3R5MgDhut
 WWWdKUq0D1yi9otDAaFCEkca3P5z+qeDpkLzETmwMIqzheGp1gbCpWXFTM51KUS8
 KP4t1HliVGXapBtF+vuvc2jmjqxm+Yfeyp43iR8yMiUShpXUgOw9/D1qSdZK2PPj
 JJTeUyAso0sZnWDB62TSe54stm7Bacfg802/GHMPdkprYINzNKWpRw3mKrvOI5HZ
 sDBbpz6SxTdHtzIQw/IHvhZLk1F2sb0Fk/PmN7r5yNRvSB6zebAVGLWl70RT3d82
 aawvzuMoKp54/YNGCByvqKvrFXl61PRRwVYyoKVRiTxT8vlSdlxReAwVDCWcukqI
 1IshcUN6oLZmQ/tgQYlaA6f6wtBCCz73ZPxm2cYvJiBisCYGN0Y5CBL7faB/ocW8
 +2kv5/rKyQD9bzTJTB9F0FdSqiM0hd9W7DVuuNFS8Nhp4KTP6ez6pASic0us8vkE
 bbF2kOdepu46/dDKyX7HchIy0Ek/tL2f3qWSJ/AHiSRXPjwOJ9t9sjSpLWDuCya1
 w5nEVbGmlq/arjbQ5emg
 =QlS+
 -----END PGP SIGNATURE-----

Merge tag 'usb-serial-3.18-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/johan/usb-serial into usb-linus

Johan writes:

USB-serial fixes for v3.18-rc4

Two fixes of non-atomic allocations in write paths.

Signed-off-by: Johan Hovold <johan@kernel.org>
2014-11-06 12:22:36 -08:00
Mark Knibbs
a88098bdb2 USB: storage: Fix timeout in usb_stor_euscsi_init() and usb_stor_huawei_e220_init()
The timeout argument to usb_stor_control_msg() is specified in jiffies, not
milliseconds.

Signed-off-by: Mark Knibbs <markk@clara.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-05 11:45:58 -08:00
Johan Hovold
4473d054ce USB: cdc-acm: only raise DTR on transitions from B0
Make sure to only raise DTR on transitions from B0 in set_termios.

Also allow set_termios to be called from open with a termios_old of
NULL. Note that DTR will not be raised prematurely in this case.

Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-05 11:25:25 -08:00
Greg Kroah-Hartman
ac0225f94f Revert "storage: Replace magic number with define in usb_stor_euscsi_init()"
This reverts commit bda9893c50 as it was
incorrect.

Reported-by: Mark Knibbs <markk@clara.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-05 11:12:17 -08:00
Peter Chen
b2108f1e51 usb: core: notify disconnection when core detects disconnect
It is safe to call notify disconnect when the usb core
thinks the device is disconnected.

This commit also fixes one bug found at below situation:
we have not enabled usb wakeup, we do system suspend when
there is an usb device at the port, after suspend, we plug out
the usb device, then plug in device again. At that time,
the nofity disconnect was not called at current code, as
the controller doesn't know the usb device was disconnected
during the suspend, but USB core knows the port has changed
during that periods.

So to fix this problem, and let the usb core call notify disconnect.

Cc: 3.17+ <stable@vger.kernel.org>
Signed-off-by: Peter Chen <peter.chen@freescale.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-03 19:29:55 -08:00
Tony Zheng
01ed67dc70 usb: core: need to call usb_phy_notify_connect after device setup
Since we notify disconnecting based on the usb device is existed
(port_dev->child, the child device at roothub is not NULL), we
need to notify connect after device has been registered.

This fixes a bug that do fast plug in/out test, and the notify_disconnect
is not called due to roothub child is NULL and the enumeration has failed.

Cc: v3.17+ <stable@vger.kernel.org>
Signed-off-by: Tony Zheng <Tony.Zheng@freescale.com>
Signed-off-by: Peter Chen <peter.chen@freescale.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-03 15:48:45 -08:00
Hans de Goede
d1d9548256 uas: Add US_FL_NO_ATA_1X quirk for 2 more Seagate models
These drives hang when receiving ATA12 commands, so set the US_FL_NO_ATA_1X
quirk to filter these out.

Cc: stable@vger.kernel.org # 3.16
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-03 15:48:45 -08:00
Oliver Neukum
b45abacde3 xhci: no switching back on non-ULT Haswell
The switch back is limited to ULT even on HP. The contrary
finding arose by bad luck in BIOS versions for testing.
This fixes spontaneous resume from S3 on some HP laptops.

Signed-off-by: Oliver Neukum <oneukum@suse.de>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-03 15:48:45 -08:00
Adel Gadllah
d749947561 USB: quirks: enable device-qualifier quirk for yet another Elan touchscreen
Yet another device affected by this.

Tested-by: Kevin Fenzi <kevin@scrye.com>
Signed-off-by: Adel Gadllah <adel.gadllah@gmail.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-03 15:26:32 -08:00
Adel Gadllah
876af5d454 USB: quirks: enable device-qualifier quirk for another Elan touchscreen
Currently this quirk is enabled for the model with the device id 0x0089, it
is needed for the 0x009b model, which is found on the Fujitsu Lifebook u904
as well.

Signed-off-by: Adel Gadllah <adel.gadllah@gmail.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-03 15:26:16 -08:00
Luis Henriques
ec5633ba67 usb: storage: fix build warnings !CONFIG_PM
Functions fw5895_init() and config_autodelink_before_power_down() are used
only when CONFIG_PM is defined.

drivers/usb/storage/realtek_cr.c:699:13: warning: 'fw5895_init' defined but not used [-Wunused-function]
drivers/usb/storage/realtek_cr.c:629:12: warning: 'config_autodelink_before_power_down' defined but not used [-Wunused-function]

Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-03 15:26:16 -08:00
Sylwester Nawrocki
cd6e245a2d usb: Remove references to non-existent PLAT_S5P symbol
The PLAT_S5P Kconfig symbol was removed in commit d78c16ccde
("ARM: SAMSUNG: Remove remaining legacy code"). There are still
some references left, fix that by replacing them with ARCH_S5PV210.

Fixes: d78c16ccde ("ARM: SAMSUNG: Remove remaining legacy code")
Reported-by: Paul Bolle <pebolle@tiscali.nl>
Acked-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-03 15:26:16 -08:00
Hans de Goede
673029fe9c uas: Add NO_ATA_1X for VIA VL711 devices
Just like some Seagate enclosures, these devices do not seem to grok ata
pass through commands.

Cc: stable@vger.kernel.org # 3.16
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-03 15:26:15 -08:00
Hans de Goede
2391eacbd0 xhci: Disable streams on Asmedia 1042 xhci controllers
Streams seem to be broken on the Asmedia 1042. An uas capable Seagate disk
which is known to work fine with other controllers causes the system to freeze
when connected over usb-3 with this controller, where as it works fine with
uas in usb-2 ports, indicating a problem with streams.

This is a bit bigger hammer then I would like to use for this, but for now it
will have to make do. I've ordered a pci-e usb controller card with an Asmedia
1042, once that arrives I'll try to get streams to work (with a quirk flag if
necessary) and then we can re-enable them. For now this at least makes uas
capable disk enclosures work again by forcing fallback to the usb-storage
driver.

Reported-by: Bogdan Mihalcea <bogdan.mihalcea@infim.ro>
Cc: Bogdan Mihalcea <bogdan.mihalcea@infim.ro>
Cc: stable@vger.kernel.org # 3.16
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-03 15:26:15 -08:00
Dan Carpenter
cee2448e5b USB: HWA: fix a warning message
We wanted to print the version as (major).(minor) but because the shift
operation is higher precedence than the mask then we print
(minor).(minor).

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-03 15:26:15 -08:00
Hans de Goede
aee0ce3ae7 uas: Add US_FL_NO_ATA_1X quirk for 1 more Seagate model
These drives hang when receiving ATA12 commands, so set the US_FL_NO_ATA_1X
quirk to filter these out.

Cc: stable@vger.kernel.org # 3.16
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-03 15:26:15 -08:00
Alan Stern
93c9bf4d18 usb-storage: handle a skipped data phase
Sometimes mass-storage devices using the Bulk-only transport will
mistakenly skip the data phase of a command.  Rather than sending the
data expected by the host or sending a zero-length packet, they go
directly to the status phase and send the CSW.

This causes problems for usb-storage, for obvious reasons.  The driver
will interpret the CSW as a short data transfer and will wait to
receive a CSW.  The device won't have anything left to send, so the
command eventually times out.

The SCSI layer doesn't retry commands after they time out (this is a
relatively recent change).  Therefore we should do our best to detect
a skipped data phase and handle it promptly.

This patch adds code to do that.  If usb-storage receives a short
13-byte data transfer from the device, and if the first four bytes of
the data match the CSW signature, the driver will set the residue to
the full transfer length and interpret the data as a CSW.

This fixes Bugzilla #86611.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
CC: Matthew Dharm <mdharm-usb@one-eyed-alien.net>
Tested-by: Paul Osmialowski <newchief@king.net.pl>
CC: <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-03 15:26:15 -08:00
Hans de Goede
90a646c770 usb: Do not allow usb_alloc_streams on unconfigured devices
This commit fixes the following oops:

[10238.622067] scsi host3: uas_eh_bus_reset_handler start
[10240.766164] usb 3-4: reset SuperSpeed USB device number 3 using xhci_hcd
[10245.779365] usb 3-4: device descriptor read/8, error -110
[10245.883331] usb 3-4: reset SuperSpeed USB device number 3 using xhci_hcd
[10250.897603] usb 3-4: device descriptor read/8, error -110
[10251.058200] BUG: unable to handle kernel NULL pointer dereference at  0000000000000040
[10251.058244] IP: [<ffffffff815ac6e1>] xhci_check_streams_endpoint+0x91/0x140
<snip>
[10251.059473] Call Trace:
[10251.059487]  [<ffffffff815aca6c>] xhci_calculate_streams_and_bitmask+0xbc/0x130
[10251.059520]  [<ffffffff815aeb5f>] xhci_alloc_streams+0x10f/0x5a0
[10251.059548]  [<ffffffff810a4685>] ? check_preempt_curr+0x75/0xa0
[10251.059575]  [<ffffffff810a46dc>] ? ttwu_do_wakeup+0x2c/0x100
[10251.059601]  [<ffffffff810a49e6>] ? ttwu_do_activate.constprop.111+0x66/0x70
[10251.059635]  [<ffffffff815779ab>] usb_alloc_streams+0xab/0xf0
[10251.059662]  [<ffffffffc0616b48>] uas_configure_endpoints+0x128/0x150 [uas]
[10251.059694]  [<ffffffffc0616bac>] uas_post_reset+0x3c/0xb0 [uas]
[10251.059722]  [<ffffffff815727d9>] usb_reset_device+0x1b9/0x2a0
[10251.059749]  [<ffffffffc0616f42>] uas_eh_bus_reset_handler+0xb2/0x190 [uas]
[10251.059781]  [<ffffffff81514293>] scsi_try_bus_reset+0x53/0x110
[10251.059808]  [<ffffffff815163b7>] scsi_eh_bus_reset+0xf7/0x270
<snip>

The problem is the following call sequence (simplified):

1) usb_reset_device
2)  usb_reset_and_verify_device
2)   hub_port_init
3)    hub_port_finish_reset
3)     xhci_discover_or_reset_device
        This frees xhci->devs[slot_id]->eps[ep_index].ring for all eps but 0
4)    usb_get_device_descriptor
       This fails
5)   hub_port_init fails
6)  usb_reset_and_verify_device fails, does not restore device config
7)  uas_post_reset
8)   xhci_alloc_streams
      NULL deref on the free-ed ring

This commit fixes this by not allowing usb_alloc_streams to continue if
the device is not configured.

Note that we do allow usb_free_streams to continue after a (logical)
disconnect, as it is necessary to explicitly free the streams at the xhci
controller level.

Cc: stable@vger.kernel.org
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-03 15:26:15 -08:00
Jim Paris
24cb4502c9 cdc-acm: ensure that termios get set when the port is activated
The driver wasn't properly configuring the hardware for the current
termios settings under all conditions.  Ensure that termios are
written to the device when the port is activated.

Signed-off-by: Jim Paris <jim@jtan.com>
Reviewed-by: Johan Hovold <johan@kernel.org>
Acked-by: Oliver Neukum <oneukum@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-03 15:26:15 -08:00
Johan Hovold
cf84a691a6 USB: cdc-acm: add device id for GW Instek AFG-2225
Add device-id entry for GW Instek AFG-2225, which has a byte swapped
bInterfaceSubClass (0x20).

Reported-by: Karl Palsson <karlp@tweak.net.au>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-03 15:26:15 -08:00
Johan Hovold
e681286de2 USB: opticon: fix non-atomic allocation in write path
Write may be called from interrupt context so make sure to use
GFP_ATOMIC for all allocations in write.

Fixes: 0d930e51cf ("USB: opticon: Add Opticon OPN2001 write support")
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2014-11-03 09:07:30 +01:00
Johan Hovold
1912528376 USB: kobil_sct: fix non-atomic allocation in write path
Write may be called from interrupt context so make sure to use
GFP_ATOMIC for all allocations in write.

Fixes: 1da177e4c3 ("Linux-2.6.12-rc2")
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2014-11-03 09:07:28 +01:00
Greg Kroah-Hartman
9c19db5b11 USB-serial fixes for v3.18-rc3
These updates remove two allocations of unused buffers from kobil_sct
 and add some new device ids.
 
 Signed-off-by: Johan Hovold <johan@kernel.org>
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2
 
 iQIcBAABAgAGBQJUUK1CAAoJEEEN5E/e4bSVVusQAM3DJ2pS2YvygoZ8+O9AUkIQ
 beDoRV5mAV1qEnEq9+reO90qKC4KvVwJbsi1b+m4tc488mjNCOTgty9YweWatvte
 3BrAl7r5Y3vy26waFSjLoixS+R/SesTwnOu7jiRDIv3Cx4ppSuVjBJ6xWrFsEJyy
 mOMGY34nt51SSPl4MDUBqdAVpnqy2epwG186i6/092jDBo3bbhtO2sh4qfFSAn2H
 ypKjWNnG0BXx/gwrVFkpDJuiO1CY68orvSKzTIpWqipn3lTGSU7gMuz0W3NeLXkL
 1LGHhtA8C+k/7PeYT5pRUuOfbr3GbLPsTiy3yP05DbeS1whtJ4gXzlQuNvE0beuY
 RV/5auz9zXrE62p1uR3uY14OamUi300NKriOYTLDSKrp0SzTu+5LEwM6DHfbxxiN
 Cr8Bd6XW/UegHPnWKUvMWViVyUpSjBCy3j7aSmrXmv9HRnaP+shXvIZjuRcVUfwE
 6UskyFd/4tPeYbQo5FASh8vrAmoYKqS/0pNZGi1oM1+rrxIIqveNBkfKebwH5q1Z
 hCMfFysEohlf0sbSgJWjGEdqfmfDOHlE36ovY83ytGqBBVYh7f5pW1jMZSaTqomB
 GRAcuJNs61BVaigRiQFmluEFTETrUrZy1Z5AuAfUXRJPsE+Jz/N5E5FXT8rVkjc4
 JfeP/L3uVME6GYww7Qsj
 =PSiW
 -----END PGP SIGNATURE-----

Merge tag 'usb-serial-3.18-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/johan/usb-serial into usb-linus

Johan writes:

USB-serial fixes for v3.18-rc3

These updates remove two allocations of unused buffers from kobil_sct
and add some new device ids.

Signed-off-by: Johan Hovold <johan@kernel.org>
2014-10-29 09:24:42 -07:00
Marek Szyprowski
9599815de6 usb: dwc2: gadget: fix enumeration issues
Excessive debug messages might cause timing issues that prevent correct
usb enumeration. This patch hides information about USB bus reset to let
driver enumerate fast enough to avoid making host angry. This fixes
endless enumeration and usb reset loop observed with some Linux hosts.

Acked-by: Paul Zimmerman <paulz@synopsys.com>
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Reviewed-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2014-10-28 10:40:58 -05:00
Torsten Fleischer
9680b60ed7 usb: chipidea: Fix oops when removing the ci_hdrc module
The call of 'kfree(ci->hw_bank.regmap)' in ci_hdrc_remove() sometimes causes
a kernel oops when removing the ci_hdrc module.

Since there is no separate memory allocated for the ci->hw_bank.regmap array,
there is no need to free it.

Cc: v3.14+ <stable@@vger.kernel.org>
Signed-off-by: Torsten Fleischer <to-fleischer@t-online.de>
Signed-off-by: Peter Chen <peter.chen@freescale.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-10-27 10:01:05 +08:00
Pavitrakumar Managutte
9b1763553a usb: gadget: function: Fixed the return value on error path
Fixed the return value on failure. status variable
is set to 0 at usb_assign_descriptors call and the same is
returned on error which is incorrect.

Acked-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Pavitrakumar Managutte <pavitra1729@gmail.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2014-10-23 14:49:35 -05:00
Marek Szyprowski
3a8146aafc usb: dwc2: gadget: disable phy before turning off power regulators
This patch fixes probe function to match the pattern used elsewhere in
the driver, where power regulators are turned off as the last element in
the device shutdown procedure.

Acked-by: Paul Zimmerman <paulz@synopsys.com>
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2014-10-23 13:58:51 -05:00
Pavitrakumar Managutte
d12a872717 usb: gadget: function: Remove redundant usb_free_all_descriptors
Removed usb_free_all_descriptors in the bind functions, which
results in double-free corruption of the descriptors on error path.
The usb descriptors are allocated by usb_assign_descriptors.

Signed-off-by: Pavitrakumar Managutte <pavitra1729@gmail.com>
Reviewed-by: Robert Baldyga <r.baldyga@samsung.com>
Reviewed-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2014-10-23 13:57:24 -05:00
Jack Pham
1200a82a59 usb: dwc3: gadget: Properly initialize LINK TRB
On ISOC endpoints the last trb_pool entry used as a
LINK TRB is not getting zeroed out correctly due to
memset being called incorrectly and in the wrong place.
If pool allocated from DMA was not zero-initialized
to begin with this will result in the size and ctrl
values being random garbage. Call memset correctly after
assignment of the trb_link pointer.

Fixes: f6bafc6a1c ("usb: dwc3: convert TRBs into bitshifts")
Cc: <stable@vger.kernel.org> # v3.4+
Signed-off-by: Jack Pham <jackp@codeaurora.org>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2014-10-23 13:57:24 -05:00
Marek Szyprowski
32805c350b usb: dwc2: gadget: fix gadget unregistration in udc_stop() function
udc_stop() should clear ->driver pointer unconditionally to let the UDC
framework to work correctly with both registering/unregistering gadgets
and enabling/disabling gadgets by writing to
/sys/class/udc/*hsotg/soft_connect interface.

Acked-by: Paul Zimmerman <paulz@synopsys.com>
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2014-10-23 13:57:08 -05:00
Charles Manning
fd4850cfd4 usb: dwc2: Bits in bitfield should add up to 32
The unioned u32 is used for clearing etc. Having the number of
bitfield bits add up to more than 32 is broken, even if benign.

Acked-by: Paul Zimmerman <paulz@synopsys.com>
Signed-off-by: Charles Manning <cdhmanning@gmail.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2014-10-23 09:55:43 -05:00
Sudip Mukherjee
b585a48b8a usb: dwc2: gadget: sparse warning of context imbalance
sparse was giving the following warning:
        warning: context imbalance in 's3c_hsotg_ep_enable'
	                - different lock contexts for basic block

we were returning ENOMEM while still holding the spinlock.
The sparse warning was fixed by releasing the spinlock before return.

Cc: <stable@vger.kernel.org> # v3.17
Acked-by: Paul Zimmerman <paulz@synopsys.com>
Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2014-10-23 09:55:43 -05:00
Felipe Balbi
bfa6b18c68 usb: gadget: udc: core: fix kernel oops with soft-connect
Currently, there's no guarantee that udc->driver
will be valid when using soft_connect sysfs
interface. In fact, we can very easily trigger
a NULL pointer dereference by trying to disconnect
when a gadget driver isn't loaded.

Fix this bug:

~# echo disconnect > soft_connect
[   33.685743] Unable to handle kernel NULL pointer dereference at virtual address 00000014
[   33.694221] pgd = ed0cc000
[   33.697174] [00000014] *pgd=ae351831, *pte=00000000, *ppte=00000000
[   33.703766] Internal error: Oops: 17 [#1] SMP ARM
[   33.708697] Modules linked in: xhci_plat_hcd xhci_hcd snd_soc_davinci_mcasp snd_soc_tlv320aic3x snd_soc_edma snd_soc_omap snd_soc_evm snd_soc_core dwc3 snd_compress snd_pcm_dmaengine snd_pcm snd_timer snd lis3lv02d_i2c matrix_keypad lis3lv02d dwc3_omap input_polldev soundcore
[   33.734372] CPU: 0 PID: 1457 Comm: bash Not tainted 3.17.0-09740-ga93416e-dirty #345
[   33.742457] task: ee71ce00 ti: ee68a000 task.ti: ee68a000
[   33.748116] PC is at usb_udc_softconn_store+0xa4/0xec
[   33.753416] LR is at mark_held_locks+0x78/0x90
[   33.758057] pc : [<c04df128>]    lr : [<c00896a4>]    psr: 20000013
[   33.758057] sp : ee68bec8  ip : c0c00008  fp : ee68bee4
[   33.770050] r10: ee6b394c  r9 : ee68bf80  r8 : ee6062c0
[   33.775508] r7 : 00000000  r6 : ee6062c0  r5 : 0000000b  r4 : ee739408
[   33.782346] r3 : 00000000  r2 : 00000000  r1 : ee71d390  r0 : ee664170
[   33.789168] Flags: nzCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment user
[   33.796636] Control: 10c5387d  Table: ad0cc059  DAC: 00000015
[   33.802638] Process bash (pid: 1457, stack limit = 0xee68a248)
[   33.808740] Stack: (0xee68bec8 to 0xee68c000)
[   33.813299] bec0:                   0000000b c0411284 ee6062c0 00000000 ee68bef4 ee68bee8
[   33.821862] bee0: c04112ac c04df090 ee68bf14 ee68bef8 c01c2868 c0411290 0000000b ee6b3940
[   33.830419] bf00: 00000000 00000000 ee68bf4c ee68bf18 c01c1a24 c01c2818 00000000 00000000
[   33.838990] bf20: ee61b940 ee2f47c0 0000000b 000ce408 ee68bf80 c000f304 ee68a000 00000000
[   33.847544] bf40: ee68bf7c ee68bf50 c0152dd8 c01c1960 ee68bf7c c0170af8 ee68bf7c ee2f47c0
[   33.856099] bf60: ee2f47c0 000ce408 0000000b c000f304 ee68bfa4 ee68bf80 c0153330 c0152d34
[   33.864653] bf80: 00000000 00000000 0000000b 000ce408 b6e7fb50 00000004 00000000 ee68bfa8
[   33.873204] bfa0: c000f080 c01532e8 0000000b 000ce408 00000001 000ce408 0000000b 00000000
[   33.881763] bfc0: 0000000b 000ce408 b6e7fb50 00000004 0000000b 00000000 000c5758 00000000
[   33.890319] bfe0: 00000000 bec2c924 b6de422d b6e1d226 40000030 00000001 75716d2f 00657565
[   33.898890] [<c04df128>] (usb_udc_softconn_store) from [<c04112ac>] (dev_attr_store+0x28/0x34)
[   33.907920] [<c04112ac>] (dev_attr_store) from [<c01c2868>] (sysfs_kf_write+0x5c/0x60)
[   33.916200] [<c01c2868>] (sysfs_kf_write) from [<c01c1a24>] (kernfs_fop_write+0xd0/0x194)
[   33.924773] [<c01c1a24>] (kernfs_fop_write) from [<c0152dd8>] (vfs_write+0xb0/0x1bc)
[   33.932874] [<c0152dd8>] (vfs_write) from [<c0153330>] (SyS_write+0x54/0xb0)
[   33.940247] [<c0153330>] (SyS_write) from [<c000f080>] (ret_fast_syscall+0x0/0x48)
[   33.948160] Code: e1a01007 e12fff33 e5140004 e5143008 (e5933014)
[   33.954625] ---[ end trace f849bead94eab7ea ]---

Fixes: 2ccea03 (usb: gadget: introduce UDC Class)
Cc: <stable@vger.kernel.org> # v3.1+
Signed-off-by: Felipe Balbi <balbi@ti.com>
2014-10-23 09:55:43 -05:00
Sebastian Andrzej Siewior
f042e9cbae usb: musb: musb_dsps: fix NULL pointer in suspend
So testing managed to configure musb in DMA mode but not load the
matching cppi41 driver for DMA. This results in

|musb-hdrc musb-hdrc.0.auto: Failed to request rx1.
|musb-hdrc musb-hdrc.0.auto: musb_init_controller failed with status -517
|platform musb-hdrc.0.auto: Driver musb-hdrc requests probe deferral

which is "okay". Once the driver is loaded we re-try probing and
everyone is happy. Until then if you try suspend say
    echo mem > /sys/power/state
then you go boom

|Unable to handle kernel NULL pointer dereference at virtual address 000003a4
|pgd = cf50c000
|[000003a4] *pgd=8f6a3831, *pte=00000000, *ppte=00000000
|Internal error: Oops: 17 [#1] ARM
|PC is at dsps_suspend+0x18/0x9c [musb_dsps]
|LR is at dsps_suspend+0x18/0x9c [musb_dsps]
|pc : [<bf08e268>] lr : [<bf08e268>] psr: a0000013
|sp : cbd97e00 ip : c0af4394 fp : 00000000
|r10: c0831d90 r9 : 00000002 r8 : cf6da410
|r7 : c03ba4dc r6 : bf08f224 r5 : 00000000 r4 : cbc5fcd0
|r3 : bf08e250 r2 : bf08f264 r1 : cf6da410 r0 : 00000000
|[<bf08e268>] (dsps_suspend [musb_dsps]) from [<c03ba508>] (platform_pm_suspend+0x2c/0x54)
|Code: e1a04000 e9900041 e2800010 eb4caa8e (e59053a4)

because platform_get_drvdata(glue->musb) returns a NULL pointer as long as the
device is not fully probed.

Tested-by: George Cherian <george.cherian@ti.com>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2014-10-23 09:55:43 -05:00
Sebastian Andrzej Siewior
53185b3a44 usb: musb: dsps: start OTG timer on resume again
Commit 468bcc2a2c ("usb: musb: dsps: kill OTG timer on suspend") stopped
the timer in suspend path but forgot the re-enable it in the resume
path. This patch fixes the behaviour.

Cc: <stable@vger.kernel.org> # v3.14+
Fixes 468bcc2a2c "usb: musb: dsps: kill OTG timer on suspend"
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2014-10-23 09:55:42 -05:00
Felipe Balbi
e0857ce58e usb: gadget: loopback: don't queue requests to bogus endpoints
A request allocated from e.g. ep1out cannot
be queued to any other endpoint. This bug has
been in f_loopback at least since mid-2011 and
since nobody has really screamed about it, we're
not backporting to any stable kernels.

Debugged with MUSB since that's the only controller
which complains about this case.

Signed-off-by: Felipe Balbi <balbi@ti.com>
2014-10-23 09:55:42 -05:00
David Cohen
c0d31b3c3d usb: ffs: fix regression when quirk_ep_out_aligned_size flag is set
The commit '2e4c7553cd usb: gadget: f_fs: add aio support' broke the
quirk implemented to align buffer size to maxpacketsize on out endpoint.
As result, functionfs does not work on Intel platforms using dwc3 driver
(i.e. Bay Trail and Merrifield). This patch fixes the issue.

This code is based on a previous Qiuxu's patch.

Fixes: 2e4c7553cd (usb: gadget: f_fs: add aio support)
Cc: <stable@vger.kernel.org> # v3.16+
Signed-off-by: David Cohen <david.a.cohen@linux.intel.com>
Signed-off-by: Qiuxu Zhuo <qiuxu.zhuo@intel.com>
Acked-by: Michal Nazarewicz <mina86@mina86.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2014-10-23 09:55:42 -05:00
Robert Baldyga
a3058a5d82 usb: gadget: f_fs: remove redundant ffs_data_get()
During FunctionFS bind, ffs_data_get() function was called twice
(in functionfs_bind() and in ffs_do_functionfs_bind()), while on unbind
ffs_data_put() was called once (in functionfs_unbind() function).
In result refcount never reached value 0, and ffs memory resources has
been never released.

Since ffs_data_get() call in ffs_do_functionfs_bind() is redundant
and not neccessary, we remove it to have equal number of gets ans puts,
and free allocated memory after refcount reach 0.

Fixes: 5920cda (usb: gadget: FunctionFS: convert to new function
	interface with backward compatibility)
Cc: <stable@vger.kernel.org> # v3.14+
Signed-off-by: Robert Baldyga <r.baldyga@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2014-10-23 09:55:42 -05:00
Geert Uytterhoeven
f1113be1bf usb: gadget: udc: USB_GADGET_XILINX should depend on HAS_DMA
If NO_DMA=y:

drivers/built-in.o: In function `xudc_done':
udc-xilinx.c:(.text+0x54f4d2): undefined reference to `usb_gadget_unmap_request'
drivers/built-in.o: In function `xudc_dma_send':
udc-xilinx.c:(.text+0x54f9f8): undefined reference to `dma_sync_single_for_cpu'
drivers/built-in.o: In function `xudc_read_fifo':
udc-xilinx.c:(.text+0x54ff4a): undefined reference to `dma_sync_single_for_cpu'
drivers/built-in.o: In function `xudc_ep_queue':
udc-xilinx.c:(.text+0x550e7c): undefined reference to `usb_gadget_map_request'

Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2014-10-23 09:55:41 -05:00
Roger Quadros
b01ff5cb2f Revert "usb: dwc3: dwc3-omap: Disable/Enable only wrapper interrupts in prepare/complete"
This reverts commit 02dae36aa6.

That commit is bogus in two ways:

1) There's no way dwc3-omap's ->suspend() can cause any effect
	on xhci's ->suspend(). Linux device driver model guarantees
	that a parent's ->suspend() will only be called after all
	children are suspended. dwc3-omap is the parent of the
	parent of xhci.

2) When implementing Deep Sleep states where context is lost,
	USBOTGSS_IRQ0 register, well, looses context so we
	_must_ rewrite it otherwise core IRQs will never be
	reenabled and USB will appear to be dead.

Fixes: 02dae36 (usb: dwc3: dwc3-omap: Disable/Enable only
	wrapper interrupts in prepare/complete)
Cc: <stable@vger.kernel.org> # v3.17
Cc: George Cherian <george.cherian@ti.com>
Signed-off-by: Roger Quadros <rogerq@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2014-10-23 09:55:41 -05:00
Felipe Balbi
a6615937bc usb: gadget: composite: enable BESL support
According to USB 2.0 ECN Errata for Link Power
Management (USB2-LPM-Errata-final.pdf), BESL
must be enabled if LPM is enabled.

This helps with USB30CV TD 9.21 LPM L1
Suspend Resume Test.

Signed-off-by: Felipe Balbi <balbi@ti.com>
2014-10-23 09:55:41 -05:00
Thomas Gleixner
d2e6d62c9c usb: musb: cppi41: restart hrtimer only if not yet done
commit c58d80f52 ("usb: musb: Ensure that cppi41 timer gets armed on
premature DMA TX irq") fixed hrtimer scheduling bug. There is one left
which does not trigger that often.
The following scenario is still possible:

    lock(&x->lock);
    hrtimer_start(&x->t);
    unlock(&x->lock);

expires:
    t->function();
                                lock(&x->lock);
    lock(&x->lock);             if (!hrtimer_queued(&x->t))
                                        hrtimer_start(&x->t);
                                unlock(&x->lock);

    if (!list_empty(x->early_tx_list))
           ret = HRTIMER_RESTART;
->         hrtimer_forward_now(...)
    } else
           ret = HRTIMER_NORESTART;

    unlock(&x->lock);

and the timer callback returns HRTIMER_RESTART for an armed timer. This
is wrong and we run into the BUG_ON() in __run_hrtimer().
This can happens on SMP or PREEMPT-RT.
The patch fixes the problem by only starting the timer if the timer is
not yet queued.

Cc: stable@vger.kernel.org
Reported-by: Torben Hohn <torbenh@linutronix.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
[bigeasy: collected information and created a patch + description based
          on it]
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2014-10-23 09:55:41 -05:00
Felipe Balbi
36f84ffb45 usb: dwc3: ep0: fix Data Phase for transfer sizes aligned to wMaxPacketSize
According to Section 8.5.3.2 of the USB 2.0 specification,
a USB device must terminate a Data Phase with either a
short packet or a ZLP (if the previous transfer was
a multiple of wMaxPacketSize).

For reference, here's what the USB 2.0 specification, section
8.5.3.2 says:

"
8.5.3.2 Variable-length Data Stage

A control pipe may have a variable-length data phase
in which the host requests more data than is contained
in the specified data structure. When all of the data
structure is returned to the host, the function should
indicate that the Data stage is ended by returning a
packet that is shorter than the MaxPacketSize for the
pipe. If the data structure is an exact multiple of
wMaxPacketSize for the pipe, the function will return
a zero-length packet to indicate the end of the Data
stage.
"

Signed-off-by: Felipe Balbi <balbi@ti.com>
2014-10-23 09:55:35 -05:00
Perry Hung
7f2719f000 usb: serial: ftdi_sio: add "bricked" FTDI device PID
An official recent Windows driver from FTDI detects counterfeit devices
and reprograms the internal EEPROM containing the USB PID to 0, effectively
bricking the device.

Add support for this VID/PID pair to correctly bind the driver on these
devices.

See:
http://hackaday.com/2014/10/22/watch-that-windows-update-ftdi-drivers-are-killing-fake-chips/

Signed-off-by: Perry Hung <iperry@gmail.com>
Cc: stable <stable@vger.kernel.org>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2014-10-23 09:52:57 +02:00
Peter Hurley
dc477ad386 USB: kobil_sct: Remove unused transfer buffer allocs
Commit 90419cfcb5,
"USB: kobil_sct: fix control requests without data stage", removed
the bogus data buffer arguments, but still allocate transfer
buffers which are not used.

Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
2014-10-22 10:10:50 +02:00
Dan Williams
012eee1522 USB: option: add Haier CE81B CDMA modem
Port layout:

0: QCDM/DIAG
1: NMEA
2: AT
3: AT/PPP

Signed-off-by: Dan Williams <dcbw@redhat.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2014-10-22 10:09:30 +02:00
Daniele Palmas
2d0eb862dd usb: option: add support for Telit LE910
Add VID/PID for Telit LE910 modem. Interfaces description is almost the
same than LE920, except that the qmi interface is number 2 (instead than
5).

Signed-off-by: Daniele Palmas <dnlplm@gmail.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2014-10-22 10:05:49 +02:00
Frans Klaver
edd74ffab1 usb: serial: ftdi_sio: add Awinda Station and Dongle products
Add new IDs for the Xsens Awinda Station and Awinda Dongle.

While at it, order the definitions by PID and add a logical separation
between devices using Xsens' VID and those using FTDI's VID.

Cc: <stable@vger.kernel.org>
Signed-off-by: Frans Klaver <frans.klaver@xsens.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
2014-10-22 10:04:35 +02:00