[alsa-devel] How ALSA handle PCM playing when the ALSA modules are removing

Zhu, Yingjiang yingjiang.zhu at linux.intel.com
Wed Jan 23 06:55:09 CET 2019


On 1/23/2019 1:22 PM, Takashi Sakamoto wrote:
> Hi,
>
> (I'm another Takashi.)
>
> On 2019/01/23 14:01, Zhu, Yingjiang wrote:
>>          I am doing an ALSA module test with insert module/remove 
>> module loop, when playing a wave during this loop, there will be 
>> kernel oops. 
>
> It's just a bug of your modules.
>
> Linux kernel module is maintained by reference counter. In Linux sound
> subsystem, when applications opens any character devices added by driver
> module, the reference counter is incremented, then it cannot be unload
> until all of character devices added by the module are released by
> applications.
>
> If you can unload your module during transmission of audio data frame,
> it's apparently a bug of your module.
>
>> Does ALSA need handle this case? Or just forbid wave playing during 
>> the module load/unload?
>>          If this need to be handled, module unload will wait the wave 
>> play ending, or just stop the wave play at the first of the load/unload?
>
> All of character devices for a sound card are associated to sound card
> structure (struct snd_card). Kernel modules should set 'disconnected'
> state to the structure in its callback for .remove invoked in
> unloading/unbinding operation. Then appliations receives errors in I/O
> operations to the character device. The applications are expected to
> close the character device. When all of character devices are closed,
> then sound card structure is going to be released.
>
OK, thank you very much! I will check the reference count in my module.

BR

Yingjiang

>
> Regards
>
> Takashi Sakamoto


More information about the Alsa-devel mailing list