Received: by 2002:a05:6358:111d:b0:dc:6189:e246 with SMTP id f29csp1679444rwi; Mon, 31 Oct 2022 21:05:00 -0700 (PDT) X-Google-Smtp-Source: AMsMyM56ZmgeDEBs1Vv5Ilrv7K3/HfU3vCcXje4SAsq0XLRxhSAk4uq5wBC50TjYkN9mWREAvevg X-Received: by 2002:a17:90a:f507:b0:211:e623:da5b with SMTP id cs7-20020a17090af50700b00211e623da5bmr36007786pjb.37.1667275499366; Mon, 31 Oct 2022 21:04:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667275499; cv=none; d=google.com; s=arc-20160816; b=hb0SLm1uwNPnU/Ot7XbwLMnrpdDdPEEPp1XEnJrgY/yahgk6WRAUEpeWf4LogJOCnh me2Rn5NyCLgROWF0O1olGu74sb0Gb6tOhG90/HNfeCTbnxoJPFj7SKX+Obmhe/cr7QHI TxJ/MGcS3X2Nfk9ByU1Tyas35Uo5aBrnQioTweS3Tt3PF2U7Kjwqbm//CrPkMFBeIPgu 5XbJSrI2KSwdbGahsZqQYeSCYMDSzDcXIlMRjiczlquIEZwJrhRN9t11fHsoiQ0k9biU yQSnCOWklcA1qfkDcZi3wEL89kXz0Zv1nRNIf/NugLtf4wEYtRYmm8NfEFtzzr0eA9UY O8Tg== 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=XGwO4GhQFCnfEGWVPRq8FBqqasnQ0/oWKbkrBe1VfIA=; b=QMErd1UPfPV0JXvBi8wh8S/oh0A42zS92zDXS9eDf9XwVYkg85XrMTKydMzAh7aQFc dIS5lY1iHXd2TApy7m+ozxlODL3NyTogr+rgsi7fN8ybOvBw6a+PKZ7HS261MKib1dez rp5UE+DxGXSeAHjwRio96TKBr9jqaJ8Owo2d/raqR+eJNuXjoy4nNMGFy5z8CEbEAP2a cQJ6kaMgF2XfX1IuOtca0ySRiIqfIx6tBXmmOI8cyGpExl/DRFAEJ+OD4jHyHuQ2pBnD nAQSVA+9pDXiG64ruVFhJovP5XGDDAhHR0hpS8w4w2H5yrlZZmb6y/k1G9Ayz7e5gDSF +PQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mTkPZRYD; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f1-20020a636a01000000b004606d9040b8si11043775pgc.387.2022.10.31.21.04.47; Mon, 31 Oct 2022 21:04:59 -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=mTkPZRYD; 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 S229913AbiKACrz (ORCPT + 97 others); Mon, 31 Oct 2022 22:47:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42236 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229832AbiKACrw (ORCPT ); Mon, 31 Oct 2022 22:47:52 -0400 Received: from mail-pg1-x535.google.com (mail-pg1-x535.google.com [IPv6:2607:f8b0:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6C1517894 for ; Mon, 31 Oct 2022 19:47:51 -0700 (PDT) Received: by mail-pg1-x535.google.com with SMTP id q1so12282069pgl.11 for ; Mon, 31 Oct 2022 19:47:51 -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=XGwO4GhQFCnfEGWVPRq8FBqqasnQ0/oWKbkrBe1VfIA=; b=mTkPZRYDYhw7QQ4scrrL39McOrmqG4T2zdd9b1wJc1nA4b4vOHpdpe2kQIBil7+LLD 2ZRTIHbgqZo1u2pX5NK3RY9NdieoqMYh3AxjH+xsnP+X5JoUdv7ApEWQdqDJz4DNzFa+ RX0mx/sFa46oPS5LrNP+0FUWDUjDgei/9C7J4jMn6S8MnRfvipYU+Do7DzYSDJU4SdY2 l5//Wj1X/eibK1Pg3kEj/kryDik3M4ZOjdyIqIskK+IE2rgOMevVRB2ZyFv/OhlZE97L h19CJ8DsgqfSkhUIRSTuFucLbA+2+L3ZTWUZVjx9v6I4QDLMEuHXB59VWI4Ep6PsaiXi fQoA== 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=XGwO4GhQFCnfEGWVPRq8FBqqasnQ0/oWKbkrBe1VfIA=; b=WsivHhmQyhqH3x3tOq61unjGCo6GvBrD1o3B/9wPCM6joWfaFRuVAg/gcAx6nGkTkR PMh5WgpmBZiLUu9g4iu+z20LWJsCI6jeOYzdNwZ6M1tpJsA4CoYtV7bc0T2HN/ml6KBh G6uFn/4z6LVfzVPa+0DWX86AH9GPkVS2MTg63KnNnynOqOTJR4ShbfCWPLrU5qnPt369 9zkY7+7uC7L85suxpQXlgo1Si8d9vDm1SWkLakCxFvxhHbSPm+1aPZz/jwrOpQxHB32k WVFZB0gWp8R+B1LFttz2vGgX+nuDOGRQRGyjrPWcWs72xGjGOs0mf7mFky+I0o8VNLfZ Su8g== X-Gm-Message-State: ACrzQf1e1k5FIxLSrqr4padZMO4AjHtUNhKaBrPCsdRHT6kmM9L5erUt d2AzeVt0T6rl5/RSc27+Mkx9wQ== X-Received: by 2002:a62:4c6:0:b0:55f:c739:51e0 with SMTP id 189-20020a6204c6000000b0055fc73951e0mr17184994pfe.49.1667270871297; Mon, 31 Oct 2022 19:47:51 -0700 (PDT) Received: from localhost.localdomain (80.251.214.228.16clouds.com. [80.251.214.228]) by smtp.gmail.com with ESMTPSA id y4-20020a170902ed4400b001714c36a6e7sm5079570plb.284.2022.10.31.19.47.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Oct 2022 19:47:50 -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 v2 1/3] PM: domains: Pass generic PM noirq hooks to genpd_finish_suspend() Date: Tue, 1 Nov 2022 10:47:34 +0800 Message-Id: <20221101024736.1509207-2-shawn.guo@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221101024736.1509207-1-shawn.guo@linaro.org> References: <20221101024736.1509207-1-shawn.guo@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 While argument `poweroff` works fine for genpd_finish_suspend() to handle distinction between suspend and poweroff, it won't scale if we want to use it for freeze as well. Pass generic PM noirq hooks as arguments instead, so that the function can possibly cover freeze case too. Signed-off-by: Shawn Guo --- drivers/base/power/domain.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 6471b559230e..54f6b0dd35fb 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -1189,12 +1189,15 @@ static int genpd_prepare(struct device *dev) * genpd_finish_suspend - Completion of suspend or hibernation of device in an * I/O pm domain. * @dev: Device to suspend. - * @poweroff: Specifies if this is a poweroff_noirq or suspend_noirq callback. + * @suspend_noirq: Generic suspend_noirq callback. + * @resume_noirq: Generic resume_noirq callback. * * Stop the device and remove power from the domain if all devices in it have * been stopped. */ -static int genpd_finish_suspend(struct device *dev, bool poweroff) +static int genpd_finish_suspend(struct device *dev, + int (*suspend_noirq)(struct device *dev), + int (*resume_noirq)(struct device *dev)) { struct generic_pm_domain *genpd; int ret = 0; @@ -1203,10 +1206,7 @@ static int genpd_finish_suspend(struct device *dev, bool poweroff) if (IS_ERR(genpd)) return -EINVAL; - if (poweroff) - ret = pm_generic_poweroff_noirq(dev); - else - ret = pm_generic_suspend_noirq(dev); + ret = suspend_noirq(dev); if (ret) return ret; @@ -1217,10 +1217,7 @@ static int genpd_finish_suspend(struct device *dev, bool poweroff) !pm_runtime_status_suspended(dev)) { ret = genpd_stop_dev(genpd, dev); if (ret) { - if (poweroff) - pm_generic_restore_noirq(dev); - else - pm_generic_resume_noirq(dev); + resume_noirq(dev); return ret; } } @@ -1244,7 +1241,9 @@ static int genpd_suspend_noirq(struct device *dev) { dev_dbg(dev, "%s()\n", __func__); - return genpd_finish_suspend(dev, false); + return genpd_finish_suspend(dev, + pm_generic_suspend_noirq, + pm_generic_resume_noirq); } /** @@ -1353,7 +1352,9 @@ static int genpd_poweroff_noirq(struct device *dev) { dev_dbg(dev, "%s()\n", __func__); - return genpd_finish_suspend(dev, true); + return genpd_finish_suspend(dev, + pm_generic_poweroff_noirq, + pm_generic_restore_noirq); } /** -- 2.25.1