From patchwork Sun Oct 16 09:58:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Guo X-Patchwork-Id: 616370 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 E6B77C4332F for ; Sun, 16 Oct 2022 09:58:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229721AbiJPJ6n (ORCPT ); Sun, 16 Oct 2022 05:58:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52600 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229719AbiJPJ6k (ORCPT ); Sun, 16 Oct 2022 05:58:40 -0400 Received: from mail-pg1-x52c.google.com (mail-pg1-x52c.google.com [IPv6:2607:f8b0:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 70C523640C for ; Sun, 16 Oct 2022 02:58:37 -0700 (PDT) Received: by mail-pg1-x52c.google.com with SMTP id h185so8082434pgc.10 for ; Sun, 16 Oct 2022 02:58:37 -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=uIHYWY56QD8kdVR8UkvvdHp3cIEPSeTOMo7K4e0+8vI=; b=ZxddD8Za0wZsUUJ6Nk5mbI13E2BDhHfxNKYxve4XGPZY25S3f5dartelW6ig1AJ0TE urk9Jfrnxh9RzIRoYYOZ9fA6PU+cBmvY4TBahjbDqVUs9hCjgnEyQuVHAvD4dRN7zqVl khbXWIUjHw2GsM8BuJw1b0yQd4dsWKKVTjPhdZ6SGP9wVHwdwjiFAm9UQoff/CU0ma9D adwcI+adygygmXnksMbFYHxWu9jtYVhJJ9INfrsK8lWYTu3rLP17Hqzpv9WXQnsL3rZ5 zfrhFKvaUExS+xQk8tdSPECGcIm+cRqDKTSa4bVdQcEMHZk6B5Mv04Z84z0FGILHixFf nB6w== 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=uIHYWY56QD8kdVR8UkvvdHp3cIEPSeTOMo7K4e0+8vI=; b=KZmC1OS5FVMf9MoOK7PNVMApz6tPQbWUVAMeoVOlWE5dM6c4xVAvLNzjdaiPORW37Q Zlt3Gd7hns2c1I5OTtdkQ8HtudBgasOhe9mNOYoQEF6aOBJOiFwXj5ZYEkVuu7SgapHY N1AeAJo63MVF7lWw9AQ+zS/tpMmZy3ylDAVfREeZRksVzeAzO+7z6T5ebtnBCPpPs07y TRpyCYyyPt9JoQ7Zv7dlb9AzkuWl1sTSigBvwSLrJTsQ8CxybR+c0nWQIVLb2Nru0Rgy LEplXDbvNs6j1jhLLcCU+z+uM/eJpkp8jHgFBf9OGOKg5cG7oQLC6Xqssy4xNEBnuPep wULg== X-Gm-Message-State: ACrzQf3S37CFe54yiQML5qLay6x2AyuR9vSeJVGjihOIMNEVcQ0hQcQU xD8V88GaELquKBQeLrQo5PsMZA== X-Google-Smtp-Source: AMsMyM5PWhYCkM8N97Vm12Rtc/car+lxsxKzJ+85li/IR9jXxtbolLnQOKcPSUoj/WalqghFKHR9Hw== X-Received: by 2002:a05:6a00:1341:b0:566:5e54:8110 with SMTP id k1-20020a056a00134100b005665e548110mr6842504pfu.6.1665914316527; Sun, 16 Oct 2022 02:58:36 -0700 (PDT) Received: from localhost.localdomain (80.251.214.228.16clouds.com. [80.251.214.228]) by smtp.gmail.com with ESMTPSA id c18-20020a170902d49200b001745662d568sm4481838plg.278.2022.10.16.02.58.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 16 Oct 2022 02:58:35 -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 1/3] PM: domains: Pass generic PM noirq hooks to genpd_finish_suspend() Date: Sun, 16 Oct 2022 17:58:13 +0800 Message-Id: <20221016095815.2550034-2-shawn.guo@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221016095815.2550034-1-shawn.guo@linaro.org> References: <20221016095815.2550034-1-shawn.guo@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@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 55a10e6d4e2a..01f5644938e0 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); } /**