From patchwork Thu Feb 21 14:35:53 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 2171571 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork2.kernel.org (Postfix) with ESMTP id 0A240DF215 for ; Thu, 21 Feb 2013 14:39:47 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 06B97E6957 for ; Thu, 21 Feb 2013 06:39:47 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from moutng.kundenserver.de (moutng.kundenserver.de [212.227.126.187]) by gabe.freedesktop.org (Postfix) with ESMTP id 1F15CE694A for ; Thu, 21 Feb 2013 06:36:14 -0800 (PST) Received: from mailbox.adnet.avionic-design.de (mailbox.avionic-design.de [109.75.18.3]) by mrelayeu.kundenserver.de (node=mrbap0) with ESMTP (Nemesis) id 0MFi3J-1U3GSy3stZ-00Ej70; Thu, 21 Feb 2013 15:36:10 +0100 Received: from localhost (localhost [127.0.0.1]) by mailbox.adnet.avionic-design.de (Postfix) with ESMTP id AE4C62A28241; Thu, 21 Feb 2013 15:36:08 +0100 (CET) X-Virus-Scanned: amavisd-new at avionic-design.de Received: from mailbox.adnet.avionic-design.de ([127.0.0.1]) by localhost (mailbox.avionic-design.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Nih-hTZh4NDI; Thu, 21 Feb 2013 15:36:02 +0100 (CET) Received: from mailman.adnet.avionic-design.de (mailman.adnet.avionic-design.de [172.20.31.172]) by mailbox.adnet.avionic-design.de (Postfix) with ESMTP id 6AF8C2A28162; Thu, 21 Feb 2013 15:36:02 +0100 (CET) Received: from localhost (avionic-0098.adnet.avionic-design.de [172.20.31.233]) by mailman.adnet.avionic-design.de (Postfix) with ESMTP id D4EE510091A; Thu, 21 Feb 2013 15:35:57 +0100 (CET) From: Thierry Reding To: Dave Airlie Subject: [PATCH v4 1/9] drm: Add consistency check for page-flipping Date: Thu, 21 Feb 2013 15:35:53 +0100 Message-Id: <1361457361-13838-2-git-send-email-thierry.reding@avionic-design.de> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1361457361-13838-1-git-send-email-thierry.reding@avionic-design.de> References: <1361457361-13838-1-git-send-email-thierry.reding@avionic-design.de> X-Provags-ID: V02:K0:1pYTulT1sPIriDqALyLcLOWEoavyLduZX3b3CMSV9PX T0Se2RVK97EXb2F0aWE1GGwFDphciTjQgo9IOcbNdur+8oexYk 8lx2bl4PvP3oOYT9AD65CoMkRzWoL6PztGlm7ft5pOjKjIpDMj IMIaspSJyggeq9qflSCBBnEVU0/8HsK2W4ZXT7odvcDgZdsmvO N8EMEjIqTXLsZj9FOAf2yU8fughEX79EJhTsc28SajKLW4Qcuk 7hpGIcz+NfsuzsMGUJIG1YCXp0tUppcybjVAtgqY0WCfAqPuoZ hsVz5+wVj2f5USLM3MenMxjk0I5ebKBEQ2qpq4TC7/eTewvdCB UHjKZL4Gs0gda/ODkyCtJPWHT3bxGFxlUjU2NR0+B8rwiCG8oz b4twQtylTyYa9ngn6A/AFnARQz82hfjVJClctdnnmZKrckLHSI FDNz3 Cc: linux-tegra@vger.kernel.org, dri-devel@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Errors-To: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Driver implementations of the drm_crtc's .page_flip() function are required to update the crtc->fb field on success to reflect that the new framebuffer is now in use. This is important to keep reference counting on the framebuffers balanced. While at it, document this requirement to keep others from falling into the same trap. Suggested-by: Daniel Vetter Signed-off-by: Thierry Reding Reviewed-by: Daniel Vetter --- Documentation/DocBook/drm.tmpl | 6 ++++++ drivers/gpu/drm/drm_crtc.c | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/Documentation/DocBook/drm.tmpl b/Documentation/DocBook/drm.tmpl index 51e1904..a6428dd 100644 --- a/Documentation/DocBook/drm.tmpl +++ b/Documentation/DocBook/drm.tmpl @@ -1161,6 +1161,12 @@ int max_width, max_height; any new rendering to the frame buffer until the page flip completes. + If a page flip can be successfully scheduled the driver must set the + drm_crtc-<fb field to the new framebuffer pointed to + by fb. This is important so that the reference counting + on framebuffers stays balanced. + + If a page flip is already pending, the page_flip operation must return -EBUSY. diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c index 781aef5..3bdf2a6 100644 --- a/drivers/gpu/drm/drm_crtc.c +++ b/drivers/gpu/drm/drm_crtc.c @@ -3792,6 +3792,13 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev, /* Keep the old fb, don't unref it. */ old_fb = NULL; } else { + /* + * Warn if the driver hasn't properly updated the crtc->fb + * field to reflect that the new framebuffer is now used. + * Failing to do so will screw with the reference counting + * on framebuffers. + */ + WARN_ON(crtc->fb != fb); /* Unref only the old framebuffer. */ fb = NULL; }