iommu/fsl_pamu: merge iommu_alloc_dma_domain into fsl_pamu_domain_alloc
authorChristoph Hellwig <hch@lst.de>
Thu, 1 Apr 2021 15:52:40 +0000 (17:52 +0200)
committerJoerg Roedel <jroedel@suse.de>
Wed, 7 Apr 2021 08:56:51 +0000 (10:56 +0200)
Keep the functionality to allocate the domain together.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Will Deacon <will@kernel.org>
Acked-by: Li Yang <leoyang.li@nxp.com>
Link: https://lore.kernel.org/r/20210401155256.298656-5-hch@lst.de
Signed-off-by: Joerg Roedel <jroedel@suse.de>
drivers/iommu/fsl_pamu_domain.c

index 7bd08dd..a4da559 100644 (file)
@@ -292,25 +292,6 @@ static int check_size(u64 size, dma_addr_t iova)
        return 0;
 }
 
-static struct fsl_dma_domain *iommu_alloc_dma_domain(void)
-{
-       struct fsl_dma_domain *domain;
-
-       domain = kmem_cache_zalloc(fsl_pamu_domain_cache, GFP_KERNEL);
-       if (!domain)
-               return NULL;
-
-       domain->stash_id = ~(u32)0;
-       domain->snoop_id = ~(u32)0;
-       domain->win_cnt = pamu_get_max_subwin_cnt();
-
-       INIT_LIST_HEAD(&domain->devices);
-
-       spin_lock_init(&domain->domain_lock);
-
-       return domain;
-}
-
 static void remove_device_ref(struct device_domain_info *info, u32 win_cnt)
 {
        unsigned long flags;
@@ -412,12 +393,17 @@ static struct iommu_domain *fsl_pamu_domain_alloc(unsigned type)
        if (type != IOMMU_DOMAIN_UNMANAGED)
                return NULL;
 
-       dma_domain = iommu_alloc_dma_domain();
-       if (!dma_domain) {
-               pr_debug("dma_domain allocation failed\n");
+       dma_domain = kmem_cache_zalloc(fsl_pamu_domain_cache, GFP_KERNEL);
+       if (!dma_domain)
                return NULL;
-       }
-       /* defaul geometry 64 GB i.e. maximum system address */
+
+       dma_domain->stash_id = ~(u32)0;
+       dma_domain->snoop_id = ~(u32)0;
+       dma_domain->win_cnt = pamu_get_max_subwin_cnt();
+       INIT_LIST_HEAD(&dma_domain->devices);
+       spin_lock_init(&dma_domain->domain_lock);
+
+       /* default geometry 64 GB i.e. maximum system address */
        dma_domain->iommu_domain. geometry.aperture_start = 0;
        dma_domain->iommu_domain.geometry.aperture_end = (1ULL << 36) - 1;
        dma_domain->iommu_domain.geometry.force_aperture = true;