Re: [PATCH v20 1/2] scsi: ufs: Enable power management for wlun

From: Adrian Hunter
Date: Tue Apr 20 2021 - 00:15:35 EST


On 20/04/21 12:53 am, Asutosh Das (asd) wrote:
> On 4/19/2021 11:37 AM, Adrian Hunter wrote:
>> On 16/04/21 10:49 pm, Asutosh Das wrote:
>>>
>>> Co-developed-by: Can Guo <cang@xxxxxxxxxxxxxx>
>>> Signed-off-by: Can Guo <cang@xxxxxxxxxxxxxx>
>>> Signed-off-by: Asutosh Das <asutoshd@xxxxxxxxxxxxxx>
>>> ---
>>
>> I came across 3 issues while testing.  See comments below.
>>
> Hi Adrian
> Thanks for the comments.
>> <SNIP>
>>
>>> @@ -5794,7 +5839,7 @@ static void ufshcd_err_handling_unprepare(struct ufs_hba *hba)
>>>       if (ufshcd_is_clkscaling_supported(hba))
>>>           ufshcd_clk_scaling_suspend(hba, false);
>>>       ufshcd_clear_ua_wluns(hba);
>>
>> ufshcd_clear_ua_wluns() deadlocks trying to clear UFS_UPIU_RPMB_WLUN
>> if sdev_rpmb is suspended and sdev_ufs_device is suspending.
>> e.g. ufshcd_wl_suspend() is waiting on host_sem while ufshcd_err_handler()
>> is running, at which point sdev_rpmb has already suspended.
>>
> Umm, I didn't understand this deadlock.
> When you say, sdev_rpmb is suspended, does it mean runtime_suspended?
> sdev_ufs_device is suspending - this can't be runtime_suspending, while ufshcd_err_handling_unprepare is running.
>
> If you've a call-stack of this deadlock, please can you share it with me. I'll also try to reproduce this.

Yes it is system suspend. sdev_rpmb has suspended, sdev_ufs_device is waiting on host_sem.
ufshcd_err_handler() holds host_sem. ufshcd_clear_ua_wlun(UFS_UPIU_RPMB_WLUN) gets stuck.
I will get some call-stacks.

>
> I'll address the other comments in the next version.
>
>
> Thank you!
>
>>> -    pm_runtime_put(hba->dev);
>>> +    ufshcd_rpm_put(hba);
>>>   }
>>
>> <SNIP>
>>
>>> +void ufshcd_resume_complete(struct device *dev)
>>> +{
>