From: Vladimir Lypak <[email protected]>
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 <[email protected]>
[[email protected]: reword commit message a bit]
Signed-off-by: Luca Weiss <[email protected]>
---
This patch is required for MSM8953 GPU IOMMU.
See also downstream sources:
https://git.codelinaro.org/clo/la/kernel/msm-4.9/-/commit/f8464885dafc5b780b85de29d92a08c692d3a4d0
https://git.codelinaro.org/clo/la/kernel/msm-4.9/-/blob/LA.UM.10.6.2.r1-02500-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.
---
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,
--
Luca Weiss <[email protected]>
On Mittwoch, 11. Oktober 2023 19:57:26 CET Luca Weiss wrote:
> From: Vladimir Lypak <[email protected]>
>
> 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 <[email protected]>
> [[email protected]: reword commit message a bit]
> Signed-off-by: Luca Weiss <[email protected]>
> ---
> 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,
On Wed, 11 Oct 2023 19:57:26 +0200, Luca Weiss wrote:
> From: Vladimir Lypak <[email protected]>
>
> 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.
>
>
> [...]
Applied to will (for-joerg/arm-smmu/updates), thanks!
[1/1] iommu/qcom: restore IOMMU state if needed
https://git.kernel.org/will/c/268dd4edb748
Cheers,
--
Will
https://fixes.arm64.dev
https://next.arm64.dev
https://will.arm64.dev