Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757242AbZDJXGR (ORCPT ); Fri, 10 Apr 2009 19:06:17 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751758AbZDJXF7 (ORCPT ); Fri, 10 Apr 2009 19:05:59 -0400 Received: from smtp1.linux-foundation.org ([140.211.169.13]:53188 "EHLO smtp1.linux-foundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751083AbZDJXF6 (ORCPT ); Fri, 10 Apr 2009 19:05:58 -0400 Date: Fri, 10 Apr 2009 16:01:37 -0700 From: Andrew Morton To: Alessio Igor Bogani Cc: oakad@yahoo.com, linux-kernel@vger.kernel.org, abogani@texware.it, Ingo Molnar , Thomas Gleixner , Alan Cox Subject: Re: [PATCH] tifm: avoid inconsistent lock state Message-Id: <20090410160137.2f6261ff.akpm@linux-foundation.org> In-Reply-To: <1239288723-4240-1-git-send-email-abogani@texware.it> References: <1239288723-4240-1-git-send-email-abogani@texware.it> X-Mailer: Sylpheed version 2.2.4 (GTK+ 2.8.20; i486-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 5521 Lines: 115 On Thu, 9 Apr 2009 16:52:03 +0200 Alessio Igor Bogani wrote: > Avoid the following INFO from lock debugging: > > [ 901.190400] irq 18: nobody cared (try booting with the "irqpoll" option) > [ 901.190411] Pid: 4255, comm: pulseaudio Not tainted 2.6.30-rc1 #21 > [ 901.190415] Call Trace: > [ 901.190419] [] ? tifm_7xx1_isr+0x99/0x170 [tifm_7xx1] > [ 901.190452] [] __report_bad_irq+0x2b/0xb0 > [ 901.190459] [] note_interrupt+0x198/0x1e0 > [ 901.190467] [] handle_fasteoi_irq+0xdd/0x110 > [ 901.190474] [] handle_irq+0x24/0x40 > [ 901.190483] [] do_IRQ+0x73/0x100 > [ 901.190491] [] ret_from_intr+0x0/0x16 > [ 901.190495] [] ? _spin_unlock_irqrestore+0x72/0x80 > [ 901.190510] [] ? add_wait_queue+0x4e/0x60 > [ 901.190517] [] ? __pollwait+0x86/0x110 > [ 901.190535] [] ? snd_ctl_poll+0x61/0x70 [snd] > [ 901.190543] [] ? do_sys_poll+0x21c/0x4c0 > [ 901.190549] [] ? __pollwait+0x0/0x110 > [ 901.190556] [] ? pollwake+0x0/0x50 > [ 901.190562] [] ? pollwake+0x0/0x50 > [ 901.190569] [] ? pollwake+0x0/0x50 > [ 901.190575] [] ? pollwake+0x0/0x50 > [ 901.190581] [] ? pollwake+0x0/0x50 > [ 901.190587] [] ? pollwake+0x0/0x50 > [ 901.190594] [] ? _spin_unlock_irq+0x37/0x70 > [ 901.190601] [] ? _spin_unlock_irq+0x41/0x70 > [ 901.190609] [] ? finish_task_switch+0x83/0x140 > [ 901.190616] [] ? finish_task_switch+0x40/0x140 > [ 901.190625] [] ? __lock_acquire+0x328/0x13e0 > [ 901.190634] [] ? _raw_spin_unlock+0x7e/0xa0 > [ 901.190642] [] ? getnstimeofday+0x61/0xf0 > [ 901.190649] [] ? ktime_get_ts+0x61/0x70 > [ 901.190656] [] ? poll_select_set_timeout+0x88/0xa0 > [ 901.190663] [] ? sys_poll+0x7c/0x110 > [ 901.190670] [] ? system_call_fastpath+0x16/0x1b > [ 901.190675] handlers: > [ 901.190679] [] (usb_hcd_irq+0x0/0xe0) > [ 901.190690] [] (usb_hcd_irq+0x0/0xe0) > [ 901.190699] [] (tifm_7xx1_isr+0x0/0x170 [tifm_7xx1]) > [ 901.190710] Disabling IRQ #18 > [ 901.288126] > [ 901.288128] ================================= > [ 901.288132] [ INFO: inconsistent lock state ] > [ 901.288135] 2.6.30-rc1 #21 > [ 901.288137] --------------------------------- > [ 901.288140] inconsistent {IN-HARDIRQ-W} -> {HARDIRQ-ON-W} usage. > [ 901.288143] swapper/0 [HC0[0]:SC1[1]:HE1:SE0] takes: > [ 901.288145] (&irq_desc_lock_class){?.-...}, at: [] try_one_irq+0x33/0x160 > [ 901.288156] {IN-HARDIRQ-W} state was registered at: > [ 901.288158] [] 0xffffffffffffffff > [ 901.288172] irq event stamp: 970106 > [ 901.288174] hardirqs last enabled at (970106): [] _spin_unlock_irq+0x30/0x70 > [ 901.288181] hardirqs last disabled at (970105): [] _spin_lock_irq+0x1f/0x90 > [ 901.288186] softirqs last enabled at (970078): [] __do_softirq+0x1d4/0x250 > [ 901.288193] softirqs last disabled at (970103): [] call_softirq+0x1c/0x30 > > Signed-off-by: Alessio Igor Bogani > --- > drivers/misc/tifm_7xx1.c | 7 ++++--- > 1 files changed, 4 insertions(+), 3 deletions(-) > > diff --git a/drivers/misc/tifm_7xx1.c b/drivers/misc/tifm_7xx1.c > index a6ef182..b38ee02 100644 > --- a/drivers/misc/tifm_7xx1.c > +++ b/drivers/misc/tifm_7xx1.c > @@ -41,11 +41,12 @@ static irqreturn_t tifm_7xx1_isr(int irq, void *dev_id) > struct tifm_adapter *fm = dev_id; > struct tifm_dev *sock; > unsigned int irq_status, cnt; > + unsigned long flags; > > - spin_lock(&fm->lock); > + spin_lock_irqsave(&fm->lock, flags); > irq_status = readl(fm->addr + FM_INTERRUPT_STATUS); > if (irq_status == 0 || irq_status == (~0)) { > - spin_unlock(&fm->lock); > + spin_unlock_irqrestore(&fm->lock, flags); > return IRQ_NONE; > } > > @@ -74,7 +75,7 @@ static irqreturn_t tifm_7xx1_isr(int irq, void *dev_id) > else > tifm_queue_work(&fm->media_switcher); > > - spin_unlock(&fm->lock); > + spin_unlock_irqrestore(&fm->lock, flags); > return IRQ_HANDLED; > } > Dunno, I think the problem here is in kernel/irq/spurious.c. tifm_7xx1_isr() can legitimately use spin_lock() on that lock, because it's running in hard IRQ context and "knows" that tifm_7xx1_isr() cannot be reentered on this CPU while it is running. But try_one_irq() is running tifm_7xx1_isr() with local interrupts enabled, which upsets lockdep. An appropriate fix might be to change try_one_irq() to run the handler under local_irq_disable(), but I'm sure it'll get more complex than that :( But I suspect that the code as it stands is non-buggy. Unless the interrupt can magically come back to life. In which case any change we make is purely a make-lockdep-shut-up thing. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/