* [PATCH v2] ufs: core: clear cmd if abort success in mcq mode
@ 2023-11-15 13:10 peter.wang
2023-11-15 19:23 ` Bart Van Assche
2023-11-25 2:53 ` Martin K. Petersen
0 siblings, 2 replies; 3+ messages in thread
From: peter.wang @ 2023-11-15 13:10 UTC (permalink / raw)
To: linux-scsi, martin.petersen, avri.altman, alim.akhtar, jejb
Cc: wsd_upstream, linux-mediatek, peter.wang, chun-hung.wu,
alice.chao, cc.chou, chaotian.jing, jiajie.hao, powen.kao,
qilin.tan, lin.gui, tun-yu.yu, eddie.huang, naomi.chu, stable
From: Peter Wang <peter.wang@mediatek.com>
In mcq mode, if cmd is pending in device and abort success, response
will not return from device. So we need clear this cmd right now,
else command timeout happen and next time use same tag will have
warning. WARN_ON(lrbp->cmd).
Below is error log:
<3>[ 2277.447611][T21376] ufshcd-mtk 112b0000.ufshci: ufshcd_try_to_abort_task: cmd pending in the device. tag = 7
<3>[ 2277.476954][T21376] ufshcd-mtk 112b0000.ufshci: Aborting tag 7 / CDB 0x2a succeeded
<6>[ 2307.551263][T30974] ufshcd-mtk 112b0000.ufshci: ufshcd_abort: Device abort task at tag 7
<4>[ 2307.623264][ T327] WARNING: CPU: 5 PID: 327 at source/drivers/ufs/core/ufshcd.c:3021 ufshcd_queuecommand+0x66c/0xe34
Fixes: ab248643d3d6 ("scsi: ufs: core: Add error handling for MCQ mode")
Cc: stable@vger.kernel.org
Signed-off-by: Peter Wang <peter.wang@mediatek.com>
---
drivers/ufs/core/ufshcd.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
index 8b1031fb0a44..6aa6f79d7841 100644
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -6444,11 +6444,24 @@ static bool ufshcd_abort_one(struct request *rq, void *priv)
struct scsi_device *sdev = cmd->device;
struct Scsi_Host *shost = sdev->host;
struct ufs_hba *hba = shost_priv(shost);
+ struct ufshcd_lrb *lrbp = &hba->lrb[tag];
+ struct ufs_hw_queue *hwq;
+ unsigned long flags;
*ret = ufshcd_try_to_abort_task(hba, tag);
dev_err(hba->dev, "Aborting tag %d / CDB %#02x %s\n", tag,
hba->lrb[tag].cmd ? hba->lrb[tag].cmd->cmnd[0] : -1,
*ret ? "failed" : "succeeded");
+
+ /* Release cmd in mcq mode if abort success */
+ if (is_mcq_enabled(hba) && (*ret == 0)) {
+ hwq = ufshcd_mcq_req_to_hwq(hba, scsi_cmd_to_rq(lrbp->cmd));
+ spin_lock_irqsave(&hwq->cq_lock, flags);
+ if (ufshcd_cmd_inflight(lrbp->cmd))
+ ufshcd_release_scsi_cmd(hba, lrbp);
+ spin_unlock_irqrestore(&hwq->cq_lock, flags);
+ }
+
return *ret == 0;
}
--
2.18.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH v2] ufs: core: clear cmd if abort success in mcq mode
2023-11-15 13:10 [PATCH v2] ufs: core: clear cmd if abort success in mcq mode peter.wang
@ 2023-11-15 19:23 ` Bart Van Assche
2023-11-25 2:53 ` Martin K. Petersen
1 sibling, 0 replies; 3+ messages in thread
From: Bart Van Assche @ 2023-11-15 19:23 UTC (permalink / raw)
To: peter.wang, linux-scsi, martin.petersen, avri.altman, alim.akhtar,
jejb
Cc: wsd_upstream, linux-mediatek, chun-hung.wu, alice.chao, cc.chou,
chaotian.jing, jiajie.hao, powen.kao, qilin.tan, lin.gui,
tun-yu.yu, eddie.huang, naomi.chu, stable
On 11/15/23 05:10, peter.wang@mediatek.com wrote:
> In mcq mode, if cmd is pending in device and abort success, response
> will not return from device. So we need clear this cmd right now,
> else command timeout happen and next time use same tag will have
> warning. WARN_ON(lrbp->cmd).
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] ufs: core: clear cmd if abort success in mcq mode
2023-11-15 13:10 [PATCH v2] ufs: core: clear cmd if abort success in mcq mode peter.wang
2023-11-15 19:23 ` Bart Van Assche
@ 2023-11-25 2:53 ` Martin K. Petersen
1 sibling, 0 replies; 3+ messages in thread
From: Martin K. Petersen @ 2023-11-25 2:53 UTC (permalink / raw)
To: linux-scsi, avri.altman, alim.akhtar, jejb, peter.wang
Cc: Martin K . Petersen, wsd_upstream, linux-mediatek, chun-hung.wu,
alice.chao, cc.chou, chaotian.jing, jiajie.hao, powen.kao,
qilin.tan, lin.gui, tun-yu.yu, eddie.huang, naomi.chu, stable
On Wed, 15 Nov 2023 21:10:24 +0800, peter.wang@mediatek.com wrote:
> In mcq mode, if cmd is pending in device and abort success, response
> will not return from device. So we need clear this cmd right now,
> else command timeout happen and next time use same tag will have
> warning. WARN_ON(lrbp->cmd).
>
> Below is error log:
> <3>[ 2277.447611][T21376] ufshcd-mtk 112b0000.ufshci: ufshcd_try_to_abort_task: cmd pending in the device. tag = 7
> <3>[ 2277.476954][T21376] ufshcd-mtk 112b0000.ufshci: Aborting tag 7 / CDB 0x2a succeeded
> <6>[ 2307.551263][T30974] ufshcd-mtk 112b0000.ufshci: ufshcd_abort: Device abort task at tag 7
> <4>[ 2307.623264][ T327] WARNING: CPU: 5 PID: 327 at source/drivers/ufs/core/ufshcd.c:3021 ufshcd_queuecommand+0x66c/0xe34
>
> [...]
Applied to 6.7/scsi-fixes, thanks!
[1/1] ufs: core: clear cmd if abort success in mcq mode
https://git.kernel.org/mkp/scsi/c/93e6c0e19d5b
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-11-25 2:53 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-15 13:10 [PATCH v2] ufs: core: clear cmd if abort success in mcq mode peter.wang
2023-11-15 19:23 ` Bart Van Assche
2023-11-25 2:53 ` Martin K. Petersen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox