Lines Matching refs:ref
288 struct ttm_ref_object *ref; in ttm_ref_object_exists() local
299 ref = drm_hash_entry(hash, struct ttm_ref_object, hash); in ttm_ref_object_exists()
300 if (unlikely(base != ref->obj)) in ttm_ref_object_exists()
307 if (unlikely(atomic_read(&ref->kref.refcount) == 0)) in ttm_ref_object_exists()
324 struct ttm_ref_object *ref; in ttm_ref_object_add() local
340 ref = drm_hash_entry(hash, struct ttm_ref_object, hash); in ttm_ref_object_add()
341 if (kref_get_unless_zero(&ref->kref)) { in ttm_ref_object_add()
348 ret = ttm_mem_global_alloc(mem_glob, sizeof(*ref), in ttm_ref_object_add()
352 ref = kmalloc(sizeof(*ref), GFP_KERNEL); in ttm_ref_object_add()
353 if (unlikely(ref == NULL)) { in ttm_ref_object_add()
354 ttm_mem_global_free(mem_glob, sizeof(*ref)); in ttm_ref_object_add()
358 ref->hash.key = base->hash.key; in ttm_ref_object_add()
359 ref->obj = base; in ttm_ref_object_add()
360 ref->tfile = tfile; in ttm_ref_object_add()
361 ref->ref_type = ref_type; in ttm_ref_object_add()
362 kref_init(&ref->kref); in ttm_ref_object_add()
365 ret = drm_ht_insert_item_rcu(ht, &ref->hash); in ttm_ref_object_add()
368 list_add_tail(&ref->head, &tfile->ref_list); in ttm_ref_object_add()
379 ttm_mem_global_free(mem_glob, sizeof(*ref)); in ttm_ref_object_add()
380 kfree(ref); in ttm_ref_object_add()
389 struct ttm_ref_object *ref = in ttm_ref_object_release() local
391 struct ttm_base_object *base = ref->obj; in ttm_ref_object_release()
392 struct ttm_object_file *tfile = ref->tfile; in ttm_ref_object_release()
396 ht = &tfile->ref_hash[ref->ref_type]; in ttm_ref_object_release()
397 (void)drm_ht_remove_item_rcu(ht, &ref->hash); in ttm_ref_object_release()
398 list_del(&ref->head); in ttm_ref_object_release()
401 if (ref->ref_type != TTM_REF_USAGE && base->ref_obj_release) in ttm_ref_object_release()
402 base->ref_obj_release(base, ref->ref_type); in ttm_ref_object_release()
404 ttm_base_object_unref(&ref->obj); in ttm_ref_object_release()
405 ttm_mem_global_free(mem_glob, sizeof(*ref)); in ttm_ref_object_release()
406 kfree_rcu(ref, rcu_head); in ttm_ref_object_release()
414 struct ttm_ref_object *ref; in ttm_ref_object_base_unref() local
424 ref = drm_hash_entry(hash, struct ttm_ref_object, hash); in ttm_ref_object_base_unref()
425 kref_put(&ref->kref, ttm_ref_object_release); in ttm_ref_object_base_unref()
433 struct ttm_ref_object *ref; in ttm_object_file_release() local
448 ref = list_entry(list, struct ttm_ref_object, head); in ttm_object_file_release()
449 ttm_ref_object_release(&ref->kref); in ttm_object_file_release()