From patchwork Tue Aug 29 14:56:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 9927603 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id EDC086022E for ; Tue, 29 Aug 2017 14:57:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DE3DA28980 for ; Tue, 29 Aug 2017 14:57:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D2DA028987; Tue, 29 Aug 2017 14:57:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7243828980 for ; Tue, 29 Aug 2017 14:57:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754665AbdH2O5U (ORCPT ); Tue, 29 Aug 2017 10:57:20 -0400 Received: from mail-lf0-f53.google.com ([209.85.215.53]:37969 "EHLO mail-lf0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754661AbdH2O5Q (ORCPT ); Tue, 29 Aug 2017 10:57:16 -0400 Received: by mail-lf0-f53.google.com with SMTP id d202so14332275lfd.5 for ; Tue, 29 Aug 2017 07:57:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=dKHCfwk+yvoTIcSdGw1fMF7sumRlyzDWX+dmJ6xv8nA=; b=iT6aTuplL2iyRlieazBXchlzF+X1ufa0/cR1CShpk74PHUEZLeauzU3UF95h1RJmhR ZtbpBzKyOTSGtMVoen/DSCi9fp8kGRaTfnjSitk3CLQGTKAEoEjM+qqUsCoGciOmSbK0 NMF0BK7i19eb6kxvrENllvheVL3n7BENOsp/c= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=dKHCfwk+yvoTIcSdGw1fMF7sumRlyzDWX+dmJ6xv8nA=; b=OP3+5yN+k7GSQWX4Ztp86yUhXwC0Y6YN8PFmd9bq2n1GQGDb/lMxptgK2VzgDifb4H KaVnfMM7XRhyUpuy+wjOYgkNtUj8yIrEUxxbhE6CPzXozSbh471xM6tTqTNJXOoajvyn lWIsZ0AkGoCmww/iqsbxR+7abwlh5idx3VrfHb1raTfU6IiDa7kWuxFEeZLevZfmFwAt jYF8+GnhtjwRXWd6nYHwgcaczxdtM3MwfJxbU+CtqHv01A4Quyk1m97gSEMGice47+vM NqNNXNWTKt1LR83sAlYCA5XGTMy7OUaOK9pYZbX9HGGA0gSDgPJ11tUvd5Z4qB/xXZaN KccQ== X-Gm-Message-State: AHYfb5jE71FrWRlpfi2aZq19xXecERVcV/sCVbCdTSScxtCDHNGn+9a9 JUaOoq8oK9YIOgOO X-Received: by 10.25.21.94 with SMTP id l91mr170588lfi.160.1504018634452; Tue, 29 Aug 2017 07:57:14 -0700 (PDT) Received: from localhost.localdomain (h-158-174-22-67.NA.cust.bahnhof.se. [158.174.22.67]) by smtp.gmail.com with ESMTPSA id y23sm652454ljd.19.2017.08.29.07.57.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 29 Aug 2017 07:57:13 -0700 (PDT) From: Ulf Hansson To: Wolfram Sang , "Rafael J . Wysocki" , Len Brown , linux-acpi@vger.kernel.org, linux-pm@vger.kernel.org Cc: Kevin Hilman , Jarkko Nikula , Andy Shevchenko , Mika Westerberg , Jisheng Zhang , John Stultz , Guodong Xu , Sumit Semwal , Haojian Zhuang , Johannes Stezenbach , linux-arm-kernel@lists.infradead.org, linux-i2c@vger.kernel.org, Ulf Hansson Subject: [PATCH v3 8/8] i2c: designware: Deploy the runtime PM centric path for system sleep Date: Tue, 29 Aug 2017 16:56:50 +0200 Message-Id: <1504018610-10822-9-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504018610-10822-1-git-send-email-ulf.hansson@linaro.org> References: <1504018610-10822-1-git-send-email-ulf.hansson@linaro.org> Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Currently the device is runtime resumed in the i2c-dw-plat driver's ->suspend() callback, which is needed to manage system sleep properly. The particular reason for the runtime resume is because the PM core may unset the direct_complete flag for a parent device, in case its child device are being system suspended before. This leads to that the i2c-dw-plat driver's ->suspend() callback can be invoked when the device is runtime suspended. Runtime resuming the device in this scenario may be unnecessary, in case when the device is already in its proper lower power state for system sleep. This behaviour increases the time it takes to put the device into low power state, but means also a waste of power. Let's fix the behaviour by deploying the runtime PM centric path for system sleep, via assigning the pm_runtime_force_suspend|resume() helpers as the system sleep callbacks for the i2c-dw-plat driver. We must also inform the PM core and the ACPI PM domain that we are now using the runtime PM centric path, therefore we call dev_pm_use_rpm_sleep() during ->probe(). While deploying the runtime PM centric path, the ->prepare() callback becomes redundant, so let's drop it. Along with these improvements, of course we also get the other regular benefits one get when deploying the runtime PM centric path. Signed-off-by: Ulf Hansson --- Changes in v3: - Use dev_pm_use_rpm_sleep() instead of the earlier acpi_disable_direct_complete() from v2. - Updated changelog. --- drivers/i2c/busses/i2c-designware-platdrv.c | 26 +++++--------------------- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c index 38121c9..20db3c2 100644 --- a/drivers/i2c/busses/i2c-designware-platdrv.c +++ b/drivers/i2c/busses/i2c-designware-platdrv.c @@ -371,6 +371,7 @@ static int dw_i2c_plat_probe(struct platform_device *pdev) if (ret) goto exit_probe; + dev_pm_use_rpm_sleep(&pdev->dev); return ret; exit_probe: @@ -412,15 +413,6 @@ static const struct of_device_id dw_i2c_of_match[] = { MODULE_DEVICE_TABLE(of, dw_i2c_of_match); #endif -#ifdef CONFIG_PM_SLEEP -static int dw_i2c_plat_prepare(struct device *dev) -{ - return pm_runtime_suspended(dev); -} -#else -#define dw_i2c_plat_prepare NULL -#endif - #ifdef CONFIG_PM static int dw_i2c_plat_runtime_suspend(struct device *dev) { @@ -433,7 +425,7 @@ static int dw_i2c_plat_runtime_suspend(struct device *dev) return 0; } -static int dw_i2c_plat_resume(struct device *dev) +static int dw_i2c_plat_runtime_resume(struct device *dev) { struct platform_device *pdev = to_platform_device(dev); struct dw_i2c_dev *i_dev = platform_get_drvdata(pdev); @@ -444,19 +436,11 @@ static int dw_i2c_plat_resume(struct device *dev) return 0; } -#ifdef CONFIG_PM_SLEEP -static int dw_i2c_plat_suspend(struct device *dev) -{ - pm_runtime_resume(dev); - return dw_i2c_plat_runtime_suspend(dev); -} -#endif - static const struct dev_pm_ops dw_i2c_dev_pm_ops = { - .prepare = dw_i2c_plat_prepare, - SET_SYSTEM_SLEEP_PM_OPS(dw_i2c_plat_suspend, dw_i2c_plat_resume) + SET_LATE_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, + pm_runtime_force_resume) SET_RUNTIME_PM_OPS(dw_i2c_plat_runtime_suspend, - dw_i2c_plat_resume, + dw_i2c_plat_runtime_resume, NULL) };