From patchwork Tue Sep 9 20:49:46 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gustavo Padovan X-Patchwork-Id: 4872871 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 31F0AC033A for ; Tue, 9 Sep 2014 20:49:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 616112017A for ; Tue, 9 Sep 2014 20:49:57 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id BB08A2017D for ; Tue, 9 Sep 2014 20:49:55 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8802989F4F; Tue, 9 Sep 2014 13:49:53 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-qc0-f182.google.com (mail-qc0-f182.google.com [209.85.216.182]) by gabe.freedesktop.org (Postfix) with ESMTP id 3134A89F47; Tue, 9 Sep 2014 13:49:52 -0700 (PDT) Received: by mail-qc0-f182.google.com with SMTP id x13so4906626qcv.41 for ; Tue, 09 Sep 2014 13:49:51 -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; bh=BomLZsiBMxMHH8u4huWwA1WqZiw955x11ua0LRruwnA=; b=F4tM1LHS3H4yW/OgWuZA8cUcj5IBHrTWmt9si13/bI17fofj3kjZ6LS5rQKGVG/vua lLnGS0715IRUA9cM919OGB2Do5bOzqxLDvayrxn4A+ACslHvuUNOlZcYX5H5C9aSyg60 u2FnVjrLPvkS9GbOyqEqVUapcHG1O5Kc4MeCyh2Nq8g9sG6+bWYMUE4DQeS7e1F0RoSY bhWBHUdvmejDgg7pIGRR8nkdR4aKE7D82ictEgQHL7gA/3nUfuXs3j7ZvvS8fnt8dMTg BUxl1IGuBbOIcKrI1DbhJ90riN4yegKGuyX2zvlTtn4zAwmGbqmq0Dn+3X7/eeSptTbX eopQ== X-Received: by 10.224.5.1 with SMTP id 1mr54844949qat.30.1410295791779; Tue, 09 Sep 2014 13:49:51 -0700 (PDT) Received: from localhost.localdomain ([179.110.36.38]) by mx.google.com with ESMTPSA id t95sm10709580qgd.47.2014.09.09.13.49.49 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Sep 2014 13:49:50 -0700 (PDT) From: Gustavo Padovan To: intel-gfx@lists.freedesktop.org Date: Tue, 9 Sep 2014 17:49:46 -0300 Message-Id: <1410295786-21618-1-git-send-email-gustavo@padovan.org> X-Mailer: git-send-email 1.9.3 Cc: Gustavo Padovan , dri-devel@lists.freedesktop.org Subject: [Intel-gfx] [PATCH] drm/i915: pin sprite fb only if it changed 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=-6.7 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 Optimize code avoiding helding dev mutex if old fb and current fb are the same. Signed-off-by: Gustavo Padovan --- drivers/gpu/drm/i915/intel_sprite.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/i915/intel_sprite.c b/drivers/gpu/drm/i915/intel_sprite.c index a4306cf..a301838 100644 --- a/drivers/gpu/drm/i915/intel_sprite.c +++ b/drivers/gpu/drm/i915/intel_sprite.c @@ -1038,21 +1038,23 @@ intel_commit_sprite_plane(struct drm_plane *plane, primary_enabled = !drm_rect_equals(dst, clip) || colorkey_enabled(intel_plane); WARN_ON(!primary_enabled && !state->visible && intel_crtc->active); - mutex_lock(&dev->struct_mutex); /* Note that this will apply the VT-d workaround for scanouts, * which is more restrictive than required for sprites. (The * primary plane requires 256KiB alignment with 64 PTE padding, * the sprite planes only require 128KiB alignment and 32 PTE padding. */ - ret = intel_pin_and_fence_fb_obj(dev, obj, NULL); + if (old_obj != obj) { + mutex_lock(&dev->struct_mutex); + ret = intel_pin_and_fence_fb_obj(dev, obj, NULL); - i915_gem_track_fb(old_obj, obj, - INTEL_FRONTBUFFER_SPRITE(pipe)); - mutex_unlock(&dev->struct_mutex); + i915_gem_track_fb(old_obj, obj, + INTEL_FRONTBUFFER_SPRITE(pipe)); + mutex_unlock(&dev->struct_mutex); - if (ret) - return ret; + if (ret) + return ret; + } intel_plane->crtc_x = state->orig_dst.x1; intel_plane->crtc_y = state->orig_dst.y1; @@ -1098,15 +1100,18 @@ intel_commit_sprite_plane(struct drm_plane *plane, intel_post_enable_primary(crtc); } + if (!old_obj) + return 0; + /* Unpin old obj after new one is active to avoid ugliness */ - if (old_obj) { + if (old_obj != obj) { /* * It's fairly common to simply update the position of * an existing object. In that case, we don't need to * wait for vblank to avoid ugliness, we only need to * do the pin & ref bookkeeping. */ - if (old_obj != obj && intel_crtc->active) + if (intel_crtc->active) intel_wait_for_vblank(dev, intel_crtc->pipe); mutex_lock(&dev->struct_mutex);