* [PATCH] amdgpu: check tiling flags when creating FB on GFX8-
@ 2021-09-20 10:31 Simon Ser
2021-09-20 10:50 ` Michel Dänzer
2021-09-27 13:09 ` Simon Ser
0 siblings, 2 replies; 5+ messages in thread
From: Simon Ser @ 2021-09-20 10:31 UTC (permalink / raw)
To: amd-gfx
Cc: stable, Alex Deucher, Harry Wentland, Nicholas Kazlauskas,
Michel Dänzer, Bas Nieuwenhuizen
On GFX9+, format modifiers are always enabled and ensure the
frame-buffers can be scanned out at ADDFB2 time.
On GFX8-, format modifiers are not supported and no other check
is performed. This means ADDFB2 IOCTLs will succeed even if the
tiling isn't supported for scan-out, and will result in garbage
displayed on screen [1].
Fix this by adding a check for tiling flags for GFX8 and older.
The check is taken from radeonsi in Mesa (see how is_displayable
is populated in gfx6_compute_surface).
[1]: https://github.com/swaywm/wlroots/issues/3185
Signed-off-by: Simon Ser <contact@emersion.fr>
Cc: stable@vger.kernel.org
Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: Harry Wentland <hwentlan@amd.com>
Cc: Nicholas Kazlauskas <Nicholas.Kazlauskas@amd.com>
Cc: Michel Dänzer <michel@daenzer.net>
Cc: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 31 +++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
index 58bfc7f00d76..dfe434a56a8c 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
@@ -837,6 +837,28 @@ static int convert_tiling_flags_to_modifier(struct amdgpu_framebuffer *afb)
return 0;
}
+/* Mirrors the is_displayable check in radeonsi's gfx6_compute_surface */
+static int check_tiling_flags_gfx6(struct amdgpu_framebuffer *afb)
+{
+ u64 micro_tile_mode;
+
+ /* Zero swizzle mode means linear */
+ if (AMDGPU_TILING_GET(afb->tiling_flags, SWIZZLE_MODE) == 0)
+ return 0;
+
+ micro_tile_mode = AMDGPU_TILING_GET(afb->tiling_flags, MICRO_TILE_MODE);
+ switch (micro_tile_mode) {
+ case 0: /* DISPLAY */
+ case 3: /* RENDER */
+ return 0;
+ default:
+ drm_dbg_kms(afb->base.dev,
+ "Micro tile mode %llu not supported for scanout\n",
+ micro_tile_mode);
+ return -EINVAL;
+ }
+}
+
static void get_block_dimensions(unsigned int block_log2, unsigned int cpp,
unsigned int *width, unsigned int *height)
{
@@ -1103,6 +1125,7 @@ int amdgpu_display_framebuffer_init(struct drm_device *dev,
const struct drm_mode_fb_cmd2 *mode_cmd,
struct drm_gem_object *obj)
{
+ struct amdgpu_device *adev = drm_to_adev(dev);
int ret, i;
/*
@@ -1122,6 +1145,14 @@ int amdgpu_display_framebuffer_init(struct drm_device *dev,
if (ret)
return ret;
+ if (!dev->mode_config.allow_fb_modifiers) {
+ drm_WARN(dev, adev->family >= AMDGPU_FAMILY_AI,
+ "GFX9+ requires FB check based on format modifier\n");
+ ret = check_tiling_flags_gfx6(rfb);
+ if (ret)
+ return ret;
+ }
+
if (dev->mode_config.allow_fb_modifiers &&
!(rfb->base.flags & DRM_MODE_FB_MODIFIERS)) {
ret = convert_tiling_flags_to_modifier(rfb);
base-commit: cdccf1ffe1a37f5eb84a2d2096abe1dd6dbeeec3
--
2.33.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] amdgpu: check tiling flags when creating FB on GFX8-
2021-09-20 10:31 [PATCH] amdgpu: check tiling flags when creating FB on GFX8- Simon Ser
@ 2021-09-20 10:50 ` Michel Dänzer
2021-09-27 13:09 ` Simon Ser
1 sibling, 0 replies; 5+ messages in thread
From: Michel Dänzer @ 2021-09-20 10:50 UTC (permalink / raw)
To: Simon Ser
Cc: stable, Alex Deucher, Harry Wentland, Nicholas Kazlauskas,
Bas Nieuwenhuizen, amd-gfx
On 2021-09-20 12:31, Simon Ser wrote:
> On GFX9+, format modifiers are always enabled and ensure the
> frame-buffers can be scanned out at ADDFB2 time.
>
> On GFX8-, format modifiers are not supported and no other check
> is performed. This means ADDFB2 IOCTLs will succeed even if the
> tiling isn't supported for scan-out, and will result in garbage
> displayed on screen [1].
>
> Fix this by adding a check for tiling flags for GFX8 and older.
> The check is taken from radeonsi in Mesa (see how is_displayable
> is populated in gfx6_compute_surface).
>
> [1]: https://github.com/swaywm/wlroots/issues/3185
>
> Signed-off-by: Simon Ser <contact@emersion.fr>
> Cc: stable@vger.kernel.org
> Cc: Alex Deucher <alexander.deucher@amd.com>
> Cc: Harry Wentland <hwentlan@amd.com>
> Cc: Nicholas Kazlauskas <Nicholas.Kazlauskas@amd.com>
> Cc: Michel Dänzer <michel@daenzer.net>
> Cc: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 31 +++++++++++++++++++++
> 1 file changed, 31 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
> index 58bfc7f00d76..dfe434a56a8c 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
> @@ -837,6 +837,28 @@ static int convert_tiling_flags_to_modifier(struct amdgpu_framebuffer *afb)
> return 0;
> }
>
> +/* Mirrors the is_displayable check in radeonsi's gfx6_compute_surface */
> +static int check_tiling_flags_gfx6(struct amdgpu_framebuffer *afb)
> +{
> + u64 micro_tile_mode;
> +
> + /* Zero swizzle mode means linear */
> + if (AMDGPU_TILING_GET(afb->tiling_flags, SWIZZLE_MODE) == 0)
> + return 0;
> +
> + micro_tile_mode = AMDGPU_TILING_GET(afb->tiling_flags, MICRO_TILE_MODE);
> + switch (micro_tile_mode) {
> + case 0: /* DISPLAY */
> + case 3: /* RENDER */
> + return 0;
> + default:
> + drm_dbg_kms(afb->base.dev,
> + "Micro tile mode %llu not supported for scanout\n",
> + micro_tile_mode);
> + return -EINVAL;
> + }
> +}
> +
> static void get_block_dimensions(unsigned int block_log2, unsigned int cpp,
> unsigned int *width, unsigned int *height)
> {
> @@ -1103,6 +1125,7 @@ int amdgpu_display_framebuffer_init(struct drm_device *dev,
> const struct drm_mode_fb_cmd2 *mode_cmd,
> struct drm_gem_object *obj)
> {
> + struct amdgpu_device *adev = drm_to_adev(dev);
> int ret, i;
>
> /*
> @@ -1122,6 +1145,14 @@ int amdgpu_display_framebuffer_init(struct drm_device *dev,
> if (ret)
> return ret;
>
> + if (!dev->mode_config.allow_fb_modifiers) {
> + drm_WARN(dev, adev->family >= AMDGPU_FAMILY_AI,
> + "GFX9+ requires FB check based on format modifier\n");
drm_WARN_ONCE would be better, to avoid spamming dmesg if there's a driver bug.
With that,
Acked-by: Michel Dänzer <mdaenzer@redhat.com>
--
Earthling Michel Dänzer | https://redhat.com
Libre software enthusiast | Mesa and Xwayland developer
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] amdgpu: check tiling flags when creating FB on GFX8-
2021-09-20 10:31 [PATCH] amdgpu: check tiling flags when creating FB on GFX8- Simon Ser
2021-09-20 10:50 ` Michel Dänzer
@ 2021-09-27 13:09 ` Simon Ser
2021-09-27 14:57 ` Alex Deucher
1 sibling, 1 reply; 5+ messages in thread
From: Simon Ser @ 2021-09-27 13:09 UTC (permalink / raw)
To: amd-gfx
Cc: stable, Alex Deucher, Harry Wentland, Nicholas Kazlauskas,
Michel Dänzer, Bas Nieuwenhuizen
Alex, Harry, Nicholas: any thoughts on this patch?
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] amdgpu: check tiling flags when creating FB on GFX8-
2021-09-27 13:09 ` Simon Ser
@ 2021-09-27 14:57 ` Alex Deucher
2021-09-27 15:09 ` Simon Ser
0 siblings, 1 reply; 5+ messages in thread
From: Alex Deucher @ 2021-09-27 14:57 UTC (permalink / raw)
To: Simon Ser
Cc: amd-gfx list, for 3.8, Alex Deucher, Harry Wentland,
Nicholas Kazlauskas, Michel Dänzer, Bas Nieuwenhuizen
On Mon, Sep 27, 2021 at 9:09 AM Simon Ser <contact@emersion.fr> wrote:
>
> Alex, Harry, Nicholas: any thoughts on this patch?
No objections from me with the WARN_ONCE change suggested by Michel.
Alex
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] amdgpu: check tiling flags when creating FB on GFX8-
2021-09-27 14:57 ` Alex Deucher
@ 2021-09-27 15:09 ` Simon Ser
0 siblings, 0 replies; 5+ messages in thread
From: Simon Ser @ 2021-09-27 15:09 UTC (permalink / raw)
To: Alex Deucher
Cc: amd-gfx list, for 3.8, Alex Deucher, Harry Wentland,
Nicholas Kazlauskas, Michel Dänzer, Bas Nieuwenhuizen
On Monday, September 27th, 2021 at 16:57, Alex Deucher <alexdeucher@gmail.com> wrote:
> No objections from me with the WARN_ONCE change suggested by Michel.
Cool, just sent v2 with Michel's comment fixed.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-09-27 15:09 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-20 10:31 [PATCH] amdgpu: check tiling flags when creating FB on GFX8- Simon Ser
2021-09-20 10:50 ` Michel Dänzer
2021-09-27 13:09 ` Simon Ser
2021-09-27 14:57 ` Alex Deucher
2021-09-27 15:09 ` Simon Ser
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.