[PATCH] drm/amdgpu: refuse to reserve io mem for split VRAM buffers

Nicolai Hähnle nicolai.haehnle at amd.com
Thu Feb 16 23:21:00 UTC 2017


On 17.02.2017 00:02, Alex Deucher wrote:
> On Thu, Feb 16, 2017 at 5:55 PM, Nicolai Hähnle <nhaehnle at gmail.com> wrote:
>> From: Nicolai Hähnle <nicolai.haehnle at amd.com>
>>
>> When the fast blit path fails while attempting to move a buffer from RAM
>> to VRAM, we fall back to a CPU-based memcpy that cannot handle split VRAM
>> buffers. Instead of crashing, simply fail the buffer move.
>>
>> Ideally, we would teach TTM about split buffers so that the fallback still
>> works in this case, but that is quite involved. So for now, apply the
>> simplest possible fix.
>>
>> Fixes: 40361bb1704b ("drm/amdgpu: add VRAM manager v2")
>> Signed-off-by: Nicolai Hähnle <nicolai.haehnle at amd.com>
>
> Possibly fixes this bug report?
> https://bugzilla.kernel.org/show_bug.cgi?id=194579

It's related, but I think that report is a false positive. It does point 
at code that is not too pretty, though. I've commented on that bug 
report as well.

In any case, that overflow should indeed happen whenever the bug 
addressed by this patch happens, but (a) this patch doesn't change that, 
and (b) I'm pretty sure that the overflow reported by PaX is benign.

We may still have other bugs with split BOs, though.

Cheers,
Nicolai

>
> Alex
>
>> --
>> I ran into this bug during testing. Unfortunately it does not fix the
>> memory corruption bug that I mentioned elsewhere... oh well.
>> ---
>>  drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 3 +++
>>  1 file changed, 3 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
>> index 8d6a68f..f8b578d 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
>> @@ -529,6 +529,9 @@ static int amdgpu_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_mem_
>>         case TTM_PL_TT:
>>                 break;
>>         case TTM_PL_VRAM:
>> +               if (mem->start == AMDGPU_BO_INVALID_OFFSET)
>> +                       return -EINVAL;
>> +
>>                 mem->bus.offset = mem->start << PAGE_SHIFT;
>>                 /* check if it's visible */
>>                 if ((mem->bus.offset + mem->bus.size) > adev->mc.visible_vram_size)
>> --
>> 2.9.3
>>
>> _______________________________________________
>> amd-gfx mailing list
>> amd-gfx at lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/amd-gfx



More information about the amd-gfx mailing list