All of lore.kernel.org
 help / color / mirror / Atom feed
From: robherring2@gmail.com (Rob Herring)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v6 3/3] clk: basic clock hardware types
Date: Mon, 12 Mar 2012 17:00:57 -0500	[thread overview]
Message-ID: <4F5E7219.7020301@gmail.com> (raw)
In-Reply-To: <CAJOA=zOS44YRfg3A7D8G+jWoQ_gzRQ937A7tYDU+DxWce_khzQ@mail.gmail.com>

On 03/12/2012 03:58 PM, Turquette, Mike wrote:
> On Mon, Mar 12, 2012 at 1:18 PM, Rob Herring <robherring2@gmail.com> wrote:
>> On 03/10/2012 01:54 AM, Mike Turquette wrote:
>>> Many platforms support simple gateable clocks, fixed-rate clocks,
>>> adjustable divider clocks and multi-parent multiplexer clocks.
>>>
>>> This patch introduces basic clock types for the above-mentioned hardware
>>> which share some common characteristics.
>>>
>>> Based on original work by Jeremy Kerr and contribution by Jamie Iles.
>>> Dividers and multiplexor clocks originally contributed by Richard Zhao &
>>> Sascha Hauer.
>>>

snip

>>> +static unsigned long clk_divider_recalc_rate(struct clk_hw *hw,
>>> +             unsigned long parent_rate)
>>> +{
>>> +     struct clk_divider *divider = to_clk_divider(hw);
>>> +     unsigned int div;
>>> +     unsigned long flags = 0;
>>> +
>>> +     if (divider->lock)
>>> +             spin_lock_irqsave(divider->lock, flags);
>>> +
>>> +     div = readl(divider->reg) >> divider->shift;
>>> +     div &= (1 << divider->width) - 1;
>>> +
>>> +     if (divider->lock)
>>> +             spin_unlock_irqrestore(divider->lock, flags);
>>
>> What are you locking against? You are only reading the register.
> 
> Hi Rob,
> 
> These register-level locks originally came in from the divider &
> multiplexer patches from Richard and Sascha and I'm sure they can give
> you more details than I.
> 
> Basically on their platform they have some 32-bits regs that have a
> lot of overlapping clock functions in them, such as enable/disable and
> adjusting a divider all in one reg.  Those operations are protected by
> different locks (enable spinlock and prepare mutex, respectively) so
> some synchronization mechanism is necessary.  On OMAP we don't use
> this since we have a billion registers that typically only map to one
> clock each.  I also wonder if having device type memory for the
> affected regions makes a this irrelevant on ARM... but that wouldn't
> matter for non-ARM architectures.  Just a thought.
> 

In fact, I pointed out that locking for a register access was needed in
an early version of this series as well. However, locking is only needed
if you are doing a read-mod-write on a field in a shared register or
reading from multiple registers. It makes no sense if you are *only*
reading a single shared register as is the case here. That's already an
atomic operation.

Rob

WARNING: multiple messages have this Message-ID (diff)
From: Rob Herring <robherring2@gmail.com>
To: "Turquette, Mike" <mturquette@ti.com>
Cc: Andrew Lunn <andrew@lunn.ch>, Paul Walmsley <paul@pwsan.com>,
	linaro-dev@lists.linaro.org,
	Linus Walleij <linus.walleij@stericsson.com>,
	patches@linaro.org, Stephen Boyd <sboyd@codeaurora.org>,
	Sascha Hauer <s.hauer@pengutronix.de>,
	Mark Brown <broonie@opensource.wolfsonmicro.com>,
	Magnus Damm <magnus.damm@gmail.com>,
	linux-kernel@vger.kernel.org,
	Rob Herring <rob.herring@calxeda.com>,
	Saravana Kannan <skannan@codeaurora.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Jamie Iles <jamie@jamieiles.com>,
	Russell King <linux@arm.linux.org.uk>,
	Jeremy Kerr <jeremy.kerr@canonical.com>,
	Arnd Bergman <arnd.bergmann@linaro.org>,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v6 3/3] clk: basic clock hardware types
Date: Mon, 12 Mar 2012 17:00:57 -0500	[thread overview]
Message-ID: <4F5E7219.7020301@gmail.com> (raw)
In-Reply-To: <CAJOA=zOS44YRfg3A7D8G+jWoQ_gzRQ937A7tYDU+DxWce_khzQ@mail.gmail.com>

On 03/12/2012 03:58 PM, Turquette, Mike wrote:
> On Mon, Mar 12, 2012 at 1:18 PM, Rob Herring <robherring2@gmail.com> wrote:
>> On 03/10/2012 01:54 AM, Mike Turquette wrote:
>>> Many platforms support simple gateable clocks, fixed-rate clocks,
>>> adjustable divider clocks and multi-parent multiplexer clocks.
>>>
>>> This patch introduces basic clock types for the above-mentioned hardware
>>> which share some common characteristics.
>>>
>>> Based on original work by Jeremy Kerr and contribution by Jamie Iles.
>>> Dividers and multiplexor clocks originally contributed by Richard Zhao &
>>> Sascha Hauer.
>>>

snip

>>> +static unsigned long clk_divider_recalc_rate(struct clk_hw *hw,
>>> +             unsigned long parent_rate)
>>> +{
>>> +     struct clk_divider *divider = to_clk_divider(hw);
>>> +     unsigned int div;
>>> +     unsigned long flags = 0;
>>> +
>>> +     if (divider->lock)
>>> +             spin_lock_irqsave(divider->lock, flags);
>>> +
>>> +     div = readl(divider->reg) >> divider->shift;
>>> +     div &= (1 << divider->width) - 1;
>>> +
>>> +     if (divider->lock)
>>> +             spin_unlock_irqrestore(divider->lock, flags);
>>
>> What are you locking against? You are only reading the register.
> 
> Hi Rob,
> 
> These register-level locks originally came in from the divider &
> multiplexer patches from Richard and Sascha and I'm sure they can give
> you more details than I.
> 
> Basically on their platform they have some 32-bits regs that have a
> lot of overlapping clock functions in them, such as enable/disable and
> adjusting a divider all in one reg.  Those operations are protected by
> different locks (enable spinlock and prepare mutex, respectively) so
> some synchronization mechanism is necessary.  On OMAP we don't use
> this since we have a billion registers that typically only map to one
> clock each.  I also wonder if having device type memory for the
> affected regions makes a this irrelevant on ARM... but that wouldn't
> matter for non-ARM architectures.  Just a thought.
> 

In fact, I pointed out that locking for a register access was needed in
an early version of this series as well. However, locking is only needed
if you are doing a read-mod-write on a field in a shared register or
reading from multiple registers. It makes no sense if you are *only*
reading a single shared register as is the case here. That's already an
atomic operation.

Rob


  reply	other threads:[~2012-03-12 22:00 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-10  7:54 [PATCH v6 0/3] common clk framework Mike Turquette
2012-03-10  7:54 ` Mike Turquette
2012-03-10  7:54 ` [PATCH v6 1/3] Documentation: common clk API Mike Turquette
2012-03-10  7:54   ` Mike Turquette
2012-03-10 17:50   ` Andrew Lunn
2012-03-10 17:50     ` Andrew Lunn
2012-03-10  7:54 ` [PATCH v6 2/3] clk: introduce the common clock framework Mike Turquette
2012-03-10  7:54   ` Mike Turquette
2012-03-10 10:51   ` Thomas Gleixner
2012-03-10 10:51     ` Thomas Gleixner
2012-03-10 17:51   ` Andrew Lunn
2012-03-10 17:51     ` Andrew Lunn
2012-03-11  7:52   ` Richard Zhao
2012-03-11  7:52     ` Richard Zhao
2012-03-11 21:02     ` Turquette, Mike
2012-03-11 21:02       ` Turquette, Mike
2012-03-11 11:34   ` Sascha Hauer
2012-03-11 11:34     ` Sascha Hauer
2012-03-11 21:24     ` Turquette, Mike
2012-03-11 21:24       ` Turquette, Mike
2012-03-12 11:51       ` Sascha Hauer
2012-03-12 11:51         ` Sascha Hauer
2012-03-13  3:16         ` Turquette, Mike
2012-03-13  3:16           ` Turquette, Mike
2012-03-13 12:05           ` Sascha Hauer
2012-03-13 12:05             ` Sascha Hauer
2012-03-15  0:51             ` Turquette, Mike
2012-03-15  0:51               ` Turquette, Mike
2012-03-15  9:43               ` Sascha Hauer
2012-03-15  9:43                 ` Sascha Hauer
2012-03-16  6:22                 ` Turquette, Mike
2012-03-16  6:22                   ` Turquette, Mike
2012-03-12 20:14   ` Rob Herring
2012-03-12 20:14     ` Rob Herring
2012-03-13 21:48   ` Rob Herring
2012-03-13 21:48     ` Rob Herring
2012-03-13 22:41     ` Turquette, Mike
2012-03-13 22:41       ` Turquette, Mike
2012-03-10  7:54 ` [PATCH v6 3/3] clk: basic clock hardware types Mike Turquette
2012-03-10  7:54   ` Mike Turquette
2012-03-10 18:01   ` Andrew Lunn
2012-03-10 18:01     ` Andrew Lunn
2012-03-12 20:18   ` Rob Herring
2012-03-12 20:18     ` Rob Herring
2012-03-12 20:58     ` Turquette, Mike
2012-03-12 20:58       ` Turquette, Mike
2012-03-12 22:00       ` Rob Herring [this message]
2012-03-12 22:00         ` Rob Herring
2012-03-13  3:50   ` Matt Sealey
2012-03-13  3:50     ` Matt Sealey
2012-03-13 10:38     ` Sascha Hauer
2012-03-13 10:38       ` Sascha Hauer
2012-03-14  8:54   ` Richard Zhao
2012-03-14  8:54     ` Richard Zhao
2012-03-14 18:23   ` Sascha Hauer
2012-03-14 18:23     ` Sascha Hauer
2012-03-14 18:38     ` Rob Herring
2012-03-14 18:38       ` Rob Herring

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=4F5E7219.7020301@gmail.com \
    --to=robherring2@gmail.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.