|
21 | 21 | #include <linux/platform_device.h>
|
22 | 22 | #include <linux/pm_runtime.h>
|
23 | 23 | #include <linux/slab.h>
|
24 |
| -#include <linux/dma-iommu.h> |
25 | 24 |
|
26 | 25 | typedef u32 sysmmu_iova_t;
|
27 | 26 | typedef u32 sysmmu_pte_t;
|
@@ -735,20 +734,16 @@ static struct iommu_domain *exynos_iommu_domain_alloc(unsigned type)
|
735 | 734 | /* Check if correct PTE offsets are initialized */
|
736 | 735 | BUG_ON(PG_ENT_SHIFT < 0 || !dma_dev);
|
737 | 736 |
|
| 737 | + if (type != IOMMU_DOMAIN_DMA && type != IOMMU_DOMAIN_UNMANAGED) |
| 738 | + return NULL; |
| 739 | + |
738 | 740 | domain = kzalloc(sizeof(*domain), GFP_KERNEL);
|
739 | 741 | if (!domain)
|
740 | 742 | return NULL;
|
741 | 743 |
|
742 |
| - if (type == IOMMU_DOMAIN_DMA) { |
743 |
| - if (iommu_get_dma_cookie(&domain->domain) != 0) |
744 |
| - goto err_pgtable; |
745 |
| - } else if (type != IOMMU_DOMAIN_UNMANAGED) { |
746 |
| - goto err_pgtable; |
747 |
| - } |
748 |
| - |
749 | 744 | domain->pgtable = (sysmmu_pte_t *)__get_free_pages(GFP_KERNEL, 2);
|
750 | 745 | if (!domain->pgtable)
|
751 |
| - goto err_dma_cookie; |
| 746 | + goto err_pgtable; |
752 | 747 |
|
753 | 748 | domain->lv2entcnt = (short *)__get_free_pages(GFP_KERNEL | __GFP_ZERO, 1);
|
754 | 749 | if (!domain->lv2entcnt)
|
@@ -779,9 +774,6 @@ static struct iommu_domain *exynos_iommu_domain_alloc(unsigned type)
|
779 | 774 | free_pages((unsigned long)domain->lv2entcnt, 1);
|
780 | 775 | err_counter:
|
781 | 776 | free_pages((unsigned long)domain->pgtable, 2);
|
782 |
| -err_dma_cookie: |
783 |
| - if (type == IOMMU_DOMAIN_DMA) |
784 |
| - iommu_put_dma_cookie(&domain->domain); |
785 | 777 | err_pgtable:
|
786 | 778 | kfree(domain);
|
787 | 779 | return NULL;
|
@@ -809,9 +801,6 @@ static void exynos_iommu_domain_free(struct iommu_domain *iommu_domain)
|
809 | 801 |
|
810 | 802 | spin_unlock_irqrestore(&domain->lock, flags);
|
811 | 803 |
|
812 |
| - if (iommu_domain->type == IOMMU_DOMAIN_DMA) |
813 |
| - iommu_put_dma_cookie(iommu_domain); |
814 |
| - |
815 | 804 | dma_unmap_single(dma_dev, virt_to_phys(domain->pgtable), LV1TABLE_SIZE,
|
816 | 805 | DMA_TO_DEVICE);
|
817 | 806 |
|
|
0 commit comments