panfrost: fail in get_handle(TYPE_KMS) without a scanout resource
authorSimon Ser <contact@emersion.fr>
Tue, 27 Jul 2021 06:59:52 +0000 (08:59 +0200)
committerSimon Ser <contact@emersion.fr>
Thu, 29 Jul 2021 19:01:10 +0000 (21:01 +0200)
The previous logic was returning a handle valid for the render-only
device if rsc->scanout was NULL. However the caller doesn't expect
this: the caller will use the handle with the KMS device.

Instead of returning a handle for the wrong device, fail if we don't
have one.

Signed-off-by: Simon Ser <contact@emersion.fr>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Cc: mesa-stable
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12074>

src/gallium/drivers/panfrost/pan_resource.c

index 678977a..5914057 100644 (file)
@@ -144,13 +144,14 @@ panfrost_resource_get_handle(struct pipe_screen *pscreen,
         if (handle->type == WINSYS_HANDLE_TYPE_SHARED) {
                 return false;
         } else if (handle->type == WINSYS_HANDLE_TYPE_KMS) {
-                if (renderonly_get_handle(scanout, handle))
+                if (dev->ro) {
+                        return renderonly_get_handle(scanout, handle);
+                } else {
+                        handle->handle = rsrc->image.data.bo->gem_handle;
+                        handle->stride = rsrc->image.layout.slices[0].line_stride;
+                        handle->offset = rsrc->image.layout.slices[0].offset;
                         return true;
-
-                handle->handle = rsrc->image.data.bo->gem_handle;
-                handle->stride = rsrc->image.layout.slices[0].line_stride;
-                handle->offset = rsrc->image.layout.slices[0].offset;
-                return TRUE;
+                }
         } else if (handle->type == WINSYS_HANDLE_TYPE_FD) {
                 if (scanout) {
                         struct drm_prime_handle args = {