diff options
author | Boris Brezillon <boris.brezillon@collabora.com> | 2023-12-04 18:14:06 +0300 |
---|---|---|
committer | Boris Brezillon <boris.brezillon@collabora.com> | 2023-12-05 13:43:57 +0300 |
commit | c50a291d621aa7abaa27b05f56d450a388b64948 (patch) | |
tree | d78045005c2c019b75d727149c5a55b1f9d30a68 /drivers/gpu/drm/drm_gpuvm.c | |
parent | 157ad4ccff0754d9eb57d3a4fa31264ee6e9716b (diff) | |
download | linux-c50a291d621aa7abaa27b05f56d450a388b64948.tar.xz |
drm/gpuvm: Let drm_gpuvm_bo_put() report when the vm_bo object is destroyed
Some users need to release resources attached to the vm_bo object when
it's destroyed. In Panthor's case, we need to release the pin ref so
BO pages can be returned to the system when all GPU mappings are gone.
This could be done through a custom drm_gpuvm::vm_bo_free() hook, but
this has all sort of locking implications that would force us to expose
a drm_gem_shmem_unpin_locked() helper, not to mention the fact that
having a ::vm_bo_free() implementation without a ::vm_bo_alloc() one
seems odd. So let's keep things simple, and extend drm_gpuvm_bo_put()
to report when the object is destroyed.
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Danilo Krummrich <dakr@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20231204151406.1977285-1-boris.brezillon@collabora.com
Diffstat (limited to 'drivers/gpu/drm/drm_gpuvm.c')
-rw-r--r-- | drivers/gpu/drm/drm_gpuvm.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/drivers/gpu/drm/drm_gpuvm.c b/drivers/gpu/drm/drm_gpuvm.c index 07a6676bc4f9..9c0922c1a5a2 100644 --- a/drivers/gpu/drm/drm_gpuvm.c +++ b/drivers/gpu/drm/drm_gpuvm.c @@ -1535,14 +1535,18 @@ drm_gpuvm_bo_destroy(struct kref *kref) * hold the dma-resv or driver specific GEM gpuva lock. * * This function may only be called from non-atomic context. + * + * Returns: true if vm_bo was destroyed, false otherwise. */ -void +bool drm_gpuvm_bo_put(struct drm_gpuvm_bo *vm_bo) { might_sleep(); if (vm_bo) - kref_put(&vm_bo->kref, drm_gpuvm_bo_destroy); + return !!kref_put(&vm_bo->kref, drm_gpuvm_bo_destroy); + + return false; } EXPORT_SYMBOL_GPL(drm_gpuvm_bo_put); |