From patchwork Wed Mar 6 13:25:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aisheng Dong X-Patchwork-Id: 10841123 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 1AB321803 for ; Wed, 6 Mar 2019 13:26:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 036BC2D96E for ; Wed, 6 Mar 2019 13:26:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E9FE62D977; Wed, 6 Mar 2019 13:26:41 +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 85EE32D96E for ; Wed, 6 Mar 2019 13:26:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726882AbfCFN0l (ORCPT ); Wed, 6 Mar 2019 08:26:41 -0500 Received: from mail-eopbgr00075.outbound.protection.outlook.com ([40.107.0.75]:12354 "EHLO EUR02-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727304AbfCFN0k (ORCPT ); Wed, 6 Mar 2019 08:26:40 -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=y/xuxisU4vv5vRzHAShWyRDcg2nis3Q//bBEKXXRVb8=; b=NQ5uSdAyfI+7Lfyup71zjfiNBIO39uQQYrVJuNkHXApZjeBJaG0D7QENj8/aYVQGNxTY23LgFg4Dikp2JsARZEf6eA/GtQWDqsAR52UZeb22a96g1Ql9cBeOMUXYjejeXwMEGI3uGZEqu6IQcPKr+HPsCNHyj6yQ1IpN+nJp+0E= Received: from AM0PR04MB4211.eurprd04.prod.outlook.com (52.134.92.158) by AM0PR04MB5345.eurprd04.prod.outlook.com (20.178.112.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1686.18; Wed, 6 Mar 2019 13:25:22 +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:25:22 +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 4/6] PM / Domains: Move the Subdomain check into _genpd_power_off Thread-Topic: [PATCH 4/6] PM / Domains: Move the Subdomain check into _genpd_power_off Thread-Index: AQHU1CAMzk547olF3kOGQCSlDNQFUQ== Date: Wed, 6 Mar 2019 13:25:22 +0000 Message-ID: <1551878302-8146-5-git-send-email-aisheng.dong@nxp.com> References: <1551878302-8146-1-git-send-email-aisheng.dong@nxp.com> In-Reply-To: <1551878302-8146-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: HK0P153CA0009.APCP153.PROD.OUTLOOK.COM (2603:1096:203:18::21) 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: 519f0d6d-6b6b-43fc-d089-08d6a2372f4c 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:AM0PR04MB5345; x-ms-traffictypediagnostic: AM0PR04MB5345: x-microsoft-exchange-diagnostics: =?iso-8859-1?q?1=3BAM0PR04MB5345=3B23=3AeJ?= =?iso-8859-1?q?YEuWzAw+JqpTJUy8mwdNPHY70+Yoo8pbSz0hh8nbTgpwW66Om/YEgdVaQibJ?= =?iso-8859-1?q?EW6NE8HkX8VtApURqFhTbzr+rW/ceXQsU9OejS6RB2IyIh4EjTGSPufRdBfk?= =?iso-8859-1?q?8I8sFdxd6NN9ctMzhTT0+9eUic5nC+/qHZlungL70gQAWVB9V6RiOTRYRV3N?= =?iso-8859-1?q?DP8pKcTUILZ6W42nO5aZAUK0E6r2efrJFhy7QjXN+kgWOko+1h15Ijp0/iOj?= =?iso-8859-1?q?JhOf8eh4DnmACksntmG/D7Ah7hXTITuDJprqs8cHmf3ohjH6QOIMV7lyyh92?= =?iso-8859-1?q?S65uFs/l+5NJ2guyFhz1/NVXnOnuNi+EsJmYHNSnJnLTJJSXZdoTDTEnTMx7?= =?iso-8859-1?q?wpJdp64hIIAeCdQCaF6JhwZ4UiC0lxd7oXiv/5wK7De8iszwutFSXZU21zRq?= =?iso-8859-1?q?NlqL4diPtYtmqhGzzaKAxgGs7EUEWeB8MfRMYspeU76+czkDexb0mtPViNyX?= =?iso-8859-1?q?1BU61IPd7iGN9G1r7GjVH+Nh9QGlwpFatHDDkztpK5UvLs8pEcU7A4cR3PA2?= =?iso-8859-1?q?t/X9OJyZIwdi26l7+pVNiFnoJkYuQoDCp5CHd9GOyePR2Mf8nJLf8zdHK1Ci?= =?iso-8859-1?q?ppdV9NtwyHnQf6a9bK+X/mVWo9m6pIxg6C+2FRav18d8hzYgba2IUyzVwqEx?= =?iso-8859-1?q?Jj9obj5hzCLowjqtaABcHXWc0w9yx1g7queDfVJ3UZMxuOqZxRb+CDAIAIQ4?= =?iso-8859-1?q?8ARUn9oVM4pRsRoeQuvjKwdchcwBLAMD1zn4wdG5u/75deXm1yFCmY+B/SH/?= =?iso-8859-1?q?WD10aESD1P/3T/DLT/gkWvv4nREmVR26M9sENOEBLjaTD+CJONGCGWbQT64H?= =?iso-8859-1?q?ZmqkG97N9fIK/Uwzy2vU5XKpZmueTJTtMebPWCaVP4F+J/wQu+esPGMxNAgN?= =?iso-8859-1?q?Uge7UqQUIWPKeatCq2Ts7cGpaydnwCp8DJWdMOFdS43SsBDDUsy/sRJORbNB?= =?iso-8859-1?q?fAKTpz85E18fCcRdM0k5ls6XINsVVj8V3I41+MeP4p2n2YveZ+l+6cFjvZHI?= =?iso-8859-1?q?jzC5cerj/v3omBm4pMt5ixehEHSH8aC0NMeIMp1pdNcZVCtgFxrdEDyXHlDe?= =?iso-8859-1?q?GefO6QJ14onnSuAGX74xg+NFiXoblKdoNNnmOHrRZ/gXzYV4fbBzpz2lNaYW?= =?iso-8859-1?q?DtTk9XGfHycfmzsifz1nVBL4B1rtYfFTp619/rvkPRxmNTbgJoXG+8xPABVO?= =?iso-8859-1?q?p7BWdf6NXevC0lTUxpuXkZzpFWHlNvKrp/6nwyE+j0S9s5vyJG+ibWMQxUS9?= =?iso-8859-1?q?BUExjzdLYCryeQCpv/JKQmKXFlXYPiJz+KGBtv/A=3D=3D?= x-microsoft-antispam-prvs: x-forefront-prvs: 0968D37274 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(39860400002)(396003)(136003)(366004)(376002)(346002)(199004)(189003)(316002)(4326008)(44832011)(386003)(446003)(486006)(2906002)(2616005)(54906003)(476003)(11346002)(6506007)(68736007)(36756003)(52116002)(186003)(105586002)(2351001)(14454004)(86362001)(26005)(5660300002)(106356001)(50226002)(71200400001)(71190400001)(25786009)(102836004)(8936002)(305945005)(478600001)(6916009)(6436002)(7736002)(99286004)(8676002)(66066001)(5640700003)(76176011)(256004)(14444005)(6486002)(81156014)(97736004)(3846002)(6116002)(53936002)(2501003)(81166006)(6512007);DIR:OUT;SFP:1101;SCL:1;SRVR:AM0PR04MB5345;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: aO51EvjtVxFXkrDz1AY3lDXVIN2+ICX4lp1yaQQkcpd6fXWgB/NV0Cjy8PaHhqd/5oHeorzIALG7pXCdh6BxdQBiJze0WRCWbKnszuNwWwYHGbX/ERBklWlTKBI/nuHiOLvdvDC/GVdpVvQjA8inzSwzXeRZeFEHae58qmcWrUljPlN5dEs+BwZpQZrVsddeVC1M8FZR5xG4kxy9bKFa73NYvsT+/rnukRzEJTcKgYuAMTGDCDXFGvYpMse8LQHibOG+FtsrepHsUh52TAWhIgWutFBwT7rUXbWaZd9bDslntnvKQVHS5i0mAu3DU32EzmOa6alRA1jgqPW8tlycQ1kc10ON+Kxb1ZPBuJgoGvooAqyEppYnp2dy9MFBhR2vbjfLw6aJFv/l78+jOTMj8Y024ikEXEpDpEfnJlTG7+k= MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 519f0d6d-6b6b-43fc-d089-08d6a2372f4c X-MS-Exchange-CrossTenant-originalarrivaltime: 06 Mar 2019 13:25:22.2630 (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: AM0PR04MB5345 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 Move the Subdomain check into _genpd_power_off, then the caller does not have to check it each time. This also ensures a double check of &genpd->sd_count before really power off domain in case it's increased asynchronously by subdomains. This is the same behavior as the original genpd_power_off() does. Signed-off-by: Dong Aisheng --- drivers/base/power/domain.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 591f37f..61cd500 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -452,6 +452,9 @@ static int _genpd_power_off(struct generic_pm_domain *genpd, bool timed) if (!genpd->power_off) return 0; + if (atomic_read(&genpd->sd_count) > 0) + return -EBUSY; + if (!timed) return genpd->power_off(genpd); @@ -547,9 +550,6 @@ static int genpd_power_off(struct generic_pm_domain *genpd, bool one_dev_on, if (!genpd->gov) genpd->state_idx = 0; - if (atomic_read(&genpd->sd_count) > 0) - return -EBUSY; - /* * If sd_count > 0 at this point, one of the subdomains hasn't * managed to call genpd_power_on() for the master yet after @@ -962,8 +962,7 @@ static void genpd_sync_power_off(struct generic_pm_domain *genpd, bool use_lock, if (!genpd_status_on(genpd) || genpd_is_always_on(genpd)) return; - if (genpd->suspended_count != genpd->device_count - || atomic_read(&genpd->sd_count) > 0) + if (genpd->suspended_count != genpd->device_count) return; /* Choose the deepest state when suspending */