mirror of
https://github.com/torvalds/linux.git
synced 2026-10-26 20:46:02 +01:00
drm/gem: Add callback for when handle count goes to 0
Add an optional callback for driver-specific cleanup when the GEM handle of an object is freed. This will be used by AMDGPU to enable freeing of memory exported to other nodes in a UALink pod once all user mode references are gone. The callback is called outside the object_name_lock and before releasing the reference count on the GEM object Suggested-by: Christian König <christian.koenig@amd.com> Signed-off-by: Mukul Joshi <mukul.joshi@amd.com> Reviewed-by: Felix Kuehling <felix.kuehling@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
parent
39cfb3fe53
commit
b67d2d039f
|
|
@ -386,6 +386,14 @@ static int amdgpu_gem_object_mmap(struct drm_gem_object *obj, struct vm_area_str
|
|||
return drm_gem_ttm_mmap(obj, vma);
|
||||
}
|
||||
|
||||
static void amdgpu_gem_object_handle_free(struct drm_gem_object *gobj)
|
||||
{
|
||||
struct amdgpu_bo *aobj = gem_to_amdgpu_bo(gobj);
|
||||
|
||||
amdgpu_ualink_revoke_exported_memory(aobj);
|
||||
|
||||
}
|
||||
|
||||
const struct drm_gem_object_funcs amdgpu_gem_object_funcs = {
|
||||
.free = amdgpu_gem_object_free,
|
||||
.open = amdgpu_gem_object_open,
|
||||
|
|
@ -395,6 +403,7 @@ const struct drm_gem_object_funcs amdgpu_gem_object_funcs = {
|
|||
.vunmap = drm_gem_ttm_vunmap,
|
||||
.mmap = amdgpu_gem_object_mmap,
|
||||
.vm_ops = &amdgpu_gem_vm_ops,
|
||||
.handle_free = amdgpu_gem_object_handle_free
|
||||
};
|
||||
|
||||
static bool amdgpu_gem_are_domains_valid(u32 domains)
|
||||
|
|
|
|||
|
|
@ -353,8 +353,11 @@ void drm_gem_object_handle_put_unlocked(struct drm_gem_object *obj)
|
|||
}
|
||||
mutex_unlock(&dev->object_name_lock);
|
||||
|
||||
if (final)
|
||||
if (final) {
|
||||
if (obj->funcs->handle_free)
|
||||
obj->funcs->handle_free(obj);
|
||||
drm_gem_object_put(obj);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -227,6 +227,17 @@ struct drm_gem_object_funcs {
|
|||
*/
|
||||
size_t (*rss)(struct drm_gem_object *obj);
|
||||
|
||||
/**
|
||||
* @handle_free:
|
||||
*
|
||||
* This callback is called when the GEM handle count goes down to 0.
|
||||
* It is currently used by AMDGPU driver to release their exported BO
|
||||
* handles.
|
||||
*
|
||||
* This callback is optional.
|
||||
*/
|
||||
void (*handle_free)(struct drm_gem_object *obj);
|
||||
|
||||
/**
|
||||
* @vm_ops:
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user