aboutsummaryrefslogtreecommitdiff
path: root/mm/cma.c
AgeCommit message (Collapse)AuthorFilesLines
2014-10-27mm: cma: Always consider a 0 base address reservation as dynamicLaurent Pinchart1-1/+4
The fixed parameter to cma_declare_contiguous() tells the function whether the given base address must be honoured or should be considered as a hint only. The API considers a zero base address as meaning any base address, which must never be considered as a fixed value. Part of the implementation correctly checks both fixed and base != 0, but two locations check the fixed value only. Set fixed to false when base is 0 to fix that and simplify the code. Signed-off-by: Laurent Pinchart <[email protected]> Acked-by: Michal Nazarewicz <[email protected]> Signed-off-by: Marek Szyprowski <[email protected]>
2014-10-27mm: cma: Don't crash on allocation if CMA area can't be activatedLaurent Pinchart1-0/+1
If activation of the CMA area fails its mutex won't be initialized, leading to an oops at allocation time when trying to lock the mutex. Fix this by setting the cma area count field to 0 when activation fails, leading to allocation returning NULL immediately. Cc: <[email protected]> # v3.17 Signed-off-by: Laurent Pinchart <[email protected]> Acked-by: Michal Nazarewicz <[email protected]> Signed-off-by: Marek Szyprowski <[email protected]>
2014-10-14drivers: dma-contiguous: add initialization from device treeMarek Szyprowski1-11/+51
Add a function to create CMA region from previously reserved memory and add support for handling 'shared-dma-pool' reserved-memory device tree nodes. Based on previous code provided by Josh Cartwright <[email protected]> Signed-off-by: Marek Szyprowski <[email protected]> Cc: Arnd Bergmann <[email protected]> Cc: Michal Nazarewicz <[email protected]> Cc: Grant Likely <[email protected]> Cc: Laura Abbott <[email protected]> Cc: Josh Cartwright <[email protected]> Cc: Joonsoo Kim <[email protected]> Cc: Kyungmin Park <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2014-10-14mm/cma: fix cma bitmap aligned mask computingWeijie Yang1-1/+3
The current cma bitmap aligned mask computation is incorrect. It could cause an unexpected alignment when using cma_alloc() if the wanted align order is larger than cma->order_per_bit. Take kvm for example (PAGE_SHIFT = 12), kvm_cma->order_per_bit is set to 6. When kvm_alloc_rma() tries to alloc kvm_rma_pages, it will use 15 as the expected align value. After using the current implementation however, we get 0 as cma bitmap aligned mask other than 511. This patch fixes the cma bitmap aligned mask calculation. [[email protected]: coding-style fixes] Signed-off-by: Weijie Yang <[email protected]> Acked-by: Michal Nazarewicz <[email protected]> Cc: Joonsoo Kim <[email protected]> Cc: "Aneesh Kumar K.V" <[email protected]> Cc: <[email protected]> [3.17] Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2014-10-09mm: cma: adjust address limit to avoid hitting low/high memory boundaryMarek Szyprowski1-0/+21
Russell King recently noticed that limiting default CMA region only to low memory on ARM architecture causes serious memory management issues with machines having a lot of memory (which is mainly available as high memory). More information can be found the following thread: http://thread.gmane.org/gmane.linux.ports.arm.kernel/348441/ Those two patches removes this limit letting kernel to put default CMA region into high memory when this is possible (there is enough high memory available and architecture specific DMA limit fits). This should solve strange OOM issues on systems with lots of RAM (i.e. >1GiB) and large (>256M) CMA area. This patch (of 2): Automatically allocated regions should not cross low/high memory boundary, because such regions cannot be later correctly initialized due to spanning across two memory zones. This patch adds a check for this case and a simple code for moving region to low memory if automatically selected address might not fit completely into high memory. Signed-off-by: Marek Szyprowski <[email protected]> Acked-by: Michal Nazarewicz <[email protected]> Cc: Daniel Drake <[email protected]> Cc: Minchan Kim <[email protected]> Cc: Russell King <[email protected]> Cc: Joonsoo Kim <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2014-08-06mm, CMA: clean-up log messageJoonsoo Kim1-2/+2
We don't need explicit 'CMA:' prefix, since we already define prefix 'cma:' in pr_fmt. So remove it. Signed-off-by: Joonsoo Kim <[email protected]> Acked-by: Michal Nazarewicz <[email protected]> Reviewed-by: Zhang Yanfei <[email protected]> Cc: "Aneesh Kumar K.V" <[email protected]> Cc: Alexander Graf <[email protected]> Cc: Aneesh Kumar K.V <[email protected]> Cc: Gleb Natapov <[email protected]> Acked-by: Marek Szyprowski <[email protected]> Tested-by: Marek Szyprowski <[email protected]> Cc: Minchan Kim <[email protected]> Cc: Paolo Bonzini <[email protected]> Cc: Benjamin Herrenschmidt <[email protected]> Cc: Paul Mackerras <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2014-08-06mm, CMA: change cma_declare_contiguous() to obey coding conventionJoonsoo Kim1-6/+7
Conventionally, we put output param to the end of param list and put the 'base' ahead of 'size', but cma_declare_contiguous() doesn't look like that, so change it. Additionally, move down cma_areas reference code to the position where it is really needed. Signed-off-by: Joonsoo Kim <[email protected]> Acked-by: Michal Nazarewicz <[email protected]> Reviewed-by: Aneesh Kumar K.V <[email protected]> Cc: Alexander Graf <[email protected]> Cc: Aneesh Kumar K.V <[email protected]> Cc: Gleb Natapov <[email protected]> Acked-by: Marek Szyprowski <[email protected]> Tested-by: Marek Szyprowski <[email protected]> Cc: Minchan Kim <[email protected]> Cc: Paolo Bonzini <[email protected]> Cc: Zhang Yanfei <[email protected]> Cc: Benjamin Herrenschmidt <[email protected]> Cc: Paul Mackerras <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2014-08-06mm, CMA: clean-up CMA allocation error pathJoonsoo Kim1-3/+4
We can remove one call sites for clear_cma_bitmap() if we first call it before checking error number. Signed-off-by: Joonsoo Kim <[email protected]> Acked-by: Minchan Kim <[email protected]> Reviewed-by: Michal Nazarewicz <[email protected]> Reviewed-by: Zhang Yanfei <[email protected]> Reviewed-by: Aneesh Kumar K.V <[email protected]> Cc: Alexander Graf <[email protected]> Cc: Aneesh Kumar K.V <[email protected]> Cc: Gleb Natapov <[email protected]> Acked-by: Marek Szyprowski <[email protected]> Tested-by: Marek Szyprowski <[email protected]> Cc: Paolo Bonzini <[email protected]> Cc: Benjamin Herrenschmidt <[email protected]> Cc: Paul Mackerras <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2014-08-06CMA: generalize CMA reserved area management functionalityJoonsoo Kim1-0/+333
Currently, there are two users on CMA functionality, one is the DMA subsystem and the other is the KVM on powerpc. They have their own code to manage CMA reserved area even if they looks really similar. From my guess, it is caused by some needs on bitmap management. KVM side wants to maintain bitmap not for 1 page, but for more size. Eventually it use bitmap where one bit represents 64 pages. When I implement CMA related patches, I should change those two places to apply my change and it seem to be painful to me. I want to change this situation and reduce future code management overhead through this patch. This change could also help developer who want to use CMA in their new feature development, since they can use CMA easily without copying & pasting this reserved area management code. In previous patches, we have prepared some features to generalize CMA reserved area management and now it's time to do it. This patch moves core functions to mm/cma.c and change DMA APIs to use these functions. There is no functional change in DMA APIs. Signed-off-by: Joonsoo Kim <[email protected]> Acked-by: Michal Nazarewicz <[email protected]> Acked-by: Zhang Yanfei <[email protected]> Acked-by: Minchan Kim <[email protected]> Reviewed-by: Aneesh Kumar K.V <[email protected]> Cc: Alexander Graf <[email protected]> Cc: Aneesh Kumar K.V <[email protected]> Cc: Gleb Natapov <[email protected]> Acked-by: Marek Szyprowski <[email protected]> Tested-by: Marek Szyprowski <[email protected]> Cc: Paolo Bonzini <[email protected]> Cc: Benjamin Herrenschmidt <[email protected]> Cc: Paul Mackerras <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>