Re: [PATCH v7 2/3] ufs: host: Add ICE clock scaling during UFS clock changes

Abhinaba Rakshit
2026-04-03T18:11:27Z

On Mon, Mar 30, 2026 at 08:09:51PM +0530, Harshal Dev wrote:
> > drivers/ufs/host/ufs-qcom.c | 19 ++++++++++++++++++-
> > 1 file changed, 18 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/ufs/host/ufs-qcom.c b/drivers/ufs/host/ufs-qcom.c
> > index 8d119b3223cbdaa3297d2beabced0962a1a847d5..776444f46fe5f00f947e4b0b4dfe6d64e2ad2150 100644
> > --- a/drivers/ufs/host/ufs-qcom.c
> > +++ b/drivers/ufs/host/ufs-qcom.c
> > @@ -305,6 +305,15 @@ static int ufs_qcom_ice_prepare_key(struct blk_crypto_profile *profile,
> > return qcom_ice_prepare_key(host->ice, lt_key, lt_key_size, eph_key);
> > }
> >
> > +static int ufs_qcom_ice_scale_clk(struct ufs_qcom_host *host, unsigned long target_freq,
> > + bool round_ceil)
> > +{
> > + if (host->hba->caps & UFSHCD_CAP_CRYPTO)
> > + return qcom_ice_scale_clk(host->ice, target_freq, round_ceil);
> > +
> > + return 0;
> > +}
> > +
> > static const struct blk_crypto_ll_ops ufs_qcom_crypto_ops = {
> > .keyslot_program = ufs_qcom_ice_keyslot_program,
> > .keyslot_evict = ufs_qcom_ice_keyslot_evict,
> > @@ -339,6 +348,12 @@ static void ufs_qcom_config_ice_allocator(struct ufs_qcom_host *host)
> > {
> > }
> >
> > +static int ufs_qcom_ice_scale_clk(struct ufs_qcom_host *host, unsigned long target_freq,
> > + bool round_ceil)
> > +{
> > + return 0;
> > +}
> > +
> > #endif
> >
> > static void ufs_qcom_disable_lane_clks(struct ufs_qcom_host *host)
> > @@ -1646,8 +1661,10 @@ static int ufs_qcom_clk_scale_notify(struct ufs_hba *hba, bool scale_up,
> > else
> > err = ufs_qcom_clk_scale_down_post_change(hba, target_freq);
> >
> > + if (!err)
> > + err = ufs_qcom_ice_scale_clk(host, target_freq, !scale_up);
> >
> > - if (err) {
> > + if (err && err != -EOPNOTSUPP) {
>
> Using -EOPNOTSUPP here works fine for now. But anyone touching any of the lower APIs called by
> ufs_qcom_clk_scale_up/down_post_change() needs to ensure they don't return -EOPNOTSUPP, otherwise
> hibernate exit will be skipped. So this carries a minor risk of breaking.
>
> Since regardless of whether ufs_qcom_clk_scale_up/down_post_change() fails or ufs_qcom_ice_scale_clk()
> fails, we exit from hibernate and return from this function, I suggest you handle the error for ice_scale
> separately.
>
> > ufshcd_uic_hibern8_exit(hba);
> > return err;
> > }
> >
>
> Add the call to ufs_qcom_ice_scale_clk() along with error handle here, and let the above error handle
> remain untouched.
>
> err = ufs_qcom_ice_scale_clk(host, target_freq, !scale_up);
> if (err && err != -EOPNOTSUPP) {
> ufshcd_uic_hibern8_exit(hba);
> return err;
> }
>

Right, I did think of this later.
Yes, this needs change.
Ack will update in the v8 patchset.
Thanks.

Abhinaba Rakshit