[alsa-devel] Slow SPI reads in ALSA causing mic recording error

noman pouigt variksla at gmail.com
Thu Jun 14 11:12:35 CEST 2018


Hello Folks,

I have a DSP hardware connected over SPI
to SoC with extra interrupt line.

I am getting buffer overrun problem in DSP
while doing MIC recording. SoC SPI consecutive reads
are two slow and it is not able to empty DSP buffers
in time which causes DSP to issue overruns interrupts
to SoC and causes bad mic data recording.

ARECORD properly records mic data but when I try to use
AudioFlinger(android) then I see buffer overrun issue in
DSP. Period size is same in both arecord and AudioFlinger case.

system: arm64, latest mainline kernel, latest alsa-lib

I have below platform ops
static const struct snd_pcm_ops platform_ops = {
     .open    = platform_open,
     .ioctl      = snd_pcm_lib_ioctl,
     .pointer  = platform_pcm_pointer,
     .mmap    = snd_pcm_lib_default_mmap,
     .page      = snd_pcm_lib_get_vmalloc_page,
 };

What baffles me is that consecutive SPI read(while loop
in a workqueue) doesn't have any relation with userspace
as it is interrupt driven (DSP interrupt) but still with
audio flinger overrun happens. In the workqueue, between
SPI reads, driver calls  elapsed function to notify the userspace
to read 1 period data whenever data crosses period boundary.
I don't think that causes any issues. Aforementioned workqueue
stops only when userspace closes it so I don't know how
userspace application can slow down SPI reads?

I have also used high priority workqueues but that didn't
help either. Wondering if I can get some pointers to debug this?
also if there any alsa-utility which can simulate closely audio flinger?

Thanks,


More information about the Alsa-devel mailing list