All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/amd/display: expose additional modifier for DCN32/321
@ 2022-06-27 14:32 Aurabindo Pillai
  2022-06-28 12:31 ` Marek Olšák
  0 siblings, 1 reply; 2+ messages in thread
From: Aurabindo Pillai @ 2022-06-27 14:32 UTC (permalink / raw)
  To: amd-gfx, marek.olsak; +Cc: alexdeucher, aurabindo.pillai, harry.wentland, bas

[Why&How]
Some userspace expect a backwards compatible modifier on DCN32/321. For
hardware with num_pipes more than 16, we expose the most efficient
modifier first. As a fall back method, we need to expose slightly inefficient
modifier AMD_FMT_MOD_TILE_GFX9_64K_R_X after the best option.

Also set the number of packers to fixed value as required per hardware
documentation. This value is cached during hardware initialization and
can be read through the base driver.

Fixes: 0a2c19562ffe ('Revert "drm/amd/display: ignore modifiers when checking for format support"')
Signed-off-by: Aurabindo Pillai <aurabindo.pillai@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_display.c       | 3 +--
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 8 +++++++-
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
index 1a512d78673a..0f5bfe5df627 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
@@ -743,8 +743,7 @@ static int convert_tiling_flags_to_modifier(struct amdgpu_framebuffer *afb)
 			switch (version) {
 			case AMD_FMT_MOD_TILE_VER_GFX11:
 				pipe_xor_bits = min(block_size_bits - 8, pipes);
-				packers = min(block_size_bits - 8 - pipe_xor_bits,
-						ilog2(adev->gfx.config.gb_addr_config_fields.num_pkrs));
+				packers = ilog2(adev->gfx.config.gb_addr_config_fields.num_pkrs);
 				break;
 			case AMD_FMT_MOD_TILE_VER_GFX10_RBPLUS:
 				pipe_xor_bits = min(block_size_bits - 8, pipes);
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index c9145864ed2b..bea9cee37f65 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -5203,6 +5203,7 @@ add_gfx11_modifiers(struct amdgpu_device *adev,
 	int pkrs = 0;
 	u32 gb_addr_config;
 	unsigned swizzle_r_x;
+	uint64_t modifier_r_x_best;
 	uint64_t modifier_r_x;
 	uint64_t modifier_dcc_best;
 	uint64_t modifier_dcc_4k;
@@ -5223,10 +5224,12 @@ add_gfx11_modifiers(struct amdgpu_device *adev,
 
 	modifier_r_x = AMD_FMT_MOD |
 		AMD_FMT_MOD_SET(TILE_VERSION, AMD_FMT_MOD_TILE_VER_GFX11) |
-		AMD_FMT_MOD_SET(TILE, swizzle_r_x) |
 		AMD_FMT_MOD_SET(PIPE_XOR_BITS, pipe_xor_bits) |
 		AMD_FMT_MOD_SET(PACKERS, pkrs);
 
+	modifier_r_x_best = modifier_r_x | AMD_FMT_MOD_SET(TILE, AMD_FMT_MOD_TILE_GFX11_256K_R_X);
+	modifier_r_x = modifier_r_x | AMD_FMT_MOD_SET(TILE, AMD_FMT_MOD_TILE_GFX9_64K_R_X);
+
 	/* DCC_CONSTANT_ENCODE is not set because it can't vary with gfx11 (it's implied to be 1). */
 	modifier_dcc_best = modifier_r_x |
 		AMD_FMT_MOD_SET(DCC, 1) |
@@ -5247,6 +5250,9 @@ add_gfx11_modifiers(struct amdgpu_device *adev,
 	add_modifier(mods, size, capacity, modifier_dcc_best | AMD_FMT_MOD_SET(DCC_RETILE, 1));
 	add_modifier(mods, size, capacity, modifier_dcc_4k | AMD_FMT_MOD_SET(DCC_RETILE, 1));
 
+	if (num_pipes > 16)
+		add_modifier(mods, size, capacity, modifier_r_x_best);
+
 	add_modifier(mods, size, capacity, modifier_r_x);
 
 	add_modifier(mods, size, capacity, AMD_FMT_MOD |
-- 
2.36.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] drm/amd/display: expose additional modifier for DCN32/321
  2022-06-27 14:32 [PATCH] drm/amd/display: expose additional modifier for DCN32/321 Aurabindo Pillai
@ 2022-06-28 12:31 ` Marek Olšák
  0 siblings, 0 replies; 2+ messages in thread
From: Marek Olšák @ 2022-06-28 12:31 UTC (permalink / raw)
  To: Aurabindo Pillai
  Cc: Alex Deucher, Marek Olšák, Harry Wentland,
	amd-gfx mailing list, Bas Nieuwenhuizen

[-- Attachment #1: Type: text/plain, Size: 4511 bytes --]

This needs to be a loop inserting all 64K_R_X and all 256K_R_X modifiers.

If num_pipes > 16, insert 256K_R_X first, else insert 64K_R_X first. Insert
the other one after that. For example:

      for (unsigned i = 0; i < 2; i++) {

         unsigned swizzle_r_x;


         /* Insert the best one first. */

         if (num_pipes > 16)

            swizzle_r_x = !i ? AMD_FMT_MOD_TILE_GFX11_256K_R_X :
AMD_FMT_MOD_TILE_GFX9_64K_R_X;

         else

            swizzle_r_x = !i ? AMD_FMT_MOD_TILE_GFX9_64K_R_X :
AMD_FMT_MOD_TILE_GFX11_256K_R_X;


         uint64_t modifier_r_x = ...

         add_modifier(,,,

         add_modifier(,,,
         add_modifier(,,,
         add_modifier(,,,
         add_modifier(,,,
      }


Marek

On Mon, Jun 27, 2022 at 10:32 AM Aurabindo Pillai <aurabindo.pillai@amd.com>
wrote:

> [Why&How]
> Some userspace expect a backwards compatible modifier on DCN32/321. For
> hardware with num_pipes more than 16, we expose the most efficient
> modifier first. As a fall back method, we need to expose slightly
> inefficient
> modifier AMD_FMT_MOD_TILE_GFX9_64K_R_X after the best option.
>
> Also set the number of packers to fixed value as required per hardware
> documentation. This value is cached during hardware initialization and
> can be read through the base driver.
>
> Fixes: 0a2c19562ffe ('Revert "drm/amd/display: ignore modifiers when
> checking for format support"')
> Signed-off-by: Aurabindo Pillai <aurabindo.pillai@amd.com>
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_display.c       | 3 +--
>  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 8 +++++++-
>  2 files changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
> index 1a512d78673a..0f5bfe5df627 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
> @@ -743,8 +743,7 @@ static int convert_tiling_flags_to_modifier(struct
> amdgpu_framebuffer *afb)
>                         switch (version) {
>                         case AMD_FMT_MOD_TILE_VER_GFX11:
>                                 pipe_xor_bits = min(block_size_bits - 8,
> pipes);
> -                               packers = min(block_size_bits - 8 -
> pipe_xor_bits,
> -
>  ilog2(adev->gfx.config.gb_addr_config_fields.num_pkrs));
> +                               packers =
> ilog2(adev->gfx.config.gb_addr_config_fields.num_pkrs);
>                                 break;
>                         case AMD_FMT_MOD_TILE_VER_GFX10_RBPLUS:
>                                 pipe_xor_bits = min(block_size_bits - 8,
> pipes);
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> index c9145864ed2b..bea9cee37f65 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> @@ -5203,6 +5203,7 @@ add_gfx11_modifiers(struct amdgpu_device *adev,
>         int pkrs = 0;
>         u32 gb_addr_config;
>         unsigned swizzle_r_x;
> +       uint64_t modifier_r_x_best;
>         uint64_t modifier_r_x;
>         uint64_t modifier_dcc_best;
>         uint64_t modifier_dcc_4k;
> @@ -5223,10 +5224,12 @@ add_gfx11_modifiers(struct amdgpu_device *adev,
>
>         modifier_r_x = AMD_FMT_MOD |
>                 AMD_FMT_MOD_SET(TILE_VERSION, AMD_FMT_MOD_TILE_VER_GFX11) |
> -               AMD_FMT_MOD_SET(TILE, swizzle_r_x) |
>                 AMD_FMT_MOD_SET(PIPE_XOR_BITS, pipe_xor_bits) |
>                 AMD_FMT_MOD_SET(PACKERS, pkrs);
>
> +       modifier_r_x_best = modifier_r_x | AMD_FMT_MOD_SET(TILE,
> AMD_FMT_MOD_TILE_GFX11_256K_R_X);
> +       modifier_r_x = modifier_r_x | AMD_FMT_MOD_SET(TILE,
> AMD_FMT_MOD_TILE_GFX9_64K_R_X);
> +
>         /* DCC_CONSTANT_ENCODE is not set because it can't vary with gfx11
> (it's implied to be 1). */
>         modifier_dcc_best = modifier_r_x |
>                 AMD_FMT_MOD_SET(DCC, 1) |
> @@ -5247,6 +5250,9 @@ add_gfx11_modifiers(struct amdgpu_device *adev,
>         add_modifier(mods, size, capacity, modifier_dcc_best |
> AMD_FMT_MOD_SET(DCC_RETILE, 1));
>         add_modifier(mods, size, capacity, modifier_dcc_4k |
> AMD_FMT_MOD_SET(DCC_RETILE, 1));
>
> +       if (num_pipes > 16)
> +               add_modifier(mods, size, capacity, modifier_r_x_best);
> +
>         add_modifier(mods, size, capacity, modifier_r_x);
>
>         add_modifier(mods, size, capacity, AMD_FMT_MOD |
> --
> 2.36.1
>
>

[-- Attachment #2: Type: text/html, Size: 9927 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-06-28 12:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-27 14:32 [PATCH] drm/amd/display: expose additional modifier for DCN32/321 Aurabindo Pillai
2022-06-28 12:31 ` Marek Olšák

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.