powerpc/powernv: Implement accessor to TCE entry
This replaces direct accesses to TCE table with a helper which returns an TCE entry address. This does not make difference now but will when multi-level TCE tables get introduces. No change in behavior is expected. Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru> Reviewed-by: David Gibson <david@gibson.dropbear.id.au> Reviewed-by: Gavin Shan <gwshan@linux.vnet.ibm.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
This commit is contained in:
parent
e57080f17d
commit
c5bb44edee
1 changed files with 21 additions and 13 deletions
|
@ -572,38 +572,46 @@ struct pci_ops pnv_pci_ops = {
|
||||||
.write = pnv_pci_write_config,
|
.write = pnv_pci_write_config,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static __be64 *pnv_tce(struct iommu_table *tbl, long idx)
|
||||||
|
{
|
||||||
|
__be64 *tmp = ((__be64 *)tbl->it_base);
|
||||||
|
|
||||||
|
return tmp + idx;
|
||||||
|
}
|
||||||
|
|
||||||
int pnv_tce_build(struct iommu_table *tbl, long index, long npages,
|
int pnv_tce_build(struct iommu_table *tbl, long index, long npages,
|
||||||
unsigned long uaddr, enum dma_data_direction direction,
|
unsigned long uaddr, enum dma_data_direction direction,
|
||||||
struct dma_attrs *attrs)
|
struct dma_attrs *attrs)
|
||||||
{
|
{
|
||||||
u64 proto_tce = iommu_direction_to_tce_perm(direction);
|
u64 proto_tce = iommu_direction_to_tce_perm(direction);
|
||||||
__be64 *tcep;
|
u64 rpn = __pa(uaddr) >> tbl->it_page_shift;
|
||||||
u64 rpn;
|
long i;
|
||||||
|
|
||||||
tcep = ((__be64 *)tbl->it_base) + index - tbl->it_offset;
|
for (i = 0; i < npages; i++) {
|
||||||
rpn = __pa(uaddr) >> tbl->it_page_shift;
|
unsigned long newtce = proto_tce |
|
||||||
|
((rpn + i) << tbl->it_page_shift);
|
||||||
while (npages--)
|
unsigned long idx = index - tbl->it_offset + i;
|
||||||
*(tcep++) = cpu_to_be64(proto_tce |
|
|
||||||
(rpn++ << tbl->it_page_shift));
|
|
||||||
|
|
||||||
|
*(pnv_tce(tbl, idx)) = cpu_to_be64(newtce);
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void pnv_tce_free(struct iommu_table *tbl, long index, long npages)
|
void pnv_tce_free(struct iommu_table *tbl, long index, long npages)
|
||||||
{
|
{
|
||||||
__be64 *tcep;
|
long i;
|
||||||
|
|
||||||
tcep = ((__be64 *)tbl->it_base) + index - tbl->it_offset;
|
for (i = 0; i < npages; i++) {
|
||||||
|
unsigned long idx = index - tbl->it_offset + i;
|
||||||
|
|
||||||
while (npages--)
|
*(pnv_tce(tbl, idx)) = cpu_to_be64(0);
|
||||||
*(tcep++) = cpu_to_be64(0);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long pnv_tce_get(struct iommu_table *tbl, long index)
|
unsigned long pnv_tce_get(struct iommu_table *tbl, long index)
|
||||||
{
|
{
|
||||||
return ((u64 *)tbl->it_base)[index - tbl->it_offset];
|
return *(pnv_tce(tbl, index - tbl->it_offset));
|
||||||
}
|
}
|
||||||
|
|
||||||
struct iommu_table *pnv_pci_table_alloc(int nid)
|
struct iommu_table *pnv_pci_table_alloc(int nid)
|
||||||
|
|
Loading…
Add table
Reference in a new issue