.. | .. |
---|
11 | 11 | * Copyright (C) 2010 Cavium Networks, Inc. |
---|
12 | 12 | */ |
---|
13 | 13 | #include <linux/dma-direct.h> |
---|
14 | | -#include <linux/bootmem.h> |
---|
| 14 | +#include <linux/memblock.h> |
---|
15 | 15 | #include <linux/swiotlb.h> |
---|
16 | 16 | #include <linux/types.h> |
---|
17 | 17 | #include <linux/init.h> |
---|
.. | .. |
---|
168 | 168 | } |
---|
169 | 169 | #endif /* CONFIG_PCI */ |
---|
170 | 170 | |
---|
171 | | -dma_addr_t __phys_to_dma(struct device *dev, phys_addr_t paddr) |
---|
| 171 | +dma_addr_t phys_to_dma(struct device *dev, phys_addr_t paddr) |
---|
172 | 172 | { |
---|
173 | 173 | #ifdef CONFIG_PCI |
---|
174 | 174 | if (dev && dev_is_pci(dev)) |
---|
.. | .. |
---|
177 | 177 | return paddr; |
---|
178 | 178 | } |
---|
179 | 179 | |
---|
180 | | -phys_addr_t __dma_to_phys(struct device *dev, dma_addr_t daddr) |
---|
| 180 | +phys_addr_t dma_to_phys(struct device *dev, dma_addr_t daddr) |
---|
181 | 181 | { |
---|
182 | 182 | #ifdef CONFIG_PCI |
---|
183 | 183 | if (dev && dev_is_pci(dev)) |
---|
.. | .. |
---|
190 | 190 | |
---|
191 | 191 | void __init plat_swiotlb_setup(void) |
---|
192 | 192 | { |
---|
193 | | - int i; |
---|
| 193 | + phys_addr_t start, end; |
---|
194 | 194 | phys_addr_t max_addr; |
---|
195 | 195 | phys_addr_t addr_size; |
---|
196 | 196 | size_t swiotlbsize; |
---|
197 | 197 | unsigned long swiotlb_nslabs; |
---|
| 198 | + u64 i; |
---|
198 | 199 | |
---|
199 | 200 | max_addr = 0; |
---|
200 | 201 | addr_size = 0; |
---|
201 | 202 | |
---|
202 | | - for (i = 0 ; i < boot_mem_map.nr_map; i++) { |
---|
203 | | - struct boot_mem_map_entry *e = &boot_mem_map.map[i]; |
---|
204 | | - if (e->type != BOOT_MEM_RAM && e->type != BOOT_MEM_INIT_RAM) |
---|
205 | | - continue; |
---|
206 | | - |
---|
| 203 | + for_each_mem_range(i, &start, &end) { |
---|
207 | 204 | /* These addresses map low for PCI. */ |
---|
208 | | - if (e->addr > 0x410000000ull && !OCTEON_IS_OCTEON2()) |
---|
| 205 | + if (start > 0x410000000ull && !OCTEON_IS_OCTEON2()) |
---|
209 | 206 | continue; |
---|
210 | 207 | |
---|
211 | | - addr_size += e->size; |
---|
| 208 | + addr_size += (end - start); |
---|
212 | 209 | |
---|
213 | | - if (max_addr < e->addr + e->size) |
---|
214 | | - max_addr = e->addr + e->size; |
---|
215 | | - |
---|
| 210 | + if (max_addr < end) |
---|
| 211 | + max_addr = end; |
---|
216 | 212 | } |
---|
217 | 213 | |
---|
218 | 214 | swiotlbsize = PAGE_SIZE; |
---|
.. | .. |
---|
244 | 240 | swiotlb_nslabs = ALIGN(swiotlb_nslabs, IO_TLB_SEGSIZE); |
---|
245 | 241 | swiotlbsize = swiotlb_nslabs << IO_TLB_SHIFT; |
---|
246 | 242 | |
---|
247 | | - octeon_swiotlb = alloc_bootmem_low_pages(swiotlbsize); |
---|
| 243 | + octeon_swiotlb = memblock_alloc_low(swiotlbsize, PAGE_SIZE); |
---|
| 244 | + if (!octeon_swiotlb) |
---|
| 245 | + panic("%s: Failed to allocate %zu bytes align=%lx\n", |
---|
| 246 | + __func__, swiotlbsize, PAGE_SIZE); |
---|
248 | 247 | |
---|
249 | 248 | if (swiotlb_init_with_tbl(octeon_swiotlb, swiotlb_nslabs, 1) == -ENOMEM) |
---|
250 | 249 | panic("Cannot allocate SWIOTLB buffer"); |
---|