summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThierry Reding <treding@nvidia.com>2021-10-06 22:47:17 +0200
committerEric Engestrom <eric@engestrom.ch>2022-02-23 17:55:56 +0000
commitb295aa9997bebb5021fc80032cf06a40f1166688 (patch)
tree2ae112adc38de4dbe2efc0ca1c74dd689ec116fa
parent52e72e52f2fcf123c4bacdeda6be5127dad24160 (diff)
tegra: Use private reference count for resources
With the recent addition of the shortcuts aiming to avoid atomic operations, the reference count on resources can become unbalanced in the Tegra driver since they are wrapped and then proxied to the Nouveau driver. Fix this by keeping a private reference count. Fixes: 7688b8ae9802 ("st/mesa: eliminate all atomic ops when setting vertex buffers") Reviewed-by: Karol Herbst <kherbst@redhat.com> Tested-by: Karol Herbst <kherbst@redhat.com> (cherry picked from commit 108e6eaa83eed3eb356f3cce835c5f5e3a836b8e)
-rw-r--r--.pick_status.json2
-rw-r--r--src/gallium/drivers/tegra/tegra_resource.h1
-rw-r--r--src/gallium/drivers/tegra/tegra_screen.c6
3 files changed, 8 insertions, 1 deletions
diff --git a/.pick_status.json b/.pick_status.json
index f8da2ceae56..18e0bc3428c 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -2173,7 +2173,7 @@
"description": "tegra: Use private reference count for resources",
"nominated": true,
"nomination_type": 1,
- "resolution": 0,
+ "resolution": 1,
"main_sha": null,
"because_sha": "7688b8ae980223f094be9c70fe695e2122caf3e3"
},
diff --git a/src/gallium/drivers/tegra/tegra_resource.h b/src/gallium/drivers/tegra/tegra_resource.h
index 67507d64590..892afaf5e0f 100644
--- a/src/gallium/drivers/tegra/tegra_resource.h
+++ b/src/gallium/drivers/tegra/tegra_resource.h
@@ -31,6 +31,7 @@ struct winsys_handle;
struct tegra_resource {
struct pipe_resource base;
struct pipe_resource *gpu;
+ unsigned int refcount;
uint64_t modifier;
uint32_t stride;
diff --git a/src/gallium/drivers/tegra/tegra_screen.c b/src/gallium/drivers/tegra/tegra_screen.c
index 2b108b07908..3c4c36e0c94 100644
--- a/src/gallium/drivers/tegra/tegra_screen.c
+++ b/src/gallium/drivers/tegra/tegra_screen.c
@@ -245,6 +245,10 @@ tegra_screen_resource_create(struct pipe_screen *pscreen,
pipe_reference_init(&resource->base.reference, 1);
resource->base.screen = &screen->base;
+ /* use private reference count for wrapped resources */
+ resource->gpu->reference.count += 100000000;
+ resource->refcount = 100000000;
+
return &resource->base;
destroy:
@@ -352,6 +356,8 @@ tegra_screen_resource_destroy(struct pipe_screen *pscreen,
{
struct tegra_resource *resource = to_tegra_resource(presource);
+ /* adjust private reference count */
+ p_atomic_add(&resource->gpu->reference.count, -resource->refcount);
pipe_resource_reference(&resource->gpu, NULL);
free(resource);
}