Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/aegl/linux-2.6

* 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/aegl/linux-2.6:
[IA64] kexec: Use EFI_LOADER_DATA for ELF core header
[IA64] permon use-after-free fix
[IA64] sync compat getdents
[IA64] always build arch/ia64/lib/xor.o
[IA64] Remove stack hard limit on ia64
[IA64] point saved_max_pfn to the max_pfn of the entire system
Revert "[IA64] swiotlb abstraction (e.g. for Xen)"

+121 -181
+7 -3
arch/ia64/ia32/sys_ia32.c
··· 1267 1267 struct getdents32_callback buf; 1268 1268 int error; 1269 1269 1270 + error = -EFAULT; 1271 + if (!access_ok(VERIFY_WRITE, dirent, count)) 1272 + goto out; 1273 + 1270 1274 error = -EBADF; 1271 1275 file = fget(fd); 1272 1276 if (!file) ··· 1287 1283 error = buf.error; 1288 1284 lastdirent = buf.previous; 1289 1285 if (lastdirent) { 1290 - error = -EINVAL; 1291 1286 if (put_user(file->f_pos, &lastdirent->d_off)) 1292 - goto out_putf; 1293 - error = count - buf.count; 1287 + error = -EFAULT; 1288 + else 1289 + error = count - buf.count; 1294 1290 } 1295 1291 1296 1292 out_putf:
+36
arch/ia64/kernel/efi.c
··· 21 21 * Skip non-WB memory and ignore empty memory ranges. 22 22 */ 23 23 #include <linux/module.h> 24 + #include <linux/bootmem.h> 24 25 #include <linux/kernel.h> 25 26 #include <linux/init.h> 26 27 #include <linux/types.h> ··· 1010 1009 } else 1011 1010 ae = efi_md_end(md); 1012 1011 1012 + #ifdef CONFIG_CRASH_DUMP 1013 + /* saved_max_pfn should ignore max_addr= command line arg */ 1014 + if (saved_max_pfn < (ae >> PAGE_SHIFT)) 1015 + saved_max_pfn = (ae >> PAGE_SHIFT); 1016 + #endif 1013 1017 /* keep within max_addr= and min_addr= command line arg */ 1014 1018 as = max(as, min_addr); 1015 1019 ae = min(ae, max_addr); ··· 1181 1175 printk(KERN_WARNING "Cannot reserve 0x%lx byte of memory for crashdump\n", 1182 1176 size); 1183 1177 return ~0UL; 1178 + } 1179 + #endif 1180 + 1181 + #ifdef CONFIG_PROC_VMCORE 1182 + /* locate the size find a the descriptor at a certain address */ 1183 + unsigned long 1184 + vmcore_find_descriptor_size (unsigned long address) 1185 + { 1186 + void *efi_map_start, *efi_map_end, *p; 1187 + efi_memory_desc_t *md; 1188 + u64 efi_desc_size; 1189 + unsigned long ret = 0; 1190 + 1191 + efi_map_start = __va(ia64_boot_param->efi_memmap); 1192 + efi_map_end = efi_map_start + ia64_boot_param->efi_memmap_size; 1193 + efi_desc_size = ia64_boot_param->efi_memdesc_size; 1194 + 1195 + for (p = efi_map_start; p < efi_map_end; p += efi_desc_size) { 1196 + md = p; 1197 + if (efi_wb(md) && md->type == EFI_LOADER_DATA 1198 + && md->phys_addr == address) { 1199 + ret = efi_md_size(md); 1200 + break; 1201 + } 1202 + } 1203 + 1204 + if (ret == 0) 1205 + printk(KERN_WARNING "Cannot locate EFI vmcore descriptor\n"); 1206 + 1207 + return ret; 1184 1208 } 1185 1209 #endif
+7 -4
arch/ia64/kernel/perfmon.c
··· 2299 2299 * allocate a sampling buffer and remaps it into the user address space of the task 2300 2300 */ 2301 2301 static int 2302 - pfm_smpl_buffer_alloc(struct task_struct *task, pfm_context_t *ctx, unsigned long rsize, void **user_vaddr) 2302 + pfm_smpl_buffer_alloc(struct task_struct *task, struct file *filp, pfm_context_t *ctx, unsigned long rsize, void **user_vaddr) 2303 2303 { 2304 2304 struct mm_struct *mm = task->mm; 2305 2305 struct vm_area_struct *vma = NULL; ··· 2349 2349 * partially initialize the vma for the sampling buffer 2350 2350 */ 2351 2351 vma->vm_mm = mm; 2352 + vma->vm_file = filp; 2352 2353 vma->vm_flags = VM_READ| VM_MAYREAD |VM_RESERVED; 2353 2354 vma->vm_page_prot = PAGE_READONLY; /* XXX may need to change */ 2354 2355 ··· 2387 2386 up_write(&task->mm->mmap_sem); 2388 2387 goto error; 2389 2388 } 2389 + 2390 + get_file(filp); 2390 2391 2391 2392 /* 2392 2393 * now insert the vma in the vm list for the process, must be ··· 2467 2464 } 2468 2465 2469 2466 static int 2470 - pfm_setup_buffer_fmt(struct task_struct *task, pfm_context_t *ctx, unsigned int ctx_flags, 2467 + pfm_setup_buffer_fmt(struct task_struct *task, struct file *filp, pfm_context_t *ctx, unsigned int ctx_flags, 2471 2468 unsigned int cpu, pfarg_context_t *arg) 2472 2469 { 2473 2470 pfm_buffer_fmt_t *fmt = NULL; ··· 2508 2505 /* 2509 2506 * buffer is always remapped into the caller's address space 2510 2507 */ 2511 - ret = pfm_smpl_buffer_alloc(current, ctx, size, &uaddr); 2508 + ret = pfm_smpl_buffer_alloc(current, filp, ctx, size, &uaddr); 2512 2509 if (ret) goto error; 2513 2510 2514 2511 /* keep track of user address of buffer */ ··· 2719 2716 * does the user want to sample? 2720 2717 */ 2721 2718 if (pfm_uuid_cmp(req->ctx_smpl_buf_id, pfm_null_uuid)) { 2722 - ret = pfm_setup_buffer_fmt(current, ctx, ctx_flags, 0, req); 2719 + ret = pfm_setup_buffer_fmt(current, filp, ctx, ctx_flags, 0, req); 2723 2720 if (ret) goto buffer_error; 2724 2721 } 2725 2722
+30
arch/ia64/kernel/setup.c
··· 251 251 } 252 252 #endif 253 253 254 + #ifdef CONFIG_PROC_VMCORE 255 + if (reserve_elfcorehdr(&rsvd_region[n].start, 256 + &rsvd_region[n].end) == 0) 257 + n++; 258 + #endif 259 + 254 260 efi_memmap_init(&rsvd_region[n].start, &rsvd_region[n].end); 255 261 n++; 256 262 ··· 459 453 return 0; 460 454 } 461 455 early_param("elfcorehdr", parse_elfcorehdr); 456 + 457 + int __init reserve_elfcorehdr(unsigned long *start, unsigned long *end) 458 + { 459 + unsigned long length; 460 + 461 + /* We get the address using the kernel command line, 462 + * but the size is extracted from the EFI tables. 463 + * Both address and size are required for reservation 464 + * to work properly. 465 + */ 466 + 467 + if (elfcorehdr_addr >= ELFCORE_ADDR_MAX) 468 + return -EINVAL; 469 + 470 + if ((length = vmcore_find_descriptor_size(elfcorehdr_addr)) == 0) { 471 + elfcorehdr_addr = ELFCORE_ADDR_MAX; 472 + return -EINVAL; 473 + } 474 + 475 + *start = (unsigned long)__va(elfcorehdr_addr); 476 + *end = *start + length; 477 + return 0; 478 + } 479 + 462 480 #endif /* CONFIG_PROC_VMCORE */ 463 481 464 482 void __init
+1 -2
arch/ia64/lib/Makefile
··· 9 9 checksum.o clear_page.o csum_partial_copy.o \ 10 10 clear_user.o strncpy_from_user.o strlen_user.o strnlen_user.o \ 11 11 flush.o ip_fast_csum.o do_csum.o \ 12 - memset.o strlen.o 12 + memset.o strlen.o xor.o 13 13 14 14 lib-$(CONFIG_ITANIUM) += copy_page.o copy_user.o memcpy.o 15 15 lib-$(CONFIG_MCKINLEY) += copy_page_mck.o memcpy_mck.o 16 16 lib-$(CONFIG_PERFMON) += carta_random.o 17 - lib-$(CONFIG_MD_RAID456) += xor.o 18 17 19 18 AFLAGS___divdi3.o = 20 19 AFLAGS___udivdi3.o = -DUNSIGNED
-5
arch/ia64/mm/contig.c
··· 197 197 198 198 find_initrd(); 199 199 200 - #ifdef CONFIG_CRASH_DUMP 201 - /* If we are doing a crash dump, we still need to know the real mem 202 - * size before original memory map is reset. */ 203 - saved_max_pfn = max_pfn; 204 - #endif 205 200 } 206 201 207 202 #ifdef CONFIG_SMP
-6
arch/ia64/mm/discontig.c
··· 480 480 max_pfn = max_low_pfn; 481 481 482 482 find_initrd(); 483 - 484 - #ifdef CONFIG_CRASH_DUMP 485 - /* If we are doing a crash dump, we still need to know the real mem 486 - * size before original memory map is reset. */ 487 - saved_max_pfn = max_pfn; 488 - #endif 489 483 } 490 484 491 485 #ifdef CONFIG_SMP
+5 -1
include/asm-ia64/meminit.h
··· 17 17 * - kernel code & data 18 18 * - crash dumping code reserved region 19 19 * - Kernel memory map built from EFI memory map 20 + * - ELF core header 20 21 * 21 22 * More could be added if necessary 22 23 */ 23 - #define IA64_MAX_RSVD_REGIONS 7 24 + #define IA64_MAX_RSVD_REGIONS 8 24 25 25 26 struct rsvd_region { 26 27 unsigned long start; /* virtual address of beginning of element */ ··· 36 35 extern void find_initrd (void); 37 36 extern int filter_rsvd_memory (unsigned long start, unsigned long end, void *arg); 38 37 extern void efi_memmap_init(unsigned long *, unsigned long *); 38 + 39 + extern unsigned long vmcore_find_descriptor_size(unsigned long address); 40 + extern int reserve_elfcorehdr(unsigned long *start, unsigned long *end); 39 41 40 42 /* 41 43 * For rounding an address to the next IA64_GRANULE_SIZE or order
-1
include/asm-ia64/resource.h
··· 2 2 #define _ASM_IA64_RESOURCE_H 3 3 4 4 #include <asm/ustack.h> 5 - #define _STK_LIM_MAX DEFAULT_USER_STACK_SIZE 6 5 #include <asm-generic/resource.h> 7 6 8 7 #endif /* _ASM_IA64_RESOURCE_H */
-9
include/asm-ia64/swiotlb.h
··· 1 - #ifndef _ASM_SWIOTLB_H 2 - #define _ASM_SWIOTLB_H 1 3 - 4 - #include <asm/machvec.h> 5 - 6 - #define SWIOTLB_ARCH_NEED_LATE_INIT 7 - #define SWIOTLB_ARCH_NEED_ALLOC 8 - 9 - #endif /* _ASM_SWIOTLB_H */
-1
include/asm-x86_64/swiotlb.h
··· 44 44 extern int swiotlb_force; 45 45 46 46 #ifdef CONFIG_SWIOTLB 47 - #define SWIOTLB_ARCH_NEED_ALLOC 48 47 extern int swiotlb; 49 48 #else 50 49 #define swiotlb 0
+35 -149
lib/swiotlb.c
··· 28 28 #include <asm/io.h> 29 29 #include <asm/dma.h> 30 30 #include <asm/scatterlist.h> 31 - #include <asm/swiotlb.h> 32 31 33 32 #include <linux/init.h> 34 33 #include <linux/bootmem.h> ··· 35 36 #define OFFSET(val,align) ((unsigned long) \ 36 37 ( (val) & ( (align) - 1))) 37 38 38 - #ifndef SG_ENT_VIRT_ADDRESS 39 39 #define SG_ENT_VIRT_ADDRESS(sg) (page_address((sg)->page) + (sg)->offset) 40 40 #define SG_ENT_PHYS_ADDRESS(sg) virt_to_bus(SG_ENT_VIRT_ADDRESS(sg)) 41 - #endif 42 41 43 42 /* 44 43 * Maximum allowable number of contiguous slabs to map, ··· 101 104 * We need to save away the original address corresponding to a mapped entry 102 105 * for the sync operations. 103 106 */ 104 - #ifndef SWIOTLB_ARCH_HAS_IO_TLB_ADDR_T 105 - typedef char *io_tlb_addr_t; 106 - #define swiotlb_orig_addr_null(buffer) (!(buffer)) 107 - #define ptr_to_io_tlb_addr(ptr) (ptr) 108 - #define page_to_io_tlb_addr(pg, off) (page_address(pg) + (off)) 109 - #define sg_to_io_tlb_addr(sg) SG_ENT_VIRT_ADDRESS(sg) 110 - #endif 111 - static io_tlb_addr_t *io_tlb_orig_addr; 107 + static unsigned char **io_tlb_orig_addr; 112 108 113 109 /* 114 110 * Protect the above data structures in the map and unmap calls 115 111 */ 116 112 static DEFINE_SPINLOCK(io_tlb_lock); 117 113 118 - #ifdef SWIOTLB_EXTRA_VARIABLES 119 - SWIOTLB_EXTRA_VARIABLES; 120 - #endif 121 - 122 - #ifndef SWIOTLB_ARCH_HAS_SETUP_IO_TLB_NPAGES 123 114 static int __init 124 115 setup_io_tlb_npages(char *str) 125 116 { ··· 122 137 swiotlb_force = 1; 123 138 return 1; 124 139 } 125 - #endif 126 140 __setup("swiotlb=", setup_io_tlb_npages); 127 141 /* make io_tlb_overflow tunable too? */ 128 - 129 - #ifndef swiotlb_adjust_size 130 - #define swiotlb_adjust_size(size) ((void)0) 131 - #endif 132 - 133 - #ifndef swiotlb_adjust_seg 134 - #define swiotlb_adjust_seg(start, size) ((void)0) 135 - #endif 136 - 137 - #ifndef swiotlb_print_info 138 - #define swiotlb_print_info(bytes) \ 139 - printk(KERN_INFO "Placing %luMB software IO TLB between 0x%lx - " \ 140 - "0x%lx\n", bytes >> 20, \ 141 - virt_to_bus(io_tlb_start), virt_to_bus(io_tlb_end)) 142 - #endif 143 142 144 143 /* 145 144 * Statically reserve bounce buffer space and initialize bounce buffer data ··· 138 169 io_tlb_nslabs = (default_size >> IO_TLB_SHIFT); 139 170 io_tlb_nslabs = ALIGN(io_tlb_nslabs, IO_TLB_SEGSIZE); 140 171 } 141 - swiotlb_adjust_size(io_tlb_nslabs); 142 - swiotlb_adjust_size(io_tlb_overflow); 143 172 144 173 bytes = io_tlb_nslabs << IO_TLB_SHIFT; 145 174 ··· 155 188 * between io_tlb_start and io_tlb_end. 156 189 */ 157 190 io_tlb_list = alloc_bootmem(io_tlb_nslabs * sizeof(int)); 158 - for (i = 0; i < io_tlb_nslabs; i++) { 159 - if ( !(i % IO_TLB_SEGSIZE) ) 160 - swiotlb_adjust_seg(io_tlb_start + (i << IO_TLB_SHIFT), 161 - IO_TLB_SEGSIZE << IO_TLB_SHIFT); 191 + for (i = 0; i < io_tlb_nslabs; i++) 162 192 io_tlb_list[i] = IO_TLB_SEGSIZE - OFFSET(i, IO_TLB_SEGSIZE); 163 - } 164 193 io_tlb_index = 0; 165 - io_tlb_orig_addr = alloc_bootmem(io_tlb_nslabs * sizeof(io_tlb_addr_t)); 194 + io_tlb_orig_addr = alloc_bootmem(io_tlb_nslabs * sizeof(char *)); 166 195 167 196 /* 168 197 * Get the overflow emergency buffer ··· 166 203 io_tlb_overflow_buffer = alloc_bootmem_low(io_tlb_overflow); 167 204 if (!io_tlb_overflow_buffer) 168 205 panic("Cannot allocate SWIOTLB overflow buffer!\n"); 169 - swiotlb_adjust_seg(io_tlb_overflow_buffer, io_tlb_overflow); 170 206 171 - swiotlb_print_info(bytes); 207 + printk(KERN_INFO "Placing software IO TLB between 0x%lx - 0x%lx\n", 208 + virt_to_bus(io_tlb_start), virt_to_bus(io_tlb_end)); 172 209 } 173 - #ifndef __swiotlb_init_with_default_size 174 - #define __swiotlb_init_with_default_size swiotlb_init_with_default_size 175 - #endif 176 210 177 211 void __init 178 212 swiotlb_init(void) 179 213 { 180 - __swiotlb_init_with_default_size(64 * (1<<20)); /* default to 64MB */ 214 + swiotlb_init_with_default_size(64 * (1<<20)); /* default to 64MB */ 181 215 } 182 216 183 - #ifdef SWIOTLB_ARCH_NEED_LATE_INIT 184 217 /* 185 218 * Systems with larger DMA zones (those that don't support ISA) can 186 219 * initialize the swiotlb later using the slab allocator if needed. ··· 234 275 io_tlb_list[i] = IO_TLB_SEGSIZE - OFFSET(i, IO_TLB_SEGSIZE); 235 276 io_tlb_index = 0; 236 277 237 - io_tlb_orig_addr = (io_tlb_addr_t *)__get_free_pages(GFP_KERNEL, 238 - get_order(io_tlb_nslabs * sizeof(io_tlb_addr_t))); 278 + io_tlb_orig_addr = (unsigned char **)__get_free_pages(GFP_KERNEL, 279 + get_order(io_tlb_nslabs * sizeof(char *))); 239 280 if (!io_tlb_orig_addr) 240 281 goto cleanup3; 241 282 242 - memset(io_tlb_orig_addr, 0, io_tlb_nslabs * sizeof(io_tlb_addr_t)); 283 + memset(io_tlb_orig_addr, 0, io_tlb_nslabs * sizeof(char *)); 243 284 244 285 /* 245 286 * Get the overflow emergency buffer ··· 249 290 if (!io_tlb_overflow_buffer) 250 291 goto cleanup4; 251 292 252 - swiotlb_print_info(bytes); 293 + printk(KERN_INFO "Placing %luMB software IO TLB between 0x%lx - " 294 + "0x%lx\n", bytes >> 20, 295 + virt_to_bus(io_tlb_start), virt_to_bus(io_tlb_end)); 253 296 254 297 return 0; 255 298 256 299 cleanup4: 257 - free_pages((unsigned long)io_tlb_orig_addr, 258 - get_order(io_tlb_nslabs * sizeof(io_tlb_addr_t))); 300 + free_pages((unsigned long)io_tlb_orig_addr, get_order(io_tlb_nslabs * 301 + sizeof(char *))); 259 302 io_tlb_orig_addr = NULL; 260 303 cleanup3: 261 - free_pages((unsigned long)io_tlb_list, 262 - get_order(io_tlb_nslabs * sizeof(int))); 304 + free_pages((unsigned long)io_tlb_list, get_order(io_tlb_nslabs * 305 + sizeof(int))); 263 306 io_tlb_list = NULL; 264 307 cleanup2: 265 308 io_tlb_end = NULL; ··· 271 310 io_tlb_nslabs = req_nslabs; 272 311 return -ENOMEM; 273 312 } 274 - #endif 275 313 276 - #ifndef SWIOTLB_ARCH_HAS_NEEDS_MAPPING 277 314 static int 278 315 address_needs_mapping(struct device *hwdev, dma_addr_t addr) 279 316 { ··· 282 323 return (addr & ~mask) != 0; 283 324 } 284 325 285 - static inline int range_needs_mapping(const void *ptr, size_t size) 286 - { 287 - return swiotlb_force; 288 - } 289 - 290 - static inline int order_needs_mapping(unsigned int order) 291 - { 292 - return 0; 293 - } 294 - #endif 295 - 296 - static void 297 - __sync_single(io_tlb_addr_t buffer, char *dma_addr, size_t size, int dir) 298 - { 299 - #ifndef SWIOTLB_ARCH_HAS_SYNC_SINGLE 300 - if (dir == DMA_TO_DEVICE) 301 - memcpy(dma_addr, buffer, size); 302 - else 303 - memcpy(buffer, dma_addr, size); 304 - #else 305 - __swiotlb_arch_sync_single(buffer, dma_addr, size, dir); 306 - #endif 307 - } 308 - 309 326 /* 310 327 * Allocates bounce buffer and returns its kernel virtual address. 311 328 */ 312 329 static void * 313 - map_single(struct device *hwdev, io_tlb_addr_t buffer, size_t size, int dir) 330 + map_single(struct device *hwdev, char *buffer, size_t size, int dir) 314 331 { 315 332 unsigned long flags; 316 333 char *dma_addr; ··· 359 424 */ 360 425 io_tlb_orig_addr[index] = buffer; 361 426 if (dir == DMA_TO_DEVICE || dir == DMA_BIDIRECTIONAL) 362 - __sync_single(buffer, dma_addr, size, DMA_TO_DEVICE); 427 + memcpy(dma_addr, buffer, size); 363 428 364 429 return dma_addr; 365 430 } ··· 373 438 unsigned long flags; 374 439 int i, count, nslots = ALIGN(size, 1 << IO_TLB_SHIFT) >> IO_TLB_SHIFT; 375 440 int index = (dma_addr - io_tlb_start) >> IO_TLB_SHIFT; 376 - io_tlb_addr_t buffer = io_tlb_orig_addr[index]; 441 + char *buffer = io_tlb_orig_addr[index]; 377 442 378 443 /* 379 444 * First, sync the memory before unmapping the entry 380 445 */ 381 - if (!swiotlb_orig_addr_null(buffer) 382 - && ((dir == DMA_FROM_DEVICE) || (dir == DMA_BIDIRECTIONAL))) 446 + if (buffer && ((dir == DMA_FROM_DEVICE) || (dir == DMA_BIDIRECTIONAL))) 383 447 /* 384 448 * bounce... copy the data back into the original buffer * and 385 449 * delete the bounce buffer. 386 450 */ 387 - __sync_single(buffer, dma_addr, size, DMA_FROM_DEVICE); 451 + memcpy(buffer, dma_addr, size); 388 452 389 453 /* 390 454 * Return the buffer to the free list by setting the corresponding ··· 416 482 int dir, int target) 417 483 { 418 484 int index = (dma_addr - io_tlb_start) >> IO_TLB_SHIFT; 419 - io_tlb_addr_t buffer = io_tlb_orig_addr[index]; 485 + char *buffer = io_tlb_orig_addr[index]; 420 486 421 487 switch (target) { 422 488 case SYNC_FOR_CPU: 423 489 if (likely(dir == DMA_FROM_DEVICE || dir == DMA_BIDIRECTIONAL)) 424 - __sync_single(buffer, dma_addr, size, DMA_FROM_DEVICE); 490 + memcpy(buffer, dma_addr, size); 425 491 else 426 492 BUG_ON(dir != DMA_TO_DEVICE); 427 493 break; 428 494 case SYNC_FOR_DEVICE: 429 495 if (likely(dir == DMA_TO_DEVICE || dir == DMA_BIDIRECTIONAL)) 430 - __sync_single(buffer, dma_addr, size, DMA_TO_DEVICE); 496 + memcpy(dma_addr, buffer, size); 431 497 else 432 498 BUG_ON(dir != DMA_FROM_DEVICE); 433 499 break; ··· 435 501 BUG(); 436 502 } 437 503 } 438 - 439 - #ifdef SWIOTLB_ARCH_NEED_ALLOC 440 504 441 505 void * 442 506 swiotlb_alloc_coherent(struct device *hwdev, size_t size, ··· 451 519 */ 452 520 flags |= GFP_DMA; 453 521 454 - if (!order_needs_mapping(order)) 455 - ret = (void *)__get_free_pages(flags, order); 456 - else 457 - ret = NULL; 522 + ret = (void *)__get_free_pages(flags, order); 458 523 if (ret && address_needs_mapping(hwdev, virt_to_bus(ret))) { 459 524 /* 460 525 * The allocated memory isn't reachable by the device. ··· 489 560 *dma_handle = dev_addr; 490 561 return ret; 491 562 } 492 - EXPORT_SYMBOL(swiotlb_alloc_coherent); 493 563 494 564 void 495 565 swiotlb_free_coherent(struct device *hwdev, size_t size, void *vaddr, ··· 501 573 /* DMA_TO_DEVICE to avoid memcpy in unmap_single */ 502 574 swiotlb_unmap_single (hwdev, dma_handle, size, DMA_TO_DEVICE); 503 575 } 504 - EXPORT_SYMBOL(swiotlb_free_coherent); 505 - 506 - #endif 507 576 508 577 static void 509 578 swiotlb_full(struct device *dev, size_t size, int dir, int do_panic) ··· 542 617 * we can safely return the device addr and not worry about bounce 543 618 * buffering it. 544 619 */ 545 - if (!range_needs_mapping(ptr, size) 546 - && !address_needs_mapping(hwdev, dev_addr)) 620 + if (!address_needs_mapping(hwdev, dev_addr) && !swiotlb_force) 547 621 return dev_addr; 548 622 549 623 /* 550 624 * Oh well, have to allocate and map a bounce buffer. 551 625 */ 552 - map = map_single(hwdev, ptr_to_io_tlb_addr(ptr), size, dir); 626 + map = map_single(hwdev, ptr, size, dir); 553 627 if (!map) { 554 628 swiotlb_full(hwdev, size, dir, 1); 555 629 map = io_tlb_overflow_buffer; ··· 676 752 swiotlb_map_sg(struct device *hwdev, struct scatterlist *sg, int nelems, 677 753 int dir) 678 754 { 755 + void *addr; 679 756 dma_addr_t dev_addr; 680 757 int i; 681 758 682 759 BUG_ON(dir == DMA_NONE); 683 760 684 761 for (i = 0; i < nelems; i++, sg++) { 685 - dev_addr = SG_ENT_PHYS_ADDRESS(sg); 686 - if (range_needs_mapping(SG_ENT_VIRT_ADDRESS(sg), sg->length) 687 - || address_needs_mapping(hwdev, dev_addr)) { 688 - void *map = map_single(hwdev, sg_to_io_tlb_addr(sg), sg->length, dir); 762 + addr = SG_ENT_VIRT_ADDRESS(sg); 763 + dev_addr = virt_to_bus(addr); 764 + if (swiotlb_force || address_needs_mapping(hwdev, dev_addr)) { 765 + void *map = map_single(hwdev, addr, sg->length, dir); 689 766 if (!map) { 690 767 /* Don't panic here, we expect map_sg users 691 768 to do proper error handling. */ ··· 760 835 swiotlb_sync_sg(hwdev, sg, nelems, dir, SYNC_FOR_DEVICE); 761 836 } 762 837 763 - #ifdef SWIOTLB_ARCH_NEED_MAP_PAGE 764 - 765 - dma_addr_t 766 - swiotlb_map_page(struct device *hwdev, struct page *page, 767 - unsigned long offset, size_t size, 768 - enum dma_data_direction direction) 769 - { 770 - dma_addr_t dev_addr; 771 - char *map; 772 - 773 - dev_addr = page_to_bus(page) + offset; 774 - if (address_needs_mapping(hwdev, dev_addr)) { 775 - map = map_single(hwdev, page_to_io_tlb_addr(page, offset), size, direction); 776 - if (!map) { 777 - swiotlb_full(hwdev, size, direction, 1); 778 - map = io_tlb_overflow_buffer; 779 - } 780 - dev_addr = virt_to_bus(map); 781 - } 782 - 783 - return dev_addr; 784 - } 785 - 786 - void 787 - swiotlb_unmap_page(struct device *hwdev, dma_addr_t dev_addr, 788 - size_t size, enum dma_data_direction direction) 789 - { 790 - char *dma_addr = bus_to_virt(dev_addr); 791 - 792 - BUG_ON(direction == DMA_NONE); 793 - if (dma_addr >= io_tlb_start && dma_addr < io_tlb_end) 794 - unmap_single(hwdev, dma_addr, size, direction); 795 - else if (direction == DMA_FROM_DEVICE) 796 - dma_mark_clean(dma_addr, size); 797 - } 798 - 799 - #endif 800 - 801 838 int 802 839 swiotlb_dma_mapping_error(dma_addr_t dma_addr) 803 840 { ··· 772 885 * during bus mastering, then you would pass 0x00ffffff as the mask to 773 886 * this function. 774 887 */ 775 - #ifndef __swiotlb_dma_supported 776 - #define __swiotlb_dma_supported(hwdev, mask) (virt_to_bus(io_tlb_end - 1) <= (mask)) 777 - #endif 778 888 int 779 889 swiotlb_dma_supported(struct device *hwdev, u64 mask) 780 890 { 781 - return __swiotlb_dma_supported(hwdev, mask); 891 + return virt_to_bus(io_tlb_end - 1) <= mask; 782 892 } 783 893 784 894 EXPORT_SYMBOL(swiotlb_init); ··· 790 906 EXPORT_SYMBOL(swiotlb_sync_sg_for_cpu); 791 907 EXPORT_SYMBOL(swiotlb_sync_sg_for_device); 792 908 EXPORT_SYMBOL(swiotlb_dma_mapping_error); 909 + EXPORT_SYMBOL(swiotlb_alloc_coherent); 910 + EXPORT_SYMBOL(swiotlb_free_coherent); 793 911 EXPORT_SYMBOL(swiotlb_dma_supported);