From patchwork Thu Feb 20 15:31:17 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 3688221 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 772969F2EC for ; Thu, 20 Feb 2014 15:31:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A2BA720179 for ; Thu, 20 Feb 2014 15:31:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C7C6B201BB for ; Thu, 20 Feb 2014 15:31:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754387AbaBTPbk (ORCPT ); Thu, 20 Feb 2014 10:31:40 -0500 Received: from mail-wg0-f52.google.com ([74.125.82.52]:37139 "EHLO mail-wg0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753706AbaBTPbj (ORCPT ); Thu, 20 Feb 2014 10:31:39 -0500 Received: by mail-wg0-f52.google.com with SMTP id b13so1559013wgh.31 for ; Thu, 20 Feb 2014 07:31:38 -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=AnzrzufFAkVY+cTmdz5aDWVHRCeosixvl+E6JLOeiFNg2GQM07O0lm3pzaZmkBRAJ1 6u2VsuR4vIxGL1SnL198Qkkb9Mud7owcLEtQ+BsSt1mGfaRJfN7CUvL13K8seut5VzoD Np4qPansHCCtpsh9TmhcDDRqP/GT/IF3RMP/EItvXwrIPBRJ3IC+dOdpyOIBre5SF76H 7pRQugr9/ZYY1tTibWvVIZtf6CmznUjlyje6To/T8nmvmd/CJPQFSzXgVxS2ObhBFZFY MQ1mz9yqjicJRQ/7hcFmiOnY2b2oaaeJRireoQMm8OYXeDiVZOt2QuCnB8E7O/Q4HM8f yrQw== X-Gm-Message-State: ALoCoQmaGn0QLo3xWAMATiIFsbKLkceWk4B71g3M9EefEeb1g8ObbEWaoejYlCVEUobfGlk4DUAM X-Received: by 10.180.185.197 with SMTP id fe5mr7617645wic.56.1392910298377; Thu, 20 Feb 2014 07:31:38 -0800 (PST) Received: from localhost.localdomain ([85.235.11.236]) by mx.google.com with ESMTPSA id h9sm9719799wjz.16.2014.02.20.07.31.36 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 20 Feb 2014 07:31:37 -0800 (PST) From: Ulf Hansson To: "Rafael J. Wysocki" , Len Brown , Pavel Machek , linux-pm@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, Kevin Hilman , Alan Stern , Mark Brown , Russell King , Linus Walleij , Wolfram Sang , Alessandro Rubini , Ulf Hansson Subject: [PATCH 5/8] i2c: nomadik: Fixup system suspend Date: Thu, 20 Feb 2014 16:31:17 +0100 Message-Id: <1392910280-12891-6-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1392910280-12891-1-git-send-email-ulf.hansson@linaro.org> References: <1392910280-12891-1-git-send-email-ulf.hansson@linaro.org> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00,KHOP_BIG_TO_CC, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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