Re: [PATCH v4 5/7] scsi: ufs: ufs-qcom: Switch to the new ICE API

Eric Biggers
2023-03-27T18:19:42Z

Hi Abel,

On Mon, Mar 27, 2023 at 04:47:32PM +0300, Abel Vesa wrote:
> Now that there is a new dedicated ICE driver, drop the ufs-qcom-ice and
> use the new ICE api provided by the Qualcomm soc driver ice. The platforms
> that already have ICE support will use the API as library since there will
> not be a devicetree node, but instead they have reg range. In this case,
> the of_qcom_ice_get will return an ICE instance created for the consumer's
> device. But if there are platforms that do not have ice reg in the
> consumer devicetree node and instead provide a dedicated ICE devicetree
> node, the of_qcom_ice_get will look up the device based on qcom,ice
> property and will get the ICE instance registered by the probe function
> of the ice driver.
>
> Signed-off-by: Abel Vesa <abel.vesa@linaro.org>

I am still worried about the ICE clock. Are you sure it is being managed
correctly? With your patch, the ICE clock gets enabled in ufs_qcom_ice_resume
and disabled in ufs_qcom_ice_suspend, which hopefully pair up. But it also gets
enabled in ufs_qcom_ice_enable which isn't paired with anything. Also, this all
happens at a different time from the existing UFS clocks being enabled/disabled.

I wonder if the ICE clock should be enabled/disabled in ufs_qcom_setup_clocks()
instead of what you are doing currently?

> +static int ufs_qcom_ice_init(struct ufs_qcom_host *host)
> +{
> + struct ufs_hba *hba = host->hba;
> + struct device *dev = hba->dev;
> +
> + host->ice = of_qcom_ice_get(dev);
> + if (host->ice == ERR_PTR(-EOPNOTSUPP)) {
> + dev_warn(dev, "Disabling inline encryption support\n");
> + hba->caps &= ~UFSHCD_CAP_CRYPTO;
> + host->ice = NULL;
> + }
> +
> + if (IS_ERR(host->ice))
> + return PTR_ERR(host->ice);
> +
> + return 0;
> +}

This is still sometimes leaving UFSHCD_CAP_CRYPTO set in cases where ICE is
unsupported.

Moving the *setting* of UFSHCD_CAP_CRYPTO into here would fix that.

It is also hard to understand how the -EOPNOTSUPP case differs from the NULL
case. Can you add a comment? Or just consider keeping the original behavior,
which did not distinguish between these cases (as long as MASK_CRYPTO_SUPPORT
was set in REG_CONTROLLER_CAPABILITIES, which was checked first).

- Eric