diff options
Diffstat (limited to 'drivers/usb/storage/scsiglue.c')
-rw-r--r-- | drivers/usb/storage/scsiglue.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c index 09779f6a8179..2a42b862aa9f 100644 --- a/drivers/usb/storage/scsiglue.c +++ b/drivers/usb/storage/scsiglue.c | |||
@@ -59,6 +59,13 @@ | |||
59 | #include "transport.h" | 59 | #include "transport.h" |
60 | #include "protocol.h" | 60 | #include "protocol.h" |
61 | 61 | ||
62 | /* Vendor IDs for companies that seem to include the READ CAPACITY bug | ||
63 | * in all their devices | ||
64 | */ | ||
65 | #define VENDOR_ID_NOKIA 0x0421 | ||
66 | #define VENDOR_ID_NIKON 0x04b0 | ||
67 | #define VENDOR_ID_MOTOROLA 0x22b8 | ||
68 | |||
62 | /*********************************************************************** | 69 | /*********************************************************************** |
63 | * Host functions | 70 | * Host functions |
64 | ***********************************************************************/ | 71 | ***********************************************************************/ |
@@ -129,11 +136,35 @@ static int slave_configure(struct scsi_device *sdev) | |||
129 | max_sectors); | 136 | max_sectors); |
130 | } | 137 | } |
131 | 138 | ||
139 | /* Some USB host controllers can't do DMA; they have to use PIO. | ||
140 | * They indicate this by setting their dma_mask to NULL. For | ||
141 | * such controllers we need to make sure the block layer sets | ||
142 | * up bounce buffers in addressable memory. | ||
143 | */ | ||
144 | if (!us->pusb_dev->bus->controller->dma_mask) | ||
145 | blk_queue_bounce_limit(sdev->request_queue, BLK_BOUNCE_HIGH); | ||
146 | |||
132 | /* We can't put these settings in slave_alloc() because that gets | 147 | /* We can't put these settings in slave_alloc() because that gets |
133 | * called before the device type is known. Consequently these | 148 | * called before the device type is known. Consequently these |
134 | * settings can't be overridden via the scsi devinfo mechanism. */ | 149 | * settings can't be overridden via the scsi devinfo mechanism. */ |
135 | if (sdev->type == TYPE_DISK) { | 150 | if (sdev->type == TYPE_DISK) { |
136 | 151 | ||
152 | /* Some vendors seem to put the READ CAPACITY bug into | ||
153 | * all their devices -- primarily makers of cell phones | ||
154 | * and digital cameras. Since these devices always use | ||
155 | * flash media and can be expected to have an even number | ||
156 | * of sectors, we will always enable the CAPACITY_HEURISTICS | ||
157 | * flag unless told otherwise. */ | ||
158 | switch (le16_to_cpu(us->pusb_dev->descriptor.idVendor)) { | ||
159 | case VENDOR_ID_NOKIA: | ||
160 | case VENDOR_ID_NIKON: | ||
161 | case VENDOR_ID_MOTOROLA: | ||
162 | if (!(us->fflags & (US_FL_FIX_CAPACITY | | ||
163 | US_FL_CAPACITY_OK))) | ||
164 | us->fflags |= US_FL_CAPACITY_HEURISTICS; | ||
165 | break; | ||
166 | } | ||
167 | |||
137 | /* Disk-type devices use MODE SENSE(6) if the protocol | 168 | /* Disk-type devices use MODE SENSE(6) if the protocol |
138 | * (SubClass) is Transparent SCSI, otherwise they use | 169 | * (SubClass) is Transparent SCSI, otherwise they use |
139 | * MODE SENSE(10). */ | 170 | * MODE SENSE(10). */ |
@@ -170,6 +201,10 @@ static int slave_configure(struct scsi_device *sdev) | |||
170 | if (us->fflags & US_FL_CAPACITY_HEURISTICS) | 201 | if (us->fflags & US_FL_CAPACITY_HEURISTICS) |
171 | sdev->guess_capacity = 1; | 202 | sdev->guess_capacity = 1; |
172 | 203 | ||
204 | /* assume SPC3 or latter devices support sense size > 18 */ | ||
205 | if (sdev->scsi_level > SCSI_SPC_2) | ||
206 | us->fflags |= US_FL_SANE_SENSE; | ||
207 | |||
173 | /* Some devices report a SCSI revision level above 2 but are | 208 | /* Some devices report a SCSI revision level above 2 but are |
174 | * unable to handle the REPORT LUNS command (for which | 209 | * unable to handle the REPORT LUNS command (for which |
175 | * support is mandatory at level 3). Since we already have | 210 | * support is mandatory at level 3). Since we already have |
@@ -196,6 +231,14 @@ static int slave_configure(struct scsi_device *sdev) | |||
196 | * sector in a larger then 1 sector read, since the performance | 231 | * sector in a larger then 1 sector read, since the performance |
197 | * impact is negible we set this flag for all USB disks */ | 232 | * impact is negible we set this flag for all USB disks */ |
198 | sdev->last_sector_bug = 1; | 233 | sdev->last_sector_bug = 1; |
234 | |||
235 | /* Enable last-sector hacks for single-target devices using | ||
236 | * the Bulk-only transport, unless we already know the | ||
237 | * capacity will be decremented or is correct. */ | ||
238 | if (!(us->fflags & (US_FL_FIX_CAPACITY | US_FL_CAPACITY_OK | | ||
239 | US_FL_SCM_MULT_TARG)) && | ||
240 | us->protocol == US_PR_BULK) | ||
241 | us->use_last_sector_hacks = 1; | ||
199 | } else { | 242 | } else { |
200 | 243 | ||
201 | /* Non-disk-type devices don't need to blacklist any pages | 244 | /* Non-disk-type devices don't need to blacklist any pages |