From: Wayne Lin <Wayne.Lin@amd.com>
To: <amd-gfx@lists.freedesktop.org>
Cc: <Harry.Wentland@amd.com>, <Sunpeng.Li@amd.com>,
<Rodrigo.Siqueira@amd.com>, <Aurabindo.Pillai@amd.com>,
<roman.li@amd.com>, <wayne.lin@amd.com>,
<agustin.gutierrez@amd.com>, <chiahsuan.chung@amd.com>,
<hersenxs.wu@amd.com>, <jerry.zuo@amd.com>,
Harry Wentland <harry.wentland@amd.com>
Subject: [PATCH 01/46] drm/amd/display: Do cursor programming with rest of pipe
Date: Wed, 24 Apr 2024 16:48:46 +0800 [thread overview]
Message-ID: <20240424084931.2656128-2-Wayne.Lin@amd.com> (raw)
In-Reply-To: <20240424084931.2656128-1-Wayne.Lin@amd.com>
From: Harry Wentland <harry.wentland@amd.com>
Cursors are always programmed independently of updates on other
planes. When atomic commits program cursor and surface updates
together the cursor update might be locked out by the surface
update and not take effect.
To combat this program cursor and surface updates together via
dc_update_planes_and_stream to ensure they can be applied
atomically.
When cursor updates come on their own use the old method
to program the cursor as dc_update_planes_and_stream isn't
handling this case correctly (yet), leading to a flickering
screen.
Closes: https://gitlab.freedesktop.org/drm/amd/-/issues/2186
Reviewed-by: Agustin Gutierrez <agustin.gutierrez@amd.com>
Acked-by: Wayne Lin <wayne.lin@amd.com>
Signed-off-by: Harry Wentland <harry.wentland@amd.com>
---
.../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 79 ++++++++++++++++++-
.../amd/display/amdgpu_dm/amdgpu_dm_plane.c | 4 +-
.../amd/display/amdgpu_dm/amdgpu_dm_plane.h | 3 +
drivers/gpu/drm/amd/display/dc/core/dc.c | 5 ++
.../gpu/drm/amd/display/dc/core/dc_stream.c | 14 ++--
drivers/gpu/drm/amd/display/dc/dc_stream.h | 12 +++
6 files changed, 105 insertions(+), 12 deletions(-)
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 7481440ab124..75b65b243f1e 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -8365,6 +8365,77 @@ static inline uint32_t get_mem_type(struct drm_framebuffer *fb)
return abo->tbo.resource ? abo->tbo.resource->mem_type : 0;
}
+static void amdgpu_dm_update_cursor(struct drm_plane *plane,
+ struct drm_plane_state *old_plane_state,
+ struct dc_stream_update *update)
+{
+ struct amdgpu_device *adev = drm_to_adev(plane->dev);
+ struct amdgpu_framebuffer *afb = to_amdgpu_framebuffer(plane->state->fb);
+ struct drm_crtc *crtc = afb ? plane->state->crtc : old_plane_state->crtc;
+ struct dm_crtc_state *crtc_state = crtc ? to_dm_crtc_state(crtc->state) : NULL;
+ struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
+ uint64_t address = afb ? afb->address : 0;
+ struct dc_cursor_position position = {0};
+ struct dc_cursor_attributes attributes;
+ int ret;
+
+ if (!plane->state->fb && !old_plane_state->fb)
+ return;
+
+ drm_dbg_atomic(plane->dev, "crtc_id=%d with size %d to %d\n",
+ amdgpu_crtc->crtc_id, plane->state->crtc_w,
+ plane->state->crtc_h);
+
+ ret = amdgpu_dm_plane_get_cursor_position(plane, crtc, &position);
+ if (ret)
+ return;
+
+ if (!position.enable) {
+ /* turn off cursor */
+ if (crtc_state && crtc_state->stream) {
+ dc_stream_set_cursor_position(crtc_state->stream,
+ &position);
+ update->cursor_position = &crtc_state->stream->cursor_position;
+ }
+ return;
+ }
+
+ amdgpu_crtc->cursor_width = plane->state->crtc_w;
+ amdgpu_crtc->cursor_height = plane->state->crtc_h;
+
+ memset(&attributes, 0, sizeof(attributes));
+ attributes.address.high_part = upper_32_bits(address);
+ attributes.address.low_part = lower_32_bits(address);
+ attributes.width = plane->state->crtc_w;
+ attributes.height = plane->state->crtc_h;
+ attributes.color_format = CURSOR_MODE_COLOR_PRE_MULTIPLIED_ALPHA;
+ attributes.rotation_angle = 0;
+ attributes.attribute_flags.value = 0;
+
+ /* Enable cursor degamma ROM on DCN3+ for implicit sRGB degamma in DRM
+ * legacy gamma setup.
+ */
+ if (crtc_state->cm_is_degamma_srgb &&
+ adev->dm.dc->caps.color.dpp.gamma_corr)
+ attributes.attribute_flags.bits.ENABLE_CURSOR_DEGAMMA = 1;
+
+ attributes.pitch = afb->base.pitches[0] / afb->base.format->cpp[0];
+
+ if (crtc_state->stream) {
+ if (!dc_stream_set_cursor_attributes(crtc_state->stream,
+ &attributes))
+ DRM_ERROR("DC failed to set cursor attributes\n");
+
+ update->cursor_attributes = &crtc_state->stream->cursor_attributes;
+
+ if (!dc_stream_set_cursor_position(crtc_state->stream,
+ &position))
+ DRM_ERROR("DC failed to set cursor position\n");
+
+ update->cursor_position = &crtc_state->stream->cursor_position;
+ }
+}
+
static void amdgpu_dm_commit_planes(struct drm_atomic_state *state,
struct drm_device *dev,
struct amdgpu_display_manager *dm,
@@ -8388,6 +8459,7 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state,
bool cursor_update = false;
bool pflip_present = false;
bool dirty_rects_changed = false;
+ bool updated_planes_and_streams = false;
struct {
struct dc_surface_update surface_updates[MAX_SURFACES];
struct dc_plane_info plane_infos[MAX_SURFACES];
@@ -8424,8 +8496,10 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state,
/* Cursor plane is handled after stream updates */
if (plane->type == DRM_PLANE_TYPE_CURSOR) {
if ((fb && crtc == pcrtc) ||
- (old_plane_state->fb && old_plane_state->crtc == pcrtc))
+ (old_plane_state->fb && old_plane_state->crtc == pcrtc)) {
cursor_update = true;
+ amdgpu_dm_update_cursor(plane, old_plane_state, &bundle->stream_update);
+ }
continue;
}
@@ -8698,6 +8772,7 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state,
acrtc_state->stream,
&bundle->stream_update,
bundle->surface_updates);
+ updated_planes_and_streams = true;
/**
* Enable or disable the interrupts on the backend.
@@ -8775,7 +8850,7 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state,
* This avoids redundant programming in the case where we're going
* to be disabling a single plane - those pipes are being disabled.
*/
- if (acrtc_state->active_planes)
+ if (acrtc_state->active_planes && !updated_planes_and_streams)
amdgpu_dm_commit_cursors(state);
cleanup:
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c
index 3c03f690852c..a64f20fcddaa 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c
@@ -1197,8 +1197,8 @@ static int amdgpu_dm_plane_atomic_async_check(struct drm_plane *plane,
return 0;
}
-static int amdgpu_dm_plane_get_cursor_position(struct drm_plane *plane, struct drm_crtc *crtc,
- struct dc_cursor_position *position)
+int amdgpu_dm_plane_get_cursor_position(struct drm_plane *plane, struct drm_crtc *crtc,
+ struct dc_cursor_position *position)
{
struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
int x, y;
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.h b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.h
index b51a6b57bd9b..6498359bff6f 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.h
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.h
@@ -29,6 +29,9 @@
#include "dc.h"
+int amdgpu_dm_plane_get_cursor_position(struct drm_plane *plane, struct drm_crtc *crtc,
+ struct dc_cursor_position *position);
+
void amdgpu_dm_plane_handle_cursor_update(struct drm_plane *plane,
struct drm_plane_state *old_plane_state);
diff --git a/drivers/gpu/drm/amd/display/dc/core/dc.c b/drivers/gpu/drm/amd/display/dc/core/dc.c
index 3e16041bf4f9..e955c97697ff 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc.c
@@ -3340,6 +3340,11 @@ static void commit_planes_do_stream_update(struct dc *dc,
}
}
+ if (stream_update->cursor_attributes)
+ program_cursor_attributes(dc, stream);
+
+ if (stream_update->cursor_position)
+ program_cursor_position(dc, stream);
/* Full fe update*/
if (update_type == UPDATE_TYPE_FAST)
diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_stream.c b/drivers/gpu/drm/amd/display/dc/core/dc_stream.c
index 3ac1fec4bf53..b5a89b587d86 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_stream.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_stream.c
@@ -219,10 +219,9 @@ struct dc_stream_status *dc_stream_get_status(
return dc_state_get_stream_status(dc->current_state, stream);
}
-static void program_cursor_attributes(
+void program_cursor_attributes(
struct dc *dc,
- struct dc_stream_state *stream,
- const struct dc_cursor_attributes *attributes)
+ struct dc_stream_state *stream)
{
int i;
struct resource_context *res_ctx;
@@ -318,7 +317,7 @@ bool dc_stream_program_cursor_attributes(
reset_idle_optimizations = true;
}
- program_cursor_attributes(dc, stream, attributes);
+ program_cursor_attributes(dc, stream);
/* re-enable idle optimizations if necessary */
if (reset_idle_optimizations && !dc->debug.disable_dmub_reallow_idle)
@@ -330,10 +329,9 @@ bool dc_stream_program_cursor_attributes(
return false;
}
-static void program_cursor_position(
+void program_cursor_position(
struct dc *dc,
- struct dc_stream_state *stream,
- const struct dc_cursor_position *position)
+ struct dc_stream_state *stream)
{
int i;
struct resource_context *res_ctx;
@@ -410,7 +408,7 @@ bool dc_stream_program_cursor_position(
reset_idle_optimizations = true;
}
- program_cursor_position(dc, stream, position);
+ program_cursor_position(dc, stream);
/* re-enable idle optimizations if necessary */
if (reset_idle_optimizations && !dc->debug.disable_dmub_reallow_idle)
dc_allow_idle_optimizations(dc, true);
diff --git a/drivers/gpu/drm/amd/display/dc/dc_stream.h b/drivers/gpu/drm/amd/display/dc/dc_stream.h
index 8dd65a95d84b..1469a20f2511 100644
--- a/drivers/gpu/drm/amd/display/dc/dc_stream.h
+++ b/drivers/gpu/drm/amd/display/dc/dc_stream.h
@@ -341,6 +341,9 @@ struct dc_stream_update {
struct test_pattern *pending_test_pattern;
struct dc_crtc_timing_adjust *crtc_timing_adjust;
+
+ struct dc_cursor_attributes *cursor_attributes;
+ struct dc_cursor_position *cursor_position;
};
bool dc_is_stream_unchanged(
@@ -480,6 +483,15 @@ struct dc_stream_status *dc_stream_get_status(
* Cursor interfaces - To manages the cursor within a stream
******************************************************************************/
/* TODO: Deprecated once we switch to dc_set_cursor_position */
+
+void program_cursor_attributes(
+ struct dc *dc,
+ struct dc_stream_state *stream);
+
+void program_cursor_position(
+ struct dc *dc,
+ struct dc_stream_state *stream);
+
bool dc_stream_set_cursor_attributes(
struct dc_stream_state *stream,
const struct dc_cursor_attributes *attributes);
--
2.37.3
next prev parent reply other threads:[~2024-04-24 8:50 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-24 8:48 [PATCH 00/46] DC Patches April 29, 2024 Wayne Lin
2024-04-24 8:48 ` Wayne Lin [this message]
2024-04-24 8:48 ` [PATCH 02/46] drm/amd/display: Always use legacy way of setting cursor on DCE Wayne Lin
2024-04-24 8:48 ` [PATCH 03/46] drm/amd/display: Add NULL pointer check for kzalloc Wayne Lin
2024-04-24 8:48 ` [PATCH 04/46] drm/amd/display: Check index msg_id before read or write Wayne Lin
2024-04-24 8:48 ` [PATCH 05/46] drm/amd/display: Check pipe offset before setting vblank Wayne Lin
2024-04-24 8:48 ` [PATCH 06/46] drm/amd/display: Skip finding free audio for unknown engine_id Wayne Lin
2024-04-24 8:48 ` [PATCH 07/46] drm/amd/display: Fix overlapping copy within dml_core_mode_programming Wayne Lin
2024-04-24 8:48 ` [PATCH 08/46] drm/amd/display: Do not return negative stream id for array Wayne Lin
2024-04-24 8:48 ` [PATCH 09/46] drm/amd/display: ASSERT when failing to find index by plane/stream id Wayne Lin
2024-04-24 8:48 ` [PATCH 10/46] drm/amd/display: Remove unnecessary files Wayne Lin
2024-04-24 8:48 ` [PATCH 11/46] drm/amd/display: Improve registers write Wayne Lin
2024-04-24 8:48 ` [PATCH 12/46] drm/amd/display: Add missing SMU version Wayne Lin
2024-04-24 8:48 ` [PATCH 13/46] drm/amd/display: Adjust codestyle for dcn31 and hdcp_msg Wayne Lin
2024-04-24 8:48 ` [PATCH 14/46] drm/amd/display: Add VCO speed parameter for DCN31 FPU Wayne Lin
2024-04-24 8:49 ` [PATCH 15/46] drm/amd/display: Adjust functions prefix for some of the dcn301 fpu functions Wayne Lin
2024-04-24 8:49 ` [PATCH 16/46] drm/amd/display: Enable legacy fast update for dcn301 Wayne Lin
2024-04-24 8:49 ` [PATCH 17/46] drm/amd/display: Update some of the dcn303 parameters Wayne Lin
2024-04-24 8:49 ` [PATCH 18/46] drm/amd/display: Remove legacy code in DC Wayne Lin
2024-04-24 8:49 ` [PATCH 19/46] drm/amd/display: Add log_color_state callback to multiple DCNs Wayne Lin
2024-04-24 8:49 ` [PATCH 20/46] drm/amd/display: Handle the case which quad_part is equal 0 Wayne Lin
2024-04-24 8:49 ` [PATCH 21/46] drm/amd/display: Refactor for Replay Link off frame count Wayne Lin
2024-04-24 8:49 ` [PATCH 22/46] drm/amd/display: Restrict multi-disp support for in-game FAMS Wayne Lin
2024-04-24 8:49 ` [PATCH 23/46] drm/amd/display: Defer handling mst up request in resume Wayne Lin
2024-04-24 8:49 ` [PATCH 24/46] drm/amd/display: Fix DC mode screen flickering on DCN321 Wayne Lin
2024-04-24 8:49 ` [PATCH 25/46] drm/amd/display: take ODM slice count into account when deciding DSC slice Wayne Lin
2024-04-24 8:49 ` [PATCH 26/46] drm/amd/display: Re-enable IPS2 for static screen Wayne Lin
2024-04-24 8:49 ` [PATCH 27/46] drm/amd/display: Add trigger FIFO resync path for DCN35 Wayne Lin
2024-04-24 8:49 ` [PATCH 28/46] drm/amd/display: Enable RCO for PHYSYMCLK in DCN35 Wayne Lin
2024-04-24 13:48 ` Li, Roman
2024-04-24 8:49 ` [PATCH 29/46] drm/amd/display: Revert "dc: Keep VBios pixel rate div setting util next mode set" Wayne Lin
2024-04-24 8:49 ` [PATCH 30/46] drm/amd/display: Only program P-State force if pipe config changed Wayne Lin
2024-04-24 8:49 ` [PATCH 31/46] drm/amd/display: Remove redundant include file Wayne Lin
2024-04-24 8:49 ` [PATCH 32/46] drm/amd/display: Refactor HUBBUB into component folder Wayne Lin
2024-04-24 8:49 ` [PATCH 33/46] drm/amd/display: Assign linear_pitch_alignment even for VM Wayne Lin
2024-04-24 8:49 ` [PATCH 34/46] drm/amd/display: gpuvm handling in DML21 Wayne Lin
2024-04-24 8:49 ` [PATCH 35/46] drm/amd/display: For FPO + Vactive check that all pipes support VA Wayne Lin
2024-04-24 8:49 ` [PATCH 36/46] drm/amd/display: Fix uninitialized variables in DM Wayne Lin
2024-04-24 8:49 ` [PATCH 37/46] drm/amd/display: Fix uninitialized variables in DC Wayne Lin
2024-04-24 8:49 ` [PATCH 38/46] drm/amd/display: Fix FEC_READY write on DP LT Wayne Lin
2024-04-24 8:49 ` [PATCH 39/46] drm/amd/display: use even ODM slice width for two pixels per container Wayne Lin
2024-04-24 8:49 ` [PATCH 40/46] drm/amd/display: Enable Replay for DCN315 Wayne Lin
2024-04-24 8:49 ` [PATCH 41/46] drm/amd/display: Notify idle link detection through shared state Wayne Lin
2024-04-24 8:49 ` [PATCH 42/46] drm/amd/display: Add periodic detection for IPS Wayne Lin
2024-04-24 8:49 ` [PATCH 43/46] drm/amd/display: Change ASSR disable sequence Wayne Lin
2024-04-24 8:49 ` [PATCH 44/46] drm/amd/display: Fix uninitialized variables in DC Wayne Lin
2024-04-24 8:49 ` [PATCH 45/46] drm/amd/display: Disable seamless boot on 128b/132b encoding Wayne Lin
2024-04-24 8:49 ` [PATCH 46/46] drm/amd/display: 3.2.283 Wayne Lin
2024-04-29 13:17 ` [PATCH 00/46] DC Patches April 29, 2024 Wheeler, Daniel
-- strict thread matches above, loose matches on Subject: below --
2024-04-24 8:31 Wayne Lin
2024-04-24 8:31 ` [PATCH 01/46] drm/amd/display: Do cursor programming with rest of pipe Wayne Lin
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=20240424084931.2656128-2-Wayne.Lin@amd.com \
--to=wayne.lin@amd.com \
--cc=Aurabindo.Pillai@amd.com \
--cc=Harry.Wentland@amd.com \
--cc=Rodrigo.Siqueira@amd.com \
--cc=Sunpeng.Li@amd.com \
--cc=agustin.gutierrez@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=chiahsuan.chung@amd.com \
--cc=hersenxs.wu@amd.com \
--cc=jerry.zuo@amd.com \
--cc=roman.li@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 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.