element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
    About the element14 Community
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      •  Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Raspberry Pi
  • Products
  • More
Raspberry Pi
Raspberry Pi Forum Driver instability issue
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Raspberry Pi to participate - click to join for free!
Featured Articles
Announcing Pi
Technical Specifications
Raspberry Pi FAQs
Win a Pi
Raspberry Pi Wishlist
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Suggested Answer
  • Replies 21 replies
  • Answers 1 answer
  • Subscribers 693 subscribers
  • Views 3551 views
  • Users 0 members are here
  • raspberry_pi
  • raspeberry_pi_accessories
Related

Driver instability issue

Former Member
Former Member over 12 years ago

I've got the Wolfson Audio card running with an application that makes use of the Line-In and Line-Out ports. The Line-In port is _constantly_ read and to the Line-out port audio is written in parallel from time to time. Sampling rate is 48k. The kernel is compiled following the description here in this forum.

 

 

I now had the issue twice that the app hangs after about a day and a half. The second time I was able to collect the following info:

 

End of dmesg:

root@raspberrypi:/home/pi# dmesg | tail
 [135777.724427] arizona spi0.1: FLL1: Timed out waiting for lock
 [136377.676455] arizona spi0.1: FLL1: Timed out waiting for lock
 [136977.638482] arizona spi0.1: FLL1: Timed out waiting for lock
 [137577.600549] arizona spi0.1: FLL1: Timed out waiting for lock
 [138099.977529] arizona spi0.1: FLL1: Timed out waiting for lock
 [138777.524608] arizona spi0.1: FLL1: Timed out waiting for lock
 [139377.496589] arizona spi0.1: FLL1: Timed out waiting for lock
 [139977.448573] arizona spi0.1: FLL1: Timed out waiting for lock
 [139977.522931] ERROR: 4096 KiB atomic DMA coherent pool is too small!
 [139977.522931] Please increase it with coherent_pool= kernel parameter!

 

 

The app hangs. After kill -9 any attempt to restart fails with the following message from the app:

 

*** ERROR: snd_pcm_start failed (unrecoverable error): Cannot allocate memory
 *** ERROR: Start capture failed

 

Here is the end of the corresponding strace of an app start attempt:

 

stat64("/usr/share/alsa/alsa.conf", {st_mode=S_IFREG|0644, st_size=9184, ...}) = 0
 open("/dev/snd/controlC0", O_RDONLY|O_CLOEXEC) = 5
 fcntl64(5, F_SETFD, FD_CLOEXEC)         = 0
 ioctl(5, UI_DEV_CREATE, 0xbef492cc)     = 0
 close(5)                                = 0
 open("/dev/snd/controlC0", O_RDWR|O_CLOEXEC) = 5
 fcntl64(5, F_SETFD, FD_CLOEXEC)         = 0
 ioctl(5, USBDEVFS_CONTROL or USBDEVFS_CONTROL32, 0xbef4946c) = 0
 ioctl(5, 0x40045532, 0xbef494a4)        = 0
 open("/dev/snd/pcmC0D0c", O_RDWR|O_NONBLOCK|O_CLOEXEC) = 6
 fcntl64(6, F_SETFD, FD_CLOEXEC)         = 0
 close(5)                                = 0
 ioctl(6, AGPIOC_ACQUIRE or APM_IOC_STANDBY, 0xbef492e8) = 0
 fcntl64(6, F_GETFL)                     = 0x802 (flags O_RDWR|O_NONBLOCK)
 ioctl(6, AGPIOC_INFO, 0xbef492dc)       = 0
 clock_gettime(CLOCK_MONOTONIC, {172144, 75851672}) = 0
 ioctl(6, AGPIOC_SETUP, 0xbef492e4)      = 0
 mmap2(NULL, 4096, PROT_READ, MAP_SHARED, 6, 0x80000) = -1 ENXIO (No such device or address)
 ioctl(6, 0xc0844123, 0xbef49408)        = 0
 fcntl64(6, F_GETFL)                     = 0x802 (flags O_RDWR|O_NONBLOCK)
 fcntl64(6, F_SETFL, O_RDWR)             = 0
 ioctl(6, 0xc25c4110, 0x1935718)         = 0
 ioctl(6, 0xc25c4110, 0x1935718)         = 0
 ioctl(6, 0xc25c4110, 0x1935718)         = 0
 ioctl(6, 0xc25c4110, 0x1935718)         = 0
 ioctl(6, 0xc25c4110, 0x1935718)         = 0
 ioctl(6, 0xc25c4110, 0x1935718)         = 0
 ioctl(6, 0xc25c4110, 0x1935718)         = 0
 ioctl(6, 0xc25c4110, 0x1935718)         = 0
 ioctl(6, 0xc25c4110, 0x1935718)         = 0
 ioctl(6, 0xc25c4110, 0x1935718)         = 0
 ioctl(6, 0xc25c4110, 0x1935718)         = 0
 ioctl(6, 0xc25c4111, 0x1935718)         = 0
 ioctl(6, 0xc0844123, 0x1935bb8)         = 0
 ioctl(6, 0xc0684113, 0xbef496d4)        = 0
 ioctl(6, 0x4140, 0xb69d5000)            = 0
 ioctl(6, 0xc0844123, 0x1935bb8)         = 0
 ioctl(6, 0xc0684113, 0x19353e0)         = 0
 ioctl(6, 0x4140, 0xb69d5000)            = 0
 ioctl(6, 0xc0844123, 0x1935bb8)         = 0
 ioctl(6, 0xc0844123, 0x1935bb8)         = 0
 ioctl(6, 0x4142, 0x1935bb8)             = -1 ENOMEM (Cannot allocate memory)
 write(2, "*** ERROR: snd_pcm_start failed "..., 55*** ERROR: snd_pcm_start failed (unrecoverable error): ) = 55
 write(2, "Cannot allocate memory", 22Cannot allocate memory)  = 22
 write(2, "\n", 1
 )                       = 1
 write(2, "*** ERROR: Start capture failed", 31*** ERROR: Start capture failed) = 31
 write(2, "\n", 1
 )                       = 1
 ioctl(6, 0x4143, 0xb69d5000)            = 0
 ioctl(6, 0x4112, 0xf5519900)            = 0
 close(6)                                = 0
 write(2, "*** ERROR: Could not open audio "..., 53*** ERROR: Could not open audio device for receiver ") = 53
 write(2, "Rx1", 3Rx1)                      = 3
 write(2, "\"\n", 2"
 )                     = 2
 close(4)                                = 0
 brk(0x1955000)                          = 0x1955000
 brk(0x1947000)                          = 0x1947000
 write(2, "*** ERROR: Could not initialize "..., 36*** ERROR: Could not initialize RX ") = 36
 write(2, "Rx1", 3Rx1)                      = 3
 write(2, "\"\n", 2"
 )                     = 2
 write(2, "*** ERROR: Could not initialize "..., 46*** ERROR: Could not initialize Logic object ") = 46
 write(2, "RepeaterLogic", 13RepeaterLogic)           = 13
 write(2, "\". Skipping...\n", 15". Skipping...
 )       = 15
 write(2, "*** ERROR: No logics available. "..., 47*** ERROR: No logics available. Bailing out...
 ) = 47
 exit_group(1)                           = ?

 

BTW, the app is supposed to run _for-ever_ reading and processing audio... running for two years without restart is common for users of this app on x86 hardware.

 

Is there any driver update on the way that could fix this (and allow lower sampling rates on the analogue input)?

Thanks?

  • Sign in to reply
  • Cancel
  • Former Member
    0 Former Member over 11 years ago in reply to Former Member

    I can confirm the issue that Paul reported; getting the exact same error message. Since the last update in this thread was on May 3rd, I wonder if any solution has been found so far to get rid of this error without rebooting?

     

    Thomas

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • matwillis
    0 matwillis over 11 years ago in reply to Former Member

    Hi all

    I have just come back to this problem of 'running out of coherent memory for DMA' with the wolfson card (Hoping that someone else would fix the problem!!)

     

    I confirm that it is NOT a problem with size of memory , but indeed a memory leak.

    Specifically, the problem is that in bcm2708-dmaengine.c , the function bcm2708_dma_desc_free (which should free the memory used by the alsa sound driver for aplay/arecord etc) is NEVER called.

     

    I have a simple patch that can be applied to bcm2708-dmaengine.c, for anyone that understands how to rebuild the RPi kernel (find details elsewhere).

    The patch works by checking whether coherent memory has already been allocated, when further coherent memory is requested, and if so forces the old memory to be free'd. It presumes that the I2S driver is the only thing using this cyclic dma, and just 2 blocks (for playback and record) are managed.

    (If bcm2708_dma_desc_free DOES start getting called properly in future, my code will print diags to remind to remove this patch)

     

    I am still using a version of 3.12 kernel (but saw the problem with the standard 3.10 kernel) - I cannot see that anyone has fixed this issue already, but I have not confirmed that the problem has not 'gone away' already with later kernels.

     

    It fixes the problem for me - hope it helps others.

     

    Matt Willis

    Oxford Creative Technology Ltd

    Attachments:
    bcm2708_rpi_wsp_cyclic_dma.patch.zip
    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Former Member
    0 Former Member over 11 years ago in reply to matwillis

    Last night, somebody pointed me to this thread and told me that the problem is that bcm2835_dma_terminate_all doesn't free the resources bcm2835_dma_desc_free would free. However, it calls vchan_dma_desc_free_list, which would in turn call bcm2835_dma_desc_free, so that doesn't quite add up. I don't have the hardware to investigate this properly myself, but if somebody can provide some more information to go on, I could certainly fix it. Otherwise, I would have to write a test module to try to trigger the problem.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Former Member
    0 Former Member over 11 years ago in reply to Former Member

    Adding printk statements to bcm2835_dma_desc_free and bcm2835_dma_terminate_all showed that bcm2835_dma_desc_free is called for scatter/gather DMA allocated by bcm2835_dma_prep_slave_sg but not for cyclic DMA allocated by bcm2835_dma_prep_dma_cyclic. I can see that bcm2835_dma_terminate_all sets c->desc to NULL before it calls vchan_dma_desc_free_list, so I think it's already leaked by that point. The issue seems to be that the control block in c->desc isn't freed before c->desc is set to NULL.

     

    If you do manage to get hold of one, I can reproduce the issue with a Wolfson board using the Volumio distribution (I'm running with a custom kernel built from https://github.com/manish-wolfsonmicro, which is the subject of https://github.com/raspberrypi/linux/pull/705/files), put a bunch of files in the playlist and run "mpc next" in a loop.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Former Member
    0 Former Member over 11 years ago in reply to Former Member

    bcm2835_dma_desc_free, determines desc using container_of, not by reading c->desc. Although  c->desc is set to NULL, vd is still contained by the structure previously pointed to by c->desc.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Former Member
    0 Former Member over 11 years ago

    Does anyone know if there is still somebody working on this issue?

     

    I also ran into the "ERROR: 4096 KiB atomic DMA coherent pool is too small!" error using a 3.16.5 kernel on a Raspberry Compute Module. It came up unexpectedly after a few minutes of playing around with aplay and gst-launch. First the system froze for about 2 minutes (but I could still ping it), then it came back to life with the error, plus I/O errors on the SD card interface because the system was in the middle of writing some file when the error occurred. File system was corrupted after a power cycle...

     

    Today, I checked again with kernel 3.19.0 (revision f589118 from https://github.com/raspberrypi/linux.git) and tried something similar to what Paul Roe has done in post #10, but with aplay instead of arecord. Apparently there were some changes applied to the I2S driver, so I was hoping for better results than with 3.16.5, but I got disappointed.

     

    Here is what I've tried with a simple one second long stereo file at 44.1 kHz:

     

    $ for i in $(seq 10000); do aplay 1sec.wav || break; echo $(date) $i; done

    Playing WAVE '1sec.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo

    Fri Feb 13 08:53:17 UTC 2015 1

    ....

    This went on for about 20 minutes, then after a bit more than 900 iterations the loop broke.

     

    Attempting to play the .wav with aplay yielded an error after ten seconds ("aplay: pcm_write:1947: write error: Input/output error").

    Attempting to cat some random file not already in fscache also yielded an I/O error (maybe trying to load the cat executable already gave the error, not sure).

     

    To my surprise, there was no atomic-DMA-coherent-pool-error, but found this in the kernel log after these actions:

    [ 1732.219441] mmc0: Timeout waiting for hardware interrupt.

    [ 1732.225168] mmcblk0: error -110 transferring data, sector 3013168, nr 32, cmd response 0x900, card status 0xb00

    [ 1732.236730] mmcblk0: retrying using single block read

    [ 1772.279443] mmc0: Timeout waiting for hardware interrupt.

    [ 1772.285206] mmcblk0: error -110 transferring data, sector 3707576, nr 16, cmd response 0x900, card status 0xd00

    [ 1772.296995] blk_update_request: I/O error, dev mmcblk0, sector 3707576

    [ 1772.303841] blk_update_request: I/O error, dev mmcblk0, sector 3707584

    [ 1772.311732] Aborting journal on device mmcblk0p7-8.

    [ 1782.319444] mmc0: Timeout waiting for hardware interrupt.

    [ 1782.325167] mmcblk0: error -110 transferring data, sector 3301472, nr 8, cmd response 0x900, card status 0xb00

    [ 1782.336796] mmcblk0: retrying using single block read

    [ 1792.359440] mmc0: Timeout waiting for hardware interrupt.

    [ 1792.365216] mmcblk0: error -110 transferring data, sector 3706880, nr 8, cmd response 0x900, card status 0xd00

    [ 1792.376864] blk_update_request: I/O error, dev mmcblk0, sector 3706880

    [ 1792.383702] Buffer I/O error on dev mmcblk0p7, logical block 131072, lost sync page write

    [ 1792.393305] JBD2: Error -5 detected when updating journal superblock for mmcblk0p7-8.

     

    Well, the DMA-related error message was removed as part of a bigger change in 36d0fd2, so it cannot show up anymore.

     

    Needless to say, attempting to cleanly shut down via shutdown -r now yielded more errors. I power-cycled the system after several minutes of waiting. There was no file system corruption this time (system booted, fsck.ext4 -v -n -f reported no errors), probably because there was no coincidental writing in the background when the I/O errors started to show up.

     

    So, the original problem seems to persist: playing audio over I2S kills the system and may lead to file system corruption even in the latest kernel version.

    Is there anyone who is working on this problem?

     

    By the way, the patch from post #12 does not apply to the latest kernel anymore. As it contains the work "hack" many times, I am also not so sure that it should be used in production anyway. I didn't try it on older kernels.

     

     

    Maybe unrelated, but I also found this in the kernel log:

    [  602.269309] bcm2708_fb_blank(1) returns=1 p[1]=0x0

    That's the video driver speaking here (linux/drivers/video/bcm2708_fb.c).

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Former Member
    0 Former Member over 11 years ago in reply to Former Member

    Hi,

     

    I am seeing a similar problem on a custom rpi b board with rpi-proto codec connected via i2s.

    Tried 3.12.37 PREEMPT and 3.18.6 with Device Tree support enabled.

     

    Does anyone knows how to fix the issue?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Former Member
    0 Former Member over 11 years ago in reply to Former Member

    Did you compile Kernel 3.19 with cirrus/wolfson drivers? When I compiled the driver I only got 3.18. https://github.com/CirrusLogic/rpi-linux/wiki/Building-the-code

    How did you do it?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Former Member
    0 Former Member over 10 years ago in reply to Former Member

    I got back to the topic and finally found the problem. It is a memory leak that was actually present in several dmaengine implementations, and the fixes got already merged into vanilla kernel in commit 0a48127 (so the fixes are in v4.0-rc7).

     

    In the Raspberry Pi branch, a similar fix must be manually applied to file drivers/dma/bcm2708-dmaengine.c as no such fix has been applied to their driver yet.

     

    Here is a patch for kernel 3.18:

    --- a/drivers/dma/bcm2708-dmaengine.c
    +++ b/drivers/dma/bcm2708-dmaengine.c
    @@ -684,6 +684,7 @@ static int bcm2835_dma_terminate_all(struct bcm2835_chan *c)
            * c->desc is NULL and exit.)
            */
           if (c->desc) {
    +              bcm2835_dma_desc_free(&c->desc->vd);
                   c->desc = NULL;
                   bcm2835_dma_abort(c->chan_base);

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Former Member
    0 Former Member over 10 years ago in reply to Former Member

    Will you or someone be able to upload and share this kernel with this modification ?

     

    Not a lot of people have time or able to build a new kernel.

     

    Thanks in advance.

     

    Best Regards

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
<>
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2026 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube