Linux SCSI subsystem development
 help / color / mirror / Atom feed
* [PATCH v3 1/1] scsi: ufs: core: Flush exception handling work when RPM level is zero
@ 2026-01-29  7:06 Thomas Yen
  2026-01-29 13:42 ` Peter Wang (王信友)
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Thomas Yen @ 2026-01-29  7:06 UTC (permalink / raw)
  Cc: Thomas Yen, Stable Tree, Alim Akhtar, Avri Altman,
	Bart Van Assche, James E.J. Bottomley, Martin K. Petersen,
	Peter Wang, Bean Huo, Adrian Hunter, Bao D. Nguyen,
	open list:UNIVERSAL FLASH STORAGE HOST CONTROLLER DRIVER,
	open list

Ensure that the exception event handling work is explicitly flushed
during suspend when the runtime power management level is set to
UFS_PM_LVL_0.

When the RPM level is zero, the device power mode and link state both
remain active. Previously, the UFS core driver bypassed flushing
exception event handling jobs in this configuration. This created a race
condition where the driver could attempt to access the host controller
to handle an exception after the system had already entered a deep
power-down state, resulting in a system crash.

Explicitly flush this work and disable auto BKOPs before the suspend
callback proceeds. This guarantees that pending exception tasks complete
and prevents illegal hardware access during the power-down sequence.

Signed-off-by: Thomas Yen <thomasyen@google.com>
Cc: Stable Tree <stable@vger.kernel.org>
---
v3:
 - Add logic to disable BKOPs.
v2:
 - Add Cc: stable tag.
 - Reformat commit message text for better line wrapping.
---
 drivers/ufs/core/ufshcd.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
index 0369043ca010..8c88dd5c2cca 100644
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -9997,6 +9997,8 @@ static int __ufshcd_wl_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op)
 
 	if (req_dev_pwr_mode == UFS_ACTIVE_PWR_MODE &&
 			req_link_state == UIC_LINK_ACTIVE_STATE) {
+		ufshcd_disable_auto_bkops(hba);
+		flush_work(&hba->eeh_work);
 		goto vops_suspend;
 	}
 

base-commit: a48ca06cf343423faa01c573aeafba9fa5f92577
-- 
2.53.0.rc1.225.gd81095ad13-goog


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH v3 1/1] scsi: ufs: core: Flush exception handling work when RPM level is zero
  2026-01-29  7:06 [PATCH v3 1/1] scsi: ufs: core: Flush exception handling work when RPM level is zero Thomas Yen
@ 2026-01-29 13:42 ` Peter Wang (王信友)
  2026-01-29 14:08 ` [PATCH v3] " Markus Elfring
  2026-01-29 17:04 ` [PATCH v3 1/1] " Bart Van Assche
  2 siblings, 0 replies; 8+ messages in thread
From: Peter Wang (王信友) @ 2026-01-29 13:42 UTC (permalink / raw)
  To: thomasyen@google.com
  Cc: beanhuo@micron.com, avri.altman@wdc.com, quic_nguyenb@quicinc.com,
	linux-scsi@vger.kernel.org, bvanassche@acm.org,
	linux-kernel@vger.kernel.org, adrian.hunter@intel.com,
	alim.akhtar@samsung.com, stable@vger.kernel.org,
	martin.petersen@oracle.com, James.Bottomley@HansenPartnership.com

On Thu, 2026-01-29 at 15:06 +0800, Thomas Yen wrote:
> Ensure that the exception event handling work is explicitly flushed
> during suspend when the runtime power management level is set to
> UFS_PM_LVL_0.
> 
> When the RPM level is zero, the device power mode and link state both
> remain active. Previously, the UFS core driver bypassed flushing
> exception event handling jobs in this configuration. This created a
> race
> condition where the driver could attempt to access the host
> controller
> to handle an exception after the system had already entered a deep
> power-down state, resulting in a system crash.
> 
> Explicitly flush this work and disable auto BKOPs before the suspend
> callback proceeds. This guarantees that pending exception tasks
> complete
> and prevents illegal hardware access during the power-down sequence.
> 
> Signed-off-by: Thomas Yen <thomasyen@google.com>
> Cc: Stable Tree <stable@vger.kernel.org>
> ---


Reviewed-by: Peter Wang <peter.wang@mediatek.com>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v3] scsi: ufs: core: Flush exception handling work when RPM level is zero
  2026-01-29  7:06 [PATCH v3 1/1] scsi: ufs: core: Flush exception handling work when RPM level is zero Thomas Yen
  2026-01-29 13:42 ` Peter Wang (王信友)
@ 2026-01-29 14:08 ` Markus Elfring
  2026-01-29 17:04 ` [PATCH v3 1/1] " Bart Van Assche
  2 siblings, 0 replies; 8+ messages in thread
From: Markus Elfring @ 2026-01-29 14:08 UTC (permalink / raw)
  To: Thomas Yen, linux-scsi, Adrian Hunter, Alim Akhtar, Avri Altman,
	Bao D. Nguyen, Bart Van Assche, Bean Huo, James Bottomley,
	Martin K. Petersen, Peter Wang
  Cc: stable, LKML

You should probably specify message recipients not only in the header field “Cc”.
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.19-rc7#n231> ---
> v3:
> v2:
>  - Add Cc: stable tag.
…

Will the tag “Fixes” become also helpful accordingly?
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.19-rc7#n145

Regards,
Markus

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v3 1/1] scsi: ufs: core: Flush exception handling work when RPM level is zero
  2026-01-29  7:06 [PATCH v3 1/1] scsi: ufs: core: Flush exception handling work when RPM level is zero Thomas Yen
  2026-01-29 13:42 ` Peter Wang (王信友)
  2026-01-29 14:08 ` [PATCH v3] " Markus Elfring
@ 2026-01-29 17:04 ` Bart Van Assche
  2026-01-29 17:19   ` Thomas Yen
  2 siblings, 1 reply; 8+ messages in thread
From: Bart Van Assche @ 2026-01-29 17:04 UTC (permalink / raw)
  To: Thomas Yen
  Cc: Stable Tree, Alim Akhtar, Avri Altman, James E.J. Bottomley,
	Martin K. Petersen, Peter Wang, Bean Huo, Adrian Hunter,
	Bao D. Nguyen,
	open list:UNIVERSAL FLASH STORAGE HOST CONTROLLER DRIVER,
	open list

On 1/28/26 11:06 PM, Thomas Yen wrote:
> Ensure that the exception event handling work is explicitly flushed
> during suspend when the runtime power management level is set to
> UFS_PM_LVL_0.
> 
> When the RPM level is zero, the device power mode and link state both
> remain active. Previously, the UFS core driver bypassed flushing
> exception event handling jobs in this configuration. This created a race
> condition where the driver could attempt to access the host controller
> to handle an exception after the system had already entered a deep
> power-down state, resulting in a system crash.
> 
> Explicitly flush this work and disable auto BKOPs before the suspend
> callback proceeds. This guarantees that pending exception tasks complete
> and prevents illegal hardware access during the power-down sequence.
> 
> Signed-off-by: Thomas Yen <thomasyen@google.com>
> Cc: Stable Tree <stable@vger.kernel.org>
For future patch submissions, please place the Cc: tag above the
Signed-off-by tag. I think that is a widely used convention in the Linux
kernel community. Anyway:

Reviewed-by: Bart Van Assche <bvanassche@acm.org>


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v3 1/1] scsi: ufs: core: Flush exception handling work when RPM level is zero
  2026-01-29 17:04 ` [PATCH v3 1/1] " Bart Van Assche
@ 2026-01-29 17:19   ` Thomas Yen
  2026-01-29 17:23     ` Bart Van Assche
  0 siblings, 1 reply; 8+ messages in thread
From: Thomas Yen @ 2026-01-29 17:19 UTC (permalink / raw)
  To: Bart Van Assche
  Cc: Stable Tree, Alim Akhtar, Avri Altman, James E.J. Bottomley,
	Martin K. Petersen, Peter Wang, Bean Huo, Adrian Hunter,
	Bao D. Nguyen,
	open list:UNIVERSAL FLASH STORAGE HOST CONTROLLER DRIVER,
	open list

Hi Bart,

Thanks for the tip regarding the tag ordering. I will ensure the Cc
tag is placed above the Signed-off-by tag in future submissions.

I had just sent v4 (to add the missing Fixes tag) before seeing this
message. Since the code logic in v4 is identical to v3, I hope that is
acceptable. Thanks.

Thomas


On Fri, Jan 30, 2026 at 1:04 AM Bart Van Assche <bvanassche@acm.org> wrote:
>
> On 1/28/26 11:06 PM, Thomas Yen wrote:
> > Ensure that the exception event handling work is explicitly flushed
> > during suspend when the runtime power management level is set to
> > UFS_PM_LVL_0.
> >
> > When the RPM level is zero, the device power mode and link state both
> > remain active. Previously, the UFS core driver bypassed flushing
> > exception event handling jobs in this configuration. This created a race
> > condition where the driver could attempt to access the host controller
> > to handle an exception after the system had already entered a deep
> > power-down state, resulting in a system crash.
> >
> > Explicitly flush this work and disable auto BKOPs before the suspend
> > callback proceeds. This guarantees that pending exception tasks complete
> > and prevents illegal hardware access during the power-down sequence.
> >
> > Signed-off-by: Thomas Yen <thomasyen@google.com>
> > Cc: Stable Tree <stable@vger.kernel.org>
> For future patch submissions, please place the Cc: tag above the
> Signed-off-by tag. I think that is a widely used convention in the Linux
> kernel community. Anyway:
>
> Reviewed-by: Bart Van Assche <bvanassche@acm.org>
>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v3 1/1] scsi: ufs: core: Flush exception handling work when RPM level is zero
  2026-01-29 17:19   ` Thomas Yen
@ 2026-01-29 17:23     ` Bart Van Assche
  2026-01-29 17:39       ` Thomas Yen
  0 siblings, 1 reply; 8+ messages in thread
From: Bart Van Assche @ 2026-01-29 17:23 UTC (permalink / raw)
  To: Thomas Yen
  Cc: Stable Tree, Alim Akhtar, Avri Altman, James E.J. Bottomley,
	Martin K. Petersen, Peter Wang, Bean Huo, Adrian Hunter,
	Bao D. Nguyen,
	open list:UNIVERSAL FLASH STORAGE HOST CONTROLLER DRIVER,
	open list

On 1/29/26 9:19 AM, Thomas Yen wrote:
> I had just sent v4 (to add the missing Fixes tag) before seeing this
> message. Since the code logic in v4 is identical to v3, I hope that is
> acceptable.
It seems like our emails crossed each other. This is something that can
happen.

When reposting a patch, Reviewed-by tags should be included. I don't see
any Reviewed-by tags in v4 of this patch although Peter Wang had posted
a Reviewed-by?

Thanks,

Bart.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v3 1/1] scsi: ufs: core: Flush exception handling work when RPM level is zero
  2026-01-29 17:23     ` Bart Van Assche
@ 2026-01-29 17:39       ` Thomas Yen
  2026-01-30 22:58         ` Bart Van Assche
  0 siblings, 1 reply; 8+ messages in thread
From: Thomas Yen @ 2026-01-29 17:39 UTC (permalink / raw)
  To: Bart Van Assche
  Cc: Stable Tree, Alim Akhtar, Avri Altman, James E.J. Bottomley,
	Martin K. Petersen, Peter Wang, Bean Huo, Adrian Hunter,
	Bao D. Nguyen,
	open list:UNIVERSAL FLASH STORAGE HOST CONTROLLER DRIVER,
	open list

Hi Bart,

My apologies. I missed that Peter had already replied with his
Reviewed-by tag on this v3 thread before I sent v4.

Since v4 is currently bare of tags but the code is identical, would
you prefer I send a v5 to consolidate all the tags and fix the Cc-tag
ordering? Or should I wait for you and Peter to reply to the v4
thread?

Thanks,
Thomas

On Fri, Jan 30, 2026 at 1:23 AM Bart Van Assche <bvanassche@acm.org> wrote:
>
> On 1/29/26 9:19 AM, Thomas Yen wrote:
> > I had just sent v4 (to add the missing Fixes tag) before seeing this
> > message. Since the code logic in v4 is identical to v3, I hope that is
> > acceptable.
> It seems like our emails crossed each other. This is something that can
> happen.
>
> When reposting a patch, Reviewed-by tags should be included. I don't see
> any Reviewed-by tags in v4 of this patch although Peter Wang had posted
> a Reviewed-by?
>
> Thanks,
>
> Bart.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v3 1/1] scsi: ufs: core: Flush exception handling work when RPM level is zero
  2026-01-29 17:39       ` Thomas Yen
@ 2026-01-30 22:58         ` Bart Van Assche
  0 siblings, 0 replies; 8+ messages in thread
From: Bart Van Assche @ 2026-01-30 22:58 UTC (permalink / raw)
  To: Thomas Yen
  Cc: Stable Tree, Alim Akhtar, Avri Altman, James E.J. Bottomley,
	Martin K. Petersen, Peter Wang, Bean Huo, Adrian Hunter,
	Bao D. Nguyen,
	open list:UNIVERSAL FLASH STORAGE HOST CONTROLLER DRIVER,
	open list

On 1/29/26 9:39 AM, Thomas Yen wrote:
> My apologies. I missed that Peter had already replied with his
> Reviewed-by tag on this v3 thread before I sent v4.

In the future, please leave more time between posting different versions
of a patch. Posting four versions of the same patch in five days is too
frequent because it doesn't give reviewers enough time to react.

Thanks,

Bart.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2026-01-30 22:59 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-29  7:06 [PATCH v3 1/1] scsi: ufs: core: Flush exception handling work when RPM level is zero Thomas Yen
2026-01-29 13:42 ` Peter Wang (王信友)
2026-01-29 14:08 ` [PATCH v3] " Markus Elfring
2026-01-29 17:04 ` [PATCH v3 1/1] " Bart Van Assche
2026-01-29 17:19   ` Thomas Yen
2026-01-29 17:23     ` Bart Van Assche
2026-01-29 17:39       ` Thomas Yen
2026-01-30 22:58         ` Bart Van Assche

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox