lima: remove its hash table entry when invalidating a resource
authorIcenowy Zheng <icenowy@aosc.io>
Sat, 22 Feb 2020 08:54:56 +0000 (16:54 +0800)
committerMarge Bot <eric+marge@anholt.net>
Mon, 24 Feb 2020 20:53:31 +0000 (20:53 +0000)
When a resouce is already invalidated, its hash table entry becomes
useless. In addition, the lima_job_free() function won't remove the hash
table entry for invalidated resource. So the hash entry should be
removed when invalidating the resource, otherwise bogus hash entry might
be left in the table, and when the resource is reused in another job,
the code will find the freed job when invalidating and thus result in crash.

Fixes: c64994433c0d ("lima: track write submits of context (v3)")
Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
Reviewed-by: Vasily Khoruzhick <anarsoul@gmail.com>
Reviewed-by: Qiang Yu <yuq825@gmail.com>
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3917>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3917>

src/gallium/drivers/lima/lima_context.c

index f5d62c9..9538f9a 100644 (file)
@@ -118,6 +118,8 @@ lima_invalidate_resource(struct pipe_context *pctx, struct pipe_resource *prsc)
 
    if (job->key.cbuf && (job->key.cbuf->texture == prsc))
       job->resolve &= ~PIPE_CLEAR_COLOR0;
+
+   _mesa_hash_table_remove_key(ctx->write_jobs, prsc);
 }
 
 static void