Skip to content

Commit db38da8

Browse files
Rajendra Nayakgregkh
authored andcommitted
ARM: OMAP: clocks: Delay clk inits atleast until slab is initialized
commit ff931c8 upstream. clk inits on OMAP happen quite early, even before slab is available. The dependency comes from the fact that the timer init code starts to use clocks and hwmod and we need clocks to be initialized by then. There are various problems doing clk inits this early, one is, not being able to do dynamic clk registrations and hence the dependency on clk-private.h. The other is, inability to debug early kernel crashes without enabling DEBUG_LL and earlyprintk. Doing early clk init also exposed another instance of a kernel panic due to a BUG() when CONFIG_DEBUG_SLAB is enabled. [ 0.000000] Kernel BUG at c01174f8 [verbose debug info unavailable] [ 0.000000] Internal error: Oops - BUG: 0 [#1] SMP ARM [ 0.000000] Modules linked in: [ 0.000000] CPU: 0 Not tainted (3.9.0-rc1-12179-g72d48f9 #6) [ 0.000000] PC is at __kmalloc+0x1d4/0x248 [ 0.000000] LR is at __clk_init+0x2e0/0x364 [ 0.000000] pc : [<c01174f8>] lr : [<c0441f54>] psr: 600001d3 [ 0.000000] sp : c076ff28 ip : c065cefc fp : c0441f54 [ 0.000000] r10: 0000001c r9 : 000080d0 r8 : c076ffd4 [ 0.000000] r7 : c074b578 r6 : c0794d88 r5 : 00000040 r4 : 00000000 [ 0.000000] r3 : 00000000 r2 : c07cac70 r1 : 000080d0 r0 : 0000001c [ 0.000000] Flags: nZCv IRQs off FIQs off Mode SVC_32 ISA ARM Segment kernel [ 0.000000] Control: 10c53c7d Table: 8000404a DAC: 00000017 [ 0.000000] Process swapper (pid: 0, stack limit = 0xc076e240) [ 0.000000] Stack: (0xc076ff28 to 0xc0770000) [ 0.000000] ff20: 22222222 c0794ec8 c06546e8 00000000 00000040 c0794d88 [ 0.000000] ff40: c074b578 c076ffd4 c07951c8 c076e000 00000000 c0441f54 c074b578 c076ffd4 [ 0.000000] ff60: c0793828 00000040 c0794d88 c074b578 c076ffd4 c0776900 c076e000 c07272ac [ 0.000000] ff80: 2f800000 c074c968 c07f93d0 c0719780 c076ffa0 c076ff98 00000000 00000000 [ 0.000000] ffa0: 00000000 00000000 00000000 00000001 c074cd6c c077b1ec 8000406 c0715724 [ 0.000000] ffc0: 00000000 00000000 00000000 00000000 00000000 c074c968 10c53c7d c0776974 [ 0.000000] ffe0: c074cd6c c077b1ec 8000406 411fc092 00000000 80008074 00000000 00000000 [ 0.000000] [<c01174f8>] (__kmalloc+0x1d4/0x248) from [<c0441f54>] (__clk_init+0x2e0/0x364) [ 0.000000] [<c0441f54>] (__clk_init+0x2e0/0x364) from [<c07272ac>] (omap4xxx_clk_init+0xbc/0x140) [ 0.000000] [<c07272ac>] (omap4xxx_clk_init+0xbc/0x140) from [<c0719780>] (setup_arch+0x15c/0x284) [ 0.000000] [<c0719780>] (setup_arch+0x15c/0x284) from [<c0715724>] (start_kernel+0x7c/0x334) [ 0.000000] [<c0715724>] (start_kernel+0x7c/0x334) from [<80008074>] (0x80008074) [ 0.000000] Code: e5883004 e1a00006 e28dd00c e8bd8ff0 (e7f001f2) [ 0.000000] ---[ end trace 1b75b31a2719ed1c ]--- [ 0.000000] Kernel panic - not syncing: Attempted to kill the idle task! It was a know issue, that slab allocations would fail when common clock core tries to cache parent pointers for mux clocks on OMAP, and hence a patch 'clk: Allow late cache allocation for clk->parents, commit 7975059' was added to work this problem around. A BUG() within kmalloc() with CONFIG_DEBUG_SLAB enabled was completely overlooked causing this regression. More details on the issue reported can be found here, http://www.mail-archive.com/[email protected]/msg85932.html With all these issues around clk inits happening way too early, it makes sense to at least move them to a point where dynamic memory allocations are possible. So move them to a point just before the timer code starts using clocks and hwmod. This should at least pave way for clk inits on OMAP moving to dynamic clock registrations instead of using the static macros defined in clk-private.h. The issue with kernel panic while CONFIG_DEBUG_SLAB is enabled was reported by Piotr Haber and Tony Lindgren and this patch fixes the reported issue as well. Reported-by: Piotr Haber <[email protected]> Reported-by: Tony Lindgren <[email protected]> Signed-off-by: Rajendra Nayak <[email protected]> Acked-by: Santosh Shilimkar <[email protected]> Reviewed-by: Mike Turquette <[email protected]> Acked-by: Paul Walmsley <[email protected]> Signed-off-by: Tony Lindgren <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 9daa43b commit db38da8

File tree

3 files changed

+19
-6
lines changed

3 files changed

+19
-6
lines changed

arch/arm/mach-omap2/common.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,5 +286,8 @@ extern void omap_reserve(void);
286286
struct omap_hwmod;
287287
extern int omap_dss_reset(struct omap_hwmod *);
288288

289+
/* SoC specific clock initializer */
290+
extern int (*omap_clk_init)(void);
291+
289292
#endif /* __ASSEMBLER__ */
290293
#endif /* __ARCH_ARM_MACH_OMAP2PLUS_COMMON_H */

arch/arm/mach-omap2/io.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@
5454
#include "prm3xxx.h"
5555
#include "prm44xx.h"
5656

57+
/*
58+
* omap_clk_init: points to a function that does the SoC-specific
59+
* clock initializations
60+
*/
61+
int (*omap_clk_init)(void);
62+
5763
/*
5864
* The machine specific code may provide the extra mapping besides the
5965
* default mapping provided here.
@@ -397,7 +403,7 @@ void __init omap2420_init_early(void)
397403
omap242x_clockdomains_init();
398404
omap2420_hwmod_init();
399405
omap_hwmod_init_postsetup();
400-
omap2420_clk_init();
406+
omap_clk_init = omap2420_clk_init;
401407
}
402408

403409
void __init omap2420_init_late(void)
@@ -427,7 +433,7 @@ void __init omap2430_init_early(void)
427433
omap243x_clockdomains_init();
428434
omap2430_hwmod_init();
429435
omap_hwmod_init_postsetup();
430-
omap2430_clk_init();
436+
omap_clk_init = omap2430_clk_init;
431437
}
432438

433439
void __init omap2430_init_late(void)
@@ -462,7 +468,7 @@ void __init omap3_init_early(void)
462468
omap3xxx_clockdomains_init();
463469
omap3xxx_hwmod_init();
464470
omap_hwmod_init_postsetup();
465-
omap3xxx_clk_init();
471+
omap_clk_init = omap3xxx_clk_init;
466472
}
467473

468474
void __init omap3430_init_early(void)
@@ -500,7 +506,7 @@ void __init ti81xx_init_early(void)
500506
omap3xxx_clockdomains_init();
501507
omap3xxx_hwmod_init();
502508
omap_hwmod_init_postsetup();
503-
omap3xxx_clk_init();
509+
omap_clk_init = omap3xxx_clk_init;
504510
}
505511

506512
void __init omap3_init_late(void)
@@ -568,7 +574,7 @@ void __init am33xx_init_early(void)
568574
am33xx_clockdomains_init();
569575
am33xx_hwmod_init();
570576
omap_hwmod_init_postsetup();
571-
am33xx_clk_init();
577+
omap_clk_init = am33xx_clk_init;
572578
}
573579
#endif
574580

@@ -593,7 +599,7 @@ void __init omap4430_init_early(void)
593599
omap44xx_clockdomains_init();
594600
omap44xx_hwmod_init();
595601
omap_hwmod_init_postsetup();
596-
omap4xxx_clk_init();
602+
omap_clk_init = omap4xxx_clk_init;
597603
}
598604

599605
void __init omap4430_init_late(void)

arch/arm/mach-omap2/timer.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,8 @@ static inline void __init realtime_counter_init(void)
554554
clksrc_nr, clksrc_src) \
555555
static void __init omap##name##_gptimer_timer_init(void) \
556556
{ \
557+
if (omap_clk_init) \
558+
omap_clk_init(); \
557559
omap_dmtimer_init(); \
558560
omap2_gp_clockevent_init((clkev_nr), clkev_src, clkev_prop); \
559561
omap2_gptimer_clocksource_init((clksrc_nr), clksrc_src); \
@@ -563,6 +565,8 @@ static void __init omap##name##_gptimer_timer_init(void) \
563565
clksrc_nr, clksrc_src) \
564566
static void __init omap##name##_sync32k_timer_init(void) \
565567
{ \
568+
if (omap_clk_init) \
569+
omap_clk_init(); \
566570
omap_dmtimer_init(); \
567571
omap2_gp_clockevent_init((clkev_nr), clkev_src, clkev_prop); \
568572
/* Enable the use of clocksource="gp_timer" kernel parameter */ \

0 commit comments

Comments
 (0)