From patchwork Sat Mar 1 10:56:08 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 3746781 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 2AFA1BF13A for ; Sat, 1 Mar 2014 11:00:07 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 57EE220259 for ; Sat, 1 Mar 2014 11:00:06 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 58DF820179 for ; Sat, 1 Mar 2014 11:00:05 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WJhc3-0006OE-3B; Sat, 01 Mar 2014 10:57:48 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WJhbg-0007X3-DI; Sat, 01 Mar 2014 10:57:24 +0000 Received: from mail-la0-f54.google.com ([209.85.215.54]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WJhb9-0007QP-6d for linux-arm-kernel@lists.infradead.org; Sat, 01 Mar 2014 10:56:52 +0000 Received: by mail-la0-f54.google.com with SMTP id mc6so3456157lab.13 for ; Sat, 01 Mar 2014 02:56:29 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=x5X4vLrabIhyCPyvsVr2meSEBCH+iRLslgOGJwNv0co=; b=ikPfiXJ3tGtqFxL6BSEHRxnJkHHTdbslhLzsYg14pXSAVy/BmtSy7b+KGymWVb6OLa Q74SaZz7A5aURwD67ducnZSWrUjZxnC5/GNzXOIFc1wCDuOyrYsdBKpWsC0AUIQMexYu k4vjBjFy4+1E9uaN15WPk3tsede38eo7riiYufry/1GEVqDCquRwMF2C7hxXjDfzVhZm LJ8yZfyZo8ESw1MXUook7E6/jY0L8l+e+cGiqI6ZS9TRDrukHm3nRaDj0pw74M3t8opQ oO0njpfo+A3TsxkXE1cgy0Lhycxcac93udmV4+rhxgON8DJCzcPnS3KUvPAMOmPSDxBI 10GQ== X-Gm-Message-State: ALoCoQkbiC78DLEV9JDE5En1BhObXpRNWAAIgbT2pkmHk68h4pkj8IJ9ZW7HPN4yB7cWytMKosxX X-Received: by 10.152.28.7 with SMTP id x7mr23359lag.57.1393671388984; Sat, 01 Mar 2014 02:56:28 -0800 (PST) Received: from linaro-ulf.lan (90-231-160-185-no158.tbcn.telia.com. [90.231.160.185]) by mx.google.com with ESMTPSA id qf1sm4532484lbc.8.2014.03.01.02.56.26 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 01 Mar 2014 02:56:27 -0800 (PST) From: Ulf Hansson To: "Rafael J. Wysocki" , Len Brown , Pavel Machek , linux-pm@vger.kernel.org Subject: [PATCH 5/8] i2c: nomadik: Fixup system suspend Date: Sat, 1 Mar 2014 11:56:08 +0100 Message-Id: <1393671371-2398-6-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1393671371-2398-1-git-send-email-ulf.hansson@linaro.org> References: <1393671371-2398-1-git-send-email-ulf.hansson@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140301_055651_425005_A6069029 X-CRM114-Status: GOOD ( 14.88 ) X-Spam-Score: 0.5 (/) Cc: Ulf Hansson , Kevin Hilman , Russell King , Wolfram Sang , Greg Kroah-Hartman , Linus Walleij , Mark Brown , Alan Stern , Josh Cartwright , linux-arm-kernel@lists.infradead.org, Alessandro Rubini X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,KHOP_BIG_TO_CC, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=no version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP For !CONFIG_PM_RUNTIME, the device were never put back into active state while resuming. For CONFIG_PM_RUNTIME, we blindly trusted the device to be inactive while we were about to handle it at suspend late, which is just too optimistic. Even if the driver uses pm_runtime_put_sync() after each tranfer to return it's runtime PM resources, there are no guarantees this will actually mean the device will inactivated. The reason is that the PM core will prevent runtime suspend during system suspend, and thus when a transfer occurs during the early phases of system suspend the device will be kept active after the transfer. To handle both issues above, use pm_runtime_force_suspend|resume() from the system suspend|resume callbacks. Cc: Alessandro Rubini Cc: Linus Walleij Cc: Wolfram Sang Signed-off-by: Ulf Hansson --- drivers/i2c/busses/i2c-nomadik.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/i2c/busses/i2c-nomadik.c b/drivers/i2c/busses/i2c-nomadik.c index 8082f5c..519f5b8 100644 --- a/drivers/i2c/busses/i2c-nomadik.c +++ b/drivers/i2c/busses/i2c-nomadik.c @@ -879,19 +879,19 @@ static irqreturn_t i2c_irq_handler(int irq, void *arg) #ifdef CONFIG_PM_SLEEP static int nmk_i2c_suspend_late(struct device *dev) { - pinctrl_pm_select_sleep_state(dev); + int ret; + ret = pm_runtime_force_suspend(dev); + if (ret) + return ret; + + pinctrl_pm_select_sleep_state(dev); return 0; } static int nmk_i2c_resume_early(struct device *dev) { - /* First go to the default state */ - pinctrl_pm_select_default_state(dev); - /* Then let's idle the pins until the next transfer happens */ - pinctrl_pm_select_idle_state(dev); - - return 0; + return pm_runtime_force_resume(dev); } #endif