[Mesa-dev] [PATCH] radv: add debug flags to zero vram allocations.

Samuel Pitoiset samuel.pitoiset at gmail.com
Mon Sep 11 09:50:25 UTC 2017



On 09/11/2017 01:49 AM, Dave Airlie wrote:
> From: Dave Airlie <airlied at redhat.com>
> 
> We are seeing apps that sometimes rely on Windows behaviour, add
> a flag to rule out vram zeroing.
> 
> Signed-off-by: Dave Airlie <airlied at redhat.com>
> ---
>   src/amd/vulkan/radv_debug.h                       | 1 +
>   src/amd/vulkan/radv_device.c                      | 1 +
>   src/amd/vulkan/winsys/amdgpu/radv_amdgpu_bo.c     | 4 ++--
>   src/amd/vulkan/winsys/amdgpu/radv_amdgpu_winsys.c | 1 +
>   src/amd/vulkan/winsys/amdgpu/radv_amdgpu_winsys.h | 1 +
>   5 files changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/src/amd/vulkan/radv_debug.h b/src/amd/vulkan/radv_debug.h
> index 18ef7e7..e45c987 100644
> --- a/src/amd/vulkan/radv_debug.h
> +++ b/src/amd/vulkan/radv_debug.h
> @@ -39,6 +39,7 @@ enum {
>   	RADV_DEBUG_NO_IBS            = 0x200,
>   	RADV_DEBUG_DUMP_SPIRV        = 0x400,
>   	RADV_DEBUG_VM_FAULTS         = 0x800,
> +	RADV_DEBUG_ZERO_VRAM         = 0x1000,
>   };
>   
>   enum {
> diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c
> index a68278f..6b96a3d 100644
> --- a/src/amd/vulkan/radv_device.c
> +++ b/src/amd/vulkan/radv_device.c
> @@ -412,6 +412,7 @@ static const struct debug_control radv_debug_options[] = {
>   	{"noibs", RADV_DEBUG_NO_IBS},
>   	{"spirv", RADV_DEBUG_DUMP_SPIRV},
>   	{"vmfaults", RADV_DEBUG_VM_FAULTS},
> +	{"zerovram", RADV_DEBUG_ZERO_VRAM},
>   	{NULL, 0}
>   };
>   
> diff --git a/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_bo.c b/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_bo.c
> index a6941a7..c8b67a0 100644
> --- a/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_bo.c
> +++ b/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_bo.c
> @@ -332,8 +332,8 @@ radv_amdgpu_winsys_bo_create(struct radeon_winsys *_ws,
>   		request.flags |= AMDGPU_GEM_CREATE_CPU_GTT_USWC;
>   
>   	/* this won't do anything on pre 4.9 kernels */
> -	if (initial_domain & RADEON_DOMAIN_VRAM)
> -		request.flags |= (AMDGPU_GEM_CREATE_VRAM_CLEARED);
The patch doesn't apply on git master because the above lines don't 
exist, but looks good to me.

Using this debug flag "fixes" the unity hang on my box.

Reviewed-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>

> +	if (ws->zero_all_vram_allocs && (initial_domain & RADEON_DOMAIN_VRAM))
> +		request.flags |= AMDGPU_GEM_CREATE_VRAM_CLEARED;
>   	r = amdgpu_bo_alloc(ws->dev, &request, &buf_handle);
>   	if (r) {
>   		fprintf(stderr, "amdgpu: Failed to allocate a buffer:\n");
> diff --git a/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_winsys.c b/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_winsys.c
> index a6dedfa..f721964 100644
> --- a/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_winsys.c
> +++ b/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_winsys.c
> @@ -106,6 +106,7 @@ radv_amdgpu_winsys_create(int fd, uint64_t debug_flags, uint64_t perftest_flags)
>   	if (debug_flags & RADV_DEBUG_NO_IBS)
>   		ws->use_ib_bos = false;
>   
> +	ws->zero_all_vram_allocs = !!(debug_flags & RADV_DEBUG_ZERO_VRAM);
>   	ws->batchchain = !(perftest_flags & RADV_PERFTEST_NO_BATCHCHAIN);
>   	LIST_INITHEAD(&ws->global_bo_list);
>   	pthread_mutex_init(&ws->global_bo_list_lock, NULL);
> diff --git a/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_winsys.h b/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_winsys.h
> index f84f62c..66c9347 100644
> --- a/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_winsys.h
> +++ b/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_winsys.h
> @@ -45,6 +45,7 @@ struct radv_amdgpu_winsys {
>   	bool debug_all_bos;
>   	bool batchchain;
>   	bool use_ib_bos;
> +	bool zero_all_vram_allocs;
>   	unsigned num_buffers;
>   
>   	pthread_mutex_t global_bo_list_lock;
> 


More information about the mesa-dev mailing list