Lines Matching refs:mmg
20 struct hl_mmap_mem_buf *hl_mmap_mem_buf_get(struct hl_mem_mgr *mmg, u64 handle) in hl_mmap_mem_buf_get() argument
24 spin_lock(&mmg->lock); in hl_mmap_mem_buf_get()
25 buf = idr_find(&mmg->handles, lower_32_bits(handle >> PAGE_SHIFT)); in hl_mmap_mem_buf_get()
27 spin_unlock(&mmg->lock); in hl_mmap_mem_buf_get()
28 dev_dbg(mmg->dev, "Buff get failed, no match to handle %#llx\n", handle); in hl_mmap_mem_buf_get()
32 spin_unlock(&mmg->lock); in hl_mmap_mem_buf_get()
66 spin_lock(&buf->mmg->lock); in hl_mmap_mem_buf_release()
67 idr_remove(&buf->mmg->handles, lower_32_bits(buf->handle >> PAGE_SHIFT)); in hl_mmap_mem_buf_release()
68 spin_unlock(&buf->mmg->lock); in hl_mmap_mem_buf_release()
86 idr_remove(&buf->mmg->handles, lower_32_bits(buf->handle >> PAGE_SHIFT)); in hl_mmap_mem_buf_remove_idr_locked()
113 int hl_mmap_mem_buf_put_handle(struct hl_mem_mgr *mmg, u64 handle) in hl_mmap_mem_buf_put_handle() argument
117 spin_lock(&mmg->lock); in hl_mmap_mem_buf_put_handle()
118 buf = idr_find(&mmg->handles, lower_32_bits(handle >> PAGE_SHIFT)); in hl_mmap_mem_buf_put_handle()
120 spin_unlock(&mmg->lock); in hl_mmap_mem_buf_put_handle()
121 dev_dbg(mmg->dev, in hl_mmap_mem_buf_put_handle()
127 spin_unlock(&mmg->lock); in hl_mmap_mem_buf_put_handle()
132 spin_unlock(&mmg->lock); in hl_mmap_mem_buf_put_handle()
148 hl_mmap_mem_buf_alloc(struct hl_mem_mgr *mmg, in hl_mmap_mem_buf_alloc() argument
159 spin_lock(&mmg->lock); in hl_mmap_mem_buf_alloc()
160 rc = idr_alloc(&mmg->handles, buf, 1, 0, GFP_ATOMIC); in hl_mmap_mem_buf_alloc()
161 spin_unlock(&mmg->lock); in hl_mmap_mem_buf_alloc()
163 dev_err(mmg->dev, in hl_mmap_mem_buf_alloc()
169 buf->mmg = mmg; in hl_mmap_mem_buf_alloc()
176 dev_err(mmg->dev, "%s: Failure in buffer alloc callback %d\n", in hl_mmap_mem_buf_alloc()
184 spin_lock(&mmg->lock); in hl_mmap_mem_buf_alloc()
185 idr_remove(&mmg->handles, lower_32_bits(buf->handle >> PAGE_SHIFT)); in hl_mmap_mem_buf_alloc()
186 spin_unlock(&mmg->lock); in hl_mmap_mem_buf_alloc()
230 int hl_mem_mgr_mmap(struct hl_mem_mgr *mmg, struct vm_area_struct *vma, argument
245 buf = hl_mmap_mem_buf_get(mmg, handle);
247 dev_err(mmg->dev,
255 dev_err(mmg->dev,
269 dev_err(mmg->dev, "%s: User pointer is invalid - 0x%lx\n",
277 dev_err(mmg->dev,
314 void hl_mem_mgr_init(struct device *dev, struct hl_mem_mgr *mmg) argument
316 mmg->dev = dev;
317 spin_lock_init(&mmg->lock);
318 idr_init(&mmg->handles);
355 void hl_mem_mgr_fini(struct hl_mem_mgr *mmg, struct hl_mem_mgr_fini_stats *stats) argument
365 idp = &mmg->handles;
371 dev_err(mmg->dev,
386 void hl_mem_mgr_idr_destroy(struct hl_mem_mgr *mmg) argument
388 if (!idr_is_empty(&mmg->handles))
389 dev_crit(mmg->dev, "memory manager IDR is destroyed while it is not empty!\n");
391 idr_destroy(&mmg->handles);