aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/include/asm/amd_iommu_types.h
diff options
context:
space:
mode:
authorJoerg Roedel <joerg.roedel@amd.com>2010-05-11 17:40:57 +0200
committerJoerg Roedel <joerg.roedel@amd.com>2010-05-11 17:40:57 +0200
commit795e74f7a69f9c08afa4fa7c86cc4f18a62bd630 (patch)
tree8448ece35101d8db945c49df50d0d5889687de9f /arch/x86/include/asm/amd_iommu_types.h
parentx86/amd-iommu: Add amd_iommu=off command line option (diff)
parentiommu-api: Remove iommu_{un}map_range functions (diff)
downloadlinux-dev-795e74f7a69f9c08afa4fa7c86cc4f18a62bd630.tar.xz
linux-dev-795e74f7a69f9c08afa4fa7c86cc4f18a62bd630.zip
Merge branch 'iommu/largepages' into amd-iommu/2.6.35
Conflicts: arch/x86/kernel/amd_iommu.c
Diffstat (limited to 'arch/x86/include/asm/amd_iommu_types.h')
-rw-r--r--arch/x86/include/asm/amd_iommu_types.h34
1 files changed, 34 insertions, 0 deletions
diff --git a/arch/x86/include/asm/amd_iommu_types.h b/arch/x86/include/asm/amd_iommu_types.h
index 86a0ff0aeac7..7014e88bc779 100644
--- a/arch/x86/include/asm/amd_iommu_types.h
+++ b/arch/x86/include/asm/amd_iommu_types.h
@@ -174,6 +174,40 @@
(~((1ULL << (12 + ((lvl) * 9))) - 1)))
#define PM_ALIGNED(lvl, addr) ((PM_MAP_MASK(lvl) & (addr)) == (addr))
+/*
+ * Returns the page table level to use for a given page size
+ * Pagesize is expected to be a power-of-two
+ */
+#define PAGE_SIZE_LEVEL(pagesize) \
+ ((__ffs(pagesize) - 12) / 9)
+/*
+ * Returns the number of ptes to use for a given page size
+ * Pagesize is expected to be a power-of-two
+ */
+#define PAGE_SIZE_PTE_COUNT(pagesize) \
+ (1ULL << ((__ffs(pagesize) - 12) % 9))
+
+/*
+ * Aligns a given io-virtual address to a given page size
+ * Pagesize is expected to be a power-of-two
+ */
+#define PAGE_SIZE_ALIGN(address, pagesize) \
+ ((address) & ~((pagesize) - 1))
+/*
+ * Creates an IOMMU PTE for an address an a given pagesize
+ * The PTE has no permission bits set
+ * Pagesize is expected to be a power-of-two larger than 4096
+ */
+#define PAGE_SIZE_PTE(address, pagesize) \
+ (((address) | ((pagesize) - 1)) & \
+ (~(pagesize >> 1)) & PM_ADDR_MASK)
+
+/*
+ * Takes a PTE value with mode=0x07 and returns the page size it maps
+ */
+#define PTE_PAGE_SIZE(pte) \
+ (1ULL << (1 + ffz(((pte) | 0xfffULL))))
+
#define IOMMU_PTE_P (1ULL << 0)
#define IOMMU_PTE_TV (1ULL << 1)
#define IOMMU_PTE_U (1ULL << 59)