Hello,...
I've run into a CMA-related issue while testing a DMA engine driver with
dmatest on a Renesas R-Car ARM platform.
When allocating contiguous memory through CMA the kernel prints the following
messages to the kernel log.
[ 99.770000] alloc_contig_range test_pages_isolated(6b843, 6b844) failed
[ 124.220000] alloc_contig_range test_pages_isolated(6b843, 6b844) failed
[ 127.550000] alloc_contig_range test_pages_isolated(6b845, 6b846) failed
[ 132.850000] alloc_contig_range test_pages_isolated(6b845, 6b846) failed
[ 151.390000] alloc_contig_range test_pages_isolated(6b843, 6b844) failed
[ 166.490000] alloc_contig_range test_pages_isolated(6b843, 6b844) failed
[ 181.450000] alloc_contig_range test_pages_isolated(6b845, 6b846) failed
I've stripped the dmatest module down as much as possible to remove any
hardware dependencies and came up with the following implementation.
Loading the module will start 4 threads that will allocate and free DMA
coherent memory in a tight loop and eventually produce the error. It seems
like the probability of occurrence grows with the number of threads, which
could indicate a race condition.
The tests have been run on 3.18-rc1, but previous tests on 3.16 did exhibit
the same behaviour.
I'm not that familiar with the CMA internals, help would be appreciated to
debug the problem.