Lines Matching refs:tbl
48 void pnv_pci_setup_iommu_table(struct iommu_table *tbl, in pnv_pci_setup_iommu_table() argument
52 tbl->it_blocksize = 16; in pnv_pci_setup_iommu_table()
53 tbl->it_base = (unsigned long)tce_mem; in pnv_pci_setup_iommu_table()
54 tbl->it_page_shift = page_shift; in pnv_pci_setup_iommu_table()
55 tbl->it_offset = dma_offset >> tbl->it_page_shift; in pnv_pci_setup_iommu_table()
56 tbl->it_index = 0; in pnv_pci_setup_iommu_table()
57 tbl->it_size = tce_size >> 3; in pnv_pci_setup_iommu_table()
58 tbl->it_busno = 0; in pnv_pci_setup_iommu_table()
59 tbl->it_type = TCE_PCI; in pnv_pci_setup_iommu_table()
83 static __be64 *pnv_tce(struct iommu_table *tbl, bool user, long idx, bool alloc) in pnv_tce() argument
85 __be64 *tmp = user ? tbl->it_userspace : (__be64 *) tbl->it_base; in pnv_tce()
86 int level = tbl->it_indirect_levels; in pnv_tce()
87 const long shift = ilog2(tbl->it_level_size); in pnv_tce()
88 unsigned long mask = (tbl->it_level_size - 1) << (level * shift); in pnv_tce()
100 tmp2 = pnv_alloc_tce_level(tbl->it_nid, in pnv_tce()
101 ilog2(tbl->it_level_size) + 3); in pnv_tce()
110 ilog2(tbl->it_level_size) + 3, 1); in pnv_tce()
124 int pnv_tce_build(struct iommu_table *tbl, long index, long npages, in pnv_tce_build() argument
129 u64 rpn = __pa(uaddr) >> tbl->it_page_shift; in pnv_tce_build()
137 ((rpn + i) << tbl->it_page_shift); in pnv_tce_build()
138 unsigned long idx = index - tbl->it_offset + i; in pnv_tce_build()
140 *(pnv_tce(tbl, false, idx, true)) = cpu_to_be64(newtce); in pnv_tce_build()
147 int pnv_tce_xchg(struct iommu_table *tbl, long index, in pnv_tce_xchg() argument
153 unsigned long idx = index - tbl->it_offset; in pnv_tce_xchg()
156 BUG_ON(*hpa & ~IOMMU_PAGE_MASK(tbl)); in pnv_tce_xchg()
159 ptce = pnv_tce(tbl, false, idx, false); in pnv_tce_xchg()
167 ptce = pnv_tce(tbl, false, idx, alloc); in pnv_tce_xchg()
182 __be64 *pnv_tce_useraddrptr(struct iommu_table *tbl, long index, bool alloc) in pnv_tce_useraddrptr() argument
184 if (WARN_ON_ONCE(!tbl->it_userspace)) in pnv_tce_useraddrptr()
187 return pnv_tce(tbl, true, index - tbl->it_offset, alloc); in pnv_tce_useraddrptr()
191 void pnv_tce_free(struct iommu_table *tbl, long index, long npages) in pnv_tce_free() argument
196 unsigned long idx = index - tbl->it_offset + i; in pnv_tce_free()
197 __be64 *ptce = pnv_tce(tbl, false, idx, false); in pnv_tce_free()
203 i |= tbl->it_level_size - 1; in pnv_tce_free()
207 unsigned long pnv_tce_get(struct iommu_table *tbl, long index) in pnv_tce_get() argument
209 __be64 *ptce = pnv_tce(tbl, false, index - tbl->it_offset, false); in pnv_tce_get()
241 void pnv_pci_ioda2_table_free_pages(struct iommu_table *tbl) in pnv_pci_ioda2_table_free_pages() argument
243 const unsigned long size = tbl->it_indirect_levels ? in pnv_pci_ioda2_table_free_pages()
244 tbl->it_level_size : tbl->it_size; in pnv_pci_ioda2_table_free_pages()
246 if (!tbl->it_size) in pnv_pci_ioda2_table_free_pages()
249 pnv_pci_ioda2_table_do_free_pages((__be64 *)tbl->it_base, size, in pnv_pci_ioda2_table_free_pages()
250 tbl->it_indirect_levels); in pnv_pci_ioda2_table_free_pages()
251 if (tbl->it_userspace) { in pnv_pci_ioda2_table_free_pages()
252 pnv_pci_ioda2_table_do_free_pages(tbl->it_userspace, size, in pnv_pci_ioda2_table_free_pages()
253 tbl->it_indirect_levels); in pnv_pci_ioda2_table_free_pages()
293 bool alloc_userspace_copy, struct iommu_table *tbl) in pnv_pci_ioda2_table_alloc_pages() argument
348 pnv_pci_setup_iommu_table(tbl, addr, tce_table_size, bus_offset, in pnv_pci_ioda2_table_alloc_pages()
350 tbl->it_level_size = 1ULL << (level_shift - 3); in pnv_pci_ioda2_table_alloc_pages()
351 tbl->it_indirect_levels = levels - 1; in pnv_pci_ioda2_table_alloc_pages()
352 tbl->it_userspace = uas; in pnv_pci_ioda2_table_alloc_pages()
353 tbl->it_nid = nid; in pnv_pci_ioda2_table_alloc_pages()
356 window_size, tce_table_size, bus_offset, tbl->it_base, in pnv_pci_ioda2_table_alloc_pages()
357 tbl->it_userspace, 1, levels); in pnv_pci_ioda2_table_alloc_pages()
371 void pnv_pci_unlink_table_and_group(struct iommu_table *tbl, in pnv_pci_unlink_table_and_group() argument
378 if (!tbl || !table_group) in pnv_pci_unlink_table_and_group()
385 list_for_each_entry_rcu(tgl, &tbl->it_group_list, next) { in pnv_pci_unlink_table_and_group()
401 if (table_group->tables[i] == tbl) { in pnv_pci_unlink_table_and_group()
402 iommu_tce_table_put(tbl); in pnv_pci_unlink_table_and_group()
412 struct iommu_table *tbl, in pnv_pci_link_table_and_group() argument
417 if (WARN_ON(!tbl || !table_group)) in pnv_pci_link_table_and_group()
426 list_add_rcu(&tgl->next, &tbl->it_group_list); in pnv_pci_link_table_and_group()
428 table_group->tables[num] = iommu_tce_table_get(tbl); in pnv_pci_link_table_and_group()