From patchwork Mon Nov 24 20:42:19 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 5369971 Return-Path: X-Original-To: patchwork-dri-devel@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 5155D9F2F5 for ; Mon, 24 Nov 2014 20:42:03 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6F93B200F4 for ; Mon, 24 Nov 2014 20:42:02 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 7C184200EC for ; Mon, 24 Nov 2014 20:42:01 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 54DC96ED4E; Mon, 24 Nov 2014 12:42:00 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wg0-f49.google.com (mail-wg0-f49.google.com [74.125.82.49]) by gabe.freedesktop.org (Postfix) with ESMTP id 5808F6EA31 for ; Mon, 24 Nov 2014 12:41:59 -0800 (PST) Received: by mail-wg0-f49.google.com with SMTP id x12so13320425wgg.8 for ; Mon, 24 Nov 2014 12:41:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id; bh=dw4xjb/HEWUGeds3l96icdvNpyWvMvByIfYR3TSxcdo=; b=kfblLMLqH2h4CqdsDWNX7BnNDOjctcDK2pRMJa9MJapllq76sIroOpYAgOFr5W+GFk IWv6srLEENdAAaB2G2OYmR6W3xRBslAuGa+AizdqMIq6FZb8OzrcsaaV77gpIICgB9+i xNl06l2/BVwiF1H9DQlb/AJZrebTG7iP9zrXA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=dw4xjb/HEWUGeds3l96icdvNpyWvMvByIfYR3TSxcdo=; b=Jbibela56PpxRb3GpxJbWst0MWyshJoEC2temLLS15zR+dhGxadmS6F3U1D1LLKepA 1uYhWdffaeRnG+XMUu2hATDAHH46fPYjIQd35+C1HWluoJWgf/bmBZN6owOKhAlmcfo8 WpbqlAS0siumQ/gvpZXVP+GusK7hzR9oO/uErd4HdBGmQwIWUaSRDhrtL8t9vy5Xm55J TvZ0SfikCYl/GK852Yp1HUP6kFIkRnERsNreYbh9qN2F8pkLeg2bwB3wTfQHpQh4k/BU MMQxdmrYaLs0867okc1YrI6U/TzN+17i0Y0ENcnVcbilLZMCEin9ASwFFf2fUVkra+1r fzuA== X-Gm-Message-State: ALoCoQnegtxRvucUy4n3HQZVVxGuG4L5KRQbNjHBEIUjAVbV4FdzXWmG7CoC069pKf76pM2V22E2 X-Received: by 10.194.71.203 with SMTP id x11mr2499404wju.131.1416861718235; Mon, 24 Nov 2014 12:41:58 -0800 (PST) Received: from phenom.ffwll.local (84-73-67-144.dclient.hispeed.ch. [84.73.67.144]) by mx.google.com with ESMTPSA id n8sm7903706wjx.0.2014.11.24.12.41.55 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 24 Nov 2014 12:41:56 -0800 (PST) From: Daniel Vetter To: DRI Development Subject: [PATCH] drm/atomic-helper: Skip vblank waits for unchanged fbs Date: Mon, 24 Nov 2014 21:42:19 +0100 Message-Id: <1416861739-15031-1-git-send-email-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.1.1 Cc: Daniel Vetter , Intel Graphics Development , Daniel Vetter 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-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_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 Especially with legacy cursor ioctls existing userspace assumes that you can pile up lots of updates in one go. The super-proper way to support this would be a special commit mode which overwrites the last update. But getting there will be quite a bit of work. Meanwhile do what pretty much all the drivers have done for the plane update functions: Simply skip the vblank wait for the buffer cleanup if the buffer is the same. Since the universal cursor plane code will not recreate framebuffers needlessly this allows us to not slow down legacy pageflip events while someone moves the cursor around. v2: Drop the async plane update hunk from a previous attempt at this issue. v3: Fix up kerneldoc. v4: Don't oops so badly. Reported by Jasper. Cc: Rob Clark Cc: "Jasper St. Pierre" Reviewed-by: Rob Clark Signed-off-by: Daniel Vetter Reviewed-by: Jasper St. Pierre Tested-by: Jasper St. Pierre --- drivers/gpu/drm/drm_atomic_helper.c | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c index af37f1edd3ed..0d32039d072f 100644 --- a/drivers/gpu/drm/drm_atomic_helper.c +++ b/drivers/gpu/drm/drm_atomic_helper.c @@ -748,6 +748,33 @@ static void wait_for_fences(struct drm_device *dev, } } +static bool framebuffer_changed(struct drm_device *dev, + struct drm_atomic_state *old_state, + struct drm_crtc *crtc) +{ + struct drm_plane *plane; + struct drm_plane_state *old_plane_state; + int nplanes = old_state->dev->mode_config.num_total_plane; + int i; + + for (i = 0; i < nplanes; i++) { + plane = old_state->planes[i]; + old_plane_state = old_state->plane_states[i]; + + if (!plane) + continue; + + if (plane->state->crtc != crtc && + old_plane_state->crtc != crtc) + continue; + + if (plane->state->fb != old_plane_state->fb) + return true; + } + + return false; +} + /** * drm_atomic_helper_wait_for_vblanks - wait for vblank on crtcs * @dev: DRM device @@ -755,7 +782,9 @@ static void wait_for_fences(struct drm_device *dev, * * Helper to, after atomic commit, wait for vblanks on all effected * crtcs (ie. before cleaning up old framebuffers using - * drm_atomic_helper_cleanup_planes()) + * drm_atomic_helper_cleanup_planes()). It will only wait on crtcs where the + * framebuffers have actually changed to optimize for the legacy cursor and + * plane update use-case. */ void drm_atomic_helper_wait_for_vblanks(struct drm_device *dev, @@ -781,6 +810,9 @@ drm_atomic_helper_wait_for_vblanks(struct drm_device *dev, if (!crtc->state->enable) continue; + if (!framebuffer_changed(dev, old_state, crtc)) + continue; + ret = drm_crtc_vblank_get(crtc); if (ret != 0) continue;