Re: [REVIEWv7 PATCH 05/12] vb2-dma-sg: add allocation context to dma-sg
Hi Laurent, On 11/26/2014 09:01 PM, Laurent Pinchart wrote: Hi Hans, Thank you for the patch. On Tuesday 18 November 2014 13:51:01 Hans Verkuil wrote: From: Hans Verkuil hans.verk...@cisco.com Require that dma-sg also uses an allocation context. This is in preparation for adding prepare/finish memops to sync the memory between DMA and CPU. I think this has been raised before, but given that our allocation contexts just hold a struct device pointer, wouldn't it be simpler to just pass it explicitly when creating the queue ? Do we have use cases for using different struct device instances per plane ? No, we don't, and yes, I plan on replacing the allocation context with a simple device struct pointer. But I didn't want to mix that in with the rest of this series. You can expect a patch changing this in the near future (and that will also take care of your comment regarding the previous patch). Regards, Hans Signed-off-by: Hans Verkuil hans.verk...@cisco.com --- drivers/media/pci/cx23885/cx23885-417.c | 1 + drivers/media/pci/cx23885/cx23885-core.c| 10 +++- drivers/media/pci/cx23885/cx23885-dvb.c | 1 + drivers/media/pci/cx23885/cx23885-vbi.c | 1 + drivers/media/pci/cx23885/cx23885-video.c | 1 + drivers/media/pci/cx23885/cx23885.h | 1 + drivers/media/pci/saa7134/saa7134-core.c| 18 ++ drivers/media/pci/saa7134/saa7134-ts.c | 1 + drivers/media/pci/saa7134/saa7134-vbi.c | 1 + drivers/media/pci/saa7134/saa7134-video.c | 1 + drivers/media/pci/saa7134/saa7134.h | 1 + drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c | 10 drivers/media/pci/solo6x10/solo6x10.h | 1 + drivers/media/pci/tw68/tw68-core.c | 15 +--- drivers/media/pci/tw68/tw68-video.c | 1 + drivers/media/pci/tw68/tw68.h | 1 + drivers/media/platform/marvell-ccic/mcam-core.c | 13 +- drivers/media/platform/marvell-ccic/mcam-core.h | 1 + drivers/media/v4l2-core/videobuf2-dma-sg.c | 32 ++ include/media/videobuf2-dma-sg.h| 3 +++ 20 files changed, 104 insertions(+), 10 deletions(-) diff --git a/drivers/media/pci/cx23885/cx23885-417.c b/drivers/media/pci/cx23885/cx23885-417.c index 3948db3..d72a3ec 100644 --- a/drivers/media/pci/cx23885/cx23885-417.c +++ b/drivers/media/pci/cx23885/cx23885-417.c @@ -1148,6 +1148,7 @@ static int queue_setup(struct vb2_queue *q, const struct v4l2_format *fmt, dev-ts1.ts_packet_count = mpeglines; *num_planes = 1; sizes[0] = mpeglinesize * mpeglines; +alloc_ctxs[0] = dev-alloc_ctx; *num_buffers = mpegbufs; return 0; } diff --git a/drivers/media/pci/cx23885/cx23885-core.c b/drivers/media/pci/cx23885/cx23885-core.c index 331edda..d452b5c 100644 --- a/drivers/media/pci/cx23885/cx23885-core.c +++ b/drivers/media/pci/cx23885/cx23885-core.c @@ -1997,9 +1997,14 @@ static int cx23885_initdev(struct pci_dev *pci_dev, if (!pci_dma_supported(pci_dev, 0x)) { printk(%s/0: Oops: no 32bit PCI DMA ???\n, dev-name); err = -EIO; -goto fail_irq; +goto fail_context; } +dev-alloc_ctx = vb2_dma_sg_init_ctx(pci_dev-dev); +if (IS_ERR(dev-alloc_ctx)) { +err = PTR_ERR(dev-alloc_ctx); +goto fail_context; +} err = request_irq(pci_dev-irq, cx23885_irq, IRQF_SHARED, dev-name, dev); if (err 0) { @@ -2028,6 +2033,8 @@ static int cx23885_initdev(struct pci_dev *pci_dev, return 0; fail_irq: +vb2_dma_sg_cleanup_ctx(dev-alloc_ctx); +fail_context: cx23885_dev_unregister(dev); fail_ctrl: v4l2_ctrl_handler_free(hdl); @@ -2053,6 +2060,7 @@ static void cx23885_finidev(struct pci_dev *pci_dev) free_irq(pci_dev-irq, dev); cx23885_dev_unregister(dev); +vb2_dma_sg_cleanup_ctx(dev-alloc_ctx); v4l2_ctrl_handler_free(dev-ctrl_handler); v4l2_device_unregister(v4l2_dev); kfree(dev); diff --git a/drivers/media/pci/cx23885/cx23885-dvb.c b/drivers/media/pci/cx23885/cx23885-dvb.c index 1ed92ee..44fafba 100644 --- a/drivers/media/pci/cx23885/cx23885-dvb.c +++ b/drivers/media/pci/cx23885/cx23885-dvb.c @@ -102,6 +102,7 @@ static int queue_setup(struct vb2_queue *q, const struct v4l2_format *fmt, port-ts_packet_count = 32; *num_planes = 1; sizes[0] = port-ts_packet_size * port-ts_packet_count; +alloc_ctxs[0] = port-dev-alloc_ctx; *num_buffers = 32; return 0; } diff --git a/drivers/media/pci/cx23885/cx23885-vbi.c b/drivers/media/pci/cx23885/cx23885-vbi.c index a7c6ef8..1d339a6 100644 --- a/drivers/media/pci/cx23885/cx23885-vbi.c +++ b/drivers/media/pci/cx23885/cx23885-vbi.c @@ -132,6 +132,7 @@ static int queue_setup(struct vb2_queue *q, const struct v4l2_format *fmt, lines =
Re: [REVIEWv7 PATCH 05/12] vb2-dma-sg: add allocation context to dma-sg
Hi Hans, Thank you for the patch. On Tuesday 18 November 2014 13:51:01 Hans Verkuil wrote: From: Hans Verkuil hans.verk...@cisco.com Require that dma-sg also uses an allocation context. This is in preparation for adding prepare/finish memops to sync the memory between DMA and CPU. I think this has been raised before, but given that our allocation contexts just hold a struct device pointer, wouldn't it be simpler to just pass it explicitly when creating the queue ? Do we have use cases for using different struct device instances per plane ? Signed-off-by: Hans Verkuil hans.verk...@cisco.com --- drivers/media/pci/cx23885/cx23885-417.c | 1 + drivers/media/pci/cx23885/cx23885-core.c| 10 +++- drivers/media/pci/cx23885/cx23885-dvb.c | 1 + drivers/media/pci/cx23885/cx23885-vbi.c | 1 + drivers/media/pci/cx23885/cx23885-video.c | 1 + drivers/media/pci/cx23885/cx23885.h | 1 + drivers/media/pci/saa7134/saa7134-core.c| 18 ++ drivers/media/pci/saa7134/saa7134-ts.c | 1 + drivers/media/pci/saa7134/saa7134-vbi.c | 1 + drivers/media/pci/saa7134/saa7134-video.c | 1 + drivers/media/pci/saa7134/saa7134.h | 1 + drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c | 10 drivers/media/pci/solo6x10/solo6x10.h | 1 + drivers/media/pci/tw68/tw68-core.c | 15 +--- drivers/media/pci/tw68/tw68-video.c | 1 + drivers/media/pci/tw68/tw68.h | 1 + drivers/media/platform/marvell-ccic/mcam-core.c | 13 +- drivers/media/platform/marvell-ccic/mcam-core.h | 1 + drivers/media/v4l2-core/videobuf2-dma-sg.c | 32 ++ include/media/videobuf2-dma-sg.h| 3 +++ 20 files changed, 104 insertions(+), 10 deletions(-) diff --git a/drivers/media/pci/cx23885/cx23885-417.c b/drivers/media/pci/cx23885/cx23885-417.c index 3948db3..d72a3ec 100644 --- a/drivers/media/pci/cx23885/cx23885-417.c +++ b/drivers/media/pci/cx23885/cx23885-417.c @@ -1148,6 +1148,7 @@ static int queue_setup(struct vb2_queue *q, const struct v4l2_format *fmt, dev-ts1.ts_packet_count = mpeglines; *num_planes = 1; sizes[0] = mpeglinesize * mpeglines; + alloc_ctxs[0] = dev-alloc_ctx; *num_buffers = mpegbufs; return 0; } diff --git a/drivers/media/pci/cx23885/cx23885-core.c b/drivers/media/pci/cx23885/cx23885-core.c index 331edda..d452b5c 100644 --- a/drivers/media/pci/cx23885/cx23885-core.c +++ b/drivers/media/pci/cx23885/cx23885-core.c @@ -1997,9 +1997,14 @@ static int cx23885_initdev(struct pci_dev *pci_dev, if (!pci_dma_supported(pci_dev, 0x)) { printk(%s/0: Oops: no 32bit PCI DMA ???\n, dev-name); err = -EIO; - goto fail_irq; + goto fail_context; } + dev-alloc_ctx = vb2_dma_sg_init_ctx(pci_dev-dev); + if (IS_ERR(dev-alloc_ctx)) { + err = PTR_ERR(dev-alloc_ctx); + goto fail_context; + } err = request_irq(pci_dev-irq, cx23885_irq, IRQF_SHARED, dev-name, dev); if (err 0) { @@ -2028,6 +2033,8 @@ static int cx23885_initdev(struct pci_dev *pci_dev, return 0; fail_irq: + vb2_dma_sg_cleanup_ctx(dev-alloc_ctx); +fail_context: cx23885_dev_unregister(dev); fail_ctrl: v4l2_ctrl_handler_free(hdl); @@ -2053,6 +2060,7 @@ static void cx23885_finidev(struct pci_dev *pci_dev) free_irq(pci_dev-irq, dev); cx23885_dev_unregister(dev); + vb2_dma_sg_cleanup_ctx(dev-alloc_ctx); v4l2_ctrl_handler_free(dev-ctrl_handler); v4l2_device_unregister(v4l2_dev); kfree(dev); diff --git a/drivers/media/pci/cx23885/cx23885-dvb.c b/drivers/media/pci/cx23885/cx23885-dvb.c index 1ed92ee..44fafba 100644 --- a/drivers/media/pci/cx23885/cx23885-dvb.c +++ b/drivers/media/pci/cx23885/cx23885-dvb.c @@ -102,6 +102,7 @@ static int queue_setup(struct vb2_queue *q, const struct v4l2_format *fmt, port-ts_packet_count = 32; *num_planes = 1; sizes[0] = port-ts_packet_size * port-ts_packet_count; + alloc_ctxs[0] = port-dev-alloc_ctx; *num_buffers = 32; return 0; } diff --git a/drivers/media/pci/cx23885/cx23885-vbi.c b/drivers/media/pci/cx23885/cx23885-vbi.c index a7c6ef8..1d339a6 100644 --- a/drivers/media/pci/cx23885/cx23885-vbi.c +++ b/drivers/media/pci/cx23885/cx23885-vbi.c @@ -132,6 +132,7 @@ static int queue_setup(struct vb2_queue *q, const struct v4l2_format *fmt, lines = VBI_NTSC_LINE_COUNT; *num_planes = 1; sizes[0] = lines * VBI_LINE_LENGTH * 2; + alloc_ctxs[0] = dev-alloc_ctx; return 0; } diff --git a/drivers/media/pci/cx23885/cx23885-video.c b/drivers/media/pci/cx23885/cx23885-video.c index 091f5db..371eecf 100644 --- a/drivers/media/pci/cx23885/cx23885-video.c +++
Re: [REVIEWv7 PATCH 05/12] vb2-dma-sg: add allocation context to dma-sg
On Tue, Nov 18, 2014 at 9:51 PM, Hans Verkuil hverk...@xs4all.nl wrote: From: Hans Verkuil hans.verk...@cisco.com Require that dma-sg also uses an allocation context. This is in preparation for adding prepare/finish memops to sync the memory between DMA and CPU. Signed-off-by: Hans Verkuil hans.verk...@cisco.com Acked-by: Pawel Osciak pa...@osciak.com -- Best regards, Pawel Osciak -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[REVIEWv7 PATCH 05/12] vb2-dma-sg: add allocation context to dma-sg
From: Hans Verkuil hans.verk...@cisco.com Require that dma-sg also uses an allocation context. This is in preparation for adding prepare/finish memops to sync the memory between DMA and CPU. Signed-off-by: Hans Verkuil hans.verk...@cisco.com --- drivers/media/pci/cx23885/cx23885-417.c | 1 + drivers/media/pci/cx23885/cx23885-core.c| 10 +++- drivers/media/pci/cx23885/cx23885-dvb.c | 1 + drivers/media/pci/cx23885/cx23885-vbi.c | 1 + drivers/media/pci/cx23885/cx23885-video.c | 1 + drivers/media/pci/cx23885/cx23885.h | 1 + drivers/media/pci/saa7134/saa7134-core.c| 18 ++ drivers/media/pci/saa7134/saa7134-ts.c | 1 + drivers/media/pci/saa7134/saa7134-vbi.c | 1 + drivers/media/pci/saa7134/saa7134-video.c | 1 + drivers/media/pci/saa7134/saa7134.h | 1 + drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c | 10 drivers/media/pci/solo6x10/solo6x10.h | 1 + drivers/media/pci/tw68/tw68-core.c | 15 +--- drivers/media/pci/tw68/tw68-video.c | 1 + drivers/media/pci/tw68/tw68.h | 1 + drivers/media/platform/marvell-ccic/mcam-core.c | 13 +- drivers/media/platform/marvell-ccic/mcam-core.h | 1 + drivers/media/v4l2-core/videobuf2-dma-sg.c | 32 + include/media/videobuf2-dma-sg.h| 3 +++ 20 files changed, 104 insertions(+), 10 deletions(-) diff --git a/drivers/media/pci/cx23885/cx23885-417.c b/drivers/media/pci/cx23885/cx23885-417.c index 3948db3..d72a3ec 100644 --- a/drivers/media/pci/cx23885/cx23885-417.c +++ b/drivers/media/pci/cx23885/cx23885-417.c @@ -1148,6 +1148,7 @@ static int queue_setup(struct vb2_queue *q, const struct v4l2_format *fmt, dev-ts1.ts_packet_count = mpeglines; *num_planes = 1; sizes[0] = mpeglinesize * mpeglines; + alloc_ctxs[0] = dev-alloc_ctx; *num_buffers = mpegbufs; return 0; } diff --git a/drivers/media/pci/cx23885/cx23885-core.c b/drivers/media/pci/cx23885/cx23885-core.c index 331edda..d452b5c 100644 --- a/drivers/media/pci/cx23885/cx23885-core.c +++ b/drivers/media/pci/cx23885/cx23885-core.c @@ -1997,9 +1997,14 @@ static int cx23885_initdev(struct pci_dev *pci_dev, if (!pci_dma_supported(pci_dev, 0x)) { printk(%s/0: Oops: no 32bit PCI DMA ???\n, dev-name); err = -EIO; - goto fail_irq; + goto fail_context; } + dev-alloc_ctx = vb2_dma_sg_init_ctx(pci_dev-dev); + if (IS_ERR(dev-alloc_ctx)) { + err = PTR_ERR(dev-alloc_ctx); + goto fail_context; + } err = request_irq(pci_dev-irq, cx23885_irq, IRQF_SHARED, dev-name, dev); if (err 0) { @@ -2028,6 +2033,8 @@ static int cx23885_initdev(struct pci_dev *pci_dev, return 0; fail_irq: + vb2_dma_sg_cleanup_ctx(dev-alloc_ctx); +fail_context: cx23885_dev_unregister(dev); fail_ctrl: v4l2_ctrl_handler_free(hdl); @@ -2053,6 +2060,7 @@ static void cx23885_finidev(struct pci_dev *pci_dev) free_irq(pci_dev-irq, dev); cx23885_dev_unregister(dev); + vb2_dma_sg_cleanup_ctx(dev-alloc_ctx); v4l2_ctrl_handler_free(dev-ctrl_handler); v4l2_device_unregister(v4l2_dev); kfree(dev); diff --git a/drivers/media/pci/cx23885/cx23885-dvb.c b/drivers/media/pci/cx23885/cx23885-dvb.c index 1ed92ee..44fafba 100644 --- a/drivers/media/pci/cx23885/cx23885-dvb.c +++ b/drivers/media/pci/cx23885/cx23885-dvb.c @@ -102,6 +102,7 @@ static int queue_setup(struct vb2_queue *q, const struct v4l2_format *fmt, port-ts_packet_count = 32; *num_planes = 1; sizes[0] = port-ts_packet_size * port-ts_packet_count; + alloc_ctxs[0] = port-dev-alloc_ctx; *num_buffers = 32; return 0; } diff --git a/drivers/media/pci/cx23885/cx23885-vbi.c b/drivers/media/pci/cx23885/cx23885-vbi.c index a7c6ef8..1d339a6 100644 --- a/drivers/media/pci/cx23885/cx23885-vbi.c +++ b/drivers/media/pci/cx23885/cx23885-vbi.c @@ -132,6 +132,7 @@ static int queue_setup(struct vb2_queue *q, const struct v4l2_format *fmt, lines = VBI_NTSC_LINE_COUNT; *num_planes = 1; sizes[0] = lines * VBI_LINE_LENGTH * 2; + alloc_ctxs[0] = dev-alloc_ctx; return 0; } diff --git a/drivers/media/pci/cx23885/cx23885-video.c b/drivers/media/pci/cx23885/cx23885-video.c index 091f5db..371eecf 100644 --- a/drivers/media/pci/cx23885/cx23885-video.c +++ b/drivers/media/pci/cx23885/cx23885-video.c @@ -323,6 +323,7 @@ static int queue_setup(struct vb2_queue *q, const struct v4l2_format *fmt, *num_planes = 1; sizes[0] = (dev-fmt-depth * dev-width * dev-height) 3; + alloc_ctxs[0] = dev-alloc_ctx; return 0; } diff --git a/drivers/media/pci/cx23885/cx23885.h