From patchwork Mon Feb 17 15:21:14 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 24779 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f200.google.com (mail-ie0-f200.google.com [209.85.223.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id C845220143 for ; Mon, 17 Feb 2014 15:21:21 +0000 (UTC) Received: by mail-ie0-f200.google.com with SMTP id to1sf7887175ieb.3 for ; Mon, 17 Feb 2014 07:21:21 -0800 (PST) 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=jnCLffIYWLIbeAASGcgdTPIftoncbZdQJEpCXGo662Y=; b=fqLR3OFPjYODmtUfPQYZuT+agwaet6yq/CmV7Rki533kcHn378+YM2DDGJ8BqXSht+ VTtxiKGtIFMfDBHRg9imiQLyYESWnGVu4AfcQ/KBmqydo3V8AKygQXdxirRgzdDDwSoR of24YXIgL8o853SSg2R9Dua8U8Jk/Fa3KqYamLp2hAMD2c6ucybn9BOWbAfVgdNX2J3W oaSHaAM5SqRuOqS9DRsr6r8yHAiLkE49FkTf2rTCAV5y2EihhZ1zOv/d0x8iSMZmDqWZ bQy289tnFkmH7daBe8aJ65L0pdbXQH2OKaNSCzGUUPDsCT1jbQo0UqZeXo2GyTHj9H2H FD4g== X-Gm-Message-State: ALoCoQmm1/fnXxn7h0PSGN/JHyo+G80onZMPKuugetvBAm0o4sIbYyq2sGq/K1Q4rJf46CCchh6t X-Received: by 10.42.82.137 with SMTP id d9mr9584479icl.25.1392650480949; Mon, 17 Feb 2014 07:21:20 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.42.14 with SMTP id b14ls967675qga.47.gmail; Mon, 17 Feb 2014 07:21:20 -0800 (PST) X-Received: by 10.220.110.69 with SMTP id m5mr40394vcp.55.1392650480829; Mon, 17 Feb 2014 07:21:20 -0800 (PST) Received: from mail-ve0-f180.google.com (mail-ve0-f180.google.com [209.85.128.180]) by mx.google.com with ESMTPS id wg4si4541701vcb.38.2014.02.17.07.21.20 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 17 Feb 2014 07:21:20 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.180 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.180; Received: by mail-ve0-f180.google.com with SMTP id db12so12024173veb.39 for ; Mon, 17 Feb 2014 07:21:20 -0800 (PST) X-Received: by 10.52.246.227 with SMTP id xz3mr13233vdc.95.1392650480750; Mon, 17 Feb 2014 07:21:20 -0800 (PST) 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.174.196 with SMTP id u4csp146517vcz; Mon, 17 Feb 2014 07:21:20 -0800 (PST) X-Received: by 10.152.44.167 with SMTP id f7mr8573lam.86.1392650479066; Mon, 17 Feb 2014 07:21:19 -0800 (PST) Received: from mail-la0-f51.google.com (mail-la0-f51.google.com [209.85.215.51]) by mx.google.com with ESMTPS id my6si25660917lbb.142.2014.02.17.07.21.18 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 17 Feb 2014 07:21:18 -0800 (PST) Received-SPF: neutral (google.com: 209.85.215.51 is neither permitted nor denied by best guess record for domain of ulf.hansson@linaro.org) client-ip=209.85.215.51; Received: by mail-la0-f51.google.com with SMTP id c6so11462096lan.10 for ; Mon, 17 Feb 2014 07:21:18 -0800 (PST) X-Received: by 10.152.234.3 with SMTP id ua3mr1635148lac.63.1392650478345; Mon, 17 Feb 2014 07:21:18 -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 ya9sm19307613lbb.2.2014.02.17.07.21.16 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 17 Feb 2014 07:21:17 -0800 (PST) From: Ulf Hansson To: Alessandro Rubini , Linus Walleij , Wolfram Sang , linux-i2c@vger.kernel.org Cc: Russell King , linux-arm-kernel@lists.infradead.org, Mark Brown , Ulf Hansson Subject: [PATCH V3 17/17] i2c: nomadik: Fixup system suspend Date: Mon, 17 Feb 2014 16:21:14 +0100 Message-Id: <1392650474-14995-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.128.180 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, we need to re-use the runtime PM callbacks and check the runtime PM state of the device before proceeding with our operations for system suspend. Cc: Alessandro Rubini Cc: Linus Walleij Cc: Wolfram Sang Signed-off-by: Ulf Hansson --- drivers/i2c/busses/i2c-nomadik.c | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/drivers/i2c/busses/i2c-nomadik.c b/drivers/i2c/busses/i2c-nomadik.c index ceb3d05..650f5f9 100644 --- a/drivers/i2c/busses/i2c-nomadik.c +++ b/drivers/i2c/busses/i2c-nomadik.c @@ -879,21 +879,36 @@ static irqreturn_t i2c_irq_handler(int irq, void *arg) #ifdef CONFIG_PM_SLEEP static int nmk_i2c_suspend_late(struct device *dev) { - struct amba_device *adev = to_amba_device(dev); - struct nmk_i2c_dev *nmk_i2c = amba_get_drvdata(adev); + if (!pm_runtime_status_suspended(dev)) { + int ret = 0; + if (dev->pm_domain && dev->pm_domain->ops.runtime_suspend) + ret = dev->pm_domain->ops.runtime_suspend(dev); + else + ret = dev->bus->pm->runtime_suspend(dev); + if (ret) + return ret; + + pm_runtime_set_suspended(dev); + } 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); + int ret = 0; + + if (dev->pm_domain && dev->pm_domain->ops.runtime_resume) + ret = dev->pm_domain->ops.runtime_resume(dev); + else + ret = dev->bus->pm->runtime_resume(dev); + if (ret) { + dev_err(dev, "problem resuming\n"); + return ret; + } + pm_runtime_set_active(dev); return 0; } #endif