aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/powerpc/platforms/cell/iommu.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/arch/powerpc/platforms/cell/iommu.c b/arch/powerpc/platforms/cell/iommu.c
index a6e6bc1b020f..950d4327b41e 100644
--- a/arch/powerpc/platforms/cell/iommu.c
+++ b/arch/powerpc/platforms/cell/iommu.c
@@ -307,14 +307,19 @@ static int cell_iommu_find_ioc(int nid, unsigned long *base)
307} 307}
308 308
309static void cell_iommu_setup_page_tables(struct cbe_iommu *iommu, 309static void cell_iommu_setup_page_tables(struct cbe_iommu *iommu,
310 unsigned long base, unsigned long size) 310 unsigned long dbase, unsigned long dsize,
311 unsigned long fbase, unsigned long fsize)
311{ 312{
312 struct page *page; 313 struct page *page;
313 int i; 314 int i;
314 unsigned long reg, segments, pages_per_segment, ptab_size, stab_size, 315 unsigned long reg, segments, pages_per_segment, ptab_size, stab_size,
315 n_pte_pages; 316 n_pte_pages, base;
316 317
317 segments = size >> IO_SEGMENT_SHIFT; 318 base = dbase;
319 if (fsize != 0)
320 base = min(fbase, dbase);
321
322 segments = max(dbase + dsize, fbase + fsize) >> IO_SEGMENT_SHIFT;
318 pages_per_segment = 1ull << IO_PAGENO_BITS; 323 pages_per_segment = 1ull << IO_PAGENO_BITS;
319 324
320 pr_debug("%s: iommu[%d]: segments: %lu, pages per segment: %lu\n", 325 pr_debug("%s: iommu[%d]: segments: %lu, pages per segment: %lu\n",
@@ -366,7 +371,7 @@ static void cell_iommu_setup_page_tables(struct cbe_iommu *iommu,
366 } 371 }
367 372
368 pr_debug("Setting up IOMMU stab:\n"); 373 pr_debug("Setting up IOMMU stab:\n");
369 for (i = 0; i * (1ul << IO_SEGMENT_SHIFT) < size; i++) { 374 for (i = base >> IO_SEGMENT_SHIFT; i < segments; i++) {
370 iommu->stab[i] = reg | 375 iommu->stab[i] = reg |
371 (__pa(iommu->ptab) + n_pte_pages * IOMMU_PAGE_SIZE * i); 376 (__pa(iommu->ptab) + n_pte_pages * IOMMU_PAGE_SIZE * i);
372 pr_debug("\t[%d] 0x%016lx\n", i, iommu->stab[i]); 377 pr_debug("\t[%d] 0x%016lx\n", i, iommu->stab[i]);
@@ -417,7 +422,7 @@ static void cell_iommu_enable_hardware(struct cbe_iommu *iommu)
417static void cell_iommu_setup_hardware(struct cbe_iommu *iommu, 422static void cell_iommu_setup_hardware(struct cbe_iommu *iommu,
418 unsigned long base, unsigned long size) 423 unsigned long base, unsigned long size)
419{ 424{
420 cell_iommu_setup_page_tables(iommu, base, size); 425 cell_iommu_setup_page_tables(iommu, base, size, 0, 0);
421 cell_iommu_enable_hardware(iommu); 426 cell_iommu_enable_hardware(iommu);
422} 427}
423 428