aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi
diff options
context:
space:
mode:
authorKashyap, Desai <kashyap.desai@lsi.com>2009-09-14 01:32:48 -0400
committerJames Bottomley <James.Bottomley@suse.de>2009-10-02 10:48:26 -0400
commit595bb0bd62edb28a965993d90e0fa1285560ce53 (patch)
tree0447a980d9c99e21ab1c9bac0b7f893da75d18e3 /drivers/scsi
parent19d3ebe3d5c4d56c8309a64561d99e7920a35fbb (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')
-rw-r--r--drivers/scsi/mpt2sas/mpt2sas_base.c302
-rw-r--r--drivers/scsi/mpt2sas/mpt2sas_base.h49
-rw-r--r--drivers/scsi/mpt2sas/mpt2sas_ctl.c4
-rw-r--r--drivers/scsi/mpt2sas/mpt2sas_scsih.c89
4 files changed, 307 insertions, 137 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 @@
63static MPT_CALLBACK mpt_callbacks[MPT_MAX_CALLBACKS]; 63static 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
68static int max_queue_depth = -1; 68static int max_queue_depth = -1;
69module_param(max_queue_depth, int, 0); 69module_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 */
659static 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 */
1202dma_addr_t
1203mpt2sas_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 */
1317u16
1318mpt2sas_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 */
1350u16
1351mpt2sas_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
1302mpt2sas_base_free_smid(struct MPT2SAS_ADAPTER *ioc, u16 smid) 1381mpt2sas_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);
diff --git a/drivers/scsi/mpt2sas/mpt2sas_base.h b/drivers/scsi/mpt2sas/mpt2sas_base.h
index 3de37b702468..91132626f4c5 100644
--- a/drivers/scsi/mpt2sas/mpt2sas_base.h
+++ b/drivers/scsi/mpt2sas/mpt2sas_base.h
@@ -264,6 +264,13 @@ struct _internal_cmd {
264 * SAS Topology Structures 264 * SAS Topology Structures
265 */ 265 */
266 266
267#define MPTSAS_STATE_TR_SEND 0x0001
268#define MPTSAS_STATE_TR_COMPLETE 0x0002
269#define MPTSAS_STATE_CNTRL_SEND 0x0004
270#define MPTSAS_STATE_CNTRL_COMPLETE 0x0008
271
272#define MPT2SAS_REQ_SAS_CNTRL 0x0010
273
267/** 274/**
268 * struct _sas_device - attached device information 275 * struct _sas_device - attached device information
269 * @list: sas device list 276 * @list: sas device list
@@ -510,8 +517,9 @@ typedef void (*MPT_ADD_SGE)(void *paddr, u32 flags_length, dma_addr_t dma_addr);
510 * @config_page_sz: config page size 517 * @config_page_sz: config page size
511 * @config_page: reserve memory for config page payload 518 * @config_page: reserve memory for config page payload
512 * @config_page_dma: 519 * @config_page_dma:
520 * @hba_queue_depth: hba request queue depth
513 * @sge_size: sg element size for either 32/64 bit 521 * @sge_size: sg element size for either 32/64 bit
514 * @request_depth: hba request queue depth 522 * @scsiio_depth: SCSI_IO queue depth
515 * @request_sz: per request frame size 523 * @request_sz: per request frame size
516 * @request: pool of request frames 524 * @request: pool of request frames
517 * @request_dma: 525 * @request_dma:
@@ -528,6 +536,18 @@ typedef void (*MPT_ADD_SGE)(void *paddr, u32 flags_length, dma_addr_t dma_addr);
528 * @chains_needed_per_io: max chains per io 536 * @chains_needed_per_io: max chains per io
529 * @chain_offset_value_for_main_message: location 1st sg in main 537 * @chain_offset_value_for_main_message: location 1st sg in main
530 * @chain_depth: total chains allocated 538 * @chain_depth: total chains allocated
539 * @hi_priority_smid:
540 * @hi_priority:
541 * @hi_priority_dma:
542 * @hi_priority_depth:
543 * @hpr_lookup:
544 * @hpr_free_list:
545 * @internal_smid:
546 * @internal:
547 * @internal_dma:
548 * @internal_depth:
549 * @internal_lookup:
550 * @internal_free_list:
531 * @sense: pool of sense 551 * @sense: pool of sense
532 * @sense_dma: 552 * @sense_dma:
533 * @sense_dma_pool: 553 * @sense_dma_pool:
@@ -643,9 +663,10 @@ struct MPT2SAS_ADAPTER {
643 void *config_page; 663 void *config_page;
644 dma_addr_t config_page_dma; 664 dma_addr_t config_page_dma;
645 665
646 /* request */ 666 /* scsiio request */
667 u16 hba_queue_depth;
647 u16 sge_size; 668 u16 sge_size;
648 u16 request_depth; 669 u16 scsiio_depth;
649 u16 request_sz; 670 u16 request_sz;
650 u8 *request; 671 u8 *request;
651 dma_addr_t request_dma; 672 dma_addr_t request_dma;
@@ -665,6 +686,22 @@ struct MPT2SAS_ADAPTER {
665 u16 chain_offset_value_for_main_message; 686 u16 chain_offset_value_for_main_message;
666 u16 chain_depth; 687 u16 chain_depth;
667 688
689 /* hi-priority queue */
690 u16 hi_priority_smid;
691 u8 *hi_priority;
692 dma_addr_t hi_priority_dma;
693 u16 hi_priority_depth;
694 struct request_tracker *hpr_lookup;
695 struct list_head hpr_free_list;
696
697 /* internal queue */
698 u16 internal_smid;
699 u8 *internal;
700 dma_addr_t internal_dma;
701 u16 internal_depth;
702 struct request_tracker *internal_lookup;
703 struct list_head internal_free_list;
704
668 /* sense */ 705 /* sense */
669 u8 *sense; 706 u8 *sense;
670 dma_addr_t sense_dma; 707 dma_addr_t sense_dma;
@@ -720,9 +757,13 @@ int mpt2sas_base_hard_reset_handler(struct MPT2SAS_ADAPTER *ioc, int sleep_flag,
720void *mpt2sas_base_get_msg_frame(struct MPT2SAS_ADAPTER *ioc, u16 smid); 757void *mpt2sas_base_get_msg_frame(struct MPT2SAS_ADAPTER *ioc, u16 smid);
721void *mpt2sas_base_get_sense_buffer(struct MPT2SAS_ADAPTER *ioc, u16 smid); 758void *mpt2sas_base_get_sense_buffer(struct MPT2SAS_ADAPTER *ioc, u16 smid);
722void mpt2sas_base_build_zero_len_sge(struct MPT2SAS_ADAPTER *ioc, void *paddr); 759void mpt2sas_base_build_zero_len_sge(struct MPT2SAS_ADAPTER *ioc, void *paddr);
723dma_addr_t mpt2sas_base_get_msg_frame_dma(struct MPT2SAS_ADAPTER *ioc, u16 smid);
724dma_addr_t mpt2sas_base_get_sense_buffer_dma(struct MPT2SAS_ADAPTER *ioc, u16 smid); 760dma_addr_t mpt2sas_base_get_sense_buffer_dma(struct MPT2SAS_ADAPTER *ioc, u16 smid);
725 761
762/* hi-priority queue */
763u16 mpt2sas_base_get_smid_hpr(struct MPT2SAS_ADAPTER *ioc, u8 cb_idx);
764u16 mpt2sas_base_get_smid_scsiio(struct MPT2SAS_ADAPTER *ioc, u8 cb_idx,
765 struct scsi_cmnd *scmd);
766
726u16 mpt2sas_base_get_smid(struct MPT2SAS_ADAPTER *ioc, u8 cb_idx); 767u16 mpt2sas_base_get_smid(struct MPT2SAS_ADAPTER *ioc, u8 cb_idx);
727void mpt2sas_base_free_smid(struct MPT2SAS_ADAPTER *ioc, u16 smid); 768void mpt2sas_base_free_smid(struct MPT2SAS_ADAPTER *ioc, u16 smid);
728void mpt2sas_base_put_smid_scsi_io(struct MPT2SAS_ADAPTER *ioc, u16 smid, 769void mpt2sas_base_put_smid_scsi_io(struct MPT2SAS_ADAPTER *ioc, u16 smid,
diff --git a/drivers/scsi/mpt2sas/mpt2sas_ctl.c b/drivers/scsi/mpt2sas/mpt2sas_ctl.c
index 37961504aaae..466e2f42367f 100644
--- a/drivers/scsi/mpt2sas/mpt2sas_ctl.c
+++ b/drivers/scsi/mpt2sas/mpt2sas_ctl.c
@@ -509,7 +509,7 @@ _ctl_set_task_mid(struct MPT2SAS_ADAPTER *ioc, struct mpt2_ioctl_command *karg,
509 509
510 handle = le16_to_cpu(tm_request->DevHandle); 510 handle = le16_to_cpu(tm_request->DevHandle);
511 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); 511 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags);
512 for (i = ioc->request_depth; i && !found; i--) { 512 for (i = ioc->scsiio_depth; i && !found; i--) {
513 scmd = ioc->scsi_lookup[i - 1].scmd; 513 scmd = ioc->scsi_lookup[i - 1].scmd;
514 if (scmd == NULL || scmd->device == NULL || 514 if (scmd == NULL || scmd->device == NULL ||
515 scmd->device->hostdata == NULL) 515 scmd->device->hostdata == NULL)
@@ -616,7 +616,7 @@ _ctl_do_mpt_command(struct MPT2SAS_ADAPTER *ioc,
616 printk(MPT2SAS_INFO_FMT "%s: ioc is operational\n", 616 printk(MPT2SAS_INFO_FMT "%s: ioc is operational\n",
617 ioc->name, __func__); 617 ioc->name, __func__);
618 618
619 smid = mpt2sas_base_get_smid(ioc, ioc->ctl_cb_idx); 619 smid = mpt2sas_base_get_smid_scsiio(ioc, ioc->ctl_cb_idx, NULL);
620 if (!smid) { 620 if (!smid) {
621 printk(MPT2SAS_ERR_FMT "%s: failed obtaining a smid\n", 621 printk(MPT2SAS_ERR_FMT "%s: failed obtaining a smid\n",
622 ioc->name, __func__); 622 ioc->name, __func__);
diff --git a/drivers/scsi/mpt2sas/mpt2sas_scsih.c b/drivers/scsi/mpt2sas/mpt2sas_scsih.c
index 10d99086ed46..d4b003a618a1 100644
--- a/drivers/scsi/mpt2sas/mpt2sas_scsih.c
+++ b/drivers/scsi/mpt2sas/mpt2sas_scsih.c
@@ -762,66 +762,16 @@ _scsih_is_end_device(u32 device_info)
762} 762}
763 763
764/** 764/**
765 * _scsih_scsi_lookup_get - returns scmd entry 765 * mptscsih_get_scsi_lookup - returns scmd entry
766 * @ioc: per adapter object 766 * @ioc: per adapter object
767 * @smid: system request message index 767 * @smid: system request message index
768 * Context: This function will acquire ioc->scsi_lookup_lock.
769 * 768 *
770 * Returns the smid stored scmd pointer. 769 * Returns the smid stored scmd pointer.
771 */ 770 */
772static struct scsi_cmnd * 771static struct scsi_cmnd *
773_scsih_scsi_lookup_get(struct MPT2SAS_ADAPTER *ioc, u16 smid) 772_scsih_scsi_lookup_get(struct MPT2SAS_ADAPTER *ioc, u16 smid)
774{ 773{
775 unsigned long flags; 774 return ioc->scsi_lookup[smid - 1].scmd;
776 struct scsi_cmnd *scmd;
777
778 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags);
779 scmd = ioc->scsi_lookup[smid - 1].scmd;
780 spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags);
781 return scmd;
782}
783
784/**
785 * mptscsih_getclear_scsi_lookup - returns scmd entry
786 * @ioc: per adapter object
787 * @smid: system request message index
788 * Context: This function will acquire ioc->scsi_lookup_lock.
789 *
790 * Returns the smid stored scmd pointer, as well as clearing the scmd pointer.
791 */
792static struct scsi_cmnd *
793_scsih_scsi_lookup_getclear(struct MPT2SAS_ADAPTER *ioc, u16 smid)
794{
795 unsigned long flags;
796 struct scsi_cmnd *scmd;
797
798 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags);
799 scmd = ioc->scsi_lookup[smid - 1].scmd;
800 ioc->scsi_lookup[smid - 1].scmd = NULL;
801 spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags);
802 return scmd;
803}
804
805/**
806 * _scsih_scsi_lookup_set - updates scmd entry in lookup
807 * @ioc: per adapter object
808 * @smid: system request message index
809 * @scmd: pointer to scsi command object
810 * Context: This function will acquire ioc->scsi_lookup_lock.
811 *
812 * This will save scmd pointer in the scsi_lookup array.
813 *
814 * Return nothing.
815 */
816static void
817_scsih_scsi_lookup_set(struct MPT2SAS_ADAPTER *ioc, u16 smid,
818 struct scsi_cmnd *scmd)
819{
820 unsigned long flags;
821
822 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags);
823 ioc->scsi_lookup[smid - 1].scmd = scmd;
824 spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags);
825} 775}
826 776
827/** 777/**
@@ -844,9 +794,9 @@ _scsih_scsi_lookup_find_by_scmd(struct MPT2SAS_ADAPTER *ioc, struct scsi_cmnd
844 794
845 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); 795 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags);
846 smid = 0; 796 smid = 0;
847 for (i = 0; i < ioc->request_depth; i++) { 797 for (i = 0; i < ioc->scsiio_depth; i++) {
848 if (ioc->scsi_lookup[i].scmd == scmd) { 798 if (ioc->scsi_lookup[i].scmd == scmd) {
849 smid = i + 1; 799 smid = ioc->scsi_lookup[i].smid;
850 goto out; 800 goto out;
851 } 801 }
852 } 802 }
@@ -875,7 +825,7 @@ _scsih_scsi_lookup_find_by_target(struct MPT2SAS_ADAPTER *ioc, int id,
875 825
876 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); 826 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags);
877 found = 0; 827 found = 0;
878 for (i = 0 ; i < ioc->request_depth; i++) { 828 for (i = 0 ; i < ioc->scsiio_depth; i++) {
879 if (ioc->scsi_lookup[i].scmd && 829 if (ioc->scsi_lookup[i].scmd &&
880 (ioc->scsi_lookup[i].scmd->device->id == id && 830 (ioc->scsi_lookup[i].scmd->device->id == id &&
881 ioc->scsi_lookup[i].scmd->device->channel == channel)) { 831 ioc->scsi_lookup[i].scmd->device->channel == channel)) {
@@ -909,7 +859,7 @@ _scsih_scsi_lookup_find_by_lun(struct MPT2SAS_ADAPTER *ioc, int id,
909 859
910 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); 860 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags);
911 found = 0; 861 found = 0;
912 for (i = 0 ; i < ioc->request_depth; i++) { 862 for (i = 0 ; i < ioc->scsiio_depth; i++) {
913 if (ioc->scsi_lookup[i].scmd && 863 if (ioc->scsi_lookup[i].scmd &&
914 (ioc->scsi_lookup[i].scmd->device->id == id && 864 (ioc->scsi_lookup[i].scmd->device->id == id &&
915 ioc->scsi_lookup[i].scmd->device->channel == channel && 865 ioc->scsi_lookup[i].scmd->device->channel == channel &&
@@ -1119,7 +1069,7 @@ _scsih_change_queue_depth(struct scsi_device *sdev, int qdepth)
1119} 1069}
1120 1070
1121/** 1071/**
1122 * _scsih_change_queue_depth - changing device queue tag type 1072 * _scsih_change_queue_type - changing device queue tag type
1123 * @sdev: scsi device struct 1073 * @sdev: scsi device struct
1124 * @tag_type: requested tag type 1074 * @tag_type: requested tag type
1125 * 1075 *
@@ -1822,7 +1772,7 @@ mpt2sas_scsih_issue_tm(struct MPT2SAS_ADAPTER *ioc, u16 handle, uint lun,
1822 goto issue_host_reset; 1772 goto issue_host_reset;
1823 } 1773 }
1824 1774
1825 smid = mpt2sas_base_get_smid(ioc, ioc->tm_cb_idx); 1775 smid = mpt2sas_base_get_smid_hpr(ioc, ioc->tm_cb_idx);
1826 if (!smid) { 1776 if (!smid) {
1827 printk(MPT2SAS_ERR_FMT "%s: failed obtaining a smid\n", 1777 printk(MPT2SAS_ERR_FMT "%s: failed obtaining a smid\n",
1828 ioc->name, __func__); 1778 ioc->name, __func__);
@@ -1830,7 +1780,8 @@ mpt2sas_scsih_issue_tm(struct MPT2SAS_ADAPTER *ioc, u16 handle, uint lun,
1830 } 1780 }
1831 1781
1832 dtmprintk(ioc, printk(MPT2SAS_INFO_FMT "sending tm: handle(0x%04x)," 1782 dtmprintk(ioc, printk(MPT2SAS_INFO_FMT "sending tm: handle(0x%04x),"
1833 " task_type(0x%02x), smid(%d)\n", ioc->name, handle, type, smid)); 1783 " task_type(0x%02x), smid(%d)\n", ioc->name, handle, type,
1784 smid_task));
1834 ioc->tm_cmds.status = MPT2_CMD_PENDING; 1785 ioc->tm_cmds.status = MPT2_CMD_PENDING;
1835 mpi_request = mpt2sas_base_get_msg_frame(ioc, smid); 1786 mpi_request = mpt2sas_base_get_msg_frame(ioc, smid);
1836 ioc->tm_cmds.smid = smid; 1787 ioc->tm_cmds.smid = smid;
@@ -2082,7 +2033,7 @@ _scsih_target_reset(struct scsi_cmnd *scmd)
2082} 2033}
2083 2034
2084/** 2035/**
2085 * _scsih_abort - eh threads main host reset routine 2036 * _scsih_host_reset - eh threads main host reset routine
2086 * @sdev: scsi device struct 2037 * @sdev: scsi device struct
2087 * 2038 *
2088 * Returns SUCCESS if command aborted else FAILED 2039 * Returns SUCCESS if command aborted else FAILED
@@ -2440,8 +2391,8 @@ _scsih_flush_running_cmds(struct MPT2SAS_ADAPTER *ioc)
2440 u16 smid; 2391 u16 smid;
2441 u16 count = 0; 2392 u16 count = 0;
2442 2393
2443 for (smid = 1; smid <= ioc->request_depth; smid++) { 2394 for (smid = 1; smid <= ioc->scsiio_depth; smid++) {
2444 scmd = _scsih_scsi_lookup_getclear(ioc, smid); 2395 scmd = _scsih_scsi_lookup_get(ioc, smid);
2445 if (!scmd) 2396 if (!scmd)
2446 continue; 2397 continue;
2447 count++; 2398 count++;
@@ -2623,7 +2574,7 @@ _scsih_qcmd(struct scsi_cmnd *scmd, void (*done)(struct scsi_cmnd *))
2623 if ((sas_device_priv_data->flags & MPT_DEVICE_TLR_ON)) 2574 if ((sas_device_priv_data->flags & MPT_DEVICE_TLR_ON))
2624 mpi_control |= MPI2_SCSIIO_CONTROL_TLR_ON; 2575 mpi_control |= MPI2_SCSIIO_CONTROL_TLR_ON;
2625 2576
2626 smid = mpt2sas_base_get_smid(ioc, ioc->scsi_io_cb_idx); 2577 smid = mpt2sas_base_get_smid_scsiio(ioc, ioc->scsi_io_cb_idx, scmd);
2627 if (!smid) { 2578 if (!smid) {
2628 printk(MPT2SAS_ERR_FMT "%s: failed obtaining a smid\n", 2579 printk(MPT2SAS_ERR_FMT "%s: failed obtaining a smid\n",
2629 ioc->name, __func__); 2580 ioc->name, __func__);
@@ -2665,7 +2616,6 @@ _scsih_qcmd(struct scsi_cmnd *scmd, void (*done)(struct scsi_cmnd *))
2665 } 2616 }
2666 } 2617 }
2667 2618
2668 _scsih_scsi_lookup_set(ioc, smid, scmd);
2669 mpt2sas_base_put_smid_scsi_io(ioc, smid, 2619 mpt2sas_base_put_smid_scsi_io(ioc, smid,
2670 sas_device_priv_data->sas_target->handle); 2620 sas_device_priv_data->sas_target->handle);
2671 return 0; 2621 return 0;
@@ -2984,7 +2934,7 @@ _scsih_io_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 msix_index, u32 reply)
2984 u32 response_code; 2934 u32 response_code;
2985 2935
2986 mpi_reply = mpt2sas_base_get_reply_virt_addr(ioc, reply); 2936 mpi_reply = mpt2sas_base_get_reply_virt_addr(ioc, reply);
2987 scmd = _scsih_scsi_lookup_getclear(ioc, smid); 2937 scmd = _scsih_scsi_lookup_get(ioc, smid);
2988 if (scmd == NULL) 2938 if (scmd == NULL)
2989 return; 2939 return;
2990 2940
@@ -3406,9 +3356,8 @@ _scsih_expander_add(struct MPT2SAS_ADAPTER *ioc, u16 handle)
3406 } 3356 }
3407 } 3357 }
3408 3358
3409 sas_address = le64_to_cpu(expander_pg0.SASAddress);
3410
3411 spin_lock_irqsave(&ioc->sas_node_lock, flags); 3359 spin_lock_irqsave(&ioc->sas_node_lock, flags);
3360 sas_address = le64_to_cpu(expander_pg0.SASAddress);
3412 sas_expander = mpt2sas_scsih_expander_find_by_sas_address(ioc, 3361 sas_expander = mpt2sas_scsih_expander_find_by_sas_address(ioc,
3413 sas_address); 3362 sas_address);
3414 spin_unlock_irqrestore(&ioc->sas_node_lock, flags); 3363 spin_unlock_irqrestore(&ioc->sas_node_lock, flags);
@@ -4081,7 +4030,7 @@ _scsih_sas_broadcast_primative_event(struct MPT2SAS_ADAPTER *ioc,
4081 termination_count = 0; 4030 termination_count = 0;
4082 query_count = 0; 4031 query_count = 0;
4083 mpi_reply = ioc->tm_cmds.reply; 4032 mpi_reply = ioc->tm_cmds.reply;
4084 for (smid = 1; smid <= ioc->request_depth; smid++) { 4033 for (smid = 1; smid <= ioc->scsiio_depth; smid++) {
4085 scmd = _scsih_scsi_lookup_get(ioc, smid); 4034 scmd = _scsih_scsi_lookup_get(ioc, smid);
4086 if (!scmd) 4035 if (!scmd)
4087 continue; 4036 continue;
@@ -4145,8 +4094,8 @@ _scsih_sas_discovery_event(struct MPT2SAS_ADAPTER *ioc,
4145 (event_data->ReasonCode == MPI2_EVENT_SAS_DISC_RC_STARTED) ? 4094 (event_data->ReasonCode == MPI2_EVENT_SAS_DISC_RC_STARTED) ?
4146 "start" : "stop"); 4095 "start" : "stop");
4147 if (event_data->DiscoveryStatus) 4096 if (event_data->DiscoveryStatus)
4148 printk(MPT2SAS_DEBUG_FMT ", discovery_status(0x%08x)", 4097 printk("discovery_status(0x%08x)",
4149 ioc->name, le32_to_cpu(event_data->DiscoveryStatus)); 4098 le32_to_cpu(event_data->DiscoveryStatus));
4150 printk("\n"); 4099 printk("\n");
4151 } 4100 }
4152#endif 4101#endif