aboutsummaryrefslogtreecommitdiff
path: root/drivers/usb/host
AgeCommit message (Collapse)Author
2010-03-02USB: host: SL811: fix unaligned accessesMichael Hennerich
Signed-off-by: Michael Hennerich <michael.hennerich@analog.com> Signed-off-by: Bryan Wu <cooloney@kernel.org> Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2010-03-02USB: isp1362: Use kzalloc for allocating only one thingJulia Lawall
Use kzalloc rather than kcalloc(1,...) The semantic patch that makes this change is as follows: (http://coccinelle.lip6.fr/) // <smpl> @@ @@ - kcalloc(1, + kzalloc( ...) // </smpl> Signed-off-by: Julia Lawall <julia@diku.dk> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2010-03-02USB: xhci: No GFP_KERNEL in block error handlingOliver Neukum
xhci_add_endpoint() is used in the reset path. It must use GFP_NOIO to avoid a possible deadlock. Signed-off-by: Oliver Neukum <oliver@neukum.org> Acked-by: Sarah Sharp <sarah.a.sharp@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2010-03-02USB: ehci-au1xxx.c: use platform_get_resource() and resource_size()H Hartley Sweeten
Use platform_get_resource() to fetch the memory resource and resource_size() for calculate the length. Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Cc: David Brownell <dbrownell@users.sourceforge.net> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2010-03-02USB: ehci-atmel.c: use resource_size()H Hartley Sweeten
Use resource_size(). Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Cc: David Brownell <dbrownell@users.sourceforge.net> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2010-03-02USB: ehci-orion.c: use resource_size()H Hartley Sweeten
Use resource_size(). Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Cc: David Brownell <dbrownell@users.sourceforge.net> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2010-03-02USB: ehci-fsl: Add power management supportAnton Vorontsov
EHCI FSL controller preserve its state during sleep mode, so nothing fancy needs to be done. Though, during 'deep sleep' mode (as found in MPC831x CPUs) the controller turns off and needs to be reinitialized upon resume. This patch adds support for hibernation and resuming after deep sleep. Based on Dave Liu and Jerry Huang's work[1]. [1] http://www.bitshrine.org/gpp/linux-fsl-2.6.24.3-MPC8315ERDB-usb-power-mangement.patch Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2010-03-02USB: ehci-fsl: Fix sparse warningsAnton Vorontsov
This patch fixes following warnings: ehci-fsl.c:43:5: warning: symbol 'usb_hcd_fsl_probe' was not declared. Should it be static? ehci-fsl.c:150:6: warning: symbol 'usb_hcd_fsl_remove' was not declared. Should it be static? Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2010-03-02USB: ehci: fix audio record functionality for some Full speed sound blaster ↵Dmitri Epshtein
devices This patch fix audio record functionality for some Full speed sound blaster devices. Issue: Sometimes transaction complete indication is coming from HW one frame later. Solution: If scan_periodic process now frame or previous frame now-1 and sitd transaction is not finished yet, exit scan_periodic function and check the same transaction in the next frame. Signed-off-by: Dimitry Epshtein <dima@marvell.com> Signed-off-by: Saeed Bishara <saeed@marvell.com> Cc: David Brownell <dbrownell@users.sourceforge.net> Cc: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2010-03-02USB: ehci: add call of free_cached_itd_list() function in disable_periodic()Dmitri Epshtein
Sometimes disable_periodic() stop scan_periodic before than free_cached_itd_list() was called. In such case USB Host stacked during disconnect operation Solution: add call of free_cached_itd_list() function in disable_periodic() Signed-off-by: Dimitry Epshtein <dima@marvell.com> Signed-off-by: Saeed Bishara <saeed@marvell.com> Cc: David Brownell <dbrownell@users.sourceforge.net> Cc: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2010-03-02USB: Add call to notify xHC of a device reset.Sarah Sharp
Add a new host controller driver method, reset_device(), that the USB core will use to notify the host of a successful device reset. The call may fail due to out-of-memory errors; attempt the port reset sequence again if that happens. Update hub_port_init() to allow resetting a configured device. Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2010-03-02USB: xhci: Notify the xHC when a device is reset.Sarah Sharp
When a USB device is reset, the xHCI hardware must know, in order to match the device state and disable all endpoints except control endpoint 0. Issue a Reset Device command after a USB device is successfully reset. Wait on the command to finish, and then cache or free the disabled endpoint rings. There are four different USB device states that the xHCI hardware tracks: - disabled/enabled - device connection has just been detected, - default - the device has been reset and has an address of 0, - addressed - the device has a non-zero address but no configuration has been set, - configured - a set configuration succeeded. The USB core may issue a port reset when a device is in any state, but the Reset Device command will fail for a 0.96 xHC if the device is not in the addressed or configured state. Don't consider this failure as an error, but don't free any endpoint rings if this command fails. A storage driver may request that the USB device be reset during error handling, so use GPF_NOIO instead of GPF_KERNEL while allocating memory for the Reset Device command. Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2010-03-02USB: xhci: Allow roothub ports to be disabled.Sarah Sharp
Add the hub emulation code to allow ports on an xHCI root hub to be disabled. Add the code to clear the port enabled/disabled bit, and clear the port enabled/disabled change bit. Like EHCI, the port cannot be enabled by setting the port enabled/disabled bit. Instead, a port is enabled by the host controller after a reset. Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2010-03-02USB: xhci: Refactor code to clear port change bits.Sarah Sharp
Refactor the code to clear the port change bits in the port status register. All port status change bits are write one to clear. Remove a redundant port status read that was supposed to unblock any posted writes. We read the port after the write to get the updated status for debugging, so the port read after that is unnecessary. Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2010-03-02USB: xhci: Refactor test for vendor-specific completion codes.Sarah Sharp
All commands that can be issued to the xHCI hardware can come back with vendor-specific "informational" completion codes. These are to be treated like a successful completion code. Refactor out the code to test for the range of these codes and print debugging messages. Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2010-03-02USB: xhci: Allow allocation of commands without input contexts.Sarah Sharp
The xhci_command structure is the basic structure for issuing commands to the xHCI hardware. It contains a struct completion (so that the issuing function can wait on the command), command status, and a input context that is used to pass information to the hardware. Not all commands need the input context, so make it optional to allocate. Allow xhci_free_container_ctx() to be passed a NULL input context, to make freeing the xhci_command structure simple. Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2010-03-02USB: xhci: Refactor code to free or cache endpoint rings.Sarah Sharp
Refactor out the code to cache or free endpoint rings from recently dropped or disabled endpoints. This code will be used by a new function to reset a device and disable all endpoints except control endpoint 0. Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2010-03-02USB: xhci: Fix error path when configuring endpoints.Sarah Sharp
If we fail to queue an evaluate context command or a configure endpoint command to the command ring in xhci_configure_endpoint(), we need to remove the xhci_command structure from the device's command list before returning. If the command is left on the command list, it will sit there indefinitely, blocking commands submitted after this fails. Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2010-03-02USB: fix occasional ULPI timeouts with ehci-mxcValentin Longchamp
On various mxc boards, the intial ULPI reads resulted in a timeout which prevented the transceiver to be identified and thus the ehci device to be probed. Initializing the hardware lines connected to the transceiver (through pdata->init call) before actually enabling clocks and configuring registers in the devices fixes this problem. Signed-off-by: Valentin Longchamp <valentin.longchamp@epfl.ch> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2010-03-02USB: MXC: Add i.MX21 specific USB host controller driver.Martin Fuzzey
This driver is a Full / Low speed only USB host for the i.MX21. Signed-off-by: Martin Fuzzey <mfuzzey@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2010-02-16USB: FHCI: Fix build after kfifo reworkAnton Vorontsov
After kfifo rework FHCI fails to build: CC drivers/usb/host/fhci-tds.o drivers/usb/host/fhci-tds.c: In function 'fhci_ep0_free': drivers/usb/host/fhci-tds.c:108: error: used struct type value where scalar is required drivers/usb/host/fhci-tds.c:118: error: used struct type value where scalar is required drivers/usb/host/fhci-tds.c:128: error: used struct type value where scalar is required This is because kfifos are no longer pointers in the ep struct. So, instead of checking the pointers, we should now check if kfifo is initialized. Reported-by: Josh Boyer <jwboyer@gmail.com> Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com> Acked-by: Stefani Seibold <stefani@seibold.net> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2010-02-16USB: ehci: phy low power mode bug fixingAlek Du
1. There are two msleep calls inside two spin lock sections, need to unlock and lock again after msleep. 2. Save a extra status reg setting. Signed-off-by: Alek Du <alek.du@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2010-02-05usb: r8a66597-hcd: Fix up spinlock recursion in root hub polling.Paul Mundt
The current root hub polling code exhibits a spinlock recursion on the private controller lock. r8a66597_root_hub_control() is called from r8a66597_timer() which grabs the lock and disables IRQs. The following chain emerges: r8a66597_timer() <-- lock taken r8a66597_root_hub_control() r8a66597_check_syssts() usb_hcd_poll_rh_status() <-- acquires the same lock /* insert death here */ The entire chain requires IRQs to be disabled, so we just unlock and relock around the call to usb_hcd_poll_rh_status() while leaving the IRQ state unchanged. Signed-off-by: Paul Mundt <lethal@linux-sh.org> Acked-by: Yoshihiro Shimoda <shimoda.yoshihiro@renesas.com>
2010-02-05usb: r8a66597-hcd: Flush the D-cache for the pipe-in transfer buffers.Paul Mundt
This implements the same D-cache flushing logic for r8a66597-hcd as Catalin's isp1760 (http://patchwork.kernel.org/patch/76391/) change, with the same note applying here as well: When the HDC driver writes the data to the transfer buffers it pollutes the D-cache (unlike DMA drivers where the device writes the data). If the corresponding pages get mapped into user space, there are no additional cache flushing operations performed and this causes random user space faults on architectures with separate I and D caches (Harvard) or those with aliasing D-cache. This fixes up crashes during USB boot on SH7724 and others: http://marc.info/?l=linux-sh&m=126439837308912&w=2 Reported-by: Goda Yusuke <goda.yusuke@renesas.com> Tested-by: Goda Yusuke <goda.yusuke@renesas.com> Cc: stable@kernel.org Signed-off-by: Paul Mundt <lethal@linux-sh.org> Acked-by: Yoshihiro Shimoda <shimoda.yoshihiro@renesas.com>
2010-02-02usb: r8a66597-hdc disable interrupts fixMagnus Damm
This patch improves disable_controller() in the r8a66597-hdc driver to disable all interrupts and clear status flags. It also makes sure that disable_controller() is called during probe(). This fixes the relatively rare case of unexpected pending interrupts after kexec reboot. Signed-off-by: Magnus Damm <damm@opensource.se> Acked-by: Yoshihiro Shimoda <shimoda.yoshihiro@renesas.com> Signed-off-by: Paul Mundt <lethal@linux-sh.org>
2010-01-20USB: isp1362: fix build failure on ARM systems via irq_flags cleanupLothar Wassmann
There was some left over #ifdef ARM logic that is outdated but no one really noticed. So instead of relying on this tricky logic, properly load and utilize the platform irq_flags resources. Reported-by: Ben Hutchings <ben@decadent.org.uk> Signed-off-by: Lothar Wassmann <LW@KARO-electronics.de> Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2010-01-20USB: isp1362: better 64bit printf warning fixesLothar Wassmann
Some hosts that treat the return value of sizeof differently from unsigned long might still hit warnings. So use %zu for sizeof() values. This is a better version of the previous commit b0a9cf297e58721933. Signed-off-by: Lothar Wassmann <LW@KARO-electronics.de> Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2010-01-20USB: Fix level of isp1760 Reloading ptd error messageColin Tuckley
This error message is not actually an error, it's an information message. It is triggered when a transfer which ended in a NAQ is retried successfully by the hardware. Signed-off-by: Colin Tuckley <colin.tuckley@arm.com> Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Cc: Catalin Marinas <catalin.marinas@arm.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2010-01-20USB: FHCI: avoid NULL pointer dereferenceAlexander Beregalov
Assign fhci only if usb is not NULL. Signed-off-by: Alexander Beregalov <a.beregalov@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2010-01-20USB: add missing delay during remote wakeupAlan Stern
This patch (as1330) fixes a bug in khbud's handling of remote wakeups. When a device sends a remote-wakeup request, the parent hub (or the host controller driver, for directly attached devices) begins the resume sequence and notifies khubd when the sequence finishes. At this point the port's SUSPEND feature is automatically turned off. However the device needs an additional 10-ms resume-recovery time (TRSMRCY in the USB spec). Khubd does not wait for this delay if the SUSPEND feature is off, and as a result some devices fail to behave properly following a remote wakeup. This patch adds the missing delay to the remote-wakeup path. It also extends the resume-signalling delay used by ehci-hcd and uhci-hcd from 20 ms (the value in the spec) to 25 ms (the value we use for non-remote-wakeup resumes). The extra time appears to help some devices. Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Cc: stable <stable@kernel.org> Cc: Rickard Bellini <rickard.bellini@ericsson.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2010-01-20USB: EHCI & UHCI: fix race between root-hub suspend and port resumeAlan Stern
This patch (as1321) fixes a problem with EHCI and UHCI root-hub suspends: If the suspend occurs while a port is trying to resume, the resume doesn't finish and simply gets lost. When remote wakeup is enabled, this is undesirable behavior. The patch checks first to see if any port resumes are in progress, and if they are then it fails the root-hub suspend with -EBUSY. Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Cc: stable <stable@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2010-01-20USB: EHCI: fix handling of unusual interrupt intervalsAlan Stern
This patch (as1320) fixes two problems related to interrupt-URB scheduling in ehci-hcd. URBs with an interval of 2 or 4 microframes aren't handled. For the time being, the patch reduces to interval to 1 uframe. URBs are constrained to have an interval no larger than 1024 frames by usb_submit_urb(). But some EHCI controllers allow use of a schedule as short as 256 frames; for these controllers we may have to decrease the interval to the actual schedule length. The second problem isn't very significant since few devices expose interrupt endpoints with an interval larger than 256 frames. But the first problem is critical; it will prevent the kernel from working with devices having interrupt intervals of 2 or 4 uframes. Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Cc: stable <stable@kernel.org> Tested-by: Glynn Farrow <farrowg@sg.ibm.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-12-22kfifo: rename kfifo_put... into kfifo_in... and kfifo_get... into kfifo_out...Stefani Seibold
rename kfifo_put... into kfifo_in... to prevent miss use of old non in kernel-tree drivers ditto for kfifo_get... -> kfifo_out... Improve the prototypes of kfifo_in and kfifo_out to make the kerneldoc annotations more readable. Add mini "howto porting to the new API" in kfifo.h Signed-off-by: Stefani Seibold <stefani@seibold.net> Acked-by: Greg Kroah-Hartman <gregkh@suse.de> Acked-by: Mauro Carvalho Chehab <mchehab@redhat.com> Acked-by: Andi Kleen <ak@linux.intel.com> Acked-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2009-12-22kfifo: cleanup namespaceStefani Seibold
change name of __kfifo_* functions to kfifo_*, because the prefix __kfifo should be reserved for internal functions only. Signed-off-by: Stefani Seibold <stefani@seibold.net> Acked-by: Greg Kroah-Hartman <gregkh@suse.de> Acked-by: Mauro Carvalho Chehab <mchehab@redhat.com> Acked-by: Andi Kleen <ak@linux.intel.com> Acked-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2009-12-22kfifo: move out spinlockStefani Seibold
Move the pointer to the spinlock out of struct kfifo. Most users in tree do not actually use a spinlock, so the few exceptions now have to call kfifo_{get,put}_locked, which takes an extra argument to a spinlock. Signed-off-by: Stefani Seibold <stefani@seibold.net> Acked-by: Greg Kroah-Hartman <gregkh@suse.de> Acked-by: Mauro Carvalho Chehab <mchehab@redhat.com> Acked-by: Andi Kleen <ak@linux.intel.com> Acked-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2009-12-22kfifo: move struct kfifo in placeStefani Seibold
This is a new generic kernel FIFO implementation. The current kernel fifo API is not very widely used, because it has to many constrains. Only 17 files in the current 2.6.31-rc5 used it. FIFO's are like list's a very basic thing and a kfifo API which handles the most use case would save a lot of development time and memory resources. I think this are the reasons why kfifo is not in use: - The API is to simple, important functions are missing - A fifo can be only allocated dynamically - There is a requirement of a spinlock whether you need it or not - There is no support for data records inside a fifo So I decided to extend the kfifo in a more generic way without blowing up the API to much. The new API has the following benefits: - Generic usage: For kernel internal use and/or device driver. - Provide an API for the most use case. - Slim API: The whole API provides 25 functions. - Linux style habit. - DECLARE_KFIFO, DEFINE_KFIFO and INIT_KFIFO Macros - Direct copy_to_user from the fifo and copy_from_user into the fifo. - The kfifo itself is an in place member of the using data structure, this save an indirection access and does not waste the kernel allocator. - Lockless access: if only one reader and one writer is active on the fifo, which is the common use case, no additional locking is necessary. - Remove spinlock - give the user the freedom of choice what kind of locking to use if one is required. - Ability to handle records. Three type of records are supported: - Variable length records between 0-255 bytes, with a record size field of 1 bytes. - Variable length records between 0-65535 bytes, with a record size field of 2 bytes. - Fixed size records, which no record size field. - Preserve memory resource. - Performance! - Easy to use! This patch: Since most users want to have the kfifo as part of another object, reorganize the code to allow including struct kfifo in another data structure. This requires changing the kfifo_alloc and kfifo_init prototypes so that we pass an existing kfifo pointer into them. This patch changes the implementation and all existing users. [akpm@linux-foundation.org: fix warning] Signed-off-by: Stefani Seibold <stefani@seibold.net> Acked-by: Greg Kroah-Hartman <gregkh@suse.de> Acked-by: Mauro Carvalho Chehab <mchehab@redhat.com> Acked-by: Andi Kleen <ak@linux.intel.com> Acked-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2009-12-17Merge branch 'omap-fixes-for-linus' of ↵Linus Torvalds
git://git.kernel.org/pub/scm/linux/kernel/git/tmlind/linux-omap-2.6 * 'omap-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tmlind/linux-omap-2.6: OMAP3: serial - fix bug introduced in mfd: twl: fix twl4030 rename for remaining driver, board files USB ehci: replace mach header with plat omap3: Allow EHCI to be built on OMAP3
2009-12-16USB ehci: replace mach header with platThomas Weber
Replace the mach/usb.h with plat/usb.h Cc: linux-usb-devel@lists.sourceforge.net Signed-off-by: Thomas Weber <weber@corscience.de> Acked-by: Felipe Balbi <felipe.balbi@nokia.com> Acked-by: Greg Kroah-Hartman <gregkh@suse.de> Signed-off-by: Tony Lindgren <tony@atomide.com>
2009-12-16isp1362-hcd: use bitmap_find_next_zero_areaAkinobu Mita
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com> Cc: Greg Kroah-Hartman <gregkh@suse.de> Cc: Lothar Wassmann <LW@KARO-electronics.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2009-12-15const: constify remaining dev_pm_opsAlexey Dobriyan
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2009-12-11USB: xhci: Fix command completion after a drop endpoint.Sarah Sharp
The xHCI driver issues a Configure Endpoint command for two reasons: - a new configuration or alternate interface setting is selected - a quirky Fresco Logic prototype requires the command after a Reset Endpoint command. The xHCI driver only waits on the command in the first case. When a configure endpoint command completes, the driver needs to know why the command was generated. When the driver only supported selecting an initial configuration, the check was simple. Unfortunately that check doesn't work now that the driver supports alternate interfaces. If an endpoint must be dropped (because it's not in the new alternate setting) and no new endpoints are added, the math involving xhci_last_valid_endpoint() will assign -1 to an unsigned integer and cause an out-of-bounds array access. Move the check for the quirky hardware sooner and avoid the bad array access. Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-12-11USB: xhci: Make reverting an alt setting "unfailable".Sarah Sharp
When a driver wants to switch to a different alternate setting for an interface, the USB core will (soon) check whether there is enough bandwidth. Once the new alternate setting is installed in the xHCI hardware, the USB core will send a USB_REQ_SET_INTERFACE control message. That can fail in various ways, and the USB core needs to be able to reinstate the old alternate setting. With the old code, reinstating the old alt setting could fail if the there's not enough memory to allocate new endpoint rings. Keep around a cache of (at most 31) endpoint rings for this case. When we successfully switch the xHCI hardware to the new alt setting, the old alt setting's rings will be stored in the cache. Therefore we'll always have enough rings to satisfy a conversion back to a previous device setting. Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-12-11USB: ehci-omap.c: introduce missing kfreeJulia Lawall
Error handling code following a kzalloc should free the allocated data. The semantic match that finds this problem is as follows: (http://www.emn.fr/x-info/coccinelle/) // <smpl> @r exists@ local idexpression x; statement S; expression E; identifier f,f1,l; position p1,p2; expression *ptr != NULL; @@ x@p1 = \(kmalloc\|kzalloc\|kcalloc\)(...); ... if (x == NULL) S <... when != x when != if (...) { <+...x...+> } ( x->f1 = E | (x->f1 == NULL || ...) | f(...,x->f1,...) ) ...> ( return \(0\|<+...x...+>\|ptr\); | return@p2 ...; ) @script:python@ p1 << r.p1; p2 << r.p2; @@ print "* file: %s kmalloc %s return %s" % (p1[0].file,p1[0].line,p2[0].line) // </smpl> Signed-off-by: Julia Lawall <julia@diku.dk> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-12-11USB: xhci-mem.c: introduce missing kfreeJulia Lawall
Error handling code following a kzalloc should free the allocated data. The semantic match that finds this problem is as follows: (http://www.emn.fr/x-info/coccinelle/) // <smpl> @r exists@ local idexpression x; statement S; expression E; identifier f,f1,l; position p1,p2; expression *ptr != NULL; @@ x@p1 = \(kmalloc\|kzalloc\|kcalloc\)(...); ... if (x == NULL) S <... when != x when != if (...) { <+...x...+> } ( x->f1 = E | (x->f1 == NULL || ...) | f(...,x->f1,...) ) ...> ( return \(0\|<+...x...+>\|ptr\); | return@p2 ...; ) @script:python@ p1 << r.p1; p2 << r.p2; @@ print "* file: %s kmalloc %s return %s" % (p1[0].file,p1[0].line,p2[0].line) // </smpl> Signed-off-by: Julia Lawall <julia@diku.dk> Acked-by: Sarah Sharp <sarah.a.sharp@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-12-11USB: whci-hcd: correctly handle sg lists longer than QTD_MAX_XFER_SIZE.David Vrabel
When building qTDs (sTDs) from a scatter-gather list, the length of the qTD must be a multiple of wMaxPacketSize if the transfer continues into another qTD. This also fixes a link failure on configurations for 32 bit processors with 64 bit dma_addr_t (e.g., CONFIG_HIGHMEM_64G). Signed-off-by: David Vrabel <david.vrabel@csr.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-12-11USB: xhci: Handle errors that cause endpoint halts.Sarah Sharp
The xHCI 0.95 and 0.96 specification defines several transfer buffer request completion codes that indicate a USB transaction error occurred. When a stall, babble, transaction, or split transaction error completion code is set, the xHCI has halted that endpoint ring. Software must issue a Reset Endpoint command and a Set Transfer Ring Dequeue Pointer command to clean up the halted ring. The USB device driver is supposed to call into usb_reset_endpoint() when an endpoint stalls. That calls into the xHCI driver to issue the proper commands. However, drivers don't call that function for the other errors that cause the xHC to halt the endpoint ring. If a babble, transaction, or split transaction error occurs, check if the endpoint context reports a halted condition, and clean up the endpoint ring if it does. Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-12-11USB: xhci: Return success for vendor-specific info codes.Sarah Sharp
An xHCI host controller manufacturer can choose to implement several vendor-specific informational completion codes. These are all to be treated like a successful transfer completion. Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-12-11USB: xhci: Return -EPROTO on a split transaction error.Sarah Sharp
When the xHCI hardware says a transfer completed with a split transaction error, set the URB status to -EPROTO. Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-12-11USB: xhci: Set transfer descriptor size field correctly.Sarah Sharp
The transfer descriptor (TD) is a series of transfer request buffers (TRBs) that describe the buffer pointer, length, and other characteristics. The xHCI controllers want to know an estimate of how long the TD is, for caching reasons. In each TRB, there is a "TD size" field that provides a rough estimate of the remaining buffers to be transmitted, including the buffer pointed to by that TRB. The TD size is 5 bits long, and contains the remaining size in bytes, right shifted by 10 bits. So a remaining TD size less than 1024 would get a zero in the TD size field, and a remaining size greater than 32767 would get 31 in the field. This patches fixes a bug in the TD_REMAINDER macro that is triggered when the URB has a scatter gather list with a size bigger than 32767 bytes. Not all host controllers pay attention to the TD size field, so the bug will not appear on all USB 3.0 hosts. Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-12-11USB: xhci: Add tests for TRB address translation.Sarah Sharp
It's not surprising that the transfer request buffer (TRB) physical to virtual address translation function has bugs in it, since I wrote most of it at 4am last October. Add a test suite to check the TRB math. This runs at memory initialization time, and causes the driver to fail to load if the TRB math fails. Please excuse the excessively long lines in the test vectors; they can't really be made shorter and still be readable. Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>