v4l: videobuf2: Add DMA pool allocator
Subsystems (3)
cover v4l: videobuf2: Add DMA pool allocator
Hello!
The DMA pool allocator allocates a memory using dma_alloc_coherent(), creates a pool using generic allocator in the initialization. For every allocation requests, the allocator returns a part of its memory pool using generic allocator instead of new memory allocation.
This allocator used for devices have below limitations.
- the start address should be aligned
- the range of memory access limited to the offset from the start address (= the allocation address should be existed in a constant offset from the start address)
- the allocation address should be aligned
I would be grateful for your comments.
This patch series contains:
[PATCH 1/1] v4l: videobuf2: Add DMA pool allocator
Best regards,
Jeongtae Park
Patch summary:
Jeongtae Park (1):
v4l: videobuf2: Add DMA pool allocator
drivers/media/video/Kconfig | 7 + drivers/media/video/Makefile | 1 + drivers/media/video/videobuf2-dma-pool.c | 310 ++++++++++++++++++++++++++++++ include/media/videobuf2-dma-pool.h | 37 ++++ 4 files changed, 355 insertions(+), 0 deletions(-) create mode 100644 drivers/media/video/videobuf2-dma-pool.c create mode 100644 include/media/videobuf2-dma-pool.h
PATCH 1/1 v4l: videobuf2: Add DMA pool allocator
Add an implementation of DMA pool memory allocator and handling routines for videobuf2. The DMA pool allocator allocates a memory using dma_alloc_coherent(), creates a pool using generic allocator in the initialization. For every allocation requests, the allocator returns a part of its memory pool using generic allocator instead of new memory allocation.
This allocator used for devices have below limitations.
- the start address should be aligned
- the range of memory access limited to the offset from the start address (= the allocation address should be existed in a constant offset from the start address)
- the allocation address should be aligned
---
This allocator used for s5p-mfc. s5p-mfc has above limitations. The CMA and CMA allocator for videobuf2 can be resolve all of described limitations, but the CMA merge schedule is not fixed yet. Therefore CMA allocator for videobuf2 also cannot be used in the driver currently. The s5p-mfc v4l2 driver can be validated with the DMA pool allocator without CMA dependency.
drivers/media/video/Kconfig | 7 + drivers/media/video/Makefile | 1 + drivers/media/video/videobuf2-dma-pool.c | 310 ++++++++++++++++++++++++++++++ include/media/videobuf2-dma-pool.h | 37 ++++ 4 files changed, 355 insertions(+), 0 deletions(-) create mode 100644 drivers/media/video/videobuf2-dma-pool.c create mode 100644 include/media/videobuf2-dma-pool.h
drivers/media/video/Kconfig +7 -0
@@ -71,6 +71,13 @@ config VIDEOBUF2_DMA_SG select VIDEOBUF2_CORE select VIDEOBUF2_MEMOPS tristate + +config VIDEOBUF2_DMA_POOL + select VIDEOBUF2_CORE + select VIDEOBUF2_MEMOPS + select GENERIC_ALLOCATOR + tristate + # # Multimedia Video device configuration #
drivers/media/video/Makefile +1 -0
@@ -120,6 +120,7 @@ obj-$(CONFIG_VIDEOBUF2_MEMOPS) += videobuf2-memops.o obj-$(CONFIG_VIDEOBUF2_VMALLOC) += videobuf2-vmalloc.o obj-$(CONFIG_VIDEOBUF2_DMA_CONTIG) += videobuf2-dma-contig.o obj-$(CONFIG_VIDEOBUF2_DMA_SG) += videobuf2-dma-sg.o +obj-$(CONFIG_VIDEOBUF2_DMA_POOL) += videobuf2-dma-pool.o obj-$(CONFIG_V4L2_MEM2MEM_DEV) += v4l2-mem2mem.o
drivers/media/video/videobuf2-dma-pool.c new file +310 -0
310 lines not on this page · raw message
include/media/videobuf2-dma-pool.h new file +37 -0
@@ -0,0 +1,37 @@ +/* +* videobuf2-dma-pool.h - DMA pool memory allocator for videobuf2 +* +* Copyright (c) 2010 Samsung Electronics Co., Ltd. +* http://www.samsung.com/ +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +*/ + +#ifndef _MEDIA_VIDEOBUF2_DMA_POOL_H +#define _MEDIA_VIDEOBUF2_DMA_POOL_H + +#include <media/videobuf2-core.h> + +static inline unsigned long vb2_dma_pool_plane_paddr (struct vb2_buffer *vb, +unsigned int plane_no) +{ +return (unsigned long )vb2_plane_cookie (vb, plane_no); +} + +void *vb2_dma_pool_init (struct device *dev,unsigned long base_order, +unsigned long alloc_order,unsigned long size); +void vb2_dma_pool_cleanup (struct vb2_alloc_ctx *alloc_ctx); + +void **vb2_dma_pool_init_multi (struct device *dev,unsigned int num_planes, +unsigned long base_orders[], +unsigned long alloc_orders[], +unsigned long sizes[]); +void vb2_dma_pool_cleanup_multi (void **alloc_ctxes, +unsigned int num_planes); + +extern const struct vb2_mem_ops vb2_dma_pool_memops; + +#endif /* _MEDIA_VIDEOBUF2_DMA_POOL_H */
Signature · 1 line
1.6.2.5
Marek Szyprowski
maintainerHello,
Quoted 26 lines · Jeongtae Park
The DMA pool allocator allocates a memory using
dma_alloc_coherent(), creates a pool using generic allocator in the initialization. For every allocation requests, the allocator returns a part of its memory pool using generic allocator instead of new memory allocation.This allocator used for devices have below limitations.
- the start address should be aligned
- the range of memory access limited to the offset from the start address (= the allocation address should be existed in a constant offset from the start address)
- the allocation address should be alignedI would be grateful for your comments.
This patch series contains:
[PATCH 1/1] v4l: videobuf2: Add DMA pool allocator
Best regards,
Jeongtae ParkPatch summary:
Jeongtae Park (1):
v4l: videobuf2: Add DMA pool allocator
Quoted 7 lines
drivers/media/video/Kconfig | 7 + drivers/media/video/Makefile | 1 + drivers/media/video/videobuf2-dma-pool.c | 310 ++++++++++++++++++++++++++++++ include/media/videobuf2-dma-pool.h | 37 ++++ 4 files changed, 355 insertions(+), 0 deletions(-) create mode 100644 drivers/media/video/videobuf2-dma-pool.c create mode 100644 include/media/videobuf2-dma-pool.h
The code looks nice but I have one suggestion. This dma-pool memory allocator make sense only for a s5p-mfc driver. All other drivers can use dma-contig vb2 allocator directly. For this reason I suggest to move this allocator directly to drivers/media/video/s5p-mfc/ directory.
Best regards
--
Marek Szyprowski
Samsung Poland R&D Center
Hi,
Quoted 43 lines
-----Original Message-----
From: [email protected] [mailto:linux-media- [email protected]] On Behalf Of Marek Szyprowski
Sent: Tuesday, January 18, 2011 12:48 AM
To: 'Jeongtae Park'; [email protected]; linux-samsung- [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]
Subject: RE: [PATCH 0/1] v4l: videobuf2: Add DMA pool allocatorHello,
Quoted 21 lines · Jeongtae Park
The DMA pool allocator allocates a memory using
dma_alloc_coherent(), creates a pool using generic allocator in the initialization. For every allocation requests, the allocator returns a part of its memory pool using generic allocator instead of new memory allocation.This allocator used for devices have below limitations.
- the start address should be aligned
- the range of memory access limited to the offset from the start address (= the allocation address should be existed in a constant offset from the start address)
- the allocation address should be alignedI would be grateful for your comments.
This patch series contains:
[PATCH 1/1] v4l: videobuf2: Add DMA pool allocator
Best regards,
Jeongtae ParkQuoted 8 lines
Patch summary:
Jeongtae Park (1):
v4l: videobuf2: Add DMA pool allocatordrivers/media/video/Kconfig | 7 + drivers/media/video/Makefile | 1 + drivers/media/video/videobuf2-dma-pool.c | 310
Quoted 7 lines
++++++++++++++++++++++++++++++
Quoted 4 lines
include/media/videobuf2-dma-pool.h | 37 ++++ 4 files changed, 355 insertions(+), 0 deletions(-) create mode 100644 drivers/media/video/videobuf2-dma-pool.c create mode 100644 include/media/videobuf2-dma-pool.hThe code looks nice but I have one suggestion. This dma-pool memory
allocator
Quoted 3 lines
make sense only for a s5p-mfc driver. All other drivers can use dma-contig vb2
allocator directly. For this reason I suggest to move this allocator
directly
Quoted 2 lines
to
drivers/media/video/s5p-mfc/directory.
Is it not possible that there is the device with above limitations or constraints?
If it's possible, the dma-pool allocator can be useful, but currently this allocator
is useful only for a s5p-mfc.
But, all other allocators of vb2 framework are drivers/media/video/ directory.
I'm not sure which position is right for dma-pool allocator.
Thanks for your comment.
Quoted 9 lines
Best regards
--
Marek Szyprowski
Samsung Poland R&D Center--
To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Best regards