System MMUs in some implementation of Exynos core does not include correct version information in the System MMU. If the version information is not correct, exynos-iommu driver cannot take advantages of feature of higher versions of System MMu like prefetching page table entries prior to TLB miss.
This commit allows passing version information from DT to the driver. If DT does not pass version information, the driver will read the information from System MMU. Signed-off-by: KyongHo Cho <pullip....@samsung.com> --- drivers/iommu/exynos-iommu.c | 40 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/drivers/iommu/exynos-iommu.c b/drivers/iommu/exynos-iommu.c index 8cffeff..b939b6e 100644 --- a/drivers/iommu/exynos-iommu.c +++ b/drivers/iommu/exynos-iommu.c @@ -96,6 +96,9 @@ #define REG_MMU_VERSION 0x034 +#define MMU_MAJ_VER(reg) (reg >> 28) +#define MMU_MIN_VER(reg) ((reg >> 21) & 0x7F) + #define REG_PB0_SADDR 0x04C #define REG_PB0_EADDR 0x050 #define REG_PB1_SADDR 0x054 @@ -165,6 +168,12 @@ struct exynos_iommu_domain { spinlock_t pgtablelock; /* lock for modifying page table @ pgtable */ }; +struct sysmmu_version { + unsigned char major; /* major = 0 means that driver must use MMU_VERSION + register instead of this structure */ + unsigned char minor; +}; + struct sysmmu_drvdata { struct list_head node; /* entry of exynos_iommu_domain.clients */ struct device *sysmmu; /* System MMU's device descriptor */ @@ -172,6 +181,7 @@ struct sysmmu_drvdata { int nsfrs; struct clk *clk; int activations; + struct sysmmu_version ver; rwlock_t lock; struct iommu_domain *domain; sysmmu_fault_handler_t fault_handler; @@ -198,6 +208,25 @@ static bool is_sysmmu_active(struct sysmmu_drvdata *data) return data->activations > 0; } +static unsigned int __sysmmu_version(struct sysmmu_drvdata *drvdata, + int idx, unsigned int *minor) +{ + unsigned int major; + + if (drvdata->ver.major == 0) { + major = readl( + drvdata->sfrbases[idx] + REG_MMU_VERSION); + if (minor) + *minor = MMU_MIN_VER(major); + major = MMU_MAJ_VER(major); + } else { + major = drvdata->ver.major; + if (minor) + *minor = drvdata->ver.minor; + } + return major; +} + static void sysmmu_unblock(void __iomem *sfrbase) { __raw_writel(CTRL_ENABLE, sfrbase + REG_MMU_CTRL); @@ -262,7 +291,7 @@ void exynos_sysmmu_set_prefbuf(struct device *dev, goto finish; for (i = 0; i < data->nsfrs; i++) { - if ((readl(data->sfrbases[i] + REG_MMU_VERSION) >> 28) == 3) { + if (__sysmmu_version(data, i, NULL) == 3) { if (!sysmmu_block(data->sfrbases[i])) continue; @@ -460,7 +489,7 @@ static int __exynos_sysmmu_enable(struct sysmmu_drvdata *data, for (i = 0; i < data->nsfrs; i++) { __sysmmu_set_ptbase(data->sfrbases[i], pgtable); - if ((readl(data->sfrbases[i] + REG_MMU_VERSION) >> 28) == 3) { + if (__sysmmu_version(data, i, NULL) == 3) { /* System MMU version is 3.x */ __raw_writel((1 << 12) | (2 << 28), data->sfrbases[i] + REG_MMU_CFG); @@ -618,8 +647,15 @@ static int __init __sysmmu_setup(struct device *sysmmu, const char *compat; struct platform_device *pmaster = NULL; u32 master_inst_no = -1; + u32 ver[2]; int ret; + if (!of_property_read_u32_array(sysmmu->of_node, "version", ver, 2)) { + drvdata->ver.major = (unsigned char)ver[0]; + drvdata->ver.minor = (unsigned char)ver[1]; + dev_dbg(sysmmu, "Found version %d.%d\n", ver[0], ver[1]); + } + master_node = of_parse_phandle(sysmmu->of_node, "mmu-master", 0); if (!master_node && !of_property_read_string( sysmmu->of_node, "mmu-master-compat", &compat)) { -- 1.8.0 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/