| .. | .. |
|---|
| 28 | 28 | * status of a command. |
|---|
| 29 | 29 | */ |
|---|
| 30 | 30 | |
|---|
| 31 | +#include <linux/blkdev.h> |
|---|
| 32 | +#include <linux/dma-mapping.h> |
|---|
| 31 | 33 | #include <linux/module.h> |
|---|
| 32 | 34 | #include <linux/mutex.h> |
|---|
| 33 | 35 | |
|---|
| .. | .. |
|---|
| 38 | 40 | #include <scsi/scsi_eh.h> |
|---|
| 39 | 41 | |
|---|
| 40 | 42 | #include "usb.h" |
|---|
| 43 | +#include <linux/usb/hcd.h> |
|---|
| 41 | 44 | #include "scsiglue.h" |
|---|
| 42 | 45 | #include "debug.h" |
|---|
| 43 | 46 | #include "transport.h" |
|---|
| .. | .. |
|---|
| 89 | 92 | static int slave_configure(struct scsi_device *sdev) |
|---|
| 90 | 93 | { |
|---|
| 91 | 94 | struct us_data *us = host_to_us(sdev->host); |
|---|
| 95 | + struct device *dev = us->pusb_dev->bus->sysdev; |
|---|
| 92 | 96 | |
|---|
| 93 | 97 | /* |
|---|
| 94 | 98 | * Many devices have trouble transferring more than 32KB at a time, |
|---|
| .. | .. |
|---|
| 123 | 127 | } |
|---|
| 124 | 128 | |
|---|
| 125 | 129 | /* |
|---|
| 130 | + * The max_hw_sectors should be up to maximum size of a mapping for |
|---|
| 131 | + * the device. Otherwise, a DMA API might fail on swiotlb environment. |
|---|
| 132 | + */ |
|---|
| 133 | + blk_queue_max_hw_sectors(sdev->request_queue, |
|---|
| 134 | + min_t(size_t, queue_max_hw_sectors(sdev->request_queue), |
|---|
| 135 | + dma_max_mapping_size(dev) >> SECTOR_SHIFT)); |
|---|
| 136 | + |
|---|
| 137 | + /* |
|---|
| 126 | 138 | * Some USB host controllers can't do DMA; they have to use PIO. |
|---|
| 127 | | - * They indicate this by setting their dma_mask to NULL. For |
|---|
| 128 | | - * such controllers we need to make sure the block layer sets |
|---|
| 139 | + * For such controllers we need to make sure the block layer sets |
|---|
| 129 | 140 | * up bounce buffers in addressable memory. |
|---|
| 130 | 141 | */ |
|---|
| 131 | | - if (!us->pusb_dev->bus->controller->dma_mask) |
|---|
| 142 | + if (!hcd_uses_dma(bus_to_hcd(us->pusb_dev->bus)) || |
|---|
| 143 | + (bus_to_hcd(us->pusb_dev->bus)->localmem_pool != NULL)) |
|---|
| 132 | 144 | blk_queue_bounce_limit(sdev->request_queue, BLK_BOUNCE_HIGH); |
|---|
| 133 | 145 | |
|---|
| 134 | 146 | /* |
|---|
| .. | .. |
|---|
| 189 | 201 | */ |
|---|
| 190 | 202 | sdev->skip_ms_page_8 = 1; |
|---|
| 191 | 203 | |
|---|
| 192 | | - /* Some devices don't handle VPD pages correctly */ |
|---|
| 193 | | - sdev->skip_vpd_pages = 1; |
|---|
| 204 | + /* |
|---|
| 205 | + * Some devices don't handle VPD pages correctly, so skip vpd |
|---|
| 206 | + * pages if not forced by SCSI layer. |
|---|
| 207 | + */ |
|---|
| 208 | + sdev->skip_vpd_pages = !sdev->try_vpd_pages; |
|---|
| 194 | 209 | |
|---|
| 195 | 210 | /* Do not attempt to use REPORT SUPPORTED OPERATION CODES */ |
|---|
| 196 | 211 | sdev->no_report_opcodes = 1; |
|---|
| .. | .. |
|---|
| 287 | 302 | } else { |
|---|
| 288 | 303 | |
|---|
| 289 | 304 | /* |
|---|
| 290 | | - * Non-disk-type devices don't need to blacklist any pages |
|---|
| 305 | + * Non-disk-type devices don't need to ignore any pages |
|---|
| 291 | 306 | * or to force 192-byte transfer lengths for MODE SENSE. |
|---|
| 292 | 307 | * But they do need to use MODE SENSE(10). |
|---|
| 293 | 308 | */ |
|---|
| .. | .. |
|---|
| 359 | 374 | |
|---|
| 360 | 375 | /* check for state-transition errors */ |
|---|
| 361 | 376 | if (us->srb != NULL) { |
|---|
| 362 | | - printk(KERN_ERR USB_STORAGE "Error in %s: us->srb = %p\n", |
|---|
| 363 | | - __func__, us->srb); |
|---|
| 377 | + dev_err(&us->pusb_intf->dev, |
|---|
| 378 | + "Error in %s: us->srb = %p\n", __func__, us->srb); |
|---|
| 364 | 379 | return SCSI_MLQUEUE_HOST_BUSY; |
|---|
| 365 | 380 | } |
|---|
| 366 | 381 | |
|---|
| .. | .. |
|---|
| 634 | 649 | * and 2048 for USB3 devices. |
|---|
| 635 | 650 | */ |
|---|
| 636 | 651 | .max_sectors = 240, |
|---|
| 637 | | - |
|---|
| 638 | | - /* |
|---|
| 639 | | - * merge commands... this seems to help performance, but |
|---|
| 640 | | - * periodically someone should test to see which setting is more |
|---|
| 641 | | - * optimal. |
|---|
| 642 | | - */ |
|---|
| 643 | | - .use_clustering = 1, |
|---|
| 644 | 652 | |
|---|
| 645 | 653 | /* emulated HBA */ |
|---|
| 646 | 654 | .emulated = 1, |
|---|