Re: [PATCH v1] scsi: ufs: core: Remove the ufshcd_release in ufshcd_err_handling_prepare

From: Can Guo
Date: Wed Jan 31 2024 - 22:37:02 EST




On 2/1/2024 1:44 AM, Bart Van Assche wrote:
On 1/22/24 00:33, SEO HOYOUNG wrote:
This is because ufshcd_errhandling_prepare() and
ufshcd_err_handling_unprepare() repeatedly release calls.

It would have been much more clear if it would have been mentioned that
ufshcd_err_handling_prepare() should call ufshcd_hold() once and
also that ufshcd_err_handling_unprepare() should call ufshcd_release()
once.

Additionally, a Fixes: tag is missing. Is this patch perhaps a fix for commit
c72e79c0ad2b ("scsi: ufs: Recover HBA runtime PM error in error handler")?
Can Guo, since you wrote that patch, can you please take a look at this patch?

diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
index 7c59d7a02243..423e83074a20 100644
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -6351,7 +6351,6 @@ static void ufshcd_err_handling_prepare(struct ufs_hba *hba)
          ufshcd_hold(hba);
          if (!ufshcd_is_clkgating_allowed(hba))
              ufshcd_setup_clocks(hba, true);
-        ufshcd_release(hba);

When we are here, it means runtime resume has failed.

When I wrote the code (in older kernel), ufshcd_runtime_resume(), if fails, bails without calling ufshcd_release(), eventually ufshcd_err_handling_unprepare() would call ufshcd_release() to balance.

But now, I see that if __ufshcd_wl_resume() fails, ufshcd_release() is called anyways, so ufshcd_release() is not required here. Hence,

Reviewed-by: Can Guo <quic_cang@xxxxxxxxxxx>

          pm_op = hba->is_sys_suspended ? UFS_SYSTEM_PM : UFS_RUNTIME_PM;
          ufshcd_vops_resume(hba, pm_op);
      } else {

Reviewed-by: Bart Van Assche <bvanassche@xxxxxxx>