From patchwork Mon Sep 26 13:01:03 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 9350817 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 891A86077A for ; Mon, 26 Sep 2016 15:02:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7B31428B02 for ; Mon, 26 Sep 2016 15:02:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7009C28B0E; Mon, 26 Sep 2016 15:02:47 +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 DA98528B19 for ; Mon, 26 Sep 2016 15:02:43 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A1BF86E51A; Mon, 26 Sep 2016 15:02:39 +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.9]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3B0576E091 for ; Mon, 26 Sep 2016 13:01:13 +0000 (UTC) Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 3sjPGv150xz3hjX8; Mon, 26 Sep 2016 15:01:11 +0200 (CEST) Received: from localhost (dynscan1.mnet-online.de [192.168.6.68]) by mail.m-online.net (Postfix) with ESMTP id 3sjPGv0gLzzvkLv; Mon, 26 Sep 2016 15:01:11 +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 BLvkG36BOpzw; Mon, 26 Sep 2016 15:01:10 +0200 (CEST) X-Auth-Info: +bvuE6uJl7WPs0gdMGvGFN9op+R6oVOSdJzeDbJ7Ulc= Received: from chi.lan (unknown [195.140.253.167]) by mail.mnet-online.de (Postfix) with ESMTPA; Mon, 26 Sep 2016 15:01:10 +0200 (CEST) From: Marek Vasut To: dri-devel@lists.freedesktop.org Subject: [PATCH 1/2] drm/fb_cma_helper: Add drm_fb_cma_setup_fence() helper Date: Mon, 26 Sep 2016 15:01:03 +0200 Message-Id: <20160926130104.8977-1-marex@denx.de> X-Mailer: git-send-email 2.9.3 X-Mailman-Approved-At: Mon, 26 Sep 2016 15:01:57 +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_setup_fence() helper function extracted from the imx-drm driver. This function checks if the plane has DMABUF attached to it and if so, sets up the fence on which the atomic helper can wait. Signed-off-by: Marek Vasut Cc: Daniel Vetter Cc: Lucas Stach --- drivers/gpu/drm/drm_fb_cma_helper.c | 26 ++++++++++++++++++++++++++ include/drm/drm_fb_cma_helper.h | 3 +++ 2 files changed, 29 insertions(+) diff --git a/drivers/gpu/drm/drm_fb_cma_helper.c b/drivers/gpu/drm/drm_fb_cma_helper.c index 1fd6eac..2441707 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,30 @@ 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_setup_fence() - Set up the fence for atomic helper to wait on + * @plane: Which plane + * @state: Plane state to check + * + * If the plane fb has an dma-buf attached, fish out the exclusive + * fence for the atomic helper to wait on. + */ +void drm_fb_cma_setup_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_setup_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..fc122d3 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_setup_fence(struct drm_plane *plane, + struct drm_plane_state *state); + #ifdef CONFIG_DEBUG_FS struct seq_file;