All of lore.kernel.org
 help / color / mirror / Atom feed
From: skannan@codeaurora.org (Saravana Kannan)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 4/7] clk: Add simple gated clock
Date: Tue, 04 Oct 2011 18:41:36 -0700	[thread overview]
Message-ID: <4E8BB5D0.3090508@codeaurora.org> (raw)
In-Reply-To: <4E810AFA.9040004@gmail.com>

On 09/26/2011 04:30 PM, Rob Herring wrote:
> On 09/26/2011 05:37 PM, Turquette, Mike wrote:
>> On Mon, Sep 26, 2011 at 12:37 PM, Jamie Iles<jamie@jamieiles.com>  wrote:
>>> On Mon, Sep 26, 2011 at 02:10:32PM -0500, Rob Herring wrote:
>>>> On 09/26/2011 01:40 PM, Jamie Iles wrote:
>>>>> On Mon, Sep 26, 2011 at 01:33:08PM -0500, Rob Herring wrote:
>>>>>>> +static void clk_gate_set_bit(struct clk_hw *clk)
>>>>>>> +{
>>>>>>> + struct clk_gate *gate = to_clk_gate(clk);
>>>>>>> + u32 reg;
>>>>>>> +
>>>>>>> + reg = __raw_readl(gate->reg);
>>>>>>> + reg |= BIT(gate->bit_idx);
>>>>>>> + __raw_writel(reg, gate->reg);
>>>>>>
>>>>>> Don't these read-mod-writes need a spinlock around it?
>>>>>>
>>>>>> It's possible to have an enable bits and dividers in the same register.
>>>>>> If you did a set_rate and while doing an enable/disable, there would be
>>>>>> a problem. Also, it may be 2 different clocks in the same register, so
>>>>>> the spinlock needs to be shared and not per clock.
>>>>>
>>>>> Well the prepare lock will be held here and I believe that would be
>>>>> sufficient.
>>>>
>>>> No, the enable spinlock is protecting enable/disable. But set_rate is
>>>> protected by the prepare mutex. So you clearly don't need locking if you
>>>> have a register of only 1 bit enables. If you have a register accessed
>>>> by both enable/disable and prepare/unprepare/set_rate, then you need
>>>> some protection.
>>>
>>> OK fair point, but I would guess that if you had a clock like this then
>>> you probably wouldn't use this simple gated clock would you?  (speaking
>>> from my world where we have quite simple clocks ;-))
>>
>> I think it is a safe assumption that if a register controls both
>> enable/disable and some programmable divider then,
>>
>> 1) those controls are probably for the same clock
>> 2) that clock won't be using the cookie-cutter gated-clock
>> implementation anyways
>
> By definition of simple gated clock, the other bits have to be for
> another clock. The restriction is that all the other bits can only be
> clock gate bits.
>
>>
>> Rob, do you feel these assumptions are OK and locking can remain the
>> same in this patch?
>
> Perhaps it is rare enough that it is not worth it use generic code in
> this case. If so, the documentation should be clear about this
> constraint. It is not something anyone will have hit before because
> everyone used a single global lock. Now with the api being split between
> 2 locks, this adds a new complexity.

I kinda agree with Rob on this. There are very few, if any, such simple 
clocks on MSM chips. It's very easy to a SoC clock developer to 
accidentally use these simple clocks without realizing the point that 
Rob brings up.

> I think the simple gated clock code should be usable for any clock
> controlled by a single bit in a 32-bit register independent of other
> things in that register.

To take care of the scenario Rob bring up, the prepare/unprepare and 
enable/disable code will have to grab a per-tree register-lock before 
accessing any registers. The prepare/unprepare code should obviously be 
written to hold this register-lock for as small of a duration as 
possible. For example, if the prepare code is doing voltage increase, 
the register-lock should be grabber _after_ the voltage is increased. At 
least, this is approximately how the MSM clock code can be mapped onto 
this generic framework.

I think we should just go ahead and implement the per-tree register lock 
so that the generic clock implementations are more useful. The lock will 
really be held only for a very short time and hence shouldn't matter 
that there is a single lock for all the clocks in a tree.

Thomas,

Did you get a chance to send out your patches with support for per-tree 
locking? I would really like to see that as part of the first patch 
series that gets pulled in.

Thanks,
Saravana

-- 
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.

WARNING: multiple messages have this Message-ID (diff)
From: Saravana Kannan <skannan@codeaurora.org>
To: Rob Herring <robherring2@gmail.com>,
	Thomas Gleixner <tglx@linutronix.de>
Cc: "Turquette, Mike" <mturquette@ti.com>,
	Jeremy Kerr <jeremy.kerr@canonical.com>,
	paul@pwsan.com, linaro-dev@lists.linaro.org,
	linus.walleij@stericsson.com, patches@linaro.org,
	broonie@opensource.wolfsonmicro.com, magnus.damm@gmail.com,
	linux-kernel@vger.kernel.org, eric.miao@linaro.org,
	linux@arm.linux.org.uk, Jamie Iles <jamie@jamieiles.com>,
	arnd.bergmann@linaro.org,
	Saravana Kannan <skannan@codeaurora.org>,
	linux-arm-kernel@lists.infradead.org,
	Stephen Boyd <sboyd@codeaurora.org>
Subject: Re: [PATCH v2 4/7] clk: Add simple gated clock
Date: Tue, 04 Oct 2011 18:41:36 -0700	[thread overview]
Message-ID: <4E8BB5D0.3090508@codeaurora.org> (raw)
In-Reply-To: <4E810AFA.9040004@gmail.com>

On 09/26/2011 04:30 PM, Rob Herring wrote:
> On 09/26/2011 05:37 PM, Turquette, Mike wrote:
>> On Mon, Sep 26, 2011 at 12:37 PM, Jamie Iles<jamie@jamieiles.com>  wrote:
>>> On Mon, Sep 26, 2011 at 02:10:32PM -0500, Rob Herring wrote:
>>>> On 09/26/2011 01:40 PM, Jamie Iles wrote:
>>>>> On Mon, Sep 26, 2011 at 01:33:08PM -0500, Rob Herring wrote:
>>>>>>> +static void clk_gate_set_bit(struct clk_hw *clk)
>>>>>>> +{
>>>>>>> + struct clk_gate *gate = to_clk_gate(clk);
>>>>>>> + u32 reg;
>>>>>>> +
>>>>>>> + reg = __raw_readl(gate->reg);
>>>>>>> + reg |= BIT(gate->bit_idx);
>>>>>>> + __raw_writel(reg, gate->reg);
>>>>>>
>>>>>> Don't these read-mod-writes need a spinlock around it?
>>>>>>
>>>>>> It's possible to have an enable bits and dividers in the same register.
>>>>>> If you did a set_rate and while doing an enable/disable, there would be
>>>>>> a problem. Also, it may be 2 different clocks in the same register, so
>>>>>> the spinlock needs to be shared and not per clock.
>>>>>
>>>>> Well the prepare lock will be held here and I believe that would be
>>>>> sufficient.
>>>>
>>>> No, the enable spinlock is protecting enable/disable. But set_rate is
>>>> protected by the prepare mutex. So you clearly don't need locking if you
>>>> have a register of only 1 bit enables. If you have a register accessed
>>>> by both enable/disable and prepare/unprepare/set_rate, then you need
>>>> some protection.
>>>
>>> OK fair point, but I would guess that if you had a clock like this then
>>> you probably wouldn't use this simple gated clock would you?  (speaking
>>> from my world where we have quite simple clocks ;-))
>>
>> I think it is a safe assumption that if a register controls both
>> enable/disable and some programmable divider then,
>>
>> 1) those controls are probably for the same clock
>> 2) that clock won't be using the cookie-cutter gated-clock
>> implementation anyways
>
> By definition of simple gated clock, the other bits have to be for
> another clock. The restriction is that all the other bits can only be
> clock gate bits.
>
>>
>> Rob, do you feel these assumptions are OK and locking can remain the
>> same in this patch?
>
> Perhaps it is rare enough that it is not worth it use generic code in
> this case. If so, the documentation should be clear about this
> constraint. It is not something anyone will have hit before because
> everyone used a single global lock. Now with the api being split between
> 2 locks, this adds a new complexity.

I kinda agree with Rob on this. There are very few, if any, such simple 
clocks on MSM chips. It's very easy to a SoC clock developer to 
accidentally use these simple clocks without realizing the point that 
Rob brings up.

> I think the simple gated clock code should be usable for any clock
> controlled by a single bit in a 32-bit register independent of other
> things in that register.

To take care of the scenario Rob bring up, the prepare/unprepare and 
enable/disable code will have to grab a per-tree register-lock before 
accessing any registers. The prepare/unprepare code should obviously be 
written to hold this register-lock for as small of a duration as 
possible. For example, if the prepare code is doing voltage increase, 
the register-lock should be grabber _after_ the voltage is increased. At 
least, this is approximately how the MSM clock code can be mapped onto 
this generic framework.

I think we should just go ahead and implement the per-tree register lock 
so that the generic clock implementations are more useful. The lock will 
really be held only for a very short time and hence shouldn't matter 
that there is a single lock for all the clocks in a tree.

Thomas,

Did you get a chance to send out your patches with support for per-tree 
locking? I would really like to see that as part of the first patch 
series that gets pulled in.

Thanks,
Saravana

-- 
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.

  reply	other threads:[~2011-10-05  1:41 UTC|newest]

Thread overview: 144+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-22 22:26 [PATCH v2 0/7] Add a generic struct clk Mike Turquette
2011-09-22 22:26 ` Mike Turquette
2011-09-22 22:26 ` [PATCH v2 1/7] clk: Add a generic clock infrastructure Mike Turquette
2011-09-22 22:26   ` Mike Turquette
2011-09-25  3:55   ` Grant Likely
2011-09-25  3:55     ` Grant Likely
2011-09-25  5:26     ` Turquette, Mike
2011-09-25  5:26       ` Turquette, Mike
2011-10-03 14:17   ` Rob Herring
2011-10-03 14:17     ` Rob Herring
2011-10-03 14:25     ` Mark Brown
2011-10-03 14:25       ` Mark Brown
2011-10-03 15:24       ` Rob Herring
2011-10-03 15:24         ` Rob Herring
2011-10-03 16:31         ` Mark Brown
2011-10-03 16:31           ` Mark Brown
2011-10-03 16:43           ` Russell King - ARM Linux
2011-10-03 16:43             ` Russell King - ARM Linux
2011-10-03 17:05             ` Mark Brown
2011-10-03 17:05               ` Mark Brown
2011-10-04 18:09     ` Grant Likely
2011-10-04 18:09       ` Grant Likely
2011-10-27 11:54     ` Domenico Andreoli
2011-10-27 11:54       ` Domenico Andreoli
2011-10-03 22:02   ` Rob Herring
2011-10-03 22:02     ` Rob Herring
2011-10-03 22:15     ` Turquette, Mike
2011-10-03 22:15       ` Turquette, Mike
2011-10-06  1:17   ` Saravana Kannan
2011-10-06  1:17     ` Saravana Kannan
2011-10-06 16:11     ` Turquette, Mike
2011-10-06 16:11       ` Turquette, Mike
2011-10-11 11:25   ` Richard Zhao
2011-10-11 11:25     ` Richard Zhao
2011-10-13 14:44   ` Russell King - ARM Linux
2011-10-13 14:44     ` Russell King - ARM Linux
2011-10-13 17:16     ` Turquette, Mike
2011-10-13 17:16       ` Turquette, Mike
2011-10-14  8:10   ` Richard Zhao
2011-10-14  8:10     ` Richard Zhao
2011-10-14 10:05     ` Mark Brown
2011-10-14 10:05       ` Mark Brown
2011-10-14 10:32       ` Richard Zhao
2011-10-14 10:32         ` Richard Zhao
2011-10-16 17:55         ` Sascha Hauer
2011-10-16 17:55           ` Sascha Hauer
2011-10-17  8:48           ` Richard Zhao
2011-10-17  8:48             ` Richard Zhao
2011-10-17  9:20             ` Mark Brown
2011-10-17  9:20               ` Mark Brown
2011-10-17 10:53               ` Richard Zhao
2011-10-17 10:53                 ` Richard Zhao
2011-10-17 11:05                 ` Sascha Hauer
2011-10-17 11:05                   ` Sascha Hauer
2011-10-17 11:30                   ` Russell King - ARM Linux
2011-10-17 11:30                     ` Russell King - ARM Linux
2011-10-14 18:14   ` Turquette, Mike
2011-10-14 18:14     ` Turquette, Mike
2011-10-15  2:24     ` Richard Zhao
2011-10-15  2:24       ` Richard Zhao
2011-10-15  2:34       ` Richard Zhao
2011-10-15  2:34         ` Richard Zhao
2011-10-16 21:17       ` Turquette, Mike
2011-10-16 21:17         ` Turquette, Mike
2011-10-17 11:31         ` Richard Zhao
2011-10-17 11:31           ` Richard Zhao
2011-10-21  9:00   ` Richard Zhao
2011-10-21  9:00     ` Richard Zhao
2011-10-23 12:55   ` Shawn Guo
2011-10-23 12:55     ` Shawn Guo
2011-10-23 16:49     ` Turquette, Mike
2011-10-23 16:49       ` Turquette, Mike
2011-09-22 22:26 ` [PATCH v2 2/7] clk: Implement clk_set_rate Mike Turquette
2011-09-22 22:26   ` Mike Turquette
2011-10-11 11:49   ` Richard Zhao
2011-10-11 11:49     ` Richard Zhao
2011-10-23 14:24   ` Shawn Guo
2011-10-23 14:24     ` Shawn Guo
2011-10-23 16:50     ` Turquette, Mike
2011-10-23 16:50       ` Turquette, Mike
2011-09-22 22:26 ` [PATCH v2 3/7] clk: Add fixed-rate clock Mike Turquette
2011-09-22 22:26   ` Mike Turquette
2011-10-23 14:30   ` Shawn Guo
2011-10-23 14:30     ` Shawn Guo
2011-10-23 16:51     ` Turquette, Mike
2011-10-23 16:51       ` Turquette, Mike
2011-09-22 22:26 ` [PATCH v2 4/7] clk: Add simple gated clock Mike Turquette
2011-09-22 22:26   ` Mike Turquette
2011-09-25  4:02   ` Grant Likely
2011-09-25  4:02     ` Grant Likely
2011-09-25  5:27     ` Turquette, Mike
2011-09-25  5:27       ` Turquette, Mike
2011-09-26 18:33   ` Rob Herring
2011-09-26 18:33     ` Rob Herring
2011-09-26 18:40     ` Jamie Iles
2011-09-26 18:40       ` Jamie Iles
2011-09-26 19:10       ` Rob Herring
2011-09-26 19:10         ` Rob Herring
2011-09-26 19:37         ` Jamie Iles
2011-09-26 19:37           ` Jamie Iles
2011-09-26 22:37           ` Turquette, Mike
2011-09-26 22:37             ` Turquette, Mike
2011-09-26 23:30             ` Rob Herring
2011-09-26 23:30               ` Rob Herring
2011-10-05  1:41               ` Saravana Kannan [this message]
2011-10-05  1:41                 ` Saravana Kannan
2011-10-12  6:46   ` Richard Zhao
2011-10-12  6:46     ` Richard Zhao
2011-10-12 14:59     ` Turquette, Mike
2011-10-12 14:59       ` Turquette, Mike
2011-10-16 18:26       ` Sascha Hauer
2011-10-16 18:26         ` Sascha Hauer
2011-10-17  6:42         ` Richard Zhao
2011-10-17  6:42           ` Richard Zhao
2011-10-17 17:46           ` Turquette, Mike
2011-10-17 17:46             ` Turquette, Mike
2011-10-13 14:45   ` Russell King - ARM Linux
2011-10-13 14:45     ` Russell King - ARM Linux
2011-10-13 17:18     ` Turquette, Mike
2011-10-13 17:18       ` Turquette, Mike
2011-09-22 22:27 ` [PATCH v2 5/7] clk: Add Kconfig option to build all generic clk drivers Mike Turquette
2011-09-22 22:27   ` Mike Turquette
2011-09-22 22:27 ` [PATCH v2 6/7] clk: Add initial WM831x clock driver Mike Turquette
2011-09-22 22:27   ` Mike Turquette
2011-09-25  4:08   ` Grant Likely
2011-09-25  4:08     ` Grant Likely
2011-09-25  5:29     ` Turquette, Mike
2011-09-25  5:29       ` Turquette, Mike
2011-09-26  9:38     ` Mark Brown
2011-09-26  9:38       ` Mark Brown
2011-10-04 18:18       ` Grant Likely
2011-10-04 18:18         ` Grant Likely
2011-10-04 20:50         ` Mark Brown
2011-10-04 20:50           ` Mark Brown
2011-10-04 23:22           ` Grant Likely
2011-10-04 23:22             ` Grant Likely
2011-09-22 22:27 ` [PATCH v2 7/7] x86: Enable generic clk API on x86 Mike Turquette
2011-09-22 22:27   ` Mike Turquette
2011-09-22 23:17 ` [PATCH v2 0/7] Add a generic struct clk Turquette, Mike
2011-09-22 23:17   ` Turquette, Mike
2011-09-25  4:10 ` Grant Likely
2011-09-25  4:10   ` Grant Likely
2011-09-29 18:54 ` Mark Brown
2011-09-29 18:54   ` Mark Brown

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=4E8BB5D0.3090508@codeaurora.org \
    --to=skannan@codeaurora.org \
    --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.