CMA in 7.4

Issues related to applications and software problems
Post Reply
zvivered
Posts: 4
Joined: 2019/09/23 17:23:00

CMA in 7.4

Post by zvivered » 2019/09/23 17:37:06

Hello,

According to .config:
CONFIG_CMA = y
CONFIG_DMA_CMA : Does not exist

How can I enable CMA in this version ?

I have to allocate a 256MB physically contiguous memory buffer with: dma_alloc_coherent
or __get_free_pages

I managed to allocate only 4MB.

Thank you,
Zvika

User avatar
TrevorH
Forum Moderator
Posts: 26878
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: CMA in 7.4

Post by TrevorH » 2019/09/23 22:49:16

Please don't use 7.4, it's over 2 years old and riddled with security vulnerabilities. The current version is 7.7. Run yum update

Are you passing cma=xx[MG] as per/usr/share/doc/kernel-doc-3.10.0/Documentation/kernel-parameters.txt (part of the kernel-doc package)?

Code: Select all

         cma=nn[MG]      [ARM,KNL]
                        Sets the size of kernel global memory area for contiguous
                        memory allocations. For more information, see
                        include/linux/dma-contiguous.h
CentOS 5 died in March 2017 - migrate NOW!
CentOS 6 goes EOL sooner rather than later, get upgrading!
Full time Geek, part time moderator. Use the FAQ Luke

zvivered
Posts: 4
Joined: 2019/09/23 17:23:00

Re: CMA in 7.4

Post by zvivered » 2019/09/29 04:22:46

Hello,

Thank you for your reply.
I upgraded to centos 8.0.1905

I changed kernel configuration to:
CONFIG_CMA=y
CONFIG_DMA_CMA=y
In kernel boot parameters: cma=32M

When I tried to allocate up to 4MB I got the following output in dmesg:

[ 1462.787121] cma: cma_alloc(cma 000000001c0c6b6b, count 1024, align 8)
[ 1462.790433] cma: cma_alloc(): returned 00000000087f40b7
[ 1462.790434] cma: cma_release(page 00000000087f40b7)[/i]

The allocation succeeded.

Then I tried to allocate 8MB and got:
[ 1588.692877] cma: cma_alloc(cma 000000001c0c6b6b, count 2048, align 8)
[ 1588.695398] cma: cma_alloc(): returned 00000000087f40b7
[ 1588.695399] cma: cma_release(page 00000000087f40b7)

The allocation failed.
dma_alloc_coherent(NULL, 0x800000, &dma_handle, GFP_KERNEL);
returned NULL.

What am I doing wrong ?

Thank you in advance,
Zvika

zvivered
Posts: 4
Joined: 2019/09/23 17:23:00

Re: CMA in 7.4

Post by zvivered » 2019/09/29 22:20:08

Hello,

The hardware I'm using is PCIe.
The FPGA will write data by DMA to a physical address.

Is it possible that the reason for the failure is that currently I'm working without this FPGA ?

static void * virtual_adr_ptr;
static int hello_init(void)
{
printk ("-->hello_init\n");

virtual_adr_ptr=dma_alloc_coherent(NULL, BUF_SIZE, &dma_handle, GFP_KERNEL);
if (virtual_adr_ptr == 0)
{
return -1;
}

return 0;
}

Thank you,
Zvika

aks
Posts: 2843
Joined: 2014/09/20 11:22:14

Re: CMA in 7.4

Post by aks » 2019/09/30 19:04:23

No where near a C kind of guy, but I can tell you that the CMA values are published under /proc/meminfo (specfically CmaTotal & CmaFree) - might prove whether it is *actually* enabled or not (and allocation success and failure).

User avatar
TrevorH
Forum Moderator
Posts: 26878
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: CMA in 7.4

Post by TrevorH » 2019/09/30 19:26:34

And you don't need to recompile it to change it, it's a kernel parameter passed via the kernel command line.
CentOS 5 died in March 2017 - migrate NOW!
CentOS 6 goes EOL sooner rather than later, get upgrading!
Full time Geek, part time moderator. Use the FAQ Luke

Post Reply

Return to “CentOS 7 - Software Support”