amdgpu: Use bo_release to free DRI images.

Previously these would get leaked if we had multiple bo structs
pointing to the same image/GEM BO as each has their own DRI image,
but bo_destroy only gets called on the last struct.

To mitigate this we have a new callback for every struct where we
can free the DRI image.

BUG=b:185869479
TEST=Repeatedly open/close camera app on Grunt.

Change-Id: I6188346b5bf9e5cbbbbf32a3db621a3fe0276d4f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3270684
Tested-by: Bas Nieuwenhuizen <basni@chromium.org>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Commit-Queue: Bas Nieuwenhuizen <basni@chromium.org>
This commit is contained in:
Bas Nieuwenhuizen 2021-11-10 14:04:21 +01:00 committed by Commit Bot
parent 631d9e4d65
commit 136d9228c0
3 changed files with 19 additions and 2 deletions

11
dri.c
View file

@ -389,13 +389,20 @@ int dri_bo_import(struct bo *bo, struct drv_import_fd_data *data)
return 0;
}
int dri_bo_destroy(struct bo *bo)
int dri_bo_release(struct bo *bo)
{
struct dri_driver *dri = bo->drv->priv;
assert(bo->priv);
close_gem_handle(bo->handles[0].u32, bo->drv->fd);
dri->image_extension->destroyImage(bo->priv);
/* Not clearing bo->priv as we still use it to determine which destroy to call. */
return 0;
}
int dri_bo_destroy(struct bo *bo)
{
assert(bo->priv);
close_gem_handle(bo->handles[0].u32, bo->drv->fd);
bo->priv = NULL;
return 0;
}