@@ -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);
@@ -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;
@@ -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;
@@ -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;
}
@@ -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);
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(-)