Skip to contentSkip to conversation

drm/amdgpu: Use GTT for dumb buffer if sg display enabled (v2)

PATCH Deepak Sharma 2 participants 4 messages May 22, 2018 – May 24, 2018 3 messages not in the archive

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

When vram size <= THRESHOLD(256M) lets use GTT for dumb buffer allocation. As SG will be enabled with vram size <= 256M scan out will not be an issue.

v2: Use amdgpu_display_supported_domains to get supported domain.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +8 -2
index 2c8e27370284..63758db5e2ea 100644
@@ -30,6 +30,7 @@
 #include <drm/drmP.h>
 #include <drm/amdgpu_drm.h>
 #include "amdgpu.h"
+#include "amdgpu_display.h"
 
 void amdgpu_gem_object_free(struct drm_gem_object *gobj)
 {
@@ -749,15 +750,20 @@ int amdgpu_mode_dumb_create(struct drm_file *file_priv,
 	struct amdgpu_device *adev = dev->dev_private;
 	struct drm_gem_object *gobj;
 	uint32_t handle;
+	u32 domain = amdgpu_display_supported_domains(adev);
 	int r;
 
 	args->pitch = amdgpu_align_pitch(adev, args->width,
 					 DIV_ROUND_UP(args->bpp, 8), 0);
 	args->size = (u64)args->pitch * args->height;
 	args->size = ALIGN(args->size, PAGE_SIZE);
+	if (domain == (AMDGPU_GEM_DOMAIN_VRAM | AMDGPU_GEM_DOMAIN_GTT)) {
+		domain = AMDGPU_GEM_DOMAIN_VRAM;
+		if (adev->gmc.real_vram_size <= AMDGPU_SG_THRESHOLD)
+			domain = AMDGPU_GEM_DOMAIN_GTT;
+	}
 
-	r = amdgpu_gem_object_create(adev, args->size, 0,
-				     AMDGPU_GEM_DOMAIN_VRAM,
+	r = amdgpu_gem_object_create(adev, args->size, 0, domain,
 				     AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED,
 				     false, NULL, &gobj);
 	if (r)
Signature · 6 lines
2.15.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#2 lore raw
In reply to a message not in the archive

Am 23.05.2018 um 00:31 schrieb Deepak Sharma:

Quoted 29 lines

When vram size <= THRESHOLD(256M) lets use GTT for dumb buffer allocation. As SG will be enabled with vram size <= 256M scan out will not be an issue.

v2: Use amdgpu_display_supported_domains to get supported domain.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 10 ++++++++--
  1 file changed, 8 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +2 -0
index 2c8e27370284..63758db5e2ea 100644
@@ -30,6 +30,7 @@
  #include <drm/drmP.h>
  #include <drm/amdgpu_drm.h>
  #include "amdgpu.h"
+#include "amdgpu_display.h"
 
  void amdgpu_gem_object_free(struct drm_gem_object *gobj)
  {
@@ -749,15 +750,20 @@ int amdgpu_mode_dumb_create(struct drm_file *file_priv,
  	struct amdgpu_device *adev = dev->dev_private;
  	struct drm_gem_object *gobj;
  	uint32_t handle;
+	u32 domain = amdgpu_display_supported_domains(adev);
  	int r;

drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c int amdgpu_mode_dumb_create(struct drm_file *file_priv, · line 764

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +5 -0
 
  	args->pitch = amdgpu_align_pitch(adev, args->width,
  					 DIV_ROUND_UP(args->bpp, 8), 0);
  	args->size = (u64)args->pitch * args->height;
  	args->size = ALIGN(args->size, PAGE_SIZE);
+	if (domain == (AMDGPU_GEM_DOMAIN_VRAM | AMDGPU_GEM_DOMAIN_GTT)) {
+		domain = AMDGPU_GEM_DOMAIN_VRAM;
+		if (adev->gmc.real_vram_size <= AMDGPU_SG_THRESHOLD)
+			domain = AMDGPU_GEM_DOMAIN_GTT;
+	}

As Michel suggested as well better make that an helper in amdgpu_object.c.

Apart from that looks good to me,
Christian.

drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c int amdgpu_mode_dumb_create(struct drm_file *file_priv, · line 769

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +1 -2
-	r = amdgpu_gem_object_create(adev, args->size, 0,
-				     AMDGPU_GEM_DOMAIN_VRAM,
+	r = amdgpu_gem_object_create(adev, args->size, 0, domain,
  				     AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED,
  				     false, NULL, &gobj);
  	if (r)

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

#4 lore raw
In reply to a message not in the archive
Quoted 42 lines · Christian König

Am 23.05.2018 um 00:31 schrieb Deepak Sharma:

Quoted 28 lines

When vram size <= THRESHOLD(256M) lets use GTT for dumb buffer allocation. As SG will be enabled with vram size <= 256M scan out will not be an issue.

v2: Use amdgpu_display_supported_domains to get supported domain.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 10 ++++++++--

  1 file changed, 8 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +2 -0
index 2c8e27370284..63758db5e2ea 100644
@@ -30,6 +30,7 @@
   #include <drm/drmP.h>
   #include <drm/amdgpu_drm.h>
   #include "amdgpu.h"
+#include "amdgpu_display.h"
   void amdgpu_gem_object_free(struct drm_gem_object *gobj)
   {
@@ -749,15 +750,20 @@ int amdgpu_mode_dumb_create(struct drm_file 
 *file_priv,
       struct amdgpu_device *adev = dev->dev_private;
       struct drm_gem_object *gobj;
       uint32_t handle;
+    u32 domain = amdgpu_display_supported_domains(adev);

drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c int amdgpu_mode_dumb_create(struct drm_file · line 764

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +5 -0
       int r;
       args->pitch = amdgpu_align_pitch(adev, args->width,
                        DIV_ROUND_UP(args->bpp, 8), 0);
       args->size = (u64)args->pitch * args->height;
       args->size = ALIGN(args->size, PAGE_SIZE);
+    if (domain == (AMDGPU_GEM_DOMAIN_VRAM | AMDGPU_GEM_DOMAIN_GTT)) {
+        domain = AMDGPU_GEM_DOMAIN_VRAM;
+        if (adev->gmc.real_vram_size <= AMDGPU_SG_THRESHOLD)
+            domain = AMDGPU_GEM_DOMAIN_GTT;
+    }

As Michel suggested as well better make that an helper in amdgpu_object.c.

Quoted 2 lines

Apart from that looks good to me,
Christian.

I can push another patch to create helper function and use that here as well as in amdgpu_bo_pin_restricted.

otherwise I can push v3 if you want that change in this patch itself.

Thanks,
Deepak

Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c int amdgpu_mode_dumb_create(struct drm_file *file_priv, · line 769

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +1 -2
-    r = amdgpu_gem_object_create(adev, args->size, 0,
-                     AMDGPU_GEM_DOMAIN_VRAM,
+    r = amdgpu_gem_object_create(adev, args->size, 0, domain,
                        AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED,
                        false, NULL, &gobj);
       if (r)

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

#6 lore raw
In reply to a message not in the archive

Am 23.05.2018 um 20:14 schrieb Deepak Sharma:

Quoted 45 lines · Christian König
Quoted 42 lines

Am 23.05.2018 um 00:31 schrieb Deepak Sharma:

Quoted 28 lines

When vram size <= THRESHOLD(256M) lets use GTT for dumb buffer allocation. As SG will be enabled with vram size <= 256M scan out will not be an issue.

v2: Use amdgpu_display_supported_domains to get supported domain.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 10 ++++++++--

  1 file changed, 8 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +2 -0
index 2c8e27370284..63758db5e2ea 100644
@@ -30,6 +30,7 @@
   #include <drm/drmP.h>
   #include <drm/amdgpu_drm.h>
   #include "amdgpu.h"
+#include "amdgpu_display.h"
   void amdgpu_gem_object_free(struct drm_gem_object *gobj)
   {
@@ -749,15 +750,20 @@ int amdgpu_mode_dumb_create(struct drm_file 
 *file_priv,
       struct amdgpu_device *adev = dev->dev_private;
       struct drm_gem_object *gobj;
       uint32_t handle;
+    u32 domain = amdgpu_display_supported_domains(adev);

drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c int amdgpu_mode_dumb_create(struct drm_file · line 764

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +5 -0
       int r;
       args->pitch = amdgpu_align_pitch(adev, args->width,
                        DIV_ROUND_UP(args->bpp, 8), 0);
       args->size = (u64)args->pitch * args->height;
       args->size = ALIGN(args->size, PAGE_SIZE);
+    if (domain == (AMDGPU_GEM_DOMAIN_VRAM | AMDGPU_GEM_DOMAIN_GTT)) {
+        domain = AMDGPU_GEM_DOMAIN_VRAM;
+        if (adev->gmc.real_vram_size <= AMDGPU_SG_THRESHOLD)
+            domain = AMDGPU_GEM_DOMAIN_GTT;
+    }

As Michel suggested as well better make that an helper in amdgpu_object.c.

Quoted 6 lines
Quoted 2 lines

Apart from that looks good to me,
Christian.

I can push another patch to create helper function and use that here as well as in amdgpu_bo_pin_restricted.

otherwise I can push v3 if you want that change in this patch itself.

Since this is just a minor cleanup either way works with me. Use whatever approach suits you better.

Thanks,
Christian.

Quoted 12 lines

Thanks,
Deepak

Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c int amdgpu_mode_dumb_create(struct drm_file *file_priv, · line 769

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +1 -2
-    r = amdgpu_gem_object_create(adev, args->size, 0,
-                     AMDGPU_GEM_DOMAIN_VRAM,
+    r = amdgpu_gem_object_create(adev, args->size, 0, domain,
                        AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED,
                        false, NULL, &gobj);
       if (r)
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