Commit 225d4905 authored by Michael Ellerman's avatar Michael Ellerman Committed by Arnd Bergmann

[POWERPC] Allow for different IOMMU page sizes in cell IOMMU code

Make some preliminary changes to cell_iommu_alloc_ptab() to allow it to
take the page size as a parameter rather than assuming IOMMU_PAGE_SIZE.
Signed-off-by: default avatarMichael Ellerman <michael@ellerman.id.au>
Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
parent 3d3e6da1
...@@ -113,7 +113,7 @@ ...@@ -113,7 +113,7 @@
/* IOMMU sizing */ /* IOMMU sizing */
#define IO_SEGMENT_SHIFT 28 #define IO_SEGMENT_SHIFT 28
#define IO_PAGENO_BITS (IO_SEGMENT_SHIFT - IOMMU_PAGE_SHIFT) #define IO_PAGENO_BITS(shift) (IO_SEGMENT_SHIFT - (shift))
/* The high bit needs to be set on every DMA address */ /* The high bit needs to be set on every DMA address */
#define SPIDER_DMA_OFFSET 0x80000000ul #define SPIDER_DMA_OFFSET 0x80000000ul
...@@ -328,7 +328,7 @@ static void cell_iommu_setup_stab(struct cbe_iommu *iommu, ...@@ -328,7 +328,7 @@ static void cell_iommu_setup_stab(struct cbe_iommu *iommu,
static unsigned long *cell_iommu_alloc_ptab(struct cbe_iommu *iommu, static unsigned long *cell_iommu_alloc_ptab(struct cbe_iommu *iommu,
unsigned long base, unsigned long size, unsigned long gap_base, unsigned long base, unsigned long size, unsigned long gap_base,
unsigned long gap_size) unsigned long gap_size, unsigned long page_shift)
{ {
struct page *page; struct page *page;
int i; int i;
...@@ -337,7 +337,10 @@ static unsigned long *cell_iommu_alloc_ptab(struct cbe_iommu *iommu, ...@@ -337,7 +337,10 @@ static unsigned long *cell_iommu_alloc_ptab(struct cbe_iommu *iommu,
start_seg = base >> IO_SEGMENT_SHIFT; start_seg = base >> IO_SEGMENT_SHIFT;
segments = size >> IO_SEGMENT_SHIFT; segments = size >> IO_SEGMENT_SHIFT;
pages_per_segment = 1ull << IO_PAGENO_BITS; pages_per_segment = 1ull << IO_PAGENO_BITS(page_shift);
/* PTEs for each segment must start on a 4K bounday */
pages_per_segment = max(pages_per_segment,
(1 << 12) / sizeof(unsigned long));
ptab_size = segments * pages_per_segment * sizeof(unsigned long); ptab_size = segments * pages_per_segment * sizeof(unsigned long);
pr_debug("%s: iommu[%d]: ptab_size: %lu, order: %d\n", __FUNCTION__, pr_debug("%s: iommu[%d]: ptab_size: %lu, order: %d\n", __FUNCTION__,
...@@ -358,13 +361,12 @@ static unsigned long *cell_iommu_alloc_ptab(struct cbe_iommu *iommu, ...@@ -358,13 +361,12 @@ static unsigned long *cell_iommu_alloc_ptab(struct cbe_iommu *iommu,
/* initialise the STEs */ /* initialise the STEs */
reg = IOSTE_V | ((n_pte_pages - 1) << 5); reg = IOSTE_V | ((n_pte_pages - 1) << 5);
if (IOMMU_PAGE_SIZE == 0x1000) switch (page_shift) {
reg |= IOSTE_PS_4K; case 12: reg |= IOSTE_PS_4K; break;
else if (IOMMU_PAGE_SIZE == 0x10000) case 16: reg |= IOSTE_PS_64K; break;
reg |= IOSTE_PS_64K; case 20: reg |= IOSTE_PS_1M; break;
else { case 24: reg |= IOSTE_PS_16M; break;
extern void __unknown_page_size_error(void); default: BUG();
__unknown_page_size_error();
} }
gap_base = gap_base >> IO_SEGMENT_SHIFT; gap_base = gap_base >> IO_SEGMENT_SHIFT;
...@@ -429,7 +431,8 @@ static void cell_iommu_setup_hardware(struct cbe_iommu *iommu, ...@@ -429,7 +431,8 @@ static void cell_iommu_setup_hardware(struct cbe_iommu *iommu,
unsigned long base, unsigned long size) unsigned long base, unsigned long size)
{ {
cell_iommu_setup_stab(iommu, base, size, 0, 0); cell_iommu_setup_stab(iommu, base, size, 0, 0);
iommu->ptab = cell_iommu_alloc_ptab(iommu, base, size, 0, 0); iommu->ptab = cell_iommu_alloc_ptab(iommu, base, size, 0, 0,
IOMMU_PAGE_SHIFT);
cell_iommu_enable_hardware(iommu); cell_iommu_enable_hardware(iommu);
} }
...@@ -886,7 +889,8 @@ static void cell_iommu_setup_fixed_ptab(struct cbe_iommu *iommu, ...@@ -886,7 +889,8 @@ static void cell_iommu_setup_fixed_ptab(struct cbe_iommu *iommu,
int i; int i;
unsigned long base_pte, uaddr, *io_pte, *ptab; unsigned long base_pte, uaddr, *io_pte, *ptab;
ptab = cell_iommu_alloc_ptab(iommu, fbase, fsize, dbase, dsize); ptab = cell_iommu_alloc_ptab(iommu, fbase, fsize, dbase, dsize,
IOMMU_PAGE_SHIFT);
dma_iommu_fixed_base = fbase; dma_iommu_fixed_base = fbase;
...@@ -1008,7 +1012,8 @@ static int __init cell_iommu_fixed_mapping_init(void) ...@@ -1008,7 +1012,8 @@ static int __init cell_iommu_fixed_mapping_init(void)
dbase + dsize, fbase, fbase + fsize); dbase + dsize, fbase, fbase + fsize);
cell_iommu_setup_stab(iommu, dbase, dsize, fbase, fsize); cell_iommu_setup_stab(iommu, dbase, dsize, fbase, fsize);
iommu->ptab = cell_iommu_alloc_ptab(iommu, dbase, dsize, 0, 0); iommu->ptab = cell_iommu_alloc_ptab(iommu, dbase, dsize, 0, 0,
IOMMU_PAGE_SHIFT);
cell_iommu_setup_fixed_ptab(iommu, np, dbase, dsize, cell_iommu_setup_fixed_ptab(iommu, np, dbase, dsize,
fbase, fsize); fbase, fsize);
cell_iommu_enable_hardware(iommu); cell_iommu_enable_hardware(iommu);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment