Re: [PATCH v8 3/3] scsi: ufs: core: Limit early link recovery in the error handler to runtime PM

From: Bart Van Assche

Date: Mon Nov 09 2026 - 13:22:54 EST


On 11/9/26 9:08 AM, Bean Huo wrote:
> On Mon, 2026-11-09 at 13:09 +0900, HOYOUNG SEO wrote:
>> diff --git a/drivers/ufs/core/ufshcd-priv.h b/drivers/ufs/core/ufshcd-priv.h
>> index e55c2a02c1f5..ae3eaf5ab017 100644
>> --- a/drivers/ufs/core/ufshcd-priv.h
>> +++ b/drivers/ufs/core/ufshcd-priv.h
>> @@ -413,6 +413,19 @@ static inline void ufshcd_rpm_put(struct ufs_hba *hba)
>> pm_runtime_put(&hba->ufs_device_wlun->sdev_gendev);
>> }
>>
>> +/* Whether a runtime suspend or resume of the WLUN is in progress. */
>> +static inline bool ufshcd_rpm_transition_in_progress(struct ufs_hba *hba)
>> +{
>> +#ifdef CONFIG_PM
>> + enum rpm_status status =
>> + READ_ONCE(hba->ufs_device_wlun->sdev_gendev.power.runtime_status);
>> +
>> + return status == RPM_SUSPENDING || status == RPM_RESUMING;
>
> should the helper also check pm_op_in_progress?
>
> return hba->pm_op_in_progress && (status == RPM_SUSPENDING || status ==
> RPM_RESUMING);
>
> checking (status == RPM_SUSPENDING || status == RPM_RESUMING) fixes for system
> PM;
>
> Checking pm_op_in_progress limits the early path to __ufshcd_wl_suspend() and
> __ufshcd_wl_resume() during runtime PM, it was before this patch.
>
> Or what else I missed?

Good catch. The runtime PM core sets runtime_status to RPM_SUSPENDING
before calling the device's runtime suspend callback (and before
ufshcd_hold() is called), and keeps it set until after
blk_post_runtime_suspend() (after ufshcd_release() has been called).

Checking both hba->pm_op_in_progress and the WLUN runtime_status ensures
the early recovery path only runs while __ufshcd_wl_suspend() or
__ufshcd_wl_resume() is actively running and clocks are held.

Hoyoung, please include the pm_op_in_progress check in the helper or at
the call site in v9.

Thanks,

Bart.