All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wei Wang2 <wei.wang2@amd.com>
To: Keir Fraser <keir.fraser@eu.citrix.com>
Cc: "xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>
Subject: [PATCH 2/3] amd iommu: Clean up amd_iommu_reserve_domain_unity_map
Date: Thu, 27 Jan 2011 15:30:38 +0100	[thread overview]
Message-ID: <201101271530.38791.wei.wang2@amd.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 246 bytes --]

Signed-off-by: Wei Wang <wei.wang2@amd.com>
--
Advanced Micro Devices GmbH
Sitz: Dornach, Gemeinde Aschheim, 
Landkreis München Registergericht München, 
HRB Nr. 43632
WEEE-Reg-Nr: DE 12919551
Geschäftsführer:
Alberto Bozzo, Andrew Bowd

[-- Attachment #2: iommu_cleanup1.patch --]
[-- Type: text/x-diff, Size: 1794 bytes --]

diff -r 8d6f48fe45f2 xen/drivers/passthrough/amd/iommu_map.c
--- a/xen/drivers/passthrough/amd/iommu_map.c	Thu Jan 27 12:14:10 2011 +0100
+++ b/xen/drivers/passthrough/amd/iommu_map.c	Thu Jan 27 12:23:38 2011 +0100
@@ -518,38 +518,26 @@ int amd_iommu_unmap_page(struct domain *
     return 0;
 }
 
-int amd_iommu_reserve_domain_unity_map(
-    struct domain *domain,
-    unsigned long phys_addr,
-    unsigned long size, int iw, int ir)
-{
-    u64 iommu_l2e;
+int amd_iommu_reserve_domain_unity_map(struct domain *domain,
+                                       u64 phys_addr,
+                                       unsigned long size, int iw, int ir)
+{
     unsigned long npages, i;
-    struct hvm_iommu *hd = domain_hvm_iommu(domain);
+    unsigned long gfn;
+    unsigned int flags = !!ir;
+    int rt = 0;
+
+    if ( iw )
+        flags |= IOMMUF_writable;
 
     npages = region_to_pages(phys_addr, size);
-
-    spin_lock(&hd->mapping_lock);
-    for ( i = 0; i < npages; ++i )
-    {
-        iommu_l2e = iommu_l2e_from_pfn(
-            hd->root_table, hd->paging_mode, phys_addr >> PAGE_SHIFT);
-
-        if ( iommu_l2e == 0 )
-        {
-            spin_unlock(&hd->mapping_lock);
-            AMD_IOMMU_DEBUG("Invalid IO pagetable entry phys_addr = %lx\n",
-                            phys_addr);
-            domain_crash(domain);
-            return -EFAULT;
-        }
-
-        set_iommu_l1e_present(iommu_l2e,
-            (phys_addr >> PAGE_SHIFT), phys_addr, iw, ir);
-
-        phys_addr += PAGE_SIZE;
-    }
-    spin_unlock(&hd->mapping_lock);
+    gfn = phys_addr >> PAGE_SHIFT;
+    for ( i = 0; i < npages; i++ )
+    {
+        rt = amd_iommu_map_page(domain, gfn +i, gfn +i, flags);
+        if ( rt != 0 )
+            return rt;
+    }
     return 0;
 }
 

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

             reply	other threads:[~2011-01-27 14:30 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-27 14:30 Wei Wang2 [this message]
2011-01-27 18:42 ` [PATCH 2/3] amd iommu: Clean up amd_iommu_reserve_domain_unity_map Ian Jackson

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=201101271530.38791.wei.wang2@amd.com \
    --to=wei.wang2@amd.com \
    --cc=keir.fraser@eu.citrix.com \
    --cc=xen-devel@lists.xensource.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.