All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] clocksource: atmel-pit: register as a sched_clock
@ 2016-02-24 16:04 ` Romain Izard
  0 siblings, 0 replies; 10+ messages in thread
From: Romain Izard @ 2016-02-24 16:04 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel
  Cc: Nicolas Ferre, Boris Brezillon, Daniel Lezcano, Thomas Gleixner,
	Alexandre Belloni, Romain Izard

Register the counter of the Periodic Interval Timer as a possible source
for sched_clock. Keep the timer running even if the related clockevent
is disabled.

This provides a better precision than the jiffies-based default. The
TCB clocksource does not work, as it is registered too late in the
initialization sequence.

Signed-off-by: Romain Izard <romain.izard.pro@gmail.com>
---
Changelog:
v2:
- Keep the tick counter updated when the clocksource is disabled
- Ensure that sched_clock is a 64 bit counter

 drivers/clocksource/timer-atmel-pit.c | 31 ++++++++++++++++---------------
 1 file changed, 16 insertions(+), 15 deletions(-)

diff --git a/drivers/clocksource/timer-atmel-pit.c b/drivers/clocksource/timer-atmel-pit.c
index d911c5dca8f1..609892bbf9da 100644
--- a/drivers/clocksource/timer-atmel-pit.c
+++ b/drivers/clocksource/timer-atmel-pit.c
@@ -21,6 +21,7 @@
 #include <linux/of_address.h>
 #include <linux/of_irq.h>
 #include <linux/slab.h>
+#include <linux/sched_clock.h>
 
 #define AT91_PIT_MR		0x00			/* Mode Register */
 #define AT91_PIT_PITIEN			BIT(25)			/* Timer Interrupt Enable */
@@ -44,7 +45,7 @@ struct pit_data {
 
 	void __iomem	*base;
 	u32		cycle;
-	u32		cnt;
+	u64		cnt;
 	unsigned int	irq;
 	struct clk	*mck;
 };
@@ -77,7 +78,7 @@ static cycle_t read_pit_clk(struct clocksource *cs)
 {
 	struct pit_data *data = clksrc_to_pit_data(cs);
 	unsigned long flags;
-	u32 elapsed;
+	u64 elapsed;
 	u32 t;
 
 	raw_local_irq_save(flags);
@@ -90,15 +91,6 @@ static cycle_t read_pit_clk(struct clocksource *cs)
 	return elapsed;
 }
 
-static int pit_clkevt_shutdown(struct clock_event_device *dev)
-{
-	struct pit_data *data = clkevt_to_pit_data(dev);
-
-	/* disable irq, leaving the clocksource active */
-	pit_write(data->base, AT91_PIT_MR, (data->cycle - 1) | AT91_PIT_PITEN);
-	return 0;
-}
-
 /*
  * Clockevent device:  interrupts every 1/HZ (== pit_cycles * MCK/16)
  */
@@ -156,15 +148,15 @@ static irqreturn_t at91sam926x_pit_interrupt(int irq, void *dev_id)
 	WARN_ON_ONCE(!irqs_disabled());
 
 	/* The PIT interrupt may be disabled, and is shared */
-	if (clockevent_state_periodic(&data->clkevt) &&
-	    (pit_read(data->base, AT91_PIT_SR) & AT91_PIT_PITS)) {
+	if (pit_read(data->base, AT91_PIT_SR) & AT91_PIT_PITS) {
 		unsigned nr_ticks;
 
 		/* Get number of ticks performed before irq, and ack it */
 		nr_ticks = PIT_PICNT(pit_read(data->base, AT91_PIT_PIVR));
 		do {
 			data->cnt += data->cycle;
-			data->clkevt.event_handler(&data->clkevt);
+			if (clockevent_state_periodic(&data->clkevt))
+				data->clkevt.event_handler(&data->clkevt);
 			nr_ticks--;
 		} while (nr_ticks);
 
@@ -174,6 +166,13 @@ static irqreturn_t at91sam926x_pit_interrupt(int irq, void *dev_id)
 	return IRQ_NONE;
 }
 
+static struct clocksource *pit_sched_clock;
+
+static u64 pit_sched_clock_read(void)
+{
+	return read_pit_clk(pit_sched_clock);
+}
+
 /*
  * Set up both clocksource and clockevent support.
  */
@@ -206,6 +205,9 @@ static void __init at91sam926x_pit_common_init(struct pit_data *data)
 	data->clksrc.flags = CLOCK_SOURCE_IS_CONTINUOUS;
 	clocksource_register_hz(&data->clksrc, pit_rate);
 
+	pit_sched_clock = &data->clksrc;
+	sched_clock_register(pit_sched_clock_read, bits, pit_rate);
+
 	/* Set up irq handler */
 	ret = request_irq(data->irq, at91sam926x_pit_interrupt,
 			  IRQF_SHARED | IRQF_TIMER | IRQF_IRQPOLL,
@@ -221,7 +223,6 @@ static void __init at91sam926x_pit_common_init(struct pit_data *data)
 	data->clkevt.rating = 100;
 	data->clkevt.cpumask = cpumask_of(0);
 
-	data->clkevt.set_state_shutdown = pit_clkevt_shutdown;
 	data->clkevt.set_state_periodic = pit_clkevt_set_periodic;
 	data->clkevt.resume = at91sam926x_pit_resume;
 	data->clkevt.suspend = at91sam926x_pit_suspend;
-- 
2.5.0

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

* [PATCH v2] clocksource: atmel-pit: register as a sched_clock
@ 2016-02-24 16:04 ` Romain Izard
  0 siblings, 0 replies; 10+ messages in thread
From: Romain Izard @ 2016-02-24 16:04 UTC (permalink / raw)
  To: linux-arm-kernel

Register the counter of the Periodic Interval Timer as a possible source
for sched_clock. Keep the timer running even if the related clockevent
is disabled.

This provides a better precision than the jiffies-based default. The
TCB clocksource does not work, as it is registered too late in the
initialization sequence.

Signed-off-by: Romain Izard <romain.izard.pro@gmail.com>
---
Changelog:
v2:
- Keep the tick counter updated when the clocksource is disabled
- Ensure that sched_clock is a 64 bit counter

 drivers/clocksource/timer-atmel-pit.c | 31 ++++++++++++++++---------------
 1 file changed, 16 insertions(+), 15 deletions(-)

diff --git a/drivers/clocksource/timer-atmel-pit.c b/drivers/clocksource/timer-atmel-pit.c
index d911c5dca8f1..609892bbf9da 100644
--- a/drivers/clocksource/timer-atmel-pit.c
+++ b/drivers/clocksource/timer-atmel-pit.c
@@ -21,6 +21,7 @@
 #include <linux/of_address.h>
 #include <linux/of_irq.h>
 #include <linux/slab.h>
+#include <linux/sched_clock.h>
 
 #define AT91_PIT_MR		0x00			/* Mode Register */
 #define AT91_PIT_PITIEN			BIT(25)			/* Timer Interrupt Enable */
@@ -44,7 +45,7 @@ struct pit_data {
 
 	void __iomem	*base;
 	u32		cycle;
-	u32		cnt;
+	u64		cnt;
 	unsigned int	irq;
 	struct clk	*mck;
 };
@@ -77,7 +78,7 @@ static cycle_t read_pit_clk(struct clocksource *cs)
 {
 	struct pit_data *data = clksrc_to_pit_data(cs);
 	unsigned long flags;
-	u32 elapsed;
+	u64 elapsed;
 	u32 t;
 
 	raw_local_irq_save(flags);
@@ -90,15 +91,6 @@ static cycle_t read_pit_clk(struct clocksource *cs)
 	return elapsed;
 }
 
-static int pit_clkevt_shutdown(struct clock_event_device *dev)
-{
-	struct pit_data *data = clkevt_to_pit_data(dev);
-
-	/* disable irq, leaving the clocksource active */
-	pit_write(data->base, AT91_PIT_MR, (data->cycle - 1) | AT91_PIT_PITEN);
-	return 0;
-}
-
 /*
  * Clockevent device:  interrupts every 1/HZ (== pit_cycles * MCK/16)
  */
@@ -156,15 +148,15 @@ static irqreturn_t at91sam926x_pit_interrupt(int irq, void *dev_id)
 	WARN_ON_ONCE(!irqs_disabled());
 
 	/* The PIT interrupt may be disabled, and is shared */
-	if (clockevent_state_periodic(&data->clkevt) &&
-	    (pit_read(data->base, AT91_PIT_SR) & AT91_PIT_PITS)) {
+	if (pit_read(data->base, AT91_PIT_SR) & AT91_PIT_PITS) {
 		unsigned nr_ticks;
 
 		/* Get number of ticks performed before irq, and ack it */
 		nr_ticks = PIT_PICNT(pit_read(data->base, AT91_PIT_PIVR));
 		do {
 			data->cnt += data->cycle;
-			data->clkevt.event_handler(&data->clkevt);
+			if (clockevent_state_periodic(&data->clkevt))
+				data->clkevt.event_handler(&data->clkevt);
 			nr_ticks--;
 		} while (nr_ticks);
 
@@ -174,6 +166,13 @@ static irqreturn_t at91sam926x_pit_interrupt(int irq, void *dev_id)
 	return IRQ_NONE;
 }
 
+static struct clocksource *pit_sched_clock;
+
+static u64 pit_sched_clock_read(void)
+{
+	return read_pit_clk(pit_sched_clock);
+}
+
 /*
  * Set up both clocksource and clockevent support.
  */
@@ -206,6 +205,9 @@ static void __init at91sam926x_pit_common_init(struct pit_data *data)
 	data->clksrc.flags = CLOCK_SOURCE_IS_CONTINUOUS;
 	clocksource_register_hz(&data->clksrc, pit_rate);
 
+	pit_sched_clock = &data->clksrc;
+	sched_clock_register(pit_sched_clock_read, bits, pit_rate);
+
 	/* Set up irq handler */
 	ret = request_irq(data->irq, at91sam926x_pit_interrupt,
 			  IRQF_SHARED | IRQF_TIMER | IRQF_IRQPOLL,
@@ -221,7 +223,6 @@ static void __init at91sam926x_pit_common_init(struct pit_data *data)
 	data->clkevt.rating = 100;
 	data->clkevt.cpumask = cpumask_of(0);
 
-	data->clkevt.set_state_shutdown = pit_clkevt_shutdown;
 	data->clkevt.set_state_periodic = pit_clkevt_set_periodic;
 	data->clkevt.resume = at91sam926x_pit_resume;
 	data->clkevt.suspend = at91sam926x_pit_suspend;
-- 
2.5.0

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

* Re: [PATCH v2] clocksource: atmel-pit: register as a sched_clock
  2016-02-24 16:04 ` Romain Izard
@ 2016-02-24 16:15   ` Alexandre Belloni
  -1 siblings, 0 replies; 10+ messages in thread
From: Alexandre Belloni @ 2016-02-24 16:15 UTC (permalink / raw)
  To: Romain Izard
  Cc: linux-kernel, linux-arm-kernel, Nicolas Ferre, Boris Brezillon,
	Daniel Lezcano, Thomas Gleixner

On 24/02/2016 at 17:04:42 +0100, Romain Izard wrote :
> Register the counter of the Periodic Interval Timer as a possible source
> for sched_clock. Keep the timer running even if the related clockevent
> is disabled.
> 
> This provides a better precision than the jiffies-based default. The
> TCB clocksource does not work, as it is registered too late in the
> initialization sequence.
> 
> Signed-off-by: Romain Izard <romain.izard.pro@gmail.com>
> ---
> Changelog:
> v2:
> - Keep the tick counter updated when the clocksource is disabled
> - Ensure that sched_clock is a 64 bit counter
> 
>  drivers/clocksource/timer-atmel-pit.c | 31 ++++++++++++++++---------------
>  1 file changed, 16 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/clocksource/timer-atmel-pit.c b/drivers/clocksource/timer-atmel-pit.c
> index d911c5dca8f1..609892bbf9da 100644
> --- a/drivers/clocksource/timer-atmel-pit.c
> +++ b/drivers/clocksource/timer-atmel-pit.c
> @@ -21,6 +21,7 @@
>  #include <linux/of_address.h>
>  #include <linux/of_irq.h>
>  #include <linux/slab.h>
> +#include <linux/sched_clock.h>
>  
>  #define AT91_PIT_MR		0x00			/* Mode Register */
>  #define AT91_PIT_PITIEN			BIT(25)			/* Timer Interrupt Enable */
> @@ -44,7 +45,7 @@ struct pit_data {
>  
>  	void __iomem	*base;
>  	u32		cycle;
> -	u32		cnt;
> +	u64		cnt;
>  	unsigned int	irq;
>  	struct clk	*mck;
>  };
> @@ -77,7 +78,7 @@ static cycle_t read_pit_clk(struct clocksource *cs)
>  {
>  	struct pit_data *data = clksrc_to_pit_data(cs);
>  	unsigned long flags;
> -	u32 elapsed;
> +	u64 elapsed;
>  	u32 t;
>  
>  	raw_local_irq_save(flags);
> @@ -90,15 +91,6 @@ static cycle_t read_pit_clk(struct clocksource *cs)
>  	return elapsed;
>  }
>  
> -static int pit_clkevt_shutdown(struct clock_event_device *dev)
> -{
> -	struct pit_data *data = clkevt_to_pit_data(dev);
> -
> -	/* disable irq, leaving the clocksource active */
> -	pit_write(data->base, AT91_PIT_MR, (data->cycle - 1) | AT91_PIT_PITEN);
> -	return 0;
> -}
> -

What about preempt-rt where really we want to disable the pit?

>  /*
>   * Clockevent device:  interrupts every 1/HZ (== pit_cycles * MCK/16)
>   */
> @@ -156,15 +148,15 @@ static irqreturn_t at91sam926x_pit_interrupt(int irq, void *dev_id)
>  	WARN_ON_ONCE(!irqs_disabled());
>  
>  	/* The PIT interrupt may be disabled, and is shared */
> -	if (clockevent_state_periodic(&data->clkevt) &&
> -	    (pit_read(data->base, AT91_PIT_SR) & AT91_PIT_PITS)) {
> +	if (pit_read(data->base, AT91_PIT_SR) & AT91_PIT_PITS) {
>  		unsigned nr_ticks;
>  
>  		/* Get number of ticks performed before irq, and ack it */
>  		nr_ticks = PIT_PICNT(pit_read(data->base, AT91_PIT_PIVR));
>  		do {
>  			data->cnt += data->cycle;
> -			data->clkevt.event_handler(&data->clkevt);
> +			if (clockevent_state_periodic(&data->clkevt))
> +				data->clkevt.event_handler(&data->clkevt);
>  			nr_ticks--;
>  		} while (nr_ticks);
>  
> @@ -174,6 +166,13 @@ static irqreturn_t at91sam926x_pit_interrupt(int irq, void *dev_id)
>  	return IRQ_NONE;
>  }
>  
> +static struct clocksource *pit_sched_clock;
> +
> +static u64 pit_sched_clock_read(void)
> +{
> +	return read_pit_clk(pit_sched_clock);
> +}
> +
>  /*
>   * Set up both clocksource and clockevent support.
>   */
> @@ -206,6 +205,9 @@ static void __init at91sam926x_pit_common_init(struct pit_data *data)
>  	data->clksrc.flags = CLOCK_SOURCE_IS_CONTINUOUS;
>  	clocksource_register_hz(&data->clksrc, pit_rate);
>  
> +	pit_sched_clock = &data->clksrc;
> +	sched_clock_register(pit_sched_clock_read, bits, pit_rate);
> +
>  	/* Set up irq handler */
>  	ret = request_irq(data->irq, at91sam926x_pit_interrupt,
>  			  IRQF_SHARED | IRQF_TIMER | IRQF_IRQPOLL,
> @@ -221,7 +223,6 @@ static void __init at91sam926x_pit_common_init(struct pit_data *data)
>  	data->clkevt.rating = 100;
>  	data->clkevt.cpumask = cpumask_of(0);
>  
> -	data->clkevt.set_state_shutdown = pit_clkevt_shutdown;
>  	data->clkevt.set_state_periodic = pit_clkevt_set_periodic;
>  	data->clkevt.resume = at91sam926x_pit_resume;
>  	data->clkevt.suspend = at91sam926x_pit_suspend;
> -- 
> 2.5.0
> 

-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

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

* [PATCH v2] clocksource: atmel-pit: register as a sched_clock
@ 2016-02-24 16:15   ` Alexandre Belloni
  0 siblings, 0 replies; 10+ messages in thread
From: Alexandre Belloni @ 2016-02-24 16:15 UTC (permalink / raw)
  To: linux-arm-kernel

On 24/02/2016 at 17:04:42 +0100, Romain Izard wrote :
> Register the counter of the Periodic Interval Timer as a possible source
> for sched_clock. Keep the timer running even if the related clockevent
> is disabled.
> 
> This provides a better precision than the jiffies-based default. The
> TCB clocksource does not work, as it is registered too late in the
> initialization sequence.
> 
> Signed-off-by: Romain Izard <romain.izard.pro@gmail.com>
> ---
> Changelog:
> v2:
> - Keep the tick counter updated when the clocksource is disabled
> - Ensure that sched_clock is a 64 bit counter
> 
>  drivers/clocksource/timer-atmel-pit.c | 31 ++++++++++++++++---------------
>  1 file changed, 16 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/clocksource/timer-atmel-pit.c b/drivers/clocksource/timer-atmel-pit.c
> index d911c5dca8f1..609892bbf9da 100644
> --- a/drivers/clocksource/timer-atmel-pit.c
> +++ b/drivers/clocksource/timer-atmel-pit.c
> @@ -21,6 +21,7 @@
>  #include <linux/of_address.h>
>  #include <linux/of_irq.h>
>  #include <linux/slab.h>
> +#include <linux/sched_clock.h>
>  
>  #define AT91_PIT_MR		0x00			/* Mode Register */
>  #define AT91_PIT_PITIEN			BIT(25)			/* Timer Interrupt Enable */
> @@ -44,7 +45,7 @@ struct pit_data {
>  
>  	void __iomem	*base;
>  	u32		cycle;
> -	u32		cnt;
> +	u64		cnt;
>  	unsigned int	irq;
>  	struct clk	*mck;
>  };
> @@ -77,7 +78,7 @@ static cycle_t read_pit_clk(struct clocksource *cs)
>  {
>  	struct pit_data *data = clksrc_to_pit_data(cs);
>  	unsigned long flags;
> -	u32 elapsed;
> +	u64 elapsed;
>  	u32 t;
>  
>  	raw_local_irq_save(flags);
> @@ -90,15 +91,6 @@ static cycle_t read_pit_clk(struct clocksource *cs)
>  	return elapsed;
>  }
>  
> -static int pit_clkevt_shutdown(struct clock_event_device *dev)
> -{
> -	struct pit_data *data = clkevt_to_pit_data(dev);
> -
> -	/* disable irq, leaving the clocksource active */
> -	pit_write(data->base, AT91_PIT_MR, (data->cycle - 1) | AT91_PIT_PITEN);
> -	return 0;
> -}
> -

What about preempt-rt where really we want to disable the pit?

>  /*
>   * Clockevent device:  interrupts every 1/HZ (== pit_cycles * MCK/16)
>   */
> @@ -156,15 +148,15 @@ static irqreturn_t at91sam926x_pit_interrupt(int irq, void *dev_id)
>  	WARN_ON_ONCE(!irqs_disabled());
>  
>  	/* The PIT interrupt may be disabled, and is shared */
> -	if (clockevent_state_periodic(&data->clkevt) &&
> -	    (pit_read(data->base, AT91_PIT_SR) & AT91_PIT_PITS)) {
> +	if (pit_read(data->base, AT91_PIT_SR) & AT91_PIT_PITS) {
>  		unsigned nr_ticks;
>  
>  		/* Get number of ticks performed before irq, and ack it */
>  		nr_ticks = PIT_PICNT(pit_read(data->base, AT91_PIT_PIVR));
>  		do {
>  			data->cnt += data->cycle;
> -			data->clkevt.event_handler(&data->clkevt);
> +			if (clockevent_state_periodic(&data->clkevt))
> +				data->clkevt.event_handler(&data->clkevt);
>  			nr_ticks--;
>  		} while (nr_ticks);
>  
> @@ -174,6 +166,13 @@ static irqreturn_t at91sam926x_pit_interrupt(int irq, void *dev_id)
>  	return IRQ_NONE;
>  }
>  
> +static struct clocksource *pit_sched_clock;
> +
> +static u64 pit_sched_clock_read(void)
> +{
> +	return read_pit_clk(pit_sched_clock);
> +}
> +
>  /*
>   * Set up both clocksource and clockevent support.
>   */
> @@ -206,6 +205,9 @@ static void __init at91sam926x_pit_common_init(struct pit_data *data)
>  	data->clksrc.flags = CLOCK_SOURCE_IS_CONTINUOUS;
>  	clocksource_register_hz(&data->clksrc, pit_rate);
>  
> +	pit_sched_clock = &data->clksrc;
> +	sched_clock_register(pit_sched_clock_read, bits, pit_rate);
> +
>  	/* Set up irq handler */
>  	ret = request_irq(data->irq, at91sam926x_pit_interrupt,
>  			  IRQF_SHARED | IRQF_TIMER | IRQF_IRQPOLL,
> @@ -221,7 +223,6 @@ static void __init at91sam926x_pit_common_init(struct pit_data *data)
>  	data->clkevt.rating = 100;
>  	data->clkevt.cpumask = cpumask_of(0);
>  
> -	data->clkevt.set_state_shutdown = pit_clkevt_shutdown;
>  	data->clkevt.set_state_periodic = pit_clkevt_set_periodic;
>  	data->clkevt.resume = at91sam926x_pit_resume;
>  	data->clkevt.suspend = at91sam926x_pit_suspend;
> -- 
> 2.5.0
> 

-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

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

* Re: [PATCH v2] clocksource: atmel-pit: register as a sched_clock
  2016-02-24 16:04 ` Romain Izard
@ 2016-02-24 16:20   ` Sylvain Rochet
  -1 siblings, 0 replies; 10+ messages in thread
From: Sylvain Rochet @ 2016-02-24 16:20 UTC (permalink / raw)
  To: Romain Izard
  Cc: linux-kernel, linux-arm-kernel, Boris Brezillon, Daniel Lezcano,
	Nicolas Ferre, Alexandre Belloni, Thomas Gleixner

Hi,

On Wed, Feb 24, 2016 at 05:04:42PM +0100, Romain Izard wrote:
> Register the counter of the Periodic Interval Timer as a possible source
> for sched_clock. Keep the timer running even if the related clockevent
> is disabled.
> 
> This provides a better precision than the jiffies-based default. The
> TCB clocksource does not work, as it is registered too late in the
> initialization sequence.

I have mixed feelings about that, but this is probably just a 
misunderstanding from my part.

The PIT timer should not be used for systems with PM_SUSPEND enabled and 
used because it takes ages to synchronize on resume, how does this patch 
affect that ?

Ref: commit ac34ad27fc ("clockevents: Do not suspend/resume if unused")

Sylvain

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

* [PATCH v2] clocksource: atmel-pit: register as a sched_clock
@ 2016-02-24 16:20   ` Sylvain Rochet
  0 siblings, 0 replies; 10+ messages in thread
From: Sylvain Rochet @ 2016-02-24 16:20 UTC (permalink / raw)
  To: linux-arm-kernel

Hi,

On Wed, Feb 24, 2016 at 05:04:42PM +0100, Romain Izard wrote:
> Register the counter of the Periodic Interval Timer as a possible source
> for sched_clock. Keep the timer running even if the related clockevent
> is disabled.
> 
> This provides a better precision than the jiffies-based default. The
> TCB clocksource does not work, as it is registered too late in the
> initialization sequence.

I have mixed feelings about that, but this is probably just a 
misunderstanding from my part.

The PIT timer should not be used for systems with PM_SUSPEND enabled and 
used because it takes ages to synchronize on resume, how does this patch 
affect that ?

Ref: commit ac34ad27fc ("clockevents: Do not suspend/resume if unused")

Sylvain

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

* Re: [PATCH v2] clocksource: atmel-pit: register as a sched_clock
  2016-02-24 16:20   ` Sylvain Rochet
@ 2016-02-24 16:44     ` Romain Izard
  -1 siblings, 0 replies; 10+ messages in thread
From: Romain Izard @ 2016-02-24 16:44 UTC (permalink / raw)
  To: Sylvain Rochet
  Cc: LKML, linux-arm-kernel, Boris Brezillon, Daniel Lezcano,
	Nicolas Ferre, Alexandre Belloni, Thomas Gleixner

2016-02-24 17:20 GMT+01:00 Sylvain Rochet <sylvain.rochet@finsecur.com>:
> Hi,
>
> On Wed, Feb 24, 2016 at 05:04:42PM +0100, Romain Izard wrote:
>> Register the counter of the Periodic Interval Timer as a possible
>> source for sched_clock. Keep the timer running even if the related
>> clockevent is disabled.
>>
>> This provides a better precision than the jiffies-based default. The
>> TCB clocksource does not work, as it is registered too late in the
>> initialization sequence.
>
> I have mixed feelings about that, but this is probably just a
> misunderstanding from my part.
>
My goal is to get a better precision on my printk and trace logs,
because the precision of jiffies is really very bad compared to
everything else I have encountered until now. But it looks like reading
a timer is quite complicated on AT91...

> The PIT timer should not be used for systems with PM_SUSPEND enabled
> and used because it takes ages to synchronize on resume, how does this
> patch affect that ?
>
> Ref: commit ac34ad27fc ("clockevents: Do not suspend/resume if
> unused")

So your advice would be to stay clear of the PIT, because it is
(globally) useless.

I'll keep it in mind.

Best regards,
-- 
Romain Izard

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

* [PATCH v2] clocksource: atmel-pit: register as a sched_clock
@ 2016-02-24 16:44     ` Romain Izard
  0 siblings, 0 replies; 10+ messages in thread
From: Romain Izard @ 2016-02-24 16:44 UTC (permalink / raw)
  To: linux-arm-kernel

2016-02-24 17:20 GMT+01:00 Sylvain Rochet <sylvain.rochet@finsecur.com>:
> Hi,
>
> On Wed, Feb 24, 2016 at 05:04:42PM +0100, Romain Izard wrote:
>> Register the counter of the Periodic Interval Timer as a possible
>> source for sched_clock. Keep the timer running even if the related
>> clockevent is disabled.
>>
>> This provides a better precision than the jiffies-based default. The
>> TCB clocksource does not work, as it is registered too late in the
>> initialization sequence.
>
> I have mixed feelings about that, but this is probably just a
> misunderstanding from my part.
>
My goal is to get a better precision on my printk and trace logs,
because the precision of jiffies is really very bad compared to
everything else I have encountered until now. But it looks like reading
a timer is quite complicated on AT91...

> The PIT timer should not be used for systems with PM_SUSPEND enabled
> and used because it takes ages to synchronize on resume, how does this
> patch affect that ?
>
> Ref: commit ac34ad27fc ("clockevents: Do not suspend/resume if
> unused")

So your advice would be to stay clear of the PIT, because it is
(globally) useless.

I'll keep it in mind.

Best regards,
-- 
Romain Izard

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

* Re: [PATCH v2] clocksource: atmel-pit: register as a sched_clock
  2016-02-24 16:44     ` Romain Izard
@ 2016-02-24 17:13       ` Nicolas Ferre
  -1 siblings, 0 replies; 10+ messages in thread
From: Nicolas Ferre @ 2016-02-24 17:13 UTC (permalink / raw)
  To: Romain Izard, Sylvain Rochet
  Cc: LKML, linux-arm-kernel, Boris Brezillon, Daniel Lezcano,
	Alexandre Belloni, Thomas Gleixner, Cyrille Pitchen

Le 24/02/2016 17:44, Romain Izard a écrit :
> 2016-02-24 17:20 GMT+01:00 Sylvain Rochet <sylvain.rochet@finsecur.com>:
>> Hi,
>>
>> On Wed, Feb 24, 2016 at 05:04:42PM +0100, Romain Izard wrote:
>>> Register the counter of the Periodic Interval Timer as a possible
>>> source for sched_clock. Keep the timer running even if the related
>>> clockevent is disabled.
>>>
>>> This provides a better precision than the jiffies-based default. The
>>> TCB clocksource does not work, as it is registered too late in the
>>> initialization sequence.
>>
>> I have mixed feelings about that, but this is probably just a
>> misunderstanding from my part.
>>
> My goal is to get a better precision on my printk and trace logs,
> because the precision of jiffies is really very bad compared to
> everything else I have encountered until now. But it looks like reading
> a timer is quite complicated on AT91...
> 
>> The PIT timer should not be used for systems with PM_SUSPEND enabled
>> and used because it takes ages to synchronize on resume, how does this
>> patch affect that ?
>>
>> Ref: commit ac34ad27fc ("clockevents: Do not suspend/resume if
>> unused")
> 
> So your advice would be to stay clear of the PIT, because it is
> (globally) useless.
> 
> I'll keep it in mind.

I tend to think like this as well.

I would like to simplify our timer handling on AT91 and stick with TC
for this purpose.
It has de disadvantage of being obliged to use a TC(block) for
clockevent/clocksource and loose it if we want to do something else with
it but I do think that it's worth it.

If you want a modified TC driver that registers sched_clock, we can
provide you one as a workaround before that we rework the TC driver
completely. It has it's own flaws (like re-using a compatible string or
preventing the use of the "tclib") but is certainly handy.

Bye,
-- 
Nicolas Ferre

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

* [PATCH v2] clocksource: atmel-pit: register as a sched_clock
@ 2016-02-24 17:13       ` Nicolas Ferre
  0 siblings, 0 replies; 10+ messages in thread
From: Nicolas Ferre @ 2016-02-24 17:13 UTC (permalink / raw)
  To: linux-arm-kernel

Le 24/02/2016 17:44, Romain Izard a ?crit :
> 2016-02-24 17:20 GMT+01:00 Sylvain Rochet <sylvain.rochet@finsecur.com>:
>> Hi,
>>
>> On Wed, Feb 24, 2016 at 05:04:42PM +0100, Romain Izard wrote:
>>> Register the counter of the Periodic Interval Timer as a possible
>>> source for sched_clock. Keep the timer running even if the related
>>> clockevent is disabled.
>>>
>>> This provides a better precision than the jiffies-based default. The
>>> TCB clocksource does not work, as it is registered too late in the
>>> initialization sequence.
>>
>> I have mixed feelings about that, but this is probably just a
>> misunderstanding from my part.
>>
> My goal is to get a better precision on my printk and trace logs,
> because the precision of jiffies is really very bad compared to
> everything else I have encountered until now. But it looks like reading
> a timer is quite complicated on AT91...
> 
>> The PIT timer should not be used for systems with PM_SUSPEND enabled
>> and used because it takes ages to synchronize on resume, how does this
>> patch affect that ?
>>
>> Ref: commit ac34ad27fc ("clockevents: Do not suspend/resume if
>> unused")
> 
> So your advice would be to stay clear of the PIT, because it is
> (globally) useless.
> 
> I'll keep it in mind.

I tend to think like this as well.

I would like to simplify our timer handling on AT91 and stick with TC
for this purpose.
It has de disadvantage of being obliged to use a TC(block) for
clockevent/clocksource and loose it if we want to do something else with
it but I do think that it's worth it.

If you want a modified TC driver that registers sched_clock, we can
provide you one as a workaround before that we rework the TC driver
completely. It has it's own flaws (like re-using a compatible string or
preventing the use of the "tclib") but is certainly handy.

Bye,
-- 
Nicolas Ferre

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

end of thread, other threads:[~2016-02-24 17:13 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-24 16:04 [PATCH v2] clocksource: atmel-pit: register as a sched_clock Romain Izard
2016-02-24 16:04 ` Romain Izard
2016-02-24 16:15 ` Alexandre Belloni
2016-02-24 16:15   ` Alexandre Belloni
2016-02-24 16:20 ` Sylvain Rochet
2016-02-24 16:20   ` Sylvain Rochet
2016-02-24 16:44   ` Romain Izard
2016-02-24 16:44     ` Romain Izard
2016-02-24 17:13     ` Nicolas Ferre
2016-02-24 17:13       ` Nicolas Ferre

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.