[Mesa-dev] [PATCH v2 2/2] panfrost: protect access to shared bo cache and transient pool
Boris Brezillon
boris.brezillon at collabora.com
Fri Aug 30 17:19:32 UTC 2019
On Fri, 30 Aug 2019 18:00:13 +0200
Rohan Garg <rohan.garg at collabora.com> wrote:
> Both the BO cache and the transient pool are shared across
> context's. Protect access to these with mutexes.
>
> Signed-off-by: Rohan Garg <rohan.garg at collabora.com>
> --- a/src/gallium/drivers/panfrost/pan_screen.c
> +++ b/src/gallium/drivers/panfrost/pan_screen.c
> @@ -639,8 +639,10 @@ panfrost_create_screen(int fd, struct renderonly *ro)
> return NULL;
> }
>
> + pthread_mutex_init(&screen->transient_lock, NULL);
Coding style issue: indentation should use spaces not tabs.
> util_dynarray_init(&screen->transient_bo, screen);
>
> + pthread_mutex_init(&screen->bo_cache_lock, NULL);
We should probably call pthread_mutex_destroy() in
panfrost_destroy_screen().
> for (unsigned i = 0; i < ARRAY_SIZE(screen->bo_cache); ++i)
> list_inithead(&screen->bo_cache[i]);
>
> diff --git a/src/gallium/drivers/panfrost/pan_screen.h b/src/gallium/drivers/panfrost/pan_screen.h
> index 7991b395f54..e3ea246d3f3 100644
> --- a/src/gallium/drivers/panfrost/pan_screen.h
> +++ b/src/gallium/drivers/panfrost/pan_screen.h
> @@ -104,6 +104,8 @@ struct panfrost_screen {
>
> struct renderonly *ro;
>
> + pthread_mutex_t transient_lock;
> +
> /* Transient memory management is based on borrowing fixed-size slabs
> * off the screen (loaning them out to the batch). Dynamic array
> * container of panfrost_bo */
> @@ -113,6 +115,8 @@ struct panfrost_screen {
> /* Set of free transient BOs */
> BITSET_DECLARE(free_transient, MAX_TRANSIENT_SLABS);
>
> + pthread_mutex_t bo_cache_lock;
Same indentation issue.
No need to send a new version, I can fix those issues when applying.
Reviewed-by: Boris Brezillon <boris.brezillon at collabora.com>
> +
> /* The BO cache is a set of buckets with power-of-two sizes ranging
> * from 2^12 (4096, the page size) to 2^(12 + MAX_BO_CACHE_BUCKETS).
> * Each bucket is a linked list of free panfrost_bo objects. */
More information about the mesa-dev
mailing list