From patchwork Fri Jan 23 07:34:12 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Semwal X-Patchwork-Id: 43564 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f197.google.com (mail-lb0-f197.google.com [209.85.217.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 38E91240D9 for ; Fri, 23 Jan 2015 07:35:03 +0000 (UTC) Received: by mail-lb0-f197.google.com with SMTP id b6sf3292578lbj.0 for ; Thu, 22 Jan 2015 23:35:02 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:delivered-to:from:to:subject:date :message-id:cc:precedence:list-id:list-unsubscribe:list-archive :list-post:list-help:list-subscribe:mime-version:content-type :content-transfer-encoding:errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=gIzf5AUOAYcAGZUFkZVpslEoZQ0l4zPga7CFbHm1FA0=; b=dql7zuX9oB/AOVLjSNESXmn97JgNLmxcLjF4CkSpOy104x1b36pnC5LeFJG+1g5Gx8 tgrsuvINEAOiGx9Rvqz94xI0mKUxKijuKkVGhTE8gBszf8w+BgqHacmlxkaVE6EVz30H AMPF1BoWoNYYOVXsSsMwRIpmLNpPKx3Z1PjQ0XvTaoOAQVmXgqAOV7Wjt3CklDabWRQb Qwl57QYFcJh1LoaJiBczpCHI9oqZYWxMlQ3aIZ5e+KiG57nmaYANQhOUqA3C3t4Iy7c5 RrgEg87UE+r9Jf7+RJD6p8oZtoMNAUHwB8c0nLOb46chDh5Caq5rluQMuys1i0UbWBAY LLcQ== X-Gm-Message-State: ALoCoQm6EGzolRLKT4uKXvFTkob5NQbxNwtVhLzMRYswbIBwvN7M7l90MYLyAhjHDQblMupo3AVv X-Received: by 10.180.208.46 with SMTP id mb14mr68240wic.4.1421998502176; Thu, 22 Jan 2015 23:35:02 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.2.137 with SMTP id 9ls233352lau.26.gmail; Thu, 22 Jan 2015 23:35:02 -0800 (PST) X-Received: by 10.152.2.38 with SMTP id 6mr5823080lar.60.1421998502001; Thu, 22 Jan 2015 23:35:02 -0800 (PST) Received: from mail-la0-f47.google.com (mail-la0-f47.google.com. [209.85.215.47]) by mx.google.com with ESMTPS id h11si606198lbn.62.2015.01.22.23.35.01 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Jan 2015 23:35:01 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.47 as permitted sender) client-ip=209.85.215.47; Received: by mail-la0-f47.google.com with SMTP id hz20so5829777lab.6 for ; Thu, 22 Jan 2015 23:35:01 -0800 (PST) X-Received: by 10.152.3.70 with SMTP id a6mr5716880laa.71.1421998501860; Thu, 22 Jan 2015 23:35:01 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.9.200 with SMTP id c8csp156081lbb; Thu, 22 Jan 2015 23:35:00 -0800 (PST) X-Received: by 10.67.22.162 with SMTP id ht2mr9125494pad.49.1421998499527; Thu, 22 Jan 2015 23:34:59 -0800 (PST) Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTP id rq5si1004526pab.43.2015.01.22.23.34.58; Thu, 22 Jan 2015 23:34:59 -0800 (PST) Received-SPF: none (google.com: dri-devel-bounces@lists.freedesktop.org does not designate permitted sender hosts) client-ip=131.252.210.177; Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0DA486E376; Thu, 22 Jan 2015 23:34:57 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pa0-f50.google.com (mail-pa0-f50.google.com [209.85.220.50]) by gabe.freedesktop.org (Postfix) with ESMTP id C2F4672089 for ; Thu, 22 Jan 2015 23:34:55 -0800 (PST) Received: by mail-pa0-f50.google.com with SMTP id rd3so6135553pab.9 for ; Thu, 22 Jan 2015 23:34:55 -0800 (PST) X-Received: by 10.66.160.196 with SMTP id xm4mr916216pab.78.1421998495557; Thu, 22 Jan 2015 23:34:55 -0800 (PST) Received: from ss-ubuntu.lan ([106.51.225.38]) by mx.google.com with ESMTPSA id kg12sm928250pbb.44.2015.01.22.23.34.49 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 22 Jan 2015 23:34:54 -0800 (PST) From: Sumit Semwal To: linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, linux-arm-kernel@lists.infradead.org, rmk+kernel@arm.linux.org.uk, airlied@linux.ie, kgene@kernel.org, daniel.vetter@intel.com, thierry.reding@gmail.com, pawel@osciak.com, m.szyprowski@samsung.com, mchehab@osg.samsung.com, gregkh@linuxfoundation.org Subject: [RFC] dma-buf: cleanup dma_buf_export() to make it easily extensible Date: Fri, 23 Jan 2015 13:04:12 +0530 Message-Id: <1421998452-18752-1-git-send-email-sumit.semwal@linaro.org> X-Mailer: git-send-email 1.9.1 Cc: linaro-kernel@lists.linaro.org, intel-gfx@lists.freedesktop.org, linux-tegra@vger.kernel.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: 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-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: sumit.semwal@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.47 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 At present, dma_buf_export() takes a series of parameters, which makes it difficult to add any new parameters for exporters, if required. Make it simpler by moving all these parameters into a struct, and pass the struct * as parameter to dma_buf_export(). While at it, unite dma_buf_export_named() with dma_buf_export(), and change all callers accordingly. Signed-off-by: Sumit Semwal --- drivers/dma-buf/dma-buf.c | 47 +++++++++++++------------- drivers/gpu/drm/armada/armada_gem.c | 12 +++++-- drivers/gpu/drm/drm_prime.c | 14 +++++--- drivers/gpu/drm/exynos/exynos_drm_dmabuf.c | 13 +++++-- drivers/gpu/drm/i915/i915_gem_dmabuf.c | 12 +++++-- drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c | 11 +++++- drivers/gpu/drm/tegra/gem.c | 12 +++++-- drivers/gpu/drm/ttm/ttm_object.c | 11 ++++-- drivers/gpu/drm/udl/udl_dmabuf.c | 10 +++++- drivers/media/v4l2-core/videobuf2-dma-contig.c | 10 +++++- drivers/media/v4l2-core/videobuf2-dma-sg.c | 10 +++++- drivers/media/v4l2-core/videobuf2-vmalloc.c | 10 +++++- drivers/staging/android/ion/ion.c | 11 ++++-- include/linux/dma-buf.h | 28 +++++++++++---- 14 files changed, 160 insertions(+), 51 deletions(-) diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c index 5be225c2ba98..6d3df3dd9310 100644 --- a/drivers/dma-buf/dma-buf.c +++ b/drivers/dma-buf/dma-buf.c @@ -265,7 +265,7 @@ static inline int is_dma_buf_file(struct file *file) } /** - * dma_buf_export_named - Creates a new dma_buf, and associates an anon file + * dma_buf_export - Creates a new dma_buf, and associates an anon file * with this buffer, so it can be exported. * Also connect the allocator specific data and ops to the buffer. * Additionally, provide a name string for exporter; useful in debugging. @@ -277,31 +277,32 @@ static inline int is_dma_buf_file(struct file *file) * @exp_name: [in] name of the exporting module - useful for debugging. * @resv: [in] reservation-object, NULL to allocate default one. * + * All the above info comes from struct dma_buf_export_info. + * * Returns, on success, a newly created dma_buf object, which wraps the * supplied private data and operations for dma_buf_ops. On either missing * ops, or error in allocating struct dma_buf, will return negative error. * */ -struct dma_buf *dma_buf_export_named(void *priv, const struct dma_buf_ops *ops, - size_t size, int flags, const char *exp_name, - struct reservation_object *resv) +struct dma_buf *dma_buf_export(struct dma_buf_export_info *exp_info) { struct dma_buf *dmabuf; struct file *file; size_t alloc_size = sizeof(struct dma_buf); - if (!resv) + if (!exp_info->resv) alloc_size += sizeof(struct reservation_object); else /* prevent &dma_buf[1] == dma_buf->resv */ alloc_size += 1; - if (WARN_ON(!priv || !ops - || !ops->map_dma_buf - || !ops->unmap_dma_buf - || !ops->release - || !ops->kmap_atomic - || !ops->kmap - || !ops->mmap)) { + if (WARN_ON(!exp_info->priv + || !exp_info->ops + || !exp_info->ops->map_dma_buf + || !exp_info->ops->unmap_dma_buf + || !exp_info->ops->release + || !exp_info->ops->kmap_atomic + || !exp_info->ops->kmap + || !exp_info->ops->mmap)) { return ERR_PTR(-EINVAL); } @@ -309,21 +310,22 @@ struct dma_buf *dma_buf_export_named(void *priv, const struct dma_buf_ops *ops, if (dmabuf == NULL) return ERR_PTR(-ENOMEM); - dmabuf->priv = priv; - dmabuf->ops = ops; - dmabuf->size = size; - dmabuf->exp_name = exp_name; + dmabuf->priv = exp_info->priv; + dmabuf->ops = exp_info->ops; + dmabuf->size = exp_info->size; + dmabuf->exp_name = exp_info->exp_name; init_waitqueue_head(&dmabuf->poll); dmabuf->cb_excl.poll = dmabuf->cb_shared.poll = &dmabuf->poll; dmabuf->cb_excl.active = dmabuf->cb_shared.active = 0; - if (!resv) { - resv = (struct reservation_object *)&dmabuf[1]; - reservation_object_init(resv); + if (!exp_info->resv) { + exp_info->resv = (struct reservation_object *)&dmabuf[1]; + reservation_object_init(exp_info->resv); } - dmabuf->resv = resv; + dmabuf->resv = exp_info->resv; - file = anon_inode_getfile("dmabuf", &dma_buf_fops, dmabuf, flags); + file = anon_inode_getfile("dmabuf", &dma_buf_fops, dmabuf, + exp_info->flags); if (IS_ERR(file)) { kfree(dmabuf); return ERR_CAST(file); @@ -341,8 +343,7 @@ struct dma_buf *dma_buf_export_named(void *priv, const struct dma_buf_ops *ops, return dmabuf; } -EXPORT_SYMBOL_GPL(dma_buf_export_named); - +EXPORT_SYMBOL_GPL(dma_buf_export); /** * dma_buf_fd - returns a file descriptor for the given dma_buf diff --git a/drivers/gpu/drm/armada/armada_gem.c b/drivers/gpu/drm/armada/armada_gem.c index ef5feeecec84..5d109c3dd326 100644 --- a/drivers/gpu/drm/armada/armada_gem.c +++ b/drivers/gpu/drm/armada/armada_gem.c @@ -538,8 +538,16 @@ struct dma_buf * armada_gem_prime_export(struct drm_device *dev, struct drm_gem_object *obj, int flags) { - return dma_buf_export(obj, &armada_gem_prime_dmabuf_ops, obj->size, - O_RDWR, NULL); + struct dma_buf_export_info exp_info = { + .exp_name = KBUILD_MODNAME, + .ops = &armada_gem_prime_dmabuf_ops, + .size = obj->size, + .flags = O_RDWR, + .resv = NULL, + .priv = obj, + }; + + return dma_buf_export(&exp_info); } struct drm_gem_object * diff --git a/drivers/gpu/drm/drm_prime.c b/drivers/gpu/drm/drm_prime.c index 7482b06cd08f..20ae77455c04 100644 --- a/drivers/gpu/drm/drm_prime.c +++ b/drivers/gpu/drm/drm_prime.c @@ -339,13 +339,19 @@ static const struct dma_buf_ops drm_gem_prime_dmabuf_ops = { struct dma_buf *drm_gem_prime_export(struct drm_device *dev, struct drm_gem_object *obj, int flags) { - struct reservation_object *robj = NULL; + struct dma_buf_export_info exp_info = { + .exp_name = KBUILD_MODNAME, + .ops = &drm_gem_prime_dmabuf_ops, + .size = obj->size, + .flags = flags, + .resv = NULL, + .priv = obj, + }; if (dev->driver->gem_prime_res_obj) - robj = dev->driver->gem_prime_res_obj(obj); + exp_info.resv = dev->driver->gem_prime_res_obj(obj); - return dma_buf_export(obj, &drm_gem_prime_dmabuf_ops, obj->size, - flags, robj); + return dma_buf_export(&exp_info); } EXPORT_SYMBOL(drm_gem_prime_export); diff --git a/drivers/gpu/drm/exynos/exynos_drm_dmabuf.c b/drivers/gpu/drm/exynos/exynos_drm_dmabuf.c index 60192ed544f0..abc65a02dffa 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_dmabuf.c +++ b/drivers/gpu/drm/exynos/exynos_drm_dmabuf.c @@ -185,9 +185,16 @@ struct dma_buf *exynos_dmabuf_prime_export(struct drm_device *drm_dev, struct drm_gem_object *obj, int flags) { struct exynos_drm_gem_obj *exynos_gem_obj = to_exynos_gem_obj(obj); - - return dma_buf_export(obj, &exynos_dmabuf_ops, - exynos_gem_obj->base.size, flags, NULL); + struct dma_buf_export_info exp_info = { + .exp_name = KBUILD_MODNAME, + .ops = &exynos_dmabuf_ops, + .size = exynos_gem_obj->base.size, + .flags = flags, + .resv = NULL, + .priv = obj, + }; + + return dma_buf_export(&exp_info); } struct drm_gem_object *exynos_dmabuf_prime_import(struct drm_device *drm_dev, diff --git a/drivers/gpu/drm/i915/i915_gem_dmabuf.c b/drivers/gpu/drm/i915/i915_gem_dmabuf.c index 82a1f4b57778..15fa1523aefc 100644 --- a/drivers/gpu/drm/i915/i915_gem_dmabuf.c +++ b/drivers/gpu/drm/i915/i915_gem_dmabuf.c @@ -229,6 +229,15 @@ static const struct dma_buf_ops i915_dmabuf_ops = { struct dma_buf *i915_gem_prime_export(struct drm_device *dev, struct drm_gem_object *gem_obj, int flags) { + struct dma_buf_export_info exp_info = { + .exp_name = KBUILD_MODNAME, + .ops = &i915_dmabuf_ops, + .size = gem_obj->size, + .flags = flags, + .resv = NULL, + .priv = gem_obj, + }; + struct drm_i915_gem_object *obj = to_intel_bo(gem_obj); if (obj->ops->dmabuf_export) { @@ -237,8 +246,7 @@ struct dma_buf *i915_gem_prime_export(struct drm_device *dev, return ERR_PTR(ret); } - return dma_buf_export(gem_obj, &i915_dmabuf_ops, gem_obj->size, flags, - NULL); + return dma_buf_export(&exp_info); } static int i915_gem_object_get_pages_dmabuf(struct drm_i915_gem_object *obj) diff --git a/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c b/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c index a2dbfb1737b4..534718416f5e 100644 --- a/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c +++ b/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c @@ -171,7 +171,16 @@ static struct dma_buf_ops omap_dmabuf_ops = { struct dma_buf *omap_gem_prime_export(struct drm_device *dev, struct drm_gem_object *obj, int flags) { - return dma_buf_export(obj, &omap_dmabuf_ops, obj->size, flags, NULL); + struct dma_buf_export_info exp_info = { + .exp_name = KBUILD_MODNAME, + .ops = &omap_dmabuf_ops, + .size = obj->size, + .flags = flags, + .resv = NULL, + .priv = obj, + }; + + return dma_buf_export(&exp_info); } struct drm_gem_object *omap_gem_prime_import(struct drm_device *dev, diff --git a/drivers/gpu/drm/tegra/gem.c b/drivers/gpu/drm/tegra/gem.c index 8777b7f75791..79a0fbc32ad4 100644 --- a/drivers/gpu/drm/tegra/gem.c +++ b/drivers/gpu/drm/tegra/gem.c @@ -658,8 +658,16 @@ struct dma_buf *tegra_gem_prime_export(struct drm_device *drm, struct drm_gem_object *gem, int flags) { - return dma_buf_export(gem, &tegra_gem_prime_dmabuf_ops, gem->size, - flags, NULL); + struct dma_buf_export_info exp_info = { + .exp_name = KBUILD_MODNAME, + .ops = &tegra_gem_prime_dmabuf_ops, + .size = gem->size, + .flags = flags, + .resv = NULL, + .priv = gem, + }; + + return dma_buf_export(&exp_info); } struct drm_gem_object *tegra_gem_prime_import(struct drm_device *drm, diff --git a/drivers/gpu/drm/ttm/ttm_object.c b/drivers/gpu/drm/ttm/ttm_object.c index 12c87110db3a..2274f1637b89 100644 --- a/drivers/gpu/drm/ttm/ttm_object.c +++ b/drivers/gpu/drm/ttm/ttm_object.c @@ -683,6 +683,14 @@ int ttm_prime_handle_to_fd(struct ttm_object_file *tfile, dma_buf = prime->dma_buf; if (!dma_buf || !get_dma_buf_unless_doomed(dma_buf)) { + struct dma_buf_export_info exp_info = { + .exp_name = KBUILD_MODNAME, + .ops = &tdev->ops, + .size = prime->size, + .flags = flags, + .resv = NULL, + .priv = prime, + }; /* * Need to create a new dma_buf, with memory accounting. @@ -694,8 +702,7 @@ int ttm_prime_handle_to_fd(struct ttm_object_file *tfile, goto out_unref; } - dma_buf = dma_buf_export(prime, &tdev->ops, - prime->size, flags, NULL); + dma_buf = dma_buf_export(&exp_info); if (IS_ERR(dma_buf)) { ret = PTR_ERR(dma_buf); ttm_mem_global_free(tdev->mem_glob, diff --git a/drivers/gpu/drm/udl/udl_dmabuf.c b/drivers/gpu/drm/udl/udl_dmabuf.c index ac8a66b4dfc2..0e200009bae7 100644 --- a/drivers/gpu/drm/udl/udl_dmabuf.c +++ b/drivers/gpu/drm/udl/udl_dmabuf.c @@ -202,7 +202,15 @@ static struct dma_buf_ops udl_dmabuf_ops = { struct dma_buf *udl_gem_prime_export(struct drm_device *dev, struct drm_gem_object *obj, int flags) { - return dma_buf_export(obj, &udl_dmabuf_ops, obj->size, flags, NULL); + struct dma_buf_export_info exp_info = { + .exp_name = KBUILD_MODNAME, + .ops = &udl_dmabuf_ops, + .size = obj->size, + .flags = flags, + .resv = NULL, + .priv = obj, + }; + return dma_buf_export(&exp_info); } static int udl_prime_create(struct drm_device *dev, diff --git a/drivers/media/v4l2-core/videobuf2-dma-contig.c b/drivers/media/v4l2-core/videobuf2-dma-contig.c index b481d20c8372..2b3c494e18c9 100644 --- a/drivers/media/v4l2-core/videobuf2-dma-contig.c +++ b/drivers/media/v4l2-core/videobuf2-dma-contig.c @@ -402,6 +402,14 @@ static struct dma_buf *vb2_dc_get_dmabuf(void *buf_priv, unsigned long flags) { struct vb2_dc_buf *buf = buf_priv; struct dma_buf *dbuf; + struct dma_buf_export_info exp_info = { + .exp_name = KBUILD_MODNAME, + .ops = &vb2_dc_dmabuf_ops, + .size = buf->size, + .flags = flags, + .resv = NULL, + .priv = buf, + }; if (!buf->sgt_base) buf->sgt_base = vb2_dc_get_base_sgt(buf); @@ -409,7 +417,7 @@ static struct dma_buf *vb2_dc_get_dmabuf(void *buf_priv, unsigned long flags) if (WARN_ON(!buf->sgt_base)) return NULL; - dbuf = dma_buf_export(buf, &vb2_dc_dmabuf_ops, buf->size, flags, NULL); + dbuf = dma_buf_export(&exp_info); if (IS_ERR(dbuf)) return NULL; diff --git a/drivers/media/v4l2-core/videobuf2-dma-sg.c b/drivers/media/v4l2-core/videobuf2-dma-sg.c index b1838abb6d00..5a9835655146 100644 --- a/drivers/media/v4l2-core/videobuf2-dma-sg.c +++ b/drivers/media/v4l2-core/videobuf2-dma-sg.c @@ -583,11 +583,19 @@ static struct dma_buf *vb2_dma_sg_get_dmabuf(void *buf_priv, unsigned long flags { struct vb2_dma_sg_buf *buf = buf_priv; struct dma_buf *dbuf; + struct dma_buf_export_info exp_info = { + .exp_name = KBUILD_MODNAME, + .ops = &vb2_dma_sg_dmabuf_ops, + .size = buf->size, + .flags = flags, + .resv = NULL, + .priv = buf, + }; if (WARN_ON(!buf->dma_sgt)) return NULL; - dbuf = dma_buf_export(buf, &vb2_dma_sg_dmabuf_ops, buf->size, flags, NULL); + dbuf = dma_buf_export(&exp_info); if (IS_ERR(dbuf)) return NULL; diff --git a/drivers/media/v4l2-core/videobuf2-vmalloc.c b/drivers/media/v4l2-core/videobuf2-vmalloc.c index fba944e50227..fb61090f43c6 100644 --- a/drivers/media/v4l2-core/videobuf2-vmalloc.c +++ b/drivers/media/v4l2-core/videobuf2-vmalloc.c @@ -367,11 +367,19 @@ static struct dma_buf *vb2_vmalloc_get_dmabuf(void *buf_priv, unsigned long flag { struct vb2_vmalloc_buf *buf = buf_priv; struct dma_buf *dbuf; + struct dma_buf_export_info exp_info = { + .exp_name = KBUILD_MODNAME, + .ops = &vb2_vmalloc_dmabuf_ops, + .size = buf->size, + .flags = flags, + .resv = NULL, + .priv = buf, + }; if (WARN_ON(!buf->vaddr)) return NULL; - dbuf = dma_buf_export(buf, &vb2_vmalloc_dmabuf_ops, buf->size, flags, NULL); + dbuf = dma_buf_export(&exp_info); if (IS_ERR(dbuf)) return NULL; diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c index 296d347660fc..8eff2607f370 100644 --- a/drivers/staging/android/ion/ion.c +++ b/drivers/staging/android/ion/ion.c @@ -1106,6 +1106,14 @@ struct dma_buf *ion_share_dma_buf(struct ion_client *client, struct ion_buffer *buffer; struct dma_buf *dmabuf; bool valid_handle; + struct dma_buf_export_info exp_info = { + .exp_name = KBUILD_MODNAME, + .ops = &dma_buf_ops, + .size = buffer->size, + .flags = O_RDWR, + .resv = NULL, + .priv = buffer, + }; mutex_lock(&client->lock); valid_handle = ion_handle_validate(client, handle); @@ -1118,8 +1126,7 @@ struct dma_buf *ion_share_dma_buf(struct ion_client *client, ion_buffer_get(buffer); mutex_unlock(&client->lock); - dmabuf = dma_buf_export(buffer, &dma_buf_ops, buffer->size, O_RDWR, - NULL); + dmabuf = dma_buf_export(&exp_info); if (IS_ERR(dmabuf)) { ion_buffer_put(buffer); return dmabuf; diff --git a/include/linux/dma-buf.h b/include/linux/dma-buf.h index 694e1fe1c4b4..c5f3c9510368 100644 --- a/include/linux/dma-buf.h +++ b/include/linux/dma-buf.h @@ -163,6 +163,27 @@ struct dma_buf_attachment { }; /** + * struct dma_buf_export_info - holds information needed to export a dma_buf + * @exp_name: name of the exporting module - useful for debugging. + * @ops: Attach allocator-defined dma buf ops to the new buffer + * @size: Size of the buffer + * @flags: mode flags for the file + * @resv: reservation-object, NULL to allocate default one + * @priv: Attach private data of allocator to this buffer + * + * This structure holds the information required to export the buffer. Used + * with dma_buf_export() only. + */ +struct dma_buf_export_info { + const char *exp_name; + const struct dma_buf_ops *ops; + size_t size; + int flags; + struct reservation_object *resv; + void *priv; +}; + +/** * get_dma_buf - convenience wrapper for get_file. * @dmabuf: [in] pointer to dma_buf * @@ -181,12 +202,7 @@ struct dma_buf_attachment *dma_buf_attach(struct dma_buf *dmabuf, void dma_buf_detach(struct dma_buf *dmabuf, struct dma_buf_attachment *dmabuf_attach); -struct dma_buf *dma_buf_export_named(void *priv, const struct dma_buf_ops *ops, - size_t size, int flags, const char *, - struct reservation_object *); - -#define dma_buf_export(priv, ops, size, flags, resv) \ - dma_buf_export_named(priv, ops, size, flags, KBUILD_MODNAME, resv) +struct dma_buf *dma_buf_export(struct dma_buf_export_info *exp_info); int dma_buf_fd(struct dma_buf *dmabuf, int flags); struct dma_buf *dma_buf_get(int fd);