From: lee.jones@linaro.org (Lee Jones)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v7 3/5] clk: Supply the critical clock {init, enable, disable} framework
Date: Fri, 31 Jul 2015 09:32:07 +0100 [thread overview]
Message-ID: <20150731083207.GB3208@x1> (raw)
In-Reply-To: <20150731073019.GU2564@lukather>
On Fri, 31 Jul 2015, Maxime Ripard wrote:
> On Thu, Jul 30, 2015 at 03:47:20PM -0700, Michael Turquette wrote:
> > > > > */
> > > > >
> > > > > Resume:
> > > > > /* Order is unimportant */
> > > > > SPI enables Clock 4 (ref == 1)
> > > > > RAM enables Clock 4 and re-enables .leave_on (ref == 2)
> > > > > I2C enables Clock 4 (ref == 3)
> > > >
> > > > Same again. As soon as RAM calls clk_enable_critical the ref count goes
> > > > up. .leave_on does nothing as far as I can tell. The all works because
> > > > of the reference counting, which already exists before this patch
> > > > series.
> > >
> > > So fundamentally you're right in what you say. All you really need to
> > > disable a critical clock is write a knowledgeable driver, which is
> > > intentionally unbalanced i.e. just calls clk_disable(). All this
> >
> > OK, the line above is helpful. What you really want is a formalized
> > hand-off mechanism, whereby the clock is enabled at registration-time
> > and it cannot be turned off until the right driver claims it and decides
> > turning it off is OK (with a priori knowledge that the clock is already
> > enabled).
>
> There's two things that should be covered, and are related, yet can be
> done in two steps:
>
> - Have a way to, no matter what (which configuration we have, if we
> have multiple users or not that might reparent or disable their
> clocks, etc.), make sure that a clock will always be running by
> default. This is done through the call in clk-conf, and we
> identify such clocks using critical-clocks in the DT.
>
> - Now, even though that information is true, some driver who are
> aware of that fact might want to disable those critical
> clocks. This is what the clk_disable_critical and
> clk_enable_critical functions are here for.
+1
> > Note that I don't think this implementation can really work in the near
> > future. Today we do not catch unbalanced calls to clk_enable and
> > clk_disable, but I have a patch that catches this and WARNs loudly in my
> > private tree. More on that in the next stanza.
> >
> > What I don't understand is if there is ever a case for a clock consumer
> > driver to ever call clk_enable_critical... I do not think there is. What
> > you're trying to protect against is having the clock disabled BEFORE
> > that "knowledgeable driver" has a chance to enable it.
In my mind and in this implementation clk_disable_critical() will be
used _first_ by the knowledgeable driver, then when the knowledgeable
driver has finished whatever it was doing (shutting down banks of RAM
etc...), it should then call clk_enable_critical() to reset the clock
state back to the way it found it i.e. enabled and marked as critical.
> It's really about what we want the API to look like in the second
> case.
>
> Do we want such drivers to still call clk_prepare_enable? Some other
> function? Should they assume that the clock has already been enabled,
> or do we want a handover, or a force disable, or whatever.
>
> I guess we should discuss those questions, before starting to think
> about how to implement it.
>
> IMHO, I think that the existing way of doing should be used, or at
> least with the same mindset to avoid confusion, errors, and
> misinformed reviews.
>
> So I'd expect the drivers to do something like:
>
> probe:
> clk_get
> clk_critical_enable
Well becuase the clock has been marked as critical, a reference has
already been taken, so even if there are 0 users the clock now has 2
references attributed to it.
> remove / probe error path:
> clk_critical_disable
> clk_put
I think we should assume that the clock is already running in the
knowledgeable driver:
start-up:
__set_critical_clocks()
probe:
clk_get()
suspend (or whatever reason the driver wishes to disable the clk):
clk_disable_critical()
resume (or whatever ...):
clk_enable_critical()
remove:
clk_put() /* Or just rely on devm_*() */
> and use the clk_critical_enable and clk_critical_disable whenever
> needed, and thing would just work as intended.
--
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org ? Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
WARNING: multiple messages have this Message-ID (diff)
From: Lee Jones <lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
To: Maxime Ripard
<maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
Cc: Michael Turquette
<mturquette-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
kernel-F5mvAk5X5gdBDgjK7y7TUQ@public.gmane.org,
sboyd-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org,
devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
geert-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org,
s.hauer-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org
Subject: Re: [PATCH v7 3/5] clk: Supply the critical clock {init, enable, disable} framework
Date: Fri, 31 Jul 2015 09:32:07 +0100 [thread overview]
Message-ID: <20150731083207.GB3208@x1> (raw)
In-Reply-To: <20150731073019.GU2564@lukather>
On Fri, 31 Jul 2015, Maxime Ripard wrote:
> On Thu, Jul 30, 2015 at 03:47:20PM -0700, Michael Turquette wrote:
> > > > > */
> > > > >
> > > > > Resume:
> > > > > /* Order is unimportant */
> > > > > SPI enables Clock 4 (ref == 1)
> > > > > RAM enables Clock 4 and re-enables .leave_on (ref == 2)
> > > > > I2C enables Clock 4 (ref == 3)
> > > >
> > > > Same again. As soon as RAM calls clk_enable_critical the ref count goes
> > > > up. .leave_on does nothing as far as I can tell. The all works because
> > > > of the reference counting, which already exists before this patch
> > > > series.
> > >
> > > So fundamentally you're right in what you say. All you really need to
> > > disable a critical clock is write a knowledgeable driver, which is
> > > intentionally unbalanced i.e. just calls clk_disable(). All this
> >
> > OK, the line above is helpful. What you really want is a formalized
> > hand-off mechanism, whereby the clock is enabled at registration-time
> > and it cannot be turned off until the right driver claims it and decides
> > turning it off is OK (with a priori knowledge that the clock is already
> > enabled).
>
> There's two things that should be covered, and are related, yet can be
> done in two steps:
>
> - Have a way to, no matter what (which configuration we have, if we
> have multiple users or not that might reparent or disable their
> clocks, etc.), make sure that a clock will always be running by
> default. This is done through the call in clk-conf, and we
> identify such clocks using critical-clocks in the DT.
>
> - Now, even though that information is true, some driver who are
> aware of that fact might want to disable those critical
> clocks. This is what the clk_disable_critical and
> clk_enable_critical functions are here for.
+1
> > Note that I don't think this implementation can really work in the near
> > future. Today we do not catch unbalanced calls to clk_enable and
> > clk_disable, but I have a patch that catches this and WARNs loudly in my
> > private tree. More on that in the next stanza.
> >
> > What I don't understand is if there is ever a case for a clock consumer
> > driver to ever call clk_enable_critical... I do not think there is. What
> > you're trying to protect against is having the clock disabled BEFORE
> > that "knowledgeable driver" has a chance to enable it.
In my mind and in this implementation clk_disable_critical() will be
used _first_ by the knowledgeable driver, then when the knowledgeable
driver has finished whatever it was doing (shutting down banks of RAM
etc...), it should then call clk_enable_critical() to reset the clock
state back to the way it found it i.e. enabled and marked as critical.
> It's really about what we want the API to look like in the second
> case.
>
> Do we want such drivers to still call clk_prepare_enable? Some other
> function? Should they assume that the clock has already been enabled,
> or do we want a handover, or a force disable, or whatever.
>
> I guess we should discuss those questions, before starting to think
> about how to implement it.
>
> IMHO, I think that the existing way of doing should be used, or at
> least with the same mindset to avoid confusion, errors, and
> misinformed reviews.
>
> So I'd expect the drivers to do something like:
>
> probe:
> clk_get
> clk_critical_enable
Well becuase the clock has been marked as critical, a reference has
already been taken, so even if there are 0 users the clock now has 2
references attributed to it.
> remove / probe error path:
> clk_critical_disable
> clk_put
I think we should assume that the clock is already running in the
knowledgeable driver:
start-up:
__set_critical_clocks()
probe:
clk_get()
suspend (or whatever reason the driver wishes to disable the clk):
clk_disable_critical()
resume (or whatever ...):
clk_enable_critical()
remove:
clk_put() /* Or just rely on devm_*() */
> and use the clk_critical_enable and clk_critical_disable whenever
> needed, and thing would just work as intended.
--
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
WARNING: multiple messages have this Message-ID (diff)
From: Lee Jones <lee.jones@linaro.org>
To: Maxime Ripard <maxime.ripard@free-electrons.com>
Cc: Michael Turquette <mturquette@linaro.org>,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, kernel@stlinux.com,
sboyd@codeaurora.org, devicetree@vger.kernel.org,
geert@linux-m68k.org, s.hauer@pengutronix.de
Subject: Re: [PATCH v7 3/5] clk: Supply the critical clock {init, enable, disable} framework
Date: Fri, 31 Jul 2015 09:32:07 +0100 [thread overview]
Message-ID: <20150731083207.GB3208@x1> (raw)
In-Reply-To: <20150731073019.GU2564@lukather>
On Fri, 31 Jul 2015, Maxime Ripard wrote:
> On Thu, Jul 30, 2015 at 03:47:20PM -0700, Michael Turquette wrote:
> > > > > */
> > > > >
> > > > > Resume:
> > > > > /* Order is unimportant */
> > > > > SPI enables Clock 4 (ref == 1)
> > > > > RAM enables Clock 4 and re-enables .leave_on (ref == 2)
> > > > > I2C enables Clock 4 (ref == 3)
> > > >
> > > > Same again. As soon as RAM calls clk_enable_critical the ref count goes
> > > > up. .leave_on does nothing as far as I can tell. The all works because
> > > > of the reference counting, which already exists before this patch
> > > > series.
> > >
> > > So fundamentally you're right in what you say. All you really need to
> > > disable a critical clock is write a knowledgeable driver, which is
> > > intentionally unbalanced i.e. just calls clk_disable(). All this
> >
> > OK, the line above is helpful. What you really want is a formalized
> > hand-off mechanism, whereby the clock is enabled at registration-time
> > and it cannot be turned off until the right driver claims it and decides
> > turning it off is OK (with a priori knowledge that the clock is already
> > enabled).
>
> There's two things that should be covered, and are related, yet can be
> done in two steps:
>
> - Have a way to, no matter what (which configuration we have, if we
> have multiple users or not that might reparent or disable their
> clocks, etc.), make sure that a clock will always be running by
> default. This is done through the call in clk-conf, and we
> identify such clocks using critical-clocks in the DT.
>
> - Now, even though that information is true, some driver who are
> aware of that fact might want to disable those critical
> clocks. This is what the clk_disable_critical and
> clk_enable_critical functions are here for.
+1
> > Note that I don't think this implementation can really work in the near
> > future. Today we do not catch unbalanced calls to clk_enable and
> > clk_disable, but I have a patch that catches this and WARNs loudly in my
> > private tree. More on that in the next stanza.
> >
> > What I don't understand is if there is ever a case for a clock consumer
> > driver to ever call clk_enable_critical... I do not think there is. What
> > you're trying to protect against is having the clock disabled BEFORE
> > that "knowledgeable driver" has a chance to enable it.
In my mind and in this implementation clk_disable_critical() will be
used _first_ by the knowledgeable driver, then when the knowledgeable
driver has finished whatever it was doing (shutting down banks of RAM
etc...), it should then call clk_enable_critical() to reset the clock
state back to the way it found it i.e. enabled and marked as critical.
> It's really about what we want the API to look like in the second
> case.
>
> Do we want such drivers to still call clk_prepare_enable? Some other
> function? Should they assume that the clock has already been enabled,
> or do we want a handover, or a force disable, or whatever.
>
> I guess we should discuss those questions, before starting to think
> about how to implement it.
>
> IMHO, I think that the existing way of doing should be used, or at
> least with the same mindset to avoid confusion, errors, and
> misinformed reviews.
>
> So I'd expect the drivers to do something like:
>
> probe:
> clk_get
> clk_critical_enable
Well becuase the clock has been marked as critical, a reference has
already been taken, so even if there are 0 users the clock now has 2
references attributed to it.
> remove / probe error path:
> clk_critical_disable
> clk_put
I think we should assume that the clock is already running in the
knowledgeable driver:
start-up:
__set_critical_clocks()
probe:
clk_get()
suspend (or whatever reason the driver wishes to disable the clk):
clk_disable_critical()
resume (or whatever ...):
clk_enable_critical()
remove:
clk_put() /* Or just rely on devm_*() */
> and use the clk_critical_enable and clk_critical_disable whenever
> needed, and thing would just work as intended.
--
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
next prev parent reply other threads:[~2015-07-31 8:32 UTC|newest]
Thread overview: 92+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-22 13:04 [PATCH v7 0/5] clk: Provide support for always-on clocks Lee Jones
2015-07-22 13:04 ` Lee Jones
2015-07-22 13:04 ` Lee Jones
2015-07-22 13:04 ` [PATCH v7 1/5] ARM: sti: stih407-family: Supply defines for CLOCKGEN A0 Lee Jones
2015-07-22 13:04 ` Lee Jones
2015-07-22 13:04 ` Lee Jones
2015-07-22 13:04 ` [PATCH v7 2/5] ARM: sti: stih410-clocks: Identify critical clocks Lee Jones
2015-07-22 13:04 ` Lee Jones
2015-07-22 13:04 ` [PATCH v7 3/5] clk: Supply the critical clock {init, enable, disable} framework Lee Jones
2015-07-22 13:04 ` Lee Jones
2015-07-22 13:04 ` Lee Jones
2015-07-27 7:25 ` Maxime Ripard
2015-07-27 7:25 ` Maxime Ripard
2015-07-27 7:25 ` Maxime Ripard
2015-07-27 8:53 ` Lee Jones
2015-07-27 8:53 ` Lee Jones
2015-07-27 8:53 ` Lee Jones
2015-07-28 11:40 ` Maxime Ripard
2015-07-28 11:40 ` Maxime Ripard
2015-07-28 13:00 ` Lee Jones
2015-07-28 13:00 ` Lee Jones
2015-07-28 13:00 ` Lee Jones
2015-07-30 1:19 ` Michael Turquette
2015-07-30 1:19 ` Michael Turquette
2015-07-30 1:19 ` Michael Turquette
2015-07-30 9:50 ` Lee Jones
2015-07-30 9:50 ` Lee Jones
2015-07-30 9:50 ` Lee Jones
2015-07-30 22:47 ` Michael Turquette
2015-07-30 22:47 ` Michael Turquette
2015-07-31 7:30 ` Maxime Ripard
2015-07-31 7:30 ` Maxime Ripard
2015-07-31 7:30 ` Maxime Ripard
2015-07-31 8:32 ` Lee Jones [this message]
2015-07-31 8:32 ` Lee Jones
2015-07-31 8:32 ` Lee Jones
2015-07-31 7:03 ` Maxime Ripard
2015-07-31 7:03 ` Maxime Ripard
2015-07-31 7:03 ` Maxime Ripard
2015-07-31 8:48 ` Lee Jones
2015-07-31 8:48 ` Lee Jones
2015-07-30 1:21 ` Michael Turquette
2015-07-30 1:21 ` Michael Turquette
2015-07-30 1:21 ` Michael Turquette
2015-07-30 9:21 ` Lee Jones
2015-07-30 9:21 ` Lee Jones
2015-07-30 9:21 ` Lee Jones
2015-07-30 22:57 ` Michael Turquette
2015-07-30 22:57 ` Michael Turquette
2015-07-31 8:56 ` Lee Jones
2015-07-31 8:56 ` Lee Jones
2015-07-31 8:56 ` Lee Jones
2015-07-30 1:02 ` Michael Turquette
2015-07-30 1:02 ` Michael Turquette
2015-07-30 1:02 ` Michael Turquette
2015-07-30 11:17 ` Lee Jones
2015-07-30 11:17 ` Lee Jones
2015-07-30 23:35 ` Michael Turquette
2015-07-30 23:35 ` Michael Turquette
2015-07-30 23:35 ` Michael Turquette
2015-07-31 9:02 ` Lee Jones
2015-07-31 9:02 ` Lee Jones
2015-08-01 0:59 ` Michael Turquette
2015-08-01 0:59 ` Michael Turquette
2015-08-01 0:59 ` Michael Turquette
2015-07-22 13:04 ` [PATCH v7 4/5] clk: Provide critical clock support Lee Jones
2015-07-22 13:04 ` Lee Jones
2015-07-22 13:04 ` Lee Jones
2015-08-17 5:43 ` Barry Song
2015-08-17 5:43 ` Barry Song
2015-08-17 5:43 ` Barry Song
2015-08-17 7:42 ` Lee Jones
2015-08-17 7:42 ` Lee Jones
2015-08-20 13:23 ` Barry Song
2015-08-20 13:23 ` Barry Song
2015-08-20 13:23 ` Barry Song
2015-07-22 13:04 ` [PATCH v7 5/5] clk: dt: Introduce binding for " Lee Jones
2015-07-22 13:04 ` Lee Jones
2015-07-22 13:04 ` Lee Jones
2015-07-27 7:10 ` Maxime Ripard
2015-07-27 7:10 ` Maxime Ripard
2015-07-27 7:31 ` Lee Jones
2015-07-27 7:31 ` Lee Jones
2015-07-28 9:32 ` Maxime Ripard
2015-07-28 9:32 ` Maxime Ripard
2015-07-30 9:23 ` Lee Jones
2015-07-30 9:23 ` Lee Jones
2015-07-30 0:27 ` [PATCH v7 0/5] clk: Provide support for always-on clocks Michael Turquette
2015-07-30 0:27 ` Michael Turquette
2015-07-30 0:27 ` Michael Turquette
2015-07-30 9:09 ` Lee Jones
2015-07-30 9:09 ` Lee Jones
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=20150731083207.GB3208@x1 \
--to=lee.jones@linaro.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.