[PATCH] drm/amdgpu: correct vram mgr node size calculation

Philip Yang philip.yang at amd.com
Wed Jan 29 18:51:32 UTC 2020


Thanks and understand.

Philip

On 2020-01-28 2:59 p.m., Christian König wrote:
> Am 28.01.20 um 20:55 schrieb Philip Yang:
>> Use pages_per_node instead of mem->num_pages to alloc vram, this will
>> increase the chance to get vram node after vram fragments.
> 
> NAK, this is intentional to aid TLB with continuous allocations.
> 
> The fallback to using pages_per_node is directly below, so your patch 
> should be completely superfluous.
> 
> Regards,
> Christian.
> 
>>
>> Signed-off-by: Philip Yang <Philip.Yang at amd.com>
>> ---
>>   drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c | 11 +++--------
>>   1 file changed, 3 insertions(+), 8 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c 
>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
>> index 82a3299e53c0..67a454f4c37a 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
>> @@ -369,7 +369,7 @@ static int amdgpu_vram_mgr_new(struct 
>> ttm_mem_type_manager *man,
>>       spin_lock(&mgr->lock);
>>       for (i = 0; pages_left >= pages_per_node; ++i) {
>> -        unsigned long pages = rounddown_pow_of_two(pages_left);
>> +        unsigned long pages = rounddown_pow_of_two(pages_per_node);
>>           r = drm_mm_insert_node_in_range(mm, &nodes[i], pages,
>>                           pages_per_node, 0,
>> @@ -383,15 +383,11 @@ static int amdgpu_vram_mgr_new(struct 
>> ttm_mem_type_manager *man,
>>           pages_left -= pages;
>>       }
>> -    for (; pages_left; ++i) {
>> -        unsigned long pages = min(pages_left, pages_per_node);
>> +    if (pages_left) {
>>           uint32_t alignment = mem->page_alignment;
>> -        if (pages == pages_per_node)
>> -            alignment = pages_per_node;
>> -
>>           r = drm_mm_insert_node_in_range(mm, &nodes[i],
>> -                        pages, alignment, 0,
>> +                        pages_left, alignment, 0,
>>                           place->fpfn, lpfn,
>>                           mode);
>>           if (unlikely(r))
>> @@ -399,7 +395,6 @@ static int amdgpu_vram_mgr_new(struct 
>> ttm_mem_type_manager *man,
>>           vis_usage += amdgpu_vram_mgr_vis_size(adev, &nodes[i]);
>>           amdgpu_vram_mgr_virt_start(mem, &nodes[i]);
>> -        pages_left -= pages;
>>       }
>>       spin_unlock(&mgr->lock);
> 


More information about the amd-gfx mailing list