Skip to contentSkip to conversation

drm/amdgpu: enable freesync for A+A configs

PATCH In review Christian König 3 participants 6 messages Feb 1, 2021

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

PATCH 1/1 drm/amdgpu: enable freesync for A+A configs

Some newer APUs can scanout directly from GTT, that saves us from allocating another bounce buffer in VRAM and enables freesync in such configurations.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 8 ++++++--
 drivers/gpu/drm/amd/amdgpu/amdgpu_object.c  | 2 +-
 2 files changed, 7 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +6 -2
index a638709e9c92..823bc25d87de 100644
@@ -930,8 +930,10 @@ amdgpu_display_user_framebuffer_create(struct drm_device *dev,
 				       struct drm_file *file_priv,
 				       const struct drm_mode_fb_cmd2 *mode_cmd)
 {
-	struct drm_gem_object *obj;
 	struct amdgpu_framebuffer *amdgpu_fb;
+	struct drm_gem_object *obj;
+	struct amdgpu_bo *bo;
+	uint32_t domains;
 	int ret;
 
 	obj = drm_gem_object_lookup(file_priv, mode_cmd->handles[0]);
@@ -942,7 +944,9 @@ amdgpu_display_user_framebuffer_create(struct drm_device *dev,
 	}
 
 	/* Handle is imported dma-buf, so cannot be migrated to VRAM for scanout */
-	if (obj->import_attach) {
+	bo = gem_to_amdgpu_bo(obj);
+	domains = amdgpu_display_supported_domains(drm_to_adev(dev), bo->flags);
+	if (obj->import_attach && !(domains & AMDGPU_GEM_DOMAIN_GTT)) {
 		drm_dbg_kms(dev, "Cannot create framebuffer from imported dma_buf\n");
 		return ERR_PTR(-EINVAL);
 	}
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +1 -1
index 56854a3ee19c..0bd22ed1dacf 100644
@@ -900,7 +900,7 @@ int amdgpu_bo_pin_restricted(struct amdgpu_bo *bo, u32 domain,
 		return -EINVAL;
 
 	/* A shared bo cannot be migrated to VRAM */
-	if (bo->prime_shared_count) {
+	if (bo->prime_shared_count || bo->tbo.base.import_attach) {
 		if (domain & AMDGPU_GEM_DOMAIN_GTT)
 			domain = AMDGPU_GEM_DOMAIN_GTT;
 		else
Signature · 6 lines
2.25.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Reviewed-by on v1 1/1
#1 lore raw

Hello Christian,

Quoted 3 lines · Christian König

Some newer APUs can scanout directly from GTT, that saves us from allocating another bounce buffer in VRAM and enables freesync in such configurations.

Shall we add some more details about how this patch helps with VRR, like "Without this patch, it won't be possible for the IGPU to flip buffers which are composed on an external GPU" or something in those lines ?

Quoted 23 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 8 ++++++--
 drivers/gpu/drm/amd/amdgpu/amdgpu_object.c  | 2 +-
 2 files changed, 7 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +3 -1
index a638709e9c92..823bc25d87de 100644
@@ -930,8 +930,10 @@ amdgpu_display_user_framebuffer_create(struct drm_device *dev,
 				       struct drm_file *file_priv,
 				       const struct drm_mode_fb_cmd2 *mode_cmd)
 {
-	struct drm_gem_object *obj;
 	struct amdgpu_framebuffer *amdgpu_fb;
+	struct drm_gem_object *obj;
+	struct amdgpu_bo *bo;
+	uint32_t domains;
 	int ret;
 
 	obj = drm_gem_object_lookup(file_priv, mode_cmd->handles[0]);

drivers/gpu/drm/amd/amdgpu/amdgpu_display.c amdgpu_display_user_framebuffer_create(struct drm_device *dev, · line 947

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +1 -1
@@ -942,7 +944,9 @@ amdgpu_display_user_framebuffer_create(struct drm_device *dev,
 	}
 
 	/* Handle is imported dma-buf, so cannot be migrated to VRAM for scanout */
-	if (obj->import_attach) {
+	bo = gem_to_amdgpu_bo(obj);

Is it possible that the bo can be NULL ? I mean do we need a NULL check here ?

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +2 -0
+	domains = amdgpu_display_supported_domains(drm_to_adev(dev), bo->flags);
+	if (obj->import_attach && !(domains & AMDGPU_GEM_DOMAIN_GTT)) {
 		drm_dbg_kms(dev, "Cannot create framebuffer from imported dma_buf\n");
 		return ERR_PTR(-EINVAL);
 	}
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +0 -0
index 56854a3ee19c..0bd22ed1dacf 100644

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

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +1 -1
@@ -900,7 +900,7 @@ int amdgpu_bo_pin_restricted(struct amdgpu_bo *bo, u32 domain,
 		return -EINVAL;
 
 	/* A shared bo cannot be migrated to VRAM */
-	if (bo->prime_shared_count) {
+	if (bo->prime_shared_count || bo->tbo.base.import_attach) {

With the above concerns addressed (or reasoned :)), please feel free to use:

- Shashank

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

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +0 -0
 		if (domain & AMDGPU_GEM_DOMAIN_GTT)
 			domain = AMDGPU_GEM_DOMAIN_GTT;
 		else

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

#2 lore raw

Am 01.02.21 um 16:06 schrieb Shashank Sharma:

Quoted 7 lines

Hello Christian,

Quoted 3 lines · Christian König

Some newer APUs can scanout directly from GTT, that saves us from allocating another bounce buffer in VRAM and enables freesync in such configurations.

Shall we add some more details about how this patch helps with VRR, like "Without this patch, it won't be possible for the IGPU to flip buffers which are composed on an external GPU" or something in those lines ?

How about:

"Without this patch creating a framebuffer from the imported BO will fail and userspace will fall back to a copy".

Thanks,
Christian.

Quoted 41 lines
Quoted 23 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 8 ++++++--
  drivers/gpu/drm/amd/amdgpu/amdgpu_object.c  | 2 +-
  2 files changed, 7 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +3 -1
index a638709e9c92..823bc25d87de 100644
@@ -930,8 +930,10 @@ amdgpu_display_user_framebuffer_create(struct drm_device *dev,
  				       struct drm_file *file_priv,
  				       const struct drm_mode_fb_cmd2 *mode_cmd)
  {
-	struct drm_gem_object *obj;
  	struct amdgpu_framebuffer *amdgpu_fb;
+	struct drm_gem_object *obj;
+	struct amdgpu_bo *bo;
+	uint32_t domains;
  	int ret;
 
  	obj = drm_gem_object_lookup(file_priv, mode_cmd->handles[0]);

drivers/gpu/drm/amd/amdgpu/amdgpu_display.c amdgpu_display_user_framebuffer_create(struct drm_device *dev, · line 947

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +1 -1
@@ -942,7 +944,9 @@ amdgpu_display_user_framebuffer_create(struct drm_device *dev,
  	}
 
  	/* Handle is imported dma-buf, so cannot be migrated to VRAM for scanout */
-	if (obj->import_attach) {
+	bo = gem_to_amdgpu_bo(obj);

Is it possible that the bo can be NULL ? I mean do we need a NULL check here ?

Quoted 12 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +2 -0
+	domains = amdgpu_display_supported_domains(drm_to_adev(dev), bo->flags);
+	if (obj->import_attach && !(domains & AMDGPU_GEM_DOMAIN_GTT)) {
  		drm_dbg_kms(dev, "Cannot create framebuffer from imported dma_buf\n");
  		return ERR_PTR(-EINVAL);
  	}
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +0 -0
index 56854a3ee19c..0bd22ed1dacf 100644
@@ -900,7 +900,7 @@ int amdgpu_bo_pin_restricted(struct amdgpu_bo *bo, u32 domain,
  		return -EINVAL;
 
Quoted 12 lines

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

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +1 -1
  	/* A shared bo cannot be migrated to VRAM */
-	if (bo->prime_shared_count) {
+	if (bo->prime_shared_count || bo->tbo.base.import_attach) {

With the above concerns addressed (or reasoned :)), please feel free to use:

- Shashank

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +0 -0
  		if (domain & AMDGPU_GEM_DOMAIN_GTT)
  			domain = AMDGPU_GEM_DOMAIN_GTT;
  		else

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

#3 lore raw
Quoted 4 lines · Christian König

Am 01.02.21 um 16:06 schrieb Shashank Sharma:

Quoted 3 lines

Hello Christian,

On 01/02/21 8:04 pm, Christian König wrote:

Quoted 8 lines
Quoted 4 lines
Quoted 3 lines

Some newer APUs can scanout directly from GTT, that saves us from allocating another bounce buffer in VRAM and enables freesync in such configurations.

Shall we add some more details about how this patch helps with VRR, like "Without this patch, it won't be possible for the IGPU to flip buffers which are composed on an external GPU" or something in those lines ?

How about:

"Without this patch creating a framebuffer from the imported BO will fail and userspace will fall back to a copy".

Yep, looks good enough. There is just one more tiny comment below, please check that out too.

Quoted 33 lines

Thanks,
Christian.

Quoted 29 lines
Quoted 23 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 8 ++++++--
  drivers/gpu/drm/amd/amdgpu/amdgpu_object.c  | 2 +-
  2 files changed, 7 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +3 -1
index a638709e9c92..823bc25d87de 100644
@@ -930,8 +930,10 @@ amdgpu_display_user_framebuffer_create(struct drm_device *dev,
  				       struct drm_file *file_priv,
  				       const struct drm_mode_fb_cmd2 *mode_cmd)
  {
-	struct drm_gem_object *obj;
  	struct amdgpu_framebuffer *amdgpu_fb;
+	struct drm_gem_object *obj;
+	struct amdgpu_bo *bo;
+	uint32_t domains;
  	int ret;
 
  	obj = drm_gem_object_lookup(file_priv, mode_cmd->handles[0]);

drivers/gpu/drm/amd/amdgpu/amdgpu_display.c amdgpu_display_user_framebuffer_create(struct drm_device *dev, · line 947

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +1 -1
@@ -942,7 +944,9 @@ amdgpu_display_user_framebuffer_create(struct drm_device *dev,
  	}
 
  	/* Handle is imported dma-buf, so cannot be migrated to VRAM for scanout */
-	if (obj->import_attach) {
+	bo = gem_to_amdgpu_bo(obj);

Is it possible that the bo can be NULL ? I mean do we need a NULL check here ?

This one :)

- Shashank

Quoted 17 lines
Quoted 17 lines
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +2 -0
+	domains = amdgpu_display_supported_domains(drm_to_adev(dev), bo->flags);
+	if (obj->import_attach && !(domains & AMDGPU_GEM_DOMAIN_GTT)) {
  		drm_dbg_kms(dev, "Cannot create framebuffer from imported dma_buf\n");
  		return ERR_PTR(-EINVAL);
  	}
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +0 -0
index 56854a3ee19c..0bd22ed1dacf 100644

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

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +1 -1
@@ -900,7 +900,7 @@ int amdgpu_bo_pin_restricted(struct amdgpu_bo *bo, u32 domain,
  		return -EINVAL;
 
  	/* A shared bo cannot be migrated to VRAM */
-	if (bo->prime_shared_count) {
+	if (bo->prime_shared_count || bo->tbo.base.import_attach) {

With the above concerns addressed (or reasoned :)), please feel free to use:

Quoted 7 lines
Quoted 7 lines

- Shashank

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +0 -0
  		if (domain & AMDGPU_GEM_DOMAIN_GTT)
  			domain = AMDGPU_GEM_DOMAIN_GTT;
  		else

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

maintainer
#4 lore raw

Am 01.02.21 um 16:13 schrieb Shashank Sharma:

Quoted 43 lines · Christian König
Quoted 4 lines

Am 01.02.21 um 16:06 schrieb Shashank Sharma:

Quoted 3 lines

Hello Christian,

On 01/02/21 8:04 pm, Christian König wrote:

Quoted 8 lines
Quoted 4 lines
Quoted 3 lines

Some newer APUs can scanout directly from GTT, that saves us from allocating another bounce buffer in VRAM and enables freesync in such configurations.

Shall we add some more details about how this patch helps with VRR, like "Without this patch, it won't be possible for the IGPU to flip buffers which are composed on an external GPU" or something in those lines ?

How about:

"Without this patch creating a framebuffer from the imported BO will fail and userspace will fall back to a copy".

Yep, looks good enough. There is just one more tiny comment below, please check that out too.

Quoted 28 lines

Thanks,
Christian.

Quoted 25 lines
Quoted 25 lines
---
   drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 8 ++++++--
   drivers/gpu/drm/amd/amdgpu/amdgpu_object.c  | 2 +-
   2 files changed, 7 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +3 -1
index a638709e9c92..823bc25d87de 100644
@@ -930,8 +930,10 @@ amdgpu_display_user_framebuffer_create(struct drm_device *dev,
   				       struct drm_file *file_priv,
   				       const struct drm_mode_fb_cmd2 *mode_cmd)
   {
-	struct drm_gem_object *obj;
   	struct amdgpu_framebuffer *amdgpu_fb;
+	struct drm_gem_object *obj;
+	struct amdgpu_bo *bo;
+	uint32_t domains;
   	int ret;
 
   	obj = drm_gem_object_lookup(file_priv, mode_cmd->handles[0]);
@@ -942,7 +944,9 @@ amdgpu_display_user_framebuffer_create(struct drm_device *dev,
   	}
 
Quoted 5 lines
Quoted 4 lines
Quoted 4 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_display.c amdgpu_display_user_framebuffer_create(struct drm_device *dev, · line 947

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +1 -1
   	/* Handle is imported dma-buf, so cannot be migrated to VRAM for scanout */
-	if (obj->import_attach) {
+	bo = gem_to_amdgpu_bo(obj);

Is it possible that the bo can be NULL ? I mean do we need a NULL check here ?

This one :)

No, this is just a type cast.

Christian.

Quoted 27 lines

- Shashank

Quoted 24 lines
Quoted 24 lines
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +2 -0
+	domains = amdgpu_display_supported_domains(drm_to_adev(dev), bo->flags);
+	if (obj->import_attach && !(domains & AMDGPU_GEM_DOMAIN_GTT)) {
   		drm_dbg_kms(dev, "Cannot create framebuffer from imported dma_buf\n");
   		return ERR_PTR(-EINVAL);
   	}
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +0 -0
index 56854a3ee19c..0bd22ed1dacf 100644

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

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +1 -1
@@ -900,7 +900,7 @@ int amdgpu_bo_pin_restricted(struct amdgpu_bo *bo, u32 domain,
   		return -EINVAL;
 
   	/* A shared bo cannot be migrated to VRAM */
-	if (bo->prime_shared_count) {
+	if (bo->prime_shared_count || bo->tbo.base.import_attach) {

With the above concerns addressed (or reasoned :)), please feel free to use:

- Shashank

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +0 -0
   		if (domain & AMDGPU_GEM_DOMAIN_GTT)
   			domain = AMDGPU_GEM_DOMAIN_GTT;
   		else

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

#5 lore raw
Quoted 44 lines · Christian König

Am 01.02.21 um 16:13 schrieb Shashank Sharma:

Quoted 43 lines · Christian König
Quoted 4 lines

Am 01.02.21 um 16:06 schrieb Shashank Sharma:

Quoted 3 lines

Hello Christian,

On 01/02/21 8:04 pm, Christian König wrote:

Quoted 8 lines
Quoted 4 lines
Quoted 3 lines

Some newer APUs can scanout directly from GTT, that saves us from allocating another bounce buffer in VRAM and enables freesync in such configurations.

Shall we add some more details about how this patch helps with VRR, like "Without this patch, it won't be possible for the IGPU to flip buffers which are composed on an external GPU" or something in those lines ?

How about:

"Without this patch creating a framebuffer from the imported BO will fail and userspace will fall back to a copy".

Yep, looks good enough. There is just one more tiny comment below, please check that out too.

Quoted 28 lines

Thanks,
Christian.

Quoted 25 lines
Quoted 25 lines
---
   drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 8 ++++++--
   drivers/gpu/drm/amd/amdgpu/amdgpu_object.c  | 2 +-
   2 files changed, 7 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +3 -1
index a638709e9c92..823bc25d87de 100644
@@ -930,8 +930,10 @@ amdgpu_display_user_framebuffer_create(struct drm_device *dev,
   				       struct drm_file *file_priv,
   				       const struct drm_mode_fb_cmd2 *mode_cmd)
   {
-	struct drm_gem_object *obj;
   	struct amdgpu_framebuffer *amdgpu_fb;
+	struct drm_gem_object *obj;
+	struct amdgpu_bo *bo;
+	uint32_t domains;
   	int ret;
 
   	obj = drm_gem_object_lookup(file_priv, mode_cmd->handles[0]);
@@ -942,7 +944,9 @@ amdgpu_display_user_framebuffer_create(struct drm_device *dev,
   	}
 
Quoted 8 lines
Quoted 5 lines
Quoted 4 lines
Quoted 4 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_display.c amdgpu_display_user_framebuffer_create(struct drm_device *dev, · line 947

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +1 -1
   	/* Handle is imported dma-buf, so cannot be migrated to VRAM for scanout */
-	if (obj->import_attach) {
+	bo = gem_to_amdgpu_bo(obj);

Is it possible that the bo can be NULL ? I mean do we need a NULL check here ?

This one :)

No, this is just a type cast.

Christian.

Well, all is well then !

Regards

Shashank

Quoted 19 lines
Quoted 19 lines

- Shashank

Quoted 17 lines
Quoted 17 lines
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +2 -0
+	domains = amdgpu_display_supported_domains(drm_to_adev(dev), bo->flags);
+	if (obj->import_attach && !(domains & AMDGPU_GEM_DOMAIN_GTT)) {
   		drm_dbg_kms(dev, "Cannot create framebuffer from imported dma_buf\n");
   		return ERR_PTR(-EINVAL);
   	}
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +0 -0
index 56854a3ee19c..0bd22ed1dacf 100644

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

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +1 -1
@@ -900,7 +900,7 @@ int amdgpu_bo_pin_restricted(struct amdgpu_bo *bo, u32 domain,
   		return -EINVAL;
 
   	/* A shared bo cannot be migrated to VRAM */
-	if (bo->prime_shared_count) {
+	if (bo->prime_shared_count || bo->tbo.base.import_attach) {

With the above concerns addressed (or reasoned :)), please feel free to use:

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

- Shashank

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +0 -0
   		if (domain & AMDGPU_GEM_DOMAIN_GTT)
   			domain = AMDGPU_GEM_DOMAIN_GTT;
   		else

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