Re: [PATCH] drm/amd/amdgpu: Bail out of BO node creation if not enough VRAM

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2019-06-11 9:34 a.m., Christian König wrote:
> Am 10.06.19 um 16:32 schrieb StDenis, Tom:
>> Signed-off-by: Tom St Denis <tom.stdenis@xxxxxxx>
>> ---
>>   drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c | 17 ++++++++++++-----
>>   1 file changed, 12 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c 
>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
>> index 8aea2f21b202..70b4a5a97ed2 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
>> @@ -276,7 +276,7 @@ static int amdgpu_vram_mgr_new(struct 
>> ttm_mem_type_manager *man,
>>       struct drm_mm_node *nodes;
>>       enum drm_mm_insert_mode mode;
>>       unsigned long lpfn, num_nodes, pages_per_node, pages_left;
>> -    uint64_t usage = 0, vis_usage = 0;
>> +    uint64_t vis_usage = 0;
>>       unsigned i;
>>       int r;
>>   @@ -284,6 +284,13 @@ static int amdgpu_vram_mgr_new(struct 
>> ttm_mem_type_manager *man,
>>       if (!lpfn)
>>           lpfn = man->size;
>>   +    /* bail out quickly if there's likely not enough VRAM for this 
>> BO */
>> +    atomic64_add(mem->num_pages << PAGE_SHIFT, &mgr->usage);
>> +    if (atomic64_read(&mgr->usage) > adev->gmc.mc_vram_size) {
>> +        atomic64_sub(mem->num_pages << PAGE_SHIFT, &mgr->usage);
>> +        return -ENOSPC;
>> +    }
>
> That's not 100% correct IIRC. See TTM expects a return value of 0, but 
> mem->node to be NULL when allocation fails.


Yup, the node creation returns -ENOSPC which this function then 
translates to 0.  I'll submit a v2 in a minute once I pass a piglit test :-)


Tom

_______________________________________________
amd-gfx mailing list
amd-gfx@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/amd-gfx




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux