From: Joerg Roedel <joro@8bytes.org>
To: iommu@lists.linux-foundation.org
Cc: Suravee.Suthikulpanit@amd.com, linux-kernel@vger.kernel.org,
Joerg Roedel <jroedel@suse.de>
Subject: [PATCH 6/9] iommu/amd: Optimize iommu_unmap_page for new fetch_pte interface
Date: Wed, 1 Apr 2015 14:58:49 +0200 [thread overview]
Message-ID: <1427893132-18310-7-git-send-email-joro@8bytes.org> (raw)
In-Reply-To: <1427893132-18310-1-git-send-email-joro@8bytes.org>
From: Joerg Roedel <jroedel@suse.de>
Now that fetch_pte returns the page-size of the pte, this
function can be optimized a lot.
Signed-off-by: Joerg Roedel <jroedel@suse.de>
---
drivers/iommu/amd_iommu.c | 32 ++++++++------------------------
1 file changed, 8 insertions(+), 24 deletions(-)
diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c
index 24ef9e6..c9ee444 100644
--- a/drivers/iommu/amd_iommu.c
+++ b/drivers/iommu/amd_iommu.c
@@ -1428,8 +1428,8 @@ static unsigned long iommu_unmap_page(struct protection_domain *dom,
unsigned long bus_addr,
unsigned long page_size)
{
- unsigned long long unmap_size, unmapped;
- unsigned long pte_pgsize;
+ unsigned long long unmapped;
+ unsigned long unmap_size;
u64 *pte;
BUG_ON(!is_power_of_2(page_size));
@@ -1438,28 +1438,12 @@ static unsigned long iommu_unmap_page(struct protection_domain *dom,
while (unmapped < page_size) {
- pte = fetch_pte(dom, bus_addr, &pte_pgsize);
-
- if (!pte) {
- /*
- * No PTE for this address
- * move forward in 4kb steps
- */
- unmap_size = PAGE_SIZE;
- } else if (PM_PTE_LEVEL(*pte) == 0) {
- /* 4kb PTE found for this address */
- unmap_size = PAGE_SIZE;
- *pte = 0ULL;
- } else {
- int count, i;
-
- /* Large PTE found which maps this address */
- unmap_size = PTE_PAGE_SIZE(*pte);
-
- /* Only unmap from the first pte in the page */
- if ((unmap_size - 1) & bus_addr)
- break;
- count = PAGE_SIZE_PTE_COUNT(unmap_size);
+ pte = fetch_pte(dom, bus_addr, &unmap_size);
+
+ if (pte) {
+ int i, count;
+
+ count = PAGE_SIZE_PTE_COUNT(unmap_size);
for (i = 0; i < count; i++)
pte[i] = 0ULL;
}
--
1.9.1
next prev parent reply other threads:[~2015-04-01 12:59 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-01 12:58 [PATCH 0/9] AMD IOMMU Updates for v4.1 Joerg Roedel
2015-04-01 12:58 ` [PATCH 1/9] iommu/amd: Use BUS_NOTIFY_REMOVED_DEVICE Joerg Roedel
2015-04-01 12:58 ` [PATCH 2/9] iommu/amd: Ignore BUS_NOTIFY_UNBOUND_DRIVER event Joerg Roedel
2015-04-01 12:58 ` [PATCH 3/9] iommu/amd: Don't allocate with __GFP_ZERO in alloc_coherent Joerg Roedel
2015-04-01 12:58 ` [PATCH 4/9] iommu/amd: Add support for contiguous dma allocator Joerg Roedel
2015-04-01 12:58 ` [PATCH 5/9] iommu/amd: Return the pte page-size in fetch_pte Joerg Roedel
2015-04-01 12:58 ` Joerg Roedel [this message]
2015-04-01 12:58 ` [PATCH 7/9] iommu/amd: Optimize alloc_new_range for new fetch_pte interface Joerg Roedel
2015-04-01 12:58 ` [PATCH 8/9] iommu/amd: Optimize amd_iommu_iova_to_phys " Joerg Roedel
2015-04-01 12:58 ` [PATCH 9/9] iommu/amd: Correctly encode huge pages in iommu page tables Joerg Roedel
2015-04-01 19:11 ` [PATCH 0/9] AMD IOMMU Updates for v4.1 Suravee Suthikulanit
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1427893132-18310-7-git-send-email-joro@8bytes.org \
--to=joro@8bytes.org \
--cc=Suravee.Suthikulpanit@amd.com \
--cc=iommu@lists.linux-foundation.org \
--cc=jroedel@suse.de \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).