diff options
author | Alistair Popple <alistair@popple.id.au> | 2013-12-09 02:17:03 -0500 |
---|---|---|
committer | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2013-12-29 22:17:19 -0500 |
commit | d084775738b746648d4102337163a04534a02982 (patch) | |
tree | 641f5ea99dcdb27f51a7646d56a8d245f1d7f9c1 /arch/powerpc/include/asm/iommu.h | |
parent | 3a553170d35d69bea3877bffa508489dfa6f133d (diff) |
powerpc/iommu: Update the generic code to use dynamic iommu page sizes
This patch updates the generic iommu backend code to use the
it_page_shift field to determine the iommu page size instead of
using hardcoded values.
Signed-off-by: Alistair Popple <alistair@popple.id.au>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'arch/powerpc/include/asm/iommu.h')
-rw-r--r-- | arch/powerpc/include/asm/iommu.h | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/arch/powerpc/include/asm/iommu.h b/arch/powerpc/include/asm/iommu.h index 7c928342f3f5..f7a8036579b5 100644 --- a/arch/powerpc/include/asm/iommu.h +++ b/arch/powerpc/include/asm/iommu.h | |||
@@ -35,17 +35,14 @@ | |||
35 | #define IOMMU_PAGE_MASK_4K (~((1 << IOMMU_PAGE_SHIFT_4K) - 1)) | 35 | #define IOMMU_PAGE_MASK_4K (~((1 << IOMMU_PAGE_SHIFT_4K) - 1)) |
36 | #define IOMMU_PAGE_ALIGN_4K(addr) _ALIGN_UP(addr, IOMMU_PAGE_SIZE_4K) | 36 | #define IOMMU_PAGE_ALIGN_4K(addr) _ALIGN_UP(addr, IOMMU_PAGE_SIZE_4K) |
37 | 37 | ||
38 | #define IOMMU_PAGE_SIZE(tblptr) (ASM_CONST(1) << (tblptr)->it_page_shift) | ||
39 | #define IOMMU_PAGE_MASK(tblptr) (~((1 << (tblptr)->it_page_shift) - 1)) | ||
40 | #define IOMMU_PAGE_ALIGN(addr, tblptr) _ALIGN_UP(addr, IOMMU_PAGE_SIZE(tblptr)) | ||
41 | |||
38 | /* Boot time flags */ | 42 | /* Boot time flags */ |
39 | extern int iommu_is_off; | 43 | extern int iommu_is_off; |
40 | extern int iommu_force_on; | 44 | extern int iommu_force_on; |
41 | 45 | ||
42 | /* Pure 2^n version of get_order */ | ||
43 | static __inline__ __attribute_const__ int get_iommu_order(unsigned long size) | ||
44 | { | ||
45 | return __ilog2((size - 1) >> IOMMU_PAGE_SHIFT_4K) + 1; | ||
46 | } | ||
47 | |||
48 | |||
49 | /* | 46 | /* |
50 | * IOMAP_MAX_ORDER defines the largest contiguous block | 47 | * IOMAP_MAX_ORDER defines the largest contiguous block |
51 | * of dma space we can get. IOMAP_MAX_ORDER = 13 | 48 | * of dma space we can get. IOMAP_MAX_ORDER = 13 |
@@ -82,6 +79,14 @@ struct iommu_table { | |||
82 | #endif | 79 | #endif |
83 | }; | 80 | }; |
84 | 81 | ||
82 | /* Pure 2^n version of get_order */ | ||
83 | static inline __attribute_const__ | ||
84 | int get_iommu_order(unsigned long size, struct iommu_table *tbl) | ||
85 | { | ||
86 | return __ilog2((size - 1) >> tbl->it_page_shift) + 1; | ||
87 | } | ||
88 | |||
89 | |||
85 | struct scatterlist; | 90 | struct scatterlist; |
86 | 91 | ||
87 | static inline void set_iommu_table_base(struct device *dev, void *base) | 92 | static inline void set_iommu_table_base(struct device *dev, void *base) |