Skip to content

Commit 8e8b4ac

Browse files
soleenjoergroedel
authored andcommitted
iommu/tegra-smmu: use page allocation function provided by iommu-pages.h
Convert iommu/tegra-smmu.c to use the new page allocation functions provided in iommu-pages.h. Signed-off-by: Pasha Tatashin <pasha.tatashin@soleen.com> Acked-by: David Rientjes <rientjes@google.com> Acked-by: Thierry Reding <treding@nvidia.com> Tested-by: Bagas Sanjaya <bagasdotme@gmail.com> Link: https://lore.kernel.org/r/20240413002522.1101315-10-pasha.tatashin@soleen.com Signed-off-by: Joerg Roedel <jroedel@suse.de>
1 parent cb06b25 commit 8e8b4ac

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

drivers/iommu/tegra-smmu.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
#include <soc/tegra/ahb.h>
2020
#include <soc/tegra/mc.h>
2121

22+
#include "iommu-pages.h"
23+
2224
struct tegra_smmu_group {
2325
struct list_head list;
2426
struct tegra_smmu *smmu;
@@ -282,23 +284,23 @@ static struct iommu_domain *tegra_smmu_domain_alloc_paging(struct device *dev)
282284

283285
as->attr = SMMU_PD_READABLE | SMMU_PD_WRITABLE | SMMU_PD_NONSECURE;
284286

285-
as->pd = alloc_page(GFP_KERNEL | __GFP_DMA | __GFP_ZERO);
287+
as->pd = __iommu_alloc_pages(GFP_KERNEL | __GFP_DMA, 0);
286288
if (!as->pd) {
287289
kfree(as);
288290
return NULL;
289291
}
290292

291293
as->count = kcalloc(SMMU_NUM_PDE, sizeof(u32), GFP_KERNEL);
292294
if (!as->count) {
293-
__free_page(as->pd);
295+
__iommu_free_pages(as->pd, 0);
294296
kfree(as);
295297
return NULL;
296298
}
297299

298300
as->pts = kcalloc(SMMU_NUM_PDE, sizeof(*as->pts), GFP_KERNEL);
299301
if (!as->pts) {
300302
kfree(as->count);
301-
__free_page(as->pd);
303+
__iommu_free_pages(as->pd, 0);
302304
kfree(as);
303305
return NULL;
304306
}
@@ -599,14 +601,14 @@ static u32 *as_get_pte(struct tegra_smmu_as *as, dma_addr_t iova,
599601
dma = dma_map_page(smmu->dev, page, 0, SMMU_SIZE_PT,
600602
DMA_TO_DEVICE);
601603
if (dma_mapping_error(smmu->dev, dma)) {
602-
__free_page(page);
604+
__iommu_free_pages(page, 0);
603605
return NULL;
604606
}
605607

606608
if (!smmu_dma_addr_valid(smmu, dma)) {
607609
dma_unmap_page(smmu->dev, dma, SMMU_SIZE_PT,
608610
DMA_TO_DEVICE);
609-
__free_page(page);
611+
__iommu_free_pages(page, 0);
610612
return NULL;
611613
}
612614

@@ -649,7 +651,7 @@ static void tegra_smmu_pte_put_use(struct tegra_smmu_as *as, unsigned long iova)
649651
tegra_smmu_set_pde(as, iova, 0);
650652

651653
dma_unmap_page(smmu->dev, pte_dma, SMMU_SIZE_PT, DMA_TO_DEVICE);
652-
__free_page(page);
654+
__iommu_free_pages(page, 0);
653655
as->pts[pde] = NULL;
654656
}
655657
}
@@ -688,7 +690,7 @@ static struct page *as_get_pde_page(struct tegra_smmu_as *as,
688690
if (gfpflags_allow_blocking(gfp))
689691
spin_unlock_irqrestore(&as->lock, *flags);
690692

691-
page = alloc_page(gfp | __GFP_DMA | __GFP_ZERO);
693+
page = __iommu_alloc_pages(gfp | __GFP_DMA, 0);
692694

693695
if (gfpflags_allow_blocking(gfp))
694696
spin_lock_irqsave(&as->lock, *flags);
@@ -700,7 +702,7 @@ static struct page *as_get_pde_page(struct tegra_smmu_as *as,
700702
*/
701703
if (as->pts[pde]) {
702704
if (page)
703-
__free_page(page);
705+
__iommu_free_pages(page, 0);
704706

705707
page = as->pts[pde];
706708
}

0 commit comments

Comments
 (0)