From patchwork Wed Nov 2 14:21:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Guo X-Patchwork-Id: 14278 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp3668938wru; Wed, 2 Nov 2022 08:00:22 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6Ck/Mjqdq9o3CtwIBxHNdjHnZzercIBtXuyBMWC9w6+d0t+mJfxu1lDnMaT+PxVsnkk63d X-Received: by 2002:a17:903:2014:b0:186:8937:28a6 with SMTP id s20-20020a170903201400b00186893728a6mr24371016pla.39.1667401222184; Wed, 02 Nov 2022 08:00:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667401222; cv=none; d=google.com; s=arc-20160816; b=lG+SJiwoMDWH0RxI/4/zl1pv61y7JjsoxGPlKQdKNFLWSWYcJ1K6sLAx9Iwpgw0HPG CgaTbFJ0iw5TzK7Zc2Z3V+DfySvW3w7QUm2F411N70wt7Y4JJ104PyEKQNxzxwzkNeVf xoE/jbkOhFpbiJltCr8XjgjZPR/xniWmIs5LLwNAIY6Bu2wXOq2O0E9+1jxztpVTpI7D rx7S/nSOe2/1ePflJp15nq+//7xwJaY6JKjwMD9AjThbHqoYHScU3GuYB71k+KJu/UsA ssjSvSa8D/pJEr6b5XTtSMqkE/R7zHFS/zBkAxKeZ7ZkacMzpxr76PJM5bDX3bFGyMGS rr3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=GG7lcQ6B6Fm/T8LV8zudWuwDEbtHmTF64TDq9Olscfs=; b=E7bgP5VYtWDQ/u2IyOophTmyMSoux0jNIL9LtszPk6lGjbM+wd3h73y6Tq9IBGhVdh DWHgdce7IBAVZVXZszjTKZ/OUnn5/zBywbHcxJLT0fpmOvi5IS9tPJXJy+v9/ez4BVwQ ygfW42UXuIAZXZtHzmJv1Dl29kd4Ja/jOEZbLCrNqZehyQH1BkJNgaPK4mfnEWcY/30X zMz4rqxJuVHvjynntuJT6KGYCfiVrN2LFKT0QcrsYJBe2PmvIHwdxE2OWV6/tWcSbhFv jGSDz8bMuj58TtH4wbGl1o9z7ayGNAG3R54j9JILBpAwHcYy+2faxUFiTwNXJqDp6z84 hoBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PvzIPDEa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y10-20020a65528a000000b00461f71a53e1si6861209pgp.505.2022.11.02.08.00.09; Wed, 02 Nov 2022 08:00:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PvzIPDEa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231610AbiKBOWN (ORCPT + 99 others); Wed, 2 Nov 2022 10:22:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47766 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231620AbiKBOVz (ORCPT ); Wed, 2 Nov 2022 10:21:55 -0400 Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 15C7C22B1E for ; Wed, 2 Nov 2022 07:21:53 -0700 (PDT) Received: by mail-pj1-x102f.google.com with SMTP id gw22so3463664pjb.3 for ; Wed, 02 Nov 2022 07:21:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=GG7lcQ6B6Fm/T8LV8zudWuwDEbtHmTF64TDq9Olscfs=; b=PvzIPDEaMTxlCBzHeWB28vY0jwJKBCLL1AR3V06rmFooumUv1jPop0oiy7VlFAab+8 9X2W/hENaPNuh5hwH030LiHExwbxx4PlOmsmhD37ydMeugOoka5U3ADPw4TZkwYvqPG8 IcWS6xYmcj32PB2fh79Kk7136zg1voEKRW91DGoBHR+kFgIL69TrJ5foYR3hrZlaOdxQ o7m+EMklaYGDOO2e0ROew1+eXiH0eV1GwwXB9b893TqSRX7QJr9c/57qQENio0fe+fih z2gjPV6x1XGWkeSYnElgigWVp0yt8ShTlAptC14iiTL/YHnjSE2qi7Efuo1um5IF/s5V p2Tg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GG7lcQ6B6Fm/T8LV8zudWuwDEbtHmTF64TDq9Olscfs=; b=oaHhmvKuBVp67Xjca8sVM1JdeSYMrfjZZk8wgtGiAqEQzsVMofMFzEiZ1krphFFkiv 1ny8NqwpnKWUBUCHMnmEwvXbv5unEz/CiFErklNlBpLRGBP8TXK05Aq87jUSoPWUZLGj 1RuLhwX9eJX98QQN7fJD0NTlA+OmKGySZ5i9nkyPf/Mw5VWfr6Ql27fO6/+RMzlaP24Y c13BFM1uj/27MDrojePIixy1Myle8FCWDqsQNAPGHY/KEsOptVEQWPqCekswXalKzGHV tUTaCFr3BDWRZX00sWwHd4RyrmkONqrnVrwWqS/Imor0CWvTKMAGaxrKU29kpQCdyRef 7Tug== X-Gm-Message-State: ACrzQf0xVN52+FIevUTxhbTWNGomJDqxxIL5rWxUsasi2omsy0gK423s nYHqFETm9ukwTqe/lxlj2S446ZtIT+cE+A== X-Received: by 2002:a17:902:8a93:b0:17f:66ae:b6c with SMTP id p19-20020a1709028a9300b0017f66ae0b6cmr25058677plo.94.1667398912588; Wed, 02 Nov 2022 07:21:52 -0700 (PDT) Received: from localhost.localdomain (80.251.214.228.16clouds.com. [80.251.214.228]) by smtp.gmail.com with ESMTPSA id o28-20020aa7979c000000b0056b8181861esm8817773pfp.19.2022.11.02.07.21.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Nov 2022 07:21:52 -0700 (PDT) From: Shawn Guo To: "Rafael J . Wysocki" Cc: Kevin Hilman , Ulf Hansson , Len Brown , Pavel Machek , Greg Kroah-Hartman , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Shawn Guo Subject: [PATCH v3 3/4] PM: domains: Consolidate genpd_restore_noirq() and genpd_resume_noirq() Date: Wed, 2 Nov 2022 22:21:03 +0800 Message-Id: <20221102142104.2006554-4-shawn.guo@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221102142104.2006554-1-shawn.guo@linaro.org> References: <20221102142104.2006554-1-shawn.guo@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748396904287148646?= X-GMAIL-MSGID: =?utf-8?q?1748396904287148646?= Most of the logic between genpd_restore_noirq() and genpd_resume_noirq() are identical. The suspended_count decrement for restore should be the right thing to do anyway, considering there is an increment in genpd_finish_suspend() for hibernation. So consolidate these two functions into genpd_finish_resume(). Signed-off-by: Shawn Guo Reviewed-by: Ulf Hansson --- drivers/base/power/domain.c | 41 +++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index f18b8b1bc17a..7cee9439fd21 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -1247,12 +1247,14 @@ static int genpd_suspend_noirq(struct device *dev) } /** - * genpd_resume_noirq - Start of resume of device in an I/O PM domain. + * genpd_finish_resume - Completion of resume of device in an I/O PM domain. * @dev: Device to resume. + * @resume_noirq: Generic resume_noirq callback. * * Restore power to the device's PM domain, if necessary, and start the device. */ -static int genpd_resume_noirq(struct device *dev) +static int genpd_finish_resume(struct device *dev, + int (*resume_noirq)(struct device *dev)) { struct generic_pm_domain *genpd; int ret; @@ -1264,7 +1266,7 @@ static int genpd_resume_noirq(struct device *dev) return -EINVAL; if (device_wakeup_path(dev) && genpd_is_active_wakeup(genpd)) - return pm_generic_resume_noirq(dev); + return resume_noirq(dev); genpd_lock(genpd); genpd_sync_power_on(genpd, true, 0); @@ -1281,6 +1283,19 @@ static int genpd_resume_noirq(struct device *dev) return pm_generic_resume_noirq(dev); } +/** + * genpd_resume_noirq - Start of resume of device in an I/O PM domain. + * @dev: Device to resume. + * + * Restore power to the device's PM domain, if necessary, and start the device. + */ +static int genpd_resume_noirq(struct device *dev) +{ + dev_dbg(dev, "%s()\n", __func__); + + return genpd_finish_resume(dev, pm_generic_resume_noirq); +} + /** * genpd_freeze_noirq - Completion of freezing a device in an I/O PM domain. * @dev: Device to freeze. @@ -1366,27 +1381,9 @@ static int genpd_poweroff_noirq(struct device *dev) */ static int genpd_restore_noirq(struct device *dev) { - struct generic_pm_domain *genpd; - int ret = 0; - dev_dbg(dev, "%s()\n", __func__); - genpd = dev_to_genpd(dev); - if (IS_ERR(genpd)) - return -EINVAL; - - genpd_lock(genpd); - genpd_sync_power_on(genpd, true, 0); - genpd_unlock(genpd); - - if (genpd->dev_ops.stop && genpd->dev_ops.start && - !pm_runtime_status_suspended(dev)) { - ret = genpd_start_dev(genpd, dev); - if (ret) - return ret; - } - - return pm_generic_restore_noirq(dev); + return genpd_finish_resume(dev, pm_generic_restore_noirq); } /**