__alloc_contig_migrate_range() should use all possible ways to get all the
pages migrated from the given memory range, so pruning per-cpu lru lists
for all CPUs is required, regadless the cost of such operation. Otherwise
some pages which got stuck at per-cpu lru list might get missed by
migration procedure causing the contiguous allocation to fail.
Reported-by: SeongHwan Yoon <sunghwan.yun(a)samsung.com>
Signed-off-by: Marek Szyprowski <m.szyprowski(a)samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park(a)samsung.com>
---
mm/page_alloc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 1bfe2b0..fcb9719 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -5677,7 +5677,7 @@ static int __alloc_contig_migrate_range(struct compact_control *cc,
unsigned int tries = 0;
int ret = 0;
- migrate_prep_local();
+ migrate_prep();
while (pfn < end || !list_empty(&cc->migratepages)) {
if (fatal_signal_pending(current)) {
--
1.7.9.5
Hello everyone,
This patchset adds support for DMABUF [2] importing and exporting to V4L2
stack.
v10:
- rebase on media-next 3.7
- typos and style fixes in Documentation (from Hans Verkuil)
- fix compilation error with __fill_vb2_buffer
- fix uninitialized data_offset for single-planar queue
- support for DMABUF importing in S5P-FIMC mem-to-mem interface
- update layout of v4l2_exportbuffer structure
- update ioctl flags in v4l2_ioctls for VIDIOC_EXPBUF
- support for DMABUF exporting in m2m framework
- allow exporting for file handles that calle REQBUBS/CREATE_BUF
- simplify handling of get_device in vb2_dc_alloc
- reduce pr_err to pr_debug while checking alignment of userptr
- check size of userptr buffer against zero
- align size to PAGE_SIZE at allocation of dma-contig buffer
v9:
- rebase on 3.6
- change type for fs to __s32
- add support for vb2_ioctl_expbuf
- remove patch 'v4l: vb2: add support for DMA_ATTR_NO_KERNEL_MAPPING',
it will be posted as a separate patch
- fix typos and style in Documentation (from Hans Verkuil)
- only vb2-core and vb2-dma-contig selects DMA_SHARED_BUFFER in Kconfig
- use data_offset and length while queueing DMABUF
- return the most recently used fd at VIDIOC_DQBUF
- use (buffer-type, index, plane) tuple instead of mem_offset
to identify a for exporting (from Hans Verkuil)
- support for DMABUF mmap in vb2-dma-contig (from Laurent Pinchart)
- add testing alignment of vaddr and size while verifying userptr
against DMA capabilities (from Laurent Pinchart)
- substitute VM_DONTDUMP with VM_RESERVED
- simplify error handling in vb2_dc_get_dmabuf (from Laurent Pinchart)
v8:
- rebased on 3.6-rc1
- merged importer and exporter patchsets
- fixed missing fields in v4l2_plane32 and v4l2_buffer32 structs
- fixed typos/style in documentation
- significant reduction of warnings from checkpatch.pl
- fixed STREAMOFF issues reported by Dima Zavin [4] by adding
__vb2_dqbuf helper to vb2-core
- DC fails if userptr is not correctly aligned
- add support for DMA attributes in DC
- add support for buffers with no kernel mapping
- add reference counting on device from allocator context
- dummy support for mmap
- use dma_get_sgtable, drop vb2_dc_kaddr_to_pages hack and
vb2_dc_get_base_sgt helper
v7:
- support for V4L2_MEMORY_DMABUF in v4l2-compact-ioctl32.c
- cosmetic fixes to the documentation
- added importing for vmalloc because vmap support in dmabuf for 3.5
was pull-requested
- support for dmabuf importing for VIVI
- resurrect allocation of dma-contig context
- remove reference of alloc_ctx in dma-contig buffer
- use sg_alloc_table_from_pages
- fix DMA scatterlist calls to use orig_nents instead of nents
- fix memleak in vb2_dc_sgt_foreach_page (use orig_nents instead of nents)
v6:
- fixed missing entry in v4l2_memory_names
- fixed a bug occuring after get_user_pages failure
- fixed a bug caused by using invalid vma for get_user_pages
- prepare/finish no longer call dma_sync for dmabuf buffers
v5:
- removed change of importer/exporter behaviour
- fixes vb2_dc_pages_to_sgt basing on Laurent's hints
- changed pin/unpin words to lock/unlock in Doc
v4:
- rebased on mainline 3.4-rc2
- included missing importing support for s5p-fimc and s5p-tv
- added patch for changing map/unmap for importers
- fixes to Documentation part
- coding style fixes
- pairing {map/unmap}_dmabuf in vb2-core
- fixing variable types and semantic of arguments in videobufb2-dma-contig.c
v3:
- rebased on mainline 3.4-rc1
- split 'code refactor' patch to multiple smaller patches
- squashed fixes to Sumit's patches
- patchset is no longer dependant on 'DMA mapping redesign'
- separated path for handling IO and non-IO mappings
- add documentation for DMABUF importing to V4L
- removed all DMABUF exporter related code
- removed usage of dma_get_pages extension
v2:
- extended VIDIOC_EXPBUF argument from integer memoffset to struct
v4l2_exportbuffer
- added patch that breaks DMABUF spec on (un)map_atachment callcacks but allows
to work with existing implementation of DMABUF prime in DRM
- all dma-contig code refactoring patches were squashed
- bugfixes
v1: List of changes since [1].
- support for DMA api extension dma_get_pages, the function is used to retrieve
pages used to create DMA mapping.
- small fixes/code cleanup to videobuf2
- added prepare and finish callbacks to vb2 allocators, it is used keep
consistency between dma-cpu acess to the memory (by Marek Szyprowski)
- support for exporting of DMABUF buffer in V4L2 and Videobuf2, originated from
[3].
- support for dma-buf exporting in vb2-dma-contig allocator
- support for DMABUF for s5p-tv and s5p-fimc (capture interface) drivers,
originated from [3]
- changed handling for userptr buffers (by Marek Szyprowski, Andrzej
Pietrasiewicz)
- let mmap method to use dma_mmap_writecombine call (by Marek Szyprowski)
[1] http://thread.gmane.org/gmane.linux.drivers.video-input-infrastructure/4296…
[2] https://lkml.org/lkml/2011/12/26/29
[3] http://thread.gmane.org/gmane.linux.kernel.cross-arch/12819
[4] http://article.gmane.org/gmane.linux.drivers.video-input-infrastructure/497…
Laurent Pinchart (2):
v4l: vb2-dma-contig: shorten vb2_dma_contig prefix to vb2_dc
v4l: vb2-dma-contig: reorder functions
Marek Szyprowski (4):
v4l: vb2: add prepare/finish callbacks to allocators
v4l: vb2-dma-contig: add prepare/finish to dma-contig allocator
v4l: vb2-dma-contig: let mmap method to use dma_mmap_coherent call
v4l: vb2-dma-contig: fail if user ptr buffer is not correctly aligned
Sumit Semwal (4):
v4l: Add DMABUF as a memory type
v4l: vb2: add support for shared buffer (dma_buf)
v4l: vb: remove warnings about MEMORY_DMABUF
v4l: vb2-dma-contig: add support for dma_buf importing
Tomasz Stanislawski (16):
Documentation: media: description of DMABUF importing in V4L2
v4l: vb2-dma-contig: remove reference of alloc_ctx from a buffer
v4l: vb2-dma-contig: add support for scatterlist in userptr mode
v4l: vb2-vmalloc: add support for dmabuf importing
v4l: vivi: support for dmabuf importing
v4l: s5p-tv: mixer: support for dmabuf importing
v4l: s5p-fimc: support for dmabuf importing
Documentation: media: description of DMABUF exporting in V4L2
v4l: add buffer exporting via dmabuf
v4l: vb2: add buffer exporting via dmabuf
v4l: vb2-dma-contig: add support for DMABUF exporting
v4l: vb2-dma-contig: add reference counting for a device from
allocator context
v4l: vb2-dma-contig: align buffer size to PAGE_SIZE
v4l: s5p-fimc: support for dmabuf exporting
v4l: s5p-tv: mixer: support for dmabuf exporting
v4l: s5p-mfc: support for dmabuf exporting
Documentation/DocBook/media/v4l/compat.xml | 7 +
Documentation/DocBook/media/v4l/io.xml | 184 ++++-
Documentation/DocBook/media/v4l/v4l2.xml | 1 +
.../DocBook/media/v4l/vidioc-create-bufs.xml | 16 +-
Documentation/DocBook/media/v4l/vidioc-expbuf.xml | 212 ++++++
Documentation/DocBook/media/v4l/vidioc-qbuf.xml | 17 +
Documentation/DocBook/media/v4l/vidioc-reqbufs.xml | 47 +-
drivers/media/platform/s5p-fimc/fimc-capture.c | 11 +-
drivers/media/platform/s5p-fimc/fimc-m2m.c | 14 +-
drivers/media/platform/s5p-mfc/s5p_mfc_dec.c | 14 +
drivers/media/platform/s5p-mfc/s5p_mfc_enc.c | 14 +
drivers/media/platform/s5p-tv/mixer_video.c | 12 +-
drivers/media/platform/vivi.c | 2 +-
drivers/media/v4l2-core/Kconfig | 3 +
drivers/media/v4l2-core/v4l2-compat-ioctl32.c | 19 +
drivers/media/v4l2-core/v4l2-dev.c | 1 +
drivers/media/v4l2-core/v4l2-ioctl.c | 11 +
drivers/media/v4l2-core/v4l2-mem2mem.c | 13 +
drivers/media/v4l2-core/videobuf-core.c | 4 +
drivers/media/v4l2-core/videobuf2-core.c | 300 ++++++++-
drivers/media/v4l2-core/videobuf2-dma-contig.c | 702 ++++++++++++++++++--
drivers/media/v4l2-core/videobuf2-memops.c | 40 --
drivers/media/v4l2-core/videobuf2-vmalloc.c | 56 ++
include/linux/videodev2.h | 35 +
include/media/v4l2-ioctl.h | 2 +
include/media/v4l2-mem2mem.h | 3 +
include/media/videobuf2-core.h | 38 ++
include/media/videobuf2-memops.h | 5 -
28 files changed, 1645 insertions(+), 138 deletions(-)
create mode 100644 Documentation/DocBook/media/v4l/vidioc-expbuf.xml
--
1.7.9.5
Is it possible to use the devices generated from device tree for use
with CMA? The API for reserving a CMA region (dma_declare_contiguous)
requires a device pointer to properly associate a region with a device.
By the time the devices from devicetree are actually available
(generally during machine_init), dma_contiguous_remap has already been
called so it's too late to have a properly setup region.
I currently see several options:
1) All CMA devices must be statically declared in the board file
2) Scan the FDT to set up 'dummy' devices early which can later be used
to set up CMA with the 'proper' devices
3) My assumption is completely wrong and the check that I was using is
invalid:
diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
index 8404601..6d37516 100644
--- a/arch/arm/mm/dma-mapping.c
+++ b/arch/arm/mm/dma-mapping.c
@@ -368,9 +368,11 @@ struct dma_contig_early_reserve {
static struct dma_contig_early_reserve dma_mmu_remap[MAX_CMA_AREAS]
__initdata;
static int dma_mmu_remap_num __initdata;
+static int is_remapped;
void __init dma_contiguous_early_fixup(phys_addr_t base, unsigned long
size)
{
+ BUG_ON(is_remapped);
dma_mmu_remap[dma_mmu_remap_num].base = base;
dma_mmu_remap[dma_mmu_remap_num].size = size;
dma_mmu_remap_num++;
@@ -404,6 +406,7 @@ void __init dma_contiguous_remap(void)
iotable_init(&map, 1);
}
+ is_remapped = 1;
}
static void *
I'm currently leaning towards setting up #2 unless I'm missing something
obvious here. Thanks.
Laura
--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
hosted by The Linux Foundation
Hi Linus,
I would like to ask for pulling an urgent fix for ARM DMA-mapping
framework for v3.7-rc3. Due to my mistake, my previous pull request
(merged as cff7b8ba60e332377568c3d55c8036e9b1de32e6) contained a patch
which is aimed for v3.8 and lacks its dependences. This pull request
reverts it and fixes build break of ARM architecture.
Thanks!
Best regards
Marek Szyprowski
Samsung Poland R&D Center
----------------------------------------------------------------
The following changes since commit 2ab3f29dddfb444c9fcc0a2f3a56ed4bdba41969:
Merge branch 'akpm' (Andrew's fixes) (2012-10-25 16:05:57 -0700)
are available in the git repository at:
git://git.linaro.org/people/mszyprowski/linux-dma-mapping.git fixes_for_linus
for you to fetch changes up to 697575896670ba9e76760ce8bbc1f5a3001967d6:
Revert "ARM: dma-mapping: support debug_dma_mapping_error" (2012-10-26 07:39:13 +0200)
----------------------------------------------------------------
Marek Szyprowski (1):
Revert "ARM: dma-mapping: support debug_dma_mapping_error"
arch/arm/include/asm/dma-mapping.h | 1 -
1 file changed, 1 deletion(-)
Hi Linus,
I would like to ask for pulling some minor fixes for both CMA
(Contiguous Memory Allocator) and DMA-mapping framework for v3.7-rc3.
----------------------------------------------------------------
The following changes since commit 6f0c0580b70c89094b3422ba81118c7b959c7556:
Linux 3.7-rc2 (2012-10-20 12:11:32 -0700)
are available in the git repository at:
git://git.linaro.org/people/mszyprowski/linux-dma-mapping.git fixes_for_linus
for you to fetch changes up to 4e85fb831aa210fd1c5e2cb7909ac203c1f5b67f:
ARM: mm: Remove unused arm_vmregion priv field (2012-10-24 07:38:15 +0200)
----------------------------------------------------------------
This pull request consists mainly of a set of one-liner fixes and
cleanups for a few minor issues identified in both Contiguous Memory
Allocator code and ARM DMA-mapping subsystem.
Thanks!
Best regards
Marek Szyprowski
Samsung Poland R&D Center
----------------------------------------------------------------
Patch summary:
Bob Liu (1):
mm: cma: alloc_contig_range: return early for err path
Jingoo Han (1):
ARM: dma-mapping: fix build warning in __dma_alloc()
Laurent Pinchart (4):
drivers: dma-contiguous: Don't redefine SZ_1M
drivers: dma-coherent: Fix typo in dma_mmap_from_coherent documentation
drivers: cma: Fix wrong CMA selected region size default value
ARM: mm: Remove unused arm_vmregion priv field
Ming Lei (1):
ARM: dma-mapping: support debug_dma_mapping_error
arch/arm/include/asm/dma-mapping.h | 1 +
arch/arm/mm/dma-mapping.c | 2 +-
arch/arm/mm/vmregion.h | 1 -
drivers/base/Kconfig | 2 +-
drivers/base/dma-coherent.c | 5 ++---
drivers/base/dma-contiguous.c | 5 +----
mm/page_alloc.c | 2 +-
7 files changed, 7 insertions(+), 11 deletions(-)
Hello,
Some devices, which have IOMMU, for some use cases might require to
allocate a buffers for DMA which is contiguous in physical memory. Such
use cases appears for example in DRM subsystem when one wants to improve
performance or use secure buffer protection.
I would like to ask if adding a new attribute, as proposed in this RFC
is a good idea? I feel that it might be an attribute just for a single
driver, but I would like to know your opinion. Should we look for other
solution?
Best regards
--
Marek Szyprowski
Samsung Poland R&D Center
Marek Szyprowski (2):
common: DMA-mapping: add DMA_ATTR_FORCE_CONTIGUOUS attribute
ARM: dma-mapping: add support for DMA_ATTR_FORCE_CONTIGUOUS attribute
Documentation/DMA-attributes.txt | 9 +++++++++
arch/arm/mm/dma-mapping.c | 41 ++++++++++++++++++++++++++++++--------
include/linux/dma-attrs.h | 1 +
3 files changed, 43 insertions(+), 8 deletions(-)
--
1.7.9.5
Hello everyone,
This mail contains an application to test DMABUF support
in V4L2 for VIVI and S5P-FIMC drivers. The application was
tested on linux-media for 3.7 with applied patchset
"[PATCHv10 */26] Integration of videobuf2 with DMABUF"
on Universal C210 board.
Compilation:
1. Fetch media-next, apply patchset [PATCHv10 */26] Integration of videobuf2 with DMABUF
2. Execute 'make headers_install' in kernel source
3. arm-linux-gnueabi-gcc v4l-dbuf.c -o v4l-dbuf -O2 -std=gnu99 -I kernel/usr/include/
This app creates a simple pipeline between VIVI and two FIMC instances.
The scenario goes as follows:
1. FIMC0 creates an MMAP buffer at its OUTPUT queue. (testing vb2_dc_alloc)
2. The buffer from 1. is exported using VIDIOC_EXPBUF. (testing exporting in vb2-dma-config)
3. The DMABUF from 2. is imported to VIVI at CAPTURE queue. (testing importing in vb2-vmalloc)
4. Single frame is grabbed from VIVI into the DMABUF. (testing vb2_dc_dmabuf_ops_vmap)
5. FIMC1 creates an MMAP buffer at its OUTPUT queue. (testing vb2_dc_alloc)
6. he buffer from 5. is exported using VIDIOC_EXPBUF. (testing exporting in vb2-dma-config)
7. The DMABUF from 6. is imported by FIMC0 at CAPTURE queue. (testing importing in vb2-dma-contig)
8. FIMC0 is used to process a frame (format conversion/scaling/rotation).
9. USERPTR is created from an anonymous or file mapping.
10. The USERPTR from 9. is passed to FIMC1 at CAPTURE queue. (testing vb2_dc_get_userptr)
11. FIMC1 is used to process a frame (format conversion/scaling/rotation).
In the result, the USERPTR contains a frame from VIVI processed by
two FIMCs. The app should produce 'Test passed' text on finish.
The command line options allow to control the stages of the process
-v path path to vivi [default /dev/video0]
-f path path to fimc0 [default /dev/video1]
-F path path to fimc1 [default /dev/video3]
-0 4cc@WxH format between VIVI and FIMC0
-1 4cc@WxH format between FIMC0 and FIMC1
-2 4cc@WxH format between FIMC1 and destination
-V vertical flip on FIMC0
-H horizontal flip on FIMC0
-R angle rotation by angle [default 0] on FIMC0
-m size[@file[+offset]] destination mapping,
size 0 is adjusted automatically,
no file indicate anonymous mapping
-h print this help
For example:
v4l-dbuf -0 RGBP@320x200 -H -R 90 -1 RGB4@96x96 -2 YUYV@32x32 -m 0@/dev/fb0
does:
- grab frame from VIVI 320x200 in RGBP (RGB565) format
- convert this frame to 96x96 RGB4 (RGB32) format using FIMC0,
apply horizontal flip and 90 degree rotation
- convert result frame to 32x32 YUYV format using FIMC1
- store result in a framebuffer at /dev/fb0
Please, notice if destination file is missing, then anonymous mapping
is used. On platforms that support no SYSMMU for FIMC it is very likely
that VIDIOC_QBUF will fail if the size of the result image is larger
than a single page.
Please use -v, -f, -F options to setup proper paths to VIVI, FIMC0-M2M,
and FIMC1-M2M nodes.
At each stage the result frames are dumped in PPM format (Netpbm format).
Currently, dumping is supported only for RGB565, RGB32 and YUYV formats.
The app is not aborted if a format is not supported.
Please let us know if you have any further questions.
Regards,
Tomasz Stanislawski