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>
struct tegra_resource {
struct pipe_resource base;
struct pipe_resource *gpu;
+ unsigned int refcount;
uint64_t modifier;
uint32_t stride;
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:
{
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);
}