From patchwork Fri Oct 5 08:55:16 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kalle Jokiniemi X-Patchwork-Id: 1552101 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 20DA840D2D for ; Fri, 5 Oct 2012 09:01:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754836Ab2JEJBp (ORCPT ); Fri, 5 Oct 2012 05:01:45 -0400 Received: from smtp180.iad.emailsrvr.com ([207.97.245.180]:35196 "EHLO smtp180.iad.emailsrvr.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754277Ab2JEJBm (ORCPT ); Fri, 5 Oct 2012 05:01:42 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp58.relay.iad1a.emailsrvr.com (SMTP Server) with ESMTP id EAE9530822C; Fri, 5 Oct 2012 04:55:23 -0400 (EDT) X-Virus-Scanned: OK Received: by smtp58.relay.iad1a.emailsrvr.com (Authenticated sender: kalle.jokiniemi-AT-jollamobile.com) with ESMTPSA id 97F19308213; Fri, 5 Oct 2012 04:55:21 -0400 (EDT) From: Kalle Jokiniemi To: ben-linux@fluff.org, w.sang@pengutronix.de, linux-i2c@vger.kernel.org Cc: tony@atomide.com, linux-omap@vger.kernel.org, Kalle Jokiniemi Subject: [PATCH] i2c: i2c-omap: fix interrupt flood during resume Date: Fri, 5 Oct 2012 11:55:16 +0300 Message-Id: <1349427316-24990-1-git-send-email-kalle.jokiniemi@jollamobile.com> X-Mailer: git-send-email 1.7.4.1 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org The resume_noirq enables interrupts one-by-one starting from first one. Now if the wake up event for suspend came from i2c device, the i2c bus irq gets enabled before the threaded i2c device irq, causing a flood of i2c bus interrupts as the threaded irq that should clear the event is not enabled yet. Fixed the issue by adding suspend_late and resume_early functions that keep i2c bus interrupts disabled until resume_noirq has run completely. Issue was detected doing a wake up from autosleep with twl4030 power key on N9. Patch tested on N9. Signed-off-by: Kalle Jokiniemi --- drivers/i2c/busses/i2c-omap.c | 37 +++++++++++++++++++++++++++++++++++++ 1 files changed, 37 insertions(+), 0 deletions(-) diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c index 801df60..b77b0c2 100644 --- a/drivers/i2c/busses/i2c-omap.c +++ b/drivers/i2c/busses/i2c-omap.c @@ -1158,6 +1158,35 @@ omap_i2c_remove(struct platform_device *pdev) return 0; } +#ifdef CONFIG_SUSPEND +static int omap_i2c_suspend_late(struct device *dev) +{ + + struct platform_device *pdev = to_platform_device(dev); + struct omap_i2c_dev *_dev = platform_get_drvdata(pdev); + + /* + * The noirq_resume enables the interrupts one by one, + * this causes a interrupt flood if the SW irq actually reading + * event from i2c device is enabled only after i2c bus irq, as the + * irq that should clear the event is still disabled. We have to + * disable the bus irq until all other irqs have been enabled. + */ + disable_irq(_dev->irq); + return 0; +} + +static int omap_i2c_resume_early(struct device *dev) +{ + + struct platform_device *pdev = to_platform_device(dev); + struct omap_i2c_dev *_dev = platform_get_drvdata(pdev); + + enable_irq(_dev->irq); + + return 0; +} +#endif #ifdef CONFIG_PM_RUNTIME static int omap_i2c_runtime_suspend(struct device *dev) { @@ -1178,10 +1207,18 @@ static int omap_i2c_runtime_resume(struct device *dev) return 0; } +#endif +#if defined(CONFIG_SUSPEND) || defined(CONFIG_PM_RUNTIME) static struct dev_pm_ops omap_i2c_pm_ops = { +#ifdef CONFIG_SUSPEND + .suspend_late = omap_i2c_suspend_late, + .resume_early = omap_i2c_resume_early, +#endif +#ifdef CONFIG_PM_RUNTIME .runtime_suspend = omap_i2c_runtime_suspend, .runtime_resume = omap_i2c_runtime_resume, +#endif }; #define OMAP_I2C_PM_OPS (&omap_i2c_pm_ops) #else