Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[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>

authored by

Arvind Kumar and committed by
James Bottomley
02845560 2a815b5a

+105 -39
+104 -38
drivers/scsi/vmw_pvscsi.c
··· 32 32 #include <scsi/scsi_host.h> 33 33 #include <scsi/scsi_cmnd.h> 34 34 #include <scsi/scsi_device.h> 35 + #include <scsi/scsi_tcq.h> 35 36 36 37 #include "vmw_pvscsi.h" 37 38 ··· 45 44 46 45 #define PVSCSI_DEFAULT_NUM_PAGES_PER_RING 8 47 46 #define PVSCSI_DEFAULT_NUM_PAGES_MSG_RING 1 48 - #define PVSCSI_DEFAULT_QUEUE_DEPTH 64 47 + #define PVSCSI_DEFAULT_QUEUE_DEPTH 254 49 48 #define SGL_SIZE PAGE_SIZE 50 49 51 50 struct pvscsi_sg_list { ··· 105 104 106 105 107 106 /* Command line parameters */ 108 - static int pvscsi_ring_pages = PVSCSI_DEFAULT_NUM_PAGES_PER_RING; 107 + static int pvscsi_ring_pages; 109 108 static int pvscsi_msg_ring_pages = PVSCSI_DEFAULT_NUM_PAGES_MSG_RING; 110 109 static int pvscsi_cmd_per_lun = PVSCSI_DEFAULT_QUEUE_DEPTH; 111 110 static bool pvscsi_disable_msi; ··· 117 116 118 117 module_param_named(ring_pages, pvscsi_ring_pages, int, PVSCSI_RW); 119 118 MODULE_PARM_DESC(ring_pages, "Number of pages per req/cmp ring - (default=" 120 - __stringify(PVSCSI_DEFAULT_NUM_PAGES_PER_RING) ")"); 119 + __stringify(PVSCSI_DEFAULT_NUM_PAGES_PER_RING) 120 + "[up to 16 targets]," 121 + __stringify(PVSCSI_SETUP_RINGS_MAX_NUM_PAGES) 122 + "[for 16+ targets])"); 121 123 122 124 module_param_named(msg_ring_pages, pvscsi_msg_ring_pages, int, PVSCSI_RW); 123 125 MODULE_PARM_DESC(msg_ring_pages, "Number of pages for the msg ring - (default=" ··· 128 124 129 125 module_param_named(cmd_per_lun, pvscsi_cmd_per_lun, int, PVSCSI_RW); 130 126 MODULE_PARM_DESC(cmd_per_lun, "Maximum commands per lun - (default=" 131 - __stringify(PVSCSI_MAX_REQ_QUEUE_DEPTH) ")"); 127 + __stringify(PVSCSI_DEFAULT_QUEUE_DEPTH) ")"); 132 128 133 129 module_param_named(disable_msi, pvscsi_disable_msi, bool, PVSCSI_RW); 134 130 MODULE_PARM_DESC(disable_msi, "Disable MSI use in driver - (default=0)"); ··· 502 498 pvscsi_write_cmd_desc(adapter, PVSCSI_CMD_SETUP_MSG_RING, 503 499 &cmd_msg, sizeof(cmd_msg)); 504 500 } 501 + } 502 + 503 + static int pvscsi_change_queue_depth(struct scsi_device *sdev, 504 + int qdepth, 505 + int reason) 506 + { 507 + int max_depth; 508 + struct Scsi_Host *shost = sdev->host; 509 + 510 + if (reason != SCSI_QDEPTH_DEFAULT) 511 + /* 512 + * We support only changing default. 513 + */ 514 + return -EOPNOTSUPP; 515 + 516 + max_depth = shost->can_queue; 517 + if (!sdev->tagged_supported) 518 + max_depth = 1; 519 + if (qdepth > max_depth) 520 + qdepth = max_depth; 521 + scsi_adjust_queue_depth(sdev, scsi_get_tag_type(sdev), qdepth); 522 + 523 + if (sdev->inquiry_len > 7) 524 + sdev_printk(KERN_INFO, sdev, 525 + "qdepth(%d), tagged(%d), simple(%d), ordered(%d), scsi_level(%d), cmd_que(%d)\n", 526 + sdev->queue_depth, sdev->tagged_supported, 527 + sdev->simple_tags, sdev->ordered_tags, 528 + sdev->scsi_level, (sdev->inquiry[7] & 2) >> 1); 529 + return sdev->queue_depth; 505 530 } 506 531 507 532 /* ··· 998 965 .dma_boundary = UINT_MAX, 999 966 .max_sectors = 0xffff, 1000 967 .use_clustering = ENABLE_CLUSTERING, 968 + .change_queue_depth = pvscsi_change_queue_depth, 1001 969 .eh_abort_handler = pvscsi_abort, 1002 970 .eh_device_reset_handler = pvscsi_device_reset, 1003 971 .eh_bus_reset_handler = pvscsi_bus_reset, ··· 1352 1318 static int pvscsi_probe(struct pci_dev *pdev, const struct pci_device_id *id) 1353 1319 { 1354 1320 struct pvscsi_adapter *adapter; 1355 - struct Scsi_Host *host; 1356 - struct device *dev; 1321 + struct pvscsi_adapter adapter_temp; 1322 + struct Scsi_Host *host = NULL; 1357 1323 unsigned int i; 1358 1324 unsigned long flags = 0; 1359 1325 int error; 1326 + u32 max_id; 1360 1327 1361 1328 error = -ENODEV; 1362 1329 ··· 1375 1340 goto out_disable_device; 1376 1341 } 1377 1342 1378 - pvscsi_template.can_queue = 1379 - min(PVSCSI_MAX_NUM_PAGES_REQ_RING, pvscsi_ring_pages) * 1380 - PVSCSI_MAX_NUM_REQ_ENTRIES_PER_PAGE; 1381 - pvscsi_template.cmd_per_lun = 1382 - min(pvscsi_template.can_queue, pvscsi_cmd_per_lun); 1383 - host = scsi_host_alloc(&pvscsi_template, sizeof(struct pvscsi_adapter)); 1384 - if (!host) { 1385 - printk(KERN_ERR "vmw_pvscsi: failed to allocate host\n"); 1386 - goto out_disable_device; 1387 - } 1388 - 1389 - adapter = shost_priv(host); 1343 + /* 1344 + * Let's use a temp pvscsi_adapter struct until we find the number of 1345 + * targets on the adapter, after that we will switch to the real 1346 + * allocated struct. 1347 + */ 1348 + adapter = &adapter_temp; 1390 1349 memset(adapter, 0, sizeof(*adapter)); 1391 1350 adapter->dev = pdev; 1392 - adapter->host = host; 1393 - 1394 - spin_lock_init(&adapter->hw_lock); 1395 - 1396 - host->max_channel = 0; 1397 - host->max_id = 16; 1398 - host->max_lun = 1; 1399 - host->max_cmd_len = 16; 1400 - 1401 1351 adapter->rev = pdev->revision; 1402 1352 1403 1353 if (pci_request_regions(pdev, "vmw_pvscsi")) { 1404 1354 printk(KERN_ERR "vmw_pvscsi: pci memory selection failed\n"); 1405 - goto out_free_host; 1355 + goto out_disable_device; 1406 1356 } 1407 1357 1408 1358 for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) { ··· 1403 1383 if (i == DEVICE_COUNT_RESOURCE) { 1404 1384 printk(KERN_ERR 1405 1385 "vmw_pvscsi: adapter has no suitable MMIO region\n"); 1406 - goto out_release_resources; 1386 + goto out_release_resources_and_disable; 1407 1387 } 1408 1388 1409 1389 adapter->mmioBase = pci_iomap(pdev, i, PVSCSI_MEM_SPACE_SIZE); ··· 1412 1392 printk(KERN_ERR 1413 1393 "vmw_pvscsi: can't iomap for BAR %d memsize %lu\n", 1414 1394 i, PVSCSI_MEM_SPACE_SIZE); 1415 - goto out_release_resources; 1395 + goto out_release_resources_and_disable; 1416 1396 } 1417 1397 1418 1398 pci_set_master(pdev); 1399 + 1400 + /* 1401 + * Ask the device for max number of targets before deciding the 1402 + * default pvscsi_ring_pages value. 1403 + */ 1404 + max_id = pvscsi_get_max_targets(adapter); 1405 + printk(KERN_INFO "vmw_pvscsi: max_id: %u\n", max_id); 1406 + 1407 + if (pvscsi_ring_pages == 0) 1408 + /* 1409 + * Set the right default value. Up to 16 it is 8, above it is 1410 + * max. 1411 + */ 1412 + pvscsi_ring_pages = (max_id > 16) ? 1413 + PVSCSI_SETUP_RINGS_MAX_NUM_PAGES : 1414 + PVSCSI_DEFAULT_NUM_PAGES_PER_RING; 1415 + printk(KERN_INFO 1416 + "vmw_pvscsi: setting ring_pages to %d\n", 1417 + pvscsi_ring_pages); 1418 + 1419 + pvscsi_template.can_queue = 1420 + min(PVSCSI_MAX_NUM_PAGES_REQ_RING, pvscsi_ring_pages) * 1421 + PVSCSI_MAX_NUM_REQ_ENTRIES_PER_PAGE; 1422 + pvscsi_template.cmd_per_lun = 1423 + min(pvscsi_template.can_queue, pvscsi_cmd_per_lun); 1424 + host = scsi_host_alloc(&pvscsi_template, sizeof(struct pvscsi_adapter)); 1425 + if (!host) { 1426 + printk(KERN_ERR "vmw_pvscsi: failed to allocate host\n"); 1427 + goto out_release_resources_and_disable; 1428 + } 1429 + 1430 + /* 1431 + * Let's use the real pvscsi_adapter struct here onwards. 1432 + */ 1433 + adapter = shost_priv(host); 1434 + memset(adapter, 0, sizeof(*adapter)); 1435 + adapter->dev = pdev; 1436 + adapter->host = host; 1437 + /* 1438 + * Copy back what we already have to the allocated adapter struct. 1439 + */ 1440 + adapter->rev = adapter_temp.rev; 1441 + adapter->mmioBase = adapter_temp.mmioBase; 1442 + 1443 + spin_lock_init(&adapter->hw_lock); 1444 + host->max_channel = 0; 1445 + host->max_lun = 1; 1446 + host->max_cmd_len = 16; 1447 + host->max_id = max_id; 1448 + 1419 1449 pci_set_drvdata(pdev, host); 1420 1450 1421 1451 ll_adapter_reset(adapter); ··· 1477 1407 printk(KERN_ERR "vmw_pvscsi: unable to allocate ring memory\n"); 1478 1408 goto out_release_resources; 1479 1409 } 1480 - 1481 - /* 1482 - * Ask the device for max number of targets. 1483 - */ 1484 - host->max_id = pvscsi_get_max_targets(adapter); 1485 - dev = pvscsi_dev(adapter); 1486 - dev_info(dev, "vmw_pvscsi: host->max_id: %u\n", host->max_id); 1487 1410 1488 1411 /* 1489 1412 * From this point on we should reset the adapter if anything goes ··· 1551 1488 ll_adapter_reset(adapter); 1552 1489 out_release_resources: 1553 1490 pvscsi_release_resources(adapter); 1554 - out_free_host: 1555 1491 scsi_host_put(host); 1556 1492 out_disable_device: 1557 1493 pci_disable_device(pdev); 1558 1494 1559 1495 return error; 1496 + 1497 + out_release_resources_and_disable: 1498 + pvscsi_release_resources(adapter); 1499 + goto out_disable_device; 1560 1500 } 1561 1501 1562 1502 static void __pvscsi_shutdown(struct pvscsi_adapter *adapter)
+1 -1
drivers/scsi/vmw_pvscsi.h
··· 26 26 27 27 #include <linux/types.h> 28 28 29 - #define PVSCSI_DRIVER_VERSION_STRING "1.0.4.0-k" 29 + #define PVSCSI_DRIVER_VERSION_STRING "1.0.5.0-k" 30 30 31 31 #define PVSCSI_MAX_NUM_SG_ENTRIES_PER_SEGMENT 128 32 32