diff options
author | Hans Verkuil <hans.verkuil@cisco.com> | 2013-03-01 13:44:20 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2013-03-21 12:17:51 -0400 |
commit | b6ba2057f7823352bbc44ee846faa03b36e8b6ac (patch) | |
tree | 130c5bafcd2e497c45d8a1e5e9e764dc88bff00c /drivers/media/v4l2-core | |
parent | 808d24d6c0b5c30c8f804b251caf476ea63954ef (diff) |
[media] videobuf2: add gfp_flags
Some drivers have special memory requirements for their buffers, usually
related to DMA (e.g. GFP_DMA or __GFP_DMA32). Make it possible to specify
additional GFP flags for those buffers by adding a gfp_flags field to
vb2_queue.
Note that this field will be replaced in the future with a different
mechanism, but that is still work in progress and we need this feature
now so we won't be able to convert drivers with such requirements to vb2.
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Acked-by: Marek Szyprowski <m.szyprowski@samsung.com>
Acked-by: Federico Vaga <federico.vaga@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/v4l2-core')
-rw-r--r-- | drivers/media/v4l2-core/videobuf2-core.c | 2 | ||||
-rw-r--r-- | drivers/media/v4l2-core/videobuf2-dma-contig.c | 5 | ||||
-rw-r--r-- | drivers/media/v4l2-core/videobuf2-dma-sg.c | 5 | ||||
-rw-r--r-- | drivers/media/v4l2-core/videobuf2-vmalloc.c | 4 |
4 files changed, 9 insertions, 7 deletions
diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c index be0448161c60..70827feb87b4 100644 --- a/drivers/media/v4l2-core/videobuf2-core.c +++ b/drivers/media/v4l2-core/videobuf2-core.c | |||
@@ -57,7 +57,7 @@ static int __vb2_buf_mem_alloc(struct vb2_buffer *vb) | |||
57 | /* Allocate memory for all planes in this buffer */ | 57 | /* Allocate memory for all planes in this buffer */ |
58 | for (plane = 0; plane < vb->num_planes; ++plane) { | 58 | for (plane = 0; plane < vb->num_planes; ++plane) { |
59 | mem_priv = call_memop(q, alloc, q->alloc_ctx[plane], | 59 | mem_priv = call_memop(q, alloc, q->alloc_ctx[plane], |
60 | q->plane_sizes[plane]); | 60 | q->plane_sizes[plane], q->gfp_flags); |
61 | if (IS_ERR_OR_NULL(mem_priv)) | 61 | if (IS_ERR_OR_NULL(mem_priv)) |
62 | goto free; | 62 | goto free; |
63 | 63 | ||
diff --git a/drivers/media/v4l2-core/videobuf2-dma-contig.c b/drivers/media/v4l2-core/videobuf2-dma-contig.c index 10beaee7f0ae..ae35d255a430 100644 --- a/drivers/media/v4l2-core/videobuf2-dma-contig.c +++ b/drivers/media/v4l2-core/videobuf2-dma-contig.c | |||
@@ -152,7 +152,7 @@ static void vb2_dc_put(void *buf_priv) | |||
152 | kfree(buf); | 152 | kfree(buf); |
153 | } | 153 | } |
154 | 154 | ||
155 | static void *vb2_dc_alloc(void *alloc_ctx, unsigned long size) | 155 | static void *vb2_dc_alloc(void *alloc_ctx, unsigned long size, gfp_t gfp_flags) |
156 | { | 156 | { |
157 | struct vb2_dc_conf *conf = alloc_ctx; | 157 | struct vb2_dc_conf *conf = alloc_ctx; |
158 | struct device *dev = conf->dev; | 158 | struct device *dev = conf->dev; |
@@ -165,7 +165,8 @@ static void *vb2_dc_alloc(void *alloc_ctx, unsigned long size) | |||
165 | /* align image size to PAGE_SIZE */ | 165 | /* align image size to PAGE_SIZE */ |
166 | size = PAGE_ALIGN(size); | 166 | size = PAGE_ALIGN(size); |
167 | 167 | ||
168 | buf->vaddr = dma_alloc_coherent(dev, size, &buf->dma_addr, GFP_KERNEL); | 168 | buf->vaddr = dma_alloc_coherent(dev, size, &buf->dma_addr, |
169 | GFP_KERNEL | gfp_flags); | ||
169 | if (!buf->vaddr) { | 170 | if (!buf->vaddr) { |
170 | dev_err(dev, "dma_alloc_coherent of size %ld failed\n", size); | 171 | dev_err(dev, "dma_alloc_coherent of size %ld failed\n", size); |
171 | kfree(buf); | 172 | kfree(buf); |
diff --git a/drivers/media/v4l2-core/videobuf2-dma-sg.c b/drivers/media/v4l2-core/videobuf2-dma-sg.c index 25c3b360e1ad..952776fafe2c 100644 --- a/drivers/media/v4l2-core/videobuf2-dma-sg.c +++ b/drivers/media/v4l2-core/videobuf2-dma-sg.c | |||
@@ -33,7 +33,7 @@ struct vb2_dma_sg_buf { | |||
33 | 33 | ||
34 | static void vb2_dma_sg_put(void *buf_priv); | 34 | static void vb2_dma_sg_put(void *buf_priv); |
35 | 35 | ||
36 | static void *vb2_dma_sg_alloc(void *alloc_ctx, unsigned long size) | 36 | static void *vb2_dma_sg_alloc(void *alloc_ctx, unsigned long size, gfp_t gfp_flags) |
37 | { | 37 | { |
38 | struct vb2_dma_sg_buf *buf; | 38 | struct vb2_dma_sg_buf *buf; |
39 | int i; | 39 | int i; |
@@ -60,7 +60,8 @@ static void *vb2_dma_sg_alloc(void *alloc_ctx, unsigned long size) | |||
60 | goto fail_pages_array_alloc; | 60 | goto fail_pages_array_alloc; |
61 | 61 | ||
62 | for (i = 0; i < buf->sg_desc.num_pages; ++i) { | 62 | for (i = 0; i < buf->sg_desc.num_pages; ++i) { |
63 | buf->pages[i] = alloc_page(GFP_KERNEL | __GFP_ZERO | __GFP_NOWARN); | 63 | buf->pages[i] = alloc_page(GFP_KERNEL | __GFP_ZERO | |
64 | __GFP_NOWARN | gfp_flags); | ||
64 | if (NULL == buf->pages[i]) | 65 | if (NULL == buf->pages[i]) |
65 | goto fail_pages_alloc; | 66 | goto fail_pages_alloc; |
66 | sg_set_page(&buf->sg_desc.sglist[i], | 67 | sg_set_page(&buf->sg_desc.sglist[i], |
diff --git a/drivers/media/v4l2-core/videobuf2-vmalloc.c b/drivers/media/v4l2-core/videobuf2-vmalloc.c index a47fd4f589a1..313d9771b2bc 100644 --- a/drivers/media/v4l2-core/videobuf2-vmalloc.c +++ b/drivers/media/v4l2-core/videobuf2-vmalloc.c | |||
@@ -35,11 +35,11 @@ struct vb2_vmalloc_buf { | |||
35 | 35 | ||
36 | static void vb2_vmalloc_put(void *buf_priv); | 36 | static void vb2_vmalloc_put(void *buf_priv); |
37 | 37 | ||
38 | static void *vb2_vmalloc_alloc(void *alloc_ctx, unsigned long size) | 38 | static void *vb2_vmalloc_alloc(void *alloc_ctx, unsigned long size, gfp_t gfp_flags) |
39 | { | 39 | { |
40 | struct vb2_vmalloc_buf *buf; | 40 | struct vb2_vmalloc_buf *buf; |
41 | 41 | ||
42 | buf = kzalloc(sizeof(*buf), GFP_KERNEL); | 42 | buf = kzalloc(sizeof(*buf), GFP_KERNEL | gfp_flags); |
43 | if (!buf) | 43 | if (!buf) |
44 | return NULL; | 44 | return NULL; |
45 | 45 | ||