From patchwork Wed Feb 19 12:27:59 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 24953 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ve0-f198.google.com (mail-ve0-f198.google.com [209.85.128.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 8B1B12054E for ; Wed, 19 Feb 2014 12:28:06 +0000 (UTC) Received: by mail-ve0-f198.google.com with SMTP id pa12sf444418veb.5 for ; Wed, 19 Feb 2014 04:28:06 -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=VYZ3PotqJsvZAfRIaub2HwzPmxKnLwyn+pMY99gq5UQ=; b=NFoNGfdjZa4qGnyTVjaM19Ki8beG/j/msTZnyuT8pn+aVmb0YRhdTJ4t73qpJR3YFB yiUUM3iWYWBZRU7i/yHrjH5MHcV5inHZkQXlN03JguP1Q7mlXIppiDe40hR6Q/RUqhOs GujXt2B2G1ilLrWeeuePz9G7qPK+cWDVoJ16ywCehZjECCAT9M50FeO/cRuhidcIG4F4 0tMtixp6Beqk52tM9hPNsSAHfRgYJ0Y33C4gsjN0r8yA6i5CXk8x0bqIDw8SWXOWmjXk u2L7G72pEzazgySFfCzAmG1JaEORQsfLydE/X8WuZscytPTNiSfjYuLVZvg15biTlx/Q lVmA== X-Gm-Message-State: ALoCoQmib7bXseRCYSeQ/i+ddXuJaMwVQWoGc8Q3aCjG/nNHtyxXAJuU6//Ahc7NMzaER4wLcZVo X-Received: by 10.236.175.66 with SMTP id y42mr7020732yhl.38.1392812886322; Wed, 19 Feb 2014 04:28:06 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.32.116 with SMTP id g107ls89078qgg.49.gmail; Wed, 19 Feb 2014 04:28:06 -0800 (PST) X-Received: by 10.52.244.12 with SMTP id xc12mr242793vdc.83.1392812886209; Wed, 19 Feb 2014 04:28:06 -0800 (PST) Received: from mail-ve0-f179.google.com (mail-ve0-f179.google.com [209.85.128.179]) by mx.google.com with ESMTPS id ls10si13783vec.57.2014.02.19.04.28.06 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 19 Feb 2014 04:28:06 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.179 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.179; Received: by mail-ve0-f179.google.com with SMTP id jx11so279007veb.24 for ; Wed, 19 Feb 2014 04:28:06 -0800 (PST) X-Received: by 10.220.225.71 with SMTP id ir7mr292502vcb.50.1392812886139; Wed, 19 Feb 2014 04:28:06 -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 u4csp293227vcz; Wed, 19 Feb 2014 04:28:05 -0800 (PST) X-Received: by 10.152.170.135 with SMTP id am7mr26012712lac.23.1392812885108; Wed, 19 Feb 2014 04:28:05 -0800 (PST) Received: from mail-lb0-f178.google.com (mail-lb0-f178.google.com [209.85.217.178]) by mx.google.com with ESMTPS id mq2si115773lbb.32.2014.02.19.04.28.04 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 19 Feb 2014 04:28:05 -0800 (PST) Received-SPF: neutral (google.com: 209.85.217.178 is neither permitted nor denied by best guess record for domain of ulf.hansson@linaro.org) client-ip=209.85.217.178; Received: by mail-lb0-f178.google.com with SMTP id u14so239792lbd.9 for ; Wed, 19 Feb 2014 04:28:04 -0800 (PST) X-Received: by 10.152.180.42 with SMTP id dl10mr1112519lac.62.1392812884441; Wed, 19 Feb 2014 04:28:04 -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 jf8sm33933lbc.8.2014.02.19.04.28.02 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 19 Feb 2014 04:28:03 -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 V4 17/17] i2c: nomadik: Fixup system suspend Date: Wed, 19 Feb 2014 13:27:59 +0100 Message-Id: <1392812879-19251-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.179 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 --- Changes in v4: Rebased on top of v4 of patch 16. --- drivers/i2c/busses/i2c-nomadik.c | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/drivers/i2c/busses/i2c-nomadik.c b/drivers/i2c/busses/i2c-nomadik.c index 8082f5c..267375f 100644 --- a/drivers/i2c/busses/i2c-nomadik.c +++ b/drivers/i2c/busses/i2c-nomadik.c @@ -879,18 +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) { - pinctrl_pm_select_sleep_state(dev); + 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