Skip to contentSkip to conversation

drm/amd/display: remove duplicate format modifier

PATCH In review Erik Kurzinger 2 participants 2 messages Feb 10

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

PATCH v2 1/1 drm/amd/display: remove duplicate format modifier

amdgpu_dm_plane_get_plane_modifiers always adds DRM_FORMAT_MOD_LINEAR to the list of modifiers. However, with gfx12, amdgpu_dm_plane_add_gfx12_modifiers also adds that modifier to the list. So we end up with two copies. Most apps just ignore this but some (Weston) don't like it.

As a fix, we change amdgpu_dm_plane_add_gfx12_modifiers to not add DRM_FORMAT_MOD_LINEAR to the list, matching the behavior of analogous functions for other chips.

---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c +4 -4
index d3e62f511c8f..a0a7c3b5ee03 100644
@@ -704,21 +704,21 @@ static void amdgpu_dm_plane_add_gfx12_modifiers(struct amdgpu_device *adev,
 	uint8_t max_comp_block[] = {2, 1, 0};
 	uint64_t max_comp_block_mod[ARRAY_SIZE(max_comp_block)] = {0};
 	uint8_t i = 0, j = 0;
-	uint64_t gfx12_modifiers[] = {mod_256k, mod_64k, mod_4k, mod_256b, DRM_FORMAT_MOD_LINEAR};
+	/* Note, linear (no DCC) gets added to the modifier list for all chips by the caller. */
+	uint64_t gfx12_modifiers[] = {mod_256k, mod_64k, mod_4k, mod_256b};
 
 	for (i = 0; i < ARRAY_SIZE(max_comp_block); i++)
 		max_comp_block_mod[i] = AMD_FMT_MOD_SET(DCC_MAX_COMPRESSED_BLOCK, max_comp_block[i]);
 
 	/* With DCC: Best choice should be kept first. Hence, add all 256k modifiers of different
 	 * max compressed blocks first and then move on to the next smaller sized layouts.
-	 * Do not add the linear modifier here, and hence the condition of size-1 for the loop
 	 */
-	for (j = 0; j < ARRAY_SIZE(gfx12_modifiers) - 1; j++)
+	for (j = 0; j < ARRAY_SIZE(gfx12_modifiers); j++)
 		for (i = 0; i < ARRAY_SIZE(max_comp_block); i++)
 			amdgpu_dm_plane_add_modifier(mods, size, capacity,
 						     ver | dcc | max_comp_block_mod[i] | gfx12_modifiers[j]);
 
-	/* Without DCC. Add all modifiers including linear at the end */
+	/* Without DCC. */
 	for (i = 0; i < ARRAY_SIZE(gfx12_modifiers); i++)
 		amdgpu_dm_plane_add_modifier(mods, size, capacity, gfx12_modifiers[i]);
 
Signature · 1 line
2.53.0
Acked-by on v2 1/1
#1 lore raw
Quoted 7 lines · Erik Kurzinger

amdgpu_dm_plane_get_plane_modifiers always adds DRM_FORMAT_MOD_LINEAR to the list of modifiers. However, with gfx12, amdgpu_dm_plane_add_gfx12_modifiers also adds that modifier to the list. So we end up with two copies. Most apps just ignore this but some (Weston) don't like it.

Quoted 5 lines

As a fix, we change amdgpu_dm_plane_add_gfx12_modifiers to not add DRM_FORMAT_MOD_LINEAR to the list, matching the behavior of analogous functions for other chips.

Quoted 37 lines
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c +4 -5
index d3e62f511c8f..a0a7c3b5ee03 100644
@@ -704,21 +704,21 @@ static void amdgpu_dm_plane_add_gfx12_modifiers(struct amdgpu_device *adev,
        uint8_t max_comp_block[] = {2, 1, 0};
        uint64_t max_comp_block_mod[ARRAY_SIZE(max_comp_block)] = {0};
        uint8_t i = 0, j = 0;
-       uint64_t gfx12_modifiers[] = {mod_256k, mod_64k, mod_4k, mod_256b, DRM_FORMAT_MOD_LINEAR};
+       /* Note, linear (no DCC) gets added to the modifier list for all chips by the caller. */
+       uint64_t gfx12_modifiers[] = {mod_256k, mod_64k, mod_4k, mod_256b};
 
        for (i = 0; i < ARRAY_SIZE(max_comp_block); i++)
                max_comp_block_mod[i] = AMD_FMT_MOD_SET(DCC_MAX_COMPRESSED_BLOCK, max_comp_block[i]);
 
        /* With DCC: Best choice should be kept first. Hence, add all 256k modifiers of different
         * max compressed blocks first and then move on to the next smaller sized layouts.
-        * Do not add the linear modifier here, and hence the condition of size-1 for the loop
         */
-       for (j = 0; j < ARRAY_SIZE(gfx12_modifiers) - 1; j++)
+       for (j = 0; j < ARRAY_SIZE(gfx12_modifiers); j++)
                for (i = 0; i < ARRAY_SIZE(max_comp_block); i++)
                        amdgpu_dm_plane_add_modifier(mods, size, capacity,
                                                     ver | dcc | max_comp_block_mod[i] | gfx12_modifiers[j]);
 
-       /* Without DCC. Add all modifiers including linear at the end */
+       /* Without DCC. */
        for (i = 0; i < ARRAY_SIZE(gfx12_modifiers); i++)
                amdgpu_dm_plane_add_modifier(mods, size, capacity, gfx12_modifiers[i]);
 
--

2.53.0