From patchwork Wed Mar 6 13:35:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aisheng Dong X-Patchwork-Id: 10841131 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 377AC1669 for ; Wed, 6 Mar 2019 13:35:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 236F72D95F for ; Wed, 6 Mar 2019 13:35:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1787F2D9DD; Wed, 6 Mar 2019 13:35:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9311A2D95F for ; Wed, 6 Mar 2019 13:35:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726908AbfCFNfY (ORCPT ); Wed, 6 Mar 2019 08:35:24 -0500 Received: from mail-eopbgr40070.outbound.protection.outlook.com ([40.107.4.70]:40514 "EHLO EUR03-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726962AbfCFNfX (ORCPT ); Wed, 6 Mar 2019 08:35:23 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=pLe3trH4VW4zsYoRI2e0cOJ3j63s8S7vS3olX/RwCLI=; b=MKQHRGgFwRsZwH6pN+hHj41jMYoSeJ6Wj+FhDa2zdA06jPgJ1RRYBhbwBqTVIUJGVik7EjF1qZqX2jrNkB4qXGdRaexWXvf42ItCh9haG1l6UaxlPFahdPzMTLwgpNYDJeiWF41VTX4D+6qOBkQZsewinGvxKkyFMWS+uyjAQ4M= Received: from AM0PR04MB4211.eurprd04.prod.outlook.com (52.134.92.158) by AM0PR04MB4770.eurprd04.prod.outlook.com (20.177.41.154) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1665.17; Wed, 6 Mar 2019 13:35:20 +0000 Received: from AM0PR04MB4211.eurprd04.prod.outlook.com ([fe80::50ed:d1b5:c043:3b79]) by AM0PR04MB4211.eurprd04.prod.outlook.com ([fe80::50ed:d1b5:c043:3b79%2]) with mapi id 15.20.1686.016; Wed, 6 Mar 2019 13:35:20 +0000 From: Aisheng Dong To: "linux-pm@vger.kernel.org" CC: "linux-arm-kernel@lists.infradead.org" , "dongas86@gmail.com" , dl-linux-imx , "rjw@rjwysocki.net" , "ulf.hansson@linaro.org" , "khilman@kernel.org" , Aisheng Dong Subject: [PATCH 1/2] PM / Domains: Support enter deepest state for multiple states domains Thread-Topic: [PATCH 1/2] PM / Domains: Support enter deepest state for multiple states domains Thread-Index: AQHU1CFx3mZA+LLWq0ehzswGR+73hA== Date: Wed, 6 Mar 2019 13:35:20 +0000 Message-ID: <1551878926-8455-2-git-send-email-aisheng.dong@nxp.com> References: <1551878926-8455-1-git-send-email-aisheng.dong@nxp.com> In-Reply-To: <1551878926-8455-1-git-send-email-aisheng.dong@nxp.com> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.7.4 x-clientproxiedby: HK2PR04CA0052.apcprd04.prod.outlook.com (2603:1096:202:14::20) To AM0PR04MB4211.eurprd04.prod.outlook.com (2603:10a6:208:5b::30) authentication-results: spf=none (sender IP is ) smtp.mailfrom=aisheng.dong@nxp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [119.31.174.66] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: b568d619-ab6b-44b0-0b21-08d6a238939e x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600127)(711020)(4605104)(4618075)(2017052603328)(7153060)(7193020);SRVR:AM0PR04MB4770; x-ms-traffictypediagnostic: AM0PR04MB4770: x-microsoft-exchange-diagnostics: =?iso-8859-1?q?1=3BAM0PR04MB4770=3B23=3Ax/?= =?iso-8859-1?q?0AgGK4Qwjyv88PTfG5epG3hukiuYDmXSuZyV40q0Dfu44u+moQkjq5aXrmqm?= =?iso-8859-1?q?6oHxCOS4jKriDlEiAyOmZFZLHq9Aar3Ig2DJyim/4C761VLmUOv/QnjOD0GJ?= =?iso-8859-1?q?KqeYxrtZ4jfx3iOMK/tTnUxKqqOd/3vzL3mK6H6yuGrw0nRhgA/R3dIsTFw7?= =?iso-8859-1?q?vDpLLmb0voD8dvAI++va+/kWKoow6WwG3CkLWcWFIo6vZficgMUEwEandrp7?= =?iso-8859-1?q?tcCHfR6SoCOX6Ku7rtsvn/JYh9f8nt17NatWZT9SB7ni2rklT69IiATFPKTP?= =?iso-8859-1?q?DwXCbZk4zIf0GwieUuncU54ynKujA5p+aA2Dt7SXJBVyLL4kvNPmLB3KMrUV?= =?iso-8859-1?q?MYpa/XRuHuIgLug/CyVdjVJHDtT1RPu4yAczghQambpSqvml+TPNTdokau/1?= =?iso-8859-1?q?mIx1cULT7MjRv/Vf6sqZXla9D2Yb1R8dQ07qGcVJYSAqdOExqzWX37ANlqI7?= =?iso-8859-1?q?UXe3xbAedv6dYnqkG4/5nwLwzU33SED3/pU1EXTbpBM/05agiVclQl5bX73l?= =?iso-8859-1?q?AzSF9JO+9YuehxcQXegFMeD32ymHd/Bc8KNTWHRx0Vslme0ZwYMCUeMtHREJ?= =?iso-8859-1?q?b/D2M3z5tg5UZ1smnAQLCwLS1l1beN8uQgFh3NPICqzmp6UeNC5Rv+eCE0ur?= =?iso-8859-1?q?dmIgWELpjrXw2CdQ74thM4BTjntfr5L0DFENVecTMrPcIDbKdOfaxYhkzQFO?= =?iso-8859-1?q?9JsLbL0dAdg97un8O/YEEUas2pdLQLHeY2X3R5uxCzBePz4Euws+SXz/vPqR?= =?iso-8859-1?q?OM89jm4yyjup8lvKyyE42ikGJu7Je8GRk1RMl7dvpufmNC/tJSaRQ8Xj+rJb?= =?iso-8859-1?q?sk/4Wv9ND30tkPaRk3btWu35IxT9K09tB/69RiDsLmRzVBxhkLFoly/mbBz8?= =?iso-8859-1?q?Sb0a041kQ0OqIToT/uA7HGJbMi5kf2zudKjERDHAliyn+qs8/ibt4DoM/rWp?= =?iso-8859-1?q?3/cXAmKSahmvg4kgYyYw+EvRsjlyhr3OgfIwRifhP8/q98nMK5DNYASfDv/C?= =?iso-8859-1?q?PMagrwBQbuEF20MarwWwIYPUX1ipHU5SkdOPVW936H13Ssem7l2yQNG1//2c?= =?iso-8859-1?q?w7iIyGuEZNaLhJHkGBSgTrLTZi8otQmqQuI0tXbn/QtV01yoYVmyADGDggfq?= =?iso-8859-1?q?sZkK4ajo/gq+9zTVdNOKbOmj6nQVDJ9cHaDl+QsfXn4fSg8SPBFuEksDZ8BI?= =?iso-8859-1?q?u9yvBfg8iIZgUafEfXOvkt9beoq2qcoSIxDECdTJS3l1b4aFpPVAHGrWpWi+?= =?iso-8859-1?q?hzfc/2Zd/4MMTkXK7fUJ0pjbVKJMnMYsN96/F4JQ=3D=3D?= x-microsoft-antispam-prvs: x-forefront-prvs: 0968D37274 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(376002)(396003)(366004)(39860400002)(136003)(346002)(199004)(189003)(68736007)(186003)(102836004)(26005)(11346002)(105586002)(8676002)(486006)(81166006)(81156014)(106356001)(446003)(53936002)(86362001)(36756003)(97736004)(7736002)(2616005)(2351001)(6506007)(386003)(305945005)(476003)(6916009)(316002)(4326008)(6512007)(44832011)(256004)(5640700003)(71190400001)(8936002)(71200400001)(25786009)(2906002)(14454004)(52116002)(6436002)(6116002)(5660300002)(50226002)(478600001)(76176011)(99286004)(6486002)(2501003)(54906003)(66066001)(3846002)(14444005);DIR:OUT;SFP:1101;SCL:1;SRVR:AM0PR04MB4770;H:AM0PR04MB4211.eurprd04.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: Rh93CNApztYrMJ/hhqEmD2GRU2NVollDoczjmdKxUaPnVDmYE1uKYkypY/Z2LbFJUJsn+DLZKy8pjVfRfyBBxhZP2079LK4gLkNPGUzXXP6qAjAiehAVP0e4g3ddR5NKV17PKeCJiYWj/aB9sx97R4vrmu8LDesI6re6MfmUHZANCX7vtFFcO+YTDoX7p+mtwTAdcGtS/Ocy8OIWgE95CaxgnkrpuiF9Tqb6l7KhiPm/wVo6AFaBjUnWj8VWgtsycvNjaUy/UozzG9Mv/SMn1X8Ke+Plm023VJOkAi5cqDHpEch3IUY093lTZslGmKXCDfcDHdTuiMeJ+EFaSmJayGpXKyIaPOcq542+vYwmYloa81crgXOFIhAp0M0UtjJbDcBQOKoBCi4DrXtcAaRknuhlywK0AZBB3Mw0MtOY9Vk= MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: b568d619-ab6b-44b0-0b21-08d6a238939e X-MS-Exchange-CrossTenant-originalarrivaltime: 06 Mar 2019 13:35:20.0171 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB4770 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Currently the generic power domain will power off the domain if all devices in it have been stopped during system suspend. It is done by checking if the domain is active in genpd_sync_power_off, then disable it. However, for power domains supporting multiple low power states, it may have already entered an intermediate low power state by runtime PM before system suspend and the status is already GPD_STATE_POWER_OFF which results in then the power domain stay at an intermediate low power state during system suspend. Then genpd_sync_power_off will keep it at the low power state instead of completely gate off it. Let's give the power domain a chance to switch to the deepest state in case it's already off but in an intermediate low power state. Signed-off-by: Dong Aisheng --- drivers/base/power/domain.c | 18 +++++++++++++++++- include/linux/pm_domain.h | 1 + 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 61cd500..847a69e 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -959,7 +959,17 @@ static void genpd_sync_power_off(struct generic_pm_domain *genpd, bool use_lock, { struct gpd_link *link; - if (!genpd_status_on(genpd) || genpd_is_always_on(genpd)) + /* + * Give the power domain a chance to switch to the deepest state in + * case it's already off but in an intermediate low power state. + */ + genpd->state_idx_saved = genpd->state_idx; + + if (genpd_is_always_on(genpd)) + return; + + if (!genpd_status_on(genpd) && + genpd->state_idx == (genpd->state_count - 1)) return; if (genpd->suspended_count != genpd->device_count) @@ -970,6 +980,9 @@ static void genpd_sync_power_off(struct generic_pm_domain *genpd, bool use_lock, if (_genpd_power_off(genpd, false)) return; + if (genpd->status == GPD_STATE_POWER_OFF) + return; + genpd->status = GPD_STATE_POWER_OFF; list_for_each_entry(link, &genpd->slave_links, slave_node) { @@ -1017,6 +1030,9 @@ static void genpd_sync_power_on(struct generic_pm_domain *genpd, bool use_lock, _genpd_power_on(genpd, false); + /* restore save power domain state after resume */ + genpd->state_idx = genpd->state_idx_saved; + genpd->status = GPD_STATE_ACTIVE; } diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h index 1ed5874..95db21f 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h @@ -124,6 +124,7 @@ struct generic_pm_domain { }; }; + unsigned int state_idx_saved; /* saved power state for recovery after system suspend/resume */ }; static inline struct generic_pm_domain *pd_to_genpd(struct dev_pm_domain *pd)