Re: [alsa-devel] Linux 4.2 ALSA snd-usb-audio inconsistent lock state warn in PCM nonatomic mode

Shuah Khan
2015-09-01T17:40:49Z

On 09/01/2015 02:42 AM, Clemens Ladisch wrote:
> Shuah Khan wrote:
>> +++ b/sound/usb/stream.c
>> pcm->private_data = as;
>> pcm->private_free = snd_usb_audio_pcm_free;
>> pcm->info_flags = 0;
>> + pcm->nonatomic = true;
>
> Why do you think you need nonatomic mode in the USB audio driver?
>

Short answer is that the need is not a generic one, but a device
specific need to add a fewature. Now the longer version below.

This is for a for AU0828 Hauppauge HVR950Q media device. snd-usb-audio
driver provides Audio Capture support on this device with DVB and Video
drivers driving the device for Digital and Video functions.

I have been working on adding Media Controller support for this chip
as chip specific feature in ALSA. This will allow sharing resources
such as the tuner across the drivers that control the device (DVB,
Video, snd-usb-audio). Media Controller framework uses a mutex to
protect access to resources, hence there is a need to hold this mutex
from SNDRV_PCM_TRIGGER_START and SNDRV_PCM_TRIGGER_STOP which could run
in IRQ context.

The Media Controller mutex can't be converted to a spinlock as it would
break I2C drivers. During review, the idea to run PCM in non-atomic mode
came up as a way to solve the problem. The actual solution would
run PCM in nonatomic context only for the AU0828 Hauppauge HVR950Q chip.

The above change is a quick try to see if PCM nonatomic works with this
device. I have to figure out another way to solve the problem as this
isn't an option.

Hope this helps answer your question. If you would like more information
on the ALSA Media Controller work for this device, I can provide links
to the previous patch series.