[SCSI] allow sleeping in ->eh_device_reset_handler()
[safe/jmp/linux-2.6] / drivers / scsi / qla2xxx / qla_os.c
index 5794482..360974e 100644 (file)
@@ -36,27 +36,12 @@ char qla2x00_version_str[40];
 /*
  * SRB allocation cache
  */
-char srb_cachep_name[16];
-kmem_cache_t *srb_cachep;
-
-/*
- * Stats for all adpaters.
- */
-struct _qla2x00stats qla2x00_stats;
+static kmem_cache_t *srb_cachep;
 
 /*
  * Ioctl related information.
  */
-int num_hosts;
-int apiHBAInstance;
-
-/*
- * Module parameter information and variables
- */
-int ql2xmaxqdepth;
-module_param(ql2xmaxqdepth, int, S_IRUGO|S_IWUSR);
-MODULE_PARM_DESC(ql2xmaxqdepth,
-               "Maximum queue depth to report for target devices.");
+static int num_hosts;
 
 int ql2xlogintimeout = 20;
 module_param(ql2xlogintimeout, int, S_IRUGO|S_IRUSR);
@@ -69,12 +54,6 @@ MODULE_PARM_DESC(qlport_down_retry,
                "Maximum number of command retries to a port that returns"
                "a PORT-DOWN status.");
 
-int ql2xretrycount = 20;
-module_param(ql2xretrycount, int, S_IRUGO|S_IWUSR);
-MODULE_PARM_DESC(ql2xretrycount,
-               "Maximum number of mid-layer retries allowed for a command.  "
-               "Default value is 20, ");
-
 int ql2xplogiabsentdevice;
 module_param(ql2xplogiabsentdevice, int, S_IRUGO|S_IWUSR);
 MODULE_PARM_DESC(ql2xplogiabsentdevice,
@@ -95,25 +74,6 @@ MODULE_PARM_DESC(ql2xintrdelaytimer,
                "ZIO: Waiting time for Firmware before it generates an "
                "interrupt to the host to notify completion of request.");
 
-int ConfigRequired;
-module_param(ConfigRequired, int, S_IRUGO|S_IRUSR);
-MODULE_PARM_DESC(ConfigRequired,
-               "If 1, then only configured devices passed in through the"
-               "ql2xopts parameter will be presented to the OS");
-
-int Bind = BIND_BY_PORT_NAME;
-module_param(Bind, int, S_IRUGO|S_IRUSR);
-MODULE_PARM_DESC(Bind,
-               "Target persistent binding method: "
-               "0 by Portname (default); 1 by PortID; 2 by Nodename. ");
-
-int ql2xsuspendcount = SUSPEND_COUNT;
-module_param(ql2xsuspendcount, int, S_IRUGO|S_IWUSR);
-MODULE_PARM_DESC(ql2xsuspendcount,
-               "Number of 6-second suspend iterations to perform while a "
-               "target returns a <NOT READY> status.  Default is 10 "
-               "iterations.");
-
 int ql2xloginretrycount = 0;
 module_param(ql2xloginretrycount, int, S_IRUGO|S_IRUSR);
 MODULE_PARM_DESC(ql2xloginretrycount,
@@ -330,7 +290,6 @@ qla2x00_queuecommand(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *))
        sp->fcport = fcport;
        sp->cmd = cmd;
        sp->flags = 0;
-       sp->err_id = 0;
 
        CMD_SP(cmd) = (void *)sp;
        cmd->scsi_done = done;
@@ -474,7 +433,6 @@ qla2x00_wait_for_loop_ready(scsi_qla_host_t *ha)
 
        while ((!atomic_read(&ha->loop_down_timer) &&
            atomic_read(&ha->loop_state) == LOOP_DOWN) ||
-           test_bit(CFG_ACTIVE, &ha->cfg_flags) ||
            atomic_read(&ha->loop_state) != LOOP_READY) {
                msleep(1000);
                if (time_after_eq(jiffies, loop_timeout)) {
@@ -518,7 +476,6 @@ qla2xxx_eh_abort(struct scsi_cmnd *cmd)
        serial = cmd->serial_number;
 
        /* Check active list for command command. */
-       spin_unlock_irq(ha->host->host_lock);
        spin_lock(&ha->hardware_lock);
        for (i = 1; i < MAX_OUTSTANDING_COMMANDS; i++) {
                sp = ha->outstanding_cmds[i];
@@ -558,7 +515,6 @@ qla2xxx_eh_abort(struct scsi_cmnd *cmd)
                }
                spin_lock(&ha->hardware_lock);
        }
-       spin_lock_irq(ha->host->host_lock);
 
        qla_printk(KERN_INFO, ha, 
            "scsi(%ld:%d:%d): Abort command issued -- %lx %x.\n", ha->host_no,
@@ -657,12 +613,8 @@ qla2xxx_eh_device_reset(struct scsi_cmnd *cmd)
        qla_printk(KERN_INFO, ha,
            "scsi(%ld:%d:%d): DEVICE RESET ISSUED.\n", ha->host_no, id, lun);
 
-       spin_unlock_irq(ha->host->host_lock);
-
-       if (qla2x00_wait_for_hba_online(ha) != QLA_SUCCESS) {
-               spin_lock_irq(ha->host->host_lock);
+       if (qla2x00_wait_for_hba_online(ha) != QLA_SUCCESS)
                goto eh_dev_reset_done;
-       }
 
        if (qla2x00_wait_for_loop_ready(ha) == QLA_SUCCESS) {
                if (qla2x00_device_reset(ha, fcport) == 0)
@@ -713,8 +665,6 @@ qla2xxx_eh_device_reset(struct scsi_cmnd *cmd)
            "scsi(%ld:%d:%d): DEVICE RESET SUCCEEDED.\n", ha->host_no, id, lun);
 
 eh_dev_reset_done:
-       spin_lock_irq(ha->host->host_lock);
-
        return ret;
 }
 
@@ -1194,34 +1144,24 @@ int qla2x00_probe_one(struct pci_dev *pdev, struct qla_board_info *brd_info)
 
        spin_lock_init(&ha->hardware_lock);
 
-       /* 4.23 Initialize /proc/scsi/qla2x00 counters */
-       ha->actthreads = 0;
-       ha->qthreads   = 0;
-       ha->total_isr_cnt = 0;
-       ha->total_isp_aborts = 0;
-       ha->total_lip_cnt = 0;
-       ha->total_dev_errs = 0;
-       ha->total_ios = 0;
-       ha->total_bytes = 0;
-
        ha->prev_topology = 0;
        ha->ports = MAX_BUSES;
 
        if (IS_QLA2100(ha)) {
-               ha->max_targets = MAX_TARGETS_2100;
+               host->max_id = MAX_TARGETS_2100;
                ha->mbx_count = MAILBOX_REGISTER_COUNT_2100;
                ha->request_q_length = REQUEST_ENTRY_CNT_2100;
                ha->response_q_length = RESPONSE_ENTRY_CNT_2100;
                ha->last_loop_id = SNS_LAST_LOOP_ID_2100;
                host->sg_tablesize = 32;
        } else if (IS_QLA2200(ha)) {
-               ha->max_targets = MAX_TARGETS_2200;
+               host->max_id = MAX_TARGETS_2200;
                ha->mbx_count = MAILBOX_REGISTER_COUNT;
                ha->request_q_length = REQUEST_ENTRY_CNT_2200;
                ha->response_q_length = RESPONSE_ENTRY_CNT_2100;
                ha->last_loop_id = SNS_LAST_LOOP_ID_2100;
        } else /*if (IS_QLA2300(ha))*/ {
-               ha->max_targets = MAX_TARGETS_2200;
+               host->max_id = MAX_TARGETS_2200;
                ha->mbx_count = MAILBOX_REGISTER_COUNT;
                ha->request_q_length = REQUEST_ENTRY_CNT_2200;
                ha->response_q_length = RESPONSE_ENTRY_CNT_2300;
@@ -1265,8 +1205,7 @@ int qla2x00_probe_one(struct pci_dev *pdev, struct qla_board_info *brd_info)
        host->unique_id = ha->instance;
        host->max_cmd_len = MAX_CMDSZ;
        host->max_channel = ha->ports - 1;
-       host->max_id = ha->max_targets;
-       host->max_lun = ha->max_luns;
+       host->max_lun = MAX_LUNS;
        host->transportt = qla2xxx_transport_template;
        if (scsi_add_host(host, &pdev->dev))
                goto probe_alloc_failed;
@@ -2336,8 +2275,7 @@ static int __init
 qla2x00_module_init(void)
 {
        /* Allocate cache for SRBs. */
-       sprintf(srb_cachep_name, "qla2xxx_srbs");
-       srb_cachep = kmem_cache_create(srb_cachep_name, sizeof(srb_t), 0,
+       srb_cachep = kmem_cache_create("qla2xxx_srbs", sizeof(srb_t), 0,
            SLAB_HWCACHE_ALIGN, NULL, NULL);
        if (srb_cachep == NULL) {
                printk(KERN_ERR
@@ -2365,16 +2303,7 @@ qla2x00_module_init(void)
 static void __exit
 qla2x00_module_exit(void)
 {
-       /* Free SRBs cache. */
-       if (srb_cachep != NULL) {
-               if (kmem_cache_destroy(srb_cachep) != 0) {
-                       printk(KERN_ERR
-                           "qla2xxx: Unable to free SRB cache...Memory pools "
-                           "still active?\n");
-               }
-               srb_cachep = NULL;
-       }
-
+       kmem_cache_destroy(srb_cachep);
        fc_release_transport(qla2xxx_transport_template);
 }