[PATCH 2/2] drm/amdgpu: raise error on incorrect mem_type

Das, Nirmoy nirmoy.das at amd.com
Tue Jun 29 11:43:17 UTC 2021


On 6/29/2021 1:06 PM, Christian König wrote:
>
>
> Am 29.06.21 um 09:36 schrieb Nirmoy Das:
>> Be more defensive and raise error on wrong mem_type
>> argument in amdgpu_gtt_mgr_has_gart_addr().
>>
>> Signed-off-by: Nirmoy Das <nirmoy.das at amd.com>
>> ---
>>   drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c | 6 +++++-
>>   1 file changed, 5 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c 
>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
>> index 543000304a1c..0b0fa87b115c 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
>> @@ -107,8 +107,12 @@ const struct attribute_group 
>> amdgpu_gtt_mgr_attr_group = {
>>    */
>>   bool amdgpu_gtt_mgr_has_gart_addr(struct ttm_resource *res)
>>   {
>> -    struct amdgpu_gtt_node *node = to_amdgpu_gtt_node(res);
>> +    struct amdgpu_gtt_node *node;
>> +
>> +    if (WARN_ON(res->mem_type != TTM_PL_TT))
>> +        return false;
>
> I'm not sure that is a good idea. The GTT manager itself shouldn't 
> have to deal with incorrect usage of it's component.


This is in-case we accidentally use amdgpu_gtt_mgr_has_gart_addr() for 
PREEMPT bo in future. I will drop it as the previous patch should give 
us enough hint.


Regards,

Nirmoy


>
> Christian.
>
>>   +    node = to_amdgpu_gtt_node(res);
>>       return drm_mm_node_allocated(&node->base.mm_nodes[0]);
>>   }
>


More information about the dri-devel mailing list