[Mesa-dev] [PATCH] winsys/amdgpu: add BO to the global list only when RADEON_ALL_BOS is set

Marek Olšák maraeo at gmail.com
Tue Aug 29 20:42:08 UTC 2017


Reviewed-by: Marek Olšák <marek.olsak at amd.com>

Marek

On Tue, Aug 29, 2017 at 4:24 PM, Samuel Pitoiset
<samuel.pitoiset at gmail.com> wrote:
> Only useful when that debug option is enabled.
>
> Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
> ---
>  src/gallium/winsys/amdgpu/drm/amdgpu_bo.c     | 20 ++++++++++++--------
>  src/gallium/winsys/amdgpu/drm/amdgpu_cs.c     |  4 +---
>  src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c |  3 +++
>  src/gallium/winsys/amdgpu/drm/amdgpu_winsys.h |  1 +
>  4 files changed, 17 insertions(+), 11 deletions(-)
>
> diff --git a/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c b/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c
> index 97bbe235a4..1323be8356 100644
> --- a/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c
> +++ b/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c
> @@ -167,10 +167,12 @@ void amdgpu_bo_destroy(struct pb_buffer *_buf)
>
>     assert(bo->bo && "must not be called for slab entries");
>
> -   mtx_lock(&bo->ws->global_bo_list_lock);
> -   LIST_DEL(&bo->u.real.global_list_item);
> -   bo->ws->num_buffers--;
> -   mtx_unlock(&bo->ws->global_bo_list_lock);
> +   if (bo->ws->debug_all_bos) {
> +      mtx_lock(&bo->ws->global_bo_list_lock);
> +      LIST_DEL(&bo->u.real.global_list_item);
> +      bo->ws->num_buffers--;
> +      mtx_unlock(&bo->ws->global_bo_list_lock);
> +   }
>
>     amdgpu_bo_va_op(bo->bo, 0, bo->base.size, bo->va, 0, AMDGPU_VA_OP_UNMAP);
>     amdgpu_va_range_free(bo->u.real.va_handle);
> @@ -360,10 +362,12 @@ static void amdgpu_add_buffer_to_global_list(struct amdgpu_winsys_bo *bo)
>
>     assert(bo->bo);
>
> -   mtx_lock(&ws->global_bo_list_lock);
> -   LIST_ADDTAIL(&bo->u.real.global_list_item, &ws->global_bo_list);
> -   ws->num_buffers++;
> -   mtx_unlock(&ws->global_bo_list_lock);
> +   if (ws->debug_all_bos) {
> +      mtx_lock(&ws->global_bo_list_lock);
> +      LIST_ADDTAIL(&bo->u.real.global_list_item, &ws->global_bo_list);
> +      ws->num_buffers++;
> +      mtx_unlock(&ws->global_bo_list_lock);
> +   }
>  }
>
>  static struct amdgpu_winsys_bo *amdgpu_create_bo(struct amdgpu_winsys *ws,
> diff --git a/src/gallium/winsys/amdgpu/drm/amdgpu_cs.c b/src/gallium/winsys/amdgpu/drm/amdgpu_cs.c
> index 9cadfc4298..5ddde8e794 100644
> --- a/src/gallium/winsys/amdgpu/drm/amdgpu_cs.c
> +++ b/src/gallium/winsys/amdgpu/drm/amdgpu_cs.c
> @@ -903,8 +903,6 @@ static unsigned amdgpu_cs_get_buffer_list(struct radeon_winsys_cs *rcs,
>      return cs->num_real_buffers;
>  }
>
> -DEBUG_GET_ONCE_BOOL_OPTION(all_bos, "RADEON_ALL_BOS", false)
> -
>  static void amdgpu_add_fence_dependency(struct amdgpu_cs *acs,
>                                          struct amdgpu_cs_buffer *buffer)
>  {
> @@ -1097,7 +1095,7 @@ void amdgpu_cs_submit_ib(void *job, int thread_index)
>     /* Create the buffer list.
>      * Use a buffer list containing all allocated buffers if requested.
>      */
> -   if (debug_get_option_all_bos()) {
> +   if (ws->debug_all_bos) {
>        struct amdgpu_winsys_bo *bo;
>        amdgpu_bo_handle *handles;
>        unsigned num = 0;
> diff --git a/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c b/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c
> index a8b5e5b41a..5e0c1fd8d8 100644
> --- a/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c
> +++ b/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c
> @@ -50,6 +50,8 @@
>  static struct util_hash_table *dev_tab = NULL;
>  static mtx_t dev_tab_mutex = _MTX_INITIALIZER_NP;
>
> +DEBUG_GET_ONCE_BOOL_OPTION(all_bos, "RADEON_ALL_BOS", false)
> +
>  /* Helper function to do the ioctls needed for setup and init. */
>  static bool do_winsys_init(struct amdgpu_winsys *ws, int fd)
>  {
> @@ -70,6 +72,7 @@ static bool do_winsys_init(struct amdgpu_winsys *ws, int fd)
>     }
>
>     ws->check_vm = strstr(debug_get_option("R600_DEBUG", ""), "check_vm") != NULL;
> +   ws->debug_all_bos = debug_get_option_all_bos();
>
>     return true;
>
> diff --git a/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.h b/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.h
> index 7aca612f45..de54470ede 100644
> --- a/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.h
> +++ b/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.h
> @@ -79,6 +79,7 @@ struct amdgpu_winsys {
>     ADDR_HANDLE addrlib;
>
>     bool check_vm;
> +   bool debug_all_bos;
>
>     /* List of all allocated buffers */
>     mtx_t global_bo_list_lock;
> --
> 2.14.1
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list