From patchwork Wed Feb 6 11:10:28 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 2103661 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork1.kernel.org (Postfix) with ESMTP id 0A86E3FCFC for ; Wed, 6 Feb 2013 11:15:48 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EB9C8E63E1 for ; Wed, 6 Feb 2013 03:15:47 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from fireflyinternet.com (smtp.fireflyinternet.com [109.228.6.236]) by gabe.freedesktop.org (Postfix) with ESMTP id 900BCE676C for ; Wed, 6 Feb 2013 03:12:40 -0800 (PST) X-Default-Received-SPF: pass (skip=forwardok (res=PASS)) x-ip-name=78.156.73.22; Received: from arrandale.alporthouse.com (unverified [78.156.73.22]) by fireflyinternet.com (Firefly Internet (M1)) with ESMTP id 128713306-1500050 for multiple; Wed, 06 Feb 2013 11:12:32 +0000 From: Chris Wilson To: intel-gfx@lists.freedesktop.org Date: Wed, 6 Feb 2013 11:10:28 +0000 Message-Id: <1360149028-13531-8-git-send-email-chris@chris-wilson.co.uk> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1360149028-13531-1-git-send-email-chris@chris-wilson.co.uk> References: <1360149028-13531-1-git-send-email-chris@chris-wilson.co.uk> X-Originating-IP: 78.156.73.22 Subject: [Intel-gfx] [PATCH 8/8] drm/i915: Validate that the framebuffer accommodates the current mode X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org Errors-To: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org As we retrieve the mode from the BIOS it may be constructed using different assumptions for its configuration, such as utilizing the panel fitter in a conflicting manner. As such the associated framebuffer may be insufficient for our setup, and so we need to reject the current mode and install our own. Signed-off-by: Chris Wilson --- drivers/gpu/drm/i915/intel_display.c | 38 +++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c index c1d8200..f5d4d88 100644 --- a/drivers/gpu/drm/i915/intel_display.c +++ b/drivers/gpu/drm/i915/intel_display.c @@ -6441,27 +6441,40 @@ intel_framebuffer_create_for_mode(struct drm_device *dev, return intel_framebuffer_create(dev, &mode_cmd, obj); } +static bool +mode_fits_in_fb(struct drm_display_mode *mode, + struct drm_framebuffer *fb) +{ + struct drm_i915_gem_object *obj; + int min_pitch; + + min_pitch = intel_framebuffer_pitch_for_width(mode->hdisplay, + fb->bits_per_pixel); + if (fb->pitches[0] < min_pitch) + return false; + + obj = to_intel_framebuffer(fb)->obj; + if (obj == NULL) + return false; + + if (obj->base.size < mode->vdisplay * fb->pitches[0]) + return false; + + return true; +} + static struct drm_framebuffer * mode_fits_in_fbdev(struct drm_device *dev, struct drm_display_mode *mode) { struct drm_i915_private *dev_priv = dev->dev_private; - struct drm_i915_gem_object *obj; struct drm_framebuffer *fb; if (dev_priv->fbdev == NULL) return NULL; - obj = dev_priv->fbdev->ifb.obj; - if (obj == NULL) - return NULL; - fb = &dev_priv->fbdev->ifb.base; - if (fb->pitches[0] < intel_framebuffer_pitch_for_width(mode->hdisplay, - fb->bits_per_pixel)) - return NULL; - - if (obj->base.size < mode->vdisplay * fb->pitches[0]) + if (!mode_fits_in_fb(mode, fb)) return NULL; return fb; @@ -9090,6 +9103,11 @@ void intel_modeset_setup_hw_state(struct drm_device *dev, if (crtc->base.enabled) crtc->mode_valid = intel_crtc_get_mode(&crtc->base, &crtc->base.mode); + + if (crtc->base.fb && + !mode_fits_in_fb(&crtc->base.mode, crtc->base.fb)) + crtc->mode_valid = false; + if (crtc->mode_valid) { DRM_DEBUG_KMS("found active mode: "); drm_mode_debug_printmodeline(&crtc->base.mode);