cma buffer memory allocation failed

1

I am trying to write a driver for DMA Linux, and my driver has been failing to execute dma_coherent_alloc, I already increased CMA memory, and coherent_pool ...

what am I missing ?

dmesg Booting Linux on physical CPU 0x0
Linux version 4.14.0-xilinx-v2018.2 (oe-user@oe-host) (gcc version 7.2.0 (GCC)) #5 SMP PREEMPT Sun Feb 17 23:20:49 PST 2019
CPU: ARMv7 Processor [413fc090] revision 0 (ARMv7), cr=18c5387d
CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
OF: fdt: Machine model: xlnx,zynq-7000
bootconsole [earlycon0] enabled
Memory policy: Data cache writealloc
OF: fdt: Reserved memory: unsupported node format, ignoring
cma: dma_contiguous_reserve(limit ffffffff)
cma: dma_contiguous_reserve: reserving 60 MiB for global area
cma: cma_declare_contiguous(size 0x03c00000, base 0x00000000, limit 0xffffffff alignment 0x00000000)
cma: Reserved 60 MiB at 0x3c400000
On node 0 totalpages: 262144
free_area_init_node: node 0, pgdat c183af40, node_mem_map ef7f7000
Normal zone: 1536 pages used for memmap
Normal zone: 0 pages reserved
Normal zone: 196608 pages, LIFO batch:31
HighMem zone: 65536 pages, LIFO batch:15
percpu: Embedded 16 pages/cpu @ef7ce000 s34764 r8192 d22580 u65536
pcpu-alloc: s34764 r8192 d22580 u65536 alloc=16*4096
pcpu-alloc: [0] 0 [0] 1
Built 1 zonelists, mobility grouping on. Total pages: 260608
Kernel command line: console=ttyPS0,115200 earlyprintk coherent_pool=32MiB
PID hash table entries: 4096 (order: 2, 16384 bytes)
Dentry cache hash table entries: 131072 (order: 7, 524288 bytes)
Inode-cache hash table entries: 65536 (order: 6, 262144 bytes)
Memory: 953428K/1048576K available (6144K kernel code, 238K rwdata, 1568K rodata, 15360K init, 218K bss, 33708K reserved, 61440K cma-reserved, 200704K highmem)
Virtual kernel memory layout:
vector : 0xffff0000 - 0xffff1000 ( 4 kB)
fixmap : 0xffc00000 - 0xfff00000 (3072 kB)
vmalloc : 0xf0800000 - 0xff800000 ( 240 MB)
lowmem : 0xc0000000 - 0xf0000000 ( 768 MB)
pkmap : 0xbfe00000 - 0xc0000000 ( 2 MB)
modules : 0xbf000000 - 0xbfe00000 ( 14 MB)
.text : 0xc0008000 - 0xc0700000 (7136 kB)
.init : 0xc0900000 - 0xc1800000 (15360 kB)
.data : 0xc1800000 - 0xc183bb40 ( 239 kB)
.bss : 0xc183bb40 - 0xc1872344 ( 219 kB)
Preemptible hierarchical RCU implementation.
RCU restricting CPUs from NR_CPUS=4 to nr_cpu_ids=2.
Tasks RCU enabled.
RCU: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=2
NR_IRQS: 16, nr_irqs: 16, preallocated irqs: 16
efuse mapped to f0802000
slcr mapped to f0804000
L2C: platform modifies aux control register: 0x72360000 -> 0x72760000
L2C: DT/platform modifies aux control register: 0x72360000 -> 0x72760000
L2C-310 erratum 769419 enabled
L2C-310 enabling early BRESP for Cortex-A9
L2C-310 full line of zeros enabled for Cortex-A9
L2C-310 ID prefetch enabled, offset 1 lines
L2C-310 dynamic clock gating enabled, standby mode enabled
L2C-310 cache controller enabled, 8 ways, 512 kB
L2C-310: CACHE_ID 0x410000c8, AUX_CTRL 0x76760001
zynq_clock_init: clkc starts at f0804100
Zynq clock init
sched_clock: 64 bits at 249MHz, resolution 4ns, wraps every 4398046511102ns
clocksource: arm_global_timer: mask: 0xffffffffffffffff max_cycles: 0x7350b89c29, max_idle_ns: 881590431910 ns
Switching to timer-based delay loop, resolution 4ns
clocksource: ttc_clocksource: mask: 0xffff max_cycles: 0xffff, max_idle_ns: 716713566 ns
timer #0 at f080c000, irq=17
Console: colour dummy device 80x30
Calibrating delay loop (skipped), value calculated using timer frequency.. 499.99 BogoMIPS (lpj=2499999)
pid_max: default: 32768 minimum: 301
Mount-cache hash table entries: 2048 (order: 1, 8192 bytes) Mountpoint-cache hash table entries: 2048 (order: 1, 8192 bytes)
CPU: Testing write buffer coherency: ok
CPU0: thread -1, cpu 0, socket 0, mpidr 80000000
Setting up static identity map for 0x100000 - 0x100060
Hierarchical SRCU implementation.
smp: Bringing up secondary CPUs ...
CPU1: thread -1, cpu 1, socket 0, mpidr 80000001
smp: Brought up 1 node, 2 CPUs
SMP: Total of 2 processors activated (999.99 BogoMIPS).
CPU: All CPU(s) started in SVC mode.
devtmpfs: initialized
random: get_random_u32 called from bucket_table_alloc+0x1c4/0x204 with crng_init=0
VFP support v0.3: implementor 41 architecture 3 part 30 variant 9 rev 4
DMA-API: preallocated 4096 debug entries
DMA-API: debugging enabled by kernel config
clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
futex hash table entries: 512 (order: 3, 32768 bytes)
pinctrl core: initialized pinctrl subsystem
random: fast init done
NET: Registered protocol family 16
cma: cma_alloc(cma c184d3e0, count 8192, align 8)
cma: cma_alloc(): returned eff7f000
DMA: preallocated 32768 KiB pool for atomic coherent allocations
cpuidle: using governor menu
hw-breakpoint: found 5 (+1 reserved) breakpoint and 1 watchpoint registers.
hw-breakpoint: maximum watchpoint size is 4 bytes.
zynq-ocm f800c000.ocmc: ZYNQ OCM pool: 256 KiB @ 0xf2840000
zynq-pinctrl 700.pinctrl: zynq pinctrl initialized
e0001000.serial: ttyPS0 at MMIO 0xe0001000 (irq = 28, base_baud = 6249999) is a xuartps
console [ttyPS0] enabled
bootconsole [earlycon0] disabled
vgaarb: loaded
SCSI subsystem initialized
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
media: Linux media interface: v0.10
Linux video capture interface: v2.00
pps_core: LinuxPPS API ver. 1 registered
pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti
PTP clock support registered
EDAC MC: Ver: 3.0.0
FPGA manager framework
fpga-region fpga-full: FPGA Region probed
Advanced Linux Sound Architecture Driver Initialized.
clocksource: Switched to clocksource arm_global_timer
NET: Registered protocol family 2
TCP established hash table entries: 8192 (order: 3, 32768 bytes)
TCP bind hash table entries: 8192 (order: 4, 65536 bytes)
TCP: Hash tables configured (established 8192 bind 8192)
UDP hash table entries: 512 (order: 2, 16384 bytes)
UDP-Lite hash table entries: 512 (order: 2, 16384 bytes)
NET: Registered protocol family 1
RPC: Registered named UNIX socket transport module.
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
RPC: Registered tcp NFSv4.1 backchannel transport module.
PCI: CLS 0 bytes, default 64
hw perfevents: no interrupt-affinity property for /pmu@f8891000, guessing.
hw perfevents: enabled with armv7_cortex_a9 PMU driver, 7 counters available
workingset: timestamp_bits=30 max_order=18 bucket_order=0
jffs2: version 2.2. (NAND) (SUMMARY) © 2001-2006 Red Hat, Inc.
bounce: pool size: 64 pages
io scheduler noop registered
io scheduler deadline registered
io scheduler cfq registered (default)
io scheduler mq-deadline registered
io scheduler kyber registered
cma: cma_alloc(cma c184d3e0, count 1, align 0)
cma: cma_alloc(): returned effbf000
dma-pl330 f8003000.dmac: Loaded driver for PL330 DMAC-241330
dma-pl330 f8003000.dmac: DBUFF-128x8bytes Num_Chans-8 Num_Peri-4 Num_Events-16
brd: module loaded loop: module loaded m25p80 spi0.0: found s25fl128s, expected n25q512a m25p80 spi0.0: s25fl128s (16384 Kbytes)
4 ofpart partitions found on MTD device spi0.0
Creating 4 MTD partitions on "spi0.0":
0x000000000000-0x000000500000 : "boot"
0x000000500000-0x000000520000 : "bootenv"
0x000000520000-0x000000fa0000 : "kernel"
0x000000fa0000-0x000001000000 : "spare"
libphy: Fixed MDIO Bus: probed
CAN device driver interface
libphy: MACB_mii_bus: probed

cma: cma_alloc(cma c184d3e0, count 1, align 0)
cma: cma_alloc(): returned effbf020
mmc0: SDHCI controller on e0100000.sdhci [e0100000.sdhci] using ADMA
ledtrig-cpu: registered to indicate activity on CPUs
usbcore: registered new interface driver usbhid
usbhid: USB HID core driver
fpga_manager fpga0: Xilinx Zynq FPGA Manager registered
NET: Registered protocol family 10

Freeing unused kernel memory: 15360K
udevd[758]: starting version 3.2.2
udevd[759]: starting eudev-3.2.2
cma: cma_alloc(cma c184d3e0, count 1, align 0)
cma: cma_alloc(): returned effbf040
cma: cma_alloc(cma c184d3e0, count 1, align 0)
cma: cma_alloc(): returned effbf060
IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
macb e000b000.ethernet eth0: link up (1000/Full)
IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
luscher2: disagrees about version of symbol module_layout
random: crng init done
luscher2: disagrees about version of symbol module_layout
luscher2: disagrees about version of symbol module_layout
luscher3: loading out-of-tree module taints kernel.
luscher 40400000.dma: Device Tree Probing
luscher 40400000.dma: luscher at 0x40400000 mapped to 0xf2990000, irq=49
buff size 0x00000000
buff number 0x00000000
cma: cma_alloc(cma c184d3e0, count 0, align 8)
luscher 40400000.dma: Buffer memory allocation failed
Buffer memory allocation failed
luscher: probe of 40400000.dma failed with error -12

linux
linux-kernel
asked on Stack Overflow Feb 18, 2019 by MaikonNascimento • edited Feb 18, 2019 by MaikonNascimento

2 Answers

0

The function cma_alloc parameter count is equal to 0, it directly returns the failure, please check the count parameter below:

cma: cma_alloc(cma c184d3e0, count 0, align 8)
answered on Stack Overflow Feb 18, 2019 by ccxxshow
0

in my case it was a difference between the name set in the field "compatible" of the device tree and the name of the module (they must match). I also increase the coherent_pool with :

chosen {
        bootargs = "console=ttyPS0,115200 earlyprintk coherent_pool=32MiB";
           };
answered on Stack Overflow Feb 18, 2019 by MaikonNascimento

User contributions licensed under CC BY-SA 3.0