linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Boyd <sboyd@kernel.org>
To: Michael Turquette <mturquette@baylibre.com>,
	Taniya Das <tdas@codeaurora.org>
Cc: Andy Gross <andy.gross@linaro.org>,
	David Brown <david.brown@linaro.org>,
	Rajendra Nayak <rnayak@codeaurora.org>,
	Amit Nischal <anischal@codeaurora.org>,
	linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org,
	linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4 0/2] clk: qcom: Add support for RCG to register for DFS
Date: Tue, 21 Aug 2018 08:30:57 -0700	[thread overview]
Message-ID: <153486545785.28926.5289007760649251969@swboyd.mtv.corp.google.com> (raw)
In-Reply-To: <2db97037-b5f1-9234-862c-fa483b8aeb62@codeaurora.org>

Quoting Taniya Das (2018-08-21 04:36:20)
> On 8/18/2018 11:31 PM, Taniya Das wrote:
> > Hello Stephen,
> > 
> > I will test these changes and get back.
> > 
> > On 8/18/2018 7:42 AM, Stephen Boyd wrote:
> >> Quoting Taniya Das (2018-08-10 18:53:54)
> >>>   [v4]
> >>>    * Add recalc_clk_ops to calculate the clock frequency reading the 
> >>> current
> >>>      perf state, also add CLK_GET_RATE_NOCACHE flag.
> >>>    * Cleanup 'goto' during mode check in 'clk_rcg2_calculate_freq'.
> >>>    * cleanup return from function 'com_cc_register_rcg_dfs'.
> >>
> >> I want to squash this in. I have only compile tested it. Let me know
> >> what you think.
> >>
> >> ----8<---
> >> diff --git a/drivers/clk/qcom/clk-rcg.h b/drivers/clk/qcom/clk-rcg.h
> >> index e6300e05d5df..e5eca8a1abe4 100644
> >> --- a/drivers/clk/qcom/clk-rcg.h
> >> +++ b/drivers/clk/qcom/clk-rcg.h
> >> @@ -163,6 +163,15 @@ extern const struct clk_ops clk_pixel_ops;
> >>   extern const struct clk_ops clk_gfx3d_ops;
> >>   extern const struct clk_ops clk_rcg2_shared_ops;
> >> +struct clk_rcg_dfs_data {
> >> +    struct clk_rcg2 *rcg;
> >> +    struct clk_init_data *init;
> >> +};
> >> +
> >> +#define DEFINE_RCG_DFS(r) \
> >> +    { .rcg = &r##_src, .init = &r##_init }
> >> +
> >>   extern int qcom_cc_register_rcg_dfs(struct regmap *regmap,
> >> -                 struct clk_rcg2 **rcgs, int num_clks);
> >> +                    const struct clk_rcg_dfs_data *rcgs,
> >> +                    size_t len);
> >>   #endif
> >> diff --git a/drivers/clk/qcom/clk-rcg2.c b/drivers/clk/qcom/clk-rcg2.c
> >> index 55a5b58cbb15..bbe2a1916296 100644
> >> --- a/drivers/clk/qcom/clk-rcg2.c
> >> +++ b/drivers/clk/qcom/clk-rcg2.c
> >> @@ -1051,48 +1051,24 @@ static unsigned long
> >>   clk_rcg2_dfs_recalc_rate(struct clk_hw *hw, unsigned long parent_rate)
> >>   {
> >>       struct clk_rcg2 *rcg = to_clk_rcg2(hw);
> >> -    u32 cfg, hid_div, m = 0, n = 0, mode = 0, mask, level;
> >> -    int num_parents, i;
> >> -    unsigned long prate;
> >> -
> >> -    regmap_read(rcg->clkr.regmap, rcg->cmd_rcgr +
> >> -                SE_CMD_DFSR_OFFSET, &cfg);
> >> -    level = (GENMASK(4, 1) & cfg) >> 1;
> >> -
> >> -    regmap_read(rcg->clkr.regmap, rcg->cmd_rcgr +
> >> -                SE_PERF_DFSR(level), &cfg);
> >> -    if (rcg->mnd_width) {
> >> -        mask = BIT(rcg->mnd_width) - 1;
> >> -        regmap_read(rcg->clkr.regmap, rcg->cmd_rcgr +
> >> -                SE_PERF_M_DFSR(level), &m);
> >> -        m &= mask;
> >> -        regmap_read(rcg->clkr.regmap, rcg->cmd_rcgr +
> >> -                SE_PERF_N_DFSR(level), &n);
> >> -        n =  ~n;
> >> -        n &= mask;
> >> -        n += m;
> >> -        mode = cfg & CFG_MODE_MASK;
> >> -        mode >>= CFG_MODE_SHIFT;
> >> -    }
> >> +    int ret;
> >> +    u32 level;
> >> -    mask = BIT(rcg->hid_width) - 1;
> >> -    hid_div = cfg >> CFG_SRC_DIV_SHIFT;
> >> -    hid_div &= mask;
> >> -    cfg &= CFG_SRC_SEL_MASK;
> >> -    cfg >>= CFG_SRC_SEL_SHIFT;
> >> +    regmap_read(rcg->clkr.regmap,
> >> +            rcg->cmd_rcgr + SE_CMD_DFSR_OFFSET, &level);
> >> +    level &= GENMASK(4, 1);
> >> +    level >>= 1;
> >> -    num_parents = clk_hw_get_num_parents(hw);
> >> -    for (i = 0; i < num_parents; i++) {
> >> -        if (cfg == rcg->parent_map[i].cfg) {
> >> -            prate = clk_hw_get_rate(
> >> -                clk_hw_get_parent_by_index(&rcg->clkr.hw, i));
> >> -            if (parent_rate != prate)
> >> -                parent_rate = prate;
> >> +    if (!rcg->freq_tbl) {
> >> +        ret = clk_rcg2_dfs_populate_freq_table(rcg);
> 
> This function would retrieve the parent_rate and if the parent_rate is 
> not ready then it would fail to boot up.
> 
> So we have to make sure the parents are registered before these RCGs. 
> That also was one reason for me to not populate the frequency table at 
> recalc.
> 
> We would need this patch to make this work.

Hmmmm. Ok. That won't work then. recalc_rate() better not try to
populate the frequency table then or it will not work. So I suppose it
needs to fallback to reading the registers and assuming the parent_rate
coming in is the actual frequency of it's parent until the frequency
table pointer is non-NULL. Would that work?

BTW, does DFS switch parents without software knowing about it? What
happens in that case? Does the QUP driver make sure that the new parent
of this RCG is properly enabled so that it can switch to it when needed?
I'm still trying to understand this whole design. Who takes care of the
voltage requirements in this case? The QUP driver as well?


  reply	other threads:[~2018-08-21 15:31 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-11  1:53 [PATCH v4 0/2] clk: qcom: Add support for RCG to register for DFS Taniya Das
2018-08-11  1:53 ` [PATCH v4 1/2] " Taniya Das
2018-08-11  1:53 ` [PATCH v4 2/2] clk: qcom: gcc: Register QUPv3 RCGs for DFS on SDM845 Taniya Das
2018-08-18  2:12 ` [PATCH v4 0/2] clk: qcom: Add support for RCG to register for DFS Stephen Boyd
2018-08-18 18:01   ` Taniya Das
2018-08-21 11:36     ` Taniya Das
2018-08-21 15:30       ` Stephen Boyd [this message]
2018-08-22 10:28         ` Taniya Das
2018-08-23 18:25           ` Stephen Boyd
2018-08-27 21:04             ` Stephen Boyd
2018-08-28  9:06               ` Taniya Das

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=153486545785.28926.5289007760649251969@swboyd.mtv.corp.google.com \
    --to=sboyd@kernel.org \
    --cc=andy.gross@linaro.org \
    --cc=anischal@codeaurora.org \
    --cc=david.brown@linaro.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-soc@vger.kernel.org \
    --cc=mturquette@baylibre.com \
    --cc=rnayak@codeaurora.org \
    --cc=tdas@codeaurora.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).