aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/vmw_pvscsi.c
diff options
context:
space:
mode:
authorArvind Kumar <arvindkumar@vmware.com>2014-03-08 16:04:45 -0500
committerJames Bottomley <JBottomley@Parallels.com>2014-03-19 18:04:46 -0400
commit02845560090749dfd0bc0f3816c32f77b1efc56b (patch)
tree7141bebcd88d87f0b9974987fb304699d0656622 /drivers/scsi/vmw_pvscsi.c
parent2a815b5ac374d670f347f2d3a39db07105715398 (diff)
[SCSI] vmw_pvscsi: Some improvements in pvscsi driver.
This change is about the following: (1) If the number of targets is 16+ then default ring_pages to 32. (2) Change default queue depth (per device) to 254. (3) Implement change_queue_depth function so that queue_depth per device can be changed at run time. Honors the request only if coming from sysfs. (4) Clean up the info returned by modinfo. Signed-off-by: Arvind Kumar <arvindkumar@vmware.com> Signed-off-by: James Bottomley <JBottomley@Parallels.com>
Diffstat (limited to 'drivers/scsi/vmw_pvscsi.c')
-rw-r--r--drivers/scsi/vmw_pvscsi.c142
1 files changed, 104 insertions, 38 deletions
diff --git a/drivers/scsi/vmw_pvscsi.c b/drivers/scsi/vmw_pvscsi.c
index b92ea94be98f..c88e1468aad7 100644
--- a/drivers/scsi/vmw_pvscsi.c
+++ b/drivers/scsi/vmw_pvscsi.c
@@ -32,6 +32,7 @@
32#include <scsi/scsi_host.h> 32#include <scsi/scsi_host.h>
33#include <scsi/scsi_cmnd.h> 33#include <scsi/scsi_cmnd.h>
34#include <scsi/scsi_device.h> 34#include <scsi/scsi_device.h>
35#include <scsi/scsi_tcq.h>
35 36
36#include "vmw_pvscsi.h" 37#include "vmw_pvscsi.h"
37 38
@@ -44,7 +45,7 @@ MODULE_VERSION(PVSCSI_DRIVER_VERSION_STRING);
44 45
45#define PVSCSI_DEFAULT_NUM_PAGES_PER_RING 8 46#define PVSCSI_DEFAULT_NUM_PAGES_PER_RING 8
46#define PVSCSI_DEFAULT_NUM_PAGES_MSG_RING 1 47#define PVSCSI_DEFAULT_NUM_PAGES_MSG_RING 1
47#define PVSCSI_DEFAULT_QUEUE_DEPTH 64 48#define PVSCSI_DEFAULT_QUEUE_DEPTH 254
48#define SGL_SIZE PAGE_SIZE 49#define SGL_SIZE PAGE_SIZE
49 50
50struct pvscsi_sg_list { 51struct pvscsi_sg_list {
@@ -104,7 +105,7 @@ struct pvscsi_adapter {
104 105
105 106
106/* Command line parameters */ 107/* Command line parameters */
107static int pvscsi_ring_pages = PVSCSI_DEFAULT_NUM_PAGES_PER_RING; 108static int pvscsi_ring_pages;
108static int pvscsi_msg_ring_pages = PVSCSI_DEFAULT_NUM_PAGES_MSG_RING; 109static int pvscsi_msg_ring_pages = PVSCSI_DEFAULT_NUM_PAGES_MSG_RING;
109static int pvscsi_cmd_per_lun = PVSCSI_DEFAULT_QUEUE_DEPTH; 110static int pvscsi_cmd_per_lun = PVSCSI_DEFAULT_QUEUE_DEPTH;
110static bool pvscsi_disable_msi; 111static bool pvscsi_disable_msi;
@@ -116,7 +117,10 @@ static bool pvscsi_use_req_threshold = true;
116 117
117module_param_named(ring_pages, pvscsi_ring_pages, int, PVSCSI_RW); 118module_param_named(ring_pages, pvscsi_ring_pages, int, PVSCSI_RW);
118MODULE_PARM_DESC(ring_pages, "Number of pages per req/cmp ring - (default=" 119MODULE_PARM_DESC(ring_pages, "Number of pages per req/cmp ring - (default="
119 __stringify(PVSCSI_DEFAULT_NUM_PAGES_PER_RING) ")"); 120 __stringify(PVSCSI_DEFAULT_NUM_PAGES_PER_RING)
121 "[up to 16 targets],"
122 __stringify(PVSCSI_SETUP_RINGS_MAX_NUM_PAGES)
123 "[for 16+ targets])");
120 124
121module_param_named(msg_ring_pages, pvscsi_msg_ring_pages, int, PVSCSI_RW); 125module_param_named(msg_ring_pages, pvscsi_msg_ring_pages, int, PVSCSI_RW);
122MODULE_PARM_DESC(msg_ring_pages, "Number of pages for the msg ring - (default=" 126MODULE_PARM_DESC(msg_ring_pages, "Number of pages for the msg ring - (default="
@@ -124,7 +128,7 @@ MODULE_PARM_DESC(msg_ring_pages, "Number of pages for the msg ring - (default="
124 128
125module_param_named(cmd_per_lun, pvscsi_cmd_per_lun, int, PVSCSI_RW); 129module_param_named(cmd_per_lun, pvscsi_cmd_per_lun, int, PVSCSI_RW);
126MODULE_PARM_DESC(cmd_per_lun, "Maximum commands per lun - (default=" 130MODULE_PARM_DESC(cmd_per_lun, "Maximum commands per lun - (default="
127 __stringify(PVSCSI_MAX_REQ_QUEUE_DEPTH) ")"); 131 __stringify(PVSCSI_DEFAULT_QUEUE_DEPTH) ")");
128 132
129module_param_named(disable_msi, pvscsi_disable_msi, bool, PVSCSI_RW); 133module_param_named(disable_msi, pvscsi_disable_msi, bool, PVSCSI_RW);
130MODULE_PARM_DESC(disable_msi, "Disable MSI use in driver - (default=0)"); 134MODULE_PARM_DESC(disable_msi, "Disable MSI use in driver - (default=0)");
@@ -500,6 +504,35 @@ static void pvscsi_setup_all_rings(const struct pvscsi_adapter *adapter)
500 } 504 }
501} 505}
502 506
507static int pvscsi_change_queue_depth(struct scsi_device *sdev,
508 int qdepth,
509 int reason)
510{
511 int max_depth;
512 struct Scsi_Host *shost = sdev->host;
513
514 if (reason != SCSI_QDEPTH_DEFAULT)
515 /*
516 * We support only changing default.
517 */
518 return -EOPNOTSUPP;
519
520 max_depth = shost->can_queue;
521 if (!sdev->tagged_supported)
522 max_depth = 1;
523 if (qdepth > max_depth)
524 qdepth = max_depth;
525 scsi_adjust_queue_depth(sdev, scsi_get_tag_type(sdev), qdepth);
526
527 if (sdev->inquiry_len > 7)
528 sdev_printk(KERN_INFO, sdev,
529 "qdepth(%d), tagged(%d), simple(%d), ordered(%d), scsi_level(%d), cmd_que(%d)\n",
530 sdev->queue_depth, sdev->tagged_supported,
531 sdev->simple_tags, sdev->ordered_tags,
532 sdev->scsi_level, (sdev->inquiry[7] & 2) >> 1);
533 return sdev->queue_depth;
534}
535
503/* 536/*
504 * Pull a completion descriptor off and pass the completion back 537 * Pull a completion descriptor off and pass the completion back
505 * to the SCSI mid layer. 538 * to the SCSI mid layer.
@@ -965,6 +998,7 @@ static struct scsi_host_template pvscsi_template = {
965 .dma_boundary = UINT_MAX, 998 .dma_boundary = UINT_MAX,
966 .max_sectors = 0xffff, 999 .max_sectors = 0xffff,
967 .use_clustering = ENABLE_CLUSTERING, 1000 .use_clustering = ENABLE_CLUSTERING,
1001 .change_queue_depth = pvscsi_change_queue_depth,
968 .eh_abort_handler = pvscsi_abort, 1002 .eh_abort_handler = pvscsi_abort,
969 .eh_device_reset_handler = pvscsi_device_reset, 1003 .eh_device_reset_handler = pvscsi_device_reset,
970 .eh_bus_reset_handler = pvscsi_bus_reset, 1004 .eh_bus_reset_handler = pvscsi_bus_reset,
@@ -1318,11 +1352,12 @@ exit:
1318static int pvscsi_probe(struct pci_dev *pdev, const struct pci_device_id *id) 1352static int pvscsi_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1319{ 1353{
1320 struct pvscsi_adapter *adapter; 1354 struct pvscsi_adapter *adapter;
1321 struct Scsi_Host *host; 1355 struct pvscsi_adapter adapter_temp;
1322 struct device *dev; 1356 struct Scsi_Host *host = NULL;
1323 unsigned int i; 1357 unsigned int i;
1324 unsigned long flags = 0; 1358 unsigned long flags = 0;
1325 int error; 1359 int error;
1360 u32 max_id;
1326 1361
1327 error = -ENODEV; 1362 error = -ENODEV;
1328 1363
@@ -1340,34 +1375,19 @@ static int pvscsi_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1340 goto out_disable_device; 1375 goto out_disable_device;
1341 } 1376 }
1342 1377
1343 pvscsi_template.can_queue = 1378 /*
1344 min(PVSCSI_MAX_NUM_PAGES_REQ_RING, pvscsi_ring_pages) * 1379 * Let's use a temp pvscsi_adapter struct until we find the number of
1345 PVSCSI_MAX_NUM_REQ_ENTRIES_PER_PAGE; 1380 * targets on the adapter, after that we will switch to the real
1346 pvscsi_template.cmd_per_lun = 1381 * allocated struct.
1347 min(pvscsi_template.can_queue, pvscsi_cmd_per_lun); 1382 */
1348 host = scsi_host_alloc(&pvscsi_template, sizeof(struct pvscsi_adapter)); 1383 adapter = &adapter_temp;
1349 if (!host) {
1350 printk(KERN_ERR "vmw_pvscsi: failed to allocate host\n");
1351 goto out_disable_device;
1352 }
1353
1354 adapter = shost_priv(host);
1355 memset(adapter, 0, sizeof(*adapter)); 1384 memset(adapter, 0, sizeof(*adapter));
1356 adapter->dev = pdev; 1385 adapter->dev = pdev;
1357 adapter->host = host;
1358
1359 spin_lock_init(&adapter->hw_lock);
1360
1361 host->max_channel = 0;
1362 host->max_id = 16;
1363 host->max_lun = 1;
1364 host->max_cmd_len = 16;
1365
1366 adapter->rev = pdev->revision; 1386 adapter->rev = pdev->revision;
1367 1387
1368 if (pci_request_regions(pdev, "vmw_pvscsi")) { 1388 if (pci_request_regions(pdev, "vmw_pvscsi")) {
1369 printk(KERN_ERR "vmw_pvscsi: pci memory selection failed\n"); 1389 printk(KERN_ERR "vmw_pvscsi: pci memory selection failed\n");
1370 goto out_free_host; 1390 goto out_disable_device;
1371 } 1391 }
1372 1392
1373 for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) { 1393 for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) {
@@ -1383,7 +1403,7 @@ static int pvscsi_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1383 if (i == DEVICE_COUNT_RESOURCE) { 1403 if (i == DEVICE_COUNT_RESOURCE) {
1384 printk(KERN_ERR 1404 printk(KERN_ERR
1385 "vmw_pvscsi: adapter has no suitable MMIO region\n"); 1405 "vmw_pvscsi: adapter has no suitable MMIO region\n");
1386 goto out_release_resources; 1406 goto out_release_resources_and_disable;
1387 } 1407 }
1388 1408
1389 adapter->mmioBase = pci_iomap(pdev, i, PVSCSI_MEM_SPACE_SIZE); 1409 adapter->mmioBase = pci_iomap(pdev, i, PVSCSI_MEM_SPACE_SIZE);
@@ -1392,10 +1412,60 @@ static int pvscsi_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1392 printk(KERN_ERR 1412 printk(KERN_ERR
1393 "vmw_pvscsi: can't iomap for BAR %d memsize %lu\n", 1413 "vmw_pvscsi: can't iomap for BAR %d memsize %lu\n",
1394 i, PVSCSI_MEM_SPACE_SIZE); 1414 i, PVSCSI_MEM_SPACE_SIZE);
1395 goto out_release_resources; 1415 goto out_release_resources_and_disable;
1396 } 1416 }
1397 1417
1398 pci_set_master(pdev); 1418 pci_set_master(pdev);
1419
1420 /*
1421 * Ask the device for max number of targets before deciding the
1422 * default pvscsi_ring_pages value.
1423 */
1424 max_id = pvscsi_get_max_targets(adapter);
1425 printk(KERN_INFO "vmw_pvscsi: max_id: %u\n", max_id);
1426
1427 if (pvscsi_ring_pages == 0)
1428 /*
1429 * Set the right default value. Up to 16 it is 8, above it is
1430 * max.
1431 */
1432 pvscsi_ring_pages = (max_id > 16) ?
1433 PVSCSI_SETUP_RINGS_MAX_NUM_PAGES :
1434 PVSCSI_DEFAULT_NUM_PAGES_PER_RING;
1435 printk(KERN_INFO
1436 "vmw_pvscsi: setting ring_pages to %d\n",
1437 pvscsi_ring_pages);
1438
1439 pvscsi_template.can_queue =
1440 min(PVSCSI_MAX_NUM_PAGES_REQ_RING, pvscsi_ring_pages) *
1441 PVSCSI_MAX_NUM_REQ_ENTRIES_PER_PAGE;
1442 pvscsi_template.cmd_per_lun =
1443 min(pvscsi_template.can_queue, pvscsi_cmd_per_lun);
1444 host = scsi_host_alloc(&pvscsi_template, sizeof(struct pvscsi_adapter));
1445 if (!host) {
1446 printk(KERN_ERR "vmw_pvscsi: failed to allocate host\n");
1447 goto out_release_resources_and_disable;
1448 }
1449
1450 /*
1451 * Let's use the real pvscsi_adapter struct here onwards.
1452 */
1453 adapter = shost_priv(host);
1454 memset(adapter, 0, sizeof(*adapter));
1455 adapter->dev = pdev;
1456 adapter->host = host;
1457 /*
1458 * Copy back what we already have to the allocated adapter struct.
1459 */
1460 adapter->rev = adapter_temp.rev;
1461 adapter->mmioBase = adapter_temp.mmioBase;
1462
1463 spin_lock_init(&adapter->hw_lock);
1464 host->max_channel = 0;
1465 host->max_lun = 1;
1466 host->max_cmd_len = 16;
1467 host->max_id = max_id;
1468
1399 pci_set_drvdata(pdev, host); 1469 pci_set_drvdata(pdev, host);
1400 1470
1401 ll_adapter_reset(adapter); 1471 ll_adapter_reset(adapter);
@@ -1409,13 +1479,6 @@ static int pvscsi_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1409 } 1479 }
1410 1480
1411 /* 1481 /*
1412 * Ask the device for max number of targets.
1413 */
1414 host->max_id = pvscsi_get_max_targets(adapter);
1415 dev = pvscsi_dev(adapter);
1416 dev_info(dev, "vmw_pvscsi: host->max_id: %u\n", host->max_id);
1417
1418 /*
1419 * From this point on we should reset the adapter if anything goes 1482 * From this point on we should reset the adapter if anything goes
1420 * wrong. 1483 * wrong.
1421 */ 1484 */
@@ -1488,12 +1551,15 @@ out_reset_adapter:
1488 ll_adapter_reset(adapter); 1551 ll_adapter_reset(adapter);
1489out_release_resources: 1552out_release_resources:
1490 pvscsi_release_resources(adapter); 1553 pvscsi_release_resources(adapter);
1491out_free_host:
1492 scsi_host_put(host); 1554 scsi_host_put(host);
1493out_disable_device: 1555out_disable_device:
1494 pci_disable_device(pdev); 1556 pci_disable_device(pdev);
1495 1557
1496 return error; 1558 return error;
1559
1560out_release_resources_and_disable:
1561 pvscsi_release_resources(adapter);
1562 goto out_disable_device;
1497} 1563}
1498 1564
1499static void __pvscsi_shutdown(struct pvscsi_adapter *adapter) 1565static void __pvscsi_shutdown(struct pvscsi_adapter *adapter)