From patchwork Fri Jun 19 12:50:02 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: michael X-Patchwork-Id: 28912 X-Patchwork-Delegate: galak@kernel.crashing.org Return-Path: X-Original-To: patchwork-incoming@bilbo.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from ozlabs.org (ozlabs.org [203.10.76.45]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "mx.ozlabs.org", Issuer "CA Cert Signing Authority" (verified OK)) by bilbo.ozlabs.org (Postfix) with ESMTPS id 25A19B7267 for ; Fri, 19 Jun 2009 23:49:32 +1000 (EST) Received: by ozlabs.org (Postfix) id 13B8BDDDA2; Fri, 19 Jun 2009 23:49:32 +1000 (EST) Delivered-To: patchwork-incoming@ozlabs.org Received: from bilbo.ozlabs.org (bilbo.ozlabs.org [203.10.76.25]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "bilbo.ozlabs.org", Issuer "CAcert Class 3 Root" (verified OK)) by ozlabs.org (Postfix) with ESMTPS id 1211EDDDA1 for ; Fri, 19 Jun 2009 23:49:32 +1000 (EST) Received: from bilbo.ozlabs.org (localhost [127.0.0.1]) by bilbo.ozlabs.org (Postfix) with ESMTP id C60F8B75F8 for ; Fri, 19 Jun 2009 23:49:09 +1000 (EST) Received: from ozlabs.org (ozlabs.org [203.10.76.45]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "mx.ozlabs.org", Issuer "CA Cert Signing Authority" (verified OK)) by bilbo.ozlabs.org (Postfix) with ESMTPS id 56684B70F2 for ; Fri, 19 Jun 2009 23:49:02 +1000 (EST) Received: by ozlabs.org (Postfix) id 46C86DDD1C; Fri, 19 Jun 2009 23:49:02 +1000 (EST) Delivered-To: linuxppc-dev@ozlabs.org X-Greylist: delayed 3597 seconds by postgrey-1.31 at ozlabs; Fri, 19 Jun 2009 23:49:01 EST Received: from sssup.it (ms01.sssup.it [193.205.80.99]) by ozlabs.org (Postfix) with ESMTP id 38071DDD1B for ; Fri, 19 Jun 2009 23:49:00 +1000 (EST) Received: from [193.205.82.7] (HELO gandalf.sssup.it) by sssup.it (CommuniGate Pro SMTP 4.1.8) with ESMTP-TLS id 51682323; Fri, 19 Jun 2009 14:37:36 +0200 Received: from smaug.retis (smaug.retis [10.30.3.72]) by gandalf.sssup.it (8.12.10/8.12.10) with ESMTP id n5JCmxiT004763; Fri, 19 Jun 2009 14:48:59 +0200 Received: by smaug.retis (Postfix, from userid 1006) id 4A721538C3; Fri, 19 Jun 2009 14:50:02 +0200 (CEST) Date: Fri, 19 Jun 2009 14:50:02 +0200 From: Michael Trimarchi To: jochen@scram.de Subject: [RFC] Fix stuck on cpm-i2c driver Message-ID: <20090619125002.GA17067@gandalf.sssup.it> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.18 (2008-05-17) Cc: bruno@evidence.eu.com, trimarchi@gandalf.sssup.it, linux-i2c@vger.kernel.org, linuxppc-dev@ozlabs.org X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org When a process tries to read/write a disconnected i2c device, it receives a signal (e.g. ctrl-c) and the kernel gets stuck. BUG: soft lockup - CPU#0 stuck for 61s! [I2CEEpromTest:392] NIP: c01628f8 LR: c01628f0 CTR: c00177cc REGS: c39abd70 TRAP: 0901 Not tainted (2.6.25.7-alcore) MSR: 00009032 CR: 42042048 XER: 20000000 TASK = c3889bd0[392] 'I2CEEpromTest' THREAD: c39aa000 GPR00: 00009000 c39abe20 c3889bd0 c39075c8 c39abe28 00000001 00000000 00000001 GPR08: c3889bd0 c39075c8 00009032 c39abe34 00002437 NIP [c01628f8] cpm_i2c_xfer+0x5fc/0x6d0 LR [c01628f0] cpm_i2c_xfer+0x5f4/0x6d0 Call Trace: [c39abe20] [c0162924] cpm_i2c_xfer+0x628/0x6d0 (unreliable) [c39abe90] [c015f6a0] i2c_transfer+0x88/0xb4 [c39abeb0] [c0160164] i2c_master_recv+0x48/0x6c [c39abed0] [c01618dc] i2cdev_read+0x50/0xe4 [c39abef0] [c0068b24] vfs_read+0xc4/0x108 [c39abf10] [c0068f4c] sys_read+0x4c/0x90 [c39abf40] [c000d348] ret_from_syscall+0x0/0x38 Instruction dump: 3bc00064 92610010 3bf201c8 92810014 3b61 This happen because though the wait_event_interruptible_timeout takes the signals into account, the driver does not handle them. We propose to change the wait_event_interruptible_timeout with wait_event_timeout, leaving the signals to be handled in other points on the upper layers. Signed-off-by: Bruno Morelli Signed-off-by: Michael Trimarchi Acked-by: Jochen Friedrich diff --git a/drivers/i2c/busses/i2c-cpm.c b/drivers/i2c/busses/i2c-cpm.c index b5db8b8..9c2e100 100644 --- a/drivers/i2c/busses/i2c-cpm.c +++ b/drivers/i2c/busses/i2c-cpm.c @@ -140,7 +140,7 @@ static irqreturn_t cpm_i2c_interrupt(int irq, void *dev_id) dev_dbg(&adap->dev, "Interrupt: %x\n", i); - wake_up_interruptible(&cpm->i2c_wait); + wake_up(&cpm->i2c_wait); return i ? IRQ_HANDLED : IRQ_NONE; } @@ -364,12 +364,12 @@ static int cpm_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num) dev_dbg(&adap->dev, "test ready.\n"); pmsg = &msgs[tptr]; if (pmsg->flags & I2C_M_RD) - ret = wait_event_interruptible_timeout(cpm->i2c_wait, + ret = wait_event_timeout(cpm->i2c_wait, (in_be16(&tbdf[tptr].cbd_sc) & BD_SC_NAK) || !(in_be16(&rbdf[rptr].cbd_sc) & BD_SC_EMPTY), 1 * HZ); else - ret = wait_event_interruptible_timeout(cpm->i2c_wait, + ret = wait_event_timeout(cpm->i2c_wait, !(in_be16(&tbdf[tptr].cbd_sc) & BD_SC_READY), 1 * HZ); if (ret == 0) {