diff mbox series

[2/2] media: videobuf2: cleanup size argument from attach_dmabuf()

Message ID 20210325001712.197837-2-helen.koike@collabora.com (mailing list archive)
State New, archived
Headers show
Series [1/2] media: videobuf2: use dmabuf size for length | expand

Commit Message

Helen Mae Koike Fornazier March 25, 2021, 12:17 a.m. UTC
Since we always use the size of the underlying buffer for dmabuf, remove
the size parameter from the attach_dmabuf() callback.

Suggested-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Helen Koike <helen.koike@collabora.com>
---
 drivers/media/common/videobuf2/videobuf2-core.c       | 2 +-
 drivers/media/common/videobuf2/videobuf2-dma-contig.c | 7 ++-----
 drivers/media/common/videobuf2/videobuf2-dma-sg.c     | 7 ++-----
 drivers/media/common/videobuf2/videobuf2-vmalloc.c    | 7 ++-----
 include/media/videobuf2-core.h                        | 1 -
 5 files changed, 7 insertions(+), 17 deletions(-)

Comments

kernel test robot March 25, 2021, 3:44 a.m. UTC | #1
Hi Helen,

I love your patch! Yet something to improve:

[auto build test ERROR on linuxtv-media/master]
[also build test ERROR on next-20210324]
[cannot apply to v5.12-rc4]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Helen-Koike/media-videobuf2-use-dmabuf-size-for-length/20210325-082047
base:   git://linuxtv.org/media_tree.git master
config: powerpc64-randconfig-r016-20210325 (attached as .config)
compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project 5d6b4aa80d6df62b924a12af030c5ded868ee4f1)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install powerpc64 cross compiling tool for clang build
        # apt-get install binutils-powerpc64-linux-gnu
        # https://github.com/0day-ci/linux/commit/41e2cea31db8378b33e31785aec668a009d1355b
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Helen-Koike/media-videobuf2-use-dmabuf-size-for-length/20210325-082047
        git checkout 41e2cea31db8378b33e31785aec668a009d1355b
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=powerpc64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

>> drivers/media/common/videobuf2/videobuf2-dma-sg.c:631:14: error: use of undeclared identifier 'dmabuf'; did you mean 'dbuf'?
           buf->size = dmabuf->size;
                       ^~~~~~
                       dbuf
   drivers/media/common/videobuf2/videobuf2-dma-sg.c:608:75: note: 'dbuf' declared here
   static void *vb2_dma_sg_attach_dmabuf(struct device *dev, struct dma_buf *dbuf,
                                                                             ^
   1 error generated.


vim +631 drivers/media/common/videobuf2/videobuf2-dma-sg.c

   607	
   608	static void *vb2_dma_sg_attach_dmabuf(struct device *dev, struct dma_buf *dbuf,
   609					      enum dma_data_direction dma_dir)
   610	{
   611		struct vb2_dma_sg_buf *buf;
   612		struct dma_buf_attachment *dba;
   613	
   614		if (WARN_ON(!dev))
   615			return ERR_PTR(-EINVAL);
   616	
   617		buf = kzalloc(sizeof(*buf), GFP_KERNEL);
   618		if (!buf)
   619			return ERR_PTR(-ENOMEM);
   620	
   621		buf->dev = dev;
   622		/* create attachment for the dmabuf with the user device */
   623		dba = dma_buf_attach(dbuf, buf->dev);
   624		if (IS_ERR(dba)) {
   625			pr_err("failed to attach dmabuf\n");
   626			kfree(buf);
   627			return dba;
   628		}
   629	
   630		buf->dma_dir = dma_dir;
 > 631		buf->size = dmabuf->size;
   632		buf->db_attach = dba;
   633	
   634		return buf;
   635	}
   636	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
diff mbox series

Patch

diff --git a/drivers/media/common/videobuf2/videobuf2-core.c b/drivers/media/common/videobuf2/videobuf2-core.c
index 2cbde14af051..86af4f3c72eb 100644
--- a/drivers/media/common/videobuf2/videobuf2-core.c
+++ b/drivers/media/common/videobuf2/videobuf2-core.c
@@ -1266,7 +1266,7 @@  static int __prepare_dmabuf(struct vb2_buffer *vb)
 		/* Acquire each plane's memory */
 		mem_priv = call_ptr_memop(vb, attach_dmabuf,
 				q->alloc_devs[plane] ? : q->dev,
-				dbuf, planes[plane].length, q->dma_dir);
+				dbuf, q->dma_dir);
 		if (IS_ERR(mem_priv)) {
 			dprintk(q, 1, "failed to attach dmabuf\n");
 			ret = PTR_ERR(mem_priv);
diff --git a/drivers/media/common/videobuf2/videobuf2-dma-contig.c b/drivers/media/common/videobuf2/videobuf2-dma-contig.c
index a7f61ba85440..a26aa52f954b 100644
--- a/drivers/media/common/videobuf2/videobuf2-dma-contig.c
+++ b/drivers/media/common/videobuf2/videobuf2-dma-contig.c
@@ -661,14 +661,11 @@  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)
+				  enum dma_data_direction dma_dir)
 {
 	struct vb2_dc_buf *buf;
 	struct dma_buf_attachment *dba;
 
-	if (dbuf->size < size)
-		return ERR_PTR(-EFAULT);
-
 	if (WARN_ON(!dev))
 		return ERR_PTR(-EINVAL);
 
@@ -686,7 +683,7 @@  static void *vb2_dc_attach_dmabuf(struct device *dev, struct dma_buf *dbuf,
 	}
 
 	buf->dma_dir = dma_dir;
-	buf->size = size;
+	buf->size = dbuf->size;
 	buf->db_attach = dba;
 
 	return buf;
diff --git a/drivers/media/common/videobuf2/videobuf2-dma-sg.c b/drivers/media/common/videobuf2/videobuf2-dma-sg.c
index c5b06a509566..8c006f79bed4 100644
--- a/drivers/media/common/videobuf2/videobuf2-dma-sg.c
+++ b/drivers/media/common/videobuf2/videobuf2-dma-sg.c
@@ -606,7 +606,7 @@  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)
+				      enum dma_data_direction dma_dir)
 {
 	struct vb2_dma_sg_buf *buf;
 	struct dma_buf_attachment *dba;
@@ -614,9 +614,6 @@  static void *vb2_dma_sg_attach_dmabuf(struct device *dev, struct dma_buf *dbuf,
 	if (WARN_ON(!dev))
 		return ERR_PTR(-EINVAL);
 
-	if (dbuf->size < size)
-		return ERR_PTR(-EFAULT);
-
 	buf = kzalloc(sizeof(*buf), GFP_KERNEL);
 	if (!buf)
 		return ERR_PTR(-ENOMEM);
@@ -631,7 +628,7 @@  static void *vb2_dma_sg_attach_dmabuf(struct device *dev, struct dma_buf *dbuf,
 	}
 
 	buf->dma_dir = dma_dir;
-	buf->size = size;
+	buf->size = dmabuf->size;
 	buf->db_attach = dba;
 
 	return buf;
diff --git a/drivers/media/common/videobuf2/videobuf2-vmalloc.c b/drivers/media/common/videobuf2/videobuf2-vmalloc.c
index 83f95258ec8c..c2d41b375c10 100644
--- a/drivers/media/common/videobuf2/videobuf2-vmalloc.c
+++ b/drivers/media/common/videobuf2/videobuf2-vmalloc.c
@@ -404,20 +404,17 @@  static void vb2_vmalloc_detach_dmabuf(void *mem_priv)
 }
 
 static void *vb2_vmalloc_attach_dmabuf(struct device *dev, struct dma_buf *dbuf,
-	unsigned long size, enum dma_data_direction dma_dir)
+				       enum dma_data_direction dma_dir)
 {
 	struct vb2_vmalloc_buf *buf;
 
-	if (dbuf->size < size)
-		return ERR_PTR(-EFAULT);
-
 	buf = kzalloc(sizeof(*buf), GFP_KERNEL);
 	if (!buf)
 		return ERR_PTR(-ENOMEM);
 
 	buf->dbuf = dbuf;
 	buf->dma_dir = dma_dir;
-	buf->size = size;
+	buf->size = dbuf->size;
 
 	return buf;
 }
diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h
index 12955cb460d2..db07001cada8 100644
--- a/include/media/videobuf2-core.h
+++ b/include/media/videobuf2-core.h
@@ -134,7 +134,6 @@  struct vb2_mem_ops {
 
 	void		*(*attach_dmabuf)(struct device *dev,
 					  struct dma_buf *dbuf,
-					  unsigned long size,
 					  enum dma_data_direction dma_dir);
 	void		(*detach_dmabuf)(void *buf_priv);
 	int		(*map_dmabuf)(void *buf_priv);