From mboxrd@z Thu Jan 1 00:00:00 1970 From: Wei Wang2 Subject: [PATCH 2/3] amd iommu: Clean up amd_iommu_reserve_domain_unity_map Date: Thu, 27 Jan 2011 15:30:38 +0100 Message-ID: <201101271530.38791.wei.wang2@amd.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="Boundary-00=_OGYQNTknbkVvGb0" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Keir Fraser Cc: "xen-devel@lists.xensource.com" List-Id: xen-devel@lists.xenproject.org --Boundary-00=_OGYQNTknbkVvGb0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Signed-off-by: Wei Wang =2D- Advanced Micro Devices GmbH Sitz: Dornach, Gemeinde Aschheim,=20 Landkreis M=FCnchen Registergericht M=FCnchen,=20 HRB Nr. 43632 WEEE-Reg-Nr: DE 12919551 Gesch=E4ftsf=FChrer: Alberto Bozzo, Andrew Bowd --Boundary-00=_OGYQNTknbkVvGb0 Content-Type: text/x-diff; charset="us-ascii"; name="iommu_cleanup1.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="iommu_cleanup1.patch" Content-Description: iommu_cleanup1.patch 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; } --Boundary-00=_OGYQNTknbkVvGb0 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --Boundary-00=_OGYQNTknbkVvGb0--