linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeffrey Hugo <jeffrey.l.hugo@gmail.com>
To: Stephen Boyd <sboyd@kernel.org>
Cc: Michael Turquette <mturquette@baylibre.com>,
	Andy Gross <agross@kernel.org>,
	Bjorn Andersson <bjorn.andersson@linaro.org>,
	Marc Gonzalez <marc.w.gonzalez@free.fr>,
	MSM <linux-arm-msm@vger.kernel.org>,
	linux-clk@vger.kernel.org, lkml <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v4 1/2] clk: qcom: Add MSM8998 GPU Clock Controller (GPUCC) driver
Date: Mon, 28 Oct 2019 08:17:33 -0600	[thread overview]
Message-ID: <CAOCk7Npk1zdL2Y3nMxYCXeUj5deJKyoJSSbYCw1V+9ZNvxspdw@mail.gmail.com> (raw)
In-Reply-To: <20191027213659.23423205F4@mail.kernel.org>

On Sun, Oct 27, 2019 at 3:36 PM Stephen Boyd <sboyd@kernel.org> wrote:
>
> Quoting Jeffrey Hugo (2019-10-18 14:11:09)
> > On Thu, Oct 17, 2019 at 5:16 PM Jeffrey Hugo <jeffrey.l.hugo@gmail.com> wrote:
> > >
> > > On Thu, Oct 17, 2019 at 3:50 PM Stephen Boyd <sboyd@kernel.org> wrote:
> > > >
> > > > Quoting Jeffrey Hugo (2019-10-01 18:16:40)
> > > > > +static const struct freq_tbl ftbl_gfx3d_clk_src[] = {
> > > > > +       F(180000000, P_GPUPLL0_OUT_EVEN, 2, 0, 0),
> > > > > +       F(257000000, P_GPUPLL0_OUT_EVEN, 2, 0, 0),
> > > > > +       F(342000000, P_GPUPLL0_OUT_EVEN, 2, 0, 0),
> > > > > +       F(414000000, P_GPUPLL0_OUT_EVEN, 2, 0, 0),
> > > > > +       F(515000000, P_GPUPLL0_OUT_EVEN, 2, 0, 0),
> > > > > +       F(596000000, P_GPUPLL0_OUT_EVEN, 2, 0, 0),
> > > > > +       F(670000000, P_GPUPLL0_OUT_EVEN, 2, 0, 0),
> > > > > +       F(710000000, P_GPUPLL0_OUT_EVEN, 2, 0, 0),
> > > > > +       { }
> > > >
> > > > I guess this one doesn't do PLL ping pong? Instead we just reprogram the
> > > > PLL all the time? Can we have rcg2 clk ops that set the rate on the
> > > > parent to be exactly twice as much as the incoming frequency? I thought
> > > > we already had this support in the code. Indeed, it is part of
> > > > _freq_tbl_determine_rate() in clk-rcg.c, but not yet implemented in the
> > > > same function name in clk-rcg2.c! Can you implement it? That way we
> > > > don't need this long frequency table, just this weird one where it looks
> > > > like:
> > > >
> > > >         { .src = P_GPUPLL0_OUT_EVEN, .pre_div = 3 }
> > > >         { }
> > > >
> > > > And then some more logic in the rcg2 ops to allow this possibility for a
> > > > frequency table when CLK_SET_RATE_PARENT is set.
> > >
> > > Does not do PLL ping pong.  I'll look at extending the rcg2 ops like
> > > you describe.
> >
> > Am I missing something?  From what I can tell, what you describe is
> > not implemented.
> >
> > The only in-tree example of a freq_tbl with only a src and a pre_div
> > defined for rcg ops is for the tv_src clk in mmcc-msm8960 [1]
> > However, that uses a variant of rcg ops, clk_rcg_bypass_ops, not clk_rcg_ops.
> >
> > clk_rcg_bypass_ops has its own determine_rate implementation which
> > does not utilize _freq_tbl_determine_rate(), and can only do a 1:1
> > input rate to output ratio (we want a 1:2).
> >
> > _freq_tbl_determine_rate() in either rcg_ops or rcg2_ops won't work,
> > because they both use qcom_find_freq() which doesn't work when your
> > table doesn't specify any frequencies (f->freq is 0).
>
> Yes. You have to have some sort of frequency table to tell us what the
> source and predivider to use.
>
> > qcom_find_freq() won't iterate through the table, therefore f in
> > qcom_find_freq() won't be pointing at the end of the table (the null
> > entry), so when qcom_find_freq decrements f in the return, it actually
> > goes off the beginning of the array in an array out of bounds
> > violation.
>
> Ouch!
>
> >
> > Please advise how you would like to proceed.
>
> Please have a frequency table like
>
>  { .src = SOME_PLL, .div = 4 }
>
>
> >
> > I can still extend rcg2_ops to do what you want, but it won't be based
> > on what rcg_ops is doing.
>
> Why isn't rcg_ops doing it? The idea is to copy whatever is happening
> with this snippet in the _freq_tbl_determine_rate() in rcg.c to rcg2.c

That more or less exists in both cases, although rcg2_ops may need a
bit of additional work.  The problem is that in both cases, before
this snippet, we've already called qcom_find_freq(), and in both cases
(rcg_ops and rcg2_ops), f will be an invalid entry and we won't have
the proper pre_div value.

>
>         clk_flags = clk_hw_get_flags(hw);
>         p = clk_hw_get_parent_by_index(hw, index);
>         if (clk_flags & CLK_SET_RATE_PARENT) {
>                 rate = rate * f->pre_div;
>
> We have checked for CLK_SET_RATE_PARENT from the beginning. Maybe it was
> always broken! If the frequency table pointer can return us the pre div
> and source then we can do math to ask the parent PLL for something.
>
> >
> > I can spin a rcg2_ops variant to do what you want, with a custom
> > determine_rate, but it doesn't seem like I'll really be saving any
> > lines of code.  Whatever I eliminate by minimizing the gfx3d
> > freq_table I will surely be putting into clk-rcg2.c
> >
> > Or, I can just drop this idea and keep the freq_tbl as it is.  Seems
> > like just a one off scenario.
>
> Please make rcg2 clk ops "do the right thing" when the flag
> CLK_SET_RATE_PARENT is set and the frequency table is just a
> source/divider sort of thing. That way we don't have to have different
> clk ops or even put anything in the frequency table besides the source
> PLL we want to use and the predivider we want to configure.
>

Got it.  Will do.

  reply	other threads:[~2019-10-28 14:17 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-02  1:15 [PATCH v4 0/2] MSM8998 GPUCC Support Jeffrey Hugo
2019-10-02  1:16 ` [PATCH v4 1/2] clk: qcom: Add MSM8998 GPU Clock Controller (GPUCC) driver Jeffrey Hugo
2019-10-17 21:50   ` Stephen Boyd
2019-10-17 23:16     ` Jeffrey Hugo
2019-10-18 21:11       ` Jeffrey Hugo
2019-10-27 21:36         ` Stephen Boyd
2019-10-28 14:17           ` Jeffrey Hugo [this message]
2019-10-18  4:11   ` Taniya Das
2019-10-18 14:24     ` Jeffrey Hugo
2019-10-02  1:17 ` [PATCH v4 2/2] arm64: dts: qcom: msm8998: Add gpucc node Jeffrey Hugo

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=CAOCk7Npk1zdL2Y3nMxYCXeUj5deJKyoJSSbYCw1V+9ZNvxspdw@mail.gmail.com \
    --to=jeffrey.l.hugo@gmail.com \
    --cc=agross@kernel.org \
    --cc=bjorn.andersson@linaro.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marc.w.gonzalez@free.fr \
    --cc=mturquette@baylibre.com \
    --cc=sboyd@kernel.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).