Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

scsi: ufs: core: Improve ufshcd_mcq_sq_cleanup()

From the UFSHCI specification: "CleanUp Command Return Code (RTC): host
controller sets this return code to provide more details of the cleanup
process. It is valid only when CUS is 1." Hence, do not read RTC if the
CUS bitfield is zero.

Cc: Bao D. Nguyen <quic_nguyenb@quicinc.com>
Fixes: 8d7290348992 ("scsi: ufs: mcq: Add supporting functions for MCQ abort")
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Link: https://lore.kernel.org/r/20241022193130.2733293-7-bvanassche@acm.org
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Bart Van Assche and committed by
Martin K. Petersen
2c73fb13 2a366460

+8 -4
+8 -4
drivers/ufs/core/ufs-mcq.c
··· 572 572 /* SQRTCy.ICU = 1 */ 573 573 writel(SQ_ICU, opr_sqd_base + REG_SQRTC); 574 574 575 - /* Poll SQRTSy.CUS = 1. Return result from SQRTSy.RTC */ 575 + /* Wait until SQRTSy.CUS = 1. Report SQRTSy.RTC. */ 576 576 reg = opr_sqd_base + REG_SQRTS; 577 577 err = read_poll_timeout(readl, val, val & SQ_CUS, 20, 578 578 MCQ_POLL_US, false, reg); 579 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 + dev_err(hba->dev, "%s: failed. hwq=%d, tag=%d err=%d\n", 581 + __func__, id, task_tag, err); 582 + else 583 + dev_info(hba->dev, 584 + "%s, hwq %d: cleanup return code (RTC) %ld\n", 585 + __func__, id, 586 + FIELD_GET(SQ_ICU_ERR_CODE_MASK, readl(reg))); 583 587 584 588 if (ufshcd_mcq_sq_start(hba, hwq)) 585 589 err = -ETIMEDOUT;