[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen staging] x86/AMD-Vi: Fold exit paths of {enable, disable}_iommu()



commit 5b68915350e34b38968d89f03a2ff44973031429
Author:     Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
AuthorDate: Mon Aug 12 18:19:59 2019 +0100
Commit:     Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
CommitDate: Wed Aug 14 12:04:20 2019 +0100

    x86/AMD-Vi: Fold exit paths of {enable,disable}_iommu()
    
    ... to avoid having multiple spin_unlock_irqrestore() calls.
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
    Acked-by: Brian Woods <brian.woods@xxxxxxx>
---
 xen/drivers/passthrough/amd/iommu_init.c | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/xen/drivers/passthrough/amd/iommu_init.c 
b/xen/drivers/passthrough/amd/iommu_init.c
index bb9f33e264..bb5a3e57c9 100644
--- a/xen/drivers/passthrough/amd/iommu_init.c
+++ b/xen/drivers/passthrough/amd/iommu_init.c
@@ -899,11 +899,8 @@ static void enable_iommu(struct amd_iommu *iommu)
 
     spin_lock_irqsave(&iommu->lock, flags);
 
-    if ( iommu->enabled )
-    {
-        spin_unlock_irqrestore(&iommu->lock, flags); 
-        return;
-    }
+    if ( unlikely(iommu->enabled) )
+        goto out;
 
     amd_iommu_erratum_746_workaround(iommu);
 
@@ -957,6 +954,8 @@ static void enable_iommu(struct amd_iommu *iommu)
         amd_iommu_flush_all_caches(iommu);
 
     iommu->enabled = 1;
+
+ out:
     spin_unlock_irqrestore(&iommu->lock, flags);
 }
 
@@ -966,11 +965,8 @@ static void disable_iommu(struct amd_iommu *iommu)
 
     spin_lock_irqsave(&iommu->lock, flags);
 
-    if ( !iommu->enabled )
-    {
-        spin_unlock_irqrestore(&iommu->lock, flags);
-        return;
-    }
+    if ( unlikely(!iommu->enabled) )
+        goto out;
 
     if ( !iommu->ctrl.int_cap_xt_en )
         amd_iommu_msi_enable(iommu, IOMMU_CONTROL_DISABLED);
@@ -988,6 +984,7 @@ static void disable_iommu(struct amd_iommu *iommu)
 
     iommu->enabled = 0;
 
+ out:
     spin_unlock_irqrestore(&iommu->lock, flags);
 }
 
--
generated by git-patchbot for /home/xen/git/xen.git#staging

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/xen-changelog

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.