From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 28EA3606A31A for ; Tue, 1 Dec 2026 20:49:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Q/lRGPJc Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B4B0710EA61; Tue, 1 Dec 2026 20:49:45 +0000 (UTC) Received: from tor.source.kernel.org (tor.source.kernel.org [172.105.4.254]) by gabe.freedesktop.org (Postfix) with ESMTPS id CA45F10E2C5 for ; Tue, 1 Dec 2026 20:49:38 +0000 (UTC) Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id E1EEA61897; Tue, 1 Dec 2026 20:49:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 859B71F00893; Tue, 1 Dec 2026 20:49:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796158177; bh=FeMRNWt0AD6Sy++s1vCojUW+v2AXE+60SEGIDFR2qIY=; h=From:Subject:Reply-To:To:In-Reply-To:References:Date; b=Q/lRGPJcM3MbwyyfAV9FOKiDUUbpr3oepMaaTIKeFJmxmYQJnpbSMx2meGvLTzzir y80pWO7ak4W9PeTzGlgxmvJ67lDg0LVLDMndxC35oev6JA7DLPuBnNaUMlxx5omi04 VHZnKpfH+PVLm1ynOVk9Bba9kSgZOyp0cWpcGgcldiaIQAat7NYBkqllO0zVahiMJB zerfINS3rCZi4yyk5PRkWmv5z2ad+40Zjtno1nIJzXm8NGtHkSQoJZUv75O6Q/ZU9y t3JG1lukjUFs3eHxtZGPcTfjCW6hZnzbwbcnXN3Ifu5fstSYra1hExDc20QvFdcdD2 G5WJkH4xz1pcg== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v2 07/30] drm/amd/display: Account for downspread and DFS in clock validation To: "George Zhang" , amd-gfx@lists.freedesktop.org In-Reply-To: <20261201202451.463794-9-george.zhang@amd.com> References: <20261201202451.463794-2-george.zhang@amd.com> <20261201202451.463794-9-george.zhang@amd.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Tue, 01 Dec 2026 20:49:37 +0000 X-BeenThere: amd-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion list for AMD gfx List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: sashiko-reviews@lists.linux.dev Sender: "amd-gfx" X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 X-Archived-By: 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 > 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 > Signed-off-by: Ilya Bakoulin > Signed-off-by: George Zhang [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/dml= 2_cga_dcn6.c b/drivers/gpu/drm/amd/display/dc/dml2_0/dml21/src/dml2_cga/dml= 2_cga_dcn6.c > index 43ee8a0b21b3c..2817340a0586b 100644 > --- a/drivers/gpu/drm/amd/display/dc/dml2_0/dml21/src/dml2_cga/dml2_cga_d= cn6.c > +++ b/drivers/gpu/drm/amd/display/dc/dml2_0/dml21/src/dml2_cga/dml2_cga_d= cn6.c [ ... ] > @@ -40,11 +63,11 @@ static double cga_dcn6_calculate_actual_dispclk_mhz(c= onst struct dml2_clock_gran > dispclk_with_downspread_mhz =3D cga_dcn6_add_overhead_percent(dispclk_m= hz, adjuster->dcn_downspread_percent); > dispclk_with_ramp_margin_mhz =3D cga_dcn6_add_overhead_percent( > dispclk_with_downspread_mhz, adjuster->dispclk_ramp_margin_percent); > - if (dispclk_with_downspread_mhz <=3D 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 <=3D 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_m= hz) > return math_floor2(dispclk_with_downspread_mhz, CLOCK_UNIT_GRANULARITY= ); > else > return math_floor2(dispclk_with_ramp_margin_mhz, CLOCK_UNIT_GRANULARIT= Y); > @@ -63,8 +86,7 @@ static double cga_dcn6_adjust_to_dfs_clock_value_mhz(co= nst struct dml2_clock_gra > /* There are cases when a clock is not needed */ > return 0; > =20 > - vco_speed_scaled_mhz =3D math_floor2(adjuster->dispclk_dppclk_vco_speed= _mhz, 0.001); > - vco_speed_scaled_mhz *=3D DFS_DIVIDER_RANGE_SCALE_FACTOR; > + vco_speed_scaled_mhz =3D cga_dcn6_scaled_vco_mhz(adjuster); > vco_divider =3D vco_speed_scaled_mhz / clk_mhz; > vco_divider =3D math_floor(vco_divider); > adjusted_clock_mhz =3D vco_speed_scaled_mhz / vco_divider; > @@ -137,11 +159,16 @@ static double cga_dcn6_adjust_dcfclk_deepsleep_mhz(= const struct dml2_clock_granu > =20 > static void cga_dcn6_initialize(const struct dml2_cga_initialize_in_out = *in_out) > { > + const struct dml2_clk_table *dispclk =3D &in_out->soc_bb->clk_table.dis= pclk; > + > in_out->adjuster->dcn_downspread_percent =3D in_out->soc_bb->dcn_downsp= read_percent; > in_out->adjuster->dispclk_dppclk_vco_speed_mhz =3D in_out->soc_bb->disp= clk_dppclk_vco_speed_mhz; > in_out->adjuster->dispclk_ramp_margin_percent =3D in_out->ip->dispclk_r= amp_margin_percent; > + in_out->adjuster->max_adjusted_dispclk_mhz =3D > + 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 =3D > - in_out->soc_bb->clk_table.dispclk.clk_values_khz[in_out->soc_bb->clk_t= able.dispclk.num_clk_values - 1] / 1000.0; > + in_out->adjuster->max_adjusted_dispclk_mhz / (1.0 + in_out->soc_bb->dc= n_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 =3D 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 =3D 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 <=3D 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. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261201202451.4637= 94-2-george.zhang@amd.com?part=3D7