linux-omap.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Amit Kucheria <amit.kucheria-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
To: "Turquette, Mike" <mturquette-l0cyMroinI0@public.gmane.org>,
	Thomas Gleixner <tglx-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
Cc: andrew-g2DYL2Zd6BY@public.gmane.org,
	linaro-dev-cunTk1MwBs8s++Sfvej+rw@public.gmane.org,
	eric.miao-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org,
	jeremy.kerr-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org,
	linux-lFZ/pmaqli7XmaaqVzeoHQ@public.gmane.org,
	sboyd-jfJNa2p1gH1BDgjK7y7TUQ@public.gmane.org,
	magnus.damm-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
	arnd.bergmann-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org,
	patches-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org,
	linux-omap-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	paul-DWxLp4Yu+b8AvxtiuMwx3w@public.gmane.org,
	linus.walleij-0IS4wlFg1OjSUeElwK9/Pw@public.gmane.org,
	broonie-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Colin Cross <ccross-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>,
	Richard Zhao
	<richard.zhao-KZfg59tc24xl57MIdRCFDg@public.gmane.org>,
	skannan-jfJNa2p1gH1BDgjK7y7TUQ@public.gmane.org
Subject: Re: [PATCH v4 3/6] clk: introduce the common clock framework
Date: Thu, 12 Jan 2012 15:13:01 +0200	[thread overview]
Message-ID: <20120112131301.GA3478@matterhorn1> (raw)
In-Reply-To: <CAJOA=zPgwiOSoyZK1SpzZVZfTOmwruTR=WO+gRdVZrZVzNuPSA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>

On 12 Jan 04, Turquette, Mike wrote:
> On Wed, Jan 4, 2012 at 6:11 PM, Rob Herring <robherring2@gmail.com> wrote:
> > On 01/04/2012 07:01 PM, Turquette, Mike wrote:
> >> On Wed, Jan 4, 2012 at 6:32 AM, Rob Herring <robherring2@gmail.com> wrote:
> >>> On 01/03/2012 08:15 PM, Richard Zhao wrote:
> >>>> On Fri, Dec 16, 2011 at 04:45:48PM -0800, Turquette, Mike wrote:
> >>>>> On Wed, Dec 14, 2011 at 5:18 AM, Thomas Gleixner <tglx@linutronix.de> wrote:
> >>>>>> On Tue, 13 Dec 2011, Mike Turquette wrote:
> >>>
> >>> snip
> >>>
> >>>>>>> +/**
> >>>>>>> + * clk_init - initialize the data structures in a struct clk
> >>>>>>> + * @dev: device initializing this clk, placeholder for now
> >>>>>>> + * @clk: clk being initialized
> >>>>>>> + *
> >>>>>>> + * Initializes the lists in struct clk, queries the hardware for the
> >>>>>>> + * parent and rate and sets them both.  Adds the clk to the sysfs tree
> >>>>>>> + * topology.
> >>>>>>> + *
> >>>>>>> + * Caller must populate clk->name and clk->flags before calling
> >>>>>>
> >>>>>> I'm not too happy about this construct. That leaves struct clk and its
> >>>>>> members exposed to the world instead of making it a real opaque
> >>>>>> cookie. I know from my own painful experience, that this will lead to
> >>>>>> random fiddling in that data structure in drivers and arch code just
> >>>>>> because the core code has a shortcoming.
> >>>>>>
> >>>>>> Why can't we make struct clk a real cookie and confine the data
> >>>>>> structure to the core code ?
> >>>>>>
> >>>>>> That would change the init call to something like:
> >>>>>>
> >>>>>> struct clk *clk_init(struct device *dev, const struct clk_hw *hw,
> >>>>>>                     struct clk *parent)
> >>>>>>
> >>>>>> And have:
> >>>>>> struct clk_hw {
> >>>>>>       struct clk_hw_ops *ops;
> >>>>>>       const char        *name;
> >>>>>>       unsigned long     flags;
> >>>>>> };
> >>>>>>
> >>>>>> Implementers can do:
> >>>>>> struct my_clk_hw {
> >>>>>>       struct clk_hw    hw;
> >>>>>>       mydata;
> >>>>>> };
> >>>>>>
> >>>>>> And then change the clk ops callbacks to take struct clk_hw * as an
> >>>>>> argument.
> >>>> We have to define static clocks before we adopt DT binding.
> >>>> If clk is opaque and allocate memory in clk core, it'll make hard
> >>>> to define static clocks. And register/init will pass a long parameter
> >>>> list.
> >>>
> >>> DT is not a prerequisite for having dynamically created clocks. You can
> >>> make clock init dynamic without DT.
> >>
> >> Agreed.
> >>
> >>> What data goes in struct clk vs. struct clk_hw could change over time.
> >>> So perhaps we can start with some data in clk_hw and plan to move it to
> >>> struct clk later. Even if almost everything ends up in clk_hw initially,
> >>> at least the structure is in place to have common, core-only data
> >>> separate from platform data.
> >>
> >> What is the point of this?
> >
> > To have a way forward. It would be nice to have a clk infrastructure
> > before I retire...
> 
> Haha, agreed.
> 
> >
> >> The original clk_hw was defined simply as:
> >>
> >> struct clk_hw {
> >>         struct clk *clk;
> >> };
> >>
> >> It's only purpose in life was as a handle for navigation between the
> >> opaque struct clk and the hardware-specific struct my_clk_hw.  struct
> >> clk_hw is defined in clk.h and everyone can see it.  If we're suddenly
> >> OK putting clk data in this structure then why bother with an opaque
> >> struct clk at all?
> >>
> >>> What is the actual data you need to be static and accessible to the
> >>> platform code? A ptr to parent clk is the main thing I've seen for
> >>> static initialization. So make the parent ptr be struct clk_hw* and
> >>> allow the platforms to access.
> >>
> >> To answer your question on what data we're trying to expose: platform
> >> code commonly needs the parent pointer and the clk rate (and by
> >> extension, the rate of the parent).  For debug/error prints it is also
> >> nice to have the clk name.  Generic clk flags are also conceivably
> >> something that platform code might want.
> >
> > I agree with the need to have the parent and flags from a static init
> > perspective. There's not really a good reason the others can't be
> > accessed thru accessors though.
> >
> >> I'd like to spin the question around: if we're OK exposing some stuff
> >> (in your example above, the parent pointer), then what clk data are
> >> you trying to hide?
> >
> > Well, everything from drivers which the current clk implementations do
> > hide. Catching abuse in with drivers coming in from all different trees
> > and lists will be impossible.
> >
> > For platform code it is more fuzzy. I don't think platform code should
> > be allowed to muck with prepare/enable counts for example.
> 
> So there is a clear dichotomy: drivers shouldn't be exposed to any of
> it and platform code should be exposed to some of it.
> 
> How about a drivers/clk/clk-private.h which will define struct clk and
> must only be included by clk drivers in drivers/clk/*?
> 
> This establishes a bright line between those things which are allowed
> to know the details of struct clk and those that are not: namely that
> clk drivers in drivers/clk/ may use '#include "clk-private.h"'.
> Obviously struct clk is opaque to the rest of the kernel (in the same
> way it has been prior to the common clk patches) and there is no need
> for struct clk_hw anymore.  Also helper functions are no longer needed
> for clock driver code, which I think *is* a manageable set of code to
> review.  Also clk drivers must live in drivers/clk/ for this to work
> (without a big ugly path in someone's #include directive somewhere).
> 
> Thoughts?
> 
> Regards,
> Mike

Thomas? 

We're stuck on this fundamental point for a while now. And v5 of the
patchset doesn't make much sense without resolving it.

/Amit

_______________________________________________
linaro-dev mailing list
linaro-dev@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/linaro-dev

  parent reply	other threads:[~2012-01-12 13:13 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-14  3:53 [PATCH v4 0/6] common clk framework Mike Turquette
     [not found] ` <1323834838-2206-1-git-send-email-mturquette-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2011-12-14  3:53   ` [PATCH v4 1/6] clk: Kconfig: add entry for HAVE_CLK_PREPARE Mike Turquette
2011-12-14  3:53   ` [PATCH v4 2/6] Documentation: common clk API Mike Turquette
2012-01-05 14:31     ` Amit Kucheria
2012-01-05 20:04       ` Turquette, Mike
2011-12-14  3:53   ` [PATCH v4 3/6] clk: introduce the common clock framework Mike Turquette
2011-12-14  4:52     ` Ryan Mallon
     [not found]       ` <4EE82B76.2000204-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2011-12-14 19:07         ` Turquette, Mike
2011-12-14  7:50     ` Richard Zhao
2011-12-14 13:18     ` Thomas Gleixner
2011-12-17  0:45       ` Turquette, Mike
2011-12-17 11:04         ` Russell King - ARM Linux
2012-01-14  4:18           ` Saravana Kannan
     [not found]             ` <4F11021A.8070407-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2012-01-14  4:39               ` Turquette, Mike
2012-01-14  4:51                 ` Saravana Kannan
     [not found]         ` <CAJOA=zO=gM2r4pCVo+orLqE9Q1SSw4h5nXsAHo-e_SHZAfvKDA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-01-04  2:15           ` Richard Zhao
2012-01-04 14:32             ` Rob Herring
     [not found]               ` <4F0462FF.1000308-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2012-01-05  1:01                 ` Turquette, Mike
2012-01-05  1:23                   ` Richard Zhao
2012-01-05  2:11                   ` Rob Herring
2012-01-05  4:07                     ` Turquette, Mike
     [not found]                       ` <CAJOA=zPgwiOSoyZK1SpzZVZfTOmwruTR=WO+gRdVZrZVzNuPSA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-01-12 13:13                         ` Amit Kucheria [this message]
2012-01-13  0:04                       ` Saravana Kannan
2012-01-13  0:48                         ` Rob Herring
2012-01-13  1:19                           ` Saravana Kannan
     [not found]                         ` <4F0F7507.3080501-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2012-01-13 14:53                           ` Shawn Guo
2011-12-14  3:53   ` [PATCH v4 4/6] clk: introduce rate change notifiers Mike Turquette
2011-12-14  3:53   ` [PATCH v4 5/6] clk: basic gateable and fixed-rate clks Mike Turquette
2011-12-14  5:15     ` Ryan Mallon
     [not found]       ` <4EE830D5.5070305-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2011-12-17  0:57         ` Turquette, Mike
2011-12-14  3:53   ` [PATCH v4 6/6] clk: export the clk tree topology to debugfs Mike Turquette
2011-12-14  4:02 ` [PATCH v4 0/6] common clk framework Turquette, Mike

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=20120112131301.GA3478@matterhorn1 \
    --to=amit.kucheria-qsej5fyqhm4dnm+yrofe0a@public.gmane.org \
    --cc=andrew-g2DYL2Zd6BY@public.gmane.org \
    --cc=arnd.bergmann-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
    --cc=broonie-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org \
    --cc=ccross-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org \
    --cc=eric.miao-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
    --cc=jeremy.kerr-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org \
    --cc=linaro-dev-cunTk1MwBs8s++Sfvej+rw@public.gmane.org \
    --cc=linus.walleij-0IS4wlFg1OjSUeElwK9/Pw@public.gmane.org \
    --cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-lFZ/pmaqli7XmaaqVzeoHQ@public.gmane.org \
    --cc=linux-omap-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=magnus.damm-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=mturquette-l0cyMroinI0@public.gmane.org \
    --cc=patches-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
    --cc=paul-DWxLp4Yu+b8AvxtiuMwx3w@public.gmane.org \
    --cc=richard.zhao-KZfg59tc24xl57MIdRCFDg@public.gmane.org \
    --cc=sboyd-jfJNa2p1gH1BDgjK7y7TUQ@public.gmane.org \
    --cc=skannan-jfJNa2p1gH1BDgjK7y7TUQ@public.gmane.org \
    --cc=tglx-hfZtesqFncYOwBW4kG4KsQ@public.gmane.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).