Skip to content

Commit 5a0056f

Browse files
vsyrjalaintel-lab-lkp
authored andcommitted
drm/i915: Try to sanitize bogus DPLL state left over by broken SNB BIOSen
Certain SNB machines (eg. ASUS K53SV) seem to have a broken BIOS which misprograms the hardware badly when encountering a suitably high resolution display. The programmed pipe timings are somewhat bonkers and the DPLL is totally misprogrammed (P divider == 0). That will result in atomic commit timeouts as apparently the pipe is sufficiently stuck to not signal vblank interrupts. IIRC something like this was also observed on some other SNB machine years ago (might have been a Dell XPS 8300) but a BIOS update cured it. Sadly looks like this was never fixed for the ASUS K53SV as the latest BIOS (K53SV.320 11/11/2011) is still broken. The quickest way to deal with this seems to be to shut down the pipe+ports+DPLL. Unfortunately doing this during the normal sanitization phase isn't quite soon enough as we already spew several WARNs about the bogus hardware state. But it's better than hanging the boot for a few dozen seconds. Since this is limited to a few old machines it doesn't seem entirely worthwile to try and rework the readout+sanitization code to handle it more gracefully. Cc: stable@vger.kernel.org # v4.20+ Cc: Daniel Kamil Kozar <dkk089@gmail.com> Reported-by: Daniel Kamil Kozar <dkk089@gmail.com> Tested-by: Daniel Kamil Kozar <dkk089@gmail.com> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=109245 Fixes: 516a49c ("drm/i915: Fix assert_plane() warning on bootup with external display") Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
1 parent 4e8052a commit 5a0056f

File tree

1 file changed

+45
-6
lines changed

1 file changed

+45
-6
lines changed

drivers/gpu/drm/i915/intel_display.c

Lines changed: 45 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15434,16 +15434,46 @@ static void intel_sanitize_crtc(struct intel_crtc *crtc,
1543415434
}
1543515435
}
1543615436

15437+
static bool has_bogus_dpll_config(struct intel_crtc_state *crtc_state)
15438+
{
15439+
struct drm_i915_private *dev_priv = to_i915(crtc_state->base.crtc->dev);
15440+
15441+
/*
15442+
* Some SNB BIOSen (eg. ASUS K53SV) are known to misprogram
15443+
* the hardware when a high res displays plugged in. DPLL P
15444+
* divider is zero, and the pipe timings are bonkers. We'll
15445+
* try to disable everything in that case.
15446+
*
15447+
* FIXME would be nice to be able to sanitize this state
15448+
* without several WARNs, but for now let's take the easy
15449+
* road.
15450+
*/
15451+
return IS_GEN(dev_priv, 6) &&
15452+
crtc_state &&
15453+
crtc_state->base.active &&
15454+
crtc_state->shared_dpll &&
15455+
crtc_state->port_clock == 0;
15456+
}
15457+
1543715458
static void intel_sanitize_encoder(struct intel_encoder *encoder)
1543815459
{
1543915460
struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
1544015461
struct intel_connector *connector;
15462+
struct intel_crtc *crtc = to_intel_crtc(encoder->base.crtc);
15463+
struct intel_crtc_state *crtc_state = crtc ?
15464+
to_intel_crtc_state(crtc->base.state) : NULL;
1544115465

1544215466
/* We need to check both for a crtc link (meaning that the
1544315467
* encoder is active and trying to read from a pipe) and the
1544415468
* pipe itself being active. */
15445-
bool has_active_crtc = encoder->base.crtc &&
15446-
to_intel_crtc(encoder->base.crtc)->active;
15469+
bool has_active_crtc = crtc_state &&
15470+
crtc_state->base.active;
15471+
15472+
if (has_bogus_dpll_config(crtc_state)) {
15473+
DRM_DEBUG_KMS("BIOS has misprogrammed the hardware. Disabling pipe %c\n",
15474+
pipe_name(crtc->pipe));
15475+
has_active_crtc = false;
15476+
}
1544715477

1544815478
connector = intel_encoder_find_connector(encoder);
1544915479
if (connector && !has_active_crtc) {
@@ -15454,16 +15484,25 @@ static void intel_sanitize_encoder(struct intel_encoder *encoder)
1545415484
/* Connector is active, but has no active pipe. This is
1545515485
* fallout from our resume register restoring. Disable
1545615486
* the encoder manually again. */
15457-
if (encoder->base.crtc) {
15458-
struct drm_crtc_state *crtc_state = encoder->base.crtc->state;
15487+
if (crtc_state) {
15488+
struct drm_encoder *best_encoder;
1545915489

1546015490
DRM_DEBUG_KMS("[ENCODER:%d:%s] manually disabled\n",
1546115491
encoder->base.base.id,
1546215492
encoder->base.name);
15493+
15494+
/* avoid oopsing in case the hooks consult best_encoder */
15495+
best_encoder = connector->base.state->best_encoder;
15496+
connector->base.state->best_encoder = &encoder->base;
15497+
1546315498
if (encoder->disable)
15464-
encoder->disable(encoder, to_intel_crtc_state(crtc_state), connector->base.state);
15499+
encoder->disable(encoder, crtc_state,
15500+
connector->base.state);
1546515501
if (encoder->post_disable)
15466-
encoder->post_disable(encoder, to_intel_crtc_state(crtc_state), connector->base.state);
15502+
encoder->post_disable(encoder, crtc_state,
15503+
connector->base.state);
15504+
15505+
connector->base.state->best_encoder = best_encoder;
1546715506
}
1546815507
encoder->base.crtc = NULL;
1546915508

0 commit comments

Comments
 (0)