: clockevents/clocksource fixes for 4.8
Subsystems (4)
Hi Ingo,
this pull request for tip/timers/urgent contains two critical fixes and one spurious compiler warning.
- Change the get_counter error handling function in order to prevent a
warning generated by gcc for the kona driver (Arnd Bergman)
- Fix a wrong clock reference leading to a kernel hang and slow bootup.
The init function conversion introduced a regression by taking the wrong clock on armada-370-xp (Gregory Clement)
- Fix the init function prototype to return int on the mips-gic-driver
(Paul Gortmaker)
Thanks !
-- Daniel
The following changes since commit 1f3b0f8243cb934307f59bd4d8e43b868e61d4d9:
tick/nohz: Optimize nohz idle enter (2016-07-19 13:48:24 +0200)
are available in the git repository at:
ssh://[email protected]/people/daniel.lezcano/linux.git
clockevents/4.8-fixes
for you to fetch changes up to 394bc60a7ce8d4aa0f5b83b7e121dcdb393739d1:
clocksource/drivers/mips-gic-timer: Make gic_clocksource_of_init
return int (2016-08-17 07:36:32 +0200)
----------------------------------------------------------------
Arnd Bergmann (1):
clocksource/drivers/kona: Fix get_counter error handling
Gregory CLEMENT (1):
clocksource/drivers/time-armada-370-xp: Fix the clock reference
Paul Gortmaker (1):
clocksource/drivers/mips-gic-timer: Make gic_clocksource_of_init
return int
drivers/clocksource/bcm_kona_timer.c | 16 ++++++++++------ drivers/clocksource/mips-gic-timer.c | 2 +- drivers/clocksource/time-armada-370-xp.c | 1 - 3 files changed, 11 insertions(+), 8 deletions(-)
Signature · 5 lines
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook | <http://twitter.com/#!/linaroorg> Twitter | <http://www.linaro.org/linaro-blog/> Blog
PATCH 1/3 clocksource/drivers/time-armada-370-xp: Fix the clock reference
From: Gregory CLEMENT <[email protected]>
While converting the init function to return an error, the wrong clock was get. This lead to wrong clock rate and slow down the kernel. For example, before the patch a typical boot was around 15s after it was 1 minute slower.
--- drivers/clocksource/time-armada-370-xp.c | 1 - 1 file changed, 1 deletion(-)
drivers/clocksource/time-armada-370-xp.c +0 -1
@@ -357,7 +357,6 @@ static int __init armada_xp_timer_init(struct device_node *np)struct clk *clk =of_clk_get_by_name (np,"fixed" );int ret; - clk =of_clk_get (np,0 );if (IS_ERR (clk)) {pr_err ("Failed to get clock" );return PTR_ERR (clk);
Signature · 1 line
1.9.1
PATCH 2/3 clocksource/drivers/kona: Fix get_counter error handling
From: Arnd Bergmann <[email protected]>
I could not figure out why, but gcc cannot prove that the kona_timer_init function always initializes its two outputs, and we get a warning for the use of the 'lsw' variable later, which is obviously correct.
drivers/clocksource/bcm_kona_timer.c: In function 'kona_timer_init':drivers/clocksource/bcm_kona_timer.c:119:13: error: 'lsw' may be used uninitialized in this function [-Werror=maybe-uninitialized]
Slightly reordering the loop makes the warning disappear, after it becomes more obvious to the compiler that the loop is always entered on the first iteration.
As pointed out by Ray Jui, there is a related problem in the way we deal with the loop running into the limit, as we just keep going there with an invalid counter data, so instead we now propagate a -ETIMEDOUT result to the caller.
--- drivers/clocksource/bcm_kona_timer.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
drivers/clocksource/bcm_kona_timer.c +10 -6
@@ -66,10 +66,10 @@ static void kona_timer_disable_and_clear(void __iomem *base) } -static void +static int kona_timer_get_counter (void __iomem *timer_base,uint32_t *msw,uint32_t *lsw) { -int loop_limit =4 ; +int loop_limit =3 ;/* * Read 64-bit free running counter
@@ -83,18 +83,19 @@ kona_timer_get_counter(void __iomem *timer_base, uint32_t *msw, uint32_t *lsw)* if new hi-word is equal to previously read hi-word then stop. */ -while (--loop_limit) { +do { *msw =readl (timer_base +KONA_GPTIMER_STCHI_OFFSET ); *lsw =readl (timer_base +KONA_GPTIMER_STCLO_OFFSET );if (*msw ==readl (timer_base +KONA_GPTIMER_STCHI_OFFSET ))break ; - } + }while (--loop_limit);if (!loop_limit) {pr_err ("bcm_kona_timer: getting counter failed.\n" );pr_err (" Timer will be impacted\n" ); +return -ETIMEDOUT ; } -return ; +return 0 ; } static int kona_timer_set_next_event(unsigned long clc,
@@ -112,8 +113,11 @@ static int kona_timer_set_next_event(unsigned long clc,uint32_t lsw, msw;uint32_t reg; +int ret; -kona_timer_get_counter (timers.tmr_regs, &msw, &lsw); + ret =kona_timer_get_counter (timers.tmr_regs, &msw, &lsw); +if (ret) +return ret;/* Load the "next" event tick value */ writel (lsw + clc, timers.tmr_regs +KONA_GPTIMER_STCM0_OFFSET );
Signature · 1 line
1.9.1
PATCH 3/3 clocksource/drivers/mips-gic-timer: Make gic_clocksource_of_init return int
In reply to Daniel LezcanoFrom: Paul Gortmaker <[email protected]>
In commit d8152bf85d2c057fc39c3e20a4d623f524d9f09c:
("clocksource/drivers/mips-gic-timer: Convert init function to return error")
several return values were added to a void function resulting in:
clocksource/mips-gic-timer.c: In function 'gic_clocksource_of_init':
clocksource/mips-gic-timer.c:175:3: warning: 'return' with a value, in function returning void [enabled by default] clocksource/mips-gic-timer.c:183:4: warning: 'return' with a value, in function returning void [enabled by default] clocksource/mips-gic-timer.c:190:3: warning: 'return' with a value, in function returning void [enabled by default] clocksource/mips-gic-timer.c:195:3: warning: 'return' with a value, in function returning void [enabled by default] clocksource/mips-gic-timer.c:200:3: warning: 'return' with a value, in function returning void [enabled by default] clocksource/mips-gic-timer.c:211:2: warning: 'return' with a value, in function returning void [enabled by default] clocksource/mips-gic-timer.c: At top level:
clocksource/mips-gic-timer.c:213:1: warning: comparison of distinct pointer types lacks a cast [enabled by default] clocksource/mips-gic-timer.c: In function 'gic_clocksource_of_init':
clocksource/mips-gic-timer.c:183:18: warning: ignoring return value of 'PTR_ERR', declared with attribute warn_unused_result [-Wunused-result]
Given that the addition of the return values was intentional, it seems that the conversion of the containing function from void to int was simply overlooked.
--- drivers/clocksource/mips-gic-timer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clocksource/mips-gic-timer.c +1 -1
@@ -176,7 +176,7 @@ void __init gic_clocksource_init(unsigned int frequency)gic_start_count (); } -static void __init gic_clocksource_of_init (struct device_node *node) +static int __init gic_clocksource_of_init (struct device_node *node) {struct clk *clk;int ret;
Signature · 1 line
1.9.1
tip-bot for Gregory CLEMENT
merge bot[tip:timers/urgent] clocksource/drivers/time-armada-370-xp: Fix the clock reference
In reply to Daniel Lezcanoclocksource/drivers/time-armada-370-xp: Fix the clock reference
Commit-ID: 0e62fd836e4c2908cc1e32c68806529b4f859955 Gitweb: http://git.kernel.org/tip/0e62fd836e4c2908cc1e32c68806529b4f859955 Author: Gregory CLEMENT <[email protected]> AuthorDate: Wed, 17 Aug 2016 12:21:33 +0200 Committer: Ingo Molnar <[email protected]> CommitDate: Wed, 17 Aug 2016 13:08:31 +0200
clocksource/drivers/time-armada-370-xp: Fix the clock reference
While converting the init function to return an error, the wrong clock was get. This leads to the wrong clock rate and slows down the kernel. For example, it affects typical boot time:
- without fix: over 1 minute
- with fix: 15 seconds
--- drivers/clocksource/time-armada-370-xp.c | 1 - 1 file changed, 1 deletion(-)
drivers/clocksource/time-armada-370-xp.c +0 -1
@@ -338,7 +338,6 @@ static int __init armada_xp_timer_init(struct device_node *np)struct clk *clk =of_clk_get_by_name (np,"fixed" );int ret; - clk =of_clk_get (np,0 );if (IS_ERR (clk)) {pr_err ("Failed to get clock" );return PTR_ERR (clk);
tip-bot for Arnd Bergmann
merge bot[tip:timers/urgent] clocksource/drivers/kona: Fix get_counter() error handling
In reply to Daniel Lezcanoclocksource/drivers/kona: Fix get_counter() error handling
Commit-ID: 16c8eba0fe01e03317f48868105103a8f5938e85 Gitweb: http://git.kernel.org/tip/16c8eba0fe01e03317f48868105103a8f5938e85 Author: Arnd Bergmann <[email protected]> AuthorDate: Wed, 17 Aug 2016 12:21:34 +0200 Committer: Ingo Molnar <[email protected]> CommitDate: Wed, 17 Aug 2016 13:08:31 +0200
clocksource/drivers/kona: Fix get_counter() error handling
I could not figure out why, but GCC cannot prove that the kona_timer_init() function always initializes its two outputs, and we get a warning for the use of the 'lsw' variable later, which is obviously correct.
drivers/clocksource/bcm_kona_timer.c: In function 'kona_timer_init':
drivers/clocksource/bcm_kona_timer.c:119:13: error: 'lsw' may be used uninitialized in this function [-Werror=maybe-uninitialized]
Slightly reordering the loop makes the warning disappear, after it becomes more obvious to the compiler that the loop is always entered on the first iteration.
As pointed out by Ray Jui, there is a related problem in the way we deal with the loop running into the limit, as we just keep going there with an invalid counter data, so instead we now propagate a -ETIMEDOUT result to the caller.
--- drivers/clocksource/bcm_kona_timer.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
drivers/clocksource/bcm_kona_timer.c +10 -6
@@ -66,10 +66,10 @@ static void kona_timer_disable_and_clear(void __iomem *base) } -static void +static int kona_timer_get_counter (void __iomem *timer_base,uint32_t *msw,uint32_t *lsw) { -int loop_limit =4 ; +int loop_limit =3 ;/* * Read 64-bit free running counter
@@ -83,18 +83,19 @@ kona_timer_get_counter(void __iomem *timer_base, uint32_t *msw, uint32_t *lsw)* if new hi-word is equal to previously read hi-word then stop. */ -while (--loop_limit) { +do { *msw =readl (timer_base +KONA_GPTIMER_STCHI_OFFSET ); *lsw =readl (timer_base +KONA_GPTIMER_STCLO_OFFSET );if (*msw ==readl (timer_base +KONA_GPTIMER_STCHI_OFFSET ))break ; - } + }while (--loop_limit);if (!loop_limit) {pr_err ("bcm_kona_timer: getting counter failed.\n" );pr_err (" Timer will be impacted\n" ); +return -ETIMEDOUT ; } -return ; +return 0 ; } static int kona_timer_set_next_event(unsigned long clc,
@@ -112,8 +113,11 @@ static int kona_timer_set_next_event(unsigned long clc,uint32_t lsw, msw;uint32_t reg; +int ret; -kona_timer_get_counter (timers.tmr_regs, &msw, &lsw); + ret =kona_timer_get_counter (timers.tmr_regs, &msw, &lsw); +if (ret) +return ret;/* Load the "next" event tick value */ writel (lsw + clc, timers.tmr_regs +KONA_GPTIMER_STCM0_OFFSET );
tip-bot for Paul Gortmaker
merge bot[tip:timers/urgent] clocksource/drivers/mips-gic-timer: Make gic_clocksource_of_init() return int
In reply to Daniel Lezcanoclocksource/drivers/mips-gic-timer: Make gic_clocksource_of_init() return int
Commit-ID: be5769e2061ac40b32daa83e28e1c4aac7133511 Gitweb: http://git.kernel.org/tip/be5769e2061ac40b32daa83e28e1c4aac7133511 Author: Paul Gortmaker <[email protected]> AuthorDate: Wed, 17 Aug 2016 12:21:35 +0200 Committer: Ingo Molnar <[email protected]> CommitDate: Wed, 17 Aug 2016 13:08:32 +0200
clocksource/drivers/mips-gic-timer: Make gic_clocksource_of_init() return int
In commit:
d8152bf85d2c0 ("clocksource/drivers/mips-gic-timer: Convert init function to return error")
several return values were added to a void function resulting in the following warnings:
clocksource/mips-gic-timer.c: In function 'gic_clocksource_of_init':
clocksource/mips-gic-timer.c:175:3: warning: 'return' with a value, in function returning void [enabled by default] clocksource/mips-gic-timer.c:183:4: warning: 'return' with a value, in function returning void [enabled by default] clocksource/mips-gic-timer.c:190:3: warning: 'return' with a value, in function returning void [enabled by default] clocksource/mips-gic-timer.c:195:3: warning: 'return' with a value, in function returning void [enabled by default] clocksource/mips-gic-timer.c:200:3: warning: 'return' with a value, in function returning void [enabled by default] clocksource/mips-gic-timer.c:211:2: warning: 'return' with a value, in function returning void [enabled by default] clocksource/mips-gic-timer.c: At top level:
clocksource/mips-gic-timer.c:213:1: warning: comparison of distinct pointer types lacks a cast [enabled by default] clocksource/mips-gic-timer.c: In function 'gic_clocksource_of_init':
clocksource/mips-gic-timer.c:183:18: warning: ignoring return value of 'PTR_ERR', declared with attribute warn_unused_result [-Wunused-result]
Given that the addition of the return values was intentional, it seems that the conversion of the containing function from void to int was simply overlooked.
--- drivers/clocksource/mips-gic-timer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clocksource/mips-gic-timer.c +1 -1
@@ -164,7 +164,7 @@ void __init gic_clocksource_init(unsigned int frequency)gic_start_count (); } -static void __init gic_clocksource_of_init (struct device_node *node) +static int __init gic_clocksource_of_init (struct device_node *node) {struct clk *clk;int ret;