From 9da901d2b2e7ab5d5f21a0004fc294810f69f04a Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Tue, 27 Jul 2021 08:55:02 +0200 Subject: [PATCH] etnaviv: fail in get_handle(TYPE_KMS) without a scanout resource 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 Reviewed-by: Christian Gmeiner Cc: mesa-stable Part-of: --- src/gallium/drivers/etnaviv/etnaviv_resource.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/etnaviv/etnaviv_resource.c b/src/gallium/drivers/etnaviv/etnaviv_resource.c index fa865f25093..3d1552e4c23 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_resource.c +++ b/src/gallium/drivers/etnaviv/etnaviv_resource.c @@ -580,6 +580,7 @@ etna_resource_get_handle(struct pipe_screen *pscreen, struct pipe_resource *prsc, struct winsys_handle *handle, unsigned usage) { + struct etna_screen *screen = etna_screen(pscreen); struct etna_resource *rsc = etna_resource(prsc); struct renderonly_scanout *scanout; @@ -607,8 +608,8 @@ etna_resource_get_handle(struct pipe_screen *pscreen, if (handle->type == WINSYS_HANDLE_TYPE_SHARED) { return etna_bo_get_name(rsc->bo, &handle->handle) == 0; } else if (handle->type == WINSYS_HANDLE_TYPE_KMS) { - if (renderonly_get_handle(scanout, handle)) { - return true; + if (screen->ro) { + return renderonly_get_handle(scanout, handle); } else { handle->handle = etna_bo_handle(rsc->bo); return true;