Skip to contentSkip to conversation

ARM 920T build problems for patch-2.6.19-rt1 - the second try

PATCH Pavel Pisa 2 participants 3 messages Dec 15, 2006 – Dec 16, 2006

Subsystems (4)
lore
Share & tools
lore

Pavel Pisa

author
#0 lore raw

Hello Ingo and Thomas,

I have tried 2.6.19-rt14 patches on our PiMX1 ARM board. I have been able to fix some build problems and run the kernel. I have added support for high resolution time sources and time events for i.MX platform.

As I have reported some week ago, there is required next change to compile RT kernel for ARM (at least for <ARMv6).

include/asm-arm/atomic.h +2 -2
Index: linux-2.6.19-rt/include/asm-arm/atomic.h
===================================================================
@@ -188,10 +188,10 @@ static inline unsigned long __cmpxchg(vo
 	volatile unsigned long *p = ptr;
 
 	if (size == 4) {
-		local_irq_save(flags);
+		raw_local_irq_save(flags);
 		if ((prev = *p) == old)
 			*p = new;
-		local_irq_restore(flags);
+		raw_local_irq_restore(flags);
 		return(prev);
 	} else
 		return wrong_size_cmpxchg(ptr);

===================================================================

Even with this patch there are some missing symbols during link stage:
warp_check_clock_was_changed
usecs_to_cycles

The next changes allowed me to build ARM kernel with included high resolution timers for our board.

kernel/hrtimer.c +1 -0
Index: linux-2.6.19-rt/kernel/hrtimer.c
===================================================================
@@ -33,6 +33,7 @@
 
 #include <linux/clockchips.h>
 #include <linux/cpu.h>
+#include <linux/irq.h>
 #include <linux/module.h>
 #include <linux/percpu.h>
 #include <linux/hrtimer.h>
arch/arm/Kconfig +8 -1
Index: linux-2.6.19-rt/arch/arm/Kconfig
===================================================================
@@ -19,7 +19,11 @@ config ARM
 
 config GENERIC_TIME
 	bool
-	default n
+	default y
+
+config GENERIC_CLOCKEVENTS
+	bool
+	default y
 
 config MMU
 	bool
@@ -203,6 +207,7 @@ config ARCH_H720X
 
 config ARCH_IMX
 	bool "IMX"
+	select GENERIC_TIME
 	help
 	  Support for Motorola's i.MX family of processors (MX1, MXL).
 
@@ -489,6 +494,8 @@ config LOCAL_TIMERS
 
 source kernel/Kconfig.preempt
 
+source kernel/time/Kconfig
+
 config NO_IDLE_HZ
 	bool "Dynamic tick timer"
 	help

===================================================================

The kernel has been able to boot and mount NFS volume. I have run cyclic test from it.

Cyclic test shows maximal latencies under 400 usec for 200 MHz clock ARM920T MX1 processor on PiMX1 board which is quite good for board, which has been build mainly for low consumption with only 16-bit wide SDRAM. But I have not tortured board too much during test yet. There has been some Ethernet communication and dhrystone test running in parallel.

Is it possible to include the first part of the patch into RT patches to allow build for ARM.

Is it possible to provide right solution of Kbuild options for ARM?

Can I send somewhere my i.MX high resolution time events patch or should I wait for high resolution timers acceptance and iclusion in vanilla?
i.MX time source patch is already included in vanilla 2.6.20-rc1 through Russell's patch queue.

I have yet another patch for Elan SC520 high resolution time source, it usable even with vanilla kernel. Where should be this patch sent to be included in vanilla?

Thanks for nice work and best wishes

Pavel

--
Pavel Pisa
e-mail: [email protected]
www: http://cmp.felk.cvut.cz/~pisa
work: http://www.pikron.com

#1 lore raw
Quoted 7 lines · Pavel Pisa

Index: linux-2.6.19-rt/include/asm-arm/atomic.h
===================================================================

include/asm-arm/atomic.h +0 -0
@@ -188,10 +188,10 @@ static inline unsigned long __cmpxchg(vo
 	volatile unsigned long *p = ptr;
 

include/asm-arm/atomic.h static inline unsigned long __cmpxchg(vo · line 197

Quoted 10 lines
include/asm-arm/atomic.h +2 -2
 	if (size == 4) {
-		local_irq_save(flags);
+		raw_local_irq_save(flags);
 		if ((prev = *p) == old)
 			*p = new;
-		local_irq_restore(flags);
+		raw_local_irq_restore(flags);
 		return(prev);
 	} else
 		return wrong_size_cmpxchg(ptr);

Ok

Quoted 21 lines

===================================================================

Even with this patch there are some missing symbols during link stage:
warp_check_clock_was_changed
usecs_to_cycles

The next changes allowed me to build ARM kernel with included high resolution timers for our board.

Index: linux-2.6.19-rt/kernel/hrtimer.c
===================================================================

kernel/hrtimer.c +1 -0
@@ -33,6 +33,7 @@
 
 #include <linux/clockchips.h>
 #include <linux/cpu.h>
+#include <linux/irq.h>
 #include <linux/module.h>
 #include <linux/percpu.h>
 #include <linux/hrtimer.h>
Quoted 1 line

Index: linux-2.6.19-rt/arch/arm/Kconfig

ok

arch/arm/Kconfig config ARM · line 26

Quoted 13 lines

===================================================================

arch/arm/Kconfig +5 -1
@@ -19,7 +19,11 @@ config ARM
 
 config GENERIC_TIME
 	bool
-	default n
+	default y
+
+config GENERIC_CLOCKEVENTS
+	bool
+	default y

No. Both have to be set to default n and selected when the mach has the support for it.

arch/arm/Kconfig config ARCH_H720X · line 209

Quoted 6 lines
arch/arm/Kconfig +1 -0
 config MMU
 	bool
@@ -203,6 +207,7 @@ config ARCH_H720X
 config ARCH_IMX
 	bool "IMX"
+	select GENERIC_TIME

+ select GENERIC_CLOCKEVENTS

I fix that up.

tglx

author
#2 lore raw

Hello Thomas and Sascha,

Quoted 11 lines · Thomas Gleixner
Quoted 10 lines · Pavel Pisa

Index: linux-2.6.19-rt/include/asm-arm/atomic.h
===================================================================

include/asm-arm/atomic.h +1 -1
@@ -188,10 +188,10 @@ static inline unsigned long __cmpxchg(vo
 	volatile unsigned long *p = ptr;
 
 	if (size == 4) {
-		local_irq_save(flags);
+		raw_local_irq_save(flags);

......

Quoted 2 lines

Ok

Thanks.

Quoted 5 lines
Quoted 5 lines

===================================================================

arch/arm/Kconfig +0 -0
@@ -19,7 +19,11 @@ config ARM
 
Quoted 11 lines

arch/arm/Kconfig config ARM · line 26

Quoted 8 lines
arch/arm/Kconfig +5 -1
 config GENERIC_TIME
 	bool
-	default n
+	default y
+
+config GENERIC_CLOCKEVENTS
+	bool
+	default y

No. Both have to be set to default n and selected when the mach has the support for it.

OK

As for high resolution timers on i.MX, I have compared Sascha's an my patch version and there are slight differences.

My version honors original define for selection of timer (TIMER_BASE). You use directly IMX_TIM1_BASE.
On the other hand imx_timer_init() hardcodes IRQ to TIM1_INT

	setup_irq(TIM1_INT, &imx_timer_irq);

I have tried to keep file such way, that inclusion of clock event is optional. I used CONFIG_HIGH_RES_TIMERS to conditionalize it, may it be, that CONFIG_GENERIC_CLOCKEVENTS should be used instead ???

Clock events init is separated from hardware timer init in my version.

But all these are minor things to choose and not important so much.

The actual copy from my Linux patch stack is attached bellow.

I have run more tests and when I used intervals, which are not aligned to power oft two, the worst cases has extended up to 550 usec on our board. What are experiences with other ARM based machines?

Best wishes

Pavel Pisa

PS: Thomas, please, can you send me pointer to the Profibus card driver
you have recommended to me. I have tried to contact you more times about that, because my university colleagues ask for that urgently, but it seems that all my e-mails have been discarded somewhere on the way.

===================================================================
Subject: arm: i.MX/MX1 high resolution time events

Support for POSIX high resolution times.

 arch/arm/mach-imx/time.c |   57 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 57 insertions(+)
arch/arm/mach-imx/time.c +57 -0
Index: linux-2.6.19-rt/arch/arm/mach-imx/time.c
===================================================================
@@ -15,6 +15,9 @@
 #include <linux/irq.h>
 #include <linux/time.h>
 #include <linux/clocksource.h>
+#ifdef CONFIG_HIGH_RES_TIMERS
+#include <linux/clockchips.h>
+#endif
 
 #include <asm/hardware.h>
 #include <asm/io.h>
@@ -25,6 +28,11 @@
 /* Use timer 1 as system timer */
 #define TIMER_BASE IMX_TIM1_BASE
 
+#ifdef CONFIG_HIGH_RES_TIMERS
+static struct clock_event_device clockevent_imx;
+static enum clock_event_mode clockevent_mode = CLOCK_EVT_PERIODIC;
+#endif
+
 static unsigned long evt_diff;
 
 /*
@@ -42,9 +50,16 @@ imx_timer_interrupt(int irq, void *dev_i
 	if (tstat & TSTAT_COMP) {
 		do {
 
+#ifdef CONFIG_HIGH_RES_TIMERS
+			if (clockevent_imx.event_handler)
+				clockevent_imx.event_handler();
+			if  (likely(clockevent_mode != CLOCK_EVT_PERIODIC))
+				break;
+#else
 			write_seqlock(&xtime_lock);
 			timer_tick();
 			write_sequnlock(&xtime_lock);
+#endif
 			IMX_TCMP(TIMER_BASE) += evt_diff;
 
 		} while (unlikely((int32_t)(IMX_TCMP(TIMER_BASE)
@@ -99,11 +114,53 @@ static int __init imx_clocksource_init(v
 	return 0;
 }
 
+#ifdef CONFIG_HIGH_RES_TIMERS
+
+static void imx_set_next_event(unsigned long evt,
+				  struct clock_event_device *unused)
+{
+	evt_diff = evt;
+	IMX_TCMP(TIMER_BASE) = IMX_TCN(TIMER_BASE) + evt;
+}
+
+static void imx_set_mode(enum clock_event_mode mode, struct clock_event_device *evt)
+{
+	clockevent_mode = mode;
+}
+
+static struct clock_event_device clockevent_imx = {
+	.name		= "imx_timer1",
+	.capabilities	= CLOCK_CAP_NEXTEVT | CLOCK_CAP_TICK |
+			  CLOCK_CAP_UPDATE | CLOCK_CAP_PROFILE,
+	.shift		= 32,
+	.set_mode	= imx_set_mode,
+	.set_next_event	= imx_set_next_event,
+};
+
+static int __init imx_clockevent_init(void)
+{
+	clockevent_imx.mult = div_sc(imx_get_perclk1(), NSEC_PER_SEC,
+					clockevent_imx.shift);
+	clockevent_imx.max_delta_ns =
+		clockevent_delta2ns(0xfffffffe, &clockevent_imx);
+	clockevent_imx.min_delta_ns =
+		clockevent_delta2ns(0xf, &clockevent_imx);
+	register_local_clockevent(&clockevent_imx);
+
+	return 0;
+}
+#endif
+
+
 static void __init imx_timer_init(void)
 {
 	imx_timer_hardware_init();
 	imx_clocksource_init();
 
+#ifdef CONFIG_HIGH_RES_TIMERS
+	imx_clockevent_init();
+#endif
+
 	/*
 	 * Make irqs happen for the system timer
 	 */