From dbba4e03b16b80bf4071016b8197369ccb20c72b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Wed, 4 Jan 2017 11:42:13 +0100 Subject: [PATCH] vdpau: call texture_get_handle while the mutex is being held MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The context may be used by texture_get_handle. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=99158 Reviewed-by: Christian König Cc: 13.0 --- src/gallium/state_trackers/vdpau/output.c | 7 +++++-- src/gallium/state_trackers/vdpau/surface.c | 12 ++++++++---- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/gallium/state_trackers/vdpau/output.c b/src/gallium/state_trackers/vdpau/output.c index 64574b2..d67ead8 100644 --- a/src/gallium/state_trackers/vdpau/output.c +++ b/src/gallium/state_trackers/vdpau/output.c @@ -798,7 +798,6 @@ VdpStatus vlVdpOutputSurfaceDMABuf(VdpOutputSurface surface, pipe_mutex_lock(vlsurface->device->mutex); vlVdpResolveDelayedRendering(vlsurface->device, NULL, NULL); vlsurface->device->context->flush(vlsurface->device->context, NULL, 0); - pipe_mutex_unlock(vlsurface->device->mutex); memset(&whandle, 0, sizeof(struct winsys_handle)); whandle.type = DRM_API_HANDLE_TYPE_FD; @@ -806,8 +805,12 @@ VdpStatus vlVdpOutputSurfaceDMABuf(VdpOutputSurface surface, pscreen = vlsurface->surface->texture->screen; if (!pscreen->resource_get_handle(pscreen, vlsurface->device->context, vlsurface->surface->texture, &whandle, - PIPE_HANDLE_USAGE_READ_WRITE)) + PIPE_HANDLE_USAGE_READ_WRITE)) { + pipe_mutex_unlock(vlsurface->device->mutex); return VDP_STATUS_NO_IMPLEMENTATION; + } + + pipe_mutex_unlock(vlsurface->device->mutex); result->handle = whandle.handle; result->width = vlsurface->surface->width; diff --git a/src/gallium/state_trackers/vdpau/surface.c b/src/gallium/state_trackers/vdpau/surface.c index 69afce0..9a80605 100644 --- a/src/gallium/state_trackers/vdpau/surface.c +++ b/src/gallium/state_trackers/vdpau/surface.c @@ -460,10 +460,10 @@ VdpStatus vlVdpVideoSurfaceDMABuf(VdpVideoSurface surface, } surf = p_surf->video_buffer->get_surfaces(p_surf->video_buffer)[plane]; - pipe_mutex_unlock(p_surf->device->mutex); - - if (!surf) + if (!surf) { + pipe_mutex_unlock(p_surf->device->mutex); return VDP_STATUS_RESOURCES; + } memset(&whandle, 0, sizeof(struct winsys_handle)); whandle.type = DRM_API_HANDLE_TYPE_FD; @@ -472,8 +472,12 @@ VdpStatus vlVdpVideoSurfaceDMABuf(VdpVideoSurface surface, pscreen = surf->texture->screen; if (!pscreen->resource_get_handle(pscreen, p_surf->device->context, surf->texture, &whandle, - PIPE_HANDLE_USAGE_READ_WRITE)) + PIPE_HANDLE_USAGE_READ_WRITE)) { + pipe_mutex_unlock(p_surf->device->mutex); return VDP_STATUS_NO_IMPLEMENTATION; + } + + pipe_mutex_unlock(p_surf->device->mutex); result->handle = whandle.handle; result->width = surf->width; -- 2.7.4