From: Cong Wang Date: Tue, 17 Nov 2020 10:25:34 +0000 (+0800) Subject: iommu: avoid taking iova_rbtree_lock twice X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=3a651b3a27a1ee35879499ead3942dc854a20968;p=linux.git 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 Reviewed-by: Robin Murphy Signed-off-by: John Garry Link: https://lore.kernel.org/r/1605608734-84416-5-git-send-email-john.garry@huawei.com Signed-off-by: Will Deacon --- diff --git a/drivers/iommu/iova.c b/drivers/iommu/iova.c index ea04a88c673d3..ff59d8aa30418 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);