From patchwork Thu Aug 28 17:40:13 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gustavo Padovan X-Patchwork-Id: 4806021 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 8B9C69F3EE for ; Thu, 28 Aug 2014 17:40:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 09FA720158 for ; Thu, 28 Aug 2014 17:40:42 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 0D979200D4 for ; Thu, 28 Aug 2014 17:40:41 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0A4C96E3A8; Thu, 28 Aug 2014 10:40:38 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-yk0-f178.google.com (mail-yk0-f178.google.com [209.85.160.178]) by gabe.freedesktop.org (Postfix) with ESMTP id 092A46E270; Thu, 28 Aug 2014 10:40:36 -0700 (PDT) Received: by mail-yk0-f178.google.com with SMTP id q200so688067ykb.23 for ; Thu, 28 Aug 2014 10:40:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=EEwORF2i/XXiMi35fCF+TE2u23CsylhnfrL1KCWJDA0=; b=VZuJcPFGi7H5B2Labh6etyX1omp3gKBuiy1VraNmpQ9kacaKagD+HHuHFcYAAZpdbi LzQTbiDz07i6sk1uAY1sDI4JTp9CwxEpShZww516jhwXxOKpw5OgbYCgCaf3t01RGoYS e9UFqLTp19x8joFbf3/5Fgmv3BCNDiEwpZuw33FjcJ4rjYGcPSHSmM9b4aHtRjfJdgem Jypu2SJTeoPN3xug1Kcyoyxr48uViywojX9wpLdmG/TPZX0Qp0Q4CcNvX6I0VYVbZoiv 9cPgTp/UYWUH7mpxE1az+2kM583dQrq8Lw9Qr2LdVJOCak5scRBFthEvRZW5pu5CYZIt zfGA== X-Received: by 10.236.81.243 with SMTP id m79mr7444152yhe.28.1409247635502; Thu, 28 Aug 2014 10:40:35 -0700 (PDT) Received: from localhost.localdomain ([187.10.18.246]) by mx.google.com with ESMTPSA id a14sm2020073yho.33.2014.08.28.10.40.33 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Aug 2014 10:40:34 -0700 (PDT) From: Gustavo Padovan To: intel-gfx@lists.freedesktop.org Date: Thu, 28 Aug 2014 14:40:13 -0300 Message-Id: <1409247613-14232-9-git-send-email-gustavo@padovan.org> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1409247613-14232-1-git-send-email-gustavo@padovan.org> References: <1409247613-14232-1-git-send-email-gustavo@padovan.org> Cc: Gustavo Padovan , dri-devel@lists.freedesktop.org Subject: [Intel-gfx] [PATCH 9/9] drm/i915: split intel_pipe_set_base() into check() and commit() X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Gustavo Padovan Take out some parts of code that can fail from it and move them to intel_pipe_check_base(), the only failure point in intel_pipe_set_base() now is the fb pinning procudure. Signed-off-by: Gustavo Padovan --- drivers/gpu/drm/i915/intel_display.c | 39 ++++++++++++++++++++++++++++-------- 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c index eb6febf..ead2f24 100644 --- a/drivers/gpu/drm/i915/intel_display.c +++ b/drivers/gpu/drm/i915/intel_display.c @@ -2661,17 +2661,11 @@ static bool intel_crtc_has_pending_flip(struct drm_crtc *crtc) } static int -intel_pipe_set_base(struct drm_crtc *crtc, int x, int y, +intel_pipe_check_base(struct drm_crtc *crtc, int x, int y, struct drm_framebuffer *fb) { struct drm_device *dev = crtc->dev; - struct drm_i915_private *dev_priv = dev->dev_private; struct intel_crtc *intel_crtc = to_intel_crtc(crtc); - enum pipe pipe = intel_crtc->pipe; - struct drm_framebuffer *old_fb = crtc->primary->fb; - struct drm_i915_gem_object *obj = intel_fb_obj(fb); - struct drm_i915_gem_object *old_obj = intel_fb_obj(old_fb); - int ret; if (intel_crtc_has_pending_flip(crtc)) { DRM_ERROR("pipe is still busy with an old pageflip\n"); @@ -2691,6 +2685,22 @@ intel_pipe_set_base(struct drm_crtc *crtc, int x, int y, return -EINVAL; } + return 0; +} + +static int +intel_pipe_set_base(struct drm_crtc *crtc, int x, int y, + struct drm_framebuffer *fb) +{ + struct drm_device *dev = crtc->dev; + struct drm_i915_private *dev_priv = dev->dev_private; + struct intel_crtc *intel_crtc = to_intel_crtc(crtc); + enum pipe pipe = intel_crtc->pipe; + struct drm_framebuffer *old_fb = crtc->primary->fb; + struct drm_i915_gem_object *obj = intel_fb_obj(fb); + struct drm_i915_gem_object *old_obj = intel_fb_obj(old_fb); + int ret; + mutex_lock(&dev->struct_mutex); ret = intel_pin_and_fence_fb_obj(dev, obj, NULL); if (ret == 0) @@ -9868,6 +9878,10 @@ free_work: if (ret == -EIO) { out_hang: intel_crtc_wait_for_pending_flips(crtc); + ret = intel_pipe_check_base(crtc, crtc->x, crtc->y, fb); + if (ret) + return ret; + ret = intel_pipe_set_base(crtc, crtc->x, crtc->y, fb); if (ret == 0 && event) drm_send_vblank_event(dev, pipe, event); @@ -11396,6 +11410,10 @@ static int intel_crtc_set_config(struct drm_mode_set *set) intel_crtc_wait_for_pending_flips(set->crtc); + ret = intel_pipe_check_base(set->crtc, set->x, set->y, set->fb); + if (ret) + goto fail; + ret = intel_pipe_set_base(set->crtc, set->x, set->y, set->fb); @@ -11620,12 +11638,17 @@ intel_check_primary_plane(struct drm_plane *plane, struct drm_crtc *crtc, .x2 = intel_crtc->active ? intel_crtc->config.pipe_src_w : 0, .y2 = intel_crtc->active ? intel_crtc->config.pipe_src_h : 0, }; + int ret; - return drm_plane_helper_check_update(plane, crtc, fb, + ret = drm_plane_helper_check_update(plane, crtc, fb, &src, &dest, &clip, DRM_PLANE_HELPER_NO_SCALING, DRM_PLANE_HELPER_NO_SCALING, false, true, visible); + if (ret) + return ret; + + return intel_pipe_check_base(crtc, src.x1, src.y1, fb); } static int