mirror of
https://github.com/torvalds/linux
synced 2024-10-14 15:29:13 +00:00
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>
This commit is contained in:
parent
cb06b259e1
commit
8e8b4ac5b0
|
@ -19,6 +19,8 @@
|
||||||
#include <soc/tegra/ahb.h>
|
#include <soc/tegra/ahb.h>
|
||||||
#include <soc/tegra/mc.h>
|
#include <soc/tegra/mc.h>
|
||||||
|
|
||||||
|
#include "iommu-pages.h"
|
||||||
|
|
||||||
struct tegra_smmu_group {
|
struct tegra_smmu_group {
|
||||||
struct list_head list;
|
struct list_head list;
|
||||||
struct tegra_smmu *smmu;
|
struct tegra_smmu *smmu;
|
||||||
|
@ -282,7 +284,7 @@ static struct iommu_domain *tegra_smmu_domain_alloc_paging(struct device *dev)
|
||||||
|
|
||||||
as->attr = SMMU_PD_READABLE | SMMU_PD_WRITABLE | SMMU_PD_NONSECURE;
|
as->attr = SMMU_PD_READABLE | SMMU_PD_WRITABLE | SMMU_PD_NONSECURE;
|
||||||
|
|
||||||
as->pd = alloc_page(GFP_KERNEL | __GFP_DMA | __GFP_ZERO);
|
as->pd = __iommu_alloc_pages(GFP_KERNEL | __GFP_DMA, 0);
|
||||||
if (!as->pd) {
|
if (!as->pd) {
|
||||||
kfree(as);
|
kfree(as);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -290,7 +292,7 @@ static struct iommu_domain *tegra_smmu_domain_alloc_paging(struct device *dev)
|
||||||
|
|
||||||
as->count = kcalloc(SMMU_NUM_PDE, sizeof(u32), GFP_KERNEL);
|
as->count = kcalloc(SMMU_NUM_PDE, sizeof(u32), GFP_KERNEL);
|
||||||
if (!as->count) {
|
if (!as->count) {
|
||||||
__free_page(as->pd);
|
__iommu_free_pages(as->pd, 0);
|
||||||
kfree(as);
|
kfree(as);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -298,7 +300,7 @@ static struct iommu_domain *tegra_smmu_domain_alloc_paging(struct device *dev)
|
||||||
as->pts = kcalloc(SMMU_NUM_PDE, sizeof(*as->pts), GFP_KERNEL);
|
as->pts = kcalloc(SMMU_NUM_PDE, sizeof(*as->pts), GFP_KERNEL);
|
||||||
if (!as->pts) {
|
if (!as->pts) {
|
||||||
kfree(as->count);
|
kfree(as->count);
|
||||||
__free_page(as->pd);
|
__iommu_free_pages(as->pd, 0);
|
||||||
kfree(as);
|
kfree(as);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -599,14 +601,14 @@ static u32 *as_get_pte(struct tegra_smmu_as *as, dma_addr_t iova,
|
||||||
dma = dma_map_page(smmu->dev, page, 0, SMMU_SIZE_PT,
|
dma = dma_map_page(smmu->dev, page, 0, SMMU_SIZE_PT,
|
||||||
DMA_TO_DEVICE);
|
DMA_TO_DEVICE);
|
||||||
if (dma_mapping_error(smmu->dev, dma)) {
|
if (dma_mapping_error(smmu->dev, dma)) {
|
||||||
__free_page(page);
|
__iommu_free_pages(page, 0);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!smmu_dma_addr_valid(smmu, dma)) {
|
if (!smmu_dma_addr_valid(smmu, dma)) {
|
||||||
dma_unmap_page(smmu->dev, dma, SMMU_SIZE_PT,
|
dma_unmap_page(smmu->dev, dma, SMMU_SIZE_PT,
|
||||||
DMA_TO_DEVICE);
|
DMA_TO_DEVICE);
|
||||||
__free_page(page);
|
__iommu_free_pages(page, 0);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -649,7 +651,7 @@ static void tegra_smmu_pte_put_use(struct tegra_smmu_as *as, unsigned long iova)
|
||||||
tegra_smmu_set_pde(as, iova, 0);
|
tegra_smmu_set_pde(as, iova, 0);
|
||||||
|
|
||||||
dma_unmap_page(smmu->dev, pte_dma, SMMU_SIZE_PT, DMA_TO_DEVICE);
|
dma_unmap_page(smmu->dev, pte_dma, SMMU_SIZE_PT, DMA_TO_DEVICE);
|
||||||
__free_page(page);
|
__iommu_free_pages(page, 0);
|
||||||
as->pts[pde] = NULL;
|
as->pts[pde] = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -688,7 +690,7 @@ static struct page *as_get_pde_page(struct tegra_smmu_as *as,
|
||||||
if (gfpflags_allow_blocking(gfp))
|
if (gfpflags_allow_blocking(gfp))
|
||||||
spin_unlock_irqrestore(&as->lock, *flags);
|
spin_unlock_irqrestore(&as->lock, *flags);
|
||||||
|
|
||||||
page = alloc_page(gfp | __GFP_DMA | __GFP_ZERO);
|
page = __iommu_alloc_pages(gfp | __GFP_DMA, 0);
|
||||||
|
|
||||||
if (gfpflags_allow_blocking(gfp))
|
if (gfpflags_allow_blocking(gfp))
|
||||||
spin_lock_irqsave(&as->lock, *flags);
|
spin_lock_irqsave(&as->lock, *flags);
|
||||||
|
@ -700,7 +702,7 @@ static struct page *as_get_pde_page(struct tegra_smmu_as *as,
|
||||||
*/
|
*/
|
||||||
if (as->pts[pde]) {
|
if (as->pts[pde]) {
|
||||||
if (page)
|
if (page)
|
||||||
__free_page(page);
|
__iommu_free_pages(page, 0);
|
||||||
|
|
||||||
page = as->pts[pde];
|
page = as->pts[pde];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue