Skip to content

Commit 7bed8ad

Browse files
committed
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. v2: Fix potential NULL deref (kbuild test robot) Constify has_bogus_dpll_config() 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> Link: https://patchwork.freedesktop.org/patch/msgid/20190111174950.10681-1-ville.syrjala@linux.intel.com Reviewed-by: Mika Kahola <mika.kahola@intel.com>
1 parent 8a920e2 commit 7bed8ad

File tree

1 file changed

+44
-6
lines changed

1 file changed

+44
-6
lines changed

drivers/gpu/drm/i915/intel_display.c

Lines changed: 44 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15515,16 +15515,45 @@ static void intel_sanitize_crtc(struct intel_crtc *crtc,
1551515515
}
1551615516
}
1551715517

15518+
static bool has_bogus_dpll_config(const struct intel_crtc_state *crtc_state)
15519+
{
15520+
struct drm_i915_private *dev_priv = to_i915(crtc_state->base.crtc->dev);
15521+
15522+
/*
15523+
* Some SNB BIOSen (eg. ASUS K53SV) are known to misprogram
15524+
* the hardware when a high res displays plugged in. DPLL P
15525+
* divider is zero, and the pipe timings are bonkers. We'll
15526+
* try to disable everything in that case.
15527+
*
15528+
* FIXME would be nice to be able to sanitize this state
15529+
* without several WARNs, but for now let's take the easy
15530+
* road.
15531+
*/
15532+
return IS_GEN(dev_priv, 6) &&
15533+
crtc_state->base.active &&
15534+
crtc_state->shared_dpll &&
15535+
crtc_state->port_clock == 0;
15536+
}
15537+
1551815538
static void intel_sanitize_encoder(struct intel_encoder *encoder)
1551915539
{
1552015540
struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
1552115541
struct intel_connector *connector;
15542+
struct intel_crtc *crtc = to_intel_crtc(encoder->base.crtc);
15543+
struct intel_crtc_state *crtc_state = crtc ?
15544+
to_intel_crtc_state(crtc->base.state) : NULL;
1552215545

1552315546
/* We need to check both for a crtc link (meaning that the
1552415547
* encoder is active and trying to read from a pipe) and the
1552515548
* pipe itself being active. */
15526-
bool has_active_crtc = encoder->base.crtc &&
15527-
to_intel_crtc(encoder->base.crtc)->active;
15549+
bool has_active_crtc = crtc_state &&
15550+
crtc_state->base.active;
15551+
15552+
if (crtc_state && has_bogus_dpll_config(crtc_state)) {
15553+
DRM_DEBUG_KMS("BIOS has misprogrammed the hardware. Disabling pipe %c\n",
15554+
pipe_name(crtc->pipe));
15555+
has_active_crtc = false;
15556+
}
1552815557

1552915558
connector = intel_encoder_find_connector(encoder);
1553015559
if (connector && !has_active_crtc) {
@@ -15535,16 +15564,25 @@ static void intel_sanitize_encoder(struct intel_encoder *encoder)
1553515564
/* Connector is active, but has no active pipe. This is
1553615565
* fallout from our resume register restoring. Disable
1553715566
* the encoder manually again. */
15538-
if (encoder->base.crtc) {
15539-
struct drm_crtc_state *crtc_state = encoder->base.crtc->state;
15567+
if (crtc_state) {
15568+
struct drm_encoder *best_encoder;
1554015569

1554115570
DRM_DEBUG_KMS("[ENCODER:%d:%s] manually disabled\n",
1554215571
encoder->base.base.id,
1554315572
encoder->base.name);
15573+
15574+
/* avoid oopsing in case the hooks consult best_encoder */
15575+
best_encoder = connector->base.state->best_encoder;
15576+
connector->base.state->best_encoder = &encoder->base;
15577+
1554415578
if (encoder->disable)
15545-
encoder->disable(encoder, to_intel_crtc_state(crtc_state), connector->base.state);
15579+
encoder->disable(encoder, crtc_state,
15580+
connector->base.state);
1554615581
if (encoder->post_disable)
15547-
encoder->post_disable(encoder, to_intel_crtc_state(crtc_state), connector->base.state);
15582+
encoder->post_disable(encoder, crtc_state,
15583+
connector->base.state);
15584+
15585+
connector->base.state->best_encoder = best_encoder;
1554815586
}
1554915587
encoder->base.crtc = NULL;
1555015588

0 commit comments

Comments
 (0)