[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <1605180509-9183-5-git-send-email-john.garry@huawei.com>
Date: Thu, 12 Nov 2020 19:28:29 +0800
From: John Garry <john.garry@...wei.com>
To: <robin.murphy@....com>, <joro@...tes.org>
CC: <xiyou.wangcong@...il.com>, <linuxarm@...wei.com>,
<iommu@...ts.linux-foundation.org>, <linux-kernel@...r.kernel.org>,
<chenxiang66@...ilicon.com>, John Garry <john.garry@...wei.com>
Subject: [PATCH v3 4/4] iommu: avoid taking iova_rbtree_lock twice
From: Cong Wang <xiyou.wangcong@...il.com>
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 <xiyou.wangcong@...il.com>
Reviewed-by: Robin Murphy <robin.murphy@....com>
Signed-off-by: John Garry <john.garry@...wei.com>
---
drivers/iommu/iova.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/iommu/iova.c b/drivers/iommu/iova.c
index 386005055aca..3b32e6746c70 100644
--- a/drivers/iommu/iova.c
+++ b/drivers/iommu/iova.c
@@ -398,10 +398,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);
--
2.26.2
Powered by blists - more mailing lists