/* * Read the LTTPR common capabilities and switch the LTTPR PHYs to * non-transparent mode if this is supported. Preserve the * transparent/non-transparent mode on an active link. * * Return the number of detected LTTPRs in non-transparent mode or 0 if the * LTTPRs are in transparent mode or the detection failed.
*/ staticint intel_dp_init_lttpr_phys(struct intel_dp *intel_dp, const u8 dpcd[DP_RECEIVER_CAP_SIZE])
{ int lttpr_count; int ret;
if (!intel_dp_read_lttpr_common_caps(intel_dp, dpcd)) return 0;
lttpr_count = drm_dp_lttpr_count(intel_dp->lttpr_common_caps); /* * Prevent setting LTTPR transparent mode explicitly if no LTTPRs are * detected as this breaks link training at least on the Dell WD19TB * dock.
*/ if (lttpr_count == 0) return 0;
/* * Don't change the mode on an active link, to prevent a loss of link * synchronization. See DP Standard v2.0 3.6.7. about the LTTPR * resetting its internal state when the mode is changed from * non-transparent to transparent.
*/ if (intel_dp->link.active) { if (lttpr_count < 0 || intel_dp_lttpr_transparent_mode_enabled(intel_dp)) goto out_reset_lttpr_count;
return lttpr_count;
}
ret = drm_dp_lttpr_init(&intel_dp->aux, lttpr_count); if (ret) {
lt_dbg(intel_dp, DP_PHY_DPRX, "Switching to LTTPR non-transparent LT mode failed, fall-back to transparent mode\n");
for (i = 0; i < lttpr_count; i++) {
intel_dp_read_lttpr_phy_caps(intel_dp, dpcd, DP_PHY_LTTPR(i));
drm_dp_dump_lttpr_desc(&intel_dp->aux, DP_PHY_LTTPR(i));
}
/* * Detecting LTTPRs must be avoided on platforms with an AUX timeout * period < 3.2ms. (see DP Standard v2.0, 2.11.2, 3.6.6.1).
*/ if (DISPLAY_VER(display) >= 10 && !display->platform.geminilake) if (drm_dp_dpcd_probe(&intel_dp->aux,
DP_LT_TUNABLE_PHY_REPEATER_FIELD_DATA_STRUCTURE_REV)) return -EIO;
if (drm_dp_read_dpcd_caps(&intel_dp->aux, dpcd)) return -EIO;
return 0;
}
/** * intel_dp_init_lttpr_and_dprx_caps - detect LTTPR and DPRX caps, init the LTTPR link training mode * @intel_dp: Intel DP struct * * Read the LTTPR common and DPRX capabilities and switch to non-transparent * link training mode if any is detected and read the PHY capabilities for all * detected LTTPRs. In case of an LTTPR detection error or if the number of * LTTPRs is more than is supported (8), fall back to the no-LTTPR, * transparent mode link training mode. * * Returns: * >0 if LTTPRs were detected and the non-transparent LT mode was set. The * DPRX capabilities are read out. * 0 if no LTTPRs or more than 8 LTTPRs were detected or in case of a * detection failure and the transparent LT mode was set. The DPRX * capabilities are read out. * <0 Reading out the DPRX capabilities failed.
*/ int intel_dp_init_lttpr_and_dprx_caps(struct intel_dp *intel_dp)
{ struct intel_display *display = to_intel_display(intel_dp); int lttpr_count = 0;
/* * Detecting LTTPRs must be avoided on platforms with an AUX timeout * period < 3.2ms. (see DP Standard v2.0, 2.11.2, 3.6.6.1).
*/ if (!intel_dp_is_edp(intel_dp) &&
(DISPLAY_VER(display) >= 10 && !display->platform.geminilake)) {
u8 dpcd[DP_RECEIVER_CAP_SIZE]; int err = intel_dp_read_dprx_caps(intel_dp, dpcd);
/* * The DPTX shall read the DPRX caps after LTTPR detection, so re-read * it here.
*/ if (drm_dp_read_dpcd_caps(&intel_dp->aux, intel_dp->dpcd)) {
intel_dp_reset_lttpr_common_caps(intel_dp); return -EIO;
}
return lttpr_count;
}
static u8 dp_voltage_max(u8 preemph)
{ switch (preemph & DP_TRAIN_PRE_EMPHASIS_MASK) { case DP_TRAIN_PRE_EMPH_LEVEL_0: return DP_TRAIN_VOLTAGE_SWING_LEVEL_3; case DP_TRAIN_PRE_EMPH_LEVEL_1: return DP_TRAIN_VOLTAGE_SWING_LEVEL_2; case DP_TRAIN_PRE_EMPH_LEVEL_2: return DP_TRAIN_VOLTAGE_SWING_LEVEL_1; case DP_TRAIN_PRE_EMPH_LEVEL_3: default: return DP_TRAIN_VOLTAGE_SWING_LEVEL_0;
}
}
/* * Get voltage_max from the DPTX_PHY (source or LTTPR) upstream from * the DPRX_PHY we train.
*/ if (intel_dp_phy_is_downstream_of_source(intel_dp, dp_phy))
voltage_max = intel_dp->voltage_max(intel_dp, crtc_state); else
voltage_max = intel_dp_lttpr_voltage_max(intel_dp, dp_phy + 1);
/* * Get preemph_max from the DPTX_PHY (source or LTTPR) upstream from * the DPRX_PHY we train.
*/ if (intel_dp_phy_is_downstream_of_source(intel_dp, dp_phy))
preemph_max = intel_dp->preemph_max(intel_dp); else
preemph_max = intel_dp_lttpr_preemph_max(intel_dp, dp_phy + 1);
/* * 8b/10b * * FIXME: The DP spec is very confusing here, also the Link CTS spec seems to * have self contradicting tests around this area. * * In lieu of better ideas let's just stop when we've reached the max supported * vswing with its max pre-emphasis, which is either 2+1 or 3+0 depending on * whether vswing level 3 is supported or not.
*/ staticbool intel_dp_lane_max_vswing_reached(u8 train_set_lane)
{
u8 v = (train_set_lane & DP_TRAIN_VOLTAGE_SWING_MASK) >>
DP_TRAIN_VOLTAGE_SWING_SHIFT;
u8 p = (train_set_lane & DP_TRAIN_PRE_EMPHASIS_MASK) >>
DP_TRAIN_PRE_EMPHASIS_SHIFT;
if ((train_set_lane & DP_TRAIN_MAX_SWING_REACHED) == 0) returnfalse;
if (v + p != 3) returnfalse;
returntrue;
}
staticbool intel_dp_link_max_vswing_reached(struct intel_dp *intel_dp, conststruct intel_crtc_state *crtc_state)
{ int lane;
for (lane = 0; lane < crtc_state->lane_count; lane++) {
u8 train_set_lane = intel_dp->train_set[lane];
if (intel_dp_is_uhbr(crtc_state)) { if (!intel_dp_lane_max_tx_ffe_reached(train_set_lane)) returnfalse;
} else { if (!intel_dp_lane_max_vswing_reached(train_set_lane)) returnfalse;
}
}
staticvoid intel_dp_update_downspread_ctrl(struct intel_dp *intel_dp, conststruct intel_crtc_state *crtc_state)
{ /* * Currently, we set the MSA ignore bit based on vrr.in_range. * We can't really read that out during driver load since we don't have * the connector information read in yet. So if we do end up doing a * modeset during initial_commit() we'll clear the MSA ignore bit. * GOP likely wouldn't have set this bit so after the initial commit, * if there are no modesets and we enable VRR mode seamlessly * (without a full modeset), the MSA ignore bit might never get set. * * #TODO: Implement readout of vrr.in_range. * We need fastset support for setting the MSA ignore bit in DPCD, * especially on the first real commit when clearing the inherited flag.
*/
intel_dp_link_training_set_mode(intel_dp,
crtc_state->port_clock, crtc_state->vrr.in_range);
}
void intel_dp_link_training_set_bw(struct intel_dp *intel_dp, int link_bw, int rate_select, int lane_count, bool enhanced_framing)
{ if (enhanced_framing)
lane_count |= DP_LANE_COUNT_ENHANCED_FRAME_EN;
if (link_bw) { /* DP and eDP v1.3 and earlier link bw set method. */
u8 link_config[] = { link_bw, lane_count };
drm_dp_dpcd_write(&intel_dp->aux, DP_LINK_BW_SET, link_config,
ARRAY_SIZE(link_config));
} else { /* * eDP v1.4 and later link rate set method. * * eDP v1.4x sinks shall ignore DP_LINK_RATE_SET if * DP_LINK_BW_SET is set. Avoid writing DP_LINK_BW_SET. * * eDP v1.5 sinks allow choosing either, and the last choice * shall be active.
*/
drm_dp_dpcd_writeb(&intel_dp->aux, DP_LANE_COUNT_SET, lane_count);
drm_dp_dpcd_writeb(&intel_dp->aux, DP_LINK_RATE_SET, rate_select);
}
}
/* * Prepare link training by configuring the link parameters. On DDI platforms * also enable the port here.
*/ staticbool
intel_dp_prepare_link_train(struct intel_dp *intel_dp, conststruct intel_crtc_state *crtc_state)
{
u8 link_bw, rate_select;
if (intel_dp->prepare_link_retrain)
intel_dp->prepare_link_retrain(intel_dp, crtc_state);
/* * WaEdpLinkRateDataReload * * Parade PS8461E MUX (used on various TGL+ laptops) needs * to snoop the link rates reported by the sink when we * use LINK_RATE_SET in order to operate in jitter cleaning * mode (as opposed to redriver mode). Unfortunately it * loses track of the snooped link rates when powered down, * so we need to make it re-snoop often. Without this high * link rates are not stable.
*/ if (!link_bw) {
__le16 sink_rates[DP_MAX_SUPPORTED_RATES];
lt_dbg(intel_dp, DP_PHY_DPRX, "Reloading eDP link rates\n");
if (link_bw)
lt_dbg(intel_dp, DP_PHY_DPRX, "Using LINK_BW_SET value %02x\n",
link_bw); else
lt_dbg(intel_dp, DP_PHY_DPRX, "Using LINK_RATE_SET value %02x\n",
rate_select); /* * Spec DP2.1 Section 3.5.2.16 * Prior to LT DPTX should set 128b/132b DP Channel coding and then set link rate
*/
intel_dp_update_downspread_ctrl(intel_dp, crtc_state);
intel_dp_update_link_bw_set(intel_dp, crtc_state, link_bw,
rate_select);
/* * Perform the link training clock recovery phase on the given DP PHY using * training pattern 1.
*/ staticbool
intel_dp_link_training_clock_recovery(struct intel_dp *intel_dp, conststruct intel_crtc_state *crtc_state, enum drm_dp_phy dp_phy)
{
u8 old_link_status[DP_LINK_STATUS_SIZE] = {}; int voltage_tries, cr_tries, max_cr_tries;
u8 link_status[DP_LINK_STATUS_SIZE]; bool max_vswing_reached = false; int delay_us;
/* clock recovery */ if (!intel_dp_reset_link_train(intel_dp, crtc_state, dp_phy,
DP_TRAINING_PATTERN_1 |
DP_LINK_SCRAMBLING_DISABLE)) {
lt_err(intel_dp, dp_phy, "Failed to enable link training\n"); returnfalse;
}
/* * The DP 1.4 spec defines the max clock recovery retries value * as 10 but for pre-DP 1.4 devices we set a very tolerant * retry limit of 80 (4 voltage levels x 4 preemphasis levels x * x 5 identical voltage retries). Since the previous specs didn't * define a limit and created the possibility of an infinite loop * we want to prevent any sync from triggering that corner case.
*/ if (intel_dp->dpcd[DP_DPCD_REV] >= DP_DPCD_REV_14)
max_cr_tries = 10; else
max_cr_tries = 80;
if (drm_dp_dpcd_read_phy_link_status(&intel_dp->aux, dp_phy,
link_status) < 0) {
lt_err(intel_dp, dp_phy, "Failed to get link status\n"); returnfalse;
}
if (voltage_tries == 5) {
intel_dp_dump_link_status(intel_dp, dp_phy, link_status);
lt_dbg(intel_dp, dp_phy, "Same voltage tried 5 times\n"); returnfalse;
}
if (max_vswing_reached) {
intel_dp_dump_link_status(intel_dp, dp_phy, link_status);
lt_dbg(intel_dp, dp_phy, "Max Voltage Swing reached\n"); returnfalse;
}
/* Update training set as requested by target */
intel_dp_get_adjust_train(intel_dp, crtc_state, dp_phy,
link_status); if (!intel_dp_update_link_train(intel_dp, crtc_state, dp_phy)) {
lt_err(intel_dp, dp_phy, "Failed to update link training\n"); returnfalse;
}
if (!intel_dp_adjust_request_changed(crtc_state, old_link_status, link_status))
++voltage_tries; else
voltage_tries = 1;
/* * Pick Training Pattern Sequence (TPS) for channel equalization. 128b/132b TPS2 * for UHBR+, TPS4 for HBR3 or for 1.4 devices that support it, TPS3 for HBR2 or * 1.2 devices that support it, TPS2 otherwise.
*/ static u32 intel_dp_training_pattern(struct intel_dp *intel_dp, conststruct intel_crtc_state *crtc_state, enum drm_dp_phy dp_phy)
{ struct intel_display *display = to_intel_display(intel_dp); bool source_tps3, sink_tps3, source_tps4, sink_tps4;
/* UHBR+ use separate 128b/132b TPS2 */ if (intel_dp_is_uhbr(crtc_state)) return DP_TRAINING_PATTERN_2;
/* * TPS4 support is mandatory for all downstream devices that * support HBR3. There are no known eDP panels that support * TPS4 as of Feb 2018 as per VESA eDP_v1.4b_E1 specification. * LTTPRs must support TPS4.
*/
source_tps4 = intel_dp_source_supports_tps4(display);
sink_tps4 = dp_phy != DP_PHY_DPRX ||
drm_dp_tps4_supported(intel_dp->dpcd); if (source_tps4 && sink_tps4) { return DP_TRAINING_PATTERN_4;
} elseif (crtc_state->port_clock == 810000) { if (!source_tps4)
lt_dbg(intel_dp, dp_phy, "8.1 Gbps link rate without source TPS4 support\n"); if (!sink_tps4)
lt_dbg(intel_dp, dp_phy, "8.1 Gbps link rate without sink TPS4 support\n");
}
/* * TPS3 support is mandatory for downstream devices that * support HBR2. However, not all sinks follow the spec.
*/
source_tps3 = intel_dp_source_supports_tps3(display);
sink_tps3 = dp_phy != DP_PHY_DPRX ||
drm_dp_tps3_supported(intel_dp->dpcd); if (source_tps3 && sink_tps3) { return DP_TRAINING_PATTERN_3;
} elseif (crtc_state->port_clock >= 540000) { if (!source_tps3)
lt_dbg(intel_dp, dp_phy, ">=5.4/6.48 Gbps link rate without source TPS3 support\n"); if (!sink_tps3)
lt_dbg(intel_dp, dp_phy, ">=5.4/6.48 Gbps link rate without sink TPS3 support\n");
}
return DP_TRAINING_PATTERN_2;
}
/* * Perform the link training channel equalization phase on the given DP PHY * using one of training pattern 2, 3 or 4 depending on the source and * sink capabilities.
*/ staticbool
intel_dp_link_training_channel_equalization(struct intel_dp *intel_dp, conststruct intel_crtc_state *crtc_state, enum drm_dp_phy dp_phy)
{ int tries;
u32 training_pattern;
u8 link_status[DP_LINK_STATUS_SIZE]; bool channel_eq = false; int delay_us;
training_pattern = intel_dp_training_pattern(intel_dp, crtc_state, dp_phy); /* Scrambling is disabled for TPS2/3 and enabled for TPS4 */ if (training_pattern != DP_TRAINING_PATTERN_4)
training_pattern |= DP_LINK_SCRAMBLING_DISABLE;
/* channel equalization */ if (!intel_dp_set_link_train(intel_dp, crtc_state, dp_phy,
training_pattern)) {
lt_err(intel_dp, dp_phy, "Failed to start channel equalization\n"); returnfalse;
}
for (tries = 0; tries < 5; tries++) {
fsleep(delay_us);
if (drm_dp_dpcd_read_phy_link_status(&intel_dp->aux, dp_phy,
link_status) < 0) {
lt_err(intel_dp, dp_phy, "Failed to get link status\n"); break;
}
/* Make sure clock is still ok */ if (!drm_dp_clock_recovery_ok(link_status,
crtc_state->lane_count)) {
intel_dp_dump_link_status(intel_dp, dp_phy, link_status);
lt_dbg(intel_dp, dp_phy, "Clock recovery check failed, cannot continue channel equalization\n"); break;
}
if (drm_dp_channel_eq_ok(link_status,
crtc_state->lane_count)) {
channel_eq = true;
lt_dbg(intel_dp, dp_phy, "Channel EQ done. DP Training successful\n"); break;
}
/* Update training set as requested by target */
intel_dp_get_adjust_train(intel_dp, crtc_state, dp_phy,
link_status); if (!intel_dp_update_link_train(intel_dp, crtc_state, dp_phy)) {
lt_err(intel_dp, dp_phy, "Failed to update link training\n"); break;
}
}
/* Try 5 times, else fail and try at lower BW */ if (tries == 5) {
intel_dp_dump_link_status(intel_dp, dp_phy, link_status);
lt_dbg(intel_dp, dp_phy, "Channel equalization failed 5 times\n");
}
return channel_eq;
}
staticbool intel_dp_disable_dpcd_training_pattern(struct intel_dp *intel_dp, enum drm_dp_phy dp_phy)
{ int reg = intel_dp_training_pattern_set_reg(intel_dp, dp_phy);
u8 val = DP_TRAINING_PATTERN_DISABLE;
/** * intel_dp_stop_link_train - stop link training * @intel_dp: DP struct * @crtc_state: state for CRTC attached to the encoder * * Stop the link training of the @intel_dp port, disabling the training * pattern in the sink's DPCD, and disabling the test pattern symbol * generation on the port. * * What symbols are output on the port after this point is * platform specific: On DDI/VLV/CHV platforms it will be the idle pattern * with the pipe being disabled, on older platforms it's HW specific if/how an * idle pattern is generated, as the pipe is already enabled here for those. * * This function must be called after intel_dp_start_link_train().
*/ void intel_dp_stop_link_train(struct intel_dp *intel_dp, conststruct intel_crtc_state *crtc_state)
{ struct intel_display *display = to_intel_display(intel_dp); struct intel_encoder *encoder = &dp_to_dig_port(intel_dp)->base;
if (!intel_dp_link_training_clock_recovery(intel_dp, crtc_state, dp_phy)) goto out;
if (!intel_dp_link_training_channel_equalization(intel_dp, crtc_state, dp_phy)) goto out;
ret = true;
out:
lt_dbg(intel_dp, dp_phy, "Link Training %s at link rate = %d, lane count = %d\n",
ret ? "passed" : "failed",
crtc_state->port_clock, crtc_state->lane_count);
return ret;
}
staticbool intel_dp_can_link_train_fallback_for_edp(struct intel_dp *intel_dp, int link_rate,
u8 lane_count)
{ /* FIXME figure out what we actually want here */ conststruct drm_display_mode *fixed_mode =
intel_panel_preferred_fixed_mode(intel_dp->attached_connector); int mode_rate, max_rate;
staticbool reduce_link_params_in_bw_order(struct intel_dp *intel_dp, conststruct intel_crtc_state *crtc_state, int *new_link_rate, int *new_lane_count)
{ int link_rate; int lane_count; int i;
i = intel_dp_link_config_index(intel_dp, crtc_state->port_clock, crtc_state->lane_count); for (i--; i >= 0; i--) {
intel_dp_link_config_get(intel_dp, i, &link_rate, &lane_count);
/* TODO: Make switching from UHBR to non-UHBR rates work. */ if (drm_dp_is_uhbr_rate(current_rate) != drm_dp_is_uhbr_rate(new_rate)) return -1;
return new_rate;
}
staticint reduce_lane_count(struct intel_dp *intel_dp, int current_lane_count)
{ if (intel_dp->link.force_lane_count) return -1;
if (current_lane_count == 1) return -1;
return current_lane_count >> 1;
}
staticbool reduce_link_params_in_rate_lane_order(struct intel_dp *intel_dp, conststruct intel_crtc_state *crtc_state, int *new_link_rate, int *new_lane_count)
{ int link_rate; int lane_count;
staticbool reduce_link_params(struct intel_dp *intel_dp, conststruct intel_crtc_state *crtc_state, int *new_link_rate, int *new_lane_count)
{ /* TODO: Use the same fallback logic on SST as on MST. */ if (intel_crtc_has_type(crtc_state, INTEL_OUTPUT_DP_MST)) return reduce_link_params_in_bw_order(intel_dp, crtc_state,
new_link_rate, new_lane_count); else return reduce_link_params_in_rate_lane_order(intel_dp, crtc_state,
new_link_rate, new_lane_count);
}
staticint intel_dp_get_link_train_fallback_values(struct intel_dp *intel_dp, conststruct intel_crtc_state *crtc_state)
{ int new_link_rate; int new_lane_count;
if (intel_dp_is_edp(intel_dp) && !intel_dp->use_max_params) {
lt_dbg(intel_dp, DP_PHY_DPRX, "Retrying Link training for eDP with max parameters\n");
intel_dp->use_max_params = true; return 0;
}
if (!reduce_link_params(intel_dp, crtc_state, &new_link_rate, &new_lane_count)) return -1;
if (intel_dp_is_edp(intel_dp) &&
!intel_dp_can_link_train_fallback_for_edp(intel_dp, new_link_rate, new_lane_count)) {
lt_dbg(intel_dp, DP_PHY_DPRX, "Retrying Link training for eDP with same parameters\n"); return 0;
}
lt_dbg(intel_dp, DP_PHY_DPRX, "Reducing link parameters from %dx%d to %dx%d\n",
crtc_state->lane_count, crtc_state->port_clock,
new_lane_count, new_link_rate);
if (!intel_digital_port_connected(&dp_to_dig_port(intel_dp)->base)) {
lt_dbg(intel_dp, DP_PHY_DPRX, "Link Training failed on disconnected sink.\n"); returntrue;
}
if (intel_dp->hobl_active) {
lt_dbg(intel_dp, DP_PHY_DPRX, "Link Training failed with HOBL active, not enabling it from now on\n");
intel_dp->hobl_failed = true;
} elseif (intel_dp_get_link_train_fallback_values(intel_dp, crtc_state)) { returnfalse;
}
/* Schedule a Hotplug Uevent to userspace to start modeset */
intel_dp_queue_modeset_retry_for_link(state, encoder, crtc_state);
returntrue;
}
/* Perform the link training on all LTTPRs and the DPRX on a link. */ staticbool
intel_dp_link_train_all_phys(struct intel_dp *intel_dp, conststruct intel_crtc_state *crtc_state, int lttpr_count)
{ bool ret = true; int i;
for (i = lttpr_count - 1; i >= 0; i--) { enum drm_dp_phy dp_phy = DP_PHY_LTTPR(i);
ret = intel_dp_link_train_phy(intel_dp, crtc_state, dp_phy);
intel_dp_disable_dpcd_training_pattern(intel_dp, dp_phy);
if (!ret) break;
}
if (ret)
ret = intel_dp_link_train_phy(intel_dp, crtc_state, DP_PHY_DPRX);
if (intel_dp->set_idle_link_train)
intel_dp->set_idle_link_train(intel_dp, crtc_state);
/* * Reset signal levels. Start transmitting 128b/132b TPS1. * * Put DPRX and LTTPRs (if any) into intra-hop AUX mode by writing TPS1 * in DP_TRAINING_PATTERN_SET.
*/ if (!intel_dp_reset_link_train(intel_dp, crtc_state, DP_PHY_DPRX,
DP_TRAINING_PATTERN_1)) {
lt_err(intel_dp, DP_PHY_DPRX, "Failed to start 128b/132b TPS1\n"); returnfalse;
}
/* Read the initial TX FFE settings. */ if (drm_dp_dpcd_read_link_status(&intel_dp->aux, link_status) < 0) {
lt_err(intel_dp, DP_PHY_DPRX, "Failed to read TX FFE presets\n"); returnfalse;
}
/* Update signal levels and training set as requested. */
intel_dp_get_adjust_train(intel_dp, crtc_state, DP_PHY_DPRX, link_status); if (!intel_dp_update_link_train(intel_dp, crtc_state, DP_PHY_DPRX)) {
lt_err(intel_dp, DP_PHY_DPRX, "Failed to set initial TX FFE settings\n"); returnfalse;
}
/* Time budget for the LANEx_EQ_DONE Sequence */
deadline = jiffies + msecs_to_jiffies_timeout(450);
for (try = 0; try < max_tries; try++) {
fsleep(delay_us);
if (drm_dp_dpcd_read_link_status(&intel_dp->aux, link_status) < 0) {
lt_err(intel_dp, DP_PHY_DPRX, "Failed to read link status\n"); returnfalse;
}
if (drm_dp_128b132b_link_training_failed(link_status)) {
intel_dp_dump_link_status(intel_dp, DP_PHY_DPRX, link_status);
lt_err(intel_dp, DP_PHY_DPRX, "Downstream link training failure\n"); returnfalse;
}
if (time_after(jiffies, deadline))
timeout = true; /* try one last time after deadline */
/* * During LT, Tx shall read AUX_RD_INTERVAL just before writing the new FFE * presets.
*/
delay_us = drm_dp_128b132b_read_aux_rd_interval(&intel_dp->aux);
/* Update signal levels and training set as requested. */ if (!intel_dp_update_link_train(intel_dp, crtc_state, DP_PHY_DPRX)) {
lt_err(intel_dp, DP_PHY_DPRX, "Failed to update TX FFE settings\n"); returnfalse;
}
}
for (;;) { if (time_after(jiffies, deadline))
timeout = true; /* try one last time after deadline */
if (drm_dp_dpcd_read_link_status(&intel_dp->aux, link_status) < 0) {
lt_err(intel_dp, DP_PHY_DPRX, "Failed to read link status\n"); returnfalse;
}
if (drm_dp_128b132b_link_training_failed(link_status)) {
intel_dp_dump_link_status(intel_dp, DP_PHY_DPRX, link_status);
lt_err(intel_dp, DP_PHY_DPRX, "Downstream link training failure\n"); returnfalse;
}
if (drm_dp_128b132b_eq_interlane_align_done(link_status)) {
lt_dbg(intel_dp, DP_PHY_DPRX, "Interlane align done\n"); break;
}
if (drm_dp_128b132b_link_training_failed(link_status)) {
intel_dp_dump_link_status(intel_dp, DP_PHY_DPRX, link_status);
lt_err(intel_dp, DP_PHY_DPRX, "Downstream link training failure\n"); returnfalse;
}
/* * 128b/132b link training sequence. (DP 2.0 E11 SCR on link training.)
*/ staticbool
intel_dp_128b132b_link_train(struct intel_dp *intel_dp, conststruct intel_crtc_state *crtc_state, int lttpr_count)
{ bool passed = false;
if (wait_for(intel_dp_128b132b_intra_hop(intel_dp, crtc_state) == 0, 500)) {
lt_err(intel_dp, DP_PHY_DPRX, "128b/132b intra-hop not clear\n"); goto out;
}
if (intel_dp_128b132b_lane_eq(intel_dp, crtc_state) &&
intel_dp_128b132b_lane_cds(intel_dp, crtc_state, lttpr_count))
passed = true;
lt_dbg(intel_dp, DP_PHY_DPRX, "128b/132b Link Training %s at link rate = %d, lane count = %d\n",
passed ? "passed" : "failed",
crtc_state->port_clock, crtc_state->lane_count);
out: /* * Ensure that the training pattern does get set to TPS2 even in case * of a failure, as is the case at the end of a passing link training * and what is expected by the transcoder. Leaving TPS1 set (and * disabling the link train mode in DP_TP_CTL later from TPS1 directly) * would result in a stuck transcoder HW state and flip-done timeouts * later in the modeset sequence.
*/ if (!passed)
intel_dp_program_link_training_pattern(intel_dp, crtc_state,
DP_PHY_DPRX, DP_TRAINING_PATTERN_2);
return passed;
}
/** * intel_dp_start_link_train - start link training * @state: Atomic state * @intel_dp: DP struct * @crtc_state: state for CRTC attached to the encoder * * Start the link training of the @intel_dp port, scheduling a fallback * retraining with reduced link rate/lane parameters if the link training * fails. * After calling this function intel_dp_stop_link_train() must be called.
*/ void intel_dp_start_link_train(struct intel_atomic_state *state, struct intel_dp *intel_dp, conststruct intel_crtc_state *crtc_state)
{ struct intel_display *display = to_intel_display(state); struct intel_digital_port *dig_port = dp_to_dig_port(intel_dp); struct intel_encoder *encoder = &dig_port->base; bool passed; /* * Reinit the LTTPRs here to ensure that they are switched to * non-transparent mode. During an earlier LTTPR detection this * could've been prevented by an active link.
*/ int lttpr_count;
if (intel_dp->link.force_train_failure) {
intel_dp->link.force_train_failure--;
lt_dbg(intel_dp, DP_PHY_DPRX, "Forcing link training failure\n");
} elseif (passed) {
intel_dp->link.seq_train_failures = 0; return;
}
intel_dp->link.seq_train_failures++;
/* * Ignore the link failure in CI * * In fixed environments like CI, sometimes unexpected long HPDs are * generated by the displays. If ignore_long_hpd flag is set, such long * HPDs are ignored. And probably as a consequence of these ignored * long HPDs, subsequent link trainings are failed resulting into CI * execution failures. * * For test cases which rely on the link training or processing of HPDs * ignore_long_hpd flag can unset from the testcase.
*/ if (display->hotplug.ignore_long_hpd) {
lt_dbg(intel_dp, DP_PHY_DPRX, "Ignore the link failure\n"); return;
}
if (intel_dp->link.seq_train_failures < MAX_SEQ_TRAIN_FAILURES) return;
if (intel_dp_schedule_fallback_link_training(state, intel_dp, crtc_state)) return;
intel_dp->link.retrain_disabled = true;
if (!passed)
lt_err(intel_dp, DP_PHY_DPRX, "Can't reduce link training parameters after failure\n"); else
lt_dbg(intel_dp, DP_PHY_DPRX, "Can't reduce link training parameters after forced failure\n");
}
void intel_dp_128b132b_sdp_crc16(struct intel_dp *intel_dp, conststruct intel_crtc_state *crtc_state)
{ /* * VIDEO_DIP_CTL register bit 31 should be set to '0' to not * disable SDP CRC. This is applicable for Display version 13. * Default value of bit 31 is '0' hence discarding the write * TODO: Corrective actions on SDP corruption yet to be defined
*/ if (!intel_dp_is_uhbr(crtc_state)) return;
/* DP v2.0 SCR on SDP CRC16 for 128b/132b Link Layer */
drm_dp_dpcd_writeb(&intel_dp->aux,
DP_SDP_ERROR_DETECTION_CONFIGURATION,
DP_SDP_CRC16_128B132B_EN);
lt_dbg(intel_dp, DP_PHY_DPRX, "DP2.0 SDP CRC16 for 128b/132b enabled\n");
}
staticint i915_dp_force_link_rate_show(struct seq_file *m, void *data)
{ struct intel_connector *connector = to_intel_connector(m->private); struct intel_display *display = to_intel_display(connector); struct intel_dp *intel_dp = intel_attached_dp(connector); int current_rate = -1; int force_rate; int err; int i;
err = drm_modeset_lock_single_interruptible(&display->drm->mode_config.connection_mutex); if (err) return err;
if (intel_dp->link.active)
current_rate = intel_dp->link_rate;
force_rate = intel_dp->link.force_rate;
for (i = 1; i <= 4; i <<= 1)
seq_printf(m, " %s%d%s%s",
i == force_lane_count ? "[" : "",
i,
i == current_lane_count ? "*" : "",
i == force_lane_count ? "]" : "");
seq_putc(m, '\n');
return 0;
}
staticint parse_lane_count(constchar __user *ubuf, size_t len)
{ char *kbuf; constchar *p; int lane_count; int ret = 0;
kbuf = memdup_user_nul(ubuf, len); if (IS_ERR(kbuf)) return PTR_ERR(kbuf);
p = strim(kbuf);
if (!strcmp(p, "auto")) {
lane_count = 0;
} else {
ret = kstrtoint(p, 0, &lane_count); if (ret < 0) goto out_free;
switch (lane_count) { case 1: case 2: case 4: break; default:
ret = -EINVAL;
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.