LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [patch 0/3] clock_event patches for arm systems
@ 2007-01-09 10:09 s.hauer
  2007-01-09 10:09 ` [patch 1/3] clockevent driver for arm/imx s.hauer
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: s.hauer @ 2007-01-09 10:09 UTC (permalink / raw)
  To: linux-kernel; +Cc: tglx, mingo

Hi,

Here is a new set of clock_event patches for i.MX, pxa and netx systems.
I (hopefully) integrated all of Thomas proposed changes into the patches.

Looking forward to your comments.

Sascha

--
 Dipl.-Ing. Sascha Hauer | http://www.pengutronix.de
  Pengutronix - Linux Solutions for Science and Industry
    Handelsregister: Amtsgericht Hildesheim, HRA 2686
      Hannoversche Str. 2, 31134 Hildesheim, Germany
    Phone: +49-5121-206917-0 |  Fax: +49-5121-206917-9

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [patch 1/3] clockevent driver for arm/imx
  2007-01-09 10:09 [patch 0/3] clock_event patches for arm systems s.hauer
@ 2007-01-09 10:09 ` s.hauer
  2007-01-09 10:09 ` [patch 2/3] clockevent driver for arm/netx s.hauer
  2007-01-09 10:10 ` [patch 3/3] clockevent driver for arm/pxa2xx s.hauer
  2 siblings, 0 replies; 8+ messages in thread
From: s.hauer @ 2007-01-09 10:09 UTC (permalink / raw)
  To: linux-kernel; +Cc: tglx, mingo, Luotao Fu, Sascha Hauer

[-- Attachment #1: clockevents-driver-for-arm-imx.diff --]
[-- Type: text/plain, Size: 3625 bytes --]

Add a clockevent driver for i.MX systems.

Signed-off-by: Luotao Fu <lfu@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>

---
 arch/arm/mach-imx/time.c |   71 +++++++++++++++++++++++++++++++++++++++--------
 1 file changed, 59 insertions(+), 12 deletions(-)

Index: arch/arm/mach-imx/time.c
===================================================================
--- a/arch/arm/mach-imx/time.c.orig
+++ b/arch/arm/mach-imx/time.c
@@ -15,6 +15,7 @@
 #include <linux/irq.h>
 #include <linux/time.h>
 #include <linux/clocksource.h>
+#include <linux/clockchips.h>
 
 #include <asm/hardware.h>
 #include <asm/io.h>
@@ -25,7 +26,52 @@
 /* Use timer 1 as system timer */
 #define TIMER_BASE IMX_TIM1_BASE
 
-static unsigned long evt_diff;
+enum clock_event_mode clockevent_mode = 0;
+
+static void imx_set_next_event(unsigned long evt,
+			       struct clock_event_device *unused)
+{
+	IMX_TCMP(IMX_TIM1_BASE) = IMX_TCN(IMX_TIM1_BASE) + evt;
+}
+
+static void imx_set_mode(enum clock_event_mode mode,
+			 struct clock_event_device *evt)
+{
+	switch (mode) {
+	case CLOCK_EVT_PERIODIC:
+	case CLOCK_EVT_ONESHOT:
+		IMX_TCTL(TIMER_BASE) |= TCTL_IRQEN;
+		break;
+
+	case CLOCK_EVT_SHUTDOWN:
+		IMX_TCTL(TIMER_BASE) &= ~TCTL_IRQEN;
+		return;
+	}
+
+	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;
+}
 
 /*
  * IRQ handler for the timer
@@ -42,10 +88,12 @@ imx_timer_interrupt(int irq, void *dev_i
 	if (tstat & TSTAT_COMP) {
 		do {
 
-			write_seqlock(&xtime_lock);
-			timer_tick();
-			write_sequnlock(&xtime_lock);
-			IMX_TCMP(TIMER_BASE) += evt_diff;
+			clockevent_imx.event_handler();
+
+			if (clockevent_mode != CLOCK_EVT_PERIODIC)
+				break;
+
+			IMX_TCMP(TIMER_BASE) += LATCH;
 
 		} while (unlikely((int32_t)(IMX_TCMP(TIMER_BASE)
 					- IMX_TCN(TIMER_BASE)) < 0));
@@ -70,10 +118,8 @@ static void __init imx_timer_hardware_in
 	 */
 	IMX_TCTL(TIMER_BASE) = 0;
 	IMX_TPRER(TIMER_BASE) = 0;
-	IMX_TCMP(TIMER_BASE) = LATCH - 1;
-
-	IMX_TCTL(TIMER_BASE) = TCTL_FRR | TCTL_CLK_PCLK1 | TCTL_IRQEN | TCTL_TEN;
-	evt_diff = LATCH;
+	IMX_TCMP(TIMER_BASE) = LATCH;
+	IMX_TCTL(TIMER_BASE) = TCTL_FRR | TCTL_CLK_PCLK1 | TCTL_TEN | TCTL_IRQEN;
 }
 
 cycle_t imx_get_cycles(void)
@@ -82,12 +128,12 @@ cycle_t imx_get_cycles(void)
 }
 
 static struct clocksource clocksource_imx = {
-	.name 		= "imx_timer1",
+	.name		= "imx_timer1",
 	.rating		= 200,
 	.read		= imx_get_cycles,
 	.mask		= 0xFFFFFFFF,
-	.shift 		= 20,
-	.is_continuous 	= 1,
+	.shift		= 20,
+	.is_continuous	= 1,
 };
 
 static int __init imx_clocksource_init(void)
@@ -103,6 +149,7 @@ static void __init imx_timer_init(void)
 {
 	imx_timer_hardware_init();
 	imx_clocksource_init();
+	imx_clockevent_init();
 
 	/*
 	 * Make irqs happen for the system timer

--
 Dipl.-Ing. Sascha Hauer | http://www.pengutronix.de
  Pengutronix - Linux Solutions for Science and Industry
    Handelsregister: Amtsgericht Hildesheim, HRA 2686
      Hannoversche Str. 2, 31134 Hildesheim, Germany
    Phone: +49-5121-206917-0 |  Fax: +49-5121-206917-9

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [patch 2/3] clockevent driver for arm/netx
  2007-01-09 10:09 [patch 0/3] clock_event patches for arm systems s.hauer
  2007-01-09 10:09 ` [patch 1/3] clockevent driver for arm/imx s.hauer
@ 2007-01-09 10:09 ` s.hauer
  2007-01-09 10:10 ` [patch 3/3] clockevent driver for arm/pxa2xx s.hauer
  2 siblings, 0 replies; 8+ messages in thread
From: s.hauer @ 2007-01-09 10:09 UTC (permalink / raw)
  To: linux-kernel; +Cc: tglx, mingo, Luotao Fu, Sascha Hauer

[-- Attachment #1: clockevents-driver-for-arm-netx.diff --]
[-- Type: text/plain, Size: 4126 bytes --]

Add a clockevent driver for netx systems

Signed-off-by: Luotao Fu <lfu@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>

---
 arch/arm/mach-netx/time.c |   80 ++++++++++++++++++++++++++++++++++++----------
 1 file changed, 64 insertions(+), 16 deletions(-)

Index: arch/arm/mach-netx/time.c
===================================================================
--- a/arch/arm/mach-netx/time.c.orig
+++ b/arch/arm/mach-netx/time.c
@@ -21,27 +21,65 @@
 #include <linux/interrupt.h>
 #include <linux/irq.h>
 #include <linux/clocksource.h>
+#include <linux/clockchips.h>
 
 #include <asm/hardware.h>
 #include <asm/io.h>
 #include <asm/mach/time.h>
 #include <asm/arch/netx-regs.h>
 
+static void netx_set_next_event(unsigned long evt,
+				  struct clock_event_device *unused)
+{
+	writel(0 - evt, NETX_GPIO_COUNTER_CURRENT(0));
+}
+
+static void netx_set_mode(enum clock_event_mode mode,
+			  struct clock_event_device *evt)
+{
+	u32 tmode = NETX_GPIO_COUNTER_CTRL_IRQ_EN | NETX_GPIO_COUNTER_CTRL_RUN;
+
+	/* disable timer */
+	writel( 0, NETX_GPIO_COUNTER_CTRL(0));
+
+	switch(mode) {
+	case CLOCK_EVT_PERIODIC:
+		/* Set timer period  */
+		writel(LATCH, NETX_GPIO_COUNTER_MAX(0));
+		tmode |= NETX_GPIO_COUNTER_CTRL_RST_EN;
+		break;
+
+	case CLOCK_EVT_ONESHOT:
+		writel(0, NETX_GPIO_COUNTER_MAX(0));
+		break;
+
+	case CLOCK_EVT_SHUTDOWN:
+		return;
+	}
+
+	writel(tmode, NETX_GPIO_COUNTER_CTRL(0));
+}
+
+static struct clock_event_device clockevent_netx = {
+	.name		= "netx_timer1",
+	.capabilities	= CLOCK_CAP_NEXTEVT | CLOCK_CAP_TICK |
+			  CLOCK_CAP_UPDATE | CLOCK_CAP_PROFILE,
+	.shift		= 32,
+	.set_mode	= netx_set_mode,
+	.set_next_event	= netx_set_next_event,
+};
+
 /*
  * IRQ handler for the timer
  */
 static irqreturn_t
 netx_timer_interrupt(int irq, void *dev_id)
 {
-	write_seqlock(&xtime_lock);
-
-	timer_tick();
-
-	write_sequnlock(&xtime_lock);
-
 	/* acknowledge interrupt */
 	writel(COUNTER_BIT(0), NETX_GPIO_IRQ);
 
+	clockevent_netx.event_handler();
+
 	return IRQ_HANDLED;
 }
 
@@ -57,12 +95,12 @@ cycle_t netx_get_cycles(void)
 }
 
 static struct clocksource clocksource_netx = {
-	.name 		= "netx_timer",
+	.name		= "netx_timer",
 	.rating		= 200,
 	.read		= netx_get_cycles,
 	.mask		= CLOCKSOURCE_MASK(32),
-	.shift 		= 20,
-	.is_continuous 	= 1,
+	.shift		= 20,
+	.is_continuous	= 1,
 };
 
 /*
@@ -81,24 +119,34 @@ static void __init netx_timer_init(void)
 	/* acknowledge interrupt */
 	writel(COUNTER_BIT(0), NETX_GPIO_IRQ);
 
-	/* Enable the interrupt in the specific timer register and start timer */
+	/* Enable the interrupt in the specific timer register and
+	 * start timer
+	 */
 	writel(COUNTER_BIT(0), NETX_GPIO_IRQ_ENABLE);
 	writel(NETX_GPIO_COUNTER_CTRL_IRQ_EN | NETX_GPIO_COUNTER_CTRL_RUN,
-		NETX_GPIO_COUNTER_CTRL(0));
+	       NETX_GPIO_COUNTER_CTRL(0));
 
 	setup_irq(NETX_IRQ_TIMER0, &netx_timer_irq);
 
 	/* Setup timer one for clocksource */
-        writel(0, NETX_GPIO_COUNTER_CTRL(1));
-        writel(0, NETX_GPIO_COUNTER_CURRENT(1));
-        writel(0xFFFFFFFF, NETX_GPIO_COUNTER_MAX(1));
+	writel(0, NETX_GPIO_COUNTER_CTRL(1));
+	writel(0, NETX_GPIO_COUNTER_CURRENT(1));
+	writel(0xFFFFFFFF, NETX_GPIO_COUNTER_MAX(1));
 
-        writel(NETX_GPIO_COUNTER_CTRL_RUN,
-                NETX_GPIO_COUNTER_CTRL(1));
+	writel(NETX_GPIO_COUNTER_CTRL_RUN,
+	       NETX_GPIO_COUNTER_CTRL(1));
 
 	clocksource_netx.mult =
 		clocksource_hz2mult(CLOCK_TICK_RATE, clocksource_netx.shift);
 	clocksource_register(&clocksource_netx);
+
+	clockevent_netx.mult = div_sc(CLOCK_TICK_RATE, NSEC_PER_SEC,
+					clockevent_netx.shift);
+	clockevent_netx.max_delta_ns =
+		clockevent_delta2ns(0xfffffffe, &clockevent_netx);
+	clockevent_netx.min_delta_ns =
+		clockevent_delta2ns(0xf, &clockevent_netx);
+	register_local_clockevent(&clockevent_netx);
 }
 
 struct sys_timer netx_timer = {

--
 Dipl.-Ing. Sascha Hauer | http://www.pengutronix.de
  Pengutronix - Linux Solutions for Science and Industry
    Handelsregister: Amtsgericht Hildesheim, HRA 2686
      Hannoversche Str. 2, 31134 Hildesheim, Germany
    Phone: +49-5121-206917-0 |  Fax: +49-5121-206917-9

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [patch 3/3] clockevent driver for arm/pxa2xx
  2007-01-09 10:09 [patch 0/3] clock_event patches for arm systems s.hauer
  2007-01-09 10:09 ` [patch 1/3] clockevent driver for arm/imx s.hauer
  2007-01-09 10:09 ` [patch 2/3] clockevent driver for arm/netx s.hauer
@ 2007-01-09 10:10 ` s.hauer
  2007-01-19 19:13   ` Guennadi Liakhovetski
  2 siblings, 1 reply; 8+ messages in thread
From: s.hauer @ 2007-01-09 10:10 UTC (permalink / raw)
  To: linux-kernel; +Cc: tglx, mingo, Luotao Fu, Sascha Hauer

[-- Attachment #1: clockevents-driver-for-arm-pxa.diff --]
[-- Type: text/plain, Size: 4536 bytes --]

Add a clockevent driver for pxa systems. This patch also removes the pxa
dyntick support since it is not necessary anymore with generic dynamic
tick support

Signed-off-by: Luotao Fu <lfu@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>

---
 arch/arm/mach-pxa/time.c |  106 ++++++++++++++++++++++-------------------------
 1 file changed, 51 insertions(+), 55 deletions(-)

Index: arch/arm/mach-pxa/time.c
===================================================================
--- a/arch/arm/mach-pxa/time.c.orig
+++ b/arch/arm/mach-pxa/time.c
@@ -19,6 +19,7 @@
 #include <linux/errno.h>
 #include <linux/sched.h>
 #include <linux/clocksource.h>
+#include <linux/clockchips.h>
 
 #include <asm/system.h>
 #include <asm/hardware.h>
@@ -29,6 +30,50 @@
 #include <asm/mach/time.h>
 #include <asm/arch/pxa-regs.h>
 
+static u32 clockevent_mode = 0;
+
+static void pxa_set_next_event(unsigned long evt,
+				  struct clock_event_device *unused)
+{
+	OSMR0 = OSCR + evt;
+}
+
+static void pxa_set_mode(enum clock_event_mode mode, struct clock_event_device *evt)
+{
+	switch (mode) {
+	case CLOCK_EVT_PERIODIC:
+	case CLOCK_EVT_ONESHOT:
+		OIER |= OIER_E0;
+		break;
+
+	case CLOCK_EVT_SHUTDOWN:
+		OIER &= ~OIER_E0;
+		return;
+	}
+	clockevent_mode = mode;
+}
+
+static struct clock_event_device clockevent_pxa = {
+	.name		= "pxa_timer1",
+	.capabilities	= CLOCK_CAP_NEXTEVT | CLOCK_CAP_TICK |
+			  CLOCK_CAP_UPDATE | CLOCK_CAP_PROFILE,
+	.shift		= 32,
+	.set_mode	= pxa_set_mode,
+	.set_next_event	= pxa_set_next_event,
+};
+
+static int __init pxa_clockevent_init(void)
+{
+	clockevent_pxa.mult = div_sc(CLOCK_TICK_RATE, NSEC_PER_SEC,
+					clockevent_pxa.shift);
+	clockevent_pxa.max_delta_ns =
+		clockevent_delta2ns(0xfffffffe, &clockevent_pxa);
+	clockevent_pxa.min_delta_ns =
+		clockevent_delta2ns(0xf, &clockevent_pxa);
+	register_local_clockevent(&clockevent_pxa);
+
+	return 0;
+}
 
 static inline unsigned long pxa_get_rtc_time(void)
 {
@@ -49,25 +94,11 @@ static int pxa_set_rtc(void)
 	return 0;
 }
 
-#ifdef CONFIG_NO_IDLE_HZ
-static unsigned long initial_match;
-static int match_posponed;
-#endif
-
 static irqreturn_t
 pxa_timer_interrupt(int irq, void *dev_id)
 {
 	int next_match;
 
-	write_seqlock(&xtime_lock);
-
-#ifdef CONFIG_NO_IDLE_HZ
-	if (match_posponed) {
-		match_posponed = 0;
-		OSMR0 = initial_match;
-	}
-#endif
-
 	/* Loop until we get ahead of the free running timer.
 	 * This ensures an exact clock tick count and time accuracy.
 	 * Since IRQs are disabled at this point, coherence between
@@ -85,13 +116,15 @@ pxa_timer_interrupt(int irq, void *dev_i
 	 * exactly one tick period which should be a pretty rare event.
 	 */
 	do {
-		timer_tick();
+		clockevent_pxa.event_handler();
 		OSSR = OSSR_M0;  /* Clear match on timer 0 */
+
+		if (clockevent_mode != CLOCK_EVT_PERIODIC)
+			break;
+
 		next_match = (OSMR0 += LATCH);
 	} while( (signed long)(next_match - OSCR) <= 8 );
 
-	write_sequnlock(&xtime_lock);
-
 	return IRQ_HANDLED;
 }
 
@@ -141,44 +174,10 @@ static void __init pxa_timer_init(void)
 	clocksource_pxa.mult =
 		clocksource_hz2mult(CLOCK_TICK_RATE, clocksource_pxa.shift);
 	clocksource_register(&clocksource_pxa);
-}
-
-#ifdef CONFIG_NO_IDLE_HZ
-static int pxa_dyn_tick_enable_disable(void)
-{
-	/* nothing to do */
-	return 0;
-}
-
-static void pxa_dyn_tick_reprogram(unsigned long ticks)
-{
-	if (ticks > 1) {
-		initial_match = OSMR0;
-		OSMR0 = initial_match + ticks * LATCH;
-		match_posponed = 1;
-	}
-}
 
-static irqreturn_t
-pxa_dyn_tick_handler(int irq, void *dev_id)
-{
-	if (match_posponed) {
-		match_posponed = 0;
-		OSMR0 = initial_match;
-		if ( (signed long)(initial_match - OSCR) <= 8 )
-			return pxa_timer_interrupt(irq, dev_id);
-	}
-	return IRQ_NONE;
+	pxa_clockevent_init();
 }
 
-static struct dyn_tick_timer pxa_dyn_tick = {
-	.enable		= pxa_dyn_tick_enable_disable,
-	.disable	= pxa_dyn_tick_enable_disable,
-	.reprogram	= pxa_dyn_tick_reprogram,
-	.handler	= pxa_dyn_tick_handler,
-};
-#endif
-
 #ifdef CONFIG_PM
 static unsigned long osmr[4], oier;
 
@@ -213,7 +212,4 @@ struct sys_timer pxa_timer = {
 	.init		= pxa_timer_init,
 	.suspend	= pxa_timer_suspend,
 	.resume		= pxa_timer_resume,
-#ifdef CONFIG_NO_IDLE_HZ
-	.dyn_tick	= &pxa_dyn_tick,
-#endif
 };

--
 Dipl.-Ing. Sascha Hauer | http://www.pengutronix.de
  Pengutronix - Linux Solutions for Science and Industry
    Handelsregister: Amtsgericht Hildesheim, HRA 2686
      Hannoversche Str. 2, 31134 Hildesheim, Germany
    Phone: +49-5121-206917-0 |  Fax: +49-5121-206917-9

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [patch 3/3] clockevent driver for arm/pxa2xx
  2007-01-09 10:10 ` [patch 3/3] clockevent driver for arm/pxa2xx s.hauer
@ 2007-01-19 19:13   ` Guennadi Liakhovetski
  2007-01-19 19:33     ` Thomas Gleixner
  0 siblings, 1 reply; 8+ messages in thread
From: Guennadi Liakhovetski @ 2007-01-19 19:13 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: linux-kernel, tglx, mingo, Luotao Fu

On Tue, 9 Jan 2007 s.hauer@pengutronix.de wrote:

> Add a clockevent driver for pxa systems. This patch also removes the pxa
> dyntick support since it is not necessary anymore with generic dynamic
> tick support
> 
> Signed-off-by: Luotao Fu <lfu@pengutronix.de>
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> 
> ---
>  arch/arm/mach-pxa/time.c |  106 ++++++++++++++++++++++-------------------------
>  1 file changed, 51 insertions(+), 55 deletions(-)
> 
> Index: arch/arm/mach-pxa/time.c
> ===================================================================
> --- a/arch/arm/mach-pxa/time.c.orig
> +++ b/arch/arm/mach-pxa/time.c
> @@ -19,6 +19,7 @@
>  #include <linux/errno.h>
>  #include <linux/sched.h>
>  #include <linux/clocksource.h>
> +#include <linux/clockchips.h>
>  
>  #include <asm/system.h>
>  #include <asm/hardware.h>
> @@ -29,6 +30,50 @@
>  #include <asm/mach/time.h>
>  #include <asm/arch/pxa-regs.h>
>  
> +static u32 clockevent_mode = 0;
> +
> +static void pxa_set_next_event(unsigned long evt,
> +				  struct clock_event_device *unused)
> +{
> +	OSMR0 = OSCR + evt;
> +}

This doesn't work for me in various nasty ways. Please, check for a 
minimum delay or loop to get ahead of time. See code in the "old" timer 
ISR. See how it unconditionally adds at least 10 ticks...

Thanks
Guennadi
---
Guennadi Liakhovetski

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [patch 3/3] clockevent driver for arm/pxa2xx
  2007-01-19 19:13   ` Guennadi Liakhovetski
@ 2007-01-19 19:33     ` Thomas Gleixner
  2007-01-20 16:08       ` Guennadi Liakhovetski
  0 siblings, 1 reply; 8+ messages in thread
From: Thomas Gleixner @ 2007-01-19 19:33 UTC (permalink / raw)
  To: Guennadi Liakhovetski; +Cc: Sascha Hauer, linux-kernel, mingo, Luotao Fu

On Fri, 2007-01-19 at 20:13 +0100, Guennadi Liakhovetski wrote:
> > +static u32 clockevent_mode = 0;
> > +
> > +static void pxa_set_next_event(unsigned long evt,
> > +				  struct clock_event_device *unused)
> > +{
> > +	OSMR0 = OSCR + evt;
> > +}
> 
> This doesn't work for me in various nasty ways. Please, check for a 
> minimum delay or loop to get ahead of time. See code in the "old" timer 
> ISR. See how it unconditionally adds at least 10 ticks...

I added support for match register based devices and you want to do
something like this:

static int hpet_next_event(unsigned long delta,
                           struct clock_event_device *evt)
{
        unsigned long cnt;

        cnt = hpet_readl(HPET_COUNTER);
        cnt += delta;
        hpet_writel(cnt, HPET_T0_CMP);

        return ((long)(hpet_readl(HPET_COUNTER) - cnt ) > 0);
}

The generic code takes care of the already expired event.

	tglx


	


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [patch 3/3] clockevent driver for arm/pxa2xx
  2007-01-19 19:33     ` Thomas Gleixner
@ 2007-01-20 16:08       ` Guennadi Liakhovetski
  2007-01-20 16:13         ` Thomas Gleixner
  0 siblings, 1 reply; 8+ messages in thread
From: Guennadi Liakhovetski @ 2007-01-20 16:08 UTC (permalink / raw)
  To: Thomas Gleixner; +Cc: Sascha Hauer, linux-kernel, mingo, Luotao Fu

On Fri, 19 Jan 2007, Thomas Gleixner wrote:

> On Fri, 2007-01-19 at 20:13 +0100, Guennadi Liakhovetski wrote:
> > > +static u32 clockevent_mode = 0;
> > > +
> > > +static void pxa_set_next_event(unsigned long evt,
> > > +				  struct clock_event_device *unused)
> > > +{
> > > +	OSMR0 = OSCR + evt;
> > > +}
> > 
> > This doesn't work for me in various nasty ways. Please, check for a 
> > minimum delay or loop to get ahead of time. See code in the "old" timer 
> > ISR. See how it unconditionally adds at least 10 ticks...
> 
> I added support for match register based devices and you want to do
> something like this:
> 
> static int hpet_next_event(unsigned long delta,
>                            struct clock_event_device *evt)
> {
>         unsigned long cnt;
> 
>         cnt = hpet_readl(HPET_COUNTER);
>         cnt += delta;
>         hpet_writel(cnt, HPET_T0_CMP);
> 
>         return ((long)(hpet_readl(HPET_COUNTER) - cnt ) > 0);
> }
> 
> The generic code takes care of the already expired event.

The thing is - 2.6.20-rc5-rt3 didn't provide clockevent on PXA, so, I took 
Sascha's patch instead of my own, which I've been using with 2.6.18, as 
his patches were already submitted to various lists and had chances to 
become mainline. And strait away it didn't work. The code above seems to 
be doing something close to Sascha's patch, so, I expect it would behave 
in the same way. And until I introduced a minimum increment for the match 
register, it didn't work. I either got hangs, or WARN_ON dumps about "time 
warp detected". I think, any timer related code for PXA has to be tested 
on real hardware under significant (real-time) load before going upstream. 
Haven't tested -rt7 though, so, maybe it is already handled there?

Thanks
Guennadi
---
Guennadi Liakhovetski

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [patch 3/3] clockevent driver for arm/pxa2xx
  2007-01-20 16:08       ` Guennadi Liakhovetski
@ 2007-01-20 16:13         ` Thomas Gleixner
  0 siblings, 0 replies; 8+ messages in thread
From: Thomas Gleixner @ 2007-01-20 16:13 UTC (permalink / raw)
  To: Guennadi Liakhovetski; +Cc: Sascha Hauer, linux-kernel, mingo, Luotao Fu

On Sat, 2007-01-20 at 17:08 +0100, Guennadi Liakhovetski wrote:
> > static int hpet_next_event(unsigned long delta,
> >                            struct clock_event_device *evt)
> > {
> >         unsigned long cnt;
> > 
> >         cnt = hpet_readl(HPET_COUNTER);
> >         cnt += delta;
> >         hpet_writel(cnt, HPET_T0_CMP);
> > 
> >         return ((long)(hpet_readl(HPET_COUNTER) - cnt ) > 0);
> > }
> > 
> > The generic code takes care of the already expired event.
> 
> The thing is - 2.6.20-rc5-rt3 didn't provide clockevent on PXA, so, I took 
> Sascha's patch instead of my own, which I've been using with 2.6.18, as 
> his patches were already submitted to various lists and had chances to 
> become mainline. And strait away it didn't work. The code above seems to 
> be doing something close to Sascha's patch, so, I expect it would behave 
> in the same way. And until I introduced a minimum increment for the match 
> register, it didn't work. I either got hangs, or WARN_ON dumps about "time 
> warp detected". I think, any timer related code for PXA has to be tested 
> on real hardware under significant (real-time) load before going upstream. 
> Haven't tested -rt7 though, so, maybe it is already handled there?

No, as I'm reworking clock events a bit and I added the handling for the
match register based devices. The above will catch the event in the past
and the generic code handles that. Will be on -rt soon.

	tglx



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2007-01-20 16:13 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-01-09 10:09 [patch 0/3] clock_event patches for arm systems s.hauer
2007-01-09 10:09 ` [patch 1/3] clockevent driver for arm/imx s.hauer
2007-01-09 10:09 ` [patch 2/3] clockevent driver for arm/netx s.hauer
2007-01-09 10:10 ` [patch 3/3] clockevent driver for arm/pxa2xx s.hauer
2007-01-19 19:13   ` Guennadi Liakhovetski
2007-01-19 19:33     ` Thomas Gleixner
2007-01-20 16:08       ` Guennadi Liakhovetski
2007-01-20 16:13         ` Thomas Gleixner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).