aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/qla2xxx/qla_os.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/qla2xxx/qla_os.c')
-rw-r--r--drivers/scsi/qla2xxx/qla_os.c149
1 files changed, 36 insertions, 113 deletions
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index 3c97aa45772d..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)) {
@@ -519,7 +477,6 @@ qla2xxx_eh_abort(struct scsi_cmnd *cmd)
519 serial = cmd->serial_number; 477 serial = cmd->serial_number;
520 478
521 /* Check active list for command command. */ 479 /* Check active list for command command. */
522 spin_unlock_irq(ha->host->host_lock);
523 spin_lock_irqsave(&ha->hardware_lock, flags); 480 spin_lock_irqsave(&ha->hardware_lock, flags);
524 for (i = 1; i < MAX_OUTSTANDING_COMMANDS; i++) { 481 for (i = 1; i < MAX_OUTSTANDING_COMMANDS; i++) {
525 sp = ha->outstanding_cmds[i]; 482 sp = ha->outstanding_cmds[i];
@@ -558,7 +515,6 @@ qla2xxx_eh_abort(struct scsi_cmnd *cmd)
558 "%x.\n", ha->host_no, id, lun, serial, ret); 515 "%x.\n", ha->host_no, id, lun, serial, ret);
559 } 516 }
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,
@@ -658,12 +614,8 @@ qla2xxx_eh_device_reset(struct scsi_cmnd *cmd)
658 qla_printk(KERN_INFO, ha, 614 qla_printk(KERN_INFO, ha,
659 "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);
660 616
661 spin_unlock_irq(ha->host->host_lock); 617 if (qla2x00_wait_for_hba_online(ha) != QLA_SUCCESS)
662
663 if (qla2x00_wait_for_hba_online(ha) != QLA_SUCCESS) {
664 spin_lock_irq(ha->host->host_lock);
665 goto eh_dev_reset_done; 618 goto eh_dev_reset_done;
666 }
667 619
668 if (qla2x00_wait_for_loop_ready(ha) == QLA_SUCCESS) { 620 if (qla2x00_wait_for_loop_ready(ha) == QLA_SUCCESS) {
669 if (qla2x00_device_reset(ha, fcport) == 0) 621 if (qla2x00_device_reset(ha, fcport) == 0)
@@ -714,8 +666,6 @@ qla2xxx_eh_device_reset(struct scsi_cmnd *cmd)
714 "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);
715 667
716eh_dev_reset_done: 668eh_dev_reset_done:
717 spin_lock_irq(ha->host->host_lock);
718
719 return ret; 669 return ret;
720} 670}
721 671
@@ -805,8 +755,6 @@ qla2xxx_eh_bus_reset(struct scsi_cmnd *cmd)
805 qla_printk(KERN_INFO, ha, 755 qla_printk(KERN_INFO, ha,
806 "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);
807 757
808 spin_unlock_irq(ha->host->host_lock);
809
810 if (qla2x00_wait_for_hba_online(ha) != QLA_SUCCESS) { 758 if (qla2x00_wait_for_hba_online(ha) != QLA_SUCCESS) {
811 DEBUG2(printk("%s failed:board disabled\n",__func__)); 759 DEBUG2(printk("%s failed:board disabled\n",__func__));
812 goto eh_bus_reset_done; 760 goto eh_bus_reset_done;
@@ -828,8 +776,6 @@ eh_bus_reset_done:
828 qla_printk(KERN_INFO, ha, "%s: reset %s\n", __func__, 776 qla_printk(KERN_INFO, ha, "%s: reset %s\n", __func__,
829 (ret == FAILED) ? "failed" : "succeded"); 777 (ret == FAILED) ? "failed" : "succeded");
830 778
831 spin_lock_irq(ha->host->host_lock);
832
833 return ret; 779 return ret;
834} 780}
835 781
@@ -871,8 +817,6 @@ qla2xxx_eh_host_reset(struct scsi_cmnd *cmd)
871 qla_printk(KERN_INFO, ha, 817 qla_printk(KERN_INFO, ha,
872 "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);
873 819
874 spin_unlock_irq(ha->host->host_lock);
875
876 if (qla2x00_wait_for_hba_online(ha) != QLA_SUCCESS) 820 if (qla2x00_wait_for_hba_online(ha) != QLA_SUCCESS)
877 goto eh_host_reset_lock; 821 goto eh_host_reset_lock;
878 822
@@ -901,8 +845,6 @@ qla2xxx_eh_host_reset(struct scsi_cmnd *cmd)
901 ret = SUCCESS; 845 ret = SUCCESS;
902 846
903eh_host_reset_lock: 847eh_host_reset_lock:
904 spin_lock_irq(ha->host->host_lock);
905
906 qla_printk(KERN_INFO, ha, "%s: reset %s\n", __func__, 848 qla_printk(KERN_INFO, ha, "%s: reset %s\n", __func__,
907 (ret == FAILED) ? "failed" : "succeded"); 849 (ret == FAILED) ? "failed" : "succeded");
908 850
@@ -1150,7 +1092,7 @@ iospace_error_exit:
1150 */ 1092 */
1151int 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)
1152{ 1094{
1153 int ret; 1095 int ret = -ENODEV;
1154 device_reg_t __iomem *reg; 1096 device_reg_t __iomem *reg;
1155 struct Scsi_Host *host; 1097 struct Scsi_Host *host;
1156 scsi_qla_host_t *ha; 1098 scsi_qla_host_t *ha;
@@ -1161,7 +1103,7 @@ int qla2x00_probe_one(struct pci_dev *pdev, struct qla_board_info *brd_info)
1161 fc_port_t *fcport; 1103 fc_port_t *fcport;
1162 1104
1163 if (pci_enable_device(pdev)) 1105 if (pci_enable_device(pdev))
1164 return -1; 1106 goto probe_out;
1165 1107
1166 host = scsi_host_alloc(&qla2x00_driver_template, 1108 host = scsi_host_alloc(&qla2x00_driver_template,
1167 sizeof(scsi_qla_host_t)); 1109 sizeof(scsi_qla_host_t));
@@ -1183,9 +1125,8 @@ int qla2x00_probe_one(struct pci_dev *pdev, struct qla_board_info *brd_info)
1183 1125
1184 /* Configure PCI I/O space */ 1126 /* Configure PCI I/O space */
1185 ret = qla2x00_iospace_config(ha); 1127 ret = qla2x00_iospace_config(ha);
1186 if (ret != 0) { 1128 if (ret)
1187 goto probe_alloc_failed; 1129 goto probe_failed;
1188 }
1189 1130
1190 /* Sanitize the information from PCI BIOS. */ 1131 /* Sanitize the information from PCI BIOS. */
1191 host->irq = pdev->irq; 1132 host->irq = pdev->irq;
@@ -1196,34 +1137,24 @@ int qla2x00_probe_one(struct pci_dev *pdev, struct qla_board_info *brd_info)
1196 1137
1197 spin_lock_init(&ha->hardware_lock); 1138 spin_lock_init(&ha->hardware_lock);
1198 1139
1199 /* 4.23 Initialize /proc/scsi/qla2x00 counters */
1200 ha->actthreads = 0;
1201 ha->qthreads = 0;
1202 ha->total_isr_cnt = 0;
1203 ha->total_isp_aborts = 0;
1204 ha->total_lip_cnt = 0;
1205 ha->total_dev_errs = 0;
1206 ha->total_ios = 0;
1207 ha->total_bytes = 0;
1208
1209 ha->prev_topology = 0; 1140 ha->prev_topology = 0;
1210 ha->ports = MAX_BUSES; 1141 ha->ports = MAX_BUSES;
1211 1142
1212 if (IS_QLA2100(ha)) { 1143 if (IS_QLA2100(ha)) {
1213 ha->max_targets = MAX_TARGETS_2100; 1144 host->max_id = MAX_TARGETS_2100;
1214 ha->mbx_count = MAILBOX_REGISTER_COUNT_2100; 1145 ha->mbx_count = MAILBOX_REGISTER_COUNT_2100;
1215 ha->request_q_length = REQUEST_ENTRY_CNT_2100; 1146 ha->request_q_length = REQUEST_ENTRY_CNT_2100;
1216 ha->response_q_length = RESPONSE_ENTRY_CNT_2100; 1147 ha->response_q_length = RESPONSE_ENTRY_CNT_2100;
1217 ha->last_loop_id = SNS_LAST_LOOP_ID_2100; 1148 ha->last_loop_id = SNS_LAST_LOOP_ID_2100;
1218 host->sg_tablesize = 32; 1149 host->sg_tablesize = 32;
1219 } else if (IS_QLA2200(ha)) { 1150 } else if (IS_QLA2200(ha)) {
1220 ha->max_targets = MAX_TARGETS_2200; 1151 host->max_id = MAX_TARGETS_2200;
1221 ha->mbx_count = MAILBOX_REGISTER_COUNT; 1152 ha->mbx_count = MAILBOX_REGISTER_COUNT;
1222 ha->request_q_length = REQUEST_ENTRY_CNT_2200; 1153 ha->request_q_length = REQUEST_ENTRY_CNT_2200;
1223 ha->response_q_length = RESPONSE_ENTRY_CNT_2100; 1154 ha->response_q_length = RESPONSE_ENTRY_CNT_2100;
1224 ha->last_loop_id = SNS_LAST_LOOP_ID_2100; 1155 ha->last_loop_id = SNS_LAST_LOOP_ID_2100;
1225 } else /*if (IS_QLA2300(ha))*/ { 1156 } else /*if (IS_QLA2300(ha))*/ {
1226 ha->max_targets = MAX_TARGETS_2200; 1157 host->max_id = MAX_TARGETS_2200;
1227 ha->mbx_count = MAILBOX_REGISTER_COUNT; 1158 ha->mbx_count = MAILBOX_REGISTER_COUNT;
1228 ha->request_q_length = REQUEST_ENTRY_CNT_2200; 1159 ha->request_q_length = REQUEST_ENTRY_CNT_2200;
1229 ha->response_q_length = RESPONSE_ENTRY_CNT_2300; 1160 ha->response_q_length = RESPONSE_ENTRY_CNT_2300;
@@ -1258,23 +1189,10 @@ int qla2x00_probe_one(struct pci_dev *pdev, struct qla_board_info *brd_info)
1258 qla_printk(KERN_WARNING, ha, 1189 qla_printk(KERN_WARNING, ha,
1259 "[ERROR] Failed to allocate memory for adapter\n"); 1190 "[ERROR] Failed to allocate memory for adapter\n");
1260 1191
1261 goto probe_alloc_failed; 1192 ret = -ENOMEM;
1193 goto probe_failed;
1262 } 1194 }
1263 1195
1264 pci_set_drvdata(pdev, ha);
1265 host->this_id = 255;
1266 host->cmd_per_lun = 3;
1267 host->unique_id = ha->instance;
1268 host->max_cmd_len = MAX_CMDSZ;
1269 host->max_channel = ha->ports - 1;
1270 host->max_id = ha->max_targets;
1271 host->max_lun = ha->max_luns;
1272 host->transportt = qla2xxx_transport_template;
1273 if (scsi_add_host(host, &pdev->dev))
1274 goto probe_alloc_failed;
1275
1276 qla2x00_alloc_sysfs_attr(ha);
1277
1278 if (qla2x00_initialize_adapter(ha) && 1196 if (qla2x00_initialize_adapter(ha) &&
1279 !(ha->device_flags & DFLG_NO_CABLE)) { 1197 !(ha->device_flags & DFLG_NO_CABLE)) {
1280 1198
@@ -1285,11 +1203,10 @@ int qla2x00_probe_one(struct pci_dev *pdev, struct qla_board_info *brd_info)
1285 "Adapter flags %x.\n", 1203 "Adapter flags %x.\n",
1286 ha->host_no, ha->device_flags)); 1204 ha->host_no, ha->device_flags));
1287 1205
1206 ret = -ENODEV;
1288 goto probe_failed; 1207 goto probe_failed;
1289 } 1208 }
1290 1209
1291 qla2x00_init_host_attr(ha);
1292
1293 /* 1210 /*
1294 * Startup the kernel thread for this host adapter 1211 * Startup the kernel thread for this host adapter
1295 */ 1212 */
@@ -1299,17 +1216,26 @@ int qla2x00_probe_one(struct pci_dev *pdev, struct qla_board_info *brd_info)
1299 qla_printk(KERN_WARNING, ha, 1216 qla_printk(KERN_WARNING, ha,
1300 "Unable to start DPC thread!\n"); 1217 "Unable to start DPC thread!\n");
1301 1218
1219 ret = -ENODEV;
1302 goto probe_failed; 1220 goto probe_failed;
1303 } 1221 }
1304 wait_for_completion(&ha->dpc_inited); 1222 wait_for_completion(&ha->dpc_inited);
1305 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
1306 if (IS_QLA2100(ha) || IS_QLA2200(ha)) 1232 if (IS_QLA2100(ha) || IS_QLA2200(ha))
1307 ret = request_irq(host->irq, qla2100_intr_handler, 1233 ret = request_irq(host->irq, qla2100_intr_handler,
1308 SA_INTERRUPT|SA_SHIRQ, ha->brd_info->drv_name, ha); 1234 SA_INTERRUPT|SA_SHIRQ, ha->brd_info->drv_name, ha);
1309 else 1235 else
1310 ret = request_irq(host->irq, qla2300_intr_handler, 1236 ret = request_irq(host->irq, qla2300_intr_handler,
1311 SA_INTERRUPT|SA_SHIRQ, ha->brd_info->drv_name, ha); 1237 SA_INTERRUPT|SA_SHIRQ, ha->brd_info->drv_name, ha);
1312 if (ret != 0) { 1238 if (ret) {
1313 qla_printk(KERN_WARNING, ha, 1239 qla_printk(KERN_WARNING, ha,
1314 "Failed to reserve interrupt %d already in use.\n", 1240 "Failed to reserve interrupt %d already in use.\n",
1315 host->irq); 1241 host->irq);
@@ -1363,9 +1289,18 @@ int qla2x00_probe_one(struct pci_dev *pdev, struct qla_board_info *brd_info)
1363 msleep(10); 1289 msleep(10);
1364 } 1290 }
1365 1291
1292 pci_set_drvdata(pdev, ha);
1366 ha->flags.init_done = 1; 1293 ha->flags.init_done = 1;
1367 num_hosts++; 1294 num_hosts++;
1368 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
1369 qla_printk(KERN_INFO, ha, "\n" 1304 qla_printk(KERN_INFO, ha, "\n"
1370 " QLogic Fibre Channel HBA Driver: %s\n" 1305 " QLogic Fibre Channel HBA Driver: %s\n"
1371 " QLogic %s - %s\n" 1306 " QLogic %s - %s\n"
@@ -1384,9 +1319,6 @@ int qla2x00_probe_one(struct pci_dev *pdev, struct qla_board_info *brd_info)
1384probe_failed: 1319probe_failed:
1385 fc_remove_host(ha->host); 1320 fc_remove_host(ha->host);
1386 1321
1387 scsi_remove_host(host);
1388
1389probe_alloc_failed:
1390 qla2x00_free_device(ha); 1322 qla2x00_free_device(ha);
1391 1323
1392 scsi_host_put(host); 1324 scsi_host_put(host);
@@ -1394,7 +1326,8 @@ probe_alloc_failed:
1394probe_disable_device: 1326probe_disable_device:
1395 pci_disable_device(pdev); 1327 pci_disable_device(pdev);
1396 1328
1397 return -1; 1329probe_out:
1330 return ret;
1398} 1331}
1399EXPORT_SYMBOL_GPL(qla2x00_probe_one); 1332EXPORT_SYMBOL_GPL(qla2x00_probe_one);
1400 1333
@@ -2338,8 +2271,7 @@ static int __init
2338qla2x00_module_init(void) 2271qla2x00_module_init(void)
2339{ 2272{
2340 /* Allocate cache for SRBs. */ 2273 /* Allocate cache for SRBs. */
2341 sprintf(srb_cachep_name, "qla2xxx_srbs"); 2274 srb_cachep = kmem_cache_create("qla2xxx_srbs", sizeof(srb_t), 0,
2342 srb_cachep = kmem_cache_create(srb_cachep_name, sizeof(srb_t), 0,
2343 SLAB_HWCACHE_ALIGN, NULL, NULL); 2275 SLAB_HWCACHE_ALIGN, NULL, NULL);
2344 if (srb_cachep == NULL) { 2276 if (srb_cachep == NULL) {
2345 printk(KERN_ERR 2277 printk(KERN_ERR
@@ -2367,16 +2299,7 @@ qla2x00_module_init(void)
2367static void __exit 2299static void __exit
2368qla2x00_module_exit(void) 2300qla2x00_module_exit(void)
2369{ 2301{
2370 /* Free SRBs cache. */ 2302 kmem_cache_destroy(srb_cachep);
2371 if (srb_cachep != NULL) {
2372 if (kmem_cache_destroy(srb_cachep) != 0) {
2373 printk(KERN_ERR
2374 "qla2xxx: Unable to free SRB cache...Memory pools "
2375 "still active?\n");
2376 }
2377 srb_cachep = NULL;
2378 }
2379
2380 fc_release_transport(qla2xxx_transport_template); 2303 fc_release_transport(qla2xxx_transport_template);
2381} 2304}
2382 2305