From patchwork Sun Aug 7 05:26:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Packard X-Patchwork-Id: 9266215 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 4D91D6075A for ; Sun, 7 Aug 2016 05:51:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3DED527D4D for ; Sun, 7 Aug 2016 05:51:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 330302808C; Sun, 7 Aug 2016 05:51:53 +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]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id ADD3E27D4D for ; Sun, 7 Aug 2016 05:51:52 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8A39C6E177; Sun, 7 Aug 2016 05:51:48 +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 56A2B6E07A for ; Sun, 7 Aug 2016 05:26:12 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by elaine.keithp.com (Postfix) with ESMTP id 1ECFE3F20850; Sat, 6 Aug 2016 22:26:12 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at keithp.com X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "Cc" 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 a3sbjaaJZH7J; Sat, 6 Aug 2016 22:26:10 -0700 (PDT) Received: from hiro.keithp.com (hiro.keithp.com [10.0.0.36]) by elaine.keithp.com (Postfix) with ESMTPSA id 273BC3F202B3; Sat, 6 Aug 2016 22:26:10 -0700 (PDT) Received: by hiro.keithp.com (Postfix, from userid 1001) id 202D27419D5; Sat, 6 Aug 2016 22:26:10 -0700 (PDT) From: Keith Packard To: Daniel Vetter Subject: Re: [PATCH] drm: Don't prepare or cleanup unchanging frame buffers [v2] In-Reply-To: <20160802135417.GO6232@phenom.ffwll.local> References: <1469952534-6516-1-git-send-email-keithp@keithp.com> <20160802135417.GO6232@phenom.ffwll.local> User-Agent: Notmuch/0.22 (http://notmuchmail.org) Emacs/24.5.1 (x86_64-pc-linux-gnu) Date: Sat, 06 Aug 2016 22:26:09 -0700 Message-ID: <86a8gpkv4e.fsf@hiro.keithp.com> MIME-Version: 1.0 X-Mailman-Approved-At: Sun, 07 Aug 2016 05:51:39 +0000 Cc: keithp@keithp.com, linux-kernel@vger.kernel.org, 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Daniel Vetter writes: > Hm, I can't see v1 anywhere, but I think it'd be better. You can't store > any transient state related to the current update in struct drm_plane. In > this case the cleanup_buffers from a previous update might overlap (for > nonblocking atomic commits) with the prepare_planes for the next one. > Either we need special cleanup vs. error-path code, or some flag somewhere > in the drm_plane_state. Ok, here's pretty much the previous version, which works now that I've fixed the intel driver. Instead of just comparing the fb's, I'm using the framebuffer_changed function, which seems like a nice bit of documentation if nothing else. From a75251d5762b1c200ed2f3dca2a5b00cc85bea95 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 4 Jun 2016 01:16:22 -0700 Subject: [PATCH] drm: Don't prepare or cleanup unchanging frame buffers [v3] 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. v3: use drm_atomic_helper_framebuffer_changed in both prepare and cleanup phases instead of keeping state in the plane. cc: dri-devel@lists.freedesktop.org cc: David Airlie cc: Daniel Vetter Signed-off-by: Keith Packard --- drivers/gpu/drm/drm_atomic_helper.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c index ddfa0d1..72e50bc 100644 --- a/drivers/gpu/drm/drm_atomic_helper.c +++ b/drivers/gpu/drm/drm_atomic_helper.c @@ -1246,18 +1246,19 @@ 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; + int max_prepared_i = 0; - 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) + if (!drm_atomic_helper_framebuffer_changed(dev, state, plane_state->crtc)) continue; funcs = plane->helper_private; @@ -1267,24 +1268,25 @@ int drm_atomic_helper_prepare_planes(struct drm_device *dev, if (ret) goto fail; } + max_prepared_i = i; } 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 (i > max_prepared_i) + break; + + if (!drm_atomic_helper_framebuffer_changed(dev, state, plane_state->crtc)) continue; funcs = plane->helper_private; if (funcs->cleanup_fb) funcs->cleanup_fb(plane, plane_state); - } return ret; @@ -1527,6 +1529,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 (!drm_atomic_helper_framebuffer_changed(dev, old_state, plane_state->crtc)) + continue; + funcs = plane->helper_private; if (funcs->cleanup_fb) -- 2.8.1