Commit 3a553170 authored by Alistair Popple's avatar Alistair Popple Committed by Benjamin Herrenschmidt

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: default avatarAlistair Popple <alistair@popple.id.au>
Signed-off-by: default avatarBenjamin Herrenschmidt <benh@kernel.crashing.org>
parent e589a440
...@@ -76,6 +76,7 @@ struct iommu_table { ...@@ -76,6 +76,7 @@ struct iommu_table {
struct iommu_pool large_pool; struct iommu_pool large_pool;
struct iommu_pool pools[IOMMU_NR_POOLS]; struct iommu_pool pools[IOMMU_NR_POOLS];
unsigned long *it_map; /* A simple allocation bitmap for now */ unsigned long *it_map; /* A simple allocation bitmap for now */
unsigned long it_page_shift;/* table iommu page size */
#ifdef CONFIG_IOMMU_API #ifdef CONFIG_IOMMU_API
struct iommu_group *it_group; struct iommu_group *it_group;
#endif #endif
......
...@@ -1177,9 +1177,10 @@ static struct iommu_table *vio_build_iommu_table(struct vio_dev *dev) ...@@ -1177,9 +1177,10 @@ static struct iommu_table *vio_build_iommu_table(struct vio_dev *dev)
&tbl->it_index, &offset, &size); &tbl->it_index, &offset, &size);
/* TCE table size - measured in tce entries */ /* TCE table size - measured in tce entries */
tbl->it_size = size >> IOMMU_PAGE_SHIFT_4K; tbl->it_page_shift = IOMMU_PAGE_SHIFT_4K;
tbl->it_size = size >> tbl->it_page_shift;
/* offset for VIO should always be 0 */ /* offset for VIO should always be 0 */
tbl->it_offset = offset >> IOMMU_PAGE_SHIFT_4K; tbl->it_offset = offset >> tbl->it_page_shift;
tbl->it_busno = 0; tbl->it_busno = 0;
tbl->it_type = TCE_VB; tbl->it_type = TCE_VB;
tbl->it_blocksize = 16; tbl->it_blocksize = 16;
......
...@@ -197,7 +197,7 @@ static int tce_build_cell(struct iommu_table *tbl, long index, long npages, ...@@ -197,7 +197,7 @@ static int tce_build_cell(struct iommu_table *tbl, long index, long npages,
io_pte = (unsigned long *)tbl->it_base + (index - tbl->it_offset); io_pte = (unsigned long *)tbl->it_base + (index - tbl->it_offset);
for (i = 0; i < npages; i++, uaddr += IOMMU_PAGE_SIZE_4K) for (i = 0; i < npages; i++, uaddr += tbl->it_page_shift)
io_pte[i] = base_pte | (__pa(uaddr) & CBE_IOPTE_RPN_Mask); io_pte[i] = base_pte | (__pa(uaddr) & CBE_IOPTE_RPN_Mask);
mb(); mb();
...@@ -487,8 +487,10 @@ cell_iommu_setup_window(struct cbe_iommu *iommu, struct device_node *np, ...@@ -487,8 +487,10 @@ cell_iommu_setup_window(struct cbe_iommu *iommu, struct device_node *np,
window->table.it_blocksize = 16; window->table.it_blocksize = 16;
window->table.it_base = (unsigned long)iommu->ptab; window->table.it_base = (unsigned long)iommu->ptab;
window->table.it_index = iommu->nid; window->table.it_index = iommu->nid;
window->table.it_offset = (offset >> IOMMU_PAGE_SHIFT_4K) + pte_offset; window->table.it_page_shift = IOMMU_PAGE_SHIFT_4K;
window->table.it_size = size >> IOMMU_PAGE_SHIFT_4K; window->table.it_offset =
(offset >> window->table.it_page_shift) + pte_offset;
window->table.it_size = size >> window->table.it_page_shift;
iommu_init_table(&window->table, iommu->nid); iommu_init_table(&window->table, iommu->nid);
......
...@@ -138,8 +138,11 @@ static void iommu_table_iobmap_setup(void) ...@@ -138,8 +138,11 @@ static void iommu_table_iobmap_setup(void)
pr_debug(" -> %s\n", __func__); pr_debug(" -> %s\n", __func__);
iommu_table_iobmap.it_busno = 0; iommu_table_iobmap.it_busno = 0;
iommu_table_iobmap.it_offset = 0; iommu_table_iobmap.it_offset = 0;
iommu_table_iobmap.it_page_shift = IOBMAP_PAGE_SHIFT;
/* it_size is in number of entries */ /* it_size is in number of entries */
iommu_table_iobmap.it_size = 0x80000000 >> IOBMAP_PAGE_SHIFT; iommu_table_iobmap.it_size =
0x80000000 >> iommu_table_iobmap.it_page_shift;
/* Initialize the common IOMMU code */ /* Initialize the common IOMMU code */
iommu_table_iobmap.it_base = (unsigned long)iob_l2_base; iommu_table_iobmap.it_base = (unsigned long)iob_l2_base;
......
...@@ -564,7 +564,8 @@ void pnv_pci_setup_iommu_table(struct iommu_table *tbl, ...@@ -564,7 +564,8 @@ void pnv_pci_setup_iommu_table(struct iommu_table *tbl,
{ {
tbl->it_blocksize = 16; tbl->it_blocksize = 16;
tbl->it_base = (unsigned long)tce_mem; tbl->it_base = (unsigned long)tce_mem;
tbl->it_offset = dma_offset >> IOMMU_PAGE_SHIFT_4K; tbl->it_page_shift = IOMMU_PAGE_SHIFT_4K;
tbl->it_offset = dma_offset >> tbl->it_page_shift;
tbl->it_index = 0; tbl->it_index = 0;
tbl->it_size = tce_size >> 3; tbl->it_size = tce_size >> 3;
tbl->it_busno = 0; tbl->it_busno = 0;
......
...@@ -486,9 +486,10 @@ static void iommu_table_setparms(struct pci_controller *phb, ...@@ -486,9 +486,10 @@ static void iommu_table_setparms(struct pci_controller *phb,
memset((void *)tbl->it_base, 0, *sizep); memset((void *)tbl->it_base, 0, *sizep);
tbl->it_busno = phb->bus->number; tbl->it_busno = phb->bus->number;
tbl->it_page_shift = IOMMU_PAGE_SHIFT_4K;
/* Units of tce entries */ /* Units of tce entries */
tbl->it_offset = phb->dma_window_base_cur >> IOMMU_PAGE_SHIFT_4K; tbl->it_offset = phb->dma_window_base_cur >> tbl->it_page_shift;
/* Test if we are going over 2GB of DMA space */ /* Test if we are going over 2GB of DMA space */
if (phb->dma_window_base_cur + phb->dma_window_size > 0x80000000ul) { 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,7 +500,7 @@ static void iommu_table_setparms(struct pci_controller *phb,
phb->dma_window_base_cur += phb->dma_window_size; phb->dma_window_base_cur += phb->dma_window_size;
/* Set the tce table size - measured in entries */ /* Set the tce table size - measured in entries */
tbl->it_size = phb->dma_window_size >> IOMMU_PAGE_SHIFT_4K; tbl->it_size = phb->dma_window_size >> tbl->it_page_shift;
tbl->it_index = 0; tbl->it_index = 0;
tbl->it_blocksize = 16; tbl->it_blocksize = 16;
...@@ -537,11 +538,12 @@ static void iommu_table_setparms_lpar(struct pci_controller *phb, ...@@ -537,11 +538,12 @@ static void iommu_table_setparms_lpar(struct pci_controller *phb,
of_parse_dma_window(dn, dma_window, &tbl->it_index, &offset, &size); of_parse_dma_window(dn, dma_window, &tbl->it_index, &offset, &size);
tbl->it_busno = phb->bus->number; tbl->it_busno = phb->bus->number;
tbl->it_page_shift = IOMMU_PAGE_SHIFT_4K;
tbl->it_base = 0; tbl->it_base = 0;
tbl->it_blocksize = 16; tbl->it_blocksize = 16;
tbl->it_type = TCE_PCI; tbl->it_type = TCE_PCI;
tbl->it_offset = offset >> IOMMU_PAGE_SHIFT_4K; tbl->it_offset = offset >> tbl->it_page_shift;
tbl->it_size = size >> IOMMU_PAGE_SHIFT_4K; tbl->it_size = size >> tbl->it_page_shift;
} }
static void pci_dma_bus_setup_pSeries(struct pci_bus *bus) static void pci_dma_bus_setup_pSeries(struct pci_bus *bus)
......
...@@ -381,8 +381,9 @@ static struct wsp_dma_table *wsp_pci_create_dma32_table(struct wsp_phb *phb, ...@@ -381,8 +381,9 @@ static struct wsp_dma_table *wsp_pci_create_dma32_table(struct wsp_phb *phb,
/* Init bits and pieces */ /* Init bits and pieces */
tbl->table.it_blocksize = 16; tbl->table.it_blocksize = 16;
tbl->table.it_offset = addr >> IOMMU_PAGE_SHIFT_4K; tbl->table.it_page_shift = IOMMU_PAGE_SHIFT_4K;
tbl->table.it_size = size >> IOMMU_PAGE_SHIFT_4K; tbl->table.it_offset = addr >> tbl->table.it_page_shift;
tbl->table.it_size = size >> tbl->table.it_page_shift;
/* /*
* It's already blank but we clear it anyway. * It's already blank but we clear it anyway.
......
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