23 Oct, 2015

1 commit

  • This was found during userspace fuzzing test when a large size dma cma
    allocation is made by driver(like ion) through userspace.

    show_stack+0x10/0x1c
    dump_stack+0x74/0xc8
    kasan_report_error+0x2b0/0x408
    kasan_report+0x34/0x40
    __asan_storeN+0x15c/0x168
    memset+0x20/0x44
    __dma_alloc_coherent+0x114/0x18c

    Signed-off-by: Rohit Vaswani
    Acked-by: Greg Kroah-Hartman
    Cc: Marek Szyprowski
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Rohit Vaswani
     

07 Aug, 2014

1 commit

  • 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
    Acked-by: Michal Nazarewicz
    Acked-by: Zhang Yanfei
    Acked-by: Minchan Kim
    Reviewed-by: Aneesh Kumar K.V
    Cc: Alexander Graf
    Cc: Aneesh Kumar K.V
    Cc: Gleb Natapov
    Acked-by: Marek Szyprowski
    Tested-by: Marek Szyprowski
    Cc: Paolo Bonzini
    Cc: Benjamin Herrenschmidt
    Cc: Paul Mackerras
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Joonsoo Kim
     

05 Jun, 2014

1 commit

  • Currently, "cma=" kernel parameter is used to specify the size of CMA,
    but we can't specify where it is located. We want to locate CMA below
    4GB for devices only supporting 32-bit addressing on 64-bit systems
    without iommu.

    This enables to specify the placement of CMA by extending "cma=" kernel
    parameter.

    Examples:
    1. locate 64MB CMA below 4GB by "cma=64M@0-4G"
    2. locate 64MB CMA exact at 512MB by "cma=64M@512M"

    Note that the DMA contiguous memory allocator on x86 assumes that
    page_address() works for the pages to allocate. So this change requires
    to limit end address of contiguous memory area upto max_pfn_mapped to
    prevent from locating it on highmem area by the argument of
    dma_contiguous_reserve().

    Signed-off-by: Akinobu Mita
    Cc: Marek Szyprowski
    Cc: Konrad Rzeszutek Wilk
    Cc: David Woodhouse
    Cc: Don Dutile
    Cc: Thomas Gleixner
    Cc: Ingo Molnar
    Cc: "H. Peter Anvin"
    Cc: Andi Kleen
    Cc: Yinghai Lu
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Akinobu Mita
     

27 Aug, 2013

1 commit

  • This patch cleans the initialization of dma contiguous framework. The
    all-in-one dma_declare_contiguous() function is now separated into
    dma_contiguous_reserve_area() which only steals the the memory from
    memblock allocator and dma_contiguous_add_device() function, which
    assigns given device to the specified reserved memory area. This improves
    the flexibility in defining contiguous memory areas and assigning device
    to them, because now it is possible to assign more than one device to
    the given contiguous memory area. Such split in initialization procedure
    is also required for upcoming device tree support.

    Signed-off-by: Marek Szyprowski
    Acked-by: Kyungmin Park
    Acked-by: Michal Nazarewicz
    Acked-by: Tomasz Figa

    Marek Szyprowski
     

02 Jul, 2013

1 commit

  • We want to use CMA for allocating hash page table and real mode area for
    PPC64. Hence move DMA contiguous related changes into a seperate config
    so that ppc64 can enable CMA without requiring DMA contiguous.

    Acked-by: Michal Nazarewicz
    Acked-by: Paul Mackerras
    Signed-off-by: Aneesh Kumar K.V
    [removed defconfig changes]
    Signed-off-by: Marek Szyprowski

    Aneesh Kumar K.V
     

11 Dec, 2012

1 commit

  • This commit changes the CMA early initialization code to use phys_addr_t
    for representing physical addresses instead of unsigned long.

    Without this change, among other things, dma_declare_contiguous() simply
    discards any memory regions whose address is not representable as unsigned
    long.

    This is a problem on 32-bit PAE machines where unsigned long is 32-bit
    but physical address space is larger.

    Signed-off-by: Vitaly Andrianov
    Signed-off-by: Cyril Chemparathy
    Acked-by: Michal Nazarewicz
    Signed-off-by: Marek Szyprowski

    Vitaly Andrianov
     

21 May, 2012

1 commit

  • The Contiguous Memory Allocator is a set of helper functions for DMA
    mapping framework that improves allocations of contiguous memory chunks.

    CMA grabs memory on system boot, marks it with MIGRATE_CMA migrate type
    and gives back to the system. Kernel is allowed to allocate only movable
    pages within CMA's managed memory so that it can be used for example for
    page cache when DMA mapping do not use it. On
    dma_alloc_from_contiguous() request such pages are migrated out of CMA
    area to free required contiguous block and fulfill the request. This
    allows to allocate large contiguous chunks of memory at any time
    assuming that there is enough free memory available in the system.

    This code is heavily based on earlier works by Michal Nazarewicz.

    Signed-off-by: Marek Szyprowski
    Signed-off-by: Kyungmin Park
    Signed-off-by: Michal Nazarewicz
    Acked-by: Arnd Bergmann
    Tested-by: Rob Clark
    Tested-by: Ohad Ben-Cohen
    Tested-by: Benjamin Gaignard
    Tested-by: Robert Nelson
    Tested-by: Barry Song

    Marek Szyprowski