Skip to contentSkip to conversation

drm/amdgpu: check domain sanity in amdgpu_bo_pin_restricted()

PATCH In review Flora Cui 5 participants 7 messages Aug 18, 2016 3 messages not in the archive

Subsystems (2)
lore
Share & tools
lore

Flora Cui

author
#0 lore raw

PATCH 1/3 drm/amdgpu: check domain sanity in amdgpu_bo_pin_restricted()

abort if the bo is pined to other domain already

Change-Id I0e8eb3e0af0fad1edaf647050399e5a36226a5d9
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +5 -0
index 4d084ee..0a0f3cb 100644
@@ -520,6 +520,11 @@ int amdgpu_bo_pin_restricted(struct amdgpu_bo *bo, u32 domain,
 		return -EINVAL;
 
 	if (bo->pin_count) {
+		uint32_t mem_type = bo->tbo.mem.mem_type;
+
+		if (domain != amdgpu_mem_type_to_domain(mem_type))
+			return -EINVAL;
+
 		bo->pin_count++;
 		if (gpu_addr)
 			*gpu_addr = amdgpu_bo_gpu_offset(bo);
Signature · 6 lines
2.7.4

_______________________________________________
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): 1471498619-7497-1-git-send-email-Flora.Cui-5C7GfCeVMHo@public.gmane.org

author
#2 lore raw

PATCH 2/3 drm/amdgpu: update gart_pin_size only if the bo is pined to GTT

Change-Id I975a0a97d570bd14b8031c4033cb447a3b3d2b1a
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +1 -1
index 0a0f3cb..dbab3c0 100644
@@ -578,7 +578,7 @@ int amdgpu_bo_pin_restricted(struct amdgpu_bo *bo, u32 domain,
 		bo->adev->vram_pin_size += amdgpu_bo_size(bo);
 		if (bo->flags & AMDGPU_GEM_CREATE_NO_CPU_ACCESS)
 			bo->adev->invisible_pin_size += amdgpu_bo_size(bo);
-	} else {
+	} else if (domain == AMDGPU_GEM_DOMAIN_GTT) {
 		bo->adev->gart_pin_size += amdgpu_bo_size(bo);
 	}
 
Signature · 6 lines
2.7.4

_______________________________________________
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): 1471498619-7497-2-git-send-email-Flora.Cui-5C7GfCeVMHo@public.gmane.org

Reviewed-by Alex Deucher
#4 lore raw

RE: [PATCH 2/3] drm/amdgpu: update gart_pin_size only if the bo is pined to GTT

Quoted 11 lines

-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of Flora Cui
Sent: Thursday, August 18, 2016 1:37 AM
To: [email protected]
Cc: Cui, Flora
Subject: [PATCH 2/3] drm/amdgpu: update gart_pin_size only if the bo is pined to GTT

Change-Id I975a0a97d570bd14b8031c4033cb447a3b3d2b1a
Quoted 20 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +1 -1
index 0a0f3cb..dbab3c0 100644
@@ -578,7 +578,7 @@ int amdgpu_bo_pin_restricted(struct amdgpu_bo
 *bo, u32 domain,
 		bo->adev->vram_pin_size += amdgpu_bo_size(bo);
 		if (bo->flags & AMDGPU_GEM_CREATE_NO_CPU_ACCESS)
 			bo->adev->invisible_pin_size +=
 amdgpu_bo_size(bo);
-	} else {
+	} else if (domain == AMDGPU_GEM_DOMAIN_GTT) {
 		bo->adev->gart_pin_size += amdgpu_bo_size(bo);

}

Quoted 7 lines

--
2.7.4

_______________________________________________
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

author
#5 lore raw

PATCH 3/3 drm/amdgpu: use domain's gpu_offset for start addr

In reply to a message not in the archive
Change-Id I77610c286af4cf77bb508136fffc0c77c7cbc34b
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 6 +-----
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c    | 8 ++------
 2 files changed, 3 insertions(+), 11 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +1 -5
index dbab3c0..2c08e1b 100644
@@ -530,11 +530,7 @@ int amdgpu_bo_pin_restricted(struct amdgpu_bo *bo, u32 domain,
 			*gpu_addr = amdgpu_bo_gpu_offset(bo);
 
 		if (max_offset != 0) {
-			u64 domain_start;
-			if (domain == AMDGPU_GEM_DOMAIN_VRAM)
-				domain_start = bo->adev->mc.vram_start;
-			else
-				domain_start = bo->adev->mc.gtt_start;
+			u64 domain_start = bo->tbo.bdev->man[mem_type].gpu_offset;
 			WARN_ON_ONCE(max_offset <
 				     (amdgpu_bo_gpu_offset(bo) - domain_start));
 		}
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +2 -6
index 105bd22..8a12b24 100644
@@ -257,10 +257,8 @@ static int amdgpu_move_blit(struct ttm_buffer_object *bo,
 
 	switch (old_mem->mem_type) {
 	case TTM_PL_VRAM:
-		old_start += adev->mc.vram_start;
-		break;
 	case TTM_PL_TT:
-		old_start += adev->mc.gtt_start;
+		old_start += bo->bdev->man[old_mem->mem_type].gpu_offset;
 		break;
 	default:
 		DRM_ERROR("Unknown placement %d\n", old_mem->mem_type);
@@ -268,10 +266,8 @@ static int amdgpu_move_blit(struct ttm_buffer_object *bo,
 	}
 	switch (new_mem->mem_type) {
 	case TTM_PL_VRAM:
-		new_start += adev->mc.vram_start;
-		break;
 	case TTM_PL_TT:
-		new_start += adev->mc.gtt_start;
+		new_start += bo->bdev->man[new_mem->mem_type].gpu_offset;
 		break;
 	default:
 		DRM_ERROR("Unknown placement %d\n", old_mem->mem_type);
Signature · 6 lines
2.7.4

_______________________________________________
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): 1471498619-7497-3-git-send-email-Flora.Cui-5C7GfCeVMHo@public.gmane.org

Reviewed-by Ken Wang
#7 lore raw

答复: [PATCH 3/3] drm/amdgpu: use domain's gpu_offset for start addr

________________________________
发件人: amd-gfx <[email protected]> 代表 Flora Cui <[email protected]> 发送时间: 2016年8月18日 13:36:59
收件人: [email protected]
抄送: Cui, Flora
主题: [PATCH 3/3] drm/amdgpu: use domain's gpu_offset for start addr

Change-Id I77610c286af4cf77bb508136fffc0c77c7cbc34b
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 6 +-----
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c    | 8 ++------
 2 files changed, 3 insertions(+), 11 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +1 -5
index dbab3c0..2c08e1b 100644
@@ -530,11 +530,7 @@ int amdgpu_bo_pin_restricted(struct amdgpu_bo *bo, u32 domain,
                         *gpu_addr = amdgpu_bo_gpu_offset(bo);
 
                 if (max_offset != 0) {
-                       u64 domain_start;
-                       if (domain == AMDGPU_GEM_DOMAIN_VRAM)
-                               domain_start = bo->adev->mc.vram_start;
-                       else
-                               domain_start = bo->adev->mc.gtt_start;
+                       u64 domain_start = bo->tbo.bdev->man[mem_type].gpu_offset;
                         WARN_ON_ONCE(max_offset <
                                      (amdgpu_bo_gpu_offset(bo) - domain_start));
                 }
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +2 -6
index 105bd22..8a12b24 100644
@@ -257,10 +257,8 @@ static int amdgpu_move_blit(struct ttm_buffer_object *bo,
 
         switch (old_mem->mem_type) {
         case TTM_PL_VRAM:
-               old_start += adev->mc.vram_start;
-               break;
         case TTM_PL_TT:
-               old_start += adev->mc.gtt_start;
+               old_start += bo->bdev->man[old_mem->mem_type].gpu_offset;
                 break;
         default:
                 DRM_ERROR("Unknown placement %d\n", old_mem->mem_type);
@@ -268,10 +266,8 @@ static int amdgpu_move_blit(struct ttm_buffer_object *bo,
         }
         switch (new_mem->mem_type) {
         case TTM_PL_VRAM:
-               new_start += adev->mc.vram_start;
-               break;
         case TTM_PL_TT:
-               new_start += adev->mc.gtt_start;
+               new_start += bo->bdev->man[new_mem->mem_type].gpu_offset;
                 break;
         default:
                 DRM_ERROR("Unknown placement %d\n", old_mem->mem_type);

--
2.7.4

_______________________________________________
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

Reviewed-by
#8 lore raw
In reply to a message not in the archive
Quoted 4 lines · Flora Cui

abort if the bo is pined to other domain already

Change-Id I0e8eb3e0af0fad1edaf647050399e5a36226a5d9

The new patches 1 & 3 are

Signature · 6 lines
Earthling Michel Dänzer               |               http://www.amd.com
Libre software enthusiast             |             Mesa and X developer
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Reviewed-by
#9 lore raw
In reply to a message not in the archive

Am 18.08.2016 um 07:36 schrieb Flora Cui:

Quoted 4 lines

abort if the bo is pined to other domain already

Change-Id I0e8eb3e0af0fad1edaf647050399e5a36226a5d9
Quoted 10 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 5 +++++
  1 file changed, 5 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +0 -0
index 4d084ee..0a0f3cb 100644
@@ -520,6 +520,11 @@ int amdgpu_bo_pin_restricted(struct amdgpu_bo *bo, u32 domain,
  		return -EINVAL;

drivers/gpu/drm/amd/amdgpu/amdgpu_object.c int amdgpu_bo_pin_restricted(struct amdgpu_bo *bo, u32 domain, · line 530

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +5 -0
 
  	if (bo->pin_count) {
+		uint32_t mem_type = bo->tbo.mem.mem_type;
+
+		if (domain != amdgpu_mem_type_to_domain(mem_type))
+			return -EINVAL;
+
  		bo->pin_count++;
  		if (gpu_addr)
  			*gpu_addr = amdgpu_bo_gpu_offset(bo);

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx