All of lore.kernel.org
 help / color / mirror / Atom feed
From: viresh.kumar@st.com (Viresh KUMAR)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v4] GPIO PL061: Adding Clk framework support
Date: Thu, 15 Jul 2010 11:32:19 +0530	[thread overview]
Message-ID: <4C3EA46B.1000709@st.com> (raw)
In-Reply-To: <20100713182644.GC30142@n2100.arm.linux.org.uk>

On 7/13/2010 11:56 PM, Russell King - ARM Linux wrote:
> On Tue, Jul 13, 2010 at 01:00:51PM +0200, Linus Walleij wrote:
>> Since that works, it means that we can likely insert
>> amba_bus_clk_[disable|enable] at the same sites that we have
>> this in the current code for the external clocks at the same time,
>> atleast for pl011, pl022 and pl180.
> 
> Almost - but there's a few corner cases.  Basically, what I think you'll
> need for pl011 is:
> 1. add an amba_bus_clk_disable() at the end of the successful probe
>    function
> 2. add amba_bus_clk_enable() at the beginning of the remove function.
> 3. add amba_bus_clk_enable()/amba_bus_clk_disable() around each of the
>    suspend(), resume(), pl011_console_write(), and
>    pl011_console_get_options() functions.
> 4. amba_bus_clk_enable() at the start of the startup method.
> 5. amba_bus_clk_disable() at the end of the shutdown method.
> 
> Most of these do tie up with existing clk_enable()s, but there are some
> additional places you'd need to enable the pclk because of register
> accesses.
> 

Russell,

These cases particularly in our architecture where functional and
interface clock are tied together (through same gating option) would
produce difficult scenarios (as already mentioned by you) and which
would be difficult and not so clean to handle.

For example just looking at driver src which disables bus clock (without
enabling it) in different scenarios would not be very readable.
Further that would vary from architecture to architecture (even for
standard drivers).

>> > For drivers that need to conserve power, also the block
>> > clock has to be gated when the device is not in use,
>> > sometimes since that affects some hardware that keep
>> > track of the usecount of the clock tree for a larger region of
>> > silicon, so the power savings can be drastic.
> You can't have the core code doing that.  If you unconditionally turn
> the bus clock off after probe, what happens when a driver receives an
> interrupt and tries to access its registers?
> 
> Hint: the core code can't know that the driver has registered an IRQ
> handler.

We haven't seen this kind of issues in our devices, SPEAr as well as
U300 (as we have both clocks controlled by same bit). Normally, when device
is not in use then interrupts are disabled. When device is used then interrupts
and clock are enabled and clocks are not disabled till the time work is
finished. So, this condition might not occur that you have landed in interrupt
handler with clocks off.

IMO, Clocks enabling is required at following places:
1. During device add where we need to read id registers.
- We can do this by simple enabling/disabling "apb_bus" clk before and
  after reading registers.
2. In driver, when device is used.
- This can be handled best by the driver itself. We don't require to
  enable interface clock from amba_probe for ever.


One way to do this cleanly is:
- Add clock structures for devices with connection id "apb_bus".
  (Platforms can have 2 different structures if they have different
controlling bits otherwise single structure will solve the purpose.)
- amba_device_register can simple get this clk and use it.
- Drivers need to enable/disable both interface and functional clock to
save maximum power.



regards,
viresh kumar.

  reply	other threads:[~2010-07-15  6:02 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-22  5:07 [PATCH v4] GPIO PL061: Adding Clk framework support Viresh KUMAR
2010-06-22 17:06 ` Baruch Siach
2010-07-09 12:40 ` Russell King - ARM Linux
2010-07-09 23:55   ` Linus Walleij
2010-07-10  7:19     ` Russell King - ARM Linux
2010-07-10  7:30       ` Russell King - ARM Linux
2010-07-10 15:36       ` Linus Walleij
2010-07-13  7:44         ` Russell King - ARM Linux
2010-07-13 11:00           ` Linus Walleij
2010-07-13 18:26             ` Russell King - ARM Linux
2010-07-15  6:02               ` Viresh KUMAR [this message]
2010-07-15  8:30                 ` Russell King - ARM Linux
2010-07-15  9:35                   ` Viresh KUMAR
2010-07-15  9:44                     ` Linus Walleij
2010-07-15  9:56                     ` Russell King - ARM Linux
2010-07-15 16:09                       ` Rabin Vincent
2010-07-15 16:22                         ` Russell King - ARM Linux
2010-07-29 23:22                       ` Kevin Wells
2010-07-30  7:09                         ` Russell King - ARM Linux
2010-08-03  0:40                           ` Kevin Wells
2010-08-03 13:00                             ` Linus Walleij
2010-08-03 20:36                               ` Kevin Wells
2010-08-03 21:23                             ` Russell King - ARM Linux
2010-07-30 15:19                         ` Linus Walleij
2010-07-12  4:07   ` Viresh KUMAR
2010-07-12  7:53     ` Linus Walleij
2010-07-12  8:07     ` Russell King - ARM Linux
2010-07-12  8:18       ` Viresh KUMAR
2010-07-12  8:34         ` Russell King - ARM Linux

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=4C3EA46B.1000709@st.com \
    --to=viresh.kumar@st.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.