[Intel-gfx] [PATCH 6/6] drm/i915: Attach a fb to the load-detect pipe

Chris Wilson chris at chris-wilson.co.uk
Wed Apr 20 11:22:22 CEST 2011


We need to ensure that we feed valid memory into the display plane
attached to the pipe when switching the pipe on. Otherwise, the display
engine may read through an invalid PTE and so throw an PGTBL_ER
exception.

For bonus amusement value, we perform the first load detect before even
establishing our fbdev.

Reported-by: Knut Petersen <Knut_Petersen at t-online.de>
References: https://bugs.freedesktop.org/show_bug.cgi?id=36246
Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/intel_display.c |   18 +++++++++++++++++-
 1 files changed, 17 insertions(+), 1 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 9b1a3e1..e68dd08 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -5549,6 +5549,8 @@ bool intel_get_load_detect_pipe(struct intel_encoder *intel_encoder,
 	struct drm_encoder *encoder = &intel_encoder->base;
 	struct drm_crtc *crtc = NULL;
 	struct drm_device *dev = encoder->dev;
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	struct drm_framebuffer *old_fb;
 	int i = -1;
 
 	/*
@@ -5613,8 +5615,22 @@ bool intel_get_load_detect_pipe(struct intel_encoder *intel_encoder,
 	if (!mode)
 		mode = &load_detect_mode;
 
-	if (!drm_crtc_helper_set_mode(crtc, mode, 0, 0, crtc->fb)) {
+	/* Ensure we bind a framebuffer to supply the plane.
+	 * As we may be called during intel_framebuffer_init,
+	 * we need to be careful that we have actually initialised
+	 * the fbcon before using it.
+	 */
+	if (dev_priv->fbdev == NULL || dev_priv->fbdev->ifb.obj == NULL) {
+		DRM_DEBUG("no fb to bind for load-detect pipe\n");
+		return false;
+	}
+
+	old_fb = crtc->fb;
+	crtc->fb = &dev_priv->fbdev->ifb.base;
+
+	if (!drm_crtc_helper_set_mode(crtc, mode, 0, 0, old_fb)) {
 		DRM_DEBUG_KMS("failed to set mode on load-detect pipe\n");
+		crtc->fb = old_fb;
 		return false;
 	}
 
-- 
1.7.4.1




More information about the Intel-gfx mailing list