8
8
9
9
#include <linux/bitmap.h>
10
10
#include <linux/delay.h>
11
- #include <linux/dma-iommu.h>
12
11
#include <linux/dma-mapping.h>
13
12
#include <linux/err.h>
14
13
#include <linux/export.h>
@@ -564,10 +563,13 @@ static irqreturn_t ipmmu_irq(int irq, void *dev)
564
563
* IOMMU Operations
565
564
*/
566
565
567
- static struct iommu_domain * __ipmmu_domain_alloc (unsigned type )
566
+ static struct iommu_domain * ipmmu_domain_alloc (unsigned type )
568
567
{
569
568
struct ipmmu_vmsa_domain * domain ;
570
569
570
+ if (type != IOMMU_DOMAIN_UNMANAGED && type != IOMMU_DOMAIN_DMA )
571
+ return NULL ;
572
+
571
573
domain = kzalloc (sizeof (* domain ), GFP_KERNEL );
572
574
if (!domain )
573
575
return NULL ;
@@ -577,27 +579,6 @@ static struct iommu_domain *__ipmmu_domain_alloc(unsigned type)
577
579
return & domain -> io_domain ;
578
580
}
579
581
580
- static struct iommu_domain * ipmmu_domain_alloc (unsigned type )
581
- {
582
- struct iommu_domain * io_domain = NULL ;
583
-
584
- switch (type ) {
585
- case IOMMU_DOMAIN_UNMANAGED :
586
- io_domain = __ipmmu_domain_alloc (type );
587
- break ;
588
-
589
- case IOMMU_DOMAIN_DMA :
590
- io_domain = __ipmmu_domain_alloc (type );
591
- if (io_domain && iommu_get_dma_cookie (io_domain )) {
592
- kfree (io_domain );
593
- io_domain = NULL ;
594
- }
595
- break ;
596
- }
597
-
598
- return io_domain ;
599
- }
600
-
601
582
static void ipmmu_domain_free (struct iommu_domain * io_domain )
602
583
{
603
584
struct ipmmu_vmsa_domain * domain = to_vmsa_domain (io_domain );
@@ -606,7 +587,6 @@ static void ipmmu_domain_free(struct iommu_domain *io_domain)
606
587
* Free the domain resources. We assume that all devices have already
607
588
* been detached.
608
589
*/
609
- iommu_put_dma_cookie (io_domain );
610
590
ipmmu_domain_destroy_context (domain );
611
591
free_io_pgtable_ops (domain -> iop );
612
592
kfree (domain );
0 commit comments