From mboxrd@z Thu Jan 1 00:00:00 1970 From: Takashi Iwai Subject: Re: spin_lock_irqwhat ? Date: Mon, 10 May 2004 17:08:49 +0200 Sender: alsa-devel-admin@lists.sourceforge.net Message-ID: References: Mime-Version: 1.0 (generated by SEMI 1.14.5 - "Awara-Onsen") Content-Type: text/plain; charset=US-ASCII Return-path: In-Reply-To: Errors-To: alsa-devel-admin@lists.sourceforge.net List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , List-Archive: To: Giuliano Pochini Cc: Alsa-devel , Clemens Ladisch List-Id: alsa-devel@alsa-project.org 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