Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp308813pxt; Fri, 6 Aug 2021 02:34:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxd6UIWDkyQ3IyTkQo63+Fjv9aypiqqYrGeYMGDAeLM4o6/6K0vl3fCwJVM68M25YcR+gqE X-Received: by 2002:a92:d483:: with SMTP id p3mr179742ilg.50.1628242465945; Fri, 06 Aug 2021 02:34:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628242465; cv=none; d=google.com; s=arc-20160816; b=LYl6/TAJnIytKupzzYdc3kbyVmLT26qyELKXs5CXLOSVJWY/6XOcsDJOF0HgUmNNwx vQ1lrCZWeEYx+mCd96sH7NeAtxbVZxxJv8enNqYiMHzeCsMnKfVMeoyK4Rb7XugEFcf3 NVj0ao0kdC8Mm1dLr/qeFEIWJIUUY9hiuEre+oivPrGkiJ4z8N5D2nd9Hc4BMZ2ZGRnm B7FSsDTzYd74sQt+HQQ+wPghi2F0W9+JcHLDibO1IdJBN6emV6Farjur05Koybd8gI6j PnA2Ab89ayoqEIeUY1BCckg5Bh9xEdfHqDKsa0mrPZs4v1rr4ZfrN9PTXJgxgmMhFdox NCDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=hG7ad08wIaDvmaneskOxS98xzOuakO0shjMfqcJhf/0=; b=l6/Wa2wW9ICmzFYYRK0ZdUDHY9+hq5tdsXgkr58MttUuVFPR1r/1JyfPVwntTowj+u aF2deJIFRXlZaZomke8sEwwcyK67UzRBjN1KKdAo6CN3SHfu3DtplbF6nwHa21d4v+pS V5zd+zJ+eW7V6CEqRS51joKQUNSAncWZVO7bIN/sntLK1dmrqsWPXZG8QXY0IUR2R7xh YRUzzWEby4XFVN+vccFswbnkcG/frvnsr+P229hC5x5qW96c6sngPiQpIaibYQTmptHe AS730mOogAeKL2Mfiqkg37b1mtvAObUIdrc0NGM6mZBzPexp1/elB4Z+HLfR20l4zQ2R SlyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hMu6wdms; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z4si7962092ioz.87.2021.08.06.02.34.14; Fri, 06 Aug 2021 02:34:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hMu6wdms; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S244411AbhHFJc5 (ORCPT + 99 others); Fri, 6 Aug 2021 05:32:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46416 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244184AbhHFJcz (ORCPT ); Fri, 6 Aug 2021 05:32:55 -0400 Received: from mail-vs1-xe35.google.com (mail-vs1-xe35.google.com [IPv6:2607:f8b0:4864:20::e35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7796DC061799 for ; Fri, 6 Aug 2021 02:32:40 -0700 (PDT) Received: by mail-vs1-xe35.google.com with SMTP id b138so4838382vsd.2 for ; Fri, 06 Aug 2021 02:32:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=hG7ad08wIaDvmaneskOxS98xzOuakO0shjMfqcJhf/0=; b=hMu6wdmsIydv5n9UioqGMhi3NdWSB/gd114kREAS+K9yylruPgSJndFExuw8ozfeGO GdtAjzm8rBOTxnmkHvqbu7kIjYoIlQVlFMcJu6gZwcMsEnTfAgWtR5bOCu8ULScBXQJJ VcVw53SwVoCGiEySclc/39VPhrTmkILFH5aNXYcXbTYJcXc84+XPdsNGt04gU3EXEknv 987It+qBSY6m5j60ObfZ1xEocKkPVA3EMrVmgLpNOp2DRns9mVHCVAA1aakeRdTw5JoO Z4/7cRQBAk228VIIWMTo+Wx8N4HchVa6WWVCZYoGpKP+CER9LgvANl5oVUC3K7A2/y04 5OPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=hG7ad08wIaDvmaneskOxS98xzOuakO0shjMfqcJhf/0=; b=pDYUfHL7MPlZoVT+Q5/myaeZTev4YITbtMQtDuTzc1PYbcNzcOUesRkH1laTZAms3b Kh5Pnr4+hOBQCMtjahVKSV8HWem8g6U8TJgStzAQ+0kTxGlXBoQyRIyrAcYiuz7/iwVm brG6FPeObVmWSkdF4rMCUoKr1kp+1pN4ePRGGdslKRiBvhYZyLut6CHVMne0rJbWHFoo q1BYgcFPVkAxu+mmgu0B3wCDVXcoJVBpAX+drq4OCRlymrwlshyF4tTyCDy9Yn9/rcU7 QIv/hyujBMoSTuw1oZOaht1uBm9uSJ9S0+/2okr40773dPrzjYzobTh2Rkc2JAjzc0OA O+eQ== X-Gm-Message-State: AOAM532TC8pv0dn0zWIx9+LmuWPk4CjG5PB/soSfkP80WLeqKMjEKYpH MDZtDhzzWFKTp9lASvnrmZKkqqvEqciupfDObnUNvA== X-Received: by 2002:a67:7c14:: with SMTP id x20mr8347304vsc.42.1628242359627; Fri, 06 Aug 2021 02:32:39 -0700 (PDT) MIME-Version: 1.0 References: <1628074696-7979-1-git-send-email-rnayak@codeaurora.org> <1628074696-7979-2-git-send-email-rnayak@codeaurora.org> In-Reply-To: <1628074696-7979-2-git-send-email-rnayak@codeaurora.org> From: Ulf Hansson Date: Fri, 6 Aug 2021 11:32:03 +0200 Message-ID: Subject: Re: [PATCH v6 1/2] PM / Domains: Add support for 'required-opps' to set default perf state To: Rajendra Nayak Cc: Bjorn Andersson , Viresh Kumar , Linux PM , DTML , Linux Kernel Mailing List , linux-arm-msm , Stephen Boyd , Roja Rani Yarubandi , Stephan Gerhold Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 4 Aug 2021 at 12:58, Rajendra Nayak wrote: > > Some devices within power domains with performance states do not > support DVFS, but still need to vote on a default/static state > while they are active. They can express this using the 'required-opps' > property in device tree, which points to the phandle of the OPP > supported by the corresponding power-domains. > > Add support to parse this information from DT and then set the > specified performance state during attach and drop it on detach. > runtime suspend/resume callbacks already have logic to drop/set > the vote as needed and should take care of dropping the default > perf state vote on runtime suspend and restore it back on runtime > resume. > > Signed-off-by: Rajendra Nayak > --- > drivers/base/power/domain.c | 28 ++++++++++++++++++++++++++-- > include/linux/pm_domain.h | 1 + > 2 files changed, 27 insertions(+), 2 deletions(-) > > diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c > index a934c67..b9b5a9b 100644 > --- a/drivers/base/power/domain.c > +++ b/drivers/base/power/domain.c > @@ -2598,6 +2598,12 @@ static void genpd_dev_pm_detach(struct device *dev, bool power_off) > > dev_dbg(dev, "removing from PM domain %s\n", pd->name); > > + /* Drop the default performance state */ > + if (dev_gpd_data(dev)->default_pstate) { > + dev_pm_genpd_set_performance_state(dev, 0); > + dev_gpd_data(dev)->default_pstate = 0; > + } > + > for (i = 1; i < GENPD_RETRY_MAX_MS; i <<= 1) { > ret = genpd_remove_device(pd, dev); > if (ret != -EAGAIN) > @@ -2637,6 +2643,8 @@ static int __genpd_dev_pm_attach(struct device *dev, struct device *base_dev, > { > struct of_phandle_args pd_args; > struct generic_pm_domain *pd; > + struct device_node *np; > + int pstate; > int ret; > > ret = of_parse_phandle_with_args(dev->of_node, "power-domains", > @@ -2675,10 +2683,26 @@ static int __genpd_dev_pm_attach(struct device *dev, struct device *base_dev, > genpd_unlock(pd); > } > > - if (ret) > + if (ret) { > genpd_remove_device(pd, dev); > + return -EPROBE_DEFER; > + } > + > + /* Set the default performance state */ > + np = dev->of_node; > + if (of_parse_phandle(np, "required-opps", index)) { Looks like Viresh thinks it's a good idea to drop the error print in of_get_required_opp_performance_state() when there is no "required-opps" specifier. Would you mind folding in a patch for that in the series, so this code can be simplified according to our earlier discussions? > + pstate = of_get_required_opp_performance_state(np, index); > + if (pstate < 0) { > + ret = pstate; > + dev_err(dev, "failed to set required performance state for power-domain %s: %d\n", > + pd->name, ret); > + } else { > + dev_pm_genpd_set_performance_state(dev, pstate); > + dev_gpd_data(dev)->default_pstate = pstate; > + } > + } > > - return ret ? -EPROBE_DEFER : 1; > + return ret ? ret : 1; > } > > /** > diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h > index 21a0577..67017c9 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 default_pstate; > unsigned int rpm_pstate; > ktime_t next_wakeup; > void *data; Other than the above, this looks good to me! Kind regards Uffe