[RFC PATCH 1/2] drm/amdgpu: amdgpu_vram_mgr_new(): Clamp lpfn to total vram

Christian König christian.koenig at amd.com
Fri May 2 08:28:38 UTC 2025


On 4/30/25 23:20, Alex Deucher wrote:
> + Christian
> 
> On Tue, Apr 29, 2025 at 7:24 AM John Olender <john.olender at gmail.com> wrote:
>>
>> The drm_mm allocator tolerated being passed end > mm->size, but the
>> drm_buddy allocator does not.
>>
>> Restore the pre-buddy-allocator behavior of allowing such placements.
>>
>> Closes: https://gitlab.freedesktop.org/drm/amd/-/issues/3448
>> Signed-off-by: John Olender <john.olender at gmail.com>
> 
> This looks correct to me.
> Reviewed-by: Alex Deucher <alexander.deucher at amd.com>


Good catch, Arun needs to look at this.

My educated guess is that it would be better to make the drm buddy tolerate being passed end > mm->size.

Regards,
Christian.

> 
>> ---
>>  drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
>> index 2d7f82e98df9..abdc52b0895a 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
>> @@ -463,7 +463,7 @@ static int amdgpu_vram_mgr_new(struct ttm_resource_manager *man,
>>         int r;
>>
>>         lpfn = (u64)place->lpfn << PAGE_SHIFT;
>> -       if (!lpfn)
>> +       if (!lpfn || lpfn > man->size)
>>                 lpfn = man->size;
>>
>>         fpfn = (u64)place->fpfn << PAGE_SHIFT;
>> --
>> 2.47.2
>>



More information about the amd-gfx mailing list