Lines Matching full:mem
34 intel_memory_region_free_pages(struct intel_memory_region *mem, in intel_memory_region_free_pages() argument
41 size += i915_buddy_block_size(&mem->mm, block); in intel_memory_region_free_pages()
42 i915_buddy_free(&mem->mm, block); in intel_memory_region_free_pages()
50 __intel_memory_region_put_pages_buddy(struct intel_memory_region *mem, in __intel_memory_region_put_pages_buddy() argument
53 mutex_lock(&mem->mm_lock); in __intel_memory_region_put_pages_buddy()
54 mem->avail += intel_memory_region_free_pages(mem, blocks); in __intel_memory_region_put_pages_buddy()
55 mutex_unlock(&mem->mm_lock); in __intel_memory_region_put_pages_buddy()
69 __intel_memory_region_get_pages_buddy(struct intel_memory_region *mem, in __intel_memory_region_get_pages_buddy() argument
77 GEM_BUG_ON(!IS_ALIGNED(size, mem->mm.chunk_size)); in __intel_memory_region_get_pages_buddy()
81 min_order = ilog2(mem->min_page_size) - in __intel_memory_region_get_pages_buddy()
82 ilog2(mem->mm.chunk_size); in __intel_memory_region_get_pages_buddy()
87 min_order = ilog2(size) - ilog2(mem->mm.chunk_size); in __intel_memory_region_get_pages_buddy()
90 if (size > mem->mm.size) in __intel_memory_region_get_pages_buddy()
93 n_pages = size >> ilog2(mem->mm.chunk_size); in __intel_memory_region_get_pages_buddy()
95 mutex_lock(&mem->mm_lock); in __intel_memory_region_get_pages_buddy()
102 GEM_BUG_ON(order > mem->mm.max_order); in __intel_memory_region_get_pages_buddy()
106 block = i915_buddy_alloc(&mem->mm, order); in __intel_memory_region_get_pages_buddy()
116 block->private = mem; in __intel_memory_region_get_pages_buddy()
123 mem->avail -= size; in __intel_memory_region_get_pages_buddy()
124 mutex_unlock(&mem->mm_lock); in __intel_memory_region_get_pages_buddy()
128 intel_memory_region_free_pages(mem, blocks); in __intel_memory_region_get_pages_buddy()
129 mutex_unlock(&mem->mm_lock); in __intel_memory_region_get_pages_buddy()
134 __intel_memory_region_get_block_buddy(struct intel_memory_region *mem, in __intel_memory_region_get_block_buddy() argument
142 ret = __intel_memory_region_get_pages_buddy(mem, size, flags, &blocks); in __intel_memory_region_get_block_buddy()
151 int intel_memory_region_init_buddy(struct intel_memory_region *mem) in intel_memory_region_init_buddy() argument
153 return i915_buddy_init(&mem->mm, resource_size(&mem->region), in intel_memory_region_init_buddy()
157 void intel_memory_region_release_buddy(struct intel_memory_region *mem) in intel_memory_region_release_buddy() argument
159 i915_buddy_fini(&mem->mm); in intel_memory_region_release_buddy()
170 struct intel_memory_region *mem; in intel_memory_region_create() local
173 mem = kzalloc(sizeof(*mem), GFP_KERNEL); in intel_memory_region_create()
174 if (!mem) in intel_memory_region_create()
177 mem->i915 = i915; in intel_memory_region_create()
178 mem->region = (struct resource)DEFINE_RES_MEM(start, size); in intel_memory_region_create()
179 mem->io_start = io_start; in intel_memory_region_create()
180 mem->min_page_size = min_page_size; in intel_memory_region_create()
181 mem->ops = ops; in intel_memory_region_create()
182 mem->total = size; in intel_memory_region_create()
183 mem->avail = mem->total; in intel_memory_region_create()
185 mutex_init(&mem->objects.lock); in intel_memory_region_create()
186 INIT_LIST_HEAD(&mem->objects.list); in intel_memory_region_create()
187 INIT_LIST_HEAD(&mem->objects.purgeable); in intel_memory_region_create()
189 mutex_init(&mem->mm_lock); in intel_memory_region_create()
192 err = ops->init(mem); in intel_memory_region_create()
197 kref_init(&mem->kref); in intel_memory_region_create()
198 return mem; in intel_memory_region_create()
201 kfree(mem); in intel_memory_region_create()
205 void intel_memory_region_set_name(struct intel_memory_region *mem, in intel_memory_region_set_name() argument
211 vsnprintf(mem->name, sizeof(mem->name), fmt, ap); in intel_memory_region_set_name()
217 struct intel_memory_region *mem = in __intel_memory_region_destroy() local
218 container_of(kref, typeof(*mem), kref); in __intel_memory_region_destroy()
220 if (mem->ops->release) in __intel_memory_region_destroy()
221 mem->ops->release(mem); in __intel_memory_region_destroy()
223 mutex_destroy(&mem->mm_lock); in __intel_memory_region_destroy()
224 mutex_destroy(&mem->objects.lock); in __intel_memory_region_destroy()
225 kfree(mem); in __intel_memory_region_destroy()
229 intel_memory_region_get(struct intel_memory_region *mem) in intel_memory_region_get() argument
231 kref_get(&mem->kref); in intel_memory_region_get()
232 return mem; in intel_memory_region_get()
235 void intel_memory_region_put(struct intel_memory_region *mem) in intel_memory_region_put() argument
237 kref_put(&mem->kref, __intel_memory_region_destroy); in intel_memory_region_put()
247 struct intel_memory_region *mem = ERR_PTR(-ENODEV); in intel_memory_regions_hw_probe() local
256 mem = i915_gem_shmem_setup(i915); in intel_memory_regions_hw_probe()
259 mem = i915_gem_stolen_setup(i915); in intel_memory_regions_hw_probe()
262 mem = intel_setup_fake_lmem(i915); in intel_memory_regions_hw_probe()
266 if (IS_ERR(mem)) { in intel_memory_regions_hw_probe()
267 err = PTR_ERR(mem); in intel_memory_regions_hw_probe()
274 mem->id = intel_region_map[i]; in intel_memory_regions_hw_probe()
275 mem->type = type; in intel_memory_regions_hw_probe()
276 mem->instance = MEMORY_INSTANCE_FROM_REGION(intel_region_map[i]); in intel_memory_regions_hw_probe()
278 i915->mm.regions[i] = mem; in intel_memory_regions_hw_probe()