Re: [PATCH v1 1/2] scsi: ufs: add required delay after gating reference clock

From: Can Guo
Date: Wed Feb 19 2020 - 05:33:48 EST


Hi Stanley,

On 2020-02-19 17:11, Stanley Chu wrote:
Hi Can,

On Wed, 2020-02-19 at 10:35 +0800, Can Guo wrote:

Since we all need this delay here, how about put the delay in the
entrence of ufshcd_setup_clocks(), before vops_setup_clocks()?
If so, we can remove all the delays we added in our vops since the
delay anyways delays everything inside ufshcd_setup_clocks().


Always putting the delay in the entrance of ufshcd_setup_clocks() may
add unwanted delay for vendors, just like your current implementation,
or some other vendors who do not want to disable the reference clock.

I think current patch is more reasonable because the delay is applied to
clock only named as "ref_clk" specifically.

If you needs to keep "ref_clk" in DT, would you consider to remove the
delay in your ufs_qcom_dev_ref_clk_ctrl() and let the delay happens via
common ufshcd_setup_clocks() only? However you may still need delay if
call path comes from ufs_qcom_pwr_change_notify().

What do you think?


I agree current change is more reasonable from what it looks, but the fact
is that I canont remove the delay in ufs_qcom_dev_ref_clk_ctrl() even with
this change. On our platforms, ref_clk in DT serves multipule purposes,
the ref_clk provided to UFS device is actually controlled in
ufs_qcom_dev_ref_clk_ctrl(), which comes before where this change kicks start,
so if I remove the delay in ufs_qcom_dev_ref_clk_ctrl(), this change cannot
provide us the correct delay before gate the ref_clk provided to UFS device.

Always putting the delay in the entrance of ufshcd_setup_clocks() may
add unwanted delay for vendors, just like your current implementation,
or some other vendors who do not want to disable the reference clock.

I meant if we put the delay in the entrance, I will be able to remove
the delay in ufs_qcom_dev_ref_clk_ctrl(). Meanwhile, we can add proper
checks before the delay to make sure it is initiated only if ref_clk needs
to be disabled, i.e:

if(!on && !skip_ref_clk && hba->dev_info.clk_gating_wait_us)
usleep_range();

Does this look better to you?

Anyways, we will see regressions with this change on our platforms, can we
have more discussions before get it merged? It should be OK if you go with
patch #2 alone first, right? Thanks.

Best regards,
Can Guo.

Meanwhile, if you want to modify the delay
(hba->dev_info.clk_gating_wait_us) for some reasons, say for specific
UFS devices, you still can do it in vops_apply_dev_quirks().

What do you say?

Thanks,
Can Guo.

Thanks,
Stanley Chu