Alsa-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Mack <daniel@caiaq.de>
To: Tobias Schneider <tobsnyder@gmx.de>
Cc: alsa-devel@alsa-project.org
Subject: Re: ALSA Control Questions
Date: Thu, 3 Dec 2009 20:50:18 +0100	[thread overview]
Message-ID: <20091203195018.GK14091@buzzloop.caiaq.de> (raw)
In-Reply-To: <4B1803CE.3080501@gmx.de>

On Thu, Dec 03, 2009 at 07:30:38PM +0100, Tobias Schneider wrote:
> 2. The more interesting question: as written in "Writing an alsa driver" 
> callbacks are basically not atomic, but I am getting  BUG: scheduling 
> while atomic: amixer/0x00000001/430 Call Trace: .[..] in "put" 
> callback?? So what is meant with "basically not atomic"?? What is 
> allowed and what is not allowed, am I able to get hardware interrupts in 
> this context?

That message basically means that you called a scheduling function while
you have preemption switched off. One common pitfall is to let the CPU
reschedule from an interrupt handler or while holding a spinlock.

The basic problem is that if you hold a spinlock and let the CPU do
something else, some other execution path (on the same CPU) could
also try to access the same lock which then deadlocks your system.

It all boils down to: from interrupt handlers or while you hold a
spinlock, you must never call any function that will sleep (and thereby
reschedule). Some functions such like kmalloc have a flag that you can
pass depending on whether you want it to allow to sleep (GFP_KERNEL)
or not (GFP_ATOMIC). If you necessarily _have_ to sleep from atomic
context, you must postpone your work using a work_struct or something
similar.

You should post your code so people can have a look.

HTH,
Daniel

  reply	other threads:[~2009-12-03 19:50 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-03 18:30 ALSA Control Questions Tobias Schneider
2009-12-03 19:50 ` Daniel Mack [this message]
2009-12-04  9:31   ` ALSA Control Questions (atomicity, error handling) Tobias Schneider
2009-12-04 11:27     ` Daniel Mack
2009-12-04 11:34     ` Daniel Mack
2009-12-04 12:02       ` Tobias Schneider
2009-12-04 12:06         ` Daniel Mack
2009-12-04 12:33     ` Clemens Ladisch

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=20091203195018.GK14091@buzzloop.caiaq.de \
    --to=daniel@caiaq.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=tobsnyder@gmx.de \
    /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