Skip to content

Commit 6154cc9

Browse files
vsyrjalarodrigovivi
authored andcommitted
drm/i915/cdclk: Fix voltage_level programming edge case
Currently we only consider the relationship of the old and new CDCLK frequencies when determining whether to do the repgramming from intel_set_cdclk_pre_plane_update() or intel_set_cdclk_post_plane_update(). It is technically possible to have a situation where the CDCLK frequency is decreasing, but the voltage_level is increasing due a DDI port. In this case we should bump the voltage level already in intel_set_cdclk_pre_plane_update() (so that the voltage_level will have been increased by the time the port gets enabled), while leaving the CDCLK frequency unchanged (as active planes/etc. may still depend on it). We can then reduce the CDCLK frequency to its final value from intel_set_cdclk_post_plane_update(). In order to handle that correctly we shall construct a suitable amalgam of the old and new cdclk states in intel_set_cdclk_pre_plane_update(). And we can simply call intel_set_cdclk() unconditionally in both places as it will not do anything if nothing actually changes vs. the current hw state. v2: Handle cdclk_state->disable_pipes v3: Only synchronize the cd2x update against the pipe's vblank when the cdclk frequency is changing during the current commit phase (Gustavo) Cc: [email protected] Cc: Gustavo Sousa <[email protected]> Reviewed-by: Uma Shankar <[email protected]> Signed-off-by: Ville Syrjälä <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] (cherry picked from commit 34d127e) Signed-off-by: Rodrigo Vivi <[email protected]>
1 parent 7b1f6b5 commit 6154cc9

File tree

1 file changed

+27
-10
lines changed

1 file changed

+27
-10
lines changed

drivers/gpu/drm/i915/display/intel_cdclk.c

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2534,7 +2534,8 @@ intel_set_cdclk_pre_plane_update(struct intel_atomic_state *state)
25342534
intel_atomic_get_old_cdclk_state(state);
25352535
const struct intel_cdclk_state *new_cdclk_state =
25362536
intel_atomic_get_new_cdclk_state(state);
2537-
enum pipe pipe = new_cdclk_state->pipe;
2537+
struct intel_cdclk_config cdclk_config;
2538+
enum pipe pipe;
25382539

25392540
if (!intel_cdclk_changed(&old_cdclk_state->actual,
25402541
&new_cdclk_state->actual))
@@ -2543,12 +2544,25 @@ intel_set_cdclk_pre_plane_update(struct intel_atomic_state *state)
25432544
if (IS_DG2(i915))
25442545
intel_cdclk_pcode_pre_notify(state);
25452546

2546-
if (new_cdclk_state->disable_pipes ||
2547-
old_cdclk_state->actual.cdclk <= new_cdclk_state->actual.cdclk) {
2548-
drm_WARN_ON(&i915->drm, !new_cdclk_state->base.changed);
2547+
if (new_cdclk_state->disable_pipes) {
2548+
cdclk_config = new_cdclk_state->actual;
2549+
pipe = INVALID_PIPE;
2550+
} else {
2551+
if (new_cdclk_state->actual.cdclk >= old_cdclk_state->actual.cdclk) {
2552+
cdclk_config = new_cdclk_state->actual;
2553+
pipe = new_cdclk_state->pipe;
2554+
} else {
2555+
cdclk_config = old_cdclk_state->actual;
2556+
pipe = INVALID_PIPE;
2557+
}
25492558

2550-
intel_set_cdclk(i915, &new_cdclk_state->actual, pipe);
2559+
cdclk_config.voltage_level = max(new_cdclk_state->actual.voltage_level,
2560+
old_cdclk_state->actual.voltage_level);
25512561
}
2562+
2563+
drm_WARN_ON(&i915->drm, !new_cdclk_state->base.changed);
2564+
2565+
intel_set_cdclk(i915, &cdclk_config, pipe);
25522566
}
25532567

25542568
/**
@@ -2566,7 +2580,7 @@ intel_set_cdclk_post_plane_update(struct intel_atomic_state *state)
25662580
intel_atomic_get_old_cdclk_state(state);
25672581
const struct intel_cdclk_state *new_cdclk_state =
25682582
intel_atomic_get_new_cdclk_state(state);
2569-
enum pipe pipe = new_cdclk_state->pipe;
2583+
enum pipe pipe;
25702584

25712585
if (!intel_cdclk_changed(&old_cdclk_state->actual,
25722586
&new_cdclk_state->actual))
@@ -2576,11 +2590,14 @@ intel_set_cdclk_post_plane_update(struct intel_atomic_state *state)
25762590
intel_cdclk_pcode_post_notify(state);
25772591

25782592
if (!new_cdclk_state->disable_pipes &&
2579-
old_cdclk_state->actual.cdclk > new_cdclk_state->actual.cdclk) {
2580-
drm_WARN_ON(&i915->drm, !new_cdclk_state->base.changed);
2593+
new_cdclk_state->actual.cdclk < old_cdclk_state->actual.cdclk)
2594+
pipe = new_cdclk_state->pipe;
2595+
else
2596+
pipe = INVALID_PIPE;
25812597

2582-
intel_set_cdclk(i915, &new_cdclk_state->actual, pipe);
2583-
}
2598+
drm_WARN_ON(&i915->drm, !new_cdclk_state->base.changed);
2599+
2600+
intel_set_cdclk(i915, &new_cdclk_state->actual, pipe);
25842601
}
25852602

25862603
static int intel_pixel_rate_to_cdclk(const struct intel_crtc_state *crtc_state)

0 commit comments

Comments
 (0)