dma-buf: use parameter structure for dma_buf_attach
Subsystems (11)
PATCH 1/1 dma-buf: use parameter structure for dma_buf_attach
Move the parameters into a structure to make it simpler to extend it in follow up patches.
This also adds the importer private as parameter so that we can directly work with a completely filled in attachment structure.
--- drivers/dma-buf/dma-buf.c | 16 +++++++++------- drivers/gpu/drm/armada/armada_gem.c | 6 +++++- drivers/gpu/drm/drm_prime.c | 6 +++++- drivers/gpu/drm/i915/i915_gem_dmabuf.c | 6 +++++- drivers/gpu/drm/tegra/gem.c | 6 +++++- drivers/gpu/drm/udl/udl_dmabuf.c | 6 +++++- drivers/media/common/videobuf2/videobuf2-dma-contig.c | 6 +++++- drivers/media/common/videobuf2/videobuf2-dma-sg.c | 6 +++++- drivers/staging/media/tegra-vde/tegra-vde.c | 6 +++++- include/linux/dma-buf.h | 19 +++++++++++++++++-- 10 files changed, 66 insertions(+), 17 deletions(-)
drivers/dma-buf/dma-buf.c +9 -7
@@ -534,8 +534,9 @@ EXPORT_SYMBOL_GPL(dma_buf_put);/** * dma_buf_attach - Add the device to dma_buf's attachments list; optionally, * calls attach() of dma_buf_ops to allow device-specific attach functionality -* @dmabuf: [in] buffer to attach device to. -* @dev: [in] device to be attached. +* @info: [in] holds all the attach related information provided +* by the importer. see &struct dma_buf_attach_info +* for further details. * * Returns struct dma_buf_attachment pointer for this attachment. Attachments * must be cleaned up by calling dma_buf_detach().
@@ -549,26 +550,27 @@ EXPORT_SYMBOL_GPL(dma_buf_put);* accessible to @dev, and cannot be moved to a more suitable place. This is * indicated with the error code -EBUSY. */ -struct dma_buf_attachment *dma_buf_attach (struct dma_buf *dmabuf, -struct device *dev) +struct dma_buf_attachment *dma_buf_attach (const struct dma_buf_attach_info *info) { +struct dma_buf *dmabuf = info->dmabuf;struct dma_buf_attachment *attach;int ret; -if (WARN_ON (!dmabuf || !dev)) +if (WARN_ON (!dmabuf || !info->dev))return ERR_PTR (-EINVAL ); attach =kzalloc (sizeof (*attach),GFP_KERNEL );if (!attach)return ERR_PTR (-ENOMEM ); - attach->dev = dev; + attach->dev = info->dev; attach->dmabuf = dmabuf; + attach->priv = info->priv;mutex_lock (&dmabuf->lock);if (dmabuf->ops->attach) { - ret = dmabuf->ops->attach (dmabuf, dev, attach); + ret = dmabuf->ops->attach (dmabuf, info->dev, attach);if (ret) goto err_attach; }
drivers/gpu/drm/armada/armada_gem.c +5 -1
@@ -514,6 +514,10 @@ armada_gem_prime_export(struct drm_device *dev, struct drm_gem_object *obj,struct drm_gem_object *armada_gem_prime_import (struct drm_device *dev,struct dma_buf *buf) { +struct dma_buf_attach_info attach_info = { + .dev = dev->dev, + .dmabuf = buf + };struct dma_buf_attachment *attach;struct armada_gem_object *dobj;
@@ -529,7 +533,7 @@ armada_gem_prime_import(struct drm_device *dev, struct dma_buf *buf) } } - attach =dma_buf_attach (buf, dev->dev); + attach =dma_buf_attach (&attach_info);if (IS_ERR (attach))return ERR_CAST (attach);
drivers/gpu/drm/drm_prime.c +5 -1
@@ -707,6 +707,10 @@ struct drm_gem_object *drm_gem_prime_import_dev(struct drm_device *dev,struct dma_buf *dma_buf, struct device *attach_dev) { + struct dma_buf_attach_info attach_info = { + .dev = attach_dev, + .dmabuf = dma_buf + };struct dma_buf_attachment *attach;struct sg_table *sgt;struct drm_gem_object *obj;
@@ -727,7 +731,7 @@ struct drm_gem_object *drm_gem_prime_import_dev(struct drm_device *dev,if (!dev->driver->gem_prime_import_sg_table)return ERR_PTR (-EINVAL ); - attach =dma_buf_attach (dma_buf, attach_dev); + attach =dma_buf_attach (&attach_info);if (IS_ERR (attach))return ERR_CAST (attach);
drivers/gpu/drm/i915/i915_gem_dmabuf.c +5 -1
@@ -288,6 +288,10 @@ static const struct drm_i915_gem_object_ops i915_gem_object_dmabuf_ops = {struct drm_gem_object *i915_gem_prime_import (struct drm_device *dev,struct dma_buf *dma_buf) { +struct dma_buf_attach_info attach_info = { + .dev = dev->dev, + .dmabuf = dma_buf + };struct dma_buf_attachment *attach;struct drm_i915_gem_object *obj;int ret;
@@ -306,7 +310,7 @@ struct drm_gem_object *i915_gem_prime_import(struct drm_device *dev, }/* need to attach */ - attach =dma_buf_attach (dma_buf, dev->dev); + attach =dma_buf_attach (&attach_info);if (IS_ERR (attach))return ERR_CAST (attach);
drivers/gpu/drm/tegra/gem.c +5 -1
@@ -332,6 +332,10 @@ struct tegra_bo *tegra_bo_create_with_handle(struct drm_file *file,static struct tegra_bo *tegra_bo_import (struct drm_device *drm,struct dma_buf *buf) { +struct dma_buf_attach_info attach_info = { + .dev = drm->dev, + .dmabuf = buf + };struct tegra_drm *tegra = drm->dev_private;struct dma_buf_attachment *attach;struct tegra_bo *bo;
@@ -341,7 +345,7 @@ static struct tegra_bo *tegra_bo_import(struct drm_device *drm,if (IS_ERR (bo))return bo; - attach =dma_buf_attach (buf, drm->dev); + attach =dma_buf_attach (&attach_info);if (IS_ERR (attach)) { err =PTR_ERR (attach); goto free;
drivers/gpu/drm/udl/udl_dmabuf.c +5 -1
@@ -243,6 +243,10 @@ static int udl_prime_create(struct drm_device *dev,struct drm_gem_object *udl_gem_prime_import (struct drm_device *dev,struct dma_buf *dma_buf) { +struct dma_buf_attach_info attach_info = { + .dev = dev->dev, + .dmabuf = dma_buf + };struct dma_buf_attachment *attach;struct sg_table *sg;struct udl_gem_object *uobj;
@@ -250,7 +254,7 @@ struct drm_gem_object *udl_gem_prime_import(struct drm_device *dev,/* need to attach */ get_device (dev->dev); - attach =dma_buf_attach (dma_buf, dev->dev); + attach =dma_buf_attach (&attach_info);if (IS_ERR (attach)) {put_device (dev->dev);return ERR_CAST (attach);
drivers/media/common/videobuf2/videobuf2-dma-contig.c +5 -1
@@ -677,6 +677,10 @@ static void vb2_dc_detach_dmabuf(void *mem_priv)static void *vb2_dc_attach_dmabuf (struct device *dev,struct dma_buf *dbuf,unsigned long size,enum dma_data_direction dma_dir) { +struct dma_buf_attach_info attach_info = { + .dev = dev, + .dmabuf = dbuf + };struct vb2_dc_buf *buf;struct dma_buf_attachment *dba;
@@ -692,7 +696,7 @@ static void *vb2_dc_attach_dmabuf(struct device *dev, struct dma_buf *dbuf, buf->dev = dev;/* create attachment for the dmabuf with the user device */ - dba =dma_buf_attach (dbuf, buf->dev); + dba =dma_buf_attach (&attach_info);if (IS_ERR (dba)) {pr_err ("failed to attach dmabuf\n" );kfree (buf);
drivers/media/common/videobuf2/videobuf2-dma-sg.c +5 -1
@@ -609,6 +609,10 @@ static void vb2_dma_sg_detach_dmabuf(void *mem_priv)static void *vb2_dma_sg_attach_dmabuf (struct device *dev,struct dma_buf *dbuf,unsigned long size,enum dma_data_direction dma_dir) { +struct dma_buf_attach_info attach_info = { + .dev = dev, + .dmabuf = dbuf + };struct vb2_dma_sg_buf *buf;struct dma_buf_attachment *dba;
@@ -624,7 +628,7 @@ static void *vb2_dma_sg_attach_dmabuf(struct device *dev, struct dma_buf *dbuf, buf->dev = dev;/* create attachment for the dmabuf with the user device */ - dba =dma_buf_attach (dbuf, buf->dev); + dba =dma_buf_attach (&attach_info);if (IS_ERR (dba)) {pr_err ("failed to attach dmabuf\n" );kfree (buf);
drivers/staging/media/tegra-vde/tegra-vde.c +5 -1
@@ -529,6 +529,10 @@ static int tegra_vde_attach_dmabuf(struct device *dev,size_t *size, enum dma_data_direction dma_dir) { + struct dma_buf_attach_info attach_info = { + .dev = dev, + .dmabuf = dmabuf + };struct dma_buf_attachment *attachment;struct dma_buf *dmabuf;struct sg_table *sgt;
@@ -547,7 +551,7 @@ static int tegra_vde_attach_dmabuf(struct device *dev,return -EINVAL ; } - attachment =dma_buf_attach (dmabuf, dev); + attachment =dma_buf_attach (&attach_info);if (IS_ERR (attachment)) {dev_err (dev,"Failed to attach dmabuf\n" ); err =PTR_ERR (attachment);
include/linux/dma-buf.h +17 -2
@@ -362,6 +362,21 @@ struct dma_buf_export_info {struct dma_buf_export_info name = { .exp_name =KBUILD_MODNAME , \ .owner =THIS_MODULE } +/** +* struct dma_buf_attach_info - holds information needed to attach to a dma_buf +* @dmabuf: the exported dma_buf +* @dev: the device which wants to import the attachment +* @priv: private data of importer to this attachment +* +* This structure holds the information required to attach to a buffer. Used +* with dma_buf_attach() only. + */ +struct dma_buf_attach_info { +struct dma_buf *dmabuf; +struct device *dev; +void *priv; +}; +/** * get_dma_buf - convenience wrapper for get_file. * @dmabuf: [in] pointer to dma_buf
@@ -376,8 +391,8 @@ static inline void get_dma_buf(struct dma_buf *dmabuf)get_file (dmabuf->file); } -struct dma_buf_attachment *dma_buf_attach (struct dma_buf *dmabuf, -struct device *dev); +struct dma_buf_attachment * +dma_buf_attach (const struct dma_buf_attach_info *info);void dma_buf_detach (struct dma_buf *dmabuf,struct dma_buf_attachment *dmabuf_attach);
Signature · 6 lines
2.14.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 20180325113451.2425-1-christian.koenig-5C7GfCeVMHo@public.gmane.org
kbuild test robot
build botI love your patch! Yet something to improve:
Hi Christian,
I love your patch! Yet something to improve:
[auto build test ERROR on drm/drm-next]
[also build test ERROR on v4.16-rc6 next-20180323]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Christian-K-nig/dma-buf-use-parameter-structure-for-dma_buf_attach/20180326-044631 base: git://people.freedesktop.org/~airlied/linux.git drm-next config: xtensa-allmodconfig (attached as .config) compiler: xtensa-linux-gcc (GCC) 7.2.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=xtensa
All errors (new ones prefixed by >>):
drivers/staging/media/tegra-vde/tegra-vde.c: In function 'tegra_vde_attach_dmabuf':
>> drivers/staging/media/tegra-vde/tegra-vde.c:534:13: error: 'dmabuf' undeclared (first use in this function); did you mean 'dma_buf'?
.dmabuf = dmabuf
^~~~~~
dma_buf
drivers/staging/media/tegra-vde/tegra-vde.c:534:13: note: each undeclared identifier is reported only once for each function it appears in
vim +534 drivers/staging/media/tegra-vde/tegra-vde.c
521
522 static int tegra_vde_attach_dmabuf(struct device *dev,
523 int fd,
524 unsigned long offset,
525 unsigned int min_size,
526 struct dma_buf_attachment **a,
527 dma_addr_t *addr,
528 struct sg_table **s,
529 size_t *size,
530 enum dma_data_direction dma_dir)
531 {
532 struct dma_buf_attach_info attach_info = {
533 .dev = dev,
> 534 .dmabuf = dmabuf 535 };
536 struct dma_buf_attachment *attachment;
537 struct dma_buf *dmabuf;
538 struct sg_table *sgt;
539 int err;
540
541 dmabuf = dma_buf_get(fd);
542 if (IS_ERR(dmabuf)) {
543 dev_err(dev, "Invalid dmabuf FD\n");
544 return PTR_ERR(dmabuf);
545 }
546
547 if ((u64)offset + min_size > dmabuf->size) {
548 dev_err(dev, "Too small dmabuf size %zu @0x%lX, "
549 "should be at least %d\n",
550 dmabuf->size, offset, min_size);
551 return -EINVAL;
552 }
553
554 attachment = dma_buf_attach(&attach_info);
555 if (IS_ERR(attachment)) {
556 dev_err(dev, "Failed to attach dmabuf\n");
557 err = PTR_ERR(attachment);
558 goto err_put;
559 }
560
561 sgt = dma_buf_map_attachment(attachment, dma_dir);
562 if (IS_ERR(sgt)) {
563 dev_err(dev, "Failed to get dmabufs sg_table\n");
564 err = PTR_ERR(sgt);
565 goto err_detach;
566 }
567
568 if (sgt->nents != 1) {
569 dev_err(dev, "Sparse DMA region is unsupported\n");
570 err = -EINVAL;
571 goto err_unmap;
572 }
573
574 *addr = sg_dma_address(sgt->sgl) + offset;
575 *a = attachment;
576 *s = sgt;
577
578 if (size)
579 *size = dmabuf->size - offset;
580
581 return 0;
582
583 err_unmap:
584 dma_buf_unmap_attachment(attachment, sgt, dma_dir);
585 err_detach:
586 dma_buf_detach(dmabuf, attachment);
587 err_put:
588 dma_buf_put(dmabuf);
589
590 return err;
591 }
592
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
kbuild test robot
build botI love your patch! Yet something to improve:
Hi Christian,
I love your patch! Yet something to improve:
[auto build test ERROR on drm/drm-next]
[also build test ERROR on v4.16-rc7 next-20180327]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Christian-K-nig/dma-buf-use-parameter-structure-for-dma_buf_attach/20180326-044631 base: git://people.freedesktop.org/~airlied/linux.git drm-next config: openrisc-allmodconfig (attached as .config) compiler: or1k-linux-gcc (GCC) 6.0.0 20160327 (experimental)
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=openrisc
All errors (new ones prefixed by >>):
drivers/staging/media/tegra-vde/tegra-vde.c: In function 'tegra_vde_attach_dmabuf':
>> drivers/staging/media/tegra-vde/tegra-vde.c:534:13: error: 'dmabuf' undeclared (first use in this function)
.dmabuf = dmabuf
^~~~~~
drivers/staging/media/tegra-vde/tegra-vde.c:534:13: note: each undeclared identifier is reported only once for each function it appears in
vim +/dmabuf +534 drivers/staging/media/tegra-vde/tegra-vde.c
521
522 static int tegra_vde_attach_dmabuf(struct device *dev,
523 int fd,
524 unsigned long offset,
525 unsigned int min_size,
526 struct dma_buf_attachment **a,
527 dma_addr_t *addr,
528 struct sg_table **s,
529 size_t *size,
530 enum dma_data_direction dma_dir)
531 {
532 struct dma_buf_attach_info attach_info = {
533 .dev = dev,
> 534 .dmabuf = dmabuf 535 };
536 struct dma_buf_attachment *attachment;
537 struct dma_buf *dmabuf;
538 struct sg_table *sgt;
539 int err;
540
541 dmabuf = dma_buf_get(fd);
542 if (IS_ERR(dmabuf)) {
543 dev_err(dev, "Invalid dmabuf FD\n");
544 return PTR_ERR(dmabuf);
545 }
546
547 if ((u64)offset + min_size > dmabuf->size) {
548 dev_err(dev, "Too small dmabuf size %zu @0x%lX, "
549 "should be at least %d\n",
550 dmabuf->size, offset, min_size);
551 return -EINVAL;
552 }
553
554 attachment = dma_buf_attach(&attach_info);
555 if (IS_ERR(attachment)) {
556 dev_err(dev, "Failed to attach dmabuf\n");
557 err = PTR_ERR(attachment);
558 goto err_put;
559 }
560
561 sgt = dma_buf_map_attachment(attachment, dma_dir);
562 if (IS_ERR(sgt)) {
563 dev_err(dev, "Failed to get dmabufs sg_table\n");
564 err = PTR_ERR(sgt);
565 goto err_detach;
566 }
567
568 if (sgt->nents != 1) {
569 dev_err(dev, "Sparse DMA region is unsupported\n");
570 err = -EINVAL;
571 goto err_unmap;
572 }
573
574 *addr = sg_dma_address(sgt->sgl) + offset;
575 *a = attachment;
576 *s = sgt;
577
578 if (size)
579 *size = dmabuf->size - offset;
580
581 return 0;
582
583 err_unmap:
584 dma_buf_unmap_attachment(attachment, sgt, dma_dir);
585 err_detach:
586 dma_buf_detach(dmabuf, attachment);
587 err_put:
588 dma_buf_put(dmabuf);
589
590 return err;
591 }
592
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 25 lines · Christian König
Move the parameters into a structure to make it simpler to extend it in follow up patches.
This also adds the importer private as parameter so that we can directly work with a completely filled in attachment structure.
Signed-off-by Christian König <[email protected]>--- drivers/dma-buf/dma-buf.c | 16 +++++++++------- drivers/gpu/drm/armada/armada_gem.c | 6 +++++- drivers/gpu/drm/drm_prime.c | 6 +++++- drivers/gpu/drm/i915/i915_gem_dmabuf.c | 6 +++++- drivers/gpu/drm/tegra/gem.c | 6 +++++- drivers/gpu/drm/udl/udl_dmabuf.c | 6 +++++- drivers/media/common/videobuf2/videobuf2-dma-contig.c | 6 +++++- drivers/media/common/videobuf2/videobuf2-dma-sg.c | 6 +++++- drivers/staging/media/tegra-vde/tegra-vde.c | 6 +++++- include/linux/dma-buf.h | 19 +++++++++++++++++-- 10 files changed, 66 insertions(+), 17 deletions(-)drivers/dma-buf/dma-buf.c +0
-0
drivers/dma-buf/dma-buf.c EXPORT_SYMBOL_GPL(dma_buf_put); · line 539
Quoted 8 lines
drivers/dma-buf/dma-buf.c +3
-2@@ -534,8 +534,9 @@ EXPORT_SYMBOL_GPL(dma_buf_put);/** * dma_buf_attach - Add the device to dma_buf's attachments list; optionally, * calls attach() of dma_buf_ops to allow device-specific attach functionality -* @dmabuf: [in] buffer to attach device to. -* @dev: [in] device to be attached. +* @info: [in] holds all the attach related information provided +* by the importer. see &struct dma_buf_attach_info +* for further details.
Minor bikeshed, but I like to keep the object we operate on explicit, i.e. leave the dmabuf as the first paramater and only stuff everything else into the struct. But I don't think there's enough precedence either way.
Quoted 17 lines
drivers/dma-buf/dma-buf.c +3
-3* * Returns struct dma_buf_attachment pointer for this attachment. Attachments * must be cleaned up by calling dma_buf_detach(). @@ -549,26 +550,27 @@ EXPORT_SYMBOL_GPL(dma_buf_put);* accessible to @dev, and cannot be moved to a more suitable place. This is * indicated with the error code -EBUSY. */ -struct dma_buf_attachment *dma_buf_attach (struct dma_buf *dmabuf, -struct device *dev) +struct dma_buf_attachment *dma_buf_attach (const struct dma_buf_attach_info *info) { +struct dma_buf *dmabuf = info->dmabuf;struct dma_buf_attachment *attach;int ret; -if (WARN_ON (!dmabuf || !dev)) +if (WARN_ON (!dmabuf || !info->dev))
drivers/dma-buf/dma-buf.c EXPORT_SYMBOL_GPL(dma_buf_put); · line 568
Quoted 10 lines
drivers/dma-buf/dma-buf.c +2
-1return ERR_PTR (-EINVAL ); attach =kzalloc (sizeof (*attach),GFP_KERNEL );if (!attach)return ERR_PTR (-ENOMEM ); - attach->dev = dev; + attach->dev = info->dev; attach->dmabuf = dmabuf; + attach->priv = info->priv;
The ->priv field is for the exporter, not the importer. See e.g. drm_gem_map_attach. You can't let the importer set this now too, so needs to be removed from the info struct.
-Daniel
Quoted 245 lines
drivers/dma-buf/dma-buf.c +1
-1mutex_lock (&dmabuf->lock);if (dmabuf->ops->attach) { - ret = dmabuf->ops->attach (dmabuf, dev, attach); + ret = dmabuf->ops->attach (dmabuf, info->dev, attach);if (ret) goto err_attach; }drivers/gpu/drm/armada/armada_gem.c +5
-1@@ -514,6 +514,10 @@ armada_gem_prime_export(struct drm_device *dev, struct drm_gem_object *obj,struct drm_gem_object *armada_gem_prime_import (struct drm_device *dev,struct dma_buf *buf) { +struct dma_buf_attach_info attach_info = { + .dev = dev->dev, + .dmabuf = buf + };struct dma_buf_attachment *attach;struct armada_gem_object *dobj;@@ -529,7 +533,7 @@ armada_gem_prime_import(struct drm_device *dev, struct dma_buf *buf) } } - attach =dma_buf_attach (buf, dev->dev); + attach =dma_buf_attach (&attach_info);if (IS_ERR (attach))return ERR_CAST (attach);drivers/gpu/drm/drm_prime.c +5
-1@@ -707,6 +707,10 @@ struct drm_gem_object *drm_gem_prime_import_dev(struct drm_device *dev,struct dma_buf *dma_buf, struct device *attach_dev) { + struct dma_buf_attach_info attach_info = { + .dev = attach_dev, + .dmabuf = dma_buf + };struct dma_buf_attachment *attach;struct sg_table *sgt;struct drm_gem_object *obj;@@ -727,7 +731,7 @@ struct drm_gem_object *drm_gem_prime_import_dev(struct drm_device *dev,if (!dev->driver->gem_prime_import_sg_table)return ERR_PTR (-EINVAL ); - attach =dma_buf_attach (dma_buf, attach_dev); + attach =dma_buf_attach (&attach_info);if (IS_ERR (attach))return ERR_CAST (attach);drivers/gpu/drm/i915/i915_gem_dmabuf.c +5
-1@@ -288,6 +288,10 @@ static const struct drm_i915_gem_object_ops i915_gem_object_dmabuf_ops = {struct drm_gem_object *i915_gem_prime_import (struct drm_device *dev,struct dma_buf *dma_buf) { +struct dma_buf_attach_info attach_info = { + .dev = dev->dev, + .dmabuf = dma_buf + };struct dma_buf_attachment *attach;struct drm_i915_gem_object *obj;int ret;@@ -306,7 +310,7 @@ struct drm_gem_object *i915_gem_prime_import(struct drm_device *dev, }/* need to attach */ - attach =dma_buf_attach (dma_buf, dev->dev); + attach =dma_buf_attach (&attach_info);if (IS_ERR (attach))return ERR_CAST (attach);drivers/gpu/drm/tegra/gem.c +5
-1@@ -332,6 +332,10 @@ struct tegra_bo *tegra_bo_create_with_handle(struct drm_file *file,static struct tegra_bo *tegra_bo_import (struct drm_device *drm,struct dma_buf *buf) { +struct dma_buf_attach_info attach_info = { + .dev = drm->dev, + .dmabuf = buf + };struct tegra_drm *tegra = drm->dev_private;struct dma_buf_attachment *attach;struct tegra_bo *bo;@@ -341,7 +345,7 @@ static struct tegra_bo *tegra_bo_import(struct drm_device *drm,if (IS_ERR (bo))return bo; - attach =dma_buf_attach (buf, drm->dev); + attach =dma_buf_attach (&attach_info);if (IS_ERR (attach)) { err =PTR_ERR (attach); goto free;drivers/gpu/drm/udl/udl_dmabuf.c +5
-1@@ -243,6 +243,10 @@ static int udl_prime_create(struct drm_device *dev,struct drm_gem_object *udl_gem_prime_import (struct drm_device *dev,struct dma_buf *dma_buf) { +struct dma_buf_attach_info attach_info = { + .dev = dev->dev, + .dmabuf = dma_buf + };struct dma_buf_attachment *attach;struct sg_table *sg;struct udl_gem_object *uobj;@@ -250,7 +254,7 @@ struct drm_gem_object *udl_gem_prime_import(struct drm_device *dev,/* need to attach */ get_device (dev->dev); - attach =dma_buf_attach (dma_buf, dev->dev); + attach =dma_buf_attach (&attach_info);if (IS_ERR (attach)) {put_device (dev->dev);return ERR_CAST (attach);drivers/media/common/videobuf2/videobuf2-dma-contig.c +5
-1@@ -677,6 +677,10 @@ static void vb2_dc_detach_dmabuf(void *mem_priv)static void *vb2_dc_attach_dmabuf (struct device *dev,struct dma_buf *dbuf,unsigned long size,enum dma_data_direction dma_dir) { +struct dma_buf_attach_info attach_info = { + .dev = dev, + .dmabuf = dbuf + };struct vb2_dc_buf *buf;struct dma_buf_attachment *dba;@@ -692,7 +696,7 @@ static void *vb2_dc_attach_dmabuf(struct device *dev, struct dma_buf *dbuf, buf->dev = dev;/* create attachment for the dmabuf with the user device */ - dba =dma_buf_attach (dbuf, buf->dev); + dba =dma_buf_attach (&attach_info);if (IS_ERR (dba)) {pr_err ("failed to attach dmabuf\n" );kfree (buf);drivers/media/common/videobuf2/videobuf2-dma-sg.c +5
-1@@ -609,6 +609,10 @@ static void vb2_dma_sg_detach_dmabuf(void *mem_priv)static void *vb2_dma_sg_attach_dmabuf (struct device *dev,struct dma_buf *dbuf,unsigned long size,enum dma_data_direction dma_dir) { +struct dma_buf_attach_info attach_info = { + .dev = dev, + .dmabuf = dbuf + };struct vb2_dma_sg_buf *buf;struct dma_buf_attachment *dba;@@ -624,7 +628,7 @@ static void *vb2_dma_sg_attach_dmabuf(struct device *dev, struct dma_buf *dbuf, buf->dev = dev;/* create attachment for the dmabuf with the user device */ - dba =dma_buf_attach (dbuf, buf->dev); + dba =dma_buf_attach (&attach_info);if (IS_ERR (dba)) {pr_err ("failed to attach dmabuf\n" );kfree (buf);drivers/staging/media/tegra-vde/tegra-vde.c +5
-1@@ -529,6 +529,10 @@ static int tegra_vde_attach_dmabuf(struct device *dev,size_t *size, enum dma_data_direction dma_dir) { + struct dma_buf_attach_info attach_info = { + .dev = dev, + .dmabuf = dmabuf + };struct dma_buf_attachment *attachment;struct dma_buf *dmabuf;struct sg_table *sgt;@@ -547,7 +551,7 @@ static int tegra_vde_attach_dmabuf(struct device *dev,return -EINVAL ; } - attachment =dma_buf_attach (dmabuf, dev); + attachment =dma_buf_attach (&attach_info);if (IS_ERR (attachment)) {dev_err (dev,"Failed to attach dmabuf\n" ); err =PTR_ERR (attachment);include/linux/dma-buf.h +17
-2@@ -362,6 +362,21 @@ struct dma_buf_export_info {struct dma_buf_export_info name = { .exp_name =KBUILD_MODNAME , \ .owner =THIS_MODULE } +/** +* struct dma_buf_attach_info - holds information needed to attach to a dma_buf +* @dmabuf: the exported dma_buf +* @dev: the device which wants to import the attachment +* @priv: private data of importer to this attachment +* +* This structure holds the information required to attach to a buffer. Used +* with dma_buf_attach() only. + */ +struct dma_buf_attach_info { +struct dma_buf *dmabuf; +struct device *dev; +void *priv; +}; +/** * get_dma_buf - convenience wrapper for get_file. * @dmabuf: [in] pointer to dma_buf @@ -376,8 +391,8 @@ static inline void get_dma_buf(struct dma_buf *dmabuf)get_file (dmabuf->file); } -struct dma_buf_attachment *dma_buf_attach (struct dma_buf *dmabuf, -struct device *dev); +struct dma_buf_attachment * +dma_buf_attach (const struct dma_buf_attach_info *info);void dma_buf_detach (struct dma_buf *dmabuf,struct dma_buf_attachment *dmabuf_attach);Signature · 6 lines
2.14.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
A message that is not in the archive (sent off-list or not yet received): 20180326083638.GS14155-dv86pmgwkMBes7Z6vYuT8azUEOm+Xw19@public.gmane.org
Am 26.03.2018 um 10:36 schrieb Daniel Vetter:
Quoted 1 line · Christian König
[SNIP]
Quoted 7 lines
drivers/dma-buf/dma-buf.c EXPORT_SYMBOL_GPL(dma_buf_put); · line 568
Quoted 4 lines
drivers/dma-buf/dma-buf.c +2
-1- attach->dev = dev; + attach->dev = info->dev; attach->dmabuf = dmabuf; + attach->priv = info->priv;The ->priv field is for the exporter, not the importer. See e.g.
drm_gem_map_attach. You can't let the importer set this now too, so needs to be removed from the info struct.
Crap, in this case I need to add an importer_priv field because we now need to map from the attachment to it's importer object as well.
Thanks for noticing this.
Regards,
Christian.
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 0242b504-87cd-2c80-ad86-868622c3c681-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Quoted 11 lines · Christian König
Am 26.03.2018 um 10:36 schrieb Daniel Vetter:
Quoted 1 line · Christian König
[SNIP]
Quoted 7 lines
drivers/dma-buf/dma-buf.c EXPORT_SYMBOL_GPL(dma_buf_put); · line 568
Quoted 4 lines
drivers/dma-buf/dma-buf.c +2
-1- attach->dev = dev; + attach->dev = info->dev; attach->dmabuf = dmabuf; + attach->priv = info->priv;The ->priv field is for the exporter, not the importer. See e.g.
drm_gem_map_attach. You can't let the importer set this now too, so needs to be removed from the info struct.
Quoted 4 lines
Crap, in this case I need to add an
importer_privfield because we now need to map from the attachment to it's importer object as well.Thanks for noticing this.
Maybe add the importer_priv field only in the series that actually adds it, not in this prep patch. You can mention all the fields you need here in the commit message for justification.
-Daniel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Am 26.03.2018 um 10:36 schrieb Daniel Vetter:
Quoted 1 line · Christian König
[SNIP]
Quoted 7 lines
drivers/dma-buf/dma-buf.c EXPORT_SYMBOL_GPL(dma_buf_put); · line 568
Quoted 4 lines
drivers/dma-buf/dma-buf.c +2
-1- attach->dev = dev; + attach->dev = info->dev; attach->dmabuf = dmabuf; + attach->priv = info->priv;The ->priv field is for the exporter, not the importer. See e.g.
drm_gem_map_attach. You can't let the importer set this now too, so needs to be removed from the info struct.
Crap, in this case I need to add an importer_priv field because we now need to map from the attachment to it's importer object as well.
Thanks for noticing this.
Regards,
Christian.
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx