Skip to content

Commit 998d2cd

Browse files
committed
drm/i915/fdi: Improve FDI BW sharing between pipe B and C
At the moment modesetting pipe C on IVB will fail if pipe B uses 4 FDI lanes. Make the BW sharing more dynamic by trying to reduce pipe B's link bpp in this case, until pipe B uses only up to 2 FDI lanes. For this instead of the encoder compute config retry loop - which reduced link bpp only for the encoder's pipe - reduce the maximum link bpp for pipe B/C as required after all CRTC states are computed and recompute the CRTC states with the new bpp limit. Atm, all FDI encoder's compute config function returns an error if a BW constrain prevents increasing the pipe bpp value. The corresponding crtc_state->bw_constrained check can be replaced with checking crtc_state->max_link_bpp_x16, add TODO comments for this. SDVO is an exception where this case is only handled in the outer config retry loop, failing the modeset with a WARN, add a FIXME comment to handle this in the encoder code similarly to other encoders. v2: - Don't assume that a CRTC is already in the atomic state, while reducing its link bpp. - Add DocBook description to intel_fdi_atomic_check_link(). v3: - Enable BW management for FDI links in a separate patch. (Ville) v4: (Ville) - Fail the SDVO encoder config computation if it doesn't support the link bpp limit. - Add TODO: comments about checking link_bpp_x16 instead of bw_constrained. v5: - Replace link bpp limit check with a FIXME: comment in intel_sdvo_compute_config(). (Ville) Cc: Ville Syrjälä <[email protected]> Reviewed-by: Ville Syrjälä <[email protected]> [Amended commit message wrt. changes in v5] Signed-off-by: Imre Deak <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 8ca0b87 commit 998d2cd

File tree

9 files changed

+140
-40
lines changed

9 files changed

+140
-40
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "intel_display_types.h"
1717
#include "intel_dp_aux.h"
1818
#include "intel_dpio_phy.h"
19+
#include "intel_fdi.h"
1920
#include "intel_fifo_underrun.h"
2021
#include "intel_hdmi.h"
2122
#include "intel_hotplug.h"
@@ -133,8 +134,11 @@ static int g4x_hdmi_compute_config(struct intel_encoder *encoder,
133134
struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
134135
struct drm_i915_private *i915 = to_i915(encoder->base.dev);
135136

136-
if (HAS_PCH_SPLIT(i915))
137+
if (HAS_PCH_SPLIT(i915)) {
137138
crtc_state->has_pch_encoder = true;
139+
if (!intel_fdi_compute_pipe_bpp(crtc_state))
140+
return -EINVAL;
141+
}
138142

139143
if (IS_G4X(i915))
140144
crtc_state->has_hdmi_sink = g4x_compute_has_hdmi_sink(state, crtc);

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,9 @@ static int pch_crt_compute_config(struct intel_encoder *encoder,
413413
return -EINVAL;
414414

415415
pipe_config->has_pch_encoder = true;
416+
if (!intel_fdi_compute_pipe_bpp(pipe_config))
417+
return -EINVAL;
418+
416419
pipe_config->output_format = INTEL_OUTPUT_FORMAT_RGB;
417420

418421
return 0;
@@ -435,10 +438,14 @@ static int hsw_crt_compute_config(struct intel_encoder *encoder,
435438
return -EINVAL;
436439

437440
pipe_config->has_pch_encoder = true;
441+
if (!intel_fdi_compute_pipe_bpp(pipe_config))
442+
return -EINVAL;
443+
438444
pipe_config->output_format = INTEL_OUTPUT_FORMAT_RGB;
439445

440446
/* LPT FDI RX only supports 8bpc. */
441447
if (HAS_PCH_LPT(dev_priv)) {
448+
/* TODO: Check crtc_state->max_link_bpp_x16 instead of bw_constrained */
442449
if (pipe_config->bw_constrained && pipe_config->pipe_bpp < 24) {
443450
drm_dbg_kms(&dev_priv->drm,
444451
"LPT only supports 24bpp\n");

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

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4655,7 +4655,6 @@ intel_modeset_pipe_config(struct intel_atomic_state *state,
46554655
struct drm_connector_state *connector_state;
46564656
int pipe_src_w, pipe_src_h;
46574657
int base_bpp, ret, i;
4658-
bool retry = true;
46594658

46604659
crtc_state->cpu_transcoder = (enum transcoder) crtc->pipe;
46614660

@@ -4685,6 +4684,7 @@ intel_modeset_pipe_config(struct intel_atomic_state *state,
46854684
"[CRTC:%d:%s] Link bpp limited to " BPP_X16_FMT "\n",
46864685
crtc->base.base.id, crtc->base.name,
46874686
BPP_X16_ARGS(crtc_state->max_link_bpp_x16));
4687+
crtc_state->bw_constrained = true;
46884688
}
46894689

46904690
base_bpp = crtc_state->pipe_bpp;
@@ -4728,7 +4728,6 @@ intel_modeset_pipe_config(struct intel_atomic_state *state,
47284728
crtc_state->output_types |= BIT(encoder->type);
47294729
}
47304730

4731-
encoder_retry:
47324731
/* Ensure the port clock defaults are reset when retrying. */
47334732
crtc_state->port_clock = 0;
47344733
crtc_state->pixel_multiplier = 1;
@@ -4768,17 +4767,6 @@ intel_modeset_pipe_config(struct intel_atomic_state *state,
47684767
ret = intel_crtc_compute_config(state, crtc);
47694768
if (ret == -EDEADLK)
47704769
return ret;
4771-
if (ret == -EAGAIN) {
4772-
if (drm_WARN(&i915->drm, !retry,
4773-
"[CRTC:%d:%s] loop in pipe configuration computation\n",
4774-
crtc->base.base.id, crtc->base.name))
4775-
return -EINVAL;
4776-
4777-
drm_dbg_kms(&i915->drm, "[CRTC:%d:%s] bw constrained, retrying\n",
4778-
crtc->base.base.id, crtc->base.name);
4779-
retry = false;
4780-
goto encoder_retry;
4781-
}
47824770
if (ret < 0) {
47834771
drm_dbg_kms(&i915->drm, "[CRTC:%d:%s] config failure: %d\n",
47844772
crtc->base.base.id, crtc->base.name, ret);

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2219,7 +2219,8 @@ intel_dp_compute_config_link_bpp_limits(struct intel_dp *intel_dp,
22192219
const struct intel_encoder *encoder = &dp_to_dig_port(intel_dp)->base;
22202220
int max_link_bpp_x16;
22212221

2222-
max_link_bpp_x16 = to_bpp_x16(limits->pipe.max_bpp);
2222+
max_link_bpp_x16 = min(crtc_state->max_link_bpp_x16,
2223+
to_bpp_x16(limits->pipe.max_bpp));
22232224

22242225
if (!dsc) {
22252226
max_link_bpp_x16 = rounddown(max_link_bpp_x16, to_bpp_x16(2 * 3));

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

Lines changed: 95 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "intel_display_types.h"
1414
#include "intel_fdi.h"
1515
#include "intel_fdi_regs.h"
16+
#include "intel_link_bw.h"
1617

1718
struct intel_fdi_funcs {
1819
void (*fdi_link_train)(struct intel_crtc *crtc,
@@ -129,13 +130,16 @@ static int pipe_required_fdi_lanes(struct intel_crtc_state *crtc_state)
129130
}
130131

131132
static int ilk_check_fdi_lanes(struct drm_device *dev, enum pipe pipe,
132-
struct intel_crtc_state *pipe_config)
133+
struct intel_crtc_state *pipe_config,
134+
enum pipe *pipe_to_reduce)
133135
{
134136
struct drm_i915_private *dev_priv = to_i915(dev);
135137
struct drm_atomic_state *state = pipe_config->uapi.state;
136138
struct intel_crtc *other_crtc;
137139
struct intel_crtc_state *other_crtc_state;
138140

141+
*pipe_to_reduce = pipe;
142+
139143
drm_dbg_kms(&dev_priv->drm,
140144
"checking fdi config on pipe %c, lanes %i\n",
141145
pipe_name(pipe), pipe_config->fdi_lanes);
@@ -198,6 +202,9 @@ static int ilk_check_fdi_lanes(struct drm_device *dev, enum pipe pipe,
198202
if (pipe_required_fdi_lanes(other_crtc_state) > 2) {
199203
drm_dbg_kms(&dev_priv->drm,
200204
"fdi link B uses too many lanes to enable link C\n");
205+
206+
*pipe_to_reduce = PIPE_B;
207+
201208
return -EINVAL;
202209
}
203210
return 0;
@@ -232,16 +239,42 @@ int intel_fdi_link_freq(struct drm_i915_private *i915,
232239
return i915->display.fdi.pll_freq;
233240
}
234241

242+
/**
243+
* intel_fdi_compute_pipe_bpp - compute pipe bpp limited by max link bpp
244+
* @crtc_state: the crtc state
245+
*
246+
* Compute the pipe bpp limited by the CRTC's maximum link bpp. Encoders can
247+
* call this function during state computation in the simple case where the
248+
* link bpp will always match the pipe bpp. This is the case for all non-DP
249+
* encoders, while DP encoders will use a link bpp lower than pipe bpp in case
250+
* of DSC compression.
251+
*
252+
* Returns %true in case of success, %false if pipe bpp would need to be
253+
* reduced below its valid range.
254+
*/
255+
bool intel_fdi_compute_pipe_bpp(struct intel_crtc_state *crtc_state)
256+
{
257+
int pipe_bpp = min(crtc_state->pipe_bpp,
258+
to_bpp_int(crtc_state->max_link_bpp_x16));
259+
260+
pipe_bpp = rounddown(pipe_bpp, 2 * 3);
261+
262+
if (pipe_bpp < 6 * 3)
263+
return false;
264+
265+
crtc_state->pipe_bpp = pipe_bpp;
266+
267+
return true;
268+
}
269+
235270
int ilk_fdi_compute_config(struct intel_crtc *crtc,
236271
struct intel_crtc_state *pipe_config)
237272
{
238273
struct drm_device *dev = crtc->base.dev;
239274
struct drm_i915_private *i915 = to_i915(dev);
240275
const struct drm_display_mode *adjusted_mode = &pipe_config->hw.adjusted_mode;
241-
int lane, link_bw, fdi_dotclock, ret;
242-
bool needs_recompute = false;
276+
int lane, link_bw, fdi_dotclock;
243277

244-
retry:
245278
/* FDI is a binary signal running at ~2.7GHz, encoding
246279
* each output octet as 10 bits. The actual frequency
247280
* is stored as a divider into a 100MHz clock, and the
@@ -261,25 +294,69 @@ int ilk_fdi_compute_config(struct intel_crtc *crtc,
261294
intel_link_compute_m_n(pipe_config->pipe_bpp, lane, fdi_dotclock,
262295
link_bw, &pipe_config->fdi_m_n, false);
263296

264-
ret = ilk_check_fdi_lanes(dev, crtc->pipe, pipe_config);
265-
if (ret == -EDEADLK)
297+
return 0;
298+
}
299+
300+
static int intel_fdi_atomic_check_bw(struct intel_atomic_state *state,
301+
struct intel_crtc *crtc,
302+
struct intel_crtc_state *pipe_config,
303+
struct intel_link_bw_limits *limits)
304+
{
305+
struct drm_i915_private *i915 = to_i915(crtc->base.dev);
306+
enum pipe pipe_to_reduce;
307+
int ret;
308+
309+
ret = ilk_check_fdi_lanes(&i915->drm, crtc->pipe, pipe_config,
310+
&pipe_to_reduce);
311+
if (ret != -EINVAL)
266312
return ret;
267313

268-
if (ret == -EINVAL && pipe_config->pipe_bpp > 6*3) {
269-
pipe_config->pipe_bpp -= 2*3;
270-
drm_dbg_kms(&i915->drm,
271-
"fdi link bw constraint, reducing pipe bpp to %i\n",
272-
pipe_config->pipe_bpp);
273-
needs_recompute = true;
274-
pipe_config->bw_constrained = true;
314+
ret = intel_link_bw_reduce_bpp(state, limits,
315+
BIT(pipe_to_reduce),
316+
"FDI link BW");
275317

276-
goto retry;
277-
}
318+
return ret ? : -EAGAIN;
319+
}
278320

279-
if (needs_recompute)
280-
return -EAGAIN;
321+
/**
322+
* intel_fdi_atomic_check_link - check all modeset FDI link configuration
323+
* @state: intel atomic state
324+
* @limits: link BW limits
325+
*
326+
* Check the link configuration for all modeset FDI outputs. If the
327+
* configuration is invalid @limits will be updated if possible to
328+
* reduce the total BW, after which the configuration for all CRTCs in
329+
* @state must be recomputed with the updated @limits.
330+
*
331+
* Returns:
332+
* - 0 if the confugration is valid
333+
* - %-EAGAIN, if the configuration is invalid and @limits got updated
334+
* with fallback values with which the configuration of all CRTCs
335+
* in @state must be recomputed
336+
* - Other negative error, if the configuration is invalid without a
337+
* fallback possibility, or the check failed for another reason
338+
*/
339+
int intel_fdi_atomic_check_link(struct intel_atomic_state *state,
340+
struct intel_link_bw_limits *limits)
341+
{
342+
struct intel_crtc *crtc;
343+
struct intel_crtc_state *crtc_state;
344+
int i;
345+
346+
for_each_new_intel_crtc_in_state(state, crtc, crtc_state, i) {
347+
int ret;
348+
349+
if (!crtc_state->has_pch_encoder ||
350+
!intel_crtc_needs_modeset(crtc_state) ||
351+
!crtc_state->hw.enable)
352+
continue;
281353

282-
return ret;
354+
ret = intel_fdi_atomic_check_bw(state, crtc, crtc_state, limits);
355+
if (ret)
356+
return ret;
357+
}
358+
359+
return 0;
283360
}
284361

285362
static void cpt_set_fdi_bc_bifurcation(struct drm_i915_private *dev_priv, bool enable)

drivers/gpu/drm/i915/display/intel_fdi.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,23 @@
66
#ifndef _INTEL_FDI_H_
77
#define _INTEL_FDI_H_
88

9+
#include <linux/types.h>
10+
911
enum pipe;
1012
struct drm_i915_private;
13+
struct intel_atomic_state;
1114
struct intel_crtc;
1215
struct intel_crtc_state;
1316
struct intel_encoder;
17+
struct intel_link_bw_limits;
1418

1519
int intel_fdi_link_freq(struct drm_i915_private *i915,
1620
const struct intel_crtc_state *pipe_config);
21+
bool intel_fdi_compute_pipe_bpp(struct intel_crtc_state *crtc_state);
1722
int ilk_fdi_compute_config(struct intel_crtc *intel_crtc,
1823
struct intel_crtc_state *pipe_config);
24+
int intel_fdi_atomic_check_link(struct intel_atomic_state *state,
25+
struct intel_link_bw_limits *limits);
1926
void intel_fdi_normal_train(struct intel_crtc *crtc);
2027
void ilk_fdi_disable(struct intel_crtc *crtc);
2128
void ilk_fdi_pll_disable(struct intel_crtc *intel_crtc);

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
#include "intel_atomic.h"
99
#include "intel_display_types.h"
10+
#include "intel_fdi.h"
1011
#include "intel_link_bw.h"
1112

1213
/**
@@ -139,7 +140,13 @@ intel_link_bw_set_bpp_limit_for_pipe(struct intel_atomic_state *state,
139140
static int check_all_link_config(struct intel_atomic_state *state,
140141
struct intel_link_bw_limits *limits)
141142
{
142-
/* TODO: Check all shared display link configurations like FDI */
143+
/* TODO: Check additional shared display link configurations like MST */
144+
int ret;
145+
146+
ret = intel_fdi_atomic_check_link(state, limits);
147+
if (ret)
148+
return ret;
149+
143150
return 0;
144151
}
145152

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -425,11 +425,18 @@ static int intel_lvds_compute_config(struct intel_encoder *encoder,
425425
return -EINVAL;
426426
}
427427

428+
if (HAS_PCH_SPLIT(i915)) {
429+
crtc_state->has_pch_encoder = true;
430+
if (!intel_fdi_compute_pipe_bpp(crtc_state))
431+
return -EINVAL;
432+
}
433+
428434
if (lvds_encoder->a3_power == LVDS_A3_POWER_UP)
429435
lvds_bpp = 8*3;
430436
else
431437
lvds_bpp = 6*3;
432438

439+
/* TODO: Check crtc_state->max_link_bpp_x16 instead of bw_constrained */
433440
if (lvds_bpp != crtc_state->pipe_bpp && !crtc_state->bw_constrained) {
434441
drm_dbg_kms(&i915->drm,
435442
"forcing display bpp (was %d) to LVDS (%d)\n",
@@ -453,9 +460,6 @@ static int intel_lvds_compute_config(struct intel_encoder *encoder,
453460
if (adjusted_mode->flags & DRM_MODE_FLAG_DBLSCAN)
454461
return -EINVAL;
455462

456-
if (HAS_PCH_SPLIT(i915))
457-
crtc_state->has_pch_encoder = true;
458-
459463
ret = intel_panel_fitting(crtc_state, conn_state);
460464
if (ret)
461465
return ret;

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
#include "intel_crtc.h"
4545
#include "intel_de.h"
4646
#include "intel_display_types.h"
47+
#include "intel_fdi.h"
4748
#include "intel_fifo_underrun.h"
4849
#include "intel_gmbus.h"
4950
#include "intel_hdmi.h"
@@ -1351,14 +1352,18 @@ static int intel_sdvo_compute_config(struct intel_encoder *encoder,
13511352
struct drm_display_mode *adjusted_mode = &pipe_config->hw.adjusted_mode;
13521353
struct drm_display_mode *mode = &pipe_config->hw.mode;
13531354

1355+
if (HAS_PCH_SPLIT(to_i915(encoder->base.dev))) {
1356+
pipe_config->has_pch_encoder = true;
1357+
if (!intel_fdi_compute_pipe_bpp(pipe_config))
1358+
return -EINVAL;
1359+
}
1360+
13541361
DRM_DEBUG_KMS("forcing bpc to 8 for SDVO\n");
1362+
/* FIXME: Don't increase pipe_bpp */
13551363
pipe_config->pipe_bpp = 8*3;
13561364
pipe_config->sink_format = INTEL_OUTPUT_FORMAT_RGB;
13571365
pipe_config->output_format = INTEL_OUTPUT_FORMAT_RGB;
13581366

1359-
if (HAS_PCH_SPLIT(to_i915(encoder->base.dev)))
1360-
pipe_config->has_pch_encoder = true;
1361-
13621367
/*
13631368
* We need to construct preferred input timings based on our
13641369
* output timings. To do that, we have to set the output

0 commit comments

Comments
 (0)