Skip to contentSkip to conversation

How ALSA handle PCM playing when the ALSA modules are removing

DISCUSSION Zhu, Yingjiang 2 participants 3 messages Jan 23, 2019

lore
Share & tools
lore
#0 lore raw

Hi, Takashi

        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. 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?

BR

Yingjiang

_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

#1 lore raw

Hi,

(I'm another Takashi.)

Quoted 2 lines · Yingjiang

        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.

Quoted 3 lines

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.

Regards

Takashi Sakamoto
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

#2 lore raw
Quoted 21 lines · Takashi Sakamoto

Hi,

(I'm another Takashi.)

Quoted 1 line · Yingjiang

         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.

Quoted 2 lines

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?

Quoted 8 lines

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

Quoted 4 lines

Regards

Takashi Sakamoto

_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel