From patchwork Thu Apr 10 13:59:36 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 28190 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qg0-f69.google.com (mail-qg0-f69.google.com [209.85.192.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 7B9DD20671 for ; Thu, 10 Apr 2014 13:59:42 +0000 (UTC) Received: by mail-qg0-f69.google.com with SMTP id a108sf7454275qge.0 for ; Thu, 10 Apr 2014 06:59:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=BYcOu/nt/Gb9KAoXph80mvUyQPWxu7GeSeZcAEqc6sw=; b=gZQhFudOclGb9rAkiUU1hiMvfOYrWWlCE7ytUOModLwy5IY6ZYkKqzE2GVLXLh9dxq NpbyDlk1sMcU9DOa/AlU+Jo4rxAzbhyKopC9TRNdiwB5Ko3kw6LCVNrVXctFozC1aNq7 QlNm2wqPngpp0IepB0ncAN/pjoZpa+l0IEtuvth3hm5J4jRz7cX9zmyJa45TWtxgF4Kv MJYTbuaiRTf0VoYdKF+0bYDUhBqgERPrVsO4H0ctD/a6bodc3tSoOlIJxqNKTn1vpR0v 0OdI5i6/aREH49ql+WyHmkL46ofMed7y+Tq/UOrs2czkv9uMqEg//jlmgcr/VfE0PaS6 2Hkw== X-Gm-Message-State: ALoCoQlzE+MhK0Ps59pbj8p+kcyH811H1xAZMxglo/8P4ojASPd5mKfWIohvrcxtvm9gCKKP7PbD X-Received: by 10.58.94.232 with SMTP id df8mr7582336veb.23.1397138382261; Thu, 10 Apr 2014 06:59:42 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.83.137 with SMTP id j9ls1196858qgd.70.gmail; Thu, 10 Apr 2014 06:59:42 -0700 (PDT) X-Received: by 10.58.186.71 with SMTP id fi7mr334026vec.32.1397138382094; Thu, 10 Apr 2014 06:59:42 -0700 (PDT) Received: from mail-vc0-f170.google.com (mail-vc0-f170.google.com [209.85.220.170]) by mx.google.com with ESMTPS id qr10si708426vcb.81.2014.04.10.06.59.42 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 10 Apr 2014 06:59:42 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.170 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.170; Received: by mail-vc0-f170.google.com with SMTP id hu19so3566214vcb.1 for ; Thu, 10 Apr 2014 06:59:42 -0700 (PDT) X-Received: by 10.220.81.194 with SMTP id y2mr533426vck.29.1397138382014; Thu, 10 Apr 2014 06:59:42 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.221.72 with SMTP id ib8csp61705vcb; Thu, 10 Apr 2014 06:59:41 -0700 (PDT) X-Received: by 10.194.85.19 with SMTP id d19mr39260wjz.96.1397138381159; Thu, 10 Apr 2014 06:59:41 -0700 (PDT) Received: from mail-we0-f182.google.com (mail-we0-f182.google.com [74.125.82.182]) by mx.google.com with ESMTPS id rx16si1573826wjb.142.2014.04.10.06.59.40 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 10 Apr 2014 06:59:41 -0700 (PDT) Received-SPF: neutral (google.com: 74.125.82.182 is neither permitted nor denied by best guess record for domain of ulf.hansson@linaro.org) client-ip=74.125.82.182; Received: by mail-we0-f182.google.com with SMTP id p61so4021150wes.27 for ; Thu, 10 Apr 2014 06:59:40 -0700 (PDT) X-Received: by 10.180.97.72 with SMTP id dy8mr15264351wib.5.1397138380564; Thu, 10 Apr 2014 06:59:40 -0700 (PDT) Received: from localhost.localdomain ([85.235.11.236]) by mx.google.com with ESMTPSA id bq12sm1728022wib.0.2014.04.10.06.59.38 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 10 Apr 2014 06:59:39 -0700 (PDT) From: Ulf Hansson To: Wolfram Sang , linux-i2c@vger.kernel.org Cc: Linus Walleij , Kevin Hilman , Daniel Lezcano , Alessandro Rubini , linux-arm-kernel@lists.infradead.org, Ulf Hansson Subject: [PATCH] i2c: nomadik: Fixup system suspend Date: Thu, 10 Apr 2014 15:59:36 +0200 Message-Id: <1397138376-28427-1-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 1.7.9.5 X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ulf.hansson@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.170 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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 Acked-by: Linus Walleij --- Do note, this patch were sent during the previous kernel release cycle, as a part of another patchset on the PM core. Back then, it provided proof of concept, for the new runtime PM helper functions: pm_runtime_force_suspend|resume(). --- 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 28cbe1b..7d27eee 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