From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758853Ab0EEH5p (ORCPT ); Wed, 5 May 2010 03:57:45 -0400 Received: from cantor2.suse.de ([195.135.220.15]:40880 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758543Ab0EEH5o (ORCPT ); Wed, 5 May 2010 03:57:44 -0400 Date: Wed, 05 May 2010 09:57:42 +0200 Message-ID: From: Takashi Iwai To: Dan Carpenter Cc: Stefan Richter , alsa-devel@alsa-project.org, Jaroslav Kysela , linux-kernel@vger.kernel.org Subject: Re: [patch] take tu->qlock with irqs disabled In-Reply-To: <20100428082914.GA24513@bicker> References: <20100428082914.GA24513@bicker> User-Agent: Wanderlust/2.15.6 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.7 Emacs/23.1 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org At Wed, 28 Apr 2010 10:29:14 +0200, Dan Carpenter wrote: > > We should disable irqs when we take the tu->qlock because it is used in > the irq handler. The only place that doesn't is > snd_timer_user_ccallback(). Most of the time snd_timer_user_ccallback() > is called with interrupts disabled but the the first ti->ccallback() > call in snd_timer_notify1() has interrupts enabled. > > This was caught by lockdep which generates the following message: > > > ================================= > > [ INFO: inconsistent lock state ] > > 2.6.34-rc5 #5 > > --------------------------------- > > inconsistent {HARDIRQ-ON-W} -> {IN-HARDIRQ-W} usage. > > dolphin/4003 [HC1[1]:SC0[0]:HE0:SE1] takes: > > (&(&tu->qlock)->rlock){?.+...}, at: [] snd_timer_user_tinterrupt+0x28/0x132 [snd_timer] > > {HARDIRQ-ON-W} state was registered at: > > [] __lock_acquire+0x654/0x1482 > > [] lock_acquire+0x5c/0x73 > > [] _raw_spin_lock+0x25/0x34 > > [] snd_timer_user_ccallback+0x55/0x95 [snd_timer] > > [] snd_timer_notify1+0x53/0xca [snd_timer] > > Reported-by: Stefan Richter > Signed-off-by: Dan Carpenter Thanks, applied now. Will be included in the next pull request. Takashi > diff --git a/sound/core/timer.c b/sound/core/timer.c > index 7394365..5040c7b 100644 > --- a/sound/core/timer.c > +++ b/sound/core/timer.c > @@ -1160,6 +1160,7 @@ static void snd_timer_user_ccallback(struct snd_timer_instance *timeri, > { > struct snd_timer_user *tu = timeri->callback_data; > struct snd_timer_tread r1; > + unsigned long flags; > > if (event >= SNDRV_TIMER_EVENT_START && > event <= SNDRV_TIMER_EVENT_PAUSE) > @@ -1169,9 +1170,9 @@ static void snd_timer_user_ccallback(struct snd_timer_instance *timeri, > r1.event = event; > r1.tstamp = *tstamp; > r1.val = resolution; > - spin_lock(&tu->qlock); > + spin_lock_irqsave(&tu->qlock, flags); > snd_timer_user_append_to_tqueue(tu, &r1); > - spin_unlock(&tu->qlock); > + spin_unlock_irqrestore(&tu->qlock, flags); > kill_fasync(&tu->fasync, SIGIO, POLL_IN); > wake_up(&tu->qchange_sleep); > } >