Skip to content

Commit 3297234

Browse files
committed
drm/i915: Adjust eDP's logical vco in a reliable place.
On intel_dp_compute_config() we were calculating the needed vco for eDP on gen9 and we stashing it in intel_atomic_state.cdclk.logical.vco However few moments later on intel_modeset_checks() we fully replace entire intel_atomic_state.cdclk.logical with dev_priv->cdclk.logical fully overwriting the logical desired vco for eDP on gen9. So, with wrong VCO value we end up with wrong desired cdclk, but also it will raise a lot of WARNs: On gen9, when we read CDCLK_CTL to verify if we configured properly the desired frequency the CD Frequency Select bits [27:26] == 10b can mean 337.5 or 308.57 MHz depending on the VCO. So if we have wrong VCO value stashed we will believe the frequency selection didn't stick and start to raise WARNs of cdclk mismatch. [ 42.857519] [drm:intel_dump_cdclk_state [i915]] Changing CDCLK to 308571 kHz, VCO 8640000 kHz, ref 24000 kHz, bypass 24000 kHz, voltage level 0 [ 42.897269] cdclk state doesn't match! [ 42.901052] WARNING: CPU: 5 PID: 1116 at drivers/gpu/drm/i915/intel_cdclk.c:2084 intel_set_cdclk+0x5d/0x110 [i915] [ 42.938004] RIP: 0010:intel_set_cdclk+0x5d/0x110 [i915] [ 43.155253] WARNING: CPU: 5 PID: 1116 at drivers/gpu/drm/i915/intel_cdclk.c:2084 intel_set_cdclk+0x5d/0x110 [i915] [ 43.170277] [drm:intel_dump_cdclk_state [i915]] [hw state] 337500 kHz, VCO 8100000 kHz, ref 24000 kHz, bypass 24000 kHz, voltage level 0 [ 43.182566] [drm:intel_dump_cdclk_state [i915]] [sw state] 308571 kHz, VCO 8640000 kHz, ref 24000 kHz, bypass 24000 kHz, voltage level 0 v2: Move the entire eDP's vco logical adjustment to inside the skl_modeset_calc_cdclk as suggested by Ville. Cc: Ville Syrjälä <[email protected]> Signed-off-by: Rodrigo Vivi <[email protected]> Reviewed-by: Ville Syrjälä <[email protected]> Fixes: bb0f4aa ("drm/i915: Track full cdclk state for the logical and actual cdclk frequencies") Cc: <[email protected]> # v4.12+ Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent e21b141 commit 3297234

File tree

2 files changed

+37
-24
lines changed

2 files changed

+37
-24
lines changed

drivers/gpu/drm/i915/intel_cdclk.c

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2302,19 +2302,52 @@ static int bdw_modeset_calc_cdclk(struct drm_atomic_state *state)
23022302
return 0;
23032303
}
23042304

2305+
static int skl_dpll0_vco(struct intel_atomic_state *intel_state)
2306+
{
2307+
struct drm_i915_private *dev_priv = to_i915(intel_state->base.dev);
2308+
struct intel_crtc *crtc;
2309+
struct intel_crtc_state *crtc_state;
2310+
int vco, i;
2311+
2312+
vco = intel_state->cdclk.logical.vco;
2313+
if (!vco)
2314+
vco = dev_priv->skl_preferred_vco_freq;
2315+
2316+
for_each_new_intel_crtc_in_state(intel_state, crtc, crtc_state, i) {
2317+
if (!crtc_state->base.enable)
2318+
continue;
2319+
2320+
if (!intel_crtc_has_type(crtc_state, INTEL_OUTPUT_EDP))
2321+
continue;
2322+
2323+
/*
2324+
* DPLL0 VCO may need to be adjusted to get the correct
2325+
* clock for eDP. This will affect cdclk as well.
2326+
*/
2327+
switch (crtc_state->port_clock / 2) {
2328+
case 108000:
2329+
case 216000:
2330+
vco = 8640000;
2331+
break;
2332+
default:
2333+
vco = 8100000;
2334+
break;
2335+
}
2336+
}
2337+
2338+
return vco;
2339+
}
2340+
23052341
static int skl_modeset_calc_cdclk(struct drm_atomic_state *state)
23062342
{
2307-
struct drm_i915_private *dev_priv = to_i915(state->dev);
23082343
struct intel_atomic_state *intel_state = to_intel_atomic_state(state);
23092344
int min_cdclk, cdclk, vco;
23102345

23112346
min_cdclk = intel_compute_min_cdclk(state);
23122347
if (min_cdclk < 0)
23132348
return min_cdclk;
23142349

2315-
vco = intel_state->cdclk.logical.vco;
2316-
if (!vco)
2317-
vco = dev_priv->skl_preferred_vco_freq;
2350+
vco = skl_dpll0_vco(intel_state);
23182351

23192352
/*
23202353
* FIXME should also account for plane ratio

drivers/gpu/drm/i915/intel_dp.c

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1929,26 +1929,6 @@ intel_dp_compute_config(struct intel_encoder *encoder,
19291929
reduce_m_n);
19301930
}
19311931

1932-
/*
1933-
* DPLL0 VCO may need to be adjusted to get the correct
1934-
* clock for eDP. This will affect cdclk as well.
1935-
*/
1936-
if (intel_dp_is_edp(intel_dp) && IS_GEN9_BC(dev_priv)) {
1937-
int vco;
1938-
1939-
switch (pipe_config->port_clock / 2) {
1940-
case 108000:
1941-
case 216000:
1942-
vco = 8640000;
1943-
break;
1944-
default:
1945-
vco = 8100000;
1946-
break;
1947-
}
1948-
1949-
to_intel_atomic_state(pipe_config->base.state)->cdclk.logical.vco = vco;
1950-
}
1951-
19521932
if (!HAS_DDI(dev_priv))
19531933
intel_dp_set_clock(encoder, pipe_config);
19541934

0 commit comments

Comments
 (0)