drm/amdgpu: refuse to reserve io mem for split VRAM buffers
Subsystems (2)
PATCH 1/1 drm/amdgpu: refuse to reserve io mem for split VRAM buffers
From: Nicolai Hähnle <[email protected]>
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.
--
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(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +3 -0
@@ -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)
Signature · 6 lines
2.9.3 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 20170216225545.3515-1-nhaehnle-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Quoted 6 lines · Nicolai Hähnle
From: Nicolai Hähnle <[email protected]>
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.
Quoted 6 lines
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 <[email protected]>
Possibly fixes this bug report?
https://bugzilla.kernel.org/show_bug.cgi?id=194579
Alex
Quoted 24 lines
--
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(+)drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +3
-1@@ -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
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): CADnq5_OOcfke79Wkr37vD6Dgw7ySsTjEAoFCTpHZY-QPG4P6aQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Quoted 11 lines · Alex Deucher
Quoted 10 lines · Nicolai Hähnle
From: Nicolai Hähnle <[email protected]>
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.
Quoted 5 lines
Quoted 2 lines
Fixes 40361bb1704b ("drm/amdgpu: add VRAM manager v2")Signed-off-by Nicolai Hähnle <[email protected]>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
Quoted 27 lines
Alex
Quoted 24 lines
--
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(+)drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +3
-1@@ -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
Quoted 4 lines
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 0aa5b052-a748-8cd2-8ba7-9efa7e9a769a-5C7GfCeVMHo@public.gmane.org
Am 17.02.2017 um 00:21 schrieb Nicolai Hähnle:
Quoted 15 lines · Alex Deucher
Quoted 14 lines · Nicolai Hähnle
Quoted 12 lines
From: Nicolai Hähnle <[email protected]>
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 <[email protected]>
Quoted 6 lines
Quoted 2 lines
Possibly fixes this bug report?
https://bugzilla.kernel.org/show_bug.cgi?id=194579It'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.
Yes, agree. The bug report is indeed a false positive.
Nicolai what do you think about removing the offset from the BO structure and only calculate it on demand?
Quoted 2 lines
We may still have other bugs with split BOs, though.
Yeah, agree as well. I was also considering disabling that feature by default for the moment if it helps with your corruption bug.
Regards,
Christian.
Quoted 33 lines
Cheers,
NicolaiQuoted 29 lines
Alex
Quoted 26 lines
Signature · 5 lines
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(+)drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0
-0@@ -529,6 +529,9 @@ static int amdgpu_ttm_io_mem_reserve(struct
ttm_bo_device*bdev, structttm_mem_case TTM_PL_TT: break; case TTM_PL_VRAM:drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +3
-0+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)Signature · 1 line
2.9.3
Quoted 9 lines
Quoted 4 lines
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): afdc021d-b768-4ec5-06d1-e783bf2d226d-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org
Quoted 32 lines · Christian König
Am 17.02.2017 um 00:21 schrieb Nicolai Hähnle:
Quoted 22 lines · Alex Deucher
Quoted 15 lines
Quoted 13 lines · Nicolai Hähnle
From: Nicolai Hähnle <[email protected]>
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.Quoted 5 lines
Quoted 2 lines
Fixes 40361bb1704b ("drm/amdgpu: add VRAM manager v2")Signed-off-by Nicolai Hähnle <[email protected]>Possibly fixes this bug report?
https://bugzilla.kernel.org/show_bug.cgi?id=194579Quoted 8 lines
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.
Quoted 4 lines
Yes, agree. The bug report is indeed a false positive.
Nicolai what do you think about removing the offset from the BO structure and only calculate it on demand?
I think it's a good idea. There are lots of uses in other drivers, though, so a first step would be adding a helper analogous to amdgpu_bo_gpu_offset in ttm_bo_api.h.
Quoted 4 lines
Quoted 1 line
We may still have other bugs with split BOs, though.
Yeah, agree as well. I was also considering disabling that feature by default for the moment if it helps with your corruption bug.
Good point, I'll give that a try as well.
Cheers,
Nicolai
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 5 lines · Christian König
Am 17.02.2017 um 00:21 schrieb Nicolai Hähnle:
Quoted 1 line
We may still have other bugs with split BOs, though.
Yeah, agree as well. I was also considering disabling that feature by default for the moment if it helps with your corruption bug.
The corruption still occurs with amdgpu.vram_page_split = -1, unfortunately.
Cheers,
Nicolai
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Ping? People seem to agree, but I haven't seen an explicit R-b...
Quoted 25 lines · Nicolai Hähnle
From: Nicolai Hähnle <[email protected]>
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 <[email protected]>--
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(+)drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0
-0
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static int amdgpu_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_mem_ · line 537
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +3
-0@@ -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)
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): eed2cf3c-abf2-ef32-60c2-f5c5be407634-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Sorry, patch is Reviewed-by: Christian König <[email protected]>.
Christian.
Am 20.02.2017 um 18:23 schrieb Nicolai Hähnle:
Quoted 36 lines
Ping? People seem to agree, but I haven't seen an explicit R-b...
Quoted 33 lines · Nicolai Hähnle
From: Nicolai Hähnle <[email protected]>
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 <[email protected]>Signature · 5 lines
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(+)drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0
-0@@ -529,6 +529,9 @@ static int amdgpu_ttm_io_mem_reserve(struct
ttm_bo_device*bdev, structttm_mem_case TTM_PL_TT: break; case TTM_PL_VRAM:drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +3
-0+if (mem->start ==AMDGPU_BO_INVALID_OFFSET ) +return -EINVAL ; + mem->bus.offset = mem->start <<PAGE_SHIFT ;/* check if it's visible */
Quoted 8 lines
Quoted 3 lines
if ((mem->bus.offset + mem->bus.size) >
adev->mc.visible_vram_size)_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 95bce921-2f09-b632-854e-14a523f43795-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org
Quoted 1 line · Christian König
Sorry, patch is Reviewed-by: Christian König <[email protected]>.
Thanks!
Quoted 53 lines
Christian.
Am 20.02.2017 um 18:23 schrieb Nicolai Hähnle:
Quoted 47 lines
Ping? People seem to agree, but I haven't seen an explicit R-b...
Quoted 37 lines · Nicolai Hähnle
From: Nicolai Hähnle <[email protected]>
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 <[email protected]>--
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(+)drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0
-0@@ -529,6 +529,9 @@ static int amdgpu_ttm_io_mem_reserve(struct
ttm_bo_device*bdev, structttm_mem_case TTM_PL_TT: break; case TTM_PL_VRAM:drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +3
-0+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) >Quoted 2 lines
adev->mc.visible_vram_size)_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx