Skip to content

Commit bf0c6cc

Browse files
ptr324martinkpetersen
authored andcommitted
scsi: ufs: core: Fix the issue of ICU failure
When setting the ICU bit without using read-modify-write, SQRTCy will restart SQ again and receive an RTC return error code 2 (Failure - SQ not stopped). Additionally, the error log has been modified so that this type of error can be observed. Fixes: ab24864 ("scsi: ufs: core: Add error handling for MCQ mode") Cc: stable@vger.kernel.org Signed-off-by: Peter Wang <peter.wang@mediatek.com> Link: https://lore.kernel.org/r/20241001091917.6917-2-peter.wang@mediatek.com Reviewed-by: Bao D. Nguyen <quic_nguyenb@quicinc.com> Reviewed-by: Bart Van Assche <bvanassche@acm.org> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent d539a87 commit bf0c6cc

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

drivers/ufs/core/ufs-mcq.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ int ufshcd_mcq_sq_cleanup(struct ufs_hba *hba, int task_tag)
539539
struct scsi_cmnd *cmd = lrbp->cmd;
540540
struct ufs_hw_queue *hwq;
541541
void __iomem *reg, *opr_sqd_base;
542-
u32 nexus, id, val;
542+
u32 nexus, id, val, rtc;
543543
int err;
544544

545545
if (hba->quirks & UFSHCD_QUIRK_MCQ_BROKEN_RTC)
@@ -569,17 +569,18 @@ int ufshcd_mcq_sq_cleanup(struct ufs_hba *hba, int task_tag)
569569
opr_sqd_base = mcq_opr_base(hba, OPR_SQD, id);
570570
writel(nexus, opr_sqd_base + REG_SQCTI);
571571

572-
/* SQRTCy.ICU = 1 */
573-
writel(SQ_ICU, opr_sqd_base + REG_SQRTC);
572+
/* Initiate Cleanup */
573+
writel(readl(opr_sqd_base + REG_SQRTC) | SQ_ICU,
574+
opr_sqd_base + REG_SQRTC);
574575

575576
/* Poll SQRTSy.CUS = 1. Return result from SQRTSy.RTC */
576577
reg = opr_sqd_base + REG_SQRTS;
577578
err = read_poll_timeout(readl, val, val & SQ_CUS, 20,
578579
MCQ_POLL_US, false, reg);
579-
if (err)
580-
dev_err(hba->dev, "%s: failed. hwq=%d, tag=%d err=%ld\n",
581-
__func__, id, task_tag,
582-
FIELD_GET(SQ_ICU_ERR_CODE_MASK, readl(reg)));
580+
rtc = FIELD_GET(SQ_ICU_ERR_CODE_MASK, readl(reg));
581+
if (err || rtc)
582+
dev_err(hba->dev, "%s: failed. hwq=%d, tag=%d err=%d RTC=%d\n",
583+
__func__, id, task_tag, err, rtc);
583584

584585
if (ufshcd_mcq_sq_start(hba, hwq))
585586
err = -ETIMEDOUT;

0 commit comments

Comments
 (0)