iommu/qcom: Disable clocks if restoring the secure config fails
Subsystems (4)
PATCH 1/1 iommu/qcom: Disable clocks if restoring the secure config fails
From: Suyuan Wang <[email protected]>
qcom_iommu_resume() enables the clocks and then, for an IOMMU with a power domain, calls qcom_scm_restore_sec_cfg(). If that call fails, the error is returned but the clocks stay enabled. The PM core then treats the device as still suspended, so qcom_iommu_suspend() will not run to turn them off.
Disable the clocks again when qcom_scm_restore_sec_cfg() fails.
Found with a static analysis tool and checked by hand.
---
Compile tested on arm64 (W=1). I don't have the hardware.
--- drivers/iommu/arm/arm-smmu/qcom_iommu.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/iommu/arm/arm-smmu/qcom_iommu.c +5 -2
@@ -898,8 +898,11 @@ static int __maybe_unused qcom_iommu_resume(struct device *dev)if (ret <0 )return ret; -if (dev->pm_domain) -return qcom_scm_restore_sec_cfg (qcom_iommu->sec_id,0 ); +if (dev->pm_domain) { + ret =qcom_scm_restore_sec_cfg (qcom_iommu->sec_id,0 ); +if (ret) +clk_bulk_disable_unprepare (CLK_NUM , qcom_iommu->clks); + }return ret; }
Quoted 12 lines · On 11/22/26 11:11 AM, Suyuan Wang via B4 Relay wrote:
From: Suyuan Wang <[email protected]>
qcom_iommu_resume()enables the clocks and then, for an IOMMU with a power domain, callsqcom_scm_restore_sec_cfg(). If that call fails, the error is returned but the clocks stay enabled. The PM core then treats the device as still suspended, soqcom_iommu_suspend()will not run to turn them off.Disable the clocks again when
qcom_scm_restore_sec_cfg()fails.Found with a static analysis tool and checked by hand.
Quoted 8 lines
Fixes 268dd4edb748 ("iommu/qcom: restore IOMMU state if needed")Co-developed-by Kaixuan Li <[email protected]>Signed-off-by Kaixuan Li <[email protected]>Signed-off-by Suyuan Wang <[email protected]>---
Compile tested on arm64 (W=1). I don't have the hardware.
---
Konrad