diff mbox series

[v2,37/44] qla2xxx: Stop using the SCSI pointer

Message ID 20220208172514.3481-38-bvanassche@acm.org
State Superseded
Headers show
Series Remove the SCSI pointer from struct scsi_cmnd | expand

Commit Message

Bart Van Assche Feb. 8, 2022, 5:25 p.m. UTC
Instead of using the SCp.ptr field to track whether or not a command is
in flight, use the sp->type field to track this information. sp->type
must be set for proper operation of the qla2xxx driver. See e.g. the
switch (sp->type) statement in qla2x00_ct_entry().

This patch prepares for removal of the SCSI pointer from struct scsi_cmnd.

Cc: Nilesh Javali <njavali@marvell.com>
Cc: Himanshu Madhani <himanshu.madhani@oracle.com>
Cc: Daniel Wagner <dwagner@suse.de>
Cc: Ewan D. Milne <emilne@redhat.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/qla2xxx/qla_def.h |  2 --
 drivers/scsi/qla2xxx/qla_os.c  | 13 +++++--------
 2 files changed, 5 insertions(+), 10 deletions(-)

Comments

Himanshu Madhani Feb. 8, 2022, 6:38 p.m. UTC | #1
> On Feb 8, 2022, at 9:25 AM, Bart Van Assche <bvanassche@acm.org> wrote:
> 
> Instead of using the SCp.ptr field to track whether or not a command is
> in flight, use the sp->type field to track this information. sp->type
> must be set for proper operation of the qla2xxx driver. See e.g. the
> switch (sp->type) statement in qla2x00_ct_entry().
> 
> This patch prepares for removal of the SCSI pointer from struct scsi_cmnd.
> 
> Cc: Nilesh Javali <njavali@marvell.com>
> Cc: Himanshu Madhani <himanshu.madhani@oracle.com>
> Cc: Daniel Wagner <dwagner@suse.de>
> Cc: Ewan D. Milne <emilne@redhat.com>
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
> drivers/scsi/qla2xxx/qla_def.h |  2 --
> drivers/scsi/qla2xxx/qla_os.c  | 13 +++++--------
> 2 files changed, 5 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
> index 9ebf4a234d9a..064496f9eba3 100644
> --- a/drivers/scsi/qla2xxx/qla_def.h
> +++ b/drivers/scsi/qla2xxx/qla_def.h
> @@ -5191,8 +5191,6 @@ struct secure_flash_update_block_pk {
> 
> #define	QLA_DSDS_PER_IOCB	37
> 
> -#define CMD_SP(Cmnd)		((Cmnd)->SCp.ptr)
> -
> #define QLA_SG_ALL	1024
> 
> enum nexus_wait_type {
> diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
> index abcd30917263..6c45379a5306 100644
> --- a/drivers/scsi/qla2xxx/qla_os.c
> +++ b/drivers/scsi/qla2xxx/qla_os.c
> @@ -730,7 +730,7 @@ void qla2x00_sp_compl(srb_t *sp, int res)
> 
> 	sp->free(sp);
> 	cmd->result = res;
> -	CMD_SP(cmd) = NULL;
> +	sp->type = 0;
> 	scsi_done(cmd);
> 	if (comp)
> 		complete(comp);
> @@ -821,7 +821,7 @@ void qla2xxx_qpair_sp_compl(srb_t *sp, int res)
> 
> 	sp->free(sp);
> 	cmd->result = res;
> -	CMD_SP(cmd) = NULL;
> +	sp->type = 0;
> 	scsi_done(cmd);
> 	if (comp)
> 		complete(comp);
> @@ -923,8 +923,6 @@ qla2xxx_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd)
> 
> 	sp->u.scmd.cmd = cmd;
> 	sp->type = SRB_SCSI_CMD;
> -
> -	CMD_SP(cmd) = (void *)sp;
> 	sp->free = qla2x00_sp_free_dma;
> 	sp->done = qla2x00_sp_compl;
> 
> @@ -1012,7 +1010,6 @@ qla2xxx_mqueuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd,
> 
> 	sp->u.scmd.cmd = cmd;
> 	sp->type = SRB_SCSI_CMD;
> -	CMD_SP(cmd) = (void *)sp;
> 	sp->free = qla2xxx_qpair_sp_free_dma;
> 	sp->done = qla2xxx_qpair_sp_compl;
> 
> @@ -1057,6 +1054,7 @@ qla2x00_eh_wait_on_command(struct scsi_cmnd *cmd)
> 	unsigned long wait_iter = ABORT_WAIT_ITER;
> 	scsi_qla_host_t *vha = shost_priv(cmd->device->host);
> 	struct qla_hw_data *ha = vha->hw;
> +	srb_t *sp = scsi_cmd_priv(cmd);
> 	int ret = QLA_SUCCESS;
> 
> 	if (unlikely(pci_channel_offline(ha->pdev)) || ha->flags.eeh_busy) {
> @@ -1065,10 +1063,9 @@ qla2x00_eh_wait_on_command(struct scsi_cmnd *cmd)
> 		return ret;
> 	}
> 
> -	while (CMD_SP(cmd) && wait_iter--) {
> +	while (sp->type && wait_iter--)
> 		msleep(ABORT_POLLING_PERIOD);
> -	}
> -	if (CMD_SP(cmd))
> +	if (sp->type)
> 		ret = QLA_FUNCTION_FAILED;
> 
> 	return ret;

Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>

--
Himanshu Madhani	 Oracle Linux Engineering
Hannes Reinecke Feb. 9, 2022, 8:24 a.m. UTC | #2
On 2/8/22 18:25, Bart Van Assche wrote:
> Instead of using the SCp.ptr field to track whether or not a command is
> in flight, use the sp->type field to track this information. sp->type
> must be set for proper operation of the qla2xxx driver. See e.g. the
> switch (sp->type) statement in qla2x00_ct_entry().
> 
> This patch prepares for removal of the SCSI pointer from struct scsi_cmnd.
> 
> Cc: Nilesh Javali <njavali@marvell.com>
> Cc: Himanshu Madhani <himanshu.madhani@oracle.com>
> Cc: Daniel Wagner <dwagner@suse.de>
> Cc: Ewan D. Milne <emilne@redhat.com>
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
>   drivers/scsi/qla2xxx/qla_def.h |  2 --
>   drivers/scsi/qla2xxx/qla_os.c  | 13 +++++--------
>   2 files changed, 5 insertions(+), 10 deletions(-)
> 
Reviewed-by: Hannes Reinecke <hare@suse.de>

Cheers,

Hannes
Daniel Wagner Feb. 9, 2022, 10:11 a.m. UTC | #3
On Tue, Feb 08, 2022 at 09:25:07AM -0800, Bart Van Assche wrote:
> Instead of using the SCp.ptr field to track whether or not a command is
> in flight, use the sp->type field to track this information. sp->type
> must be set for proper operation of the qla2xxx driver. See e.g. the
> switch (sp->type) statement in qla2x00_ct_entry().
> 
> This patch prepares for removal of the SCSI pointer from struct scsi_cmnd.
> 
> Cc: Nilesh Javali <njavali@marvell.com>
> Cc: Himanshu Madhani <himanshu.madhani@oracle.com>
> Cc: Daniel Wagner <dwagner@suse.de>
> Cc: Ewan D. Milne <emilne@redhat.com>
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>

Reviewed-by: Daniel Wagner <dwagner@suse.de>
diff mbox series

Patch

diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
index 9ebf4a234d9a..064496f9eba3 100644
--- a/drivers/scsi/qla2xxx/qla_def.h
+++ b/drivers/scsi/qla2xxx/qla_def.h
@@ -5191,8 +5191,6 @@  struct secure_flash_update_block_pk {
 
 #define	QLA_DSDS_PER_IOCB	37
 
-#define CMD_SP(Cmnd)		((Cmnd)->SCp.ptr)
-
 #define QLA_SG_ALL	1024
 
 enum nexus_wait_type {
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index abcd30917263..6c45379a5306 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -730,7 +730,7 @@  void qla2x00_sp_compl(srb_t *sp, int res)
 
 	sp->free(sp);
 	cmd->result = res;
-	CMD_SP(cmd) = NULL;
+	sp->type = 0;
 	scsi_done(cmd);
 	if (comp)
 		complete(comp);
@@ -821,7 +821,7 @@  void qla2xxx_qpair_sp_compl(srb_t *sp, int res)
 
 	sp->free(sp);
 	cmd->result = res;
-	CMD_SP(cmd) = NULL;
+	sp->type = 0;
 	scsi_done(cmd);
 	if (comp)
 		complete(comp);
@@ -923,8 +923,6 @@  qla2xxx_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd)
 
 	sp->u.scmd.cmd = cmd;
 	sp->type = SRB_SCSI_CMD;
-
-	CMD_SP(cmd) = (void *)sp;
 	sp->free = qla2x00_sp_free_dma;
 	sp->done = qla2x00_sp_compl;
 
@@ -1012,7 +1010,6 @@  qla2xxx_mqueuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd,
 
 	sp->u.scmd.cmd = cmd;
 	sp->type = SRB_SCSI_CMD;
-	CMD_SP(cmd) = (void *)sp;
 	sp->free = qla2xxx_qpair_sp_free_dma;
 	sp->done = qla2xxx_qpair_sp_compl;
 
@@ -1057,6 +1054,7 @@  qla2x00_eh_wait_on_command(struct scsi_cmnd *cmd)
 	unsigned long wait_iter = ABORT_WAIT_ITER;
 	scsi_qla_host_t *vha = shost_priv(cmd->device->host);
 	struct qla_hw_data *ha = vha->hw;
+	srb_t *sp = scsi_cmd_priv(cmd);
 	int ret = QLA_SUCCESS;
 
 	if (unlikely(pci_channel_offline(ha->pdev)) || ha->flags.eeh_busy) {
@@ -1065,10 +1063,9 @@  qla2x00_eh_wait_on_command(struct scsi_cmnd *cmd)
 		return ret;
 	}
 
-	while (CMD_SP(cmd) && wait_iter--) {
+	while (sp->type && wait_iter--)
 		msleep(ABORT_POLLING_PERIOD);
-	}
-	if (CMD_SP(cmd))
+	if (sp->type)
 		ret = QLA_FUNCTION_FAILED;
 
 	return ret;