Skip to contentSkip to conversation

dmr/amdgpu: Fix wrongly unref of BO

PATCH NAK Alex Xie 2 participants 3 messages Apr 18, 2017 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

Alex Xie

author
#0 lore raw

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.

Change-Id If76071a768950a0d3ad9d5da7fcae04881807621
---
 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
index a09ad3cf..79b5fda 100644
@@ -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

author
#2 lore raw

PATCH v2 2/2 drm/amdgpu: print debug message when fails to reserve BO

Change-Id Ie5a6ba045bde07ccd35b27690709ad1670139447
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3 -0
index 79b5fda..7e43f63 100644
@@ -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
#3 lore raw
In reply to a message not in the archive

Am 18.04.2017 um 17:43 schrieb Alex Xie:

Quoted 5 lines

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.

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 If76071a768950a0d3ad9d5da7fcae04881807621
---
  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
index a09ad3cf..79b5fda 100644

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