scsi: qla2xxx: Declare fourth qla2x00_set_model_info() argument const
[linux-2.6-block.git] / drivers / scsi / qla2xxx / qla_init.c
index 4059655639d909e8799fe991a6f4d0961820215c..1fd9a086748e39786a986aabb3903ead7605cdee 100644 (file)
@@ -99,9 +99,22 @@ static void qla24xx_abort_iocb_timeout(void *data)
 {
        srb_t *sp = data;
        struct srb_iocb *abt = &sp->u.iocb_cmd;
+       struct qla_qpair *qpair = sp->qpair;
+       u32 handle;
+       unsigned long flags;
+
+       spin_lock_irqsave(qpair->qp_lock_ptr, flags);
+       for (handle = 1; handle < qpair->req->num_outstanding_cmds; handle++) {
+               /* removing the abort */
+               if (qpair->req->outstanding_cmds[handle] == sp) {
+                       qpair->req->outstanding_cmds[handle] = NULL;
+                       break;
+               }
+       }
+       spin_unlock_irqrestore(qpair->qp_lock_ptr, flags);
 
        abt->u.abt.comp_status = CS_TIMEOUT;
-       sp->done(sp, QLA_FUNCTION_TIMEOUT);
+       sp->done(sp, QLA_OS_TIMER_EXPIRED);
 }
 
 static void qla24xx_abort_sp_done(void *ptr, int res)
@@ -109,12 +122,11 @@ static void qla24xx_abort_sp_done(void *ptr, int res)
        srb_t *sp = ptr;
        struct srb_iocb *abt = &sp->u.iocb_cmd;
 
-       if (del_timer(&sp->u.iocb_cmd.timer)) {
-               if (sp->flags & SRB_WAKEUP_ON_COMP)
-                       complete(&abt->u.abt.comp);
-               else
-                       sp->free(sp);
-       }
+       del_timer(&sp->u.iocb_cmd.timer);
+       if (sp->flags & SRB_WAKEUP_ON_COMP)
+               complete(&abt->u.abt.comp);
+       else
+               sp->free(sp);
 }
 
 static int qla24xx_async_abort_cmd(srb_t *cmd_sp, bool wait)
@@ -289,8 +301,13 @@ qla2x00_async_login(struct scsi_qla_host *vha, fc_port_t *fcport,
        struct srb_iocb *lio;
        int rval = QLA_FUNCTION_FAILED;
 
-       if (!vha->flags.online)
-               goto done;
+       if (!vha->flags.online || (fcport->flags & FCF_ASYNC_SENT) ||
+           fcport->loop_id == FC_NO_LOOP_ID) {
+               ql_log(ql_log_warn, vha, 0xffff,
+                   "%s: %8phC - not sending command.\n",
+                   __func__, fcport->port_name);
+               return rval;
+       }
 
        sp = qla2x00_get_sp(vha, fcport, GFP_KERNEL);
        if (!sp)
@@ -359,9 +376,6 @@ qla2x00_async_logout(struct scsi_qla_host *vha, fc_port_t *fcport)
        struct srb_iocb *lio;
        int rval = QLA_FUNCTION_FAILED;
 
-       if (!vha->flags.online || (fcport->flags & FCF_ASYNC_SENT))
-               return rval;
-
        fcport->flags |= FCF_ASYNC_SENT;
        sp = qla2x00_get_sp(vha, fcport, GFP_KERNEL);
        if (!sp)
@@ -1262,8 +1276,13 @@ int qla24xx_async_gpdb(struct scsi_qla_host *vha, fc_port_t *fcport, u8 opt)
        struct port_database_24xx *pd;
        struct qla_hw_data *ha = vha->hw;
 
-       if (!vha->flags.online || (fcport->flags & FCF_ASYNC_SENT))
+       if (!vha->flags.online || (fcport->flags & FCF_ASYNC_SENT) ||
+           fcport->loop_id == FC_NO_LOOP_ID) {
+               ql_log(ql_log_warn, vha, 0xffff,
+                   "%s: %8phC - not sending command.\n",
+                   __func__, fcport->port_name);
                return rval;
+       }
 
        fcport->disc_state = DSC_GPDB;
 
@@ -1663,9 +1682,9 @@ void qla24xx_handle_relogin_event(scsi_qla_host_t *vha,
        }
 
        if (fcport->last_rscn_gen != fcport->rscn_gen) {
-               ql_dbg(ql_dbg_disc, vha, 0x20e9, "%s %d %8phC post gidpn\n",
+               ql_dbg(ql_dbg_disc, vha, 0x20e9, "%s %d %8phC post gnl\n",
                    __func__, __LINE__, fcport->port_name);
-
+               qla24xx_post_gnl_work(vha, fcport);
                return;
        }
 
@@ -1953,8 +1972,11 @@ qla24xx_handle_plogi_done_event(struct scsi_qla_host *vha, struct event_arg *ea)
                return;
        }
 
-       if (fcport->disc_state == DSC_DELETE_PEND)
+       if ((fcport->disc_state == DSC_DELETE_PEND) ||
+           (fcport->disc_state == DSC_DELETED)) {
+               set_bit(RELOGIN_NEEDED, &vha->dpc_flags);
                return;
+       }
 
        if (ea->sp->gen2 != fcport->login_gen) {
                /* target side must have changed it. */
@@ -2266,6 +2288,10 @@ qla2x00_initialize_adapter(scsi_qla_host_t *vha)
        if (qla_ini_mode_enabled(vha) || qla_dual_mode_enabled(vha))
                rval = qla2x00_init_rings(vha);
 
+       /* No point in continuing if firmware initialization failed. */
+       if (rval != QLA_SUCCESS)
+               return rval;
+
        ha->flags.chip_reset_done = 1;
 
        if (rval == QLA_SUCCESS && IS_QLA84XX(ha)) {
@@ -4400,7 +4426,7 @@ qla2x00_configure_hba(scsi_qla_host_t *vha)
 
 inline void
 qla2x00_set_model_info(scsi_qla_host_t *vha, uint8_t *model, size_t len,
-       char *def)
+                      const char *def)
 {
        char *st, *en;
        uint16_t index;
@@ -5058,7 +5084,7 @@ qla2x00_configure_local_loop(scsi_qla_host_t *vha)
 
        uint16_t        index;
        uint16_t        entries;
-       char            *id_iter;
+       struct gid_list_info *gid;
        uint16_t        loop_id;
        uint8_t         domain, area, al_pa;
        struct qla_hw_data *ha = vha->hw;
@@ -5133,18 +5159,16 @@ qla2x00_configure_local_loop(scsi_qla_host_t *vha)
        new_fcport->flags &= ~FCF_FABRIC_DEVICE;
 
        /* Add devices to port list. */
-       id_iter = (char *)ha->gid_list;
+       gid = ha->gid_list;
        for (index = 0; index < entries; index++) {
-               domain = ((struct gid_list_info *)id_iter)->domain;
-               area = ((struct gid_list_info *)id_iter)->area;
-               al_pa = ((struct gid_list_info *)id_iter)->al_pa;
+               domain = gid->domain;
+               area = gid->area;
+               al_pa = gid->al_pa;
                if (IS_QLA2100(ha) || IS_QLA2200(ha))
-                       loop_id = (uint16_t)
-                           ((struct gid_list_info *)id_iter)->loop_id_2100;
+                       loop_id = gid->loop_id_2100;
                else
-                       loop_id = le16_to_cpu(
-                           ((struct gid_list_info *)id_iter)->loop_id);
-               id_iter += ha->gid_list_info_size;
+                       loop_id = le16_to_cpu(gid->loop_id);
+               gid = (void *)gid + ha->gid_list_info_size;
 
                /* Bypass reserved domain fields. */
                if ((domain & 0xf0) == 0xf0)
@@ -5369,7 +5393,7 @@ qla2x00_reg_remote_port(scsi_qla_host_t *vha, fc_port_t *fcport)
            "%s %8phN. rport %p is %s mode\n",
            __func__, fcport->port_name, rport,
            (fcport->port_type == FCT_TARGET) ? "tgt" :
-           ((fcport->port_type & FCT_NVME) ? "nvme" :"ini"));
+           ((fcport->port_type & FCT_NVME) ? "nvme" : "ini"));
 
        fc_remote_port_rolechg(rport, rport_ids.roles);
 }
@@ -6698,8 +6722,10 @@ qla2x00_abort_isp_cleanup(scsi_qla_host_t *vha)
        }
 
        /* Clear all async request states across all VPs. */
-       list_for_each_entry(fcport, &vha->vp_fcports, list)
+       list_for_each_entry(fcport, &vha->vp_fcports, list) {
                fcport->flags &= ~(FCF_LOGIN_NEEDED | FCF_ASYNC_SENT);
+               fcport->scan_state = 0;
+       }
        spin_lock_irqsave(&ha->vport_slock, flags);
        list_for_each_entry(vp, &ha->vp_list, list) {
                atomic_inc(&vp->vref_count);