]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
qla2xxx: Further consolidation of SRB related code changes.
authorGiridhar Malavali <giridhar.malavali@qlogic.com>
Wed, 11 Apr 2012 06:03:27 +0000 (11:33 +0530)
committerMaxim Uvarov <maxim.uvarov@oracle.com>
Wed, 9 May 2012 00:40:58 +0000 (17:40 -0700)
JIRA Key: V2632FC-134

Signed-off-by: Saurav Kashyap <saurav.kashyap@qlogic.com>
drivers/scsi/qla2xxx/qla_gbl.h
drivers/scsi/qla2xxx/qla_init.c
drivers/scsi/qla2xxx/qla_inline.h
drivers/scsi/qla2xxx/qla_os.c

index bc9180f495f70f0b318c142907e7791e07f52933..bc98d92aea4fa6218551094d88d9263e20c54656 100644 (file)
@@ -154,7 +154,6 @@ extern void qla2x00_do_dpc_all_vps(scsi_qla_host_t *);
 extern int qla24xx_vport_create_req_sanity_check(struct fc_vport *);
 extern scsi_qla_host_t * qla24xx_create_vhost(struct fc_vport *);
 
-extern void qla2x00_sp_compl(void *, void *, int);
 extern void qla2x00_sp_free_dma(void *, void *);
 extern char *qla2x00_get_fw_version_str(struct scsi_qla_host *, char *);
 
index eef0e73eb4f8e487d66da5411858ee1e283ffdfe..6e13cc25bc97d9e4a92d688b021a5fbf60ed43fe 100644 (file)
@@ -137,8 +137,6 @@ qla2x00_async_login(struct scsi_qla_host *vha, fc_port_t *fcport,
        srb_t *sp;
        struct srb_iocb *lio;
        int rval;
-       unsigned long flags;
-       struct qla_hw_data *ha = vha->hw;
 
        rval = QLA_FUNCTION_FAILED;
        sp = qla2x00_get_sp(vha, fcport, GFP_KERNEL);
@@ -166,9 +164,7 @@ qla2x00_async_login(struct scsi_qla_host *vha, fc_port_t *fcport,
        return rval;
 
 done_free_sp:
-       spin_lock_irqsave(&ha->hardware_lock, flags);
        sp->free(vha, sp);
-       spin_unlock_irqrestore(&ha->hardware_lock, flags);
 done:
        return rval;
 }
@@ -192,8 +188,6 @@ qla2x00_async_logout(struct scsi_qla_host *vha, fc_port_t *fcport)
        srb_t *sp;
        struct srb_iocb *lio;
        int rval;
-       unsigned long flags;
-       struct qla_hw_data *ha = vha->hw;
 
        rval = QLA_FUNCTION_FAILED;
        sp = qla2x00_get_sp(vha, fcport, GFP_KERNEL);
@@ -218,9 +212,7 @@ qla2x00_async_logout(struct scsi_qla_host *vha, fc_port_t *fcport)
        return rval;
 
 done_free_sp:
-       spin_lock_irqsave(&ha->hardware_lock, flags);
        sp->free(vha, sp);
-       spin_unlock_irqrestore(&ha->hardware_lock, flags);
 done:
        return rval;
 }
@@ -245,8 +237,6 @@ qla2x00_async_adisc(struct scsi_qla_host *vha, fc_port_t *fcport,
        srb_t *sp;
        struct srb_iocb *lio;
        int rval;
-       struct qla_hw_data *ha = vha->hw;
-       unsigned long flags;
 
        rval = QLA_FUNCTION_FAILED;
        sp = qla2x00_get_sp(vha, fcport, GFP_KERNEL);
@@ -272,9 +262,7 @@ qla2x00_async_adisc(struct scsi_qla_host *vha, fc_port_t *fcport,
        return rval;
 
 done_free_sp:
-       spin_lock_irqsave(&ha->hardware_lock, flags);
        sp->free(vha, sp);
-       spin_unlock_irqrestore(&ha->hardware_lock, flags);
 done:
        return rval;
 }
@@ -314,8 +302,6 @@ qla2x00_async_tm_cmd(fc_port_t *fcport, uint32_t tm_flags, uint32_t lun,
        srb_t *sp;
        struct srb_iocb *tcf;
        int rval;
-       struct qla_hw_data *ha = vha->hw;
-       unsigned long flags;
 
        rval = QLA_FUNCTION_FAILED;
        sp = qla2x00_get_sp(vha, fcport, GFP_KERNEL);
@@ -324,13 +310,7 @@ qla2x00_async_tm_cmd(fc_port_t *fcport, uint32_t tm_flags, uint32_t lun,
 
        sp->type = SRB_TM_CMD;
        sp->name = "tmf";
-       if (qla2x00_init_timer(sp, qla2x00_get_async_timeout(vha) + 2)) {
-               spin_lock_irqsave(&ha->hardware_lock, flags);
-               mempool_free(sp, ha->srb_mempool);
-               spin_unlock_irqrestore(&ha->hardware_lock, flags);
-               sp = NULL;
-               goto done;
-       }
+       qla2x00_init_timer(sp, qla2x00_get_async_timeout(vha) + 2);
 
        tcf = &sp->u.iocb_cmd;
        tcf->u.tmf.flags = tm_flags;
@@ -350,9 +330,7 @@ qla2x00_async_tm_cmd(fc_port_t *fcport, uint32_t tm_flags, uint32_t lun,
        return rval;
 
 done_free_sp:
-       spin_lock_irqsave(&ha->hardware_lock, flags);
        sp->free(vha, sp);
-       spin_unlock_irqrestore(&ha->hardware_lock, flags);
 done:
        return rval;
 }
index ca4c92e8dabcf926f13fe379ca7370470a004895..c4c6ce08c2d2840642e894893cedaee1b7c4415b 100644 (file)
@@ -155,7 +155,7 @@ qla2x00_get_sp(scsi_qla_host_t *vha, fc_port_t *fcport, gfp_t flag)
        uint8_t bail;
 
        QLA_VHA_MARK_BUSY(vha, bail);
-       if (bail)
+       if (unlikely(bail))
                return NULL;
 
        sp = mempool_alloc(ha->srb_mempool, flag);
@@ -171,7 +171,7 @@ done:
        return sp;
 }
 
-static inline int
+static inline void
 qla2x00_init_timer(srb_t *sp, unsigned long tmo)
 {
        init_timer(&sp->u.iocb_cmd.timer);
@@ -180,19 +180,6 @@ qla2x00_init_timer(srb_t *sp, unsigned long tmo)
        sp->u.iocb_cmd.timer.function = qla2x00_sp_timeout;
        add_timer(&sp->u.iocb_cmd.timer);
        sp->free = qla2x00_sp_free;
-       return QLA_SUCCESS;
-}
-
-static inline int
-qla2x00_init_scmd(srb_t *sp, struct scsi_cmnd *cmd)
-{
-       sp->u.scmd.cmd = cmd;
-       sp->type = SRB_SCSI_CMD;
-       atomic_set(&sp->ref_count, 1);
-       CMD_SP(cmd) = (void *)sp;
-       sp->free = qla2x00_sp_free_dma;
-       sp->done = qla2x00_sp_compl;
-       return QLA_SUCCESS;
 }
 
 static inline int
index 360ab7a9d4a0beb1f09ef121dc16d891c276183b..5cd36bc03892ce65910e8ba5b8ad84dfb19ed609 100644 (file)
@@ -558,6 +558,78 @@ qla24xx_fw_version_str(struct scsi_qla_host *vha, char *str)
        return str;
 }
 
+void
+qla2x00_sp_free_dma(void *vha, void *ptr)
+{
+       srb_t *sp = (srb_t *)ptr;
+       struct scsi_cmnd *cmd = GET_CMD_SP(sp);
+       struct qla_hw_data *ha = sp->fcport->vha->hw;
+       void *ctx = GET_CMD_CTX_SP(sp);
+
+       if (sp->flags & SRB_DMA_VALID) {
+               scsi_dma_unmap(cmd);
+               sp->flags &= ~SRB_DMA_VALID;
+       }
+
+       if (sp->flags & SRB_CRC_PROT_DMA_VALID) {
+               dma_unmap_sg(&ha->pdev->dev, scsi_prot_sglist(cmd),
+                   scsi_prot_sg_count(cmd), cmd->sc_data_direction);
+               sp->flags &= ~SRB_CRC_PROT_DMA_VALID;
+       }
+
+       if (sp->flags & SRB_CRC_CTX_DSD_VALID) {
+               /* List assured to be having elements */
+               qla2x00_clean_dsd_pool(ha, sp);
+               sp->flags &= ~SRB_CRC_CTX_DSD_VALID;
+       }
+
+       if (sp->flags & SRB_CRC_CTX_DMA_VALID) {
+               dma_pool_free(ha->dl_dma_pool, ctx,
+                   ((struct crc_context *)ctx)->crc_ctx_dma);
+               sp->flags &= ~SRB_CRC_CTX_DMA_VALID;
+       }
+
+       if (sp->flags & SRB_FCP_CMND_DMA_VALID) {
+               struct ct6_dsd *ctx1 = (struct ct6_dsd *)ctx;
+
+               dma_pool_free(ha->fcp_cmnd_dma_pool, ctx1->fcp_cmnd,
+                       ctx1->fcp_cmnd_dma);
+               list_splice(&ctx1->dsd_list, &ha->gbl_dsd_list);
+               ha->gbl_dsd_inuse -= ctx1->dsd_use_cnt;
+               ha->gbl_dsd_avail += ctx1->dsd_use_cnt;
+               mempool_free(ctx1, ha->ctx_mempool);
+               ctx1 = NULL;
+       }
+
+       CMD_SP(cmd) = NULL;
+       mempool_free(sp, ha->srb_mempool);
+}
+
+static void
+qla2x00_sp_compl(void *data, void *ptr, int res)
+{
+       struct qla_hw_data *ha = (struct qla_hw_data *)data;
+       srb_t *sp = (srb_t*)ptr;
+       struct scsi_cmnd *cmd = GET_CMD_SP(sp);
+
+       if (res)
+               cmd->result = res;
+
+       if (atomic_read(&sp->ref_count) == 0) {
+               ql_dbg(ql_dbg_io, sp->fcport->vha, 0x3015,
+                   "SP reference-count to ZERO -- sp=%p cmd=%p.\n",
+                   sp, GET_CMD_SP(sp));
+               if (ql2xextended_error_logging & ql_dbg_io)
+                       BUG();
+               return;
+       }
+       if (!atomic_dec_and_test(&sp->ref_count))
+               return;
+
+       qla2x00_sp_free_dma(ha, sp);
+       cmd->scsi_done(cmd);
+}
+
 static int
 qla2xxx_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd)
 {
@@ -623,10 +695,12 @@ qla2xxx_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd)
        if (!sp)
                goto qc24_host_busy;
 
-       if (qla2x00_init_scmd(sp, cmd)) {
-               mempool_free(sp, ha->srb_mempool);
-               goto qc24_host_busy;
-       }
+       sp->u.scmd.cmd = cmd;
+       sp->type = SRB_SCSI_CMD;
+       atomic_set(&sp->ref_count, 1);
+       CMD_SP(cmd) = (void *)sp;
+       sp->free = qla2x00_sp_free_dma;
+       sp->done = qla2x00_sp_compl;
 
        rval = ha->isp_ops->start_scsi(sp);
        if (rval != QLA_SUCCESS) {
@@ -3780,78 +3854,6 @@ qla2x00_rst_aen(scsi_qla_host_t *vha)
        }
 }
 
-void
-qla2x00_sp_free_dma(void *vha, void *ptr)
-{
-       srb_t *sp = (srb_t *)ptr;
-       struct scsi_cmnd *cmd = GET_CMD_SP(sp);
-       struct qla_hw_data *ha = sp->fcport->vha->hw;
-       void *ctx = GET_CMD_CTX_SP(sp);
-
-       if (sp->flags & SRB_DMA_VALID) {
-               scsi_dma_unmap(cmd);
-               sp->flags &= ~SRB_DMA_VALID;
-       }
-
-       if (sp->flags & SRB_CRC_PROT_DMA_VALID) {
-               dma_unmap_sg(&ha->pdev->dev, scsi_prot_sglist(cmd),
-                   scsi_prot_sg_count(cmd), cmd->sc_data_direction);
-               sp->flags &= ~SRB_CRC_PROT_DMA_VALID;
-       }
-
-       if (sp->flags & SRB_CRC_CTX_DSD_VALID) {
-               /* List assured to be having elements */
-               qla2x00_clean_dsd_pool(ha, sp);
-               sp->flags &= ~SRB_CRC_CTX_DSD_VALID;
-       }
-
-       if (sp->flags & SRB_CRC_CTX_DMA_VALID) {
-               dma_pool_free(ha->dl_dma_pool, ctx,
-                   ((struct crc_context *)ctx)->crc_ctx_dma);
-               sp->flags &= ~SRB_CRC_CTX_DMA_VALID;
-       }
-
-       if (sp->flags & SRB_FCP_CMND_DMA_VALID) {
-               struct ct6_dsd *ctx1 = (struct ct6_dsd *)ctx;
-
-               dma_pool_free(ha->fcp_cmnd_dma_pool, ctx1->fcp_cmnd,
-                       ctx1->fcp_cmnd_dma);
-               list_splice(&ctx1->dsd_list, &ha->gbl_dsd_list);
-               ha->gbl_dsd_inuse -= ctx1->dsd_use_cnt;
-               ha->gbl_dsd_avail += ctx1->dsd_use_cnt;
-               mempool_free(ctx1, ha->ctx_mempool);
-               ctx1 = NULL;
-       }
-
-       CMD_SP(cmd) = NULL;
-       mempool_free(sp, ha->srb_mempool);
-}
-
-void
-qla2x00_sp_compl(void *data, void *ptr, int res)
-{
-       struct qla_hw_data *ha = (struct qla_hw_data *)data;
-       srb_t *sp = (srb_t*)ptr;
-       struct scsi_cmnd *cmd = GET_CMD_SP(sp);
-
-       if (res)
-               cmd->result = res;
-
-       if (atomic_read(&sp->ref_count) == 0) {
-               ql_dbg(ql_dbg_io, sp->fcport->vha, 0x3015,
-                   "SP reference-count to ZERO -- sp=%p cmd=%p.\n",
-                   sp, GET_CMD_SP(sp));
-               if (ql2xextended_error_logging & ql_dbg_io)
-                       BUG();
-               return;
-       }
-       if (!atomic_dec_and_test(&sp->ref_count))
-               return;
-
-       qla2x00_sp_free_dma(ha, sp);
-       cmd->scsi_done(cmd);
-}
-
 /**************************************************************************
 *   qla2x00_timer
 *