All of lore.kernel.org
 help / color / mirror / Atom feed
From: torbenh@gmx.de (torbenh)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH RFC] clk: add support for automatic parent handling
Date: Thu, 5 May 2011 10:35:31 +0200	[thread overview]
Message-ID: <20110505083531.GC3528@siel.b> (raw)
In-Reply-To: <BANLkTime=g3qmWsN3X4mMe0_VBO0SZc0qg@mail.gmail.com>

On Mon, May 02, 2011 at 11:35:25PM -0700, Colin Cross wrote:
> On Sat, Apr 30, 2011 at 7:27 AM, torbenh <torbenh@gmx.de> wrote:
> > On Fri, Apr 29, 2011 at 02:26:13PM +0100, Russell King - ARM Linux wrote:
> >> On Fri, Apr 29, 2011 at 02:13:06PM +0200, Thomas Gleixner wrote:
> >> > This are all well defined semantical problems and should be solved in
> >> > common code rather than having different buggy implementations in each
> >> > SoC clock "framework".
> >>
> >> Why are you associating functional elements in drivers/clk with the
> >> SoC clock framework?
> >
> > i think i pretty much understand what thomas is after. but i have
> > problems understanding, what you want here.
> >
> > until this point, it looks like you only want the driver/clk to
> > model the clock endpoints inside the devices. A device itself shouldnt
> > be caring for clock parents or anything. its only concern is that a
> > clock pin is fed with the right frequency, or off...
> >
> >>
> >> I think that's the root cause of this misunderstanding, and until you
> >> start realising that these building blocks are not part of the SoC
> >> implementation, we're going to continue arguing about this.
> >
> > what you say now, pretty much sounds like what thomas wants.
> > these building blocks would be objects derived from the clock baseclass,
> > which thomas is trying to define. he doesnt seem to be concerned about
> > the second more special layer yet.
> >
> > i am quite puzzled, what exactly your fighting over :S
> 
> Thomas wants a core framework that handles the clock tree, with each
> clock being the implementation of just the clock.  Russell thinks this
> is impossible, and wants to stop at implementing building blocks for
> the standard clock types, and let each SoC put them into a tree.

Thomas wants the clocks to reference a clock_chip.
(much like genirq... you have irq_desc and and irq_chip)
so there is still one component which has the "big picture"
and can implement crazy platform rules, if necessary.
> 
> I don't think anybody can argue that a shared clock tree framework, if
> it was possible to do well, would be a benefit.  But there are a few
> problems that make abstracting the differences between SoCs very hard
> at that level.
> 
> After implementing the Tegra clock tree at least 10 times to solve
> different problems, there are two very hard problems to solve.
> 
> First is locking.  Per-clock locking is hard because it requires
> choosing up front which way locking will go, usually locking the
> child, then locking the parent, then enabling the parent, and enabling
> the child.  Any operation flow that requires traversing the tree from
> the parent to the child, for example changing the rate of the parent,
> causes lock inversion.  Global locking is easy, but can be wasteful on
> platforms that have some very slow clocks (think external i2c clocks),
> and some very fast clocks (internal register writes).  This is
> mitigated by the separation of clk_prepare and clk_enable locking -
> clk_enable can never sleep, so it can't be blocked for long.  Locking
> at the root node of the tree would be nice, but most SoCs don't have a
> root node - they have a fast root clock and a slow root clock, and can
> switch the all or most of clock tree over to the slow clock in some
> modes.

yeah. one of the big reasons, why the generic code should do the
locking. 
> 
> The second problem is rate changing.  Different platforms require
> wildly different strategies for changing clock rates.  On Tegra,
> clk_set_rate will never change the parent, because we can generally
> set up the parent clocks to the correct frequencies for all the
> devices, and then device drivers can change their dividers to get the
> rate they need.  The few cases where the parent needs to change
> (cpufreq and display pclk), the driver manually calls clk_set_parent.
> On other platforms, it is common to need to change the parent to get
> the necessary rate.
> 
> Automatically selecting parents in a generic way is impossible.  If
> one DEV1 calls clk_set_rate and clk_enable, and the core framework
> responds by setting pll A to frequency X, and setting the parent of
> DEV1 to A, what happens when DEV2 calls clk_set_rate to a frequency
> that can only be satisfied by setting pll A to frequency Y?  DEV1
> can't be switched to another pll, because it is already enabled, and
> some platforms can't support glitchlessly changing a mux, even if the
> frequency doesn't change.

in the case where we cant change a parent clock, the generic code could
just fail to set_rate. then delegate the problem to the clk_chip which
can resolve the problem.
the locking would be tricky, but it is solvable.
but its still somthing we only want implemented once.

so how does changing a mux, which glitches, work now ?
do the child clocked devices need to be turned off/notified when this
happens ?

> 
> I still think a common implementation of the clock tree framework
> would be useful, even if not all platforms can use it.  Allow the
> platforms that can to use it, providing only clock data, and maybe a
> few clock implementations if the building blocks are not sufficient,
> and allow those that can't to implement their own versions of the
> clk_* functions on top of the clock building blocks.  Tegra already
> has a fairly generic implementation of a clock tree in
> arch/arm/mach-tegra/clock.c, moving it to the common clk struct and
> sharing it with other platforms wouldn't be any extra code, even if no
> other platforms could use it.  And I bet at least OMAP could use it,
> from what I've seen.
> 
> Per-tree locking is a solvable problem, as long as a tree was
> considered as an ordered graph - two root nodes that feed into the
> same clocks would be considered part of the same tree.  The core
> framework could look at all possible parents of a clock to determine
> what clock trees were truly independent, which would result in a
> single global lock on most platforms, but multiple locks on platforms
> that really had independent clock trees.  Dynamically added clocks
> would cause problems with this solution.
> 
> I think automatic clock parent and rate setting would need to be
> delegated to a platform-specific layer, and I'm not sure how.  Maybe
> allow platforms to override the set_rate ops in the clock tree
> building blocks, or a new op that can determine the new tree
> structure, and call the old set_rate op to set the registers.

yeah, getting these constraints solved automatically is pretty
expensive. some heuristics are probably indicated here.

-- 
torben Hohn

  reply	other threads:[~2011-05-05  8:35 UTC|newest]

Thread overview: 165+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-15 19:08 [RFC] sanitizing crazy clock data files Sascha Hauer
2011-04-15 19:08 ` [PATCH 01/10] Add a common struct clk Sascha Hauer
2011-04-21 19:48   ` Thomas Gleixner
2011-04-22  0:28     ` Richard Zhao
2011-04-22  9:23       ` Thomas Gleixner
2011-04-23 14:08         ` Richard Zhao
2011-04-23 15:30           ` Thomas Gleixner
2011-04-24  2:54             ` Richard Zhao
2011-04-24  7:20             ` Linus Walleij
2011-04-24  9:55               ` Richard Zhao
2011-04-22  4:57     ` Saravana Kannan
2011-04-22  9:13       ` Thomas Gleixner
2011-04-29 10:09     ` Russell King - ARM Linux
2011-04-29 10:45       ` Thomas Gleixner
2011-04-29 10:58         ` Tony Lindgren
2011-04-29 11:01         ` Russell King - ARM Linux
2011-04-30 18:30           ` Pavel Machek
2011-04-30  8:06   ` Linus Walleij
2011-04-30  9:01     ` Russell King - ARM Linux
2011-04-30 16:30       ` Linus Walleij
2011-05-01 20:33   ` Rob Herring
2011-05-02  1:09     ` Jeremy Kerr
2011-05-02  3:09       ` Rob Herring
2011-05-02  3:40         ` Jeremy Kerr
2011-05-02 16:30           ` Rob Herring
2011-05-02 22:36             ` Russell King - ARM Linux
2011-05-03  0:22               ` Saravana Kannan
2011-05-04  6:40                 ` Sascha Hauer
2011-05-04 18:33                   ` Saravana Kannan
2011-05-04 23:35               ` Paul Walmsley
2011-05-10 20:06                 ` Saravana Kannan
2011-05-02 16:55           ` David Brown
2011-05-02 17:31             ` Stephen Boyd
2011-04-15 19:08 ` [PATCH 02/10] clk: Generic support for fixed-rate clocks Sascha Hauer
2011-04-15 19:08 ` [PATCH 03/10] clk: Make NULL a valid clock again Sascha Hauer
2011-04-19  0:53   ` Jeremy Kerr
2011-04-19  6:25     ` Sascha Hauer
2011-04-20 12:53   ` Uwe Kleine-König
2011-04-15 19:08 ` [PATCH 04/10] clk: implement parent pass through functions Sascha Hauer
2011-04-18  9:25   ` Uwe Kleine-König
2011-04-18  9:48     ` Sascha Hauer
2011-04-19 17:20   ` Stephen Boyd
2011-04-19 17:53     ` Sascha Hauer
2011-04-19 19:09       ` Uwe Kleine-König
2011-04-19 20:58         ` Sascha Hauer
2011-04-19 21:54         ` Thomas Gleixner
2011-04-20  7:16           ` Uwe Kleine-König
2011-04-20  8:34             ` Thomas Gleixner
2011-04-20 14:07           ` [PATCH RFC] clk: add support for automatic parent handling Uwe Kleine-König
2011-04-20 16:16             ` Thomas Gleixner
2011-04-20 18:59               ` Uwe Kleine-König
2011-04-20 19:52                 ` Thomas Gleixner
2011-04-21  6:58                   ` Saravana Kannan
2011-04-21  6:58                     ` Saravana Kannan
2011-04-21  6:58                     ` Saravana Kannan
2011-04-21 10:33                     ` Thomas Gleixner
2011-04-21 10:33                       ` Thomas Gleixner
2011-04-21 10:33                       ` Thomas Gleixner
2011-04-21 19:22                       ` torbenh
2011-04-21 19:22                         ` torbenh
2011-04-21 19:22                         ` torbenh
2011-04-23 23:26                       ` Benjamin Herrenschmidt
2011-04-23 23:26                         ` Benjamin Herrenschmidt
2011-04-23 23:26                         ` Benjamin Herrenschmidt
2011-04-21  7:22                   ` Uwe Kleine-König
2011-04-21  9:12                     ` Thomas Gleixner
2011-04-21 10:31                       ` Mark Brown
2011-04-21 11:42                         ` Tony Lindgren
2011-04-21 14:52                           ` Thomas Gleixner
2011-04-22  7:09                             ` Tony Lindgren
2011-04-22  8:22                               ` Thomas Gleixner
2011-04-21 14:29                         ` Thomas Gleixner
2011-04-29 10:37                       ` Russell King - ARM Linux
2011-04-29 11:01                         ` Thomas Gleixner
2011-04-29 11:06                           ` Russell King - ARM Linux
2011-04-29 12:13                             ` Thomas Gleixner
2011-04-29 13:26                               ` Russell King - ARM Linux
2011-04-29 15:31                                 ` Thomas Gleixner
2011-04-29 22:07                                   ` Russell King - ARM Linux
2011-04-29 22:16                                     ` Thomas Gleixner
2011-04-29 22:19                                       ` Russell King - ARM Linux
2011-04-29 22:47                                         ` Thomas Gleixner
2011-04-30 14:27                                 ` torbenh
2011-05-03  6:35                                   ` Colin Cross
2011-05-05  8:35                                     ` torbenh [this message]
2011-05-03  2:44                                 ` Saravana Kannan
2011-05-03  2:46                                   ` Saravana Kannan
2011-04-21 10:13                     ` Mark Brown
2011-04-21 11:39                       ` Tony Lindgren
2011-04-21  7:42                   ` Sascha Hauer
2011-04-21  9:21                     ` Thomas Gleixner
2011-04-21 11:50                       ` Mark Brown
2011-04-21 12:20                         ` Thomas Gleixner
2011-04-21 12:35                           ` Mark Brown
2011-04-25  2:03                             ` Richard Zhao
2011-04-25 10:57                               ` Mark Brown
2011-04-25 14:41                                 ` Richard Zhao
2011-04-25 14:44                                   ` Mark Brown
2011-04-29 10:49                           ` Russell King - ARM Linux
2011-04-29 11:11                             ` Thomas Gleixner
2011-04-29 11:38                               ` Russell King - ARM Linux
2011-04-29 12:19                                 ` Thomas Gleixner
2011-04-29 13:27                                   ` Russell King - ARM Linux
2011-04-29 15:47                                     ` Thomas Gleixner
2011-04-21 12:06                       ` Sascha Hauer
2011-04-21 15:38                         ` Thomas Gleixner
2011-04-22  0:23                           ` Colin Cross
2011-04-22  9:51                             ` Thomas Gleixner
2011-04-22 16:14                               ` Thomas Gleixner
2011-04-22 16:39                               ` Colin Cross
2011-04-22 16:57                                 ` Thomas Gleixner
2011-04-22 22:26                                   ` Saravana Kannan
2011-04-22 22:55                                     ` Thomas Gleixner
2011-04-23  0:48                                       ` Saravana Kannan
2011-04-23 23:34                                         ` Benjamin Herrenschmidt
2011-04-22  4:54                           ` Saravana Kannan
2011-04-22  9:06                             ` Thomas Gleixner
2011-04-29 10:30                   ` Russell King - ARM Linux
2011-04-29 10:51                     ` Thomas Gleixner
2011-04-29 10:56                       ` Russell King - ARM Linux
2011-04-24  9:45             ` Richard Zhao
2011-04-24 20:14               ` Uwe Kleine-König
2011-04-29 10:20       ` [PATCH 04/10] clk: implement parent pass through functions Russell King - ARM Linux
2011-04-15 19:08 ` [PATCH 05/10] clk: Add support for simple dividers Sascha Hauer
2011-04-18  9:49   ` Uwe Kleine-König
2011-04-18 10:07     ` Sascha Hauer
2011-04-19  2:45       ` Saravana Kannan
2011-04-19  7:32         ` Uwe Kleine-König
2011-04-19  8:55           ` Saravana Kannan
2011-04-19  9:31             ` Sascha Hauer
2011-04-19 22:28               ` Saravana Kannan
2011-04-20  6:36                 ` Sascha Hauer
2011-04-20 21:45                   ` Saravana Kannan
2011-04-21  7:39                     ` Uwe Kleine-König
2011-04-28 15:14         ` Russell King - ARM Linux
2011-05-03  3:37           ` Saravana Kannan
2011-05-03  7:12             ` Uwe Kleine-König
2011-04-28 15:22     ` Russell King - ARM Linux
2011-05-02  7:58       ` Sascha Hauer
2011-04-18 22:40   ` Stephen Boyd
2011-04-19  0:32     ` Jeremy Kerr
2011-04-19  5:41       ` Stephen Boyd
2011-04-24 13:48   ` Richard Zhao
2011-04-25 18:51     ` Sascha Hauer
2011-04-26  1:54       ` Richard Zhao
2011-04-15 19:08 ` [PATCH 06/10] clk: Add support for a generic clock multiplexer Sascha Hauer
2011-04-18 13:15   ` Uwe Kleine-König
2011-04-18 13:33     ` Sascha Hauer
2011-04-18 13:54       ` Uwe Kleine-König
2011-04-18 17:54       ` Stephen Boyd
2011-04-18 18:34         ` Russell King - ARM Linux
2011-04-18 18:41           ` Russell King - ARM Linux
2011-04-18 18:46             ` Stephen Boyd
2011-04-15 19:08 ` [PATCH 07/10] ARM i.MX: Support for clock building blocks Sascha Hauer
2011-04-15 19:08 ` [PATCH 08/10] ARM i.MX: Add generic support for pllv2 Sascha Hauer
2011-04-15 19:08 ` [PATCH 09/10] ARM i.MX51/53: reimplement clock support Sascha Hauer
2011-04-15 19:08 ` [PATCH 10/10] ARM i.MX51/53: remove old " Sascha Hauer
2011-04-15 19:36 ` [RFC] sanitizing crazy clock data files Russell King - ARM Linux
2011-04-15 20:12   ` Sascha Hauer
2011-04-15 20:25     ` Russell King - ARM Linux
2011-04-15 20:28       ` Russell King - ARM Linux
2011-04-15 20:49         ` Uwe Kleine-König
2011-04-18  4:07     ` Shawn Guo
2011-04-15 20:45 ` Uwe Kleine-König
2011-04-18  7:42 ` Sascha Hauer

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=20110505083531.GC3528@siel.b \
    --to=torbenh@gmx.de \
    --cc=linux-arm-kernel@lists.infradead.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.