[Mesa-dev] [PATCH] st/mesa: create framebuffer iface hash table per st manager

James Legg jlegg at feralinteractive.com
Tue Jul 25 13:24:08 UTC 2017


On Sun, 2017-07-23 at 16:37 -0700, Charmaine Lee wrote:
> With this patch, framebuffer interface hash table is created
> per state tracker manager.
> 
> Fixes crash with steam.
> 
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=101876
> Fixes: 5124bf98239 ("st/mesa: add destroy_drawable interface")
> Tested-by: Christoph Haag <haagch at frickel.club>

> --- a/src/mesa/state_tracker/st_manager.c
> +++ b/src/mesa/state_tracker/st_manager.c
> @@ -511,45 +515,63 @@ st_framebuffer_iface_equal(const void *a, const void *b)
>  
>  
>  static boolean
> -st_framebuffer_iface_lookup(const struct st_framebuffer_iface *stfbi)
> +st_framebuffer_iface_lookup(struct st_manager *smapi,
> +                            const struct st_framebuffer_iface *stfbi)
>  {
> +   struct st_manager_private *smPriv =
> +      (struct st_manager_private *)smapi->st_manager_private;
>     struct hash_entry *entry;
>  
> -   mtx_lock(&st_mutex);
> -   entry = _mesa_hash_table_search(st_fbi_ht, stfbi);
> -   mtx_unlock(&st_mutex);
> +   assert(smPriv);
> +   assert(smPriv->stfbi_ht);
> +
> +   mtx_lock(&smPriv->st_mutex);
> +   entry = _mesa_hash_table_search(smPriv->stfbi_ht, stfbi);
> +   mtx_unlock(&smPriv->st_mutex);
>  
>     return entry != NULL;
>  }
>  
>  
>  static boolean
> -st_framebuffer_iface_insert(struct st_framebuffer_iface *stfbi)
> +st_framebuffer_iface_insert(struct st_manager *smapi,
> +                            struct st_framebuffer_iface *stfbi)
>  {
> +   struct st_manager_private *smPriv =
> +      (struct st_manager_private *)smapi->st_manager_private;
>     struct hash_entry *entry;
>  
> -   mtx_lock(&st_mutex);
> -   entry = _mesa_hash_table_insert(st_fbi_ht, stfbi, stfbi);
> -   mtx_unlock(&st_mutex);
> +   assert(smPriv);
> +   assert(smPriv->stfbi_ht);
> +
> +   mtx_lock(&smPriv->st_mutex);
> +   entry = _mesa_hash_table_insert(smPriv->stfbi_ht, stfbi, stfbi);
> +   mtx_unlock(&smPriv->st_mutex);
>  
>     return entry != NULL;
>  }
>  
>  
>  static void
> -st_framebuffer_iface_remove(struct st_framebuffer_iface *stfbi)
> +st_framebuffer_iface_remove(struct st_manager *smapi,
> +                            struct st_framebuffer_iface *stfbi)
>  {
> +   struct st_manager_private *smPriv =
> +      (struct st_manager_private *)smapi->st_manager_private;
>     struct hash_entry *entry;
>  
> -   mtx_lock(&st_mutex);
> -   entry = _mesa_hash_table_search(st_fbi_ht, stfbi);
> +   if (!smPriv || !smPriv->stfbi_ht);
> +      return;

The semicolon after the if causes the return to execute
unconditionally.

> +
> +   mtx_lock(&smPriv->st_mutex);
> +   entry = _mesa_hash_table_search(smPriv->stfbi_ht, stfbi);
>     if (!entry)
>        goto unlock;
>  
> -   _mesa_hash_table_remove(st_fbi_ht, entry);
> +   _mesa_hash_table_remove(smPriv->stfbi_ht, entry);
>  
>  unlock:
> -   mtx_unlock(&st_mutex);
> +   mtx_unlock(&smPriv->st_mutex);
>  }
>  
>  

James


More information about the mesa-dev mailing list