From patchwork Wed Sep 13 02:05:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Peng Fan \(OSS\)" X-Patchwork-Id: 722987 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B0374EE49B7 for ; Wed, 13 Sep 2023 02:01:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229543AbjIMCBS (ORCPT ); Tue, 12 Sep 2023 22:01:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52514 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235255AbjIMCBS (ORCPT ); Tue, 12 Sep 2023 22:01:18 -0400 Received: from EUR02-DB5-obe.outbound.protection.outlook.com (mail-db5eur02on2083.outbound.protection.outlook.com [40.107.249.83]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 11C181706; Tue, 12 Sep 2023 19:01:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=L1SAju/jrQkvjYEDffv0FVKoqUl1T26rPbqzTqtO6ZrAdjdTOzXboaFg8gKhBYligXQrtpzQjhGNv9tQAm1xq0SwbfSm0VC0CyoS5JPmL69EUtndLUzpSeHgTQ9HeavEWQz8tny/9IiN8AlTsVbfA2KJCGTQTEOO6z7w9OaM9+M0fo1eu3RZdPIbatdc9JGsKGpE84mFpIX96nugTTEsAOcGfUywHsMiKTSTp/lPrB069f2MbAhKalDsBvH2mQFupeznRCK8B39zX1fKbvKPRhVqodB2MsbV1IDwgTIKBGSfd8H8M66sgwmWWv1NKWGkRUfVf8uBHXwlgPE3NZFnsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=6CphTRmQFp4aKG1R6ujHLI+fgirNZKeqT8MlKcLFtWE=; b=UIRTA0qEkMc0wYXHSsOtrpBmUmLhMsZUeq7Qnj/n3U+pzFF20xCwwohpvfDKfJOBlH8FLUe3Pl+RjoOQ0SiPLi2CtXIiqOmhZa4EzF13VpAPsumRvzsInBFGlft9LWk7bPmz1VoJPufaekJ1ttDC9b+XGMJGJbgOAdI44u/F1nE+KGmNKD17/uBKHwx6zfxumkMg0K9snyNZjCSl3x9QpO4UUPJ/9/oyuUTpMswiEo2BSDmyWh+NP9akQ9Ohhk3Q63nigxUon6e4fZzzwDebr13D5DmdROGYQxPMVCH8Wl2hTMFQKBozzj4Jr4fva6scXRp0iyoNKYgCzVSyDbS2QA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6CphTRmQFp4aKG1R6ujHLI+fgirNZKeqT8MlKcLFtWE=; b=EBxKJmUrSfmUiXXko7IjW9RnFq3ylLfW+pbb4qyviC7DnATxMUkIHytk0XoQLcfVnNFS3K2dAKa3uYK59C+3NrZWUj4dhBQhqTkdlmqJAlfzE6ImdGgw7vmNmKZrH4mgg5cS43Pl148mIllZbzeQB+88Oes74FevqGyZCuFesIQ= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from DU0PR04MB9417.eurprd04.prod.outlook.com (2603:10a6:10:358::11) by PAXPR04MB8894.eurprd04.prod.outlook.com (2603:10a6:102:20d::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6768.37; Wed, 13 Sep 2023 02:01:11 +0000 Received: from DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::2b3:d8de:95c8:b28b]) by DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::2b3:d8de:95c8:b28b%3]) with mapi id 15.20.6768.029; Wed, 13 Sep 2023 02:01:10 +0000 From: "Peng Fan (OSS)" Date: Wed, 13 Sep 2023 10:05:36 +0800 Subject: [PATCH 1/3] PM / Domains: Support enter deepest state for multiple states domains Message-Id: <20230913-multiple-state-scu-v1-1-9d91c6904ffa@nxp.com> References: <20230913-multiple-state-scu-v1-0-9d91c6904ffa@nxp.com> In-Reply-To: <20230913-multiple-state-scu-v1-0-9d91c6904ffa@nxp.com> To: "Rafael J. Wysocki" , Kevin Hilman , Ulf Hansson , Len Brown , Pavel Machek , Greg Kroah-Hartman , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Dong Aisheng , Peng Fan X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1694570751; l=2848; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=WzVpFHVCTbI8zhHb0izO8j6+hEmyN9JYHoZIs2nN/00=; b=x5MB0kWQ+YlcRxwsvZKSgszc3sxU43xTKgNHYIqa2Qd+X1abSo1zjvXi84fnR87XcfTLtL7zF 5pIJ+jVPPWrBmMDHDznqPVnlbo5lUIu9oJbeHQ5T6ATqEr8wsFpkmn7 X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SI2PR02CA0015.apcprd02.prod.outlook.com (2603:1096:4:194::16) To DU0PR04MB9417.eurprd04.prod.outlook.com (2603:10a6:10:358::11) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU0PR04MB9417:EE_|PAXPR04MB8894:EE_ X-MS-Office365-Filtering-Correlation-Id: 8e91393e-1fa2-4cb1-4932-08dbb3fd4c23 X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9pCkJXy1V3cjkeC/UI9vwlWFveOiHWxHNz9qegFHluc4rXomXp9iLDVkRKZ40CJVBvagZ0OdeFJawLbOpaTP4caicOo2MnfpSA9o1MyO4XXXNx12fTaDFP0wuPdR/BCIHW2qvABkDjNGvU3RJUUAjm/brnYNLG3ZGgxFStbgysHewmwwO23KBHuEDf9tCJnZkAj6UcUUGu6sPBe5yT4yZIkF7hgsIeraXCbtg8LSg20nD2A55Sp4cvPWWOcYW/qPlexn7Z0cohdZGzBb495C9Y925lffEdBudjdKLqLTfUJLWI5fkd0doIyhSY3cdOJ14wbaAqKTBuV7VqGMRiLaZ1n0+oe1k/UULycJoJ/8vMzmrRid9NZ37QMVfn5kWNy3KhqbkZm2zHeBJWei/y/sxTxZodU8hEL/RgQtnh4UQxdhEoqd1O2wqLspFyhAz23YnB0wa74e058f1gyE6xKmqE3emorBnchepWOEEyIZ+U60kZGQh77qVQ9qPcBet1KMxu1yhdd4XokU+tgUNS/YCq3wbNxyPnfRDbWuZP8p5WAFOwfLU+3t79AAfB3PkGgHja+qIszLDJMdy2TGJHT+LofSX2FhsIC1Q1xiJAspTYLOEIyvIh4P3tgpw18doug7ur0/ThfgGsRafGHnD+2Yow== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DU0PR04MB9417.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(376002)(39860400002)(396003)(366004)(346002)(136003)(186009)(451199024)(1800799009)(9686003)(6512007)(7416002)(5660300002)(6666004)(52116002)(6486002)(6506007)(26005)(478600001)(2906002)(83380400001)(8936002)(8676002)(4326008)(66946007)(921005)(41300700001)(316002)(54906003)(110136005)(38100700002)(36756003)(38350700002)(86362001)(66556008)(66476007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?EdN4iNwSpWbz/u/b15RNGXUJRxVh?= =?utf-8?q?1PTN+SECpiPNlRtTvFwZBe7o5Hgb3HJGf4j69w1oKKY1DfRUnEHoXG9KXKCSiGG/z?= =?utf-8?q?wBQpE9jC2EUVyHGEeb9/q1QYWdKIiWBtRnxvLshfojw8S0bYuQvAoLsPE7hwYWsEn?= =?utf-8?q?qjsBnhl6nVThcjJmC/3q4DRs7k7TYdvx8DGYsKr3YN/UmMBDVV95S63w5ILkwJavN?= =?utf-8?q?G/18zO+ALppbpvaUnFNRK9zDThG5b3hALZGaw7AitDZWw95z36XkAh8bBwTInCdTq?= =?utf-8?q?x6Rytpz+Ch2b83x/WqszL5bQUUb29xWmwOyAQtsbfXJrs+5c+pxg3IlI6kVk71n3T?= =?utf-8?q?KYfD/OrVR4LXoqxLBdoZzTgSAmI5nmaATonIJp6GEOK18zmvbTlcGzK7jxMHsCELZ?= =?utf-8?q?fJnL1UtTlHagYhrhWGShqSv4YoJaHlblMff7Jgs2nGFpF/VOcpe329gxP5xC3Qm+/?= =?utf-8?q?Bh3jW+BC2+OizvjiCsevlXbS1uZbLFOxgYBWeFqH6klE/deDW7NOwcipVP2t6PKs4?= =?utf-8?q?W++E9qiz48fJwLHYL3lOmKzVtzZ9RjlLt4JcRMa12a/CkvVm2+gslBUvKmrSe5URH?= =?utf-8?q?mLMzZEdcbyLBJLSVpEdleW47JkO/mkv3tq0PRtruHBdHADy8yR2ksq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?utf-8?q?lmFbMRHVRXWw?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8e91393e-1fa2-4cb1-4932-08dbb3fd4c23 X-MS-Exchange-CrossTenant-AuthSource: DU0PR04MB9417.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Sep 2023 02:01:10.9312 (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-CrossTenant-UserPrincipalName: ggCCo251r+V5bjg8O79a9aQAABb7kEbfnaDWFNm1hmPWAYpxGfpKqJWJ8w/c1d3yISU7hU6MGq6dEh7AblB/zg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8894 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org From: Dong Aisheng 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 Signed-off-by: Peng Fan --- 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 5cb2023581d4..22cfa3020b18 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -1124,7 +1124,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 @@ -1143,6 +1153,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 == GENPD_STATE_OFF) + return; + genpd->status = GENPD_STATE_OFF; list_for_each_entry(link, &genpd->child_links, child_node) { @@ -1189,6 +1202,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 = GENPD_STATE_ON; } diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h index f776fb93eaa0..bbd08115a1fc 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h @@ -167,6 +167,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) From patchwork Wed Sep 13 02:05:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Peng Fan \(OSS\)" X-Patchwork-Id: 722440 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4AE35EE49B7 for ; Wed, 13 Sep 2023 02:01:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238124AbjIMCBZ (ORCPT ); Tue, 12 Sep 2023 22:01:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33572 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238110AbjIMCBX (ORCPT ); Tue, 12 Sep 2023 22:01:23 -0400 Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02on2044.outbound.protection.outlook.com [40.107.241.44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F21D6170A; Tue, 12 Sep 2023 19:01:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fgtoY2xHd0kVfaqaasVZycwYeMWc3iZrtSFfQvNcT9mhx+hhi2/qjvMVGM5zAvx3l6gxlYBTI5lq1wFrNBgrGqTps57uJCPMF9k1z7RKRlS+hiOJruNTLFFRtcthfOiYfc7TqteVFx6TQn0pQmpoYcKN0XtFnHY3zzzIkmuHtLLZCv018Vh3TjMLuvrQM4uZxVRSyGEgVnVWct5D0GmygO3DJ9Ga8hJmw8uPN09KeRAZZKri1swotxWIavUaJvEenibQFy0neYE5MxqJ/9aQRiQaV+tJZHfladkKE+qXzkGwDAHzOFlmA6oYezeL/Zt+8x3VXlB0Y7UAEsePequZNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=MK8g8WBtLs1659Dih8bzw/P9yNUtWe4jegDKFUTaTeM=; b=Y0EC53vXuvqD2DNqRblfx06EJW2Oz9HrLATvQetjVAhypRMXRRQPBhZhh9I7vTvvrh5hz6BOOnjWvw919ybNP1f+rU7qsqukxB4SS+beNR81uKRnaKGZ8hAkGXkBY9rXOcmZMKsrgQCoiuLkrUbBCzJe8mSiihqDi0NzuA7ZEIENYiL6DSVMKiNaHabvXNFIIMmXCpi+dyt1a1fqvHAj/MfabLV9UU4PZmvLXTtv7qE27oUuFeQ5uOktRNVRnWCBTayErHELiEdSiohdpa8t1A11flsWYudZc0Ay9kKM1uaoGcj7MyzU7wSYfdZomae1fP7w4sYt6ZFE+OtBEl5p/g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=MK8g8WBtLs1659Dih8bzw/P9yNUtWe4jegDKFUTaTeM=; b=M5QCDLqulxk0juDn/L4+UK0jvWY9PwRU0uQIpIbRcUD4G22FjZ0m5UKscbi05vaJfWdnT298b1ChrYw4+sRwxgdm20wjxA6/qpCOdU4gW8EfUtwA91x/NS00ltevzO3uo9J5O/2I/JpZfjLEFFfGAQ4ssL/LrjLJoDq7tNOw0uY= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from DU0PR04MB9417.eurprd04.prod.outlook.com (2603:10a6:10:358::11) by PAXPR04MB8894.eurprd04.prod.outlook.com (2603:10a6:102:20d::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6768.37; Wed, 13 Sep 2023 02:01:16 +0000 Received: from DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::2b3:d8de:95c8:b28b]) by DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::2b3:d8de:95c8:b28b%3]) with mapi id 15.20.6768.029; Wed, 13 Sep 2023 02:01:16 +0000 From: "Peng Fan (OSS)" Date: Wed, 13 Sep 2023 10:05:37 +0800 Subject: [PATCH 2/3] PM / Domains: Choose the deepest state to enter if no devices using it Message-Id: <20230913-multiple-state-scu-v1-2-9d91c6904ffa@nxp.com> References: <20230913-multiple-state-scu-v1-0-9d91c6904ffa@nxp.com> In-Reply-To: <20230913-multiple-state-scu-v1-0-9d91c6904ffa@nxp.com> To: "Rafael J. Wysocki" , Kevin Hilman , Ulf Hansson , Len Brown , Pavel Machek , Greg Kroah-Hartman , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Dong Aisheng , Peng Fan X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1694570751; l=915; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=qvVSxMEbUt5msArNvyrVU8YXTGWc1AE9b3pKa/4hFSo=; b=LXguZlHBKDCysSJp4EOPAEoEi7JoxskXTmrfTGVYexYNHJWlpAv+3A8JHrLy62M2z8YmgXBrx K77ryN+kOXZDJy+ERwxsFdc9MQ4cC388Hxj3ykAy4uVzEQnRwThR9By X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SI2PR02CA0015.apcprd02.prod.outlook.com (2603:1096:4:194::16) To DU0PR04MB9417.eurprd04.prod.outlook.com (2603:10a6:10:358::11) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU0PR04MB9417:EE_|PAXPR04MB8894:EE_ X-MS-Office365-Filtering-Correlation-Id: 44053930-43de-4423-e7f4-08dbb3fd5040 X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: fypPQTHgRqmI+xumNRPuRMZr1vSdDW7s2og5k14AQdXT6fCJ/8yniWHzmHTUEGcspDs/XunedE+tHeF5F/dA4dFF5IvctVGp31S5sMD/z2ruiAJgQlooAZsQ4cN/DKdTvGyTSFhtSY7FUnH8CGTgRe4f/b92uhXrBUKfBnX5aTiRXHtm1BNp/5XaG1V1KcHuGg51bbVHNmuBrzUwplw9yy+TsFBCZb4x38rrGwaUZhu5MRcUxD+AUHBH/Zdy0+DrUhcdlDeynFdtSOPO1hs3Wgx7MC6hHFFnfonFVqvUy2weCoAevTSo7H9yEMG/i1zRJVP/t82I1rDsDnDI/sVt0BmMW7j/qgRvIqM+rJIpmX1DQhA9ERGQEj2/u16ZolqMffns5Tl5T4XgS1X9vFHLIyW3f79625TY4R7dIa7SxfpktGsZGe3Q7nxO8PI1UM9LvUh7H5Z/x7xxzK5sKUYtnX5fpdQDPnNL1NgLqLj87Mx+W+XRo6xifjTGo65WokSbdWEDLZvAom4MM5XOrtN8zxSbvdzjTgfFsNLMZG8h/olev8BdhSVbtEH4vhkd5UAs55pqjBt8iShov3TlcBB6QoPPpCoEDsAOkxdOjTq+3jYufw4R+J8HOQM+m4CUT5JwzOJPzynjfGUqRzxU0EirbQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DU0PR04MB9417.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(376002)(39860400002)(396003)(366004)(346002)(136003)(186009)(451199024)(1800799009)(9686003)(6512007)(7416002)(5660300002)(6666004)(52116002)(6486002)(6506007)(26005)(4744005)(478600001)(2906002)(83380400001)(8936002)(8676002)(4326008)(66946007)(921005)(41300700001)(316002)(54906003)(110136005)(38100700002)(36756003)(38350700002)(86362001)(66556008)(66476007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?9Ao4iu+Fur6EYrzKaqVDq59gyHVI?= =?utf-8?q?1eH5bQDmdcKnknWdbhUQZx5uxPRaOghUvX4VXRBzeZrQ2S3w+vdRjuRCpQowfYv34?= =?utf-8?q?eM/qzJoal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JGe6ytP/KnmdPaID9evyUxERxzbPN8sgWA?= =?utf-8?q?qs4bwCYtHI4PGeVj0dn0PCk0Cc9qoqGU6CP6Jffs7/hNNAdDnRsCNnnWrMhYKELBa?= =?utf-8?q?NcXr9JqrtVwXeEUoIKNG2WE39xyq+LZU5xVVD/UpwEYfJj86rWCm7jp1d2qyDJ2lf?= =?utf-8?q?/ZKOlXjwBYquBoPTPdeoVMVXxUiyLMzY2bv52RPTpLz+xhiCYBPBOqQGmGVSylhhs?= =?utf-8?q?UFrKVNRs0fQOmxdU6cdgRPax0AZSU8ausussGK7lk27oiyOkB27TpUbIUkiPjS2mp?= =?utf-8?q?J4Qb1LqcnsY5TVUWQZ++aXctoba2s2ssQDpvQDn38PpuIJ+paMQtnTYgM7FW80ePa?= =?utf-8?q?KYkd38oRzhh8e7EXNAxE4LVrv5JxWfHpVsSAJZmOKDSNXLGXLbLv1DKJvRU514v7P?= =?utf-8?q?QUTlPH3Pj44lDzYCEc5oaDrjKRq0tQ8GxCi1DroSWe/Jc97y7c1ynGGmXjv3LqiWD?= =?utf-8?q?2CvQGZn+6eYZlATkZZ5ZFVjXIHCtnAR7qZCpiSEeNm67ZupO3UD3n6fSWlQxN5XHP?= =?utf-8?q?kpqdzqyb9q+y?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 44053930-43de-4423-e7f4-08dbb3fd5040 X-MS-Exchange-CrossTenant-AuthSource: DU0PR04MB9417.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Sep 2023 02:01:16.0113 (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-CrossTenant-UserPrincipalName: F+nMZG0HvD0HK8rhI2qiLc+EpVFRrnjErs51ZueK78I+yr3W85gmXFMhgxL2WIgV1o7gD2xrqFh1Omb7975mqg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8894 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org From: Dong Aisheng For a domain has no working devices anymore, let's choose the deepest state to enter to save power. e.g. driver probe failure. Signed-off-by: Dong Aisheng Signed-off-by: Peng Fan --- drivers/base/power/domain.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 22cfa3020b18..1887eb1b3130 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -730,6 +730,10 @@ static int genpd_power_off(struct generic_pm_domain *genpd, bool one_dev_on, if (atomic_read(&genpd->sd_count) > 0) return -EBUSY; + /* Choose the deepest state if no devices using this domain */ + if (!genpd->device_count) + genpd->state_idx = genpd->state_count - 1; + ret = _genpd_power_off(genpd, true); if (ret) { genpd->states[genpd->state_idx].rejected++; From patchwork Wed Sep 13 02:05:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Peng Fan \(OSS\)" X-Patchwork-Id: 722986 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 62B99EE3F3F for ; Wed, 13 Sep 2023 02:01:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238133AbjIMCBb (ORCPT ); Tue, 12 Sep 2023 22:01:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33710 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238148AbjIMCB1 (ORCPT ); Tue, 12 Sep 2023 22:01:27 -0400 Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02on2051.outbound.protection.outlook.com [40.107.241.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 91B501716; Tue, 12 Sep 2023 19:01:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Jaxt6kWvM62V9rlnTdXC8IVnC8FwKreSniZPvzB+ikQXOf/8HUiWdiaOrxSFkwEFWZVI2t2b6nLPBk1rKIg7Akf1o2lRwC2bhQlpKJM9EZv971B4ncMesJIGRyg7u9m2WUjXoRgn65N7rnaeIm6MdlgLoP8ix5ZkClc3UaNNv5Xd3N32E5kVmbeWL5sFURD0fDFQmI0a29Yof4t1y+fwsKlTDRB6tjR0rTBOWjmspiugRISKyTq9t4QqBmXUQyoDVoAs8W8I5x8Fj3+SpKsLv3M5xuesTcL1xvozHM34v2S5vTLcN3i7aUas+VD6Ft40gFOKAao5EcHvJk7u0UVGJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=cYVpx50VecpP5SLn9VJhxZ4KG+DJoe59lzjo9EVj/lc=; b=OvNyGsJP7/XDRgYId5ef1iTT8wnRK5neLetGc77zUhNbkkS7sSF7Tu4SO2mg7zGanNmS2IN2h39/oNUZ8oMPDATXgqRBq4SWmdscT/XBCAmK48hEN60psM/GipXriNn3+QZMlDP+m+uRvTGclBshyTD0ksx1hzd41VJ8Hxs7Gm8yQrpsS2YZk/GELumjzDqA43E1Tf8VSgB8Z7AGXHDaVIg1f8PZIP/gVuLfgXAEIRV0lnu6KO0ds5pDA1SYc18e+Pxbvz560RhQogvveoT1Lq+aeWgG0jodjp9uAQ9ptVNxiyawEPr59Nh4gw/vDjmqkYT14Eyqmf1bCcojMlA/TA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=cYVpx50VecpP5SLn9VJhxZ4KG+DJoe59lzjo9EVj/lc=; b=kmrk2KfhPxRynCBEshPOkLr6TqGj8/RM/KFctsvLL68IqJ+h4d7gSv6eGibkElaXRemSFchjEYvc13EB+/xfKgzmRwA3lyDKqHIToWGB84C/upECOlJd/UGC/MvkX82GW3QR8qWFEgA9wZinQaD2ohxERZuE9+hIp453VTRIYFs= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from DU0PR04MB9417.eurprd04.prod.outlook.com (2603:10a6:10:358::11) by PAXPR04MB8894.eurprd04.prod.outlook.com (2603:10a6:102:20d::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6768.37; Wed, 13 Sep 2023 02:01:20 +0000 Received: from DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::2b3:d8de:95c8:b28b]) by DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::2b3:d8de:95c8:b28b%3]) with mapi id 15.20.6768.029; Wed, 13 Sep 2023 02:01:20 +0000 From: "Peng Fan (OSS)" Date: Wed, 13 Sep 2023 10:05:38 +0800 Subject: [PATCH 3/3] genpd: imx: scu-pd: add multi states support Message-Id: <20230913-multiple-state-scu-v1-3-9d91c6904ffa@nxp.com> References: <20230913-multiple-state-scu-v1-0-9d91c6904ffa@nxp.com> In-Reply-To: <20230913-multiple-state-scu-v1-0-9d91c6904ffa@nxp.com> To: "Rafael J. Wysocki" , Kevin Hilman , Ulf Hansson , Len Brown , Pavel Machek , Greg Kroah-Hartman , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Peng Fan X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1694570751; l=3099; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=zvjF/DrHc41OMqevgsg7lem3OK3BtRsEIn6QfoUxmA0=; b=vL7wz5JIyUGGhrP3HvnvIEPQnRcPawmgAqXdOlIp9c8GpeW24UO/iKd8+18TRylHyVmWBwEUh Lthtl8J9dpqCGiDdRiftaP7BfkXpt0ykGS0uBnNkBQoDCon9EbQYLdr X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SI2PR02CA0015.apcprd02.prod.outlook.com (2603:1096:4:194::16) To DU0PR04MB9417.eurprd04.prod.outlook.com (2603:10a6:10:358::11) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU0PR04MB9417:EE_|PAXPR04MB8894:EE_ X-MS-Office365-Filtering-Correlation-Id: ebe400e1-5d96-4783-1d46-08dbb3fd5300 X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qqktsG/2tdh3zUX5sHRUenkYrxJO0hRhNP1U86AbgYaqV+wm1FBmWpmSaVw+CK21b5sV842Z20CxqUmNANBP0HvAMfbey45CZKoIzjqzK53CObEs6O9f/ZQ6oEegqTvWQNfV1n7Zq6uP7Ce6tUqVwqjcSlGS0vpL+O7o9I0pWXutY8iEtkuhmHNJ/CLRFeiB5aR7pFC+fq+GSnzv/1xrS8bvT8TIcIwziF/N81l+boRXYDf/+8QNwV297HKWQ2ibTrwnFDQkp5VkRdEs+VLMkGC9UntKcPXE3r5ZW27OZtfB77hKuyLFQR+wSuG1rMRLKqecmIvX4mzglrlPhVNn2BhYFtXT25oKzVR1XxnzRYGQePrV68fXWDrh3FL4ev3pVZ8lhAIBhCI3yR7RpU2JgUMANR6N+SORPihohtJgq+oKAO/1VG0BT+plP51Z/QEsWLIEmlolOCZW0OC4EH3ocJGTZwRj4TK8Mw4nsf/BHkdWhCqd7VrArOP8n9n+45ZLt4UCn7VrDoSEvgB8KOWit1UpDZl1FDlJZdcNeI9lUAgxPWWN/kuISmg1drSwc88WmRhw/ntaoQGNUoVMWw3Mne5FWJCekShOg55INejCs2lpCf7ejfxt/aS8UUMixI9N7ytKEwTL7XhYu+rxDhDIxQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DU0PR04MB9417.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(376002)(39860400002)(396003)(366004)(346002)(136003)(186009)(451199024)(1800799009)(9686003)(6512007)(7416002)(5660300002)(6666004)(52116002)(6486002)(6506007)(26005)(478600001)(2906002)(83380400001)(8936002)(8676002)(4326008)(66946007)(921005)(41300700001)(316002)(110136005)(38100700002)(36756003)(38350700002)(86362001)(66556008)(66476007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?6OJHZAUP54gB9EnOf4mgN4EMfqj5?= =?utf-8?q?m3QIFFNnt82+0AUn6BZ/Z2EwWTl0/LuR5dxBPFRIx3w3mlW9NdDw+GsIP+Ips2i0Y?= =?utf-8?q?9NR3MrDzeEAuoVTD2CB5fO9MJ4tEp1+nR+aV0uPSzJ6dHZBoRwx7MimdlhwmL02zT?= =?utf-8?q?6lyeSdSn6JK6Da9Q7y/D5miwY4xhouf2u2msWfUxX68jn+4PninlnfKHc2bBz+YLs?= =?utf-8?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sB9wp0vaAsmPrtbOgIc6cuzWIDllmyANACx27tsFEy0ay2RwZ3BXwUtNtQpcYt?= =?utf-8?q?bNhYUnW01+WdV9rEaeRp+yp6ehJkxYm46qprv93ZROjpT0z2e6AOrL+fGIHr8ciOJ?= =?utf-8?q?oTFfAmBmJgbH1VasYKuiXftV59GnBCusuSWVBLwDA+aeGM6e48cHe6d6xga7TLX8Q?= =?utf-8?q?jaTRkHCWQeANSNmwcXBSnuZtunLobDxVCP7Xe+3XxnpzVCEQ7Y8Fb6dhWEPmIACt5?= =?utf-8?q?qKXKuHHfTs3yMSg4tNG18wE1m4Yj+WFNuA8qCOzJS5mxx+I8aVbto+5s8SJ6oBIlq?= =?utf-8?q?68ji56GT42ORuI2tdA+IsIqsxkKE0k1jAGl+3h2uv4KFk/4q1nDR3yRbsdzoKFqj0?= =?utf-8?q?LX68vasfygWjm96DjIv7A+0FEQR4ZNpixhQ1t40YSOOWjDkAo4/2upJb1x0Whg6Ci?= =?utf-8?q?Ol9QKFZ5vrtE?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: ebe400e1-5d96-4783-1d46-08dbb3fd5300 X-MS-Exchange-CrossTenant-AuthSource: DU0PR04MB9417.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Sep 2023 02:01:20.6099 (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-CrossTenant-UserPrincipalName: b/uuN9U7/yu4OlAeqHsKO75ZfmS3qWPXtHn0+9jMBKxSndRvUP23acWkkFIy/32hsuKaQba/pZFjJeIUzX6jTw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8894 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org From: Peng Fan Add multi states support, this is to support devices could run in LP mode when runtime suspend, and OFF mode when system suspend. Signed-off-by: Peng Fan --- drivers/genpd/imx/scu-pd.c | 42 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/drivers/genpd/imx/scu-pd.c b/drivers/genpd/imx/scu-pd.c index 2f693b67ddb4..f1a43cb0bf79 100644 --- a/drivers/genpd/imx/scu-pd.c +++ b/drivers/genpd/imx/scu-pd.c @@ -368,7 +368,8 @@ static int imx_sc_pd_power(struct generic_pm_domain *domain, bool power_on) hdr->size = 2; msg.resource = pd->rsrc; - msg.mode = power_on ? IMX_SC_PM_PW_MODE_ON : IMX_SC_PM_PW_MODE_LP; + msg.mode = power_on ? IMX_SC_PM_PW_MODE_ON : pd->pd.state_idx ? + IMX_SC_PM_PW_MODE_OFF : IMX_SC_PM_PW_MODE_LP; /* keep uart console power on for no_console_suspend */ if (imx_con_rsrc == pd->rsrc && !console_suspend_enabled && !power_on) @@ -412,11 +413,33 @@ static struct generic_pm_domain *imx_scu_pd_xlate(struct of_phandle_args *spec, return domain; } +static bool imx_sc_pd_suspend_ok(struct device *dev) +{ + /* Always true */ + return true; +} + +static bool imx_sc_pd_power_down_ok(struct dev_pm_domain *pd) +{ + struct generic_pm_domain *genpd = pd_to_genpd(pd); + + /* For runtime suspend, choose LP mode */ + genpd->state_idx = 0; + + return true; +} + +struct dev_power_governor imx_sc_pd_qos_governor = { + .suspend_ok = imx_sc_pd_suspend_ok, + .power_down_ok = imx_sc_pd_power_down_ok, +}; + static struct imx_sc_pm_domain * imx_scu_add_pm_domain(struct device *dev, int idx, const struct imx_sc_pd_range *pd_ranges) { struct imx_sc_pm_domain *sc_pd; + struct genpd_power_state *states; bool is_off; int mode, ret; @@ -427,9 +450,22 @@ imx_scu_add_pm_domain(struct device *dev, int idx, if (!sc_pd) return ERR_PTR(-ENOMEM); + states = devm_kcalloc(dev, PD_STATE_MAX, sizeof(*states), GFP_KERNEL); + if (!states) { + devm_kfree(dev, sc_pd); + return ERR_PTR(-ENOMEM); + } + sc_pd->rsrc = pd_ranges->rsrc + idx; sc_pd->pd.power_off = imx_sc_pd_power_off; sc_pd->pd.power_on = imx_sc_pd_power_on; + states[PD_STATE_LP].power_off_latency_ns = 25000; + states[PD_STATE_LP].power_on_latency_ns = 25000; + states[PD_STATE_OFF].power_off_latency_ns = 2500000; + states[PD_STATE_OFF].power_on_latency_ns = 2500000; + + sc_pd->pd.states = states; + sc_pd->pd.state_count = PD_STATE_MAX; if (pd_ranges->postfix) snprintf(sc_pd->name, sizeof(sc_pd->name), @@ -455,14 +491,16 @@ imx_scu_add_pm_domain(struct device *dev, int idx, sc_pd->name, sc_pd->rsrc); devm_kfree(dev, sc_pd); + devm_kfree(dev, states); return NULL; } - ret = pm_genpd_init(&sc_pd->pd, NULL, is_off); + ret = pm_genpd_init(&sc_pd->pd, &imx_sc_pd_qos_governor, is_off); if (ret) { dev_warn(dev, "failed to init pd %s rsrc id %d", sc_pd->name, sc_pd->rsrc); devm_kfree(dev, sc_pd); + devm_kfree(dev, states); return NULL; }