etnaviv: fix double scanout import of multiplanar resources
authorLucas Stach <l.stach@pengutronix.de>
Mon, 30 Jan 2023 17:58:30 +0000 (18:58 +0100)
committerMarge Bot <emma+marge@anholt.net>
Thu, 2 Feb 2023 19:08:29 +0000 (19:08 +0000)
etna_resource_from_handle() is called for each plane of a multiplanar
resource, so there is no point in looping over all planes to do the
renderonly scanout import. In fact that will cause us to lose track
of the scanout imports from later planes when the earlier planes are
redoing the import, overwriting the pointer to the allocated
renderonly_scanout struct.

Drop the loop and just do the import for the current plane.

Fixes: 826f95778a4e ("etnaviv: always try to create KMS side handles for imported resources")
Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20993>

src/gallium/drivers/etnaviv/etnaviv_resource.c

index cffa43a..92cb5ce 100644 (file)
@@ -696,15 +696,9 @@ etna_resource_from_handle(struct pipe_screen *pscreen,
                                                                   level->padded_height);
    level->size = level->layer_stride;
 
-   if (screen->ro) {
-      struct pipe_resource *imp_prsc = prsc;
-      do {
-         etna_resource(imp_prsc)->scanout =
-               renderonly_create_gpu_import_for_resource(imp_prsc, screen->ro,
-                                                         NULL);
-         /* failure is expected for scanout incompatible buffers */
-      } while ((imp_prsc = imp_prsc->next));
-   }
+   if (screen->ro)
+      rsc->scanout = renderonly_create_gpu_import_for_resource(prsc, screen->ro,
+                                                               NULL);
 
    /* If the buffer is for a TS plane, skip the RS compatible checks */
    if (handle->plane >= util_format_get_num_planes(prsc->format))