* [PATCH] scsi: ufs: core: cancel RTC work in active-active suspend
@ 2026-07-08 12:49 Guangshuo Li
2026-07-08 21:04 ` Bean Huo
0 siblings, 1 reply; 4+ messages in thread
From: Guangshuo Li @ 2026-07-08 12:49 UTC (permalink / raw)
To: Alim Akhtar, Avri Altman, Bart Van Assche, James E.J. Bottomley,
Martin K. Petersen, Peter Wang, Bean Huo, Can Guo, Adrian Hunter,
Luca Porzio, Thomas Weißschuh, Mike Bi, linux-scsi,
linux-kernel
Cc: Guangshuo Li
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.
Fixes: 6bf999e0eb41 ("scsi: ufs: core: Add UFS RTC support")
Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>
---
drivers/ufs/core/ufshcd.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
index d3044a3089b5..9d5571a7aec2 100644
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -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;
}
--
2.43.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] scsi: ufs: core: cancel RTC work in active-active suspend
2026-07-08 12:49 [PATCH] scsi: ufs: core: cancel RTC work in active-active suspend Guangshuo Li
@ 2026-07-08 21:04 ` Bean Huo
2026-07-09 14:49 ` Bean Huo
0 siblings, 1 reply; 4+ messages in thread
From: Bean Huo @ 2026-07-08 21:04 UTC (permalink / raw)
To: Guangshuo Li, Alim Akhtar, Avri Altman, Bart Van Assche,
James E.J. Bottomley, Martin K. Petersen, Peter Wang, Bean Huo,
Can Guo, Adrian Hunter, Thomas Weißschuh, linux-scsi,
linux-kernel
On Wed, 2026-07-08 at 20:49 +0800, Guangshuo Li wrote:
> 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.
>
> 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() during
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
Fixes: b0bd84c39289, not 6bf999e0eb41.
> Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>
> ---
> drivers/ufs/core/ufshcd.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
> index d3044a3089b5..9d5571a7aec2 100644
> --- a/drivers/ufs/core/ufshcd.c
> +++ b/drivers/ufs/core/ufshcd.c
> @@ -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:
diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
index 376a314189e4..06f253b08b65 100644
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -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);
else
Kind regards,
Bean
> goto vops_suspend;
> }
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] scsi: ufs: core: cancel RTC work in active-active suspend
2026-07-08 21:04 ` Bean Huo
@ 2026-07-09 14:49 ` Bean Huo
2026-07-14 16:45 ` Guangshuo Li
0 siblings, 1 reply; 4+ messages in thread
From: Bean Huo @ 2026-07-09 14:49 UTC (permalink / raw)
To: Guangshuo Li, Alim Akhtar, Avri Altman, Bart Van Assche,
James E.J. Bottomley, Martin K. Petersen, Peter Wang, Bean Huo,
Can Guo, Adrian Hunter, Thomas Weißschuh, linux-scsi,
linux-kernel
Hi Guangshuo
would you like to update your patch with the consideration of RTC update resume?
Kind regard,
Bean
On Wed, 2026-07-08 at 23:04 +0200, Bean Huo wrote:
> On Wed, 2026-07-08 at 20:49 +0800, Guangshuo Li wrote:
> > 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.
> >
> > 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() during
> 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
> Fixes: b0bd84c39289, not 6bf999e0eb41.
>
> > Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>
> > ---
> > drivers/ufs/core/ufshcd.c | 1 +
> > 1 file changed, 1 insertion(+)
> >
> > diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
> > index d3044a3089b5..9d5571a7aec2 100644
> > --- a/drivers/ufs/core/ufshcd.c
> > +++ b/drivers/ufs/core/ufshcd.c
> > @@ -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:
>
>
>
> diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
> index 376a314189e4..06f253b08b65 100644
> --- a/drivers/ufs/core/ufshcd.c
> +++ b/drivers/ufs/core/ufshcd.c
> @@ -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);
> else
>
> Kind regards,
> Bean
>
>
>
> > goto vops_suspend;
> > }
> >
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] scsi: ufs: core: cancel RTC work in active-active suspend
2026-07-09 14:49 ` Bean Huo
@ 2026-07-14 16:45 ` Guangshuo Li
0 siblings, 0 replies; 4+ messages in thread
From: Guangshuo Li @ 2026-07-14 16:45 UTC (permalink / raw)
To: Bean Huo
Cc: Alim Akhtar, Avri Altman, Bart Van Assche, James E.J. Bottomley,
Martin K. Petersen, Peter Wang, Bean Huo, Can Guo, Adrian Hunter,
Thomas Weißschuh, linux-scsi, linux-kernel
Hi Bean,
On Thu, 9 Jul 2026 at 22:50, Bean Huo <beanhuo@iokpp.de> wrote:
>
> Hi Guangshuo
>
> would you like to update your patch with the consideration of RTC update resume?
>
>
> Kind regard,
> Bean
>
>
> On Wed, 2026-07-08 at 23:04 +0200, Bean Huo wrote:
> > On Wed, 2026-07-08 at 20:49 +0800, Guangshuo Li wrote:
> > > 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.
> > >
> > > 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() during
> > 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
> > Fixes: b0bd84c39289, not 6bf999e0eb41.
> >
> > > Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>
> > > ---
> > > drivers/ufs/core/ufshcd.c | 1 +
> > > 1 file changed, 1 insertion(+)
> > >
> > > diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
> > > index d3044a3089b5..9d5571a7aec2 100644
> > > --- a/drivers/ufs/core/ufshcd.c
> > > +++ b/drivers/ufs/core/ufshcd.c
> > > @@ -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:
> >
> >
> >
> > diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
> > index 376a314189e4..06f253b08b65 100644
> > --- a/drivers/ufs/core/ufshcd.c
> > +++ b/drivers/ufs/core/ufshcd.c
> > @@ -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);
> > else
> >
> > Kind regards,
> > Bean
> >
> >
> >
> > > goto 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
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-07-14 16:45 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-08 12:49 [PATCH] scsi: ufs: core: cancel RTC work in active-active suspend Guangshuo Li
2026-07-08 21:04 ` Bean Huo
2026-07-09 14:49 ` Bean Huo
2026-07-14 16:45 ` Guangshuo Li
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox