diff options
author | Cong Wang <[email protected]> | 2020-11-17 18:25:34 +0800 |
---|---|---|
committer | Will Deacon <[email protected]> | 2020-12-01 21:04:56 +0000 |
commit | 3a651b3a27a1ee35879499ead3942dc854a20968 (patch) | |
tree | 01c83fe3814ff00104395810a62ee6ff74e5596d | |
parent | 6fa3525b455ae1fde5b424907141b33651f137b0 (diff) |
iommu: avoid taking iova_rbtree_lock twice
Both find_iova() and __free_iova() take iova_rbtree_lock,
there is no reason to take and release it twice inside
free_iova().
Fold them into one critical section by calling the unlock
versions instead.
Signed-off-by: Cong Wang <[email protected]>
Reviewed-by: Robin Murphy <[email protected]>
Signed-off-by: John Garry <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Will Deacon <[email protected]>
-rw-r--r-- | drivers/iommu/iova.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/drivers/iommu/iova.c b/drivers/iommu/iova.c index ea04a88c673d..ff59d8aa3041 100644 --- a/drivers/iommu/iova.c +++ b/drivers/iommu/iova.c @@ -402,10 +402,14 @@ EXPORT_SYMBOL_GPL(__free_iova); void free_iova(struct iova_domain *iovad, unsigned long pfn) { - struct iova *iova = find_iova(iovad, pfn); + unsigned long flags; + struct iova *iova; + spin_lock_irqsave(&iovad->iova_rbtree_lock, flags); + iova = private_find_iova(iovad, pfn); if (iova) - __free_iova(iovad, iova); + private_free_iova(iovad, iova); + spin_unlock_irqrestore(&iovad->iova_rbtree_lock, flags); } EXPORT_SYMBOL_GPL(free_iova); |