From patchwork Wed Jun 21 19:21:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 106115 Delivered-To: patches@linaro.org Received: by 10.140.91.2 with SMTP id y2csp2092603qgd; Wed, 21 Jun 2017 12:21:48 -0700 (PDT) X-Received: by 10.46.22.4 with SMTP id w4mr10608399ljd.76.1498072908699; Wed, 21 Jun 2017 12:21:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498072908; cv=none; d=google.com; s=arc-20160816; b=fTeFJCDW/6wKo0LADlHqGxlYc4MM2FXSgX+4M54JHa8sv85GkxgtMYgM7BBQSCv4Qd kexGuAc58bVSQY9OeXrmeGMIupCG+brNWiARfAHwDSWCw+VpQy/Vwp2CGJKQcQrIYWsB 5mlxIO2AJ/Pw/ZKN5vRUcmfDCuGvLKcSY6EBLGTBfqv0HXUNIPttYjKUvnJZ+b5uRNNx MfS1JZ5+tqskR8w8PkwEE1JwK3SGW9b2YCWZfSk75DUk0cVq+7u23UUxNCFZz6B2KmBl GxsPXWnZj7xF1nlgtKuUNgv4t98Xe5Loi9ox/r6QlQTUoNX3Pz1xZhn4z9sBjGuf8bu1 8q/w== 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=Hkbj1E2AEUQlZDx5XqIyiBh7IzpD/A3kthJqUCXy8qM=; b=dMhk76ll3c/xyO4oN1WwApB5A/LVHKJRWn7PPa3yRCAyAHdrFO9LhWc0qEq4akbOqK Mrv8orkTsVPwA8wYzW3nrhPVLozA/0ufTLk8wN1RICk/9OOKOSOxEh5/y9IKJr9xO0Hp +IMI9To2QrN7XiFT0YHvXPfwwsBToOnOWzbXwSWabAhfuoJ46iftpADlHVKTGef8L8Gf 3KpXa5E6Y1vksQTBXlz52btfE7feyKMslCrvOixhMS+AebbWlcV8YQZDh8f3tdeMMy/p UejSwQ5HlNPY84BTR5t8RtqMmAPP/pZEM8Mgj7wLSC2XN9AKwndFls5ICCOWVVOdqDiO R6qg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.b=UGZ4I4pI; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::232 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-x232.google.com (mail-lf0-x232.google.com. [2a00:1450:4010:c07::232]) by mx.google.com with ESMTPS id j14si9464908lfg.150.2017.06.21.12.21.48 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Jun 2017 12:21:48 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::232 as permitted sender) client-ip=2a00:1450:4010:c07::232; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.b=UGZ4I4pI; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::232 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-x232.google.com with SMTP id h22so23138237lfk.3 for ; Wed, 21 Jun 2017 12:21:48 -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=Hkbj1E2AEUQlZDx5XqIyiBh7IzpD/A3kthJqUCXy8qM=; b=UGZ4I4pISJ+TP0a5uQR0NyfLYpvw0L22hGRxWwbOH6JExVqFsUecKehSdFbjCCDrx8 rVkIN8J6XagH/1SPeb3174ZfBggHEdHVVqNpTLyEg2ypNNrz2/yfPN11LWcmGkQTqVkc 9es5X2xa2dqyRQKzFwE4LicMureVSIz+WhlSc= 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=Hkbj1E2AEUQlZDx5XqIyiBh7IzpD/A3kthJqUCXy8qM=; b=BrK7ysH9c3SwBrbfFtSjCdp8i4IjzhLTBFncii/UiDdwjRMY06PHUGMbB9J7aJJDwM W/+CAgmp0ULAMHuxD5iDrQDmVD4tVkRoIdHXeaNEAzDj0a2WEXPEihEZlB+YHKJjNZht Tc2a8uXRxL0jNTTdhHM1i9kkGMxU8HPq5E9YV8ysAyeto/UlcLb4er+W+Ru48SYhl2GH mQokBlqs9d/E42CQaQb6eNWNhZkQRsjCBfmy7MW0wVf8bj2Qrr3zWSob73sOe2Hr8xKf +UtvUqngCt7KgERkN61/VahJLN1zBVEyNpQEzWuLbh5kPCJDb1oyrVvSC6gWRLlX4Lil shjQ== X-Gm-Message-State: AKS2vOxtEj7Bqqr+TaZLYmKeHi4Jx8XYVqzgplXvD/9bmOkKeYh39cJI ZuVPq4ngiKCTODCMf7E= X-Received: by 10.25.31.18 with SMTP id f18mr12377097lff.126.1498072908287; Wed, 21 Jun 2017 12:21:48 -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 t24sm3920047ljd.1.2017.06.21.12.21.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 21 Jun 2017 12:21:47 -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 , linux-arm-kernel@lists.infradead.org, linux-i2c@vger.kernel.org, Ulf Hansson , stable@vger.linux.org Subject: [PATCH 1/9] i2c: designware: Fix system suspend Date: Wed, 21 Jun 2017 21:21:20 +0200 Message-Id: <1498072888-14782-2-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1498072888-14782-1-git-send-email-ulf.hansson@linaro.org> References: <1498072888-14782-1-git-send-email-ulf.hansson@linaro.org> The commit 8503ff166504 ("i2c: designware: Avoid unnecessary resuming during system suspend"), may suggest to the PM core to try out the so called direct_complete path for system sleep. In this path, the PM core treats a runtime suspended device as it's already in a proper low power state for system sleep, which makes it skip calling the system sleep callbacks for the device, except for the ->prepare() and the ->complete() callback. Moreover, under certain circumstances the PM core may unset the direct_complete flag for a parent device, in case its child device are being system suspended before. In other words, the PM core doesn't skip calling the system sleep callbacks, no matter if the device is runtime suspended or not. In cases of an i2c slave device, the above situation is triggered. Unfortunate, this also breaks the assumption that the i2c device is always runtime resumed, whenever the dw_i2c_plat_suspend() callback is being invoked, which then leads to a regression. More precisely, dw_i2c_plat_suspend() then calls clk_core_disable() and clk_core_unprepare(), for an already disabled/unprepared clock, leading to complaints about clocks calls being wrongly balanced. In cases when the i2c device is attached to the ACPI PM domain, the problem doesn't occur. That's because ACPI's ->suspend() callback, assigned to acpi_subsys_suspend(), calls pm_runtime_resume() for the i2c device. To make a simple fix for this regression, let's runtime resume the i2c device in the ->prepare() callback, assigned to dw_i2c_plat_prepare(). This prevents the direct_complete path from being executed by the PM core and guarantees the dw_i2c_plat_suspend() is called with the i2c device always being runtime resumed. Of course this change is suboptimal, because to always force a runtime resume of the i2c device in ->prepare() is a waste, especially in those cases when it could have remained runtime suspended during the entire system sleep sequence. However, to accomplish that behaviour a bigger change is needed, so defer that to future changes not applicable as fixes or for stable. Fixes: 8503ff166504 ("i2c: designware: Avoid unnecessary resuming...") Cc: stable@vger.linux.org Signed-off-by: Ulf Hansson --- drivers/i2c/busses/i2c-designware-platdrv.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) -- 2.7.4 diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c index d1263b8..2b7fa75 100644 --- a/drivers/i2c/busses/i2c-designware-platdrv.c +++ b/drivers/i2c/busses/i2c-designware-platdrv.c @@ -375,17 +375,11 @@ MODULE_DEVICE_TABLE(of, dw_i2c_of_match); #ifdef CONFIG_PM_SLEEP static int dw_i2c_plat_prepare(struct device *dev) { - return pm_runtime_suspended(dev); -} - -static void dw_i2c_plat_complete(struct device *dev) -{ - if (dev->power.direct_complete) - pm_request_resume(dev); + pm_runtime_resume(dev); + return 0; } #else #define dw_i2c_plat_prepare NULL -#define dw_i2c_plat_complete NULL #endif #ifdef CONFIG_PM @@ -413,7 +407,6 @@ static int dw_i2c_plat_resume(struct device *dev) static const struct dev_pm_ops dw_i2c_dev_pm_ops = { .prepare = dw_i2c_plat_prepare, - .complete = dw_i2c_plat_complete, SET_SYSTEM_SLEEP_PM_OPS(dw_i2c_plat_suspend, dw_i2c_plat_resume) SET_RUNTIME_PM_OPS(dw_i2c_plat_suspend, dw_i2c_plat_resume, NULL) }; From patchwork Wed Jun 21 19:21:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 106116 Delivered-To: patches@linaro.org Received: by 10.140.91.2 with SMTP id y2csp2092608qgd; Wed, 21 Jun 2017 12:21:50 -0700 (PDT) X-Received: by 10.25.22.105 with SMTP id m102mr1733244lfi.66.1498072910039; Wed, 21 Jun 2017 12:21:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498072910; cv=none; d=google.com; s=arc-20160816; b=n/L5LqYablxE1vZ1UuWkJX058NZ2VDkMJnDIKKQmjqx75jwFnIQvM15OmfDY26JzL0 AfKKB8Jrwj7o0NW4LKrfi6piZRykYOsTIEZcykkR+dxWJ1SrjKOPdXCAB6F8JpEEk+Tj Y7yZ8OjKGcq99E3ixPfYuaywVETp7W25LgnG1lQZ0qHV1SLFS8NiaLhGKXKbwHeI7pfB VzmqP0GwlwBycdLTe1ah667lS6gSFaTNIXOpsmih8H/W3AVCM7Lx8DnKf5iF8D7+aDdB M0J3nTIecFhwxf4c1/6tTDmCkaz1Bt0G6Iqe9pUpJJA+RbRN6Vm3GNR4zirPwSHmakvh Vfcg== 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=liNEDxp84FpoKqU17EtPadGxsRlMpLk7RyQaj+68Pn8=; b=ME6ZYwqHc4ff7Iq9B0g8LA1cbnfODpQUnv4PG4FE2Uc3YCZwEJk3OymZFheqgezyTy 9P42PbFK4tWVdc5+CD0vuKp0YWccdtRIDNZ55E/JnfbIQSO8wCZr7Eb98Abco8hbwtPX /JSBjAHVOX3btOnxkuRcLx5FiLfUT8hw/x7H/b2qndjE7EWhqzJNn5iOfZA5k6SqGkqI Y3F6OrwBKIzJm2cHcmpW1b3ot2uyucKPoeobHC4KNRej+cvO3qU7GEW6JL6Harkx5/fW Q1GlEx12q3SEImYgTqHIWc1CqdaL54nhVyJloHsL4bAUABqJhVGvwQ/TD+k/tiYrSJiZ c6RQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.b=QpBhcd9P; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::230 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-x230.google.com (mail-lf0-x230.google.com. [2a00:1450:4010:c07::230]) by mx.google.com with ESMTPS id y130si9029249lfc.86.2017.06.21.12.21.49 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Jun 2017 12:21:50 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::230 as permitted sender) client-ip=2a00:1450:4010:c07::230; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.b=QpBhcd9P; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::230 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-x230.google.com with SMTP id p189so102983872lfe.2 for ; Wed, 21 Jun 2017 12:21:49 -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=liNEDxp84FpoKqU17EtPadGxsRlMpLk7RyQaj+68Pn8=; b=QpBhcd9P1jje4M9S6CA/cWb3cpYGJJv3n+gwayJJFmtcQIdrx0xXqn521c2JFZ3PMi jumVQF4jG2z3NY4bNqz0BQLvdEwMNJ8I81qkFBNbMHWpBtU60UoFKvVUSTe2dK7M/crp N9iQQ9rVnkCmWiBY7mhXetBkPt2cWtAGJPo5I= 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=liNEDxp84FpoKqU17EtPadGxsRlMpLk7RyQaj+68Pn8=; b=rWdPV+TV7BnfN57C/4fm+CeVYKxxPZ+T5Qn22iaXZV3eyuI9Ltv4Fq8m6AAs9ZNqig J90qhbHOUDIhMlDmo/sPw7kQD3FTy38o1WyV2XH+m3dr1Ga2sVRHdPuUYTwx+ND3zn5W 8bygWvTUcBA4Yj4YLy4FiX1beH3LfKuJZJdb1obzXL9emkdpUPSM0bl1oDC/fqUZGW2r cqSUU5ADvlzIhebc/a6CniqnFvmBQDoLKl46tK7SBCJ5kAKCZUvjVJH8QhhSoU27r7SS Z7AmFy8mlKhMMe1cxvUNo5EOPvLxx1CpBx5aqRMCp52LYRjzu8mXOGR18tDeIJorcd+X 54Sw== X-Gm-Message-State: AKS2vOyuPxdLqjdH//XSBud/L9xbDUEc8At0LlLHJaFgP3/z7WBSDgXQ op5mmO9kfdD1HvwefUU= X-Received: by 10.46.80.84 with SMTP id v20mr7354828ljd.129.1498072909680; Wed, 21 Jun 2017 12:21:49 -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 t24sm3920047ljd.1.2017.06.21.12.21.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 21 Jun 2017 12:21:49 -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 , linux-arm-kernel@lists.infradead.org, linux-i2c@vger.kernel.org, Ulf Hansson Subject: [PATCH 2/9] PM / ACPI: Restore acpi_subsys_complete() Date: Wed, 21 Jun 2017 21:21:21 +0200 Message-Id: <1498072888-14782-3-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1498072888-14782-1-git-send-email-ulf.hansson@linaro.org> References: <1498072888-14782-1-git-send-email-ulf.hansson@linaro.org> The commit 58a1fbbb2ee8 ("PM / PCI / ACPI: Kick devices that might have been reset by firmware"), made PCI's and ACPI's ->complete() callbacks to be assigned to a new API called pm_complete_with_resume_check(), which was introduced in the same change. Later it turned out that using pm_complete_with_resume_check() isn't good enough for PCI, as it needs additional PCI specific checks, before deciding whether runtime resuming the device is needed when running the ->complete() callback. This leaves ACPI being the only user of pm_complete_with_resume_check(). Therefore let's restore ACPI's acpi_subsys_complete(), which was dropped in commit 58a1fbbb2ee8 ("PM / PCI / ACPI: Kick devices that might have been reset by firmware"). This enables us to remove the pm_complete_with_resume_check() API in a following change, but it also enables ACPI to add more ACPI specific checks in acpi_subsys_complete() if it turns out that is needed. Signed-off-by: Ulf Hansson --- drivers/acpi/acpi_lpss.c | 2 +- drivers/acpi/device_pm.c | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) -- 2.7.4 diff --git a/drivers/acpi/acpi_lpss.c b/drivers/acpi/acpi_lpss.c index 10347e3..d7b6778 100644 --- a/drivers/acpi/acpi_lpss.c +++ b/drivers/acpi/acpi_lpss.c @@ -879,7 +879,7 @@ static struct dev_pm_domain acpi_lpss_pm_domain = { #ifdef CONFIG_PM #ifdef CONFIG_PM_SLEEP .prepare = acpi_subsys_prepare, - .complete = pm_complete_with_resume_check, + .complete = acpi_subsys_complete, .suspend = acpi_subsys_suspend, .suspend_late = acpi_lpss_suspend_late, .resume_early = acpi_lpss_resume_early, diff --git a/drivers/acpi/device_pm.c b/drivers/acpi/device_pm.c index ca02102..d38acbc 100644 --- a/drivers/acpi/device_pm.c +++ b/drivers/acpi/device_pm.c @@ -964,6 +964,23 @@ int acpi_subsys_prepare(struct device *dev) EXPORT_SYMBOL_GPL(acpi_subsys_prepare); /** + * acpi_subsys_complete - Finalize device's resume during system resume. + * @dev: Device to handle. + */ +void acpi_subsys_complete(struct device *dev) +{ + pm_generic_complete(dev); + /* + * If the device had been runtime-suspended before the system went into + * the sleep state it is going out of and it has never been resumed till + * now, resume it in case the firmware powered it up. + */ + if (dev->power.direct_complete && pm_resume_via_firmware()) + pm_request_resume(dev); +} +EXPORT_SYMBOL_GPL(acpi_subsys_complete); + +/** * acpi_subsys_suspend - Run the device driver's suspend callback. * @dev: Device to handle. * @@ -1031,7 +1048,7 @@ static struct dev_pm_domain acpi_general_pm_domain = { .runtime_resume = acpi_subsys_runtime_resume, #ifdef CONFIG_PM_SLEEP .prepare = acpi_subsys_prepare, - .complete = pm_complete_with_resume_check, + .complete = acpi_subsys_complete, .suspend = acpi_subsys_suspend, .suspend_late = acpi_subsys_suspend_late, .resume_early = acpi_subsys_resume_early, From patchwork Wed Jun 21 19:21:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 106117 Delivered-To: patches@linaro.org Received: by 10.140.91.2 with SMTP id y2csp2092617qgd; Wed, 21 Jun 2017 12:21:51 -0700 (PDT) X-Received: by 10.25.199.7 with SMTP id x7mr12710647lff.170.1498072911302; Wed, 21 Jun 2017 12:21:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498072911; cv=none; d=google.com; s=arc-20160816; b=kF+9cTsOGRYNsEH+WxYywzk0crAGEdGwOETsCw78sT1BFf7dgDaOL8ABbgRAwKMAFq RrQmhFyzctgyuVsql+ninuLIMq5YXG7qIa3uQGF67AKSZNrOF1KnqO1T3gzLyY3z+lvk x8IfHi22oHFme/uXZB1Z/un8NcB4kLwlzN25kb0Dx9sqmjKW3wYZUsmPYKBdDsoV8O73 AhJsRvBzQCUWPEYXtyfwekbPPtWHkZy5zSDb9IWANxg7Mf6wFMtVmRLxB/rIXh0fyMIJ NgE8J9rSYY2XWLmPjT8Axk539FqICJsh7Wj7/s8+SOuh8xlqf4vvHgjaNyBQDbdcZak+ exUg== 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=KzkiJrP+RXUqgQpKd2YKZSCcFMl32WEDW7yWmfTxSJw=; b=ti3hbqjgLpyCjTd5EmLgth0FyZtSanzPQar3sntFVXpdRbsAhQylZHx7ZBFbJAOF90 CQJHoymftp3mcL9XBFvb51BjUUtlEF4NXLIZUtP80xDpeJqoWAhNhx2No9NxCU3s/xHA zb01GZTDpC+3dEKtU0+4BTv5tfR6D45vBJYvHCMHc0NilqsolpY8OIJeApgETwJ0xoYK AVY+yfUhLQ82nOmraILi1u4y0Cvm/STIpTsBNzPlh7Iw3VePHvnSHQHkYxJVbCTQJQ8C E3nsSjcCPiLfy/9J85L5D62ESSYr+ZhyAjpp9+9R/eIfNPO+CASOwNiL0qav5Mjwvmly aNnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.b=Go2CE6r8; 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 x21si9024712lfa.410.2017.06.21.12.21.51 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Jun 2017 12:21:51 -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.b=Go2CE6r8; 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 l13so43021989lfl.1 for ; Wed, 21 Jun 2017 12:21:51 -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=KzkiJrP+RXUqgQpKd2YKZSCcFMl32WEDW7yWmfTxSJw=; b=Go2CE6r8lwsHY/l2KaPw4zjAfMsatCOsaAn5jbJJrsZwjJdJe/l+jGLWrYkgLlXEqq GQH3zy6JEcACboOTUN/GEtzk6kFX2fBOewn6TPUHOmfvfXeZ7g2lEUKCNR8R6aFtPmAb TDAIvZE9syfg4qt2r7hr5Fe1jbg5+dGxAhDuU= 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=KzkiJrP+RXUqgQpKd2YKZSCcFMl32WEDW7yWmfTxSJw=; b=a8Rk1nb5869IuJ0TvSTuANXvJTOdBxQ/junj6AA2NRFtwbcaZr/5UMGNoM1DTiLvRn rLOUlVODx7EoIl2oxEaYIg2fBnjsO84WMndVMh23PQ2JfBAb6a9/+F6CObyQiGB1kNKo iCMOgS3rt1wUyvLil/Wc3pfgOqjJiJsghj9Y/dnV372f8W3ZVkNzxpeH3b61zDlFS0rD f+YXOpQ2wOxxTUXHL1SV+gdqscILojmL0F1d9l8jUfYj+WK8RbNZ1r4EoTSq7HoQGDlL Y7ehi+zxLcu3ggKeHmwU/Pfu8K1DlQsUjb2s79YXLSGeVsoV5Ch692RAf3izmhBFMDvs b2sA== X-Gm-Message-State: AKS2vOwToMD70VEKrBBqqMUXrdDr/mCuRM3WAnXNq3AI5E0jRLJCEu4D kwMuwfWA8WUUI5dLu/k= X-Received: by 10.46.80.24 with SMTP id e24mr11516026ljb.19.1498072910962; Wed, 21 Jun 2017 12:21:50 -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 t24sm3920047ljd.1.2017.06.21.12.21.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 21 Jun 2017 12:21:50 -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 , linux-arm-kernel@lists.infradead.org, linux-i2c@vger.kernel.org, Ulf Hansson Subject: [PATCH 3/9] PM / Sleep: Remove pm_complete_with_resume_check() Date: Wed, 21 Jun 2017 21:21:22 +0200 Message-Id: <1498072888-14782-4-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1498072888-14782-1-git-send-email-ulf.hansson@linaro.org> References: <1498072888-14782-1-git-send-email-ulf.hansson@linaro.org> According to recent changes for ACPI, the are longer any users of pm_complete_with_resume_check(), thus let's drop it. Signed-off-by: Ulf Hansson --- drivers/base/power/generic_ops.c | 23 ----------------------- include/linux/pm.h | 1 - 2 files changed, 24 deletions(-) -- 2.7.4 diff --git a/drivers/base/power/generic_ops.c b/drivers/base/power/generic_ops.c index 07c3c4a..b2ed606 100644 --- a/drivers/base/power/generic_ops.c +++ b/drivers/base/power/generic_ops.c @@ -9,7 +9,6 @@ #include #include #include -#include #ifdef CONFIG_PM /** @@ -298,26 +297,4 @@ void pm_generic_complete(struct device *dev) if (drv && drv->pm && drv->pm->complete) drv->pm->complete(dev); } - -/** - * pm_complete_with_resume_check - Complete a device power transition. - * @dev: Device to handle. - * - * Complete a device power transition during a system-wide power transition and - * optionally schedule a runtime resume of the device if the system resume in - * progress has been initated by the platform firmware and the device had its - * power.direct_complete flag set. - */ -void pm_complete_with_resume_check(struct device *dev) -{ - pm_generic_complete(dev); - /* - * If the device had been runtime-suspended before the system went into - * the sleep state it is going out of and it has never been resumed till - * now, resume it in case the firmware powered it up. - */ - if (dev->power.direct_complete && pm_resume_via_firmware()) - pm_request_resume(dev); -} -EXPORT_SYMBOL_GPL(pm_complete_with_resume_check); #endif /* CONFIG_PM_SLEEP */ diff --git a/include/linux/pm.h b/include/linux/pm.h index a0894bc..de28313 100644 --- a/include/linux/pm.h +++ b/include/linux/pm.h @@ -733,7 +733,6 @@ extern int pm_generic_poweroff_noirq(struct device *dev); extern int pm_generic_poweroff_late(struct device *dev); extern int pm_generic_poweroff(struct device *dev); extern void pm_generic_complete(struct device *dev); -extern void pm_complete_with_resume_check(struct device *dev); #else /* !CONFIG_PM_SLEEP */ From patchwork Wed Jun 21 19:21:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 106118 Delivered-To: patches@linaro.org Received: by 10.140.91.2 with SMTP id y2csp2092629qgd; Wed, 21 Jun 2017 12:21:52 -0700 (PDT) X-Received: by 10.25.17.169 with SMTP id 41mr11180440lfr.129.1498072912673; Wed, 21 Jun 2017 12:21:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498072912; cv=none; d=google.com; s=arc-20160816; b=uJ16h92Jk5tXVayD/cprTwyncSbO97eKrhe5Pl4IcwS6SzDwtJ6I1szLkfhqcwzO0M FS+potTJ0COExQHXWDHgDFfChek4GThcVI/rRYX9xJfmKwMZjsTXdcN2A+/+CtljRzCE nd0Vd4prldPyWN5GjAPnE8acukKu7sj+Tyq7Rs1xrhFPnXAjpAuN5SgY6knXdqw2tZ6P cLqiuEn4XSNaS+AAfmJMgvlB4v0orGD8FieEuKy10qgGQRWtLR8aJyag5pLnx/IcqVPb 5xCQqjabHNbdVh+G7RUxx/V/dnTCqSPCSzbVJ4e4vNTnZ6ELRFWpeVWVN6+PmjHg7S+E SiSw== 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=QCVzUUSyFMYIjzPdmvE3ollrHFMCZblrrm/7PLOSfB4=; b=a4xUso8852clKqyvCT9jLY4eZ9kGyuDC8+tDulOTxKTfBc6TDEtkcJF+ST5SHQvs1D n6yQ8JoYGf6KfYDZNNtf7k5hggcmMPcREy53RPqkP2iYvLj/6ITRCq/CF34D4+k+iEJS YfV9bM3mw8m778EyamnkcYNCAv5UOHH7YHwwjBAeqWpoiQ/ZlpQ0bx9hJAggIcSgLNSd bXP5jhZaMGzHNKKv5MSl3GzWAyntLY3ZvCilKbVofo2aOvXXNbgqejPpLBlayKW6cC8A 9PguDEFQ0L0XQiGf9U2wgJWzSFRxYO7NHv/0T/Vdsy38lrj8ppTNMb62+obC8R8pU2Wv h+bQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.b=WrLfgvzO; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::231 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-x231.google.com (mail-lf0-x231.google.com. [2a00:1450:4010:c07::231]) by mx.google.com with ESMTPS id q4si9072028lff.291.2017.06.21.12.21.52 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Jun 2017 12:21:52 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::231 as permitted sender) client-ip=2a00:1450:4010:c07::231; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.b=WrLfgvzO; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::231 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-x231.google.com with SMTP id p189so102984460lfe.2 for ; Wed, 21 Jun 2017 12:21:52 -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=QCVzUUSyFMYIjzPdmvE3ollrHFMCZblrrm/7PLOSfB4=; b=WrLfgvzOQxvP87vRcIkGWskfv9c0t/XSUojcSmwNJEKQL3xR+NMWYGOVIgZPDx9/qC 0OrLg+JDjG1uURL+F1fEgpCsg0w/mY1JsEy5cl4QGMtlAmYMFudIpht+NE7o9qagR+nP Nk9USDuJS/uQr2NH3r0ibJG5Hg0NT3LvGoEP0= 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=QCVzUUSyFMYIjzPdmvE3ollrHFMCZblrrm/7PLOSfB4=; b=KcAATOqjS7SoJq/U75D/HaNQO/dUxz8aU+f6PLY2VMHeYuXeztFKSrwWnidBGLc1nd p4eBRwQui0/aRsgkuCIJxHAtPnWm5EIKz8MK+GF4OWS+1TSdUSGvh7/DC+41FYLSJO/D aw46p/WuHNuHcovEJlVpcg/PV6Z/dzJUiA5j0c3h9N6pRlBjp+2OO35TdM9rF6NwdMKn eeEZKptUoz97EYn1wdPBjeB+5pVfBMmVJh+4qdtUgHuzHz+GNtPWnUB5n2c2rBd592mi wZqyMiTosmK1DOnrMGdx0zpVVbEDACSFqEO3hlo42w7gUSUbDi4oPSOVJAFQcBlpUDqD VPnA== X-Gm-Message-State: AKS2vOwvu30K0Kp/0bDPcWZkVfGJvVCgKOo160/dNrlcHLocUvI48zXP HONvv78YJnTORXDDXSo= X-Received: by 10.46.71.195 with SMTP id u186mr10471288lja.16.1498072912347; Wed, 21 Jun 2017 12:21:52 -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 t24sm3920047ljd.1.2017.06.21.12.21.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 21 Jun 2017 12:21:51 -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 , linux-arm-kernel@lists.infradead.org, linux-i2c@vger.kernel.org, Ulf Hansson Subject: [PATCH 4/9] PM / ACPI: Split code validating need for runtime resume in ->prepare() Date: Wed, 21 Jun 2017 21:21:23 +0200 Message-Id: <1498072888-14782-5-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1498072888-14782-1-git-send-email-ulf.hansson@linaro.org> References: <1498072888-14782-1-git-send-email-ulf.hansson@linaro.org> Move the code dealing with validation of whether runtime resuming the device is needed during system suspend. In this way it becomes more clear for what circumstances ACPI is prevented from trying the direct_complete path. Signed-off-by: Ulf Hansson --- drivers/acpi/device_pm.c | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) -- 2.7.4 diff --git a/drivers/acpi/device_pm.c b/drivers/acpi/device_pm.c index d38acbc..ee51e75 100644 --- a/drivers/acpi/device_pm.c +++ b/drivers/acpi/device_pm.c @@ -933,6 +933,27 @@ int acpi_dev_resume_early(struct device *dev) } EXPORT_SYMBOL_GPL(acpi_dev_resume_early); +static bool acpi_dev_needs_resume(struct device *dev, struct acpi_device *adev) +{ + u32 sys_target = acpi_target_system_state(); + int ret, state; + + if (device_may_wakeup(dev) != !!adev->wakeup.prepare_count) + return true; + + if (sys_target == ACPI_STATE_S0) + return false; + + if (adev->power.flags.dsw_present) + return true; + + ret = acpi_dev_pm_get_state(dev, adev, sys_target, NULL, &state); + if (ret) + return true; + + return !(state == adev->power.state); +} + /** * acpi_subsys_prepare - Prepare device for system transition to a sleep state. * @dev: Device to prepare. @@ -940,26 +961,16 @@ EXPORT_SYMBOL_GPL(acpi_dev_resume_early); int acpi_subsys_prepare(struct device *dev) { struct acpi_device *adev = ACPI_COMPANION(dev); - u32 sys_target; - int ret, state; + int ret; ret = pm_generic_prepare(dev); if (ret < 0) return ret; - if (!adev || !pm_runtime_suspended(dev) - || device_may_wakeup(dev) != !!adev->wakeup.prepare_count) - return 0; - - sys_target = acpi_target_system_state(); - if (sys_target == ACPI_STATE_S0) - return 1; - - if (adev->power.flags.dsw_present) + if (!adev || !pm_runtime_suspended(dev)) return 0; - ret = acpi_dev_pm_get_state(dev, adev, sys_target, NULL, &state); - return !ret && state == adev->power.state; + return !acpi_dev_needs_resume(dev, adev); } EXPORT_SYMBOL_GPL(acpi_subsys_prepare); From patchwork Wed Jun 21 19:21:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 106119 Delivered-To: patches@linaro.org Received: by 10.140.91.2 with SMTP id y2csp2092644qgd; Wed, 21 Jun 2017 12:21:54 -0700 (PDT) X-Received: by 10.25.158.78 with SMTP id h75mr11186915lfe.178.1498072914079; Wed, 21 Jun 2017 12:21:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498072914; cv=none; d=google.com; s=arc-20160816; b=gZwDc8aNQVv2ANCB5ly4ewV9QdfzzxKT/vl09OQig6bSCBMWrq8zXw7pisimYS580Y M2ETy7zmdHCt0/ncKgFBmKLWyWy21+Le6H+s8/qaHk5N2HTJh77BlzaI2Dqooq88qTnH CGB8s1faf1UF5WlrvmDCogQX5dtFwgC0EWzy3ncTXpQICr/thBbqrnWkx9ZRGD7rxKRN obSYdHkutkGSzQQKOSv0cI+TeRQ0n//IgTUuAItsRzJ6AzecDFjKbmGZ+2VZuJb+c6AD u4ZuuDpprLuNRrx13sVYolaASV/e0OA+1wadnO0YT/MN6nAnTdChZvCYUwkFpj4wSnDj xFQw== 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=JaEwCekFsuVLnVwL8IUqLgCL1SsSfKEdsOUQ9nlXA3M=; b=efbY06ql35+2qtoAsW1NSeKWyGuEoCuJx2e7gPHXcZV7FCK+Nq2AWyy6sgf0qvMlIV R/LhZNN2kz1yVmOmUS+anJGjxJbTgIN2fIcCqJeBxEWr6rzd26vQdx47vnZNBLDq3Thd bqAq5r8rxTltXMDOeU/ocKz0f0Um8FhDdvFYdqXlbT5GSvC9ORcivY9hK05FIoJMIJ8h FxQDmLEpvijRq4mDfBis3zyBV0kEpDudoDbrwqL4iq7novBuHfbbhl36ENRhxObLj8kE tiW/CnnfOnbN253q1SqPZKxnF7jt1RClhD0OhHKJtbkDdfNOX0ZSIo8GY8FO9eu2C13U B9Ew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.b=PMLMk2+V; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::229 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-x229.google.com (mail-lf0-x229.google.com. [2a00:1450:4010:c07::229]) by mx.google.com with ESMTPS id d23si9668424lfb.242.2017.06.21.12.21.53 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Jun 2017 12:21:54 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::229 as permitted sender) client-ip=2a00:1450:4010:c07::229; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.b=PMLMk2+V; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::229 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-x229.google.com with SMTP id p189so102984795lfe.2 for ; Wed, 21 Jun 2017 12:21:53 -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=JaEwCekFsuVLnVwL8IUqLgCL1SsSfKEdsOUQ9nlXA3M=; b=PMLMk2+VMub8w9US46yrAeuN3GiD9ZZINXAT4O6g/cAoUyApaT3WqTH7bmSEstBpvx 9znN2wtGdSEjq54DHcr15CguRdWyroKQIgFin21ddvZQPtsbWlY6EYP7Pa1hf89sd1+H OI7KstOCGFqv05+O+Mx+o7zk6lu4uyaLRlfEw= 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=JaEwCekFsuVLnVwL8IUqLgCL1SsSfKEdsOUQ9nlXA3M=; b=AB/m42qHJnCfx3IHmwubXFWwpNU1Yh8dbQLCX6re7NANr83Cr3JtRKCGAzpPX2ufyz 0eC6bCnCezSocsxF/OE0Jqj6Mpf/SklaNHrZ8t8phXlaXx79Urpx6kwTJvLZWUQgr6mZ WMJmPgnjUxmvGgdwdhtjX94FTP7qap/ikSFnv7gqHrTWvm+X9xhyLDxMvlac4ThfcAqI rt/51HZ87+Td5QcjxV17U+goVQOEUVUSGkTi2OqnkMWi3UmZjZX5JfWBGsE9JHak5znq 299OuKhcNp+cIBJTL4hB1NgwshX99ws5YTKUNAyNdNo5/sYBlb7pOaGVz2dB5bOzcyGJ saCA== X-Gm-Message-State: AKS2vOyfkBIV6isR5ZokycijASJC9ZqiIIIpreKLeS1qR7xRQWHZuLV9 Rm+8qM4vWW8QNF5fj9s= X-Received: by 10.46.84.90 with SMTP id y26mr11084220ljd.77.1498072913735; Wed, 21 Jun 2017 12:21:53 -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 t24sm3920047ljd.1.2017.06.21.12.21.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 21 Jun 2017 12:21:53 -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 , linux-arm-kernel@lists.infradead.org, linux-i2c@vger.kernel.org, Ulf Hansson Subject: [PATCH 5/9] PM / ACPI: Split acpi_lpss_suspend_late|resume_early() Date: Wed, 21 Jun 2017 21:21:24 +0200 Message-Id: <1498072888-14782-6-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1498072888-14782-1-git-send-email-ulf.hansson@linaro.org> References: <1498072888-14782-1-git-send-email-ulf.hansson@linaro.org> Move the code which is special to ACPI LPSS into separate functions. This may clarify the code a bit, but the main purpose of this change, is instead to prepare for additional changes on top. Ideally the following changes should then become easier to review. Signed-off-by: Ulf Hansson --- drivers/acpi/acpi_lpss.c | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) -- 2.7.4 diff --git a/drivers/acpi/acpi_lpss.c b/drivers/acpi/acpi_lpss.c index d7b6778..12bc5c7 100644 --- a/drivers/acpi/acpi_lpss.c +++ b/drivers/acpi/acpi_lpss.c @@ -702,22 +702,28 @@ static void acpi_lpss_dismiss(struct device *dev) } #ifdef CONFIG_PM_SLEEP -static int acpi_lpss_suspend_late(struct device *dev) +static int lpss_suspend_late(struct device *dev) { struct lpss_private_data *pdata = acpi_driver_data(ACPI_COMPANION(dev)); + + if (pdata->dev_desc->flags & LPSS_SAVE_CTX) + acpi_lpss_save_ctx(dev, pdata); + + return acpi_dev_suspend_late(dev); +} + +static int acpi_lpss_suspend_late(struct device *dev) +{ int ret; ret = pm_generic_suspend_late(dev); if (ret) return ret; - if (pdata->dev_desc->flags & LPSS_SAVE_CTX) - acpi_lpss_save_ctx(dev, pdata); - - return acpi_dev_suspend_late(dev); + return lpss_suspend_late(dev); } -static int acpi_lpss_resume_early(struct device *dev) +static int lpss_resume_early(struct device *dev) { struct lpss_private_data *pdata = acpi_driver_data(ACPI_COMPANION(dev)); int ret; @@ -731,6 +737,17 @@ static int acpi_lpss_resume_early(struct device *dev) if (pdata->dev_desc->flags & LPSS_SAVE_CTX) acpi_lpss_restore_ctx(dev, pdata); + return 0; +} + +static int acpi_lpss_resume_early(struct device *dev) +{ + int ret; + + ret = lpss_resume_early(dev); + if (ret) + return ret; + return pm_generic_resume_early(dev); } #endif /* CONFIG_PM_SLEEP */ From patchwork Wed Jun 21 19:21:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 106120 Delivered-To: patches@linaro.org Received: by 10.140.91.2 with SMTP id y2csp2092660qgd; Wed, 21 Jun 2017 12:21:55 -0700 (PDT) X-Received: by 10.46.0.77 with SMTP id 74mr10556901lja.109.1498072915438; Wed, 21 Jun 2017 12:21:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498072915; cv=none; d=google.com; s=arc-20160816; b=wLotHTsej6wbJ6H89x2d5gteenVh418L2nBGe1DsX2eWJx+rDdKQB2qGEn+Pl0woVt 94UIcTKudJ3J/v0S+eMsK+9PZ+ONczL2GQJqy2JG/dt0F8mTEdVwcPXWXIthuFAfx4+P /WTBwVdTywej3I/2ip6PvYDlC4sYXALHfpjoildtDnrGdCytEDXRE9NSOEpD1UKuJmhJ oPgAIVsk4lwufamjsJTrabcJHXx3sf1PbbO8uqvYataRVadwIoWfbZw0UKSUV6ewG8cZ p66tJ6dd9KuaS/sVdYh1Kgk/MtRWZs9VFKqhJvjAhYWlFyf37WT2Q/jwX6AFSxx4iqFe 2Htg== 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=yNZoxAcOWEEwBaVDzkOncnO5GKkzAwnoEZB40/a+44E=; b=pBsprO6D8jsF0lu60Ggj4/FmLjygBtToQrLl96icFeBS7udTcG1g2ywmqReS4kJczw lIWZbkWCZpeZvLy4/jdJ6VsJlyRZ/vDXs412JpoK5yI5iOJauhUMOAusunBzje7seQSe FDL89O1HxfL0KQMRUdhtRWXgWAEJ94wstR78SPDgj0/bbkM42kHSun7UhTs6a/CDRvAt 1KUZEsy84v1NfYy58MnVNJuGlno0UOHH7x4VNi4UQ/ezmMW6qoL7rzbJ03SbpgLaqdI9 tVkuSYJ9hr/uKJwS7c9WDABcWQIqhsuZtMi4Bh6bya55gy6NWn5/rGDL8ujxhmHXGp/x jB0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.b=jJeH32cK; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::22d 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-x22d.google.com (mail-lf0-x22d.google.com. [2a00:1450:4010:c07::22d]) by mx.google.com with ESMTPS id g95si9513108lji.68.2017.06.21.12.21.55 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Jun 2017 12:21:55 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::22d as permitted sender) client-ip=2a00:1450:4010:c07::22d; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.b=jJeH32cK; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::22d 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-x22d.google.com with SMTP id p189so102985110lfe.2 for ; Wed, 21 Jun 2017 12:21:55 -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=yNZoxAcOWEEwBaVDzkOncnO5GKkzAwnoEZB40/a+44E=; b=jJeH32cK4vDO3vmzPP+W3LxMZ+2w+zTK+qn05tJMQL4lVD5avGtMAFikUOVJkGcZ/V TjE5tVCaYB9yizw8dkdP5laiZOdMAnomCxaTf1oQlyxFSsMn9MImh9UxOnF08nTaJ6OX soNY9baBQ1ZHp0lZ+/HnsWYCmksPBJFqr/Nlk= 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=yNZoxAcOWEEwBaVDzkOncnO5GKkzAwnoEZB40/a+44E=; b=DwuB+QcmYMbHc3zqwDWDOWOk/zi0+41DC4K/DnQGDdGhhs4LpYiFKeE+pYBN5aZ2Zd r/qH42A/4pFKKK5gKd8oslrEplzrTVe10yAY6TIl8+QhL2VjNRzpNPS3sDD1SdBXDGFe zjRoVnIm0+caoXhjgsj55eoKQzr1lazVrg7H0YSTRyUu8gmBwOkwTWt3fut+gItZtDvM C8Ed4H20YGZyTXKAwtDoZzOSTXUw6wdbo4naWb+OWtCptBUWBkJ1Fb0z1SN/lORK5rQa s/oyJ/YLC8r2kyDwj7Cb5V9/zF+FKVufcWebdV/Bz2PUD0kx6ABl1ieliUfP+mJY0ZtW j7OQ== X-Gm-Message-State: AKS2vOyfJTeru4duPqsW+AlGcRCkDiSqHCSF8E0gZHKSX2YdngHiHNyH BhNWY0JRfaNuAW4Ff/c= X-Received: by 10.46.69.133 with SMTP id s127mr11625301lja.13.1498072915038; Wed, 21 Jun 2017 12:21:55 -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 t24sm3920047ljd.1.2017.06.21.12.21.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 21 Jun 2017 12:21:54 -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 , linux-arm-kernel@lists.infradead.org, linux-i2c@vger.kernel.org, Ulf Hansson Subject: [PATCH 6/9] PM / ACPI: Provide option to disable direct_complete for ACPI devices Date: Wed, 21 Jun 2017 21:21:25 +0200 Message-Id: <1498072888-14782-7-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1498072888-14782-1-git-send-email-ulf.hansson@linaro.org> References: <1498072888-14782-1-git-send-email-ulf.hansson@linaro.org> In some cases a driver for an ACPI device needs to be able to prevent the ACPI PM domain from using the direct_complete path during system sleep. One typical case is when the driver for the device needs its device to stay runtime enabled, during the __device_suspend phase. This isn't the case when the direct_complete path is being executed by the PM core, as it then disables runtime PM for the device in __device_suspend(). Any following attempts to runtime resume the device after that point, just fails. A workaround to this problem is to let the driver runtime resume its device from its ->prepare() callback, as that would prevent the direct_complete path from being executed. However, that may often be a waste, especially if it turned out that no one really needed the device. For this reason, invent acpi_dev_disable|enable_direct_complete(), to allow drivers to inform the ACPI PM domain to change its default behaviour during system sleep, and thus control whether it may use the direct_complete path or not. Typically a driver should call acpi_dev_disable_direct_comlete() during ->probe() and acpi_dev_enable_direct_complete() in ->remove(). Signed-off-by: Ulf Hansson --- drivers/acpi/device_pm.c | 37 ++++++++++++++++++++++++++++++++++++- include/acpi/acpi_bus.h | 1 + include/linux/acpi.h | 4 ++++ 3 files changed, 41 insertions(+), 1 deletion(-) -- 2.7.4 diff --git a/drivers/acpi/device_pm.c b/drivers/acpi/device_pm.c index ee51e75..2393a1a 100644 --- a/drivers/acpi/device_pm.c +++ b/drivers/acpi/device_pm.c @@ -879,6 +879,41 @@ EXPORT_SYMBOL_GPL(acpi_subsys_runtime_resume); #ifdef CONFIG_PM_SLEEP /** + * acpi_dev_disable_direct_complete - Disable the direct_complete path for ACPI. + * @dev: Device to disable the path for. + * + * Per default the ACPI PM domain tries to use the direct_complete path for its + * devices during system sleep. This function allows a user, typically a driver + * during probe, to disable the direct_complete path from being used by ACPI. + */ +void acpi_dev_disable_direct_complete(struct device *dev) +{ + struct acpi_device *adev = ACPI_COMPANION(dev); + + if (adev) + adev->no_direct_complete = true; +} +EXPORT_SYMBOL_GPL(acpi_dev_disable_direct_complete); + +/** + * acpi_dev_enable_direct_complete - Enable the direct_complete path for ACPI. + * @dev: Device to enable the path for. + * + * Enable the direct_complete path to be used during system suspend for the ACPI + * PM domain, which is the default option. Typically a driver that disabled the + * path during ->probe(), must call this function during ->remove() to re-enable + * the direct_complete path to be used by ACPI. + */ +void acpi_dev_enable_direct_complete(struct device *dev) +{ + struct acpi_device *adev = ACPI_COMPANION(dev); + + if (adev) + adev->no_direct_complete = false; +} +EXPORT_SYMBOL_GPL(acpi_dev_enable_direct_complete); + +/** * acpi_dev_suspend_late - Put device into a low-power state using ACPI. * @dev: Device to put into a low-power state. * @@ -967,7 +1002,7 @@ int acpi_subsys_prepare(struct device *dev) if (ret < 0) return ret; - if (!adev || !pm_runtime_suspended(dev)) + if (!adev || adev->no_direct_complete || !pm_runtime_suspended(dev)) return 0; return !acpi_dev_needs_resume(dev, adev); diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h index 63a90a6..2293d24 100644 --- a/include/acpi/acpi_bus.h +++ b/include/acpi/acpi_bus.h @@ -380,6 +380,7 @@ struct acpi_device { struct list_head physical_node_list; struct mutex physical_node_lock; void (*remove)(struct acpi_device *); + bool no_direct_complete; }; /* Non-device subnode */ diff --git a/include/linux/acpi.h b/include/linux/acpi.h index 137e4a3..a41cca5 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -859,6 +859,8 @@ static inline int acpi_dev_pm_attach(struct device *dev, bool power_on) #endif #if defined(CONFIG_ACPI) && defined(CONFIG_PM_SLEEP) +void acpi_dev_disable_direct_complete(struct device *dev); +void acpi_dev_enable_direct_complete(struct device *dev); int acpi_dev_suspend_late(struct device *dev); int acpi_dev_resume_early(struct device *dev); int acpi_subsys_prepare(struct device *dev); @@ -868,6 +870,8 @@ int acpi_subsys_resume_early(struct device *dev); int acpi_subsys_suspend(struct device *dev); int acpi_subsys_freeze(struct device *dev); #else +static inline void acpi_dev_disable_direct_complete(struct device *dev) {} +static inline void acpi_dev_enable_direct_complete(struct device *dev) {} static inline int acpi_dev_suspend_late(struct device *dev) { return 0; } static inline int acpi_dev_resume_early(struct device *dev) { return 0; } static inline int acpi_subsys_prepare(struct device *dev) { return 0; } From patchwork Wed Jun 21 19:21:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 106121 Delivered-To: patches@linaro.org Received: by 10.140.91.2 with SMTP id y2csp2092673qgd; Wed, 21 Jun 2017 12:21:57 -0700 (PDT) X-Received: by 10.25.79.25 with SMTP id d25mr12194965lfb.133.1498072917068; Wed, 21 Jun 2017 12:21:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498072917; cv=none; d=google.com; s=arc-20160816; b=ADnMkpba6MsyqD/pUGj1dAv0zxwk7P9rmcaf/iyfxnCCvvR81pj0PG3+59nAmhnclt VCABlgbrCZMUiuf6aA7zPnVFFgk/ODPzv1vrDVD7zZT5ku6I2raKa8Mp0YRffXjNfoNP px5dB/deVzzK11o3ELYdQmiGNhC3nkuGo5YKZXcZz1siWRqe/PrAe2CIai9ABrFCEP4s dtWB5uXe3/QuhPCeY6N/lKqbjyVdCZKPs5jpDIKLLs3fwcjrBVArNpvTTvAMFhwrPTGQ /SbWqqOOUq+h8Jypj3rfFuteEZNSolLw8VXCDpo/uFvM0AjLwub/DkyBIY92Gh3Zkc9q QgjQ== 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=L0Bxj+RAgtEBUb4zoOfwrjAydIDoVxBTErkG28rFqDg=; b=EcqTFgLtu949ZwU/C0vDQ/UIEW1Sx+9sHfSQbFYJOhD1PpEe51v6dGO4cSh5Lr1mDD tfFoScGorYvzVZ5STZojSEVfEU6McpG0bIxP4s7c6W8DZV1wRyezFAiToeev6Xt72/ag Le5H8lPdX3wwA9g3or8OkfHrnUl+WhP+iSZ70QjGBGlUmiCDm6gBfVNSNlTCPk88EChh Tz2efgEMnQPlqLAl38rfZ5S4L1Euu5nePMV7O41/ikNClazX9kdOAFcqEACbCAb2ILeS o8cZ2c2efVS84RbKWSILUNhJFj2oJhcjNqXlX14mOYrkGhtvrvxI2gxyjVte35tLlbKS F6Mw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.b=JMZnweGX; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::22f 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-x22f.google.com (mail-lf0-x22f.google.com. [2a00:1450:4010:c07::22f]) by mx.google.com with ESMTPS id z2si6441453lfa.120.2017.06.21.12.21.56 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Jun 2017 12:21:57 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::22f as permitted sender) client-ip=2a00:1450:4010:c07::22f; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.b=JMZnweGX; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::22f 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-x22f.google.com with SMTP id p189so102985486lfe.2 for ; Wed, 21 Jun 2017 12:21:56 -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=L0Bxj+RAgtEBUb4zoOfwrjAydIDoVxBTErkG28rFqDg=; b=JMZnweGXE6cfTzq7pnNuqP1d+D0VCi66aT+yTlyccON8Gg5x83vlianEiZiks0hjcT ZJUvK/r+8eR6QiD277Fy11GY8cW94xdUog3oZzCoAMdQunvyZjZG06Gu7C0hOAUBa/us uTGUmp2WZ+3cEnkkRMUP7xFVPjgAHsBhcckD0= 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=L0Bxj+RAgtEBUb4zoOfwrjAydIDoVxBTErkG28rFqDg=; b=Y1q7hnlRpmxC52QMBunR17JLJdUaXTWrQGPulUybi6gxRu3upU/yc9QELwFMS8gjRp 2qDzRbjppjWTejw56nnTfvpuJFNO04ACu/Q/BBOqU/pKw1EpuM90f+PK+5acrx+chP6u TCekfOmypPDXpuYTJvuH+10C38T2yDPx0cvfTLSZHqVYg//ubfLyFSxGX5jLAaEHAiq3 3L1lrdVe/W8d/FYBLH6oEvZORQLpKQsnxQDTQ1mUHfWBV9852vc1tTbBTWSKfogGrC6s TEuMYUgLFBwUn1e1OCLP4Jv0v8/9DIhhg5AkhoIgDFdrcJ1+zFW0uWTlOsidjFwMLhii n6cA== X-Gm-Message-State: AKS2vOx7tj7jZqixAdVw6TL81KczVwo9lrpCNYL1JjwD6j4t51rosK4D KSzs384bhWrq2T1uzA4= X-Received: by 10.46.83.13 with SMTP id h13mr9780791ljb.102.1498072916598; Wed, 21 Jun 2017 12:21:56 -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 t24sm3920047ljd.1.2017.06.21.12.21.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 21 Jun 2017 12:21:55 -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 , linux-arm-kernel@lists.infradead.org, linux-i2c@vger.kernel.org, Ulf Hansson Subject: [PATCH 7/9] PM / ACPI: Enable the runtime PM centric approach for system sleep Date: Wed, 21 Jun 2017 21:21:26 +0200 Message-Id: <1498072888-14782-8-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1498072888-14782-1-git-send-email-ulf.hansson@linaro.org> References: <1498072888-14782-1-git-send-email-ulf.hansson@linaro.org> This change extends the interpretation of the ACPI's no_direct_complete flag to be used to enable the so called runtime PM centric approach, for devices being attached to the ACPI PM domain. The principle behind the runtime PM centric approach is to re-use the runtime PM callbacks to implement system sleep for drivers/subsystems. Moreover, using the runtime PM centric approach gives an optimized behaviour around avoiding to wake up a device from its low power state during system sleep, unless really needed. To deploy the runtime PM centric approach for a subsystem/driver, the following adaptations needs to be made. First, the runtime PM callbacks may be called when runtime PM has been disabled for the device. This serves as an indication for the callbacks to understand they are running in the system sleep sequence, instead of in the regular runtime PM path. In some cases, a callback needs to take different actions depending in what path it is being executed in, as is the case for the ACPI PM domain. In particular for the ACPI PM domain's ->runtime_suspend|resume() callbacks, when those finds runtime PM being disabled for the device, it instead executes the same operations as normally being run when ->suspend_late() and ->resume_early() callbacks are invoked during system sleep. Second, at the PM domain level, it is expected that the driver for the device makes use of pm_runtime_force_suspend|resume(), to re-use the runtime PM callbacks to put the device into low power state and to wake it up when needed during system sleep. For the ACPI PM domain's ->suspend_late() and ->resume_early() callbacks, it means bypassing the operations putting the device into low power state and the operations that wakes it up. Instead it shall invoke only the lower level ->suspend_late() and ->resume_early() callbacks for the driver, if present. Signed-off-by: Ulf Hansson --- drivers/acpi/acpi_lpss.c | 58 +++++++++++++++++++++++++++++++++--------------- drivers/acpi/device_pm.c | 56 ++++++++++++++++++++++++++++++++++++++++------ 2 files changed, 89 insertions(+), 25 deletions(-) -- 2.7.4 diff --git a/drivers/acpi/acpi_lpss.c b/drivers/acpi/acpi_lpss.c index 12bc5c7..adc84b3 100644 --- a/drivers/acpi/acpi_lpss.c +++ b/drivers/acpi/acpi_lpss.c @@ -714,10 +714,11 @@ static int lpss_suspend_late(struct device *dev) static int acpi_lpss_suspend_late(struct device *dev) { + struct acpi_device *adev = ACPI_COMPANION(dev); int ret; ret = pm_generic_suspend_late(dev); - if (ret) + if (ret || adev->no_direct_complete) return ret; return lpss_suspend_late(dev); @@ -742,13 +743,23 @@ static int lpss_resume_early(struct device *dev) static int acpi_lpss_resume_early(struct device *dev) { - int ret; + struct acpi_device *adev = ACPI_COMPANION(dev); + int ret = 0; - ret = lpss_resume_early(dev); - if (ret) - return ret; + if (!adev->no_direct_complete) + ret = lpss_resume_early(dev); - return pm_generic_resume_early(dev); + return ret ? ret : pm_generic_resume_early(dev); +} +#else +static inline int lpss_suspend_late(struct device *dev) +{ + return 0; +} + +static inline int lpss_resume_early(struct device *dev) +{ + return 0; } #endif /* CONFIG_PM_SLEEP */ @@ -846,6 +857,9 @@ static int acpi_lpss_runtime_suspend(struct device *dev) if (ret) return ret; + if (!pm_runtime_enabled(dev)) + return lpss_suspend_late(dev); + if (pdata->dev_desc->flags & LPSS_SAVE_CTX) acpi_lpss_save_ctx(dev, pdata); @@ -867,21 +881,29 @@ static int acpi_lpss_runtime_resume(struct device *dev) struct lpss_private_data *pdata = acpi_driver_data(ACPI_COMPANION(dev)); int ret; - /* - * This call is kept first to be in symmetry with - * acpi_lpss_runtime_suspend() one. - */ - if (lpss_quirks & LPSS_QUIRK_ALWAYS_POWER_ON && iosf_mbi_available()) - lpss_iosf_exit_d3_state(); + if (pm_runtime_enabled(dev)) { + /* + * This call is kept first to be in symmetry with + * acpi_lpss_runtime_suspend() one. + */ + if (lpss_quirks & LPSS_QUIRK_ALWAYS_POWER_ON && + iosf_mbi_available()) + lpss_iosf_exit_d3_state(); - ret = acpi_dev_runtime_resume(dev); - if (ret) - return ret; + ret = acpi_dev_runtime_resume(dev); + if (ret) + return ret; - acpi_lpss_d3_to_d0_delay(pdata); + acpi_lpss_d3_to_d0_delay(pdata); - if (pdata->dev_desc->flags & LPSS_SAVE_CTX) - acpi_lpss_restore_ctx(dev, pdata); + if (pdata->dev_desc->flags & LPSS_SAVE_CTX) + acpi_lpss_restore_ctx(dev, pdata); + + } else { + ret = lpss_resume_early(dev); + if (ret) + return ret; + } return pm_generic_runtime_resume(dev); } diff --git a/drivers/acpi/device_pm.c b/drivers/acpi/device_pm.c index 2393a1a..e0324ab 100644 --- a/drivers/acpi/device_pm.c +++ b/drivers/acpi/device_pm.c @@ -859,7 +859,14 @@ EXPORT_SYMBOL_GPL(acpi_dev_runtime_resume); int acpi_subsys_runtime_suspend(struct device *dev) { int ret = pm_generic_runtime_suspend(dev); - return ret ? ret : acpi_dev_runtime_suspend(dev); + + if (ret) + return ret; + + if (!pm_runtime_enabled(dev)) + return acpi_dev_suspend_late(dev); + + return acpi_dev_runtime_suspend(dev); } EXPORT_SYMBOL_GPL(acpi_subsys_runtime_suspend); @@ -872,7 +879,17 @@ EXPORT_SYMBOL_GPL(acpi_subsys_runtime_suspend); */ int acpi_subsys_runtime_resume(struct device *dev) { - int ret = acpi_dev_runtime_resume(dev); + struct acpi_device *adev = ACPI_COMPANION(dev); + int ret = 0; + + if (!adev) + return 0; + + if (!pm_runtime_enabled(dev)) + ret = acpi_dev_resume_early(dev); + else + ret = acpi_dev_runtime_resume(dev); + return ret ? ret : pm_generic_runtime_resume(dev); } EXPORT_SYMBOL_GPL(acpi_subsys_runtime_resume); @@ -1015,13 +1032,21 @@ EXPORT_SYMBOL_GPL(acpi_subsys_prepare); */ void acpi_subsys_complete(struct device *dev) { + struct acpi_device *adev = ACPI_COMPANION(dev); + + if (!adev) + return; + pm_generic_complete(dev); /* * If the device had been runtime-suspended before the system went into * the sleep state it is going out of and it has never been resumed till - * now, resume it in case the firmware powered it up. + * now, resume it in case the firmware powered it up. Also resume it in + * case no_direct_complete is set for the device, to be sure the device + * are managed correctly when firmware has powered it up. */ - if (dev->power.direct_complete && pm_resume_via_firmware()) + if ((dev->power.direct_complete || adev->no_direct_complete) && + pm_resume_via_firmware()) pm_request_resume(dev); } EXPORT_SYMBOL_GPL(acpi_subsys_complete); @@ -1049,8 +1074,17 @@ EXPORT_SYMBOL_GPL(acpi_subsys_suspend); */ int acpi_subsys_suspend_late(struct device *dev) { - int ret = pm_generic_suspend_late(dev); - return ret ? ret : acpi_dev_suspend_late(dev); + struct acpi_device *adev = ACPI_COMPANION(dev); + int ret; + + if (!adev) + return 0; + + ret = pm_generic_suspend_late(dev); + if (ret || adev->no_direct_complete) + return ret; + + return acpi_dev_suspend_late(dev); } EXPORT_SYMBOL_GPL(acpi_subsys_suspend_late); @@ -1064,7 +1098,15 @@ EXPORT_SYMBOL_GPL(acpi_subsys_suspend_late); */ int acpi_subsys_resume_early(struct device *dev) { - int ret = acpi_dev_resume_early(dev); + struct acpi_device *adev = ACPI_COMPANION(dev); + int ret = 0; + + if (!adev) + return 0; + + if (!adev->no_direct_complete) + ret = acpi_dev_resume_early(dev); + return ret ? ret : pm_generic_resume_early(dev); } EXPORT_SYMBOL_GPL(acpi_subsys_resume_early); From patchwork Wed Jun 21 19:21:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 106122 Delivered-To: patches@linaro.org Received: by 10.140.91.2 with SMTP id y2csp2092685qgd; Wed, 21 Jun 2017 12:21:58 -0700 (PDT) X-Received: by 10.25.199.13 with SMTP id x13mr11997997lff.52.1498072918426; Wed, 21 Jun 2017 12:21:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498072918; cv=none; d=google.com; s=arc-20160816; b=Mjh+3F0dI7dh2xibnNDuo7uswP1ykqT50yucyUF9KH9FZOD9IJo6rBARD3labBCCQT 18uDKv4wMjokjqBl0mI7Vtg9SGIGUFDO7jIewfxBJXAd6C7PCOAel9M+IBxPm+Pux6q5 aGfcK69/a7ZesAGYL8My4W8zeuORs/8vJhvcNJebdnmluhcdPqvtls6ht1iNIawJ2MM9 OhRFBibFrA4qVuwulO/rpCDNztdciRybkmugOBV4HJUggzSt5q1aFXw6o5YJevKScvaA I5cPJB7MZL0VVxHOaiL8oGMdhW+oCWujqYSGSkOUeONE1YQhrpfP8OTuAV3mfYiXFrpn gIhg== 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=CAI7eMLczbKxpADKYBOT9FpeOYlOScekjsamv5c1doA=; b=zMUtzaXTvNf1eZoXRO6rHPWy21mGVELI9O9NsHJmlMjyaP1OzGYxtoMaLD6PNy2b/i CXUHsEhGJ9j5AEuwYwNhJK7yyfXrh01g2OI3HIhZJepZCl7GAyRHaknUDgUAHsuxlbdK S5/xdZtGBpwRTvBs4059wT4sQRRS7e8TToAbk059JHUFIn1ts5jLljs2ApCijqbidvGh pP92RsmrwVf0gS0Cpc/gxtJ75Fvm1xuPuviIN61Jumav9XAJsYxlWPpBkNFT1yg+H0vH 6eTdXb2+O1NNbdJFZwqzB/zGGJb2/5/vyO41wO1UQfLVBsSGZXXEogDkj8ULVxsi+Ht4 wKYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.b=HIJlqKgS; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::22b 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-x22b.google.com (mail-lf0-x22b.google.com. [2a00:1450:4010:c07::22b]) by mx.google.com with ESMTPS id n68si9551905lfi.330.2017.06.21.12.21.58 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Jun 2017 12:21:58 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::22b as permitted sender) client-ip=2a00:1450:4010:c07::22b; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.b=HIJlqKgS; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::22b 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-x22b.google.com with SMTP id m77so102862430lfe.0 for ; Wed, 21 Jun 2017 12:21:58 -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=CAI7eMLczbKxpADKYBOT9FpeOYlOScekjsamv5c1doA=; b=HIJlqKgSphwFvwGdoMRyLKo2/2TdIaXn7JeT1O+7xHuC0MvINd1DLgMIaLWvvl5Ouk QAheBFiu+YXi2f+jVFGtBLBRY1h0F1Y7N8SV9AOGqNX1HqJ2x7DSS4X9psl6/K2Y0csS HTQtXmAgsCYuzh8rLYnWuX1uh3zvdHdgNVJgk= 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=CAI7eMLczbKxpADKYBOT9FpeOYlOScekjsamv5c1doA=; b=tz62uJn4Lk8z6CKWt+F+w+BTodLvvpMOHlrh37xqzn9nsHDoHPVDw07QdOA0OsTYsp yrou9s/w85SLbC8i3SIF1QXf7XnxVis4Ab5W+vghZC+vuxOtl5PR2fHQuOJGevxTq1is hbRWfB6WzVzs45LxIrki7E8sbQW7sX35FOioLF7tECzduXdWKA1rnVZMTpHs48e0J9xh PzDwzhiPlFCq/UMEcvKK07LqpJb28v/kM3VKva5A1trpm3oJUVaIVwvD3FXLI2zlmz6R BZJ4cSOGAb+rt1hoHsIltQv4ISftfrY5Xc3bBxOavVwFxtcGk/W9dtAX1VKcJKvi5eCi A3rA== X-Gm-Message-State: AKS2vOwnnKb/f+7lFFuUxfZHfXJ/NqKbURQr9DXIK0JQmxpxy1X2nA12 vsplJuV9r3LkCMWb+ZA= X-Received: by 10.46.82.68 with SMTP id g65mr1552089ljb.123.1498072918074; Wed, 21 Jun 2017 12:21:58 -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 t24sm3920047ljd.1.2017.06.21.12.21.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 21 Jun 2017 12:21:57 -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 , linux-arm-kernel@lists.infradead.org, linux-i2c@vger.kernel.org, Ulf Hansson Subject: [PATCH 8/9] PM / ACPI: Avoid runtime resuming device in acpi_subsys_suspend|freeze() Date: Wed, 21 Jun 2017 21:21:27 +0200 Message-Id: <1498072888-14782-9-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1498072888-14782-1-git-send-email-ulf.hansson@linaro.org> References: <1498072888-14782-1-git-send-email-ulf.hansson@linaro.org> In the case when the no_direct_complete flag is set for the ACPI device, we can under some conditions during system sleep, avoid runtime resuming the device in acpi_subsys_suspend|freeze(). This will of course improve the time it takes for the system to suspend, but also avoid wasting power. More precisely, from acpi_subsys_suspend|freeze(), let's call acpi_dev_needs_resume() when the no_direct_complete flag is set, as it tells us when runtime resume of the device is needed, thus let's avoid it if possible. Signed-off-by: Ulf Hansson --- drivers/acpi/device_pm.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) -- 2.7.4 diff --git a/drivers/acpi/device_pm.c b/drivers/acpi/device_pm.c index e0324ab..f3061f9 100644 --- a/drivers/acpi/device_pm.c +++ b/drivers/acpi/device_pm.c @@ -1056,10 +1056,19 @@ EXPORT_SYMBOL_GPL(acpi_subsys_complete); * @dev: Device to handle. * * Follow PCI and resume devices suspended at run time before running their - * system suspend callbacks. + * system suspend callbacks. However, try to avoid it when no_direct_complete + * is set. */ int acpi_subsys_suspend(struct device *dev) { + struct acpi_device *adev = ACPI_COMPANION(dev); + + if (!adev) + return 0; + + if (adev->no_direct_complete && !acpi_dev_needs_resume(dev, adev)) + return pm_generic_suspend(dev); + pm_runtime_resume(dev); return pm_generic_suspend(dev); } @@ -1117,12 +1126,22 @@ EXPORT_SYMBOL_GPL(acpi_subsys_resume_early); */ int acpi_subsys_freeze(struct device *dev) { + struct acpi_device *adev = ACPI_COMPANION(dev); + + if (!adev) + return 0; + /* * This used to be done in acpi_subsys_prepare() for all devices and * some drivers may depend on it, so do it here. Ideally, however, * runtime-suspended devices should not be touched during freeze/thaw - * transitions. + * transitions. At least when no_direct_complete is set, let's try to + * avoid it. */ + + if (adev->no_direct_complete && !acpi_dev_needs_resume(dev, adev)) + return pm_generic_freeze(dev); + pm_runtime_resume(dev); return pm_generic_freeze(dev); } From patchwork Wed Jun 21 19:21:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 106123 Delivered-To: patches@linaro.org Received: by 10.140.91.2 with SMTP id y2csp2092701qgd; Wed, 21 Jun 2017 12:22:00 -0700 (PDT) X-Received: by 10.46.5.20 with SMTP id 20mr10798572ljf.34.1498072920146; Wed, 21 Jun 2017 12:22:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498072920; cv=none; d=google.com; s=arc-20160816; b=DwUv1lCSdoU/PdJDDKjr0muLvnt9t2TqG49QAZNmZ9mSlfTcWIM3vqs79Ekqg53H62 XdTq2EQX6n8nWQCavV3fW6R6r1/SkE6/uFg+IezlfntCksBtjDILAsVJkgop4YTui032 wlzvhrwGjalwXyAWLSggrVO8SSd4BxQf1sKAROWvCWiY98bGk9L85adIK1wZ1rWU96md NPAvso8ePtjcAQt5t7zWXkGvwqBan3TDTSwRkcynwtMtEd+GEu5hinzh0NCn4Xe+QYba LLyc3NQe98Yb1d2g3KiFRDtCRWP6i/y5TtqIt1WrmckDHaYz25Itmz74cPyWZP7rlP2d 6oTw== 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=gQ0z6uQZXEMVLPfg2GRn6Y71LvqWlZHeak/YrTUGnt4=; b=t7I4oePds1aKzmYnLQw5d49m1aKqS5dnLMBqC2CSFvRAGlnaG5DD6VaRmS8HjBNIOH rKyGj9IlzLXTi7KKQTXo/KKgtkCVudQqKyDIwseo1nSjwRTgHwJdFlB2FP7C1VtFiemO vEsh83ZWLW/kCy/Y6yFUIp4yi5leyJvCy/JMW6hBkMQ27aEbpM/XFZO2nXoEC9QeS88e 1AaoLF572o4PrBkMmtXKfNCsxQDVkhu3MY3VJF49XpDwcBPvQdXhZsrRgQmQUqtKP0tJ P7oNhgXMusu+bnwOHHRbZv2Mrm8OPPTiWB4n26nTEr+6ryZXFn5bNeVUKcET0dPwAw48 TwFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.b=SPk29lmN; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::230 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-x230.google.com (mail-lf0-x230.google.com. [2a00:1450:4010:c07::230]) by mx.google.com with ESMTPS id x5si8979074lfa.188.2017.06.21.12.21.59 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Jun 2017 12:22:00 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::230 as permitted sender) client-ip=2a00:1450:4010:c07::230; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.b=SPk29lmN; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::230 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-x230.google.com with SMTP id p189so102986166lfe.2 for ; Wed, 21 Jun 2017 12:21:59 -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=gQ0z6uQZXEMVLPfg2GRn6Y71LvqWlZHeak/YrTUGnt4=; b=SPk29lmNM/olTnoR6riPwVRdcsRAEOODzwFzN7MaybsAnsZhxnNYpc41QGwDSXhk9u uGuIFltxl3D7vuzACyyGt8MkpvMV4+MQxJZ7OdZLMtfkyKx8P8VB8BdslWqqoorfhvIt xUfj2GF0Qjd9Y7xrZQlqPo/d1+QWALNgbyOr0= 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=gQ0z6uQZXEMVLPfg2GRn6Y71LvqWlZHeak/YrTUGnt4=; b=Mub5usSgyWv3BLpNOIu9FVTHA+VSGZQR50IST0VsCy97qUnKmzgqGRcBvj3zUP6AYW XbW6xIn7lStdwNKzpQEqMaMJZ8ETBXdAM5d9c2j94dDsz5HRs4V7rnnkIJufZbtJljhU v+c2wBGbgErWOSioyiTlltZvIADHVNYBOLDMECZlt91eae+sNhA00WWINnRxrCiTBEzR 2j28/0YWkIcrQVV+ZQ8Z0pxVplofjzsMlYRjpxnDJy6+xGik0cM2eioTw8RPD6P4cl+b l4dfaAEwkn8UR8T3QFCxRaAgfeBaEu9AaOFONh4iwp5yWJz/bepKh4RoSBZMd3KguzJC w1ZA== X-Gm-Message-State: AKS2vOwq77yyl5U/6+3PEnINEF/8FTDCcJcdr1ssQkCMDGul4Yvk78tB W3hqsU5ys9x4njsN4r8= X-Received: by 10.46.69.212 with SMTP id s203mr11199810lja.67.1498072919669; Wed, 21 Jun 2017 12:21:59 -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 t24sm3920047ljd.1.2017.06.21.12.21.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 21 Jun 2017 12:21:58 -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 , linux-arm-kernel@lists.infradead.org, linux-i2c@vger.kernel.org, Ulf Hansson Subject: [PATCH 9/9] i2c: designware: Deploy the runtime PM centric approach for system sleep Date: Wed, 21 Jun 2017 21:21:28 +0200 Message-Id: <1498072888-14782-10-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1498072888-14782-1-git-send-email-ulf.hansson@linaro.org> References: <1498072888-14782-1-git-send-email-ulf.hansson@linaro.org> Currently we runtime resume the device in the ->prepare() callback to make sure we manage system sleep properly. The earlier attempt to avoid that, as it's surely a waste in many situations, was based upon using the direct_complete path during system sleep. However, that failed because we could end up having the ->suspend() callback being invoked when the device was runtime suspended, causing calls for clock enable/disable and clock prepare/unprepare to become unbalanced. Deploying the runtime PM centric approach, via using the pm_runtime_force_suspend|resume() helpers as the system sleep callbacks, improves the behavior in the following regards: *) It avoids runtime resuming the device in the ->prepare() callback. **) The device remains runtime PM enabled during the device_suspend() phase, which thus makes it possible for users to send i2c transfers this entire phase. ***) It doesn't unnecessary runtime resume the device during system suspend, but allows the device to remain runtime suspended if that is possible. ****) It avoids to bring the device back to full power during system resume, unless really needed. Instead this task may get postponed to be managed by runtime PM. In case when the i2c device is attached to the ACPI PM domain, we need to inform ACPI to adapt its behavior for the runtime PM centric path during system sleep, which is done by calling acpi_dev_disable_direct_complete(). Worth to notice, comparing the earlier attempt of using the direct_complete() approach is that **) couldn't be supported and ****) relied on the device to be runtime suspended in the device_suspend() phase. Signed-off-by: Ulf Hansson --- drivers/i2c/busses/i2c-designware-platdrv.c | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) -- 2.7.4 diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c index 2b7fa75..b6e05ba 100644 --- a/drivers/i2c/busses/i2c-designware-platdrv.c +++ b/drivers/i2c/busses/i2c-designware-platdrv.c @@ -331,6 +331,8 @@ static int dw_i2c_plat_probe(struct platform_device *pdev) if (r) goto exit_probe; + acpi_dev_disable_direct_complete(&pdev->dev); + return r; exit_probe: @@ -346,6 +348,7 @@ static int dw_i2c_plat_remove(struct platform_device *pdev) { struct dw_i2c_dev *dev = platform_get_drvdata(pdev); + acpi_dev_enable_direct_complete(&pdev->dev); pm_runtime_get_sync(&pdev->dev); i2c_del_adapter(&dev->adapter); @@ -372,18 +375,8 @@ 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) -{ - pm_runtime_resume(dev); - return 0; -} -#else -#define dw_i2c_plat_prepare NULL -#endif - #ifdef CONFIG_PM -static int dw_i2c_plat_suspend(struct device *dev) +static int dw_i2c_plat_runtime_suspend(struct device *dev) { struct platform_device *pdev = to_platform_device(dev); struct dw_i2c_dev *i_dev = platform_get_drvdata(pdev); @@ -394,7 +387,7 @@ static int dw_i2c_plat_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); @@ -406,9 +399,11 @@ static int dw_i2c_plat_resume(struct device *dev) } 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_RUNTIME_PM_OPS(dw_i2c_plat_suspend, dw_i2c_plat_resume, NULL) + 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_runtime_resume, + NULL) }; #define DW_I2C_DEV_PMOPS (&dw_i2c_dev_pm_ops)