aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorK. Y. Srinivasan <kys@microsoft.com>2015-03-27 03:27:15 -0400
committerJames Bottomley <JBottomley@Odin.com>2015-04-09 16:22:11 -0400
commitf458aada75891e6e9aff391f8f12a2cb2aac7d58 (patch)
treef9719318ec53f15e41af3acca2489421e84ca576
parentb9ec3a55389560a13e226c8d835db6bf0b3d61fd (diff)
scsi: storvsc: Size the queue depth based on the ringbuffer size
Size the queue depth based on the ringbuffer size. Also accommodate for the fact that we could have multiple channels (ringbuffers) per adaptor. Signed-off-by: K. Y. Srinivasan <kys@microsoft.com> Reviewed-by: Long Li <longli@microsoft.com> Signed-off-by: James Bottomley <JBottomley@Odin.com>
-rw-r--r--drivers/scsi/storvsc_drv.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c
index 27fe850bdfed..7f569f971164 100644
--- a/drivers/scsi/storvsc_drv.c
+++ b/drivers/scsi/storvsc_drv.c
@@ -309,10 +309,15 @@ enum storvsc_request_type {
309 */ 309 */
310 310
311static int storvsc_ringbuffer_size = (256 * PAGE_SIZE); 311static int storvsc_ringbuffer_size = (256 * PAGE_SIZE);
312static u32 max_outstanding_req_per_channel;
313
314static int storvsc_vcpus_per_sub_channel = 4;
312 315
313module_param(storvsc_ringbuffer_size, int, S_IRUGO); 316module_param(storvsc_ringbuffer_size, int, S_IRUGO);
314MODULE_PARM_DESC(storvsc_ringbuffer_size, "Ring buffer size (bytes)"); 317MODULE_PARM_DESC(storvsc_ringbuffer_size, "Ring buffer size (bytes)");
315 318
319module_param(storvsc_vcpus_per_sub_channel, int, S_IRUGO);
320MODULE_PARM_DESC(vcpus_per_sub_channel, "Ratio of VCPUs to subchannels");
316/* 321/*
317 * Timeout in seconds for all devices managed by this driver. 322 * Timeout in seconds for all devices managed by this driver.
318 */ 323 */
@@ -320,7 +325,6 @@ static int storvsc_timeout = 180;
320 325
321static int msft_blist_flags = BLIST_TRY_VPD_PAGES; 326static int msft_blist_flags = BLIST_TRY_VPD_PAGES;
322 327
323#define STORVSC_MAX_IO_REQUESTS 200
324 328
325static void storvsc_on_channel_callback(void *context); 329static void storvsc_on_channel_callback(void *context);
326 330
@@ -1376,7 +1380,6 @@ static int storvsc_do_io(struct hv_device *device,
1376 1380
1377static int storvsc_device_configure(struct scsi_device *sdevice) 1381static int storvsc_device_configure(struct scsi_device *sdevice)
1378{ 1382{
1379 scsi_change_queue_depth(sdevice, STORVSC_MAX_IO_REQUESTS);
1380 1383
1381 blk_queue_max_segment_size(sdevice->request_queue, PAGE_SIZE); 1384 blk_queue_max_segment_size(sdevice->request_queue, PAGE_SIZE);
1382 1385
@@ -1646,7 +1649,6 @@ static struct scsi_host_template scsi_driver = {
1646 .eh_timed_out = storvsc_eh_timed_out, 1649 .eh_timed_out = storvsc_eh_timed_out,
1647 .slave_configure = storvsc_device_configure, 1650 .slave_configure = storvsc_device_configure,
1648 .cmd_per_lun = 255, 1651 .cmd_per_lun = 255,
1649 .can_queue = STORVSC_MAX_IO_REQUESTS*STORVSC_MAX_TARGETS,
1650 .this_id = -1, 1652 .this_id = -1,
1651 /* no use setting to 0 since ll_blk_rw reset it to 1 */ 1653 /* no use setting to 0 since ll_blk_rw reset it to 1 */
1652 /* currently 32 */ 1654 /* currently 32 */
@@ -1686,6 +1688,7 @@ static int storvsc_probe(struct hv_device *device,
1686 const struct hv_vmbus_device_id *dev_id) 1688 const struct hv_vmbus_device_id *dev_id)
1687{ 1689{
1688 int ret; 1690 int ret;
1691 int num_cpus = num_online_cpus();
1689 struct Scsi_Host *host; 1692 struct Scsi_Host *host;
1690 struct hv_host_device *host_dev; 1693 struct hv_host_device *host_dev;
1691 bool dev_is_ide = ((dev_id->driver_data == IDE_GUID) ? true : false); 1694 bool dev_is_ide = ((dev_id->driver_data == IDE_GUID) ? true : false);
@@ -1694,6 +1697,7 @@ static int storvsc_probe(struct hv_device *device,
1694 int max_luns_per_target; 1697 int max_luns_per_target;
1695 int max_targets; 1698 int max_targets;
1696 int max_channels; 1699 int max_channels;
1700 int max_sub_channels = 0;
1697 1701
1698 /* 1702 /*
1699 * Based on the windows host we are running on, 1703 * Based on the windows host we are running on,
@@ -1719,12 +1723,18 @@ static int storvsc_probe(struct hv_device *device,
1719 max_luns_per_target = STORVSC_MAX_LUNS_PER_TARGET; 1723 max_luns_per_target = STORVSC_MAX_LUNS_PER_TARGET;
1720 max_targets = STORVSC_MAX_TARGETS; 1724 max_targets = STORVSC_MAX_TARGETS;
1721 max_channels = STORVSC_MAX_CHANNELS; 1725 max_channels = STORVSC_MAX_CHANNELS;
1726 /*
1727 * On Windows8 and above, we support sub-channels for storage.
1728 * The number of sub-channels offerred is based on the number of
1729 * VCPUs in the guest.
1730 */
1731 max_sub_channels = (num_cpus / storvsc_vcpus_per_sub_channel);
1722 break; 1732 break;
1723 } 1733 }
1724 1734
1725 if (dev_id->driver_data == SFC_GUID) 1735 scsi_driver.can_queue = (max_outstanding_req_per_channel *
1726 scsi_driver.can_queue = (STORVSC_MAX_IO_REQUESTS * 1736 (max_sub_channels + 1));
1727 STORVSC_FC_MAX_TARGETS); 1737
1728 host = scsi_host_alloc(&scsi_driver, 1738 host = scsi_host_alloc(&scsi_driver,
1729 sizeof(struct hv_host_device)); 1739 sizeof(struct hv_host_device));
1730 if (!host) 1740 if (!host)
@@ -1837,7 +1847,6 @@ static struct hv_driver storvsc_drv = {
1837 1847
1838static int __init storvsc_drv_init(void) 1848static int __init storvsc_drv_init(void)
1839{ 1849{
1840 u32 max_outstanding_req_per_channel;
1841 1850
1842 /* 1851 /*
1843 * Divide the ring buffer data size (which is 1 page less 1852 * Divide the ring buffer data size (which is 1 page less
@@ -1852,10 +1861,6 @@ static int __init storvsc_drv_init(void)
1852 vmscsi_size_delta, 1861 vmscsi_size_delta,
1853 sizeof(u64))); 1862 sizeof(u64)));
1854 1863
1855 if (max_outstanding_req_per_channel <
1856 STORVSC_MAX_IO_REQUESTS)
1857 return -EINVAL;
1858
1859 return vmbus_driver_register(&storvsc_drv); 1864 return vmbus_driver_register(&storvsc_drv);
1860} 1865}
1861 1866