aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorJoerg Roedel <joerg.roedel@amd.com>2008-12-02 13:48:43 -0500
committerJoerg Roedel <joerg.roedel@amd.com>2009-01-03 08:11:56 -0500
commitc6229ca649aa9b312d1f1de20af8d2603b14eead (patch)
tree2df5caa2708e5566e8e9acb82fa22aac9fc3a2d3 /arch
parent01106066a6900b518debe990ddaadf376d433bd6 (diff)
AMD IOMMU: add domain map function for IOMMU API
Impact: add a generic function to map pages into protection domains Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
Diffstat (limited to 'arch')
-rw-r--r--arch/x86/kernel/amd_iommu.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/arch/x86/kernel/amd_iommu.c b/arch/x86/kernel/amd_iommu.c
index 2f7c0b3a448b..1fcedbe39a99 100644
--- a/arch/x86/kernel/amd_iommu.c
+++ b/arch/x86/kernel/amd_iommu.c
@@ -1718,4 +1718,33 @@ static int amd_iommu_attach_device(struct iommu_domain *dom,
1718 return 0; 1718 return 0;
1719} 1719}
1720 1720
1721static int amd_iommu_map_range(struct iommu_domain *dom,
1722 unsigned long iova, phys_addr_t paddr,
1723 size_t size, int iommu_prot)
1724{
1725 struct protection_domain *domain = dom->priv;
1726 unsigned long i, npages = iommu_num_pages(paddr, size, PAGE_SIZE);
1727 int prot = 0;
1728 int ret;
1729
1730 if (iommu_prot & IOMMU_READ)
1731 prot |= IOMMU_PROT_IR;
1732 if (iommu_prot & IOMMU_WRITE)
1733 prot |= IOMMU_PROT_IW;
1734
1735 iova &= PAGE_MASK;
1736 paddr &= PAGE_MASK;
1737
1738 for (i = 0; i < npages; ++i) {
1739 ret = iommu_map_page(domain, iova, paddr, prot);
1740 if (ret)
1741 return ret;
1742
1743 iova += PAGE_SIZE;
1744 paddr += PAGE_SIZE;
1745 }
1746
1747 return 0;
1748}
1749
1721#endif 1750#endif