From: jeremy.kerr@canonical.com (Jeremy Kerr)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC,PATCH 1/2] Add a common struct clk
Date: Mon, 14 Jun 2010 11:10:25 +0800 [thread overview]
Message-ID: <201006141110.26440.jeremy.kerr@canonical.com> (raw)
In-Reply-To: <20100613222349.GD31045@fluff.org.uk>
Hi Ben,
> You also need a warning that even if it protects the clock, it may not
> protect any access to the hardware implementing it.
Yep, agreed. HW clock implementations are free to acquire the mutex in their
ops.
> > I believe we need to ensure that clocks are enabled when clk_enable
> > returns, so we'll need some mechanism for waiting on the thread doing
> > the enable/disable. Since (as you say) some clocks may take 100s of
> > microseconds to enable, we'll need a lock that we can hold while
> > sleeping.
>
> Well, mutexes give us that, whilst enabling we hold the mutex.
Exactly, that's why I think the mutex option is the best way to go.
> > I've just yesterday added the following to my tree, to allow dynamic
> > initialisation:
> >
> > static inline void clk_init(struct clk *clk, const struct clk_ops *ops)
> > {
> >
> > clk->ops = ops;
> > clk->enable_count = 0;
> > mutex_init(&clk->mutex);
> >
> > }
> >
> > So we can do this either way.
>
> the above is in my view better.
By 'the above' do you mean doing the mutex init at registration time, or the
clk_init code above?
Either way should be fine; delaying the mutex_init until registration will has
the nice property of not requiring the clock name to be passed to INIT_CLK.
> > I've been debating dropping the get_parent and set_parent ops entirely,
> > actually; setting a parent seems to be quite specific to hardware (you
> > have to know that a particular clock can be a parent of another clock),
> > so it seems like something that we shouldn't expose to drivers through
> > this API. For the code that knows the hardware, it can probably access
> > the underlying clock types directly.
>
> Not really, and it is in use with extant drivers, so not easily
> removable either.
OK, is set_parent used much? I can see the use of get_parent, but calls
set_parent need to know specifics of the clock hardware.
> > Checking for the ops first allows us to skip the mutex acquire, but I'm
> > happy either way.
>
> erm, sorry, yes, you can check for them before mutex. any chages
> should be done with mutex held.
Yep.
> > Using default ops would mean a couple of things:
> >
> > 1) we can no longer mark the real ops as const; and
> > 2) we can no longer avoid the hard-to-predict indirect branch
>
> ok, how about people have to mark these as a default non op in their
> clock structure, and then error if they try and register a clock with
> null ops. anyone changing these to NULL later deserves all the pain and
> agony they get.
That addresses the first point, but still means we have an unnecessary
indirect branch to a function that does nothing. Since I've unlined the code
where this happens, the checks for null ops are pretty unobtrusive. If we
require all ops to be not-null, then we'll need much larger chunks of code
where the ops are defined. I like that you can just set the ops callbacks that
you need, and the rest "just works".
Cheers,
Jeremy
next prev parent reply other threads:[~2010-06-14 3:10 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-04 7:30 [RFC,PATCH 0/2] Common struct clk implementation, v4 Jeremy Kerr
2010-06-04 7:30 ` [RFC,PATCH 2/2] clk: Generic support for fixed-rate clocks Jeremy Kerr
2010-06-04 7:30 ` [RFC,PATCH 1/2] Add a common struct clk Jeremy Kerr
2010-06-11 4:20 ` Ben Dooks
2010-06-11 6:50 ` Benjamin Herrenschmidt
2010-06-11 7:57 ` Jeremy Kerr
2010-06-11 8:14 ` Lothar Waßmann
2010-06-11 9:18 ` Jeremy Kerr
2010-06-11 9:23 ` Lothar Waßmann
2010-06-11 9:58 ` Uwe Kleine-König
2010-06-11 10:08 ` Lothar Waßmann
2010-06-11 10:50 ` Jeremy Kerr
2010-06-12 5:14 ` Benjamin Herrenschmidt
2010-06-14 6:39 ` Lothar Waßmann
2010-06-14 6:40 ` Uwe Kleine-König
2010-06-14 6:52 ` Lothar Waßmann
2010-06-14 9:34 ` Uwe Kleine-König
2010-06-16 21:14 ` Ben Dooks
2010-06-16 21:13 ` Ben Dooks
2010-06-14 9:22 ` Benjamin Herrenschmidt
2010-06-14 9:30 ` Lothar Waßmann
2010-06-14 9:43 ` Uwe Kleine-König
2010-06-16 21:16 ` Ben Dooks
2010-06-16 23:33 ` Benjamin Herrenschmidt
2010-06-13 22:27 ` Ben Dooks
2010-06-11 14:11 ` Uwe Kleine-König
2010-06-12 5:12 ` Benjamin Herrenschmidt
2010-06-12 5:10 ` Benjamin Herrenschmidt
2010-06-13 22:25 ` Ben Dooks
2010-06-13 22:23 ` Ben Dooks
2010-06-14 3:10 ` Jeremy Kerr [this message]
2010-09-10 2:10 ` Jeremy Kerr
2010-06-14 10:18 ` Jeremy Kerr
-- strict thread matches above, loose matches on Subject: below --
2010-06-02 11:56 [RFC,PATCH 0/2] Common struct clk implementation, v3 Jeremy Kerr
2010-06-02 11:56 ` [RFC,PATCH 1/2] Add a common struct clk Jeremy Kerr
2010-06-02 12:03 ` Ben Dooks
2010-06-03 3:21 ` Jeremy Kerr
2010-06-03 8:13 ` Ben Dooks
2010-06-03 10:24 ` Jeremy Kerr
2010-06-03 11:05 ` Russell King - ARM Linux
2010-06-04 0:06 ` Ben Dooks
2010-06-04 1:43 ` Jeremy Kerr
2010-06-04 1:40 ` Jeremy Kerr
2010-06-03 21:09 ` Ryan Mallon
2010-06-03 23:45 ` Ben Dooks
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=201006141110.26440.jeremy.kerr@canonical.com \
--to=jeremy.kerr@canonical.com \
--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 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).