Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move Contiguous Memory Region Specification to the Device Tree #4

Open
bperez77 opened this issue Jul 21, 2016 · 4 comments
Open

Move Contiguous Memory Region Specification to the Device Tree #4

bperez77 opened this issue Jul 21, 2016 · 4 comments
Assignees

Comments

@bperez77
Copy link
Owner

To allocate large regions of physically-contiguous memory, the driver uses the CMA (contiguous memory allocator). At boot time, the user specifies the cma=<size>M parameter to reserve a region of size megabytes for the CMA.

It would be much nicer if the user could instead specify this in the device tree, as this requires less manual user intervention, since they don't need to update the command line via U-Boot or the device tree.

This can be done via a reserved memory region device tree node. The user specifies a device tree node that describes the contiguous memory region (size, alignment, type, etc.). Then the user would put the memory-region property in the driver's device tree node. This is simply a phandle to the reserved memory region device tree node. See the reserved-memory documentation for more details.

@jannikmahr
Copy link

This DMA Buffer driver already has support for "reserved-memory":
https://github.com/ikwzm/udmabuf#memory-region

You probably already know this project, but if not it might contain some useful code.

@maikonadams
Copy link

I am using petalinux, programming over JTAG right now, and I do not know where to set to configure CMA, when I run the benchmark I get :

cma: cma_alloc: alloc failed, req-size: 2025 pages, ret: -12
axidma: axidma_chrdev.c: axidma_mmap: 285: Unable to allocate contiguous DMA memory region of size 8294400.
axidma: axidma_chrdev.c: axidma_mmap: 287: Please make sure that you specified cma= on the kernel command line, and the size is large enough.

I tried to set it in the system-user.dtsi
chosen {
bootargs = "console=ttyPS0,115200 CMA=28MB earlyprintk";
stdout-path = "serial0:115200n8";
};

@guerricmeurice
Copy link

Hello @maikonadams,

For CMA configuration using petalinux (tested with 2017.4):

Go to kernel features
Make sure the following settings are met:
o Contiguous Memory Allocator
 True
o CMA debug messages (DEVELOPMENT) (if you want...)
 True

Then enable and set the CMA value:

Go to Device Drivers / Generic Driver options
Make sure the following settings are met:
o DMA Contiguous Memory Allocator
 True
o Size in Mega Bytes
 25 (for example)

@maikonadams
Copy link

thank you @guerricmeurice !
it looks it worked now cos I get
cma: cma_alloc(cma c184d420, count 8, align 3)
cma: cma_alloc(): returned effbf900
cma: cma_alloc(cma c184d420, count 1, align 0)
cma: cma_alloc(): returned effbf880
cma: cma_alloc(cma c184d420, count 8, align 3)
cma: cma_alloc(): returned effbfa00
cma: cma_alloc(cma c184d420, count 1, align 0)
cma: cma_alloc(): returned effbf8a0
axidma: axidma_dma.c: axidma_dma_init: 718: DMA: Found 1 transmit channels and 1 receive channels.
axidma: axidma_dma.c: axidma_dma_init: 720: VDMA: Found 0 transmit channels and 0 receive channels.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants