[PATCH] drm/amdgpu: fix a warning about different types in min() macro

Nicolai Hähnle nicolai.haehnle at amd.com
Tue Feb 14 12:01:19 UTC 2017


On 14.02.2017 11:57, Christian König wrote:
> Am 14.02.2017 um 11:40 schrieb Nicolai Hähnle:
>> From: Nicolai Hähnle <nicolai.haehnle at amd.com>
>>
>> In file included from ./include/linux/list.h:8:0,
>>                   from drivers/gpu/drm/amd/amdgpu/amdgpu_object.c:32:
>> drivers/gpu/drm/amd/amdgpu/amdgpu_object.c: In function
>> ‘amdgpu_bo_create_restricted’:
>> ./include/linux/kernel.h:739:16: warning: comparison of distinct
>> pointer types lacks a cast
>>    (void) (&min1 == &min2);   \
>>                  ^
>> ./include/linux/kernel.h:742:2: note: in expansion of macro ‘__min’
>>    __min(typeof(x), typeof(y),   \
>>    ^~~~~
>> drivers/gpu/drm/amd/amdgpu/amdgpu_object.c:434:21: note: in expansion
>> of macro ‘min’
>>    bo->tbo.priority = min(bo->tbo.priority, TTM_MAX_BO_PRIORITY - 1);
>>                       ^~~
>>
>> Signed-off-by: Nicolai Hähnle <nicolai.haehnle at amd.com>
>
> Thanks for taking care of this, but I would prefer to fix the root cause
> and make the define of TTM_MAX_BO_PRIORITY unsigned.

Makes sense, will do.


>
> Regards,
> Christian.
>
>> ---
>>   drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 3 ++-
>>   1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
>> index bea845f..71dfea4 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
>> @@ -431,7 +431,8 @@ int amdgpu_bo_create_restricted(struct
>> amdgpu_device *adev,
>>       bo->tbo.priority = ilog2(bo->tbo.num_pages);
>>       if (kernel)
>>           bo->tbo.priority *= 2;
>> -    bo->tbo.priority = min(bo->tbo.priority, TTM_MAX_BO_PRIORITY - 1);
>> +    bo->tbo.priority = min(bo->tbo.priority,
>> +                   (unsigned)(TTM_MAX_BO_PRIORITY - 1));
>>         if (flags & AMDGPU_GEM_CREATE_VRAM_CLEARED &&
>>           bo->tbo.mem.placement & TTM_PL_FLAG_VRAM) {
>
>



More information about the amd-gfx mailing list