AMD-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "George Zhang" <george.zhang@amd.com>, amd-gfx@lists.freedesktop.org
Subject: Re: [PATCH v2 21/30] drm/amd/display: Improve P-state admissability logic
Date: Tue, 01 Dec 2026 20:50:57 +0000	[thread overview]
Message-ID: <sashiko-outbox-244248@kernel.org> (raw)
In-Reply-To: <20261201202451.463794-23-george.zhang@amd.com>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] drm/amd/display: vblank_nom not replaced in
  dcn6_build_pstate_meta_per_stream()
- [Medium] drm/amd/display: v_total vs vblank_nom mismatch in DCN6
  pstate admissibility
--

commit 0206c2992e2de04f212b5f64a6b0b9d2d0262f39
Author: Dillon Varone <Dillon.Varone@amd.com>

drm/amd/display: Improve P-state admissability logic

This commit updates DCN6 P-state schedule window and admissibility
calculations to include unallocated VBlank lines when VStartup is smaller
than VBlank, and clamps the per-stream ideal P-state disallow time to the
allow delay divided by the number of streams.

> diff --git a/drivers/gpu/drm/amd/display/dc/dml2_0/dml21/src/dml2_core/dml2_core_dcn6_calcs_dchub.c b/drivers/gpu/drm/amd/display/dc/dml2_0/dml21/src/dml2_core/dml2_core_dcn6_calcs_dchub.c
> index 69439ec644e01..7b7fa428958eb 100644
> --- a/drivers/gpu/drm/amd/display/dc/dml2_0/dml21/src/dml2_core/dml2_core_dcn6_calcs_dchub.c
> +++ b/drivers/gpu/drm/amd/display/dc/dml2_0/dml21/src/dml2_core/dml2_core_dcn6_calcs_dchub.c
> @@ -1715,6 +1715,8 @@ void dcn6_calculate_pstate_schedule_windows(
>  		int num_active_planes,
>  		const unsigned int v_blank_start[DML2_MAX_PLANES],
>  		const unsigned int v_blank_end[DML2_MAX_PLANES],
> +		const unsigned int v_startup[DML2_MAX_PLANES],
> +		const unsigned int v_total[DML2_MAX_PLANES],
>  		const double otg_vline_time_us[DML2_MAX_PLANES],
>  		const double det_fill_delay_us[DML2_MAX_PLANES],
>  		const double reserved_vblank_us[DML2_MAX_PLANES],
> @@ -1728,6 +1730,7 @@ void dcn6_calculate_pstate_schedule_windows(
>  	int det_fill_delay_otg_vlines;
>  	int blackout_otg_vlines;
>  	int reserved_vblank_otg_vlines;
> +	int unallocated_vblank_otg_vlines;
>  
>  	/**
>  	 * Calculate allow start and end for pstate in vactive:
> @@ -1742,10 +1745,13 @@ void dcn6_calculate_pstate_schedule_windows(
>  		blackout_otg_vlines = (int)(math_ceil(blackout_us / otg_vline_time_us[k]));
>  		det_fill_delay_otg_vlines = (int)(math_ceil(det_fill_delay_us[k] / otg_vline_time_us[k]));
>  		reserved_vblank_otg_vlines = (int)(math_ceil(reserved_vblank_us[k] / otg_vline_time_us[k]));
> +		unallocated_vblank_otg_vlines = v_total[k] - v_blank_start[k] + v_blank_end[k] - v_startup[k];
>  
>  		/* for vactive only, make relative to vblank end */
>  		allow_start_otg_vlines = det_fill_delay_otg_vlines;
> -		allow_end_otg_vlines = v_blank_start[k] - v_blank_end[k] - (blackout_otg_vlines - reserved_vblank_otg_vlines);
> +		allow_end_otg_vlines = v_blank_start[k] - v_blank_end[k] +
> +				unallocated_vblank_otg_vlines -
> +				(blackout_otg_vlines - reserved_vblank_otg_vlines);
>  
>  		/* Convert them back to time since the start of a frame */
>  		allow_start_us[k] = allow_start_otg_vlines * otg_vline_time_us[k];

[Severity: Medium]
Does adding unallocated_vblank_otg_vlines (computed from v_total) to
allow_end_otg_vlines cause dcn6_calculate_pstate_schedule_admissibility()
to under-calculate disallow_window_us when v_total - v_active exceeds
vblank_nom?

dcn6_ms_check_pstate_schedule_admissibility() computes frame_time_us[k] via
dml2_core_utils_get_frame_time_us(), which uses vblank_nom + v_active
rather than v_total:

drivers/gpu/drm/amd/display/dc/dml2_0/dml21/src/dml2_core/dml2_core_utils.c:dml2_core_utils_get_frame_time_us() {
	double otg_vline_time_us = (double)stream->timing.h_total / (double)stream->timing.pixel_clock_khz * 1000.0;
	double non_vtotal = stream->timing.vblank_nom + stream->timing.v_active;
	double frame_time_us = non_vtotal * otg_vline_time_us;

When dcn6_calculate_pstate_schedule_admissibility() computes
disallow_window_us[cur_id] = group_frame_time_us - allow_window_us[cur_id],
subtracting a v_total-based allow_window_us from a (vblank_nom + v_active)
frame time double-subtracts (v_total - v_active - vblank_nom) lines.  On
timings whose VBlank exceeds vblank_nom, this reduces or zeroes
disallow_window_us and lets non-admissible P-state schedules pass mode
support validation.

[ ... ]

> diff --git a/drivers/gpu/drm/amd/display/dc/dml2_0/dml21/src/dml2_pmo/dml2_pmo_dcn6_stage_optimizers.c b/drivers/gpu/drm/amd/display/dc/dml2_0/dml21/src/dml2_pmo/dml2_pmo_dcn6_stage_optimizers.c
> index 71407eec2d836..44cc7de4d8dc7 100644
> --- a/drivers/gpu/drm/amd/display/dc/dml2_0/dml21/src/dml2_pmo/dml2_pmo_dcn6_stage_optimizers.c
> +++ b/drivers/gpu/drm/amd/display/dc/dml2_0/dml21/src/dml2_pmo/dml2_pmo_dcn6_stage_optimizers.c

[ ... ]

> @@ -836,11 +848,12 @@ static void dcn6_build_pstate_meta_per_stream(const struct dml2_display_cfg *dis
>  	if (stream_pstate_meta->method_vactive.max_vactive_det_fill_delay_us > 0.0) {
>  		stream_pstate_meta->method_vactive.common.allow_start_otg_vline =
>  				timing->v_blank_end + stream_pstate_meta->method_vactive.max_vactive_det_fill_delay_otg_vlines;
> +
>  		stream_pstate_meta->method_vactive.common.allow_end_otg_vline =
>  				stream_pstate_meta->vblank_start +
>  				stream_pstate_meta->nom_vtotal -
>  				stream_descriptor->timing.v_active -
> -				stream_descriptor->timing.vblank_nom -
> +				stream_pstate_meta->method_vactive.vstartup_lines -
>  				stream_pstate_meta->blackout_otg_vlines +
>  				stream_pstate_meta->method_vactive.reserved_blank_required_vlines;
>  	} else {

[Severity: Medium]
Should the max allow delay enforcement immediately above in
dcn6_build_pstate_meta_per_stream() also subtract
stream_pstate_meta->method_vactive.vstartup_lines instead of
stream_descriptor->timing.vblank_nom?

drivers/gpu/drm/amd/display/dc/dml2_0/dml21/src/dml2_pmo/dml2_pmo_dcn6_stage_optimizers.c:dcn6_build_pstate_meta_per_stream() {
	...
	/* consider max allow delay enforcement */
	if (stream_pstate_meta->method_vactive.max_vactive_det_fill_delay_otg_vlines > 0) {
		stream_pstate_meta->method_vactive.max_vactive_det_fill_delay_otg_vlines = (int)math_min2(
				(double)stream_pstate_meta->method_vactive.max_vactive_det_fill_delay_otg_vlines,
				math_max2(0.0,
				stream_pstate_meta->max_allow_delay_otg_vlines +
				stream_pstate_meta->method_vactive.reserved_blank_required_vlines -
				(int)stream_descriptor->timing.vblank_nom -
				stream_pstate_meta->blackout_otg_vlines));
	} else {
		stream_pstate_meta->method_vactive.max_vactive_det_fill_delay_otg_vlines = (int)math_max2(0.0,
				stream_pstate_meta->max_allow_delay_otg_vlines +
				stream_pstate_meta->method_vactive.reserved_blank_required_vlines -
				(int)stream_descriptor->timing.vblank_nom -
				stream_pstate_meta->blackout_otg_vlines);
	}
	...
}

When vstartup_lines < vblank_nom, subtracting vblank_nom underestimates
max_vactive_det_fill_delay_otg_vlines by (vblank_nom - vstartup_lines) and
can clamp max_vactive_det_fill_delay_us to 0.0, which skips the allow
window calculation above and leaves allow_start_otg_vline and
allow_end_otg_vline at 0.  Similarly,
dcn6_update_worksheet_for_pstate_admissibility() still computes
vblank_time_us from timing.vblank_nom rather than vstartup_lines when
bounding delta_reserved_vblank_time_us, which can reserve more VBlank time
than fits in VStartup.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261201202451.463794-2-george.zhang@amd.com?part=21

  reply	other threads:[~2026-12-01 20:51 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
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 [this message]
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-244248@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