Skip to contentSkip to conversation

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

PATCH In review Deepak Sharma 4 participants 8 messages May 21, 2018 – May 22, 2018 7 messages not in the archive

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

PATCH 1/1 drm/amdgpu: Use GTT for dumb buffer if sg display enabled

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.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +5 -2
index 2c8e27370284..c547d92dbf4e 100644
@@ -749,15 +749,18 @@ 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;
 	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);
+	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

A message that is not in the archive (sent off-list or not yet received): 20180521232203.12086-1-Deepak.Sharma-5C7GfCeVMHo@public.gmane.org

#2 lore raw
Quoted 17 lines · Deepak Sharma

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.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +0 -0
index 2c8e27370284..c547d92dbf4e 100644
@@ -749,15 +749,18 @@ 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;

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

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +4 -0
+	u32 domain;
 	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);
+	domain = AMDGPU_GEM_DOMAIN_VRAM;
+	if (adev->gmc.real_vram_size <= AMDGPU_SG_THRESHOLD)
+		domain = AMDGPU_GEM_DOMAIN_GTT;

This could choose GTT even in cases where scanout from that isn't supported.

It should call amdgpu_display_supported_domains, and then use the same logic as in amdgpu_bo_pin_restricted:

        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;
        }

Maybe this logic could be refactored into a helper function.

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

A message that is not in the archive (sent off-list or not yet received): f0e83630-9736-76b1-6489-265882b664d6-otUistvHUpPR7s880joybQ@public.gmane.org

#4 lore raw

Am 22.05.2018 um 09:09 schrieb Michel Dänzer:

Quoted 34 lines · Deepak Sharma
Quoted 17 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.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 7 +++++--
  1 file changed, 5 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +0 -0
index 2c8e27370284..c547d92dbf4e 100644
@@ -749,15 +749,18 @@ 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;

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

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +4 -0
+	u32 domain;
  	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);
+	domain = AMDGPU_GEM_DOMAIN_VRAM;
+	if (adev->gmc.real_vram_size <= AMDGPU_SG_THRESHOLD)
+		domain = AMDGPU_GEM_DOMAIN_GTT;

This could choose GTT even in cases where scanout from that isn't supported.

It should call amdgpu_display_supported_domains, and then use the same logic as in amdgpu_bo_pin_restricted:

Quoted 7 lines
         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;
         }

Maybe this logic could be refactored into a helper function.

Actually you don't even need that logic here. All you need to do is to use amdgpu_display_supported_domains and you're done.

The BO is moved to the correct place when it is pinned for scanout or use with the fb interface.

Regards,
Christian.
_______________________________________________
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): 965c9ef7-44c7-86c7-d797-3bf0b767519f-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#6 lore raw
Quoted 43 lines · Christian König

Am 22.05.2018 um 09:09 schrieb Michel Dänzer:

Quoted 42 lines · Deepak Sharma
Quoted 18 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.

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

  1 file changed, 5 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +0 -0
index 2c8e27370284..c547d92dbf4e 100644
@@ -749,15 +749,18 @@ int amdgpu_mode_dumb_create(struct drm_file
 *file_priv,
       struct amdgpu_device *adev = dev->dev_private;
       struct drm_gem_object *gobj;

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

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +4 -0
       uint32_t handle;
+    u32 domain;
       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);
+    domain = AMDGPU_GEM_DOMAIN_VRAM;
+    if (adev->gmc.real_vram_size <= AMDGPU_SG_THRESHOLD)
+        domain = AMDGPU_GEM_DOMAIN_GTT;

This could choose GTT even in cases where scanout from that isn't supported.

It should call amdgpu_display_supported_domains, and then use the same logic as in amdgpu_bo_pin_restricted:

         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;
         }

Quoted 7 lines
Quoted 1 line

Maybe this logic could be refactored into a helper function.

Actually you don't even need that logic here. All you need to do is to use amdgpu_display_supported_domains and you're done.

The BO is moved to the correct place when it is pinned for scanout or use with the fb interface.

Right, however, if the buffer is going to be pinned to GTT for scanout, it would be nice to create it there in the first place, otherwise we incur some overhead for moving it (and possibly for the slower CPU access while it's in VRAM).

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

A message that is not in the archive (sent off-list or not yet received): 000f9d6a-af14-34d0-abfb-51fabad0c29d-otUistvHUpPR7s880joybQ@public.gmane.org

#8 lore raw

Am 22.05.2018 um 12:14 schrieb Michel Dänzer:

Quoted 48 lines · Christian König
Quoted 47 lines

Am 22.05.2018 um 09:09 schrieb Michel Dänzer:

Quoted 35 lines · Deepak Sharma
Quoted 18 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.

---
   drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 7 +++++--
   1 file changed, 5 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +0 -0
index 2c8e27370284..c547d92dbf4e 100644
@@ -749,15 +749,18 @@ int amdgpu_mode_dumb_create(struct drm_file
 *file_priv,
       struct amdgpu_device *adev = dev->dev_private;
       struct drm_gem_object *gobj;

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

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +4 -0
       uint32_t handle;
+    u32 domain;
       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);
+    domain = AMDGPU_GEM_DOMAIN_VRAM;
+    if (adev->gmc.real_vram_size <= AMDGPU_SG_THRESHOLD)
+        domain = AMDGPU_GEM_DOMAIN_GTT;

This could choose GTT even in cases where scanout from that isn't supported.

It should call amdgpu_display_supported_domains, and then use the same logic as in amdgpu_bo_pin_restricted:

Quoted 8 lines

         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;
         }

Maybe this logic could be refactored into a helper function.

Actually you don't even need that logic here. All you need to do is to use amdgpu_display_supported_domains and you're done.

Quoted 6 lines
Quoted 2 lines

The BO is moved to the correct place when it is pinned for scanout or use with the fb interface.

Right, however, if the buffer is going to be pinned to GTT for scanout, it would be nice to create it there in the first place, otherwise we incur some overhead for moving it (and possibly for the slower CPU access while it's in VRAM).

If the BO is moved from VRAM to VRAM (to make it linear) or from VRAM to GTT for scanout doesn't really matter.

And BTW GTT BOs used for scanout should be created USWC, so the argument that it is faster for CPU access isn't really true either.

Regards,
Christian.
_______________________________________________
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): 0d1e4e69-a41f-5432-1d95-2c964051bd41-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#10 lore raw
Quoted 51 lines · Christian König

Am 22.05.2018 um 12:14 schrieb Michel Dänzer:

Quoted 50 lines · Christian König
Quoted 49 lines

Am 22.05.2018 um 09:09 schrieb Michel Dänzer:

Quoted 35 lines · Deepak Sharma
Quoted 18 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.

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

   1 file changed, 5 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +0 -0
index 2c8e27370284..c547d92dbf4e 100644
@@ -749,15 +749,18 @@ int amdgpu_mode_dumb_create(struct drm_file
 *file_priv,
        struct amdgpu_device *adev = dev->dev_private;
        struct drm_gem_object *gobj;

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

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +4 -0
        uint32_t handle;
+    u32 domain;
        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);
+    domain = AMDGPU_GEM_DOMAIN_VRAM;
+    if (adev->gmc.real_vram_size <= AMDGPU_SG_THRESHOLD)
+        domain = AMDGPU_GEM_DOMAIN_GTT;

This could choose GTT even in cases where scanout from that isn't supported.

It should call amdgpu_display_supported_domains, and then use the same logic as in amdgpu_bo_pin_restricted:

Quoted 8 lines

          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;
          }

Maybe this logic could be refactored into a helper function.

Actually you don't even need that logic here. All you need to do is to use amdgpu_display_supported_domains and you're done.

The BO is moved to the correct place when it is pinned for scanout or use with the fb interface.

Quoted 7 lines
Quoted 4 lines

Right, however, if the buffer is going to be pinned to GTT for scanout, it would be nice to create it there in the first place, otherwise we incur some overhead for moving it (and possibly for the slower CPU access while it's in VRAM).

If the BO is moved from VRAM to VRAM (to make it linear) or from VRAM to GTT for scanout doesn't really matter.

Not sure what you mean. Dumb BOs are only used for CPU access and scanout, and should be created accordingly.

Quoted 2 lines

And BTW GTT BOs used for scanout should be created USWC, so the argument that it is faster for CPU access isn't really true either.

You're saying scanout doesn't work from cacheable GTT BOs? If it does work, it would be preferable for dumb BOs.

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

A message that is not in the archive (sent off-list or not yet received): cbceb91e-45b3-f998-8b16-c199e1906aab-otUistvHUpPR7s880joybQ@public.gmane.org

#12 lore raw

[SNIP]

Quoted 4 lines
Quoted 2 lines

If the BO is moved from VRAM to VRAM (to make it linear) or from VRAM to GTT for scanout doesn't really matter.

Not sure what you mean. Dumb BOs are only used for CPU access and scanout, and should be created accordingly.

Well what I wanted to say is that it isn't worse than before.

On the other hand thinking about it something like 5 lines of code sounds to avoid the extra copy sounds reasonable to me.

Quoted 4 lines
Quoted 2 lines

And BTW GTT BOs used for scanout should be created USWC, so the argument that it is faster for CPU access isn't really true either.

You're saying scanout doesn't work from cacheable GTT BOs? If it does work, it would be preferable for dumb BOs.

Well, scanout does seem to work from cachable GTT BOs. But from the documentation from the hardware team I'm pretty sure they never validated this.

And as usually nobody from the hardware guys I asked so far could give me a clear answer if it works or not.

Regards,
Christian.
_______________________________________________
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): bbf167e1-9053-3800-981f-b8cc9cc4bd22-5C7GfCeVMHo@public.gmane.org

#14 lore raw
Quoted 10 lines · Christian König

[SNIP]

Quoted 4 lines
Quoted 2 lines

If the BO is moved from VRAM to VRAM (to make it linear) or from VRAM to GTT for scanout doesn't really matter.

Not sure what you mean. Dumb BOs are only used for CPU access and scanout, and should be created accordingly.

Well what I wanted to say is that it isn't worse than before.

On the other hand thinking about it something like 5 lines of code sounds to avoid the extra copy sounds reasonable to me.

Thanks, I missed that point , Will use amdgpu_display_supported_domains as suggested and push v2.

Quoted 9 lines
Quoted 4 lines
Quoted 2 lines

And BTW GTT BOs used for scanout should be created USWC, so the argument that it is faster for CPU access isn't really true either.

You're saying scanout doesn't work from cacheable GTT BOs? If it does work, it would be preferable for dumb BOs.

Well, scanout does seem to work from cachable GTT BOs. But from the documentation from the hardware team I'm pretty sure they never validated this.

And as usually nobody from the hardware guys I asked so far could give me a clear answer if it works or not.

FWIW, I tested this on Stoney with Cros where dumb buffers used for splash screen, Its working fine.

Quoted 2 lines

Regards,
Christian.

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