Switch reference counting to GEM instead of TTM
Subsystems (7)
Hello everyone,
to make use of drm_exec it is necessary to have TTM drivers actually use the GEM reference count instead of the TTM one.
This patch set is a start to do that. It switches all uses of ttm_bo_get/put to the GEM counterpart and then makes ttm_bo_get private to TTM.
Netx step is to completely remove the TTM refcounting.
Please review and/or comment.
Cheers,
Christian.
PATCH 1/9 drm/amdgpu: use GEM references instead of TTMs
Instead of a TTM reference grab a GEM reference whenever necessary.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 8 ++++---- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 7 ++----- 2 files changed, 6 insertions(+), 9 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +4 -4
@@ -87,11 +87,11 @@ static const struct vm_operations_struct amdgpu_gem_vm_ops = {static void amdgpu_gem_object_free (struct drm_gem_object *gobj) { -struct amdgpu_bo *robj =gem_to_amdgpu_bo (gobj); +struct amdgpu_bo *aobj =gem_to_amdgpu_bo (gobj); -if (robj) { -amdgpu_hmm_unregister (robj); -amdgpu_bo_unref (&robj); +if (aobj) { +amdgpu_hmm_unregister (aobj); +ttm_bo_put (&aobj->tbo); } }
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +2 -5
@@ -853,7 +853,7 @@ struct amdgpu_bo *amdgpu_bo_ref(struct amdgpu_bo *bo)if (bo ==NULL )return NULL ; -ttm_bo_get (&bo->tbo); +drm_gem_object_get (&bo->tbo.base);return bo; }
@@ -865,13 +865,10 @@ struct amdgpu_bo *amdgpu_bo_ref(struct amdgpu_bo *bo)*/ void amdgpu_bo_unref (struct amdgpu_bo **bo) { -struct ttm_buffer_object *tbo; -if ((*bo) ==NULL )return ; - tbo = &((*bo)->tbo); -ttm_bo_put (tbo); +drm_gem_object_get (&(*bo)->tbo.base); *bo =NULL ; }
Signature · 1 line
2.34.1
Matthew Brost
reviewerRe: [PATCH 1/9] drm/amdgpu: use GEM references instead of TTMs
Quoted 15 lines · Christian König
Instead of a TTM reference grab a GEM reference whenever necessary.
Signed-off-by Christian König <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 8 ++++---- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 7 ++----- 2 files changed, 6 insertions(+), 9 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +0
-0@@ -87,11 +87,11 @@ static const struct vm_operations_struct amdgpu_gem_vm_ops = {static void amdgpu_gem_object_free (struct drm_gem_object *gobj)
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c static const struct vm_operations_struct amdgpu_gem_vm_ops = { · line 94
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +4
-4{ -struct amdgpu_bo *robj =gem_to_amdgpu_bo (gobj); +struct amdgpu_bo *aobj =gem_to_amdgpu_bo (gobj); -if (robj) { -amdgpu_hmm_unregister (robj); -amdgpu_bo_unref (&robj); +if (aobj) { +amdgpu_hmm_unregister (aobj); +ttm_bo_put (&aobj->tbo);
So, this relates to my comment in patch number #9 about dropping the TTM ref count. If TTM only uses the GEM ref count, could we convert this ttm_bo_put to something like ttm_bo_fini here (also in Xe and any other drivers with code like this)?
I think that might be cleaner.
Matt
Quoted 34 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +0
-0} }drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +2
-5@@ -853,7 +853,7 @@ struct amdgpu_bo *amdgpu_bo_ref(struct amdgpu_bo *bo)if (bo ==NULL )return NULL ; -ttm_bo_get (&bo->tbo); +drm_gem_object_get (&bo->tbo.base);return bo; }@@ -865,13 +865,10 @@ struct amdgpu_bo *amdgpu_bo_ref(struct amdgpu_bo *bo)*/ void amdgpu_bo_unref (struct amdgpu_bo **bo) { -struct ttm_buffer_object *tbo; -if ((*bo) ==NULL )return ; - tbo = &((*bo)->tbo); -ttm_bo_put (tbo); +drm_gem_object_get (&(*bo)->tbo.base); *bo =NULL ; }Signature · 1 line
2.34.1
Re: [PATCH 1/9] drm/amdgpu: use GEM references instead of TTMs
Am 16.07.24 um 23:53 schrieb Matthew Brost:
Quoted 20 lines · Christian König
Quoted 19 lines
Instead of a TTM reference grab a GEM reference whenever necessary.
Signed-off-by Christian König <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 8 ++++---- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 7 ++----- 2 files changed, 6 insertions(+), 9 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +1
-1@@ -87,11 +87,11 @@ static const struct vm_operations_struct amdgpu_gem_vm_ops = {static void amdgpu_gem_object_free (struct drm_gem_object *gobj) { -struct amdgpu_bo *robj =gem_to_amdgpu_bo (gobj); +struct amdgpu_bo *aobj =gem_to_amdgpu_bo (gobj);
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c static const struct vm_operations_struct amdgpu_gem_vm_ops = { · line 94
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +3
-3-if (robj) { -amdgpu_hmm_unregister (robj); -amdgpu_bo_unref (&robj); +if (aobj) { +amdgpu_hmm_unregister (aobj); +ttm_bo_put (&aobj->tbo);So, this relates to my comment in patch number #9 about dropping the TTM ref count. If TTM only uses the GEM ref count, could we convert this
ttm_bo_putto something likettm_bo_finihere (also in Xe and any other drivers with code like this)?
That's exactly what I was planning to do as a follow up.
Regards,
Christian.
Quoted 39 lines
I think that might be cleaner.
Matt
Quoted 34 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +0
-0} }drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +2
-5@@ -853,7 +853,7 @@ struct amdgpu_bo *amdgpu_bo_ref(struct amdgpu_bo *bo)if (bo ==NULL )return NULL ; -ttm_bo_get (&bo->tbo); +drm_gem_object_get (&bo->tbo.base);return bo; }@@ -865,13 +865,10 @@ struct amdgpu_bo *amdgpu_bo_ref(struct amdgpu_bo *bo)*/ void amdgpu_bo_unref (struct amdgpu_bo **bo) { -struct ttm_buffer_object *tbo; -if ((*bo) ==NULL )return ; - tbo = &((*bo)->tbo); -ttm_bo_put (tbo); +drm_gem_object_get (&(*bo)->tbo.base); *bo =NULL ; }Signature · 1 line
2.34.1
Matthew Brost
reviewerRe: [PATCH 1/9] drm/amdgpu: use GEM references instead of TTMs
Quoted 30 lines · Christian König
Am 16.07.24 um 23:53 schrieb Matthew Brost:
Quoted 20 lines · Christian König
Quoted 19 lines
Instead of a TTM reference grab a GEM reference whenever necessary.
Signed-off-by Christian König <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 8 ++++---- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 7 ++----- 2 files changed, 6 insertions(+), 9 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +1
-3@@ -87,11 +87,11 @@ static const struct vm_operations_struct amdgpu_gem_vm_ops = {static void amdgpu_gem_object_free (struct drm_gem_object *gobj) { -struct amdgpu_bo *robj =gem_to_amdgpu_bo (gobj); +struct amdgpu_bo *aobj =gem_to_amdgpu_bo (gobj); -if (robj) { -amdgpu_hmm_unregister (robj);Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c static const struct vm_operations_struct amdgpu_gem_vm_ops = { · line 94
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +3
-1-amdgpu_bo_unref (&robj); +if (aobj) { +amdgpu_hmm_unregister (aobj); +ttm_bo_put (&aobj->tbo);So, this relates to my comment in patch number #9 about dropping the TTM ref count. If TTM only uses the GEM ref count, could we convert this
ttm_bo_putto something likettm_bo_finihere (also in Xe and any other drivers with code like this)?
Quoted 2 lines
That's exactly what I was planning to do as a follow up.
Cool, glad we are aligned.
Matt
Quoted 38 lines
Regards,
Christian.Quoted 34 lines
I think that might be cleaner.
Matt
Quoted 29 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +0
-0} }drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +2
-5@@ -853,7 +853,7 @@ struct amdgpu_bo *amdgpu_bo_ref(struct amdgpu_bo *bo)if (bo ==NULL )return NULL ; -ttm_bo_get (&bo->tbo); +drm_gem_object_get (&bo->tbo.base);return bo; }@@ -865,13 +865,10 @@ struct amdgpu_bo *amdgpu_bo_ref(struct amdgpu_bo *bo)*/ void amdgpu_bo_unref (struct amdgpu_bo **bo) { -struct ttm_buffer_object *tbo; -if ((*bo) ==NULL )return ; - tbo = &((*bo)->tbo); -ttm_bo_put (tbo); +drm_gem_object_get (&(*bo)->tbo.base); *bo =NULL ; }Signature · 1 line
2.34.1
PATCH 2/9 drm/loongson: use GEM references instead of TTMs
In reply to Christian KönigInstead of a TTM reference grab a GEM reference whenever necessary.
--- drivers/gpu/drm/loongson/lsdc_ttm.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/gpu/drm/loongson/lsdc_ttm.c +2 -6
@@ -341,16 +341,12 @@ void lsdc_bo_unpin(struct lsdc_bo *lbo)void lsdc_bo_ref (struct lsdc_bo *lbo) { -struct ttm_buffer_object *tbo = &lbo->tbo; - -ttm_bo_get (tbo); +drm_gem_object_get (&lbo->tbo.base); }void lsdc_bo_unref (struct lsdc_bo *lbo) { -struct ttm_buffer_object *tbo = &lbo->tbo; - -ttm_bo_put (tbo); +drm_gem_object_put (&lbo->tbo.base); }int lsdc_bo_kmap (struct lsdc_bo *lbo)
Signature · 1 line
2.34.1
PATCH 3/9 drm/nouveau: use GEM references instead of TTMs
In reply to Christian KönigInstead of a TTM reference grab a GEM reference whenever necessary.
--- drivers/gpu/drm/nouveau/nouveau_bo.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/nouveau/nouveau_bo.h +2 -2
@@ -63,13 +63,13 @@ nouveau_bo_ref(struct nouveau_bo *ref, struct nouveau_bo **pnvbo) prev = *pnvbo;if (ref) { -ttm_bo_get (&ref->bo); +drm_gem_object_get (&ref->bo.base); *pnvbo =nouveau_bo (&ref->bo); }else { *pnvbo =NULL ; }if (prev) -ttm_bo_put (&prev->bo); +drm_gem_object_put (&prev->bo.base);return 0 ; }
Signature · 1 line
2.34.1
PATCH 4/9 drm/radeon: use GEM references instead of TTMs
In reply to Christian KönigInstead of a TTM reference grab a GEM reference whenever necessary.
--- drivers/gpu/drm/radeon/radeon_gem.c | 2 +- drivers/gpu/drm/radeon/radeon_object.c | 7 ++----- 2 files changed, 3 insertions(+), 6 deletions(-)
drivers/gpu/drm/radeon/radeon_gem.c +1 -1
@@ -88,7 +88,7 @@ static void radeon_gem_object_free(struct drm_gem_object *gobj)if (robj) {radeon_mn_unregister (robj); -radeon_bo_unref (&robj); +ttm_bo_put (&robj->tbo); } }
drivers/gpu/drm/radeon/radeon_object.c +2 -5
@@ -256,18 +256,15 @@ struct radeon_bo *radeon_bo_ref(struct radeon_bo *bo)if (bo ==NULL )return NULL ; -ttm_bo_get (&bo->tbo); +drm_gem_object_get (&bo->tbo.base);return bo; }void radeon_bo_unref (struct radeon_bo **bo) { -struct ttm_buffer_object *tbo; -if ((*bo) ==NULL )return ; - tbo = &((*bo)->tbo); -ttm_bo_put (tbo); +drm_gem_object_put (&(*bo)->tbo.base); *bo =NULL ; }
Signature · 1 line
2.34.1
PATCH 5/9 drm/vmwgfx: use GEM references instead of TTMs
In reply to Christian KönigInstead of a TTM reference grab a GEM reference whenever necessary.
--- drivers/gpu/drm/vmwgfx/vmwgfx_bo.c | 4 ++-- drivers/gpu/drm/vmwgfx/vmwgfx_bo.h | 19 ++----------------- drivers/gpu/drm/vmwgfx/vmwgfx_cotable.c | 4 ++-- drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 4 ++-- drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 6 +++--- drivers/gpu/drm/vmwgfx/vmwgfx_overlay.c | 2 +- drivers/gpu/drm/vmwgfx/vmwgfx_resource.c | 16 ++++++++-------- drivers/gpu/drm/vmwgfx/vmwgfx_shader.c | 4 ++-- drivers/gpu/drm/vmwgfx/vmwgfx_surface.c | 2 +- 9 files changed, 23 insertions(+), 38 deletions(-)
drivers/gpu/drm/vmwgfx/vmwgfx_bo.c +2 -2
@@ -501,7 +501,7 @@ static int vmw_user_bo_synccpu_release(struct drm_file *filp,if (!(flags & drm_vmw_synccpu_allow_cs)) {atomic_dec (&vmw_bo->cpu_writers); } -vmw_user_bo_unref (&vmw_bo); +vmw_bo_unreference (&vmw_bo); }return ret;
@@ -543,7 +543,7 @@ int vmw_user_bo_synccpu_ioctl(struct drm_device *dev, void *data,return ret; ret =vmw_user_bo_synccpu_grab (vbo, arg->flags); -vmw_user_bo_unref (&vbo); +vmw_bo_unreference (&vbo);if (unlikely (ret !=0 )) {if (ret == -ERESTARTSYS || ret == -EBUSY )return -EBUSY ;
drivers/gpu/drm/vmwgfx/vmwgfx_bo.h +2 -17
@@ -188,30 +188,15 @@ static inline void vmw_bo_unreference(struct vmw_bo **buf) *buf =NULL ;if (tmp_buf) -ttm_bo_put (&tmp_buf->tbo); +drm_gem_object_put (&tmp_buf->tbo.base); }static inline struct vmw_bo *vmw_bo_reference (struct vmw_bo *buf) { -ttm_bo_get (&buf->tbo); +drm_gem_object_get (&buf->tbo.base);return buf; } -static inline struct vmw_bo *vmw_user_bo_ref (struct vmw_bo *vbo) -{ -drm_gem_object_get (&vbo->tbo.base); -return vbo; -} - -static inline void vmw_user_bo_unref (struct vmw_bo **buf) -{ -struct vmw_bo *tmp_buf = *buf; - - *buf =NULL ; -if (tmp_buf) -drm_gem_object_put (&tmp_buf->tbo.base); -} -static inline struct vmw_bo *to_vmw_bo (struct drm_gem_object *gobj) { return container_of((gobj), struct vmw_bo, tbo.base);
drivers/gpu/drm/vmwgfx/vmwgfx_cotable.c +2 -2
@@ -502,7 +502,7 @@ static int vmw_cotable_resize(struct vmw_resource *res, size_t new_size)vmw_resource_mob_attach (res);/* Let go of the old mob. */ -vmw_user_bo_unref (&old_buf); +vmw_bo_unreference (&old_buf); res->id = vcotbl->type; ret =dma_resv_reserve_fences (bo->base.resv,1 );
@@ -521,7 +521,7 @@ static int vmw_cotable_resize(struct vmw_resource *res, size_t new_size) out_wait:ttm_bo_unpin (bo);ttm_bo_unreserve (bo); -vmw_user_bo_unref (&buf); +vmw_bo_unreference (&buf); out_done:MKS_STAT_TIME_POP (MKSSTAT_KERN_COTABLE_RESIZE );
drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c +2 -2
@@ -1166,7 +1166,7 @@ static int vmw_translate_mob_ptr(struct vmw_private *dev_priv,vmw_bo_placement_set (vmw_bo,VMW_BO_DOMAIN_MOB ,VMW_BO_DOMAIN_MOB ); ret =vmw_validation_add_bo (sw_context->ctx, vmw_bo); tmp_bo = vmw_bo; -vmw_user_bo_unref (&tmp_bo); +vmw_bo_unreference (&tmp_bo);if (unlikely (ret !=0 ))return ret;
@@ -1223,7 +1223,7 @@ static int vmw_translate_guest_ptr(struct vmw_private *dev_priv, VMW_BO_DOMAIN_GMR | VMW_BO_DOMAIN_VRAM); ret =vmw_validation_add_bo (sw_context->ctx, vmw_bo); tmp_bo = vmw_bo; -vmw_user_bo_unref (&tmp_bo); +vmw_bo_unreference (&tmp_bo);if (unlikely (ret !=0 ))return ret;
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +3 -3
@@ -1476,8 +1476,8 @@ static int vmw_create_bo_proxy(struct drm_device *dev,/* Reserve and switch the backing mob. */ mutex_lock (&res->dev_priv->cmdbuf_mutex); (void )vmw_resource_reserve (res, false, true); -vmw_user_bo_unref (&res->guest_memory_bo); - res->guest_memory_bo =vmw_user_bo_ref (bo_mob); +vmw_bo_unreference (&res->guest_memory_bo); + res->guest_memory_bo =vmw_bo_reference (bo_mob); res->guest_memory_offset =0 ;vmw_resource_unreserve (res, false, false, false,NULL ,0 );mutex_unlock (&res->dev_priv->cmdbuf_mutex);
@@ -1670,7 +1670,7 @@ static struct drm_framebuffer *vmw_kms_fb_create(struct drm_device *dev, err_out:/* vmw_user_lookup_handle takes one ref so does new_fb */ if (bo) -vmw_user_bo_unref (&bo); +vmw_bo_unreference (&bo);if (surface)vmw_surface_unreference (&surface);
drivers/gpu/drm/vmwgfx/vmwgfx_overlay.c +1 -1
@@ -451,7 +451,7 @@ int vmw_overlay_ioctl(struct drm_device *dev, void *data, ret =vmw_overlay_update_stream (dev_priv, buf, arg, true); -vmw_user_bo_unref (&buf); +vmw_bo_unreference (&buf); out_unlock:mutex_unlock (&overlay->mutex);
drivers/gpu/drm/vmwgfx/vmwgfx_resource.c +8 -8
@@ -141,7 +141,7 @@ static void vmw_resource_release(struct kref *kref)if (res->coherent)vmw_bo_dirty_release (res->guest_memory_bo);ttm_bo_unreserve (bo); -vmw_user_bo_unref (&res->guest_memory_bo); +vmw_bo_unreference (&res->guest_memory_bo); }if (likely (res->hw_destroy !=NULL )) {
@@ -457,11 +457,11 @@ void vmw_resource_unreserve(struct vmw_resource *res,vmw_resource_mob_detach (res);if (res->coherent)vmw_bo_dirty_release (res->guest_memory_bo); -vmw_user_bo_unref (&res->guest_memory_bo); +vmw_bo_unreference (&res->guest_memory_bo); }if (new_guest_memory_bo) { - res->guest_memory_bo =vmw_user_bo_ref (new_guest_memory_bo); + res->guest_memory_bo =vmw_bo_reference (new_guest_memory_bo);/* * The validation code should already have added a
@@ -522,7 +522,7 @@ vmw_resource_check_buffer(struct ww_acquire_ctx *ticket, }INIT_LIST_HEAD (&val_list); -ttm_bo_get (&res->guest_memory_bo->tbo); +drm_gem_object_get (&res->guest_memory_bo->tbo.base); val_buf->bo = &res->guest_memory_bo->tbo; val_buf->num_shared =0 ;list_add_tail (&val_buf->head, &val_list);
@@ -548,10 +548,10 @@ vmw_resource_check_buffer(struct ww_acquire_ctx *ticket, out_no_validate:ttm_eu_backoff_reservation (ticket, &val_list); out_no_reserve: -ttm_bo_put (val_buf->bo); +drm_gem_object_put (&val_buf->bo->base); val_buf->bo =NULL ;if (guest_memory_dirty) -vmw_user_bo_unref (&res->guest_memory_bo); +vmw_bo_unreference (&res->guest_memory_bo);return ret; }
@@ -610,7 +610,7 @@ vmw_resource_backoff_reservation(struct ww_acquire_ctx *ticket,INIT_LIST_HEAD (&val_list);list_add_tail (&val_buf->head, &val_list);ttm_eu_backoff_reservation (ticket, &val_list); -ttm_bo_put (val_buf->bo); +drm_gem_object_put (&val_buf->bo->base); val_buf->bo =NULL ; }
@@ -727,7 +727,7 @@ int vmw_resource_validate(struct vmw_resource *res, bool intr, goto out_no_validate; else if (!res->func->needs_guest_memory && res->guest_memory_bo) {WARN_ON_ONCE (vmw_resource_mob_attached (res)); -vmw_user_bo_unref (&res->guest_memory_bo); +vmw_bo_unreference (&res->guest_memory_bo); }return 0 ;
drivers/gpu/drm/vmwgfx/vmwgfx_shader.c +2 -2
@@ -180,7 +180,7 @@ static int vmw_gb_shader_init(struct vmw_private *dev_priv, res->guest_memory_size = size;if (byte_code) { - res->guest_memory_bo =vmw_user_bo_ref (byte_code); + res->guest_memory_bo =vmw_bo_reference (byte_code); res->guest_memory_offset = offset; } shader->size = size;
@@ -809,7 +809,7 @@ static int vmw_shader_define(struct drm_device *dev, struct drm_file *file_priv, shader_type, num_input_sig, num_output_sig, tfile, shader_handle); out_bad_arg: -vmw_user_bo_unref (&buffer); +vmw_bo_unreference (&buffer);return ret; }
drivers/gpu/drm/vmwgfx/vmwgfx_surface.c +1 -1
@@ -1505,7 +1505,7 @@ vmw_gb_surface_define_internal(struct drm_device *dev,if (ret ==0 ) {if (res->guest_memory_bo->tbo.base.size < res->guest_memory_size) {VMW_DEBUG_USER ("Surface backup buffer too small.\n" ); -vmw_user_bo_unref (&res->guest_memory_bo); +vmw_bo_unreference (&res->guest_memory_bo); ret = -EINVAL ; goto out_unlock; }else {
Signature · 1 line
2.34.1
PATCH 6/9 drm/vmwgfx: partially revert "Adapt validation code for reference-free lookups"
In reply to Christian KönigThis reverts commit 64ad2abfe9a628ce79859d072704bd1ef7682044.
To me it looks like this functionality was never actually used. At least I can't find any protection in vmw_bo_free().
--- drivers/gpu/drm/vmwgfx/vmwgfx_validation.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/gpu/drm/vmwgfx/vmwgfx_validation.c +3 -2
@@ -262,7 +262,8 @@ int vmw_validation_add_bo(struct vmw_validation_context *ctx, bo_node->hash.key); } val_buf = &bo_node->base; - val_buf->bo =ttm_bo_get_unless_zero (&vbo->tbo); +vmw_bo_reference (vbo); + val_buf->bo = &vbo->tbo;if (!val_buf->bo)return -ESRCH ; val_buf->num_shared =0 ;
@@ -656,7 +657,7 @@ void vmw_validation_unref_lists(struct vmw_validation_context *ctx)struct vmw_validation_res_node *val;list_for_each_entry (entry, &ctx->bo_list, base.head) { -ttm_bo_put (entry->base.bo); +drm_gem_object_put (&entry->base.bo->base); entry->base.bo =NULL ; }
Signature · 1 line
2.34.1
PATCH 7/9 drm/ttm: revert "Export ttm_bo_get_unless_zero()"
In reply to Christian KönigThis reverts commit 24dc64c1ba5c3ef0463d59fef6df09336754188d.
Shouldn't be needed by drivers any more.
--- drivers/gpu/drm/ttm/ttm_bo.c | 1 + drivers/gpu/drm/ttm/ttm_bo_internal.h | 48 +++++++++++++++++++++++++++ drivers/gpu/drm/ttm/ttm_bo_util.c | 2 ++ drivers/gpu/drm/ttm/ttm_device.c | 1 + include/drm/ttm/ttm_bo.h | 18 ---------- 5 files changed, 52 insertions(+), 18 deletions(-) create mode 100644 drivers/gpu/drm/ttm/ttm_bo_internal.h
drivers/gpu/drm/ttm/ttm_bo.c +1 -0
@@ -45,6 +45,7 @@#include <linux/dma-resv.h> #include "ttm_module.h" +#include "ttm_bo_internal.h" static void ttm_bo_mem_space_debug (struct ttm_buffer_object *bo,struct ttm_placement *placement)
drivers/gpu/drm/ttm/ttm_bo_internal.h new file +48 -0
48 lines not on this page · raw message
drivers/gpu/drm/ttm/ttm_bo_util.c +2 -0
@@ -37,6 +37,8 @@#include <drm/drm_cache.h> +#include "ttm_bo_internal.h" +struct ttm_transfer_obj {struct ttm_buffer_object base;struct ttm_buffer_object *bo;
drivers/gpu/drm/ttm/ttm_device.c +1 -0
@@ -36,6 +36,7 @@#include <drm/ttm/ttm_placement.h> #include "ttm_module.h" +#include "ttm_bo_internal.h" /* * ttm_global_mutex - protecting the global state
include/drm/ttm/ttm_bo.h +0 -18
@@ -239,24 +239,6 @@ static inline void ttm_bo_get(struct ttm_buffer_object *bo)kref_get (&bo->kref); } -/** -* ttm_bo_get_unless_zero - reference a struct ttm_buffer_object unless -* its refcount has already reached zero. -* @bo: The buffer object. -* -* Used to reference a TTM buffer object in lookups where the object is removed -* from the lookup structure during the destructor and for RCU lookups. -* -* Returns: @bo if the referencing was successful, NULL otherwise. -*/ -static inline __must_check struct ttm_buffer_object * -ttm_bo_get_unless_zero (struct ttm_buffer_object *bo) -{ -if (!kref_get_unless_zero (&bo->kref)) -return NULL ; -return bo; -} -/** * ttm_bo_reserve: *
Signature · 1 line
2.34.1
Re: [PATCH 7/9] drm/ttm: revert "Export ttm_bo_get_unless_zero()"
Quoted 5 lines · Christian König
This reverts commit
24dc64c1ba5c3ef0463d59fef6df09336754188d.Shouldn't be needed by drivers any more.
Signed-off-by Christian König <[email protected]>
Quoted 132 lines
--- drivers/gpu/drm/ttm/ttm_bo.c | 1 + drivers/gpu/drm/ttm/ttm_bo_internal.h | 48 +++++++++++++++++++++++++++ drivers/gpu/drm/ttm/ttm_bo_util.c | 2 ++ drivers/gpu/drm/ttm/ttm_device.c | 1 + include/drm/ttm/ttm_bo.h | 18 ---------- 5 files changed, 52 insertions(+), 18 deletions(-) create mode 100644 drivers/gpu/drm/ttm/ttm_bo_internal.hdrivers/gpu/drm/ttm/ttm_bo.c +1
-0@@ -45,6 +45,7 @@#include <linux/dma-resv.h> #include "ttm_module.h" +#include "ttm_bo_internal.h" static void ttm_bo_mem_space_debug (struct ttm_buffer_object *bo,struct ttm_placement *placement)drivers/gpu/drm/ttm/ttm_bo_internal.h new file +48
-0@@ -0,0 +1,48 @@ +/* +* Copyright 2018 Advanced Micro Devices, Inc. +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR +* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +* OTHER DEALINGS IN THE SOFTWARE. +* +* +*/ + +#ifndef _TTM_BO_INTERNAL_H_ +#define _TTM_BO_INTERNAL_H_ + +#include <drm/ttm/ttm_bo.h> + +/** +* ttm_bo_get_unless_zero - reference a struct ttm_buffer_object unless +* its refcount has already reached zero. +* @bo: The buffer object. +* +* Used to reference a TTM buffer object in lookups where the object is removed +* from the lookup structure during the destructor and for RCU lookups. +* +* Returns: @bo if the referencing was successful, NULL otherwise. +*/ +static inline __must_check struct ttm_buffer_object * +ttm_bo_get_unless_zero (struct ttm_buffer_object *bo) +{ +if (!kref_get_unless_zero (&bo->kref)) +return NULL ; +return bo; +} + +#endif drivers/gpu/drm/ttm/ttm_bo_util.c +2
-0@@ -37,6 +37,8 @@#include <drm/drm_cache.h> +#include "ttm_bo_internal.h" +struct ttm_transfer_obj {struct ttm_buffer_object base;struct ttm_buffer_object *bo;drivers/gpu/drm/ttm/ttm_device.c +1
-0@@ -36,6 +36,7 @@#include <drm/ttm/ttm_placement.h> #include "ttm_module.h" +#include "ttm_bo_internal.h" /* * ttm_global_mutex - protecting the global state include/drm/ttm/ttm_bo.h +0
-18@@ -239,24 +239,6 @@ static inline void ttm_bo_get(struct ttm_buffer_object *bo)kref_get (&bo->kref); } -/** -* ttm_bo_get_unless_zero - reference a struct ttm_buffer_object unless -* its refcount has already reached zero. -* @bo: The buffer object. -* -* Used to reference a TTM buffer object in lookups where the object is removed -* from the lookup structure during the destructor and for RCU lookups. -* -* Returns: @bo if the referencing was successful, NULL otherwise. -*/ -static inline __must_check struct ttm_buffer_object * -ttm_bo_get_unless_zero (struct ttm_buffer_object *bo) -{ -if (!kref_get_unless_zero (&bo->kref)) -return NULL ; -return bo; -} -/** * ttm_bo_reserve: * Signature · 1 line
2.34.1
PATCH 8/9 drm/ttm: use GEM references for VM mappings
In reply to Christian KönigInstead of a TTM reference grab a GEM reference whenever necessary for a VM mapping.
--- drivers/gpu/drm/ttm/ttm_bo_vm.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/gpu/drm/ttm/ttm_bo_vm.c +7 -7
@@ -58,13 +58,13 @@ static vm_fault_t ttm_bo_vm_fault_idle(struct ttm_buffer_object *bo,if (vmf->flags &FAULT_FLAG_RETRY_NOWAIT )return VM_FAULT_RETRY ; -ttm_bo_get (bo); +drm_gem_object_get (&bo->base);mmap_read_unlock (vmf->vma->vm_mm); (void )dma_resv_wait_timeout (bo->base.resv,DMA_RESV_USAGE_KERNEL , true,MAX_SCHEDULE_TIMEOUT );dma_resv_unlock (bo->base.resv); -ttm_bo_put (bo); +drm_gem_object_put (&bo->base);return VM_FAULT_RETRY ; }
@@ -130,12 +130,12 @@ vm_fault_t ttm_bo_vm_reserve(struct ttm_buffer_object *bo,*/ if (fault_flag_allow_retry_first (vmf->flags)) {if (!(vmf->flags &FAULT_FLAG_RETRY_NOWAIT )) { -ttm_bo_get (bo); +drm_gem_object_get (&bo->base);mmap_read_unlock (vmf->vma->vm_mm);if (!dma_resv_lock_interruptible (bo->base.resv,NULL ))dma_resv_unlock (bo->base.resv); -ttm_bo_put (bo); +drm_gem_object_put (&bo->base); }return VM_FAULT_RETRY ;
@@ -353,7 +353,7 @@ void ttm_bo_vm_open(struct vm_area_struct *vma)WARN_ON (bo->bdev->dev_mapping != vma->vm_file->f_mapping); -ttm_bo_get (bo); +drm_gem_object_get (&bo->base); }EXPORT_SYMBOL (ttm_bo_vm_open);
@@ -361,7 +361,7 @@ void ttm_bo_vm_close(struct vm_area_struct *vma) {struct ttm_buffer_object *bo = vma->vm_private_data; -ttm_bo_put (bo); +drm_gem_object_put (&bo->base); vma->vm_private_data =NULL ; }EXPORT_SYMBOL (ttm_bo_vm_close);
@@ -462,7 +462,7 @@ int ttm_bo_mmap_obj(struct vm_area_struct *vma, struct ttm_buffer_object *bo)if (is_cow_mapping (vma->vm_flags))return -EINVAL ; -ttm_bo_get (bo); +drm_gem_object_get (&bo->base);/* * Drivers may want to override the vm_ops field. Otherwise we
Signature · 1 line
2.34.1
Re: [PATCH 8/9] drm/ttm: use GEM references for VM mappings
Quoted 4 lines · Christian König
Instead of a TTM reference grab a GEM reference whenever necessary for a VM mapping.
Signed-off-by Christian König <[email protected]>
Quoted 69 lines
--- drivers/gpu/drm/ttm/ttm_bo_vm.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)drivers/gpu/drm/ttm/ttm_bo_vm.c +7
-7@@ -58,13 +58,13 @@ static vm_fault_t ttm_bo_vm_fault_idle(struct ttm_buffer_object *bo,if (vmf->flags &FAULT_FLAG_RETRY_NOWAIT )return VM_FAULT_RETRY ; -ttm_bo_get (bo); +drm_gem_object_get (&bo->base);mmap_read_unlock (vmf->vma->vm_mm); (void )dma_resv_wait_timeout (bo->base.resv,DMA_RESV_USAGE_KERNEL , true,MAX_SCHEDULE_TIMEOUT );dma_resv_unlock (bo->base.resv); -ttm_bo_put (bo); +drm_gem_object_put (&bo->base);return VM_FAULT_RETRY ; }@@ -130,12 +130,12 @@ vm_fault_t ttm_bo_vm_reserve(struct ttm_buffer_object *bo,*/ if (fault_flag_allow_retry_first (vmf->flags)) {if (!(vmf->flags &FAULT_FLAG_RETRY_NOWAIT )) { -ttm_bo_get (bo); +drm_gem_object_get (&bo->base);mmap_read_unlock (vmf->vma->vm_mm);if (!dma_resv_lock_interruptible (bo->base.resv,NULL ))dma_resv_unlock (bo->base.resv); -ttm_bo_put (bo); +drm_gem_object_put (&bo->base); }return VM_FAULT_RETRY ;@@ -353,7 +353,7 @@ void ttm_bo_vm_open(struct vm_area_struct *vma)WARN_ON (bo->bdev->dev_mapping != vma->vm_file->f_mapping); -ttm_bo_get (bo); +drm_gem_object_get (&bo->base); }EXPORT_SYMBOL (ttm_bo_vm_open);@@ -361,7 +361,7 @@ void ttm_bo_vm_close(struct vm_area_struct *vma) {struct ttm_buffer_object *bo = vma->vm_private_data; -ttm_bo_put (bo); +drm_gem_object_put (&bo->base); vma->vm_private_data =NULL ; }EXPORT_SYMBOL (ttm_bo_vm_close);@@ -462,7 +462,7 @@ int ttm_bo_mmap_obj(struct vm_area_struct *vma, struct ttm_buffer_object *bo)if (is_cow_mapping (vma->vm_flags))return -EINVAL ; -ttm_bo_get (bo); +drm_gem_object_get (&bo->base);/* * Drivers may want to override the vm_ops field. Otherwise we Signature · 1 line
2.34.1
PATCH 9/9 drm/ttm: make ttm_bo_get internal
In reply to Christian KönigPrevent drivers from using this directly.
--- drivers/gpu/drm/ttm/ttm_bo_internal.h | 10 ++++++++++ include/drm/ttm/ttm_bo.h | 10 ---------- 2 files changed, 10 insertions(+), 10 deletions(-)
drivers/gpu/drm/ttm/ttm_bo_internal.h +10 -0
@@ -27,6 +27,16 @@#include <drm/ttm/ttm_bo.h> +/** +* ttm_bo_get - reference a struct ttm_buffer_object +* +* @bo: The buffer object. +*/ +static inline void ttm_bo_get (struct ttm_buffer_object *bo) +{ +kref_get (&bo->kref); +} +/** * ttm_bo_get_unless_zero - reference a struct ttm_buffer_object unless * its refcount has already reached zero.
include/drm/ttm/ttm_bo.h +0 -10
@@ -229,16 +229,6 @@ struct ttm_lru_walk {s64 ttm_lru_walk_for_evict (struct ttm_lru_walk *walk,struct ttm_device *bdev,struct ttm_resource_manager *man,s64 target); -/** -* ttm_bo_get - reference a struct ttm_buffer_object -* -* @bo: The buffer object. -*/ -static inline void ttm_bo_get (struct ttm_buffer_object *bo) -{ -kref_get (&bo->kref); -} -/** * ttm_bo_reserve: *
Signature · 1 line
2.34.1
Matthew Brost
reviewerRe: [PATCH 9/9] drm/ttm: make ttm_bo_get internal
Quoted 2 lines · Christian König
Prevent drivers from using this directly.
This is a good change. Early on in Xe, our reference counting for BOs was flawed (and incorrect) due to confusion between GEM ref count and TTM ref count.
Is there any way we can just eliminate this and use GEM ref count? I'm still confused about why we seemingly have two reference counts for the same object.
Matt
Quoted 51 lines
Signed-off-by Christian König <[email protected]>--- drivers/gpu/drm/ttm/ttm_bo_internal.h | 10 ++++++++++ include/drm/ttm/ttm_bo.h | 10 ---------- 2 files changed, 10 insertions(+), 10 deletions(-)drivers/gpu/drm/ttm/ttm_bo_internal.h +10
-0@@ -27,6 +27,16 @@#include <drm/ttm/ttm_bo.h> +/** +* ttm_bo_get - reference a struct ttm_buffer_object +* +* @bo: The buffer object. +*/ +static inline void ttm_bo_get (struct ttm_buffer_object *bo) +{ +kref_get (&bo->kref); +} +/** * ttm_bo_get_unless_zero - reference a struct ttm_buffer_object unless * its refcount has already reached zero. include/drm/ttm/ttm_bo.h +0
-10@@ -229,16 +229,6 @@ struct ttm_lru_walk {s64 ttm_lru_walk_for_evict (struct ttm_lru_walk *walk,struct ttm_device *bdev,struct ttm_resource_manager *man,s64 target); -/** -* ttm_bo_get - reference a struct ttm_buffer_object -* -* @bo: The buffer object. -*/ -static inline void ttm_bo_get (struct ttm_buffer_object *bo) -{ -kref_get (&bo->kref); -} -/** * ttm_bo_reserve: * Signature · 1 line
2.34.1
Re: [PATCH 9/9] drm/ttm: make ttm_bo_get internal
Am 16.07.24 um 23:37 schrieb Matthew Brost:
Quoted 10 lines · Christian König
Quoted 2 lines
Prevent drivers from using this directly.
This is a good change. Early on in Xe, our reference counting for BOs was flawed (and incorrect) due to confusion between GEM ref count and TTM ref count.
Is there any way we can just eliminate this and use GEM ref count? I'm still confused about why we seemingly have two reference counts for the same object.
I don't want to give your nightmares but initially we had *four* reference counts for the same object!
I've already removed one of it quite a while ago because I ran into similar issues, but currently we have three:
1. The GEM kref
2. The GEM handle count
3. The TTM kref
The handle count and GEM kref make sense since the handle count controls when to release DMA-buf and the GEM kref controls when to release the structure and backing store.
The TTM kref is another structure reference created because historically TTM BOs were not based on GEM objects. Since this is no longer the case we can probably nuke that one.
Regards,
Christian.
Quoted 54 lines
Matt
Quoted 51 lines
Signed-off-by Christian König <[email protected]>--- drivers/gpu/drm/ttm/ttm_bo_internal.h | 10 ++++++++++ include/drm/ttm/ttm_bo.h | 10 ---------- 2 files changed, 10 insertions(+), 10 deletions(-)drivers/gpu/drm/ttm/ttm_bo_internal.h +10
-0@@ -27,6 +27,16 @@#include <drm/ttm/ttm_bo.h> +/** +* ttm_bo_get - reference a struct ttm_buffer_object +* +* @bo: The buffer object. +*/ +static inline void ttm_bo_get (struct ttm_buffer_object *bo) +{ +kref_get (&bo->kref); +} +/** * ttm_bo_get_unless_zero - reference a struct ttm_buffer_object unless * its refcount has already reached zero. include/drm/ttm/ttm_bo.h +0
-10@@ -229,16 +229,6 @@ struct ttm_lru_walk {s64 ttm_lru_walk_for_evict (struct ttm_lru_walk *walk,struct ttm_device *bdev,struct ttm_resource_manager *man,s64 target); -/** -* ttm_bo_get - reference a struct ttm_buffer_object -* -* @bo: The buffer object. -*/ -static inline void ttm_bo_get (struct ttm_buffer_object *bo) -{ -kref_get (&bo->kref); -} -/** * ttm_bo_reserve: * Signature · 1 line
2.34.1
Re: [PATCH 9/9] drm/ttm: make ttm_bo_get internal
In reply to Christian KönigQuoted 3 lines · Christian König
Prevent drivers from using this directly.
Signed-off-by Christian König <[email protected]>
Quoted 50 lines
--- drivers/gpu/drm/ttm/ttm_bo_internal.h | 10 ++++++++++ include/drm/ttm/ttm_bo.h | 10 ---------- 2 files changed, 10 insertions(+), 10 deletions(-)drivers/gpu/drm/ttm/ttm_bo_internal.h +10
-0@@ -27,6 +27,16 @@#include <drm/ttm/ttm_bo.h> +/** +* ttm_bo_get - reference a struct ttm_buffer_object +* +* @bo: The buffer object. +*/ +static inline void ttm_bo_get (struct ttm_buffer_object *bo) +{ +kref_get (&bo->kref); +} +/** * ttm_bo_get_unless_zero - reference a struct ttm_buffer_object unless * its refcount has already reached zero. include/drm/ttm/ttm_bo.h +0
-10@@ -229,16 +229,6 @@ struct ttm_lru_walk {s64 ttm_lru_walk_for_evict (struct ttm_lru_walk *walk,struct ttm_device *bdev,struct ttm_resource_manager *man,s64 target); -/** -* ttm_bo_get - reference a struct ttm_buffer_object -* -* @bo: The buffer object. -*/ -static inline void ttm_bo_get (struct ttm_buffer_object *bo) -{ -kref_get (&bo->kref); -} -/** * ttm_bo_reserve: * Signature · 1 line
2.34.1
Danilo Krummrich
maintainerHi Christian,
Quoted 8 lines · Christian König
Hello everyone,
to make use of
drm_execit is necessary to have TTM drivers actually use the GEM reference count instead of the TTM one.This patch set is a start to do that. It switches all uses of ttm_bo_get/put to the GEM counterpart and then makes
ttm_bo_getprivate to TTM.
That makes a lot of sense.
But I think for at least some drivers it requires a bit more than just replacing ttm_bo_{get, put} with drm_gem_object_{get, put}.
I gave this a quick shot on Nouveau, and as is, it creates a refcount underflow for the GEM object's reference count.
At a first glance this seems to happen because some of the previous ttm_bo_put() calls intend to compensate for the initial refcount of a ttm_buffer_object.
I will have a closer look later on.
- Danilo
Quoted 9 lines
Netx step is to completely remove the TTM refcounting.
Please review and/or comment.
Cheers,
Christian.
Danilo Krummrich
maintainerQuoted 2 lines · Danilo Krummrich
Hi Christian,
Forgot to say, please also add driver maintainers and related mailing lists, dri-devel gets a lot of messages and I saw this series by chance.
- Danilo
Quoted 33 lines · Christian König
Quoted 8 lines
Hello everyone,
to make use of
drm_execit is necessary to have TTM drivers actually use the GEM reference count instead of the TTM one.This patch set is a start to do that. It switches all uses of ttm_bo_get/put to the GEM counterpart and then makes
ttm_bo_getprivate to TTM.That makes a lot of sense.
But I think for at least some drivers it requires a bit more than just replacing ttm_bo_{get, put} with drm_gem_object_{get, put}.
I gave this a quick shot on Nouveau, and as is, it creates a refcount underflow for the GEM object's reference count.
At a first glance this seems to happen because some of the previous
ttm_bo_put()calls intend to compensate for the initial refcount of attm_buffer_object.I will have a closer look later on.
- Danilo
Quoted 9 lines
Netx step is to completely remove the TTM refcounting.
Please review and/or comment.
Cheers,
Christian.
Am 16.07.24 um 15:24 schrieb Danilo Krummrich:
Quoted 7 lines · Danilo Krummrich
Quoted 2 lines
Hi Christian,
Forgot to say, please also add driver maintainers and related mailing lists, dri-devel gets a lot of messages and I saw this series by chance.
Ah, yes good point.
Quoted 20 lines
- Danilo
Quoted 17 lines · Christian König
Quoted 8 lines
Hello everyone,
to make use of
drm_execit is necessary to have TTM drivers actually use the GEM reference count instead of the TTM one.This patch set is a start to do that. It switches all uses of ttm_bo_get/put to the GEM counterpart and then makes
ttm_bo_getprivate to TTM.That makes a lot of sense.
But I think for at least some drivers it requires a bit more than just replacing ttm_bo_{get, put} with drm_gem_object_{get, put}.
I gave this a quick shot on Nouveau, and as is, it creates a refcount underflow for the GEM object's reference count.
Crap, I thought I got all of those.
Quoted 2 lines
Quoted 2 lines
At a first glance this seems to happen because some of the previous
ttm_bo_put()calls intend to compensate for the initial refcount of attm_buffer_object.
Mhm, there should be only one left of those.
Quoted 2 lines
Quoted 2 lines
I will have a closer look later on.
Thanks,
Christian.
Quoted 12 lines
Quoted 12 lines
- Danilo
Quoted 9 lines
Netx step is to completely remove the TTM refcounting.
Please review and/or comment.
Cheers,
Christian.
Quoted 10 lines · Christian König
Hello everyone,
to make use of
drm_execit is necessary to have TTM drivers actually use
the GEM reference count instead of the TTM one.This patch set is a start to do that. It switches all uses of ttm_bo_get/put to the GEM counterpart and then makes
ttm_bo_getprivate
to TTM.
For xe
Quoted 2 lines
Netx step is to completely remove the TTM refcounting.
This is probably going to be a bit complicated, and in particular IMO we must ensure that the refcount resurrection doesn't leak to the gem refcount and annotate the driver callbacks that might get called with deleted (gem refcount 0) objects.
/Thomas
Quoted 7 lines
Please review and/or comment.
Cheers,
Christian.