xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Wei Wang <wei.wang2@amd.com>
To: JBeulich@suse.com, xen-devel@lists.xen.org
Subject: [PATCH 3 of 3] amd iommu: Remove unnecessary map/unmap for l1 page tables
Date: Mon, 13 Aug 2012 17:46:07 +0200	[thread overview]
Message-ID: <076df9db4c273e9786ea.1344872767@gran.amd.com> (raw)
In-Reply-To: <patchbomb.1344872764@gran.amd.com>

# HG changeset patch
# User Wei Wang <wei.wang2@amd.com>
# Date 1344872316 -7200
# Node ID 076df9db4c273e9786ea373bda092716015d9403
# Parent  273471c6dedd1e66caab7e4eede72130e4e0c00f
amd iommu: Remove unnecessary map/unmap for l1 page tables

Signed-off-by: Wei Wang <wei.wang2@amd.com>

diff -r 273471c6dedd -r 076df9db4c27 xen/drivers/passthrough/amd/pci_amd_iommu.c
--- a/xen/drivers/passthrough/amd/pci_amd_iommu.c	Mon Aug 13 17:38:33 2012 +0200
+++ b/xen/drivers/passthrough/amd/pci_amd_iommu.c	Mon Aug 13 17:38:36 2012 +0200
@@ -394,25 +394,27 @@ static void deallocate_next_page_table(s
     u64 next_table_maddr;
     int index, next_level;
 
+    if ( level <= 1 )
+    {
+        free_amd_iommu_pgtable(pg);
+        return;
+    }
+
     table_vaddr = __map_domain_page(pg);
 
-    if ( level > 1 )
+    for ( index = 0; index < PTE_PER_TABLE_SIZE; index++ )
     {
-        for ( index = 0; index < PTE_PER_TABLE_SIZE; index++ )
+        pde = table_vaddr + (index * IOMMU_PAGE_TABLE_ENTRY_SIZE);
+        next_table_maddr = amd_iommu_get_next_table_from_pte(pde);
+        next_level = iommu_next_level((u32*)pde);
+
+        if ( (next_table_maddr != 0) && (next_level != 0)
+             && iommu_is_pte_present((u32*)pde) )
         {
-            pde = table_vaddr + (index * IOMMU_PAGE_TABLE_ENTRY_SIZE);
-            next_table_maddr = amd_iommu_get_next_table_from_pte(pde);
-
-            next_level = iommu_next_level((u32*)pde);
-
-            if ( (next_table_maddr != 0) && (next_level != 0)
-                && iommu_is_pte_present((u32*)pde) )
-            {
-                /* We do not support skip level yet */
-                ASSERT( next_level == level - 1 );
-                deallocate_next_page_table(
-                    maddr_to_page(next_table_maddr), next_level);
-            }
+            /* We do not support skip levels yet */
+            ASSERT( next_level == level - 1 );
+            deallocate_next_page_table(maddr_to_page(next_table_maddr), 
+                                       next_level);
         }
     }

  parent reply	other threads:[~2012-08-13 15:46 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-13 15:46 [PATCH 0 of 3] amd iommu: Clean up iommu page table deallocation Wei Wang
2012-08-13 15:46 ` [PATCH 1 of 3] amd iommu: Add 2 helper functions: iommu_is_pte_present and iommu_next_level Wei Wang
2012-08-13 15:46 ` [PATCH 2 of 3] amd iommu: Use next_level instead of recalculating it Wei Wang
2012-08-13 15:46 ` Wei Wang [this message]
2012-08-13 16:09 ` [PATCH 0 of 3] amd iommu: Clean up iommu page table deallocation Jan Beulich
2012-08-14  9:08   ` Wei Wang

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=076df9db4c273e9786ea.1344872767@gran.amd.com \
    --to=wei.wang2@amd.com \
    --cc=JBeulich@suse.com \
    --cc=xen-devel@lists.xen.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).