Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754786AbeAHRiu (ORCPT + 1 other); Mon, 8 Jan 2018 12:38:50 -0500 Received: from terminus.zytor.com ([65.50.211.136]:34699 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754002AbeAHRip (ORCPT ); Mon, 8 Jan 2018 12:38:45 -0500 Date: Mon, 8 Jan 2018 09:34:19 -0800 From: tip-bot for Daniel Lezcano Message-ID: Cc: alexandre.torgue@st.com, torvalds@linux-foundation.org, linux-kernel@vger.kernel.org, mingo@kernel.org, daniel.lezcano@linaro.org, hpa@zytor.com, peterz@infradead.org, benjamin.gaignard@st.com, mcoquelin.stm32@gmail.com, tglx@linutronix.de Reply-To: mcoquelin.stm32@gmail.com, benjamin.gaignard@st.com, peterz@infradead.org, tglx@linutronix.de, hpa@zytor.com, daniel.lezcano@linaro.org, linux-kernel@vger.kernel.org, mingo@kernel.org, torvalds@linux-foundation.org, alexandre.torgue@st.com In-Reply-To: <1515418139-23276-20-git-send-email-daniel.lezcano@linaro.org> References: <1515418139-23276-20-git-send-email-daniel.lezcano@linaro.org> To: linux-tip-commits@vger.kernel.org Subject: [tip:timers/core] clocksource/drivers/stm32: Start the timer's counter sooner Git-Commit-ID: 103bb56a2831bfc7f2d442da9e47f89f37d34952 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: Commit-ID: 103bb56a2831bfc7f2d442da9e47f89f37d34952 Gitweb: https://git.kernel.org/tip/103bb56a2831bfc7f2d442da9e47f89f37d34952 Author: Daniel Lezcano AuthorDate: Mon, 8 Jan 2018 14:28:59 +0100 Committer: Ingo Molnar CommitDate: Mon, 8 Jan 2018 17:57:26 +0100 clocksource/drivers/stm32: Start the timer's counter sooner As we have a lot of timers on this platform, we can have potentially all the timers enabled in the DT, so we don't want to start the timer for every probe otherwise they will be running for nothing as only one will be used. Start the timer only when setting the mode or when the clocksource is enabled. Tested-by: Benjamin Gaignard Signed-off-by: Daniel Lezcano Acked-by: Benjamin Gaignard Cc: Alexandre Torgue Cc: Linus Torvalds Cc: Maxime Coquelin Cc: Peter Zijlstra Cc: Thomas Gleixner Link: http://lkml.kernel.org/r/1515418139-23276-20-git-send-email-daniel.lezcano@linaro.org Signed-off-by: Ingo Molnar --- drivers/clocksource/timer-stm32.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/drivers/clocksource/timer-stm32.c b/drivers/clocksource/timer-stm32.c index c7d1dae..e5cdc3a 100644 --- a/drivers/clocksource/timer-stm32.c +++ b/drivers/clocksource/timer-stm32.c @@ -101,7 +101,15 @@ static void stm32_clock_event_disable(struct timer_of *to) writel_relaxed(0, timer_of_base(to) + TIM_DIER); } -static void stm32_clock_event_enable(struct timer_of *to) +/** + * stm32_timer_start - Start the counter without event + * @to: a timer_of structure pointer + * + * Start the timer in order to have the counter reset and start + * incrementing but disable interrupt event when there is a counter + * overflow. By default, the counter direction is used as upcounter. + */ +static void stm32_timer_start(struct timer_of *to) { writel_relaxed(TIM_CR1_UDIS | TIM_CR1_CEN, timer_of_base(to) + TIM_CR1); } @@ -137,7 +145,7 @@ static int stm32_clock_event_set_periodic(struct clock_event_device *clkevt) { struct timer_of *to = to_timer_of(clkevt); - stm32_clock_event_enable(to); + stm32_timer_start(to); return stm32_clock_event_set_next_event(timer_of_period(to), clkevt); } @@ -146,7 +154,7 @@ static int stm32_clock_event_set_oneshot(struct clock_event_device *clkevt) { struct timer_of *to = to_timer_of(clkevt); - stm32_clock_event_enable(to); + stm32_timer_start(to); return 0; } @@ -235,6 +243,13 @@ static int __init stm32_clocksource_init(struct timer_of *to) * sched_clock. */ if (bits == 32 && !stm32_timer_cnt) { + + /* + * Start immediately the counter as we will be using + * it right after. + */ + stm32_timer_start(to); + stm32_timer_cnt = timer_of_base(to) + TIM_CNT; sched_clock_register(stm32_read_sched_clock, bits, timer_of_rate(to)); pr_info("%s: STM32 sched_clock registered\n", name);