Skip to contentSkip to conversation

Initcall changes for omaps

PATCH New Tony Lindgren 2 participants 9 messages Nov 30, 2015 – Dec 3, 2015

Subsystems (4)
lore
Share & tools
lore

Tony Lindgren

author maintainer
#0 lore raw

cover Initcall changes for omaps

Hi,

Here are some initcall changes to initialize things a bit later. This make it easier to make timers into drivers and allows us to make most of the clocks into regular device drivers.

Regards,

Tony

Tony Lindgren (2):
ARM: OMAP2+: Initialize timers later with late_time_init
ARM: OMAP2+: Change core_initcall levels to postcore_initcall

 arch/arm/mach-omap2/omap2-restart.c |  2 +-
 arch/arm/mach-omap2/omap_device.c   |  2 +-
 arch/arm/mach-omap2/omap_hwmod.c    |  2 +-
 arch/arm/mach-omap2/serial.c        |  2 +-
 arch/arm/mach-omap2/timer.c         | 46 ++++++++++++++++++++++++++++++++-----
 5 files changed, 44 insertions(+), 10 deletions(-)
Signature · 1 line
2.6.2
author maintainer
#1 lore raw

PATCH 1/2 ARM: OMAP2+: Initialize timers later with late_time_init

We don't need timers right away and initializing them later gives us few nice things like interrupts and kmalloc. As the timers have a dependency to the clock framework, we're better off initializing things later rather than early if things go wrong. And this allows us to make the mux clock driver needed for system timers into early_platform drivers.

Note that smp_prepare_cpus() will get called later on during the init so we just need to local_irq_enable/disable for clocksource_probe().

Cc Felipe Balbi <[email protected]>
Cc Grygorii Strashko <[email protected]>
Cc Paul Walmsley <[email protected]>
Cc Tero Kristo <[email protected]>
---
 arch/arm/mach-omap2/timer.c | 46 +++++++++++++++++++++++++++++++++++++++------
 1 file changed, 40 insertions(+), 6 deletions(-)
arch/arm/mach-omap2/timer.c +40 -6
index b18ebbe..68bf482 100644
@@ -478,36 +478,56 @@ static void __init __omap_sync32k_timer_init(int clkev_nr, const char *clkev_src
 	omap2_gp_clockevent_init(clkev_nr, clkev_src, clkev_prop);
 
 	/* Enable the use of clocksource="gp_timer" kernel parameter */
+	local_irq_disable();
 	if (use_gptimer_clksrc || gptimer)
 		omap2_gptimer_clocksource_init(clksrc_nr, clksrc_src,
 						clksrc_prop);
 	else
 		omap2_sync32k_clocksource_init();
+	local_irq_enable();
 }
 
-void __init omap_init_time(void)
+static void __init omap_init_time_late(void)
 {
 	__omap_sync32k_timer_init(1, "timer_32k_ck", "ti,timer-alwon",
 			2, "timer_sys_ck", NULL, false);
 
-	if (of_have_populated_dt())
+	if (of_have_populated_dt()) {
+		local_irq_disable();
 		clocksource_probe();
+		local_irq_enable();
+	}
+}
+
+void __init omap_init_time(void)
+{
+	late_time_init = omap_init_time_late;
 }
 
 #if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_SOC_AM43XX)
-void __init omap3_secure_sync32k_timer_init(void)
+static void __init omap3_secure_sync32k_timer_late_init(void)
 {
 	__omap_sync32k_timer_init(12, "secure_32k_fck", "ti,timer-secure",
 			2, "timer_sys_ck", NULL, false);
 }
+
+void __init omap3_secure_sync32k_timer_init(void)
+{
+	late_time_init = omap3_secure_sync32k_timer_late_init;
+}
 #endif /* CONFIG_ARCH_OMAP3 */
 
 #if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_SOC_AM33XX)
-void __init omap3_gptimer_timer_init(void)
+static void __init omap3_gptimer_late_init(void)
 {
 	__omap_sync32k_timer_init(2, "timer_sys_ck", NULL,
 			1, "timer_sys_ck", "ti,timer-alwon", true);
 }
+
+void __init omap3_gptimer_timer_init(void)
+{
+	late_time_init = omap3_gptimer_late_init;
+}
 #endif
 
 #if defined(CONFIG_ARCH_OMAP4) || defined(CONFIG_SOC_OMAP5) ||		\
@@ -518,10 +538,17 @@ static void __init omap4_sync32k_timer_init(void)
 			2, "sys_clkin_ck", NULL, false);
 }
 
-void __init omap4_local_timer_init(void)
+static void __init omap4_local_timer_late_init(void)
 {
 	omap4_sync32k_timer_init();
+	local_irq_disable();
 	clocksource_probe();
+	local_irq_enable();
+}
+
+void __init omap4_local_timer_init(void)
+{
+	late_time_init = omap4_local_timer_late_init;
 }
 #endif
 
@@ -640,12 +667,19 @@ sysclk1_based:
 #endif
 }
 
-void __init omap5_realtime_timer_init(void)
+static void __init omap5_realtime_timer_late_init(void)
 {
 	omap4_sync32k_timer_init();
 	realtime_counter_init();
 
+	local_irq_disable();
 	clocksource_probe();
+	local_irq_enable();
+}
+
+void __init omap5_realtime_timer_init(void)
+{
+	late_time_init = omap5_realtime_timer_late_init;
 }
 #endif /* CONFIG_SOC_OMAP5 || CONFIG_SOC_DRA7XX */
 
Signature · 1 line
2.6.2
#2 lore raw

PATCH 1/2 ARM: OMAP2+: Initialize timers later with late_time_init

Quoted 23 lines · Tony Lindgren

We don't need timers right away and initializing them later gives us few nice things like interrupts and kmalloc. As the timers have a dependency to the clock framework, we're better off initializing things later rather than early if things go wrong. And this allows us to make the mux clock driver needed for system timers into early_platform drivers.

Note that smp_prepare_cpus() will get called later on during the init so we just need to local_irq_enable/disable for clocksource_probe().

Cc Felipe Balbi <[email protected]>
Cc Grygorii Strashko <[email protected]>
Cc Paul Walmsley <[email protected]>
Cc Tero Kristo <[email protected]>
---
  arch/arm/mach-omap2/timer.c | 46 +++++++++++++++++++++++++++++++++++++++------
  1 file changed, 40 insertions(+), 6 deletions(-)
arch/arm/mach-omap2/timer.c +0 -0
index b18ebbe..68bf482 100644

arch/arm/mach-omap2/timer.c static void __init __omap_sync32k_timer_init(int clkev_nr, const char *clkev_src · line 487

Quoted 10 lines
arch/arm/mach-omap2/timer.c +2 -0
@@ -478,36 +478,56 @@ static void __init __omap_sync32k_timer_init(int clkev_nr, const char *clkev_src
  	omap2_gp_clockevent_init(clkev_nr, clkev_src, clkev_prop);
 
  	/* Enable the use of clocksource="gp_timer" kernel parameter */
+	local_irq_disable();
  	if (use_gptimer_clksrc || gptimer)
  		omap2_gptimer_clocksource_init(clksrc_nr, clksrc_src,
  						clksrc_prop);
  	else
  		omap2_sync32k_clocksource_init();
+	local_irq_enable();

So, this will be called now after sched_clock_postinit() and to W/A warnings you've added local_irq_disable()/local_irq_enable(). Am I right?

Are you sure this is safe?

Signature · 2 lines
regards,
-grygorii
author maintainer
#3 lore raw

PATCH 1/2 ARM: OMAP2+: Initialize timers later with late_time_init

Quoted 38 lines · Grygorii Strashko
Quoted 23 lines · Tony Lindgren

We don't need timers right away and initializing them later gives us few nice things like interrupts and kmalloc. As the timers have a dependency to the clock framework, we're better off initializing things later rather than early if things go wrong. And this allows us to make the mux clock driver needed for system timers into early_platform drivers.

Note that smp_prepare_cpus() will get called later on during the init so we just need to local_irq_enable/disable for clocksource_probe().

Cc Felipe Balbi <[email protected]>
Cc Grygorii Strashko <[email protected]>
Cc Paul Walmsley <[email protected]>
Cc Tero Kristo <[email protected]>
---
  arch/arm/mach-omap2/timer.c | 46 +++++++++++++++++++++++++++++++++++++++------
  1 file changed, 40 insertions(+), 6 deletions(-)
arch/arm/mach-omap2/timer.c +0 -0
index b18ebbe..68bf482 100644

arch/arm/mach-omap2/timer.c static void __init __omap_sync32k_timer_init(int clkev_nr, const char *clkev_src · line 487

Quoted 10 lines
arch/arm/mach-omap2/timer.c +2 -0
@@ -478,36 +478,56 @@ static void __init __omap_sync32k_timer_init(int clkev_nr, const char *clkev_src
  	omap2_gp_clockevent_init(clkev_nr, clkev_src, clkev_prop);
 
  	/* Enable the use of clocksource="gp_timer" kernel parameter */
+	local_irq_disable();
  	if (use_gptimer_clksrc || gptimer)
  		omap2_gptimer_clocksource_init(clksrc_nr, clksrc_src,
  						clksrc_prop);
  	else
  		omap2_sync32k_clocksource_init();
+	local_irq_enable();

So, this will be called now after sched_clock_postinit() and to W/A warnings you've added local_irq_disable()/local_irq_enable(). Am I right?

Quoted 1 line

Are you sure this is safe?

Hmm good point, update_sched_clock() is never called again and so it's running on jiffies. We could separate out the sched_clock when the 32k source or a local timer is used. But that does allow initializing the gptimer later on. Anyways, clearly this needs more work.

Regards,

Tony

author maintainer
#4 lore raw

PATCH 2/2 ARM: OMAP2+: Change core_initcall levels to postcore_initcall

In reply to Tony Lindgren

We want to be able to probe a few selected device drivers before hwmod code populates the clocks in omap_hwmod_setup_all(). This allows us to convert most of the clock drivers into regular device drivers.

We only need a few minimal clock drivers early for the system timers to select between the 32KiHz clock and the high frequency oscillator.

With these changes, initializing the clock drivers can be just done at core_initcall time with something like:

np = of_find_node_by_name(NULL, "plls");
if (np)

	of_platform_populate(np, NULL, NULL, NULL);

And then these clocks will be available for the interconnect code to use.

Having most of the clock drivers being regular device drivers allows us to use the nice things like devm_* functions and dev_err and dev_dbg. As an extra bonus, this also allows us to develop the clock drivers for new SoCs as loadable modules initially for cases where we can boot up the system based on the bootloader configured clocks.

To do this, let's change the core_initcalls to postcore_initcall under mach-omap2.

Cc Felipe Balbi <[email protected]>
Cc Grygorii Strashko <[email protected]>
Cc Paul Walmsley <[email protected]>
Cc Tero Kristo <[email protected]>
---
 arch/arm/mach-omap2/omap2-restart.c | 2 +-
 arch/arm/mach-omap2/omap_device.c   | 2 +-
 arch/arm/mach-omap2/omap_hwmod.c    | 2 +-
 arch/arm/mach-omap2/serial.c        | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)
arch/arm/mach-omap2/omap2-restart.c +1 -1
index d937b2e..497269d 100644
@@ -62,4 +62,4 @@ static int __init omap2xxx_common_look_up_clks_for_reset(void)
 
 	return 0;
 }
-omap_core_initcall(omap2xxx_common_look_up_clks_for_reset);
+omap_postcore_initcall(omap2xxx_common_look_up_clks_for_reset);
arch/arm/mach-omap2/omap_device.c +1 -1
index 72ebc4c..3750ed1 100644
@@ -869,7 +869,7 @@ static int __init omap_device_init(void)
 	bus_register_notifier(&platform_bus_type, &platform_nb);
 	return 0;
 }
-omap_core_initcall(omap_device_init);
+omap_postcore_initcall(omap_device_init);
 
 /**
  * omap_device_late_idle - idle devices without drivers
arch/arm/mach-omap2/omap_hwmod.c +1 -1
index cc8a987..49d5376 100644
@@ -3307,7 +3307,7 @@ static int __init omap_hwmod_setup_all(void)
 
 	return 0;
 }
-omap_core_initcall(omap_hwmod_setup_all);
+omap_postcore_initcall(omap_hwmod_setup_all);
 
 /**
  * omap_hwmod_enable - enable an omap_hwmod
arch/arm/mach-omap2/serial.c +1 -1
index 5fb50fe..f164c6b 100644
@@ -213,7 +213,7 @@ static int __init omap_serial_early_init(void)
 
 	return 0;
 }
-omap_core_initcall(omap_serial_early_init);
+omap_postcore_initcall(omap_serial_early_init);
 
 /**
  * omap_serial_init_port() - initialize single serial port
Signature · 1 line
2.6.2
author maintainer
#5 lore raw

PATCH 2/2 ARM: OMAP2+: Change core_initcall levels to postcore_initcall

Quoted 16 lines · Tony Lindgren

We want to be able to probe a few selected device drivers before hwmod code populates the clocks in omap_hwmod_setup_all(). This allows us to convert most of the clock drivers into regular device drivers.

We only need a few minimal clock drivers early for the system timers to select between the 32KiHz clock and the high frequency oscillator.

With these changes, initializing the clock drivers can be just done at core_initcall time with something like:

np = of_find_node_by_name(NULL, "plls");
if (np)

	of_platform_populate(np, NULL, NULL, NULL);

And then these clocks will be available for the interconnect code to use.

Quoted 8 lines

Having most of the clock drivers being regular device drivers allows us to use the nice things like devm_* functions and dev_err and dev_dbg. As an extra bonus, this also allows us to develop the clock drivers for new SoCs as loadable modules initially for cases where we can boot up the system based on the bootloader configured clocks.

To do this, let's change the core_initcalls to postcore_initcall under mach-omap2.

FYI I'm applying this one into omap-for-v4.5/soc today, the first patch in this series needs more work as discussed.

Regards,

Tony

#6 lore raw

PATCH 2/2 ARM: OMAP2+: Change core_initcall levels to postcore_initcall

Quoted 4 lines · Tony Lindgren
Quoted 3 lines · Tony Lindgren

We want to be able to probe a few selected device drivers before hwmod code populates the clocks in omap_hwmod_setup_all(). This allows us to convert most of the clock drivers into regular device drivers.

if understand things right, ti clks now will be populated and initialized from
__omap_sync32k_timer_init
- omap_clk_init()
- ..
- of_clk_init()
- ..
- omap_clk_soc_init()

and __omap_sync32k_timer_init(), in turn, will be called from:
arch/arm/kernel/time.c
- time_init()

	machine_desc->init_time();

(without your patch 1).

So, I don't see real dependency here between clk initialization and hwmods :(

Quoted 19 lines
Quoted 19 lines

We only need a few minimal clock drivers early for the system timers to select between the 32KiHz clock and the high frequency oscillator.

With these changes, initializing the clock drivers can be just done at core_initcall time with something like:

np = of_find_node_by_name(NULL, "plls");
if (np)

	of_platform_populate(np, NULL, NULL, NULL);

And then these clocks will be available for the interconnect code to use.

Having most of the clock drivers being regular device drivers allows us to use the nice things like devm_* functions and dev_err and dev_dbg. As an extra bonus, this also allows us to develop the clock drivers for new SoCs as loadable modules initially for cases where we can boot up the system based on the bootloader configured clocks.

Quoted 6 lines
Quoted 2 lines

To do this, let's change the core_initcalls to postcore_initcall under mach-omap2.

FYI I'm applying this one into omap-for-v4.5/soc today, the first patch in this series needs more work as discussed.

To be honest I don't see how this will help to convert ti clks in regular devices right now.
Wouldn't it be better to move forward with this patch together with future patches? So it will be clear what benefits will this approach provide.

In other words, I think it should be a part of some bigger series.

Signature · 2 lines
regards,
-grygorii
author maintainer
#7 lore raw

PATCH 2/2 ARM: OMAP2+: Change core_initcall levels to postcore_initcall

Quoted 15 lines · Grygorii Strashko
Quoted 4 lines · Tony Lindgren
Quoted 3 lines · Tony Lindgren

We want to be able to probe a few selected device drivers before hwmod code populates the clocks in omap_hwmod_setup_all(). This allows us to convert most of the clock drivers into regular device drivers.

if understand things right, ti clks now will be populated and initialized from
__omap_sync32k_timer_init
- omap_clk_init()
- ..
- of_clk_init()
- ..
- omap_clk_soc_init()

Quoted 5 lines

and __omap_sync32k_timer_init(), in turn, will be called from:
arch/arm/kernel/time.c
- time_init()

	machine_desc->init_time();

(without your patch 1).

Yes that's the current approach, but we can do better. We only need the following clocks for system timers at that point:

- mux clocks to select between the 32k and hf oscillator source

- clkctrl driver to gate the ocp clock

All the other clocks can be initialized at core_initcall time with this change.

Quoted 1 line

So, I don't see real dependency here between clk initialization and hwmods :(

You don't because it's only implemented so far for the dm814x ADPLL clock :)

That I posted as "[PATCH 0/2] Clock driver for dm814x ADPLL". Note how it's just a regular device driver that also works as loadable module on boards that have all the necessary clocks enabled already by the bootloader.

Regards,

Tony

#8 lore raw

PATCH 2/2 ARM: OMAP2+: Change core_initcall levels to postcore_initcall

Quoted 31 lines · Tony Lindgren
Quoted 15 lines · Grygorii Strashko
Quoted 4 lines · Tony Lindgren
Quoted 3 lines · Tony Lindgren

We want to be able to probe a few selected device drivers before hwmod code populates the clocks in omap_hwmod_setup_all(). This allows us to convert most of the clock drivers into regular device drivers.

if understand things right, ti clks now will be populated and initialized from
__omap_sync32k_timer_init
- omap_clk_init()
- ..
- of_clk_init()
- ..
- omap_clk_soc_init()

Quoted 5 lines

and __omap_sync32k_timer_init(), in turn, will be called from:
arch/arm/kernel/time.c
- time_init()

	machine_desc->init_time();

(without your patch 1).

Yes that's the current approach, but we can do better. We only need the following clocks for system timers at that point:

- mux clocks to select between the 32k and hf oscillator source

- clkctrl driver to gate the ocp clock

All the other clocks can be initialized at core_initcall time with this change.

Quoted 8 lines
Quoted 1 line

So, I don't see real dependency here between clk initialization and hwmods :(

You don't because it's only implemented so far for the dm814x ADPLL clock :)

That I posted as "[PATCH 0/2] Clock driver for dm814x ADPLL". Note how it's just a regular device driver that also works as loadable module on boards that have all the necessary clocks enabled already by the bootloader.

Ah. Thanks. I see it now.

Signature · 2 lines
regards,
-grygorii