Skip to content

Commit 0d6d3da

Browse files
mszyprowjoergroedel
authored andcommitted
iommu/exynos: Fix warnings from DMA-debug
Add a simple checks for dma_map_single() return value to make DMA-debug checker happly. Exynos IOMMU on Samsung Exynos SoCs always use device, which has linear DMA mapping ops (dma address is equal to physical memory address), so no failures are returned from dma_map_single(). Signed-off-by: Marek Szyprowski <[email protected]> Signed-off-by: Joerg Roedel <[email protected]>
1 parent ec5d241 commit 0d6d3da

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

drivers/iommu/exynos-iommu.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -744,6 +744,8 @@ static struct iommu_domain *exynos_iommu_domain_alloc(unsigned type)
744744
DMA_TO_DEVICE);
745745
/* For mapping page table entries we rely on dma == phys */
746746
BUG_ON(handle != virt_to_phys(domain->pgtable));
747+
if (dma_mapping_error(dma_dev, handle))
748+
goto err_lv2ent;
747749

748750
spin_lock_init(&domain->lock);
749751
spin_lock_init(&domain->pgtablelock);
@@ -755,6 +757,8 @@ static struct iommu_domain *exynos_iommu_domain_alloc(unsigned type)
755757

756758
return &domain->domain;
757759

760+
err_lv2ent:
761+
free_pages((unsigned long)domain->lv2entcnt, 1);
758762
err_counter:
759763
free_pages((unsigned long)domain->pgtable, 2);
760764
err_dma_cookie:
@@ -898,6 +902,7 @@ static sysmmu_pte_t *alloc_lv2entry(struct exynos_iommu_domain *domain,
898902
}
899903

900904
if (lv1ent_fault(sent)) {
905+
dma_addr_t handle;
901906
sysmmu_pte_t *pent;
902907
bool need_flush_flpd_cache = lv1ent_zero(sent);
903908

@@ -909,7 +914,12 @@ static sysmmu_pte_t *alloc_lv2entry(struct exynos_iommu_domain *domain,
909914
update_pte(sent, mk_lv1ent_page(virt_to_phys(pent)));
910915
kmemleak_ignore(pent);
911916
*pgcounter = NUM_LV2ENTRIES;
912-
dma_map_single(dma_dev, pent, LV2TABLE_SIZE, DMA_TO_DEVICE);
917+
handle = dma_map_single(dma_dev, pent, LV2TABLE_SIZE,
918+
DMA_TO_DEVICE);
919+
if (dma_mapping_error(dma_dev, handle)) {
920+
kmem_cache_free(lv2table_kmem_cache, pent);
921+
return ERR_PTR(-EADDRINUSE);
922+
}
913923

914924
/*
915925
* If pre-fetched SLPD is a faulty SLPD in zero_l2_table,

0 commit comments

Comments
 (0)