[Mesa-dev] [PATCH 3/7] winsys/amdgpu: add an assertion to cik_get_num_tile_pipes

Michel Dänzer michel at daenzer.net
Sun Jan 31 19:21:17 PST 2016


On 30.01.2016 06:18, Marek Olšák wrote:
> From: Marek Olšák <marek.olsak at amd.com>
> 
> ---
>  src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c b/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c
> index d1ba259..8366f8f 100644
> --- a/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c
> +++ b/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c
> @@ -68,7 +68,6 @@ static unsigned cik_get_num_tile_pipes(struct amdgpu_gpu_info *info)
>  
>     switch (CIK__GB_TILE_MODE__PIPE_CONFIG(mode2d)) {
>     case CIK__PIPE_CONFIG__ADDR_SURF_P2:
> -   default:
>         return 2;
>     case CIK__PIPE_CONFIG__ADDR_SURF_P4_8x16:
>     case CIK__PIPE_CONFIG__ADDR_SURF_P4_16x16:
> @@ -86,6 +85,9 @@ static unsigned cik_get_num_tile_pipes(struct amdgpu_gpu_info *info)
>     case CIK__PIPE_CONFIG__ADDR_SURF_P16_32X32_8X16:
>     case CIK__PIPE_CONFIG__ADDR_SURF_P16_32X32_16X16:
>         return 16;
> +   default:
> +       assert(!"this should never occur");
> +       return 2;
>     }
>  }

assert() is a no-op in release builds, so a normal user might never
notice that something's wrong here. Also, the message should be more
specific. How about:

   default:
       fprintf(stderr, "Invalid CIK pipe configuration, assuming P2\n");
       assert(0);
       return 2;

This will print the message for any build type, and then abort with a
non-release build.


-- 
Earthling Michel Dänzer               |               http://www.amd.com
Libre software enthusiast             |             Mesa and X developer


More information about the mesa-dev mailing list