mirror of
https://github.com/SCST-project/scst.git
synced 2026-08-21 14:46:23 +00:00
qla2x00t-32gbit: Let the compiler check the type of the SCSI command context pointer
Split srb_cmd.ctx into two pointers such that the compiler can check the type of that pointer. [ commit 5ec9f9040f61dfd0412a53fa2fc1e321727a5a61 upstream ] git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@8549 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
@@ -331,7 +331,8 @@ struct srb_cmd {
|
||||
uint32_t request_sense_length;
|
||||
uint32_t fw_sense_length;
|
||||
uint8_t *request_sense_ptr;
|
||||
void *ctx;
|
||||
struct ct6_dsd *ct6_ctx;
|
||||
struct crc_context *crc_ctx;
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -648,7 +649,6 @@ typedef struct srb {
|
||||
} srb_t;
|
||||
|
||||
#define GET_CMD_SP(sp) (sp->u.scmd.cmd)
|
||||
#define GET_CMD_CTX_SP(sp) (sp->u.scmd.ctx)
|
||||
|
||||
#define GET_CMD_SENSE_LEN(sp) \
|
||||
(sp->u.scmd.request_sense_length)
|
||||
|
||||
@@ -621,7 +621,7 @@ qla24xx_build_scsi_type_6_iocbs(srb_t *sp, struct cmd_type_6 *cmd_pkt,
|
||||
}
|
||||
|
||||
cur_seg = scsi_sglist(cmd);
|
||||
ctx = GET_CMD_CTX_SP(sp);
|
||||
ctx = sp->u.scmd.ct6_ctx;
|
||||
|
||||
while (tot_dsds) {
|
||||
avail_dsds = (tot_dsds > QLA_DSDS_PER_IOCB) ?
|
||||
@@ -954,8 +954,7 @@ alloc_and_fill:
|
||||
|
||||
if (sp) {
|
||||
list_add_tail(&dsd_ptr->list,
|
||||
&((struct crc_context *)
|
||||
sp->u.scmd.ctx)->dsd_list);
|
||||
&sp->u.scmd.crc_ctx->dsd_list);
|
||||
|
||||
sp->flags |= SRB_CRC_CTX_DSD_VALID;
|
||||
} else {
|
||||
@@ -1052,8 +1051,7 @@ qla24xx_walk_and_build_sglist(struct qla_hw_data *ha, srb_t *sp,
|
||||
|
||||
if (sp) {
|
||||
list_add_tail(&dsd_ptr->list,
|
||||
&((struct crc_context *)
|
||||
sp->u.scmd.ctx)->dsd_list);
|
||||
&sp->u.scmd.crc_ctx->dsd_list);
|
||||
|
||||
sp->flags |= SRB_CRC_CTX_DSD_VALID;
|
||||
} else {
|
||||
@@ -1100,7 +1098,7 @@ qla24xx_walk_and_build_prot_sglist(struct qla_hw_data *ha, srb_t *sp,
|
||||
|
||||
sgl = scsi_prot_sglist(cmd);
|
||||
vha = sp->vha;
|
||||
difctx = sp->u.scmd.ctx;
|
||||
difctx = sp->u.scmd.crc_ctx;
|
||||
direction_to_device = cmd->sc_data_direction == DMA_TO_DEVICE;
|
||||
ql_dbg(ql_dbg_tgt + ql_dbg_verbose, vha, 0xe021,
|
||||
"%s: scsi_cmnd: %p, crc_ctx: %p, sp: %p\n",
|
||||
@@ -1441,7 +1439,7 @@ qla24xx_build_scsi_crc_2_iocbs(srb_t *sp, struct cmd_type_crc_2 *cmd_pkt,
|
||||
bundling = 0;
|
||||
|
||||
/* Allocate CRC context from global pool */
|
||||
crc_ctx_pkt = sp->u.scmd.ctx =
|
||||
crc_ctx_pkt = sp->u.scmd.crc_ctx =
|
||||
dma_pool_zalloc(ha->dl_dma_pool, GFP_ATOMIC, &crc_ctx_dma);
|
||||
|
||||
if (!crc_ctx_pkt)
|
||||
@@ -3200,7 +3198,7 @@ sufficient_dsds:
|
||||
goto queuing_error;
|
||||
}
|
||||
|
||||
ctx = sp->u.scmd.ctx =
|
||||
ctx = sp->u.scmd.ct6_ctx =
|
||||
mempool_alloc(ha->ctx_mempool, GFP_ATOMIC);
|
||||
if (!ctx) {
|
||||
ql_log(ql_log_fatal, vha, 0x3010,
|
||||
@@ -3396,9 +3394,9 @@ queuing_error:
|
||||
if (tot_dsds)
|
||||
scsi_dma_unmap(cmd);
|
||||
|
||||
if (sp->u.scmd.ctx) {
|
||||
mempool_free(sp->u.scmd.ctx, ha->ctx_mempool);
|
||||
sp->u.scmd.ctx = NULL;
|
||||
if (sp->u.scmd.crc_ctx) {
|
||||
mempool_free(sp->u.scmd.crc_ctx, ha->ctx_mempool);
|
||||
sp->u.scmd.crc_ctx = NULL;
|
||||
}
|
||||
spin_unlock_irqrestore(&ha->hardware_lock, flags);
|
||||
|
||||
|
||||
@@ -3685,7 +3685,7 @@ qla82xx_chip_reset_cleanup(scsi_qla_host_t *vha)
|
||||
for (cnt = 1; cnt < req->num_outstanding_cmds; cnt++) {
|
||||
sp = req->outstanding_cmds[cnt];
|
||||
if (sp) {
|
||||
if ((!sp->u.scmd.ctx ||
|
||||
if ((!sp->u.scmd.crc_ctx ||
|
||||
(sp->flags &
|
||||
SRB_FCP_CMND_DMA_VALID)) &&
|
||||
!ha->flags.isp82xx_fw_hung) {
|
||||
|
||||
@@ -676,7 +676,6 @@ void qla2x00_sp_free_dma(srb_t *sp)
|
||||
{
|
||||
struct qla_hw_data *ha = sp->vha->hw;
|
||||
struct scsi_cmnd *cmd = GET_CMD_SP(sp);
|
||||
void *ctx = GET_CMD_CTX_SP(sp);
|
||||
|
||||
if (sp->flags & SRB_DMA_VALID) {
|
||||
scsi_dma_unmap(cmd);
|
||||
@@ -689,24 +688,21 @@ void qla2x00_sp_free_dma(srb_t *sp)
|
||||
sp->flags &= ~SRB_CRC_PROT_DMA_VALID;
|
||||
}
|
||||
|
||||
if (!ctx)
|
||||
return;
|
||||
|
||||
if (sp->flags & SRB_CRC_CTX_DSD_VALID) {
|
||||
/* List assured to be having elements */
|
||||
qla2x00_clean_dsd_pool(ha, ctx);
|
||||
qla2x00_clean_dsd_pool(ha, sp->u.scmd.crc_ctx);
|
||||
sp->flags &= ~SRB_CRC_CTX_DSD_VALID;
|
||||
}
|
||||
|
||||
if (sp->flags & SRB_CRC_CTX_DMA_VALID) {
|
||||
struct crc_context *ctx0 = ctx;
|
||||
struct crc_context *ctx0 = sp->u.scmd.crc_ctx;
|
||||
|
||||
dma_pool_free(ha->dl_dma_pool, ctx0, ctx0->crc_ctx_dma);
|
||||
sp->flags &= ~SRB_CRC_CTX_DMA_VALID;
|
||||
}
|
||||
|
||||
if (sp->flags & SRB_FCP_CMND_DMA_VALID) {
|
||||
struct ct6_dsd *ctx1 = ctx;
|
||||
struct ct6_dsd *ctx1 = sp->u.scmd.ct6_ctx;
|
||||
|
||||
dma_pool_free(ha->fcp_cmnd_dma_pool, ctx1->fcp_cmnd,
|
||||
ctx1->fcp_cmnd_dma);
|
||||
@@ -739,7 +735,6 @@ void qla2xxx_qpair_sp_free_dma(srb_t *sp)
|
||||
{
|
||||
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);
|
||||
@@ -752,17 +747,14 @@ void qla2xxx_qpair_sp_free_dma(srb_t *sp)
|
||||
sp->flags &= ~SRB_CRC_PROT_DMA_VALID;
|
||||
}
|
||||
|
||||
if (!ctx)
|
||||
return;
|
||||
|
||||
if (sp->flags & SRB_CRC_CTX_DSD_VALID) {
|
||||
/* List assured to be having elements */
|
||||
qla2x00_clean_dsd_pool(ha, ctx);
|
||||
qla2x00_clean_dsd_pool(ha, sp->u.scmd.crc_ctx);
|
||||
sp->flags &= ~SRB_CRC_CTX_DSD_VALID;
|
||||
}
|
||||
|
||||
if (sp->flags & SRB_DIF_BUNDL_DMA_VALID) {
|
||||
struct crc_context *difctx = ctx;
|
||||
struct crc_context *difctx = sp->u.scmd.crc_ctx;
|
||||
struct dsd_dma *dif_dsd, *nxt_dsd;
|
||||
|
||||
list_for_each_entry_safe(dif_dsd, nxt_dsd,
|
||||
@@ -798,7 +790,7 @@ void qla2xxx_qpair_sp_free_dma(srb_t *sp)
|
||||
}
|
||||
|
||||
if (sp->flags & SRB_FCP_CMND_DMA_VALID) {
|
||||
struct ct6_dsd *ctx1 = ctx;
|
||||
struct ct6_dsd *ctx1 = sp->u.scmd.ct6_ctx;
|
||||
|
||||
dma_pool_free(ha->fcp_cmnd_dma_pool, ctx1->fcp_cmnd,
|
||||
ctx1->fcp_cmnd_dma);
|
||||
@@ -810,9 +802,9 @@ void qla2xxx_qpair_sp_free_dma(srb_t *sp)
|
||||
}
|
||||
|
||||
if (sp->flags & SRB_CRC_CTX_DMA_VALID) {
|
||||
struct crc_context *ctx0 = ctx;
|
||||
struct crc_context *ctx0 = sp->u.scmd.crc_ctx;
|
||||
|
||||
dma_pool_free(ha->dl_dma_pool, ctx, ctx0->crc_ctx_dma);
|
||||
dma_pool_free(ha->dl_dma_pool, ctx0, ctx0->crc_ctx_dma);
|
||||
sp->flags &= ~SRB_CRC_CTX_DMA_VALID;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user