linux/drivers/gpu/drm/amd/display/dc/hwss
Francis Marlou Pacaro 2ac2fe765e drm/amd/display: fix MALL hysteresis timer underflow at high refresh rates
dcn30_apply_idle_power_optimizations() derives the MALL frame cache
hysteresis timer with

	tmr_delay = (uint32_t)(div_u64(..., denom) - 64LL);

div_u64() returns a u64, so when the quotient is smaller than 64 the
subtraction wraps instead of going negative and tmr_delay ends up huge.
The loop that follows tries to squeeze it into the 6 bit register field
by doubling denom, but that only makes the quotient smaller, so tmr_delay
can never converge.  tmr_scale is bumped past 3 and the function gives up
with

	/* Delay exceeds range of hysteresis timer */
	ASSERT(false);

even though the requested delay is too *short* to encode, not too long.

With mall_additional_timer_percent left at its default of 0, the quotient
drops below 64 once the refresh rate used for the calculation goes above
~243 Hz.  Every DCN 3.0 display above that loses MALL static screen
entirely and splats a WARN once per boot.  Reproduced on Navi 23
(RX 6600) driving 1920x1080, resetting /sys/kernel/debug/clear_warn_once
between modes:

	refresh   MALL       ASSERT
	144 Hz    enabled    no
	240 Hz    enabled    no
	280 Hz    skipped    yes
	360 Hz    skipped    yes

Commit 3bb68cec4d ("drm/amd/display: Add Overflow check to skip MALL")
already covered the other end of the range, where a large stutter period
makes the delay too long to encode.  Cover the short end by clamping to
0, which selects the shortest hysteresis the register can express,
65.28us * 64 = ~4.18ms.  That is marginally longer than what the formula
asks for at these refresh rates, and erring long is the safe direction:
it only delays MALL entry, it can never enter early.

The numerator does not change between iterations, only denom does, so
compute it once and keep both call sites inside 100 columns.

The genuinely out of range case at very low refresh rates still reaches
the ASSERT, which is where it belongs.

Fixes: 52f2e83e2f ("drm/amdgpu/display: add MALL support (v2)")
Signed-off-by: Francis Marlou Pacaro <pacaro.francis.marlou.n@gmail.com>
Reviewed-by: Leo Li <sunpeng.li@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit 387550e53e1405f1f960b62b22f8783db17c8e1d)
2026-09-17 11:59:24 -04:00
..
dce drm/amd/display: Enable DCN6 sources compilation 2026-08-06 09:53:32 -04:00
dce60 drm/amd/display: Refactor DPP_SET_OUTPUT_TRANSFER_FUNC to drop pipe_ctx 2026-07-28 18:32:21 -04:00
dce80
dce100
dce110 drm/amd/display: Check for tg ops in dce110_set_avmute 2026-08-06 13:43:27 -04:00
dce112
dce120 drm/amd/display: Fix implicit narrowing conversion warnings 2026-04-17 15:41:15 -04:00
dcn10 drm/amd/display: Enable DCN6 sources compilation 2026-08-06 09:53:32 -04:00
dcn20 drm/amd/display: Enable DCN6 sources compilation 2026-08-06 09:53:32 -04:00
dcn21 drm/amd/display: Enable CACP on Linux 2026-07-14 19:12:34 -04:00
dcn30 drm/amd/display: fix MALL hysteresis timer underflow at high refresh rates 2026-09-17 11:59:24 -04:00
dcn31 drm/amd/display: Fix seamless mode switch not triggering for HDR to SDR transition 2026-08-06 09:58:41 -04:00
dcn32 drm/amd/display: Enable DCN6 sources compilation 2026-08-06 09:53:32 -04:00
dcn35 drm/amd/display: Fix seamless mode switch not triggering for HDR to SDR transition 2026-08-06 09:58:41 -04:00
dcn42 drm/amd/display: Migrate color manager HW and fix MCM blend LUT issues 2026-08-06 12:44:26 -04:00
dcn42b drm/amd/display: Add DCN42B DC resource files 2026-06-03 13:43:52 -04:00
dcn50 drm/amd/display: Fix NULL dereference in dcn50/dcn60 init_hw 2026-09-17 11:57:29 -04:00
dcn60 drm/amd/display: Fix NULL dereference in dcn50/dcn60 init_hw 2026-09-17 11:57:29 -04:00
dcn201 drm/amd/display: Refactor surface_update_flags to flat struct with helpers 2026-06-17 16:15:51 -04:00
dcn301 drm/amd/display: Enable additional wait for pipe pending checks 2026-05-19 11:45:40 -04:00
dcn302
dcn303 drm/amd/display: Fixed Silence complier warnings in dc 2026-03-30 15:12:15 -04:00
dcn314 drm/amd/display: Tie FRL programming together in HWSS 2026-06-03 13:44:37 -04:00
dcn351 drm/amd/display: Tie FRL programming together in HWSS 2026-06-03 13:44:37 -04:00
dcn401 drm/amd/display: Migrate color manager HW and fix MCM blend LUT issues 2026-08-06 12:44:26 -04:00
hw_sequencer_private.h drm/amd/display: Migrate color manager HW and fix MCM blend LUT issues 2026-08-06 12:44:26 -04:00
hw_sequencer.h drm/amd/display: Migrate color manager HW and fix MCM blend LUT issues 2026-08-06 12:44:26 -04:00
Makefile drm/amd/display: Enable DCN6 sources compilation 2026-08-06 09:53:32 -04:00