All of lore.kernel.org
 help / color / mirror / Atom feed
* How ALSA handle PCM playing when the ALSA modules are removing
@ 2019-01-23  5:01 Zhu, Yingjiang
  2019-01-23  5:22 ` Takashi Sakamoto
  0 siblings, 1 reply; 3+ messages in thread
From: Zhu, Yingjiang @ 2019-01-23  5:01 UTC (permalink / raw)
  To: alsa-devel, tiwai, pierre-louis.bossart@linux.intel.com; liam.r.girdwood

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
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: How ALSA handle PCM playing when the ALSA modules are removing
  2019-01-23  5:01 How ALSA handle PCM playing when the ALSA modules are removing Zhu, Yingjiang
@ 2019-01-23  5:22 ` Takashi Sakamoto
  2019-01-23  5:55   ` Zhu, Yingjiang
  0 siblings, 1 reply; 3+ messages in thread
From: Takashi Sakamoto @ 2019-01-23  5:22 UTC (permalink / raw)
  To: Zhu, Yingjiang, alsa-devel, tiwai, pierre-louis.bossart, Liam Girdwood

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.


Regards

Takashi Sakamoto
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: How ALSA handle PCM playing when the ALSA modules are removing
  2019-01-23  5:22 ` Takashi Sakamoto
@ 2019-01-23  5:55   ` Zhu, Yingjiang
  0 siblings, 0 replies; 3+ messages in thread
From: Zhu, Yingjiang @ 2019-01-23  5:55 UTC (permalink / raw)
  To: Takashi Sakamoto, alsa-devel, tiwai, pierre-louis.bossart, Liam Girdwood


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
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-01-23  5:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-23  5:01 How ALSA handle PCM playing when the ALSA modules are removing Zhu, Yingjiang
2019-01-23  5:22 ` Takashi Sakamoto
2019-01-23  5:55   ` Zhu, Yingjiang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.