• Home
  • Raw
  • Download

Lines Matching refs:glob

51 	struct ttm_mem_global *glob;  member
99 spin_lock(&zone->glob->lock); in ttm_mem_zone_show()
110 spin_unlock(&zone->glob->lock); in ttm_mem_zone_show()
116 static void ttm_check_swapping(struct ttm_mem_global *glob);
136 spin_lock(&zone->glob->lock); in ttm_mem_zone_store()
149 spin_unlock(&zone->glob->lock); in ttm_mem_zone_store()
151 ttm_check_swapping(zone->glob); in ttm_mem_zone_store()
177 static bool ttm_zones_above_swap_target(struct ttm_mem_global *glob, in ttm_zones_above_swap_target() argument
184 for (i = 0; i < glob->num_zones; ++i) { in ttm_zones_above_swap_target()
185 zone = glob->zones[i]; in ttm_zones_above_swap_target()
209 static void ttm_shrink(struct ttm_mem_global *glob, bool from_wq, in ttm_shrink() argument
214 spin_lock(&glob->lock); in ttm_shrink()
216 while (ttm_zones_above_swap_target(glob, from_wq, extra)) { in ttm_shrink()
217 spin_unlock(&glob->lock); in ttm_shrink()
219 spin_lock(&glob->lock); in ttm_shrink()
224 spin_unlock(&glob->lock); in ttm_shrink()
233 struct ttm_mem_global *glob = in ttm_shrink_work() local
236 ttm_shrink(glob, true, 0ULL, &ctx); in ttm_shrink_work()
239 static int ttm_mem_init_kernel_zone(struct ttm_mem_global *glob, in ttm_mem_init_kernel_zone() argument
258 zone->glob = glob; in ttm_mem_init_kernel_zone()
259 glob->zone_kernel = zone; in ttm_mem_init_kernel_zone()
261 &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, zone->name); in ttm_mem_init_kernel_zone()
266 glob->zones[glob->num_zones++] = zone; in ttm_mem_init_kernel_zone()
271 static int ttm_mem_init_highmem_zone(struct ttm_mem_global *glob, in ttm_mem_init_highmem_zone() argument
294 zone->glob = glob; in ttm_mem_init_highmem_zone()
295 glob->zone_highmem = zone; in ttm_mem_init_highmem_zone()
297 &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, "%s", in ttm_mem_init_highmem_zone()
303 glob->zones[glob->num_zones++] = zone; in ttm_mem_init_highmem_zone()
307 static int ttm_mem_init_dma32_zone(struct ttm_mem_global *glob, in ttm_mem_init_dma32_zone() argument
342 zone->glob = glob; in ttm_mem_init_dma32_zone()
343 glob->zone_dma32 = zone; in ttm_mem_init_dma32_zone()
345 &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, zone->name); in ttm_mem_init_dma32_zone()
350 glob->zones[glob->num_zones++] = zone; in ttm_mem_init_dma32_zone()
355 int ttm_mem_global_init(struct ttm_mem_global *glob, struct device *dev) in ttm_mem_global_init() argument
362 spin_lock_init(&glob->lock); in ttm_mem_global_init()
363 glob->swap_queue = create_singlethread_workqueue("ttm_swap"); in ttm_mem_global_init()
364 INIT_WORK(&glob->work, ttm_shrink_work); in ttm_mem_global_init()
366 ret = kobject_init_and_add(&glob->kobj, &ttm_mem_glob_kobj_type, in ttm_mem_global_init()
369 kobject_put(&glob->kobj); in ttm_mem_global_init()
375 ret = ttm_mem_init_kernel_zone(glob, &si); in ttm_mem_global_init()
379 ret = ttm_mem_init_highmem_zone(glob, &si); in ttm_mem_global_init()
383 ret = ttm_mem_init_dma32_zone(glob, &si); in ttm_mem_global_init()
387 for (i = 0; i < glob->num_zones; ++i) { in ttm_mem_global_init()
388 zone = glob->zones[i]; in ttm_mem_global_init()
394 ttm_mem_global_release(glob); in ttm_mem_global_init()
398 void ttm_mem_global_release(struct ttm_mem_global *glob) in ttm_mem_global_release() argument
403 flush_workqueue(glob->swap_queue); in ttm_mem_global_release()
404 destroy_workqueue(glob->swap_queue); in ttm_mem_global_release()
405 glob->swap_queue = NULL; in ttm_mem_global_release()
406 for (i = 0; i < glob->num_zones; ++i) { in ttm_mem_global_release()
407 zone = glob->zones[i]; in ttm_mem_global_release()
411 kobject_del(&glob->kobj); in ttm_mem_global_release()
412 kobject_put(&glob->kobj); in ttm_mem_global_release()
413 memset(glob, 0, sizeof(*glob)); in ttm_mem_global_release()
416 static void ttm_check_swapping(struct ttm_mem_global *glob) in ttm_check_swapping() argument
422 spin_lock(&glob->lock); in ttm_check_swapping()
423 for (i = 0; i < glob->num_zones; ++i) { in ttm_check_swapping()
424 zone = glob->zones[i]; in ttm_check_swapping()
431 spin_unlock(&glob->lock); in ttm_check_swapping()
434 (void)queue_work(glob->swap_queue, &glob->work); in ttm_check_swapping()
438 static void ttm_mem_global_free_zone(struct ttm_mem_global *glob, in ttm_mem_global_free_zone() argument
445 spin_lock(&glob->lock); in ttm_mem_global_free_zone()
446 for (i = 0; i < glob->num_zones; ++i) { in ttm_mem_global_free_zone()
447 zone = glob->zones[i]; in ttm_mem_global_free_zone()
452 spin_unlock(&glob->lock); in ttm_mem_global_free_zone()
455 void ttm_mem_global_free(struct ttm_mem_global *glob, in ttm_mem_global_free() argument
458 return ttm_mem_global_free_zone(glob, glob->zone_kernel, amount); in ttm_mem_global_free()
462 static int ttm_mem_global_reserve(struct ttm_mem_global *glob, in ttm_mem_global_reserve() argument
471 spin_lock(&glob->lock); in ttm_mem_global_reserve()
472 for (i = 0; i < glob->num_zones; ++i) { in ttm_mem_global_reserve()
473 zone = glob->zones[i]; in ttm_mem_global_reserve()
485 for (i = 0; i < glob->num_zones; ++i) { in ttm_mem_global_reserve()
486 zone = glob->zones[i]; in ttm_mem_global_reserve()
495 spin_unlock(&glob->lock); in ttm_mem_global_reserve()
496 ttm_check_swapping(glob); in ttm_mem_global_reserve()
502 static int ttm_mem_global_alloc_zone(struct ttm_mem_global *glob, in ttm_mem_global_alloc_zone() argument
509 while (unlikely(ttm_mem_global_reserve(glob, in ttm_mem_global_alloc_zone()
517 ttm_shrink(glob, false, memory + (memory >> 2) + 16, ctx); in ttm_mem_global_alloc_zone()
523 int ttm_mem_global_alloc(struct ttm_mem_global *glob, uint64_t memory, in ttm_mem_global_alloc() argument
531 return ttm_mem_global_alloc_zone(glob, glob->zone_kernel, memory, ctx); in ttm_mem_global_alloc()
535 int ttm_mem_global_alloc_page(struct ttm_mem_global *glob, in ttm_mem_global_alloc_page() argument
547 if (PageHighMem(page) && glob->zone_highmem != NULL) in ttm_mem_global_alloc_page()
548 zone = glob->zone_highmem; in ttm_mem_global_alloc_page()
550 if (glob->zone_dma32 && page_to_pfn(page) > 0x00100000UL) in ttm_mem_global_alloc_page()
551 zone = glob->zone_kernel; in ttm_mem_global_alloc_page()
553 return ttm_mem_global_alloc_zone(glob, zone, size, ctx); in ttm_mem_global_alloc_page()
556 void ttm_mem_global_free_page(struct ttm_mem_global *glob, struct page *page, in ttm_mem_global_free_page() argument
562 if (PageHighMem(page) && glob->zone_highmem != NULL) in ttm_mem_global_free_page()
563 zone = glob->zone_highmem; in ttm_mem_global_free_page()
565 if (glob->zone_dma32 && page_to_pfn(page) > 0x00100000UL) in ttm_mem_global_free_page()
566 zone = glob->zone_kernel; in ttm_mem_global_free_page()
568 ttm_mem_global_free_zone(glob, zone, size); in ttm_mem_global_free_page()