[PATCH] drm/amdgpu: Fix VRAM BO swap issue

Arunpravin Paneer Selvam arunpravin.paneerselvam at amd.com
Thu Sep 22 15:20:17 UTC 2022



On 9/22/2022 7:04 PM, Alex Deucher wrote:
> On Thu, Sep 22, 2022 at 9:19 AM Arunpravin Paneer Selvam
> <Arunpravin.PaneerSelvam at amd.com> wrote:
>> DRM buddy manager allocates the contiguous memory requests in
>> a single block or multiple blocks. So for the ttm move operation
>> (incase of low vram memory) we should consider all the blocks to
>> compute the total memory size which compared with the struct
>> ttm_resource num_pages in order to verify that the blocks are
>> contiguous for the eviction process.
>>
>> Signed-off-by: Arunpravin Paneer Selvam <Arunpravin.PaneerSelvam at amd.com>
> Please add a Fixes line and any relevant bug report links.
Hi Alex,
There is no bug created for this issue, I will add Fixes line.

Thanks,
Arun
>
> Alex
>
>> ---
>>   drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 20 ++++++++++++++++++--
>>   1 file changed, 18 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
>> index b1c455329023..b1223c8e30c9 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
>> @@ -426,6 +426,7 @@ static bool amdgpu_mem_visible(struct amdgpu_device *adev,
>>   {
>>          uint64_t mem_size = (u64)mem->num_pages << PAGE_SHIFT;
>>          struct amdgpu_res_cursor cursor;
>> +       u64 start, size, total_size = 0;
>>
>>          if (mem->mem_type == TTM_PL_SYSTEM ||
>>              mem->mem_type == TTM_PL_TT)
>> @@ -435,8 +436,23 @@ static bool amdgpu_mem_visible(struct amdgpu_device *adev,
>>
>>          amdgpu_res_first(mem, 0, mem_size, &cursor);
>>
>> -       /* ttm_resource_ioremap only supports contiguous memory */
>> -       if (cursor.size != mem_size)
>> +       do {
>> +               start = cursor.start;
>> +               size = cursor.size;
>> +
>> +               total_size += size;
>> +
>> +               amdgpu_res_next(&cursor, cursor.size);
>> +
>> +               if (!cursor.remaining)
>> +                       break;
>> +
>> +               /* ttm_resource_ioremap only supports contiguous memory */
>> +               if (start + size != cursor.start)
>> +                       return false;
>> +       } while (1);
>> +
>> +       if (total_size != mem_size)
>>                  return false;
>>
>>          return cursor.start + cursor.size <= adev->gmc.visible_vram_size;
>> --
>> 2.25.1
>>



More information about the amd-gfx mailing list