Lines Matching refs:tfile

127 	struct ttm_object_file *tfile;  member
133 ttm_object_file_ref(struct ttm_object_file *tfile) in ttm_object_file_ref() argument
135 kref_get(&tfile->refcount); in ttm_object_file_ref()
136 return tfile; in ttm_object_file_ref()
139 static int ttm_tfile_find_ref_rcu(struct ttm_object_file *tfile, in ttm_tfile_find_ref_rcu() argument
145 hash_for_each_possible_rcu(tfile->ref_hash, hash, head, key) { in ttm_tfile_find_ref_rcu()
154 static int ttm_tfile_find_ref(struct ttm_object_file *tfile, in ttm_tfile_find_ref() argument
160 hash_for_each_possible(tfile->ref_hash, hash, head, key) { in ttm_tfile_find_ref()
171 struct ttm_object_file *tfile = in ttm_object_file_destroy() local
174 kfree(tfile); in ttm_object_file_destroy()
180 struct ttm_object_file *tfile = *p_tfile; in ttm_object_file_unref() local
183 kref_put(&tfile->refcount, ttm_object_file_destroy); in ttm_object_file_unref()
187 int ttm_base_object_init(struct ttm_object_file *tfile, in ttm_base_object_init() argument
193 struct ttm_object_device *tdev = tfile->tdev; in ttm_base_object_init()
197 base->tfile = ttm_object_file_ref(tfile); in ttm_base_object_init()
210 ret = ttm_ref_object_add(tfile, base, NULL, false); in ttm_base_object_init()
228 struct ttm_object_device *tdev = base->tfile->tdev; in ttm_release_base()
240 ttm_object_file_unref(&base->tfile); in ttm_release_base()
254 struct ttm_base_object *ttm_base_object_lookup(struct ttm_object_file *tfile, in ttm_base_object_lookup() argument
261 spin_lock(&tfile->lock); in ttm_base_object_lookup()
262 ret = ttm_tfile_find_ref(tfile, key, &hash); in ttm_base_object_lookup()
269 spin_unlock(&tfile->lock); in ttm_base_object_lookup()
290 int ttm_ref_object_add(struct ttm_object_file *tfile, in ttm_ref_object_add() argument
299 if (base->tfile != tfile && !base->shareable) in ttm_ref_object_add()
307 ret = ttm_tfile_find_ref_rcu(tfile, base->handle, &hash); in ttm_ref_object_add()
328 ref->tfile = tfile; in ttm_ref_object_add()
331 spin_lock(&tfile->lock); in ttm_ref_object_add()
332 hash_add_rcu(tfile->ref_hash, &ref->hash.head, ref->hash.key); in ttm_ref_object_add()
335 list_add_tail(&ref->head, &tfile->ref_list); in ttm_ref_object_add()
337 spin_unlock(&tfile->lock); in ttm_ref_object_add()
345 static void __releases(tfile->lock) __acquires(tfile->lock)
350 struct ttm_object_file *tfile = ref->tfile; in ttm_ref_object_release() local
354 spin_unlock(&tfile->lock); in ttm_ref_object_release()
358 spin_lock(&tfile->lock); in ttm_ref_object_release()
361 int ttm_ref_object_base_unref(struct ttm_object_file *tfile, in ttm_ref_object_base_unref() argument
368 spin_lock(&tfile->lock); in ttm_ref_object_base_unref()
369 ret = ttm_tfile_find_ref(tfile, key, &hash); in ttm_ref_object_base_unref()
371 spin_unlock(&tfile->lock); in ttm_ref_object_base_unref()
376 spin_unlock(&tfile->lock); in ttm_ref_object_base_unref()
384 struct ttm_object_file *tfile = *p_tfile; in ttm_object_file_release() local
387 spin_lock(&tfile->lock); in ttm_object_file_release()
394 while (!list_empty(&tfile->ref_list)) { in ttm_object_file_release()
395 list = tfile->ref_list.next; in ttm_object_file_release()
400 spin_unlock(&tfile->lock); in ttm_object_file_release()
402 ttm_object_file_unref(&tfile); in ttm_object_file_release()
407 struct ttm_object_file *tfile = kmalloc(sizeof(*tfile), GFP_KERNEL); in ttm_object_file_init() local
409 if (unlikely(tfile == NULL)) in ttm_object_file_init()
412 spin_lock_init(&tfile->lock); in ttm_object_file_init()
413 tfile->tdev = tdev; in ttm_object_file_init()
414 kref_init(&tfile->refcount); in ttm_object_file_init()
415 INIT_LIST_HEAD(&tfile->ref_list); in ttm_object_file_init()
417 hash_init(tfile->ref_hash); in ttm_object_file_init()
419 return tfile; in ttm_object_file_init()
515 struct ttm_object_device *tdev = base->tfile->tdev; in ttm_prime_dmabuf_release()
537 int ttm_prime_fd_to_handle(struct ttm_object_file *tfile, in ttm_prime_fd_to_handle() argument
540 struct ttm_object_device *tdev = tfile->tdev; in ttm_prime_fd_to_handle()
556 ret = ttm_ref_object_add(tfile, base, NULL, false); in ttm_prime_fd_to_handle()
572 int ttm_prime_handle_to_fd(struct ttm_object_file *tfile, in ttm_prime_handle_to_fd() argument
576 struct ttm_object_device *tdev = tfile->tdev; in ttm_prime_handle_to_fd()
582 base = ttm_base_object_lookup(tfile, handle); in ttm_prime_handle_to_fd()
653 int ttm_prime_object_init(struct ttm_object_file *tfile, size_t size, in ttm_prime_object_init() argument
664 return ttm_base_object_init(tfile, &prime->base, shareable, in ttm_prime_object_init()