Re: [PATCH v1 1/2] scsi: ufs: set device as default active power mode during initialization only

From: Can Guo
Date: Mon Dec 30 2019 - 21:13:40 EST


On 2019-12-31 09:07, Stanley Chu wrote:
Hi Asutosh,


I see that there's a get_sync done before.
So, how would the suspend be triggered in that case?


Would you mean pm_runtime_get_sync() in ufshcd_init()?
If yes, it will only happen during initialization.

The runtime resume path may go through ufshcd_probe_hba() without
ufshcd_init() invoked before, for example,

ufshcd_probe_hba+0xe10/0x1874
ufshcd_host_reset_and_restore+0x114/0x1a4
ufshcd_resume+0x1d0/0x480
ufshcd_runtime_resume+0x40/0x188
ufshcd_pltfrm_runtime_resume+0x10/0x18
pm_generic_runtime_resume+0x24/0x44
__rpm_callback+0x100/0x250
rpm_resume+0x548/0x7c8
rpm_resume+0x2b4/0x7c8
rpm_resume+0x2b4/0x7c8
rpm_resume+0x2b4/0x7c8
pm_runtime_work+0x9c/0xa0
process_one_work+0x210/0x4e0
worker_thread+0x390/0x520
kthread+0x154/0x18c
ret_from_fork+0x10/0x18

This case happens if link is in "off" state while resume.

Thanks,
Stanley

Hi Stanley,

I see skipping ufshcd_set_ufs_dev_active() in ufshcd_probe_hba()
if it is called from ufshcd_resume() path is the purpose here.

If so, then ufshcd_set_dev_pwr_mode() would be called, meaning
SSU command will be sent. Why is this SSU command needed to be
sent after a full host reset and restore? Is ufshcd_probe_hba()
not enough to make UFS device fully functional?

<snip>
} else if (ufshcd_is_link_off(hba)) {
ret = ufshcd_host_reset_and_restore(hba);
/*
* ufshcd_host_reset_and_restore() should have already
* set the link state as active
*/
if (ret || !ufshcd_is_link_active(hba))
goto vendor_suspend;
}

if (!ufshcd_is_ufs_dev_active(hba)) {
ret = ufshcd_set_dev_pwr_mode(hba, UFS_ACTIVE_PWR_MODE);
if (ret)
goto set_old_link_state;
}
<snip>

Thanks,

Can Guo.