dmr/amdgpu: Fix wrongly unref of BO
Subsystems (2)
PATCH v2 1/2 dmr/amdgpu: Fix wrongly unref of BO
According to comment of amdgpu_bo_reserve, amdgpu_bo_reserve can return with -ERESTARTSYS. When this function was interrupted by a signal, BO should not be unref. Otherwise the BO might be released while is kmapped and pinned, or BO MIGHT be deref multiple times, etc.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -1
@@ -355,8 +355,8 @@ static void amdgpu_vram_scratch_fini(struct amdgpu_device *adev)amdgpu_bo_kunmap (adev->vram_scratch.robj);amdgpu_bo_unpin (adev->vram_scratch.robj);amdgpu_bo_unreserve (adev->vram_scratch.robj); +amdgpu_bo_unref (&adev->vram_scratch.robj); } -amdgpu_bo_unref (&adev->vram_scratch.robj); }/**
Signature · 6 lines
1.9.1 _______________________________________________ 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): 1492530225-5219-1-git-send-email-AlexBin.Xie-5C7GfCeVMHo@public.gmane.org
PATCH v2 2/2 drm/amdgpu: print debug message when fails to reserve BO
--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3 -0
@@ -356,6 +356,9 @@ static void amdgpu_vram_scratch_fini(struct amdgpu_device *adev)amdgpu_bo_unpin (adev->vram_scratch.robj);amdgpu_bo_unreserve (adev->vram_scratch.robj);amdgpu_bo_unref (&adev->vram_scratch.robj); + }else { +DRM_DEBUG ("amdgpu_vram_scratch_fini failed. " +"BO is still referenced.\n" ); } }
Signature · 6 lines
1.9.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Christian König
NAKAm 18.04.2017 um 17:43 schrieb Alex Xie:
Quoted 5 lines
According to comment of
amdgpu_bo_reserve,amdgpu_bo_reservecan return with-ERESTARTSYS. When this function was interrupted by a signal, BO should not be unref. Otherwise the BO might be released while is kmapped and pinned, or BO MIGHT be deref multiple times, etc.
NAK, as explained in the other thread freeing up a BO while it is mapped is perfectly ok.
On the other hand reserving the BO interruptible here doesn't make any sense at all, so should probably be fixed.
Regards,
Christian.
Quoted 12 lines
Change-Id If76071a768950a0d3ad9d5da7fcae04881807621Signed-off-by Alex Xie <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-0
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c static void amdgpu_vram_scratch_fini(struct amdgpu_device *adev) · line 362
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1
-1@@ -355,8 +355,8 @@ static void amdgpu_vram_scratch_fini(struct amdgpu_device *adev)amdgpu_bo_kunmap (adev->vram_scratch.robj);amdgpu_bo_unpin (adev->vram_scratch.robj);amdgpu_bo_unreserve (adev->vram_scratch.robj); +amdgpu_bo_unref (&adev->vram_scratch.robj); } -amdgpu_bo_unref (&adev->vram_scratch.robj); }/**
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx