* [PATCH] Improve behaviour of Dreamcast aica ALSA driver in poor resource conditions
@ 2007-07-03 21:36 Adrian McMenamin
2007-07-03 23:08 ` Adrian McMenamin
0 siblings, 1 reply; 3+ messages in thread
From: Adrian McMenamin @ 2007-07-03 21:36 UTC (permalink / raw)
To: alsa-devel; +Cc: linux-kernel
This patch stops the driver from crashing in certain situations (eg if
the network fails when NFS mounted), please apply.
Signed-off by: Adrian McMenamin <adrian@mcmen.demon.co.uk>
--- alsa-kernel/sh/aica.c 2007-06-23 15:25:55.000000000 +0100
+++ linux-2.6.21/sound/sh/aica.c 2007-07-03 22:28:16.000000000 +0100
@@ -366,7 +366,9 @@
*substream)
{
struct snd_card_aica *dreamcastcard = substream->pcm->private_data;
+ flush_workqueue(aica_queue);
del_timer(&dreamcastcard->timer);
+ aica_chn_halt();
kfree(dreamcastcard->channel);
spu_disable();
return 0;
@@ -402,16 +404,11 @@
static int snd_aicapcm_pcm_trigger(struct snd_pcm_substream
*substream, int cmd)
{
- struct snd_card_aica *dreamcastcard;
switch (cmd) {
case SNDRV_PCM_TRIGGER_START:
spu_begin_dma(substream);
break;
case SNDRV_PCM_TRIGGER_STOP:
- dreamcastcard = substream->pcm->private_data;
- if (dreamcastcard->timer.data)
- del_timer(&dreamcastcard->timer);
- aica_chn_halt();
break;
default:
return -EINVAL;
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] Improve behaviour of Dreamcast aica ALSA driver in poor resource conditions
2007-07-03 21:36 [PATCH] Improve behaviour of Dreamcast aica ALSA driver in poor resource conditions Adrian McMenamin
@ 2007-07-03 23:08 ` Adrian McMenamin
2007-07-04 8:51 ` [alsa-devel] " Takashi Iwai
0 siblings, 1 reply; 3+ messages in thread
From: Adrian McMenamin @ 2007-07-03 23:08 UTC (permalink / raw)
To: alsa-devel; +Cc: linux-kernel
On 03/07/07, Adrian McMenamin <adrianmcmenamin@gmail.com> wrote:
> This patch stops the driver from crashing in certain situations (eg if
> the network fails when NFS mounted), please apply.
>
Actually, looked at this again and while the previous patch stopped
the driver from crashing it still locked the sound subsystem. This was
because INIT_WORK was being called on the same work_struct when the
device recovered from the network failure. The patch below ensures
that this does not happen and that instead, PREPARE_WORK is called.
Submitted by: Adrian McMenamin <adrian@mcmen.demon.co.uk>
Signed-off by: Adrian McMenamin <adrian@mcmen.demon.co.uk>
--- alsa-kernel/sh/aica.c 2007-06-23 15:25:55.000000000 +0100
+++ linux-2.6.21/sound/sh/aica.c 2007-07-04 00:01:23.000000000 +0100
@@ -68,6 +68,7 @@
static struct spu_work_holder {
struct work_struct spu_dma_work;
void *sspointer;
+ int already_started;
} spu_working;
static struct workqueue_struct *aica_queue;
@@ -319,7 +320,13 @@
dreamcastcard = substream->pcm->private_data;
/* Use queue to do the heavy lifting */
spu_working.sspointer = substream;
- INIT_WORK(&(spu_working.spu_dma_work), run_spu_dma);
+ if (spu_working.already_started == 1) {
+ PREPARE_WORK(&(spu_working.spu_dma_work), run_spu_dma);
+ }
+ else {
+ INIT_WORK(&(spu_working.spu_dma_work), run_spu_dma);
+ spu_working.already_started = 1;
+ }
queue_work(aica_queue, &(spu_working.spu_dma_work));
/* Timer may already be running */
if (unlikely(dreamcastcard->timer.data)) {
@@ -366,7 +373,9 @@
*substream)
{
struct snd_card_aica *dreamcastcard = substream->pcm->private_data;
+ flush_workqueue(aica_queue);
del_timer(&dreamcastcard->timer);
+ aica_chn_halt();
kfree(dreamcastcard->channel);
spu_disable();
return 0;
@@ -402,17 +411,10 @@
static int snd_aicapcm_pcm_trigger(struct snd_pcm_substream
*substream, int cmd)
{
- struct snd_card_aica *dreamcastcard;
switch (cmd) {
case SNDRV_PCM_TRIGGER_START:
spu_begin_dma(substream);
break;
- case SNDRV_PCM_TRIGGER_STOP:
- dreamcastcard = substream->pcm->private_data;
- if (dreamcastcard->timer.data)
- del_timer(&dreamcastcard->timer);
- aica_chn_halt();
- break;
default:
return -EINVAL;
}
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [alsa-devel] [PATCH] Improve behaviour of Dreamcast aica ALSA driver in poor resource conditions
2007-07-03 23:08 ` Adrian McMenamin
@ 2007-07-04 8:51 ` Takashi Iwai
0 siblings, 0 replies; 3+ messages in thread
From: Takashi Iwai @ 2007-07-04 8:51 UTC (permalink / raw)
To: Adrian McMenamin; +Cc: alsa-devel, linux-kernel
At Wed, 4 Jul 2007 00:08:46 +0100,
Adrian McMenamin wrote:
>
> On 03/07/07, Adrian McMenamin <adrianmcmenamin@gmail.com> wrote:
> > This patch stops the driver from crashing in certain situations (eg if
> > the network fails when NFS mounted), please apply.
> >
>
> Actually, looked at this again and while the previous patch stopped
> the driver from crashing it still locked the sound subsystem. This was
> because INIT_WORK was being called on the same work_struct when the
> device recovered from the network failure. The patch below ensures
> that this does not happen and that instead, PREPARE_WORK is called.
>
> Submitted by: Adrian McMenamin <adrian@mcmen.demon.co.uk>
> Signed-off by: Adrian McMenamin <adrian@mcmen.demon.co.uk>
>
> --- alsa-kernel/sh/aica.c 2007-06-23 15:25:55.000000000 +0100
> +++ linux-2.6.21/sound/sh/aica.c 2007-07-04 00:01:23.000000000 +0100
> @@ -68,6 +68,7 @@
> static struct spu_work_holder {
> struct work_struct spu_dma_work;
> void *sspointer;
> + int already_started;
> } spu_working;
>
> static struct workqueue_struct *aica_queue;
> @@ -319,7 +320,13 @@
> dreamcastcard = substream->pcm->private_data;
> /* Use queue to do the heavy lifting */
> spu_working.sspointer = substream;
> - INIT_WORK(&(spu_working.spu_dma_work), run_spu_dma);
> + if (spu_working.already_started == 1) {
> + PREPARE_WORK(&(spu_working.spu_dma_work), run_spu_dma);
> + }
> + else {
> + INIT_WORK(&(spu_working.spu_dma_work), run_spu_dma);
> + spu_working.already_started = 1;
> + }
> queue_work(aica_queue, &(spu_working.spu_dma_work));
> /* Timer may already be running */
> if (unlikely(dreamcastcard->timer.data)) {
Better to initialize at the beginning of the driver initialization.
With this patch, the work struct is reset at each time you open the
PCM, which is inefficient and can be even racy.
Also, it'd be cleaner to move struct spu_work_holder into struct
snd_card_aica. We'll have snd_card_aica pointer via container_of, so
sspointer can be removed (snd_card_aica has substream).
thanks,
Takashi
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-07-04 8:51 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-07-03 21:36 [PATCH] Improve behaviour of Dreamcast aica ALSA driver in poor resource conditions Adrian McMenamin
2007-07-03 23:08 ` Adrian McMenamin
2007-07-04 8:51 ` [alsa-devel] " Takashi Iwai
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®