| .. | .. |
|---|
| 41 | 41 | |
|---|
| 42 | 42 | #define TTM_MEMORY_ALLOC_RETRIES 4 |
|---|
| 43 | 43 | |
|---|
| 44 | +struct ttm_mem_global ttm_mem_glob; |
|---|
| 45 | +EXPORT_SYMBOL(ttm_mem_glob); |
|---|
| 46 | + |
|---|
| 44 | 47 | struct ttm_mem_zone { |
|---|
| 45 | 48 | struct kobject kobj; |
|---|
| 46 | 49 | struct ttm_mem_global *glob; |
|---|
| .. | .. |
|---|
| 78 | 81 | struct ttm_mem_zone *zone = |
|---|
| 79 | 82 | container_of(kobj, struct ttm_mem_zone, kobj); |
|---|
| 80 | 83 | |
|---|
| 81 | | - pr_info("Zone %7s: Used memory at exit: %llu kiB\n", |
|---|
| 84 | + pr_info("Zone %7s: Used memory at exit: %llu KiB\n", |
|---|
| 82 | 85 | zone->name, (unsigned long long)zone->used_mem >> 10); |
|---|
| 83 | 86 | kfree(zone); |
|---|
| 84 | 87 | } |
|---|
| .. | .. |
|---|
| 256 | 259 | return false; |
|---|
| 257 | 260 | } |
|---|
| 258 | 261 | |
|---|
| 259 | | -/** |
|---|
| 262 | +/* |
|---|
| 260 | 263 | * At this point we only support a single shrink callback. |
|---|
| 261 | 264 | * Extend this if needed, perhaps using a linked list of callbacks. |
|---|
| 262 | 265 | * Note that this function is reentrant: |
|---|
| .. | .. |
|---|
| 272 | 275 | |
|---|
| 273 | 276 | while (ttm_zones_above_swap_target(glob, from_wq, extra)) { |
|---|
| 274 | 277 | spin_unlock(&glob->lock); |
|---|
| 275 | | - ret = ttm_bo_swapout(glob->bo_glob, ctx); |
|---|
| 278 | + ret = ttm_bo_swapout(&ttm_bo_glob, ctx); |
|---|
| 276 | 279 | spin_lock(&glob->lock); |
|---|
| 277 | 280 | if (unlikely(ret != 0)) |
|---|
| 278 | 281 | break; |
|---|
| .. | .. |
|---|
| 445 | 448 | #endif |
|---|
| 446 | 449 | for (i = 0; i < glob->num_zones; ++i) { |
|---|
| 447 | 450 | zone = glob->zones[i]; |
|---|
| 448 | | - pr_info("Zone %7s: Available graphics memory: %llu kiB\n", |
|---|
| 451 | + pr_info("Zone %7s: Available graphics memory: %llu KiB\n", |
|---|
| 449 | 452 | zone->name, (unsigned long long)zone->max_mem >> 10); |
|---|
| 450 | 453 | } |
|---|
| 451 | 454 | ttm_page_alloc_init(glob, glob->zone_kernel->max_mem/(2*PAGE_SIZE)); |
|---|
| .. | .. |
|---|
| 455 | 458 | ttm_mem_global_release(glob); |
|---|
| 456 | 459 | return ret; |
|---|
| 457 | 460 | } |
|---|
| 458 | | -EXPORT_SYMBOL(ttm_mem_global_init); |
|---|
| 459 | 461 | |
|---|
| 460 | 462 | void ttm_mem_global_release(struct ttm_mem_global *glob) |
|---|
| 461 | 463 | { |
|---|
| 462 | | - unsigned int i; |
|---|
| 463 | 464 | struct ttm_mem_zone *zone; |
|---|
| 465 | + unsigned int i; |
|---|
| 464 | 466 | |
|---|
| 465 | 467 | /* let the page allocator first stop the shrink work. */ |
|---|
| 466 | 468 | ttm_page_alloc_fini(); |
|---|
| .. | .. |
|---|
| 473 | 475 | zone = glob->zones[i]; |
|---|
| 474 | 476 | kobject_del(&zone->kobj); |
|---|
| 475 | 477 | kobject_put(&zone->kobj); |
|---|
| 476 | | - } |
|---|
| 478 | + } |
|---|
| 477 | 479 | kobject_del(&glob->kobj); |
|---|
| 478 | 480 | kobject_put(&glob->kobj); |
|---|
| 481 | + memset(glob, 0, sizeof(*glob)); |
|---|
| 479 | 482 | } |
|---|
| 480 | | -EXPORT_SYMBOL(ttm_mem_global_release); |
|---|
| 481 | 483 | |
|---|
| 482 | 484 | static void ttm_check_swapping(struct ttm_mem_global *glob) |
|---|
| 483 | 485 | { |
|---|
| .. | .. |
|---|
| 521 | 523 | void ttm_mem_global_free(struct ttm_mem_global *glob, |
|---|
| 522 | 524 | uint64_t amount) |
|---|
| 523 | 525 | { |
|---|
| 524 | | - return ttm_mem_global_free_zone(glob, NULL, amount); |
|---|
| 526 | + return ttm_mem_global_free_zone(glob, glob->zone_kernel, amount); |
|---|
| 525 | 527 | } |
|---|
| 526 | 528 | EXPORT_SYMBOL(ttm_mem_global_free); |
|---|
| 527 | 529 | |
|---|
| .. | .. |
|---|
| 552 | 554 | |
|---|
| 553 | 555 | return false; |
|---|
| 554 | 556 | } |
|---|
| 555 | | -EXPORT_SYMBOL(ttm_check_under_lowerlimit); |
|---|
| 556 | 557 | |
|---|
| 557 | 558 | static int ttm_mem_global_reserve(struct ttm_mem_global *glob, |
|---|
| 558 | 559 | struct ttm_mem_zone *single_zone, |
|---|
| .. | .. |
|---|
| 620 | 621 | { |
|---|
| 621 | 622 | /** |
|---|
| 622 | 623 | * Normal allocations of kernel memory are registered in |
|---|
| 623 | | - * all zones. |
|---|
| 624 | + * the kernel zone. |
|---|
| 624 | 625 | */ |
|---|
| 625 | 626 | |
|---|
| 626 | | - return ttm_mem_global_alloc_zone(glob, NULL, memory, ctx); |
|---|
| 627 | + return ttm_mem_global_alloc_zone(glob, glob->zone_kernel, memory, ctx); |
|---|
| 627 | 628 | } |
|---|
| 628 | 629 | EXPORT_SYMBOL(ttm_mem_global_alloc); |
|---|
| 629 | 630 | |
|---|
| .. | .. |
|---|
| 680 | 681 | return 0; |
|---|
| 681 | 682 | } |
|---|
| 682 | 683 | EXPORT_SYMBOL(ttm_round_pot); |
|---|
| 683 | | - |
|---|
| 684 | | -uint64_t ttm_get_kernel_zone_memory_size(struct ttm_mem_global *glob) |
|---|
| 685 | | -{ |
|---|
| 686 | | - return glob->zone_kernel->max_mem; |
|---|
| 687 | | -} |
|---|
| 688 | | -EXPORT_SYMBOL(ttm_get_kernel_zone_memory_size); |
|---|