Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp431025pxv; Wed, 30 Jun 2021 08:48:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx3O9yUf9HM9Q8Q5ZXrLcqCF1Y6F69f7XOrGaeyiG9Mc22cemgVqwJM4PHasbLmDRpGRu0T X-Received: by 2002:a05:6638:9a:: with SMTP id v26mr9378822jao.124.1625068096201; Wed, 30 Jun 2021 08:48:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625068096; cv=none; d=google.com; s=arc-20160816; b=QCAJSwuZox63+ODnkMybixfLbJmhoz0Z7DpuUwEjdVSubJYCnOD+aP6Cx70uWmjoEU /GTxQGm5T+BZ8NQzwE1GGfNSG1Ekv7jtYiDqwKGC1YpTwPC9D+ObmW+KV07p2O083qK5 W1jd+ZamWACZpmNlTzhlJoivnpNlYZkkw2mXnXj2mZAfRQgR3Lh/wfLghX9qYJkHRuS4 qkh7Mi6D5IvK3rDuoOrxLun41sreCLe+uMxEzmW4kMG936Yl0mFjQ2HHoVJrnPXjmcVf VnfsoSx9B5s2KSoMOhbzbwNcqLfCd7jMak5cpmazWyWXaj5dO/kO0YGjjs0Sd2Qhsbrz 4H6g== 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=VxezOHsPVxs+xB6BVTLLYf2XI/Gpz28qXdqPvfvuUuY=; b=IwG/q3Xzh1sufmKr7Vztk8pdnnB6T8bDUNs17I4sn5KhKW3OO1MFh3VSfH7fu1gNnU rzgb4OZaprE1AHbKUDxhNjFquzw5obj9ZfAil67YxeZV64AYehXdXcRHE92aQ/VgumLi zlZmh/VRK5FVwz6pDEumXFUnCauq86hCB7UrA3eI9QqCcaBlYCoXvBzWQPTHHddXy3Qn IFCJ0utyc95lncwp09Hk4Hd4vas4ijopMbQWzMCiKuq5U/uVWbDdfl8Fyx0sIjiPbPXN M9N4gUOnEUI03vJyItgHIdL02DNzC2nAfV31QewDHt6D/PM1UvYJhY5Nf7uQy3qLg9XI A/EQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=swaiBn8G; 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 p19si24916293jas.9.2021.06.30.08.48.03; Wed, 30 Jun 2021 08:48:16 -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=swaiBn8G; 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 S235867AbhF3Pt7 (ORCPT + 99 others); Wed, 30 Jun 2021 11:49:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44276 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235743AbhF3Pt7 (ORCPT ); Wed, 30 Jun 2021 11:49:59 -0400 Received: from mail-qv1-xf33.google.com (mail-qv1-xf33.google.com [IPv6:2607:f8b0:4864:20::f33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A281EC0617A8 for ; Wed, 30 Jun 2021 08:47:28 -0700 (PDT) Received: by mail-qv1-xf33.google.com with SMTP id h18so1336426qve.1 for ; Wed, 30 Jun 2021 08:47:28 -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=VxezOHsPVxs+xB6BVTLLYf2XI/Gpz28qXdqPvfvuUuY=; b=swaiBn8GrCoTmoRBrySgqREVdAql6hqiSVM2EWhkYOjNdx1uYvOEZKtm6LuGTYKbNe C6Y8HhXzvumyE55ctUhCymF4q7GKDLoD09ByN5GMlkH/J5e5MwpwSS37xdKzsIOYpW7j WwiXv2C7tgQz8bS3v4kQhzF9AiN88YZt91YjpOc8Wp18kp/I5e+npykGyw4AzSR6SP4V ywTkN21gsgbMydOL+WiGbLey/rCKJh3rXNe5keH9lsX+/57XWfJ8ssOTtf6Fe4AfV4SB yynX3BebGV2NgYkLi+8eipvZ9s5UTQybGMOpDgWtRjtAo+4w87pxvaTAY4R+AY1eljjN eFQQ== 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=VxezOHsPVxs+xB6BVTLLYf2XI/Gpz28qXdqPvfvuUuY=; b=UFNPSvJOFA3xkSFoKlzij8q3Eu6JNRxaZhDeZhAkB1EIuGOUi/PmgrmHHLpKVoKd2K mg9NfsH3aoShHEDvGfVwn5ImFP1m7Tew7ecOHwZh5InhmAZZqSPKIKlyj8JfW9nuusXX V4+Xb4MfjPqmcyiURXHuNTF3l6Y0yct/wJ+XMCxtMqnfv7Mb9o1Pwuia3I/qz8iQyXVz efre/mXjnK8Y3ZFKVcodUERB3P1fVsq7OORUgLq4AfXXULzfe7BDRLrokUPvN1fjkL9w /H1Laoqy8PD07083hXw9ys3XDLUmPNGBr9XCfIpC3aTWSlFGu0aU0iHgf2uhFZmUXJin /HDA== X-Gm-Message-State: AOAM532DAjgfephEfROEr0A7diyeYgaEFhACEEB4EuaoRjEPKt4SFiet fsns63Lis0Xungr78Du19PKSLRxkh+sD3erRJeCu0g== X-Received: by 2002:a05:6214:1021:: with SMTP id k1mr37760978qvr.4.1625068047671; Wed, 30 Jun 2021 08:47:27 -0700 (PDT) MIME-Version: 1.0 References: <20210630133149.3204290-1-dmitry.baryshkov@linaro.org> <20210630133149.3204290-4-dmitry.baryshkov@linaro.org> In-Reply-To: From: Dmitry Baryshkov Date: Wed, 30 Jun 2021 18:47:16 +0300 Message-ID: Subject: Re: [PATCH 3/6] clk: qcom: gdsc: enable optional power domain support To: Bjorn Andersson Cc: Andy Gross , Rob Herring , Stephen Boyd , Taniya Das , Jonathan Marek , Michael Turquette , "open list:DRM DRIVER FOR MSM ADRENO GPU" , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , "open list:COMMON CLK FRAMEWORK" , "Bryan O'Donoghue" , Mark Brown , Ulf Hansson , open list Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Wed, 30 Jun 2021 at 18:00, Bjorn Andersson wrote: > > On Wed 30 Jun 08:31 CDT 2021, Dmitry Baryshkov wrote: > > > On sm8250 dispcc and videocc registers are powered up by the MMCX power > > domain. Currently we used a regulator to enable this domain on demand, > > however this has some consequences, as genpd code is not reentrant. > > > > Teach Qualcomm clock controller code about setting up power domains and > > using them for gdsc control. > > > > Signed-off-by: Dmitry Baryshkov > > There's a proposal to add a generic binding for statically assigning a > performance states here: > > https://lore.kernel.org/linux-arm-msm/1622095949-2014-1-git-send-email-rnayak@codeaurora.org/ > > > But that said, do you really need this? > > The requirement for driving MMCX to LOW_SVS on SM8250 (and NOM on > SM8150/SC8180x) seems to only come from the fact that you push MDP_CLK > to 460MHz in &mdss. > > But then in &mdss_mdp you do the same using an opp-table based on the > actual MDP_CLK, which per its power-domains will scale MMCX accordingly. MDSS and DSI would bump up MMCX performance state requirements on their own, depending on the frequency being selected. > So wouldn't it be sufficient to ensure that MDSS_GDSC is parented by > MMCX and then use opp-tables associated with the devices that scales the > clock and thereby actually carries the "required-opps". Actually no. I set the performance state in the qcom_cc_map, so that further register access is possible. Initially I was doing this in the qcom_cc_really_probe() and it was already too late. Just to remind: this patchset is not about MDSS_GDSC being parented by MMCX, it is about dispcc/videocc registers being gated with MMCX. > I presume your testing indicates that it doesn't matter on sm8250, but > as stated above, 460MHz on sm8150/sc8180x requires nominal, so per your > suggestion we'd have to vote nominal in &mdss, which means that if the > DPU decides to go to 200MHz the &mdss will still keep the voltage at > NOM, even though the DPU's opp-table says that LOW_SVS is sufficient. Let me check whether LOW_SVS is really a requirement or if setting MIN_SVS would also be sufficient for that. Interesting enough, from the downstream drivers it looks like dispcc should be able to work with MIN_SVS, while videocc would require LOW_SVS. > > Regards, > Bjorn > > > --- > > drivers/clk/qcom/common.c | 55 ++++++++++++++++++++++++++++++++++----- > > drivers/clk/qcom/gdsc.c | 6 +++++ > > 2 files changed, 55 insertions(+), 6 deletions(-) > > > > diff --git a/drivers/clk/qcom/common.c b/drivers/clk/qcom/common.c > > index 60d2a78d1395..eeb5b8c93032 100644 > > --- a/drivers/clk/qcom/common.c > > +++ b/drivers/clk/qcom/common.c > > @@ -10,6 +10,8 @@ > > #include > > #include > > #include > > +#include > > +#include > > > > #include "common.h" > > #include "clk-rcg.h" > > @@ -76,6 +78,16 @@ qcom_cc_map(struct platform_device *pdev, const struct qcom_cc_desc *desc) > > struct resource *res; > > struct device *dev = &pdev->dev; > > > > + if (of_find_property(dev->of_node, "required-opps", NULL)) { > > + int pd_opp; > > + > > + pd_opp = of_get_required_opp_performance_state(dev->of_node, 0); > > + if (pd_opp < 0) > > + return ERR_PTR(pd_opp); > > + > > + dev_pm_genpd_set_performance_state(dev, pd_opp); > > + } > > + > > res = platform_get_resource(pdev, IORESOURCE_MEM, 0); > > base = devm_ioremap_resource(dev, res); > > if (IS_ERR(base)) > > @@ -224,6 +236,11 @@ static struct clk_hw *qcom_cc_clk_hw_get(struct of_phandle_args *clkspec, > > return cc->rclks[idx] ? &cc->rclks[idx]->hw : NULL; > > } > > > > +static void qcom_cc_pm_runtime_disable(void *data) > > +{ > > + pm_runtime_disable(data); > > +} > > + > > int qcom_cc_really_probe(struct platform_device *pdev, > > const struct qcom_cc_desc *desc, struct regmap *regmap) > > { > > @@ -236,11 +253,28 @@ int qcom_cc_really_probe(struct platform_device *pdev, > > struct clk_regmap **rclks = desc->clks; > > size_t num_clk_hws = desc->num_clk_hws; > > struct clk_hw **clk_hws = desc->clk_hws; > > + bool use_pm = false; > > > > cc = devm_kzalloc(dev, sizeof(*cc), GFP_KERNEL); > > if (!cc) > > return -ENOMEM; > > > > + if (of_find_property(dev->of_node, "required-opps", NULL)) { > > + use_pm = true; > > + > > + pm_runtime_enable(dev); > > + ret = pm_runtime_get_sync(dev); > > + if (ret < 0) { > > + pm_runtime_put(dev); > > + pm_runtime_disable(dev); > > + return ret; > > + } > > + > > + ret = devm_add_action_or_reset(dev, qcom_cc_pm_runtime_disable, dev); > > + if (ret) > > + return ret; > > + } > > + > > reset = &cc->reset; > > reset->rcdev.of_node = dev->of_node; > > reset->rcdev.ops = &qcom_reset_ops; > > @@ -251,7 +285,7 @@ int qcom_cc_really_probe(struct platform_device *pdev, > > > > ret = devm_reset_controller_register(dev, &reset->rcdev); > > if (ret) > > - return ret; > > + goto err; > > > > if (desc->gdscs && desc->num_gdscs) { > > scd = devm_kzalloc(dev, sizeof(*scd), GFP_KERNEL); > > @@ -262,11 +296,11 @@ int qcom_cc_really_probe(struct platform_device *pdev, > > scd->num = desc->num_gdscs; > > ret = gdsc_register(scd, &reset->rcdev, regmap); > > if (ret) > > - return ret; > > + goto err; > > ret = devm_add_action_or_reset(dev, qcom_cc_gdsc_unregister, > > scd); > > if (ret) > > - return ret; > > + goto err; > > } > > > > cc->rclks = rclks; > > @@ -277,7 +311,7 @@ int qcom_cc_really_probe(struct platform_device *pdev, > > for (i = 0; i < num_clk_hws; i++) { > > ret = devm_clk_hw_register(dev, clk_hws[i]); > > if (ret) > > - return ret; > > + goto err; > > } > > > > for (i = 0; i < num_clks; i++) { > > @@ -286,14 +320,23 @@ int qcom_cc_really_probe(struct platform_device *pdev, > > > > ret = devm_clk_register_regmap(dev, rclks[i]); > > if (ret) > > - return ret; > > + goto err; > > } > > > > ret = devm_of_clk_add_hw_provider(dev, qcom_cc_clk_hw_get, cc); > > if (ret) > > - return ret; > > + goto err; > > + > > + if (use_pm) > > + pm_runtime_put(dev); > > > > return 0; > > + > > +err: > > + if (use_pm) > > + pm_runtime_put(dev); > > + > > + return ret; > > } > > EXPORT_SYMBOL_GPL(qcom_cc_really_probe); > > > > diff --git a/drivers/clk/qcom/gdsc.c b/drivers/clk/qcom/gdsc.c > > index 51ed640e527b..40c384bda4fc 100644 > > --- a/drivers/clk/qcom/gdsc.c > > +++ b/drivers/clk/qcom/gdsc.c > > @@ -11,6 +11,7 @@ > > #include > > #include > > #include > > +#include > > #include > > #include > > #include > > @@ -237,6 +238,8 @@ static int gdsc_enable(struct generic_pm_domain *domain) > > struct gdsc *sc = domain_to_gdsc(domain); > > int ret; > > > > + pm_runtime_get_sync(domain->dev.parent); > > + > > if (sc->pwrsts == PWRSTS_ON) > > return gdsc_deassert_reset(sc); > > > > @@ -326,6 +329,8 @@ static int gdsc_disable(struct generic_pm_domain *domain) > > if (sc->flags & CLAMP_IO) > > gdsc_assert_clamp_io(sc); > > > > + pm_runtime_put(domain->dev.parent); > > + > > return 0; > > } > > > > @@ -427,6 +432,7 @@ int gdsc_register(struct gdsc_desc *desc, > > continue; > > scs[i]->regmap = regmap; > > scs[i]->rcdev = rcdev; > > + scs[i]->pd.dev.parent = desc->dev; > > ret = gdsc_init(scs[i]); > > if (ret) > > return ret; > > -- > > 2.30.2 > > -- With best wishes Dmitry