On 1/17/22 10:50 AM, Lu Baolu wrote:
On 12/29/21 4:56 PM, Guoqing Jiang wrote:
Call irq_domain_free_fwnode to free 'fn' if dmar_enable_qi returns
failure, same as when irq_domain_create_hierarchy returns failure.

Signed-off-by: Guoqing Jiang <[email protected]>

Add a "Fixes" tag if you think this change needs backport.

I guess the tag might be:

Fixes: e3beca48a45b ("irqdomain/treewide: Keep firmware node unconditionally allocated")

Since before that commit, irq_domain_free_fwnode is called unconditionally after create ir_domain,
please correct me if my understanding is not correct.


---
  drivers/iommu/intel/irq_remapping.c | 1 +
  1 file changed, 1 insertion(+)

diff --git a/drivers/iommu/intel/irq_remapping.c b/drivers/iommu/intel/irq_remapping.c
index f912fe45bea2..6e8362c21fc3 100644
--- a/drivers/iommu/intel/irq_remapping.c
+++ b/drivers/iommu/intel/irq_remapping.c
@@ -594,6 +594,7 @@ static int intel_setup_irq_remapping(struct intel_iommu *iommu)
          dmar_disable_qi(iommu);
            if (dmar_enable_qi(iommu)) {
+            irq_domain_free_fwnode(fn);
              pr_err("Failed to enable queued invalidation\n");
              goto out_free_bitmap;
          }


The rewinding paths in intel_setup_irq_remapping() need more
enhancement. How about below changes?

diff --git a/drivers/iommu/intel/irq_remapping.c b/drivers/iommu/intel/irq_remapping.c
index f912fe45bea2..89c32bf173ef 100644
--- a/drivers/iommu/intel/irq_remapping.c
+++ b/drivers/iommu/intel/irq_remapping.c
@@ -569,9 +569,8 @@ static int intel_setup_irq_remapping(struct intel_iommu *iommu)
                                            fn, &intel_ir_domain_ops,
                                            iommu);
        if (!iommu->ir_domain) {
-               irq_domain_free_fwnode(fn);
                pr_err("IR%d: failed to allocate irqdomain\n", iommu->seq_id);
-               goto out_free_bitmap;
+               goto out_free_fwnode;
        }
        iommu->ir_msi_domain =
arch_create_remap_msi_irq_domain(iommu->ir_domain,
@@ -595,7 +594,7 @@ static int intel_setup_irq_remapping(struct intel_iommu *iommu)

                if (dmar_enable_qi(iommu)) {
                        pr_err("Failed to enable queued invalidation\n");
-                       goto out_free_bitmap;
+                       goto out_free_ir_domain;
                }
        }

@@ -619,6 +618,14 @@ static int intel_setup_irq_remapping(struct intel_iommu *iommu)

        return 0;

+out_free_ir_domain:
+       if (iommu->ir_msi_domain)
+               irq_domain_remove(iommu->ir_msi_domain);
+       irq_domain_remove(iommu->ir_domain);
+       iommu->ir_msi_domain = NULL;
+       iommu->ir_domain = NULL;
+out_free_fwnode:
+       irq_domain_free_fwnode(fn);
 out_free_bitmap:
        bitmap_free(bitmap);
 out_free_pages:

Thanks for the suggestion, will send new version with your suggested-by.

Thanks,
Guoqing
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu

Reply via email to