函数源码 |
Source File:kernel\dma\swiotlb.c |
Create Date:2022-07-27 11:35:53 |
首页 | Copyright©Brick |
327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 | int swiotlb_late_init_with_tbl( char *tlb, unsigned long nslabs) { unsigned long i, bytes; bytes = nslabs << IO_TLB_SHIFT; io_tlb_nslabs = nslabs; io_tlb_start = virt_to_phys(tlb); io_tlb_end = io_tlb_start + bytes; set_memory_decrypted((unsigned long )tlb, bytes >> PAGE_SHIFT); memset (tlb, 0, bytes); /* * Allocate and initialize the free list array. This array is used * to find contiguous free memory regions of size up to IO_TLB_SEGSIZE * between io_tlb_start and io_tlb_end. */ io_tlb_list = (unsigned int *)__get_free_pages(GFP_KERNEL, get_order(io_tlb_nslabs * sizeof ( int ))); if (!io_tlb_list) goto cleanup3; io_tlb_orig_addr = (phys_addr_t *) __get_free_pages(GFP_KERNEL, get_order(io_tlb_nslabs * sizeof (phys_addr_t))); if (!io_tlb_orig_addr) goto cleanup4; for (i = 0; i < io_tlb_nslabs; i++) { io_tlb_list[i] = IO_TLB_SEGSIZE - OFFSET(i, IO_TLB_SEGSIZE); io_tlb_orig_addr[i] = INVALID_PHYS_ADDR; } io_tlb_index = 0; swiotlb_print_info(); late_alloc = 1; swiotlb_set_max_segment(io_tlb_nslabs << IO_TLB_SHIFT); return 0; cleanup4: free_pages((unsigned long )io_tlb_list, get_order(io_tlb_nslabs * sizeof ( int ))); io_tlb_list = NULL; cleanup3: swiotlb_cleanup(); return -ENOMEM; } |