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: 10841119 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 73CFA1803 for ; Wed, 6 Mar 2019 13:26:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5B9012D96D for ; Wed, 6 Mar 2019 13:26:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4FE632D975; Wed, 6 Mar 2019 13:26:13 +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=-5.2 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id EE8D72D96D for ; Wed, 6 Mar 2019 13:26:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:In-Reply-To:References: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ST4ZEytLnd4PeJudZqAALNn5vDKM43Ok43SJ562QMSA=; b=UqDxsoIKhLYNbk xy5Ln/WaIcEOPs1335TaqubTfsLIQPm0ti0PRcRC5MO4/xd7zlrtJpeVIPWMgVy0HPmndH0EMfTmz QOzYBJGl4j/1wlc8RGhWCkgro5Un3MkeSjz/886zSeh5dE9kddk6sX0Igbx0/PevC2skvYBoRFPZR bGyi+xV0r/zpAtmjPx4xnepbgnryhH/Qk3HJry5CphptmhUQMDk4FK/+E5QwHZvLlzEat4u0s2Q5V a8Zokmnv9qtThnrUPWEmzrl33jwvlqC8t7wPFBvBz5x9XNrzF1de4z14MJaFAx1theJN9E/1vQ2Z7 HSnqkiwDnFeYBzhw4BOQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1h1WYk-0006Gn-1f; Wed, 06 Mar 2019 13:26:10 +0000 Received: from mail-am5eur02on0609.outbound.protection.outlook.com ([2a01:111:f400:fe07::609] helo=EUR02-AM5-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h1WY5-0004wD-CG for linux-arm-kernel@lists.infradead.org; Wed, 06 Mar 2019 13:25:35 +0000 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" 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; AM0PR04MB5345; 23:eJYEuWzAw+JqpTJUy8mwdNPHY70+Yoo8pbSz0hh?= =?iso-8859-1?q?8nbTgpwW66Om/YE?= =?iso-8859-1?q?gdVaQibJEW6NE8HkX8VtApURqFhTbzr+rW/ceXQsU9OejS6RB2IyIh4EjTGS?= =?iso-8859-1?q?PufRdBfk8I8sFdxd6NN9ctMzhTT0+9eUic5nC+/qHZlungL70gQAWVB9V6Ri?= =?iso-8859-1?q?OTRYRV3NDP8pKcTUILZ6W42nO5aZAUK0E6r2efrJFhy7QjXN+kgWOko+1h15?= =?iso-8859-1?q?Ijp0/iOjJhOf8eh4DnmACksntmG/D7Ah7hXTITuDJprqs8cHmf3ohjH6QOIM?= =?iso-8859-1?q?V7lyyh92S65uFs/l+5NJ2guyFhz1/NVXnOnuNi+EsJmYHNSnJnLTJJSXZdoT?= =?iso-8859-1?q?DTEnTMx7wpJdp64hIIAeCdQCaF6JhwZ4UiC0lxd7oXiv/5wK7De8iszwutFS?= =?iso-8859-1?q?XZU21zRqNlqL4diPtYtmqhGzzaKAxgGs7EUEWeB8MfRMYspeU76+czkDexb0?= =?iso-8859-1?q?mtPViNyX1BU61IPd7iGN9G1r7GjVH+Nh9QGlwpFatHDDkztpK5UvLs8pEcU7?= =?iso-8859-1?q?A4cR3PA2t/X9OJyZIwdi26l7+pVNiFnoJkYuQoDCp5CHd9GOyePR2Mf8nJLf?= =?iso-8859-1?q?8zdHK1CippdV9NtwyHnQf6a9bK+X/mVWo9m6pIxg6C+2FRav18d8hzYgba2I?= =?iso-8859-1?q?UyzVwqExJj9obj5hzCLowjqtaABcHXWc0w9yx1g7queDfVJ3UZMxuOqZxRb+?= =?iso-8859-1?q?CDAIAIQ48ARUn9oVM4pRsRoeQuvjKwdchcwBLAMD1zn4wdG5u/75deXm1yFC?= =?iso-8859-1?q?mY+B/SH/WD10aESD1P/3T/DLT/gkWvv4nREmVR26M9sENOEBLjaTD+CJONGC?= =?iso-8859-1?q?GWbQT64HZmqkG97N9fIK/Uwzy2vU5XKpZmueTJTtMebPWCaVP4F+J/wQu+es?= =?iso-8859-1?q?PGMxNAgNUge7UqQUIWPKeatCq2Ts7cGpaydnwCp8DJWdMOFdS43SsBDDUsy/?= =?iso-8859-1?q?sRJORbNBfAKTpz85E18fCcRdM0k5ls6XINsVVj8V3I41+MeP4p2n2YveZ+l+?= =?iso-8859-1?q?6cFjvZHIjzC5cerj/v3omBm4pMt5ixehEHSH8aC0NMeIMp1pdNcZVCtgFxrd?= =?iso-8859-1?q?EDyXHlDeGefO6QJ14onnSuAGX74xg+NFiXoblKdoNNnmOHrRZ/gXzYV4fbBz?= =?iso-8859-1?q?pz2lNaYWDtTk9XGfHycfmzsifz1nVBL4B1rtYfFTp619/rvkPRxmNTbgJoXG?= =?iso-8859-1?q?+8xPABVOp7BWdf6NXevC0lTUxpuXkZzpFWHlNvKrp/6nwyE+j0S9s5vyJG+i?= =?iso-8859-1?q?bWMQxUS9BUExjzdLYCryeQCpv/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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190306_052529_990676_D77C0CEE X-CRM114-Status: GOOD ( 13.10 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Aisheng Dong , "ulf.hansson@linaro.org" , "dongas86@gmail.com" , "khilman@kernel.org" , "rjw@rjwysocki.net" , dl-linux-imx , "linux-arm-kernel@lists.infradead.org" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.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 */