Gernot Hillier [Mon, 11 Jan 2010 08:35:17 +0000 (09:35 +0100)]
USB: serial: option.c: Add 4G W14 stick to blacklist for option_send_setup
The 4G XS Stick W14 seems to not understand RTS/DTR setting in
option_send_setup causing long timeouts on any open() which disturbs a
lot of well-known userspace applications like minicom or ModemManager.
Therefore, we enable OPTION_BLACKLIST_SENDSETUP blacklisting for it.
Gernot Hillier [Mon, 11 Jan 2010 08:30:00 +0000 (09:30 +0100)]
USB: serial: option.c: Add blacklisting infrastructure for special device handling
As suggested by Matthias Urlichs, this patch adds a somehow generic
mechanism for special handling of devices which don't support all bits
expected by this driver.
The blacklisting code is heavily stolen from sierra.c, but extended to
support different special cases.
For now, one case is implemented (OPTION_BLACKLIST_SENDSETUP), targeted
at the 4G W14 device: devices which don't understand the setting of
RTS/DTR in option_send_setup() causing a USB timeout of 5 s in any
userspace open() which leads to errors in most userspace applications.
In addition, I prepared another case for devices with interfaces which
shall not be accessed by this driver (targeted at the D-Link DWM 652).
However, OPTION_BLACKLIST_RESERVED_IF is not fully implemented yet as I
have no device to test this. Anyone volunteering to help here? If not,
I'll contact the guys who added D-Link DWM 652 support soon.
Herbert Xu [Sun, 10 Jan 2010 09:15:03 +0000 (20:15 +1100)]
USB: Move hcd free_dev call into usb_disconnect to fix oops
USB: Move hcd free_dev call into usb_disconnect
I found a way to oops the kernel:
1. Open a USB device through devio.
2. Remove the hcd module in the host kernel.
3. Close the devio file descriptor.
The problem is that closing the file descriptor does usb_release_dev
as it is the last reference. usb_release_dev then tries to invoke
the hcd free_dev function (or rather dereferencing the hcd driver
struct). This causes an oops as the hcd driver has already been
unloaded so the struct is gone.
This patch tries to fix this by bringing the free_dev call earlier
and into usb_disconnect. I have verified that repeating the
above steps no longer crashes with this patch applied.
Pete Zaitcev [Fri, 8 Jan 2010 22:39:22 +0000 (15:39 -0700)]
USB: fix crash in uhci_scan_schedule
When hardware is removed on a Stratus, the system may crash like this:
ACPI: PCI interrupt for device 0000:7c:00.1 disabled
Trying to free nonexistent resource <00000000a8000000-00000000afffffff>
Trying to free nonexistent resource <00000000a4800000-00000000a480ffff>
uhci_hcd 0000:7e:1d.0: remove, state 1
usb usb2: USB disconnect, address 1
usb 2-1: USB disconnect, address 2
Unable to handle kernel paging request at 0000000000100100 RIP:
[<ffffffff88021950>] :uhci_hcd:uhci_scan_schedule+0xa2/0x89c
This occurs because an interrupt scans uhci->skelqh, which is
being freed. We do the right thing: disable the interrupts in the
device, and do not do any processing if the interrupt is shared
with other source, but it's possible that another CPU gets
delayed somewhere (e.g. loops) until we started freeing.
The agreed-upon solution is to wait for interrupts to play out
before proceeding. No other bareers are neceesary.
A backport of this patch was tested on a 2.6.18 based kernel.
Testing of 2.6.32-based kernels is under way, but it takes us
forever (months) to turn this around. So I think it's a good
patch and we should keep it.
Alan Stern [Fri, 8 Jan 2010 17:57:28 +0000 (12:57 -0500)]
USB: convert to the runtime PM framework
This patch (as1329) converts the USB stack over to the PM core's
runtime PM framework. This involves numerous changes throughout
usbcore, especially to hub.c and driver.c. Perhaps the most notable
change is that CONFIG_USB_SUSPEND now depends on CONFIG_PM_RUNTIME
instead of CONFIG_PM.
Several fields in the usb_device and usb_interface structures are no
longer needed. Some code which used to depend on CONFIG_USB_PM now
depends on CONFIG_USB_SUSPEND (requiring some rearrangement of header
files).
The only visible change in behavior should be that following a system
sleep (resume from RAM or resume from hibernation), autosuspended USB
devices will be resumed just like everything else. They won't remain
suspended. But if they aren't in use then they will naturally
autosuspend again in a few seconds.
Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Alan Stern [Fri, 8 Jan 2010 17:57:02 +0000 (12:57 -0500)]
USB: change handling of negative autosuspend delays
This patch (as1327) changes the way negative autosuspend delays
prevent device from autosuspending. The current code checks for
negative values explicitly in the autosuspend_check() routine. The
updated code keeps things from getting that far by using
usb_autoresume_device() to increment the usage counter when a negative
delay is set, and by using usb_autosuspend_device() to decrement the
usage counter when a non-negative delay is set.
This complicates the set_autosuspend() attribute method code slightly,
but it will reduce the overall power management overhead.
Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Alan Stern [Fri, 8 Jan 2010 17:56:54 +0000 (12:56 -0500)]
USB: implement usb_enable_autosuspend
This patch (as1326) adds usb_enable_autosuspend() and
usb_disable_autosuspend() routines for use by drivers. If a driver
knows that its device can handle suspends and resumes correctly, it
can enable autosuspend all by itself. This is equivalent to the user
writing "auto" to the device's power/level attribute.
The implementation differs slightly from what it used to be. Now
autosuspend is disabled simply by doing usb_autoresume_device() (to
increment the usage counter) and enabled by doing
usb_autosuspend_device() (to decrement the usage counter).
The set_level() attribute method is updated to use the new routines,
and the USB Power-Management documentation is updated.
The patch adds a usb_enable_autosuspend() call to the hub driver's
probe routine, allowing the special-case code for hubs in quirks.c to
be removed.
Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Alan Stern [Fri, 8 Jan 2010 17:56:42 +0000 (12:56 -0500)]
USB: use the device lock for persist_enabled
This patch (as1325) changes the locking for the persist_enabled flag
in struct usb_device. Now it is protected by the device lock, along
with all its neighboring bit flags, instead of the PM lock (which is
about to vanish anyway).
Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Alan Stern [Fri, 8 Jan 2010 17:56:30 +0000 (12:56 -0500)]
USB: consolidate remote wakeup routines
This patch (as1324) makes a small change to the code used for remote
wakeup of root hubs. hcd_resume_work() now calls the hub driver's
remote-wakeup routine instead of implementing its own version.
The patch is complicated by the need to rename remote_wakeup() to
usb_remote_wakeup(), make it non-static, and declare it in a header
file. There's also the additional complication required to make
everything work when CONFIG_PM isn't set; the do-nothing inline
routine had to be moved into the header file.
Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Alan Stern [Fri, 8 Jan 2010 17:56:19 +0000 (12:56 -0500)]
USB: change locking for device-level autosuspend
This patch (as1323) changes the locking requirements for
usb_autosuspend_device(), usb_autoresume_device(), and
usb_try_autosuspend_device(). This isn't a very important change;
mainly it's meant to make the locking more uniform.
The most tricky part of the patch involves changes to usbdev_open().
To avoid an ABBA locking problem, it was necessary to reduce the
region protected by usbfs_mutex. Since that mutex now protects only
against simultaneous open and remove, this posed no difficulty -- its
scope was larger than necessary.
And it turns out that usbfs_mutex is no longer needed in
usbdev_release() at all. The list of usbfs "ps" structures is now
protected by the device lock instead of by usbfs_mutex.
Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Sarah Sharp [Tue, 5 Jan 2010 22:33:29 +0000 (14:33 -0800)]
USB: Use bInterfaceNumber in bandwidth allocations.
USB devices do not have to sort interfaces in their descriptors based on
the interface number, and they may choose to skip interface numbers. The
USB bandwidth allocation code for installing a new configuration assumes
the for loop variable will match the interface number. Make it use the
interface number (bInterfaceNumber) in the descriptor instead.
Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Jan Dumon [Tue, 5 Jan 2010 14:53:26 +0000 (15:53 +0100)]
USB: unusual_devs: Add support for multiple Option 3G sticks
Enable the SD-Card interface on multiple Option 3G sticks.
The unusual_devs.h entry is necessary because the device descriptor is
vendor-specific. That prevents usb-storage from binding to it as an interface
driver.
Signed-off-by: Jan Dumon <j.dumon@option.com> Signed-off-by: Phil Dibowitz <phil@ipom.com> Cc: stable <stable@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Sarah Sharp [Mon, 4 Jan 2010 20:20:17 +0000 (12:20 -0800)]
USB: xhci: Fix compile issues with xhci_get_slot_state()
Randy Dunlap reported this error when compiling the xHCI driver:
linux-next-20100104/drivers/usb/host/xhci.h:1214:
sorry, unimplemented: inlining failed in call to 'xhci_get_slot_state': function body not available
The xhci_get_slot_state() function belongs in xhci-dbg.c, since it
involves debugging internal xHCI structures. However, it is only used in
xhci-hcd.c. Some toolchains may have issues since the inlined function
body is not in the xhci.h header file. Remove the inline keyword to avoid
this.
Reported-by: Randy Dunlap <randy.dunlap@oracle.com> Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com> Acked-by: Randy Dunlap <randy.dunlap@oracle.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Dan Carpenter [Thu, 31 Dec 2009 15:42:55 +0000 (17:42 +0200)]
USB: serial: fix DMA buffers on stack for io_edgeport.c
The original code was passing a stack variable as a dma buffer, so I
made it an allocated variable. Instead of adding a bunch of kfree()
calls, I changed all the error return paths to gotos.
Also I noticed that the error checking wasn't correct because
usb_get_descriptor() can return negative values.
While I was at it, I made an unrelated white space change by moving
the unicode_to_ascii() on to one line.
Signed-off-by: Dan Carpenter <error27@gmail.com> Cc: Johan Hovold <jhovold@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Swaminathan S [Mon, 28 Dec 2009 11:40:38 +0000 (13:40 +0200)]
usb: musb: Fix cppi_channel_abort() function to handle Tx abort correctly
This patch fixes the Tx abort/teardown logic. We now wait for the teardown
completion interrupt and acknowledge the same by setting the tx_complete
register to 0.
This change is needed to ensure that abort processing works on DM365 platform.
Without this change after completion of abort processing the system is
overwhelmed with continuous stream of abort interrupts.
This change has been tested on all CPPI3.x platforms (DM644x, DM646x, DM35x,
DM36x).
Signed-off-by: Swaminathan S <swami.iyer@ti.com> Signed-off-by: Felipe Balbi <felipe.balbi@nokia.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Swaminathan S [Mon, 28 Dec 2009 11:40:37 +0000 (13:40 +0200)]
usb: musb: workaround toggle bug when doing bulk transfer after isoc
This patch implements the work around for a Mentor controller related
bug where it's observed a BULK Tx toggle error on the bus when a
BULK IO gets scheduled on an endpoint that was earlier used for
handling ISOC transaction and needed to start on 1 toggle. When such
a situation arises even if the TXCSR toggle bits are programmed
correctly by the musb driver the data gets transmitted with 0 toggle
which leads to toggle error on the bus and the BULK transaction fails.
In case of MSC write, the device gets reset by the Host.
This Mentor bug is observed on almost all Mentor versions (1.3, 1.5,
1.8). Confirmed on DM644x, DM355, DM365, OMAPL13x platforms.
Signed-off-by: Swaminathan S <swami.iyer@ti.com> Signed-off-by: Felipe Balbi <felipe.balbi@nokia.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Anand Gadiyar [Mon, 28 Dec 2009 11:40:36 +0000 (13:40 +0200)]
usb: musb: workaround MUSB DMA_INTR sometimes reads zero
MUSB DMA_INTR register may sometimes read zero when infact there
was a pending interrupt. Workaround this by reading the DMA_COUNT
values for all enabled channels when this condition occurs.
Flag these channels as the ones needing to be serviced.
Additionally, the absence of a debug print meant we would never
catch a spurious DMA interrupt in MUSB. So this patch adds a
debug print in the IRQ handler.
Signed-off-by: Anand Gadiyar <gadiyar@ti.com> Cc: Ajay Kumar Gupta <ajay.gupta@ti.com> Cc: David Brownell <dbrownell@users.sourceforge.net> Cc: Sergei Shtylyov <sshtylyov@ru.mvista.com> Cc: Vikram Pandita <vikram.pandita@ti.com> Signed-off-by: Felipe Balbi <felipe.balbi@nokia.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
We have observed MSC data read corruption when USB LAN device is
also connected and it's interface is up.
Silicon team has confirmed an errata where in all the active
transfers should use FIFO space either in first 8K or next 8K.
So far we have observed the issue in above use case scenario.
As a workaround to it, adding a new FIFO config (5) fitting well
within first 8K which can be used for such use cases.
Robert P. J. Day [Mon, 28 Dec 2009 11:31:08 +0000 (06:31 -0500)]
USB: Correct CONFIG variable typo.
Signed-off-by: Robert P. J. Day <rpjday@crashcourse.ca> Cc: David Brownell <dbrownell@users.sourceforge.net> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Johan Hovold [Thu, 24 Dec 2009 11:42:11 +0000 (12:42 +0100)]
USB: ftdi_sio: remove unnecessary initialisations
Return values are being initialised to zero only to be unconditionally
assigned to a few instructions later. This may give the impression that
zero is returned on success, which is not the case.
Note also that ftdi_NDI_device_setup never reports errors.
Signed-off-by: Johan Hovold <jhovold@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Dan Streetman [Wed, 6 Jan 2010 14:56:53 +0000 (09:56 -0500)]
USB: retain USB device power/wakeup setting across reconfiguration
Currently a non-root-hub USB device's wakeup settings are initialized when the
device is set to a configured state using device_init_wakeup(), but this is not
correct as wakeup is split into "capable" (can_wakeup) and "enabled"
(should_wakeup). The settings should be initialized instead in the device
initialization (usb_new_device) with the "capable" setting disabled and the
"enabled" setting enabled. The "capable" setting should be set based on the
device being configured or unconfigured, and "enabled" setting set based on
the sysfs power/wakeup control.
This patch retains the sysfs power/wakeup setting of a non-root-hub USB device
over a USB device re-configuration, which can happen (for example) after a
suspend/resume cycle.
Signed-off-by: Dan Streetman <ddstreet@ieee.org> Cc: David Brownell <dbrownell@users.sourceforge.net> Cc: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Pete Zaitcev [Tue, 5 Jan 2010 18:50:07 +0000 (11:50 -0700)]
usbmon: add bus number to text API
Due to a simple oversight when bus zero was added, the text API fails to
deliver the bus number in 'E' messages (which are equivalent of 'C'
messages, only for error case). This makes it harder, for instance,
use a search-and-highlight in a text editor. So fix it.
Also, Alan Stern requested adding timestamps to 'E' messages. This is
purely cosmetic, but makes it easier to read the trace. This is done
for both text and binary APIs.
Signed-off-by: Pete Zaitcev <zaitcev@redhat.com> Cc: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Bryan Wu [Mon, 21 Dec 2009 15:43:06 +0000 (10:43 -0500)]
USB: gadget: use ep5 for bulk-in and ep6 for bulk-out for Blackfin MUSB
Normally, the musb uses ep1 as the bidirectional bulk endpoint. This won't
work on the Blackfin musb as all endpoints (except ep0) are unidirectional.
Further, ep1-ep4 have a small 128 byte FIFO which makes them undesirable
for bulk endpoints (which need more like a 512 byte FIFO). This leaves us
with ep5-ep7 which have 1024 byte FIFOs and can be configured as either
in/out and bulk/interrupt/iso on the fly.
Signed-off-by: Bryan Wu <cooloney@kernel.org> Signed-off-by: Cliff Cai <cliff.cai@analog.com> Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Mike Frysinger [Fri, 18 Dec 2009 21:33:03 +0000 (16:33 -0500)]
USB: cypress_m8: allow unstable baud rates
I've got a crappy cypress converter here, and while running at higher
baud rates craps out on throughput, it works fine with lower ones.
While it'd be nice to simply use a lower baud rate, not all devices
can be configured this way, and it is possible to (slowly) interact
at higher rates by sending a byte at a time. So let people force
higher rates when they need it via a module parameter.
Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Mike Frysinger [Fri, 18 Dec 2009 21:33:02 +0000 (16:33 -0500)]
USB: cypress_m8: unify confusing new baudrate check
The current code has a confusing duplicate new_baudrate init when setting
the serial parameters. So just combine the if statement checks to avoid
this.
Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Oliver Neukum [Sat, 16 Jan 2010 00:33:03 +0000 (01:33 +0100)]
USB: Export QUIRK_RESET_MORPHS through sysfs
Some devices which use mode switching revert to their
primary mode as they are reset. They must not be reset for
error handling. As user spaces makes the switch it also
has to tell the kernel that a device is quirky.
Signed-off-by: Oliver Neukum <oliver@neukum.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Oliver Neukum [Fri, 18 Dec 2009 11:14:21 +0000 (12:14 +0100)]
USB: storage: Never reset devices that will morph to an old mode
Some devices must be switched to a new mode to fully use them.
A reset would make them revert to the old mode. Therefore a reset
must not be used for error handling with such devices.
Signed-off-by: Oliver Neukum <oliver@neukum.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Felipe Balbi [Thu, 17 Dec 2009 11:01:36 +0000 (13:01 +0200)]
USB: otg: add notifier support
The notifier will be used to communicate usb events
to other drivers like the charger chip.
This can be used as source of information to kick
usb charger detection as described by the USB
Battery Charging Specification 1.1 and/or to
pass bMaxPower field of selected usb_configuration
to charger chip in order to use that information
as input current on the charging profile
setup.
Signed-off-by: Felipe Balbi <felipe.balbi@nokia.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Julia Lawall [Thu, 17 Dec 2009 13:57:33 +0000 (13:57 +0000)]
USB: wusb: check CHID is all zeros before stopping the host
An incorrect sizeof() resulted in only 4 (or 8) octets of the CHID being
checked instead of all 16 octets. A randomly generated CHID had a
probability of being unable to start a WUSB host of less than 1 in
2 billion.
Signed-off-by: Julia Lawall <julia@diku.dk> Signed-off-by: David Vrabel <david.vrabel@csr.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>