summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBas Nieuwenhuizen <basni@chromium.org>2021-11-10 13:47:16 +0100
committerCommit Bot <commit-bot@chromium.org>2021-11-12 14:06:34 +0000
commit631d9e4d653567eba0dfc846ec849be5e490f574 (patch)
tree02131dcf142b2607430500b4559f266d09ccc290
parent58098919592b94c978073b1a9f4815bf06b0bf21 (diff)
downloadminigbm-631d9e4d653567eba0dfc846ec849be5e490f574.tar.gz
drv: Add new bo_release driver callback.
The current bo_destroy callback only gets called if the bo has the last references to the GEM BOs, and otherwise plain free gets called. However, this is an issue if bo->priv contains something per bo that needs to be cleaned up. To solve this we introduce a new callback to clean up things per bo instance. BUG=b:185869479 TEST=none for this patch. See follow-on patch making use of this. Change-Id: I9d48b3b5a70264adbc4de55a5c7b18e1a2209553 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3270683 Tested-by: Bas Nieuwenhuizen <basni@chromium.org> Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org> Commit-Queue: Bas Nieuwenhuizen <basni@chromium.org>
-rw-r--r--drv.c3
-rw-r--r--drv_priv.h3
2 files changed, 6 insertions, 0 deletions
diff --git a/drv.c b/drv.c
index 31a5ee5..ada02ba 100644
--- a/drv.c
+++ b/drv.c
@@ -300,6 +300,9 @@ static bool drv_bo_release(struct bo *bo)
struct driver *drv = bo->drv;
uintptr_t num;
+ if (drv->backend->bo_release)
+ drv->backend->bo_release(bo);
+
pthread_mutex_lock(&drv->buffer_table_lock);
for (size_t plane = 0; plane < bo->meta.num_planes; plane++) {
if (!drmHashLookup(drv->buffer_table, bo->handles[plane].u32, (void **)&num)) {
diff --git a/drv_priv.h b/drv_priv.h
index 63f7804..d2da440 100644
--- a/drv_priv.h
+++ b/drv_priv.h
@@ -85,6 +85,9 @@ struct backend {
int (*bo_compute_metadata)(struct bo *bo, uint32_t width, uint32_t height, uint32_t format,
uint64_t use_flags, const uint64_t *modifiers, uint32_t count);
int (*bo_create_from_metadata)(struct bo *bo);
+ /* Called for every non-test-buffer BO on free */
+ int (*bo_release)(struct bo *bo);
+ /* Called on free if this bo is the last object referencing the contained GEM BOs */
int (*bo_destroy)(struct bo *bo);
int (*bo_import)(struct bo *bo, struct drv_import_fd_data *data);
void *(*bo_map)(struct bo *bo, struct vma *vma, size_t plane, uint32_t map_flags);