diff options
author | Kashyap, Desai <kashyap.desai@lsi.com> | 2009-09-14 01:32:48 -0400 |
---|---|---|
committer | James Bottomley <James.Bottomley@suse.de> | 2009-10-02 10:48:26 -0400 |
commit | 595bb0bd62edb28a965993d90e0fa1285560ce53 (patch) | |
tree | 0447a980d9c99e21ab1c9bac0b7f893da75d18e3 /drivers/scsi/mpt2sas/mpt2sas_base.c | |
parent | 19d3ebe3d5c4d56c8309a64561d99e7920a35fbb (diff) |
[SCSI] mpt2sas: Added SCSIIO, Internal and high priority memory pools to support multiple TM
1) create a pool of high priority message frames in the region of memory
between message frames and chains. The modifications are in
_base_allocate_memory_pools. Also create a seperate pool of memory for
internal commands located near the same region of memory. The pool of high
priority message frames is restriced by the facts->HighPriorityCredit.
2) Create additional API for accessing request message frames. New function
mpt2sas_base_get_smid_hpr is for highpriority request. New function
mpt2sas_base_get_smid_scsiio for SCSI_IO, passing in the scsi command
pointer. The mpt2sas_base_get_smid function is for requesting internal
commands.
3) Added new function _base_get_cb_idx to obtain the callback
index from one of the three pools of request message frames.
4) Removed wrapper functions _scsih_scsi_lookup_set and
_scsih_scsi_lookup_getclear. These were removed because this handling was
moved into mpt2sas_base_get_smid_scsiio and mpt2sas_base_free_smid.
5) The function mpt2sas_base_free_smid is modified so the request message
frames are put back on one of the three pools of request message frames.
Signed-off-by: Kashyap Desai <kashyap.desai@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
Diffstat (limited to 'drivers/scsi/mpt2sas/mpt2sas_base.c')
-rw-r--r-- | drivers/scsi/mpt2sas/mpt2sas_base.c | 302 |
1 files changed, 241 insertions, 61 deletions
diff --git a/drivers/scsi/mpt2sas/mpt2sas_base.c b/drivers/scsi/mpt2sas/mpt2sas_base.c index 675a049a7a5d..4c583ff458db 100644 --- a/drivers/scsi/mpt2sas/mpt2sas_base.c +++ b/drivers/scsi/mpt2sas/mpt2sas_base.c | |||
@@ -63,7 +63,7 @@ | |||
63 | static MPT_CALLBACK mpt_callbacks[MPT_MAX_CALLBACKS]; | 63 | static MPT_CALLBACK mpt_callbacks[MPT_MAX_CALLBACKS]; |
64 | 64 | ||
65 | #define FAULT_POLLING_INTERVAL 1000 /* in milliseconds */ | 65 | #define FAULT_POLLING_INTERVAL 1000 /* in milliseconds */ |
66 | #define MPT2SAS_MAX_REQUEST_QUEUE 500 /* maximum controller queue depth */ | 66 | #define MPT2SAS_MAX_REQUEST_QUEUE 600 /* maximum controller queue depth */ |
67 | 67 | ||
68 | static int max_queue_depth = -1; | 68 | static int max_queue_depth = -1; |
69 | module_param(max_queue_depth, int, 0); | 69 | module_param(max_queue_depth, int, 0); |
@@ -650,6 +650,34 @@ _base_async_event(struct MPT2SAS_ADAPTER *ioc, u8 msix_index, u32 reply) | |||
650 | } | 650 | } |
651 | 651 | ||
652 | /** | 652 | /** |
653 | * _base_get_cb_idx - obtain the callback index | ||
654 | * @ioc: per adapter object | ||
655 | * @smid: system request message index | ||
656 | * | ||
657 | * Return callback index. | ||
658 | */ | ||
659 | static u8 | ||
660 | _base_get_cb_idx(struct MPT2SAS_ADAPTER *ioc, u16 smid) | ||
661 | { | ||
662 | int i; | ||
663 | u8 cb_idx = 0xFF; | ||
664 | |||
665 | if (smid >= ioc->hi_priority_smid) { | ||
666 | if (smid < ioc->internal_smid) { | ||
667 | i = smid - ioc->hi_priority_smid; | ||
668 | cb_idx = ioc->hpr_lookup[i].cb_idx; | ||
669 | } else { | ||
670 | i = smid - ioc->internal_smid; | ||
671 | cb_idx = ioc->internal_lookup[i].cb_idx; | ||
672 | } | ||
673 | } else { | ||
674 | i = smid - 1; | ||
675 | cb_idx = ioc->scsi_lookup[i].cb_idx; | ||
676 | } | ||
677 | return cb_idx; | ||
678 | } | ||
679 | |||
680 | /** | ||
653 | * _base_mask_interrupts - disable interrupts | 681 | * _base_mask_interrupts - disable interrupts |
654 | * @ioc: pointer to scsi command object | 682 | * @ioc: pointer to scsi command object |
655 | * | 683 | * |
@@ -747,9 +775,10 @@ _base_interrupt(int irq, void *bus_id) | |||
747 | MPI2_RPY_DESCRIPT_FLAGS_TARGETASSIST_SUCCESS) | 775 | MPI2_RPY_DESCRIPT_FLAGS_TARGETASSIST_SUCCESS) |
748 | goto next; | 776 | goto next; |
749 | if (smid) | 777 | if (smid) |
750 | cb_idx = ioc->scsi_lookup[smid - 1].cb_idx; | 778 | cb_idx = _base_get_cb_idx(ioc, smid); |
751 | if (smid && cb_idx != 0xFF) { | 779 | if (smid && cb_idx != 0xFF) { |
752 | mpt_callbacks[cb_idx](ioc, smid, msix_index, reply); | 780 | mpt_callbacks[cb_idx](ioc, smid, msix_index, |
781 | reply); | ||
753 | if (reply) | 782 | if (reply) |
754 | _base_display_reply_info(ioc, smid, msix_index, | 783 | _base_display_reply_info(ioc, smid, msix_index, |
755 | reply); | 784 | reply); |
@@ -1193,19 +1222,6 @@ mpt2sas_base_map_resources(struct MPT2SAS_ADAPTER *ioc) | |||
1193 | } | 1222 | } |
1194 | 1223 | ||
1195 | /** | 1224 | /** |
1196 | * mpt2sas_base_get_msg_frame_dma - obtain request mf pointer phys addr | ||
1197 | * @ioc: per adapter object | ||
1198 | * @smid: system request message index(smid zero is invalid) | ||
1199 | * | ||
1200 | * Returns phys pointer to message frame. | ||
1201 | */ | ||
1202 | dma_addr_t | ||
1203 | mpt2sas_base_get_msg_frame_dma(struct MPT2SAS_ADAPTER *ioc, u16 smid) | ||
1204 | { | ||
1205 | return ioc->request_dma + (smid * ioc->request_sz); | ||
1206 | } | ||
1207 | |||
1208 | /** | ||
1209 | * mpt2sas_base_get_msg_frame - obtain request mf pointer | 1225 | * mpt2sas_base_get_msg_frame - obtain request mf pointer |
1210 | * @ioc: per adapter object | 1226 | * @ioc: per adapter object |
1211 | * @smid: system request message index(smid zero is invalid) | 1227 | * @smid: system request message index(smid zero is invalid) |
@@ -1260,7 +1276,7 @@ mpt2sas_base_get_reply_virt_addr(struct MPT2SAS_ADAPTER *ioc, u32 phys_addr) | |||
1260 | } | 1276 | } |
1261 | 1277 | ||
1262 | /** | 1278 | /** |
1263 | * mpt2sas_base_get_smid - obtain a free smid | 1279 | * mpt2sas_base_get_smid - obtain a free smid from internal queue |
1264 | * @ioc: per adapter object | 1280 | * @ioc: per adapter object |
1265 | * @cb_idx: callback index | 1281 | * @cb_idx: callback index |
1266 | * | 1282 | * |
@@ -1274,6 +1290,39 @@ mpt2sas_base_get_smid(struct MPT2SAS_ADAPTER *ioc, u8 cb_idx) | |||
1274 | u16 smid; | 1290 | u16 smid; |
1275 | 1291 | ||
1276 | spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); | 1292 | spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); |
1293 | if (list_empty(&ioc->internal_free_list)) { | ||
1294 | spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags); | ||
1295 | printk(MPT2SAS_ERR_FMT "%s: smid not available\n", | ||
1296 | ioc->name, __func__); | ||
1297 | return 0; | ||
1298 | } | ||
1299 | |||
1300 | request = list_entry(ioc->internal_free_list.next, | ||
1301 | struct request_tracker, tracker_list); | ||
1302 | request->cb_idx = cb_idx; | ||
1303 | smid = request->smid; | ||
1304 | list_del(&request->tracker_list); | ||
1305 | spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags); | ||
1306 | return smid; | ||
1307 | } | ||
1308 | |||
1309 | /** | ||
1310 | * mpt2sas_base_get_smid_scsiio - obtain a free smid from scsiio queue | ||
1311 | * @ioc: per adapter object | ||
1312 | * @cb_idx: callback index | ||
1313 | * @scmd: pointer to scsi command object | ||
1314 | * | ||
1315 | * Returns smid (zero is invalid) | ||
1316 | */ | ||
1317 | u16 | ||
1318 | mpt2sas_base_get_smid_scsiio(struct MPT2SAS_ADAPTER *ioc, u8 cb_idx, | ||
1319 | struct scsi_cmnd *scmd) | ||
1320 | { | ||
1321 | unsigned long flags; | ||
1322 | struct request_tracker *request; | ||
1323 | u16 smid; | ||
1324 | |||
1325 | spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); | ||
1277 | if (list_empty(&ioc->free_list)) { | 1326 | if (list_empty(&ioc->free_list)) { |
1278 | spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags); | 1327 | spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags); |
1279 | printk(MPT2SAS_ERR_FMT "%s: smid not available\n", | 1328 | printk(MPT2SAS_ERR_FMT "%s: smid not available\n", |
@@ -1283,6 +1332,36 @@ mpt2sas_base_get_smid(struct MPT2SAS_ADAPTER *ioc, u8 cb_idx) | |||
1283 | 1332 | ||
1284 | request = list_entry(ioc->free_list.next, | 1333 | request = list_entry(ioc->free_list.next, |
1285 | struct request_tracker, tracker_list); | 1334 | struct request_tracker, tracker_list); |
1335 | request->scmd = scmd; | ||
1336 | request->cb_idx = cb_idx; | ||
1337 | smid = request->smid; | ||
1338 | list_del(&request->tracker_list); | ||
1339 | spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags); | ||
1340 | return smid; | ||
1341 | } | ||
1342 | |||
1343 | /** | ||
1344 | * mpt2sas_base_get_smid_hpr - obtain a free smid from hi-priority queue | ||
1345 | * @ioc: per adapter object | ||
1346 | * @cb_idx: callback index | ||
1347 | * | ||
1348 | * Returns smid (zero is invalid) | ||
1349 | */ | ||
1350 | u16 | ||
1351 | mpt2sas_base_get_smid_hpr(struct MPT2SAS_ADAPTER *ioc, u8 cb_idx) | ||
1352 | { | ||
1353 | unsigned long flags; | ||
1354 | struct request_tracker *request; | ||
1355 | u16 smid; | ||
1356 | |||
1357 | spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); | ||
1358 | if (list_empty(&ioc->hpr_free_list)) { | ||
1359 | spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags); | ||
1360 | return 0; | ||
1361 | } | ||
1362 | |||
1363 | request = list_entry(ioc->hpr_free_list.next, | ||
1364 | struct request_tracker, tracker_list); | ||
1286 | request->cb_idx = cb_idx; | 1365 | request->cb_idx = cb_idx; |
1287 | smid = request->smid; | 1366 | smid = request->smid; |
1288 | list_del(&request->tracker_list); | 1367 | list_del(&request->tracker_list); |
@@ -1302,10 +1381,32 @@ void | |||
1302 | mpt2sas_base_free_smid(struct MPT2SAS_ADAPTER *ioc, u16 smid) | 1381 | mpt2sas_base_free_smid(struct MPT2SAS_ADAPTER *ioc, u16 smid) |
1303 | { | 1382 | { |
1304 | unsigned long flags; | 1383 | unsigned long flags; |
1384 | int i; | ||
1305 | 1385 | ||
1306 | spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); | 1386 | spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); |
1307 | ioc->scsi_lookup[smid - 1].cb_idx = 0xFF; | 1387 | if (smid >= ioc->hi_priority_smid) { |
1308 | list_add_tail(&ioc->scsi_lookup[smid - 1].tracker_list, | 1388 | if (smid < ioc->internal_smid) { |
1389 | /* hi-priority */ | ||
1390 | i = smid - ioc->hi_priority_smid; | ||
1391 | ioc->hpr_lookup[i].cb_idx = 0xFF; | ||
1392 | list_add_tail(&ioc->hpr_lookup[i].tracker_list, | ||
1393 | &ioc->hpr_free_list); | ||
1394 | } else { | ||
1395 | /* internal queue */ | ||
1396 | i = smid - ioc->internal_smid; | ||
1397 | ioc->internal_lookup[i].cb_idx = 0xFF; | ||
1398 | list_add_tail(&ioc->internal_lookup[i].tracker_list, | ||
1399 | &ioc->internal_free_list); | ||
1400 | } | ||
1401 | spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags); | ||
1402 | return; | ||
1403 | } | ||
1404 | |||
1405 | /* scsiio queue */ | ||
1406 | i = smid - 1; | ||
1407 | ioc->scsi_lookup[i].cb_idx = 0xFF; | ||
1408 | ioc->scsi_lookup[i].scmd = NULL; | ||
1409 | list_add_tail(&ioc->scsi_lookup[i].tracker_list, | ||
1309 | &ioc->free_list); | 1410 | &ioc->free_list); |
1310 | spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags); | 1411 | spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags); |
1311 | 1412 | ||
@@ -1713,6 +1814,8 @@ _base_release_memory_pools(struct MPT2SAS_ADAPTER *ioc) | |||
1713 | } | 1814 | } |
1714 | 1815 | ||
1715 | kfree(ioc->scsi_lookup); | 1816 | kfree(ioc->scsi_lookup); |
1817 | kfree(ioc->hpr_lookup); | ||
1818 | kfree(ioc->internal_lookup); | ||
1716 | } | 1819 | } |
1717 | 1820 | ||
1718 | 1821 | ||
@@ -1732,7 +1835,6 @@ _base_allocate_memory_pools(struct MPT2SAS_ADAPTER *ioc, int sleep_flag) | |||
1732 | u16 num_of_reply_frames; | 1835 | u16 num_of_reply_frames; |
1733 | u16 chains_needed_per_io; | 1836 | u16 chains_needed_per_io; |
1734 | u32 sz, total_sz; | 1837 | u32 sz, total_sz; |
1735 | u16 i; | ||
1736 | u32 retry_sz; | 1838 | u32 retry_sz; |
1737 | u16 max_request_credit; | 1839 | u16 max_request_credit; |
1738 | 1840 | ||
@@ -1760,7 +1862,10 @@ _base_allocate_memory_pools(struct MPT2SAS_ADAPTER *ioc, int sleep_flag) | |||
1760 | MPT2SAS_MAX_REQUEST_QUEUE) ? MPT2SAS_MAX_REQUEST_QUEUE : | 1862 | MPT2SAS_MAX_REQUEST_QUEUE) ? MPT2SAS_MAX_REQUEST_QUEUE : |
1761 | facts->RequestCredit; | 1863 | facts->RequestCredit; |
1762 | } | 1864 | } |
1763 | ioc->request_depth = max_request_credit; | 1865 | |
1866 | ioc->hba_queue_depth = max_request_credit; | ||
1867 | ioc->hi_priority_depth = facts->HighPriorityCredit; | ||
1868 | ioc->internal_depth = ioc->hi_priority_depth + 5; | ||
1764 | 1869 | ||
1765 | /* request frame size */ | 1870 | /* request frame size */ |
1766 | ioc->request_sz = facts->IOCRequestFrameSize * 4; | 1871 | ioc->request_sz = facts->IOCRequestFrameSize * 4; |
@@ -1798,7 +1903,7 @@ _base_allocate_memory_pools(struct MPT2SAS_ADAPTER *ioc, int sleep_flag) | |||
1798 | ioc->chains_needed_per_io = chains_needed_per_io; | 1903 | ioc->chains_needed_per_io = chains_needed_per_io; |
1799 | 1904 | ||
1800 | /* reply free queue sizing - taking into account for events */ | 1905 | /* reply free queue sizing - taking into account for events */ |
1801 | num_of_reply_frames = ioc->request_depth + 32; | 1906 | num_of_reply_frames = ioc->hba_queue_depth + 32; |
1802 | 1907 | ||
1803 | /* number of replies frames can't be a multiple of 16 */ | 1908 | /* number of replies frames can't be a multiple of 16 */ |
1804 | /* decrease number of reply frames by 1 */ | 1909 | /* decrease number of reply frames by 1 */ |
@@ -1819,7 +1924,7 @@ _base_allocate_memory_pools(struct MPT2SAS_ADAPTER *ioc, int sleep_flag) | |||
1819 | * frames | 1924 | * frames |
1820 | */ | 1925 | */ |
1821 | 1926 | ||
1822 | queue_size = ioc->request_depth + num_of_reply_frames + 1; | 1927 | queue_size = ioc->hba_queue_depth + num_of_reply_frames + 1; |
1823 | /* round up to 16 byte boundary */ | 1928 | /* round up to 16 byte boundary */ |
1824 | if (queue_size % 16) | 1929 | if (queue_size % 16) |
1825 | queue_size += 16 - (queue_size % 16); | 1930 | queue_size += 16 - (queue_size % 16); |
@@ -1833,60 +1938,85 @@ _base_allocate_memory_pools(struct MPT2SAS_ADAPTER *ioc, int sleep_flag) | |||
1833 | if (queue_diff % 16) | 1938 | if (queue_diff % 16) |
1834 | queue_diff += 16 - (queue_diff % 16); | 1939 | queue_diff += 16 - (queue_diff % 16); |
1835 | 1940 | ||
1836 | /* adjust request_depth, reply_free_queue_depth, | 1941 | /* adjust hba_queue_depth, reply_free_queue_depth, |
1837 | * and queue_size | 1942 | * and queue_size |
1838 | */ | 1943 | */ |
1839 | ioc->request_depth -= queue_diff; | 1944 | ioc->hba_queue_depth -= queue_diff; |
1840 | ioc->reply_free_queue_depth -= queue_diff; | 1945 | ioc->reply_free_queue_depth -= queue_diff; |
1841 | queue_size -= queue_diff; | 1946 | queue_size -= queue_diff; |
1842 | } | 1947 | } |
1843 | ioc->reply_post_queue_depth = queue_size; | 1948 | ioc->reply_post_queue_depth = queue_size; |
1844 | 1949 | ||
1845 | /* max scsi host queue depth */ | ||
1846 | ioc->shost->can_queue = ioc->request_depth - INTERNAL_CMDS_COUNT; | ||
1847 | dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "scsi host queue: depth" | ||
1848 | "(%d)\n", ioc->name, ioc->shost->can_queue)); | ||
1849 | |||
1850 | dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "scatter gather: " | 1950 | dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "scatter gather: " |
1851 | "sge_in_main_msg(%d), sge_per_chain(%d), sge_per_io(%d), " | 1951 | "sge_in_main_msg(%d), sge_per_chain(%d), sge_per_io(%d), " |
1852 | "chains_per_io(%d)\n", ioc->name, ioc->max_sges_in_main_message, | 1952 | "chains_per_io(%d)\n", ioc->name, ioc->max_sges_in_main_message, |
1853 | ioc->max_sges_in_chain_message, ioc->shost->sg_tablesize, | 1953 | ioc->max_sges_in_chain_message, ioc->shost->sg_tablesize, |
1854 | ioc->chains_needed_per_io)); | 1954 | ioc->chains_needed_per_io)); |
1855 | 1955 | ||
1956 | ioc->scsiio_depth = ioc->hba_queue_depth - | ||
1957 | ioc->hi_priority_depth - ioc->internal_depth; | ||
1958 | |||
1959 | /* set the scsi host can_queue depth | ||
1960 | * with some internal commands that could be outstanding | ||
1961 | */ | ||
1962 | ioc->shost->can_queue = ioc->scsiio_depth - (2); | ||
1963 | dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "scsi host: " | ||
1964 | "can_queue depth (%d)\n", ioc->name, ioc->shost->can_queue)); | ||
1965 | |||
1856 | /* contiguous pool for request and chains, 16 byte align, one extra " | 1966 | /* contiguous pool for request and chains, 16 byte align, one extra " |
1857 | * "frame for smid=0 | 1967 | * "frame for smid=0 |
1858 | */ | 1968 | */ |
1859 | ioc->chain_depth = ioc->chains_needed_per_io * ioc->request_depth; | 1969 | ioc->chain_depth = ioc->chains_needed_per_io * ioc->scsiio_depth; |
1860 | sz = ((ioc->request_depth + 1 + ioc->chain_depth) * ioc->request_sz); | 1970 | sz = ((ioc->scsiio_depth + 1 + ioc->chain_depth) * ioc->request_sz); |
1971 | |||
1972 | /* hi-priority queue */ | ||
1973 | sz += (ioc->hi_priority_depth * ioc->request_sz); | ||
1974 | |||
1975 | /* internal queue */ | ||
1976 | sz += (ioc->internal_depth * ioc->request_sz); | ||
1861 | 1977 | ||
1862 | ioc->request_dma_sz = sz; | 1978 | ioc->request_dma_sz = sz; |
1863 | ioc->request = pci_alloc_consistent(ioc->pdev, sz, &ioc->request_dma); | 1979 | ioc->request = pci_alloc_consistent(ioc->pdev, sz, &ioc->request_dma); |
1864 | if (!ioc->request) { | 1980 | if (!ioc->request) { |
1865 | printk(MPT2SAS_ERR_FMT "request pool: pci_alloc_consistent " | 1981 | printk(MPT2SAS_ERR_FMT "request pool: pci_alloc_consistent " |
1866 | "failed: req_depth(%d), chains_per_io(%d), frame_sz(%d), " | 1982 | "failed: hba_depth(%d), chains_per_io(%d), frame_sz(%d), " |
1867 | "total(%d kB)\n", ioc->name, ioc->request_depth, | 1983 | "total(%d kB)\n", ioc->name, ioc->hba_queue_depth, |
1868 | ioc->chains_needed_per_io, ioc->request_sz, sz/1024); | 1984 | ioc->chains_needed_per_io, ioc->request_sz, sz/1024); |
1869 | if (ioc->request_depth < MPT2SAS_SAS_QUEUE_DEPTH) | 1985 | if (ioc->scsiio_depth < MPT2SAS_SAS_QUEUE_DEPTH) |
1870 | goto out; | 1986 | goto out; |
1871 | retry_sz += 64; | 1987 | retry_sz += 64; |
1872 | ioc->request_depth = max_request_credit - retry_sz; | 1988 | ioc->hba_queue_depth = max_request_credit - retry_sz; |
1873 | goto retry_allocation; | 1989 | goto retry_allocation; |
1874 | } | 1990 | } |
1875 | 1991 | ||
1876 | if (retry_sz) | 1992 | if (retry_sz) |
1877 | printk(MPT2SAS_ERR_FMT "request pool: pci_alloc_consistent " | 1993 | printk(MPT2SAS_ERR_FMT "request pool: pci_alloc_consistent " |
1878 | "succeed: req_depth(%d), chains_per_io(%d), frame_sz(%d), " | 1994 | "succeed: hba_depth(%d), chains_per_io(%d), frame_sz(%d), " |
1879 | "total(%d kb)\n", ioc->name, ioc->request_depth, | 1995 | "total(%d kb)\n", ioc->name, ioc->hba_queue_depth, |
1880 | ioc->chains_needed_per_io, ioc->request_sz, sz/1024); | 1996 | ioc->chains_needed_per_io, ioc->request_sz, sz/1024); |
1881 | 1997 | ||
1882 | ioc->chain = ioc->request + ((ioc->request_depth + 1) * | 1998 | |
1999 | /* hi-priority queue */ | ||
2000 | ioc->hi_priority = ioc->request + ((ioc->scsiio_depth + 1) * | ||
1883 | ioc->request_sz); | 2001 | ioc->request_sz); |
1884 | ioc->chain_dma = ioc->request_dma + ((ioc->request_depth + 1) * | 2002 | ioc->hi_priority_dma = ioc->request_dma + ((ioc->scsiio_depth + 1) * |
2003 | ioc->request_sz); | ||
2004 | |||
2005 | /* internal queue */ | ||
2006 | ioc->internal = ioc->hi_priority + (ioc->hi_priority_depth * | ||
1885 | ioc->request_sz); | 2007 | ioc->request_sz); |
2008 | ioc->internal_dma = ioc->hi_priority_dma + (ioc->hi_priority_depth * | ||
2009 | ioc->request_sz); | ||
2010 | |||
2011 | ioc->chain = ioc->internal + (ioc->internal_depth * | ||
2012 | ioc->request_sz); | ||
2013 | ioc->chain_dma = ioc->internal_dma + (ioc->internal_depth * | ||
2014 | ioc->request_sz); | ||
2015 | |||
1886 | dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "request pool(0x%p): " | 2016 | dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "request pool(0x%p): " |
1887 | "depth(%d), frame_size(%d), pool_size(%d kB)\n", ioc->name, | 2017 | "depth(%d), frame_size(%d), pool_size(%d kB)\n", ioc->name, |
1888 | ioc->request, ioc->request_depth, ioc->request_sz, | 2018 | ioc->request, ioc->hba_queue_depth, ioc->request_sz, |
1889 | ((ioc->request_depth + 1) * ioc->request_sz)/1024)); | 2019 | (ioc->hba_queue_depth * ioc->request_sz)/1024)); |
1890 | dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "chain pool(0x%p): depth" | 2020 | dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "chain pool(0x%p): depth" |
1891 | "(%d), frame_size(%d), pool_size(%d kB)\n", ioc->name, ioc->chain, | 2021 | "(%d), frame_size(%d), pool_size(%d kB)\n", ioc->name, ioc->chain, |
1892 | ioc->chain_depth, ioc->request_sz, ((ioc->chain_depth * | 2022 | ioc->chain_depth, ioc->request_sz, ((ioc->chain_depth * |
@@ -1895,7 +2025,7 @@ _base_allocate_memory_pools(struct MPT2SAS_ADAPTER *ioc, int sleep_flag) | |||
1895 | ioc->name, (unsigned long long) ioc->request_dma)); | 2025 | ioc->name, (unsigned long long) ioc->request_dma)); |
1896 | total_sz += sz; | 2026 | total_sz += sz; |
1897 | 2027 | ||
1898 | ioc->scsi_lookup = kcalloc(ioc->request_depth, | 2028 | ioc->scsi_lookup = kcalloc(ioc->scsiio_depth, |
1899 | sizeof(struct request_tracker), GFP_KERNEL); | 2029 | sizeof(struct request_tracker), GFP_KERNEL); |
1900 | if (!ioc->scsi_lookup) { | 2030 | if (!ioc->scsi_lookup) { |
1901 | printk(MPT2SAS_ERR_FMT "scsi_lookup: kcalloc failed\n", | 2031 | printk(MPT2SAS_ERR_FMT "scsi_lookup: kcalloc failed\n", |
@@ -1903,12 +2033,38 @@ _base_allocate_memory_pools(struct MPT2SAS_ADAPTER *ioc, int sleep_flag) | |||
1903 | goto out; | 2033 | goto out; |
1904 | } | 2034 | } |
1905 | 2035 | ||
1906 | /* initialize some bits */ | 2036 | dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "scsiio(0x%p): " |
1907 | for (i = 0; i < ioc->request_depth; i++) | 2037 | "depth(%d)\n", ioc->name, ioc->request, |
1908 | ioc->scsi_lookup[i].smid = i + 1; | 2038 | ioc->scsiio_depth)); |
2039 | |||
2040 | /* initialize hi-priority queue smid's */ | ||
2041 | ioc->hpr_lookup = kcalloc(ioc->hi_priority_depth, | ||
2042 | sizeof(struct request_tracker), GFP_KERNEL); | ||
2043 | if (!ioc->hpr_lookup) { | ||
2044 | printk(MPT2SAS_ERR_FMT "hpr_lookup: kcalloc failed\n", | ||
2045 | ioc->name); | ||
2046 | goto out; | ||
2047 | } | ||
2048 | ioc->hi_priority_smid = ioc->scsiio_depth + 1; | ||
2049 | dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "hi_priority(0x%p): " | ||
2050 | "depth(%d), start smid(%d)\n", ioc->name, ioc->hi_priority, | ||
2051 | ioc->hi_priority_depth, ioc->hi_priority_smid)); | ||
2052 | |||
2053 | /* initialize internal queue smid's */ | ||
2054 | ioc->internal_lookup = kcalloc(ioc->internal_depth, | ||
2055 | sizeof(struct request_tracker), GFP_KERNEL); | ||
2056 | if (!ioc->internal_lookup) { | ||
2057 | printk(MPT2SAS_ERR_FMT "internal_lookup: kcalloc failed\n", | ||
2058 | ioc->name); | ||
2059 | goto out; | ||
2060 | } | ||
2061 | ioc->internal_smid = ioc->hi_priority_smid + ioc->hi_priority_depth; | ||
2062 | dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "internal(0x%p): " | ||
2063 | "depth(%d), start smid(%d)\n", ioc->name, ioc->internal, | ||
2064 | ioc->internal_depth, ioc->internal_smid)); | ||
1909 | 2065 | ||
1910 | /* sense buffers, 4 byte align */ | 2066 | /* sense buffers, 4 byte align */ |
1911 | sz = ioc->request_depth * SCSI_SENSE_BUFFERSIZE; | 2067 | sz = ioc->scsiio_depth * SCSI_SENSE_BUFFERSIZE; |
1912 | ioc->sense_dma_pool = pci_pool_create("sense pool", ioc->pdev, sz, 4, | 2068 | ioc->sense_dma_pool = pci_pool_create("sense pool", ioc->pdev, sz, 4, |
1913 | 0); | 2069 | 0); |
1914 | if (!ioc->sense_dma_pool) { | 2070 | if (!ioc->sense_dma_pool) { |
@@ -1925,7 +2081,7 @@ _base_allocate_memory_pools(struct MPT2SAS_ADAPTER *ioc, int sleep_flag) | |||
1925 | } | 2081 | } |
1926 | dinitprintk(ioc, printk(MPT2SAS_INFO_FMT | 2082 | dinitprintk(ioc, printk(MPT2SAS_INFO_FMT |
1927 | "sense pool(0x%p): depth(%d), element_size(%d), pool_size" | 2083 | "sense pool(0x%p): depth(%d), element_size(%d), pool_size" |
1928 | "(%d kB)\n", ioc->name, ioc->sense, ioc->request_depth, | 2084 | "(%d kB)\n", ioc->name, ioc->sense, ioc->scsiio_depth, |
1929 | SCSI_SENSE_BUFFERSIZE, sz/1024)); | 2085 | SCSI_SENSE_BUFFERSIZE, sz/1024)); |
1930 | dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "sense_dma(0x%llx)\n", | 2086 | dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "sense_dma(0x%llx)\n", |
1931 | ioc->name, (unsigned long long)ioc->sense_dma)); | 2087 | ioc->name, (unsigned long long)ioc->sense_dma)); |
@@ -3166,6 +3322,7 @@ _base_make_ioc_operational(struct MPT2SAS_ADAPTER *ioc, int sleep_flag) | |||
3166 | int r, i; | 3322 | int r, i; |
3167 | unsigned long flags; | 3323 | unsigned long flags; |
3168 | u32 reply_address; | 3324 | u32 reply_address; |
3325 | u16 smid; | ||
3169 | 3326 | ||
3170 | dinitprintk(ioc, printk(MPT2SAS_DEBUG_FMT "%s\n", ioc->name, | 3327 | dinitprintk(ioc, printk(MPT2SAS_DEBUG_FMT "%s\n", ioc->name, |
3171 | __func__)); | 3328 | __func__)); |
@@ -3173,11 +3330,34 @@ _base_make_ioc_operational(struct MPT2SAS_ADAPTER *ioc, int sleep_flag) | |||
3173 | /* initialize the scsi lookup free list */ | 3330 | /* initialize the scsi lookup free list */ |
3174 | spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); | 3331 | spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); |
3175 | INIT_LIST_HEAD(&ioc->free_list); | 3332 | INIT_LIST_HEAD(&ioc->free_list); |
3176 | for (i = 0; i < ioc->request_depth; i++) { | 3333 | smid = 1; |
3334 | for (i = 0; i < ioc->scsiio_depth; i++, smid++) { | ||
3177 | ioc->scsi_lookup[i].cb_idx = 0xFF; | 3335 | ioc->scsi_lookup[i].cb_idx = 0xFF; |
3336 | ioc->scsi_lookup[i].smid = smid; | ||
3337 | ioc->scsi_lookup[i].scmd = NULL; | ||
3178 | list_add_tail(&ioc->scsi_lookup[i].tracker_list, | 3338 | list_add_tail(&ioc->scsi_lookup[i].tracker_list, |
3179 | &ioc->free_list); | 3339 | &ioc->free_list); |
3180 | } | 3340 | } |
3341 | |||
3342 | /* hi-priority queue */ | ||
3343 | INIT_LIST_HEAD(&ioc->hpr_free_list); | ||
3344 | smid = ioc->hi_priority_smid; | ||
3345 | for (i = 0; i < ioc->hi_priority_depth; i++, smid++) { | ||
3346 | ioc->hpr_lookup[i].cb_idx = 0xFF; | ||
3347 | ioc->hpr_lookup[i].smid = smid; | ||
3348 | list_add_tail(&ioc->hpr_lookup[i].tracker_list, | ||
3349 | &ioc->hpr_free_list); | ||
3350 | } | ||
3351 | |||
3352 | /* internal queue */ | ||
3353 | INIT_LIST_HEAD(&ioc->internal_free_list); | ||
3354 | smid = ioc->internal_smid; | ||
3355 | for (i = 0; i < ioc->internal_depth; i++, smid++) { | ||
3356 | ioc->internal_lookup[i].cb_idx = 0xFF; | ||
3357 | ioc->internal_lookup[i].smid = smid; | ||
3358 | list_add_tail(&ioc->internal_lookup[i].tracker_list, | ||
3359 | &ioc->internal_free_list); | ||
3360 | } | ||
3181 | spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags); | 3361 | spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags); |
3182 | 3362 | ||
3183 | /* initialize Reply Free Queue */ | 3363 | /* initialize Reply Free Queue */ |
@@ -3272,6 +3452,17 @@ mpt2sas_base_attach(struct MPT2SAS_ADAPTER *ioc) | |||
3272 | if (r) | 3452 | if (r) |
3273 | goto out_free_resources; | 3453 | goto out_free_resources; |
3274 | 3454 | ||
3455 | ioc->pfacts = kcalloc(ioc->facts.NumberOfPorts, | ||
3456 | sizeof(Mpi2PortFactsReply_t), GFP_KERNEL); | ||
3457 | if (!ioc->pfacts) | ||
3458 | goto out_free_resources; | ||
3459 | |||
3460 | for (i = 0 ; i < ioc->facts.NumberOfPorts; i++) { | ||
3461 | r = _base_get_port_facts(ioc, i, CAN_SLEEP); | ||
3462 | if (r) | ||
3463 | goto out_free_resources; | ||
3464 | } | ||
3465 | |||
3275 | r = _base_allocate_memory_pools(ioc, CAN_SLEEP); | 3466 | r = _base_allocate_memory_pools(ioc, CAN_SLEEP); |
3276 | if (r) | 3467 | if (r) |
3277 | goto out_free_resources; | 3468 | goto out_free_resources; |
@@ -3321,17 +3512,6 @@ mpt2sas_base_attach(struct MPT2SAS_ADAPTER *ioc) | |||
3321 | _base_unmask_events(ioc, MPI2_EVENT_IR_OPERATION_STATUS); | 3512 | _base_unmask_events(ioc, MPI2_EVENT_IR_OPERATION_STATUS); |
3322 | _base_unmask_events(ioc, MPI2_EVENT_TASK_SET_FULL); | 3513 | _base_unmask_events(ioc, MPI2_EVENT_TASK_SET_FULL); |
3323 | _base_unmask_events(ioc, MPI2_EVENT_LOG_ENTRY_ADDED); | 3514 | _base_unmask_events(ioc, MPI2_EVENT_LOG_ENTRY_ADDED); |
3324 | |||
3325 | ioc->pfacts = kcalloc(ioc->facts.NumberOfPorts, | ||
3326 | sizeof(Mpi2PortFactsReply_t), GFP_KERNEL); | ||
3327 | if (!ioc->pfacts) | ||
3328 | goto out_free_resources; | ||
3329 | |||
3330 | for (i = 0 ; i < ioc->facts.NumberOfPorts; i++) { | ||
3331 | r = _base_get_port_facts(ioc, i, CAN_SLEEP); | ||
3332 | if (r) | ||
3333 | goto out_free_resources; | ||
3334 | } | ||
3335 | r = _base_make_ioc_operational(ioc, CAN_SLEEP); | 3515 | r = _base_make_ioc_operational(ioc, CAN_SLEEP); |
3336 | if (r) | 3516 | if (r) |
3337 | goto out_free_resources; | 3517 | goto out_free_resources; |
@@ -3460,7 +3640,7 @@ _wait_for_commands_to_complete(struct MPT2SAS_ADAPTER *ioc, int sleep_flag) | |||
3460 | 3640 | ||
3461 | /* pending command count */ | 3641 | /* pending command count */ |
3462 | spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); | 3642 | spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); |
3463 | for (i = 0; i < ioc->request_depth; i++) | 3643 | for (i = 0; i < ioc->scsiio_depth; i++) |
3464 | if (ioc->scsi_lookup[i].cb_idx != 0xFF) | 3644 | if (ioc->scsi_lookup[i].cb_idx != 0xFF) |
3465 | ioc->pending_io_count++; | 3645 | ioc->pending_io_count++; |
3466 | spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags); | 3646 | spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags); |