From: ryan@bluewatersys.com (Ryan Mallon)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/2] Add a common struct clk
Date: Mon, 17 Jan 2011 09:41:46 +1300 [thread overview]
Message-ID: <4D33580A.8090007@bluewatersys.com> (raw)
In-Reply-To: <AANLkTikjnz6RBCpOZM2imzX3d1ANUkaOZ2Qg9nqhpfpt@mail.gmail.com>
On 01/16/2011 08:26 PM, Grant Likely wrote:
> On Mon, Jan 10, 2011 at 5:54 PM, Jeremy Kerr <jeremy.kerr@canonical.com> wrote:
>> Hi Russell,
>>
>>> Unless the locking problems can be resolved, the patches aren't ready.
>>>
>>> From what I've seen there's still quite a problem with what kind of
>>> lock to use in the clock - mutex or spinlock.
>>
>> Yes, the clock driver may either use a spinlock or mutex.
>>
>> However, this exactly the same as the current clock code, my patches do not
>> alter what we currently have.
>>
>> I do agree that we should define some specific semantics for the clock API
>> with regards to sleeping, and I'll start a new thread about that. But we
>> should definitely separate that issue from the problem of having multiple
>> definitions for struct clk, which is what these patches address.
>
> Given that each current struct clk implementation makes it's own
> decisions about how to handle locking, would it not make sense to omit
> locking entirely? At least as a first step? Let the clock ops
> implement their own locking. Make enable count management their
> responsibility too. That's all that the lock protects anyway. The
> clk_* apis can fall directly through to the ops hooks with no
> manipulation or locking. The way v3 of the patch worked.
This doesn't really work in a generic API because the call sites need to
know whether it safe to call clk_enable/disable, etc from a
non-sleepable context. This has essentially the same problems as using a
union with both a mutex and a spinlock.
That said, although we are aiming for a generic clock API, it's usage
typically isn't. Most of the users of the clock API are machine/platform
specific drivers and so they can make assumptions about the
implementation of the clock API calls. We currently do have a generic
set of clock calls which do not define rules about calling from atomic
context. We have a number of drivers, for several platforms, using the
clk_enable/disable calls. Some platforms are using sleeping clocks and
others are using atomic clocks, but because the _usage_ of the API is
largely platform specific it all hangs together.
This is a bit ugly in practice. It's hardly desirable to have an API
which looks generic, but in reality is platform/machine specific. I'm
guessing that a large benefit of having a unified API and well defined
rules about whether clock API calls may sleep or not allows the usage of
the clock API to become more generic.
I agree with Russell that the best short term approach is to create two
clock APIs, one for clocks which are atomic and the other for clocks
which need to sleep. If nothing else this at least allows the rules
about calling context to nailed down.
~Ryan
--
Bluewater Systems Ltd - ARM Technology Solution Centre
Ryan Mallon 5 Amuri Park, 404 Barbadoes St
ryan at bluewatersys.com PO Box 13 889, Christchurch 8013
http://www.bluewatersys.com New Zealand
Phone: +64 3 3779127 Freecall: Australia 1800 148 751
Fax: +64 3 3779135 USA 1800 261 2934
WARNING: multiple messages have this Message-ID (diff)
From: Ryan Mallon <ryan@bluewatersys.com>
To: Grant Likely <grant.likely@secretlab.ca>
Cc: "Jeremy Kerr" <jeremy.kerr@canonical.com>,
"Russell King - ARM Linux" <linux@arm.linux.org.uk>,
"Sascha Hauer" <s.hauer@pengutronix.de>,
"Ben Herrenchmidt" <benh@kernel.crashing.org>,
linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Subject: Re: [PATCH 1/2] Add a common struct clk
Date: Mon, 17 Jan 2011 09:41:46 +1300 [thread overview]
Message-ID: <4D33580A.8090007@bluewatersys.com> (raw)
In-Reply-To: <AANLkTikjnz6RBCpOZM2imzX3d1ANUkaOZ2Qg9nqhpfpt@mail.gmail.com>
On 01/16/2011 08:26 PM, Grant Likely wrote:
> On Mon, Jan 10, 2011 at 5:54 PM, Jeremy Kerr <jeremy.kerr@canonical.com> wrote:
>> Hi Russell,
>>
>>> Unless the locking problems can be resolved, the patches aren't ready.
>>>
>>> From what I've seen there's still quite a problem with what kind of
>>> lock to use in the clock - mutex or spinlock.
>>
>> Yes, the clock driver may either use a spinlock or mutex.
>>
>> However, this exactly the same as the current clock code, my patches do not
>> alter what we currently have.
>>
>> I do agree that we should define some specific semantics for the clock API
>> with regards to sleeping, and I'll start a new thread about that. But we
>> should definitely separate that issue from the problem of having multiple
>> definitions for struct clk, which is what these patches address.
>
> Given that each current struct clk implementation makes it's own
> decisions about how to handle locking, would it not make sense to omit
> locking entirely? At least as a first step? Let the clock ops
> implement their own locking. Make enable count management their
> responsibility too. That's all that the lock protects anyway. The
> clk_* apis can fall directly through to the ops hooks with no
> manipulation or locking. The way v3 of the patch worked.
This doesn't really work in a generic API because the call sites need to
know whether it safe to call clk_enable/disable, etc from a
non-sleepable context. This has essentially the same problems as using a
union with both a mutex and a spinlock.
That said, although we are aiming for a generic clock API, it's usage
typically isn't. Most of the users of the clock API are machine/platform
specific drivers and so they can make assumptions about the
implementation of the clock API calls. We currently do have a generic
set of clock calls which do not define rules about calling from atomic
context. We have a number of drivers, for several platforms, using the
clk_enable/disable calls. Some platforms are using sleeping clocks and
others are using atomic clocks, but because the _usage_ of the API is
largely platform specific it all hangs together.
This is a bit ugly in practice. It's hardly desirable to have an API
which looks generic, but in reality is platform/machine specific. I'm
guessing that a large benefit of having a unified API and well defined
rules about whether clock API calls may sleep or not allows the usage of
the clock API to become more generic.
I agree with Russell that the best short term approach is to create two
clock APIs, one for clocks which are atomic and the other for clocks
which need to sleep. If nothing else this at least allows the rules
about calling context to nailed down.
~Ryan
--
Bluewater Systems Ltd - ARM Technology Solution Centre
Ryan Mallon 5 Amuri Park, 404 Barbadoes St
ryan@bluewatersys.com PO Box 13 889, Christchurch 8013
http://www.bluewatersys.com New Zealand
Phone: +64 3 3779127 Freecall: Australia 1800 148 751
Fax: +64 3 3779135 USA 1800 261 2934
next prev parent reply other threads:[~2011-01-16 20:41 UTC|newest]
Thread overview: 86+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-05 3:51 [PATCH 0/2] Common struct clk implementation, v10 Jeremy Kerr
2011-01-05 3:51 ` Jeremy Kerr
2011-01-05 3:51 ` [PATCH 2/2] clk: Generic support for fixed-rate clocks Jeremy Kerr
2011-01-05 3:51 ` Jeremy Kerr
2011-01-05 3:51 ` [PATCH 1/2] Add a common struct clk Jeremy Kerr
2011-01-05 3:51 ` Jeremy Kerr
2011-01-06 16:07 ` Richard Cochran
2011-01-06 16:07 ` Richard Cochran
2011-01-06 20:11 ` Uwe Kleine-König
2011-01-06 20:11 ` Uwe Kleine-König
2011-01-07 0:10 ` Jeremy Kerr
2011-01-07 0:10 ` Jeremy Kerr
2011-01-07 0:32 ` Russell King - ARM Linux
2011-01-07 0:32 ` Russell King - ARM Linux
2011-01-07 9:40 ` Uwe Kleine-König
2011-01-07 9:40 ` Uwe Kleine-König
2011-01-08 13:15 ` Sascha Hauer
2011-01-08 13:15 ` Sascha Hauer
2011-01-10 2:43 ` Jeremy Kerr
2011-01-10 2:43 ` Jeremy Kerr
2011-01-10 10:41 ` Sascha Hauer
2011-01-10 10:41 ` Sascha Hauer
2011-01-10 11:00 ` Russell King - ARM Linux
2011-01-10 11:00 ` Russell King - ARM Linux
2011-01-11 0:54 ` Jeremy Kerr
2011-01-11 0:54 ` Jeremy Kerr
2011-01-16 7:26 ` Grant Likely
2011-01-16 7:26 ` Grant Likely
2011-01-16 20:41 ` Ryan Mallon [this message]
2011-01-16 20:41 ` Ryan Mallon
2011-01-16 21:07 ` Uwe Kleine-König
2011-01-16 21:07 ` Uwe Kleine-König
2011-01-16 21:39 ` Ryan Mallon
2011-01-16 21:39 ` Ryan Mallon
2011-01-11 10:16 ` Sascha Hauer
2011-01-11 10:16 ` Sascha Hauer
2011-01-11 10:27 ` Jeremy Kerr
2011-01-11 10:27 ` Jeremy Kerr
2011-01-11 11:22 ` Sascha Hauer
2011-01-11 11:22 ` Sascha Hauer
2011-01-18 8:44 ` Paul Mundt
2011-01-18 8:44 ` Paul Mundt
2011-01-18 9:21 ` Sascha Hauer
2011-01-18 9:21 ` Sascha Hauer
2011-01-18 9:23 ` Paul Mundt
2011-01-18 9:23 ` Paul Mundt
2011-01-18 12:21 ` Russell King - ARM Linux
2011-01-18 12:21 ` Russell King - ARM Linux
2011-01-05 3:55 ` [PATCH 0/2] Common struct clk implementation, v10 Jeremy Kerr
2011-01-07 1:33 ` Ben Dooks
2011-01-07 9:49 ` Uwe Kleine-König
-- strict thread matches above, loose matches on Subject: below --
2011-03-03 6:40 [PATCH 0/2] Common struct clk implementation, v14 Jeremy Kerr
2011-02-21 2:50 [PATCH 0/2] Common struct clk implementation, v13 Jeremy Kerr
2011-02-21 2:50 ` [PATCH 1/2] Add a common struct clk Jeremy Kerr
2011-02-21 2:50 ` Jeremy Kerr
2011-02-21 2:50 ` Jeremy Kerr
2011-02-22 20:17 `
2011-02-22 20:17 ` Uwe Kleine-König
2011-02-22 20:17 ` Uwe Kleine-König
2011-02-23 2:49 ` Jeremy Kerr
2011-02-23 2:49 ` Jeremy Kerr
2011-02-23 2:49 ` Jeremy Kerr
2011-03-03 6:40 ` Jeremy Kerr
2011-03-03 6:40 ` Jeremy Kerr
2011-03-03 6:40 ` Jeremy Kerr
2011-04-14 12:49 ` Tony Lindgren
2011-04-14 12:49 ` Tony Lindgren
2011-04-14 12:49 ` Tony Lindgren
2011-01-05 3:18 [PATCH 0/2] Common struct clk implementation, v10 Jeremy Kerr
2011-01-05 3:18 ` [PATCH 1/2] Add a common struct clk Jeremy Kerr
2010-12-08 2:08 [PATCH 0/2] Common struct clk implementation, v8 Jeremy Kerr
2010-12-08 2:08 ` [PATCH 1/2] Add a common struct clk Jeremy Kerr
2010-12-08 2:08 ` Jeremy Kerr
2010-12-08 2:05 Jeremy Kerr
2010-12-08 2:05 ` Jeremy Kerr
2010-12-08 10:21 ` Uwe Kleine-König
2010-12-08 10:21 ` Uwe Kleine-König
2010-12-10 1:58 ` Jeremy Kerr
2010-12-10 1:58 ` Jeremy Kerr
2010-12-10 9:21 ` Uwe Kleine-König
2010-07-12 2:37 [PATCH 0/2] Common struct clk implementation, v6 Jeremy Kerr
2010-07-12 2:37 ` [PATCH 1/2] Add a common struct clk Jeremy Kerr
2010-07-12 2:37 ` Jeremy Kerr
2010-06-21 5:35 [PATCH 0/2] Common struct clk implementation, v5 Jeremy Kerr
2010-06-21 5:35 ` [PATCH 1/2] Add a common struct clk Jeremy Kerr
2010-06-21 5:35 ` Jeremy Kerr
2010-06-22 4:43 ` Baruch Siach
2010-06-22 4:43 ` Baruch Siach
2010-07-05 2:33 ` MyungJoo Ham
2010-07-05 2:33 ` MyungJoo Ham
2010-07-12 2:19 ` Jeremy Kerr
2010-07-12 2:19 ` Jeremy Kerr
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=4D33580A.8090007@bluewatersys.com \
--to=ryan@bluewatersys.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 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.