public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: James Hogan <james.hogan@imgtec.com>
To: Doug Anderson <dianders@chromium.org>
Cc: Saravana Kannan <skannan@codeaurora.org>,
	Mike Turquette <mturquette@linaro.org>,
	"linux-arm-kernel@lists.infradead.org" 
	<linux-arm-kernel@lists.infradead.org>,
	Stephen Boyd <sboyd@codeaurora.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v4 5/5] clk: clk-mux: implement remuxing on set_rate
Date: Thu, 13 Jun 2013 16:18:57 +0100	[thread overview]
Message-ID: <51B9E2E1.9020203@imgtec.com> (raw)
In-Reply-To: <CAD=FV=VFqTzqLc3+UOHD21NiTqtu84DzwYD1Qag-RxiD0qcFDA@mail.gmail.com>

On 12/06/13 02:01, Doug Anderson wrote:
> Hi,
> 
> Mike pointed me at this series since I'm running into parenting
> problems at the moment as well...
> 
> On Mon, May 20, 2013 at 9:44 PM, Saravana Kannan <skannan@codeaurora.org> wrote:
>> While writing a similar code for our internal tree, I quickly came to the
>> realization that, "all parents are equal, but some are more equal than
>> others". The simplest example is a clock tree like this:
>>
>> Source -> Divider -> Mux
>> Source -> Mux
>>
>> A rate of Y can be achieved for Mux by either running Source at Y and
>> picking that input or running Source at Y * 2 and Divider set to div-2 and
>> picking the Divider input.
>>
>> The solution seems to be a priority list of parents. I'm sure there would be
>> other reason (jitter, clock quality, etc) for a mux to pick one parent vs.
>> another when both of them can provide the required rate.
>>
>> I think this loop should loop over parents based on their priority order.
>> So, parents should become a struct of { clk, index } and have the parents
>> listed in the order of priority. Well, at least in that long run that would
>> be better to avoid messing up parent/index values. But for now, you could
>> just have a priority array of index or parents.
>>
>> It might not fit 100% of the cases where two parents can provide the same
>> rate, but it should fit most use cases.
> 
> I'm slightly worried about similar problems, but I don't have a really
> great solution.
> 
> In my case I'm working on exynos5 hardware which has a bunch of PLLs
> and a crazy number of muxing options.  Many of the muxing options are
> not really meant to be used but seem to have been added to the SoC as
> a "backup plan" of some sort.  :-/  Most of the PLLs are intended to
> be used for one purpose and one purpose only though muxing options
> allow them to be used all over the place.
> 
> For instance if I look at my current bootup of exynos5250-snow, I see:
> 
> fout_apll/clk_rate:1700000000
> fout_bpll/clk_rate:800000000
> fout_cpll/clk_rate:333000000
> fout_epll/clk_rate:45158401
> fout_gpll/clk_rate:533000000
> fout_mpll/clk_rate:1600000000
> 
> * APLL is intended to be the parent of the 2 ARM cores and changes due
> to cpu load
> * EPLL is intended to be the parent for audio and changes dpending on
> audio playback rates.
> * GPLL is intended to be the parent of the GPU and changes due to gpu load
> * VPLL is intended to be the parent for video related things and could
> change depending on the LCD.
> * MPLL doesn't change a lot and is intended to be the parent for most things.
> * In some systems BPLL can be used for memory or GPU
> 
> My main concern here is the CCF will end up deciding at some point
> that it should reparent some clock onto a PLL that is going to change
> a whole lot.  Maybe the user will plug in an SD card that requests a
> frequency of 52MHz and at the moment we'll be running EPLL at 104 MHz
> so it will be a perfect match!  ...but then the user wants to play
> audio at a different rate.  The audio code assumes that it can mess
> with its clock and we've got code setup to call CLK_SET_RATE_PARENT
> all the way up to EPLL.  That will really mess with the SD card.
> Really we'd rather just have the SD card clock always parented on the
> stable MPLL and it's OK if 52MHz gets rounded down to 50MHz.

One possible approach to handling this is by making drivers register
clock rate change notifications, which can reject a clock rate change,
however I believe at the moment this would simply make the clock rate
change fail rather than finding an alternative change which isn't
rejected, so it may have limited use at the moment.

> Of course, on another board maybe they don't have an audio codec and
> aren't using epll for audio and have realized that EPLL would be a
> perfect way to get their SD card to run 4% faster.  It ought to work.
> 
> 
> I guess to summarize the above:
> 
> * It seems like much of the muxing on exynos5250 is just too
> complicated to leave it to an simple automated algorithm.
> * It seems like we can't make muxing decisions on the SoC level.
> * Your automatic muxing patches don't hurt me and could be useful for
> _some_ of the muxing options, just not the top PLL ones.
> 
> ...but the only place that leaves me for my muxing needs is the device
> tree.  ...and as Mike pointed out on IRC the device tree should
> describe hardware, not policy.  Ick.

Yes, we have a similar situation with the TZ1090, except it may be worse
as some of the clocks/devices may be driven by different non-Linux cores
or hardware threads (e.g. the WiFi/DAB firmware drives the I2C/SPI bus
the tuner chip is connected to, and related clocks), in which case Linux
literally has no knowledge of whether the hardware is already in use
aside from some form of application-specific configuration (currently
munged into device tree due to the lack of an alternative).

Cheers
James


  parent reply	other threads:[~2013-06-13 15:19 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-20 13:28 [PATCH v4 0/5] clk: implement remuxing during set_rate James Hogan
2013-05-20 13:28 ` [PATCH v4 1/5] clk: abstract parent cache James Hogan
2013-05-20 13:28 ` [PATCH v4 2/5] clk: move some parent related functions upwards James Hogan
2013-05-20 21:16   ` Stephen Boyd
2013-05-20 13:28 ` [PATCH v4 3/5] clk: add support for clock reparent on set_rate James Hogan
2013-05-20 21:17   ` Stephen Boyd
2013-06-13 14:31     ` James Hogan
2013-05-21  5:10   ` Saravana Kannan
2013-05-22 10:13     ` James Hogan
2013-05-20 13:28 ` [PATCH v4 4/5] clk: add CLK_SET_RATE_NO_REPARENT flag James Hogan
2013-05-20 20:44   ` Stephen Warren
2013-05-22 15:52   ` Maxime Ripard
2013-05-20 13:28 ` [PATCH v4 5/5] clk: clk-mux: implement remuxing on set_rate James Hogan
2013-05-21  4:44   ` Saravana Kannan
2013-06-12  1:01     ` Doug Anderson
2013-06-12 17:45       ` Mike Turquette
2013-06-12 17:55         ` Doug Anderson
2013-06-12 18:07           ` Mike Turquette
2013-06-13 15:18       ` James Hogan [this message]
2013-06-13 15:02     ` James Hogan
2013-06-06  1:39 ` [PATCH v4 0/5] clk: implement remuxing during set_rate Haojian Zhuang
2013-06-13  1:35 ` Stephen Boyd

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=51B9E2E1.9020203@imgtec.com \
    --to=james.hogan@imgtec.com \
    --cc=dianders@chromium.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mturquette@linaro.org \
    --cc=sboyd@codeaurora.org \
    --cc=skannan@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