Message ID | 20221104231927.9613-35-michael.christie@oracle.com |
---|---|
State | Superseded |
Headers | show |
Series | Allow scsi_execute users to control retries | expand |
On 11/4/22 16:19, Mike Christie wrote: > This has scsi-ml retry errors instead of driving them itself. > > Signed-off-by: Mike Christie <michael.christie@oracle.com> > --- > drivers/ufs/core/ufshcd.c | 19 +++++++++---------- > 1 file changed, 9 insertions(+), 10 deletions(-) > > diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c > index fbd694bc4ef9..a8415e1b8a4e 100644 > --- a/drivers/ufs/core/ufshcd.c > +++ b/drivers/ufs/core/ufshcd.c > @@ -8719,6 +8719,12 @@ static int ufshcd_execute_start_stop(struct scsi_device *sdev, > struct request *req; > struct scsi_cmnd *scmd; > int ret; > + struct scsi_failure failures[] = { > + { > + .allowed = 2, > + .result = SCMD_FAILURE_RESULT_ANY, > + }, > + }; > > req = scsi_alloc_request(sdev->request_queue, REQ_OP_DRV_IN, > BLK_MQ_REQ_PM); > @@ -8730,6 +8736,7 @@ static int ufshcd_execute_start_stop(struct scsi_device *sdev, > memcpy(scmd->cmnd, cdb, scmd->cmd_len); > scmd->allowed = 0/*retries*/; > scmd->flags |= SCMD_FAIL_IF_RECOVERING; > + scmd->failures = failures; > req->timeout = 1 * HZ; > req->rq_flags |= RQF_PM | RQF_QUIET; > > @@ -8760,7 +8767,7 @@ static int ufshcd_set_dev_pwr_mode(struct ufs_hba *hba, > struct scsi_sense_hdr sshdr; > struct scsi_device *sdp; > unsigned long flags; > - int ret, retries; > + int ret; > > spin_lock_irqsave(hba->host->host_lock, flags); > sdp = hba->ufs_device_wlun; > @@ -8786,15 +8793,7 @@ static int ufshcd_set_dev_pwr_mode(struct ufs_hba *hba, > * callbacks hence set the RQF_PM flag so that it doesn't resume the > * already suspended childs. > */ > - for (retries = 3; retries > 0; --retries) { > - ret = ufshcd_execute_start_stop(sdp, pwr_mode, &sshdr); > - /* > - * scsi_execute() only returns a negative value if the request > - * queue is dying. > - */ > - if (ret <= 0) > - break; > - } > + ret = ufshcd_execute_start_stop(sdp, pwr_mode, &sshdr); > if (ret) { > sdev_printk(KERN_WARNING, sdp, > "START_STOP failed for power mode: %d, result %x\n", ufshcd_execute_start_stop() has been introduced because scsi_execute() does not support setting the SCMD_FAIL_IF_RECOVERING flag. If support for setting the SCSI flags would be added to scsi_execute() that would allow to remove the ufshcd_execute_start_stop() function. I can implement this with a follow-up patch if you prefer that I implement this change. Since I'm fine with the above changes: Acked-by: Bart Van Assche <bvanassche@acm.org>
diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index fbd694bc4ef9..a8415e1b8a4e 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -8719,6 +8719,12 @@ static int ufshcd_execute_start_stop(struct scsi_device *sdev, struct request *req; struct scsi_cmnd *scmd; int ret; + struct scsi_failure failures[] = { + { + .allowed = 2, + .result = SCMD_FAILURE_RESULT_ANY, + }, + }; req = scsi_alloc_request(sdev->request_queue, REQ_OP_DRV_IN, BLK_MQ_REQ_PM); @@ -8730,6 +8736,7 @@ static int ufshcd_execute_start_stop(struct scsi_device *sdev, memcpy(scmd->cmnd, cdb, scmd->cmd_len); scmd->allowed = 0/*retries*/; scmd->flags |= SCMD_FAIL_IF_RECOVERING; + scmd->failures = failures; req->timeout = 1 * HZ; req->rq_flags |= RQF_PM | RQF_QUIET; @@ -8760,7 +8767,7 @@ static int ufshcd_set_dev_pwr_mode(struct ufs_hba *hba, struct scsi_sense_hdr sshdr; struct scsi_device *sdp; unsigned long flags; - int ret, retries; + int ret; spin_lock_irqsave(hba->host->host_lock, flags); sdp = hba->ufs_device_wlun; @@ -8786,15 +8793,7 @@ static int ufshcd_set_dev_pwr_mode(struct ufs_hba *hba, * callbacks hence set the RQF_PM flag so that it doesn't resume the * already suspended childs. */ - for (retries = 3; retries > 0; --retries) { - ret = ufshcd_execute_start_stop(sdp, pwr_mode, &sshdr); - /* - * scsi_execute() only returns a negative value if the request - * queue is dying. - */ - if (ret <= 0) - break; - } + ret = ufshcd_execute_start_stop(sdp, pwr_mode, &sshdr); if (ret) { sdev_printk(KERN_WARNING, sdp, "START_STOP failed for power mode: %d, result %x\n",
This has scsi-ml retry errors instead of driving them itself. Signed-off-by: Mike Christie <michael.christie@oracle.com> --- drivers/ufs/core/ufshcd.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-)