Skip to contentSkip to conversation

drm/amd/display: ignore modifiers when checking for format support

PATCH In review Aurabindo Pillai 4 participants 8 messages Jun 9, 2022 – Jun 15, 2022

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

PATCH 1/1 drm/amd/display: ignore modifiers when checking for format support

[Why&How]
There are cases where swizzle modes are set but modifiers arent. For such a userspace, we need not check modifiers while checking compatibilty in the drm hook for checking plane format.

Ignore checking modifiers but check the DCN generation for the supported swizzle mode.

---
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 51 +++++++++++++++++--
 1 file changed, 46 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +46 -5
index 2023baf41b7e..1322df491736 100644
@@ -4938,6 +4938,7 @@ static bool dm_plane_format_mod_supported(struct drm_plane *plane,
 {
 	struct amdgpu_device *adev = drm_to_adev(plane->dev);
 	const struct drm_format_info *info = drm_format_info(format);
+	struct hw_asic_id asic_id = adev->dm.dc->ctx->asic_id;
 	int i;
 
 	enum dm_micro_swizzle microtile = modifier_gfx9_swizzle_mode(modifier) & 3;
@@ -4955,13 +4956,53 @@ static bool dm_plane_format_mod_supported(struct drm_plane *plane,
 		return true;
 	}
 
-	/* Check that the modifier is on the list of the plane's supported modifiers. */
-	for (i = 0; i < plane->modifier_count; i++) {
-		if (modifier == plane->modifiers[i])
+	/* check if swizzle mode is supported by this version of DCN */
+	switch (asic_id.chip_family) {
+		case FAMILY_SI:
+		case FAMILY_CI:
+		case FAMILY_KV:
+		case FAMILY_CZ:
+		case FAMILY_VI:
+			/* AI and earlier asics does not have modifier support */
+			return false;
+			break;
+		case FAMILY_AI:
+		case FAMILY_RV:
+		case FAMILY_NV:
+		case FAMILY_VGH:
+		case FAMILY_YELLOW_CARP:
+		case AMDGPU_FAMILY_GC_10_3_6:
+		case AMDGPU_FAMILY_GC_10_3_7:
+			switch (AMD_FMT_MOD_GET(TILE, modifier)) {
+				case AMD_FMT_MOD_TILE_GFX9_64K_R_X:
+				case AMD_FMT_MOD_TILE_GFX9_64K_D_X:
+				case AMD_FMT_MOD_TILE_GFX9_64K_S_X:
+				case AMD_FMT_MOD_TILE_GFX9_64K_D:
+					return true;
+					break;
+				default:
+					return false;
+					break;
+			}
+			break;
+		case AMDGPU_FAMILY_GC_11_0_0:
+			switch (AMD_FMT_MOD_GET(TILE, modifier)) {
+				case AMD_FMT_MOD_TILE_GFX11_256K_R_X:
+				case AMD_FMT_MOD_TILE_GFX9_64K_R_X:
+				case AMD_FMT_MOD_TILE_GFX9_64K_D_X:
+				case AMD_FMT_MOD_TILE_GFX9_64K_S_X:
+				case AMD_FMT_MOD_TILE_GFX9_64K_D:
+					return true;
+					break;
+				default:
+					return false;
+					break;
+			}
+			break;
+		default:
+			ASSERT(0); /* Unknown asic */
 			break;
 	}
-	if (i == plane->modifier_count)
-		return false;
 
 	/*
 	 * For D swizzle the canonical modifier depends on the bpp, so check
Signature · 1 line
2.36.1
Reviewed-by on v1 1/1
#1 lore raw

Marek

Quoted 95 lines · Aurabindo Pillai

[Why&How]
There are cases where swizzle modes are set but modifiers arent. For such a userspace, we need not check modifiers while checking compatibilty in the drm hook for checking plane format.

Ignore checking modifiers but check the DCN generation for the supported swizzle mode.

---
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 51 +++++++++++++++++--
 1 file changed, 46 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1 -0
index 2023baf41b7e..1322df491736 100644
@@ -4938,6 +4938,7 @@ static bool dm_plane_format_mod_supported(struct
 drm_plane *plane,
 {
        struct amdgpu_device *adev = drm_to_adev(plane->dev);
        const struct drm_format_info *info = drm_format_info(format);
+       struct hw_asic_id asic_id = adev->dm.dc->ctx->asic_id;
        int i;
 

enum dm_micro_swizzle microtile =
modifier_gfx9_swizzle_mode(modifier) & 3;

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0 -1
@@ -4955,13 +4956,53 @@ static bool dm_plane_format_mod_supported(struct
 drm_plane *plane,
                return true;
        }
 
-       /* Check that the modifier is on the list of the plane's supported

modifiers. */

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +8 -2
-       for (i = 0; i < plane->modifier_count; i++) {
-               if (modifier == plane->modifiers[i])
+       /* check if swizzle mode is supported by this version of DCN */
+       switch (asic_id.chip_family) {
+               case FAMILY_SI:
+               case FAMILY_CI:
+               case FAMILY_KV:
+               case FAMILY_CZ:
+               case FAMILY_VI:
+                       /* AI and earlier asics does not have modifier

support */

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +37 -2
+                       return false;
+                       break;
+               case FAMILY_AI:
+               case FAMILY_RV:
+               case FAMILY_NV:
+               case FAMILY_VGH:
+               case FAMILY_YELLOW_CARP:
+               case AMDGPU_FAMILY_GC_10_3_6:
+               case AMDGPU_FAMILY_GC_10_3_7:
+                       switch (AMD_FMT_MOD_GET(TILE, modifier)) {
+                               case AMD_FMT_MOD_TILE_GFX9_64K_R_X:
+                               case AMD_FMT_MOD_TILE_GFX9_64K_D_X:
+                               case AMD_FMT_MOD_TILE_GFX9_64K_S_X:
+                               case AMD_FMT_MOD_TILE_GFX9_64K_D:
+                                       return true;
+                                       break;
+                               default:
+                                       return false;
+                                       break;
+                       }
+                       break;
+               case AMDGPU_FAMILY_GC_11_0_0:
+                       switch (AMD_FMT_MOD_GET(TILE, modifier)) {
+                               case AMD_FMT_MOD_TILE_GFX11_256K_R_X:
+                               case AMD_FMT_MOD_TILE_GFX9_64K_R_X:
+                               case AMD_FMT_MOD_TILE_GFX9_64K_D_X:
+                               case AMD_FMT_MOD_TILE_GFX9_64K_S_X:
+                               case AMD_FMT_MOD_TILE_GFX9_64K_D:
+                                       return true;
+                                       break;
+                               default:
+                                       return false;
+                                       break;
+                       }
+                       break;
+               default:
+                       ASSERT(0); /* Unknown asic */
                        break;
        }
-       if (i == plane->modifier_count)
-               return false;
 
        /*
         * For D swizzle the canonical modifier depends on the bpp, so

check
--
2.36.1

#2 lore raw
In reply to Aurabindo Pillai

+ return true;
+ break;

Possibly a coding style problem, 'break' after 'return' looks redundant.

Regards,
Guchun

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Aurabindo Pillai
Sent: Thursday, June 9, 2022 10:27 PM
To: Olsak, Marek <[email protected]>; [email protected]
Cc: Li, Sun peng (Leo) <[email protected]>; Siqueira, Rodrigo <[email protected]>; Li, Roman <[email protected]>; Qiao, Ken <[email protected]>; Pillai, Aurabindo <[email protected]>; Deucher, Alexander <[email protected]>; Wentland, Harry <[email protected]>
Subject: [PATCH] drm/amd/display: ignore modifiers when checking for format support

[Why&How]
There are cases where swizzle modes are set but modifiers arent. For such a userspace, we need not check modifiers while checking compatibilty in the drm hook for checking plane format.

Ignore checking modifiers but check the DCN generation for the supported swizzle mode.

---
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 51 +++++++++++++++++--
 1 file changed, 46 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1 -0
index 2023baf41b7e..1322df491736 100644
@@ -4938,6 +4938,7 @@ static bool dm_plane_format_mod_supported(struct drm_plane *plane,  {
 	struct amdgpu_device *adev = drm_to_adev(plane->dev);
 	const struct drm_format_info *info = drm_format_info(format);
+	struct hw_asic_id asic_id = adev->dm.dc->ctx->asic_id;
 	int i;
 
 	enum dm_micro_swizzle microtile = modifier_gfx9_swizzle_mode(modifier) & 3; @@ -4955,13 +4956,53 @@ static bool dm_plane_format_mod_supported(struct drm_plane *plane,
 		return true;

}

- /* Check that the modifier is on the list of the plane's supported modifiers. */
- for (i = 0; i < plane->modifier_count; i++) {
- if (modifier == plane->modifiers[i])
+ /* check if swizzle mode is supported by this version of DCN */
+ switch (asic_id.chip_family) {
+ case FAMILY_SI:
+ case FAMILY_CI:
+ case FAMILY_KV:
+ case FAMILY_CZ:
+ case FAMILY_VI:
+ /* AI and earlier asics does not have modifier support */
+ return false;
+ break;
+ case FAMILY_AI:
+ case FAMILY_RV:
+ case FAMILY_NV:
+ case FAMILY_VGH:
+ case FAMILY_YELLOW_CARP:
+ case AMDGPU_FAMILY_GC_10_3_6:
+ case AMDGPU_FAMILY_GC_10_3_7:
+ switch (AMD_FMT_MOD_GET(TILE, modifier)) {
+ case AMD_FMT_MOD_TILE_GFX9_64K_R_X:
+ case AMD_FMT_MOD_TILE_GFX9_64K_D_X:
+ case AMD_FMT_MOD_TILE_GFX9_64K_S_X:
+ case AMD_FMT_MOD_TILE_GFX9_64K_D:
+ return true;
+ break;
+ default:
+ return false;
+ break;
+ }
+ break;
+ case AMDGPU_FAMILY_GC_11_0_0:
+ switch (AMD_FMT_MOD_GET(TILE, modifier)) {
+ case AMD_FMT_MOD_TILE_GFX11_256K_R_X:
+ case AMD_FMT_MOD_TILE_GFX9_64K_R_X:
+ case AMD_FMT_MOD_TILE_GFX9_64K_D_X:
+ case AMD_FMT_MOD_TILE_GFX9_64K_S_X:
+ case AMD_FMT_MOD_TILE_GFX9_64K_D:
+ return true;
+ break;
+ default:
+ return false;
+ break;
+ }
+ break;
+ default:
+ ASSERT(0); /* Unknown asic */
break;
}
- if (i == plane->modifier_count)
- return false;

/*
* For D swizzle the canonical modifier depends on the bpp, so check
--
2.36.1

#3 lore raw

[AMD Official Use Only - General]

Thanks for noticing, will fix it in a separate patch since I already merged this.

--

Regards,
Jay
________________________________
From: Chen, Guchun <[email protected]>
Sent: Thursday, June 9, 2022 9:28 PM
To: Pillai, Aurabindo <[email protected]>; Olsak, Marek <[email protected]>; [email protected] <[email protected]>
Cc: Li, Sun peng (Leo) <[email protected]>; Siqueira, Rodrigo <[email protected]>; Li, Roman <[email protected]>; Qiao, Ken <[email protected]>; Pillai, Aurabindo <[email protected]>; Deucher, Alexander <[email protected]>; Wentland, Harry <[email protected]>
Subject: RE: [PATCH] drm/amd/display: ignore modifiers when checking for format support

+ return true;
+ break;

Possibly a coding style problem, 'break' after 'return' looks redundant.

Regards,
Guchun

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Aurabindo Pillai
Sent: Thursday, June 9, 2022 10:27 PM
To: Olsak, Marek <[email protected]>; [email protected]
Cc: Li, Sun peng (Leo) <[email protected]>; Siqueira, Rodrigo <[email protected]>; Li, Roman <[email protected]>; Qiao, Ken <[email protected]>; Pillai, Aurabindo <[email protected]>; Deucher, Alexander <[email protected]>; Wentland, Harry <[email protected]>
Subject: [PATCH] drm/amd/display: ignore modifiers when checking for format support

[Why&How]
There are cases where swizzle modes are set but modifiers arent. For such a userspace, we need not check modifiers while checking compatibilty in the drm hook for checking plane format.

Ignore checking modifiers but check the DCN generation for the supported swizzle mode.

---
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 51 +++++++++++++++++--
 1 file changed, 46 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1 -0
index 2023baf41b7e..1322df491736 100644
@@ -4938,6 +4938,7 @@ static bool dm_plane_format_mod_supported(struct drm_plane *plane,  {
         struct amdgpu_device *adev = drm_to_adev(plane->dev);
         const struct drm_format_info *info = drm_format_info(format);
+       struct hw_asic_id asic_id = adev->dm.dc->ctx->asic_id;
         int i;
 
         enum dm_micro_swizzle microtile = modifier_gfx9_swizzle_mode(modifier) & 3; @@ -4955,13 +4956,53 @@ static bool dm_plane_format_mod_supported(struct drm_plane *plane,
                 return true;
         }

- /* Check that the modifier is on the list of the plane's supported modifiers. */
- for (i = 0; i < plane->modifier_count; i++) {
- if (modifier == plane->modifiers[i])
+ /* check if swizzle mode is supported by this version of DCN */
+ switch (asic_id.chip_family) {

+               case FAMILY_SI:
+               case FAMILY_CI:
+               case FAMILY_KV:
+               case FAMILY_CZ:
+               case FAMILY_VI:
+                       /* AI and earlier asics does not have modifier support */
+                       return false;
+                       break;
+               case FAMILY_AI:
+               case FAMILY_RV:
+               case FAMILY_NV:
+               case FAMILY_VGH:
+               case FAMILY_YELLOW_CARP:
+               case AMDGPU_FAMILY_GC_10_3_6:
+               case AMDGPU_FAMILY_GC_10_3_7:
+                       switch (AMD_FMT_MOD_GET(TILE, modifier)) {
+                               case AMD_FMT_MOD_TILE_GFX9_64K_R_X:
+                               case AMD_FMT_MOD_TILE_GFX9_64K_D_X:
+                               case AMD_FMT_MOD_TILE_GFX9_64K_S_X:
+                               case AMD_FMT_MOD_TILE_GFX9_64K_D:

+ return true;
+ break;
+ default:
+ return false;
+ break;
+ }
+ break;
+ case AMDGPU_FAMILY_GC_11_0_0:
+ switch (AMD_FMT_MOD_GET(TILE, modifier)) {

+                               case AMD_FMT_MOD_TILE_GFX11_256K_R_X:
+                               case AMD_FMT_MOD_TILE_GFX9_64K_R_X:
+                               case AMD_FMT_MOD_TILE_GFX9_64K_D_X:
+                               case AMD_FMT_MOD_TILE_GFX9_64K_S_X:
+                               case AMD_FMT_MOD_TILE_GFX9_64K_D:

+ return true;
+ break;
+ default:
+ return false;
+ break;
+ }
+ break;
+ default:
+ ASSERT(0); /* Unknown asic */

                         break;
         }

- if (i == plane->modifier_count)
- return false;

/*
* For D swizzle the canonical modifier depends on the bpp, so check
--
2.36.1

#4 lore raw
In reply to Aurabindo Pillai
Quoted 70 lines · Aurabindo Pillai

[Why&How]
There are cases where swizzle modes are set but modifiers arent. For such a userspace, we need not check modifiers while checking compatibilty in the drm hook for checking plane format.

Ignore checking modifiers but check the DCN generation for the supported swizzle mode.

---
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 51 +++++++++++++++++--
 1 file changed, 46 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +38 -3
index 2023baf41b7e..1322df491736 100644
@@ -4938,6 +4938,7 @@ static bool dm_plane_format_mod_supported(struct drm_plane *plane,
 {
        struct amdgpu_device *adev = drm_to_adev(plane->dev);
        const struct drm_format_info *info = drm_format_info(format);
+       struct hw_asic_id asic_id = adev->dm.dc->ctx->asic_id;
        int i;
 
        enum dm_micro_swizzle microtile = modifier_gfx9_swizzle_mode(modifier) & 3;
@@ -4955,13 +4956,53 @@ static bool dm_plane_format_mod_supported(struct drm_plane *plane,
                return true;
        }
 
-       /* Check that the modifier is on the list of the plane's supported modifiers. */
-       for (i = 0; i < plane->modifier_count; i++) {
-               if (modifier == plane->modifiers[i])
+       /* check if swizzle mode is supported by this version of DCN */
+       switch (asic_id.chip_family) {
+               case FAMILY_SI:
+               case FAMILY_CI:
+               case FAMILY_KV:
+               case FAMILY_CZ:
+               case FAMILY_VI:
+                       /* AI and earlier asics does not have modifier support */
+                       return false;
+                       break;
+               case FAMILY_AI:
+               case FAMILY_RV:
+               case FAMILY_NV:
+               case FAMILY_VGH:
+               case FAMILY_YELLOW_CARP:
+               case AMDGPU_FAMILY_GC_10_3_6:
+               case AMDGPU_FAMILY_GC_10_3_7:
+                       switch (AMD_FMT_MOD_GET(TILE, modifier)) {
+                               case AMD_FMT_MOD_TILE_GFX9_64K_R_X:
+                               case AMD_FMT_MOD_TILE_GFX9_64K_D_X:
+                               case AMD_FMT_MOD_TILE_GFX9_64K_S_X:
+                               case AMD_FMT_MOD_TILE_GFX9_64K_D:
+                                       return true;
+                                       break;
+                               default:
+                                       return false;
+                                       break;
+                       }
+                       break;
+               case AMDGPU_FAMILY_GC_11_0_0:
+                       switch (AMD_FMT_MOD_GET(TILE, modifier)) {
+                               case AMD_FMT_MOD_TILE_GFX11_256K_R_X:
+                               case AMD_FMT_MOD_TILE_GFX9_64K_R_X:
+                               case AMD_FMT_MOD_TILE_GFX9_64K_D_X:
+                               case AMD_FMT_MOD_TILE_GFX9_64K_S_X:
+                               case AMD_FMT_MOD_TILE_GFX9_64K_D:
+                                       return true;

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static bool dm_plane_format_mod_supported(struct drm_plane *plane, · line 5005

Quoted 10 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +8 -0
+                                       break;
+                               default:
+                                       return false;
+                                       break;
+                       }
+                       break;
+               default:
+                       ASSERT(0); /* Unknown asic */
                        break;
        }

This seems broken to me. AFAICT we always return in the switch so the code after this that checks for valid DCC usage isn't executed. Checking the list of modifiers is also essential to make sure other stuff in the modifier is set properly.

If you have userspace that is not using modifiers that is giving you issues, a better place to look might be convert_tiling_flags_to_modifier in amdgpu_display.c

Quoted 8 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0 -3
-       if (i == plane->modifier_count)
-               return false;
 
        /*
         * For D swizzle the canonical modifier depends on the bpp, so check
--

2.36.1

#5 lore raw

Bas, the code was literally rejecting swizzle modes that were not in the modifier list, which was incorrect. That's because the modifier list is a subset of all supported swizzle modes.

Marek

Quoted 108 lines · Bas Nieuwenhuizen
Quoted 9 lines · Aurabindo Pillai

[Why&How]
There are cases where swizzle modes are set but modifiers arent. For such a userspace, we need not check modifiers while checking compatibilty in the drm hook for checking plane format.

Ignore checking modifiers but check the DCN generation for the supported swizzle mode.

Review

Quoted 6 lines
---
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 51 +++++++++++++++++--
 1 file changed, 46 insertions(+), 5 deletions(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static bool dm_plane_format_mod_supported(struct

Quoted 4 lines

index 2023baf41b7e..1322df491736 100644

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0 -0
@@ -4938,6 +4938,7 @@ static bool dm_plane_format_mod_supported(struct

drm_plane *plane,

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static bool dm_plane_format_mod_supported(struct drm_plane *plane,

Quoted 7 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1 -0
 {
        struct amdgpu_device *adev = drm_to_adev(plane->dev);
        const struct drm_format_info *info = drm_format_info(format);
+       struct hw_asic_id asic_id = adev->dm.dc->ctx->asic_id;
        int i;
 
        enum dm_micro_swizzle microtile =

modifier_gfx9_swizzle_mode(modifier) & 3;

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static bool dm_plane_format_mod_supported(struct

Quoted 1 line
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0 -0
@@ -4955,13 +4956,53 @@ static bool dm_plane_format_mod_supported(struct

drm_plane *plane,

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static bool dm_plane_format_mod_supported(struct drm_plane *plane,

Quoted 4 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0 -1
                return true;
        }
 
-       /* Check that the modifier is on the list of the plane's

supported modifiers. */

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static bool dm_plane_format_mod_supported(struct drm_plane *plane,

Quoted 10 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +8 -2
-       for (i = 0; i < plane->modifier_count; i++) {
-               if (modifier == plane->modifiers[i])
+       /* check if swizzle mode is supported by this version of DCN */
+       switch (asic_id.chip_family) {
+               case FAMILY_SI:
+               case FAMILY_CI:
+               case FAMILY_KV:
+               case FAMILY_CZ:
+               case FAMILY_VI:
+                       /* AI and earlier asics does not have modifier

support */

Quoted 29 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +29 -0
+                       return false;
+                       break;
+               case FAMILY_AI:
+               case FAMILY_RV:
+               case FAMILY_NV:
+               case FAMILY_VGH:
+               case FAMILY_YELLOW_CARP:
+               case AMDGPU_FAMILY_GC_10_3_6:
+               case AMDGPU_FAMILY_GC_10_3_7:
+                       switch (AMD_FMT_MOD_GET(TILE, modifier)) {
+                               case AMD_FMT_MOD_TILE_GFX9_64K_R_X:
+                               case AMD_FMT_MOD_TILE_GFX9_64K_D_X:
+                               case AMD_FMT_MOD_TILE_GFX9_64K_S_X:
+                               case AMD_FMT_MOD_TILE_GFX9_64K_D:
+                                       return true;
+                                       break;
+                               default:
+                                       return false;
+                                       break;
+                       }
+                       break;
+               case AMDGPU_FAMILY_GC_11_0_0:
+                       switch (AMD_FMT_MOD_GET(TILE, modifier)) {
+                               case AMD_FMT_MOD_TILE_GFX11_256K_R_X:
+                               case AMD_FMT_MOD_TILE_GFX9_64K_R_X:
+                               case AMD_FMT_MOD_TILE_GFX9_64K_D_X:
+                               case AMD_FMT_MOD_TILE_GFX9_64K_S_X:
+                               case AMD_FMT_MOD_TILE_GFX9_64K_D:
+                                       return true;

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static bool dm_plane_format_mod_supported(struct drm_plane *plane, · line 5005

Quoted 10 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +8 -0
+                                       break;
+                               default:
+                                       return false;
+                                       break;
+                       }
+                       break;
+               default:
+                       ASSERT(0); /* Unknown asic */
                        break;
        }

This seems broken to me. AFAICT we always return in the switch so the code after this that checks for valid DCC usage isn't executed. Checking the list of modifiers is also essential to make sure other stuff in the modifier is set properly.

If you have userspace that is not using modifiers that is giving you issues, a better place to look might be convert_tiling_flags_to_modifier in amdgpu_display.c

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static bool dm_plane_format_mod_supported(struct drm_plane *plane,

Quoted 5 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0 -2
-       if (i == plane->modifier_count)
-               return false;
 
        /*
         * For D swizzle the canonical modifier depends on the bpp, so

check

Quoted 3 lines

--
2.36.1

#6 lore raw
Quoted 2 lines · Marek Olšák

Bas, the code was literally rejecting swizzle modes that were not in the modifier list, which was incorrect. That's because the modifier list is a subset of all supported swizzle modes.

That was WAI. The kernel is now in charge of rejecting stuff that is not capable of being displayed.

Allowing all in format_mod_supported has several implications on exposed & accepted modifiers as well, that should be avoided even if we should do a behavior change for non-modifiers: We now expose (i.e. list) modifiers for formats which they don't support and we removed the check that the modifier is in the list for commits with modifiers too. Hence this logic would need a serious rework instead of the patch that was sent.

What combinations were failing, and can't we just add modifiers for them?

Quoted 105 lines

Marek

Quoted 101 lines · Bas Nieuwenhuizen
Quoted 70 lines · Aurabindo Pillai

[Why&How]
There are cases where swizzle modes are set but modifiers arent. For such a userspace, we need not check modifiers while checking compatibilty in the drm hook for checking plane format.

Ignore checking modifiers but check the DCN generation for the supported swizzle mode.

---
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 51 +++++++++++++++++--
 1 file changed, 46 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +38 -3
index 2023baf41b7e..1322df491736 100644
@@ -4938,6 +4938,7 @@ static bool dm_plane_format_mod_supported(struct drm_plane *plane,
 {
        struct amdgpu_device *adev = drm_to_adev(plane->dev);
        const struct drm_format_info *info = drm_format_info(format);
+       struct hw_asic_id asic_id = adev->dm.dc->ctx->asic_id;
        int i;
 
        enum dm_micro_swizzle microtile = modifier_gfx9_swizzle_mode(modifier) & 3;
@@ -4955,13 +4956,53 @@ static bool dm_plane_format_mod_supported(struct drm_plane *plane,
                return true;
        }
 
-       /* Check that the modifier is on the list of the plane's supported modifiers. */
-       for (i = 0; i < plane->modifier_count; i++) {
-               if (modifier == plane->modifiers[i])
+       /* check if swizzle mode is supported by this version of DCN */
+       switch (asic_id.chip_family) {
+               case FAMILY_SI:
+               case FAMILY_CI:
+               case FAMILY_KV:
+               case FAMILY_CZ:
+               case FAMILY_VI:
+                       /* AI and earlier asics does not have modifier support */
+                       return false;
+                       break;
+               case FAMILY_AI:
+               case FAMILY_RV:
+               case FAMILY_NV:
+               case FAMILY_VGH:
+               case FAMILY_YELLOW_CARP:
+               case AMDGPU_FAMILY_GC_10_3_6:
+               case AMDGPU_FAMILY_GC_10_3_7:
+                       switch (AMD_FMT_MOD_GET(TILE, modifier)) {
+                               case AMD_FMT_MOD_TILE_GFX9_64K_R_X:
+                               case AMD_FMT_MOD_TILE_GFX9_64K_D_X:
+                               case AMD_FMT_MOD_TILE_GFX9_64K_S_X:
+                               case AMD_FMT_MOD_TILE_GFX9_64K_D:
+                                       return true;
+                                       break;
+                               default:
+                                       return false;
+                                       break;
+                       }
+                       break;
+               case AMDGPU_FAMILY_GC_11_0_0:
+                       switch (AMD_FMT_MOD_GET(TILE, modifier)) {
+                               case AMD_FMT_MOD_TILE_GFX11_256K_R_X:
+                               case AMD_FMT_MOD_TILE_GFX9_64K_R_X:
+                               case AMD_FMT_MOD_TILE_GFX9_64K_D_X:
+                               case AMD_FMT_MOD_TILE_GFX9_64K_S_X:
+                               case AMD_FMT_MOD_TILE_GFX9_64K_D:
+                                       return true;

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static bool dm_plane_format_mod_supported(struct drm_plane *plane, · line 5005

Quoted 10 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +8 -0
+                                       break;
+                               default:
+                                       return false;
+                                       break;
+                       }
+                       break;
+               default:
+                       ASSERT(0); /* Unknown asic */
                        break;
        }

This seems broken to me. AFAICT we always return in the switch so the code after this that checks for valid DCC usage isn't executed. Checking the list of modifiers is also essential to make sure other stuff in the modifier is set properly.

If you have userspace that is not using modifiers that is giving you issues, a better place to look might be convert_tiling_flags_to_modifier in amdgpu_display.c

Quoted 8 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0 -3
-       if (i == plane->modifier_count)
-               return false;
 
        /*
         * For D swizzle the canonical modifier depends on the bpp, so check
--

2.36.1

#7 lore raw

We can reject invalid modifiers elsewhere, but it can't be here because it's also the non-modifier path.

We expose 256KB_R_X or 64KB_R_X modifiers depending on chip-specific settings, but not both. Only the optimal option is exposed. This is OK for modifiers, but not OK with AMD-specific BO metadata where the UMD determines the swizzle mode.

Marek

Quoted 138 lines · Bas Nieuwenhuizen
Quoted 2 lines · Marek Olšák

Bas, the code was literally rejecting swizzle modes that were not in the

modifier list, which was incorrect. That's because the modifier list is a subset of all supported swizzle modes.

That was WAI. The kernel is now in charge of rejecting stuff that is not capable of being displayed.

Allowing all in format_mod_supported has several implications on exposed & accepted modifiers as well, that should be avoided even if we should do a behavior change for non-modifiers: We now expose (i.e. list) modifiers for formats which they don't support and we removed the check that the modifier is in the list for commits with modifiers too. Hence this logic would need a serious rework instead of the patch that was sent.

What combinations were failing, and can't we just add modifiers for them?

Quoted 4 lines

Marek

On Sun, Jun 12, 2022 at 7:54 PM Bas Nieuwenhuizen <

Quoted 9 lines · [email protected]> wrote:
Quoted 9 lines
Quoted 6 lines · Aurabindo Pillai

[Why&How]
There are cases where swizzle modes are set but modifiers arent. For such a userspace, we need not check modifiers while checking compatibilty in the drm hook for checking plane format.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

Ignore checking modifiers but check the DCN generation for the supported swizzle mode.

---
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 51

+++++++++++++++++--

Quoted 3 lines
Quoted 3 lines

Review

Quoted 3 lines
 1 file changed, 46 insertions(+), 5 deletions(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c

Quoted 4 lines
Quoted 4 lines

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static bool

Quoted 4 lines

index 2023baf41b7e..1322df491736 100644

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0 -0
@@ -4938,6 +4938,7 @@ static bool

dm_plane_format_mod_supported(struct drm_plane *plane,

Quoted 7 lines
Quoted 7 lines

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static bool dm_plane_format_mod_supported(struct drm_plane *plane,

Quoted 7 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1 -0
 {
        struct amdgpu_device *adev = drm_to_adev(plane->dev);
        const struct drm_format_info *info = drm_format_info(format);
+       struct hw_asic_id asic_id = adev->dm.dc->ctx->asic_id;
        int i;
 
        enum dm_micro_swizzle microtile =

modifier_gfx9_swizzle_mode(modifier) & 3;

Quoted 1 line
Quoted 1 line

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static bool

Quoted 1 line
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0 -0
@@ -4955,13 +4956,53 @@ static bool

dm_plane_format_mod_supported(struct drm_plane *plane,

Quoted 4 lines
Quoted 4 lines

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static bool dm_plane_format_mod_supported(struct drm_plane *plane,

Quoted 4 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0 -1
                return true;
        }
 
-       /* Check that the modifier is on the list of the plane's

supported modifiers. */

Quoted 3 lines
Quoted 3 lines

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static bool dm_plane_format_mod_supported(struct drm_plane *plane,

Quoted 3 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1 -2
-       for (i = 0; i < plane->modifier_count; i++) {
-               if (modifier == plane->modifiers[i])
+       /* check if swizzle mode is supported by this version of DCN

*/

Quoted 7 lines
Quoted 7 lines

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static bool dm_plane_format_mod_supported(struct drm_plane *plane,

Quoted 7 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +7 -0
+       switch (asic_id.chip_family) {
+               case FAMILY_SI:
+               case FAMILY_CI:
+               case FAMILY_KV:
+               case FAMILY_CZ:
+               case FAMILY_VI:
+                       /* AI and earlier asics does not have

modifier support */

Quoted 49 lines
Quoted 49 lines
Quoted 29 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +29 -0
+                       return false;
+                       break;
+               case FAMILY_AI:
+               case FAMILY_RV:
+               case FAMILY_NV:
+               case FAMILY_VGH:
+               case FAMILY_YELLOW_CARP:
+               case AMDGPU_FAMILY_GC_10_3_6:
+               case AMDGPU_FAMILY_GC_10_3_7:
+                       switch (AMD_FMT_MOD_GET(TILE, modifier)) {
+                               case AMD_FMT_MOD_TILE_GFX9_64K_R_X:
+                               case AMD_FMT_MOD_TILE_GFX9_64K_D_X:
+                               case AMD_FMT_MOD_TILE_GFX9_64K_S_X:
+                               case AMD_FMT_MOD_TILE_GFX9_64K_D:
+                                       return true;
+                                       break;
+                               default:
+                                       return false;
+                                       break;
+                       }
+                       break;
+               case AMDGPU_FAMILY_GC_11_0_0:
+                       switch (AMD_FMT_MOD_GET(TILE, modifier)) {
+                               case AMD_FMT_MOD_TILE_GFX11_256K_R_X:
+                               case AMD_FMT_MOD_TILE_GFX9_64K_R_X:
+                               case AMD_FMT_MOD_TILE_GFX9_64K_D_X:
+                               case AMD_FMT_MOD_TILE_GFX9_64K_S_X:
+                               case AMD_FMT_MOD_TILE_GFX9_64K_D:
+                                       return true;

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static bool dm_plane_format_mod_supported(struct drm_plane *plane, · line 5005

Quoted 10 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +8 -0
+                                       break;
+                               default:
+                                       return false;
+                                       break;
+                       }
+                       break;
+               default:
+                       ASSERT(0); /* Unknown asic */
                        break;
        }

This seems broken to me. AFAICT we always return in the switch so the code after this that checks for valid DCC usage isn't executed. Checking the list of modifiers is also essential to make sure other stuff in the modifier is set properly.

If you have userspace that is not using modifiers that is giving you issues, a better place to look might be convert_tiling_flags_to_modifier in amdgpu_display.c

Quoted 5 lines
Quoted 5 lines

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static bool dm_plane_format_mod_supported(struct drm_plane *plane,

Quoted 5 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0 -2
-       if (i == plane->modifier_count)
-               return false;
 
        /*
         * For D swizzle the canonical modifier depends on the bpp,

so check

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

--
2.36.1