Commit ad39619b authored by Hans de Goede's avatar Hans de Goede Committed by Luis Henriques

uas: Add US_FL_MAX_SECTORS_240 flag

commit ee136af4 upstream.

The usb-storage driver sets max_sectors = 240 in its scsi-host template,
for uas we do not want to do that for all devices, but testing has shown
that some devices need it.

This commit adds a US_FL_MAX_SECTORS_240 flag for such devices, and
implements support for it in uas.c, while at it it also adds support
for US_FL_MAX_SECTORS_64 to uas.c.
Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
Acked-by: default avatarAlan Stern <stern@rowland.harvard.edu>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarLuis Henriques <luis.henriques@canonical.com>
parent 812629aa
...@@ -3462,6 +3462,8 @@ bytes respectively. Such letter suffixes can also be entirely omitted. ...@@ -3462,6 +3462,8 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
READ_CAPACITY_16 command); READ_CAPACITY_16 command);
f = NO_REPORT_OPCODES (don't use report opcodes f = NO_REPORT_OPCODES (don't use report opcodes
command, uas only); command, uas only);
g = MAX_SECTORS_240 (don't transfer more than
240 sectors at a time, uas only);
h = CAPACITY_HEURISTICS (decrease the h = CAPACITY_HEURISTICS (decrease the
reported device capacity by one reported device capacity by one
sector if the number is odd); sector if the number is odd);
......
...@@ -936,7 +936,10 @@ static int uas_eh_bus_reset_handler(struct scsi_cmnd *cmnd) ...@@ -936,7 +936,10 @@ static int uas_eh_bus_reset_handler(struct scsi_cmnd *cmnd)
static int uas_slave_alloc(struct scsi_device *sdev) static int uas_slave_alloc(struct scsi_device *sdev)
{ {
sdev->hostdata = (void *)sdev->host->hostdata; struct uas_dev_info *devinfo =
(struct uas_dev_info *)sdev->host->hostdata;
sdev->hostdata = devinfo;
/* USB has unusual DMA-alignment requirements: Although the /* USB has unusual DMA-alignment requirements: Although the
* starting address of each scatter-gather element doesn't matter, * starting address of each scatter-gather element doesn't matter,
...@@ -955,6 +958,11 @@ static int uas_slave_alloc(struct scsi_device *sdev) ...@@ -955,6 +958,11 @@ static int uas_slave_alloc(struct scsi_device *sdev)
*/ */
blk_queue_update_dma_alignment(sdev->request_queue, (512 - 1)); blk_queue_update_dma_alignment(sdev->request_queue, (512 - 1));
if (devinfo->flags & US_FL_MAX_SECTORS_64)
blk_queue_max_hw_sectors(sdev->request_queue, 64);
else if (devinfo->flags & US_FL_MAX_SECTORS_240)
blk_queue_max_hw_sectors(sdev->request_queue, 240);
return 0; return 0;
} }
......
...@@ -477,7 +477,8 @@ void usb_stor_adjust_quirks(struct usb_device *udev, unsigned long *fflags) ...@@ -477,7 +477,8 @@ void usb_stor_adjust_quirks(struct usb_device *udev, unsigned long *fflags)
US_FL_SINGLE_LUN | US_FL_NO_WP_DETECT | US_FL_SINGLE_LUN | US_FL_NO_WP_DETECT |
US_FL_NO_READ_DISC_INFO | US_FL_NO_READ_CAPACITY_16 | US_FL_NO_READ_DISC_INFO | US_FL_NO_READ_CAPACITY_16 |
US_FL_INITIAL_READ10 | US_FL_WRITE_CACHE | US_FL_INITIAL_READ10 | US_FL_WRITE_CACHE |
US_FL_NO_ATA_1X | US_FL_NO_REPORT_OPCODES); US_FL_NO_ATA_1X | US_FL_NO_REPORT_OPCODES |
US_FL_MAX_SECTORS_240);
p = quirks; p = quirks;
while (*p) { while (*p) {
...@@ -518,6 +519,9 @@ void usb_stor_adjust_quirks(struct usb_device *udev, unsigned long *fflags) ...@@ -518,6 +519,9 @@ void usb_stor_adjust_quirks(struct usb_device *udev, unsigned long *fflags)
case 'f': case 'f':
f |= US_FL_NO_REPORT_OPCODES; f |= US_FL_NO_REPORT_OPCODES;
break; break;
case 'g':
f |= US_FL_MAX_SECTORS_240;
break;
case 'h': case 'h':
f |= US_FL_CAPACITY_HEURISTICS; f |= US_FL_CAPACITY_HEURISTICS;
break; break;
......
...@@ -77,6 +77,8 @@ ...@@ -77,6 +77,8 @@
/* Cannot handle ATA_12 or ATA_16 CDBs */ \ /* Cannot handle ATA_12 or ATA_16 CDBs */ \
US_FLAG(NO_REPORT_OPCODES, 0x04000000) \ US_FLAG(NO_REPORT_OPCODES, 0x04000000) \
/* Cannot handle MI_REPORT_SUPPORTED_OPERATION_CODES */ \ /* Cannot handle MI_REPORT_SUPPORTED_OPERATION_CODES */ \
US_FLAG(MAX_SECTORS_240, 0x08000000) \
/* Sets max_sectors to 240 */ \
#define US_FLAG(name, value) US_FL_##name = value , #define US_FLAG(name, value) US_FL_##name = value ,
enum { US_DO_ALL_FLAGS }; enum { US_DO_ALL_FLAGS };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment