Skip to contentSkip to conversation

Handle init_iova_flush_queue failure in dma-iommu path

PATCH Applied Tom Murphy 3 participants 4 messages Sep 10, 2020 – Sep 18, 2020

Subsystems (2)
lore
Share & tools
lore

Tom Murphy

author
#0 lore raw

PATCH 1/1 Handle init_iova_flush_queue failure in dma-iommu path

init_iova_flush_queue can fail if we run out of memory. Fall back to noflush
queue if it fails.

---
 drivers/iommu/dma-iommu.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/iommu/dma-iommu.c +5 -2
index 4959f5df21bd..5f69126f3e91 100644
@@ -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)
Signature · 6 lines
2.20.1

_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
maintainer
#1 lore raw
Quoted 16 lines · Tom Murphy

init_iova_flush_queue can fail if we run out of memory. Fall back to noflush
queue if it fails.

---
 drivers/iommu/dma-iommu.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/iommu/dma-iommu.c +0 -0
index 4959f5df21bd..5f69126f3e91 100644
@@ -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) {

drivers/iommu/dma-iommu.c static int iommu_dma_init_domain(struct iommu_domain *domain, dma_addr_t base, · line 353

Quoted 10 lines
drivers/iommu/dma-iommu.c +5 -2
-		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)

Looks good to me, but Robin should also have a look.

maintainer Reviewed-by
#2 lore raw
Quoted 26 lines · Joerg Roedel
Quoted 25 lines · Tom Murphy

init_iova_flush_queue can fail if we run out of memory. Fall back to noflush
queue if it fails.

---
  drivers/iommu/dma-iommu.c | 7 +++++--
  1 file changed, 5 insertions(+), 2 deletions(-)
drivers/iommu/dma-iommu.c +5 -2
index 4959f5df21bd..5f69126f3e91 100644
@@ -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;
  	}
 
Quoted 3 lines

drivers/iommu/dma-iommu.c static int iommu_dma_init_domain(struct iommu_domain *domain, dma_addr_t base, · line 353

Quoted 1 line
drivers/iommu/dma-iommu.c +0 -0
  	if (!dev)

Looks good to me, but Robin should also have a look.

Yup, seems reasonable, thanks Tom!