Skip to contentSkip to conversation

modify videobuf2-dma-contig and update sta2x11_vip

PATCH Superseded Federico Vaga 5 participants 13 messages Jan 10, 2013

Subsystems (6)
lore
Share & tools
lore
#0 lore raw

PATCH v5 1/1 modify videobuf2-dma-contig and update sta2x11_vip

Just one comment about the first patch. I modified the prototype of the dma-contig context allocator:

   -void *vb2_dma_contig_init_ctx(struct device *dev);
   +void *vb2_dma_contig_init_ctx(struct device *dev, gfp_t mem_flags);

Now it accepts a gfp_t parameter to specify the memory flags to use during buffer allocation. I also modified all existent drivers according to this modification. I cannot do a compile test on every different platform (I don't have the time and it takes long time); the modification is tiny but just to be sure please take a look at it.

To find all drivers which use this memory allocator, I simply did:

git grep -n -C 1 vb2_dma_contig_init_ctx

and edited all the driver found. If I forgot someone, please tell me

#1 lore raw

PATCH v5 1/3 videobuf2-dma-contig: user can specify GFP flags

This is useful when you need to specify specific GFP flags during memory allocation (e.g. GFP_DMA).

---
 drivers/media/platform/blackfin/bfin_capture.c           | 2 +-
 drivers/media/platform/coda.c                            | 2 +-
 drivers/media/platform/davinci/vpbe_display.c            | 2 +-
 drivers/media/platform/davinci/vpif_capture.c            | 4 ++--
 drivers/media/platform/davinci/vpif_display.c            | 2 +-
 drivers/media/platform/exynos-gsc/gsc-core.c             | 2 +-
 drivers/media/platform/m2m-deinterlace.c                 | 2 +-
 drivers/media/platform/marvell-ccic/mcam-core.c          | 2 +-
 drivers/media/platform/mx2_emmaprp.c                     | 2 +-
 drivers/media/platform/s3c-camif/camif-core.c            | 2 +-
 drivers/media/platform/s5p-fimc/fimc-core.c              | 2 +-
 drivers/media/platform/s5p-fimc/fimc-lite.c              | 2 +-
 drivers/media/platform/s5p-g2d/g2d.c                     | 2 +-
 drivers/media/platform/s5p-jpeg/jpeg-core.c              | 2 +-
 drivers/media/platform/s5p-mfc/s5p_mfc.c                 | 4 ++--
 drivers/media/platform/s5p-tv/mixer_video.c              | 2 +-
 drivers/media/platform/sh_veu.c                          | 2 +-
 drivers/media/platform/soc_camera/atmel-isi.c            | 2 +-
 drivers/media/platform/soc_camera/mx2_camera.c           | 2 +-
 drivers/media/platform/soc_camera/mx3_camera.c           | 2 +-
 drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c | 2 +-
 drivers/media/v4l2-core/videobuf2-dma-contig.c           | 7 +++++--
 drivers/staging/media/davinci_vpfe/vpfe_video.c          | 2 +-
 drivers/staging/media/dt3155v4l/dt3155v4l.c              | 2 +-
 include/media/videobuf2-dma-contig.h                     | 2 +-

25 file modificati, 31 inserzioni(+), 28 rimozioni(-)

drivers/media/platform/blackfin/bfin_capture.c +1 -1
index aa9f846..57e911f 100644
@@ -978,7 +978,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, GFP_KERNEL);
 	if (IS_ERR(bcap_dev->alloc_ctx)) {
 		ret = PTR_ERR(bcap_dev->alloc_ctx);
 		goto err_free_ppi;
drivers/media/platform/coda.c +1 -1
index 2721f83..abe547d 100644
@@ -1846,7 +1846,7 @@ static void coda_fw_callback(const struct firmware *fw, void *context)
 	snprintf(dev->vfd.name, sizeof(dev->vfd.name), "%s", CODA_NAME);
 	video_set_drvdata(&dev->vfd, dev);
 
-	dev->alloc_ctx = vb2_dma_contig_init_ctx(&pdev->dev);
+	dev->alloc_ctx = vb2_dma_contig_init_ctx(&pdev->dev, GFP_KERNEL);
 	if (IS_ERR(dev->alloc_ctx)) {
 		v4l2_err(&dev->v4l2_dev, "Failed to alloc vb2 context\n");
 		return;
drivers/media/platform/davinci/vpbe_display.c +1 -1
index d078738..362a7bc 100644
@@ -1391,7 +1391,7 @@ static int vpbe_display_reqbufs(struct file *file, void *priv,
 		return -EBUSY;
 	}
 	/* Initialize videobuf queue as per the buffer type */
-	layer->alloc_ctx = vb2_dma_contig_init_ctx(vpbe_dev->pdev);
+	layer->alloc_ctx = vb2_dma_contig_init_ctx(vpbe_dev->pdev, GFP_KERNEL);
 	if (IS_ERR(layer->alloc_ctx)) {
 		v4l2_err(&vpbe_dev->v4l2_dev, "Failed to get the context\n");
 		return PTR_ERR(layer->alloc_ctx);
drivers/media/platform/davinci/vpif_capture.c +2 -2
index 5892d2b..9d80d24 100644
@@ -1023,7 +1023,7 @@ static int vpif_reqbufs(struct file *file, void *priv,
 		return -EBUSY;
 
 	/* Initialize videobuf2 queue as per the buffer type */
-	common->alloc_ctx = vb2_dma_contig_init_ctx(vpif_dev);
+	common->alloc_ctx = vb2_dma_contig_init_ctx(vpif_dev, GFP_KERNEL);
 	if (IS_ERR(common->alloc_ctx)) {
 		vpif_err("Failed to get the context\n");
 		return PTR_ERR(common->alloc_ctx);
@@ -1039,7 +1039,7 @@ static int vpif_reqbufs(struct file *file, void *priv,
 	ret = vb2_queue_init(q);
 	if (ret) {
 		vpif_err("vpif_capture: vb2_queue_init() failed\n");
-		vb2_dma_contig_cleanup_ctx(common->alloc_ctx);
+		vb2_dma_contig_cleanup_ctx(common->alloc_ctx, GFP_KERNEL);
 		return ret;
 	}
 	/* Set io allowed member of file handle to TRUE */
drivers/media/platform/davinci/vpif_display.c +1 -1
index dd249c9..f63f81e 100644
@@ -989,7 +989,7 @@ static int vpif_reqbufs(struct file *file, void *priv,
 		field = V4L2_VBI_INTERLACED;
 	}
 	/* Initialize videobuf2 queue as per the buffer type */
-	common->alloc_ctx = vb2_dma_contig_init_ctx(vpif_dev);
+	common->alloc_ctx = vb2_dma_contig_init_ctx(vpif_dev, GFP_KERNEL);
 	if (IS_ERR(common->alloc_ctx)) {
 		vpif_err("Failed to get the context\n");
 		return PTR_ERR(common->alloc_ctx);
drivers/media/platform/exynos-gsc/gsc-core.c +1 -1
index ae885c7..4f2961a 100644
@@ -1133,7 +1133,7 @@ static int gsc_probe(struct platform_device *pdev)
 		goto err_m2m;
 
 	/* Initialize continious memory allocator */
-	gsc->alloc_ctx = vb2_dma_contig_init_ctx(dev);
+	gsc->alloc_ctx = vb2_dma_contig_init_ctx(dev, GFP_KERNEL);
 	if (IS_ERR(gsc->alloc_ctx)) {
 		ret = PTR_ERR(gsc->alloc_ctx);
 		goto err_pm;
drivers/media/platform/m2m-deinterlace.c +1 -1
index 6c4db9b..e065be5 100644
@@ -1043,7 +1043,7 @@ static int deinterlace_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, pcdev);
 
-	pcdev->alloc_ctx = vb2_dma_contig_init_ctx(&pdev->dev);
+	pcdev->alloc_ctx = vb2_dma_contig_init_ctx(&pdev->dev, GFP_KERNEL);
 	if (IS_ERR(pcdev->alloc_ctx)) {
 		v4l2_err(&pcdev->v4l2_dev, "Failed to alloc vb2 context\n");
 		ret = PTR_ERR(pcdev->alloc_ctx);
drivers/media/platform/marvell-ccic/mcam-core.c +1 -1
index 7012913f..c79c3e6 100644
@@ -1104,7 +1104,7 @@ 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, GFP_KERNEL);
 		vq->io_modes = VB2_MMAP | VB2_USERPTR;
 		cam->dma_setup = mcam_ctlr_dma_contig;
 		cam->frame_complete = mcam_dma_contig_done;
drivers/media/platform/mx2_emmaprp.c +1 -1
index 6b155d7..eeb7898 100644
@@ -956,7 +956,7 @@ static int emmaprp_probe(struct platform_device *pdev)
 		goto rel_vdev;
 	}
 
-	pcdev->alloc_ctx = vb2_dma_contig_init_ctx(&pdev->dev);
+	pcdev->alloc_ctx = vb2_dma_contig_init_ctx(&pdev->dev, GFP_KERNEL);
 	if (IS_ERR(pcdev->alloc_ctx)) {
 		v4l2_err(&pcdev->v4l2_dev, "Failed to alloc vb2 context\n");
 		ret = PTR_ERR(pcdev->alloc_ctx);
drivers/media/platform/s3c-camif/camif-core.c +1 -1
index 37c9b6f..d39986d 100644
@@ -476,7 +476,7 @@ static int s3c_camif_probe(struct platform_device *pdev)
 		goto err_pm;
 
 	/* Initialize contiguous memory allocator */
-	camif->alloc_ctx = vb2_dma_contig_init_ctx(dev);
+	camif->alloc_ctx = vb2_dma_contig_init_ctx(dev, GFP_KERNEL);
 	if (IS_ERR(camif->alloc_ctx)) {
 		ret = PTR_ERR(camif->alloc_ctx);
 		goto err_alloc;
drivers/media/platform/s5p-fimc/fimc-core.c +1 -1
index 2a1558a..9b80388 100644
@@ -944,7 +944,7 @@ static int fimc_probe(struct platform_device *pdev)
 	if (ret < 0)
 		goto err_sd;
 	/* Initialize contiguous memory allocator */
-	fimc->alloc_ctx = vb2_dma_contig_init_ctx(&pdev->dev);
+	fimc->alloc_ctx = vb2_dma_contig_init_ctx(&pdev->dev, GFP_KERNEL);
 	if (IS_ERR(fimc->alloc_ctx)) {
 		ret = PTR_ERR(fimc->alloc_ctx);
 		goto err_pm;
drivers/media/platform/s5p-fimc/fimc-lite.c +1 -1
index 765b8e4..4d7f562 100644
@@ -1542,7 +1542,7 @@ static int __devinit fimc_lite_probe(struct platform_device *pdev)
 	if (ret < 0)
 		goto err_sd;
 
-	fimc->alloc_ctx = vb2_dma_contig_init_ctx(&pdev->dev);
+	fimc->alloc_ctx = vb2_dma_contig_init_ctx(&pdev->dev, GFP_KERNEL);
 	if (IS_ERR(fimc->alloc_ctx)) {
 		ret = PTR_ERR(fimc->alloc_ctx);
 		goto err_pm;
drivers/media/platform/s5p-g2d/g2d.c +1 -1
index 1bfbc32..57bbd76 100644
@@ -755,7 +755,7 @@ static int g2d_probe(struct platform_device *pdev)
 		goto put_clk_gate;
 	}
 
-	dev->alloc_ctx = vb2_dma_contig_init_ctx(&pdev->dev);
+	dev->alloc_ctx = vb2_dma_contig_init_ctx(&pdev->dev, GFP_KERNEL);
 	if (IS_ERR(dev->alloc_ctx)) {
 		ret = PTR_ERR(dev->alloc_ctx);
 		goto unprep_clk_gate;
drivers/media/platform/s5p-jpeg/jpeg-core.c +1 -1
index 17983c4..5e07a50 100644
@@ -1370,7 +1370,7 @@ static int s5p_jpeg_probe(struct platform_device *pdev)
 		goto device_register_rollback;
 	}
 
-	jpeg->alloc_ctx = vb2_dma_contig_init_ctx(&pdev->dev);
+	jpeg->alloc_ctx = vb2_dma_contig_init_ctx(&pdev->dev, GFP_KERNEL);
 	if (IS_ERR(jpeg->alloc_ctx)) {
 		v4l2_err(&jpeg->v4l2_dev, "Failed to init memory allocator\n");
 		ret = PTR_ERR(jpeg->alloc_ctx);
drivers/media/platform/s5p-mfc/s5p_mfc.c +2 -2
index 3afe879..dc7cb91 100644
@@ -1097,12 +1097,12 @@ static int s5p_mfc_probe(struct platform_device *pdev)
 		goto err_res;
 	}
 
-	dev->alloc_ctx[0] = vb2_dma_contig_init_ctx(dev->mem_dev_l);
+	dev->alloc_ctx[0] = vb2_dma_contig_init_ctx(dev->mem_dev_l, GFP_KERNEL);
 	if (IS_ERR_OR_NULL(dev->alloc_ctx[0])) {
 		ret = PTR_ERR(dev->alloc_ctx[0]);
 		goto err_res;
 	}
-	dev->alloc_ctx[1] = vb2_dma_contig_init_ctx(dev->mem_dev_r);
+	dev->alloc_ctx[1] = vb2_dma_contig_init_ctx(dev->mem_dev_r, GFP_KERNEL);
 	if (IS_ERR_OR_NULL(dev->alloc_ctx[1])) {
 		ret = PTR_ERR(dev->alloc_ctx[1]);
 		goto err_mem_init_ctx_1;
drivers/media/platform/s5p-tv/mixer_video.c +1 -1
index 7379e77..3ac2929 100644
@@ -79,7 +79,7 @@ int __devinit mxr_acquire_video(struct mxr_device *mdev,
 		goto fail;
 	}
 
-	mdev->alloc_ctx = vb2_dma_contig_init_ctx(mdev->dev);
+	mdev->alloc_ctx = vb2_dma_contig_init_ctx(mdev->dev, GFP_KERNEL);
 	if (IS_ERR_OR_NULL(mdev->alloc_ctx)) {
 		mxr_err(mdev, "could not acquire vb2 allocator\n");
 		goto fail_v4l2_dev;
drivers/media/platform/sh_veu.c +1 -1
index a018676..f293706 100644
@@ -1181,7 +1181,7 @@ static int __devinit sh_veu_probe(struct platform_device *pdev)
 
 	vdev = &veu->vdev;
 
-	veu->alloc_ctx = vb2_dma_contig_init_ctx(&pdev->dev);
+	veu->alloc_ctx = vb2_dma_contig_init_ctx(&pdev->dev, GFP_KERNEL);
 	if (IS_ERR(veu->alloc_ctx)) {
 		ret = PTR_ERR(veu->alloc_ctx);
 		goto einitctx;
drivers/media/platform/soc_camera/atmel-isi.c +1 -1
index c8d748a..62843e4 100644
@@ -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, GFP_KERNEL);
 	if (IS_ERR(isi->alloc_ctx)) {
 		ret = PTR_ERR(isi->alloc_ctx);
 		goto err_alloc_ctx;
drivers/media/platform/soc_camera/mx2_camera.c +1 -1
index 28d5c84..5a58c89 100644
@@ -1866,7 +1866,7 @@ static int __devinit mx2_camera_probe(struct platform_device *pdev)
 	if (is_imx25_camera(pcdev))
 		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, GFP_KERNEL);
 	if (IS_ERR(pcdev->alloc_ctx)) {
 		err = PTR_ERR(pcdev->alloc_ctx);
 		goto eallocctx;
drivers/media/platform/soc_camera/mx3_camera.c +1 -1
index 574d125..b0d19f1 100644
@@ -1218,7 +1218,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, GFP_KERNEL);
 	if (IS_ERR(mx3_cam->alloc_ctx)) {
 		err = PTR_ERR(mx3_cam->alloc_ctx);
 		goto eallocctx;
drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c +1 -1
index 9f02104..73243ca 100644
@@ -2154,7 +2154,7 @@ static int __devinit sh_mobile_ceu_probe(struct platform_device *pdev)
 	pcdev->ici.ops = &sh_mobile_ceu_host_ops;
 	pcdev->ici.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, GFP_KERNEL);
 	if (IS_ERR(pcdev->alloc_ctx)) {
 		err = PTR_ERR(pcdev->alloc_ctx);
 		goto exit_free_clk;
drivers/media/v4l2-core/videobuf2-dma-contig.c +5 -2
index 10beaee..00f1b85 100644
@@ -23,6 +23,7 @@
 
 struct vb2_dc_conf {
 	struct device		*dev;
+	gfp_t				mem_flags;
 };
 
 struct vb2_dc_buf {
@@ -165,7 +166,8 @@ static void *vb2_dc_alloc(void *alloc_ctx, unsigned long size)
 	/* align image size to PAGE_SIZE */
 	size = PAGE_ALIGN(size);
 
-	buf->vaddr = dma_alloc_coherent(dev, size, &buf->dma_addr, GFP_KERNEL);
+	buf->vaddr = dma_alloc_coherent(dev, size, &buf->dma_addr,
+									GFP_KERNEL | conf->mem_flags);
 	if (!buf->vaddr) {
 		dev_err(dev, "dma_alloc_coherent of size %ld failed\n", size);
 		kfree(buf);
@@ -751,7 +753,7 @@ const struct vb2_mem_ops vb2_dma_contig_memops = {
 };
 EXPORT_SYMBOL_GPL(vb2_dma_contig_memops);
 
-void *vb2_dma_contig_init_ctx(struct device *dev)
+void *vb2_dma_contig_init_ctx(struct device *dev, gfp_t mem_flags)
 {
 	struct vb2_dc_conf *conf;
 
@@ -760,6 +762,7 @@ void *vb2_dma_contig_init_ctx(struct device *dev)
 		return ERR_PTR(-ENOMEM);
 
 	conf->dev = dev;
+	conf->mem_flags = mem_flags;
 
 	return conf;
 }
drivers/staging/media/davinci_vpfe/vpfe_video.c +1 -1
index 99ccbeb..4ab10ce 100644
@@ -1315,7 +1315,7 @@ static int vpfe_reqbufs(struct file *file, void *priv,
 	video->memory = req_buf->memory;
 
 	/* Initialize videobuf2 queue as per the buffer type */
-	video->alloc_ctx = vb2_dma_contig_init_ctx(vpfe_dev->pdev);
+	video->alloc_ctx = vb2_dma_contig_init_ctx(vpfe_dev->pdev, GFP_KERNEL);
 	if (IS_ERR(video->alloc_ctx)) {
 		v4l2_err(&vpfe_dev->v4l2_dev, "Failed to get the context\n");
 		return PTR_ERR(video->alloc_ctx);
drivers/staging/media/dt3155v4l/dt3155v4l.c +1 -1
index e33b7f5..4907f39 100644
@@ -232,7 +232,7 @@ dt3155_queue_setup(struct vb2_queue *q, const struct v4l2_format *fmt,
 	sizes[0] = img_width * img_height;
 	if (pd->q->alloc_ctx[0])
 		return 0;
-	ret = vb2_dma_contig_init_ctx(&pd->pdev->dev);
+	ret = vb2_dma_contig_init_ctx(&pd->pdev->dev, GFP_KERNEL);
 	if (IS_ERR(ret))
 		return PTR_ERR(ret);
 	pd->q->alloc_ctx[0] = ret;
include/media/videobuf2-dma-contig.h +1 -1
index 8197f87..8d5a5a3 100644
@@ -24,7 +24,7 @@ vb2_dma_contig_plane_dma_addr(struct vb2_buffer *vb, unsigned int plane_no)
 	return *addr;
 }
 
-void *vb2_dma_contig_init_ctx(struct device *dev);
+void *vb2_dma_contig_init_ctx(struct device *dev, gfp_t mem_flags);
 void vb2_dma_contig_cleanup_ctx(void *alloc_ctx);
 
 extern const struct vb2_mem_ops vb2_dma_contig_memops;
Signature · 1 line
1.7.11.7
#2 lore raw

Re: [PATCH v5 1/3] videobuf2-dma-contig: user can specify GFP flags

Hi Federico,

Thanks for the patch.

Quoted 31 lines · On Thursday 10 January 2013 13:46:48 Federico Vaga wrote:

This is useful when you need to specify specific GFP flags during memory allocation (e.g. GFP_DMA).

---
 drivers/media/platform/blackfin/bfin_capture.c           | 2 +-
 drivers/media/platform/coda.c                            | 2 +-
 drivers/media/platform/davinci/vpbe_display.c            | 2 +-
 drivers/media/platform/davinci/vpif_capture.c            | 4 ++--
 drivers/media/platform/davinci/vpif_display.c            | 2 +-
 drivers/media/platform/exynos-gsc/gsc-core.c             | 2 +-
 drivers/media/platform/m2m-deinterlace.c                 | 2 +-
 drivers/media/platform/marvell-ccic/mcam-core.c          | 2 +-
 drivers/media/platform/mx2_emmaprp.c                     | 2 +-
 drivers/media/platform/s3c-camif/camif-core.c            | 2 +-
 drivers/media/platform/s5p-fimc/fimc-core.c              | 2 +-
 drivers/media/platform/s5p-fimc/fimc-lite.c              | 2 +-
 drivers/media/platform/s5p-g2d/g2d.c                     | 2 +-
 drivers/media/platform/s5p-jpeg/jpeg-core.c              | 2 +-
 drivers/media/platform/s5p-mfc/s5p_mfc.c                 | 4 ++--
 drivers/media/platform/s5p-tv/mixer_video.c              | 2 +-
 drivers/media/platform/sh_veu.c                          | 2 +-
 drivers/media/platform/soc_camera/atmel-isi.c            | 2 +-
 drivers/media/platform/soc_camera/mx2_camera.c           | 2 +-
 drivers/media/platform/soc_camera/mx3_camera.c           | 2 +-
 drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c | 2 +-
 drivers/media/v4l2-core/videobuf2-dma-contig.c           | 7 +++++--
 drivers/staging/media/davinci_vpfe/vpfe_video.c          | 2 +-
 drivers/staging/media/dt3155v4l/dt3155v4l.c              | 2 +-
 include/media/videobuf2-dma-contig.h                     | 2 +-

25 file modificati, 31 inserzioni(+), 28 rimozioni(-)

[snip]

Quoted 15 lines
(quoted diff) +0 -0

b/drivers/media/v4l2-core/videobuf2-dma-contig.c index 10beaee..00f1b85 100644

drivers/media/v4l2-core/videobuf2-dma-contig.c +1 -0
@@ -23,6 +23,7 @@
 
 struct vb2_dc_conf {
 	struct device		*dev;
+	gfp_t				mem_flags;
 };
 
 struct vb2_dc_buf {
@@ -165,7 +166,8 @@ static void *vb2_dc_alloc(void *alloc_ctx, unsigned long

size) /* align image size to PAGE_SIZE */

drivers/media/v4l2-core/videobuf2-dma-contig.c static void *vb2_dc_alloc(void *alloc_ctx, unsigned long size) · line 170

Quoted 5 lines
drivers/media/v4l2-core/videobuf2-dma-contig.c +2 -1
 	size = PAGE_ALIGN(size);
 
-	buf->vaddr = dma_alloc_coherent(dev, size, &buf->dma_addr, GFP_KERNEL);
+	buf->vaddr = dma_alloc_coherent(dev, size, &buf->dma_addr,
+									GFP_KERNEL | conf->mem_flags);

The only purpose of this patch is to pass GFP_DMA (or GFP_DMA32) to the DMA coherent allocator. Wouldn't it be easier to just set the device coherent DMA mask (dev->coherent_dma_mask) instead ? The DMA allocator should then select the appropriate GFP_DMA flags.

Quoted 20 lines
drivers/media/v4l2-core/videobuf2-dma-contig.c +2 -1
 	if (!buf->vaddr) {
 		dev_err(dev, "dma_alloc_coherent of size %ld failed\n", size);
 		kfree(buf);
@@ -751,7 +753,7 @@ const struct vb2_mem_ops vb2_dma_contig_memops = {
 };
 EXPORT_SYMBOL_GPL(vb2_dma_contig_memops);
 
-void *vb2_dma_contig_init_ctx(struct device *dev)
+void *vb2_dma_contig_init_ctx(struct device *dev, gfp_t mem_flags)
 {
 	struct vb2_dc_conf *conf;
 
@@ -760,6 +762,7 @@ void *vb2_dma_contig_init_ctx(struct device *dev)
 		return ERR_PTR(-ENOMEM);
 
 	conf->dev = dev;
+	conf->mem_flags = mem_flags;
 
 	return conf;
 }

[snip]

Quoted 13 lines
(quoted diff) +0 -0

b/include/media/videobuf2-dma-contig.h index 8197f87..8d5a5a3 100644

include/media/videobuf2-dma-contig.h +1 -1
@@ -24,7 +24,7 @@ vb2_dma_contig_plane_dma_addr(struct vb2_buffer *vb,
 unsigned int plane_no) return *addr;
 }
 
-void *vb2_dma_contig_init_ctx(struct device *dev);
+void *vb2_dma_contig_init_ctx(struct device *dev, gfp_t mem_flags);
 void vb2_dma_contig_cleanup_ctx(void *alloc_ctx);
 
 extern const struct vb2_mem_ops vb2_dma_contig_memops;
Signature · 3 lines
Regards,

Laurent Pinchart
#3 lore raw

PATCH v5 1/3 videobuf2-dma-contig: user can specify GFP flags

In reply to Federico Vaga

drivers/media/v4l2-core/videobuf2-dma-contig.c static void *vb2_dc_alloc(void *alloc_ctx, unsigned long size)

Quoted 7 lines

struct vb2_dc_buf {

(quoted diff) +0 -0
@@ -165,7 +166,8 @@ static void *vb2_dc_alloc(void *alloc_ctx, unsigned long

size) /* align image size to PAGE_SIZE */

drivers/media/v4l2-core/videobuf2-dma-contig.c +0 -1
 	size = PAGE_ALIGN(size);
 
-	buf->vaddr = dma_alloc_coherent(dev, size, &buf->dma_addr, 

GFP_KERNEL);

Review

Quoted 2 lines
(quoted diff) +2 -0
+	buf->vaddr = dma_alloc_coherent(dev, size, &buf->dma_addr,
+									

GFP_KERNEL | conf->mem_flags);

Unfortunately, I forgot to remove this from Patch v4 series. I did not see it while re-reading the first time. I'll send a new patch series (v6). It should be:

buf->vaddr = dma_alloc_coherent(dev, size, &buf->dma_addr, conf->mem_flags);

I'm terribly sorry

Signature · 1 line
Federico Vaga
#4 lore raw

PATCH v5 2/3 sta2x11_vip: convert to videobuf2 and control framework

In reply to Federico Vaga

This patch re-write the driver and use the videobuf2 interface instead of the old videobuf. Moreover, it uses also the control framework which allows the driver to inherit controls from its subdevice (ADV7180)

---
 drivers/media/pci/sta2x11/Kconfig       |    2 +-
 drivers/media/pci/sta2x11/sta2x11_vip.c | 1243 ++++++++++---------------------

2 file modificati, 415 inserzioni(+), 830 rimozioni(-)

drivers/media/pci/sta2x11/Kconfig +1 -1
index 6749f67..a94ccad 100644
@@ -2,7 +2,7 @@ config STA2X11_VIP
 	tristate "STA2X11 VIP Video For Linux"
 	depends on STA2X11
 	select VIDEO_ADV7180 if MEDIA_SUBDRV_AUTOSELECT
-	select VIDEOBUF_DMA_CONTIG
+	select VIDEOBUF2_DMA_CONTIG
 	depends on PCI && VIDEO_V4L2 && VIRT_TO_BUS
 	help
 	  Say Y for support for STA2X11 VIP (Video Input Port) capture
drivers/media/pci/sta2x11/sta2x11_vip.c +414 -829

1,668 lines not on this page · raw message

Signature · 1 line
1.7.11.7
#5 lore raw

PATCH v5 2/3 sta2x11_vip: convert to videobuf2 and control framework

@Hans: here the output of v4l2-compliance that you request me for the v4 version. This is done on the v5 version where I applied your suggestion. I have 1 warning but I don't understand where is the problem

Driver Info:

	Driver name   : sta2x11_vip
	Card type     : sta2x11_vip
	Bus info      : PCI:0000:06:00.0
	Driver version: 3.6.0
	Capabilities  : 0x85000001
		Video Capture
		Read/Write
		Streaming
		Device Capabilities
	Device Caps   : 0x05000001
		Video Capture
		Read/Write
		Streaming

Compliance test for device /dev/video0 (not using libv4l2):

Required ioctls:
test VIDIOC_QUERYCAP: OK

Allow for multiple opens:
test second video open: OK
test VIDIOC_QUERYCAP: OK
test VIDIOC_G/S_PRIORITY: OK

Debug ioctls:
test VIDIOC_DBG_G_CHIP_IDENT: Not Supported test VIDIOC_DBG_G/S_REGISTER: Not Supported test VIDIOC_LOG_STATUS: OK

Input ioctls:
test VIDIOC_G/S_TUNER: Not Supported
test VIDIOC_G/S_FREQUENCY: Not Supported
test VIDIOC_S_HW_FREQ_SEEK: OK
test VIDIOC_ENUMAUDIO: Not Supported
test VIDIOC_G/S/ENUMINPUT: OK
test VIDIOC_G/S_AUDIO: Not Supported
Inputs: 2 Audio Inputs: 0 Tuners: 0

Output ioctls:
test VIDIOC_G/S_MODULATOR: Not Supported
test VIDIOC_G/S_FREQUENCY: Not Supported
test VIDIOC_ENUMAUDOUT: Not Supported
test VIDIOC_G/S/ENUMOUTPUT: Not Supported
test VIDIOC_G/S_AUDOUT: Not Supported
Outputs: 0 Audio Outputs: 0 Modulators: 0

Control ioctls:
test VIDIOC_QUERYCTRL/MENU: OK
test VIDIOC_G/S_CTRL: OK
test VIDIOC_G/S/TRY_EXT_CTRLS: OK test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: OK test VIDIOC_G/S_JPEGCOMP: Not Supported Standard Controls: 5 Private Controls: 0

Input/Output configuration ioctls:
test VIDIOC_ENUM/G/S/QUERY_STD: OK
test VIDIOC_ENUM/G/S/QUERY_DV_PRESETS: Not Supported test VIDIOC_ENUM/G/S/QUERY_DV_TIMINGS: Not Supported test VIDIOC_DV_TIMINGS_CAP: Not Supported

Format ioctls:
test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK test VIDIOC_G/S_PARM: OK
test VIDIOC_G_FBUF: Not Supported
test VIDIOC_G_FMT: OK
test VIDIOC_TRY_FMT: OK
test VIDIOC_S_FMT: OK
test VIDIOC_G_SLICED_VBI_CAP: Not Supported

Buffer ioctls:
test VIDIOC_REQBUFS/CREATE_BUFS: OK
test read/write: OK

Total: 36, Succeeded: 36, Failed: 0, Warnings: 1

Signature · 1 line
Federico Vaga
#6 lore raw

PATCH v5 2/3 sta2x11_vip: convert to videobuf2 and control framework

Quoted 3 lines · On Thu 10 January 2013 13:57:19 Federico Vaga wrote:

@Hans: here the output of v4l2-compliance that you request me for the v4 version. This is done on the v5 version where I applied your suggestion. I have 1 warning but I don't understand where is the problem

To see the warning you need to run v4l2-compliance with the '-v1' option.

Hmm, I think I should probably change v4l2-compliance to show warnings by default and add an option that surpresses warnings. That might work better.

Regards,

Hans

Quoted 79 lines

Driver Info:

	Driver name   : sta2x11_vip
	Card type     : sta2x11_vip
	Bus info      : PCI:0000:06:00.0
	Driver version: 3.6.0
	Capabilities  : 0x85000001
		Video Capture
		Read/Write
		Streaming
		Device Capabilities
	Device Caps   : 0x05000001
		Video Capture
		Read/Write
		Streaming

Compliance test for device /dev/video0 (not using libv4l2):

Required ioctls:
test VIDIOC_QUERYCAP: OK

Allow for multiple opens:
test second video open: OK
test VIDIOC_QUERYCAP: OK
test VIDIOC_G/S_PRIORITY: OK

Debug ioctls:
test VIDIOC_DBG_G_CHIP_IDENT: Not Supported test VIDIOC_DBG_G/S_REGISTER: Not Supported test VIDIOC_LOG_STATUS: OK

Input ioctls:
test VIDIOC_G/S_TUNER: Not Supported
test VIDIOC_G/S_FREQUENCY: Not Supported
test VIDIOC_S_HW_FREQ_SEEK: OK
test VIDIOC_ENUMAUDIO: Not Supported
test VIDIOC_G/S/ENUMINPUT: OK
test VIDIOC_G/S_AUDIO: Not Supported
Inputs: 2 Audio Inputs: 0 Tuners: 0

Output ioctls:
test VIDIOC_G/S_MODULATOR: Not Supported
test VIDIOC_G/S_FREQUENCY: Not Supported
test VIDIOC_ENUMAUDOUT: Not Supported
test VIDIOC_G/S/ENUMOUTPUT: Not Supported
test VIDIOC_G/S_AUDOUT: Not Supported
Outputs: 0 Audio Outputs: 0 Modulators: 0

Control ioctls:
test VIDIOC_QUERYCTRL/MENU: OK
test VIDIOC_G/S_CTRL: OK
test VIDIOC_G/S/TRY_EXT_CTRLS: OK test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: OK test VIDIOC_G/S_JPEGCOMP: Not Supported Standard Controls: 5 Private Controls: 0

Input/Output configuration ioctls:
test VIDIOC_ENUM/G/S/QUERY_STD: OK
test VIDIOC_ENUM/G/S/QUERY_DV_PRESETS: Not Supported test VIDIOC_ENUM/G/S/QUERY_DV_TIMINGS: Not Supported test VIDIOC_DV_TIMINGS_CAP: Not Supported

Format ioctls:
test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK test VIDIOC_G/S_PARM: OK
test VIDIOC_G_FBUF: Not Supported
test VIDIOC_G_FMT: OK
test VIDIOC_TRY_FMT: OK
test VIDIOC_S_FMT: OK
test VIDIOC_G_SLICED_VBI_CAP: Not Supported

Buffer ioctls:
test VIDIOC_REQBUFS/CREATE_BUFS: OK
test read/write: OK

Total: 36, Succeeded: 36, Failed: 0, Warnings: 1

#7 lore raw

PATCH v5 2/3 sta2x11_vip: convert to videobuf2 and control framework

Quoted 4 lines

To see the warning you need to run v4l2-compliance with the '-v1' option.

Hmm, I think I should probably change v4l2-compliance to show warnings by default and add an option that surpresses warnings. That might work better.

I was expecting warning information by default

Signature · 1 line
Federico Vaga
#8 lore raw

PATCH v5 2/3 sta2x11_vip: convert to videobuf2 and control framework

In reply to Federico Vaga

This would be easier to review if it were broken up into separate patches.

1) There are superflous white spaces changes
2) Changes to the copyright
3) pr_warning => pr_warn
4) The REG_READ and REG_WRITE macros are now inline functions
5) KBUILD_MODNAME is used instead of DRV_NAME
6) It now uses the video_drvdata() function
7) Lots of comments deleted. For exmple, vidioc_enum_fmt_vid_cap() didn't change. Just the comments were deleted.
8) Comments added for existing code.
9) Other behavior changes not related to using videobuf2 like in vidioc_try_fmt_vid_cap().
10) etc...

If all the uninteresting changes are in separate patches it makes the complicated stuff much shorter and easier to review.

regards,
dan carpenter

#9 lore raw

PATCH v5 2/3 sta2x11_vip: convert to videobuf2 and control framework

Quoted 2 lines

If all the uninteresting changes are in separate patches it makes the complicated stuff much shorter and easier to review.

Thank you :) I will try to separate

Signature · 1 line
Federico Vaga
#10 lore raw

PATCH v5 3/3 adv7180: remove {query/g_/s_}ctrl

In reply to Federico Vaga

All drivers which use this subdevice use also the control framework. The v4l2_subdev_core_ops operations {query/g_/s_}ctrl are useless because device drivers will inherit controls from this subdevice.

---
 drivers/media/i2c/adv7180.c | 3 ---

1 file modificato, 3 rimozioni(-)

drivers/media/i2c/adv7180.c +0 -3
index 45ecf8d..43bc2b9 100644
@@ -402,9 +402,6 @@ static const struct v4l2_subdev_video_ops adv7180_video_ops = {
 static const struct v4l2_subdev_core_ops adv7180_core_ops = {
 	.g_chip_ident = adv7180_g_chip_ident,
 	.s_std = adv7180_s_std,
-	.queryctrl = v4l2_subdev_queryctrl,
-	.g_ctrl = v4l2_subdev_g_ctrl,
-	.s_ctrl = v4l2_subdev_s_ctrl,
 };
 
 static const struct v4l2_subdev_ops adv7180_ops = {
Signature · 1 line
1.7.11.7
#11 lore raw

PATCH v5 1/1 modify videobuf2-dma-contig and update sta2x11_vip

In reply to Federico Vaga

We have some new ideas for this new complex architecture (sta2x11) that can fix our DMA problems without change the existent code. Obviously, ideas arrive when I already sent the patches. Anyway, consider this patch series as an RFC. They are not ready for the mainline. I take some time to investigate on the architecture side of the project to try to fix our problem.

Anyway, if you consider interesting configure the gfp flags for dma-contig, I can propose a v6 series which correct the alloc coherent line.

Sorry for the spam :(

Signature · 1 line
Federico Vaga
#12 lore raw

PATCH v5 1/1 modify videobuf2-dma-contig and update sta2x11_vip

Em Thu, 10 Jan 2013 16:22:39 +0100
Federico Vaga <[email protected]> escreveu:

Quoted 10 lines

We have some new ideas for this new complex architecture (sta2x11) that can fix our DMA problems without change the existent code. Obviously, ideas arrive when I already sent the patches. Anyway, consider this patch series as an RFC. They are not ready for the mainline. I take some time to investigate on the architecture side of the project to try to fix our problem.

Anyway, if you consider interesting configure the gfp flags for dma-contig, I can propose a v6 series which correct the alloc coherent line.

Sorry for the spam :(

This is not spam, it is part of the process of maturating a patchset ;)

I'll just tag all those patches as RFC on linux-media patchwork.

Regards,
Mauro