Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial
[linux-2.6-block.git] / drivers / scsi / qla2xxx / qla_bsg.c
index 5afdc3a25014c52ed8f0a449c7dfe4e3dc6c2c9d..aa57bf0af574e872ab6e00dae36f7fe4df1a2199 100644 (file)
@@ -125,7 +125,7 @@ qla24xx_proc_fcp_prio_cfg_cmd(struct fc_bsg_job *bsg_job)
        uint32_t len;
        uint32_t oper;
 
-       if (!(IS_QLA24XX_TYPE(ha) || IS_QLA25XX(ha) || IS_QLA82XX(ha))) {
+       if (!(IS_QLA24XX_TYPE(ha) || IS_QLA25XX(ha) || IS_P3P_TYPE(ha))) {
                ret = -EINVAL;
                goto exit_fcp_prio_cfg;
        }
@@ -559,7 +559,7 @@ qla81xx_reset_loopback_mode(scsi_qla_host_t *vha, uint16_t *config,
        uint16_t new_config[4];
        struct qla_hw_data *ha = vha->hw;
 
-       if (!IS_QLA81XX(ha) && !IS_QLA8031(ha))
+       if (!IS_QLA81XX(ha) && !IS_QLA8031(ha) && !IS_QLA8044(ha))
                goto done_reset_internal;
 
        memset(new_config, 0 , sizeof(new_config));
@@ -627,9 +627,10 @@ qla81xx_set_loopback_mode(scsi_qla_host_t *vha, uint16_t *config,
 {
        int ret = 0;
        int rval = 0;
+       unsigned long rem_tmo = 0, current_tmo = 0;
        struct qla_hw_data *ha = vha->hw;
 
-       if (!IS_QLA81XX(ha) && !IS_QLA8031(ha))
+       if (!IS_QLA81XX(ha) && !IS_QLA8031(ha) && !IS_QLA8044(ha))
                goto done_set_internal;
 
        if (mode == INTERNAL_LOOPBACK)
@@ -652,8 +653,19 @@ qla81xx_set_loopback_mode(scsi_qla_host_t *vha, uint16_t *config,
        }
 
        /* Wait for DCBX complete event */
-       if (!wait_for_completion_timeout(&ha->dcbx_comp,
-           (DCBX_COMP_TIMEOUT * HZ))) {
+       current_tmo = DCBX_COMP_TIMEOUT * HZ;
+       while (1) {
+               rem_tmo = wait_for_completion_timeout(&ha->dcbx_comp,
+                   current_tmo);
+               if (!ha->idc_extend_tmo || rem_tmo) {
+                       ha->idc_extend_tmo = 0;
+                       break;
+               }
+               current_tmo = ha->idc_extend_tmo * HZ;
+               ha->idc_extend_tmo = 0;
+       }
+
+       if (!rem_tmo) {
                ql_dbg(ql_dbg_user, vha, 0x7022,
                    "DCBX completion not received.\n");
                ret = qla81xx_reset_loopback_mode(vha, new_config, 0, 0);
@@ -678,6 +690,7 @@ qla81xx_set_loopback_mode(scsi_qla_host_t *vha, uint16_t *config,
        }
 
        ha->notify_dcbx_comp = 0;
+       ha->idc_extend_tmo = 0;
 
 done_set_internal:
        return rval;
@@ -773,7 +786,7 @@ qla2x00_process_loopback(struct fc_bsg_job *bsg_job)
 
        if (atomic_read(&vha->loop_state) == LOOP_READY &&
            (ha->current_topology == ISP_CFG_F ||
-           ((IS_QLA81XX(ha) || IS_QLA8031(ha)) &&
+           ((IS_QLA81XX(ha) || IS_QLA8031(ha) || IS_QLA8044(ha)) &&
            le32_to_cpu(*(uint32_t *)req_data) == ELS_OPCODE_BYTE
            && req_data_len == MAX_ELS_FRAME_PAYLOAD)) &&
                elreq.options == EXTERNAL_LOOPBACK) {
@@ -783,7 +796,7 @@ qla2x00_process_loopback(struct fc_bsg_job *bsg_job)
                command_sent = INT_DEF_LB_ECHO_CMD;
                rval = qla2x00_echo_test(vha, &elreq, response);
        } else {
-               if (IS_QLA81XX(ha) || IS_QLA8031(ha)) {
+               if (IS_QLA81XX(ha) || IS_QLA8031(ha) || IS_QLA8044(ha)) {
                        memset(config, 0, sizeof(config));
                        memset(new_config, 0, sizeof(new_config));
 
@@ -806,7 +819,7 @@ qla2x00_process_loopback(struct fc_bsg_job *bsg_job)
                            "elreq.options=%04x\n", elreq.options);
 
                        if (elreq.options == EXTERNAL_LOOPBACK)
-                               if (IS_QLA8031(ha))
+                               if (IS_QLA8031(ha) || IS_QLA8044(ha))
                                        rval = qla81xx_set_loopback_mode(vha,
                                            config, new_config, elreq.options);
                                else
@@ -1266,6 +1279,7 @@ qla24xx_iidma(struct fc_bsg_job *bsg_job)
        int rval = 0;
        struct qla_port_param *port_param = NULL;
        fc_port_t *fcport = NULL;
+       int found = 0;
        uint16_t mb[MAILBOX_REGISTER_COUNT];
        uint8_t *rsp_ptr = NULL;
 
@@ -1288,10 +1302,12 @@ qla24xx_iidma(struct fc_bsg_job *bsg_job)
                if (memcmp(port_param->fc_scsi_addr.dest_addr.wwpn,
                        fcport->port_name, sizeof(fcport->port_name)))
                        continue;
+
+               found = 1;
                break;
        }
 
-       if (!fcport) {
+       if (!found) {
                ql_log(ql_log_warn, vha, 0x7049,
                    "Failed to find port.\n");
                return -EINVAL;
@@ -1318,12 +1334,9 @@ qla24xx_iidma(struct fc_bsg_job *bsg_job)
 
        if (rval) {
                ql_log(ql_log_warn, vha, 0x704c,
-                   "iIDMA cmd failed for %02x%02x%02x%02x%02x%02x%02x%02x -- "
-                   "%04x %x %04x %04x.\n", fcport->port_name[0],
-                   fcport->port_name[1], fcport->port_name[2],
-                   fcport->port_name[3], fcport->port_name[4],
-                   fcport->port_name[5], fcport->port_name[6],
-                   fcport->port_name[7], rval, fcport->fp_speed, mb[0], mb[1]);
+                   "iIDMA cmd failed for %8phN -- "
+                   "%04x %x %04x %04x.\n", fcport->port_name,
+                   rval, fcport->fp_speed, mb[0], mb[1]);
                rval = (DID_ERROR << 16);
        } else {
                if (!port_param->mode) {