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: 111226 Delivered-To: patches@linaro.org Received: by 10.140.95.112 with SMTP id h103csp1457708qge; Tue, 29 Aug 2017 07:57:15 -0700 (PDT) X-Received: by 10.46.64.149 with SMTP id r21mr249315lje.61.1504018634965; Tue, 29 Aug 2017 07:57:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504018634; cv=none; d=google.com; s=arc-20160816; b=PpqMRJX0QsBSYEBJeicS78WCYrh98uPoLx5d1D+9nxpbypRQlWJ5qA5dwKjJ5PxIow yeYi+HS/iAak8LEXWxgbzyx+jMY2KNe+EiJ2HLC2Y9IwT1Hi05nL7jxwm8UgD6WMx/zx rDArJlKr/mfJ1iPa8Q/KNMynw6fa3E+NkakfMNMav2ZdbGlIzp0Myc9lThqZaYYEdB7y 0dJenieUdEdulQ5YOi4YMGDO4aDaZ8iROnPdD4gaF0cHJfGQvoxcC3XgiLhOshzFs/gT VAsqVAGDU7O41SeHjgyvMFujiTxGuKYPJ42mbz+chHI9K0lkkmSIQz7UquMiJrDgOvXJ 5SSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=dKHCfwk+yvoTIcSdGw1fMF7sumRlyzDWX+dmJ6xv8nA=; b=gVDPEiqo96gn0fR6oQhgFhWuGpTYrakkj9A0fOFK143siR6Z1aGL29KVCPccEHRkgA UyuMQYuBPxvnocth9MY9RKWl7N7yup1+u+S7+2xFJIBMUer1h+Td6Cem42Xz8XpkX1oW qdBsF/EoBOTfmeXtKIdFPoBt0PAAHxzi8UjDyQkOJy4HEKIB/fkLXiTFtIi/+zmnE5ib H4QP3/ytVEllnXHJfin1F6YfDdI7AdjBuA/v4SVinarS1EDijWisZnzDN0NIMqdJpJK3 sNXDuAAcR+L16+PoGPKwCQYXHMAsgTzrb3WpMTQ1iToVtVG/do1YElmT3SV+EjJ03bNr bIWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iT6aTupl; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::234 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-lf0-x234.google.com (mail-lf0-x234.google.com. [2a00:1450:4010:c07::234]) by mx.google.com with ESMTPS id h21si1275964lfe.309.2017.08.29.07.57.14 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 Aug 2017 07:57:14 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::234 as permitted sender) client-ip=2a00:1450:4010:c07::234; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iT6aTupl; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::234 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by mail-lf0-x234.google.com with SMTP id z12so14371541lfd.3 for ; Tue, 29 Aug 2017 07:57:14 -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=ueaKGbRmGbF3m0C418EcxlKeNqItPHOM55NW38P7+kIBjy9SkAifdnO2FKYcBi7zOU N6B7pEGiGCLeQPZvwXpiNXTiRM4SbiTCWuPz4lKFzwm9L9VxqeG1VEjGBgkWKMsH1jGf GRBa2EJbHK33AN1eLEnYoQv+04NT4BHTQZ//w+xOHSZd91OVGi649zOuGF0+ZpAe1zv5 kjpNTpXswkAnR4NN+TuQFnyzOdbW9/2Wkv0csal1mZOv6LWFgJGON7f6n3tRE6r0U4tj Zrhc2bzqo96zGO3J97Hoal8bQ/rXpY7FOG8+TFhXLUsr9yAoHtrypcLK3HsFzHWifHTz +fGw== X-Gm-Message-State: AHYfb5iewzT0/yWkxXpLzAfrPTmfLZ4JKLwcRyaHHZElvr+1FPX3fmsR mIymXcp+z9899/uMvh4= X-Received: by 10.25.21.94 with SMTP id l91mr170588lfi.160.1504018634452; Tue, 29 Aug 2017 07:57:14 -0700 (PDT) Return-Path: 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> 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(-) -- 2.7.4 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) };