Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/807142/?format=api
{ "id": 807142, "url": "http://patchwork.ozlabs.org/api/patches/807142/?format=api", "web_url": "http://patchwork.ozlabs.org/project/linux-i2c/patch/1504018610-10822-7-git-send-email-ulf.hansson@linaro.org/", "project": { "id": 35, "url": "http://patchwork.ozlabs.org/api/projects/35/?format=api", "name": "Linux I2C development", "link_name": "linux-i2c", "list_id": "linux-i2c.vger.kernel.org", "list_email": "linux-i2c@vger.kernel.org", "web_url": "", "scm_url": "", "webscm_url": "", "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<1504018610-10822-7-git-send-email-ulf.hansson@linaro.org>", "list_archive_url": null, "date": "2017-08-29T14:56:48", "name": "[v3,6/8] PM / ACPI: Enable the runtime PM centric approach for system sleep", "commit_ref": null, "pull_url": null, "state": "not-applicable", "archived": false, "hash": "76542d52ec0120a0174aee0a90389ad40a8e4fb9", "submitter": { "id": 21036, "url": "http://patchwork.ozlabs.org/api/people/21036/?format=api", "name": "Ulf Hansson", "email": "ulf.hansson@linaro.org" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/linux-i2c/patch/1504018610-10822-7-git-send-email-ulf.hansson@linaro.org/mbox/", "series": [ { "id": 387, "url": "http://patchwork.ozlabs.org/api/series/387/?format=api", "web_url": "http://patchwork.ozlabs.org/project/linux-i2c/list/?series=387", "date": "2017-08-29T14:56:42", "name": "PM / ACPI / i2c: Deploy runtime PM centric path for system sleep", "version": 3, "mbox": "http://patchwork.ozlabs.org/series/387/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/807142/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/807142/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<linux-i2c-owner@vger.kernel.org>", "X-Original-To": "incoming@patchwork.ozlabs.org", "Delivered-To": "patchwork-incoming@bilbo.ozlabs.org", "Authentication-Results": [ "ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=vger.kernel.org\n\t(client-ip=209.132.180.67; helo=vger.kernel.org;\n\tenvelope-from=linux-i2c-owner@vger.kernel.org;\n\treceiver=<UNKNOWN>)", "ozlabs.org; dkim=pass (1024-bit key;\n\tunprotected) header.d=linaro.org header.i=@linaro.org\n\theader.b=\"KLZcXQUM\"; dkim-atps=neutral" ], "Received": [ "from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3xhWvW1YXlz9t38\n\tfor <incoming@patchwork.ozlabs.org>;\n\tWed, 30 Aug 2017 00:57:27 +1000 (AEST)", "(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1751664AbdH2O5Y (ORCPT <rfc822;incoming@patchwork.ozlabs.org>);\n\tTue, 29 Aug 2017 10:57:24 -0400", "from mail-lf0-f44.google.com ([209.85.215.44]:37950 \"EHLO\n\tmail-lf0-f44.google.com\" rhost-flags-OK-OK-OK-OK) by vger.kernel.org\n\twith ESMTP id S1754674AbdH2O5M (ORCPT\n\t<rfc822; linux-i2c@vger.kernel.org>); Tue, 29 Aug 2017 10:57:12 -0400", "by mail-lf0-f44.google.com with SMTP id d202so14331628lfd.5\n\tfor <linux-i2c@vger.kernel.org>; Tue, 29 Aug 2017 07:57:11 -0700 (PDT)", "from localhost.localdomain (h-158-174-22-67.NA.cust.bahnhof.se.\n\t[158.174.22.67]) by smtp.gmail.com with ESMTPSA id\n\ty23sm652454ljd.19.2017.08.29.07.57.09\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128);\n\tTue, 29 Aug 2017 07:57:10 -0700 (PDT)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references;\n\tbh=8jrgc/IfGCMNNVG6RujufZsFpV26gsYCNTzrZZAH2L4=;\n\tb=KLZcXQUMH0ZdlLmvFgQYyCQ49ecr9blyUkiwvpKM8mjDpHCY2GoUOOVO3+Yu0oeZlz\n\tmuu5dasMhdfkbWYTrFo2YJISL5zr9i+WYX5ODcesC14QMHB9wOMA33N75LdPRM7JOSM0\n\t4nuIpPyKO/aWaiZM3IvRxWPm8ot5n0TOXvhzc=", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references;\n\tbh=8jrgc/IfGCMNNVG6RujufZsFpV26gsYCNTzrZZAH2L4=;\n\tb=KSuZw3FS9Ys1kJTKxs1/HJXMdMQ/RXg4LF47yonsk8rVtyukrLNACkMs/1PHDhaZAX\n\tBN3fJxw0M46Bd0EbFaePEG+f7u4sdHklgz/K73+gWzSQiW5/4Y+Df/RXEzgCm9CmT1Kb\n\tGnKEcr6VWeOv+KSAtXcLpE5r50mdABWgNT8bdVMdZS4XGvRricG2YBRXun2CX8lXKD3m\n\tiakuV8HKI8v4wPR/TIRgChtEmJVX/veKwDC4U9xtAIfcquvuUc3lCD/dyCD/H7qbsNvS\n\t8fpfwBeqaH3u/tv0E+2vNlnvIhopCUGijuKqq6vMJ+sJIvGGhP3dNP4exmpvxySeE9Jb\n\tgi0g==", "X-Gm-Message-State": "AHYfb5iIY2QB4UtqRU1NJ0IbZ1ByVvW4+Dt6zZEmLQmhebivkMzrlsF0\n\t2+rwOBYsPOGB2dPI", "X-Received": "by 10.25.216.89 with SMTP id p86mr208017lfg.27.1504018630869;\n\tTue, 29 Aug 2017 07:57:10 -0700 (PDT)", "From": "Ulf Hansson <ulf.hansson@linaro.org>", "To": "Wolfram Sang <wsa@the-dreams.de>,\n\t\"Rafael J . Wysocki\" <rjw@rjwysocki.net>,\n\tLen Brown <lenb@kernel.org>, linux-acpi@vger.kernel.org,\n\tlinux-pm@vger.kernel.org", "Cc": "Kevin Hilman <khilman@kernel.org>,\n\tJarkko Nikula <jarkko.nikula@linux.intel.com>,\n\tAndy Shevchenko <andriy.shevchenko@linux.intel.com>,\n\tMika Westerberg <mika.westerberg@linux.intel.com>,\n\tJisheng Zhang <jszhang@marvell.com>,\n\tJohn Stultz <john.stultz@linaro.org>, Guodong Xu <guodong.xu@linaro.org>,\n\tSumit Semwal <sumit.semwal@linaro.org>,\n\tHaojian Zhuang <haojian.zhuang@linaro.org>,\n\tJohannes Stezenbach <js@sig21.net>,\n\tlinux-arm-kernel@lists.infradead.org, linux-i2c@vger.kernel.org,\n\tUlf Hansson <ulf.hansson@linaro.org>", "Subject": "[PATCH v3 6/8] PM / ACPI: Enable the runtime PM centric approach\n\tfor system sleep", "Date": "Tue, 29 Aug 2017 16:56:48 +0200", "Message-Id": "<1504018610-10822-7-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-i2c-owner@vger.kernel.org", "Precedence": "bulk", "List-ID": "<linux-i2c.vger.kernel.org>", "X-Mailing-List": "linux-i2c@vger.kernel.org" }, "content": "This change enables the ACPI PM domain to cope with drivers that deploys\nthe runtime PM centric path for system sleep.\n\nCurrently the ACPI PM domain supports the direct_complete path, which\noffers some nice optimizations from PM point of view during system sleep.\nHowever, the runtime PM centric path have some additional optimizations\nthat this change enables for the ACPI PM domain. Let's walk through them.\n\n*)\nThe runtime PM centric path, doesn't require the device to be runtime\nsuspended during system suspend, when later during system resume trying to\navoid to bring it back into full power. That is the case for the\ndirect_complete path. This further avoids wasting power during system\nresume, but should also decrease the time it takes to resume the device.\n\n**)\nWhen the runtime PM centric path is used, the PM core does not skip calling\nany system sleep callbacks for the device, which is the case in the\ndirect_complete path. Based on that knowledge and relying on the driver to\ndo the right thing, the ACPI PM domain may avoid to always runtime resume\nthe device in the device_suspend() phase.\n\n***)\nIn the runtime PM centric path, the device may remain runtime PM enabled\nuntil the device_suspend_late() phase, instead of as in the direct_complete\npath, in the device_suspend() phase. This is convenient if the device needs\nto be runtime resumed sometime during the device_suspend() phase.\n\nTo deploy the runtime PM centric approach for the ACPI PM domain, and make\nit benefit from the above optimizations, the follow changes are made.\n\nFirst, the ACPI PM domain's runtime PM callbacks may be called when runtime\nPM has been disabled for the device. This serves as an indication to\nunderstand when they are running in the system sleep sequence, instead of\nin the regular runtime PM path. For these cases, make the ACPI PM domain to\nexecute the same operations as normally being run, when the\n->suspend_late() and the ->resume_early() callbacks are invoked.\n\nSecond, the ACPI PM domain's ->suspend_late() callback, shall not execute\nthe regular operations to put the device into low power state, when the\nruntime PM centric path is used. Calling pm_generic_suspend_late() is\nsufficient. Vice verse applies to the ACPI PM domain's ->resume_early()\ncallback.\n\nThird, in the ACPI PM domain's ->suspend|freeze() callbacks, let's avoid\nruntime resuming the device in case the runtime PM centric path is used,\nunless there are ACPI PM domain specific reasons to not.\n\nSigned-off-by: Ulf Hansson <ulf.hansson@linaro.org>\n---\n\nChanges in v3:\n\t- Convert to use the PM core flag, is_rpm_sleep flag.\n\t- Fold in changes from patch v2 7/9, which means avoiding to runtime\n\tresume the device in the ACPI PM domain's ->suspend|freeze() callbacks.\n\t- Updated changelog to reflect new changes.\n\n---\n drivers/acpi/acpi_lpss.c | 56 ++++++++++++++++++++++++++++++---------------\n drivers/acpi/device_pm.c | 59 ++++++++++++++++++++++++++++++++++++++++--------\n 2 files changed, 87 insertions(+), 28 deletions(-)", "diff": "diff --git a/drivers/acpi/acpi_lpss.c b/drivers/acpi/acpi_lpss.c\nindex e726173..2e34f69 100644\n--- a/drivers/acpi/acpi_lpss.c\n+++ b/drivers/acpi/acpi_lpss.c\n@@ -732,7 +732,7 @@ static int acpi_lpss_suspend_late(struct device *dev)\n \tint ret;\n \n \tret = pm_generic_suspend_late(dev);\n-\tif (ret)\n+\tif (ret || dev_pm_is_rpm_sleep(dev))\n \t\treturn ret;\n \n \treturn lpss_suspend_late(dev);\n@@ -757,13 +757,22 @@ static int lpss_resume_early(struct device *dev)\n \n static int acpi_lpss_resume_early(struct device *dev)\n {\n-\tint ret;\n+\tint ret = 0;\n \n-\tret = lpss_resume_early(dev);\n-\tif (ret)\n-\t\treturn ret;\n+\tif (!dev_pm_is_rpm_sleep(dev))\n+\t\tret = lpss_resume_early(dev);\n \n-\treturn pm_generic_resume_early(dev);\n+\treturn ret ? ret : pm_generic_resume_early(dev);\n+}\n+#else\n+static inline int lpss_suspend_late(struct device *dev)\n+{\n+\treturn 0;\n+}\n+\n+static inline int lpss_resume_early(struct device *dev)\n+{\n+\treturn 0;\n }\n #endif /* CONFIG_PM_SLEEP */\n \n@@ -861,6 +870,9 @@ static int acpi_lpss_runtime_suspend(struct device *dev)\n \tif (ret)\n \t\treturn ret;\n \n+\tif (!pm_runtime_enabled(dev))\n+\t\treturn lpss_suspend_late(dev);\n+\n \tif (pdata->dev_desc->flags & LPSS_SAVE_CTX)\n \t\tacpi_lpss_save_ctx(dev, pdata);\n \n@@ -882,21 +894,29 @@ static int acpi_lpss_runtime_resume(struct device *dev)\n \tstruct lpss_private_data *pdata = acpi_driver_data(ACPI_COMPANION(dev));\n \tint ret;\n \n-\t/*\n-\t * This call is kept first to be in symmetry with\n-\t * acpi_lpss_runtime_suspend() one.\n-\t */\n-\tif (lpss_quirks & LPSS_QUIRK_ALWAYS_POWER_ON && iosf_mbi_available())\n-\t\tlpss_iosf_exit_d3_state();\n+\tif (pm_runtime_enabled(dev)) {\n+\t\t/*\n+\t\t * This call is kept first to be in symmetry with\n+\t\t * acpi_lpss_runtime_suspend() one.\n+\t\t */\n+\t\tif (lpss_quirks & LPSS_QUIRK_ALWAYS_POWER_ON &&\n+\t\t iosf_mbi_available())\n+\t\t\tlpss_iosf_exit_d3_state();\n \n-\tret = acpi_dev_runtime_resume(dev);\n-\tif (ret)\n-\t\treturn ret;\n+\t\tret = acpi_dev_runtime_resume(dev);\n+\t\tif (ret)\n+\t\t\treturn ret;\n \n-\tacpi_lpss_d3_to_d0_delay(pdata);\n+\t\tacpi_lpss_d3_to_d0_delay(pdata);\n \n-\tif (pdata->dev_desc->flags & LPSS_SAVE_CTX)\n-\t\tacpi_lpss_restore_ctx(dev, pdata);\n+\t\tif (pdata->dev_desc->flags & LPSS_SAVE_CTX)\n+\t\t\tacpi_lpss_restore_ctx(dev, pdata);\n+\n+\t} else {\n+\t\tret = lpss_resume_early(dev);\n+\t\tif (ret)\n+\t\t\treturn ret;\n+\t}\n \n \treturn pm_generic_runtime_resume(dev);\n }\ndiff --git a/drivers/acpi/device_pm.c b/drivers/acpi/device_pm.c\nindex 5181057..f5c4d0e 100644\n--- a/drivers/acpi/device_pm.c\n+++ b/drivers/acpi/device_pm.c\n@@ -913,7 +913,14 @@ EXPORT_SYMBOL_GPL(acpi_dev_runtime_resume);\n int acpi_subsys_runtime_suspend(struct device *dev)\n {\n \tint ret = pm_generic_runtime_suspend(dev);\n-\treturn ret ? ret : acpi_dev_runtime_suspend(dev);\n+\n+\tif (ret)\n+\t\treturn ret;\n+\n+\tif (!pm_runtime_enabled(dev))\n+\t\treturn acpi_dev_suspend_late(dev);\n+\n+\treturn acpi_dev_runtime_suspend(dev);\n }\n EXPORT_SYMBOL_GPL(acpi_subsys_runtime_suspend);\n \n@@ -926,7 +933,13 @@ EXPORT_SYMBOL_GPL(acpi_subsys_runtime_suspend);\n */\n int acpi_subsys_runtime_resume(struct device *dev)\n {\n-\tint ret = acpi_dev_runtime_resume(dev);\n+\tint ret = 0;\n+\n+\tif (!pm_runtime_enabled(dev))\n+\t\tret = acpi_dev_resume_early(dev);\n+\telse\n+\t\tret = acpi_dev_runtime_resume(dev);\n+\n \treturn ret ? ret : pm_generic_runtime_resume(dev);\n }\n EXPORT_SYMBOL_GPL(acpi_subsys_runtime_resume);\n@@ -1023,7 +1036,7 @@ int acpi_subsys_prepare(struct device *dev)\n \tif (ret < 0)\n \t\treturn ret;\n \n-\tif (!adev || !pm_runtime_suspended(dev))\n+\tif (!adev || dev_pm_is_rpm_sleep(dev) || !pm_runtime_suspended(dev))\n \t\treturn 0;\n \n \treturn !acpi_dev_needs_resume(dev, adev);\n@@ -1042,7 +1055,8 @@ void acpi_subsys_complete(struct device *dev)\n \t * the sleep state it is going out of and it has never been resumed till\n \t * now, resume it in case the firmware powered it up.\n \t */\n-\tif (dev->power.direct_complete && pm_resume_via_firmware())\n+\tif ((dev->power.direct_complete || dev_pm_is_rpm_sleep(dev)) &&\n+\t pm_resume_via_firmware())\n \t\tpm_request_resume(dev);\n }\n EXPORT_SYMBOL_GPL(acpi_subsys_complete);\n@@ -1052,11 +1066,20 @@ EXPORT_SYMBOL_GPL(acpi_subsys_complete);\n * @dev: Device to handle.\n *\n * Follow PCI and resume devices suspended at run time before running their\n- * system suspend callbacks.\n+ * system suspend callbacks. However, try to avoid it in case the runtime PM\n+ * centric path is used for the device and then trust the driver to do the\n+ * right thing.\n */\n int acpi_subsys_suspend(struct device *dev)\n {\n-\tpm_runtime_resume(dev);\n+\tstruct acpi_device *adev = ACPI_COMPANION(dev);\n+\n+\tif (!adev)\n+\t\treturn 0;\n+\n+\tif (!dev_pm_is_rpm_sleep(dev) || acpi_dev_needs_resume(dev, adev))\n+\t\tpm_runtime_resume(dev);\n+\n \treturn pm_generic_suspend(dev);\n }\n EXPORT_SYMBOL_GPL(acpi_subsys_suspend);\n@@ -1071,7 +1094,11 @@ EXPORT_SYMBOL_GPL(acpi_subsys_suspend);\n int acpi_subsys_suspend_late(struct device *dev)\n {\n \tint ret = pm_generic_suspend_late(dev);\n-\treturn ret ? ret : acpi_dev_suspend_late(dev);\n+\n+\tif (ret || dev_pm_is_rpm_sleep(dev))\n+\t\treturn ret;\n+\n+\treturn acpi_dev_suspend_late(dev);\n }\n EXPORT_SYMBOL_GPL(acpi_subsys_suspend_late);\n \n@@ -1085,7 +1112,11 @@ EXPORT_SYMBOL_GPL(acpi_subsys_suspend_late);\n */\n int acpi_subsys_resume_early(struct device *dev)\n {\n-\tint ret = acpi_dev_resume_early(dev);\n+\tint ret = 0;\n+\n+\tif (!dev_pm_is_rpm_sleep(dev))\n+\t\tret = acpi_dev_resume_early(dev);\n+\n \treturn ret ? ret : pm_generic_resume_early(dev);\n }\n EXPORT_SYMBOL_GPL(acpi_subsys_resume_early);\n@@ -1096,13 +1127,21 @@ EXPORT_SYMBOL_GPL(acpi_subsys_resume_early);\n */\n int acpi_subsys_freeze(struct device *dev)\n {\n+\tstruct acpi_device *adev = ACPI_COMPANION(dev);\n+\n+\tif (!adev)\n+\t\treturn 0;\n+\n \t/*\n \t * This used to be done in acpi_subsys_prepare() for all devices and\n \t * some drivers may depend on it, so do it here. Ideally, however,\n \t * runtime-suspended devices should not be touched during freeze/thaw\n-\t * transitions.\n+\t * transitions. In case the runtime PM centric path is used, let's try\n+\t * to avoid it.\n \t */\n-\tpm_runtime_resume(dev);\n+\tif (!dev_pm_is_rpm_sleep(dev) || acpi_dev_needs_resume(dev, adev))\n+\t\tpm_runtime_resume(dev);\n+\n \treturn pm_generic_freeze(dev);\n }\n EXPORT_SYMBOL_GPL(acpi_subsys_freeze);\n", "prefixes": [ "v3", "6/8" ] }