[Mesa-dev] [PATCH 1/2] vdpau: call texture_get_handle while the mutex is being held

Christian König deathsimple at vodafone.de
Wed Jan 4 12:50:11 UTC 2017


Am 04.01.2017 um 11:47 schrieb Marek Olšák:
> From: Marek Olšák <marek.olsak at amd.com>
>
> The context may be used by texture_get_handle.
>
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=99158

Ah, yes of course. Did you added the context to resource_get_handle 
recently? If not CC stable might be a good idea.

Anyway both patches are Reviewed-by: Christian König 
<christian.koenig at amd.com>.

Regards,
Christian.

> ---
>   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
> @@ -791,30 +791,33 @@ VdpStatus vlVdpOutputSurfaceDMABuf(VdpOutputSurface surface,
>      memset(result, 0, sizeof(*result));
>      result->handle = -1;
>   
>      vlsurface = vlGetDataHTAB(surface);
>      if (!vlsurface || !vlsurface->surface)
>         return VDP_STATUS_INVALID_HANDLE;
>   
>      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;
>   
>      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;
>      result->height = vlsurface->surface->height;
>      result->offset = whandle.offset;
>      result->stride = whandle.stride;
>      result->format = PipeToFormatRGBA(vlsurface->surface->format);
>   
>      return VDP_STATUS_OK;
>   }
> 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
> @@ -453,34 +453,38 @@ VdpStatus vlVdpVideoSurfaceDMABuf(VdpVideoSurface surface,
>      }
>   
>      /* Check if surface match interop requirements */
>      if (p_surf->video_buffer == NULL || !p_surf->video_buffer->interlaced ||
>          p_surf->video_buffer->buffer_format != PIPE_FORMAT_NV12) {
>         pipe_mutex_unlock(p_surf->device->mutex);
>         return VDP_STATUS_NO_IMPLEMENTATION;
>      }
>   
>      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;
>      whandle.layer = surf->u.tex.first_layer;
>   
>      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;
>      result->height = surf->height;
>      result->offset = whandle.offset;
>      result->stride = whandle.stride;
>   
>      if (surf->format == PIPE_FORMAT_R8_UNORM)
>         result->format = VDP_RGBA_FORMAT_R8;
>      else




More information about the mesa-dev mailing list