Skip to contentSkip to conversation

drm/amdgpu: ttm_bind only when user needs gpu_addr in bo pin

PATCH In review Chunming Zhou 2 participants 4 messages Jul 12, 2017 3 messages not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amdgpu: ttm_bind only when user needs gpu_addr in bo pin

Change-Id I282e1212346ed76470cadf39153109ab135f32f3
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +7 -6
index a0ad0e0..81c1486 100644
@@ -778,15 +778,16 @@ int amdgpu_bo_pin_restricted(struct amdgpu_bo *bo, u32 domain,
 		dev_err(adev->dev, "%p pin failed\n", bo);
 		goto error;
 	}
-	r = amdgpu_ttm_bind(&bo->tbo, &bo->tbo.mem);
-	if (unlikely(r)) {
-		dev_err(adev->dev, "%p bind failed\n", bo);
-		goto error;
-	}
 
 	bo->pin_count = 1;
-	if (gpu_addr != NULL)
+	if (gpu_addr != NULL) {
+		r = amdgpu_ttm_bind(&bo->tbo, &bo->tbo.mem);
+		if (unlikely(r)) {
+			dev_err(adev->dev, "%p bind failed\n", bo);
+			goto error;
+		}
 		*gpu_addr = amdgpu_bo_gpu_offset(bo);
+	}
 	if (domain == AMDGPU_GEM_DOMAIN_VRAM) {
 		adev->vram_pin_size += amdgpu_bo_size(bo);
 		if (bo->flags & AMDGPU_GEM_CREATE_NO_CPU_ACCESS)
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): 1499834315-11413-1-git-send-email-David1.Zhou-5C7GfCeVMHo@public.gmane.org

#2 lore raw

Looks like it makes sense, but why should that be useful?

Christian.

Am 12.07.2017 um 06:38 schrieb Chunming Zhou:

Quoted 23 lines
Change-Id I282e1212346ed76470cadf39153109ab135f32f3
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 13 +++++++------
  1 file changed, 7 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +1 -6
index a0ad0e0..81c1486 100644
@@ -778,15 +778,16 @@ int amdgpu_bo_pin_restricted(struct amdgpu_bo *bo, u32 domain,
  		dev_err(adev->dev, "%p pin failed\n", bo);
  		goto error;
  	}
-	r = amdgpu_ttm_bind(&bo->tbo, &bo->tbo.mem);
-	if (unlikely(r)) {
-		dev_err(adev->dev, "%p bind failed\n", bo);
-		goto error;
-	}
 
  	bo->pin_count = 1;
-	if (gpu_addr != NULL)
+	if (gpu_addr != NULL) {

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

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +6 -0
+		r = amdgpu_ttm_bind(&bo->tbo, &bo->tbo.mem);
+		if (unlikely(r)) {
+			dev_err(adev->dev, "%p bind failed\n", bo);
+			goto error;
+		}
  		*gpu_addr = amdgpu_bo_gpu_offset(bo);
+	}
  	if (domain == AMDGPU_GEM_DOMAIN_VRAM) {
  		adev->vram_pin_size += amdgpu_bo_size(bo);
  		if (bo->flags & AMDGPU_GEM_CREATE_NO_CPU_ACCESS)

_______________________________________________
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): e2c6e19f-0bd8-b3d6-e7a3-9d07c52a68e9-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org

author
#4 lore raw
Quoted 1 line · Christian König

Looks like it makes sense, but why should that be useful?

1. when you set gart size 256M, the space is limit, so only bind gart when necessary.
2. less cpu overhead with un-necessary statements.

Regards,
David Zhou

Quoted 29 lines

Christian.

Am 12.07.2017 um 06:38 schrieb Chunming Zhou:

Quoted 25 lines
Change-Id I282e1212346ed76470cadf39153109ab135f32f3
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 13 +++++++------
  1 file changed, 7 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +3 -6
index a0ad0e0..81c1486 100644
@@ -778,15 +778,16 @@ int amdgpu_bo_pin_restricted(struct amdgpu_bo 
 *bo, u32 domain,
          dev_err(adev->dev, "%p pin failed\n", bo);
          goto error;
      }
-    r = amdgpu_ttm_bind(&bo->tbo, &bo->tbo.mem);
-    if (unlikely(r)) {
-        dev_err(adev->dev, "%p bind failed\n", bo);
-        goto error;
-    }
        bo->pin_count = 1;
-    if (gpu_addr != NULL)
+    if (gpu_addr != NULL) {
+        r = amdgpu_ttm_bind(&bo->tbo, &bo->tbo.mem);
+        if (unlikely(r)) {
Quoted 10 lines

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

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +4 -0
+            dev_err(adev->dev, "%p bind failed\n", bo);
+            goto error;
+        }
          *gpu_addr = amdgpu_bo_gpu_offset(bo);
+    }
      if (domain == AMDGPU_GEM_DOMAIN_VRAM) {
          adev->vram_pin_size += amdgpu_bo_size(bo);
          if (bo->flags & AMDGPU_GEM_CREATE_NO_CPU_ACCESS)

_______________________________________________
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): [email protected]

#6 lore raw

Am 12.07.2017 um 10:06 schrieb zhoucm1:

Quoted 6 lines · Christian König
Quoted 1 line

Looks like it makes sense, but why should that be useful?

1. when you set gart size 256M, the space is limit, so only bind gart when necessary.
2. less cpu overhead with un-necessary statements.

Yeah, that was obvious. My question was rather where we actually use the function this way in the upstream driver :)

But searching the code a bit I stumbled over the prime handling which can make good use of that.

So patch is Reviewed-by: Christian König <[email protected]>.

Regards,
Christian.

Quoted 43 lines

Regards,
David Zhou

Quoted 29 lines

Christian.

Am 12.07.2017 um 06:38 schrieb Chunming Zhou:

Quoted 25 lines
Change-Id I282e1212346ed76470cadf39153109ab135f32f3
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 13 +++++++------
  1 file changed, 7 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +3 -6
index a0ad0e0..81c1486 100644
@@ -778,15 +778,16 @@ int amdgpu_bo_pin_restricted(struct amdgpu_bo 
 *bo, u32 domain,
          dev_err(adev->dev, "%p pin failed\n", bo);
          goto error;
      }
-    r = amdgpu_ttm_bind(&bo->tbo, &bo->tbo.mem);
-    if (unlikely(r)) {
-        dev_err(adev->dev, "%p bind failed\n", bo);
-        goto error;
-    }
        bo->pin_count = 1;
-    if (gpu_addr != NULL)
+    if (gpu_addr != NULL) {
+        r = amdgpu_ttm_bind(&bo->tbo, &bo->tbo.mem);
+        if (unlikely(r)) {
Quoted 10 lines

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

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +4 -0
+            dev_err(adev->dev, "%p bind failed\n", bo);
+            goto error;
+        }
          *gpu_addr = amdgpu_bo_gpu_offset(bo);
+    }
      if (domain == AMDGPU_GEM_DOMAIN_VRAM) {
          adev->vram_pin_size += amdgpu_bo_size(bo);
          if (bo->flags & AMDGPU_GEM_CREATE_NO_CPU_ACCESS)
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