diff options
author | Russell King <rmk+kernel@arm.linux.org.uk> | 2015-07-27 12:29:10 (GMT) |
---|---|---|
committer | Thierry Reding <treding@nvidia.com> | 2015-08-13 14:06:38 (GMT) |
commit | 8482ee5ea1097445f6498ee522965f5311667763 (patch) | |
tree | 260f1f5252fd57215466274dd8c0e0794544ab5e /drivers/iommu | |
parent | b98e34f0c6f1c4ac7af41afecc4a26f5f2ebe68d (diff) | |
download | linux-8482ee5ea1097445f6498ee522965f5311667763.tar.xz |
iommu/tegra-smmu: Factor out common PTE setting
Factor out the common PTE setting code into a separate function.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Thierry Reding <treding@nvidia.com>
Diffstat (limited to 'drivers/iommu')
-rw-r--r-- | drivers/iommu/tegra-smmu.c | 37 |
1 files changed, 17 insertions, 20 deletions
diff --git a/drivers/iommu/tegra-smmu.c b/drivers/iommu/tegra-smmu.c index a7a7645..53d0f15 100644 --- a/drivers/iommu/tegra-smmu.c +++ b/drivers/iommu/tegra-smmu.c @@ -541,12 +541,24 @@ static void tegra_smmu_pte_put_use(struct tegra_smmu_as *as, unsigned long iova) } } +static void tegra_smmu_set_pte(struct tegra_smmu_as *as, unsigned long iova, + u32 *pte, struct page *pte_page, u32 val) +{ + struct tegra_smmu *smmu = as->smmu; + unsigned long offset = offset_in_page(pte); + + *pte = val; + + smmu->soc->ops->flush_dcache(pte_page, offset, 4); + smmu_flush_ptc(smmu, pte_page, offset); + smmu_flush_tlb_group(smmu, as->id, iova); + smmu_flush(smmu); +} + static int tegra_smmu_map(struct iommu_domain *domain, unsigned long iova, phys_addr_t paddr, size_t size, int prot) { struct tegra_smmu_as *as = to_smmu_as(domain); - struct tegra_smmu *smmu = as->smmu; - unsigned long offset; struct page *page; u32 *pte; @@ -554,13 +566,8 @@ static int tegra_smmu_map(struct iommu_domain *domain, unsigned long iova, if (!pte) return -ENOMEM; - *pte = __phys_to_pfn(paddr) | SMMU_PTE_ATTR; - offset = offset_in_page(pte); - - smmu->soc->ops->flush_dcache(page, offset, 4); - smmu_flush_ptc(smmu, page, offset); - smmu_flush_tlb_group(smmu, as->id, iova); - smmu_flush(smmu); + tegra_smmu_set_pte(as, iova, pte, page, + __phys_to_pfn(paddr) | SMMU_PTE_ATTR); return 0; } @@ -569,8 +576,6 @@ static size_t tegra_smmu_unmap(struct iommu_domain *domain, unsigned long iova, size_t size) { struct tegra_smmu_as *as = to_smmu_as(domain); - struct tegra_smmu *smmu = as->smmu; - unsigned long offset; struct page *page; u32 *pte; @@ -578,15 +583,7 @@ static size_t tegra_smmu_unmap(struct iommu_domain *domain, unsigned long iova, if (!pte || !*pte) return 0; - *pte = 0; - - offset = offset_in_page(pte); - - smmu->soc->ops->flush_dcache(page, offset, 4); - smmu_flush_ptc(smmu, page, offset); - smmu_flush_tlb_group(smmu, as->id, iova); - smmu_flush(smmu); - + tegra_smmu_set_pte(as, iova, pte, page, 0); tegra_smmu_pte_put_use(as, iova); return size; |