History log of /drivers/usb/storage/transport.c
Revision Date Author Comments
b8db6d6402ddca1c78a27407fbd10a6ccb23ab14 25-Feb-2012 Sebastian Andrzej Siewior <bigeasy@linutronix.de> usb/storage: redefine US_BULK_FLAG_IN and use it

US_BULK_FLAG_IN is defined as 1 and not used. The USB storage spec says
that bit 7 of flags within CBW defines the data direction. 1 is DATA-IN
(read from device) and 0 is the DATA-OUT. Bit 6 is obselete and bits 0-5
are reserved.
This patch redefines the unsued define US_BULK_FLAG_IN from 1 to 1 << 7
aka 0x80 and replaces the obvious users. In a following patch the
storage gadget will use it as well.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
f940fcd8eadfe5b909a1474b57de7755edeee62b 27-May-2011 Paul Gortmaker <paul.gortmaker@windriver.com> usb: Add export.h for EXPORT_SYMBOL/THIS_MODULE where needed

With module.h being implicitly everywhere via device.h, the absence
of explicitly including something for EXPORT_SYMBOL went unnoticed.
Since we are heading to fix things up and clean module.h from the
device.h file, we need to explicitly include these files now.

Use the lightweight version of the header that has just THIS_MODULE
and EXPORT_SYMBOL variants.

Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
e16da02fcdf1c5e824432f88abf42623dafdf191 12-Nov-2010 Luben Tuikov <ltuikov@yahoo.com> USB: storage: Use normalized sense when emulating autosense

This patch solves two things:
1) Enables autosense emulation code to correctly
interpret descriptor format sense data, and
2) Fixes a bug whereby the autosense emulation
code would overwrite descriptor format sense data
with SENSE KEY HARDWARE ERROR in fixed format, to
incorrectly look like this:

Oct 21 14:11:07 localhost kernel: sd 7:0:0:0: [sdc] Sense Key : Recovered Error [current] [descriptor]
Oct 21 14:11:07 localhost kernel: Descriptor sense data with sense descriptors (in hex):
Oct 21 14:11:07 localhost kernel: 72 01 04 1d 00 00 00 0e 09 0c 00 00 00 00 00 00
Oct 21 14:11:07 localhost kernel: 00 4f 00 c2 00 50
Oct 21 14:11:07 localhost kernel: sd 7:0:0:0: [sdc] ASC=0x4 ASCQ=0x1d

Signed-off-by: Luben Tuikov <ltuikov@yahoo.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Acked-by: Matthew Dharm <mdharm-usb@one-eyed-alien.net>
Cc: stable <stable@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
21c13a4f7bc185552c4b402b792c3bbb9aa69df0 07-Jun-2011 Alan Stern <stern@rowland.harvard.edu> usb-storage: redo incorrect reads

Some USB mass-storage devices have bugs that cause them not to handle
the first READ(10) command they receive correctly. The Corsair
Padlock v2 returns completely bogus data for its first read (possibly
it returns the data in encrypted form even though the device is
supposed to be unlocked). The Feiya SD/SDHC card reader fails to
complete the first READ(10) command after it is plugged in or after a
new card is inserted, returning a status code that indicates it thinks
the command was invalid, which prevents the kernel from retrying the
read.

Since the first read of a new device or a new medium is for the
partition sector, the kernel is unable to retrieve the device's
partition table. Users have to manually issue an "hdparm -z" or
"blockdev --rereadpt" command before they can access the device.

This patch (as1470) works around the problem. It adds a new quirk
flag, US_FL_INVALID_READ10, indicating that the first READ(10) should
always be retried immediately, as should any failing READ(10) commands
(provided the preceding READ(10) command succeeded, to avoid getting
stuck in a loop). The patch also adds appropriate unusual_devs
entries containing the new flag.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Tested-by: Sven Geggus <sven-usbst@geggus.net>
Tested-by: Paul Hartman <paul.hartman+linux@gmail.com>
CC: Matthew Dharm <mdharm-usb@one-eyed-alien.net>
CC: <stable@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
8fa7fd74ef398370383df276ca41082ba35aafd8 07-Oct-2010 Michal Nazarewicz <mina86@mina86.com> USB: storage: Use USB_ prefix instead of US_ prefix

This commit changes prefix for some of the USB mass storage
class related macros (ie. USB_SC_ for subclass and USB_PR_
for class).

Signed-off-by: Michal Nazarewicz <mina86@mina86.com>
Cc: Alan Stern <stern@rowland.harvard.edu>
Cc: Matthew Wilcox <willy@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
c222fb2efaf1a421f5bf74403df40a9384ccf516 12-Jul-2010 Bob Copeland <me@bobcopeland.com> USB: usb-storage: fix initializations of urb fields

Commit 0ede76fcec5415ef82a423a95120286895822e2d, "USB: remove uses of
URB_NO_SETUP_DMA_MAP" introduced a regression by inadvertantly removing
initialization of the transfer flags. This caused initialization
failures in the ums-karma driver. Fix the regression by zeroing it.

While at it, as Alan Stern points out, the initializers for
actual_length and status are handled by the core and error_count
only matters for isochronous urbs, so they don't need to be set here.
Remove them.

Signed-off-by: Bob Copeland <me@bobcopeland.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
0ede76fcec5415ef82a423a95120286895822e2d 05-Mar-2010 Alan Stern <stern@rowland.harvard.edu> USB: remove uses of URB_NO_SETUP_DMA_MAP

This patch (as1350) removes all usages of coherent buffers for USB
control-request setup-packet buffers. There's no good reason to
reserve coherent memory for these things; control requests are hardly
ever used in large quantity (the major exception is firmware
transfers, and they aren't time-critical). Furthermore, only seven
drivers used it. We might as well always use streaming DMA mappings
for setup-packet buffers, and remove some extra complexity from
usbcore.

The DMA-mapping portion of hcd.c is currently in flux. A separate
patch will be submitted to remove support for URB_NO_SETUP_DMA_MAP
after everything else settles down. The removal should go smoothly,
as by then nobody will be using it.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
5a0e3ad6af8660be21ca98a971cd00f331318c05 24-Mar-2010 Tejun Heo <tj@kernel.org> include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h

percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.

percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.

http://userweb.kernel.org/~tj/misc/slabh-sweep.py

The script does the followings.

* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.

* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.

* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.

The conversion was done in the following steps.

1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.

2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.

3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.

4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.

5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.

6. percpu.h was updated not to include slab.h.

7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).

* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig

8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.

Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.

Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
5d3987796c7a747e5ed3ded1eb64a9632d52a1a4 18-Dec-2009 Oliver Neukum <oliver@neukum.org> 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>
a0bb108112a872c0b0c4b3ef4974f95fb75b155d 07-Dec-2009 Alan Stern <stern@rowland.harvard.edu> USB: usb-storage: add BAD_SENSE flag

This patch (as1311) fixes a problem in usb-storage: Some devices are
pretty broken when it comes to reporting sense data. The information
they send back indicates that they have more than 18 bytes of sense
data available, but when the system asks for more than 18 they fail or
hang. The symptom is that probing fails with multiple resets.

The patch adds a new BAD_SENSE flag to indicate that usb-storage
should never ask for more than 18 bytes of sense data. The flag can
be set in an unusual_devs entry or via the "quirks=" module parameter,
and it is set automatically whenever a REQUEST SENSE command for more
than 18 bytes fails or times out.

An unusual_devs entry is added for the Agfa photo frame, which uses a
Prolific chip having this bug.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Tested-by: Daniel Kukula <daniel.kuku@gmail.com>
Cc: stable <stable@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
b8430e1b82b7e514d76a88eb70a7d8831d50df1e 13-Oct-2009 Benjamin Herrenschmidt <benh@kernel.crashing.org> usb-storage: Workaround devices with bogus sense size

usb-storage: Workaround devices with bogus sense size

Some devices, such as Huawei E169, advertise more than the standard
amount of sense data, causing us to set US_FL_SANE_SENSE, assuming
they support it. However, they subsequently fail the request sense
with that size.

This works around it generically. When a sense request fails due to
a device returning an error, US_FL_SANE_SENSE was set, and that sense
request used a larger sense size, we retry with a smaller size before
giving up.

Based on an original patch by Ben Efros <ben@pc-doctor.com>

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Cc: stable <stable@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
f1a0743bc0e7a30c032b1eb78f6a2b0f805b4597 06-Oct-2009 Alan Stern <stern@rowland.harvard.edu> USB: storage: When a device returns no sense data, call it a Hardware Error

This patch (as1294) fixes a problem that has plagued users for several
kernel releases. Some USB mass-storage devices don't return any sense
data when they encounter certain kinds of errors. The SCSI layer
interprets this to mean that the operation should be retried, and the
same thing happens -- over and over again with no limit. In some
circumstances (such as when a bus reset occurs) that is the right
thing to do, but not here.

The patch checks for this condition (a transport failure with no sense
data) and changes the result code to DID_ERROR and the sense code to
Hardware Error. This does get only a limited number of retries, and
so the command will fail relatively quickly instead of getting stuck
in an infinite loop.

This fixes a large part of Bugzilla #14118.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Tested-by: Mantas Mikulenas <grawity@gmail.com>
CC: stable <stable@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
7a777919bbeec3eac1d7904a728a60e9c2bb9c67 13-Jul-2009 Giacomo Lozito <james@develia.org> USB: storage: raise timeout in usb_stor_Bulk_max_lun

Requests to get max LUN, for certain USB storage devices, require a
longer timeout before a correct reply is returned. This happens for a
Realtek USB Card Reader (0bda:0152), which has a max LUN of 3 but is set
to 0, thus losing functionality, because of the timeout occurring too
quickly.

Raising the timeout value fixes the issue and might help other devices
to return a correct max LUN value as well.

Signed-off-by: Giacomo Lozito <james@develia.org>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Cc: stable <stable@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
3444b26afa145148951112534f298bdc554ec789 08-Apr-2009 David Vrabel <david.vrabel@csr.com> USB: add reset endpoint operations

Wireless USB endpoint state has a sequence number and a current
window and not just a single toggle bit. So allow HCDs to provide a
endpoint_reset method and call this or clear the software toggles as
required (after a clear halt, set configuration etc.).

usb_settoggle() and friends are then HCD internal and are moved into
core/hcd.h and all device drivers call usb_reset_endpoint() instead.

If the device endpoint state has been reset (with a clear halt) but
the host endpoint state has not then subsequent data transfers will
not complete. The device will only work again after it is reset or
disconnected.

Signed-off-by: David Vrabel <david.vrabel@csr.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
e6e244b6cb1f70e7109381626293cd40a8334ed3 12-Feb-2009 Alan Stern <stern@rowland.harvard.edu> usb-storage: prepare for subdriver separation

This patch (as1206) is the first step in converting usb-storage's
subdrivers into separate modules. It makes the following large-scale
changes:

Remove a bunch of unnecessary #ifdef's from usb_usual.h.
Not truly necessary, but it does clean things up.

Move the USB device-ID table (which is duplicated between
libusual and usb-storage) into its own source file,
usual-tables.c, and arrange for this to be linked with
either libusual or usb-storage according to whether
USB_LIBUSUAL is configured.

Add to usual-tables.c a new usb_usual_ignore_device()
function to detect whether a particular device needs to be
managed by a subdriver and not by the standard handlers
in usb-storage.

Export a whole bunch of functions in usb-storage, renaming
some of them because their names don't already begin with
"usb_stor_". These functions will be needed by the new
subdriver modules.

Split usb-storage's probe routine into two functions.
The subdrivers will call the probe1 routine, then fill in
their transport and protocol settings, and then call the
probe2 routine.

Take the default cases and error checking out of
get_transport() and get_protocol(), which run during
probe1, and instead put a check for invalid transport
or protocol values into the probe2 function.

Add a new probe routine to be used for standard devices,
i.e., those that don't need a subdriver. This new routine
checks whether the device should be ignored (because it
should be handled by ub or by a subdriver), and if not,
calls the probe1 and probe2 functions.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
CC: Matthew Dharm <mdharm-usb@one-eyed-alien.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
1c9fbafc8c629c89183d6dccec67a8415513b0d1 04-Jan-2009 Martin K. Petersen <martin.petersen@oracle.com> [SCSI] Remove SUGGEST flags

The SUGGEST_* flags in the SCSI command result have been out of fashion
for a while and we don't actually use them in the error handling.
Remove the remaining occurrences.

Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
0d020aae0a154cffce680a7775c74788fa0bea92 02-Feb-2009 Alan Stern <stern@rowland.harvard.edu> USB: usb-storage: remove WARN from last-sector hacks

This patch (as1201) removes the WARN() from the last-sector hacks in
usb-storage, thereby making the code match the version now in
.27-stable and .28-stable. The WARN() isn't needed, since there is no
longer any intention of assuming that all storage devices have an even
number of sectors, and it annoys users for no good reason.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
25ff1c316f6a763f1eefe7f8984b2d8c03888432 15-Dec-2008 Alan Stern <stern@rowland.harvard.edu> USB: storage: add last-sector hacks

This patch (as1189b) adds some hacks to usb-storage for dealing with
the growing problems involving bad capacity values and last-sector
accesses:

A new flag, US_FL_CAPACITY_OK, is created to indicate that
the device is known to report its capacity correctly. An
unusual_devs entry for Linux's own File-backed Storage Gadget
is added with this flag set, since g_file_storage always
reports the correct capacity and since the capacity need
not be even (it is determined by the size of the backing
file).

An entry in unusual_devs.h which has only the CAPACITY_OK
flag set shouldn't prejudice libusual, since the device will
work perfectly well with either usb-storage or ub. So a
new macro, COMPLIANT_DEV, is added to let libusual know
about these entries.

When a last-sector access succeeds and the total number of
sectors is odd (the unexpected case, in which guessing that
the number is even might cause trouble), a WARN is triggered.
The kerneloops.org project will collect these warnings,
allowing us to add CAPACITY_OK flags for the devices in
question before implementing the default-to-even heuristic.
If users want to prevent the stack dump produced by the WARN,
they can disable the hack by adding an unusual_devs entry
for their device with the CAPACITY_OK flag.

When a last-sector access fails three times in a row and
neither the FIX_CAPACITY nor the CAPACITY_OK flag is set,
we assume the last-sector bug is present. We replace the
existing status and sense data with values that will cause
the SCSI core to fail the access immediately rather than
retry indefinitely. This should fix the difficulties
people have been having with Nokia phones.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Cc: stable <stable@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
64648a9dc4d7ac0189364188207310ec6bc75bbe 20-Nov-2008 Alan Stern <stern@rowland.harvard.edu> USB: usb-storage: merge CB and CBI transport routines

This patch (as1173) merges usb-storage's CB and CBI transports into a
single routine. So much of their code is common, it's silly to keep
them separate.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
CC: Matthew Dharm <mdharm-usb@one-eyed-alien.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
1537e0ad944acf3a4c2b311a646d7993b89499f7 18-Nov-2008 Ben Efros <ben@pc-doctor.com> USB: storage devices and SAT

Add the SANE SENSE flag to indicate that a device is capable of handling
more than 18-bytes of sense data. This functionality is required for
USB-ATA bridges implementing SAT. A future patch will actually enable this
function for several devices.

The logic behind this is that we can detect support for SANE_SENSE in a few ways:
1) ATA PASS THROUGH (12) or (16) execute successfully
2) SPC-3 or higher is in use
3) A previous CHECK CONDITION occurred with sense format 70-73 and had
a length greater than 18-bytes total

Signed-off-by: Ben Efros <ben@pc-doctor.com>
Signed-off-by: Matthew Dharm <mdharm-usb@one-eyed-alien.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
011b15df465745474e3ec85482633685933ed5a7 04-Nov-2008 Alan Stern <stern@rowland.harvard.edu> USB: change interface to usb_lock_device_for_reset()

This patch (as1161) changes the interface to
usb_lock_device_for_reset(). The existing interface is apparently not
very clear, judging from the fact that several of its callers don't
use it correctly. The new interface always returns 0 for success and
it always requires the caller to unlock the device afterward.

The new routine will not return immediately if it is called while the
driver's probe method is running. Instead it will wait until the
probe is over and the device has been unlocked. This shouldn't cause
any problems; I don't know of any cases where drivers call
usb_lock_device_for_reset() during probe.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Cc: Pete Zaitcev <zaitcev@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
8bfa24727087d7252f9ecfb5fea2dfc92d797fbd 02-Sep-2008 Alan Stern <stern@rowland.harvard.edu> usb-storage: report underflow with no sense data

This patch (as1118) addresses a problem with certain USB mass-storage
devices. These devices sometimes return less data than asked for and
then provide no sense data to explain the problem. Currently
usb-storage leaves it up to the SCSI layer to decide how this should
be handled, and the SCSI layer interprets the lack of sense data to
mean that nothing went wrong. But if we got less data than required
then something definitely _did_ go wrong, and we should say so.

The patch tells the SCSI layer to retry the command when this sort of
thing happens. Retrying may not solve the underlying problem, but
it's better than believing that data was transferred when it wasn't.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
59f4ff2ecff4cef36378928cec891785b402e80c 29-Jul-2008 Alan Stern <stern@rowland.harvard.edu> usb-storage: automatically recognize bad residues

This patch (as1119) will help to reduce the clutter of usb-storage's
unusual_devs file by automatically detecting some devices that need
the IGNORE_RESIDUE flag. The idea is that devices should never return
a non-zero residue for an INQUIRY or a READ CAPACITY command unless
they failed to transfer all the requested data. So if one of these
commands transfers a standard amount of data but there is a positive
residue, we know that the residue is bogus and we can set the flag.

This fixes the problems reported in Bugzilla #11125.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
742120c63138651c898614001cb58cd607401eac 18-Jun-2008 Ming Lei <tom.leiming@gmail.com> USB: fix usb_reset_device and usb_reset_composite_device(take 3)

This patch renames the existing usb_reset_device in hub.c to
usb_reset_and_verify_device and renames the existing
usb_reset_composite_device to usb_reset_device. Also the new
usb_reset_and_verify_device does't need to be EXPORTED .

The idea of the patch is that external interface driver
should warn the other interfaces' driver of the same
device before and after reseting the usb device. One interface
driver shoud call _old_ usb_reset_composite_device instead of
_old_ usb_reset_device since it can't assume the device contains
only one interface. The _old_ usb_reset_composite_device
is safe for single interface device also. we rename the two
functions to make the change easily.

This patch is under guideline from Alan Stern.

Signed-off-by: Ming Lei <tom.leiming@gmail.com>
625f694936cbbdee98e6cc65f72724a7660e7946 15-Jun-2008 Ming Lei <tom.leiming@gmail.com> USB: remove interface parameter of usb_reset_composite_device

From the current implementation of usb_reset_composite_device
function, the iface parameter is no longer useful. This function
doesn't do something special for the iface usb_interface,compared
with other interfaces in the usb_device. So remove the parameter
and fix the related caller.

Signed-off-by: Ming Lei <tom.leiming@gmail.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
ea05af61a874ffbc158d9cf06df8a9396f299f38 20-May-2008 Adrian Bunk <bunk@kernel.org> USB: remove CVS keywords

This patch removes CVS keywords that weren't updated for a long time
from comments.

Signed-off-by: Adrian Bunk <bunk@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
543f7810fba2a62e412efa9473ad08167b691f09 08-May-2008 Alan Stern <stern@rowland.harvard.edu> usb-storage: implement "soft" unbinding

This patch (as1092) implements "soft" unbinding for usb-storage. When
the disconnect routine is called, all commands and reset delays are
allowed to complete normally until after scsi_remove_host() returns.
This means that the commands needed for an orderly shutdown will be
sent through to the device.

Unlike before, the driver will now execute every command that it
accepts. Hence there's no need for special code to catch unexecuted
commands and fail them.

The new sequence of events when disconnect runs goes as follows:

If the device is truly unplugged, set the DISCONNECTING
flag so we won't try to access it any more.

If the SCSI-scanning thread hasn't started up yet, prevent
it from doing anything by setting the new DONT_SCAN flag.
Then wake it up and wait for it to terminate.

Remove the SCSI host. This unbinds the upper-level drivers,
doing an orderly shutdown. Commands sent to quiesce the
device will be transmitted normally, unless the device is
unplugged.

Set the DISCONNECTING flag so that we won't accept any new
commands that might get submitted (there aren't supposed to be
any) and we won't try to access the device for resets.

Tell the control thread to exit by waking it up with no
pending command, and wait for it to terminate.

Go on to do all the other normal stuff: releasing resources,
freeing memory, and so on.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
7e4d6c387994294ac8198b624ee71e75de60dfd2 01-May-2008 Alan Stern <stern@rowland.harvard.edu> usb-storage: separate dynamic flags from fixed flags

This patch (as1089) separates out the dynamic atomic bitflags and the
static bitfields in usb-storage. Until now the two sorts of flags
have been sharing the same word; this has always been awkward.

To help prevent possible confusion, the two new fields each have a
different name from the original. us->fflags contains the fixed
bitfields (mostly taken from the USB ID table in unusual_devs.h), and
us->dflags contains the dynamic atomic bitflags (used with set_bit,
test_bit, and so on).

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Cc: Matthew Dharm <mdharm-usb@one-eyed-alien.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
cdc97792289179974af6dda781c855696358d307 24-Feb-2008 Ming Lei <tom.leiming@gmail.com> USB: remove unnecessary type casting of urb->context

urb->context code cleanup

Signed-off-by: Ming Lei <tom.leiming@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
441b62c1edb986827154768d89bbac0ba779984f 04-Mar-2008 Harvey Harrison <harvey.harrison@gmail.com> USB: replace remaining __FUNCTION__ occurrences

__FUNCTION__ is gcc-specific, use __func__

Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
d277064e7e16d02e0078a6bc1820764ae00dea87 19-Mar-2008 matthieu castet <castet.matthieu@free.fr> USB: mass storage: emulation of sat scsi_pass_thru with ATACB

I have got a cypress usb-ide bridge and I would like to tune or monitor
my disk with tools like hdparm, hddtemp or smartctl.

My controller support a way to send raw ATA command to the disk with
something call atacb (see
http://download.cypress.com.edgesuite.net/design_resources/datasheets/contents/cy7c68300c_8.pdf).

Atacb support can be added for each application, but there is some disadvantages :
- all application need to be patched
- A race is possible if there other accesses, because the emulation can
be split in 2 atacb scsi transactions. One for sending the command, one
for reading the register (if ck_cond is set).

I have implemented the emulation in usb-storage with a special proto_handler,
and an unsual entry.

Signed-off-by: Matthieu CASTET <castet.matthieu@free.fr>
Signed-off-by: Matthew Dharm <mdharm-usb@one-eyed-alien.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
cc36bdd47ae51b66780b317c1fa519221f894405 16-Mar-2008 Constantin Baranov <const@tltsu.ru> USB: add support for Motorola ROKR Z6 cellphone in mass storage mode

Motorola ROKR Z6 cellphone has bugs in its USB, so it is impossible to use
it as mass storage. Patch describes new "unusual" USB device for it with
FIX_INQUIRY and FIX_CAPACITY flags and new BULK_IGNORE_TAG flag.
Last flag relaxes check for equality of bcs->Tag and us->tag in
usb_stor_Bulk_transport routine.

Signed-off-by: Constantin Baranov <const@tltsu.ru>
Signed-off-by: Matthew Dharm <mdharm-usb@one-eyed-alien.net>
Signed-off-by: Daniel Drake <dsd@gentoo.org>
Cc: stable <stable@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
a462549b6ad6d4de19a7702c13fbb954d9a10f29 13-Feb-2008 Alan Stern <stern@rowland.harvard.edu> USB: usb-storage: don't clear-halt when Get-Max-LUN stalls

This patch (as1032) removes the Clear-Halt calls in
usb_stor_Bulk_max_lun(). Evidently some devices (such as the Oracom
MP3 player) really don't like to receive these requests when their
bulk endpoints aren't halted.

The only reason for adding them originally was to get an ancient
ZIP-100 drive to work. But since this device has only a single LUN,
we don't need to send it a Get-Max-LUN request at all. Adding an
unusual_devs entry for the ZIP-100 with the SINGLE_LUN flag set will
cause this step to be skipped.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
6d416e6173394defda5933e419e805b696681b7e 10-Sep-2007 Boaz Harrosh <bharrosh@panasas.com> [SCSI] usb: transport - convert to accessors and !use_sg code path removal

- This patch depends on:
usb: transport.c use scsi_eh API in REQUEST_SENSE execution

- Use scsi data accessors and remove of !use_sg code path.
- New usb_stor_bulk_srb() for use by drivers

[jejb: updated with corrective fix.

had a bug in residual handling in the new usb_stor_bulk_srb()
function. Found by Gabriel C. in -mm tree.

Tested-by: Gabriel C <nix.or.die@googlemail.com>
]

Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
Acked-by: Matthew Dharm <mdharm-scsi@one-eyed-alien.net>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
dff6de73f9d29868729cb1d21d86ba0dbd28871f 10-Sep-2007 Boaz Harrosh <bharrosh@panasas.com> [SCSI] usb storage: use scsi_eh API in REQUEST_SENSE execution

- Use new scsi_eh_prep/restor_cmnd() for synchronous
REQUEST_SENSE invocation.

Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
55acbda0965ca0a29b0ca276e7d17a55edc11d1b 07-Dec-2006 Christoph Lameter <clameter@sgi.com> [PATCH] slab: remove SLAB_NOIO

SLAB_NOIO is an alias of GFP_NOIO with a single instance of use.

Signed-off-by: Christoph Lameter <clameter@sgi.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
7d12e780e003f93433d49ce78cfedf4b4c52adc5 05-Oct-2006 David Howells <dhowells@redhat.com> IRQ: Maintain regs pointer globally rather than passing to IRQ handlers

Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.

The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around. On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).

Where appropriate, an arch may override the generic storage facility and do
something different with the variable. On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.

Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions. Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller. A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.

I've build this code with allyesconfig for x86_64 and i386. I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.

This will affect all archs. Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:

struct pt_regs *old_regs = set_irq_regs(regs);

And put the old one back at the end:

set_irq_regs(old_regs);

Don't pass regs through to generic_handle_irq() or __do_IRQ().

In timer_interrupt(), this sort of change will be necessary:

- update_process_times(user_mode(regs));
- profile_tick(CPU_PROFILING, regs);
+ update_process_times(user_mode(get_irq_regs()));
+ profile_tick(CPU_PROFILING);

I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().

Some notes on the interrupt handling in the drivers:

(*) input_dev() is now gone entirely. The regs pointer is no longer stored in
the input_dev struct.

(*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
something different depending on whether it's been supplied with a regs
pointer or not.

(*) Various IRQ handler function pointers have been moved to type
irq_handler_t.

Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
38e2bfc94e95dd6005fdaf40dfec0157396741da 19-Sep-2006 Pete Zaitcev <zaitcev@redhat.com> USB: Dealias -110 code (more complete)

The purpose of this patch is to split off the case when a device does
not reply on the lower level (which is reported by HC hardware), and
a case when the device accepted the request, but does not reply at
upper level. This redefinition allows to diagnose issues easier,
without asking the user if the -110 happened "immediately".

The usbmon splits such cases already thanks to its timestamp, but
it's not always available.

I adjusted all drivers which I found affected (by searching for "urb").
Out of tree drivers may suffer a little bit, but I do not expect much
breakage. At worst they may print a few messages.

Signed-off-by: Pete Zaitcev <zaitcev@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
d6b7d3b62069be60d5b13358bac8670dacdd7a81 10-Jul-2006 Alan Stern <stern@rowland.harvard.edu> [PATCH] usb-storage: wait for URB to complete

We all failed to notice that Franck's recent update to usb-storage allowed
an URB to complete after its context data was no longer valid. This patch
(as746) makes the driver wait for the URB to complete whenever there's a
timeout.

Although timeouts in usb-storage are relatively uncommon, they do occur.
Without this patch the code in 2.6.18-rc1 will fault within an interrupt
handler, which is not nice at all.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Cc: Greg KH <greg@kroah.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
6ab3d5624e172c553004ecc862bfeac16d9d68b7 30-Jun-2006 Jörn Engel <joern@wohnheim.fh-wedel.de> Remove obsolete #include <linux/config.h>

Signed-off-by: Jörn Engel <joern@wohnheim.fh-wedel.de>
Signed-off-by: Adrian Bunk <bunk@stusta.de>
47104b0dd32cec467574822b0dc3517b3de3f0ad 01-Jun-2006 Alan Stern <stern@rowland.harvard.edu> [PATCH] usb-storage: use usb_reset_composite_device

This patch (as701) modifies usb-storage to take advantage of the new
usb_reset_composite_device() API. Now we will be able to safely request
port resets even if other drivers are bound to a mass-storage device.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
3428cc43d23f125dcb31c981aa91535dd3c4cb0d 24-May-2006 Franck Bui-Huu <fbh.work@gmail.com> [PATCH] usb-storage: get rid of the timer during URB submission

This patch uses completion timeout instead of a timer to implement
a timeout when submitting an URB.

It also put the task in interruptible state instead of an
uninterruptible one while waiting for the completion.

Signed-off-by: Franck Bui-Huu <vagabon.xyz@gmail.com>
Signed-off-by: Matthew Dharm <mdharm-usb@one-eyed-alien.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
bbafa4668f37f5093a3ae2a8b0cbe327e24e12da 24-Oct-2005 Alan Stern <stern@rowland.harvard.edu> [PATCH] PATCH: usb-storage: allocate separate sense buffer

This patch is from Alan Stern (as560). It has been rediffed against a
current tree.

This patch allocates a separate buffer for usb-storage to use when
auto-sensing. Up to now we have been using the sense buffer embedded in a
scsi_cmnd struct, which is dangerous on hosts that (a) don't do
cache-coherent DMA or (b) have DMA alignment restrictions.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Matthew Dharm <mdharm-usb@one-eyed-alien.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
b876aef7f890d8c59a45b78858a36cf60fddf522 24-Oct-2005 Alan Stern <stern@rowland.harvard.edu> [PATCH] PATCH: usb-storage: move GetMaxLUN later in time

This patch is originally from Alan Stern (as557). It has been re-diffed
against a current tree, and I also corrected a minor merging error.

Some time ago we introduced a delay before device scanning, because many
devices do not like to receive SCSI commands right after enumeration.
Now it turns out there's a device that doesn't like to receive
Get-Max-LUN right after enumeration either. Accordingly this patch
delays the Get-Max-LUN request until the beginning of the scanning
procedure. This fixes Bugzilla entry #5010.

Three things are worth noting. First, I removed the locking code from
usb_stor_acquire_resources. It's not needed, because the locking is to
protect against disconnect events and acquire_resources is only called
during probe (so the disconnect routine can't be called). Second, I
initialized to 0 the buffer used for the Get-Max-LUN response. It's not
really necessary, but it will prevent random values from showing up in
the debugging log when the request fails. Third, I added a test against
the SINGLE_LUN flag. This will allow us to use the flag to indicate
Bulk-only devices that can't handle Get-Max-LUN.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Matthew Dharm <mdharm-usb@one-eyed-alien.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
b375a0495fd622037560c73c05f23ae6f127bb0c 29-Jul-2005 Alan Stern <stern@rowland.harvard.edu> [PATCH] USB: URB_ASYNC_UNLINK flag removed from the kernel

29 July 2005, Cambridge, MA:

This afternoon Alan Stern submitted a patch to remove the URB_ASYNC_UNLINK
flag from the Linux kernel. Mr. Stern explained, "This flag is a relic
from an earlier, less-well-designed system. For over a year it hasn't
been used for anything other than printing warning messages."

An anonymous spokesman for the Linux kernel development community
commented, "This is exactly the sort of thing we see happening all the
time. As the kernel evolves, support for old techniques and old code can
be jettisoned and replaced by newer, better approaches. Proprietary
operating systems do not have the freedom or flexibility to change so
quickly."

Mr. Stern, a staff member at Harvard University's Rowland Institute who
works on Linux only as a hobby, noted that the patch (labelled as548) did
not update two files, keyspan.c and option.c, in the USB drivers' "serial"
subdirectory. "Those files need more extensive changes," he remarked.
"They examine the status field of several URBs at times when they're not
supposed to. That will need to be fixed before the URB_ASYNC_UNLINK flag
is removed."

Greg Kroah-Hartman, the kernel maintainer responsible for overseeing all
of Linux's USB drivers, did not respond to our inquiries or return our
calls. His only comment was "Applied, thanks."

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
0f64e078139109d1902e5b1274c23cec9a9ad12e 28-Jul-2005 Matthew Dharm <mdharm-usb@one-eyed-alien.net> [PATCH] USB Storage: remove dependency on SCSI-provided serial/tag number

This patch started life as as531 from Alan Stern. It has been rediffed
against the latest tree.

The SCSI people have deprecated the use of scsi_cmnd.serial_number for
anything other than printk. Worse than that, the SCSI core doesn't
always increment the number (when the error handler is running, for
example). So this patch creates a locally-stored value for use in
bulk-only tags. The net result is a simplification, since we no longer
have to save & restore the serial_number value while autosensing.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Matthew Dharm <mdharm-usb@one-eyed-alien.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
4d07ef762fc8d6d35ecc1511a3b953a733a61a5f 07-Jun-2005 Matthew Dharm <mdharm-usb@one-eyed-alien.net> [PATCH] USB Storage: port reset on transport error

This patch causes a port reset whenever there's a transport error or abort.
If that fails it reverts back to doing a mass-storage device reset. It
started life as as497 and was rediffed by me.

This makes error recovery a lot quicker and more reliable.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Matthew Dharm <mdharm-usb@one-eyed-alien.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
5203ad441310a4c2abd4fb79015a6bdadc2a5a4f 07-Jun-2005 Matthew Dharm <mdharm-usb@one-eyed-alien.net> [PATCH] USB Storage: endpoint toggles and reset delays

This patch does two things to help reset recovery. It started life as
as496 and was rediffed by me.

First, the patch checks the result of a CLEAR_HALT request and doesn't reset the
endpoint's data toggle unless the request succeeded.

Second, it reduces the timeout for a device reset from 20 seconds to 5
seconds.

If all goes well, then I've finally figured quilt out and this patch should
apply cleanly.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Matthew Dharm <mdharm-usb@one-eyed-alien.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
e4334fa4c5cb62f26d7e9a0a581126bcbe0dedcf 19-Apr-2005 Phil Dibowitz <phil@ipom.com> [PATCH] Fix GO_SLOW delay

This patch changes the delay for the US_FL_GO_SLOW patch from 110us to 125.
Some delays need this extra delay includign Jan De Luyck's drive which spawned
the original increase from 110 to 110us. 125 is a microframe, so this delay
seems to make sense more than just be a random delay (thanks to David Brownell
for pointing that out after my original patch).

Signed-off-by: Phil Dibowitz <phil@ipom.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


Index: gregkh-2.6/drivers/usb/storage/transport.c
===================================================================
1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 17-Apr-2005 Linus Torvalds <torvalds@ppc970.osdl.org> Linux-2.6.12-rc2

Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.

Let it rip!