[PATCHv8 23/26] v4l: vb2: add support for DMA_ATTR_NO_KERNEL_MAPPING
From: Marek Szyprowski Signed-off-by: Marek Szyprowski --- drivers/media/video/atmel-isi.c |2 +- drivers/media/video/blackfin/bfin_capture.c |2 +- drivers/media/video/marvell-ccic/mcam-core.c |3 ++- drivers/media/video/mx2_camera.c |2 +- drivers/media/video/mx2_emmaprp.c|2 +- drivers/media/video/mx3_camera.c |2 +- drivers/media/video/s5p-fimc/fimc-core.c |2 +- drivers/media/video/s5p-fimc/fimc-lite.c |2 +- drivers/media/video/s5p-g2d/g2d.c|2 +- drivers/media/video/s5p-jpeg/jpeg-core.c |2 +- drivers/media/video/s5p-mfc/s5p_mfc.c|5 ++-- drivers/media/video/s5p-tv/mixer_video.c |2 +- drivers/media/video/sh_mobile_ceu_camera.c |2 +- drivers/media/video/videobuf2-dma-contig.c | 33 +++--- drivers/staging/media/dt3155v4l/dt3155v4l.c |2 +- include/media/videobuf2-dma-contig.h |4 +++- 16 files changed, 44 insertions(+), 25 deletions(-) diff --git a/drivers/media/video/atmel-isi.c b/drivers/media/video/atmel-isi.c index 6274a91..9fb5283 100644 --- a/drivers/media/video/atmel-isi.c +++ b/drivers/media/video/atmel-isi.c @@ -1000,7 +1000,7 @@ static int __devinit atmel_isi_probe(struct platform_device *pdev) list_add(&isi->dma_desc[i].list, &isi->dma_desc_head); } - isi->alloc_ctx = vb2_dma_contig_init_ctx(&pdev->dev); + isi->alloc_ctx = vb2_dma_contig_init_ctx(&pdev->dev, 0); if (IS_ERR(isi->alloc_ctx)) { ret = PTR_ERR(isi->alloc_ctx); goto err_alloc_ctx; diff --git a/drivers/media/video/blackfin/bfin_capture.c b/drivers/media/video/blackfin/bfin_capture.c index 1677623..7e90b65 100644 --- a/drivers/media/video/blackfin/bfin_capture.c +++ b/drivers/media/video/blackfin/bfin_capture.c @@ -893,7 +893,7 @@ static int __devinit bcap_probe(struct platform_device *pdev) } bcap_dev->ppi->priv = bcap_dev; - bcap_dev->alloc_ctx = vb2_dma_contig_init_ctx(&pdev->dev); + bcap_dev->alloc_ctx = vb2_dma_contig_init_ctx(&pdev->dev, 0); if (IS_ERR(bcap_dev->alloc_ctx)) { ret = PTR_ERR(bcap_dev->alloc_ctx); goto err_free_ppi; diff --git a/drivers/media/video/marvell-ccic/mcam-core.c b/drivers/media/video/marvell-ccic/mcam-core.c index ce2b7b4..10d4db5 100644 --- a/drivers/media/video/marvell-ccic/mcam-core.c +++ b/drivers/media/video/marvell-ccic/mcam-core.c @@ -,7 +,8 @@ static int mcam_setup_vb2(struct mcam_camera *cam) #ifdef MCAM_MODE_DMA_CONTIG vq->ops = &mcam_vb2_ops; vq->mem_ops = &vb2_dma_contig_memops; - cam->vb_alloc_ctx = vb2_dma_contig_init_ctx(cam->dev); + cam->vb_alloc_ctx = vb2_dma_contig_init_ctx(cam->dev, + VB2_CREATE_VADDR); vq->io_modes = VB2_MMAP | VB2_USERPTR; cam->dma_setup = mcam_ctlr_dma_contig; cam->frame_complete = mcam_dma_contig_done; diff --git a/drivers/media/video/mx2_camera.c b/drivers/media/video/mx2_camera.c index 637bde8..5c30302 100644 --- a/drivers/media/video/mx2_camera.c +++ b/drivers/media/video/mx2_camera.c @@ -1766,7 +1766,7 @@ static int __devinit mx2_camera_probe(struct platform_device *pdev) if (cpu_is_mx25()) pcdev->soc_host.capabilities = SOCAM_HOST_CAP_STRIDE; - pcdev->alloc_ctx = vb2_dma_contig_init_ctx(&pdev->dev); + pcdev->alloc_ctx = vb2_dma_contig_init_ctx(&pdev->dev, 0); if (IS_ERR(pcdev->alloc_ctx)) { err = PTR_ERR(pcdev->alloc_ctx); goto eallocctx; diff --git a/drivers/media/video/mx2_emmaprp.c b/drivers/media/video/mx2_emmaprp.c index 2810015..23c6c42 100644 --- a/drivers/media/video/mx2_emmaprp.c +++ b/drivers/media/video/mx2_emmaprp.c @@ -962,7 +962,7 @@ static int emmaprp_probe(struct platform_device *pdev) 0, MEM2MEM_NAME, pcdev) < 0) goto rel_vdev; - pcdev->alloc_ctx = vb2_dma_contig_init_ctx(&pdev->dev); + pcdev->alloc_ctx = vb2_dma_contig_init_ctx(&pdev->dev, 0); if (IS_ERR(pcdev->alloc_ctx)) { v4l2_err(&pcdev->v4l2_dev, "Failed to alloc vb2 context\n"); ret = PTR_ERR(pcdev->alloc_ctx); diff --git a/drivers/media/video/mx3_camera.c b/drivers/media/video/mx3_camera.c index f13643d..882026f 100644 --- a/drivers/media/video/mx3_camera.c +++ b/drivers/media/video/mx3_camera.c @@ -1227,7 +1227,7 @@ static int __devinit mx3_camera_probe(struct platform_device *pdev) soc_host->v4l2_dev.dev = &pdev->dev; soc_host->nr= pdev->id; - mx3_cam->alloc_ctx = vb2_dma_contig_init_ctx(&pdev->dev); + mx3_cam->alloc_ctx = vb2_dma_contig_init_ctx(&pdev->dev, 0); if (IS_ERR(mx3_cam->alloc_ctx)) { err = PTR_ERR(mx3_cam->alloc_ctx); goto eallocctx; diff --
[PATCHv8 23/26] v4l: vb2: add support for DMA_ATTR_NO_KERNEL_MAPPING
From: Marek Szyprowski Signed-off-by: Marek Szyprowski --- drivers/media/video/atmel-isi.c |2 +- drivers/media/video/blackfin/bfin_capture.c |2 +- drivers/media/video/marvell-ccic/mcam-core.c |3 ++- drivers/media/video/mx2_camera.c |2 +- drivers/media/video/mx2_emmaprp.c|2 +- drivers/media/video/mx3_camera.c |2 +- drivers/media/video/s5p-fimc/fimc-core.c |2 +- drivers/media/video/s5p-fimc/fimc-lite.c |2 +- drivers/media/video/s5p-g2d/g2d.c|2 +- drivers/media/video/s5p-jpeg/jpeg-core.c |2 +- drivers/media/video/s5p-mfc/s5p_mfc.c|5 ++-- drivers/media/video/s5p-tv/mixer_video.c |2 +- drivers/media/video/sh_mobile_ceu_camera.c |2 +- drivers/media/video/videobuf2-dma-contig.c | 33 +++--- drivers/staging/media/dt3155v4l/dt3155v4l.c |2 +- include/media/videobuf2-dma-contig.h |4 +++- 16 files changed, 44 insertions(+), 25 deletions(-) diff --git a/drivers/media/video/atmel-isi.c b/drivers/media/video/atmel-isi.c index 6274a91..9fb5283 100644 --- a/drivers/media/video/atmel-isi.c +++ b/drivers/media/video/atmel-isi.c @@ -1000,7 +1000,7 @@ static int __devinit atmel_isi_probe(struct platform_device *pdev) list_add(&isi->dma_desc[i].list, &isi->dma_desc_head); } - isi->alloc_ctx = vb2_dma_contig_init_ctx(&pdev->dev); + isi->alloc_ctx = vb2_dma_contig_init_ctx(&pdev->dev, 0); if (IS_ERR(isi->alloc_ctx)) { ret = PTR_ERR(isi->alloc_ctx); goto err_alloc_ctx; diff --git a/drivers/media/video/blackfin/bfin_capture.c b/drivers/media/video/blackfin/bfin_capture.c index 1677623..7e90b65 100644 --- a/drivers/media/video/blackfin/bfin_capture.c +++ b/drivers/media/video/blackfin/bfin_capture.c @@ -893,7 +893,7 @@ static int __devinit bcap_probe(struct platform_device *pdev) } bcap_dev->ppi->priv = bcap_dev; - bcap_dev->alloc_ctx = vb2_dma_contig_init_ctx(&pdev->dev); + bcap_dev->alloc_ctx = vb2_dma_contig_init_ctx(&pdev->dev, 0); if (IS_ERR(bcap_dev->alloc_ctx)) { ret = PTR_ERR(bcap_dev->alloc_ctx); goto err_free_ppi; diff --git a/drivers/media/video/marvell-ccic/mcam-core.c b/drivers/media/video/marvell-ccic/mcam-core.c index ce2b7b4..10d4db5 100644 --- a/drivers/media/video/marvell-ccic/mcam-core.c +++ b/drivers/media/video/marvell-ccic/mcam-core.c @@ -,7 +,8 @@ static int mcam_setup_vb2(struct mcam_camera *cam) #ifdef MCAM_MODE_DMA_CONTIG vq->ops = &mcam_vb2_ops; vq->mem_ops = &vb2_dma_contig_memops; - cam->vb_alloc_ctx = vb2_dma_contig_init_ctx(cam->dev); + cam->vb_alloc_ctx = vb2_dma_contig_init_ctx(cam->dev, + VB2_CREATE_VADDR); vq->io_modes = VB2_MMAP | VB2_USERPTR; cam->dma_setup = mcam_ctlr_dma_contig; cam->frame_complete = mcam_dma_contig_done; diff --git a/drivers/media/video/mx2_camera.c b/drivers/media/video/mx2_camera.c index 637bde8..5c30302 100644 --- a/drivers/media/video/mx2_camera.c +++ b/drivers/media/video/mx2_camera.c @@ -1766,7 +1766,7 @@ static int __devinit mx2_camera_probe(struct platform_device *pdev) if (cpu_is_mx25()) pcdev->soc_host.capabilities = SOCAM_HOST_CAP_STRIDE; - pcdev->alloc_ctx = vb2_dma_contig_init_ctx(&pdev->dev); + pcdev->alloc_ctx = vb2_dma_contig_init_ctx(&pdev->dev, 0); if (IS_ERR(pcdev->alloc_ctx)) { err = PTR_ERR(pcdev->alloc_ctx); goto eallocctx; diff --git a/drivers/media/video/mx2_emmaprp.c b/drivers/media/video/mx2_emmaprp.c index 2810015..23c6c42 100644 --- a/drivers/media/video/mx2_emmaprp.c +++ b/drivers/media/video/mx2_emmaprp.c @@ -962,7 +962,7 @@ static int emmaprp_probe(struct platform_device *pdev) 0, MEM2MEM_NAME, pcdev) < 0) goto rel_vdev; - pcdev->alloc_ctx = vb2_dma_contig_init_ctx(&pdev->dev); + pcdev->alloc_ctx = vb2_dma_contig_init_ctx(&pdev->dev, 0); if (IS_ERR(pcdev->alloc_ctx)) { v4l2_err(&pcdev->v4l2_dev, "Failed to alloc vb2 context\n"); ret = PTR_ERR(pcdev->alloc_ctx); diff --git a/drivers/media/video/mx3_camera.c b/drivers/media/video/mx3_camera.c index f13643d..882026f 100644 --- a/drivers/media/video/mx3_camera.c +++ b/drivers/media/video/mx3_camera.c @@ -1227,7 +1227,7 @@ static int __devinit mx3_camera_probe(struct platform_device *pdev) soc_host->v4l2_dev.dev = &pdev->dev; soc_host->nr= pdev->id; - mx3_cam->alloc_ctx = vb2_dma_contig_init_ctx(&pdev->dev); + mx3_cam->alloc_ctx = vb2_dma_contig_init_ctx(&pdev->dev, 0); if (IS_ERR(mx3_cam->alloc_ctx)) { err = PTR_ERR(mx3_cam->alloc_ctx); goto eallocctx; diff --git a
[PATCHv8 23/26] v4l: vb2: add support for DMA_ATTR_NO_KERNEL_MAPPING
Hi Tomasz, Thanks for the patch. On Tuesday 14 August 2012 17:34:53 Tomasz Stanislawski wrote: > From: Marek Szyprowski > > Signed-off-by: Marek Szyprowski > --- > drivers/media/video/atmel-isi.c |2 +- > drivers/media/video/blackfin/bfin_capture.c |2 +- > drivers/media/video/marvell-ccic/mcam-core.c |3 ++- > drivers/media/video/mx2_camera.c |2 +- > drivers/media/video/mx2_emmaprp.c|2 +- > drivers/media/video/mx3_camera.c |2 +- > drivers/media/video/s5p-fimc/fimc-core.c |2 +- > drivers/media/video/s5p-fimc/fimc-lite.c |2 +- > drivers/media/video/s5p-g2d/g2d.c|2 +- > drivers/media/video/s5p-jpeg/jpeg-core.c |2 +- > drivers/media/video/s5p-mfc/s5p_mfc.c|5 ++-- > drivers/media/video/s5p-tv/mixer_video.c |2 +- > drivers/media/video/sh_mobile_ceu_camera.c |2 +- > drivers/media/video/videobuf2-dma-contig.c | 33 --- > drivers/staging/media/dt3155v4l/dt3155v4l.c |2 +- > include/media/videobuf2-dma-contig.h |4 +++- > 16 files changed, 44 insertions(+), 25 deletions(-) [snip] > diff --git a/drivers/media/video/videobuf2-dma-contig.c > b/drivers/media/video/videobuf2-dma-contig.c index 11f4a46..0729187 100644 > --- a/drivers/media/video/videobuf2-dma-contig.c > +++ b/drivers/media/video/videobuf2-dma-contig.c > @@ -23,10 +23,12 @@ > > struct vb2_dc_conf { > struct device *dev; > + unsigned intflags; > }; > > struct vb2_dc_buf { > struct device *dev; > + unsigned intflags; > void*vaddr; > unsigned long size; > dma_addr_t dma_addr; > @@ -34,6 +36,7 @@ struct vb2_dc_buf { > struct sg_table *dma_sgt; > > /* MMAP related */ > + struct dma_attrsdma_attrs; > struct vb2_vmarea_handler handler; > atomic_trefcount; > struct sg_table *sgt_base; > @@ -98,6 +101,9 @@ static void *vb2_dc_vaddr(void *buf_priv) > { > struct vb2_dc_buf *buf = buf_priv; > > + if (WARN_ON(~buf->flags & VB2_CREATE_VADDR)) > + return NULL; > + > return buf->vaddr; > } > > @@ -147,7 +153,8 @@ static void vb2_dc_put(void *buf_priv) > sg_free_table(buf->sgt_base); > kfree(buf->sgt_base); > } > - dma_free_coherent(buf->dev, buf->size, buf->vaddr, buf->dma_addr); > + dma_free_attrs(buf->dev, buf->size, buf->vaddr, buf->dma_addr, > +&buf->dma_attrs); > put_device(buf->dev); > kfree(buf); > } > @@ -165,7 +172,14 @@ static void *vb2_dc_alloc(void *alloc_ctx, unsigned > long size) /* prevent the device from release while the buffer is exported > */ get_device(dev); > > - buf->vaddr = dma_alloc_coherent(dev, size, &buf->dma_addr, GFP_KERNEL); > + /* set up alloca attributes */ > + init_dma_attrs(&buf->dma_attrs); > + dma_set_attr(DMA_ATTR_WRITE_COMBINE, &buf->dma_attrs); > + if (!(conf->flags & VB2_CREATE_VADDR)) > + dma_set_attr(DMA_ATTR_NO_KERNEL_MAPPING, &buf->dma_attrs); > + > + buf->vaddr = dma_alloc_attrs(dev, size, &buf->dma_addr, GFP_KERNEL, > + &buf->dma_attrs); What address does dma_alloc_attrs() return when the DMA_ATTR_NO_KERNEL_MAPPING attribute is set ? > if (!buf->vaddr) { > dev_err(dev, "dma_alloc_coherent of size %ld failed\n", size); > put_device(dev); > @@ -174,6 +188,7 @@ static void *vb2_dc_alloc(void *alloc_ctx, unsigned long > size) } > > buf->dev = dev; > + buf->flags = conf->flags; > buf->size = size; > > buf->handler.refcount = &buf->refcount; > @@ -201,9 +216,8 @@ static int vb2_dc_mmap(void *buf_priv, struct > vm_area_struct *vma) */ > vma->vm_pgoff = 0; > > - ret = dma_mmap_coherent(buf->dev, vma, buf->vaddr, > - buf->dma_addr, buf->size); > - > + ret = dma_mmap_attrs(buf->dev, vma, buf->vaddr, buf->dma_addr, > + buf->size, &buf->dma_attrs); > if (ret) { > pr_err("Remapping memory failed, error: %d\n", ret); > return ret; > @@ -345,7 +359,7 @@ static void *vb2_dc_dmabuf_ops_kmap(struct dma_buf > *dbuf, unsigned long pgnum) { > struct vb2_dc_buf *buf = dbuf->priv; > > - return buf->vaddr + pgnum * PAGE_SIZE; > + return buf->vaddr ? buf->vaddr + pgnum * PAGE_SIZE : NULL; Does this mean that a V4L2 driver that doesn't need a kernel mapping will not be able to export buffers to devices that require such a mapping ? > } > > static void *vb2_dc_dmabuf_ops_vmap(struct dma_buf *dbuf) > @@ -385,8 +399,8 @@ static struct sg_table *vb2_dc_get_base_sgt(struct > vb2_dc_buf *buf) return ERR_PTR(-ENOMEM); > } > > - ret = dm
[PATCHv8 23/26] v4l: vb2: add support for DMA_ATTR_NO_KERNEL_MAPPING
On Tue August 14 2012 17:34:53 Tomasz Stanislawski wrote: > From: Marek Szyprowski Please add some more information in the commit message. I've no idea what's going on here or why :-) Regards, Hans > Signed-off-by: Marek Szyprowski > --- > drivers/media/video/atmel-isi.c |2 +- > drivers/media/video/blackfin/bfin_capture.c |2 +- > drivers/media/video/marvell-ccic/mcam-core.c |3 ++- > drivers/media/video/mx2_camera.c |2 +- > drivers/media/video/mx2_emmaprp.c|2 +- > drivers/media/video/mx3_camera.c |2 +- > drivers/media/video/s5p-fimc/fimc-core.c |2 +- > drivers/media/video/s5p-fimc/fimc-lite.c |2 +- > drivers/media/video/s5p-g2d/g2d.c|2 +- > drivers/media/video/s5p-jpeg/jpeg-core.c |2 +- > drivers/media/video/s5p-mfc/s5p_mfc.c|5 ++-- > drivers/media/video/s5p-tv/mixer_video.c |2 +- > drivers/media/video/sh_mobile_ceu_camera.c |2 +- > drivers/media/video/videobuf2-dma-contig.c | 33 > +++--- > drivers/staging/media/dt3155v4l/dt3155v4l.c |2 +- > include/media/videobuf2-dma-contig.h |4 +++- > 16 files changed, 44 insertions(+), 25 deletions(-) > > diff --git a/drivers/media/video/atmel-isi.c b/drivers/media/video/atmel-isi.c > index 6274a91..9fb5283 100644 > --- a/drivers/media/video/atmel-isi.c > +++ b/drivers/media/video/atmel-isi.c > @@ -1000,7 +1000,7 @@ static int __devinit atmel_isi_probe(struct > platform_device *pdev) > list_add(&isi->dma_desc[i].list, &isi->dma_desc_head); > } > > - isi->alloc_ctx = vb2_dma_contig_init_ctx(&pdev->dev); > + isi->alloc_ctx = vb2_dma_contig_init_ctx(&pdev->dev, 0); > if (IS_ERR(isi->alloc_ctx)) { > ret = PTR_ERR(isi->alloc_ctx); > goto err_alloc_ctx; > diff --git a/drivers/media/video/blackfin/bfin_capture.c > b/drivers/media/video/blackfin/bfin_capture.c > index 1677623..7e90b65 100644 > --- a/drivers/media/video/blackfin/bfin_capture.c > +++ b/drivers/media/video/blackfin/bfin_capture.c > @@ -893,7 +893,7 @@ static int __devinit bcap_probe(struct platform_device > *pdev) > } > bcap_dev->ppi->priv = bcap_dev; > > - bcap_dev->alloc_ctx = vb2_dma_contig_init_ctx(&pdev->dev); > + bcap_dev->alloc_ctx = vb2_dma_contig_init_ctx(&pdev->dev, 0); > if (IS_ERR(bcap_dev->alloc_ctx)) { > ret = PTR_ERR(bcap_dev->alloc_ctx); > goto err_free_ppi; > diff --git a/drivers/media/video/marvell-ccic/mcam-core.c > b/drivers/media/video/marvell-ccic/mcam-core.c > index ce2b7b4..10d4db5 100644 > --- a/drivers/media/video/marvell-ccic/mcam-core.c > +++ b/drivers/media/video/marvell-ccic/mcam-core.c > @@ -,7 +,8 @@ static int mcam_setup_vb2(struct mcam_camera *cam) > #ifdef MCAM_MODE_DMA_CONTIG > vq->ops = &mcam_vb2_ops; > vq->mem_ops = &vb2_dma_contig_memops; > - cam->vb_alloc_ctx = vb2_dma_contig_init_ctx(cam->dev); > + cam->vb_alloc_ctx = vb2_dma_contig_init_ctx(cam->dev, > + VB2_CREATE_VADDR); > vq->io_modes = VB2_MMAP | VB2_USERPTR; > cam->dma_setup = mcam_ctlr_dma_contig; > cam->frame_complete = mcam_dma_contig_done; > diff --git a/drivers/media/video/mx2_camera.c > b/drivers/media/video/mx2_camera.c > index 637bde8..5c30302 100644 > --- a/drivers/media/video/mx2_camera.c > +++ b/drivers/media/video/mx2_camera.c > @@ -1766,7 +1766,7 @@ static int __devinit mx2_camera_probe(struct > platform_device *pdev) > if (cpu_is_mx25()) > pcdev->soc_host.capabilities = SOCAM_HOST_CAP_STRIDE; > > - pcdev->alloc_ctx = vb2_dma_contig_init_ctx(&pdev->dev); > + pcdev->alloc_ctx = vb2_dma_contig_init_ctx(&pdev->dev, 0); > if (IS_ERR(pcdev->alloc_ctx)) { > err = PTR_ERR(pcdev->alloc_ctx); > goto eallocctx; > diff --git a/drivers/media/video/mx2_emmaprp.c > b/drivers/media/video/mx2_emmaprp.c > index 2810015..23c6c42 100644 > --- a/drivers/media/video/mx2_emmaprp.c > +++ b/drivers/media/video/mx2_emmaprp.c > @@ -962,7 +962,7 @@ static int emmaprp_probe(struct platform_device *pdev) >0, MEM2MEM_NAME, pcdev) < 0) > goto rel_vdev; > > - pcdev->alloc_ctx = vb2_dma_contig_init_ctx(&pdev->dev); > + pcdev->alloc_ctx = vb2_dma_contig_init_ctx(&pdev->dev, 0); > if (IS_ERR(pcdev->alloc_ctx)) { > v4l2_err(&pcdev->v4l2_dev, "Failed to alloc vb2 context\n"); > ret = PTR_ERR(pcdev->alloc_ctx); > diff --git a/drivers/media/video/mx3_camera.c > b/drivers/media/video/mx3_camera.c > index f13643d..882026f 100644 > --- a/drivers/media/video/mx3_camera.c > +++ b/drivers/media/video/mx3_camera.c > @@ -1227,7 +1227,7 @@ static int __devinit mx3_camera_probe(struct > platform_device *pdev) > soc_host->v4l2_dev.dev = &pdev-
Re: [PATCHv8 23/26] v4l: vb2: add support for DMA_ATTR_NO_KERNEL_MAPPING
Hi Tomasz, Thanks for the patch. On Tuesday 14 August 2012 17:34:53 Tomasz Stanislawski wrote: > From: Marek Szyprowski > > Signed-off-by: Marek Szyprowski > --- > drivers/media/video/atmel-isi.c |2 +- > drivers/media/video/blackfin/bfin_capture.c |2 +- > drivers/media/video/marvell-ccic/mcam-core.c |3 ++- > drivers/media/video/mx2_camera.c |2 +- > drivers/media/video/mx2_emmaprp.c|2 +- > drivers/media/video/mx3_camera.c |2 +- > drivers/media/video/s5p-fimc/fimc-core.c |2 +- > drivers/media/video/s5p-fimc/fimc-lite.c |2 +- > drivers/media/video/s5p-g2d/g2d.c|2 +- > drivers/media/video/s5p-jpeg/jpeg-core.c |2 +- > drivers/media/video/s5p-mfc/s5p_mfc.c|5 ++-- > drivers/media/video/s5p-tv/mixer_video.c |2 +- > drivers/media/video/sh_mobile_ceu_camera.c |2 +- > drivers/media/video/videobuf2-dma-contig.c | 33 --- > drivers/staging/media/dt3155v4l/dt3155v4l.c |2 +- > include/media/videobuf2-dma-contig.h |4 +++- > 16 files changed, 44 insertions(+), 25 deletions(-) [snip] > diff --git a/drivers/media/video/videobuf2-dma-contig.c > b/drivers/media/video/videobuf2-dma-contig.c index 11f4a46..0729187 100644 > --- a/drivers/media/video/videobuf2-dma-contig.c > +++ b/drivers/media/video/videobuf2-dma-contig.c > @@ -23,10 +23,12 @@ > > struct vb2_dc_conf { > struct device *dev; > + unsigned intflags; > }; > > struct vb2_dc_buf { > struct device *dev; > + unsigned intflags; > void*vaddr; > unsigned long size; > dma_addr_t dma_addr; > @@ -34,6 +36,7 @@ struct vb2_dc_buf { > struct sg_table *dma_sgt; > > /* MMAP related */ > + struct dma_attrsdma_attrs; > struct vb2_vmarea_handler handler; > atomic_trefcount; > struct sg_table *sgt_base; > @@ -98,6 +101,9 @@ static void *vb2_dc_vaddr(void *buf_priv) > { > struct vb2_dc_buf *buf = buf_priv; > > + if (WARN_ON(~buf->flags & VB2_CREATE_VADDR)) > + return NULL; > + > return buf->vaddr; > } > > @@ -147,7 +153,8 @@ static void vb2_dc_put(void *buf_priv) > sg_free_table(buf->sgt_base); > kfree(buf->sgt_base); > } > - dma_free_coherent(buf->dev, buf->size, buf->vaddr, buf->dma_addr); > + dma_free_attrs(buf->dev, buf->size, buf->vaddr, buf->dma_addr, > +&buf->dma_attrs); > put_device(buf->dev); > kfree(buf); > } > @@ -165,7 +172,14 @@ static void *vb2_dc_alloc(void *alloc_ctx, unsigned > long size) /* prevent the device from release while the buffer is exported > */ get_device(dev); > > - buf->vaddr = dma_alloc_coherent(dev, size, &buf->dma_addr, GFP_KERNEL); > + /* set up alloca attributes */ > + init_dma_attrs(&buf->dma_attrs); > + dma_set_attr(DMA_ATTR_WRITE_COMBINE, &buf->dma_attrs); > + if (!(conf->flags & VB2_CREATE_VADDR)) > + dma_set_attr(DMA_ATTR_NO_KERNEL_MAPPING, &buf->dma_attrs); > + > + buf->vaddr = dma_alloc_attrs(dev, size, &buf->dma_addr, GFP_KERNEL, > + &buf->dma_attrs); What address does dma_alloc_attrs() return when the DMA_ATTR_NO_KERNEL_MAPPING attribute is set ? > if (!buf->vaddr) { > dev_err(dev, "dma_alloc_coherent of size %ld failed\n", size); > put_device(dev); > @@ -174,6 +188,7 @@ static void *vb2_dc_alloc(void *alloc_ctx, unsigned long > size) } > > buf->dev = dev; > + buf->flags = conf->flags; > buf->size = size; > > buf->handler.refcount = &buf->refcount; > @@ -201,9 +216,8 @@ static int vb2_dc_mmap(void *buf_priv, struct > vm_area_struct *vma) */ > vma->vm_pgoff = 0; > > - ret = dma_mmap_coherent(buf->dev, vma, buf->vaddr, > - buf->dma_addr, buf->size); > - > + ret = dma_mmap_attrs(buf->dev, vma, buf->vaddr, buf->dma_addr, > + buf->size, &buf->dma_attrs); > if (ret) { > pr_err("Remapping memory failed, error: %d\n", ret); > return ret; > @@ -345,7 +359,7 @@ static void *vb2_dc_dmabuf_ops_kmap(struct dma_buf > *dbuf, unsigned long pgnum) { > struct vb2_dc_buf *buf = dbuf->priv; > > - return buf->vaddr + pgnum * PAGE_SIZE; > + return buf->vaddr ? buf->vaddr + pgnum * PAGE_SIZE : NULL; Does this mean that a V4L2 driver that doesn't need a kernel mapping will not be able to export buffers to devices that require such a mapping ? > } > > static void *vb2_dc_dmabuf_ops_vmap(struct dma_buf *dbuf) > @@ -385,8 +399,8 @@ static struct sg_table *vb2_dc_get_base_sgt(struct > vb2_dc_buf *buf) return ERR_PTR(-ENOMEM); > } > > - ret = dm
Re: [PATCHv8 23/26] v4l: vb2: add support for DMA_ATTR_NO_KERNEL_MAPPING
On Tue August 14 2012 17:34:53 Tomasz Stanislawski wrote: > From: Marek Szyprowski Please add some more information in the commit message. I've no idea what's going on here or why :-) Regards, Hans > Signed-off-by: Marek Szyprowski > --- > drivers/media/video/atmel-isi.c |2 +- > drivers/media/video/blackfin/bfin_capture.c |2 +- > drivers/media/video/marvell-ccic/mcam-core.c |3 ++- > drivers/media/video/mx2_camera.c |2 +- > drivers/media/video/mx2_emmaprp.c|2 +- > drivers/media/video/mx3_camera.c |2 +- > drivers/media/video/s5p-fimc/fimc-core.c |2 +- > drivers/media/video/s5p-fimc/fimc-lite.c |2 +- > drivers/media/video/s5p-g2d/g2d.c|2 +- > drivers/media/video/s5p-jpeg/jpeg-core.c |2 +- > drivers/media/video/s5p-mfc/s5p_mfc.c|5 ++-- > drivers/media/video/s5p-tv/mixer_video.c |2 +- > drivers/media/video/sh_mobile_ceu_camera.c |2 +- > drivers/media/video/videobuf2-dma-contig.c | 33 > +++--- > drivers/staging/media/dt3155v4l/dt3155v4l.c |2 +- > include/media/videobuf2-dma-contig.h |4 +++- > 16 files changed, 44 insertions(+), 25 deletions(-) > > diff --git a/drivers/media/video/atmel-isi.c b/drivers/media/video/atmel-isi.c > index 6274a91..9fb5283 100644 > --- a/drivers/media/video/atmel-isi.c > +++ b/drivers/media/video/atmel-isi.c > @@ -1000,7 +1000,7 @@ static int __devinit atmel_isi_probe(struct > platform_device *pdev) > list_add(&isi->dma_desc[i].list, &isi->dma_desc_head); > } > > - isi->alloc_ctx = vb2_dma_contig_init_ctx(&pdev->dev); > + isi->alloc_ctx = vb2_dma_contig_init_ctx(&pdev->dev, 0); > if (IS_ERR(isi->alloc_ctx)) { > ret = PTR_ERR(isi->alloc_ctx); > goto err_alloc_ctx; > diff --git a/drivers/media/video/blackfin/bfin_capture.c > b/drivers/media/video/blackfin/bfin_capture.c > index 1677623..7e90b65 100644 > --- a/drivers/media/video/blackfin/bfin_capture.c > +++ b/drivers/media/video/blackfin/bfin_capture.c > @@ -893,7 +893,7 @@ static int __devinit bcap_probe(struct platform_device > *pdev) > } > bcap_dev->ppi->priv = bcap_dev; > > - bcap_dev->alloc_ctx = vb2_dma_contig_init_ctx(&pdev->dev); > + bcap_dev->alloc_ctx = vb2_dma_contig_init_ctx(&pdev->dev, 0); > if (IS_ERR(bcap_dev->alloc_ctx)) { > ret = PTR_ERR(bcap_dev->alloc_ctx); > goto err_free_ppi; > diff --git a/drivers/media/video/marvell-ccic/mcam-core.c > b/drivers/media/video/marvell-ccic/mcam-core.c > index ce2b7b4..10d4db5 100644 > --- a/drivers/media/video/marvell-ccic/mcam-core.c > +++ b/drivers/media/video/marvell-ccic/mcam-core.c > @@ -,7 +,8 @@ static int mcam_setup_vb2(struct mcam_camera *cam) > #ifdef MCAM_MODE_DMA_CONTIG > vq->ops = &mcam_vb2_ops; > vq->mem_ops = &vb2_dma_contig_memops; > - cam->vb_alloc_ctx = vb2_dma_contig_init_ctx(cam->dev); > + cam->vb_alloc_ctx = vb2_dma_contig_init_ctx(cam->dev, > + VB2_CREATE_VADDR); > vq->io_modes = VB2_MMAP | VB2_USERPTR; > cam->dma_setup = mcam_ctlr_dma_contig; > cam->frame_complete = mcam_dma_contig_done; > diff --git a/drivers/media/video/mx2_camera.c > b/drivers/media/video/mx2_camera.c > index 637bde8..5c30302 100644 > --- a/drivers/media/video/mx2_camera.c > +++ b/drivers/media/video/mx2_camera.c > @@ -1766,7 +1766,7 @@ static int __devinit mx2_camera_probe(struct > platform_device *pdev) > if (cpu_is_mx25()) > pcdev->soc_host.capabilities = SOCAM_HOST_CAP_STRIDE; > > - pcdev->alloc_ctx = vb2_dma_contig_init_ctx(&pdev->dev); > + pcdev->alloc_ctx = vb2_dma_contig_init_ctx(&pdev->dev, 0); > if (IS_ERR(pcdev->alloc_ctx)) { > err = PTR_ERR(pcdev->alloc_ctx); > goto eallocctx; > diff --git a/drivers/media/video/mx2_emmaprp.c > b/drivers/media/video/mx2_emmaprp.c > index 2810015..23c6c42 100644 > --- a/drivers/media/video/mx2_emmaprp.c > +++ b/drivers/media/video/mx2_emmaprp.c > @@ -962,7 +962,7 @@ static int emmaprp_probe(struct platform_device *pdev) >0, MEM2MEM_NAME, pcdev) < 0) > goto rel_vdev; > > - pcdev->alloc_ctx = vb2_dma_contig_init_ctx(&pdev->dev); > + pcdev->alloc_ctx = vb2_dma_contig_init_ctx(&pdev->dev, 0); > if (IS_ERR(pcdev->alloc_ctx)) { > v4l2_err(&pcdev->v4l2_dev, "Failed to alloc vb2 context\n"); > ret = PTR_ERR(pcdev->alloc_ctx); > diff --git a/drivers/media/video/mx3_camera.c > b/drivers/media/video/mx3_camera.c > index f13643d..882026f 100644 > --- a/drivers/media/video/mx3_camera.c > +++ b/drivers/media/video/mx3_camera.c > @@ -1227,7 +1227,7 @@ static int __devinit mx3_camera_probe(struct > platform_device *pdev) > soc_host->v4l2_dev.dev = &pdev-