ufs: core: fix err handler mcq abort defect
Subsystems (4)
cover ufs: core: fix err handler mcq abort defect
From: Peter Wang <[email protected]>
This series fixes ufshcd_err_handler abort defect in mcq mode.
Peter Wang (2):
ufs: core: complete scsi command after release
ufs: core: force reset after mcq abort all
drivers/ufs/core/ufshcd.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
Signature · 1 line
2.45.2
PATCH 1/2 ufs: core: complete scsi command after release
From: Peter Wang <[email protected]>
When the error handler successfully aborts a MCQ request, it only releases the command and does not notify the SCSI layer. This may cause another abort after 30 seconds timeout. This patch notifies the SCSI layer to requeue the request.
Below is error log
[ 14.183804][ T74] ufshcd-mtk 112b0000.ufshci: ufshcd_err_handler started; HBA state eh_non_fatal; powered 1; shutting down 0; saved_err = 4; saved_uic_err = 64; force_reset = 0 [ 14.256164][ T74] ufshcd-mtk 112b0000.ufshci: ufshcd_try_to_abort_task: cmd pending in the device. tag = 19 [ 14.257511][ T74] ufshcd-mtk 112b0000.ufshci: Aborting tag 19 / CDB 0x35 succeeded [ 34.287949][ T8] ufshcd-mtk 112b0000.ufshci: ufshcd_abort: Device abort task at tag 19 [ 34.290514][ T8] ufshcd-mtk 112b0000.ufshci: ufshcd_mcq_abort: skip abort. cmd at tag 19 already completed.
--- drivers/ufs/core/ufshcd.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/ufs/core/ufshcd.c +5 -1
@@ -6482,8 +6482,12 @@ static bool ufshcd_abort_one(struct request *rq, void *priv)if (!hwq)return 0 ;spin_lock_irqsave (&hwq->cq_lock, flags); -if (ufshcd_cmd_inflight (lrbp->cmd)) +if (ufshcd_cmd_inflight (lrbp->cmd)) { +struct scsi_cmnd *cmd = lrbp->cmd; +set_host_byte (cmd,DID_REQUEUE );ufshcd_release_scsi_cmd (hba, lrbp); +scsi_done (cmd); + }spin_unlock_irqrestore (&hwq->cq_lock, flags); }
Signature · 1 line
2.45.2
Bart Van Assche
reviewerRe: [PATCH v1 1/2] ufs: core: complete scsi command after release
Quoted 7 lines · On 8/23/24 3:07 AM, [email protected] wrote:
drivers/ufs/core/ufshcd.c +0
-0@@ -6482,8 +6482,12 @@ static bool ufshcd_abort_one(struct request *rq, void *priv)if (!hwq)return 0 ;
drivers/ufs/core/ufshcd.c static bool ufshcd_abort_one(struct request *rq, void *priv) · line 6492
Quoted 10 lines
drivers/ufs/core/ufshcd.c +5
-1spin_lock_irqsave (&hwq->cq_lock, flags); -if (ufshcd_cmd_inflight (lrbp->cmd)) +if (ufshcd_cmd_inflight (lrbp->cmd)) { +struct scsi_cmnd *cmd = lrbp->cmd; +set_host_byte (cmd,DID_REQUEUE );ufshcd_release_scsi_cmd (hba, lrbp); +scsi_done (cmd); + }spin_unlock_irqrestore (&hwq->cq_lock, flags); }
Hmm ... isn't the ufshcd_complete_requests() call in ufshcd_abort_all() expected to complete these commands? Can the above change lead to scsi_done() being called twice, something that is not allowed?
Bart.
Re: [PATCH v1 1/2] ufs: core: complete scsi command after release
Quoted 28 lines · Bart Van Assche
External email : Please do not click links or open attachments until you have verified the sender or the content.
drivers/ufs/core/ufshcd.c static bool ufshcd_abort_one(struct request
Quoted 5 lines · On 8/23/24 3:07 AM, [email protected] wrote:
drivers/ufs/core/ufshcd.c +0
-0@@ -6482,8 +6482,12 @@ static bool ufshcd_abort_one(struct request*rq, void *priv)
drivers/ufs/core/ufshcd.c static bool ufshcd_abort_one(struct request *rq, void *priv) · line 6492
Quoted 12 lines
drivers/ufs/core/ufshcd.c +5
-1if (!hwq)return 0 ;spin_lock_irqsave (&hwq->cq_lock, flags); -if (ufshcd_cmd_inflight (lrbp->cmd)) +if (ufshcd_cmd_inflight (lrbp->cmd)) { +struct scsi_cmnd *cmd = lrbp->cmd; +set_host_byte (cmd,DID_REQUEUE );ufshcd_release_scsi_cmd (hba, lrbp); +scsi_done (cmd); +}spin_unlock_irqrestore (&hwq->cq_lock, flags); }Hmm ... isn't the
ufshcd_complete_requests()call inufshcd_abort_all()
expected to complete these commands? Can the above change lead toscsi_done()being called twice, something that is not allowed?
Quoted 2 lines
Bart.
Hi Bart,
ufshcd_complete_requests call in ufshcd_abort_all() with force_compl = false in mcq mode, which only check cq is empty or not. For already abort cmd, no response will come back and no cq slot insert by hardware, which we need release this cmd and scsi done, same as force_compl = true does.
Thanks
Peter
PATCH 2/2 ufs: core: force reset after mcq abort all
In reply to [email protected]From: Peter Wang <[email protected]>
In mcq mode gerneal case, cq (head/tail) poniter is same as sq pointer (head/tail) if the hwq is empty.
But if command send to device and abort it, no response return and cq point will less than sq. In this case will have unpredictable error. This patch force reset for this case.
Below is error log
[ 34.976612][ C3] ufshcd-mtk 112b0000.ufshci: OCS error from controller = 3 for tag 19
--- drivers/ufs/core/ufshcd.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/ufs/core/ufshcd.c +2 -0
@@ -6519,6 +6519,8 @@ static bool ufshcd_abort_all(struct ufs_hba *hba)/* Complete the requests that are cleared by s/w */ ufshcd_complete_requests (hba, false); +if (is_mcq_enabled (hba)) +return true;return ret !=0 ; }
Signature · 1 line
2.45.2
Bart Van Assche
reviewerRe: [PATCH v1 2/2] ufs: core: force reset after mcq abort all
Quoted 2 lines · On 8/23/24 3:07 AM, [email protected] wrote:
In mcq mode gerneal case, cq (head/tail) poniter is same as sq pointer (head/tail) if the hwq is empty.
poniter -> pointer
Thanks,
Bart.
Re: [PATCH v1 2/2] ufs: core: force reset after mcq abort all
Quoted 4 lines · Bart Van Assche
External email : Please do not click links or open attachments until you have verified the sender or the content.
On 8/23/24 3:07 AM, [email protected] wrote:
Quoted 8 lines
Quoted 2 lines
In mcq mode gerneal case, cq (head/tail) poniter is same as sq pointer (head/tail) if the hwq is empty.
poniter -> pointer
Thanks,
Bart.
Hi Bart,
Will fix typo next version.
Thanks.
Peter