From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C6AB3C47082 for ; Thu, 3 Jun 2021 09:56:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AC061613BF for ; Thu, 3 Jun 2021 09:56:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229809AbhFCJ61 (ORCPT ); Thu, 3 Jun 2021 05:58:27 -0400 Received: from mail-pj1-f49.google.com ([209.85.216.49]:41569 "EHLO mail-pj1-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229747AbhFCJ61 (ORCPT ); Thu, 3 Jun 2021 05:58:27 -0400 Received: by mail-pj1-f49.google.com with SMTP id b15-20020a17090a550fb029015dad75163dso3574204pji.0 for ; Thu, 03 Jun 2021 02:56:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=bWwoATch/is17syekXXf9OKGsFoEOq9WgVsQ4YbeVPM=; b=Mrt+g2TUakUnIZvvo7w0SLH+4c0hsL9MVUWE5Uk4/S4rItImANhOsDyN/6LfOUvGSf RevmCO3ibS6kHKic7/BYGFgRL69mUV7BMnkv792C2VRYdRND6XJ7XrK8fbMFeXO1PT2o 8EAamCaTMNcaPalI2QOcgXqcW9dpHT5bTLVhtqod/JqC36rS6Z9+LeWK3mpFUArZscRE vTY6iDzA3Luk5r2WBf23oNvMmNLRXHIkEofkRkIwBz11KcYe41v7ZUEUhMV3Em9MTMcd 4TAKp7OxhbQbXEwvQlDpvzzncGQxVQUKL7CSzRexC78ySQFIt5UtG6Xum/nW7SxqNxW+ 6ynA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=bWwoATch/is17syekXXf9OKGsFoEOq9WgVsQ4YbeVPM=; b=X0d2ObJ45C1lrvMMYCmIw6aMYGpokdjaXQuSCb83O2RfFED34IFd9RdY/fvyHzeeAC HhrWd25WIVn6qCyNF6jexfhySU6a6yGthHUsPFNzFUD0uC0G7+c0xAzWGKovqTQxCz4g Ys86+7kg3QnBUrxorGhtOFyOj/ouhtxQbpjCtT4eXc914NfSi0S79EHjAgCJyK02HCJC 2dUmYjogsqJxozD5qHgAYYiml60diXl1zrvOBeX4d5KgjpNjXNpBNVmamiBcaT1+lPDM k2u/9+rK3yJWyB1Oo90xl8BkeO6UGk3C6H0Bnsq6HyqIwDiP+l0m8VfjRtsMJAhj+as3 V2SQ== X-Gm-Message-State: AOAM533tXqb2RIkT9pOFsjZT6KzfcTR45hkKluKo6zyqT0y1K/LEOI9S 8L0hY+vuwlXXP2WPw6ZOkY7sPg== X-Google-Smtp-Source: ABdhPJy3ETi8TG18LS356HnFPyHJW0fzt2AaED/39O4jlOV5io9iaCRsz7cUFRiTiZhleQ5DTb9OoQ== X-Received: by 2002:a17:902:b594:b029:f8:fb4f:f8d3 with SMTP id a20-20020a170902b594b02900f8fb4ff8d3mr34898636pls.25.1622714142521; Thu, 03 Jun 2021 02:55:42 -0700 (PDT) Received: from localhost ([136.185.154.93]) by smtp.gmail.com with ESMTPSA id t12sm2049594pfc.133.2021.06.03.02.55.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Jun 2021 02:55:40 -0700 (PDT) Date: Thu, 3 Jun 2021 15:25:38 +0530 From: Viresh Kumar To: Ulf Hansson Cc: "Rafael J . Wysocki" , linux-pm@vger.kernel.org, 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: Re: [PATCH v2 3/4] PM: domains: Drop/restore performance state votes for devices at runtime PM Message-ID: <20210603095538.b2t3cq25tq7v7kih@vireshk-i7> References: <20210603093438.138705-1-ulf.hansson@linaro.org> <20210603093438.138705-4-ulf.hansson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210603093438.138705-4-ulf.hansson@linaro.org> User-Agent: NeoMutt/20180716-391-311a52 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03-06-21, 11:34, Ulf Hansson wrote: > 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 > --- > > Changes in v2: > - Rebased. > - A few minor cosmetic changes. > - Deal with the error path in genpd_runtime_resume(). > > --- > drivers/base/power/domain.c | 27 +++++++++++++++++++++++++-- > include/linux/pm_domain.h | 1 + > 2 files changed, 26 insertions(+), 2 deletions(-) > > diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c > index ef25a5b18587..e5d97174c254 100644 > --- a/drivers/base/power/domain.c > +++ b/drivers/base/power/domain.c > @@ -400,6 +400,23 @@ static int genpd_set_performance_state(struct device *dev, unsigned int state) > return ret; > } > > +static int genpd_drop_performance_state(struct device *dev) What about passing the state pointer here? that will simplify the callers to just a call. > +{ > + unsigned int prev_state = dev_gpd_data(dev)->performance_state; > + > + if (!genpd_set_performance_state(dev, 0)) > + return prev_state; > + > + return 0; > +} > + > +static void genpd_restore_performance_state(struct device *dev, > + unsigned int state) > +{ > + if (state) I will skip this check, as we are checking it in genpd_set_performance_state() anyway ? > + genpd_set_performance_state(dev, state); > +} > + > /** > * dev_pm_genpd_set_performance_state- Set performance state of device's power > * domain. > @@ -842,7 +859,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; > @@ -899,6 +917,7 @@ static int genpd_runtime_suspend(struct device *dev) > return 0; > > genpd_lock(genpd); > + gpd_data->rpm_pstate = genpd_drop_performance_state(dev); So this will become: genpd_drop_performance_state(dev, &gpd_data->rpm_pstate); and it can have return type of void. -- viresh