From f77567942a5b4de2d90f93494328bcab2f4f9601 Mon Sep 17 00:00:00 2001 From: Iago Toral Quiroga Date: Fri, 11 Nov 2022 11:36:29 +0100 Subject: [PATCH] v3dv: fix debug dump on BO free MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit We were resetting the BO struct right before dumping its data. Fix this by moving the reset later. Fixes: 44fa8304d45 ('v3dv: add a refcount mechanism to BOs') Reviewed-by: Alejandro Piñeiro Part-of: (cherry picked from commit 2c44597181e28b05d4b269ee73d4f3a59bc0a806) --- .pick_status.json | 2 +- src/broadcom/vulkan/v3dv_bo.c | 15 +++++++-------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index b8b7f24..25f502d 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -2416,7 +2416,7 @@ "description": "v3dv: fix debug dump on BO free", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "44fa8304d45e775050a42f2fc85c02ad5ddb63bd" }, diff --git a/src/broadcom/vulkan/v3dv_bo.c b/src/broadcom/vulkan/v3dv_bo.c index eaefb52..f3c819f 100644 --- a/src/broadcom/vulkan/v3dv_bo.c +++ b/src/broadcom/vulkan/v3dv_bo.c @@ -135,16 +135,9 @@ bo_free(struct v3dv_device *device, assert(p_atomic_read(&bo->refcnt) == 0); assert(bo->map == NULL); - /* Our BO structs are stored in a sparse array in the physical device, - * so we don't want to free the BO pointer, instead we want to reset it - * to 0, to signal that array entry as being free. - */ - uint32_t handle = bo->handle; - memset(bo, 0, sizeof(*bo)); - struct drm_gem_close c; memset(&c, 0, sizeof(c)); - c.handle = handle; + c.handle = bo->handle; int ret = v3dv_ioctl(device->pdevice->render_fd, DRM_IOCTL_GEM_CLOSE, &c); if (ret != 0) fprintf(stderr, "close object %d: %s\n", bo->handle, strerror(errno)); @@ -160,6 +153,12 @@ bo_free(struct v3dv_device *device, bo_dump_stats(device); } + /* Our BO structs are stored in a sparse array in the physical device, + * so we don't want to free the BO pointer, instead we want to reset it + * to 0, to signal that array entry as being free. + */ + memset(bo, 0, sizeof(*bo)); + return ret == 0; } -- 2.7.4