Merge "USB: storage: set BDI_CAP_STRICLIMIT and max_ratio for USB UICC devices"

This commit is contained in:
Linux Build Service Account 2014-11-26 15:24:16 -08:00 committed by Gerrit - the friendly Code Review server
commit e7727e9c00
3 changed files with 42 additions and 0 deletions

View file

@ -114,6 +114,7 @@ static int slave_alloc (struct scsi_device *sdev)
static int slave_configure(struct scsi_device *sdev)
{
struct us_data *us = host_to_us(sdev->host);
struct backing_dev_info *bdi = &sdev->request_queue->backing_dev_info;
/* Many devices have trouble transferring more than 32KB at a time,
* while others have trouble with more than 64K. At this time we
@ -261,6 +262,12 @@ static int slave_configure(struct scsi_device *sdev)
sdev->autosuspend_delay = us->sdev_autosuspend_delay;
}
if (us->sdev_max_ratio > 0) {
bdi->capabilities |= BDI_CAP_STRICTLIMIT;
if (bdi_set_max_ratio(bdi, us->sdev_max_ratio))
usb_stor_dbg(us, "%s, max_ratio not updated\n",
__func__);
}
} else {
/* Non-disk-type devices don't need to blacklist any pages

View file

@ -86,6 +86,17 @@ static char quirks[128];
module_param_string(quirks, quirks, sizeof(quirks), S_IRUGO | S_IWUSR);
MODULE_PARM_DESC(quirks, "supplemental list of device IDs and their quirks");
/*
* uicc_max_ratio is used to set max_ratio for uicc backing device and also
* used to enable strictlimit feature. If it's value is set to 0 then we do not
* enable strictlimit feature for UICC devices. Its default value is choosen
* as 20, as with this value we do not see any drop in UICC throughput
*/
#define UICC_MAX_RATIO 20
static unsigned int uicc_max_ratio = UICC_MAX_RATIO;
module_param(uicc_max_ratio, uint, S_IRUGO | S_IWUSR);
MODULE_PARM_DESC(uicc_max_ratio, "max ratio to be used with a UICC device");
/*
* The entries in this table correspond, line for line,
@ -767,6 +778,28 @@ static void usb_stor_set_scsi_autosuspend(struct us_data *us)
}
}
/* Initialize SCSI block device max_ratio here */
static void usb_stor_set_scsi_max_ratio(struct us_data *us)
{
struct usb_device *udev = us->pusb_dev;
struct usb_host_config *config = udev->actconfig;
struct usb_host_interface *intf;
int i;
/*
* Some USB UICC devices has Mass storage interface along
* with CCID interface. These cards have very low througput.
* Set SCSI block device max_ratio for such devices.
*/
for (i = 0; i < config->desc.bNumInterfaces; i++) {
intf = config->interface[i]->cur_altsetting;
if (intf->desc.bInterfaceClass == USB_CLASS_CSCID) {
us->sdev_max_ratio = uicc_max_ratio;
return;
}
}
}
/* Initialize all the dynamic resources we need */
static int usb_stor_acquire_resources(struct us_data *us)
{
@ -1016,6 +1049,7 @@ int usb_stor_probe2(struct us_data *us)
us->sdev_autosuspend_delay = -1;
usb_stor_set_scsi_autosuspend(us);
usb_stor_set_scsi_max_ratio(us);
snprintf(us->scsi_name, sizeof(us->scsi_name), "usb-storage %s",
dev_name(&us->pusb_intf->dev));

View file

@ -162,6 +162,7 @@ struct us_data {
int use_last_sector_hacks;
int last_sector_retries;
int sdev_autosuspend_delay;
unsigned int sdev_max_ratio;
};
/* Convert between us_data and the corresponding Scsi_Host */