aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/qla2xxx
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/qla2xxx')
-rw-r--r--drivers/scsi/qla2xxx/qla_dbg.c3
-rw-r--r--drivers/scsi/qla2xxx/qla_def.h60
-rw-r--r--drivers/scsi/qla2xxx/qla_gbl.h14
-rw-r--r--drivers/scsi/qla2xxx/qla_init.c33
-rw-r--r--drivers/scsi/qla2xxx/qla_iocb.c3
-rw-r--r--drivers/scsi/qla2xxx/qla_isr.c18
-rw-r--r--drivers/scsi/qla2xxx/qla_mbx.c6
-rw-r--r--drivers/scsi/qla2xxx/qla_os.c173
8 files changed, 53 insertions, 257 deletions
diff --git a/drivers/scsi/qla2xxx/qla_dbg.c b/drivers/scsi/qla2xxx/qla_dbg.c
index c4cd4ac414c4..329d1a1fa547 100644
--- a/drivers/scsi/qla2xxx/qla_dbg.c
+++ b/drivers/scsi/qla2xxx/qla_dbg.c
@@ -1063,8 +1063,7 @@ qla2x00_print_scsi_cmd(struct scsi_cmnd * cmd)
1063 return; 1063 return;
1064 1064
1065 printk(" sp flags=0x%x\n", sp->flags); 1065 printk(" sp flags=0x%x\n", sp->flags);
1066 printk(" r_start=0x%lx, u_start=0x%lx, f_start=0x%lx, state=%d\n", 1066 printk(" state=%d\n", sp->state);
1067 sp->r_start, sp->u_start, sp->f_start, sp->state);
1068} 1067}
1069 1068
1070#if defined(QL_DEBUG_ROUTINES) 1069#if defined(QL_DEBUG_ROUTINES)
diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
index 7d47b8d92047..83a32e403e29 100644
--- a/drivers/scsi/qla2xxx/qla_def.h
+++ b/drivers/scsi/qla2xxx/qla_def.h
@@ -252,31 +252,12 @@ typedef struct srb {
252 /* Request state */ 252 /* Request state */
253 uint16_t state; 253 uint16_t state;
254 254
255 /* Timing counts. */
256 unsigned long e_start; /* Start of extend timeout */
257 unsigned long r_start; /* Start of request */
258 unsigned long u_start; /* When sent to RISC */
259 unsigned long f_start; /* When placed in FO queue*/
260
261 /* Single transfer DMA context */ 255 /* Single transfer DMA context */
262 dma_addr_t dma_handle; 256 dma_addr_t dma_handle;
263 257
264 uint32_t request_sense_length; 258 uint32_t request_sense_length;
265 uint8_t *request_sense_ptr; 259 uint8_t *request_sense_ptr;
266 260
267 int ext_history;
268
269 /* Suspend delay */
270 int delay;
271
272 /* Raw completion info for use by failover ? */
273 uint8_t fo_retry_cnt; /* Retry count this request */
274 uint8_t err_id; /* error id */
275#define SRB_ERR_PORT 1 /* Request failed -- "port down" */
276#define SRB_ERR_LOOP 2 /* Request failed -- "loop down" */
277#define SRB_ERR_DEVICE 3 /* Request failed -- "device error" */
278#define SRB_ERR_OTHER 4
279
280 /* SRB magic number */ 261 /* SRB magic number */
281 uint16_t magic; 262 uint16_t magic;
282#define SRB_MAGIC 0x10CB 263#define SRB_MAGIC 0x10CB
@@ -2082,23 +2063,8 @@ typedef struct scsi_qla_host {
2082 uint32_t current_outstanding_cmd; 2063 uint32_t current_outstanding_cmd;
2083 srb_t *status_srb; /* Status continuation entry. */ 2064 srb_t *status_srb; /* Status continuation entry. */
2084 2065
2085 unsigned long last_irq_cpu; /* cpu where we got our last irq */
2086
2087 uint16_t revision; 2066 uint16_t revision;
2088 uint8_t ports; 2067 uint8_t ports;
2089 u_long actthreads;
2090 u_long ipreq_cnt;
2091 u_long qthreads;
2092
2093 uint32_t total_isr_cnt; /* Interrupt count */
2094 uint32_t total_isp_aborts; /* controller err cnt */
2095 uint32_t total_lip_cnt; /* LIP cnt */
2096 uint32_t total_dev_errs; /* device error cnt */
2097 uint32_t total_ios; /* IO cnt */
2098 uint64_t total_bytes; /* xfr byte cnt */
2099 uint32_t total_mbx_timeout; /* mailbox timeout cnt */
2100 uint32_t total_loop_resync; /* loop resyn cnt */
2101 uint32_t dropped_frame_error_cnt;
2102 2068
2103 /* ISP configuration data. */ 2069 /* ISP configuration data. */
2104 uint16_t loop_id; /* Host adapter loop id */ 2070 uint16_t loop_id; /* Host adapter loop id */
@@ -2124,8 +2090,6 @@ typedef struct scsi_qla_host {
2124#define P2P_LOOP 3 2090#define P2P_LOOP 3
2125 2091
2126 uint8_t marker_needed; 2092 uint8_t marker_needed;
2127 uint8_t sns_retry_cnt;
2128 uint8_t mem_err;
2129 2093
2130 uint8_t interrupts_on; 2094 uint8_t interrupts_on;
2131 2095
@@ -2138,16 +2102,11 @@ typedef struct scsi_qla_host {
2138 uint16_t nvram_base; 2102 uint16_t nvram_base;
2139 2103
2140 uint16_t loop_reset_delay; 2104 uint16_t loop_reset_delay;
2141 uint16_t minimum_timeout;
2142 uint8_t retry_count; 2105 uint8_t retry_count;
2143 uint8_t login_timeout; 2106 uint8_t login_timeout;
2144 uint16_t r_a_tov; 2107 uint16_t r_a_tov;
2145 int port_down_retry_count; 2108 int port_down_retry_count;
2146 uint8_t loop_down_timeout;
2147 uint8_t mbx_count; 2109 uint8_t mbx_count;
2148 uint16_t max_probe_luns;
2149 uint16_t max_luns;
2150 uint16_t max_targets;
2151 uint16_t last_loop_id; 2110 uint16_t last_loop_id;
2152 2111
2153 uint32_t login_retry_count; 2112 uint32_t login_retry_count;
@@ -2181,7 +2140,6 @@ typedef struct scsi_qla_host {
2181 uint8_t dpc_active; /* DPC routine is active */ 2140 uint8_t dpc_active; /* DPC routine is active */
2182 2141
2183 /* Timeout timers. */ 2142 /* Timeout timers. */
2184 uint8_t queue_restart_timer;
2185 uint8_t loop_down_abort_time; /* port down timer */ 2143 uint8_t loop_down_abort_time; /* port down timer */
2186 atomic_t loop_down_timer; /* loop down timer */ 2144 atomic_t loop_down_timer; /* loop down timer */
2187 uint8_t link_down_timeout; /* link down timeout */ 2145 uint8_t link_down_timeout; /* link down timeout */
@@ -2230,18 +2188,6 @@ typedef struct scsi_qla_host {
2230 2188
2231 mbx_cmd_t mc; 2189 mbx_cmd_t mc;
2232 2190
2233 uint8_t *cmdline;
2234
2235 uint32_t failover_type;
2236 uint32_t failback_delay;
2237 unsigned long cfg_flags;
2238#define CFG_ACTIVE 0 /* CFG during a failover, event update, or ioctl */
2239#define CFG_FAILOVER 1 /* CFG during path change */
2240
2241 uint32_t binding_type;
2242#define BIND_BY_PORT_NAME 0
2243#define BIND_BY_PORT_ID 1
2244
2245 /* Basic firmware related information. */ 2191 /* Basic firmware related information. */
2246 struct qla_board_info *brd_info; 2192 struct qla_board_info *brd_info;
2247 uint16_t fw_major_version; 2193 uint16_t fw_major_version;
@@ -2274,12 +2220,6 @@ typedef struct scsi_qla_host {
2274 uint8_t nvram_version; 2220 uint8_t nvram_version;
2275 uint32_t isp_abort_cnt; 2221 uint32_t isp_abort_cnt;
2276 2222
2277 /* Adapter I/O statistics for failover */
2278 uint64_t IosRequested;
2279 uint64_t BytesRequested;
2280 uint64_t IosExecuted;
2281 uint64_t BytesExecuted;
2282
2283 /* Needed for BEACON */ 2223 /* Needed for BEACON */
2284 uint16_t beacon_blink_led; 2224 uint16_t beacon_blink_led;
2285 uint16_t beacon_green_on; 2225 uint16_t beacon_green_on;
diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
index 2efec6c24d60..164866b199e6 100644
--- a/drivers/scsi/qla2xxx/qla_gbl.h
+++ b/drivers/scsi/qla2xxx/qla_gbl.h
@@ -53,27 +53,13 @@ extern void qla2x00_reg_remote_port(scsi_qla_host_t *, fc_port_t *);
53 */ 53 */
54extern char qla2x00_version_str[]; 54extern char qla2x00_version_str[];
55 55
56extern int num_hosts;
57extern int apiHBAInstance;
58
59extern struct _qla2x00stats qla2x00_stats;
60extern int ql2xretrycount;
61extern int ql2xlogintimeout; 56extern int ql2xlogintimeout;
62extern int qlport_down_retry; 57extern int qlport_down_retry;
63extern int ql2xmaxqdepth;
64extern int displayConfig;
65extern int ql2xplogiabsentdevice; 58extern int ql2xplogiabsentdevice;
66extern int ql2xenablezio; 59extern int ql2xenablezio;
67extern int ql2xintrdelaytimer; 60extern int ql2xintrdelaytimer;
68extern int ql2xloginretrycount; 61extern int ql2xloginretrycount;
69 62
70extern int ConfigRequired;
71
72extern int Bind;
73extern int ql2xsuspendcount;
74#if defined(MODULE)
75extern char *ql2xopts;
76#endif
77extern void qla2x00_sp_compl(scsi_qla_host_t *, srb_t *); 63extern void qla2x00_sp_compl(scsi_qla_host_t *, srb_t *);
78 64
79extern char *qla2x00_get_fw_version_str(struct scsi_qla_host *, char *); 65extern char *qla2x00_get_fw_version_str(struct scsi_qla_host *, char *);
diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
index 0387005fcb6d..7629558eba25 100644
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -85,9 +85,7 @@ qla2x00_initialize_adapter(scsi_qla_host_t *ha)
85 atomic_set(&ha->loop_down_timer, LOOP_DOWN_TIME); 85 atomic_set(&ha->loop_down_timer, LOOP_DOWN_TIME);
86 atomic_set(&ha->loop_state, LOOP_DOWN); 86 atomic_set(&ha->loop_state, LOOP_DOWN);
87 ha->device_flags = 0; 87 ha->device_flags = 0;
88 ha->sns_retry_cnt = 0;
89 ha->dpc_flags = 0; 88 ha->dpc_flags = 0;
90 ha->failback_delay = 0;
91 ha->flags.management_server_logged_in = 0; 89 ha->flags.management_server_logged_in = 0;
92 ha->marker_needed = 0; 90 ha->marker_needed = 0;
93 ha->mbx_flags = 0; 91 ha->mbx_flags = 0;
@@ -171,8 +169,6 @@ check_fw_ready_again:
171 169
172 if (wait_time == 0) 170 if (wait_time == 0)
173 rval = QLA_FUNCTION_FAILED; 171 rval = QLA_FUNCTION_FAILED;
174 if (ha->mem_err)
175 restart_risc = 1;
176 } else if (ha->device_flags & DFLG_NO_CABLE) 172 } else if (ha->device_flags & DFLG_NO_CABLE)
177 /* If no cable, then all is good. */ 173 /* If no cable, then all is good. */
178 rval = QLA_SUCCESS; 174 rval = QLA_SUCCESS;
@@ -1410,13 +1406,8 @@ qla2x00_nvram_config(scsi_qla_host_t *ha)
1410 /* Set minimum RATOV to 200 tenths of a second. */ 1406 /* Set minimum RATOV to 200 tenths of a second. */
1411 ha->r_a_tov = 200; 1407 ha->r_a_tov = 200;
1412 1408
1413 ha->minimum_timeout =
1414 (ha->login_timeout * ha->retry_count) + nv->port_down_retry_count;
1415 ha->loop_reset_delay = nv->reset_delay; 1409 ha->loop_reset_delay = nv->reset_delay;
1416 1410
1417 /* Will get the value from NVRAM. */
1418 ha->loop_down_timeout = LOOP_DOWN_TIMEOUT;
1419
1420 /* Link Down Timeout = 0: 1411 /* Link Down Timeout = 0:
1421 * 1412 *
1422 * When Port Down timer expires we will start returning 1413 * When Port Down timer expires we will start returning
@@ -1429,18 +1420,13 @@ qla2x00_nvram_config(scsi_qla_host_t *ha)
1429 */ 1420 */
1430 if (nv->link_down_timeout == 0) { 1421 if (nv->link_down_timeout == 0) {
1431 ha->loop_down_abort_time = 1422 ha->loop_down_abort_time =
1432 (LOOP_DOWN_TIME - ha->loop_down_timeout); 1423 (LOOP_DOWN_TIME - LOOP_DOWN_TIMEOUT);
1433 } else { 1424 } else {
1434 ha->link_down_timeout = nv->link_down_timeout; 1425 ha->link_down_timeout = nv->link_down_timeout;
1435 ha->loop_down_abort_time = 1426 ha->loop_down_abort_time =
1436 (LOOP_DOWN_TIME - ha->link_down_timeout); 1427 (LOOP_DOWN_TIME - ha->link_down_timeout);
1437 } 1428 }
1438 1429
1439 ha->max_luns = MAX_LUNS;
1440 ha->max_probe_luns = le16_to_cpu(nv->max_luns_per_target);
1441 if (ha->max_probe_luns == 0)
1442 ha->max_probe_luns = MIN_LUNS;
1443
1444 /* 1430 /*
1445 * Need enough time to try and get the port back. 1431 * Need enough time to try and get the port back.
1446 */ 1432 */
@@ -1457,16 +1443,6 @@ qla2x00_nvram_config(scsi_qla_host_t *ha)
1457 if (ql2xloginretrycount) 1443 if (ql2xloginretrycount)
1458 ha->login_retry_count = ql2xloginretrycount; 1444 ha->login_retry_count = ql2xloginretrycount;
1459 1445
1460 ha->binding_type = Bind;
1461 if (ha->binding_type != BIND_BY_PORT_NAME &&
1462 ha->binding_type != BIND_BY_PORT_ID) {
1463 qla_printk(KERN_WARNING, ha,
1464 "Invalid binding type specified (%d), "
1465 "defaulting to BIND_BY_PORT_NAME!!!\n", ha->binding_type);
1466
1467 ha->binding_type = BIND_BY_PORT_NAME;
1468 }
1469
1470 icb->lun_enables = __constant_cpu_to_le16(0); 1446 icb->lun_enables = __constant_cpu_to_le16(0);
1471 icb->command_resource_count = 0; 1447 icb->command_resource_count = 0;
1472 icb->immediate_notify_resource_count = 0; 1448 icb->immediate_notify_resource_count = 0;
@@ -1578,7 +1554,6 @@ qla2x00_configure_loop(scsi_qla_host_t *ha)
1578 */ 1554 */
1579 clear_bit(LOCAL_LOOP_UPDATE, &ha->dpc_flags); 1555 clear_bit(LOCAL_LOOP_UPDATE, &ha->dpc_flags);
1580 clear_bit(RSCN_UPDATE, &ha->dpc_flags); 1556 clear_bit(RSCN_UPDATE, &ha->dpc_flags);
1581 ha->mem_err = 0 ;
1582 1557
1583 /* Determine what we need to do */ 1558 /* Determine what we need to do */
1584 if (ha->current_topology == ISP_CFG_FL && 1559 if (ha->current_topology == ISP_CFG_FL &&
@@ -2707,7 +2682,6 @@ qla2x00_loop_resync(scsi_qla_host_t *ha)
2707 rval = QLA_SUCCESS; 2682 rval = QLA_SUCCESS;
2708 2683
2709 atomic_set(&ha->loop_state, LOOP_UPDATE); 2684 atomic_set(&ha->loop_state, LOOP_UPDATE);
2710 qla2x00_stats.loop_resync++;
2711 clear_bit(ISP_ABORT_RETRY, &ha->dpc_flags); 2685 clear_bit(ISP_ABORT_RETRY, &ha->dpc_flags);
2712 if (ha->flags.online) { 2686 if (ha->flags.online) {
2713 if (!(rval = qla2x00_fw_ready(ha))) { 2687 if (!(rval = qla2x00_fw_ready(ha))) {
@@ -2786,9 +2760,6 @@ qla2x00_abort_isp(scsi_qla_host_t *ha)
2786 if (ha->flags.online) { 2760 if (ha->flags.online) {
2787 ha->flags.online = 0; 2761 ha->flags.online = 0;
2788 clear_bit(ISP_ABORT_NEEDED, &ha->dpc_flags); 2762 clear_bit(ISP_ABORT_NEEDED, &ha->dpc_flags);
2789 qla2x00_stats.ispAbort++;
2790 ha->total_isp_aborts++; /* used by ioctl */
2791 ha->sns_retry_cnt = 0;
2792 2763
2793 qla_printk(KERN_INFO, ha, 2764 qla_printk(KERN_INFO, ha,
2794 "Performing ISP error recovery - ha= %p.\n", ha); 2765 "Performing ISP error recovery - ha= %p.\n", ha);
@@ -2810,8 +2781,6 @@ qla2x00_abort_isp(scsi_qla_host_t *ha)
2810 sp = ha->outstanding_cmds[cnt]; 2781 sp = ha->outstanding_cmds[cnt];
2811 if (sp) { 2782 if (sp) {
2812 ha->outstanding_cmds[cnt] = NULL; 2783 ha->outstanding_cmds[cnt] = NULL;
2813 if (ha->actthreads)
2814 ha->actthreads--;
2815 sp->flags = 0; 2784 sp->flags = 0;
2816 sp->cmd->result = DID_RESET << 16; 2785 sp->cmd->result = DID_RESET << 16;
2817 sp->cmd->host_scribble = (unsigned char *)NULL; 2786 sp->cmd->host_scribble = (unsigned char *)NULL;
diff --git a/drivers/scsi/qla2xxx/qla_iocb.c b/drivers/scsi/qla2xxx/qla_iocb.c
index af964bb3d870..ecaf9f83b2d4 100644
--- a/drivers/scsi/qla2xxx/qla_iocb.c
+++ b/drivers/scsi/qla2xxx/qla_iocb.c
@@ -433,11 +433,8 @@ qla2x00_start_scsi(srb_t *sp)
433 } else 433 } else
434 ha->request_ring_ptr++; 434 ha->request_ring_ptr++;
435 435
436 ha->actthreads++;
437 ha->total_ios++;
438 sp->flags |= SRB_DMA_VALID; 436 sp->flags |= SRB_DMA_VALID;
439 sp->state = SRB_ACTIVE_STATE; 437 sp->state = SRB_ACTIVE_STATE;
440 sp->u_start = jiffies;
441 438
442 /* Set chip new ring index. */ 439 /* Set chip new ring index. */
443 WRT_REG_WORD(ISP_REQ_Q_IN(ha, reg), ha->req_ring_index); 440 WRT_REG_WORD(ISP_REQ_Q_IN(ha, reg), ha->req_ring_index);
diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c
index 6792cfae56e2..e7a8b74157a5 100644
--- a/drivers/scsi/qla2xxx/qla_isr.c
+++ b/drivers/scsi/qla2xxx/qla_isr.c
@@ -91,9 +91,6 @@ qla2100_intr_handler(int irq, void *dev_id, struct pt_regs *regs)
91 } 91 }
92 spin_unlock_irqrestore(&ha->hardware_lock, flags); 92 spin_unlock_irqrestore(&ha->hardware_lock, flags);
93 93
94 ha->last_irq_cpu = _smp_processor_id();
95 ha->total_isr_cnt++;
96
97 if (test_bit(MBX_INTR_WAIT, &ha->mbx_cmd_flags) && 94 if (test_bit(MBX_INTR_WAIT, &ha->mbx_cmd_flags) &&
98 (status & MBX_INTERRUPT) && ha->flags.mbox_int) { 95 (status & MBX_INTERRUPT) && ha->flags.mbox_int) {
99 spin_lock_irqsave(&ha->mbx_reg_lock, flags); 96 spin_lock_irqsave(&ha->mbx_reg_lock, flags);
@@ -200,9 +197,6 @@ qla2300_intr_handler(int irq, void *dev_id, struct pt_regs *regs)
200 } 197 }
201 spin_unlock_irqrestore(&ha->hardware_lock, flags); 198 spin_unlock_irqrestore(&ha->hardware_lock, flags);
202 199
203 ha->last_irq_cpu = _smp_processor_id();
204 ha->total_isr_cnt++;
205
206 if (test_bit(MBX_INTR_WAIT, &ha->mbx_cmd_flags) && 200 if (test_bit(MBX_INTR_WAIT, &ha->mbx_cmd_flags) &&
207 (status & MBX_INTERRUPT) && ha->flags.mbox_int) { 201 (status & MBX_INTERRUPT) && ha->flags.mbox_int) {
208 spin_lock_irqsave(&ha->mbx_reg_lock, flags); 202 spin_lock_irqsave(&ha->mbx_reg_lock, flags);
@@ -417,7 +411,6 @@ qla2x00_async_event(scsi_qla_host_t *ha, uint32_t mbx)
417 /* Update AEN queue. */ 411 /* Update AEN queue. */
418 qla2x00_enqueue_aen(ha, MBA_LIP_OCCURRED, NULL); 412 qla2x00_enqueue_aen(ha, MBA_LIP_OCCURRED, NULL);
419 413
420 ha->total_lip_cnt++;
421 break; 414 break;
422 415
423 case MBA_LOOP_UP: /* Loop Up Event */ 416 case MBA_LOOP_UP: /* Loop Up Event */
@@ -485,7 +478,6 @@ qla2x00_async_event(scsi_qla_host_t *ha, uint32_t mbx)
485 /* Update AEN queue. */ 478 /* Update AEN queue. */
486 qla2x00_enqueue_aen(ha, MBA_LIP_RESET, NULL); 479 qla2x00_enqueue_aen(ha, MBA_LIP_RESET, NULL);
487 480
488 ha->total_lip_cnt++;
489 break; 481 break;
490 482
491 case MBA_POINT_TO_POINT: /* Point-to-Point */ 483 case MBA_POINT_TO_POINT: /* Point-to-Point */
@@ -695,14 +687,11 @@ qla2x00_process_completed_request(struct scsi_qla_host *ha, uint32_t index)
695 /* Free outstanding command slot. */ 687 /* Free outstanding command slot. */
696 ha->outstanding_cmds[index] = NULL; 688 ha->outstanding_cmds[index] = NULL;
697 689
698 if (ha->actthreads)
699 ha->actthreads--;
700 CMD_COMPL_STATUS(sp->cmd) = 0L; 690 CMD_COMPL_STATUS(sp->cmd) = 0L;
701 CMD_SCSI_STATUS(sp->cmd) = 0L; 691 CMD_SCSI_STATUS(sp->cmd) = 0L;
702 692
703 /* Save ISP completion status */ 693 /* Save ISP completion status */
704 sp->cmd->result = DID_OK << 16; 694 sp->cmd->result = DID_OK << 16;
705 sp->fo_retry_cnt = 0;
706 qla2x00_sp_compl(ha, sp); 695 qla2x00_sp_compl(ha, sp);
707 } else { 696 } else {
708 DEBUG2(printk("scsi(%ld): Invalid ISP SCSI completion handle\n", 697 DEBUG2(printk("scsi(%ld): Invalid ISP SCSI completion handle\n",
@@ -865,9 +854,6 @@ qla2x00_status_entry(scsi_qla_host_t *ha, sts_entry_t *pkt)
865 return; 854 return;
866 } 855 }
867 856
868 if (ha->actthreads)
869 ha->actthreads--;
870
871 comp_status = le16_to_cpu(pkt->comp_status); 857 comp_status = le16_to_cpu(pkt->comp_status);
872 /* Mask of reserved bits 12-15, before we examine the scsi status */ 858 /* Mask of reserved bits 12-15, before we examine the scsi status */
873 scsi_status = le16_to_cpu(pkt->scsi_status) & SS_MASK; 859 scsi_status = le16_to_cpu(pkt->scsi_status) & SS_MASK;
@@ -1026,7 +1012,6 @@ qla2x00_status_entry(scsi_qla_host_t *ha, sts_entry_t *pkt)
1026 cp->request_bufflen)); 1012 cp->request_bufflen));
1027 1013
1028 cp->result = DID_BUS_BUSY << 16; 1014 cp->result = DID_BUS_BUSY << 16;
1029 ha->dropped_frame_error_cnt++;
1030 break; 1015 break;
1031 } 1016 }
1032 1017
@@ -1233,8 +1218,7 @@ qla2x00_error_entry(scsi_qla_host_t *ha, sts_entry_t *pkt)
1233 if (sp) { 1218 if (sp) {
1234 /* Free outstanding command slot. */ 1219 /* Free outstanding command slot. */
1235 ha->outstanding_cmds[pkt->handle] = NULL; 1220 ha->outstanding_cmds[pkt->handle] = NULL;
1236 if (ha->actthreads) 1221
1237 ha->actthreads--;
1238 /* Bad payload or header */ 1222 /* Bad payload or header */
1239 if (pkt->entry_status & 1223 if (pkt->entry_status &
1240 (RF_INV_E_ORDER | RF_INV_E_COUNT | 1224 (RF_INV_E_ORDER | RF_INV_E_COUNT |
diff --git a/drivers/scsi/qla2xxx/qla_mbx.c b/drivers/scsi/qla2xxx/qla_mbx.c
index 15f6acaca305..eeaec7c50e6a 100644
--- a/drivers/scsi/qla2xxx/qla_mbx.c
+++ b/drivers/scsi/qla2xxx/qla_mbx.c
@@ -219,10 +219,8 @@ qla2x00_mailbox_command(scsi_qla_host_t *ha, mbx_cmd_t *mcp)
219 ha->flags.mbox_int = 0; 219 ha->flags.mbox_int = 0;
220 clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags); 220 clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags);
221 221
222 if (ha->mailbox_out[0] != MBS_COMMAND_COMPLETE) { 222 if (ha->mailbox_out[0] != MBS_COMMAND_COMPLETE)
223 qla2x00_stats.mboxerr++;
224 rval = QLA_FUNCTION_FAILED; 223 rval = QLA_FUNCTION_FAILED;
225 }
226 224
227 /* Load return mailbox registers. */ 225 /* Load return mailbox registers. */
228 iptr2 = mcp->mb; 226 iptr2 = mcp->mb;
@@ -249,8 +247,6 @@ qla2x00_mailbox_command(scsi_qla_host_t *ha, mbx_cmd_t *mcp)
249 qla2x00_dump_regs(ha); 247 qla2x00_dump_regs(ha);
250#endif 248#endif
251 249
252 qla2x00_stats.mboxtout++;
253 ha->total_mbx_timeout++;
254 rval = QLA_FUNCTION_TIMEOUT; 250 rval = QLA_FUNCTION_TIMEOUT;
255 } 251 }
256 252
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index 579448222d69..0b12498b7672 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -36,27 +36,12 @@ char qla2x00_version_str[40];
36/* 36/*
37 * SRB allocation cache 37 * SRB allocation cache
38 */ 38 */
39char srb_cachep_name[16]; 39static kmem_cache_t *srb_cachep;
40kmem_cache_t *srb_cachep;
41
42/*
43 * Stats for all adpaters.
44 */
45struct _qla2x00stats qla2x00_stats;
46 40
47/* 41/*
48 * Ioctl related information. 42 * Ioctl related information.
49 */ 43 */
50int num_hosts; 44static int num_hosts;
51int apiHBAInstance;
52
53/*
54 * Module parameter information and variables
55 */
56int ql2xmaxqdepth;
57module_param(ql2xmaxqdepth, int, S_IRUGO|S_IWUSR);
58MODULE_PARM_DESC(ql2xmaxqdepth,
59 "Maximum queue depth to report for target devices.");
60 45
61int ql2xlogintimeout = 20; 46int ql2xlogintimeout = 20;
62module_param(ql2xlogintimeout, int, S_IRUGO|S_IRUSR); 47module_param(ql2xlogintimeout, int, S_IRUGO|S_IRUSR);
@@ -69,12 +54,6 @@ MODULE_PARM_DESC(qlport_down_retry,
69 "Maximum number of command retries to a port that returns" 54 "Maximum number of command retries to a port that returns"
70 "a PORT-DOWN status."); 55 "a PORT-DOWN status.");
71 56
72int ql2xretrycount = 20;
73module_param(ql2xretrycount, int, S_IRUGO|S_IWUSR);
74MODULE_PARM_DESC(ql2xretrycount,
75 "Maximum number of mid-layer retries allowed for a command. "
76 "Default value is 20, ");
77
78int ql2xplogiabsentdevice; 57int ql2xplogiabsentdevice;
79module_param(ql2xplogiabsentdevice, int, S_IRUGO|S_IWUSR); 58module_param(ql2xplogiabsentdevice, int, S_IRUGO|S_IWUSR);
80MODULE_PARM_DESC(ql2xplogiabsentdevice, 59MODULE_PARM_DESC(ql2xplogiabsentdevice,
@@ -95,25 +74,6 @@ MODULE_PARM_DESC(ql2xintrdelaytimer,
95 "ZIO: Waiting time for Firmware before it generates an " 74 "ZIO: Waiting time for Firmware before it generates an "
96 "interrupt to the host to notify completion of request."); 75 "interrupt to the host to notify completion of request.");
97 76
98int ConfigRequired;
99module_param(ConfigRequired, int, S_IRUGO|S_IRUSR);
100MODULE_PARM_DESC(ConfigRequired,
101 "If 1, then only configured devices passed in through the"
102 "ql2xopts parameter will be presented to the OS");
103
104int Bind = BIND_BY_PORT_NAME;
105module_param(Bind, int, S_IRUGO|S_IRUSR);
106MODULE_PARM_DESC(Bind,
107 "Target persistent binding method: "
108 "0 by Portname (default); 1 by PortID; 2 by Nodename. ");
109
110int ql2xsuspendcount = SUSPEND_COUNT;
111module_param(ql2xsuspendcount, int, S_IRUGO|S_IWUSR);
112MODULE_PARM_DESC(ql2xsuspendcount,
113 "Number of 6-second suspend iterations to perform while a "
114 "target returns a <NOT READY> status. Default is 10 "
115 "iterations.");
116
117int ql2xloginretrycount = 0; 77int ql2xloginretrycount = 0;
118module_param(ql2xloginretrycount, int, S_IRUGO|S_IRUSR); 78module_param(ql2xloginretrycount, int, S_IRUGO|S_IRUSR);
119MODULE_PARM_DESC(ql2xloginretrycount, 79MODULE_PARM_DESC(ql2xloginretrycount,
@@ -330,7 +290,6 @@ qla2x00_queuecommand(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *))
330 sp->fcport = fcport; 290 sp->fcport = fcport;
331 sp->cmd = cmd; 291 sp->cmd = cmd;
332 sp->flags = 0; 292 sp->flags = 0;
333 sp->err_id = 0;
334 293
335 CMD_SP(cmd) = (void *)sp; 294 CMD_SP(cmd) = (void *)sp;
336 cmd->scsi_done = done; 295 cmd->scsi_done = done;
@@ -474,7 +433,6 @@ qla2x00_wait_for_loop_ready(scsi_qla_host_t *ha)
474 433
475 while ((!atomic_read(&ha->loop_down_timer) && 434 while ((!atomic_read(&ha->loop_down_timer) &&
476 atomic_read(&ha->loop_state) == LOOP_DOWN) || 435 atomic_read(&ha->loop_state) == LOOP_DOWN) ||
477 test_bit(CFG_ACTIVE, &ha->cfg_flags) ||
478 atomic_read(&ha->loop_state) != LOOP_READY) { 436 atomic_read(&ha->loop_state) != LOOP_READY) {
479 msleep(1000); 437 msleep(1000);
480 if (time_after_eq(jiffies, loop_timeout)) { 438 if (time_after_eq(jiffies, loop_timeout)) {
@@ -507,6 +465,7 @@ qla2xxx_eh_abort(struct scsi_cmnd *cmd)
507 int ret, i; 465 int ret, i;
508 unsigned int id, lun; 466 unsigned int id, lun;
509 unsigned long serial; 467 unsigned long serial;
468 unsigned long flags;
510 469
511 if (!CMD_SP(cmd)) 470 if (!CMD_SP(cmd))
512 return FAILED; 471 return FAILED;
@@ -518,8 +477,7 @@ qla2xxx_eh_abort(struct scsi_cmnd *cmd)
518 serial = cmd->serial_number; 477 serial = cmd->serial_number;
519 478
520 /* Check active list for command command. */ 479 /* Check active list for command command. */
521 spin_unlock_irq(ha->host->host_lock); 480 spin_lock_irqsave(&ha->hardware_lock, flags);
522 spin_lock(&ha->hardware_lock);
523 for (i = 1; i < MAX_OUTSTANDING_COMMANDS; i++) { 481 for (i = 1; i < MAX_OUTSTANDING_COMMANDS; i++) {
524 sp = ha->outstanding_cmds[i]; 482 sp = ha->outstanding_cmds[i];
525 483
@@ -534,7 +492,7 @@ qla2xxx_eh_abort(struct scsi_cmnd *cmd)
534 sp->state)); 492 sp->state));
535 DEBUG3(qla2x00_print_scsi_cmd(cmd);) 493 DEBUG3(qla2x00_print_scsi_cmd(cmd);)
536 494
537 spin_unlock(&ha->hardware_lock); 495 spin_unlock_irqrestore(&ha->hardware_lock, flags);
538 if (qla2x00_abort_command(ha, sp)) { 496 if (qla2x00_abort_command(ha, sp)) {
539 DEBUG2(printk("%s(%ld): abort_command " 497 DEBUG2(printk("%s(%ld): abort_command "
540 "mbx failed.\n", __func__, ha->host_no)); 498 "mbx failed.\n", __func__, ha->host_no));
@@ -543,22 +501,20 @@ qla2xxx_eh_abort(struct scsi_cmnd *cmd)
543 "mbx success.\n", __func__, ha->host_no)); 501 "mbx success.\n", __func__, ha->host_no));
544 ret = SUCCESS; 502 ret = SUCCESS;
545 } 503 }
546 spin_lock(&ha->hardware_lock); 504 spin_lock_irqsave(&ha->hardware_lock, flags);
547 505
548 break; 506 break;
549 } 507 }
508 spin_unlock_irqrestore(&ha->hardware_lock, flags);
550 509
551 /* Wait for the command to be returned. */ 510 /* Wait for the command to be returned. */
552 if (ret == SUCCESS) { 511 if (ret == SUCCESS) {
553 spin_unlock(&ha->hardware_lock);
554 if (qla2x00_eh_wait_on_command(ha, cmd) != QLA_SUCCESS) { 512 if (qla2x00_eh_wait_on_command(ha, cmd) != QLA_SUCCESS) {
555 qla_printk(KERN_ERR, ha, 513 qla_printk(KERN_ERR, ha,
556 "scsi(%ld:%d:%d): Abort handler timed out -- %lx " 514 "scsi(%ld:%d:%d): Abort handler timed out -- %lx "
557 "%x.\n", ha->host_no, id, lun, serial, ret); 515 "%x.\n", ha->host_no, id, lun, serial, ret);
558 } 516 }
559 spin_lock(&ha->hardware_lock);
560 } 517 }
561 spin_lock_irq(ha->host->host_lock);
562 518
563 qla_printk(KERN_INFO, ha, 519 qla_printk(KERN_INFO, ha,
564 "scsi(%ld:%d:%d): Abort command issued -- %lx %x.\n", ha->host_no, 520 "scsi(%ld:%d:%d): Abort command issued -- %lx %x.\n", ha->host_no,
@@ -588,6 +544,7 @@ qla2x00_eh_wait_for_pending_target_commands(scsi_qla_host_t *ha, unsigned int t)
588 int status; 544 int status;
589 srb_t *sp; 545 srb_t *sp;
590 struct scsi_cmnd *cmd; 546 struct scsi_cmnd *cmd;
547 unsigned long flags;
591 548
592 status = 0; 549 status = 0;
593 550
@@ -596,11 +553,11 @@ qla2x00_eh_wait_for_pending_target_commands(scsi_qla_host_t *ha, unsigned int t)
596 * array 553 * array
597 */ 554 */
598 for (cnt = 1; cnt < MAX_OUTSTANDING_COMMANDS; cnt++) { 555 for (cnt = 1; cnt < MAX_OUTSTANDING_COMMANDS; cnt++) {
599 spin_lock(&ha->hardware_lock); 556 spin_lock_irqsave(&ha->hardware_lock, flags);
600 sp = ha->outstanding_cmds[cnt]; 557 sp = ha->outstanding_cmds[cnt];
601 if (sp) { 558 if (sp) {
602 cmd = sp->cmd; 559 cmd = sp->cmd;
603 spin_unlock(&ha->hardware_lock); 560 spin_unlock_irqrestore(&ha->hardware_lock, flags);
604 if (cmd->device->id == t) { 561 if (cmd->device->id == t) {
605 if (!qla2x00_eh_wait_on_command(ha, cmd)) { 562 if (!qla2x00_eh_wait_on_command(ha, cmd)) {
606 status = 1; 563 status = 1;
@@ -608,7 +565,7 @@ qla2x00_eh_wait_for_pending_target_commands(scsi_qla_host_t *ha, unsigned int t)
608 } 565 }
609 } 566 }
610 } else { 567 } else {
611 spin_unlock(&ha->hardware_lock); 568 spin_unlock_irqrestore(&ha->hardware_lock, flags);
612 } 569 }
613 } 570 }
614 return (status); 571 return (status);
@@ -657,12 +614,8 @@ qla2xxx_eh_device_reset(struct scsi_cmnd *cmd)
657 qla_printk(KERN_INFO, ha, 614 qla_printk(KERN_INFO, ha,
658 "scsi(%ld:%d:%d): DEVICE RESET ISSUED.\n", ha->host_no, id, lun); 615 "scsi(%ld:%d:%d): DEVICE RESET ISSUED.\n", ha->host_no, id, lun);
659 616
660 spin_unlock_irq(ha->host->host_lock); 617 if (qla2x00_wait_for_hba_online(ha) != QLA_SUCCESS)
661
662 if (qla2x00_wait_for_hba_online(ha) != QLA_SUCCESS) {
663 spin_lock_irq(ha->host->host_lock);
664 goto eh_dev_reset_done; 618 goto eh_dev_reset_done;
665 }
666 619
667 if (qla2x00_wait_for_loop_ready(ha) == QLA_SUCCESS) { 620 if (qla2x00_wait_for_loop_ready(ha) == QLA_SUCCESS) {
668 if (qla2x00_device_reset(ha, fcport) == 0) 621 if (qla2x00_device_reset(ha, fcport) == 0)
@@ -713,8 +666,6 @@ qla2xxx_eh_device_reset(struct scsi_cmnd *cmd)
713 "scsi(%ld:%d:%d): DEVICE RESET SUCCEEDED.\n", ha->host_no, id, lun); 666 "scsi(%ld:%d:%d): DEVICE RESET SUCCEEDED.\n", ha->host_no, id, lun);
714 667
715eh_dev_reset_done: 668eh_dev_reset_done:
716 spin_lock_irq(ha->host->host_lock);
717
718 return ret; 669 return ret;
719} 670}
720 671
@@ -740,6 +691,7 @@ qla2x00_eh_wait_for_pending_commands(scsi_qla_host_t *ha)
740 int status; 691 int status;
741 srb_t *sp; 692 srb_t *sp;
742 struct scsi_cmnd *cmd; 693 struct scsi_cmnd *cmd;
694 unsigned long flags;
743 695
744 status = 1; 696 status = 1;
745 697
@@ -748,17 +700,17 @@ qla2x00_eh_wait_for_pending_commands(scsi_qla_host_t *ha)
748 * array 700 * array
749 */ 701 */
750 for (cnt = 1; cnt < MAX_OUTSTANDING_COMMANDS; cnt++) { 702 for (cnt = 1; cnt < MAX_OUTSTANDING_COMMANDS; cnt++) {
751 spin_lock(&ha->hardware_lock); 703 spin_lock_irqsave(&ha->hardware_lock, flags);
752 sp = ha->outstanding_cmds[cnt]; 704 sp = ha->outstanding_cmds[cnt];
753 if (sp) { 705 if (sp) {
754 cmd = sp->cmd; 706 cmd = sp->cmd;
755 spin_unlock(&ha->hardware_lock); 707 spin_unlock_irqrestore(&ha->hardware_lock, flags);
756 status = qla2x00_eh_wait_on_command(ha, cmd); 708 status = qla2x00_eh_wait_on_command(ha, cmd);
757 if (status == 0) 709 if (status == 0)
758 break; 710 break;
759 } 711 }
760 else { 712 else {
761 spin_unlock(&ha->hardware_lock); 713 spin_unlock_irqrestore(&ha->hardware_lock, flags);
762 } 714 }
763 } 715 }
764 return (status); 716 return (status);
@@ -803,8 +755,6 @@ qla2xxx_eh_bus_reset(struct scsi_cmnd *cmd)
803 qla_printk(KERN_INFO, ha, 755 qla_printk(KERN_INFO, ha,
804 "scsi(%ld:%d:%d): LOOP RESET ISSUED.\n", ha->host_no, id, lun); 756 "scsi(%ld:%d:%d): LOOP RESET ISSUED.\n", ha->host_no, id, lun);
805 757
806 spin_unlock_irq(ha->host->host_lock);
807
808 if (qla2x00_wait_for_hba_online(ha) != QLA_SUCCESS) { 758 if (qla2x00_wait_for_hba_online(ha) != QLA_SUCCESS) {
809 DEBUG2(printk("%s failed:board disabled\n",__func__)); 759 DEBUG2(printk("%s failed:board disabled\n",__func__));
810 goto eh_bus_reset_done; 760 goto eh_bus_reset_done;
@@ -826,8 +776,6 @@ eh_bus_reset_done:
826 qla_printk(KERN_INFO, ha, "%s: reset %s\n", __func__, 776 qla_printk(KERN_INFO, ha, "%s: reset %s\n", __func__,
827 (ret == FAILED) ? "failed" : "succeded"); 777 (ret == FAILED) ? "failed" : "succeded");
828 778
829 spin_lock_irq(ha->host->host_lock);
830
831 return ret; 779 return ret;
832} 780}
833 781
@@ -869,8 +817,6 @@ qla2xxx_eh_host_reset(struct scsi_cmnd *cmd)
869 qla_printk(KERN_INFO, ha, 817 qla_printk(KERN_INFO, ha,
870 "scsi(%ld:%d:%d): ADAPTER RESET ISSUED.\n", ha->host_no, id, lun); 818 "scsi(%ld:%d:%d): ADAPTER RESET ISSUED.\n", ha->host_no, id, lun);
871 819
872 spin_unlock_irq(ha->host->host_lock);
873
874 if (qla2x00_wait_for_hba_online(ha) != QLA_SUCCESS) 820 if (qla2x00_wait_for_hba_online(ha) != QLA_SUCCESS)
875 goto eh_host_reset_lock; 821 goto eh_host_reset_lock;
876 822
@@ -899,8 +845,6 @@ qla2xxx_eh_host_reset(struct scsi_cmnd *cmd)
899 ret = SUCCESS; 845 ret = SUCCESS;
900 846
901eh_host_reset_lock: 847eh_host_reset_lock:
902 spin_lock_irq(ha->host->host_lock);
903
904 qla_printk(KERN_INFO, ha, "%s: reset %s\n", __func__, 848 qla_printk(KERN_INFO, ha, "%s: reset %s\n", __func__,
905 (ret == FAILED) ? "failed" : "succeded"); 849 (ret == FAILED) ? "failed" : "succeded");
906 850
@@ -1148,7 +1092,7 @@ iospace_error_exit:
1148 */ 1092 */
1149int qla2x00_probe_one(struct pci_dev *pdev, struct qla_board_info *brd_info) 1093int qla2x00_probe_one(struct pci_dev *pdev, struct qla_board_info *brd_info)
1150{ 1094{
1151 int ret; 1095 int ret = -ENODEV;
1152 device_reg_t __iomem *reg; 1096 device_reg_t __iomem *reg;
1153 struct Scsi_Host *host; 1097 struct Scsi_Host *host;
1154 scsi_qla_host_t *ha; 1098 scsi_qla_host_t *ha;
@@ -1159,7 +1103,7 @@ int qla2x00_probe_one(struct pci_dev *pdev, struct qla_board_info *brd_info)
1159 fc_port_t *fcport; 1103 fc_port_t *fcport;
1160 1104
1161 if (pci_enable_device(pdev)) 1105 if (pci_enable_device(pdev))
1162 return -1; 1106 goto probe_out;
1163 1107
1164 host = scsi_host_alloc(&qla2x00_driver_template, 1108 host = scsi_host_alloc(&qla2x00_driver_template,
1165 sizeof(scsi_qla_host_t)); 1109 sizeof(scsi_qla_host_t));
@@ -1181,9 +1125,8 @@ int qla2x00_probe_one(struct pci_dev *pdev, struct qla_board_info *brd_info)
1181 1125
1182 /* Configure PCI I/O space */ 1126 /* Configure PCI I/O space */
1183 ret = qla2x00_iospace_config(ha); 1127 ret = qla2x00_iospace_config(ha);
1184 if (ret != 0) { 1128 if (ret)
1185 goto probe_alloc_failed; 1129 goto probe_failed;
1186 }
1187 1130
1188 /* Sanitize the information from PCI BIOS. */ 1131 /* Sanitize the information from PCI BIOS. */
1189 host->irq = pdev->irq; 1132 host->irq = pdev->irq;
@@ -1194,34 +1137,24 @@ int qla2x00_probe_one(struct pci_dev *pdev, struct qla_board_info *brd_info)
1194 1137
1195 spin_lock_init(&ha->hardware_lock); 1138 spin_lock_init(&ha->hardware_lock);
1196 1139
1197 /* 4.23 Initialize /proc/scsi/qla2x00 counters */
1198 ha->actthreads = 0;
1199 ha->qthreads = 0;
1200 ha->total_isr_cnt = 0;
1201 ha->total_isp_aborts = 0;
1202 ha->total_lip_cnt = 0;
1203 ha->total_dev_errs = 0;
1204 ha->total_ios = 0;
1205 ha->total_bytes = 0;
1206
1207 ha->prev_topology = 0; 1140 ha->prev_topology = 0;
1208 ha->ports = MAX_BUSES; 1141 ha->ports = MAX_BUSES;
1209 1142
1210 if (IS_QLA2100(ha)) { 1143 if (IS_QLA2100(ha)) {
1211 ha->max_targets = MAX_TARGETS_2100; 1144 host->max_id = MAX_TARGETS_2100;
1212 ha->mbx_count = MAILBOX_REGISTER_COUNT_2100; 1145 ha->mbx_count = MAILBOX_REGISTER_COUNT_2100;
1213 ha->request_q_length = REQUEST_ENTRY_CNT_2100; 1146 ha->request_q_length = REQUEST_ENTRY_CNT_2100;
1214 ha->response_q_length = RESPONSE_ENTRY_CNT_2100; 1147 ha->response_q_length = RESPONSE_ENTRY_CNT_2100;
1215 ha->last_loop_id = SNS_LAST_LOOP_ID_2100; 1148 ha->last_loop_id = SNS_LAST_LOOP_ID_2100;
1216 host->sg_tablesize = 32; 1149 host->sg_tablesize = 32;
1217 } else if (IS_QLA2200(ha)) { 1150 } else if (IS_QLA2200(ha)) {
1218 ha->max_targets = MAX_TARGETS_2200; 1151 host->max_id = MAX_TARGETS_2200;
1219 ha->mbx_count = MAILBOX_REGISTER_COUNT; 1152 ha->mbx_count = MAILBOX_REGISTER_COUNT;
1220 ha->request_q_length = REQUEST_ENTRY_CNT_2200; 1153 ha->request_q_length = REQUEST_ENTRY_CNT_2200;
1221 ha->response_q_length = RESPONSE_ENTRY_CNT_2100; 1154 ha->response_q_length = RESPONSE_ENTRY_CNT_2100;
1222 ha->last_loop_id = SNS_LAST_LOOP_ID_2100; 1155 ha->last_loop_id = SNS_LAST_LOOP_ID_2100;
1223 } else /*if (IS_QLA2300(ha))*/ { 1156 } else /*if (IS_QLA2300(ha))*/ {
1224 ha->max_targets = MAX_TARGETS_2200; 1157 host->max_id = MAX_TARGETS_2200;
1225 ha->mbx_count = MAILBOX_REGISTER_COUNT; 1158 ha->mbx_count = MAILBOX_REGISTER_COUNT;
1226 ha->request_q_length = REQUEST_ENTRY_CNT_2200; 1159 ha->request_q_length = REQUEST_ENTRY_CNT_2200;
1227 ha->response_q_length = RESPONSE_ENTRY_CNT_2300; 1160 ha->response_q_length = RESPONSE_ENTRY_CNT_2300;
@@ -1256,23 +1189,10 @@ int qla2x00_probe_one(struct pci_dev *pdev, struct qla_board_info *brd_info)
1256 qla_printk(KERN_WARNING, ha, 1189 qla_printk(KERN_WARNING, ha,
1257 "[ERROR] Failed to allocate memory for adapter\n"); 1190 "[ERROR] Failed to allocate memory for adapter\n");
1258 1191
1259 goto probe_alloc_failed; 1192 ret = -ENOMEM;
1193 goto probe_failed;
1260 } 1194 }
1261 1195
1262 pci_set_drvdata(pdev, ha);
1263 host->this_id = 255;
1264 host->cmd_per_lun = 3;
1265 host->unique_id = ha->instance;
1266 host->max_cmd_len = MAX_CMDSZ;
1267 host->max_channel = ha->ports - 1;
1268 host->max_id = ha->max_targets;
1269 host->max_lun = ha->max_luns;
1270 host->transportt = qla2xxx_transport_template;
1271 if (scsi_add_host(host, &pdev->dev))
1272 goto probe_alloc_failed;
1273
1274 qla2x00_alloc_sysfs_attr(ha);
1275
1276 if (qla2x00_initialize_adapter(ha) && 1196 if (qla2x00_initialize_adapter(ha) &&
1277 !(ha->device_flags & DFLG_NO_CABLE)) { 1197 !(ha->device_flags & DFLG_NO_CABLE)) {
1278 1198
@@ -1283,11 +1203,10 @@ int qla2x00_probe_one(struct pci_dev *pdev, struct qla_board_info *brd_info)
1283 "Adapter flags %x.\n", 1203 "Adapter flags %x.\n",
1284 ha->host_no, ha->device_flags)); 1204 ha->host_no, ha->device_flags));
1285 1205
1206 ret = -ENODEV;
1286 goto probe_failed; 1207 goto probe_failed;
1287 } 1208 }
1288 1209
1289 qla2x00_init_host_attr(ha);
1290
1291 /* 1210 /*
1292 * Startup the kernel thread for this host adapter 1211 * Startup the kernel thread for this host adapter
1293 */ 1212 */
@@ -1297,17 +1216,26 @@ int qla2x00_probe_one(struct pci_dev *pdev, struct qla_board_info *brd_info)
1297 qla_printk(KERN_WARNING, ha, 1216 qla_printk(KERN_WARNING, ha,
1298 "Unable to start DPC thread!\n"); 1217 "Unable to start DPC thread!\n");
1299 1218
1219 ret = -ENODEV;
1300 goto probe_failed; 1220 goto probe_failed;
1301 } 1221 }
1302 wait_for_completion(&ha->dpc_inited); 1222 wait_for_completion(&ha->dpc_inited);
1303 1223
1224 host->this_id = 255;
1225 host->cmd_per_lun = 3;
1226 host->unique_id = ha->instance;
1227 host->max_cmd_len = MAX_CMDSZ;
1228 host->max_channel = ha->ports - 1;
1229 host->max_lun = MAX_LUNS;
1230 host->transportt = qla2xxx_transport_template;
1231
1304 if (IS_QLA2100(ha) || IS_QLA2200(ha)) 1232 if (IS_QLA2100(ha) || IS_QLA2200(ha))
1305 ret = request_irq(host->irq, qla2100_intr_handler, 1233 ret = request_irq(host->irq, qla2100_intr_handler,
1306 SA_INTERRUPT|SA_SHIRQ, ha->brd_info->drv_name, ha); 1234 SA_INTERRUPT|SA_SHIRQ, ha->brd_info->drv_name, ha);
1307 else 1235 else
1308 ret = request_irq(host->irq, qla2300_intr_handler, 1236 ret = request_irq(host->irq, qla2300_intr_handler,
1309 SA_INTERRUPT|SA_SHIRQ, ha->brd_info->drv_name, ha); 1237 SA_INTERRUPT|SA_SHIRQ, ha->brd_info->drv_name, ha);
1310 if (ret != 0) { 1238 if (ret) {
1311 qla_printk(KERN_WARNING, ha, 1239 qla_printk(KERN_WARNING, ha,
1312 "Failed to reserve interrupt %d already in use.\n", 1240 "Failed to reserve interrupt %d already in use.\n",
1313 host->irq); 1241 host->irq);
@@ -1361,9 +1289,18 @@ int qla2x00_probe_one(struct pci_dev *pdev, struct qla_board_info *brd_info)
1361 msleep(10); 1289 msleep(10);
1362 } 1290 }
1363 1291
1292 pci_set_drvdata(pdev, ha);
1364 ha->flags.init_done = 1; 1293 ha->flags.init_done = 1;
1365 num_hosts++; 1294 num_hosts++;
1366 1295
1296 ret = scsi_add_host(host, &pdev->dev);
1297 if (ret)
1298 goto probe_failed;
1299
1300 qla2x00_alloc_sysfs_attr(ha);
1301
1302 qla2x00_init_host_attr(ha);
1303
1367 qla_printk(KERN_INFO, ha, "\n" 1304 qla_printk(KERN_INFO, ha, "\n"
1368 " QLogic Fibre Channel HBA Driver: %s\n" 1305 " QLogic Fibre Channel HBA Driver: %s\n"
1369 " QLogic %s - %s\n" 1306 " QLogic %s - %s\n"
@@ -1382,9 +1319,6 @@ int qla2x00_probe_one(struct pci_dev *pdev, struct qla_board_info *brd_info)
1382probe_failed: 1319probe_failed:
1383 fc_remove_host(ha->host); 1320 fc_remove_host(ha->host);
1384 1321
1385 scsi_remove_host(host);
1386
1387probe_alloc_failed:
1388 qla2x00_free_device(ha); 1322 qla2x00_free_device(ha);
1389 1323
1390 scsi_host_put(host); 1324 scsi_host_put(host);
@@ -1392,7 +1326,8 @@ probe_alloc_failed:
1392probe_disable_device: 1326probe_disable_device:
1393 pci_disable_device(pdev); 1327 pci_disable_device(pdev);
1394 1328
1395 return -1; 1329probe_out:
1330 return ret;
1396} 1331}
1397EXPORT_SYMBOL_GPL(qla2x00_probe_one); 1332EXPORT_SYMBOL_GPL(qla2x00_probe_one);
1398 1333
@@ -2336,8 +2271,7 @@ static int __init
2336qla2x00_module_init(void) 2271qla2x00_module_init(void)
2337{ 2272{
2338 /* Allocate cache for SRBs. */ 2273 /* Allocate cache for SRBs. */
2339 sprintf(srb_cachep_name, "qla2xxx_srbs"); 2274 srb_cachep = kmem_cache_create("qla2xxx_srbs", sizeof(srb_t), 0,
2340 srb_cachep = kmem_cache_create(srb_cachep_name, sizeof(srb_t), 0,
2341 SLAB_HWCACHE_ALIGN, NULL, NULL); 2275 SLAB_HWCACHE_ALIGN, NULL, NULL);
2342 if (srb_cachep == NULL) { 2276 if (srb_cachep == NULL) {
2343 printk(KERN_ERR 2277 printk(KERN_ERR
@@ -2365,16 +2299,7 @@ qla2x00_module_init(void)
2365static void __exit 2299static void __exit
2366qla2x00_module_exit(void) 2300qla2x00_module_exit(void)
2367{ 2301{
2368 /* Free SRBs cache. */ 2302 kmem_cache_destroy(srb_cachep);
2369 if (srb_cachep != NULL) {
2370 if (kmem_cache_destroy(srb_cachep) != 0) {
2371 printk(KERN_ERR
2372 "qla2xxx: Unable to free SRB cache...Memory pools "
2373 "still active?\n");
2374 }
2375 srb_cachep = NULL;
2376 }
2377
2378 fc_release_transport(qla2xxx_transport_template); 2303 fc_release_transport(qla2xxx_transport_template);
2379} 2304}
2380 2305