From: "Marek Olšák" <maraeo@gmail.com>
To: amd-gfx@lists.freedesktop.org
Cc: "Marek Olšák" <marek.olsak@amd.com>
Subject: [PATCH 13/13] drm/amdgpu: rewrite convert_tiling_flags_to_modifier_gfx12
Date: Wed, 26 Jun 2024 14:31:35 -0400 [thread overview]
Message-ID: <20240626183135.8606-13-marek.olsak@amd.com> (raw)
In-Reply-To: <20240626183135.8606-1-marek.olsak@amd.com>
There were multiple bugs, like checking SWIZZLE_MODE before checking
GFX12_SWIZZLE_MODE, which has undefined behavior.
The function had no effect before (it always returned -EINVAL).
Signed-off-by: Marek Olšák <marek.olsak@amd.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 45 +++++++++------------
1 file changed, 18 insertions(+), 27 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
index ec0299c5918e..092ec11258cd 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
@@ -724,32 +724,25 @@ extract_render_dcc_offset(struct amdgpu_device *adev,
static int convert_tiling_flags_to_modifier_gfx12(struct amdgpu_framebuffer *afb)
{
- struct amdgpu_device *adev = drm_to_adev(afb->base.dev);
- const struct drm_format_info *format_info;
u64 modifier = 0;
- int tile = 0;
- int swizzle = 0;
+ int swizzle_mode = AMDGPU_TILING_GET(afb->tiling_flags, GFX12_SWIZZLE_MODE);
- if (amdgpu_ip_version(adev, GC_HWIP, 0) >= IP_VERSION(12, 0, 0)) {
- tile = AMD_FMT_MOD_TILE_VER_GFX12;
- swizzle = AMDGPU_TILING_GET(afb->tiling_flags, GFX12_SWIZZLE_MODE);
+ if (!swizzle_mode) {
+ modifier = DRM_FORMAT_MOD_LINEAR;
+ } else {
+ int max_comp_block =
+ AMDGPU_TILING_GET(afb->tiling_flags, GFX12_DCC_MAX_COMPRESSED_BLOCK);
+
+ modifier =
+ AMD_FMT_MOD |
+ AMD_FMT_MOD_SET(TILE_VERSION, AMD_FMT_MOD_TILE_VER_GFX12) |
+ AMD_FMT_MOD_SET(TILE, swizzle_mode) |
+ AMD_FMT_MOD_SET(DCC, afb->gfx12_dcc) |
+ AMD_FMT_MOD_SET(DCC_MAX_COMPRESSED_BLOCK, max_comp_block);
}
- modifier =
- AMD_FMT_MOD |
- AMD_FMT_MOD_SET(TILE, swizzle) |
- AMD_FMT_MOD_SET(TILE_VERSION, tile) |
- AMD_FMT_MOD_SET(DCC, 0) |
- AMD_FMT_MOD_SET(DCC_MAX_COMPRESSED_BLOCK, 0);
-
- format_info = amdgpu_lookup_format_info(afb->base.format->format,
- modifier);
- if (!format_info)
- return -EINVAL;
-
afb->base.modifier = modifier;
afb->base.flags |= DRM_MODE_FB_MODIFIERS;
-
return 0;
}
@@ -777,12 +770,6 @@ static int convert_tiling_flags_to_modifier(struct amdgpu_framebuffer *afb)
int pipes = ilog2(num_pipes);
uint32_t dcc_offset = AMDGPU_TILING_GET(afb->tiling_flags, DCC_OFFSET_256B);
-
- if (amdgpu_ip_version(adev, GC_HWIP, 0) >= IP_VERSION(12, 0, 0)) {
- convert_tiling_flags_to_modifier_gfx12(afb);
- return 0;
- }
-
switch (swizzle >> 2) {
case 0: /* 256B */
block_size_bits = 8;
@@ -1281,7 +1268,11 @@ static int amdgpu_display_framebuffer_init(struct drm_device *dev,
if (!dev->mode_config.fb_modifiers_not_supported &&
!(rfb->base.flags & DRM_MODE_FB_MODIFIERS)) {
- ret = convert_tiling_flags_to_modifier(rfb);
+ if (amdgpu_ip_version(adev, GC_HWIP, 0) >= IP_VERSION(12, 0, 0))
+ ret = convert_tiling_flags_to_modifier_gfx12(rfb);
+ else
+ ret = convert_tiling_flags_to_modifier(rfb);
+
if (ret) {
drm_dbg_kms(dev, "Failed to convert tiling flags 0x%llX to a modifier",
rfb->tiling_flags);
--
2.34.1
next prev parent reply other threads:[~2024-06-26 18:32 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-26 18:31 [PATCH 01/13] drm/amdgpu: check for LINEAR_ALIGNED correctly in check_tiling_flags_gfx6 Marek Olšák
2024-06-26 18:31 ` [PATCH 02/13] drm/amdgpu/gfx11: remove superfluous cache flags Marek Olšák
2024-06-26 18:31 ` [PATCH 03/13] drm/amdgpu/gfx12: " Marek Olšák
2024-06-26 18:31 ` [PATCH 04/13] drm/amdgpu/gfx12: remove GDS leftovers Marek Olšák
2024-06-26 18:31 ` [PATCH 05/13] drm/amdgpu: remove AMD_FMT_MOD_GFX12_DCC_MAX_COMPRESSED_BLOCK_* definitions Marek Olšák
2024-06-26 20:21 ` Aurabindo Pillai
2024-06-26 18:31 ` [PATCH 06/13] drm/amdgpu/display: handle gfx12 in dm_check_cursor_fb Marek Olšák
2024-06-26 20:16 ` Aurabindo Pillai
2024-06-26 18:31 ` [PATCH 07/13] drm/amdgpu: add amdgpu_framebuffer::gfx12_dcc Marek Olšák
2024-06-26 20:51 ` Alex Deucher
2024-06-26 18:31 ` [PATCH 08/13] drm/amdgpu: don't use amdgpu_lookup_format_info on gfx12 Marek Olšák
2024-06-26 18:31 ` [PATCH 09/13] drm/amdgpu: handle gfx12 in amdgpu_display_verify_sizes Marek Olšák
2024-06-26 18:31 ` [PATCH 10/13] drm/amdgpu/display: handle gfx12 in amdgpu_dm_plane_format_mod_supported Marek Olšák
2024-06-26 20:16 ` Aurabindo Pillai
2024-06-26 18:31 ` [PATCH 11/13] drm/amdgpu/display: set plane attributes for gfx12 correctly Marek Olšák
2024-06-26 20:19 ` Aurabindo Pillai
2024-06-26 18:31 ` [PATCH 12/13] drm/amdgpu/display: add all gfx12 modifiers Marek Olšák
2024-06-26 20:20 ` Aurabindo Pillai
2024-06-26 18:31 ` Marek Olšák [this message]
2024-06-26 20:20 ` [PATCH 13/13] drm/amdgpu: rewrite convert_tiling_flags_to_modifier_gfx12 Aurabindo Pillai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240626183135.8606-13-marek.olsak@amd.com \
--to=maraeo@gmail.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=marek.olsak@amd.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox