All of lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: Giuliano Pochini <pochini@shiny.it>
Cc: Alsa-devel <alsa-devel@lists.sourceforge.net>,
	Clemens Ladisch <clemens@ladisch.de>
Subject: Re: spin_lock_irqwhat ?
Date: Mon, 10 May 2004 17:08:49 +0200	[thread overview]
Message-ID: <s5hfza8fhfi.wl@alsa2.suse.de> (raw)
In-Reply-To: <XFMail.20040510165124.pochini@shiny.it>

At Mon, 10 May 2004 16:51:24 +0200 (CEST),
Giuliano Pochini wrote:
> 
> 
> On 10-May-2004 Takashi Iwai wrote:
> 
> >> > Some drivers use spin_lock_irq() a lot, while others always use
> >> > spin_lock_irqsave(). I can't see the difference. When it's safe
> >> > using the _irq() version ?
> >>
> >> Only when you know that you are not in interrupt context.
> >
> > also, not in the context which already disabled irq.
> 
> Yes, I read the famous Rusty's unreliable guide. My question
> was ALSA-specific. The point is that I don't know when those
> conditions are true. Can and_pcm_period_elapsed() call anything
> other than the pcm callbacks ?  Does the ALSA middle layer ever
> disable interrupts before calling a driver function ?  If it
> doesn't, I can replace spin_lock_irqsave() with spin_lock_irq()
> almost everything. Some callbacks are atomic according to the
> tutorial, but it doesn't say if interrupts are disabled too.
> Are irq (and preempt) disabled before calling .prepare and
> .trigger callbacks ?

prepare and trigger callbacks are already in irq-disabled.
i.e. you need only spin_lock() in them.
also, ioctl(SNDRV_PCM_IOCTL1_RESET) is in the irq-disabled context.

others are not.

some points to be noted:

- prepare can be non-atomic by setting SNDRV_PCM_INFO_NONATOMIC_OPS to
  pcm->info_flags.  (e.g. usbaudio.c)

- pointer callback is not protected.  but it's called also in the
  interrupt context, so you can't use spin_lock_irq() in general.


Takashi


-------------------------------------------------------
This SF.Net email is sponsored by Sleepycat Software
Learn developer strategies Cisco, Motorola, Ericsson & Lucent use to deliver
higher performing products faster, at low TCO.
http://www.sleepycat.com/telcomwpreg.php?From=osdnemail3

  reply	other threads:[~2004-05-10 15:08 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-05-08 11:36 spin_lock_irqwhat ? Giuliano Pochini
2004-05-10  8:31 ` Clemens Ladisch
2004-05-10  9:25   ` Takashi Iwai
2004-05-10 14:51     ` Giuliano Pochini
2004-05-10 15:08       ` Takashi Iwai [this message]
2004-05-13  7:31         ` Giuliano Pochini
2004-05-13 18:57         ` Giuliano Pochini
2004-05-14 10:37           ` Takashi Iwai
2004-05-15 21:37             ` Giuliano Pochini
2004-05-16 15:00               ` 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=s5hfza8fhfi.wl@alsa2.suse.de \
    --to=tiwai@suse.de \
    --cc=alsa-devel@lists.sourceforge.net \
    --cc=clemens@ladisch.de \
    --cc=pochini@shiny.it \
    /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 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.