From patchwork Sun Jul 31 08:08:54 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Packard X-Patchwork-Id: 9253585 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8A7C560865 for ; Mon, 1 Aug 2016 01:29:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7B79228405 for ; Mon, 1 Aug 2016 01:29:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6E74228408; Mon, 1 Aug 2016 01:29:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D6AD628405 for ; Mon, 1 Aug 2016 01:29:16 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 43BC66E175; Mon, 1 Aug 2016 01:28:30 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from elaine.keithp.com (home.keithp.com [63.227.221.253]) by gabe.freedesktop.org (Postfix) with ESMTP id 2D86C6E0BC for ; Sun, 31 Jul 2016 08:09:10 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by elaine.keithp.com (Postfix) with ESMTP id C8E553F2089F; Sun, 31 Jul 2016 01:09:09 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at keithp.com Received: from elaine.keithp.com ([127.0.0.1]) by localhost (elaine.keithp.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id UIZPS58tv7UM; Sun, 31 Jul 2016 01:09:09 -0700 (PDT) Received: from hiro.keithp.com (hiro.keithp.com [10.0.0.36]) by elaine.keithp.com (Postfix) with ESMTPSA id F31773F20356; Sun, 31 Jul 2016 01:09:08 -0700 (PDT) Received: by hiro.keithp.com (Postfix, from userid 1001) id E086B741743; Sun, 31 Jul 2016 01:09:08 -0700 (PDT) From: Keith Packard To: linux-kernel@vger.kernel.org Subject: [PATCH] drm: Don't prepare or cleanup unchanging frame buffers [v2] Date: Sun, 31 Jul 2016 01:08:54 -0700 Message-Id: <1469952534-6516-1-git-send-email-keithp@keithp.com> X-Mailer: git-send-email 2.8.1 X-Mailman-Approved-At: Mon, 01 Aug 2016 01:28:21 +0000 Cc: Keith Packard , dri-devel@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP When reconfiguring a plane position (as in moving the cursor), the frame buffer for the cursor isn't changing, so don't call the prepare or cleanup driver functions. This avoids making cursor position updates block on all pending rendering. v2: Track which planes have been prepared to know which to cleanup. Otherwise, failure paths and success paths would need different tests in the cleanup code as the plane state points to different places in the two cases. cc: dri-devel@lists.freedesktop.org cc: David Airlie Signed-off-by: Keith Packard --- drivers/gpu/drm/drm_atomic_helper.c | 23 +++++++++++++---------- include/drm/drm_crtc.h | 1 + 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c index ddfa0d1..f7f3a51 100644 --- a/drivers/gpu/drm/drm_atomic_helper.c +++ b/drivers/gpu/drm/drm_atomic_helper.c @@ -1246,18 +1246,20 @@ EXPORT_SYMBOL(drm_atomic_helper_commit); * Returns: * 0 on success, negative error code on failure. */ + int drm_atomic_helper_prepare_planes(struct drm_device *dev, struct drm_atomic_state *state) { - int nplanes = dev->mode_config.num_total_plane; + struct drm_plane *plane; + struct drm_plane_state *plane_state; int ret, i; - for (i = 0; i < nplanes; i++) { + for_each_plane_in_state(state, plane, plane_state, i) { const struct drm_plane_helper_funcs *funcs; - struct drm_plane *plane = state->planes[i]; - struct drm_plane_state *plane_state = state->plane_states[i]; - if (!plane) + plane->prepared = false; + + if (plane->state->fb == plane_state->fb) continue; funcs = plane->helper_private; @@ -1267,24 +1269,22 @@ int drm_atomic_helper_prepare_planes(struct drm_device *dev, if (ret) goto fail; } + plane->prepared = true; } return 0; fail: - for (i--; i >= 0; i--) { + for_each_plane_in_state(state, plane, plane_state, i) { const struct drm_plane_helper_funcs *funcs; - struct drm_plane *plane = state->planes[i]; - struct drm_plane_state *plane_state = state->plane_states[i]; - if (!plane) + if (!plane->prepared) continue; funcs = plane->helper_private; if (funcs->cleanup_fb) funcs->cleanup_fb(plane, plane_state); - } return ret; @@ -1527,6 +1527,9 @@ void drm_atomic_helper_cleanup_planes(struct drm_device *dev, for_each_plane_in_state(old_state, plane, plane_state, i) { const struct drm_plane_helper_funcs *funcs; + if (!plane->prepared) + continue; + funcs = plane->helper_private; if (funcs->cleanup_fb) diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h index d1559cd..08b2033 100644 --- a/include/drm/drm_crtc.h +++ b/include/drm/drm_crtc.h @@ -1531,6 +1531,7 @@ struct drm_plane { uint32_t *format_types; unsigned int format_count; bool format_default; + bool prepared; struct drm_crtc *crtc; struct drm_framebuffer *fb;