From patchwork Wed Jun 2 10:12:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 452487 Delivered-To: patches@linaro.org Received: by 2002:a02:c735:0:0:0:0:0 with SMTP id h21csp429508jao; Wed, 2 Jun 2021 03:12:31 -0700 (PDT) X-Received: by 2002:a05:6512:2148:: with SMTP id s8mr3784156lfr.117.1622628751440; Wed, 02 Jun 2021 03:12:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622628751; cv=none; d=google.com; s=arc-20160816; b=PSAescZnbdJ8UfhNfV9ysCqM2/d8UBKvkKkazqfNslBXvyETSJStnq5OUj6U1b/gTy BzUXco+u01trt90kVAj/ib3wk4fm3VISIk+Zngc/fs4AR0CyaKpZjoN8oQUU198AcO2g trQ1ECIi2Up1RTyMsNrppIEJVJTI0xONeYCBUpFtnto6Fx2IV/nNQdCfkX9hir1Chy40 f/GMjU0s541EmPQkgQqFCfXzrP8QhjeBZN+aA9vlzyt8vsZu8spRjuWJXYGtAZb+kAw0 nVjqxxr5RtfK6jDAniRG5iE6Fup6lqpDqfRclvWQp4nhrQ1NudSNMm7aSMbbUs1lzzVW GmRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=hWJY2CFLHTV9te/K12aeGYAdOeh00bsaQx3awehhTns=; b=VyZDPnS9cO4916t/61oY6QY1qy4EIYGteJuo6KTy84n/B0HRHGg5s7vRL2HA4pjVGM xZzjUkOO8sAis5bh1dQ2Mcd7LIz206pFx0c0lUo8GCOxFTZrJzpmjgKI8MC9IociB0lB mdFLzw6m4040v3iTlv/MFi19XAqs8q1bHW6Mr8eeigyXjpSv3cTM1WFaBYuuedW/qltx tSxOL/zWYWKPaav/9tDB3s/uS/EkeEjvhTkrDOp7Ad8fVSRqLnXfI79TK1pN2Yu79oYq m7Fpj3bk4kSISrqji2zGPTvifQTH/NheYvU+JaLbSCzPxDrC1jDxUO8VFkeuFbd0NybQ mZtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=otscoI9p; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.41 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id h10sor8671164ljg.47.2021.06.02.03.12.31 for (Google Transport Security); Wed, 02 Jun 2021 03:12:31 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=otscoI9p; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.41 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=hWJY2CFLHTV9te/K12aeGYAdOeh00bsaQx3awehhTns=; b=otscoI9pFx2lrv6RxW/6Gl7A/sdHQxh3kPnxbLMMZGHhdC2it/DuwnF4MCeokvSaZz zIupfLbKOtmT4BEQ7K1IjqQUkWgfOxanvdw+SEb67ZyGIsDjCVeP6JO11fRGmgALYH+/ K3pUMG01BEnsLg4OIyMOhLm369wsjxTzXQHmKPysQtLXG9MxfFQT1KGe+16d+jwZA/nD yB/uyW5CVoiTLxd4gL7vCOqMjRGtL3D/JlGQ2rTwkfefgVRxjXwmw05VdJebQ2oSu38X Xp4JkQfw4cL0kiQgbCnUMTxPfuZ0M69DwW+Oe93PVRRDGY8LhNT9YGBKl9Tc9I6yrw41 Wd4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=hWJY2CFLHTV9te/K12aeGYAdOeh00bsaQx3awehhTns=; b=DWPu93+k20glpeWo/eQNrFbajTjhfEe4giXaiNDZXOdiQRSftAMyMxxvssQXMw9Gq7 CObM1sRJrYQIQ0pYSMbNuHe76+f3tlm0FVqgDiokQZ+3YdwJzcxL8cJdG548u7DirSrM 7f/BntBq/YEt1SK+OBxRP3cP3Y1ucO/L+zHitS/udo1WaESedNNvun5EnGUADOFesQLW PNN0ygyxkzvtSlLEHYeOt0Mod3M1k2j/oH4Mlzveo2rCVx0qhwjdINAV09i+cQBnK3/d mf/xeVNeQayhMu/jjAQ+XfhlC0d1YJKvBwOPqe/UYaJ+wJNbA01ss6BgtKXNehuUQxo4 39IQ== X-Gm-Message-State: AOAM530Nm/Je6yZzCs0Z2o+uhZBxsvKjIyYM6p01+8TFn4hbasZI6SJ2 ztiNWp32e9zetDCDk7sdX5mgrmYa X-Google-Smtp-Source: ABdhPJxYUSku4L7fSC+jpg2qG/mq4pKtA+sillsPDclxRNexC8+2QLmeOD45HAP9L6+27YKLwbnZUA== X-Received: by 2002:a2e:9083:: with SMTP id l3mr24610514ljg.315.1622628751113; Wed, 02 Jun 2021 03:12:31 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-155-4-129-146.NA.cust.bahnhof.se. [155.4.129.146]) by smtp.gmail.com with ESMTPSA id y35sm1948938lfa.122.2021.06.02.03.12.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Jun 2021 03:12:30 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Viresh Kumar , linux-pm@vger.kernel.org Cc: Ulf Hansson , Dmitry Osipenko , Jonathan Hunter , Thierry Reding , Rajendra Nayak , Stephan Gerhold , Roja Rani Yarubandi , Bjorn Andersson , Vincent Guittot , Stephen Boyd , linux-kernel@vger.kernel.org Subject: [PATCH 1/3] PM: domains: Split code in dev_pm_genpd_set_performance_state() Date: Wed, 2 Jun 2021 12:12:13 +0200 Message-Id: <20210602101215.78094-2-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210602101215.78094-1-ulf.hansson@linaro.org> References: <20210602101215.78094-1-ulf.hansson@linaro.org> MIME-Version: 1.0 To prepare some of the code in dev_pm_genpd_set_performance_state() to be re-used from subsequent changes, let's split it up into two functions. Signed-off-by: Ulf Hansson --- drivers/base/power/domain.c | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) -- 2.25.1 Reviewed-by: Viresh Kumar diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index b6a782c31613..a3b6e751f366 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -379,6 +379,24 @@ static int _genpd_set_performance_state(struct generic_pm_domain *genpd, return ret; } +static int genpd_set_performance_state(struct device *dev, unsigned int state) +{ + struct generic_pm_domain *genpd = dev_to_genpd(dev); + struct generic_pm_domain_data *gpd_data = dev_gpd_data(dev); + unsigned int prev_state; + int ret; + + prev_state = gpd_data->performance_state; + gpd_data->performance_state = state; + + state = _genpd_reeval_performance_state(genpd, state); + ret = _genpd_set_performance_state(genpd, state, 0); + if (ret) + gpd_data->performance_state = prev_state; + + return ret; +} + /** * dev_pm_genpd_set_performance_state- Set performance state of device's power * domain. @@ -397,8 +415,6 @@ static int _genpd_set_performance_state(struct generic_pm_domain *genpd, int dev_pm_genpd_set_performance_state(struct device *dev, unsigned int state) { struct generic_pm_domain *genpd; - struct generic_pm_domain_data *gpd_data; - unsigned int prev; int ret; genpd = dev_to_genpd_safe(dev); @@ -410,16 +426,7 @@ int dev_pm_genpd_set_performance_state(struct device *dev, unsigned int state) return -EINVAL; genpd_lock(genpd); - - gpd_data = to_gpd_data(dev->power.subsys_data->domain_data); - prev = gpd_data->performance_state; - gpd_data->performance_state = state; - - state = _genpd_reeval_performance_state(genpd, state); - ret = _genpd_set_performance_state(genpd, state, 0); - if (ret) - gpd_data->performance_state = prev; - + ret = genpd_set_performance_state(dev, state); genpd_unlock(genpd); return ret; From patchwork Wed Jun 2 10:12:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 452488 Delivered-To: patches@linaro.org Received: by 2002:a02:c735:0:0:0:0:0 with SMTP id h21csp429532jao; Wed, 2 Jun 2021 03:12:33 -0700 (PDT) X-Received: by 2002:ac2:5a0e:: with SMTP id q14mr10894784lfn.647.1622628753018; Wed, 02 Jun 2021 03:12:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622628753; cv=none; d=google.com; s=arc-20160816; b=o79hVilqRHUVmtP5Rwpc/oXchZOtywskrbkKFNB6dOC/dQu2s4gZR80/Ue0UFM+1x2 F9g4PN0NwGITDYr4Qbn1KU/h6i+hTst4kct4R0t6Bf8SVqBkW6SqDUJjFNG8sl2XpZKW z25UMAk9WyVfamT56N08UZGKVy8/INqCGFF2hAKIisOM2HwJ5WkJM7RxG4fmM8Rp2S/+ Po6rsvf6+NOCW/iTLfptrtuw3fjmUCRwOVhsurgvpRwLB3fNPhtLn8cvXMyXgw/2yfvx OUPXOfechPqd2p5hKzCVwMRO9r/KRy/e0g0IaSIQUxmZD8EKON8TUjX0+T2XSBNZ4LpP SnSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=KSQ/Hhdv/geuNZerNpw5PmMWOOCJZ7RFgPSp5JORONg=; b=fYRtJru6duE2BjY19mSiGKCOTiUibWu02KZWw/XLgCC6v+sIUW7RwficQUIYy497di bMX8llTbmHrovIzSroaJPMMKfzZkfZhfNi6TD3CNuCb6bcDYmE62Dhnp6iEzH5FGX4+w NxJIkiLDOLGfZIA0mvs7qnPRzCjHt8AUM8Pm5Qi196+XZazqZSiTPK5xkn0aEg1q+YEO IV87pU4VvBjJtw55004itz7ktTbO/m9W24PQQjQGE+s12RRc1u3RkvW97ic7Igg/zE48 foXj6awgIQDlFnhIhodI2gaD7kaQcT2osssnTHk2MGqI17o+EfHNj4L8j5oyql0I5yWK kV8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="IkG/6epN"; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.41 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id 10sor2129453lfo.16.2021.06.02.03.12.32 for (Google Transport Security); Wed, 02 Jun 2021 03:12:33 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="IkG/6epN"; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.41 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=KSQ/Hhdv/geuNZerNpw5PmMWOOCJZ7RFgPSp5JORONg=; b=IkG/6epNfEkZ1qT7vpb6Doka0wPZaljxQ/pa1Fi76aylVEMGZMdt0S46sfAP/7fNVM V81JWsEqBwjvDpbeGGqraXSw/dwEsUw3/rjoj+KWLwupUC9PYRuvScCpSJgCS5d38BeW eiaOvhiUuVhWtRpyTBcc/pKklqAJ01CqW8wxMWIjEHN9yh589IHdSmSzFsT5Iz9dvS3v I9BHqGMi32JjknuHwpUTdnvKbshxSx4xcl0QPfWnxmb2vYMi9DsIe5HAbMZvIZXb6k54 yuvcIir/0Di6lDsdfebIF/pphyfwC4IGrTbteJReNWa3kK5ks6VFyXkXHOEhsrvImyPW iV3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=KSQ/Hhdv/geuNZerNpw5PmMWOOCJZ7RFgPSp5JORONg=; b=NrtF32NN1TMLUR3PVBIz6CKTEfDvTZZkyAAFRBREza6h2Gidfp/KCpGXG374xwS+vp pBudJ7qUnoY/EzDNVPdRTklvKlCqf2g3KQypsmubjGmISoLCbDxp+JOArpcGr5z47uj+ ckrQfRQYWSzcdt2u9CfvEFJVAZk42Jbr9evWCatUaHoSqwrwZWslZjVQf45d5Lx5nC04 ykj2p+6ljZAt7XamWsUlnU01S6io/34LCbXhr/MfVSGmx7F/T2MXcfSUaNbMHbAAKMBi TbRR5lgD92ENgCRePl7M9DYdhZfd0cTl6hiPiN3fPpTnIZ9FWMql8LNMGfAST6+r52Eu ZWHA== X-Gm-Message-State: AOAM531S6lZ1kc8y7UIfudge9QIJgtW6/OcMeNH/efzahTNMEX6qH973 JpKwcpW+w8ldQRP0mG4YEtsjXUmlXBvTrjzl2bM= X-Google-Smtp-Source: ABdhPJx2vFqeoY4uP0jDdYZn95EyK+JpOwpNLIysagQIHxDH0hKmm4tvud9jfcRlkruXAxUZYhrZvg== X-Received: by 2002:ac2:5237:: with SMTP id i23mr4873494lfl.22.1622628752661; Wed, 02 Jun 2021 03:12:32 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-155-4-129-146.NA.cust.bahnhof.se. [155.4.129.146]) by smtp.gmail.com with ESMTPSA id y35sm1948938lfa.122.2021.06.02.03.12.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Jun 2021 03:12:31 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Viresh Kumar , linux-pm@vger.kernel.org Cc: Ulf Hansson , Dmitry Osipenko , Jonathan Hunter , Thierry Reding , Rajendra Nayak , Stephan Gerhold , Roja Rani Yarubandi , Bjorn Andersson , Vincent Guittot , Stephen Boyd , linux-kernel@vger.kernel.org Subject: [PATCH 2/3] PM: domains: Drop/restore performance state votes for devices at runtime PM Date: Wed, 2 Jun 2021 12:12:14 +0200 Message-Id: <20210602101215.78094-3-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210602101215.78094-1-ulf.hansson@linaro.org> References: <20210602101215.78094-1-ulf.hansson@linaro.org> MIME-Version: 1.0 A subsystem/driver that need to manage OPPs for its device, should typically drop its vote for the OPP when the device becomes runtime suspended. In this way, the corresponding aggregation of the performance state votes that is managed in genpd for the attached PM domain, may find that the aggregated vote can be decreased. Hence, it may allow genpd to set the lower performance state for the PM domain, thus avoiding to waste energy. To accomplish this, typically a subsystem/driver would need to call dev_pm_opp_set_rate|opp() for its device from its ->runtime_suspend() callback, to drop the vote for the OPP. Accordingly, it needs another call to dev_pm_opp_set_rate|opp() to restore the vote for the OPP from its ->runtime_resume() callback. To avoid boilerplate code in subsystems/driver to deal with these things, let's instead manage this internally in genpd. Signed-off-by: Ulf Hansson --- drivers/base/power/domain.c | 21 +++++++++++++++++++-- include/linux/pm_domain.h | 1 + 2 files changed, 20 insertions(+), 2 deletions(-) -- 2.25.1 diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index a3b6e751f366..81b9d4652b90 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -397,6 +397,18 @@ static int genpd_set_performance_state(struct device *dev, unsigned int state) return ret; } +static int genpd_drop_performance_state(struct device *dev) +{ + struct generic_pm_domain_data *gpd_data = dev_gpd_data(dev); + unsigned int prev_state; + + prev_state = gpd_data->performance_state; + if (prev_state && !genpd_set_performance_state(dev, 0)) + return prev_state; + + return 0; +} + /** * dev_pm_genpd_set_performance_state- Set performance state of device's power * domain. @@ -839,7 +851,8 @@ static int genpd_runtime_suspend(struct device *dev) { struct generic_pm_domain *genpd; bool (*suspend_ok)(struct device *__dev); - struct gpd_timing_data *td = &dev_gpd_data(dev)->td; + struct generic_pm_domain_data *gpd_data = dev_gpd_data(dev); + struct gpd_timing_data *td = &gpd_data->td; bool runtime_pm = pm_runtime_enabled(dev); ktime_t time_start; s64 elapsed_ns; @@ -896,6 +909,7 @@ static int genpd_runtime_suspend(struct device *dev) return 0; genpd_lock(genpd); + gpd_data->rpm_saved_pstate = genpd_drop_performance_state(dev); genpd_power_off(genpd, true, 0); genpd_unlock(genpd); @@ -913,7 +927,8 @@ static int genpd_runtime_suspend(struct device *dev) static int genpd_runtime_resume(struct device *dev) { struct generic_pm_domain *genpd; - struct gpd_timing_data *td = &dev_gpd_data(dev)->td; + struct generic_pm_domain_data *gpd_data = dev_gpd_data(dev); + struct gpd_timing_data *td = &gpd_data->td; bool runtime_pm = pm_runtime_enabled(dev); ktime_t time_start; s64 elapsed_ns; @@ -937,6 +952,8 @@ static int genpd_runtime_resume(struct device *dev) genpd_lock(genpd); ret = genpd_power_on(genpd, 0); + if (!ret && gpd_data->rpm_saved_pstate) + genpd_set_performance_state(dev, gpd_data->rpm_saved_pstate); genpd_unlock(genpd); if (ret) diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h index dfcfbcecc34b..c3d6c15788a3 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h @@ -198,6 +198,7 @@ struct generic_pm_domain_data { struct notifier_block *power_nb; int cpu; unsigned int performance_state; + unsigned int rpm_saved_pstate; ktime_t next_wakeup; void *data; }; From patchwork Wed Jun 2 10:12:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 452489 Delivered-To: patches@linaro.org Received: by 2002:a02:c735:0:0:0:0:0 with SMTP id h21csp429548jao; Wed, 2 Jun 2021 03:12:34 -0700 (PDT) X-Received: by 2002:a2e:b0f2:: with SMTP id h18mr13847791ljl.244.1622628754634; Wed, 02 Jun 2021 03:12:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622628754; cv=none; d=google.com; s=arc-20160816; b=Lt2LyciQbGjKcc05Ejyf4kv/YAAoTaY2meY74GmRMs/rHSvmtAIYfR9r6BT+YI9VR+ OZRZ19h2nuT6j+xckHStCIWeI21BrMDJaAZ8Xg53MyWZF2f4WyxS93NLKw/lAba8UCnF 2wtNAn0kDZT+r57dNqSxbvlGej9OdvtqcyVpOiJNErvQvFEXl5WFJ5tpMZ6jBgxfrtpy T/ADQ6bwYc6ROzs3RCKraFrc4IR1lJg2lc16lJoSZI/ML8gf4xn0gzklP3H0CLa3012L ukktq1eVJH2R7mj7AzOJEivufUDBmyWgC8SQ+XisuiNl3Q4/y1CpjQsy1eAZY/pwsInm Hs1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=C0PrEdqIlPYceQIvyi2h1VFOj+MhO3lHQ6Qic3TwKKo=; b=NBjokPe0y0vG6dV3tnSGH9RzWmD+SsSIog76pUQJQz0oVGQj1MvH/1yQYU86wEGuLc yAuwZFPsdI+YDnMDafnz4YSrgBVsWTRTLGblYX0zcQPPjJTtjtKD8Eic1OxmFc2H9bJr vwiQJfRcvhymJ+uVX9ebuZ3Ke/jUN3SGLHZiyY7n7z0NzlrI5yHlJKmcOqIZtYkTC2P/ GwjtKRiMOlcn/465WXx4LoAQk151A39hMUzcgb4sAqZKgU5Zryc1n3Kq8ZjIn2td2JWv lSh81t82Kwzy/T13pP9DvPU/HFIrlvhzQyp56/R80cLEqJrCNjMW3bgs6CzrZCZWq0Xn 2iFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EKjLMkzj; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.41 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id d16sor8791910lji.17.2021.06.02.03.12.34 for (Google Transport Security); Wed, 02 Jun 2021 03:12:34 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EKjLMkzj; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.41 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=C0PrEdqIlPYceQIvyi2h1VFOj+MhO3lHQ6Qic3TwKKo=; b=EKjLMkzjNM5QGZZKAD4GkhTXZVGHf1OP7Nrl6TRvTAVse+F7+u9GF2TiD674xJhTFH 7L0niNMYpu7RF17IZF0iW0vkyzAAEtdj/RO5oV3gAWO+HjU22L4sXVMcHvjKC14gRiGD jsDabqkAp19sUFwQWKFZgB6LoEGS+PiO13sACnS59dGHV7OK3qIgj6bHu+Jo+RJrX1ri sftgT/pWXlmtVx9QqxPJkJpfJKU1sF3bqLVqXeHSzncWTDBpnpoVZJeGhKuW5/+Hs0gQ 5CJvHdza4iOu+DKpTHLJWSKJ6HpjiyWCdlUKfOpZJ+d8ylSzqu4XfBGUEKa/K03viRaO djKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=C0PrEdqIlPYceQIvyi2h1VFOj+MhO3lHQ6Qic3TwKKo=; b=twEKPNV2DJ7rHy0ymvm4j2f3enZIgburq0NQ+lNu76TrZXvmfYDWtlMBga0uKfCchG BIO5IRjERaxFIupnKo6PlcERsuEwSEk97y6PcCe8/5U3dzwZSS4Wi9IpOIdLbDsJGWjb 7rmvk5ATZ/eldlU326kDFyzqq7npj8HC854elAB/NeVeLM9EspliLBKhY8+4zx42L3Fw QNhtxyi9q4mk8VrzL2VQnLPMktreeGbk1fG2K+rQHPlPBxvuN8oYy46lvQ48lG8OJqCP KhEYGrviL7V0NMndLT4yAGV6Ww4GdpJLbPdfuMtYrs+Uu5bPkfG29pnjr8mQVPZkpvFl fu5A== X-Gm-Message-State: AOAM532nXXsP+olXfgK/RbsjeFFMjSMcMdE+5r3e5jLS9z2AMMCsjuuY yjbPEXv6QYZ0hE98uECz+0LLlkVZ X-Google-Smtp-Source: ABdhPJyvYiEkPGa6Y6AXlYz/GT2pKU67zMM7rOxx5eSGTfjkkvNFuKoqZs0Td+mGvfPkiPvwGnNaUw== X-Received: by 2002:a2e:b0c8:: with SMTP id g8mr6076534ljl.453.1622628754305; Wed, 02 Jun 2021 03:12:34 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-155-4-129-146.NA.cust.bahnhof.se. [155.4.129.146]) by smtp.gmail.com with ESMTPSA id y35sm1948938lfa.122.2021.06.02.03.12.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Jun 2021 03:12:33 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Viresh Kumar , linux-pm@vger.kernel.org Cc: Ulf Hansson , Dmitry Osipenko , Jonathan Hunter , Thierry Reding , Rajendra Nayak , Stephan Gerhold , Roja Rani Yarubandi , Bjorn Andersson , Vincent Guittot , Stephen Boyd , linux-kernel@vger.kernel.org Subject: [PATCH 3/3] PM: domains: Drop/restore performance state votes for devices at system PM Date: Wed, 2 Jun 2021 12:12:15 +0200 Message-Id: <20210602101215.78094-4-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210602101215.78094-1-ulf.hansson@linaro.org> References: <20210602101215.78094-1-ulf.hansson@linaro.org> MIME-Version: 1.0 Recent changes in genpd drops and restore performance state votes for devices during runtime PM. For the similar reasons, but to avoid the same kind of boilerplate code in device PM callbacks for system sleep in subsystems/drivers, let's drop and restore performance states votes in genpd for the attached devices during system sleep. Signed-off-by: Ulf Hansson --- drivers/base/power/domain.c | 14 ++++++++++++++ include/linux/pm_domain.h | 1 + 2 files changed, 15 insertions(+) -- 2.25.1 diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 81b9d4652b90..8487f1690deb 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -1162,6 +1162,7 @@ static int genpd_prepare(struct device *dev) */ static int genpd_finish_suspend(struct device *dev, bool poweroff) { + struct generic_pm_domain_data *gpd_data = dev_gpd_data(dev); struct generic_pm_domain *genpd; int ret = 0; @@ -1192,6 +1193,7 @@ static int genpd_finish_suspend(struct device *dev, bool poweroff) } genpd_lock(genpd); + gpd_data->pm_saved_pstate = genpd_drop_performance_state(dev); genpd->suspended_count++; genpd_sync_power_off(genpd, true, 0); genpd_unlock(genpd); @@ -1221,6 +1223,7 @@ static int genpd_suspend_noirq(struct device *dev) */ static int genpd_resume_noirq(struct device *dev) { + struct generic_pm_domain_data *gpd_data = dev_gpd_data(dev); struct generic_pm_domain *genpd; int ret; @@ -1236,6 +1239,8 @@ static int genpd_resume_noirq(struct device *dev) genpd_lock(genpd); genpd_sync_power_on(genpd, true, 0); genpd->suspended_count--; + if (gpd_data->pm_saved_pstate) + genpd_set_performance_state(dev, gpd_data->pm_saved_pstate); genpd_unlock(genpd); if (genpd->dev_ops.stop && genpd->dev_ops.start && @@ -1331,6 +1336,7 @@ static int genpd_poweroff_noirq(struct device *dev) */ static int genpd_restore_noirq(struct device *dev) { + struct generic_pm_domain_data *gpd_data = dev_gpd_data(dev); struct generic_pm_domain *genpd; int ret = 0; @@ -1355,6 +1361,8 @@ static int genpd_restore_noirq(struct device *dev) } genpd_sync_power_on(genpd, true, 0); + if (gpd_data->pm_saved_pstate) + genpd_set_performance_state(dev, gpd_data->pm_saved_pstate); genpd_unlock(genpd); if (genpd->dev_ops.stop && genpd->dev_ops.start && @@ -1400,23 +1408,29 @@ static void genpd_complete(struct device *dev) static void genpd_switch_state(struct device *dev, bool suspend) { struct generic_pm_domain *genpd; + struct generic_pm_domain_data *gpd_data; bool use_lock; genpd = dev_to_genpd_safe(dev); if (!genpd) return; + gpd_data = dev_gpd_data(dev); + use_lock = genpd_is_irq_safe(genpd); if (use_lock) genpd_lock(genpd); if (suspend) { + gpd_data->pm_saved_pstate = genpd_drop_performance_state(dev); genpd->suspended_count++; genpd_sync_power_off(genpd, use_lock, 0); } else { genpd_sync_power_on(genpd, use_lock, 0); genpd->suspended_count--; + if(gpd_data->pm_saved_pstate) + genpd_set_performance_state(dev, gpd_data->pm_saved_pstate); } if (use_lock) diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h index c3d6c15788a3..3eb215ac8adf 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h @@ -199,6 +199,7 @@ struct generic_pm_domain_data { int cpu; unsigned int performance_state; unsigned int rpm_saved_pstate; + unsigned int pm_saved_pstate; ktime_t next_wakeup; void *data; };