linux/drivers
Alan Stern 87d61912c2 USB: EHCI: add a delay when unlinking an active QH
Michael Reutman reports that an AMD/ATI EHCI host controller on one of
his computers does not stop transferring data when an active bulk QH
is unlinked from the async schedule.  Apparently that host controller
fails to implement the IAA mechanism correctly when an active QH is
unlinked.  This leads to data corruption, because the controller
continues to update the QH in memory when the driver doesn't expect
it.  As a result, the next URB submitted for that QH can hang, because
the link pointers for the TD queue have been messed up.  This
misbehavior is observed quite regularly.

To be fair, the EHCI spec (section 4.8.2) says that active QHs should
not be unlinked.  It goes on to recommend a procedure that involves
waiting for the QH to go inactive before unlinking it.  In the real
world this is impractical, not least because the QH may _never_ go
inactive.  (What were they thinking?)  Sometimes we have no choice but
to unlink an active QH.

In an attempt to avoid the problems that can ensue, this patch changes
how the driver decides when the unlink is complete.  In addition to
waiting through two IAA cycles, in cases where the QH was not known to
be inactive beforehand we now wait until a 2-ms period has elapsed
with the host controller making no change to the QH data structure
(the hw_current and hw_token fields in particular).  The intuition
here is that after such a long period, the endpoint must be NAKing and
hopefully the QH has been dropped from the host controller's internal
cache.  There's no way to know if this reasoning is really valid --
the spec is no help in this regard -- but at least this approach fixes
Michael's problem.

The test for whether the QH is already known to be inactive involves
the reason for unlinking the QH originally.  If it was unlinked
because it had halted, or it stopped in response to a short read, or
it overlaid a dummy TD (a silicon bug), then it certainly is inactive.
If it was unlinked because the TD queue was empty and no TDs have been
added to the queue in the meantime, then it must be inactive.  Or if
the hardware status indicates that the QH is currently halted (even if
that wasn't the reason for unlinking it), then it is inactive.
Otherwise, if none of those checks apply, we go through the 2-ms
delay.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Reported-by: Michael Reutman <mreutman@epiqsolutions.com>
Tested-by: Michael Reutman <mreutman@epiqsolutions.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-02-03 13:14:52 -08:00
..
accessibility
acpi Merge branches 'acpi-video' and 'acpi-hotplug' 2016-01-29 21:44:53 +01:00
amba
android
ata Merge branch 'for-4.5' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/libata 2016-01-11 19:33:59 -08:00
atm
auxdisplay
base Driver core fix for 4.5-rc2 2016-01-31 16:55:04 -08:00
bcma GPIO bulk updates for the v4.5 kernel cycle: 2016-01-17 12:32:01 -08:00
block Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/sage/ceph-client 2016-01-24 12:34:13 -08:00
bluetooth
bus ARM: SoC driver updates for v4.5 2016-01-20 18:42:30 -08:00
cdrom
char Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs 2016-01-23 12:24:56 -08:00
clk ARM: DT updates for v4.5 2016-01-20 18:16:29 -08:00
clocksource Merge branch 'timers-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2016-01-31 15:49:06 -08:00
connector
cpufreq Merge branches 'pm-cpuidle', 'pm-cpufreq', 'pm-domains' and 'pm-sleep' 2016-01-29 21:45:17 +01:00
cpuidle Merge branches 'pm-cpuidle', 'pm-cpufreq', 'pm-domains' and 'pm-sleep' 2016-01-29 21:45:17 +01:00
crypto Merge branch 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6 2016-01-22 11:58:43 -08:00
dca
devfreq PM / devfreq: Do not show statistics if it's not ready. 2016-01-13 17:30:33 +09:00
dio
dma dmaengine fixes for 4.5-rc1 2016-01-20 10:15:21 -08:00
dma-buf
edac
eisa
extcon
firewire
firmware UBSAN: run-time undefined behavior sanity checker 2016-01-20 17:09:18 -08:00
fmc
fpga
gpio ARM: SoC multiplatform code changes for v4.5 2016-01-20 18:03:56 -08:00
gpu Merge branch 'drm-rockchip-next-fixes-2016-01-22' of https://github.com/markyzq/kernel-drm-rockchip into drm-fixes 2016-01-29 10:04:29 +10:00
hid asm-generic changes for 4.5 2016-01-20 17:30:20 -08:00
hsi
hv char/misc patches for 4.5-rc1 2016-01-13 10:23:36 -08:00
hwmon hwmon: (fam15h_power) Add bit masking for tdp_limit 2016-01-27 18:48:46 -08:00
hwspinlock
hwtracing
i2c i2c: piix4: don't regress on bus names 2016-01-29 11:13:52 +01:00
ide drivers/ide: make ide-scan-pci.c driver explicitly non-modular 2016-01-18 14:12:33 -05:00
idle
iio Staging fixes for 4.5-rc2 2016-01-31 17:00:27 -08:00
infiniband Initial roundup of 4.5 merge window patches 2016-01-23 18:45:06 -08:00
input Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input 2016-01-22 17:20:30 -08:00
iommu iommu/amd: Correct the wrong setting of alias DTE in do_attach 2016-01-29 12:30:47 +01:00
ipack
irqchip Merge branch 'irq-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2016-01-31 14:48:58 -08:00
isdn Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2016-01-11 23:55:43 -05:00
leds GPIO bulk updates for the v4.5 kernel cycle: 2016-01-17 12:32:01 -08:00
lguest lguest: Map switcher text R/O 2016-01-12 12:17:28 +01:00
lightnvm lightnvm: introduce factory reset 2016-01-12 08:21:18 -07:00
macintosh
mailbox
mcb
md Merge branch 'for-4.5/drivers' of git://git.kernel.dk/linux-block 2016-01-21 18:19:38 -08:00
media dma-mapping: always provide the dma_map_ops based implementation 2016-01-20 17:09:18 -08:00
memory ARM: SoC driver updates for v4.5 2016-01-20 18:42:30 -08:00
memstick memstick: use sector_div instead of do_div 2016-01-20 17:09:18 -08:00
message
mfd GPIO bulk updates for the v4.5 kernel cycle: 2016-01-17 12:32:01 -08:00
misc Merge branch 'akpm' (patches from Andrew) 2016-01-21 12:32:08 -08:00
mmc MMC core: 2016-01-22 12:04:21 -08:00
mtd Merge branch 'upstream' of git://git.linux-mips.org/pub/scm/ralf/upstream-linus 2016-01-24 12:50:56 -08:00
net Initial roundup of 4.5 merge window patches 2016-01-23 18:45:06 -08:00
nfc
ntb NTB: Fix macro parameter conflict with field name 2016-01-21 19:53:10 -05:00
nubus
nvdimm mm, dax, pmem: introduce {get|put}_dev_pagemap() for dax-gup 2016-01-15 17:56:32 -08:00
nvme Merge branch 'for-4.5/nvme' of git://git.kernel.dk/linux-block 2016-01-21 19:58:02 -08:00
nvmem
of Merge branch 'irq-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2016-01-31 14:48:58 -08:00
oprofile wrappers for ->i_mutex access 2016-01-22 18:04:28 -05:00
parisc parisc: convert to dma_map_ops 2016-01-20 17:09:18 -08:00
parport
pci Merge branches 'acpi-video' and 'acpi-hotplug' 2016-01-29 21:44:53 +01:00
pcmcia
perf
phy
pinctrl GPIO bulk updates for the v4.5 kernel cycle: 2016-01-17 12:32:01 -08:00
platform ideapad-laptop: Add Lenovo Yoga 700 to no_hw_rfkill dmi list 2016-01-24 10:15:01 -08:00
pnp
power power: bq27xxx_battery: Fix bq27541 AveragePower register address 2016-01-14 01:03:18 +01:00
powercap Merge branch 'powercap' 2016-01-12 01:12:40 +01:00
pps
ps3
ptp
pwm pwm: Mark all devices as "might sleep" 2016-01-21 15:04:59 +01:00
rapidio rapidio: use kobj_to_dev() 2016-01-20 17:09:18 -08:00
ras
regulator regulator: Update for v4.5 2016-01-15 12:14:47 -08:00
remoteproc virtio: make find_vqs() checkpatch.pl-friendly 2016-01-12 20:47:06 +02:00
reset
rpmsg virtio: make find_vqs() checkpatch.pl-friendly 2016-01-12 20:47:06 +02:00
rtc RTC for 4.5 2016-01-18 12:10:45 -08:00
s390 s390/cio: update measurement characteristics 2016-01-26 12:47:51 +01:00
sbus
scsi Merge remote-tracking branch 'mkp-scsi/4.5/scsi-fixes' into fixes 2016-01-26 17:44:42 -08:00
sfi
sh
sn
soc ARM: SoC support for Tegra platforms for v4.5 2016-01-22 17:30:52 -08:00
spi powerpc updates for 4.5 2016-01-15 13:18:47 -08:00
spmi
ssb
staging TTY/Serial fixes for 4.5-rc2 2016-01-31 17:09:39 -08:00
target Merge branch 'for-4.5/nvme' of git://git.kernel.dk/linux-block 2016-01-21 19:58:02 -08:00
tc
thermal Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux 2016-01-24 12:43:06 -08:00
thunderbolt
tty TTY/Serial fixes for 4.5-rc2 2016-01-31 17:09:39 -08:00
uio
usb USB: EHCI: add a delay when unlinking an active QH 2016-02-03 13:14:52 -08:00
uwb
vfio vfio/noiommu: Don't use iommu_present() to track fake groups 2016-01-27 11:22:25 -07:00
vhost
video wrappers for ->i_mutex access 2016-01-22 18:04:28 -05:00
virt
virtio virtio_pci: fix use after free on release 2016-01-26 10:18:28 +02:00
vlynq
vme
w1
watchdog watchdog: asm9260: remove __init and __exit annotations 2016-01-11 22:48:05 +01:00
xen Merge branch 'stable/for-linus-4.5' of git://git.kernel.org/pub/scm/linux/kernel/git/konrad/mm 2016-01-29 15:13:48 -08:00
zorro
Kconfig
Makefile