ALSA: compress: Make sure we trigger STOP before closing the stream.
Subsystems (2)
PATCH 1/1 ALSA: compress: Make sure we trigger STOP before closing the stream.
Currently we assume that userspace will shut down the compressed stream correctly. However, if userspcae dies (e.g. cplay & ctrl-C) we dont stop the stream before freeing it.
This now checks that the stream is stopped before freeing.
--- sound/core/compress_offload.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
sound/core/compress_offload.c +12 -0
@@ -139,6 +139,18 @@ static int snd_compr_open(struct inode *inode, struct file *f)static int snd_compr_free (struct inode *inode,struct file *f) {struct snd_compr_file *data = f->private_data; +struct snd_compr_runtime *runtime = data->stream.runtime; + +switch (runtime->state) { +case SNDRV_PCM_STATE_RUNNING : +case SNDRV_PCM_STATE_DRAINING : +case SNDRV_PCM_STATE_PAUSED : + data->stream.ops->trigger (&data->stream,SNDRV_PCM_TRIGGER_STOP ); +break ; +default : +break ; + } + data->stream.ops->free (&data->stream);kfree (data->stream.runtime->buffer);kfree (data->stream.runtime);
Signature · 1 line
1.8.1.2
PATCH 1/1 ALSA: compress: Fix compress device unregister.
snd_unregister_device() should return the device type and not stream direction.
--- sound/core/compress_offload.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
sound/core/compress_offload.c +2 -1
@@ -849,7 +849,8 @@ static int snd_compress_dev_disconnect(struct snd_device *device)struct snd_compr *compr; compr = device->device_data; -snd_unregister_device (compr->direction, compr->card, compr->device); +snd_unregister_device (SNDRV_DEVICE_TYPE_COMPRESS , compr->card, + compr->device);return 0 ; }
Signature · 1 line
1.8.1.2
Re: [PATCH] ALSA: compress: Fix compress device unregister.
Quoted 2 lines · Liam Girdwood
snd_unregister_device()should return the device type and not stream direction.
Thanks for fixing this, I saw this but didnt get time to fix it.
Is there a Tested-Acked-??
~Vinod
Quoted 23 lines
Signed-off-by Liam Girdwood <[email protected]>--- sound/core/compress_offload.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)sound/core/compress_offload.c +2
-1@@ -849,7 +849,8 @@ static int snd_compress_dev_disconnect(struct snd_device *device)struct snd_compr *compr; compr = device->device_data; -snd_unregister_device (compr->direction, compr->card, compr->device); +snd_unregister_device (SNDRV_DEVICE_TYPE_COMPRESS , compr->card, + compr->device);return 0 ; }Signature · 1 line
1.8.1.2
Re: [PATCH] ALSA: compress: Fix compress device unregister.
Quoted 7 lines · Vinod Koul
Quoted 2 lines · Liam Girdwood
snd_unregister_device()should return the device type and not stream direction.Thanks for fixing this, I saw this but didnt get time to fix it.
Acked-by Vinod Koul <[email protected]>Tested-by Vinod Koul <[email protected]>
Also pls CC stable, this fixed would help in older kernels too
~Vinod
Quoted 29 lines
Is there a Tested-Acked-??
~Vinod
Quoted 23 lines
Signed-off-by Liam Girdwood <[email protected]>--- sound/core/compress_offload.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)sound/core/compress_offload.c +2
-1@@ -849,7 +849,8 @@ static int snd_compress_dev_disconnect(struct snd_device *device)struct snd_compr *compr; compr = device->device_data; -snd_unregister_device (compr->direction, compr->card, compr->device); +snd_unregister_device (SNDRV_DEVICE_TYPE_COMPRESS , compr->card, + compr->device);return 0 ; }Signature · 1 line
1.8.1.2
Takashi Iwai
AppliedRe: [PATCH] ALSA: compress: Fix compress device unregister.
At Mon, 16 Sep 2013 09:52:11 +0530,
Quoted 11 lines · Vinod Koul
Quoted 7 lines · Vinod Koul
Quoted 2 lines · Liam Girdwood
snd_unregister_device()should return the device type and not stream direction.Thanks for fixing this, I saw this but didnt get time to fix it.
Acked-by Vinod Koul <[email protected]>Tested-by Vinod Koul <[email protected]>Also pls CC stable, this fixed would help in older kernels too
I applied this now with these tags, but a pull request to Linus will be postponed until the next week since I've been traveling now.
thanks,
Takashi
Quoted 34 lines
~Vinod
Quoted 29 lines
Is there a Tested-Acked-??
~Vinod
Quoted 23 lines
Signed-off-by Liam Girdwood <[email protected]>--- sound/core/compress_offload.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)sound/core/compress_offload.c +2
-1@@ -849,7 +849,8 @@ static int snd_compress_dev_disconnect(struct snd_device *device)struct snd_compr *compr; compr = device->device_data; -snd_unregister_device (compr->direction, compr->card, compr->device); +snd_unregister_device (SNDRV_DEVICE_TYPE_COMPRESS , compr->card, + compr->device);return 0 ; }Signature · 1 line
1.8.1.2
Quoted 16 lines · Liam Girdwood
Currently we assume that userspace will shut down the compressed stream correctly. However, if userspcae dies (e.g. cplay & ctrl-C) we dont stop the stream before freeing it.
This now checks that the stream is stopped before freeing.
Signed-off-by Liam Girdwood <[email protected]>--- sound/core/compress_offload.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)sound/core/compress_offload.c +0
-0
sound/core/compress_offload.c static int snd_compr_open(struct inode *inode, struct file *f) · line 148
Quoted 10 lines
sound/core/compress_offload.c +7
-0@@ -139,6 +139,18 @@ static int snd_compr_open(struct inode *inode, struct file *f)static int snd_compr_free (struct inode *inode,struct file *f) {struct snd_compr_file *data = f->private_data; +struct snd_compr_runtime *runtime = data->stream.runtime; + +switch (runtime->state) { +case SNDRV_PCM_STATE_RUNNING : +case SNDRV_PCM_STATE_DRAINING : +case SNDRV_PCM_STATE_PAUSED : + data->stream.ops->trigger (&data->stream,SNDRV_PCM_TRIGGER_STOP );
when usermode dies the free will get invoked as we have below. The free is a valid trigger from any state. So shouldnt the DSP then STOP the DMAs and free the streams.
Given that most of the usage is a DSP then IMO it might make send to tell DSP that stop and cleanup rather than saying stop and cleanup?
~Vinod
Quoted 11 lines
sound/core/compress_offload.c +5
-0+break ; +default : +break ; + } + data->stream.ops->free (&data->stream);kfree (data->stream.runtime->buffer);kfree (data->stream.runtime);Signature · 1 line
1.8.1.2
Quoted 22 lines · Vinod Koul
Quoted 21 lines · Liam Girdwood
Currently we assume that userspace will shut down the compressed stream correctly. However, if userspcae dies (e.g. cplay & ctrl-C) we dont stop the stream before freeing it.
This now checks that the stream is stopped before freeing.
Signed-off-by Liam Girdwood <[email protected]>--- sound/core/compress_offload.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)sound/core/compress_offload.c +2
-0@@ -139,6 +139,18 @@ static int snd_compr_open(struct inode *inode, struct file *f)static int snd_compr_free (struct inode *inode,struct file *f) {struct snd_compr_file *data = f->private_data; +struct snd_compr_runtime *runtime = data->stream.runtime; +
Quoted 8 lines
sound/core/compress_offload.c static int snd_compr_open(struct inode *inode, struct file *f) · line 148
Quoted 5 lines
sound/core/compress_offload.c +5
-0+switch (runtime->state) { +case SNDRV_PCM_STATE_RUNNING : +case SNDRV_PCM_STATE_DRAINING : +case SNDRV_PCM_STATE_PAUSED : + data->stream.ops->trigger (&data->stream,SNDRV_PCM_TRIGGER_STOP );when usermode dies the free will get invoked as we have below. The free is a valid trigger from any state. So shouldnt the DSP then STOP the DMAs and free the streams.
This means that the compressed stream ops don't follow the PCM ops wrt trigger() sequencing (i.e. we have to add extra logic in free to deal with this difference).
I think it would be better to follow the PCM operations use case here as it simplifies the driver code and stops people making the false assumption that trigger() works the same way throughout ALSA ?
Quoted 3 lines
Given that most of the usage is a DSP then IMO it might make send to tell DSP that stop and cleanup rather than saying stop and cleanup?
Sorry, don't follow you here ;)
Liam
Quoted 13 lines
~Vinod
Quoted 11 lines
sound/core/compress_offload.c +5
-0+break ; +default : +break ; + } + data->stream.ops->free (&data->stream);kfree (data->stream.runtime->buffer);kfree (data->stream.runtime);Signature · 1 line
1.8.1.2
---------------------------------------------------------------------
Intel Corporation (UK) Limited
Registered No. 1134945 (England)
Registered Office: Pipers Way, Swindon SN3 1RJ
VAT No: 860 2173 47
This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.
At Mon, 16 Sep 2013 12:01:23 +0100,
Quoted 33 lines · Liam Girdwood
Quoted 22 lines · Vinod Koul
Quoted 21 lines · Liam Girdwood
Currently we assume that userspace will shut down the compressed stream correctly. However, if userspcae dies (e.g. cplay & ctrl-C) we dont stop the stream before freeing it.
This now checks that the stream is stopped before freeing.
Signed-off-by Liam Girdwood <[email protected]>--- sound/core/compress_offload.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)sound/core/compress_offload.c +2
-0@@ -139,6 +139,18 @@ static int snd_compr_open(struct inode *inode, struct file *f)static int snd_compr_free (struct inode *inode,struct file *f) {struct snd_compr_file *data = f->private_data; +struct snd_compr_runtime *runtime = data->stream.runtime; +Quoted 8 lines
sound/core/compress_offload.c static int snd_compr_open(struct inode *inode, struct file *f) · line 148
Quoted 5 lines
sound/core/compress_offload.c +5
-0+switch (runtime->state) { +case SNDRV_PCM_STATE_RUNNING : +case SNDRV_PCM_STATE_DRAINING : +case SNDRV_PCM_STATE_PAUSED : + data->stream.ops->trigger (&data->stream,SNDRV_PCM_TRIGGER_STOP );when usermode dies the free will get invoked as we have below. The free is a valid trigger from any state. So shouldnt the DSP then STOP the DMAs and free the streams.
Quoted 7 lines
This means that the compressed stream ops don't follow the PCM ops wrt
trigger()sequencing (i.e. we have to add extra logic in free to deal with this difference).I think it would be better to follow the PCM operations use case here as it simplifies the driver code and stops people making the false assumption that
trigger()works the same way throughout ALSA ?
Well, the trigger of compress API has a few more jobs than PCM, and it's exactly what should be fixed (e.g. the proper handling of drain). We need a bit more consensus over that.
So, I didn't apply this patch yet. If Vinod is happy with this (even as a temporary solution), let me know.
thanks,
Takashi
Quoted 34 lines
Quoted 3 lines
Given that most of the usage is a DSP then IMO it might make send to tell DSP that stop and cleanup rather than saying stop and cleanup?
Sorry, don't follow you here ;)
Liam
Quoted 13 lines
~Vinod
Quoted 11 lines
sound/core/compress_offload.c +5
-0+break ; +default : +break ; + } + data->stream.ops->free (&data->stream);kfree (data->stream.runtime->buffer);kfree (data->stream.runtime);Signature · 1 line
1.8.1.2---------------------------------------------------------------------
Intel Corporation (UK) Limited
Registered No. 1134945 (England)
Registered Office: Pipers Way, Swindon SN3 1RJ
VAT No: 860 2173 47This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.
Quoted 43 lines · Takashi Iwai
At Mon, 16 Sep 2013 12:01:23 +0100,
Quoted 33 lines · Liam Girdwood
Quoted 22 lines · Vinod Koul
Quoted 21 lines · Liam Girdwood
Currently we assume that userspace will shut down the compressed stream correctly. However, if userspcae dies (e.g. cplay & ctrl-C) we dont stop the stream before freeing it.
This now checks that the stream is stopped before freeing.
Signed-off-by Liam Girdwood <[email protected]>--- sound/core/compress_offload.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)sound/core/compress_offload.c +2
-0@@ -139,6 +139,18 @@ static int snd_compr_open(struct inode *inode, struct file *f)static int snd_compr_free (struct inode *inode,struct file *f) {struct snd_compr_file *data = f->private_data; +struct snd_compr_runtime *runtime = data->stream.runtime; +Quoted 8 lines
sound/core/compress_offload.c static int snd_compr_open(struct inode *inode, struct file *f) · line 148
Quoted 5 lines
sound/core/compress_offload.c +5
-0+switch (runtime->state) { +case SNDRV_PCM_STATE_RUNNING : +case SNDRV_PCM_STATE_DRAINING : +case SNDRV_PCM_STATE_PAUSED : + data->stream.ops->trigger (&data->stream,SNDRV_PCM_TRIGGER_STOP );when usermode dies the free will get invoked as we have below. The free is a valid trigger from any state. So shouldnt the DSP then STOP the DMAs and free the streams.
Quoted 7 lines
This means that the compressed stream ops don't follow the PCM ops wrt
trigger()sequencing (i.e. we have to add extra logic in free to deal with this difference).I think it would be better to follow the PCM operations use case here as it simplifies the driver code and stops people making the false assumption that
trigger()works the same way throughout ALSA ?
Quoted 6 lines
Well, the trigger of compress API has a few more jobs than PCM, and it's exactly what should be fixed (e.g. the proper handling of drain). We need a bit more consensus over that.
So, I didn't apply this patch yet. If Vinod is happy with this (even as a temporary solution), let me know.
Without this patch we have the two different sequences for shutdown depending on whether userspace dies or not. i.e.
1) Normal: trigger(start) -> play -> trigger(stop) -> close()
2) ctrl-C: trigger(start) -> play -> ctrl-C -> close()
So we miss out the trigger(STOP) and close the device with the stream still in a trigger running state.
Liam
Quoted 40 lines · Liam Girdwood
Quoted 39 lines · Takashi Iwai
At Mon, 16 Sep 2013 12:01:23 +0100,
Quoted 37 lines · Liam Girdwood
Quoted 22 lines · Vinod Koul
Quoted 21 lines · Liam Girdwood
Currently we assume that userspace will shut down the compressed stream correctly. However, if userspcae dies (e.g. cplay & ctrl-C) we dont stop the stream before freeing it.
This now checks that the stream is stopped before freeing.
Signed-off-by Liam Girdwood <[email protected]>--- sound/core/compress_offload.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)sound/core/compress_offload.c +2
-0@@ -139,6 +139,18 @@ static int snd_compr_open(struct inode *inode, struct file *f)static int snd_compr_free (struct inode *inode,struct file *f) {struct snd_compr_file *data = f->private_data; +struct snd_compr_runtime *runtime = data->stream.runtime; +Quoted 8 lines
sound/core/compress_offload.c static int snd_compr_open(struct inode *inode, struct file *f) · line 148
Quoted 5 lines
sound/core/compress_offload.c +5
-0+switch (runtime->state) { +case SNDRV_PCM_STATE_RUNNING : +case SNDRV_PCM_STATE_DRAINING : +case SNDRV_PCM_STATE_PAUSED : + data->stream.ops->trigger (&data->stream,SNDRV_PCM_TRIGGER_STOP );when usermode dies the free will get invoked as we have below. The free is a valid trigger from any state. So shouldnt the DSP then STOP the DMAs and free the streams.
This means that the compressed stream ops don't follow the PCM ops wrt
trigger()sequencing (i.e. we have to add extra logic in free to deal with this difference).
Quoted 7 lines
Quoted 7 lines
Quoted 3 lines
I think it would be better to follow the PCM operations use case here as it simplifies the driver code and stops people making the false assumption that
trigger()works the same way throughout ALSA ?Well, the trigger of compress API has a few more jobs than PCM, and it's exactly what should be fixed (e.g. the proper handling of drain). We need a bit more consensus over that.
Drain handling would be different, I am working on taht way, havent been able to get the time it needs...
Quoted 2 lines
Quoted 2 lines
So, I didn't apply this patch yet. If Vinod is happy with this (even as a temporary solution), let me know.
Sorry my bad, your and Liam mail went to some other folder due to my bad rules set. Sorry for not reverting earlier..
Quoted 10 lines
Without this patch we have the two different sequences for shutdown depending on whether userspace dies or not. i.e.
1) Normal: trigger(start) -> play -> trigger(stop) ->
close()2) ctrl-C: trigger(start) -> play -> ctrl-C ->
close()So we miss out the trigger(STOP) and close the device with the stream still in a trigger running state.
my point was since we have DSPs we can let DSP internally treat free in not stopped cases as goto stop and then free. We do this way in our DSPs and save us a cmd to be sent. Above way though fine will just add that cmd.
The patch is okay but only argument i had was that we can save one cmd since we have a DSP. Am okay if we have this too..
~Vinod
At Mon, 23 Sep 2013 15:11:00 +0530,
Quoted 64 lines · Vinod Koul
Quoted 40 lines · Liam Girdwood
Quoted 39 lines · Takashi Iwai
At Mon, 16 Sep 2013 12:01:23 +0100,
Quoted 37 lines · Liam Girdwood
Quoted 22 lines · Vinod Koul
Quoted 21 lines · Liam Girdwood
Currently we assume that userspace will shut down the compressed stream correctly. However, if userspcae dies (e.g. cplay & ctrl-C) we dont stop the stream before freeing it.
This now checks that the stream is stopped before freeing.
Signed-off-by Liam Girdwood <[email protected]>--- sound/core/compress_offload.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)sound/core/compress_offload.c +2
-0@@ -139,6 +139,18 @@ static int snd_compr_open(struct inode *inode, struct file *f)static int snd_compr_free (struct inode *inode,struct file *f) {struct snd_compr_file *data = f->private_data; +struct snd_compr_runtime *runtime = data->stream.runtime; +Quoted 8 lines
sound/core/compress_offload.c static int snd_compr_open(struct inode *inode, struct file *f) · line 148
Quoted 5 lines
sound/core/compress_offload.c +5
-0+switch (runtime->state) { +case SNDRV_PCM_STATE_RUNNING : +case SNDRV_PCM_STATE_DRAINING : +case SNDRV_PCM_STATE_PAUSED : + data->stream.ops->trigger (&data->stream,SNDRV_PCM_TRIGGER_STOP );when usermode dies the free will get invoked as we have below. The free is a valid trigger from any state. So shouldnt the DSP then STOP the DMAs and free the streams.
This means that the compressed stream ops don't follow the PCM ops wrt
trigger()sequencing (i.e. we have to add extra logic in free to deal with this difference).Quoted 7 lines
Quoted 7 lines
Quoted 3 lines
I think it would be better to follow the PCM operations use case here as it simplifies the driver code and stops people making the false assumption that
trigger()works the same way throughout ALSA ?Well, the trigger of compress API has a few more jobs than PCM, and it's exactly what should be fixed (e.g. the proper handling of drain). We need a bit more consensus over that.
Drain handling would be different, I am working on taht way, havent been able to get the time it needs...
Quoted 2 lines
Quoted 2 lines
So, I didn't apply this patch yet. If Vinod is happy with this (even as a temporary solution), let me know.
Sorry my bad, your and Liam mail went to some other folder due to my bad rules set. Sorry for not reverting earlier..
Quoted 8 lines
Without this patch we have the two different sequences for shutdown depending on whether userspace dies or not. i.e.
1) Normal: trigger(start) -> play -> trigger(stop) ->
close()2) ctrl-C: trigger(start) -> play -> ctrl-C ->
close()
Quoted 8 lines
Quoted 2 lines
So we miss out the trigger(STOP) and close the device with the stream still in a trigger running state.
my point was since we have DSPs we can let DSP internally treat free in not stopped cases as goto stop and then free. We do this way in our DSPs and save us a cmd to be sent. Above way though fine will just add that cmd.
The patch is okay but only argument i had was that we can save one cmd since we have a DSP. Am okay if we have this too..
OK, applied this patch now, too.
thanks,
Takashi