iommu/dma: Handle init_iova_flush_queue() failure in dma-iommu path
authorTom Murphy <murphyt7@tcd.ie>
Thu, 10 Sep 2020 12:25:38 +0000 (13:25 +0100)
committerJoerg Roedel <jroedel@suse.de>
Fri, 18 Sep 2020 15:13:21 +0000 (17:13 +0200)
The init_iova_flush_queue() function can fail if we run out of memory. Fall
back to noflush queue if it fails.

Signed-off-by: Tom Murphy <murphyt7@tcd.ie>
Reviewed-by: Robin Murphy <robin.murphy@arm.com>
Link: https://lore.kernel.org/r/20200910122539.3662-1-murphyt7@tcd.ie
Signed-off-by: Joerg Roedel <jroedel@suse.de>
drivers/iommu/dma-iommu.c

index 79b4d1073dcb991ef66f06ce23f233046c9e84b9..cd6e3c70ebb31c69804512b75edc77bad15038a4 100644 (file)
@@ -343,8 +343,11 @@ static int iommu_dma_init_domain(struct iommu_domain *domain, dma_addr_t base,
 
        if (!cookie->fq_domain && !iommu_domain_get_attr(domain,
                        DOMAIN_ATTR_DMA_USE_FLUSH_QUEUE, &attr) && attr) {
-               cookie->fq_domain = domain;
-               init_iova_flush_queue(iovad, iommu_dma_flush_iotlb_all, NULL);
+               if (init_iova_flush_queue(iovad, iommu_dma_flush_iotlb_all,
+                                       NULL))
+                       pr_warn("iova flush queue initialization failed\n");
+               else
+                       cookie->fq_domain = domain;
        }
 
        if (!dev)