AMD-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: ChuanYu Tseng <ChuanYu.Tseng@amd.com>
To: <amd-gfx@lists.freedesktop.org>
Cc: Harry Wentland <harry.wentland@amd.com>,
	Leo Li <sunpeng.li@amd.com>,
	Aurabindo Pillai <aurabindo.pillai@amd.com>,
	Roman Li <roman.li@amd.com>, Wayne Lin <wayne.lin@amd.com>,
	Tom Chung <chiahsuan.chung@amd.com>,
	"Fangzhi Zuo" <jerry.zuo@amd.com>,
	Dan Wheeler <daniel.wheeler@amd.com>, Ray Wu <Ray.Wu@amd.com>,
	Ivan Lipski <ivan.lipski@amd.com>, Alex Hung <alex.hung@amd.com>,
	Benjamin Nwankwo <Benjamin.Nwankwo@amd.com>,
	"Charlene Liu" <charlene.liu@amd.com>,
	Nevenko Stupar <nevenko.stupar@amd.com>,
	"Chuanyu Tseng" <chuanyu.tseng@amd.com>
Subject: [PATCH 8/9] drm/amd/display: Clamp dc_cursor_position x_hotspot to prevent integer overflow
Date: Wed, 11 Mar 2026 10:40:40 +0800	[thread overview]
Message-ID: <20260311024652.2668570-9-ChuanYu.Tseng@amd.com> (raw)
In-Reply-To: <20260311024652.2668570-1-ChuanYu.Tseng@amd.com>

From: Benjamin Nwankwo <Benjamin.Nwankwo@amd.com>

why:
Workaround for duplicate cursor. Cursor offsetting via x_hotspot attempts
to write a 32 bit unsigned integer to the 8 bit field CURSOR_HOT_SPOT_X.
This wraps cursor position back into focus if x_hotspot exceeds 8 bits,
making duplicate cursors visible

how:
Clamp x_hotspot before writing to hardware

Reviewed-by: Charlene Liu <charlene.liu@amd.com>
Reviewed-by: Nevenko Stupar <nevenko.stupar@amd.com>
Signed-off-by: Benjamin Nwankwo <Benjamin.Nwankwo@amd.com>
Signed-off-by: Chuanyu Tseng <chuanyu.tseng@amd.com>
---
 drivers/gpu/drm/amd/display/dc/hubp/dcn401/dcn401_hubp.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/hubp/dcn401/dcn401_hubp.c b/drivers/gpu/drm/amd/display/dc/hubp/dcn401/dcn401_hubp.c
index 4985e885952d..263e0c4d34f6 100644
--- a/drivers/gpu/drm/amd/display/dc/hubp/dcn401/dcn401_hubp.c
+++ b/drivers/gpu/drm/amd/display/dc/hubp/dcn401/dcn401_hubp.c
@@ -812,9 +812,8 @@ void hubp401_cursor_set_position(
 	int x_pos_viewport = 0;
 	int x_hot_viewport = 0;
 	uint32_t cur_en = pos->enable ? 1 : 0;
-
+	uint32_t x_hotspot_clamped = pos->x_hotspot;
 	hubp->curs_pos = *pos;
-
 	/* Recout is zero for pipes if the entire dst_rect is contained
 	 * within preceeding ODM slices.
 	 */
@@ -845,6 +844,8 @@ void hubp401_cursor_set_position(
 
 	ASSERT(param->h_scale_ratio.value);
 
+	if (x_hotspot_clamped > 0xFF)
+		x_hotspot_clamped = 0xFF;
 	if (param->h_scale_ratio.value)
 		dst_x_offset = dc_fixpt_floor(dc_fixpt_div(
 			dc_fixpt_from_int(dst_x_offset),
@@ -865,7 +866,7 @@ void hubp401_cursor_set_position(
 			CURSOR_Y_POSITION, pos->y);
 
 		REG_SET_2(CURSOR_HOT_SPOT, 0,
-			CURSOR_HOT_SPOT_X, pos->x_hotspot,
+			CURSOR_HOT_SPOT_X, x_hotspot_clamped,
 			CURSOR_HOT_SPOT_Y, pos->y_hotspot);
 
 		REG_SET(CURSOR_DST_OFFSET, 0,
-- 
2.43.0


  parent reply	other threads:[~2026-03-11  2:46 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-11  2:40 DC Patches March 10, 2026 ChuanYu Tseng
2026-03-11  2:40 ` [PATCH 1/9] drm/amd/display: Add debugfs to disallow eDP Replay entry ChuanYu Tseng
2026-03-11  2:40 ` [PATCH 2/9] drm/amd/display: Fix number of opp ChuanYu Tseng
2026-03-11  2:40 ` [PATCH 3/9] drm/amd/display: Add dcn_mrq_present Field ChuanYu Tseng
2026-03-11  2:40 ` [PATCH 4/9] drm/amd/display: Plumb MRQ programming out of DML for dml2_1 ChuanYu Tseng
2026-03-11  2:40 ` [PATCH 5/9] drm/amd/display: Silence C6001 warnings ChuanYu Tseng
2026-03-11  2:40 ` [PATCH 6/9] drm/amd/display: Add a buffer for boot time crc ChuanYu Tseng
2026-03-11  2:40 ` [PATCH 7/9] drm/amd/display: Query DC for gfx handling when setting linear tiling ChuanYu Tseng
2026-03-11  2:40 ` ChuanYu Tseng [this message]
2026-03-11  2:40 ` [PATCH 9/9] drm/amd/display: Promote DC to 3.2.374 ChuanYu Tseng

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=20260311024652.2668570-9-ChuanYu.Tseng@amd.com \
    --to=chuanyu.tseng@amd.com \
    --cc=Benjamin.Nwankwo@amd.com \
    --cc=Ray.Wu@amd.com \
    --cc=alex.hung@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=aurabindo.pillai@amd.com \
    --cc=charlene.liu@amd.com \
    --cc=chiahsuan.chung@amd.com \
    --cc=daniel.wheeler@amd.com \
    --cc=harry.wentland@amd.com \
    --cc=ivan.lipski@amd.com \
    --cc=jerry.zuo@amd.com \
    --cc=nevenko.stupar@amd.com \
    --cc=roman.li@amd.com \
    --cc=sunpeng.li@amd.com \
    --cc=wayne.lin@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