Skip to content

Commit a29997b

Browse files
Dillon Varonealexdeucher
authored andcommitted
drm/amd/display: Limit VTotal range to max hw cap minus fp
[WHY & HOW] Hardware does not support the VTotal to be between fp2 lines of the maximum possible VTotal, so add a capability flag to track it and apply where necessary. Cc: Mario Limonciello <mario.limonciello@amd.com> Cc: Alex Deucher <alexander.deucher@amd.com> Cc: stable@vger.kernel.org Reviewed-by: Jun Lei <jun.lei@amd.com> Reviewed-by: Anthony Koo <anthony.koo@amd.com> Signed-off-by: Dillon Varone <dillon.varone@amd.com> Signed-off-by: Alex Hung <alex.hung@amd.com> Tested-by: Daniel Wheeler <daniel.wheeler@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
1 parent 24d3749 commit a29997b

File tree

11 files changed

+46
-3
lines changed

11 files changed

+46
-3
lines changed

drivers/gpu/drm/amd/display/dc/dc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ struct dc_caps {
290290
uint16_t subvp_vertical_int_margin_us;
291291
bool seamless_odm;
292292
uint32_t max_v_total;
293+
bool vtotal_limited_by_fp2;
293294
uint32_t max_disp_clock_khz_at_vmin;
294295
uint8_t subvp_drr_vblank_start_margin_us;
295296
bool cursor_not_scaled;

drivers/gpu/drm/amd/display/dc/dml2/dml21/dml21_translation_helper.c

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,11 +339,22 @@ void dml21_apply_soc_bb_overrides(struct dml2_initialize_instance_in_out *dml_in
339339
// }
340340
}
341341

342+
static unsigned int calc_max_hardware_v_total(const struct dc_stream_state *stream)
343+
{
344+
unsigned int max_hw_v_total = stream->ctx->dc->caps.max_v_total;
345+
346+
if (stream->ctx->dc->caps.vtotal_limited_by_fp2) {
347+
max_hw_v_total -= stream->timing.v_front_porch + 1;
348+
}
349+
350+
return max_hw_v_total;
351+
}
352+
342353
static void populate_dml21_timing_config_from_stream_state(struct dml2_timing_cfg *timing,
343354
struct dc_stream_state *stream,
344355
struct dml2_context *dml_ctx)
345356
{
346-
unsigned int hblank_start, vblank_start;
357+
unsigned int hblank_start, vblank_start, min_hardware_refresh_in_uhz;
347358

348359
timing->h_active = stream->timing.h_addressable + stream->timing.h_border_left + stream->timing.h_border_right;
349360
timing->v_active = stream->timing.v_addressable + stream->timing.v_border_bottom + stream->timing.v_border_top;
@@ -371,11 +382,23 @@ static void populate_dml21_timing_config_from_stream_state(struct dml2_timing_cf
371382
- stream->timing.v_border_top - stream->timing.v_border_bottom;
372383

373384
timing->drr_config.enabled = stream->ignore_msa_timing_param;
374-
timing->drr_config.min_refresh_uhz = stream->timing.min_refresh_in_uhz;
375385
timing->drr_config.drr_active_variable = stream->vrr_active_variable;
376386
timing->drr_config.drr_active_fixed = stream->vrr_active_fixed;
377387
timing->drr_config.disallowed = !stream->allow_freesync;
378388

389+
/* limit min refresh rate to DC cap */
390+
min_hardware_refresh_in_uhz = stream->timing.min_refresh_in_uhz;
391+
if (stream->ctx->dc->caps.max_v_total != 0) {
392+
min_hardware_refresh_in_uhz = div64_u64((stream->timing.pix_clk_100hz * 100000000ULL),
393+
(stream->timing.h_total * (long long)calc_max_hardware_v_total(stream)));
394+
}
395+
396+
if (stream->timing.min_refresh_in_uhz > min_hardware_refresh_in_uhz) {
397+
timing->drr_config.min_refresh_uhz = stream->timing.min_refresh_in_uhz;
398+
} else {
399+
timing->drr_config.min_refresh_uhz = min_hardware_refresh_in_uhz;
400+
}
401+
379402
if (dml_ctx->config.callbacks.get_max_flickerless_instant_vtotal_increase &&
380403
stream->ctx->dc->config.enable_fpo_flicker_detection == 1)
381404
timing->drr_config.max_instant_vtotal_delta = dml_ctx->config.callbacks.get_max_flickerless_instant_vtotal_increase(stream, false);

drivers/gpu/drm/amd/display/dc/resource/dcn30/dcn30_resource.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2353,6 +2353,7 @@ static bool dcn30_resource_construct(
23532353

23542354
dc->caps.dp_hdmi21_pcon_support = true;
23552355
dc->caps.max_v_total = (1 << 15) - 1;
2356+
dc->caps.vtotal_limited_by_fp2 = true;
23562357

23572358
/* read VBIOS LTTPR caps */
23582359
{

drivers/gpu/drm/amd/display/dc/resource/dcn302/dcn302_resource.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1233,6 +1233,7 @@ static bool dcn302_resource_construct(
12331233
dc->caps.extended_aux_timeout_support = true;
12341234
dc->caps.dmcub_support = true;
12351235
dc->caps.max_v_total = (1 << 15) - 1;
1236+
dc->caps.vtotal_limited_by_fp2 = true;
12361237

12371238
/* Color pipeline capabilities */
12381239
dc->caps.color.dpp.dcn_arch = 1;

drivers/gpu/drm/amd/display/dc/resource/dcn303/dcn303_resource.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1178,6 +1178,7 @@ static bool dcn303_resource_construct(
11781178
dc->caps.extended_aux_timeout_support = true;
11791179
dc->caps.dmcub_support = true;
11801180
dc->caps.max_v_total = (1 << 15) - 1;
1181+
dc->caps.vtotal_limited_by_fp2 = true;
11811182

11821183
/* Color pipeline capabilities */
11831184
dc->caps.color.dpp.dcn_arch = 1;

drivers/gpu/drm/amd/display/dc/resource/dcn32/dcn32_resource.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2189,6 +2189,7 @@ static bool dcn32_resource_construct(
21892189
dc->caps.dmcub_support = true;
21902190
dc->caps.seamless_odm = true;
21912191
dc->caps.max_v_total = (1 << 15) - 1;
2192+
dc->caps.vtotal_limited_by_fp2 = true;
21922193

21932194
/* Color pipeline capabilities */
21942195
dc->caps.color.dpp.dcn_arch = 1;

drivers/gpu/drm/amd/display/dc/resource/dcn321/dcn321_resource.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1742,6 +1742,7 @@ static bool dcn321_resource_construct(
17421742
dc->caps.extended_aux_timeout_support = true;
17431743
dc->caps.dmcub_support = true;
17441744
dc->caps.max_v_total = (1 << 15) - 1;
1745+
dc->caps.vtotal_limited_by_fp2 = true;
17451746

17461747
/* Color pipeline capabilities */
17471748
dc->caps.color.dpp.dcn_arch = 1;

drivers/gpu/drm/amd/display/dc/resource/dcn35/dcn35_resource.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1850,6 +1850,7 @@ static bool dcn35_resource_construct(
18501850
dc->caps.zstate_support = true;
18511851
dc->caps.ips_support = true;
18521852
dc->caps.max_v_total = (1 << 15) - 1;
1853+
dc->caps.vtotal_limited_by_fp2 = true;
18531854

18541855
/* Color pipeline capabilities */
18551856
dc->caps.color.dpp.dcn_arch = 1;

drivers/gpu/drm/amd/display/dc/resource/dcn351/dcn351_resource.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1829,6 +1829,7 @@ static bool dcn351_resource_construct(
18291829
dc->caps.zstate_support = true;
18301830
dc->caps.ips_support = true;
18311831
dc->caps.max_v_total = (1 << 15) - 1;
1832+
dc->caps.vtotal_limited_by_fp2 = true;
18321833

18331834
/* Color pipeline capabilities */
18341835
dc->caps.color.dpp.dcn_arch = 1;

drivers/gpu/drm/amd/display/dc/resource/dcn401/dcn401_resource.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1864,6 +1864,7 @@ static bool dcn401_resource_construct(
18641864
dc->caps.extended_aux_timeout_support = true;
18651865
dc->caps.dmcub_support = true;
18661866
dc->caps.max_v_total = (1 << 15) - 1;
1867+
dc->caps.vtotal_limited_by_fp2 = true;
18671868

18681869
if (ASICREV_IS_GC_12_0_1_A0(dc->ctx->asic_id.hw_internal_rev))
18691870
dc->caps.dcc_plane_width_limit = 7680;

0 commit comments

Comments
 (0)