Commit f39f8d0e authored by Christoph Hellwig's avatar Christoph Hellwig

MIPS/octeon: use swiotlb_init instead of open coding it

Use the generic swiotlb initialization helper instead of open coding it.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Acked-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
Reviewed-by: default avatarKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Tested-by: default avatarBoris Ostrovsky <boris.ostrovsky@oracle.com>
parent 9bbe7a7f
...@@ -186,15 +186,12 @@ phys_addr_t dma_to_phys(struct device *dev, dma_addr_t daddr) ...@@ -186,15 +186,12 @@ phys_addr_t dma_to_phys(struct device *dev, dma_addr_t daddr)
return daddr; return daddr;
} }
char *octeon_swiotlb;
void __init plat_swiotlb_setup(void) void __init plat_swiotlb_setup(void)
{ {
phys_addr_t start, end; phys_addr_t start, end;
phys_addr_t max_addr; phys_addr_t max_addr;
phys_addr_t addr_size; phys_addr_t addr_size;
size_t swiotlbsize; size_t swiotlbsize;
unsigned long swiotlb_nslabs;
u64 i; u64 i;
max_addr = 0; max_addr = 0;
...@@ -236,15 +233,7 @@ void __init plat_swiotlb_setup(void) ...@@ -236,15 +233,7 @@ void __init plat_swiotlb_setup(void)
if (OCTEON_IS_OCTEON2() && max_addr >= 0x100000000ul) if (OCTEON_IS_OCTEON2() && max_addr >= 0x100000000ul)
swiotlbsize = 64 * (1<<20); swiotlbsize = 64 * (1<<20);
#endif #endif
swiotlb_nslabs = swiotlbsize >> IO_TLB_SHIFT;
swiotlb_nslabs = ALIGN(swiotlb_nslabs, IO_TLB_SEGSIZE);
swiotlbsize = swiotlb_nslabs << IO_TLB_SHIFT;
octeon_swiotlb = memblock_alloc_low(swiotlbsize, PAGE_SIZE);
if (!octeon_swiotlb)
panic("%s: Failed to allocate %zu bytes align=%lx\n",
__func__, swiotlbsize, PAGE_SIZE);
if (swiotlb_init_with_tbl(octeon_swiotlb, swiotlb_nslabs, 1) == -ENOMEM) swiotlb_adjust_size(swiotlbsize);
panic("Cannot allocate SWIOTLB buffer"); swiotlb_init(1);
} }
...@@ -664,7 +664,7 @@ static int __init octeon_pci_setup(void) ...@@ -664,7 +664,7 @@ static int __init octeon_pci_setup(void)
/* BAR1 movable regions contiguous to cover the swiotlb */ /* BAR1 movable regions contiguous to cover the swiotlb */
octeon_bar1_pci_phys = octeon_bar1_pci_phys =
virt_to_phys(octeon_swiotlb) & ~((1ull << 22) - 1); io_tlb_default_mem.start & ~((1ull << 22) - 1);
for (index = 0; index < 32; index++) { for (index = 0; index < 32; index++) {
union cvmx_pci_bar1_indexx bar1_index; union cvmx_pci_bar1_indexx bar1_index;
......
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