diff options
author | Chad Dupuis <chad.dupuis@qlogic.com> | 2013-01-30 03:34:37 -0500 |
---|---|---|
committer | James Bottomley <JBottomley@Parallels.com> | 2013-02-22 06:28:49 -0500 |
commit | 8d93f5502221cc8eb420da65dc86a5ef07b038d0 (patch) | |
tree | 650bd96fe243dfbd73388b88ac8c90464f0780a3 /drivers/scsi/qla2xxx | |
parent | 6d1f6621fa12800fc84f62db9e0b7a6b623eb439 (diff) |
[SCSI] qla2xxx: Determine the number of outstanding commands based on available resources.
Base the number of outstanding requests the driver will keep track of on the
available resources instead of being hard-coded.
Signed-off-by: Chad Dupuis <chad.dupuis@qlogic.com>
Signed-off-by: Saurav Kashyap <saurav.kashyap@qlogic.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
Diffstat (limited to 'drivers/scsi/qla2xxx')
-rw-r--r-- | drivers/scsi/qla2xxx/qla_bsg.c | 2 | ||||
-rw-r--r-- | drivers/scsi/qla2xxx/qla_dbg.c | 2 | ||||
-rw-r--r-- | drivers/scsi/qla2xxx/qla_def.h | 12 | ||||
-rw-r--r-- | drivers/scsi/qla2xxx/qla_gbl.h | 3 | ||||
-rw-r--r-- | drivers/scsi/qla2xxx/qla_init.c | 54 | ||||
-rw-r--r-- | drivers/scsi/qla2xxx/qla_iocb.c | 37 | ||||
-rw-r--r-- | drivers/scsi/qla2xxx/qla_isr.c | 10 | ||||
-rw-r--r-- | drivers/scsi/qla2xxx/qla_mbx.c | 8 | ||||
-rw-r--r-- | drivers/scsi/qla2xxx/qla_mid.c | 7 | ||||
-rw-r--r-- | drivers/scsi/qla2xxx/qla_nx.c | 2 | ||||
-rw-r--r-- | drivers/scsi/qla2xxx/qla_os.c | 11 | ||||
-rw-r--r-- | drivers/scsi/qla2xxx/qla_target.c | 4 | ||||
-rw-r--r-- | drivers/scsi/qla2xxx/qla_target.h | 5 |
13 files changed, 110 insertions, 47 deletions
diff --git a/drivers/scsi/qla2xxx/qla_bsg.c b/drivers/scsi/qla2xxx/qla_bsg.c index 9f34dedcdad7..f7cb6a3fa7d4 100644 --- a/drivers/scsi/qla2xxx/qla_bsg.c +++ b/drivers/scsi/qla2xxx/qla_bsg.c | |||
@@ -1950,7 +1950,7 @@ qla24xx_bsg_timeout(struct fc_bsg_job *bsg_job) | |||
1950 | if (!req) | 1950 | if (!req) |
1951 | continue; | 1951 | continue; |
1952 | 1952 | ||
1953 | for (cnt = 1; cnt < MAX_OUTSTANDING_COMMANDS; cnt++) { | 1953 | for (cnt = 1; cnt < req->num_outstanding_cmds; cnt++) { |
1954 | sp = req->outstanding_cmds[cnt]; | 1954 | sp = req->outstanding_cmds[cnt]; |
1955 | if (sp) { | 1955 | if (sp) { |
1956 | if (((sp->type == SRB_CT_CMD) || | 1956 | if (((sp->type == SRB_CT_CMD) || |
diff --git a/drivers/scsi/qla2xxx/qla_dbg.c b/drivers/scsi/qla2xxx/qla_dbg.c index 53f9e492f9dc..2f3e7655db0d 100644 --- a/drivers/scsi/qla2xxx/qla_dbg.c +++ b/drivers/scsi/qla2xxx/qla_dbg.c | |||
@@ -11,7 +11,7 @@ | |||
11 | * ---------------------------------------------------------------------- | 11 | * ---------------------------------------------------------------------- |
12 | * | Level | Last Value Used | Holes | | 12 | * | Level | Last Value Used | Holes | |
13 | * ---------------------------------------------------------------------- | 13 | * ---------------------------------------------------------------------- |
14 | * | Module Init and Probe | 0x0125 | 0x4b,0xba,0xfa | | 14 | * | Module Init and Probe | 0x0126 | 0x4b,0xba,0xfa | |
15 | * | Mailbox commands | 0x114f | 0x111a-0x111b | | 15 | * | Mailbox commands | 0x114f | 0x111a-0x111b | |
16 | * | | | 0x112c-0x112e | | 16 | * | | | 0x112c-0x112e | |
17 | * | | | 0x113a | | 17 | * | | | 0x113a | |
diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h index 6e7727f46d43..a84bb8d6ff74 100644 --- a/drivers/scsi/qla2xxx/qla_def.h +++ b/drivers/scsi/qla2xxx/qla_def.h | |||
@@ -253,8 +253,8 @@ | |||
253 | #define LOOP_DOWN_TIME 255 /* 240 */ | 253 | #define LOOP_DOWN_TIME 255 /* 240 */ |
254 | #define LOOP_DOWN_RESET (LOOP_DOWN_TIME - 30) | 254 | #define LOOP_DOWN_RESET (LOOP_DOWN_TIME - 30) |
255 | 255 | ||
256 | /* Maximum outstanding commands in ISP queues (1-65535) */ | 256 | #define DEFAULT_OUTSTANDING_COMMANDS 1024 |
257 | #define MAX_OUTSTANDING_COMMANDS 1024 | 257 | #define MIN_OUTSTANDING_COMMANDS 128 |
258 | 258 | ||
259 | /* ISP request and response entry counts (37-65535) */ | 259 | /* ISP request and response entry counts (37-65535) */ |
260 | #define REQUEST_ENTRY_CNT_2100 128 /* Number of request entries. */ | 260 | #define REQUEST_ENTRY_CNT_2100 128 /* Number of request entries. */ |
@@ -2533,8 +2533,9 @@ struct req_que { | |||
2533 | uint16_t qos; | 2533 | uint16_t qos; |
2534 | uint16_t vp_idx; | 2534 | uint16_t vp_idx; |
2535 | struct rsp_que *rsp; | 2535 | struct rsp_que *rsp; |
2536 | srb_t *outstanding_cmds[MAX_OUTSTANDING_COMMANDS]; | 2536 | srb_t **outstanding_cmds; |
2537 | uint32_t current_outstanding_cmd; | 2537 | uint32_t current_outstanding_cmd; |
2538 | uint16_t num_outstanding_cmds; | ||
2538 | int max_q_depth; | 2539 | int max_q_depth; |
2539 | }; | 2540 | }; |
2540 | 2541 | ||
@@ -2561,7 +2562,7 @@ struct qlt_hw_data { | |||
2561 | void *target_lport_ptr; | 2562 | void *target_lport_ptr; |
2562 | struct qla_tgt_func_tmpl *tgt_ops; | 2563 | struct qla_tgt_func_tmpl *tgt_ops; |
2563 | struct qla_tgt *qla_tgt; | 2564 | struct qla_tgt *qla_tgt; |
2564 | struct qla_tgt_cmd *cmds[MAX_OUTSTANDING_COMMANDS]; | 2565 | struct qla_tgt_cmd *cmds[DEFAULT_OUTSTANDING_COMMANDS]; |
2565 | uint16_t current_handle; | 2566 | uint16_t current_handle; |
2566 | 2567 | ||
2567 | struct qla_tgt_vp_map *tgt_vp_map; | 2568 | struct qla_tgt_vp_map *tgt_vp_map; |
@@ -2887,6 +2888,7 @@ struct qla_hw_data { | |||
2887 | #define RISC_START_ADDRESS_2300 0x800 | 2888 | #define RISC_START_ADDRESS_2300 0x800 |
2888 | #define RISC_START_ADDRESS_2400 0x100000 | 2889 | #define RISC_START_ADDRESS_2400 0x100000 |
2889 | uint16_t fw_xcb_count; | 2890 | uint16_t fw_xcb_count; |
2891 | uint16_t fw_iocb_count; | ||
2890 | 2892 | ||
2891 | uint16_t fw_options[16]; /* slots: 1,2,3,10,11 */ | 2893 | uint16_t fw_options[16]; /* slots: 1,2,3,10,11 */ |
2892 | uint8_t fw_seriallink_options[4]; | 2894 | uint8_t fw_seriallink_options[4]; |
@@ -3248,8 +3250,6 @@ struct qla_tgt_vp_map { | |||
3248 | 3250 | ||
3249 | #define NVRAM_DELAY() udelay(10) | 3251 | #define NVRAM_DELAY() udelay(10) |
3250 | 3252 | ||
3251 | #define INVALID_HANDLE (MAX_OUTSTANDING_COMMANDS+1) | ||
3252 | |||
3253 | /* | 3253 | /* |
3254 | * Flash support definitions | 3254 | * Flash support definitions |
3255 | */ | 3255 | */ |
diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h index 2411d1a12b26..fba0651f678e 100644 --- a/drivers/scsi/qla2xxx/qla_gbl.h +++ b/drivers/scsi/qla2xxx/qla_gbl.h | |||
@@ -84,6 +84,9 @@ extern int qla83xx_nic_core_reset(scsi_qla_host_t *); | |||
84 | extern void qla83xx_reset_ownership(scsi_qla_host_t *); | 84 | extern void qla83xx_reset_ownership(scsi_qla_host_t *); |
85 | extern int qla2xxx_mctp_dump(scsi_qla_host_t *); | 85 | extern int qla2xxx_mctp_dump(scsi_qla_host_t *); |
86 | 86 | ||
87 | extern int | ||
88 | qla2x00_alloc_outstanding_cmds(struct qla_hw_data *, struct req_que *); | ||
89 | |||
87 | /* | 90 | /* |
88 | * Global Data in qla_os.c source file. | 91 | * Global Data in qla_os.c source file. |
89 | */ | 92 | */ |
diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c index 563eee3fa924..81e8ccacf55b 100644 --- a/drivers/scsi/qla2xxx/qla_init.c +++ b/drivers/scsi/qla2xxx/qla_init.c | |||
@@ -1559,6 +1559,47 @@ done: | |||
1559 | return rval; | 1559 | return rval; |
1560 | } | 1560 | } |
1561 | 1561 | ||
1562 | int | ||
1563 | qla2x00_alloc_outstanding_cmds(struct qla_hw_data *ha, struct req_que *req) | ||
1564 | { | ||
1565 | /* Don't try to reallocate the array */ | ||
1566 | if (req->outstanding_cmds) | ||
1567 | return QLA_SUCCESS; | ||
1568 | |||
1569 | if (!IS_FWI2_CAPABLE(ha) || (ha->mqiobase && | ||
1570 | (ql2xmultique_tag || ql2xmaxqueues > 1))) | ||
1571 | req->num_outstanding_cmds = DEFAULT_OUTSTANDING_COMMANDS; | ||
1572 | else { | ||
1573 | if (ha->fw_xcb_count <= ha->fw_iocb_count) | ||
1574 | req->num_outstanding_cmds = ha->fw_xcb_count; | ||
1575 | else | ||
1576 | req->num_outstanding_cmds = ha->fw_iocb_count; | ||
1577 | } | ||
1578 | |||
1579 | req->outstanding_cmds = kzalloc(sizeof(srb_t *) * | ||
1580 | req->num_outstanding_cmds, GFP_KERNEL); | ||
1581 | |||
1582 | if (!req->outstanding_cmds) { | ||
1583 | /* | ||
1584 | * Try to allocate a minimal size just so we can get through | ||
1585 | * initialization. | ||
1586 | */ | ||
1587 | req->num_outstanding_cmds = MIN_OUTSTANDING_COMMANDS; | ||
1588 | req->outstanding_cmds = kzalloc(sizeof(srb_t *) * | ||
1589 | req->num_outstanding_cmds, GFP_KERNEL); | ||
1590 | |||
1591 | if (!req->outstanding_cmds) { | ||
1592 | ql_log(ql_log_fatal, NULL, 0x0126, | ||
1593 | "Failed to allocate memory for " | ||
1594 | "outstanding_cmds for req_que %p.\n", req); | ||
1595 | req->num_outstanding_cmds = 0; | ||
1596 | return QLA_FUNCTION_FAILED; | ||
1597 | } | ||
1598 | } | ||
1599 | |||
1600 | return QLA_SUCCESS; | ||
1601 | } | ||
1602 | |||
1562 | /** | 1603 | /** |
1563 | * qla2x00_setup_chip() - Load and start RISC firmware. | 1604 | * qla2x00_setup_chip() - Load and start RISC firmware. |
1564 | * @ha: HA context | 1605 | * @ha: HA context |
@@ -1628,9 +1669,18 @@ enable_82xx_npiv: | |||
1628 | MIN_MULTI_ID_FABRIC - 1; | 1669 | MIN_MULTI_ID_FABRIC - 1; |
1629 | } | 1670 | } |
1630 | qla2x00_get_resource_cnts(vha, NULL, | 1671 | qla2x00_get_resource_cnts(vha, NULL, |
1631 | &ha->fw_xcb_count, NULL, NULL, | 1672 | &ha->fw_xcb_count, NULL, &ha->fw_iocb_count, |
1632 | &ha->max_npiv_vports, NULL); | 1673 | &ha->max_npiv_vports, NULL); |
1633 | 1674 | ||
1675 | /* | ||
1676 | * Allocate the array of outstanding commands | ||
1677 | * now that we know the firmware resources. | ||
1678 | */ | ||
1679 | rval = qla2x00_alloc_outstanding_cmds(ha, | ||
1680 | vha->req); | ||
1681 | if (rval != QLA_SUCCESS) | ||
1682 | goto failed; | ||
1683 | |||
1634 | if (!fw_major_version && ql2xallocfwdump | 1684 | if (!fw_major_version && ql2xallocfwdump |
1635 | && !IS_QLA82XX(ha)) | 1685 | && !IS_QLA82XX(ha)) |
1636 | qla2x00_alloc_fw_dump(vha); | 1686 | qla2x00_alloc_fw_dump(vha); |
@@ -1948,7 +1998,7 @@ qla2x00_init_rings(scsi_qla_host_t *vha) | |||
1948 | req = ha->req_q_map[que]; | 1998 | req = ha->req_q_map[que]; |
1949 | if (!req) | 1999 | if (!req) |
1950 | continue; | 2000 | continue; |
1951 | for (cnt = 1; cnt < MAX_OUTSTANDING_COMMANDS; cnt++) | 2001 | for (cnt = 1; cnt < req->num_outstanding_cmds; cnt++) |
1952 | req->outstanding_cmds[cnt] = NULL; | 2002 | req->outstanding_cmds[cnt] = NULL; |
1953 | 2003 | ||
1954 | req->current_outstanding_cmd = 1; | 2004 | req->current_outstanding_cmd = 1; |
diff --git a/drivers/scsi/qla2xxx/qla_iocb.c b/drivers/scsi/qla2xxx/qla_iocb.c index a481684479c1..6055d96f6410 100644 --- a/drivers/scsi/qla2xxx/qla_iocb.c +++ b/drivers/scsi/qla2xxx/qla_iocb.c | |||
@@ -349,14 +349,14 @@ qla2x00_start_scsi(srb_t *sp) | |||
349 | 349 | ||
350 | /* Check for room in outstanding command list. */ | 350 | /* Check for room in outstanding command list. */ |
351 | handle = req->current_outstanding_cmd; | 351 | handle = req->current_outstanding_cmd; |
352 | for (index = 1; index < MAX_OUTSTANDING_COMMANDS; index++) { | 352 | for (index = 1; index < req->num_outstanding_cmds; index++) { |
353 | handle++; | 353 | handle++; |
354 | if (handle == MAX_OUTSTANDING_COMMANDS) | 354 | if (handle == req->num_outstanding_cmds) |
355 | handle = 1; | 355 | handle = 1; |
356 | if (!req->outstanding_cmds[handle]) | 356 | if (!req->outstanding_cmds[handle]) |
357 | break; | 357 | break; |
358 | } | 358 | } |
359 | if (index == MAX_OUTSTANDING_COMMANDS) | 359 | if (index == req->num_outstanding_cmds) |
360 | goto queuing_error; | 360 | goto queuing_error; |
361 | 361 | ||
362 | /* Map the sg table so we have an accurate count of sg entries needed */ | 362 | /* Map the sg table so we have an accurate count of sg entries needed */ |
@@ -1467,16 +1467,15 @@ qla24xx_start_scsi(srb_t *sp) | |||
1467 | 1467 | ||
1468 | /* Check for room in outstanding command list. */ | 1468 | /* Check for room in outstanding command list. */ |
1469 | handle = req->current_outstanding_cmd; | 1469 | handle = req->current_outstanding_cmd; |
1470 | for (index = 1; index < MAX_OUTSTANDING_COMMANDS; index++) { | 1470 | for (index = 1; index < req->num_outstanding_cmds; index++) { |
1471 | handle++; | 1471 | handle++; |
1472 | if (handle == MAX_OUTSTANDING_COMMANDS) | 1472 | if (handle == req->num_outstanding_cmds) |
1473 | handle = 1; | 1473 | handle = 1; |
1474 | if (!req->outstanding_cmds[handle]) | 1474 | if (!req->outstanding_cmds[handle]) |
1475 | break; | 1475 | break; |
1476 | } | 1476 | } |
1477 | if (index == MAX_OUTSTANDING_COMMANDS) { | 1477 | if (index == req->num_outstanding_cmds) |
1478 | goto queuing_error; | 1478 | goto queuing_error; |
1479 | } | ||
1480 | 1479 | ||
1481 | /* Map the sg table so we have an accurate count of sg entries needed */ | 1480 | /* Map the sg table so we have an accurate count of sg entries needed */ |
1482 | if (scsi_sg_count(cmd)) { | 1481 | if (scsi_sg_count(cmd)) { |
@@ -1641,15 +1640,15 @@ qla24xx_dif_start_scsi(srb_t *sp) | |||
1641 | 1640 | ||
1642 | /* Check for room in outstanding command list. */ | 1641 | /* Check for room in outstanding command list. */ |
1643 | handle = req->current_outstanding_cmd; | 1642 | handle = req->current_outstanding_cmd; |
1644 | for (index = 1; index < MAX_OUTSTANDING_COMMANDS; index++) { | 1643 | for (index = 1; index < req->num_outstanding_cmds; index++) { |
1645 | handle++; | 1644 | handle++; |
1646 | if (handle == MAX_OUTSTANDING_COMMANDS) | 1645 | if (handle == req->num_outstanding_cmds) |
1647 | handle = 1; | 1646 | handle = 1; |
1648 | if (!req->outstanding_cmds[handle]) | 1647 | if (!req->outstanding_cmds[handle]) |
1649 | break; | 1648 | break; |
1650 | } | 1649 | } |
1651 | 1650 | ||
1652 | if (index == MAX_OUTSTANDING_COMMANDS) | 1651 | if (index == req->num_outstanding_cmds) |
1653 | goto queuing_error; | 1652 | goto queuing_error; |
1654 | 1653 | ||
1655 | /* Compute number of required data segments */ | 1654 | /* Compute number of required data segments */ |
@@ -1822,14 +1821,14 @@ qla2x00_alloc_iocbs(scsi_qla_host_t *vha, srb_t *sp) | |||
1822 | 1821 | ||
1823 | /* Check for room in outstanding command list. */ | 1822 | /* Check for room in outstanding command list. */ |
1824 | handle = req->current_outstanding_cmd; | 1823 | handle = req->current_outstanding_cmd; |
1825 | for (index = 1; index < MAX_OUTSTANDING_COMMANDS; index++) { | 1824 | for (index = 1; req->num_outstanding_cmds; index++) { |
1826 | handle++; | 1825 | handle++; |
1827 | if (handle == MAX_OUTSTANDING_COMMANDS) | 1826 | if (handle == req->num_outstanding_cmds) |
1828 | handle = 1; | 1827 | handle = 1; |
1829 | if (!req->outstanding_cmds[handle]) | 1828 | if (!req->outstanding_cmds[handle]) |
1830 | break; | 1829 | break; |
1831 | } | 1830 | } |
1832 | if (index == MAX_OUTSTANDING_COMMANDS) { | 1831 | if (index == req->num_outstanding_cmds) { |
1833 | ql_log(ql_log_warn, vha, 0x700b, | 1832 | ql_log(ql_log_warn, vha, 0x700b, |
1834 | "No room on outstanding cmd array.\n"); | 1833 | "No room on outstanding cmd array.\n"); |
1835 | goto queuing_error; | 1834 | goto queuing_error; |
@@ -2263,14 +2262,14 @@ qla82xx_start_scsi(srb_t *sp) | |||
2263 | 2262 | ||
2264 | /* Check for room in outstanding command list. */ | 2263 | /* Check for room in outstanding command list. */ |
2265 | handle = req->current_outstanding_cmd; | 2264 | handle = req->current_outstanding_cmd; |
2266 | for (index = 1; index < MAX_OUTSTANDING_COMMANDS; index++) { | 2265 | for (index = 1; index < req->num_outstanding_cmds; index++) { |
2267 | handle++; | 2266 | handle++; |
2268 | if (handle == MAX_OUTSTANDING_COMMANDS) | 2267 | if (handle == req->num_outstanding_cmds) |
2269 | handle = 1; | 2268 | handle = 1; |
2270 | if (!req->outstanding_cmds[handle]) | 2269 | if (!req->outstanding_cmds[handle]) |
2271 | break; | 2270 | break; |
2272 | } | 2271 | } |
2273 | if (index == MAX_OUTSTANDING_COMMANDS) | 2272 | if (index == req->num_outstanding_cmds) |
2274 | goto queuing_error; | 2273 | goto queuing_error; |
2275 | 2274 | ||
2276 | /* Map the sg table so we have an accurate count of sg entries needed */ | 2275 | /* Map the sg table so we have an accurate count of sg entries needed */ |
@@ -2767,15 +2766,15 @@ qla2x00_start_bidir(srb_t *sp, struct scsi_qla_host *vha, uint32_t tot_dsds) | |||
2767 | 2766 | ||
2768 | /* Check for room in outstanding command list. */ | 2767 | /* Check for room in outstanding command list. */ |
2769 | handle = req->current_outstanding_cmd; | 2768 | handle = req->current_outstanding_cmd; |
2770 | for (index = 1; index < MAX_OUTSTANDING_COMMANDS; index++) { | 2769 | for (index = 1; index < req->num_outstanding_cmds; index++) { |
2771 | handle++; | 2770 | handle++; |
2772 | if (handle == MAX_OUTSTANDING_COMMANDS) | 2771 | if (handle == req->num_outstanding_cmds) |
2773 | handle = 1; | 2772 | handle = 1; |
2774 | if (!req->outstanding_cmds[handle]) | 2773 | if (!req->outstanding_cmds[handle]) |
2775 | break; | 2774 | break; |
2776 | } | 2775 | } |
2777 | 2776 | ||
2778 | if (index == MAX_OUTSTANDING_COMMANDS) { | 2777 | if (index == req->num_outstanding_cmds) { |
2779 | rval = EXT_STATUS_BUSY; | 2778 | rval = EXT_STATUS_BUSY; |
2780 | goto queuing_error; | 2779 | goto queuing_error; |
2781 | } | 2780 | } |
diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c index 873c82014b16..45130738c2bf 100644 --- a/drivers/scsi/qla2xxx/qla_isr.c +++ b/drivers/scsi/qla2xxx/qla_isr.c | |||
@@ -1029,7 +1029,7 @@ qla2x00_process_completed_request(struct scsi_qla_host *vha, | |||
1029 | struct qla_hw_data *ha = vha->hw; | 1029 | struct qla_hw_data *ha = vha->hw; |
1030 | 1030 | ||
1031 | /* Validate handle. */ | 1031 | /* Validate handle. */ |
1032 | if (index >= MAX_OUTSTANDING_COMMANDS) { | 1032 | if (index >= req->num_outstanding_cmds) { |
1033 | ql_log(ql_log_warn, vha, 0x3014, | 1033 | ql_log(ql_log_warn, vha, 0x3014, |
1034 | "Invalid SCSI command index (%x).\n", index); | 1034 | "Invalid SCSI command index (%x).\n", index); |
1035 | 1035 | ||
@@ -1067,7 +1067,7 @@ qla2x00_get_sp_from_handle(scsi_qla_host_t *vha, const char *func, | |||
1067 | uint16_t index; | 1067 | uint16_t index; |
1068 | 1068 | ||
1069 | index = LSW(pkt->handle); | 1069 | index = LSW(pkt->handle); |
1070 | if (index >= MAX_OUTSTANDING_COMMANDS) { | 1070 | if (index >= req->num_outstanding_cmds) { |
1071 | ql_log(ql_log_warn, vha, 0x5031, | 1071 | ql_log(ql_log_warn, vha, 0x5031, |
1072 | "Invalid command index (%x).\n", index); | 1072 | "Invalid command index (%x).\n", index); |
1073 | if (IS_QLA82XX(ha)) | 1073 | if (IS_QLA82XX(ha)) |
@@ -1740,7 +1740,7 @@ qla25xx_process_bidir_status_iocb(scsi_qla_host_t *vha, void *pkt, | |||
1740 | sts24 = (struct sts_entry_24xx *) pkt; | 1740 | sts24 = (struct sts_entry_24xx *) pkt; |
1741 | 1741 | ||
1742 | /* Validate handle. */ | 1742 | /* Validate handle. */ |
1743 | if (index >= MAX_OUTSTANDING_COMMANDS) { | 1743 | if (index >= req->num_outstanding_cmds) { |
1744 | ql_log(ql_log_warn, vha, 0x70af, | 1744 | ql_log(ql_log_warn, vha, 0x70af, |
1745 | "Invalid SCSI completion handle 0x%x.\n", index); | 1745 | "Invalid SCSI completion handle 0x%x.\n", index); |
1746 | set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); | 1746 | set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); |
@@ -1910,9 +1910,9 @@ qla2x00_status_entry(scsi_qla_host_t *vha, struct rsp_que *rsp, void *pkt) | |||
1910 | req = ha->req_q_map[que]; | 1910 | req = ha->req_q_map[que]; |
1911 | 1911 | ||
1912 | /* Validate handle. */ | 1912 | /* Validate handle. */ |
1913 | if (handle < MAX_OUTSTANDING_COMMANDS) { | 1913 | if (handle < req->num_outstanding_cmds) |
1914 | sp = req->outstanding_cmds[handle]; | 1914 | sp = req->outstanding_cmds[handle]; |
1915 | } else | 1915 | else |
1916 | sp = NULL; | 1916 | sp = NULL; |
1917 | 1917 | ||
1918 | if (sp == NULL) { | 1918 | if (sp == NULL) { |
diff --git a/drivers/scsi/qla2xxx/qla_mbx.c b/drivers/scsi/qla2xxx/qla_mbx.c index 68c55eaa318c..319b0f2dad23 100644 --- a/drivers/scsi/qla2xxx/qla_mbx.c +++ b/drivers/scsi/qla2xxx/qla_mbx.c | |||
@@ -900,13 +900,13 @@ qla2x00_abort_command(srb_t *sp) | |||
900 | "Entered %s.\n", __func__); | 900 | "Entered %s.\n", __func__); |
901 | 901 | ||
902 | spin_lock_irqsave(&ha->hardware_lock, flags); | 902 | spin_lock_irqsave(&ha->hardware_lock, flags); |
903 | for (handle = 1; handle < MAX_OUTSTANDING_COMMANDS; handle++) { | 903 | for (handle = 1; handle < req->num_outstanding_cmds; handle++) { |
904 | if (req->outstanding_cmds[handle] == sp) | 904 | if (req->outstanding_cmds[handle] == sp) |
905 | break; | 905 | break; |
906 | } | 906 | } |
907 | spin_unlock_irqrestore(&ha->hardware_lock, flags); | 907 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
908 | 908 | ||
909 | if (handle == MAX_OUTSTANDING_COMMANDS) { | 909 | if (handle == req->num_outstanding_cmds) { |
910 | /* command not found */ | 910 | /* command not found */ |
911 | return QLA_FUNCTION_FAILED; | 911 | return QLA_FUNCTION_FAILED; |
912 | } | 912 | } |
@@ -2535,12 +2535,12 @@ qla24xx_abort_command(srb_t *sp) | |||
2535 | "Entered %s.\n", __func__); | 2535 | "Entered %s.\n", __func__); |
2536 | 2536 | ||
2537 | spin_lock_irqsave(&ha->hardware_lock, flags); | 2537 | spin_lock_irqsave(&ha->hardware_lock, flags); |
2538 | for (handle = 1; handle < MAX_OUTSTANDING_COMMANDS; handle++) { | 2538 | for (handle = 1; handle < req->num_outstanding_cmds; handle++) { |
2539 | if (req->outstanding_cmds[handle] == sp) | 2539 | if (req->outstanding_cmds[handle] == sp) |
2540 | break; | 2540 | break; |
2541 | } | 2541 | } |
2542 | spin_unlock_irqrestore(&ha->hardware_lock, flags); | 2542 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
2543 | if (handle == MAX_OUTSTANDING_COMMANDS) { | 2543 | if (handle == req->num_outstanding_cmds) { |
2544 | /* Command not found. */ | 2544 | /* Command not found. */ |
2545 | return QLA_FUNCTION_FAILED; | 2545 | return QLA_FUNCTION_FAILED; |
2546 | } | 2546 | } |
diff --git a/drivers/scsi/qla2xxx/qla_mid.c b/drivers/scsi/qla2xxx/qla_mid.c index 20fd974f903a..95cb6e78bbcd 100644 --- a/drivers/scsi/qla2xxx/qla_mid.c +++ b/drivers/scsi/qla2xxx/qla_mid.c | |||
@@ -523,6 +523,7 @@ qla25xx_free_req_que(struct scsi_qla_host *vha, struct req_que *req) | |||
523 | clear_bit(que_id, ha->req_qid_map); | 523 | clear_bit(que_id, ha->req_qid_map); |
524 | mutex_unlock(&ha->vport_lock); | 524 | mutex_unlock(&ha->vport_lock); |
525 | } | 525 | } |
526 | kfree(req->outstanding_cmds); | ||
526 | kfree(req); | 527 | kfree(req); |
527 | req = NULL; | 528 | req = NULL; |
528 | } | 529 | } |
@@ -649,6 +650,10 @@ qla25xx_create_req_que(struct qla_hw_data *ha, uint16_t options, | |||
649 | goto que_failed; | 650 | goto que_failed; |
650 | } | 651 | } |
651 | 652 | ||
653 | ret = qla2x00_alloc_outstanding_cmds(ha, req); | ||
654 | if (ret != QLA_SUCCESS) | ||
655 | goto que_failed; | ||
656 | |||
652 | mutex_lock(&ha->vport_lock); | 657 | mutex_lock(&ha->vport_lock); |
653 | que_id = find_first_zero_bit(ha->req_qid_map, ha->max_req_queues); | 658 | que_id = find_first_zero_bit(ha->req_qid_map, ha->max_req_queues); |
654 | if (que_id >= ha->max_req_queues) { | 659 | if (que_id >= ha->max_req_queues) { |
@@ -685,7 +690,7 @@ qla25xx_create_req_que(struct qla_hw_data *ha, uint16_t options, | |||
685 | "options=0x%x.\n", req->options); | 690 | "options=0x%x.\n", req->options); |
686 | ql_dbg(ql_dbg_init, base_vha, 0x00dd, | 691 | ql_dbg(ql_dbg_init, base_vha, 0x00dd, |
687 | "options=0x%x.\n", req->options); | 692 | "options=0x%x.\n", req->options); |
688 | for (cnt = 1; cnt < MAX_OUTSTANDING_COMMANDS; cnt++) | 693 | for (cnt = 1; cnt < req->num_outstanding_cmds; cnt++) |
689 | req->outstanding_cmds[cnt] = NULL; | 694 | req->outstanding_cmds[cnt] = NULL; |
690 | req->current_outstanding_cmd = 1; | 695 | req->current_outstanding_cmd = 1; |
691 | 696 | ||
diff --git a/drivers/scsi/qla2xxx/qla_nx.c b/drivers/scsi/qla2xxx/qla_nx.c index 3e3f593bada3..042368b9a2e7 100644 --- a/drivers/scsi/qla2xxx/qla_nx.c +++ b/drivers/scsi/qla2xxx/qla_nx.c | |||
@@ -3629,7 +3629,7 @@ qla82xx_chip_reset_cleanup(scsi_qla_host_t *vha) | |||
3629 | req = ha->req_q_map[que]; | 3629 | req = ha->req_q_map[que]; |
3630 | if (!req) | 3630 | if (!req) |
3631 | continue; | 3631 | continue; |
3632 | for (cnt = 1; cnt < MAX_OUTSTANDING_COMMANDS; cnt++) { | 3632 | for (cnt = 1; cnt < req->num_outstanding_cmds; cnt++) { |
3633 | sp = req->outstanding_cmds[cnt]; | 3633 | sp = req->outstanding_cmds[cnt]; |
3634 | if (sp) { | 3634 | if (sp) { |
3635 | if (!sp->u.scmd.ctx || | 3635 | if (!sp->u.scmd.ctx || |
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index 10d23f8b7036..53efffce13a2 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c | |||
@@ -360,6 +360,9 @@ static void qla2x00_free_req_que(struct qla_hw_data *ha, struct req_que *req) | |||
360 | (req->length + 1) * sizeof(request_t), | 360 | (req->length + 1) * sizeof(request_t), |
361 | req->ring, req->dma); | 361 | req->ring, req->dma); |
362 | 362 | ||
363 | if (req) | ||
364 | kfree(req->outstanding_cmds); | ||
365 | |||
363 | kfree(req); | 366 | kfree(req); |
364 | req = NULL; | 367 | req = NULL; |
365 | } | 368 | } |
@@ -1010,7 +1013,7 @@ qla2x00_eh_wait_for_pending_commands(scsi_qla_host_t *vha, unsigned int t, | |||
1010 | spin_lock_irqsave(&ha->hardware_lock, flags); | 1013 | spin_lock_irqsave(&ha->hardware_lock, flags); |
1011 | req = vha->req; | 1014 | req = vha->req; |
1012 | for (cnt = 1; status == QLA_SUCCESS && | 1015 | for (cnt = 1; status == QLA_SUCCESS && |
1013 | cnt < MAX_OUTSTANDING_COMMANDS; cnt++) { | 1016 | cnt < req->num_outstanding_cmds; cnt++) { |
1014 | sp = req->outstanding_cmds[cnt]; | 1017 | sp = req->outstanding_cmds[cnt]; |
1015 | if (!sp) | 1018 | if (!sp) |
1016 | continue; | 1019 | continue; |
@@ -1337,7 +1340,9 @@ qla2x00_abort_all_cmds(scsi_qla_host_t *vha, int res) | |||
1337 | req = ha->req_q_map[que]; | 1340 | req = ha->req_q_map[que]; |
1338 | if (!req) | 1341 | if (!req) |
1339 | continue; | 1342 | continue; |
1340 | for (cnt = 1; cnt < MAX_OUTSTANDING_COMMANDS; cnt++) { | 1343 | if (!req->outstanding_cmds) |
1344 | continue; | ||
1345 | for (cnt = 1; cnt < req->num_outstanding_cmds; cnt++) { | ||
1341 | sp = req->outstanding_cmds[cnt]; | 1346 | sp = req->outstanding_cmds[cnt]; |
1342 | if (sp) { | 1347 | if (sp) { |
1343 | req->outstanding_cmds[cnt] = NULL; | 1348 | req->outstanding_cmds[cnt] = NULL; |
@@ -4733,7 +4738,7 @@ qla2x00_timer(scsi_qla_host_t *vha) | |||
4733 | cpu_flags); | 4738 | cpu_flags); |
4734 | req = ha->req_q_map[0]; | 4739 | req = ha->req_q_map[0]; |
4735 | for (index = 1; | 4740 | for (index = 1; |
4736 | index < MAX_OUTSTANDING_COMMANDS; | 4741 | index < req->num_outstanding_cmds; |
4737 | index++) { | 4742 | index++) { |
4738 | fc_port_t *sfcp; | 4743 | fc_port_t *sfcp; |
4739 | 4744 | ||
diff --git a/drivers/scsi/qla2xxx/qla_target.c b/drivers/scsi/qla2xxx/qla_target.c index 80f4b849e2b0..aa2e86917a0a 100644 --- a/drivers/scsi/qla2xxx/qla_target.c +++ b/drivers/scsi/qla2xxx/qla_target.c | |||
@@ -1570,7 +1570,7 @@ static inline uint32_t qlt_make_handle(struct scsi_qla_host *vha) | |||
1570 | /* always increment cmd handle */ | 1570 | /* always increment cmd handle */ |
1571 | do { | 1571 | do { |
1572 | ++h; | 1572 | ++h; |
1573 | if (h > MAX_OUTSTANDING_COMMANDS) | 1573 | if (h > DEFAULT_OUTSTANDING_COMMANDS) |
1574 | h = 1; /* 0 is QLA_TGT_NULL_HANDLE */ | 1574 | h = 1; /* 0 is QLA_TGT_NULL_HANDLE */ |
1575 | if (h == ha->tgt.current_handle) { | 1575 | if (h == ha->tgt.current_handle) { |
1576 | ql_dbg(ql_dbg_tgt, vha, 0xe04e, | 1576 | ql_dbg(ql_dbg_tgt, vha, 0xe04e, |
@@ -2441,7 +2441,7 @@ static struct qla_tgt_cmd *qlt_ctio_to_cmd(struct scsi_qla_host *vha, | |||
2441 | return NULL; | 2441 | return NULL; |
2442 | } | 2442 | } |
2443 | /* handle-1 is actually used */ | 2443 | /* handle-1 is actually used */ |
2444 | if (unlikely(handle > MAX_OUTSTANDING_COMMANDS)) { | 2444 | if (unlikely(handle > DEFAULT_OUTSTANDING_COMMANDS)) { |
2445 | ql_dbg(ql_dbg_tgt, vha, 0xe052, | 2445 | ql_dbg(ql_dbg_tgt, vha, 0xe052, |
2446 | "qla_target(%d): Wrong handle %x received\n", | 2446 | "qla_target(%d): Wrong handle %x received\n", |
2447 | vha->vp_idx, handle); | 2447 | vha->vp_idx, handle); |
diff --git a/drivers/scsi/qla2xxx/qla_target.h b/drivers/scsi/qla2xxx/qla_target.h index bad749561ec2..fc61d6ab925e 100644 --- a/drivers/scsi/qla2xxx/qla_target.h +++ b/drivers/scsi/qla2xxx/qla_target.h | |||
@@ -60,8 +60,9 @@ | |||
60 | * multi-complete should come to the tgt driver or be handled there by qla2xxx | 60 | * multi-complete should come to the tgt driver or be handled there by qla2xxx |
61 | */ | 61 | */ |
62 | #define CTIO_COMPLETION_HANDLE_MARK BIT_29 | 62 | #define CTIO_COMPLETION_HANDLE_MARK BIT_29 |
63 | #if (CTIO_COMPLETION_HANDLE_MARK <= MAX_OUTSTANDING_COMMANDS) | 63 | #if (CTIO_COMPLETION_HANDLE_MARK <= DEFAULT_OUTSTANDING_COMMANDS) |
64 | #error "CTIO_COMPLETION_HANDLE_MARK not larger than MAX_OUTSTANDING_COMMANDS" | 64 | #error "CTIO_COMPLETION_HANDLE_MARK not larger than " |
65 | "DEFAULT_OUTSTANDING_COMMANDS" | ||
65 | #endif | 66 | #endif |
66 | #define HANDLE_IS_CTIO_COMP(h) (h & CTIO_COMPLETION_HANDLE_MARK) | 67 | #define HANDLE_IS_CTIO_COMP(h) (h & CTIO_COMPLETION_HANDLE_MARK) |
67 | 68 | ||