Message ID | 20220331223424.1054715-6-bvanassche@acm.org |
---|---|
State | Superseded |
Headers | show |
Series | UFS patches for kernel v5.19 | expand |
> ufshcd_lrb.sense_buffer is NULL if ufshcd_lrb.cmd is NULL and > ufshcd_lrb.sense_buffer points at cmd->sense_buffer if ufshcd_lrb.cmd > is set. In other words, the ufshcd_lrb.sense_buffer member is identical > to cmd->sense_buffer. Hence this patch that removes the > ufshcd_lrb.sense_buffer structure member. > > Signed-off-by: Bart Van Assche <bvanassche@acm.org> > --- > drivers/scsi/ufs/ufshcd.c | 9 ++++----- > drivers/scsi/ufs/ufshcd.h | 2 -- > 2 files changed, 4 insertions(+), 7 deletions(-) > > diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c > index e52e86b0b7a3..eddaa57b6aad 100644 > --- a/drivers/scsi/ufs/ufshcd.c > +++ b/drivers/scsi/ufs/ufshcd.c > @@ -2127,15 +2127,17 @@ void ufshcd_send_command(struct ufs_hba *hba, > unsigned int task_tag) > */ > static inline void ufshcd_copy_sense_data(struct ufshcd_lrb *lrbp) > { > + u8 *sense_buffer = lrbp->cmd ? lrbp->cmd->sense_buffer : NULL; lrbp->cmd is tested in __ufshcd_transfer_req_compl(), which is the only caller of ufshcd_transfer_rsp_status(), which is the only caller of ufshcd_scsi_cmd_status(), which is the only caller of ufshcd_copy_sense_data(). Thanks, Avri > int len; > - if (lrbp->sense_buffer && > + > + if (sense_buffer && > ufshcd_get_rsp_upiu_data_seg_len(lrbp->ucd_rsp_ptr)) { > int len_to_copy; > > len = be16_to_cpu(lrbp->ucd_rsp_ptr->sr.sense_data_len); > len_to_copy = min_t(int, UFS_SENSE_SIZE, len); > > - memcpy(lrbp->sense_buffer, lrbp->ucd_rsp_ptr->sr.sense_data, > + memcpy(sense_buffer, lrbp->ucd_rsp_ptr->sr.sense_data, > len_to_copy); > } > } > @@ -2789,7 +2791,6 @@ static int ufshcd_queuecommand(struct Scsi_Host > *host, struct scsi_cmnd *cmd) > lrbp = &hba->lrb[tag]; > WARN_ON(lrbp->cmd); > lrbp->cmd = cmd; > - lrbp->sense_buffer = cmd->sense_buffer; > lrbp->task_tag = tag; > lrbp->lun = ufshcd_scsi_to_upiu_lun(cmd->device->lun); > lrbp->intr_cmd = !ufshcd_is_intr_aggr_allowed(hba); > @@ -2829,7 +2830,6 @@ static int ufshcd_compose_dev_cmd(struct ufs_hba > *hba, > struct ufshcd_lrb *lrbp, enum dev_cmd_type cmd_type, int tag) > { > lrbp->cmd = NULL; > - lrbp->sense_buffer = NULL; > lrbp->task_tag = tag; > lrbp->lun = 0; /* device management cmd is not specific to any LUN */ > lrbp->intr_cmd = true; /* No interrupt aggregation */ > @@ -6800,7 +6800,6 @@ static int ufshcd_issue_devman_upiu_cmd(struct > ufs_hba *hba, > lrbp = &hba->lrb[tag]; > WARN_ON(lrbp->cmd); > lrbp->cmd = NULL; > - lrbp->sense_buffer = NULL; > lrbp->task_tag = tag; > lrbp->lun = 0; > lrbp->intr_cmd = true; > diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h > index b6162b208d99..b9f17219ca18 100644 > --- a/drivers/scsi/ufs/ufshcd.h > +++ b/drivers/scsi/ufs/ufshcd.h > @@ -181,7 +181,6 @@ struct ufs_pm_lvl_states { > * @ucd_rsp_dma_addr: UPIU response dma address for debug > * @ucd_req_dma_addr: UPIU request dma address for debug > * @cmd: pointer to SCSI command > - * @sense_buffer: pointer to sense buffer address of the SCSI command > * @scsi_status: SCSI status of the command > * @command_type: SCSI, UFS, Query. > * @task_tag: Task tag of the command > @@ -205,7 +204,6 @@ struct ufshcd_lrb { > dma_addr_t ucd_prdt_dma_addr; > > struct scsi_cmnd *cmd; > - u8 *sense_buffer; > int scsi_status; > > int command_type;
On 4/1/22 12:21, Avri Altman wrote: >> ufshcd_lrb.sense_buffer is NULL if ufshcd_lrb.cmd is NULL and >> ufshcd_lrb.sense_buffer points at cmd->sense_buffer if ufshcd_lrb.cmd >> is set. In other words, the ufshcd_lrb.sense_buffer member is identical >> to cmd->sense_buffer. Hence this patch that removes the >> ufshcd_lrb.sense_buffer structure member. >> >> Signed-off-by: Bart Van Assche <bvanassche@acm.org> >> --- >> drivers/scsi/ufs/ufshcd.c | 9 ++++----- >> drivers/scsi/ufs/ufshcd.h | 2 -- >> 2 files changed, 4 insertions(+), 7 deletions(-) >> >> diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c >> index e52e86b0b7a3..eddaa57b6aad 100644 >> --- a/drivers/scsi/ufs/ufshcd.c >> +++ b/drivers/scsi/ufs/ufshcd.c >> @@ -2127,15 +2127,17 @@ void ufshcd_send_command(struct ufs_hba *hba, >> unsigned int task_tag) >> */ >> static inline void ufshcd_copy_sense_data(struct ufshcd_lrb *lrbp) >> { >> + u8 *sense_buffer = lrbp->cmd ? lrbp->cmd->sense_buffer : NULL; > lrbp->cmd is tested in __ufshcd_transfer_req_compl(), > which is the only caller of ufshcd_transfer_rsp_status(), > which is the only caller of ufshcd_scsi_cmd_status(), > which is the only caller of ufshcd_copy_sense_data(). Thanks for the feedback. I will update this patch and leave out the lrbp->cmd test. Bart.
diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index e52e86b0b7a3..eddaa57b6aad 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -2127,15 +2127,17 @@ void ufshcd_send_command(struct ufs_hba *hba, unsigned int task_tag) */ static inline void ufshcd_copy_sense_data(struct ufshcd_lrb *lrbp) { + u8 *sense_buffer = lrbp->cmd ? lrbp->cmd->sense_buffer : NULL; int len; - if (lrbp->sense_buffer && + + if (sense_buffer && ufshcd_get_rsp_upiu_data_seg_len(lrbp->ucd_rsp_ptr)) { int len_to_copy; len = be16_to_cpu(lrbp->ucd_rsp_ptr->sr.sense_data_len); len_to_copy = min_t(int, UFS_SENSE_SIZE, len); - memcpy(lrbp->sense_buffer, lrbp->ucd_rsp_ptr->sr.sense_data, + memcpy(sense_buffer, lrbp->ucd_rsp_ptr->sr.sense_data, len_to_copy); } } @@ -2789,7 +2791,6 @@ static int ufshcd_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd) lrbp = &hba->lrb[tag]; WARN_ON(lrbp->cmd); lrbp->cmd = cmd; - lrbp->sense_buffer = cmd->sense_buffer; lrbp->task_tag = tag; lrbp->lun = ufshcd_scsi_to_upiu_lun(cmd->device->lun); lrbp->intr_cmd = !ufshcd_is_intr_aggr_allowed(hba); @@ -2829,7 +2830,6 @@ static int ufshcd_compose_dev_cmd(struct ufs_hba *hba, struct ufshcd_lrb *lrbp, enum dev_cmd_type cmd_type, int tag) { lrbp->cmd = NULL; - lrbp->sense_buffer = NULL; lrbp->task_tag = tag; lrbp->lun = 0; /* device management cmd is not specific to any LUN */ lrbp->intr_cmd = true; /* No interrupt aggregation */ @@ -6800,7 +6800,6 @@ static int ufshcd_issue_devman_upiu_cmd(struct ufs_hba *hba, lrbp = &hba->lrb[tag]; WARN_ON(lrbp->cmd); lrbp->cmd = NULL; - lrbp->sense_buffer = NULL; lrbp->task_tag = tag; lrbp->lun = 0; lrbp->intr_cmd = true; diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h index b6162b208d99..b9f17219ca18 100644 --- a/drivers/scsi/ufs/ufshcd.h +++ b/drivers/scsi/ufs/ufshcd.h @@ -181,7 +181,6 @@ struct ufs_pm_lvl_states { * @ucd_rsp_dma_addr: UPIU response dma address for debug * @ucd_req_dma_addr: UPIU request dma address for debug * @cmd: pointer to SCSI command - * @sense_buffer: pointer to sense buffer address of the SCSI command * @scsi_status: SCSI status of the command * @command_type: SCSI, UFS, Query. * @task_tag: Task tag of the command @@ -205,7 +204,6 @@ struct ufshcd_lrb { dma_addr_t ucd_prdt_dma_addr; struct scsi_cmnd *cmd; - u8 *sense_buffer; int scsi_status; int command_type;
ufshcd_lrb.sense_buffer is NULL if ufshcd_lrb.cmd is NULL and ufshcd_lrb.sense_buffer points at cmd->sense_buffer if ufshcd_lrb.cmd is set. In other words, the ufshcd_lrb.sense_buffer member is identical to cmd->sense_buffer. Hence this patch that removes the ufshcd_lrb.sense_buffer structure member. Signed-off-by: Bart Van Assche <bvanassche@acm.org> --- drivers/scsi/ufs/ufshcd.c | 9 ++++----- drivers/scsi/ufs/ufshcd.h | 2 -- 2 files changed, 4 insertions(+), 7 deletions(-)