Skip to content

Commit 5b31376

Browse files
Won Jungmartinkpetersen
authored andcommitted
scsi: ufs: core: Reset urgent_bkops_lvl to allow runtime PM power mode
Ensures that UFS Runtime PM can achieve power saving after System PM suspend by resetting hba->urgent_bkops_lvl. Also modify the ufshcd_bkops_exception_event_handler to avoid setting urgent_bkops_lvl when status is 0, which helps maintain optimal power management. On UFS devices supporting UFSHCD_CAP_AUTO_BKOPS_SUSPEND, a BKOPS exception event can lead to a situation where UFS Runtime PM can't enter low-power mode states even after the BKOPS exception has been resolved. BKOPS exception with bkops status 0 occurs, the driver logs: "ufshcd_bkops_exception_event_handler: device raised urgent BKOPS exception for bkops status 0" When a BKOPS exception occurs, ufshcd_bkops_exception_event_handler() reads the BKOPS status and sets hba->urgent_bkops_lvl to BKOPS_STATUS_NO_OP(0). This allows the device to perform Runtime PM without changing the UFS power mode. (__ufshcd_wl_suspend(hba, UFS_RUNTIME_PM)) During system PM suspend, ufshcd_disable_auto_bkops() is called, disabling auto bkops. After UFS System PM Resume, when runtime PM attempts to suspend again, ufshcd_urgent_bkops() is invoked. Since hba->urgent_bkops_lvl remains at BKOPS_STATUS_NO_OP(0), ufshcd_enable_auto_bkops() is triggered. However, in ufshcd_bkops_ctrl(), the driver compares the current BKOPS status with hba->urgent_bkops_lvl, and only enables auto bkops if curr_status >= hba->urgent_bkops_lvl. Since both values are 0, the condition is met As a result, __ufshcd_wl_suspend(hba, UFS_RUNTIME_PM) skips power mode transitions and remains in an active state, preventing power saving even though no urgent BKOPS condition exists. Signed-off-by: Won Jung <wone.jung@samsung.com> Reviewed-by: Peter Wang <peter.wang@mediatek.com> Link: https://patch.msgid.link/1891546521.01770806581968.JavaMail.epsvc@epcpadp2new Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 70ca8ca commit 5b31376

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

drivers/ufs/core/ufshcd.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5982,6 +5982,7 @@ static int ufshcd_disable_auto_bkops(struct ufs_hba *hba)
59825982

59835983
hba->auto_bkops_enabled = false;
59845984
trace_ufshcd_auto_bkops_state(hba, "Disabled");
5985+
hba->urgent_bkops_lvl = BKOPS_STATUS_PERF_IMPACT;
59855986
hba->is_urgent_bkops_lvl_checked = false;
59865987
out:
59875988
return err;
@@ -6085,7 +6086,7 @@ static void ufshcd_bkops_exception_event_handler(struct ufs_hba *hba)
60856086
* impacted or critical. Handle these device by determining their urgent
60866087
* bkops status at runtime.
60876088
*/
6088-
if (curr_status < BKOPS_STATUS_PERF_IMPACT) {
6089+
if ((curr_status > BKOPS_STATUS_NO_OP) && (curr_status < BKOPS_STATUS_PERF_IMPACT)) {
60896090
dev_err(hba->dev, "%s: device raised urgent BKOPS exception for bkops status %d\n",
60906091
__func__, curr_status);
60916092
/* update the current status as the urgent bkops level */

0 commit comments

Comments
 (0)