aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/iommu/arm-smmu.c
diff options
context:
space:
mode:
authorAndreas Herrmann <andreas.herrmann@calxeda.com>2013-10-01 08:39:06 -0400
committerWill Deacon <will.deacon@arm.com>2013-10-09 09:14:39 -0400
commitc55af7f719cbb0f0b28f42b3f98f662278f063c2 (patch)
tree9fb2e46fa757a6b44d9aef5fe373b98909dcabc8 /drivers/iommu/arm-smmu.c
parentb1950b2796da80b66df02db39cc3417266b73767 (diff)
iommu/arm-smmu: Refine check for proper size of mapped region
There is already a check to print a warning if the size of SMMU address space (calculated from SMMU register values) is greater than the size of the mapped memory region (e.g. passed via DT to the driver). Adapt this check to print also a warning in case the mapped region is larger than the SMMU address space. Such a mismatch could be intentional (to fix wrong register values). If its not intentional (e.g. due to wrong DT information) this will very likely cause a malfunction of the driver as SMMU_CB_BASE is derived from the size of the mapped region. The warning helps to identify the root cause in this case. Signed-off-by: Andreas Herrmann <andreas.herrmann@calxeda.com> Signed-off-by: Will Deacon <will.deacon@arm.com>
Diffstat (limited to 'drivers/iommu/arm-smmu.c')
-rw-r--r--drivers/iommu/arm-smmu.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c
index 878a5b926fe5..1f79daa5f4b1 100644
--- a/drivers/iommu/arm-smmu.c
+++ b/drivers/iommu/arm-smmu.c
@@ -1700,13 +1700,12 @@ static int arm_smmu_device_cfg_probe(struct arm_smmu_device *smmu)
1700 id = readl_relaxed(gr0_base + ARM_SMMU_GR0_ID1); 1700 id = readl_relaxed(gr0_base + ARM_SMMU_GR0_ID1);
1701 smmu->pagesize = (id & ID1_PAGESIZE) ? SZ_64K : SZ_4K; 1701 smmu->pagesize = (id & ID1_PAGESIZE) ? SZ_64K : SZ_4K;
1702 1702
1703 /* Check that we ioremapped enough */ 1703 /* Check for size mismatch of SMMU address space from mapped region */
1704 size = 1 << (((id >> ID1_NUMPAGENDXB_SHIFT) & ID1_NUMPAGENDXB_MASK) + 1); 1704 size = 1 << (((id >> ID1_NUMPAGENDXB_SHIFT) & ID1_NUMPAGENDXB_MASK) + 1);
1705 size *= (smmu->pagesize << 1); 1705 size *= (smmu->pagesize << 1);
1706 if (smmu->size < size) 1706 if (smmu->size != size)
1707 dev_warn(smmu->dev, 1707 dev_warn(smmu->dev, "SMMU address space size (0x%lx) differs "
1708 "device is 0x%lx bytes but only mapped 0x%lx!\n", 1708 "from mapped region size (0x%lx)!\n", size, smmu->size);
1709 size, smmu->size);
1710 1709
1711 smmu->num_s2_context_banks = (id >> ID1_NUMS2CB_SHIFT) & 1710 smmu->num_s2_context_banks = (id >> ID1_NUMS2CB_SHIFT) &
1712 ID1_NUMS2CB_MASK; 1711 ID1_NUMS2CB_MASK;