summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--kernel/dma/swiotlb.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/kernel/dma/swiotlb.c b/kernel/dma/swiotlb.c
index 9f5851064aea..dd6a8e2d53a7 100644
--- a/kernel/dma/swiotlb.c
+++ b/kernel/dma/swiotlb.c
@@ -199,6 +199,7 @@ void __init swiotlb_update_mem_attributes(void)
199int __init swiotlb_init_with_tbl(char *tlb, unsigned long nslabs, int verbose) 199int __init swiotlb_init_with_tbl(char *tlb, unsigned long nslabs, int verbose)
200{ 200{
201 unsigned long i, bytes; 201 unsigned long i, bytes;
202 size_t alloc_size;
202 203
203 bytes = nslabs << IO_TLB_SHIFT; 204 bytes = nslabs << IO_TLB_SHIFT;
204 205
@@ -211,12 +212,18 @@ int __init swiotlb_init_with_tbl(char *tlb, unsigned long nslabs, int verbose)
211 * to find contiguous free memory regions of size up to IO_TLB_SEGSIZE 212 * to find contiguous free memory regions of size up to IO_TLB_SEGSIZE
212 * between io_tlb_start and io_tlb_end. 213 * between io_tlb_start and io_tlb_end.
213 */ 214 */
214 io_tlb_list = memblock_alloc( 215 alloc_size = PAGE_ALIGN(io_tlb_nslabs * sizeof(int));
215 PAGE_ALIGN(io_tlb_nslabs * sizeof(int)), 216 io_tlb_list = memblock_alloc(alloc_size, PAGE_SIZE);
216 PAGE_SIZE); 217 if (!io_tlb_list)
217 io_tlb_orig_addr = memblock_alloc( 218 panic("%s: Failed to allocate %lu bytes align=0x%lx\n",
218 PAGE_ALIGN(io_tlb_nslabs * sizeof(phys_addr_t)), 219 __func__, alloc_size, PAGE_SIZE);
219 PAGE_SIZE); 220
221 alloc_size = PAGE_ALIGN(io_tlb_nslabs * sizeof(phys_addr_t));
222 io_tlb_orig_addr = memblock_alloc(alloc_size, PAGE_SIZE);
223 if (!io_tlb_orig_addr)
224 panic("%s: Failed to allocate %lu bytes align=0x%lx\n",
225 __func__, alloc_size, PAGE_SIZE);
226
220 for (i = 0; i < io_tlb_nslabs; i++) { 227 for (i = 0; i < io_tlb_nslabs; i++) {
221 io_tlb_list[i] = IO_TLB_SEGSIZE - OFFSET(i, IO_TLB_SEGSIZE); 228 io_tlb_list[i] = IO_TLB_SEGSIZE - OFFSET(i, IO_TLB_SEGSIZE);
222 io_tlb_orig_addr[i] = INVALID_PHYS_ADDR; 229 io_tlb_orig_addr[i] = INVALID_PHYS_ADDR;