scsi: ufs: Improve SCSI abort handling
PATCH 1/1 scsi: ufs: Improve SCSI abort handling
The following has been observed on a test setup:
WARNING: CPU: 4 PID: 250 at drivers/scsi/ufs/ufshcd.c:2737 ufshcd_queuecommand+0x468/0x65c Call trace: ufshcd_queuecommand+0x468/0x65c scsi_send_eh_cmnd+0x224/0x6a0 scsi_eh_test_devices+0x248/0x418 scsi_eh_ready_devs+0xc34/0xe58 scsi_error_handler+0x204/0x80c kthread+0x150/0x1b4 ret_from_fork+0x10/0x30
That warning is triggered by the following statement:
WARN_ON(lrbp->cmd);
Fix this warning by clearing lrbp->cmd from the abort handler.
--- drivers/scsi/ufs/ufshcd.c | 1 + 1 file changed, 1 insertion(+)
drivers/scsi/ufs/ufshcd.c +1 -0
@@ -7069,6 +7069,7 @@ static int ufshcd_abort(struct scsi_cmnd *cmd) goto release; } + lrbp->cmd =NULL ; err =SUCCESS ; release:
Quoted 13 lines · Bart Van Assche
The following has been observed on a test setup:
WARNING: CPU: 4 PID: 250 at drivers/scsi/ufs/ufshcd.c:2737 ufshcd_queuecommand+0x468/0x65c Call trace: ufshcd_queuecommand+0x468/0x65c scsi_send_eh_cmnd+0x224/0x6a0 scsi_eh_test_devices+0x248/0x418 scsi_eh_ready_devs+0xc34/0xe58 scsi_error_handler+0x204/0x80c kthread+0x150/0x1b4 ret_from_fork+0x10/0x30
Quoted 8 lines
That warning is triggered by the following statement:
WARN_ON(lrbp->cmd);Fix this warning by clearing
lrbp->cmdfrom the abort handler.Fixes 7a3e97b0dc4b ("[SCSI] ufshcd: UFS Host controller driver")Signed-off-by Bart Van Assche <[email protected]>
Quoted 16 lines
--- drivers/scsi/ufs/ufshcd.c | 1 + 1 file changed, 1 insertion(+)drivers/scsi/ufs/ufshcd.c +1
-0@@ -7069,6 +7069,7 @@ static int ufshcd_abort(struct scsi_cmnd *cmd) goto release; } + lrbp->cmd =NULL ; err =SUCCESS ; release:
PATCH 1/1 scsi: ufs: Improve SCSI abort handling
In reply to Bart Van AsscheHi Bart,
Quoted 11 lines
drivers/scsi/ufs/ufshcd.c +1
-0@@ -7069,6 +7069,7 @@ static int ufshcd_abort(struct scsi_cmnd *cmd) goto release; } + lrbp->cmd =NULL ; err =SUCCESS ;
Quoted 1 line
release:
I found similar code in the ufshcd_err_handler(). I think the following patch will required to fix another warning.
drivers/scsi/ufs/ufshcd.c +1 -0
@@ -6190,6 +6190,7 @@ static void ufshcd_err_handler(struct work_struct *work) }dev_err (hba->dev,"Aborted tag %d / CDB %#02x\n" , tag, hba->lrb[tag].cmd ? hba->lrb[tag].cmd->cmnd[0 ] :-1 ); + hba->lrb[tag].cmd =NULL ; }/* Clear pending task management requests */
Thanks,
Daejun
Quoted 8 lines · Daejun Park
I found similar code in the
ufshcd_err_handler(). I think the following patch will required to fix another warning.drivers/scsi/ufs/ufshcd.c +0
-0
drivers/scsi/ufs/ufshcd.c static void ufshcd_err_handler(struct work_struct *work) · line 6196
Quoted 7 lines
drivers/scsi/ufs/ufshcd.c +1
-0@@ -6190,6 +6190,7 @@ static void ufshcd_err_handler(struct work_struct *work) }dev_err (hba->dev,"Aborted tag %d / CDB %#02x\n" , tag, hba->lrb[tag].cmd ? hba->lrb[tag].cmd->cmnd[0 ] :-1 ); + hba->lrb[tag].cmd =NULL ; }/* Clear pending task management requests */
Hmm ... since the error handler calls ufshcd_complete_requests(), shouldn't the completion function clear the 'cmd' member? I'm concerned that the above change would break the completion handler.
Thanks,
Bart.
Daejun Park
Reviewed-byQuoted 15 lines · Daejun Park
Quoted 14 lines
I found similar code in the
ufshcd_err_handler(). I think the following patch will required to fix another warning.drivers/scsi/ufs/ufshcd.c +1
-0@@ -6190,6 +6190,7 @@ static void ufshcd_err_handler(struct work_struct *work) }dev_err (hba->dev,"Aborted tag %d / CDB %#02x\n" , tag, hba->lrb[tag].cmd ? hba->lrb[tag].cmd->cmnd[0 ] :-1 ); + hba->lrb[tag].cmd =NULL ; }
Quoted 5 lines
drivers/scsi/ufs/ufshcd.c static void ufshcd_err_handler(struct work_struct *work) · line 6196
Quoted 1 line
drivers/scsi/ufs/ufshcd.c +0
-0/* Clear pending task management requests */ Hmm ... since the error handler calls
ufshcd_complete_requests(), shouldn't the completion function clear the 'cmd' member? I'm concerned that the above change would break the completion handler.
I missed that the error handler calls ufshcd_complete_requests(). Please ignore my suggestion.
By the way, I give my reviewed-by tag.
Thanks,
Daejun
Quoted 21 lines · Daejun Park
Quoted 15 lines · Daejun Park
Quoted 14 lines
I found similar code in the
ufshcd_err_handler(). I think the following patch will required to fix another warning.drivers/scsi/ufs/ufshcd.c +1
-0@@ -6190,6 +6190,7 @@ static void ufshcd_err_handler(struct work_struct *work) }dev_err (hba->dev,"Aborted tag %d / CDB %#02x\n" , tag, hba->lrb[tag].cmd ? hba->lrb[tag].cmd->cmnd[0 ] :-1 ); + hba->lrb[tag].cmd =NULL ; }Quoted 5 lines
drivers/scsi/ufs/ufshcd.c static void ufshcd_err_handler(struct work_struct *work) · line 6196
Quoted 1 line
drivers/scsi/ufs/ufshcd.c +0
-0/* Clear pending task management requests */ Hmm ... since the error handler calls
ufshcd_complete_requests(), shouldn't the completion function clear the 'cmd' member? I'm concerned that the above change would break the completion handler.
Quoted 6 lines
I missed that the error handler calls
ufshcd_complete_requests(). Please ignore my suggestion.By the way, I give my reviewed-by tag.
Reviewed-by Daejun Park <[email protected]>
Thanks Daejun! However, your question made me wonder whether ufshcd_abort() should clear the 'tag' bit from hba->outstanding_reqs. Although the SCSI standard requires that a command that is aborted is not completed, the UFSHCI specification requires that writing into the UTRLCLR register clears the corresponding bit(s) in the UTRLDBR register. I think bit 'tag' will have to be cleared from hba->outstanding_reqs to prevent that the aborted request is completed while the SCSI core is resubmitting it.
Thanks,
Bart.
Quoted 29 lines · Daejun Park
Quoted 21 lines
Quoted 15 lines · Daejun Park
Quoted 14 lines
I found similar code in the
ufshcd_err_handler(). I think the following patch will required to fix another warning.drivers/scsi/ufs/ufshcd.c +1
-0@@ -6190,6 +6190,7 @@ static void ufshcd_err_handler(struct work_struct *work) }dev_err (hba->dev,"Aborted tag %d / CDB %#02x\n" , tag, hba->lrb[tag].cmd ? hba->lrb[tag].cmd->cmnd[0 ] :-1 ); + hba->lrb[tag].cmd =NULL ; }Quoted 5 lines
drivers/scsi/ufs/ufshcd.c static void ufshcd_err_handler(struct work_struct *work) · line 6196
Quoted 1 line
drivers/scsi/ufs/ufshcd.c +0
-0/* Clear pending task management requests */ Hmm ... since the error handler calls
ufshcd_complete_requests(), shouldn't the completion function clear the 'cmd' member? I'm concerned that the above change would break the completion handler.Quoted 6 lines
I missed that the error handler calls
ufshcd_complete_requests(). Please ignore my suggestion.By the way, I give my reviewed-by tag.
Reviewed-by Daejun Park <[email protected]>
Quoted 7 lines
Thanks Daejun! However, your question made me wonder whether
ufshcd_abort()should clear the 'tag' bit fromhba->outstanding_reqs. Although the SCSI standard requires that a command that is aborted is not completed, the UFSHCI specification requires that writing into the UTRLCLR register clears the corresponding bit(s) in the UTRLDBR register. I think bit 'tag' will have to be cleared fromhba->outstanding_reqsto prevent that the aborted request is completed while the SCSI core is resubmitting it.
My understanding is the completion of aborted request can be duplicated because SCSI core will resubmit the request. Therefore the clearing of the bit can avoid duplicated completion of the request.
Thanks,
Daejun
Hi Bart,
Quoted 30 lines · Bart Van Assche
The following has been observed on a test setup:
WARNING: CPU: 4 PID: 250 at drivers/scsi/ufs/ufshcd.c:2737 ufshcd_queuecommand+0x468/0x65c Call trace: ufshcd_queuecommand+0x468/0x65c scsi_send_eh_cmnd+0x224/0x6a0 scsi_eh_test_devices+0x248/0x418 scsi_eh_ready_devs+0xc34/0xe58 scsi_error_handler+0x204/0x80c kthread+0x150/0x1b4 ret_from_fork+0x10/0x30That warning is triggered by the following statement:
WARN_ON(lrbp->cmd);Fix this warning by clearing
lrbp->cmdfrom the abort handler.Fixes 7a3e97b0dc4b ("[SCSI] ufshcd: UFS Host controller driver")Signed-off-by Bart Van Assche <[email protected]>--- drivers/scsi/ufs/ufshcd.c | 1 + 1 file changed, 1 insertion(+)drivers/scsi/ufs/ufshcd.c +0
-0
drivers/scsi/ufs/ufshcd.c static int ufshcd_abort(struct scsi_cmnd *cmd) · line 7075
Quoted 7 lines
drivers/scsi/ufs/ufshcd.c +1
-0@@ -7069,6 +7069,7 @@ static int ufshcd_abort(struct scsi_cmnd *cmd) goto release; } + lrbp->cmd =NULL ; err =SUCCESS ; release:
Thanks for this patch! We are looking at the same issue as well recently.
Martin K. Petersen
AppliedBart,
Quoted 5 lines
That warning is triggered by the following statement:
WARN_ON(lrbp->cmd);Fix this warning by clearing
lrbp->cmdfrom the abort handler.
Applied to 5.16/scsi-staging, thanks!
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering
Martin K. Petersen
AppliedQuoted 12 lines · Bart Van Assche
The following has been observed on a test setup:
WARNING: CPU: 4 PID: 250 at drivers/scsi/ufs/ufshcd.c:2737 ufshcd_queuecommand+0x468/0x65c Call trace: ufshcd_queuecommand+0x468/0x65c scsi_send_eh_cmnd+0x224/0x6a0 scsi_eh_test_devices+0x248/0x418 scsi_eh_ready_devs+0xc34/0xe58 scsi_error_handler+0x204/0x80c kthread+0x150/0x1b4 ret_from_fork+0x10/0x30
Quoted 1 line
[...]
Applied to 5.16/scsi-fixes, thanks!
[1/1] scsi: ufs: Improve SCSI abort handling
https://git.kernel.org/mkp/scsi/c/3ff1f6b6ba6f
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering
James Bottomley
maintainerQuoted 15 lines · Martin K. Petersen
Quoted 13 lines · Bart Van Assche
The following has been observed on a test setup:
WARNING: CPU: 4 PID: 250 at drivers/scsi/ufs/ufshcd.c:2737 ufshcd_queuecommand+0x468/0x65c Call trace: ufshcd_queuecommand+0x468/0x65c scsi_send_eh_cmnd+0x224/0x6a0 scsi_eh_test_devices+0x248/0x418 scsi_eh_ready_devs+0xc34/0xe58 scsi_error_handler+0x204/0x80c kthread+0x150/0x1b4 ret_from_fork+0x10/0x30
Quoted 6 lines
Quoted 1 line
[...]
Applied to 5.16/scsi-fixes, thanks!
[1/1] scsi: ufs: Improve SCSI abort handling
https://git.kernel.org/mkp/scsi/c/3ff1f6b6ba6f
OK, so now we have a conflict between fixes and queue. My impression is that the patch causing the conflict:
https://lore.kernel.org/all/[email protected]/
Actually supersedes this one, so I can simply drop the entirety of this patch in fixes, is that correct?
James
Quoted 6 lines · James Bottomley
Quoted 4 lines · Martin K. Petersen
Applied to 5.16/scsi-fixes, thanks!
[1/1] scsi: ufs: Improve SCSI abort handling
https://git.kernel.org/mkp/scsi/c/3ff1f6b6ba6f
Quoted 7 lines
OK, so now we have a conflict between fixes and queue. My impression is that the patch causing the conflict:
https://lore.kernel.org/all/[email protected]/
Actually supersedes this one, so I can simply drop the entirety of this patch in fixes, is that correct?
Hi James,
Commit 1fbaa02dfd05 ("scsi: ufs: Improve SCSI abort handling further") is intended as an improvement for commit 3ff1f6b6ba6f ("scsi: ufs: core:
Improve SCSI abort handling"). Since commit 3ff1f6b6ba6f is already in Linus' tree I don't think that it can be dropped? A possible approach is to revert commit 3ff1f6b6ba6f before merging the mkp-scsi/for-next branch.
Thanks,
Bart.
James Bottomley
maintainerQuoted 16 lines · Bart Van Assche
Quoted 6 lines · James Bottomley
Quoted 4 lines · Martin K. Petersen
Applied to 5.16/scsi-fixes, thanks!
[1/1] scsi: ufs: Improve SCSI abort handling
https://git.kernel.org/mkp/scsi/c/3ff1f6b6ba6fQuoted 8 lines
OK, so now we have a conflict between fixes and queue. My impression
is that the patch causing the conflict:https://lore.kernel.org/all/[email protected]/
Actually supersedes this one, so I can simply drop the entirety of this patch in fixes, is that correct?
Quoted 8 lines
Hi James,
Commit
1fbaa02dfd05("scsi: ufs: Improve SCSI abort handling further") is intended as an improvement for commit3ff1f6b6ba6f("scsi: ufs: core: Improve SCSI abort handling"). Since commit3ff1f6b6ba6fis already in Linus' tree I don't think that it can be dropped? A possible approach is to revert commit3ff1f6b6ba6fbefore merging the mkp-scsi/for-next branch.
I meant the effect of the fixes patch can be dropped in the merge commit. So the sole surviving code is from the misc tree. Like what I did at the top of the for-next branch:
James
Quoted 5 lines · James Bottomley
I meant the effect of the fixes patch can be dropped in the merge commit. So the sole surviving code is from the misc tree. Like what I did at the top of the for-next branch:
Thanks for the clarification. The ufshcd_abort() code at the above URL looks good to me.
Thanks,
Bart.