v3dv: ignore imported BOs when tracking BO memory usage
Imported BOs are not allocated by the device so we don't update BO stats when they are imported. Therefore, we should not be updating them when they are freed either. Reviewed-by: Alejandro Piñeiro <apinheiro@igalia.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19675>
This commit is contained in:
committed by
Marge Bot
parent
6bb5aceb28
commit
f14e2ca099
@@ -142,15 +142,17 @@ bo_free(struct v3dv_device *device,
|
||||
if (ret != 0)
|
||||
fprintf(stderr, "close object %d: %s\n", bo->handle, strerror(errno));
|
||||
|
||||
device->bo_count--;
|
||||
device->bo_size -= bo->size;
|
||||
if (!bo->is_import) {
|
||||
device->bo_count--;
|
||||
device->bo_size -= bo->size;
|
||||
|
||||
if (dump_stats) {
|
||||
fprintf(stderr, "Freed %s%s%dkb:\n",
|
||||
bo->name ? bo->name : "",
|
||||
bo->name ? " " : "",
|
||||
bo->size / 1024);
|
||||
bo_dump_stats(device);
|
||||
if (dump_stats) {
|
||||
fprintf(stderr, "Freed %s%s%dkb:\n",
|
||||
bo->name ? bo->name : "",
|
||||
bo->name ? " " : "",
|
||||
bo->size / 1024);
|
||||
bo_dump_stats(device);
|
||||
}
|
||||
}
|
||||
|
||||
/* Our BO structs are stored in a sparse array in the physical device,
|
||||
@@ -198,9 +200,21 @@ v3dv_bo_init(struct v3dv_bo *bo,
|
||||
bo->name = name;
|
||||
bo->private = private;
|
||||
bo->dumb_handle = -1;
|
||||
bo->is_import = false;
|
||||
list_inithead(&bo->list_link);
|
||||
}
|
||||
|
||||
void
|
||||
v3dv_bo_init_import(struct v3dv_bo *bo,
|
||||
uint32_t handle,
|
||||
uint32_t size,
|
||||
uint32_t offset,
|
||||
bool private)
|
||||
{
|
||||
v3dv_bo_init(bo, handle, size, offset, "import", private);
|
||||
bo->is_import = true;
|
||||
}
|
||||
|
||||
struct v3dv_bo *
|
||||
v3dv_bo_alloc(struct v3dv_device *device,
|
||||
uint32_t size,
|
||||
|
||||
@@ -52,6 +52,9 @@ struct v3dv_bo {
|
||||
*/
|
||||
bool private;
|
||||
|
||||
/** If this BO has been imported */
|
||||
bool is_import;
|
||||
|
||||
/**
|
||||
* If this BO was allocated for a swapchain on the display device, the
|
||||
* handle of the dumb BO on that device.
|
||||
@@ -62,6 +65,7 @@ struct v3dv_bo {
|
||||
};
|
||||
|
||||
void v3dv_bo_init(struct v3dv_bo *bo, uint32_t handle, uint32_t size, uint32_t offset, const char *name, bool private);
|
||||
void v3dv_bo_init_import(struct v3dv_bo *bo, uint32_t handle, uint32_t size, uint32_t offset, bool private);
|
||||
|
||||
struct v3dv_bo *v3dv_bo_alloc(struct v3dv_device *device, uint32_t size, const char *name, bool private);
|
||||
|
||||
|
||||
@@ -2278,7 +2278,7 @@ device_import_bo(struct v3dv_device *device,
|
||||
assert(*bo);
|
||||
|
||||
if ((*bo)->refcnt == 0)
|
||||
v3dv_bo_init(*bo, handle, size, get_offset.offset, "import", false);
|
||||
v3dv_bo_init_import(*bo, handle, size, get_offset.offset, false);
|
||||
else
|
||||
p_atomic_inc(&(*bo)->refcnt);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user