From patchwork Wed Sep 28 20:15:25 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 9355851 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 D3C826077A for ; Thu, 29 Sep 2016 08:09:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C772A2989F for ; Thu, 29 Sep 2016 08:09:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BC155298A3; Thu, 29 Sep 2016 08:09:13 +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 EBEDD2989F for ; Thu, 29 Sep 2016 08:09:11 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1B0BA6E1FE; Thu, 29 Sep 2016 08:09:08 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-out.m-online.net (mail-out.m-online.net [212.18.0.10]) by gabe.freedesktop.org (Postfix) with ESMTPS id CC2C76E7C7 for ; Wed, 28 Sep 2016 20:15:35 +0000 (UTC) Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 3skpqB3nGDz3hjhh; Wed, 28 Sep 2016 22:15:34 +0200 (CEST) Received: from localhost (dynscan1.mnet-online.de [192.168.6.68]) by mail.m-online.net (Postfix) with ESMTP id 3skpqB3FxFzvlCT; Wed, 28 Sep 2016 22:15:34 +0200 (CEST) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.68]) (amavisd-new, port 10024) with ESMTP id B_sNMV0bbj4m; Wed, 28 Sep 2016 22:15:32 +0200 (CEST) X-Auth-Info: V81XIdlU0PJnFcFZ5XdSDLFWsTa1bnrdc1dNAwF/hEA= Received: from chi.lan (unknown [195.140.253.167]) by mail.mnet-online.de (Postfix) with ESMTPA; Wed, 28 Sep 2016 22:15:32 +0200 (CEST) From: Marek Vasut To: dri-devel@lists.freedesktop.org Subject: [PATCH V2 1/2] drm/fb_cma_helper: Add drm_fb_cma_extract_and_attach_fence() helper Date: Wed, 28 Sep 2016 22:15:25 +0200 Message-Id: <20160928201526.13255-1-marex@denx.de> X-Mailer: git-send-email 2.9.3 X-Mailman-Approved-At: Thu, 29 Sep 2016 08:09:07 +0000 Cc: Marek Vasut , 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-Virus-Scanned: ClamAV using ClamSMTP Add new drm_fb_cma_extract_and_attach_fence() helper function extracted from the imx-drm driver. This function checks if the plane has DMABUF attached to it, extracts the exclusive fence from it and attaches it to the plane state for the atomic helper to wait on it. Signed-off-by: Marek Vasut Cc: Daniel Vetter Cc: Lucas Stach --- V2: Rename the function to drm_fb_cma_extract_and_attach_fence() and clarify the documentation (thanks to Lucas Stach) --- drivers/gpu/drm/drm_fb_cma_helper.c | 27 +++++++++++++++++++++++++++ include/drm/drm_fb_cma_helper.h | 3 +++ 2 files changed, 30 insertions(+) diff --git a/drivers/gpu/drm/drm_fb_cma_helper.c b/drivers/gpu/drm/drm_fb_cma_helper.c index 1fd6eac..74c7188 100644 --- a/drivers/gpu/drm/drm_fb_cma_helper.c +++ b/drivers/gpu/drm/drm_fb_cma_helper.c @@ -23,8 +23,10 @@ #include #include #include +#include #include #include +#include #define DEFAULT_FBDEFIO_DELAY_MS 50 @@ -265,6 +267,31 @@ struct drm_gem_cma_object *drm_fb_cma_get_gem_obj(struct drm_framebuffer *fb, } EXPORT_SYMBOL_GPL(drm_fb_cma_get_gem_obj); +/** + * drm_fb_cma_extract_and_attach_fence() - Extract fence from plane and attach to planestate + * @plane: Which plane + * @state: Plane state attach fence to + * + * If the plane fb has an dma-buf attached, fish out the exclusive + * fence and attach it to plane state for the atomic helper to wait + * on. + */ +void drm_fb_cma_extract_and_attach_fence(struct drm_plane *plane, + struct drm_plane_state *state) +{ + struct dma_buf *dma_buf; + + if ((plane->state->fb == state->fb) || !state->fb) + return; + + dma_buf = drm_fb_cma_get_gem_obj(state->fb, 0)->base.dma_buf; + if (!dma_buf) + return; + + state->fence = reservation_object_get_excl_rcu(dma_buf->resv); +} +EXPORT_SYMBOL_GPL(drm_fb_cma_extract_and_attach_fence); + #ifdef CONFIG_DEBUG_FS static void drm_fb_cma_describe(struct drm_framebuffer *fb, struct seq_file *m) { diff --git a/include/drm/drm_fb_cma_helper.h b/include/drm/drm_fb_cma_helper.h index f313211..d514faa 100644 --- a/include/drm/drm_fb_cma_helper.h +++ b/include/drm/drm_fb_cma_helper.h @@ -41,6 +41,9 @@ struct drm_framebuffer *drm_fb_cma_create(struct drm_device *dev, struct drm_gem_cma_object *drm_fb_cma_get_gem_obj(struct drm_framebuffer *fb, unsigned int plane); +void drm_fb_cma_extract_and_attach_fence(struct drm_plane *plane, + struct drm_plane_state *state); + #ifdef CONFIG_DEBUG_FS struct seq_file;