From: sashiko-bot@kernel.org
To: "George Zhang" <george.zhang@amd.com>, amd-gfx@lists.freedesktop.org
Subject: Re: [PATCH v2 07/30] drm/amd/display: Account for downspread and DFS in clock validation
Date: Tue, 01 Dec 2026 20:49:37 +0000 [thread overview]
Message-ID: <sashiko-outbox-244246@kernel.org> (raw)
In-Reply-To: <20261201202451.463794-9-george.zhang@amd.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] drm/amd/display: precision mismatch in cga_dcn6_initialize()
DFS ceiling
- [Low] drm/amd/display: missing Fixes: trailer for commit 7f7d7ea1fa51
--
commit 89c9a06cc3d1454a268be85d4e1c884dc45f81fd
Author: Ilya Bakoulin <Ilya.Bakoulin@amd.com>
> drm/amd/display: Account for downspread and DFS in clock validation
>
> [Why]
> ODM selection can choose a combine factor that fails the final DISPCLK
> check when downspread raises the clock requirement above the limit.
> Clamping ramp margin to a cap between DFS steps can also round the
> request up past the cap even when the mandatory clock fits.
>
> [How]
> Use the highest supported DFS step for the DCN6 ramp-margin clamp and
> account for downspread when passing that ceiling to ODM selection.
> Preserve the final check for mandatory clock requirements. Derive the
> DISPCLK ceiling from the highest DFS step at or below the clock
> table's maximum DISPCLK, floored to whole kHz.
>
> Account for downspread in the DCN5 DISPCLK, DPPCLK, and DSCCLK limits.
>
> Cc: Wenjing Liu <wenjing.liu@amd.com>
> Signed-off-by: Ilya Bakoulin <Ilya.Bakoulin@amd.com>
> Signed-off-by: George Zhang <george.zhang@amd.com>
[Severity: Low]
This fixes clock validation in DCN5 and DCN6. Should it include a Fixes:
tag for 7f7d7ea1fa51 ("drm/amd/display: Add new sources for DCN6")?
> diff --git a/drivers/gpu/drm/amd/display/dc/dml2_0/dml21/src/dml2_cga/dml2_cga_dcn6.c b/drivers/gpu/drm/amd/display/dc/dml2_0/dml21/src/dml2_cga/dml2_cga_dcn6.c
> index 43ee8a0b21b3c..2817340a0586b 100644
> --- a/drivers/gpu/drm/amd/display/dc/dml2_0/dml21/src/dml2_cga/dml2_cga_dcn6.c
> +++ b/drivers/gpu/drm/amd/display/dc/dml2_0/dml21/src/dml2_cga/dml2_cga_dcn6.c
[ ... ]
> @@ -40,11 +63,11 @@ static double cga_dcn6_calculate_actual_dispclk_mhz(const struct dml2_clock_gran
> dispclk_with_downspread_mhz = cga_dcn6_add_overhead_percent(dispclk_mhz, adjuster->dcn_downspread_percent);
> dispclk_with_ramp_margin_mhz = cga_dcn6_add_overhead_percent(
> dispclk_with_downspread_mhz, adjuster->dispclk_ramp_margin_percent);
> - if (dispclk_with_downspread_mhz <= adjuster->max_dispclk_mhz &&
> - dispclk_with_ramp_margin_mhz > adjuster->max_dispclk_mhz)
> - /* when dispclk with ramp margin is slightly over max, clamp the ramp margin to the max dispclk */
> - return math_floor2(adjuster->max_dispclk_mhz, CLOCK_UNIT_GRANULARITY);
> - else if (dispclk_with_downspread_mhz > adjuster->max_dispclk_mhz)
> + if (dispclk_with_downspread_mhz <= adjuster->max_adjusted_dispclk_mhz &&
> + dispclk_with_ramp_margin_mhz > adjuster->max_adjusted_dispclk_mhz)
> + /* Clamp optional ramp margin to the highest reachable DFS clock. */
> + return adjuster->max_adjusted_dispclk_mhz;
> + else if (dispclk_with_downspread_mhz > adjuster->max_adjusted_dispclk_mhz)
> return math_floor2(dispclk_with_downspread_mhz, CLOCK_UNIT_GRANULARITY);
> else
> return math_floor2(dispclk_with_ramp_margin_mhz, CLOCK_UNIT_GRANULARITY);
> @@ -63,8 +86,7 @@ static double cga_dcn6_adjust_to_dfs_clock_value_mhz(const struct dml2_clock_gra
> /* There are cases when a clock is not needed */
> return 0;
>
> - vco_speed_scaled_mhz = math_floor2(adjuster->dispclk_dppclk_vco_speed_mhz, 0.001);
> - vco_speed_scaled_mhz *= DFS_DIVIDER_RANGE_SCALE_FACTOR;
> + vco_speed_scaled_mhz = cga_dcn6_scaled_vco_mhz(adjuster);
> vco_divider = vco_speed_scaled_mhz / clk_mhz;
> vco_divider = math_floor(vco_divider);
> adjusted_clock_mhz = vco_speed_scaled_mhz / vco_divider;
> @@ -137,11 +159,16 @@ static double cga_dcn6_adjust_dcfclk_deepsleep_mhz(const struct dml2_clock_granu
>
> static void cga_dcn6_initialize(const struct dml2_cga_initialize_in_out *in_out)
> {
> + const struct dml2_clk_table *dispclk = &in_out->soc_bb->clk_table.dispclk;
> +
> in_out->adjuster->dcn_downspread_percent = in_out->soc_bb->dcn_downspread_percent;
> in_out->adjuster->dispclk_dppclk_vco_speed_mhz = in_out->soc_bb->dispclk_dppclk_vco_speed_mhz;
> in_out->adjuster->dispclk_ramp_margin_percent = in_out->ip->dispclk_ramp_margin_percent;
> + in_out->adjuster->max_adjusted_dispclk_mhz =
> + cga_dcn6_max_dfs_dispclk_khz(in_out->adjuster,
> + dispclk->clk_values_khz[dispclk->num_clk_values - 1]) / 1000.0;
> in_out->adjuster->max_dispclk_mhz =
> - in_out->soc_bb->clk_table.dispclk.clk_values_khz[in_out->soc_bb->clk_table.dispclk.num_clk_values - 1] / 1000.0;
> + in_out->adjuster->max_adjusted_dispclk_mhz / (1.0 + in_out->soc_bb->dcn_downspread_percent / 100.0);
> }
[Severity: Medium]
Can computing max_adjusted_dispclk_mhz via `/ 1000.0` cause
dcn6_ms_check_dispclk_and_dppclk_support() to reject valid modes at the
top DFS step?
cga_dcn6_adjust_to_dfs_clock_value_mhz() quantizes RequiredDISPCLK with
math_floor2(..., CLOCK_UNIT_GRANULARITY), which multiplies the integer kHz
value K by 0.001 (`((int)(arg / 0.001)) * 0.001`). In IEEE 754 binary64,
0.001 is strictly greater than 1.0 / 1000.0, so for many integer kHz
values (e.g. K = 1309090 kHz at 3600 MHz VCO / divider 11), `K * 0.001`
is 1 ULP larger than `K / 1000.0`. Moreover, when scaled_vco_khz is an
exact multiple of the divider and `K / 1000.0` rounds up, passing a
clamped `clk_mhz = adjuster->max_adjusted_dispclk_mhz` into
cga_dcn6_adjust_to_dfs_clock_value_mhz() yields `vco_speed_scaled_mhz /
clk_mhz < divider`, so math_floor(vco_divider) steps down to `divider - 1`
and bumps RequiredDISPCLK to the next higher DFS step. In both cases,
`inputs->RequiredDISPCLK <= ctx->clock_adjuster->max_adjusted_dispclk_mhz`
fails.
Multiplying the kHz value by CLOCK_UNIT_GRANULARITY (or passing the
unfloored DFS clock for the top divider through
cga_dcn6_adjust_to_dfs_clock_value_mhz()) would keep both sides on the
same floating-point representation.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261201202451.463794-2-george.zhang@amd.com?part=7
next prev parent reply other threads:[~2026-12-01 20:49 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-01 20:22 [PATCH v2 00/30] DC Patches for Nov 30 2026 George Zhang
2026-12-01 20:22 ` [PATCH v2 01/30] drm/amd/display: cast clamped rate conversion George Zhang
2026-12-01 20:22 ` [PATCH v2 02/30] drm/amd/display: Split HWSS_CURSOR_LOCK into flat BLS operations George Zhang
2026-12-01 20:22 ` [PATCH v2 03/30] drm/amd/display: clamp AUX reply length as unsigned George Zhang
2026-12-01 20:22 ` [PATCH v2 04/30] drm/amd/display: keep the DPCD read result signed in the MST ISR George Zhang
2026-12-01 20:22 ` [PATCH v2 05/30] drm/amd/display: copy only the status byte on a DMUB AUX write status retry George Zhang
2026-12-01 20:22 ` [PATCH v2 06/30] drm/amd/display: test the DMUB AUX write status reply copy George Zhang
2026-12-01 20:22 ` [PATCH v2 07/30] drm/amd/display: Account for downspread and DFS in clock validation George Zhang
2026-12-01 20:49 ` sashiko-bot [this message]
2026-12-01 20:22 ` [PATCH v2 08/30] drm/amd/display: Read max LSDMA BW from DMU George Zhang
2026-12-01 20:22 ` [PATCH v2 09/30] drm/amd/display: Precompute EASF lookup thresholds George Zhang
2026-12-01 20:22 ` [PATCH v2 10/30] drm/amd/display: Make DPP_SET_INPUT_TRANSFER_FUNC BLS compliant George Zhang
2026-12-01 20:22 ` [PATCH v2 11/30] drm/amd/display: Add pipe init to core2 George Zhang
2026-12-01 20:54 ` sashiko-bot
2026-12-01 20:22 ` [PATCH v2 12/30] drm/amd/display: Fix HDMI FRL no_timeout behavior George Zhang
2026-12-01 20:42 ` sashiko-bot
2026-12-01 20:22 ` [PATCH v2 13/30] drm/amd/display: Re-enable HUBP/DPP Driver PG on DCN42 George Zhang
2026-12-01 20:22 ` [PATCH v2 14/30] drm/amd/display: Program DSC on one stream in DC2 George Zhang
2026-12-01 20:55 ` sashiko-bot
2026-12-01 20:22 ` [PATCH v2 15/30] drm/amd/display: enable dcn42b hubp/dpp pg control from driver side George Zhang
2026-12-01 20:22 ` [PATCH v2 16/30] drm/amd/display: cover gamma 2.4 and 2.6 on the wide curve George Zhang
2026-12-01 20:22 ` [PATCH v2 17/30] drm/amd/display: Revoke alternate channel P-State before pipe teardown George Zhang
2026-12-01 21:09 ` sashiko-bot
2026-12-01 20:22 ` [PATCH v2 18/30] drm/amd/display: block pr in mst right George Zhang
2026-12-01 20:46 ` sashiko-bot
2026-12-01 20:22 ` [PATCH v2 19/30] drm/amd/display: Add a per-ASIC default for the DC2 selection George Zhang
2026-12-01 20:22 ` [PATCH v2 20/30] drm/amd/display: Refactor Max VStartup calculations for DCN6 George Zhang
2026-12-01 20:22 ` [PATCH v2 21/30] drm/amd/display: Improve P-state admissability logic George Zhang
2026-12-01 20:50 ` sashiko-bot
2026-12-01 20:22 ` [PATCH v2 22/30] drm/amd/display: Flip every DPP pipe of the stream in DC2 George Zhang
2026-12-01 21:00 ` sashiko-bot
2026-12-01 20:22 ` [PATCH v2 23/30] drm/amd/display: Report a DC2 BLS step overflow behind a debug option George Zhang
2026-12-01 20:22 ` [PATCH v2 24/30] drm/amd/display: VRR Support on Direct MST Sinks George Zhang
2026-12-01 20:22 ` [PATCH v2 25/30] drm/amd/display: Program YCbCr output in DC2 George Zhang
2026-12-01 20:23 ` [PATCH v2 26/30] drm/amd/display: Skip a stream with no OTG master " George Zhang
2026-12-01 20:23 ` [PATCH v2 27/30] drm/amd/display: Sync OTG timing in the DC2 non-seamless commit George Zhang
2026-12-01 20:57 ` sashiko-bot
2026-12-01 20:23 ` [PATCH v2 28/30] drm/amd/display: Move shared dcn401 builder code to its own file George Zhang
2026-12-01 20:23 ` [PATCH v2 29/30] drm/amd/display: Allow disabling CRC capture when the stream is gone George Zhang
2026-12-01 20:52 ` sashiko-bot
2026-12-01 20:23 ` [PATCH v2 30/30] drm/amd/display: Promote DC to 3.2.410 George Zhang
2026-12-01 20:45 ` sashiko-bot
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=sashiko-outbox-244246@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=amd-gfx@lists.freedesktop.org \
--cc=george.zhang@amd.com \
--cc=sashiko-reviews@lists.linux.dev \
/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