Skip to content

Commit 2802456

Browse files
jgunthorpejoergroedel
authored andcommitted
iommu/pages: Remove iommu_alloc_page/pages()
A few small changes to the remaining drivers using these will allow them to be removed: - Exynos wants to allocate fixed 16K/8K allocations - Rockchip already has a define SPAGE_SIZE which is used by the dma_map immediately following, using SPAGE_ORDER which is a lg2size - tegra has size constants already for its two allocations Acked-by: Marek Szyprowski <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Joerg Roedel <[email protected]>
1 parent d50aaa4 commit 2802456

File tree

4 files changed

+8
-32
lines changed

4 files changed

+8
-32
lines changed

drivers/iommu/exynos-iommu.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -902,11 +902,11 @@ static struct iommu_domain *exynos_iommu_domain_alloc_paging(struct device *dev)
902902
if (!domain)
903903
return NULL;
904904

905-
domain->pgtable = iommu_alloc_pages(GFP_KERNEL, 2);
905+
domain->pgtable = iommu_alloc_pages_sz(GFP_KERNEL, SZ_16K);
906906
if (!domain->pgtable)
907907
goto err_pgtable;
908908

909-
domain->lv2entcnt = iommu_alloc_pages(GFP_KERNEL, 1);
909+
domain->lv2entcnt = iommu_alloc_pages_sz(GFP_KERNEL, SZ_8K);
910910
if (!domain->lv2entcnt)
911911
goto err_counter;
912912

drivers/iommu/iommu-pages.h

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -100,20 +100,6 @@ static inline void *iommu_alloc_pages_node(int nid, gfp_t gfp,
100100
return iommu_alloc_pages_node_sz(nid, gfp, 1 << (order + PAGE_SHIFT));
101101
}
102102

103-
/**
104-
* iommu_alloc_pages - allocate a zeroed page of a given order
105-
* @gfp: buddy allocator flags
106-
* @order: page order
107-
*
108-
* returns the virtual address of the allocated page
109-
* Prefer to use iommu_alloc_pages_lg2()
110-
*/
111-
static inline void *iommu_alloc_pages(gfp_t gfp, int order)
112-
{
113-
return iommu_alloc_pages_node_sz(NUMA_NO_NODE, gfp,
114-
1 << (order + PAGE_SHIFT));
115-
}
116-
117103
/**
118104
* iommu_alloc_pages_sz - Allocate a zeroed page of a given size from
119105
* specific NUMA node
@@ -141,16 +127,4 @@ static inline void *iommu_alloc_page_node(int nid, gfp_t gfp)
141127
return iommu_alloc_pages_node_sz(nid, gfp, PAGE_SIZE);
142128
}
143129

144-
/**
145-
* iommu_alloc_page - allocate a zeroed page
146-
* @gfp: buddy allocator flags
147-
*
148-
* returns the virtual address of the allocated page
149-
* Prefer to use iommu_alloc_pages_lg2()
150-
*/
151-
static inline void *iommu_alloc_page(gfp_t gfp)
152-
{
153-
return iommu_alloc_pages_node_sz(NUMA_NO_NODE, gfp, PAGE_SIZE);
154-
}
155-
156130
#endif /* __IOMMU_PAGES_H */

drivers/iommu/rockchip-iommu.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,8 @@ static u32 *rk_dte_get_page_table(struct rk_iommu_domain *rk_domain,
730730
if (rk_dte_is_pt_valid(dte))
731731
goto done;
732732

733-
page_table = iommu_alloc_page(GFP_ATOMIC | rk_ops->gfp_flags);
733+
page_table = iommu_alloc_pages_sz(GFP_ATOMIC | rk_ops->gfp_flags,
734+
SPAGE_SIZE);
734735
if (!page_table)
735736
return ERR_PTR(-ENOMEM);
736737

@@ -1062,7 +1063,8 @@ static struct iommu_domain *rk_iommu_domain_alloc_paging(struct device *dev)
10621063
* Each level1 (dt) and level2 (pt) table has 1024 4-byte entries.
10631064
* Allocate one 4 KiB page for each table.
10641065
*/
1065-
rk_domain->dt = iommu_alloc_page(GFP_KERNEL | rk_ops->gfp_flags);
1066+
rk_domain->dt = iommu_alloc_pages_sz(GFP_KERNEL | rk_ops->gfp_flags,
1067+
SPAGE_SIZE);
10661068
if (!rk_domain->dt)
10671069
goto err_free_domain;
10681070

drivers/iommu/tegra-smmu.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ static struct iommu_domain *tegra_smmu_domain_alloc_paging(struct device *dev)
295295

296296
as->attr = SMMU_PD_READABLE | SMMU_PD_WRITABLE | SMMU_PD_NONSECURE;
297297

298-
as->pd = iommu_alloc_page(GFP_KERNEL | __GFP_DMA);
298+
as->pd = iommu_alloc_pages_sz(GFP_KERNEL | __GFP_DMA, SMMU_SIZE_PD);
299299
if (!as->pd) {
300300
kfree(as);
301301
return NULL;
@@ -695,7 +695,7 @@ static struct tegra_pt *as_get_pde_page(struct tegra_smmu_as *as,
695695
if (gfpflags_allow_blocking(gfp))
696696
spin_unlock_irqrestore(&as->lock, *flags);
697697

698-
pt = iommu_alloc_page(gfp | __GFP_DMA);
698+
pt = iommu_alloc_pages_sz(gfp | __GFP_DMA, SMMU_SIZE_PT);
699699

700700
if (gfpflags_allow_blocking(gfp))
701701
spin_lock_irqsave(&as->lock, *flags);

0 commit comments

Comments
 (0)