mirror of
https://src.fedoraproject.org/rpms/mesa.git
synced 2024-11-24 09:32:42 +00:00
59 lines
2.1 KiB
Diff
59 lines
2.1 KiB
Diff
|
From 6e786d9e657dc3a0cb659dbf68a11fe75e554d8f Mon Sep 17 00:00:00 2001
|
||
|
From: Thierry Reding <treding@nvidia.com>
|
||
|
Date: Wed, 6 Oct 2021 22:47:17 +0200
|
||
|
Subject: [PATCH 2/6] 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")
|
||
|
Tested-by: Karol Herbst <kherbst@redhat.com>
|
||
|
---
|
||
|
src/gallium/drivers/tegra/tegra_resource.h | 1 +
|
||
|
src/gallium/drivers/tegra/tegra_screen.c | 6 ++++++
|
||
|
2 files changed, 7 insertions(+)
|
||
|
|
||
|
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);
|
||
|
}
|
||
|
--
|
||
|
2.31.1
|
||
|
|