diff options
author | Alistair Popple <alistair@popple.id.au> | 2013-12-09 02:17:02 -0500 |
---|---|---|
committer | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2013-12-29 22:17:13 -0500 |
commit | 3a553170d35d69bea3877bffa508489dfa6f133d (patch) | |
tree | 9cb5b53ea4a60e10c9cfe2644f35a9fe4673d050 | |
parent | e589a4404fa06730355de204d3d136ed9bbc7dea (diff) |
powerpc/iommu: Add it_page_shift field to determine iommu page size
This patch adds a it_page_shift field to struct iommu_table and
initiliases it to 4K for all platforms.
Signed-off-by: Alistair Popple <alistair@popple.id.au>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
-rw-r--r-- | arch/powerpc/include/asm/iommu.h | 1 | ||||
-rw-r--r-- | arch/powerpc/kernel/vio.c | 5 | ||||
-rw-r--r-- | arch/powerpc/platforms/cell/iommu.c | 8 | ||||
-rw-r--r-- | arch/powerpc/platforms/pasemi/iommu.c | 5 | ||||
-rw-r--r-- | arch/powerpc/platforms/powernv/pci.c | 3 | ||||
-rw-r--r-- | arch/powerpc/platforms/pseries/iommu.c | 10 | ||||
-rw-r--r-- | arch/powerpc/platforms/wsp/wsp_pci.c | 5 |
7 files changed, 24 insertions, 13 deletions
diff --git a/arch/powerpc/include/asm/iommu.h b/arch/powerpc/include/asm/iommu.h index 0869c7e74421..7c928342f3f5 100644 --- a/arch/powerpc/include/asm/iommu.h +++ b/arch/powerpc/include/asm/iommu.h | |||
@@ -76,6 +76,7 @@ struct iommu_table { | |||
76 | struct iommu_pool large_pool; | 76 | struct iommu_pool large_pool; |
77 | struct iommu_pool pools[IOMMU_NR_POOLS]; | 77 | struct iommu_pool pools[IOMMU_NR_POOLS]; |
78 | unsigned long *it_map; /* A simple allocation bitmap for now */ | 78 | unsigned long *it_map; /* A simple allocation bitmap for now */ |
79 | unsigned long it_page_shift;/* table iommu page size */ | ||
79 | #ifdef CONFIG_IOMMU_API | 80 | #ifdef CONFIG_IOMMU_API |
80 | struct iommu_group *it_group; | 81 | struct iommu_group *it_group; |
81 | #endif | 82 | #endif |
diff --git a/arch/powerpc/kernel/vio.c b/arch/powerpc/kernel/vio.c index 2e89fa350763..170ac24a0106 100644 --- a/arch/powerpc/kernel/vio.c +++ b/arch/powerpc/kernel/vio.c | |||
@@ -1177,9 +1177,10 @@ static struct iommu_table *vio_build_iommu_table(struct vio_dev *dev) | |||
1177 | &tbl->it_index, &offset, &size); | 1177 | &tbl->it_index, &offset, &size); |
1178 | 1178 | ||
1179 | /* TCE table size - measured in tce entries */ | 1179 | /* TCE table size - measured in tce entries */ |
1180 | tbl->it_size = size >> IOMMU_PAGE_SHIFT_4K; | 1180 | tbl->it_page_shift = IOMMU_PAGE_SHIFT_4K; |
1181 | tbl->it_size = size >> tbl->it_page_shift; | ||
1181 | /* offset for VIO should always be 0 */ | 1182 | /* offset for VIO should always be 0 */ |
1182 | tbl->it_offset = offset >> IOMMU_PAGE_SHIFT_4K; | 1183 | tbl->it_offset = offset >> tbl->it_page_shift; |
1183 | tbl->it_busno = 0; | 1184 | tbl->it_busno = 0; |
1184 | tbl->it_type = TCE_VB; | 1185 | tbl->it_type = TCE_VB; |
1185 | tbl->it_blocksize = 16; | 1186 | tbl->it_blocksize = 16; |
diff --git a/arch/powerpc/platforms/cell/iommu.c b/arch/powerpc/platforms/cell/iommu.c index fc61b908eaf0..2b90ff8a93be 100644 --- a/arch/powerpc/platforms/cell/iommu.c +++ b/arch/powerpc/platforms/cell/iommu.c | |||
@@ -197,7 +197,7 @@ static int tce_build_cell(struct iommu_table *tbl, long index, long npages, | |||
197 | 197 | ||
198 | io_pte = (unsigned long *)tbl->it_base + (index - tbl->it_offset); | 198 | io_pte = (unsigned long *)tbl->it_base + (index - tbl->it_offset); |
199 | 199 | ||
200 | for (i = 0; i < npages; i++, uaddr += IOMMU_PAGE_SIZE_4K) | 200 | for (i = 0; i < npages; i++, uaddr += tbl->it_page_shift) |
201 | io_pte[i] = base_pte | (__pa(uaddr) & CBE_IOPTE_RPN_Mask); | 201 | io_pte[i] = base_pte | (__pa(uaddr) & CBE_IOPTE_RPN_Mask); |
202 | 202 | ||
203 | mb(); | 203 | mb(); |
@@ -487,8 +487,10 @@ cell_iommu_setup_window(struct cbe_iommu *iommu, struct device_node *np, | |||
487 | window->table.it_blocksize = 16; | 487 | window->table.it_blocksize = 16; |
488 | window->table.it_base = (unsigned long)iommu->ptab; | 488 | window->table.it_base = (unsigned long)iommu->ptab; |
489 | window->table.it_index = iommu->nid; | 489 | window->table.it_index = iommu->nid; |
490 | window->table.it_offset = (offset >> IOMMU_PAGE_SHIFT_4K) + pte_offset; | 490 | window->table.it_page_shift = IOMMU_PAGE_SHIFT_4K; |
491 | window->table.it_size = size >> IOMMU_PAGE_SHIFT_4K; | 491 | window->table.it_offset = |
492 | (offset >> window->table.it_page_shift) + pte_offset; | ||
493 | window->table.it_size = size >> window->table.it_page_shift; | ||
492 | 494 | ||
493 | iommu_init_table(&window->table, iommu->nid); | 495 | iommu_init_table(&window->table, iommu->nid); |
494 | 496 | ||
diff --git a/arch/powerpc/platforms/pasemi/iommu.c b/arch/powerpc/platforms/pasemi/iommu.c index 7d2d036754b5..2e576f2ae442 100644 --- a/arch/powerpc/platforms/pasemi/iommu.c +++ b/arch/powerpc/platforms/pasemi/iommu.c | |||
@@ -138,8 +138,11 @@ static void iommu_table_iobmap_setup(void) | |||
138 | pr_debug(" -> %s\n", __func__); | 138 | pr_debug(" -> %s\n", __func__); |
139 | iommu_table_iobmap.it_busno = 0; | 139 | iommu_table_iobmap.it_busno = 0; |
140 | iommu_table_iobmap.it_offset = 0; | 140 | iommu_table_iobmap.it_offset = 0; |
141 | iommu_table_iobmap.it_page_shift = IOBMAP_PAGE_SHIFT; | ||
142 | |||
141 | /* it_size is in number of entries */ | 143 | /* it_size is in number of entries */ |
142 | iommu_table_iobmap.it_size = 0x80000000 >> IOBMAP_PAGE_SHIFT; | 144 | iommu_table_iobmap.it_size = |
145 | 0x80000000 >> iommu_table_iobmap.it_page_shift; | ||
143 | 146 | ||
144 | /* Initialize the common IOMMU code */ | 147 | /* Initialize the common IOMMU code */ |
145 | iommu_table_iobmap.it_base = (unsigned long)iob_l2_base; | 148 | iommu_table_iobmap.it_base = (unsigned long)iob_l2_base; |
diff --git a/arch/powerpc/platforms/powernv/pci.c b/arch/powerpc/platforms/powernv/pci.c index 7f4d857668a9..569b46423a93 100644 --- a/arch/powerpc/platforms/powernv/pci.c +++ b/arch/powerpc/platforms/powernv/pci.c | |||
@@ -564,7 +564,8 @@ void pnv_pci_setup_iommu_table(struct iommu_table *tbl, | |||
564 | { | 564 | { |
565 | tbl->it_blocksize = 16; | 565 | tbl->it_blocksize = 16; |
566 | tbl->it_base = (unsigned long)tce_mem; | 566 | tbl->it_base = (unsigned long)tce_mem; |
567 | tbl->it_offset = dma_offset >> IOMMU_PAGE_SHIFT_4K; | 567 | tbl->it_page_shift = IOMMU_PAGE_SHIFT_4K; |
568 | tbl->it_offset = dma_offset >> tbl->it_page_shift; | ||
568 | tbl->it_index = 0; | 569 | tbl->it_index = 0; |
569 | tbl->it_size = tce_size >> 3; | 570 | tbl->it_size = tce_size >> 3; |
570 | tbl->it_busno = 0; | 571 | tbl->it_busno = 0; |
diff --git a/arch/powerpc/platforms/pseries/iommu.c b/arch/powerpc/platforms/pseries/iommu.c index 1b7531ce0c0c..e0299183ae54 100644 --- a/arch/powerpc/platforms/pseries/iommu.c +++ b/arch/powerpc/platforms/pseries/iommu.c | |||
@@ -486,9 +486,10 @@ static void iommu_table_setparms(struct pci_controller *phb, | |||
486 | memset((void *)tbl->it_base, 0, *sizep); | 486 | memset((void *)tbl->it_base, 0, *sizep); |
487 | 487 | ||
488 | tbl->it_busno = phb->bus->number; | 488 | tbl->it_busno = phb->bus->number; |
489 | tbl->it_page_shift = IOMMU_PAGE_SHIFT_4K; | ||
489 | 490 | ||
490 | /* Units of tce entries */ | 491 | /* Units of tce entries */ |
491 | tbl->it_offset = phb->dma_window_base_cur >> IOMMU_PAGE_SHIFT_4K; | 492 | tbl->it_offset = phb->dma_window_base_cur >> tbl->it_page_shift; |
492 | 493 | ||
493 | /* Test if we are going over 2GB of DMA space */ | 494 | /* Test if we are going over 2GB of DMA space */ |
494 | if (phb->dma_window_base_cur + phb->dma_window_size > 0x80000000ul) { | 495 | if (phb->dma_window_base_cur + phb->dma_window_size > 0x80000000ul) { |
@@ -499,7 +500,7 @@ static void iommu_table_setparms(struct pci_controller *phb, | |||
499 | phb->dma_window_base_cur += phb->dma_window_size; | 500 | phb->dma_window_base_cur += phb->dma_window_size; |
500 | 501 | ||
501 | /* Set the tce table size - measured in entries */ | 502 | /* Set the tce table size - measured in entries */ |
502 | tbl->it_size = phb->dma_window_size >> IOMMU_PAGE_SHIFT_4K; | 503 | tbl->it_size = phb->dma_window_size >> tbl->it_page_shift; |
503 | 504 | ||
504 | tbl->it_index = 0; | 505 | tbl->it_index = 0; |
505 | tbl->it_blocksize = 16; | 506 | tbl->it_blocksize = 16; |
@@ -537,11 +538,12 @@ static void iommu_table_setparms_lpar(struct pci_controller *phb, | |||
537 | of_parse_dma_window(dn, dma_window, &tbl->it_index, &offset, &size); | 538 | of_parse_dma_window(dn, dma_window, &tbl->it_index, &offset, &size); |
538 | 539 | ||
539 | tbl->it_busno = phb->bus->number; | 540 | tbl->it_busno = phb->bus->number; |
541 | tbl->it_page_shift = IOMMU_PAGE_SHIFT_4K; | ||
540 | tbl->it_base = 0; | 542 | tbl->it_base = 0; |
541 | tbl->it_blocksize = 16; | 543 | tbl->it_blocksize = 16; |
542 | tbl->it_type = TCE_PCI; | 544 | tbl->it_type = TCE_PCI; |
543 | tbl->it_offset = offset >> IOMMU_PAGE_SHIFT_4K; | 545 | tbl->it_offset = offset >> tbl->it_page_shift; |
544 | tbl->it_size = size >> IOMMU_PAGE_SHIFT_4K; | 546 | tbl->it_size = size >> tbl->it_page_shift; |
545 | } | 547 | } |
546 | 548 | ||
547 | static void pci_dma_bus_setup_pSeries(struct pci_bus *bus) | 549 | static void pci_dma_bus_setup_pSeries(struct pci_bus *bus) |
diff --git a/arch/powerpc/platforms/wsp/wsp_pci.c b/arch/powerpc/platforms/wsp/wsp_pci.c index 8a589618551e..9a15e5b39bb8 100644 --- a/arch/powerpc/platforms/wsp/wsp_pci.c +++ b/arch/powerpc/platforms/wsp/wsp_pci.c | |||
@@ -381,8 +381,9 @@ static struct wsp_dma_table *wsp_pci_create_dma32_table(struct wsp_phb *phb, | |||
381 | 381 | ||
382 | /* Init bits and pieces */ | 382 | /* Init bits and pieces */ |
383 | tbl->table.it_blocksize = 16; | 383 | tbl->table.it_blocksize = 16; |
384 | tbl->table.it_offset = addr >> IOMMU_PAGE_SHIFT_4K; | 384 | tbl->table.it_page_shift = IOMMU_PAGE_SHIFT_4K; |
385 | tbl->table.it_size = size >> IOMMU_PAGE_SHIFT_4K; | 385 | tbl->table.it_offset = addr >> tbl->table.it_page_shift; |
386 | tbl->table.it_size = size >> tbl->table.it_page_shift; | ||
386 | 387 | ||
387 | /* | 388 | /* |
388 | * It's already blank but we clear it anyway. | 389 | * It's already blank but we clear it anyway. |