Re: [PATCH] iommu/qcom: restore IOMMU state if needed

From: Luca Weiss
Date: Sat Nov 25 2023 - 07:07:36 EST


On Mittwoch, 11. Oktober 2023 19:57:26 CET Luca Weiss wrote:
> From: Vladimir Lypak <vladimir.lypak@xxxxxxxxx>
>
> If the IOMMU has a power domain then some state will be lost in
> qcom_iommu_suspend and TZ will reset device if we don't call
> qcom_scm_restore_sec_cfg before accessing it again.
>
> Signed-off-by: Vladimir Lypak <vladimir.lypak@xxxxxxxxx>
> [luca@xxxxxxxxx: reword commit message a bit]
> Signed-off-by: Luca Weiss <luca@xxxxxxxxx>
> ---
> This patch is required for MSM8953 GPU IOMMU.
>
> See also downstream sources:
> https://git.codelinaro.org/clo/la/kernel/msm-4.9/-/commit/f8464885dafc5b780b
> 85de29d92a08c692d3a4d0
> https://git.codelinaro.org/clo/la/kernel/msm-4.9/-/blob/LA.UM.10.6.2.r1-025
> 00-89xx.0/drivers/iommu/arm-smmu.c#L4221-4225
>
> Since the compatibles provided by this driver (qcom,msm-iommu-v*) is
> only used on msm8916, msm8939 and msm8953, and both 8916 and 8939 don't
> have a power domain on the IOMMU, I also don't expect anything to break
> there.

Hi all,

Any feedback on this patch?

Regards
Luca

> ---
> drivers/iommu/arm/arm-smmu/qcom_iommu.c | 10 +++++++++-
> 1 file changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/iommu/arm/arm-smmu/qcom_iommu.c
> b/drivers/iommu/arm/arm-smmu/qcom_iommu.c index 97b2122032b2..67abeb02cf53
> 100644
> --- a/drivers/iommu/arm/arm-smmu/qcom_iommu.c
> +++ b/drivers/iommu/arm/arm-smmu/qcom_iommu.c
> @@ -900,8 +900,16 @@ static void qcom_iommu_device_remove(struct
> platform_device *pdev) static int __maybe_unused qcom_iommu_resume(struct
> device *dev)
> {
> struct qcom_iommu_dev *qcom_iommu = dev_get_drvdata(dev);
> + int ret;
> +
> + ret = clk_bulk_prepare_enable(CLK_NUM, qcom_iommu->clks);
> + if (ret < 0)
> + return ret;
> +
> + if (dev->pm_domain)
> + return qcom_scm_restore_sec_cfg(qcom_iommu->sec_id, 0);
>
> - return clk_bulk_prepare_enable(CLK_NUM, qcom_iommu->clks);
> + return ret;
> }
>
> static int __maybe_unused qcom_iommu_suspend(struct device *dev)
>
> ---
> base-commit: 2933a1156742d8c47550493a77af8e2d81cf3c84
> change-id: 20231011-msm8953-iommu-restore-fabc2e31fee7
>
> Best regards,