alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: Jiri Slaby <jslaby@suse.cz>
Cc: linux-kernel@vger.kernel.org, Jaroslav Kysela <perex@perex.cz>,
	alsa-devel@alsa-project.org
Subject: Re: [PATCH v2 2/2] sound: dummy, avoid race with timer
Date: Mon, 19 Jan 2015 10:59:46 +0100	[thread overview]
Message-ID: <s5hppabqeel.wl-tiwai@suse.de> (raw)
In-Reply-To: <1421661401-10533-1-git-send-email-jslaby@suse.cz>

At Mon, 19 Jan 2015 10:56:41 +0100,
Jiri Slaby wrote:
> 
> There is a race between timer and process contexts. Process context
> does not disable irqs, so when a timer ticks inside process' critical
> section, the system can deadlock. Fix this by a traditional _irqsave
> variant of spin_lock.
> 
> [v2] removed ->pointer change as it is called with BH off

Sorry, my previous comment was incorrect.  The start function here is
also called from PCM trigger callback that is already irq-disabled.
So, this is also superfluous.


thanks,

Takashi

> 
> Signed-off-by: Jiri Slaby <jslaby@suse.cz>
> Cc: Jaroslav Kysela <perex@perex.cz>
> Cc: Takashi Iwai <tiwai@suse.de>
> Cc: alsa-devel@alsa-project.org
> ---
>  sound/drivers/dummy.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/sound/drivers/dummy.c b/sound/drivers/dummy.c
> index d11baaf0f0b4..0791210cb4e7 100644
> --- a/sound/drivers/dummy.c
> +++ b/sound/drivers/dummy.c
> @@ -271,10 +271,13 @@ static void dummy_systimer_update(struct dummy_systimer_pcm *dpcm)
>  static int dummy_systimer_start(struct snd_pcm_substream *substream)
>  {
>  	struct dummy_systimer_pcm *dpcm = substream->runtime->private_data;
> -	spin_lock(&dpcm->lock);
> +	unsigned long flags;
> +
> +	spin_lock_irqsave(&dpcm->lock, flags);
>  	dpcm->base_time = jiffies;
>  	dummy_systimer_rearm(dpcm);
> -	spin_unlock(&dpcm->lock);
> +	spin_unlock_irqrestore(&dpcm->lock, flags);
> +
>  	return 0;
>  }
>  
> -- 
> 2.2.1
> 

  reply	other threads:[~2015-01-19  9:59 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-19  9:42 [PATCH 1/3] sound: dummy, use setup_timer and mod_timer Jiri Slaby
2015-01-19  9:42 ` [PATCH 2/3] sound: dummy, use del_timer_sync Jiri Slaby
2015-01-19  9:52   ` Takashi Iwai
2015-01-19  9:59     ` Jiri Slaby
2015-01-19  9:42 ` [PATCH 3/3] sound: dummy, avoid races with timer Jiri Slaby
2015-01-19  9:49   ` Takashi Iwai
2015-01-19  9:53     ` Jiri Slaby
2015-01-19  9:56     ` [PATCH v2 2/2] sound: dummy, avoid race " Jiri Slaby
2015-01-19  9:59       ` Takashi Iwai [this message]
2015-01-19  9:53 ` [PATCH 1/3] sound: dummy, use setup_timer and mod_timer Takashi Iwai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=s5hppabqeel.wl-tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=jslaby@suse.cz \
    --cc=linux-kernel@vger.kernel.org \
    --cc=perex@perex.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).