Skip to contentSkip to conversation

alsa-utils aplay/arecord can't be interrupted when streaming is not active

DISCUSSION jiwang 2 participants 7 messages Apr 16, 2014 – Apr 21, 2014

lore
Share & tools
lore

jiwang

author
#0 lore raw

Hi All

With latest 1.0.27.2 alsa-utils, I am facing problem to interrupt aplay/arecord when the streaming is not active (no data can be written to or read from cards) further more, if I start aplay/arecord with "-N" nonblocking option, then aplay/arecord can never exit, unless I do a system reset

I found if I revert the following patch

/commit 1d0042d7e948815f8015c62bc53143eed3b83206// //Author: Jaroslav Kysela <[email protected]>//
//Date: Mon Apr 8 13:30:54 2013 +0200//
//
// aplay/arecord: change the interrupt handling using snd_pcm_abort()//
////

//    It is required (exclude the fatal SIGABRT) to call snd_pcm_close() and//
//    the end of work (outside of the interrupt handler). Use new snd_pcm_abort()//
//    function to inform alsa-lib to not ignore EINTR and move the in_aborting//
//    variable to the global scope to be checked in the i/o loops.//

////
// Signed-off-by: Jaroslav Kysela <[email protected]>//
/
http://git.alsa-project.org/?p=alsa-utils.git;a=commit;h=1d0042d7e948815f8015c62bc53143eed3b83206

then aplay/arecord can be interrupted correctly

Is it a defect in aplay.c or did I miss something?

Thanks,
Jiada

#1 lore raw
Quoted 8 lines · jiwang

Hi All

With latest 1.0.27.2 alsa-utils, I am facing problem to interrupt aplay/arecord
when the streaming is not active (no data can be written to or read from cards)
further more, if I start aplay/arecord with "-N" nonblocking option, then aplay/arecord can never exit, unless I do a system reset

If I/O stalls it's usually problem in the driver. You don't write any information about your configuration - post 'aplay -v' to see more.

You may kill the process using the SIGABRT signal.. No reboot is required.

Quoted 27 lines

I found if I revert the following patch

/commit 1d0042d7e948815f8015c62bc53143eed3b83206// //Author: Jaroslav Kysela <[email protected]>//
//Date: Mon Apr 8 13:30:54 2013 +0200//
//

//    aplay/arecord: change the interrupt handling using snd_pcm_abort()//
//    //
//    It is required (exclude the fatal SIGABRT) to call snd_pcm_close()

and//
// the end of work (outside of the interrupt handler). Use new
snd_pcm_abort()//
// function to inform alsa-lib to not ignore EINTR and move the
in_aborting//

//    variable to the global scope to be checked in the i/o loops.//
//    //
//    Signed-off-by: Jaroslav Kysela <[email protected]>//

/
http://git.alsa-project.org/?p=alsa-utils.git;a=commit;h=1d0042d7e948815f8015c62bc53143eed3b83206

then aplay/arecord can be interrupted correctly

Is it a defect in aplay.c or did I miss something?

Thanks,
Jiada

Signature · 3 lines
Jaroslav Kysela <[email protected]>
Linux Kernel Sound Maintainer
ALSA Project; Red Hat, Inc.
author
#2 lore raw

Hi Jaroslav

Quoted 11 lines · Jaroslav Kysela
Quoted 8 lines · jiwang

Hi All

With latest 1.0.27.2 alsa-utils, I am facing problem to interrupt aplay/arecord
when the streaming is not active (no data can be written to or read from cards)
further more, if I start aplay/arecord with "-N" nonblocking option, then aplay/arecord can never exit, unless I do a system reset

If I/O stalls it's usually problem in the driver. You don't write any information about your configuration - post 'aplay -v' to see more.

This issue is caught when we were doing some tests, test for both correct and incorrect configuration of driver and we expect SIGINT can interrupt aplay/arecord in both cases (which was the cause with the old version 1.0.26)

Quoted 1 line

You may kill the process using the SIGABRT signal.. No reboot is required.

Yes, SIGABRT works,
But as in our case:
CPU dai device is waiting on a external clock,
but isnt provided caused the I/O stall
the driver is functioning properly and should still be SIGINT-ed in my opinion

Thanks,
Jiada

Quoted 28 lines
Quoted 27 lines

I found if I revert the following patch

/commit 1d0042d7e948815f8015c62bc53143eed3b83206// //Author: Jaroslav Kysela <[email protected]>//
//Date: Mon Apr 8 13:30:54 2013 +0200//
//

//    aplay/arecord: change the interrupt handling using snd_pcm_abort()//
//    //
//    It is required (exclude the fatal SIGABRT) to call snd_pcm_close()

and//
// the end of work (outside of the interrupt handler). Use new
snd_pcm_abort()//
// function to inform alsa-lib to not ignore EINTR and move the
in_aborting//

//    variable to the global scope to be checked in the i/o loops.//
//    //
//    Signed-off-by: Jaroslav Kysela <[email protected]>//

/
http://git.alsa-project.org/?p=alsa-utils.git;a=commit;h=1d0042d7e948815f8015c62bc53143eed3b83206

then aplay/arecord can be interrupted correctly

Is it a defect in aplay.c or did I miss something?

Thanks,
Jiada

#3 lore raw
Quoted 19 lines · jiwang

Hi Jaroslav

Quoted 11 lines · Jaroslav Kysela
Quoted 8 lines · jiwang

Hi All

With latest 1.0.27.2 alsa-utils, I am facing problem to interrupt aplay/arecord
when the streaming is not active (no data can be written to or read from cards)
further more, if I start aplay/arecord with "-N" nonblocking option, then aplay/arecord can never exit, unless I do a system reset

If I/O stalls it's usually problem in the driver. You don't write any information about your configuration - post 'aplay -v' to see more.

This issue is caught when we were doing some tests, test for both correct and incorrect configuration of driver and we expect SIGINT can interrupt aplay/arecord in both cases (which was the cause with the old version 1.0.26)

Quoted 8 lines
Quoted 1 line

You may kill the process using the SIGABRT signal.. No reboot is required.

Yes, SIGABRT works,
But as in our case:
CPU dai device is waiting on a external clock,
but isnt provided caused the I/O stall
the driver is functioning properly and should still be SIGINT-ed in my opinion

The user space received SIGINT, but the current aplay code tries to finish the device close sequence. Could you determine, in which syscall is the process after you sent SIGINT? A backtrace would be great.

Quoted 32 lines

Thanks,
Jiada

Quoted 28 lines
Quoted 27 lines

I found if I revert the following patch

/commit 1d0042d7e948815f8015c62bc53143eed3b83206// //Author: Jaroslav Kysela <[email protected]>//
//Date: Mon Apr 8 13:30:54 2013 +0200//
//

//    aplay/arecord: change the interrupt handling using snd_pcm_abort()//
//    //
//    It is required (exclude the fatal SIGABRT) to call snd_pcm_close()

and//
// the end of work (outside of the interrupt handler). Use new
snd_pcm_abort()//
// function to inform alsa-lib to not ignore EINTR and move the
in_aborting//

//    variable to the global scope to be checked in the i/o loops.//
//    //
//    Signed-off-by: Jaroslav Kysela <[email protected]>//

/
http://git.alsa-project.org/?p=alsa-utils.git;a=commit;h=1d0042d7e948815f8015c62bc53143eed3b83206

then aplay/arecord can be interrupted correctly

Is it a defect in aplay.c or did I miss something?

Thanks,
Jiada

Signature · 3 lines
Jaroslav Kysela <[email protected]>
Linux Kernel Sound Maintainer
ALSA Project; Red Hat, Inc.
author
#4 lore raw

Hi Jaroslav

Quoted 29 lines · Jaroslav Kysela
Quoted 19 lines · jiwang

Hi Jaroslav

Quoted 11 lines · Jaroslav Kysela
Quoted 8 lines · jiwang

Hi All

With latest 1.0.27.2 alsa-utils, I am facing problem to interrupt aplay/arecord
when the streaming is not active (no data can be written to or read from cards)
further more, if I start aplay/arecord with "-N" nonblocking option, then aplay/arecord can never exit, unless I do a system reset

If I/O stalls it's usually problem in the driver. You don't write any information about your configuration - post 'aplay -v' to see more.

This issue is caught when we were doing some tests, test for both correct and incorrect configuration of driver and we expect SIGINT can interrupt aplay/arecord in both cases (which was the cause with the old version 1.0.26)

Quoted 8 lines
Quoted 1 line

You may kill the process using the SIGABRT signal.. No reboot is required.

Yes, SIGABRT works,
But as in our case:
CPU dai device is waiting on a external clock,
but isnt provided caused the I/O stall
the driver is functioning properly and should still be SIGINT-ed in my opinion

Quoted 4 lines

The user space received SIGINT, but the current aplay code tries to finish the device close sequence. Could you determine, in which syscall is the process after you sent SIGINT? A backtrace would be great.

Currently I don't have access to board,

if I recall correctly
when aplay/arecord work in blocking mode
aplay is at:
pcm_write
--> writei_func(handle, data, count);
arecord is at:
pcm_read
--> readi_func(handle, data, count);

when aplay/arecord work in nonblocking mode
aplay is looping at
pcm_write
--> while (count > 0) { ... }
arecord is looping at
pcm_read
--> while (count > 0) { ... }

I will check it again when I have access to my board tomorrow

Thanks,
Jiada

Quoted 34 lines
Quoted 32 lines

Thanks,
Jiada

Quoted 28 lines
Quoted 27 lines

I found if I revert the following patch

/commit 1d0042d7e948815f8015c62bc53143eed3b83206// //Author: Jaroslav Kysela <[email protected]>//
//Date: Mon Apr 8 13:30:54 2013 +0200//
//

//    aplay/arecord: change the interrupt handling using snd_pcm_abort()//
//    //
//    It is required (exclude the fatal SIGABRT) to call snd_pcm_close()

and//
// the end of work (outside of the interrupt handler). Use new
snd_pcm_abort()//
// function to inform alsa-lib to not ignore EINTR and move the
in_aborting//

//    variable to the global scope to be checked in the i/o loops.//
//    //
//    Signed-off-by: Jaroslav Kysela <[email protected]>//

/
http://git.alsa-project.org/?p=alsa-utils.git;a=commit;h=1d0042d7e948815f8015c62bc53143eed3b83206

then aplay/arecord can be interrupted correctly

Is it a defect in aplay.c or did I miss something?

Thanks,
Jiada

author
#5 lore raw
In reply to Jaroslav Kysela

Hi Jaroslav

Quoted 27 lines · Jaroslav Kysela
Quoted 19 lines · jiwang

Hi Jaroslav

Quoted 11 lines · Jaroslav Kysela
Quoted 8 lines · jiwang

Hi All

With latest 1.0.27.2 alsa-utils, I am facing problem to interrupt aplay/arecord
when the streaming is not active (no data can be written to or read from cards)
further more, if I start aplay/arecord with "-N" nonblocking option, then aplay/arecord can never exit, unless I do a system reset

If I/O stalls it's usually problem in the driver. You don't write any information about your configuration - post 'aplay -v' to see more.

This issue is caught when we were doing some tests, test for both correct and incorrect configuration of driver and we expect SIGINT can interrupt aplay/arecord in both cases (which was the cause with the old version 1.0.26)

Quoted 7 lines
Quoted 1 line

You may kill the process using the SIGABRT signal.. No reboot is required.

Yes, SIGABRT works,
But as in our case:
CPU dai device is waiting on a external clock,
but isnt provided caused the I/O stall
the driver is functioning properly and should still be SIGINT-ed in my opinion

Quoted 3 lines

The user space received SIGINT, but the current aplay code tries to finish the device close sequence. Could you determine, in which syscall is the process after you sent SIGINT? A backtrace would be great.

I am not sure if this is want you wanted
I got the following trace just after send SIGINT to blocking aplay

cat trace | tail -10

           aplay-648   [001] ...1  1677.882125: snd_pcm_sync_ptr 
<-snd_pcm_common_ioctl1
           aplay-648   [001] ...1  1677.882161: snd_pcm_playback_ioctl 
<-vfs_ioctl
           aplay-648   [001] ...1  1677.882162: snd_pcm_lib_write 
<-snd_pcm_playback_ioctl1
           aplay-648   [001] d..3  1677.882165: soc_pcm_pointer 
<-snd_pcm_update_hw_ptr0
           aplay-648   [001] d..3  1677.882167: 
snd_dmaengine_pcm_pointer_no_residue <-soc_pcm_pointer
          <idle>-0     [001] d.h4  1677.882321: fsl_esai_start_transmit 
<-tx_startup_timer_callback
           aplay-648   [000] ...1  1687.539380: snd_pcm_playback_ioctl 
<-vfs_ioctl
           aplay-648   [000] ...1  1687.539386: snd_pcm_lib_write 
<-snd_pcm_playback_ioctl1
           aplay-648   [000] d..3  1687.539391: soc_pcm_pointer 
<-snd_pcm_update_hw_ptr0
           aplay-648   [000] d..3  1687.539393: 

snd_dmaengine_pcm_pointer_no_residue <-soc_pcm_pointer

Thanks,
Jiada

Quoted 31 lines
Quoted 30 lines

Thanks,
Jiada

Quoted 27 lines
Quoted 27 lines

I found if I revert the following patch

/commit 1d0042d7e948815f8015c62bc53143eed3b83206// //Author: Jaroslav Kysela <[email protected]>//
//Date: Mon Apr 8 13:30:54 2013 +0200//
//

//    aplay/arecord: change the interrupt handling using snd_pcm_abort()//
//    //
//    It is required (exclude the fatal SIGABRT) to call snd_pcm_close()

and//
// the end of work (outside of the interrupt handler). Use new
snd_pcm_abort()//
// function to inform alsa-lib to not ignore EINTR and move the
in_aborting//

//    variable to the global scope to be checked in the i/o loops.//
//    //
//    Signed-off-by: Jaroslav Kysela <[email protected]>//

/
http://git.alsa-project.org/?p=alsa-utils.git;a=commit;h=1d0042d7e948815f8015c62bc53143eed3b83206

then aplay/arecord can be interrupted correctly

Is it a defect in aplay.c or did I miss something?

Thanks,
Jiada

author
#6 lore raw
In reply to Jaroslav Kysela

Hi Jaroslva

Quoted 29 lines · Jaroslav Kysela
Quoted 19 lines · jiwang

Hi Jaroslav

Quoted 11 lines · Jaroslav Kysela
Quoted 8 lines · jiwang

Hi All

With latest 1.0.27.2 alsa-utils, I am facing problem to interrupt aplay/arecord
when the streaming is not active (no data can be written to or read from cards)
further more, if I start aplay/arecord with "-N" nonblocking option, then aplay/arecord can never exit, unless I do a system reset

If I/O stalls it's usually problem in the driver. You don't write any information about your configuration - post 'aplay -v' to see more.

This issue is caught when we were doing some tests, test for both correct and incorrect configuration of driver and we expect SIGINT can interrupt aplay/arecord in both cases (which was the cause with the old version 1.0.26)

Quoted 8 lines
Quoted 1 line

You may kill the process using the SIGABRT signal.. No reboot is required.

Yes, SIGABRT works,
But as in our case:
CPU dai device is waiting on a external clock,
but isnt provided caused the I/O stall
the driver is functioning properly and should still be SIGINT-ed in my opinion

Quoted 4 lines

The user space received SIGINT, but the current aplay code tries to finish the device close sequence. Could you determine, in which syscall is the process after you sent SIGINT? A backtrace would be great.

Do you have any update on this?
is more log required? do you think it should be fixed in aplay?

Thanks,
Jiada

Quoted 34 lines
Quoted 32 lines

Thanks,
Jiada

Quoted 28 lines
Quoted 27 lines

I found if I revert the following patch

/commit 1d0042d7e948815f8015c62bc53143eed3b83206// //Author: Jaroslav Kysela <[email protected]>//
//Date: Mon Apr 8 13:30:54 2013 +0200//
//

//    aplay/arecord: change the interrupt handling using snd_pcm_abort()//
//    //
//    It is required (exclude the fatal SIGABRT) to call snd_pcm_close()

and//
// the end of work (outside of the interrupt handler). Use new
snd_pcm_abort()//
// function to inform alsa-lib to not ignore EINTR and move the
in_aborting//

//    variable to the global scope to be checked in the i/o loops.//
//    //
//    Signed-off-by: Jaroslav Kysela <[email protected]>//

/
http://git.alsa-project.org/?p=alsa-utils.git;a=commit;h=1d0042d7e948815f8015c62bc53143eed3b83206

then aplay/arecord can be interrupted correctly

Is it a defect in aplay.c or did I miss something?

Thanks,
Jiada