scsi: ufs: core: cancel RTC work in active-active suspend
Subsystems (2)
PATCH 1/1 scsi: ufs: core: cancel RTC work in active-active suspend
UFS RTC support schedules ufs_rtc_update_work to periodically update the device RTC. The work can issue query commands and access the UFS host controller.
__ufshcd_wl_suspend() cancels ufs_rtc_update_work in the common suspend path before calling the vendor suspend callback. However, the active-active path, where both the device power mode and link state stay active, jumps directly to vops_suspend after flushing exception handling work. That jump bypasses the RTC work cancellation.
If the RTC work runs while the vendor suspend callback is gating or otherwise changing hardware state, it can access the controller during suspend and trigger an SError.
Cancel the RTC work in the active-active path before jumping to vops_suspend, matching the common suspend path.
--- drivers/ufs/core/ufshcd.c | 1 + 1 file changed, 1 insertion(+)
drivers/ufs/core/ufshcd.c +1 -0
@@ -10269,6 +10269,7 @@ static int __ufshcd_wl_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op) req_link_state == UIC_LINK_ACTIVE_STATE) {ufshcd_disable_auto_bkops (hba);flush_work (&hba->eeh_work); +cancel_delayed_work_sync (&hba->ufs_rtc_update_work); goto vops_suspend; }
Signature · 1 line
2.43.0
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] The patch cancels ufs_rtc_update_work during the active-active suspend path but fails to…
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The patch cancels ufs_rtc_update_work during the active-active suspend path but fails to re-schedule it when the device resumes, causing periodic RTC updates to permanently stop. --
--- Patch [1]: [PATCH] scsi: ufs: core: cancel RTC work in active-active suspend --- commit d6ec0bf16c0b8402d3955ca2fc9c1ec563b33c79
Author: Guangshuo Li <[email protected]>
scsi: ufs: core: cancel RTC work in active-active suspend
This commit modifies the active-active suspend path in __ufshcd_wl_suspend() to cancel the ufs_rtc_update_work before jumping to vops_suspend. This prevents the RTC work from accessing the controller while the hardware state is changing.
drivers/ufs/core/ufshcd.c static int __ufshcd_wl_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op) · line 10272
Quoted 9 lines
drivers/ufs/core/ufshcd.c +1
-0@@ -10269,6 +10269,7 @@ static int __ufshcd_wl_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op) req_link_state == UIC_LINK_ACTIVE_STATE) {ufshcd_disable_auto_bkops (hba);flush_work (&hba->eeh_work); +cancel_delayed_work_sync (&hba->ufs_rtc_update_work);
[Severity: Medium]
If the work is cancelled here during active-active suspend, will it be safely rescheduled on resume?
Looking at __ufshcd_wl_resume(), the rescheduling of ufs_rtc_update_work appears to be gated by a check for whether the device is not active:
drivers/ufs/core/ufshcd.c:__ufshcd_wl_resume() {
...
if (!ufshcd_is_ufs_dev_active(hba)) {
ret = ufshcd_set_dev_pwr_mode(hba, UFS_ACTIVE_PWR_MODE);
if (ret)
goto set_old_link_state;
ufshcd_set_timestamp_attr(hba);
schedule_delayed_work(&hba->ufs_rtc_update_work,
msecs_to_jiffies(UFS_RTC_UPDATE_INTERVAL_MS));
}
...
}Since the active-active suspend path leaves the device in UFS_ACTIVE_PWR_MODE, it looks like ufshcd_is_ufs_dev_active(hba) will evaluate to true. Does this cause the periodic RTC work to be permanently stopped after the first active-active suspend cycle?
Quoted 3 lines
drivers/ufs/core/ufshcd.c +0
-0goto vops_suspend; }
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Quoted 50 lines · On Wed, 2026-07-08 at 13:03 +0000, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The patch cancelsufs_rtc_update_workduring the active-active suspend path but fails to re-schedule it when the device resumes, causing periodic RTC updates to permanently stop.
----- Patch [1]: [PATCH] scsi: ufs: core: cancel RTC work in active-active suspend ---
commitd6ec0bf16c0b8402d3955ca2fc9c1ec563b33c79
Author: Guangshuo Li <[email protected]>scsi: ufs: core: cancel RTC work in active-active suspend
This commit modifies the active-active suspend path in__ufshcd_wl_suspend()to cancel theufs_rtc_update_workbefore jumping tovops_suspend. This prevents the RTC work from accessing the controller while the hardware state is changing.drivers/ufs/core/ufshcd.c static int __ufshcd_wl_suspend(struct ufs_hba *hba, · line 10273
Quoted 10 lines
drivers/ufs/core/ufshcd.c +1
-0@@ -10269,6 +10269,7 @@ static int __ufshcd_wl_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op) req_link_state == UIC_LINK_ACTIVE_STATE) { ufshcd_disable_auto_bkops(hba); flush_work(&hba->eeh_work); + cancel_delayed_work_sync(&hba->ufs_rtc_update_work);[Severity: Medium]
If the work is cancelled here during active-active suspend, will it be safely rescheduled on resume?Looking at
__ufshcd_wl_resume(), the rescheduling ofufs_rtc_update_workappears to be gated by a check for whether the device is not active:drivers/ufs/core/ufshcd.c:__ufshcd_wl_resume() {
...
if (!ufshcd_is_ufs_dev_active(hba)) {
ret =ufshcd_set_dev_pwr_mode(hba, UFS_ACTIVE_PWR_MODE); if (ret)
gotoset_old_link_state;ufshcd_set_timestamp_attr(hba);schedule_delayed_work(&hba->ufs_rtc_update_work, msecs_to_jiffies(UFS_RTC_UPDATE_INTERVAL_MS)); }
...
}
Quoted 4 lines
Since the active-active suspend path leaves the device in
UFS_ACTIVE_PWR_MODE, it looks likeufshcd_is_ufs_dev_active(hba)will evaluate to true. Does this cause the periodic RTC work to be permanently stopped after the first active-active suspend cycle?
good catch, about this change:
drivers/ufs/core/ufshcd.c +0 -0
@@ -10339,6 +10339,7 @@ static int __ufshcd_wl_suspend(struct ufs_hba *hba, enum
ufs_pm_op pm_op)
req_link_state == UIC_LINK_ACTIVE_STATE) {
ufshcd_disable_auto_bkops(hba);
flush_work(&hba->eeh_work);
+ cancel_delayed_work_sync(&hba->ufs_rtc_update_work);
goto vops_suspend;
}@@ -10548,10 +10549,11 @@ static int __ufshcd_wl_resume(struct ufs_hba *hba, enum ufs_pm_op pm_op)
if (ret)
goto set_old_link_state;
ufshcd_set_timestamp_attr(hba);
- schedule_delayed_work(&hba->ufs_rtc_update_work,
-
msecs_to_jiffies(UFS_RTC_UPDATE_INTERVAL_MS));
}+ schedule_delayed_work(&hba->ufs_rtc_update_work,
+ msecs_to_jiffies(UFS_RTC_UPDATE_INTERVAL_MS));
+
if (ufshcd_keep_autobkops_enabled_except_suspend(hba))
ufshcd_enable_auto_bkops(hba);
elseQuoted 5 lines
Quoted 4 lines
drivers/ufs/core/ufshcd.c +0
-0goto vops_suspend; }
Quoted 10 lines · Guangshuo Li
UFS RTC support schedules
ufs_rtc_update_workto periodically update the device RTC. The work can issue query commands and access the UFS host controller.
__ufshcd_wl_suspend()cancelsufs_rtc_update_workin the common suspend path before calling the vendor suspend callback. However, the active-active path, where both the device power mode and link state stay active, jumps directly tovops_suspendafter flushing exception handling work. That jump bypasses the RTC work cancellation.
Quoted 8 lines
If the RTC work runs while the vendor suspend callback is gating or otherwise changing hardware state, it can access the controller during suspend and trigger an SError.
Cancel the RTC work in the active-active path before jumping to
vops_suspend, matching the common suspend path.Fixes 6bf999e0eb41 ("scsi: ufs: core: Add UFS RTC support")
this fix tag is wrong, should be:
UFS suspend")
since 6bf999e0eb41 ("scsi: ufs: core: Add UFS RTC support") placed the cancel after the vops_suspend: label (after the POST_CHANGE vops call), so the active- active goto vops_suspend path did cancel the work. then b0bd84c39289 ("scsi:
ufs: core: Fix SError in ufshcd_rtc_work() during UFS suspend", moved the cancel up above the PRE_CHANGE vops call to close a race in the common path. That move is what removed cancellation from the active-active path. So the correct tag is
Quoted 10 lines
Signed-off-by Guangshuo Li <[email protected]>---
drivers/ufs/core/ufshcd.c | 1 +1 file changed, 1 insertion(+)drivers/ufs/core/ufshcd.c +0
-0
drivers/ufs/core/ufshcd.c static int __ufshcd_wl_suspend(struct ufs_hba *hba, · line 10273
Quoted 5 lines
drivers/ufs/core/ufshcd.c +1
-0@@ -10269,6 +10269,7 @@ static int __ufshcd_wl_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op) req_link_state == UIC_LINK_ACTIVE_STATE) { ufshcd_disable_auto_bkops(hba); flush_work(&hba->eeh_work); + cancel_delayed_work_sync(&hba->ufs_rtc_update_work);
RTC updates stop permanently after the first active-active suspend. you need to add resume:
drivers/ufs/core/ufshcd.c +0 -0
@@ -10339,6 +10339,7 @@ static int __ufshcd_wl_suspend(struct ufs_hba *hba, enum
ufs_pm_op pm_op)
req_link_state == UIC_LINK_ACTIVE_STATE) {
ufshcd_disable_auto_bkops(hba);
flush_work(&hba->eeh_work);
+ cancel_delayed_work_sync(&hba->ufs_rtc_update_work);
goto vops_suspend;
}@@ -10548,10 +10549,11 @@ static int __ufshcd_wl_resume(struct ufs_hba *hba, enum ufs_pm_op pm_op)
if (ret)
goto set_old_link_state;
ufshcd_set_timestamp_attr(hba);
- schedule_delayed_work(&hba->ufs_rtc_update_work,
-
msecs_to_jiffies(UFS_RTC_UPDATE_INTERVAL_MS));
}+ schedule_delayed_work(&hba->ufs_rtc_update_work,
+ msecs_to_jiffies(UFS_RTC_UPDATE_INTERVAL_MS));
+
if (ufshcd_keep_autobkops_enabled_except_suspend(hba))
ufshcd_enable_auto_bkops(hba);
elseKind regards,
Bean
Quoted 3 lines
drivers/ufs/core/ufshcd.c +0
-0goto vops_suspend; }
Hi Guangshuo
would you like to update your patch with the consideration of RTC update resume?
Kind regard,
Bean
Quoted 99 lines · Bean Huo
Quoted 10 lines · Guangshuo Li
UFS RTC support schedules
ufs_rtc_update_workto periodically update the device RTC. The work can issue query commands and access the UFS host controller.
__ufshcd_wl_suspend()cancelsufs_rtc_update_workin the common suspend path before calling the vendor suspend callback. However, the active-active path, where both the device power mode and link state stay active, jumps directly tovops_suspendafter flushing exception handling work. That jump bypasses the RTC work cancellation.Quoted 8 lines
If the RTC work runs while the vendor suspend callback is gating or otherwise changing hardware state, it can access the controller during suspend and trigger an SError.
Cancel the RTC work in the active-active path before jumping to
vops_suspend, matching the common suspend path.Fixes 6bf999e0eb41 ("scsi: ufs: core: Add UFS RTC support")this fix tag is wrong, should be:
Fixes b0bd84c39289 ("scsi: ufs: core: Fix SError in ufshcd_rtc_work() duringUFS suspend")
since
6bf999e0eb41("scsi: ufs: core: Add UFS RTC support") placed the cancel after thevops_suspend: label (after thePOST_CHANGEvops call), so the active-
active gotovops_suspendpath did cancel the work. thenb0bd84c39289("scsi:
ufs: core: Fix SError inufshcd_rtc_work()during UFS suspend", moved the cancel
up above thePRE_CHANGEvops call to close a race in the common path. That move
is what removed cancellation from the active-active path. So the correct tag isFixes b0bd84c39289, not 6bf999e0eb41.Quoted 10 lines
Signed-off-by Guangshuo Li <[email protected]>---
drivers/ufs/core/ufshcd.c | 1 +1 file changed, 1 insertion(+)drivers/ufs/core/ufshcd.c +0
-0drivers/ufs/core/ufshcd.c static int __ufshcd_wl_suspend(struct ufs_hba *hba, · line 10273
Quoted 5 lines
drivers/ufs/core/ufshcd.c +1
-0@@ -10269,6 +10269,7 @@ static int __ufshcd_wl_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op) req_link_state == UIC_LINK_ACTIVE_STATE) { ufshcd_disable_auto_bkops(hba); flush_work(&hba->eeh_work); + cancel_delayed_work_sync(&hba->ufs_rtc_update_work);RTC updates stop permanently after the first active-active suspend. you need to
add resume:drivers/ufs/core/ufshcd.c +0
-0@@ -10339,6 +10339,7 @@ static int __ufshcd_wl_suspend(struct ufs_hba *hba,enum
ufs_pm_oppm_op)
req_link_state==UIC_LINK_ACTIVE_STATE) {ufshcd_disable_auto_bkops(hba);flush_work(&hba->eeh_work);
+cancel_delayed_work_sync(&hba->ufs_rtc_update_work); gotovops_suspend;
}drivers/ufs/core/ufshcd.c +0
-2@@ -10548,10 +10549,11 @@ static int __ufshcd_wl_resume(struct ufs_hba *hba, enum ufs_pm_op pm_op) if (ret) goto set_old_link_state; ufshcd_set_timestamp_attr(hba); - schedule_delayed_work(&hba->ufs_rtc_update_work, - msecs_to_jiffies(UFS_RTC_UPDATE_INTERVAL_MS)); }
+ schedule_delayed_work(&hba->ufs_rtc_update_work,
+msecs_to_jiffies(UFS_RTC_UPDATE_INTERVAL_MS)); +
if (ufshcd_keep_autobkops_enabled_except_suspend(hba))ufshcd_enable_auto_bkops(hba);
elseKind regards,
BeanQuoted 3 lines
drivers/ufs/core/ufshcd.c +0
-0goto vops_suspend; }
Hi Bean,
Quoted 111 lines · Bean Huo
Hi Guangshuo
would you like to update your patch with the consideration of RTC update resume?
Kind regard,
BeanQuoted 99 lines · Bean Huo
Quoted 10 lines · Guangshuo Li
UFS RTC support schedules
ufs_rtc_update_workto periodically update the device RTC. The work can issue query commands and access the UFS host controller.
__ufshcd_wl_suspend()cancelsufs_rtc_update_workin the common suspend path before calling the vendor suspend callback. However, the active-active path, where both the device power mode and link state stay active, jumps directly tovops_suspendafter flushing exception handling work. That jump bypasses the RTC work cancellation.Quoted 8 lines
If the RTC work runs while the vendor suspend callback is gating or otherwise changing hardware state, it can access the controller during suspend and trigger an SError.
Cancel the RTC work in the active-active path before jumping to
vops_suspend, matching the common suspend path.Fixes 6bf999e0eb41 ("scsi: ufs: core: Add UFS RTC support")this fix tag is wrong, should be:
Fixes b0bd84c39289 ("scsi: ufs: core: Fix SError in ufshcd_rtc_work() duringUFS suspend")
since
6bf999e0eb41("scsi: ufs: core: Add UFS RTC support") placed the cancel after thevops_suspend: label (after thePOST_CHANGEvops call), so the active-
active gotovops_suspendpath did cancel the work. thenb0bd84c39289("scsi:
ufs: core: Fix SError inufshcd_rtc_work()during UFS suspend", moved the cancel
up above thePRE_CHANGEvops call to close a race in the common path. That move
is what removed cancellation from the active-active path. So the correct tag isFixes b0bd84c39289, not 6bf999e0eb41.Quoted 10 lines
Signed-off-by Guangshuo Li <[email protected]>--- drivers/ufs/core/ufshcd.c | 1 + 1 file changed, 1 insertion(+)drivers/ufs/core/ufshcd.c +0
-0drivers/ufs/core/ufshcd.c static int __ufshcd_wl_suspend(struct ufs_hba *hba, · line 10273
Quoted 5 lines
drivers/ufs/core/ufshcd.c +1
-0@@ -10269,6 +10269,7 @@ static int __ufshcd_wl_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op) req_link_state == UIC_LINK_ACTIVE_STATE) {ufshcd_disable_auto_bkops (hba);flush_work (&hba->eeh_work); +cancel_delayed_work_sync (&hba->ufs_rtc_update_work);RTC updates stop permanently after the first active-active suspend. you need to
add resume:drivers/ufs/core/ufshcd.c +0
-0@@ -10339,6 +10339,7 @@ static int __ufshcd_wl_suspend(struct ufs_hba *hba,enum
ufs_pm_oppm_op)req_link_state == UIC_LINK_ACTIVE_STATE) { ufshcd_disable_auto_bkops(hba); flush_work(&hba->eeh_work);drivers/ufs/core/ufshcd.c +4
-2+cancel_delayed_work_sync (&hba->ufs_rtc_update_work); goto vops_suspend; }@@ -10548,10 +10549,11 @@ static int __ufshcd_wl_resume(struct ufs_hba *hba, enum ufs_pm_op pm_op) if (ret) goto set_old_link_state; ufshcd_set_timestamp_attr(hba); -schedule_delayed_work (&hba->ufs_rtc_update_work, - msecs_to_jiffies(UFS_RTC_UPDATE_INTERVAL_MS)); } + schedule_delayed_work(&hba->ufs_rtc_update_work, + msecs_to_jiffies(UFS_RTC_UPDATE_INTERVAL_MS)); + if (ufshcd_keep_autobkops_enabled_except_suspend(hba))ufshcd_enable_auto_bkops(hba); elseKind regards,
BeanQuoted 3 lines
drivers/ufs/core/ufshcd.c +0
-0goto vops_suspend; }
Yes, I will update the patch to fix the Fixes tag and add the RTC work rescheduling in the resume path.
Thanks for your review and suggestion.
Kind regards,
Guangshuo