From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
To: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Cc: Thomas Gleixner <tglx@linutronix.de>,
Boris Brezillon <boris.brezillon@free-electrons.com>,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, linux-rt-users@vger.kernel.org,
Nicolas Ferre <nicolas.ferre@atmel.com>
Subject: arm: at91: do not disable/enable clocks in a row
Date: Wed, 9 Mar 2016 10:58:24 +0100 [thread overview]
Message-ID: <20160309095824.GC10517@linutronix.de> (raw)
In-Reply-To: <20160308183910.GD5845@piout.net>
* Alexandre Belloni | 2016-03-08 19:39:10 [+0100]:
>Hi,
Hi,
>Both are things to work on. In the mean time, I'm using the following
>patch:
>https://github.com/alexandrebelloni/linux/commit/3a2eae463fce18ae815b887a5c9ca1a657b180ac
>
>I understood from
>http://lkml.iu.edu/hypermail/linux/kernel/1601.2/00941.html that this
>was not your preferred course of action.
That was one thing. What about this:
---
Currently the driver will disable the clock and enable it one line later
if it is switching from periodic mode into one shot.
This can be avoided and causes a needless warning on -RT.
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
drivers/clocksource/tcb_clksrc.c | 33 +++++++++++++++++++++++++++++----
1 file changed, 29 insertions(+), 4 deletions(-)
--- a/drivers/clocksource/tcb_clksrc.c
+++ b/drivers/clocksource/tcb_clksrc.c
@@ -74,6 +74,7 @@ static struct clocksource clksrc = {
struct tc_clkevt_device {
struct clock_event_device clkevt;
struct clk *clk;
+ bool clk_enabled;
void __iomem *regs;
};
@@ -91,6 +92,24 @@ static struct tc_clkevt_device *to_tc_cl
*/
static u32 timer_clock;
+static void tc_clk_disable(struct clock_event_device *d)
+{
+ struct tc_clkevt_device *tcd = to_tc_clkevt(d);
+
+ clk_disable(tcd->clk);
+ tcd->clk_enabled = false;
+}
+
+static void tc_clk_enable(struct clock_event_device *d)
+{
+ struct tc_clkevt_device *tcd = to_tc_clkevt(d);
+
+ if (tcd->clk_enabled)
+ return;
+ clk_enable(tcd->clk);
+ tcd->clk_enabled = true;
+}
+
static int tc_shutdown(struct clock_event_device *d)
{
struct tc_clkevt_device *tcd = to_tc_clkevt(d);
@@ -98,8 +117,14 @@ static int tc_shutdown(struct clock_even
__raw_writel(0xff, regs + ATMEL_TC_REG(2, IDR));
__raw_writel(ATMEL_TC_CLKDIS, regs + ATMEL_TC_REG(2, CCR));
+ return 0;
+}
+
+static int tc_shutdown_clk_off(struct clock_event_device *d)
+{
+ tc_shutdown(d);
if (!clockevent_state_detached(d))
- clk_disable(tcd->clk);
+ tc_clk_disable(d);
return 0;
}
@@ -112,7 +137,7 @@ static int tc_set_oneshot(struct clock_e
if (clockevent_state_oneshot(d) || clockevent_state_periodic(d))
tc_shutdown(d);
- clk_enable(tcd->clk);
+ tc_clk_enable(d);
/* slow clock, count up to RC, then irq and stop */
__raw_writel(timer_clock | ATMEL_TC_CPCSTOP | ATMEL_TC_WAVE |
@@ -134,7 +159,7 @@ static int tc_set_periodic(struct clock_
/* By not making the gentime core emulate periodic mode on top
* of oneshot, we get lower overhead and improved accuracy.
*/
- clk_enable(tcd->clk);
+ tc_clk_enable(d);
/* slow clock, count up to RC, then irq and restart */
__raw_writel(timer_clock | ATMEL_TC_WAVE | ATMEL_TC_WAVESEL_UP_AUTO,
@@ -168,7 +193,7 @@ static struct tc_clkevt_device clkevt =
/* Should be lower than at91rm9200's system timer */
.rating = 125,
.set_next_event = tc_next_event,
- .set_state_shutdown = tc_shutdown,
+ .set_state_shutdown = tc_shutdown_clk_off,
.set_state_periodic = tc_set_periodic,
.set_state_oneshot = tc_set_oneshot,
},
Sebastian
next prev parent reply other threads:[~2016-03-09 9:58 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-17 2:23 Fix preempt-rt on AT91 Alexandre Belloni
2016-01-17 2:23 ` Alexandre Belloni
2016-01-17 2:23 ` [PATCH 4.4-rt2] fix arm-at91-pit-remove-irq-handler-when-clock-is-unused.patch Alexandre Belloni
2016-01-17 2:23 ` Alexandre Belloni
2016-01-18 17:25 ` Sebastian Andrzej Siewior
2016-01-18 17:25 ` Sebastian Andrzej Siewior
2016-01-18 17:25 ` Sebastian Andrzej Siewior
2016-01-18 18:42 ` Alexandre Belloni
2016-01-18 18:42 ` Alexandre Belloni
2016-01-18 20:24 ` Sebastian Andrzej Siewior
2016-01-18 20:24 ` Sebastian Andrzej Siewior
2016-01-19 1:22 ` Alexandre Belloni
2016-01-19 1:22 ` Alexandre Belloni
2016-01-20 11:07 ` Thomas Gleixner
2016-01-20 11:07 ` Thomas Gleixner
2016-03-17 19:55 ` Alexandre Belloni
2016-03-17 19:55 ` Alexandre Belloni
2016-01-18 17:42 ` Fix preempt-rt on AT91 Sebastian Andrzej Siewior
2016-01-18 17:42 ` Sebastian Andrzej Siewior
2016-01-18 19:23 ` Alexandre Belloni
2016-01-18 19:23 ` Alexandre Belloni
2016-01-18 20:30 ` Sebastian Andrzej Siewior
2016-01-18 20:30 ` Sebastian Andrzej Siewior
2016-01-19 1:02 ` Alexandre Belloni
2016-01-19 1:02 ` Alexandre Belloni
2016-03-05 11:35 ` Alexandre Belloni
2016-03-05 11:35 ` Alexandre Belloni
2016-03-08 11:06 ` Sebastian Andrzej Siewior
2016-03-08 11:06 ` Sebastian Andrzej Siewior
2016-03-08 11:26 ` Thomas Gleixner
2016-03-08 11:26 ` Thomas Gleixner
2016-03-08 18:39 ` Alexandre Belloni
2016-03-08 18:39 ` Alexandre Belloni
2016-03-09 9:58 ` Sebastian Andrzej Siewior [this message]
2016-03-17 18:09 ` arm: at91: do not disable/enable clocks in a row Alexandre Belloni
2016-03-17 18:09 ` Alexandre Belloni
2016-02-18 20:16 ` Fix preempt-rt on AT91 Jean-Denis Girard
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=20160309095824.GC10517@linutronix.de \
--to=bigeasy@linutronix.de \
--cc=alexandre.belloni@free-electrons.com \
--cc=boris.brezillon@free-electrons.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rt-users@vger.kernel.org \
--cc=nicolas.ferre@atmel.com \
--cc=tglx@linutronix.de \
/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.