From patchwork Thu Jan 11 21:44:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 10158649 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 2817160170 for ; Thu, 11 Jan 2018 21:44:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1265C286EF for ; Thu, 11 Jan 2018 21:44:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 06BE22874F; Thu, 11 Jan 2018 21:44:31 +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.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID 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 A3AA3286EF for ; Thu, 11 Jan 2018 21:44:30 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B0EF76E4A0; Thu, 11 Jan 2018 21:44:28 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qt0-x241.google.com (mail-qt0-x241.google.com [IPv6:2607:f8b0:400d:c0d::241]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7CD7B6E48C; Thu, 11 Jan 2018 21:44:26 +0000 (UTC) Received: by mail-qt0-x241.google.com with SMTP id e2so3716916qti.0; Thu, 11 Jan 2018 13:44:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ZJENbVKgteqon4z+zX28aLDz5hbvv4Kh+1+p1sdn36I=; b=DrAl4HwCO3lJeEl8yyg4OyKBRrVo6s2itZQ8l8Zo+sXgFXInpT+ztrMBJ/maUtdoGF TKzqIC766fkjnOeLIkHIk1reUChp0HAt2MJ91Q8GFoA4+FKF9ehwbfrYsII1s2wo2o2m QiLrH28tWGc3/VndJOF51XvkdeYytPVfT9bho5fvSfC3LnAl1MmP8jDrUFSEYRzqgWoi cwI8j1hLE/S7O5VWJv5zLDCioTsY3naf7g3gm12zwKVs+ymbb/qUtMnsP7P0QLQRUAnq XyvFQJTaE5CcTH3SLLEDY2ptAsKB7OpxP1kubvnwiUuNuPuQScmt8RLjAqKPJrWRgbH4 6adw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ZJENbVKgteqon4z+zX28aLDz5hbvv4Kh+1+p1sdn36I=; b=GKVKwu/sUV4vSoTEXb3jom2OkONpx6w9f55PcG/xdzBmAX0vvjwvMTcSpN7hkHJQ1I u4vaRq24VjQLpoJ/WG0+WlNhhdHiemehd17dkFrDtgiRgqbskYvnL/XbwYabrqw3r8an rLkOUhzpi58yWpOJaeOhaUrh7EGQGWkl4xGxlXpWv1yxvRpG7wpSNvPK5Gl/9himxhTX 4u0MSDrwVtygiZLxxLQLxU+KizalBsaPQigF7MgFFQ/ZdIj7O7J/9WQhvVZ4VGsWYSI5 yyev/w9+blT6YF+sbrP11ZFV9oye7p2+lEHeVGBpXldtqYvjooP+h6mxp1GKBZBeN6yl ZpdA== X-Gm-Message-State: AKwxytfQ7+Gta14YW9gItaIZ5dF5u06Ja5hTzUl+G1WfuqjSsbzEJEbp fundBSJ4qNObGMGw8ICWGAk= X-Google-Smtp-Source: ACJfBouHvR8e2dp1oEyuGTOzHJ3mLRVJTP/xY/12vIOv7RLkNnVUrqB5BpylGd0T7cq3acg4BxSU1A== X-Received: by 10.200.10.11 with SMTP id b11mr34414065qti.287.1515707065160; Thu, 11 Jan 2018 13:44:25 -0800 (PST) Received: from localhost (p200300E41F21CF00227DB10B7BBDB590.dip0.t-ipconnect.de. [2003:e4:1f21:cf00:227d:b10b:7bbd:b590]) by smtp.gmail.com with ESMTPSA id c1sm12876231qta.52.2018.01.11.13.44.24 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 11 Jan 2018 13:44:24 -0800 (PST) From: Thierry Reding To: Ben Skeggs Subject: [PATCH 2/5] drm/prime: Export more helpers for drivers Date: Thu, 11 Jan 2018 22:44:17 +0100 Message-Id: <20180111214420.26203-2-thierry.reding@gmail.com> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180111214420.26203-1-thierry.reding@gmail.com> References: <20180111214420.26203-1-thierry.reding@gmail.com> Cc: linux-tegra@vger.kernel.org, Daniel Vetter , dri-devel@lists.freedesktop.org, nouveau@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: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Thierry Reding Export some more of the helpers in order to allow drivers to more fine- grainedly select which helpers to use. This gives drivers an easy way to reuse a lot of the code in the helpers while at the same time allowing them to provide their own implementation for other functions in struct dma_buf_ops. Signed-off-by: Thierry Reding --- drivers/gpu/drm/drm_prime.c | 23 +++++++++++++---------- include/drm/drm_prime.h | 12 ++++++++++++ 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/drm_prime.c b/drivers/gpu/drm/drm_prime.c index 9a17725b0f7a..f9903e6b59f6 100644 --- a/drivers/gpu/drm/drm_prime.c +++ b/drivers/gpu/drm/drm_prime.c @@ -180,9 +180,8 @@ static int drm_prime_lookup_buf_handle(struct drm_prime_file_private *prime_fpri return -ENOENT; } -static int drm_gem_map_attach(struct dma_buf *dma_buf, - struct device *target_dev, - struct dma_buf_attachment *attach) +int drm_gem_map_attach(struct dma_buf *dma_buf, struct device *target_dev, + struct dma_buf_attachment *attach) { struct drm_prime_attachment *prime_attach; struct drm_gem_object *obj = dma_buf->priv; @@ -200,9 +199,10 @@ static int drm_gem_map_attach(struct dma_buf *dma_buf, return dev->driver->gem_prime_pin(obj); } +EXPORT_SYMBOL(drm_gem_map_attach); -static void drm_gem_map_detach(struct dma_buf *dma_buf, - struct dma_buf_attachment *attach) +void drm_gem_map_detach(struct dma_buf *dma_buf, + struct dma_buf_attachment *attach) { struct drm_prime_attachment *prime_attach = attach->priv; struct drm_gem_object *obj = dma_buf->priv; @@ -228,6 +228,7 @@ static void drm_gem_map_detach(struct dma_buf *dma_buf, kfree(prime_attach); attach->priv = NULL; } +EXPORT_SYMBOL(drm_gem_map_detach); void drm_prime_remove_buf_handle_locked(struct drm_prime_file_private *prime_fpriv, struct dma_buf *dma_buf) @@ -254,8 +255,8 @@ void drm_prime_remove_buf_handle_locked(struct drm_prime_file_private *prime_fpr } } -static struct sg_table *drm_gem_map_dma_buf(struct dma_buf_attachment *attach, - enum dma_data_direction dir) +struct sg_table *drm_gem_map_dma_buf(struct dma_buf_attachment *attach, + enum dma_data_direction dir) { struct drm_prime_attachment *prime_attach = attach->priv; struct drm_gem_object *obj = attach->dmabuf->priv; @@ -291,13 +292,15 @@ static struct sg_table *drm_gem_map_dma_buf(struct dma_buf_attachment *attach, return sgt; } +EXPORT_SYMBOL(drm_gem_map_dma_buf); -static void drm_gem_unmap_dma_buf(struct dma_buf_attachment *attach, - struct sg_table *sgt, - enum dma_data_direction dir) +void drm_gem_unmap_dma_buf(struct dma_buf_attachment *attach, + struct sg_table *sgt, + enum dma_data_direction dir) { /* nothing to be done here */ } +EXPORT_SYMBOL(drm_gem_unmap_dma_buf); /** * drm_gem_dmabuf_export - dma_buf export implementation for GEM diff --git a/include/drm/drm_prime.h b/include/drm/drm_prime.h index 59ccab402e85..3a9706815773 100644 --- a/include/drm/drm_prime.h +++ b/include/drm/drm_prime.h @@ -50,8 +50,10 @@ struct drm_prime_file_private { struct rb_root handles; }; +enum dma_data_direction; struct device; +struct dma_buf_attachment; struct dma_buf_export_info; struct dma_buf; @@ -59,6 +61,16 @@ struct drm_device; struct drm_gem_object; struct drm_file; +int drm_gem_map_attach(struct dma_buf *dma_buf, struct device *target_dev, + struct dma_buf_attachment *attach); +void drm_gem_map_detach(struct dma_buf *dma_buf, + struct dma_buf_attachment *attach); +struct sg_table *drm_gem_map_dma_buf(struct dma_buf_attachment *attach, + enum dma_data_direction dir); +void drm_gem_unmap_dma_buf(struct dma_buf_attachment *attach, + struct sg_table *sgt, + enum dma_data_direction dir); + struct dma_buf *drm_gem_prime_export(struct drm_device *dev, struct drm_gem_object *obj, int flags);