<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, May 25, 2022 at 12:20 PM Alex Deucher <<a href="mailto:alexander.deucher@amd.com">alexander.deucher@amd.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">From: Aurabindo Pillai <<a href="mailto:aurabindo.pillai@amd.com" target="_blank">aurabindo.pillai@amd.com</a>><br>
<br>
GFX11 IP introduces new tiling mode. Various combinations of DCC<br>
settings are possible and the most preferred settings must be exposed<br>
for optimal use of the hardware.<br>
<br>
add_gfx11_modifiers() is based on recommendation from Marek for the<br>
preferred tiling modifier that are most efficient for the hardware.<br>
<br>
Signed-off-by: Aurabindo Pillai <<a href="mailto:aurabindo.pillai@amd.com" target="_blank">aurabindo.pillai@amd.com</a>><br>
Acked-by: Alex Deucher <<a href="mailto:alexander.deucher@amd.com" target="_blank">alexander.deucher@amd.com</a>><br>
Signed-off-by: Alex Deucher <<a href="mailto:alexander.deucher@amd.com" target="_blank">alexander.deucher@amd.com</a>><br>
---<br>
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 40 ++++++++--<br>
.../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 74 ++++++++++++++++++-<br>
include/uapi/drm/drm_fourcc.h | 2 +<br>
3 files changed, 108 insertions(+), 8 deletions(-)<br>
<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c<br>
index ec395fe427f2..a54081a89282 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c<br>
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c<br>
@@ -30,6 +30,9 @@<br>
#include "atom.h"<br>
#include "amdgpu_connectors.h"<br>
#include "amdgpu_display.h"<br>
+#include "soc15_common.h"<br>
+#include "gc/gc_11_0_0_offset.h"<br>
+#include "gc/gc_11_0_0_sh_mask.h"<br>
#include <asm/div64.h><br>
<br>
#include <linux/pci.h><br>
@@ -662,6 +665,11 @@ static int convert_tiling_flags_to_modifier(struct amdgpu_framebuffer *afb)<br>
{<br>
struct amdgpu_device *adev = drm_to_adev(afb-><a href="http://base.dev" rel="noreferrer" target="_blank">base.dev</a>);<br>
uint64_t modifier = 0;<br>
+ int num_pipes = 0;<br>
+ int num_pkrs = 0;<br>
+<br>
+ num_pkrs = adev->gfx.config.gb_addr_config_fields.num_pkrs;<br>
+ num_pipes = adev->gfx.config.gb_addr_config_fields.num_pipes;<br>
<br>
if (!afb->tiling_flags || !AMDGPU_TILING_GET(afb->tiling_flags, SWIZZLE_MODE)) {<br>
modifier = DRM_FORMAT_MOD_LINEAR;<br>
@@ -674,7 +682,7 @@ static int convert_tiling_flags_to_modifier(struct amdgpu_framebuffer *afb)<br>
int bank_xor_bits = 0;<br>
int packers = 0;<br>
int rb = 0;<br>
- int pipes = ilog2(adev->gfx.config.gb_addr_config_fields.num_pipes);<br>
+ int pipes = ilog2(num_pipes);<br>
uint32_t dcc_offset = AMDGPU_TILING_GET(afb->tiling_flags, DCC_OFFSET_256B);<br>
<br>
switch (swizzle >> 2) {<br>
@@ -690,12 +698,17 @@ static int convert_tiling_flags_to_modifier(struct amdgpu_framebuffer *afb)<br>
case 6: /* 64 KiB _X */<br>
block_size_bits = 16;<br>
break;<br>
+ case 7: /* 256 KiB */<br>
+ block_size_bits = 18;<br>
+ break;<br>
default:<br>
/* RESERVED or VAR */<br>
return -EINVAL;<br>
}<br>
<br>
- if (adev->ip_versions[GC_HWIP][0] >= IP_VERSION(10, 3, 0))<br>
+ if (adev->ip_versions[GC_HWIP][0] >= IP_VERSION(11, 0, 0))<br>
+ version = AMD_FMT_MOD_TILE_VER_GFX11;<br>
+ else if (adev->ip_versions[GC_HWIP][0] >= IP_VERSION(10, 3, 0))<br>
version = AMD_FMT_MOD_TILE_VER_GFX10_RBPLUS;<br>
else if (adev->ip_versions[GC_HWIP][0] >= IP_VERSION(10, 0, 0))<br>
version = AMD_FMT_MOD_TILE_VER_GFX10;<br>
@@ -718,7 +731,17 @@ static int convert_tiling_flags_to_modifier(struct amdgpu_framebuffer *afb)<br>
}<br></blockquote><div><br></div><div>The switch statement right above this that is not in this patch and changes "version" should be skipped on >= gfx11. Under no circumstances should the version be changed on gfx11.<br></div><div><br></div><div>Marek<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
if (has_xor) {<br>
+ if (num_pipes == num_pkrs && num_pkrs == 0) {<br>
+ DRM_ERROR("invalid number of pipes and packers\n");<br>
+ return -EINVAL;<br>
+ }<br>
+<br>
switch (version) {<br>
+ case AMD_FMT_MOD_TILE_VER_GFX11:<br>
+ pipe_xor_bits = min(block_size_bits - 8, pipes);<br>
+ packers = min(block_size_bits - 8 - pipe_xor_bits,<br>
+ ilog2(adev->gfx.config.gb_addr_config_fields.num_pkrs));<br>
+ break;<br>
case AMD_FMT_MOD_TILE_VER_GFX10_RBPLUS:<br>
pipe_xor_bits = min(block_size_bits - 8, pipes);<br>
packers = min(block_size_bits - 8 - pipe_xor_bits,<br>
@@ -752,9 +775,10 @@ static int convert_tiling_flags_to_modifier(struct amdgpu_framebuffer *afb)<br>
u64 render_dcc_offset;<br>
<br>
/* Enable constant encode on RAVEN2 and later. */<br>
- bool dcc_constant_encode = adev->asic_type > CHIP_RAVEN ||<br>
+ bool dcc_constant_encode = (adev->asic_type > CHIP_RAVEN ||<br>
(adev->asic_type == CHIP_RAVEN &&<br>
- adev->external_rev_id >= 0x81);<br>
+ adev->external_rev_id >= 0x81)) &&<br>
+ adev->ip_versions[GC_HWIP][0] < IP_VERSION(11, 0, 0);<br>
<br>
int max_cblock_size = dcc_i64b ? AMD_FMT_MOD_DCC_BLOCK_64B :<br>
dcc_i128b ? AMD_FMT_MOD_DCC_BLOCK_128B :<br>
@@ -869,10 +893,11 @@ static unsigned int get_dcc_block_size(uint64_t modifier, bool rb_aligned,<br>
return max(10 + (rb_aligned ? (int)AMD_FMT_MOD_GET(RB, modifier) : 0), 12);<br>
}<br>
case AMD_FMT_MOD_TILE_VER_GFX10:<br>
- case AMD_FMT_MOD_TILE_VER_GFX10_RBPLUS: {<br>
+ case AMD_FMT_MOD_TILE_VER_GFX10_RBPLUS:<br>
+ case AMD_FMT_MOD_TILE_VER_GFX11: {<br>
int pipes_log2 = AMD_FMT_MOD_GET(PIPE_XOR_BITS, modifier);<br>
<br>
- if (ver == AMD_FMT_MOD_TILE_VER_GFX10_RBPLUS && pipes_log2 > 1 &&<br>
+ if (ver >= AMD_FMT_MOD_TILE_VER_GFX10_RBPLUS && pipes_log2 > 1 &&<br>
AMD_FMT_MOD_GET(PACKERS, modifier) == pipes_log2)<br>
++pipes_log2;<br>
<br>
@@ -965,6 +990,9 @@ static int amdgpu_display_verify_sizes(struct amdgpu_framebuffer *rfb)<br>
case DC_SW_64KB_S_X:<br>
block_size_log2 = 16;<br>
break;<br>
+ case DC_SW_VAR_S_X:<br>
+ block_size_log2 = 18;<br>
+ break;<br>
default:<br>
drm_dbg_kms(rfb-><a href="http://base.dev" rel="noreferrer" target="_blank">base.dev</a>,<br>
"Swizzle mode with unknown block size: %d\n", swizzle);<br>
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c<br>
index a93affc37c53..badd136f5686 100644<br>
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c<br>
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c<br>
@@ -88,10 +88,14 @@<br>
#include "dcn/dcn_1_0_offset.h"<br>
#include "dcn/dcn_1_0_sh_mask.h"<br>
#include "soc15_hw_ip.h"<br>
+#include "soc15_common.h"<br>
#include "vega10_ip_offset.h"<br>
<br>
#include "soc15_common.h"<br>
<br>
+#include "gc/gc_11_0_0_offset.h"<br>
+#include "gc/gc_11_0_0_sh_mask.h"<br>
+<br>
#include "modules/inc/mod_freesync.h"<br>
#include "modules/power/power_helpers.h"<br>
#include "modules/inc/mod_info_packet.h"<br>
@@ -4885,7 +4889,9 @@ fill_gfx9_tiling_info_from_modifier(const struct amdgpu_device *adev,<br>
unsigned int mod_bank_xor_bits = AMD_FMT_MOD_GET(BANK_XOR_BITS, modifier);<br>
unsigned int mod_pipe_xor_bits = AMD_FMT_MOD_GET(PIPE_XOR_BITS, modifier);<br>
unsigned int pkrs_log2 = AMD_FMT_MOD_GET(PACKERS, modifier);<br>
- unsigned int pipes_log2 = min(4u, mod_pipe_xor_bits);<br>
+ unsigned int pipes_log2;<br>
+<br>
+ pipes_log2 = min(5u, mod_pipe_xor_bits);<br>
<br>
fill_gfx9_tiling_info_from_device(adev, tiling_info);<br>
<br>
@@ -5221,6 +5227,67 @@ add_gfx10_3_modifiers(const struct amdgpu_device *adev,<br>
AMD_FMT_MOD_SET(TILE_VERSION, AMD_FMT_MOD_TILE_VER_GFX9));<br>
}<br>
<br>
+static void<br>
+add_gfx11_modifiers(const struct amdgpu_device *adev,<br>
+ uint64_t **mods, uint64_t *size, uint64_t *capacity)<br>
+{<br>
+ int num_pipes = 0;<br>
+ int pipe_xor_bits = 0;<br>
+ int num_pkrs = 0;<br>
+ int pkrs = 0;<br>
+ u32 gb_addr_config;<br>
+ unsigned swizzle_r_x;<br>
+ uint64_t modifier_r_x;<br>
+ uint64_t modifier_dcc_best;<br>
+ uint64_t modifier_dcc_4k;<br>
+<br>
+ /* TODO: GFX11 IP HW init hasnt finish and we get zero if we read from<br>
+ * adev->gfx.config.gb_addr_config_fields.num_{pkrs,pipes} */<br>
+ gb_addr_config = RREG32_SOC15(GC, 0, regGB_ADDR_CONFIG);<br>
+ ASSERT(gb_addr_config != 0);<br>
+<br>
+ num_pkrs = 1 << REG_GET_FIELD(gb_addr_config, GB_ADDR_CONFIG, NUM_PKRS);<br>
+ pkrs = ilog2(num_pkrs);<br>
+ num_pipes = 1 << REG_GET_FIELD(gb_addr_config, GB_ADDR_CONFIG, NUM_PIPES);<br>
+ pipe_xor_bits = ilog2(num_pipes);<br>
+<br>
+ /* R_X swizzle modes are the best for rendering and DCC requires them. */<br>
+ swizzle_r_x = num_pipes > 16 ? AMD_FMT_MOD_TILE_GFX11_256K_R_X :<br>
+ AMD_FMT_MOD_TILE_GFX9_64K_R_X;<br>
+<br>
+ modifier_r_x = AMD_FMT_MOD |<br>
+ AMD_FMT_MOD_SET(TILE_VERSION, AMD_FMT_MOD_TILE_VER_GFX11) |<br>
+ AMD_FMT_MOD_SET(TILE, swizzle_r_x) |<br>
+ AMD_FMT_MOD_SET(PIPE_XOR_BITS, pipe_xor_bits) |<br>
+ AMD_FMT_MOD_SET(PACKERS, pkrs);<br>
+<br>
+ /* DCC_CONSTANT_ENCODE is not set because it can't vary with gfx11 (it's implied to be 1). */<br>
+ modifier_dcc_best = modifier_r_x |<br>
+ AMD_FMT_MOD_SET(DCC, 1) |<br>
+ AMD_FMT_MOD_SET(DCC_INDEPENDENT_64B, 0) |<br>
+ AMD_FMT_MOD_SET(DCC_INDEPENDENT_128B, 1) |<br>
+ AMD_FMT_MOD_SET(DCC_MAX_COMPRESSED_BLOCK, AMD_FMT_MOD_DCC_BLOCK_128B);<br>
+<br>
+ /* DCC settings for 4K and greater resolutions. (required by display hw) */<br>
+ modifier_dcc_4k = modifier_r_x |<br>
+ AMD_FMT_MOD_SET(DCC, 1) |<br>
+ AMD_FMT_MOD_SET(DCC_INDEPENDENT_64B, 1) |<br>
+ AMD_FMT_MOD_SET(DCC_INDEPENDENT_128B, 1) |<br>
+ AMD_FMT_MOD_SET(DCC_MAX_COMPRESSED_BLOCK, AMD_FMT_MOD_DCC_BLOCK_64B);<br>
+<br>
+ add_modifier(mods, size, capacity, modifier_dcc_best);<br>
+ add_modifier(mods, size, capacity, modifier_dcc_4k);<br>
+<br>
+ add_modifier(mods, size, capacity, modifier_dcc_best | AMD_FMT_MOD_SET(DCC_RETILE, 1));<br>
+ add_modifier(mods, size, capacity, modifier_dcc_4k | AMD_FMT_MOD_SET(DCC_RETILE, 1));<br>
+<br>
+ add_modifier(mods, size, capacity, modifier_r_x);<br>
+<br>
+ add_modifier(mods, size, capacity, AMD_FMT_MOD |<br>
+ AMD_FMT_MOD_SET(TILE_VERSION, AMD_FMT_MOD_TILE_VER_GFX11) |<br>
+ AMD_FMT_MOD_SET(TILE, AMD_FMT_MOD_TILE_GFX9_64K_D));<br>
+}<br>
+<br>
static int<br>
get_plane_modifiers(const struct amdgpu_device *adev, unsigned int plane_type, uint64_t **mods)<br>
{<br>
@@ -5254,6 +5321,9 @@ get_plane_modifiers(const struct amdgpu_device *adev, unsigned int plane_type, u<br>
else<br>
add_gfx10_1_modifiers(adev, mods, &size, &capacity);<br>
break;<br>
+ case AMDGPU_FAMILY_GC_11_0_0:<br>
+ add_gfx11_modifiers(adev, mods, &size, &capacity);<br>
+ break;<br>
}<br>
<br>
add_modifier(mods, &size, &capacity, DRM_FORMAT_MOD_LINEAR);<br>
@@ -5292,7 +5362,7 @@ fill_gfx9_plane_attributes_from_modifiers(struct amdgpu_device *adev,<br>
dcc->enable = 1;<br>
dcc->meta_pitch = afb->base.pitches[1];<br>
dcc->independent_64b_blks = independent_64b_blks;<br>
- if (AMD_FMT_MOD_GET(TILE_VERSION, modifier) == AMD_FMT_MOD_TILE_VER_GFX10_RBPLUS) {<br>
+ if (AMD_FMT_MOD_GET(TILE_VERSION, modifier) >= AMD_FMT_MOD_TILE_VER_GFX10_RBPLUS) {<br>
if (independent_64b_blks && independent_128b_blks)<br>
dcc->dcc_ind_blk = hubp_ind_block_64b_no_128bcl;<br>
else if (independent_128b_blks)<br>
diff --git a/include/uapi/drm/drm_fourcc.h b/include/uapi/drm/drm_fourcc.h<br>
index fc0c1454d275..14cb2dafb0fa 100644<br>
--- a/include/uapi/drm/drm_fourcc.h<br>
+++ b/include/uapi/drm/drm_fourcc.h<br>
@@ -1294,6 +1294,7 @@ drm_fourcc_canonicalize_nvidia_format_mod(__u64 modifier)<br>
#define AMD_FMT_MOD_TILE_VER_GFX9 1<br>
#define AMD_FMT_MOD_TILE_VER_GFX10 2<br>
#define AMD_FMT_MOD_TILE_VER_GFX10_RBPLUS 3<br>
+#define AMD_FMT_MOD_TILE_VER_GFX11 4<br>
<br>
/*<br>
* 64K_S is the same for GFX9/GFX10/GFX10_RBPLUS and hence has GFX9 as canonical<br>
@@ -1309,6 +1310,7 @@ drm_fourcc_canonicalize_nvidia_format_mod(__u64 modifier)<br>
#define AMD_FMT_MOD_TILE_GFX9_64K_S_X 25<br>
#define AMD_FMT_MOD_TILE_GFX9_64K_D_X 26<br>
#define AMD_FMT_MOD_TILE_GFX9_64K_R_X 27<br>
+#define AMD_FMT_MOD_TILE_GFX11_256K_R_X 31<br>
<br>
#define AMD_FMT_MOD_DCC_BLOCK_64B 0<br>
#define AMD_FMT_MOD_DCC_BLOCK_128B 1<br>
-- <br>
2.35.3<br>
<br>
</blockquote></div></div>