iommu/arm-smmu: Add explicit restore_sec_cfg call at SMMU probe

restore_sec_cfg call needs to be made to inform
secure world that device have resumed from power
collapse mode and security settings need to be
relaxed. Accordingly we had a restore_sec_cfg
call in arm_smmu_resume which would be called
from regulator_notifier on regulator enable
event.

But during initial device probe also we need to
read through SMMU global registers like IDR0,
IDR1 to understand hardware configuration of SMMU
and accordingly populate our data structures. We
can't call arm_smmu_resume at this point as we
are still to identify page size of SMMU register
map which we get only through reading IDR1
register.

So make an explicit restore_sec_cfg call at SMMU
probe which would enable us to read through
SMMU global registers. We need this call only
for targets which have slave side protection
mechanism.

CRs-Fixed: 959535
Change-Id: If4e53966edbf4e76a3d03f3a8684563f0ceac13d
Signed-off-by: Susheel Khiani <skhiani@codeaurora.org>
This commit is contained in:
Susheel Khiani 2016-02-04 19:07:38 +05:30 committed by David Keitel
parent a6fba6085d
commit 8b39a23e0c

View file

@ -1517,6 +1517,22 @@ static void arm_smmu_pgtbl_unlock(struct arm_smmu_domain *smmu_domain,
spin_unlock_irqrestore(&smmu_domain->pgtbl_spin_lock, flags);
}
static int arm_smmu_restore_sec_cfg(struct arm_smmu_device *smmu)
{
int ret, scm_ret;
if (!arm_smmu_is_static_cb(smmu))
return 0;
ret = scm_restore_sec_cfg(smmu->sec_id, 0x0, &scm_ret);
if (ret || scm_ret) {
pr_err("scm call IOMMU_SECURE_CFG failed\n");
return -EINVAL;
}
return 0;
}
static int arm_smmu_init_domain_context(struct iommu_domain *domain,
struct arm_smmu_device *smmu)
{
@ -2525,15 +2541,8 @@ static void arm_smmu_resume(struct arm_smmu_device *smmu)
void __iomem *impl_def1_base = ARM_SMMU_IMPL_DEF1(smmu);
u32 reg;
if (arm_smmu_is_static_cb(smmu)) {
int ret, scm_ret;
ret = scm_restore_sec_cfg(smmu->sec_id, 0x0, &scm_ret);
if (ret || scm_ret) {
pr_err("scm call IOMMU_SECURE_CFG failed\n");
return;
}
}
if (arm_smmu_restore_sec_cfg(smmu))
return;
reg = readl_relaxed(impl_def1_base + IMPL_DEF1_MICRO_MMU_CTRL);
reg &= ~MICRO_MMU_CTRL_LOCAL_HALT_REQ;
@ -3322,6 +3331,9 @@ static int arm_smmu_device_cfg_probe(struct arm_smmu_device *smmu)
u32 id;
bool cttw_dt, cttw_reg;
if (arm_smmu_restore_sec_cfg(smmu))
return -ENODEV;
dev_dbg(smmu->dev, "probing hardware configuration...\n");
dev_dbg(smmu->dev, "SMMUv%d with:\n", smmu->version);