From 163029735bc35a1a00b1f27b8549fc330e1c1cd7 Mon Sep 17 00:00:00 2001 From: Vldly <92926213+vldly@users.noreply.github.com> Date: Thu, 5 May 2022 16:38:43 +0000 Subject: [PATCH 10/65] iommu/qcom: restore IOMMU state if needed If IOMMU has power domain the some state will be lost and TZ will reset device as it likes if we don't call qcom_scm_restore_sec_cfg before accessing device. FIXME! CB is hardcoded to 0 like on downstream which might be wrong. Signed-off-by: Vladimir Lypak Signed-off-by: Bert Karwatzki --- 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 9b15ab981716..adcfd5728825 100644 --- a/drivers/iommu/arm/arm-smmu/qcom_iommu.c +++ b/drivers/iommu/arm/arm-smmu/qcom_iommu.c @@ -1069,8 +1069,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) -- 2.39.2