Skip to contentSkip to conversation

drm/amdgpu: Do not change amdgpu framebuffer format during page flip

PATCH Superseded Zhan Liu 3 participants 4 messages Dec 22, 2020 – Jan 2, 2021

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Zhan Liu

author
#0 lore raw

PATCH 1/1 drm/amdgpu: Do not change amdgpu framebuffer format during page flip

[Why]
Driver cannot change amdgpu framebuffer (afb) format while doing page flip. Force system doing so will cause ioctl error, and result in breaking several functionalities including FreeSync.

If afb format is forced to change during page flip, following message will appear in dmesg.log:

"[drm:drm_mode_page_flip_ioctl [drm]]
Page flip is not allowed to change frame buffer format."

[How]
Do not change afb format while doing page flip. It is okay to check whether afb format is valid here, however, forcing afb format change shouldn't happen here.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 2 --
 1 file changed, 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +0 -2
index a638709e9c92..0efebd592b65 100644
@@ -831,8 +831,6 @@ static int convert_tiling_flags_to_modifier(struct amdgpu_framebuffer *afb)
 								modifier);
 			if (!format_info)
 				return -EINVAL;
-
-			afb->base.format = format_info;
 		}
 	}
 
Signature · 6 lines
2.25.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#1 lore raw
Quoted 26 lines · Zhan Liu

[Why]
Driver cannot change amdgpu framebuffer (afb) format while doing page flip. Force system doing so will cause ioctl error, and result in breaking several functionalities including FreeSync.

If afb format is forced to change during page flip, following message will appear in dmesg.log:

"[drm:drm_mode_page_flip_ioctl [drm]]
Page flip is not allowed to change frame buffer format."

[How]
Do not change afb format while doing page flip. It is okay to check whether afb format is valid here, however, forcing afb format change shouldn't happen here.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 2 --
  1 file changed, 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +0 -0
index a638709e9c92..0efebd592b65 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_display.c static int convert_tiling_flags_to_modifier(struct amdgpu_framebuffer *afb) · line 835

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +0 -2
@@ -831,8 +831,6 @@ static int convert_tiling_flags_to_modifier(struct amdgpu_framebuffer *afb)
  								modifier);
  			if (!format_info)
  				return -EINVAL;
-
-			afb->base.format = format_info;

Adding Bas for comment since he added the modifiers conversion, but I'll leave my own thoughts below.

This patch is a NAK from me - the framebuffer is still expected to be in a specific format/tiling configuration and ignoring the incoming format doesn't resolve the problem.

The problem is that the legacy page IOCTL has this check in the first place expecting that no driver is capable of performing this action.

This is not the case for amdgpu (be it DC enabled or not), so I think it's best to have a driver cap here or some new driver hook to validate that the flip is valid.

This is legacy code, and in the shared path, so I don't know how others in the list feel about modifying this but I think we do expect that legacy userspace can do this from the X side of things.

I recall seeing this happen going from DCC disabled to non DCC enabled buffers and some of this functionality being behind a version check in xf86-video-amdgpu.

Regards,
Nicholas Kazlauskas

drivers/gpu/drm/amd/amdgpu/amdgpu_display.c static int convert_tiling_flags_to_modifier(struct amdgpu_framebuffer *afb) · line 836

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +0 -0
  		}
  	}
 

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

#2 lore raw
Quoted 44 lines · Nicholas
Quoted 26 lines · Zhan Liu

[Why]
Driver cannot change amdgpu framebuffer (afb) format while doing page flip. Force system doing so will cause ioctl error, and result in breaking several functionalities including FreeSync.

If afb format is forced to change during page flip, following message will appear in dmesg.log:

"[drm:drm_mode_page_flip_ioctl [drm]]
Page flip is not allowed to change frame buffer format."

[How]
Do not change afb format while doing page flip. It is okay to check whether afb format is valid here, however, forcing afb format change shouldn't happen here.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 2 --
  1 file changed, 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +0 -0
index a638709e9c92..0efebd592b65 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_display.c static int convert_tiling_flags_to_modifier(struct amdgpu_framebuffer *afb) · line 835

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +0 -2
@@ -831,8 +831,6 @@ static int convert_tiling_flags_to_modifier(struct amdgpu_framebuffer *afb)
                                                              modifier);
                      if (!format_info)
                              return -EINVAL;
-
-                     afb->base.format = format_info;

Adding Bas for comment since he added the modifiers conversion, but I'll leave my own thoughts below.

This patch is a NAK from me - the framebuffer is still expected to be in a specific format/tiling configuration and ignoring the incoming format doesn't resolve the problem.

The problem is that the legacy page IOCTL has this check in the first place expecting that no driver is capable of performing this action.

Quoted 7 lines

This is not the case for amdgpu (be it DC enabled or not), so I think it's best to have a driver cap here or some new driver hook to validate that the flip is valid.

This is legacy code, and in the shared path, so I don't know how others in the list feel about modifying this but I think we do expect that legacy userspace can do this from the X side of things.

I think the "new" thing is that we can have different format_info structs for the same drm fourcc (as we need a different number of planes depending on modifier). It would probably make sense to relax this check to check the actual drm fourcc (i.e. fb->format->format) instead of the format_info pointer. This case would likely only be hit in the AMDGPU driver anyway (with intel being the other possibility).

Quoted 13 lines

I recall seeing this happen going from DCC disabled to non DCC enabled buffers and some of this functionality being behind a version check in xf86-video-amdgpu.

Regards,
Nicholas Kazlauskas

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +0 -0
              }
      }
 

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

#3 lore raw
In reply to Zhan Liu

https://lists.freedesktop.org/archives/dri-devel/2021-January/292761.html
is my alternative patch.

Quoted 38 lines · Zhan Liu

[Why]
Driver cannot change amdgpu framebuffer (afb) format while doing page flip. Force system doing so will cause ioctl error, and result in breaking several functionalities including FreeSync.

If afb format is forced to change during page flip, following message will appear in dmesg.log:

"[drm:drm_mode_page_flip_ioctl [drm]]
Page flip is not allowed to change frame buffer format."

[How]
Do not change afb format while doing page flip. It is okay to check whether afb format is valid here, however, forcing afb format change shouldn't happen here.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 2 --
 1 file changed, 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +0 -3
index a638709e9c92..0efebd592b65 100644
@@ -831,8 +831,6 @@ static int convert_tiling_flags_to_modifier(struct amdgpu_framebuffer *afb)
                                                                modifier);
                        if (!format_info)
                                return -EINVAL;
-
-                       afb->base.format = format_info;
                }
        }
 
--

2.25.1

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