]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commit
usb-storage: Add quirk to defeat Kindle's automatic unload
authorAlan Stern <stern@rowland.harvard.edu>
Wed, 17 Mar 2021 19:06:54 +0000 (15:06 -0400)
committerSeth Forshee <seth.forshee@canonical.com>
Thu, 8 Apr 2021 20:42:15 +0000 (15:42 -0500)
commite6f89c2af815f281acd52d86b16157d051460eee
tree87995bc7a2b4ffb660942bf1ba00c92192320d20
parent678bf9dbf465552a62b51c4ac7749d8d6163f83a
usb-storage: Add quirk to defeat Kindle's automatic unload

BugLink: https://bugs.launchpad.net/bugs/1921712
commit 546aa0e4ea6ed81b6c51baeebc4364542fa3f3a7 upstream.

Matthias reports that the Amazon Kindle automatically removes its
emulated media if it doesn't receive another SCSI command within about
one second after a SYNCHRONIZE CACHE.  It does so even when the host
has sent a PREVENT MEDIUM REMOVAL command.  The reason for this
behavior isn't clear, although it's not hard to make some guesses.

At any rate, the results can be unexpected for anyone who tries to
access the Kindle in an unusual fashion, and in theory they can lead
to data loss (for example, if one file is closed and synchronized
while other files are still in the middle of being written).

To avoid such problems, this patch creates a new usb-storage quirks
flag telling the driver always to issue a REQUEST SENSE following a
SYNCHRONIZE CACHE command, and adds an unusual_devs entry for the
Kindle with the flag set.  This is sufficient to prevent the Kindle
from doing its automatic unload, without interfering with proper
operation.

Another possible way to deal with this would be to increase the
frequency of TEST UNIT READY polling that the kernel normally carries
out for removable-media storage devices.  However that would increase
the overall load on the system and it is not as reliable, because the
user can override the polling interval.  Changing the driver's
behavior is safer and has minimal overhead.

CC: <stable@vger.kernel.org>
Reported-and-tested-by: Matthias Schwarzott <zzam@gentoo.org>
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Link: https://lore.kernel.org/r/20210317190654.GA497856@rowland.harvard.edu
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
drivers/usb/storage/transport.c
drivers/usb/storage/unusual_devs.h
include/linux/usb_usual.h