Lines Matching full:zone
47 MALLOC_DEFINE(M_TTM_ZONE, "ttm_zone", "TTM Zone");
49 static void ttm_mem_zone_kobj_release(struct ttm_mem_zone *zone) in ttm_mem_zone_kobj_release() argument
52 printf("[TTM] Zone %7s: Used memory at exit: %llu kiB\n", in ttm_mem_zone_kobj_release()
53 zone->name, (unsigned long long)zone->used_mem >> 10); in ttm_mem_zone_kobj_release()
54 free(zone, M_TTM_ZONE); in ttm_mem_zone_kobj_release()
59 static ssize_t ttm_mem_zone_show(struct ttm_mem_zone *zone;
65 mtx_lock(&zone->glob->lock);
67 val = zone->zone_mem;
69 val = zone->emer_mem;
71 val = zone->max_mem;
73 val = zone->swap_limit;
75 val = zone->used_mem;
76 mtx_unlock(&zone->glob->lock);
87 static ssize_t ttm_mem_zone_store(struct ttm_mem_zone *zone,
103 mtx_lock(&zone->glob->lock);
104 if (val64 > zone->zone_mem)
105 val64 = zone->zone_mem;
107 zone->emer_mem = val64;
108 if (zone->max_mem > val64)
109 zone->max_mem = val64;
111 zone->max_mem = val64;
112 if (zone->emer_mem < val64)
113 zone->emer_mem = val64;
115 zone->swap_limit = val64;
116 mtx_unlock(&zone->glob->lock);
118 ttm_check_swapping(zone->glob);
132 struct ttm_mem_zone *zone; in ttm_zones_above_swap_target() local
136 zone = glob->zones[i]; in ttm_zones_above_swap_target()
139 target = zone->swap_limit; in ttm_zones_above_swap_target()
141 target = zone->emer_mem; in ttm_zones_above_swap_target()
143 target = zone->max_mem; in ttm_zones_above_swap_target()
147 if (zone->used_mem > target) in ttm_zones_above_swap_target()
194 struct ttm_mem_zone *zone; in ttm_mem_init_kernel_zone() local
196 zone = malloc(sizeof(*zone), M_TTM_ZONE, M_WAITOK | M_ZERO); in ttm_mem_init_kernel_zone()
198 zone->name = "kernel"; in ttm_mem_init_kernel_zone()
199 zone->zone_mem = mem; in ttm_mem_init_kernel_zone()
200 zone->max_mem = mem >> 1; in ttm_mem_init_kernel_zone()
201 zone->emer_mem = (mem >> 1) + (mem >> 2); in ttm_mem_init_kernel_zone()
202 zone->swap_limit = zone->max_mem - (mem >> 3); in ttm_mem_init_kernel_zone()
203 zone->used_mem = 0; in ttm_mem_init_kernel_zone()
204 zone->glob = glob; in ttm_mem_init_kernel_zone()
205 glob->zone_kernel = zone; in ttm_mem_init_kernel_zone()
206 refcount_init(&zone->kobj_ref, 1); in ttm_mem_init_kernel_zone()
207 glob->zones[glob->num_zones++] = zone; in ttm_mem_init_kernel_zone()
214 struct ttm_mem_zone *zone; in ttm_mem_init_dma32_zone() local
216 zone = malloc(sizeof(*zone), M_TTM_ZONE, M_WAITOK | M_ZERO); in ttm_mem_init_dma32_zone()
219 * No special dma32 zone needed. in ttm_mem_init_dma32_zone()
223 free(zone, M_TTM_ZONE); in ttm_mem_init_dma32_zone()
230 * zone really is. in ttm_mem_init_dma32_zone()
234 zone->name = "dma32"; in ttm_mem_init_dma32_zone()
235 zone->zone_mem = mem; in ttm_mem_init_dma32_zone()
236 zone->max_mem = mem >> 1; in ttm_mem_init_dma32_zone()
237 zone->emer_mem = (mem >> 1) + (mem >> 2); in ttm_mem_init_dma32_zone()
238 zone->swap_limit = zone->max_mem - (mem >> 3); in ttm_mem_init_dma32_zone()
239 zone->used_mem = 0; in ttm_mem_init_dma32_zone()
240 zone->glob = glob; in ttm_mem_init_dma32_zone()
241 glob->zone_dma32 = zone; in ttm_mem_init_dma32_zone()
242 refcount_init(&zone->kobj_ref, 1); in ttm_mem_init_dma32_zone()
243 glob->zones[glob->num_zones++] = zone; in ttm_mem_init_dma32_zone()
252 struct ttm_mem_zone *zone; in ttm_mem_global_init() local
271 zone = glob->zones[i]; in ttm_mem_global_init()
272 printf("[TTM] Zone %7s: Available graphics memory: %llu kiB\n", in ttm_mem_global_init()
273 zone->name, (unsigned long long)zone->max_mem >> 10); in ttm_mem_global_init()
286 struct ttm_mem_zone *zone; in ttm_mem_global_release() local
296 zone = glob->zones[i]; in ttm_mem_global_release()
297 if (refcount_release(&zone->kobj_ref)) in ttm_mem_global_release()
298 ttm_mem_zone_kobj_release(zone); in ttm_mem_global_release()
308 struct ttm_mem_zone *zone; in ttm_check_swapping() local
312 zone = glob->zones[i]; in ttm_check_swapping()
313 if (zone->used_mem > zone->swap_limit) { in ttm_check_swapping()
331 struct ttm_mem_zone *zone; in ttm_mem_global_free_zone() local
335 zone = glob->zones[i]; in ttm_mem_global_free_zone()
336 if (single_zone && zone != single_zone) in ttm_mem_global_free_zone()
338 zone->used_mem -= amount; in ttm_mem_global_free_zone()
356 struct ttm_mem_zone *zone; in ttm_mem_global_reserve() local
360 zone = glob->zones[i]; in ttm_mem_global_reserve()
361 if (single_zone && zone != single_zone) in ttm_mem_global_reserve()
365 zone->emer_mem : zone->max_mem; in ttm_mem_global_reserve()
367 if (zone->used_mem > limit) in ttm_mem_global_reserve()
373 zone = glob->zones[i]; in ttm_mem_global_reserve()
374 if (single_zone && zone != single_zone) in ttm_mem_global_reserve()
376 zone->used_mem += amount; in ttm_mem_global_reserve()
429 struct ttm_mem_zone *zone = NULL; in ttm_mem_global_alloc_page() local
432 * Page allocations may be registed in a single zone in ttm_mem_global_alloc_page()
437 zone = glob->zone_kernel; in ttm_mem_global_alloc_page()
438 return ttm_mem_global_alloc_zone(glob, zone, PAGE_SIZE, no_wait, in ttm_mem_global_alloc_page()
444 struct ttm_mem_zone *zone = NULL; in ttm_mem_global_free_page() local
447 zone = glob->zone_kernel; in ttm_mem_global_free_page()
448 ttm_mem_global_free_zone(glob, zone, PAGE_SIZE); in ttm_mem_global_free_page()