diff options
author | Russell King <rmk+kernel@arm.linux.org.uk> | 2015-08-06 08:56:39 -0400 |
---|---|---|
committer | Thierry Reding <treding@nvidia.com> | 2015-08-13 10:06:43 -0400 |
commit | 7ffc6f066eb73b07a0ef7c94d05107aef271ac21 (patch) | |
tree | 976b618114e7527e91d1c234bcd710ca6afec72e /drivers/iommu/tegra-smmu.c | |
parent | 707917cbc6ac0c0ea968b5eb635722ea84808286 (diff) |
iommu/tegra-smmu: Extract tegra_smmu_pte_get_use()
Extract the use count reference accounting into a separate function and
separate it from allocating the PTE.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
[treding@nvidia.com: extract and write commit message]
Signed-off-by: Thierry Reding <treding@nvidia.com>
Diffstat (limited to 'drivers/iommu/tegra-smmu.c')
-rw-r--r-- | drivers/iommu/tegra-smmu.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/drivers/iommu/tegra-smmu.c b/drivers/iommu/tegra-smmu.c index 27d31f62a822..74ad1f43265a 100644 --- a/drivers/iommu/tegra-smmu.c +++ b/drivers/iommu/tegra-smmu.c | |||
@@ -522,7 +522,7 @@ static u32 *tegra_smmu_pte_lookup(struct tegra_smmu_as *as, unsigned long iova, | |||
522 | static u32 *as_get_pte(struct tegra_smmu_as *as, dma_addr_t iova, | 522 | static u32 *as_get_pte(struct tegra_smmu_as *as, dma_addr_t iova, |
523 | dma_addr_t *dmap) | 523 | dma_addr_t *dmap) |
524 | { | 524 | { |
525 | u32 *pd = page_address(as->pd), *pt; | 525 | u32 *pd = page_address(as->pd); |
526 | unsigned int pde = iova_pd_index(iova); | 526 | unsigned int pde = iova_pd_index(iova); |
527 | struct tegra_smmu *smmu = as->smmu; | 527 | struct tegra_smmu *smmu = as->smmu; |
528 | 528 | ||
@@ -563,13 +563,14 @@ static u32 *as_get_pte(struct tegra_smmu_as *as, dma_addr_t iova, | |||
563 | *dmap = smmu_pde_to_dma(pd[pde]); | 563 | *dmap = smmu_pde_to_dma(pd[pde]); |
564 | } | 564 | } |
565 | 565 | ||
566 | pt = tegra_smmu_pte_offset(as->pts[pde], iova); | 566 | return tegra_smmu_pte_offset(as->pts[pde], iova); |
567 | } | ||
567 | 568 | ||
568 | /* Keep track of entries in this page table. */ | 569 | static void tegra_smmu_pte_get_use(struct tegra_smmu_as *as, unsigned long iova) |
569 | if (*pt == 0) | 570 | { |
570 | as->count[pde]++; | 571 | unsigned int pd_index = iova_pd_index(iova); |
571 | 572 | ||
572 | return pt; | 573 | as->count[pd_index]++; |
573 | } | 574 | } |
574 | 575 | ||
575 | static void tegra_smmu_pte_put_use(struct tegra_smmu_as *as, unsigned long iova) | 576 | static void tegra_smmu_pte_put_use(struct tegra_smmu_as *as, unsigned long iova) |
@@ -630,6 +631,10 @@ static int tegra_smmu_map(struct iommu_domain *domain, unsigned long iova, | |||
630 | if (!pte) | 631 | if (!pte) |
631 | return -ENOMEM; | 632 | return -ENOMEM; |
632 | 633 | ||
634 | /* If we aren't overwriting a pre-existing entry, increment use */ | ||
635 | if (*pte == 0) | ||
636 | tegra_smmu_pte_get_use(as, iova); | ||
637 | |||
633 | tegra_smmu_set_pte(as, iova, pte, pte_dma, | 638 | tegra_smmu_set_pte(as, iova, pte, pte_dma, |
634 | __phys_to_pfn(paddr) | SMMU_PTE_ATTR); | 639 | __phys_to_pfn(paddr) | SMMU_PTE_ATTR); |
635 | 640 | ||