All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] OMAP: timekeeping: time should not stop during suspend
@ 2009-11-17 23:41 Kevin Hilman
  2009-11-18 18:58 ` Tony Lindgren
  0 siblings, 1 reply; 3+ messages in thread
From: Kevin Hilman @ 2009-11-17 23:41 UTC (permalink / raw
  To: linux-omap; +Cc: Jon Hunter

During suspend, the kernel timekeeping subsystem is shut down.  Before
suspend and upon resume, it uses a weak function
read_persistent_clock() to determine the amount of time that elapsed
during suspend.

This function was not implemented on OMAP, so from the timekeeping
subsystem perspective (and thus userspace as well) it appeared that no
time elapsed during suspend.

This patch uses the 32k sync timer as a the persistent clock the 32k
sync timer value converted to seconds.

NOTE: This does *NOT* handle wrapping of the 32k sync timer, so
      wrapping of the 32k sync timer during suspend may cause
      problems.  Also, there are not interrupts when the 32k sync
      timer wraps, so something else has to be done.

Reported-by: Jon Hunter <jon-hunter@ti.com>
Signed-off-by: Kevin Hilman <khilman@deeprootsystems.com>
---
Since v1 of this patch, the signature of this function changed.

Also note that forthcoming omap_device patches will depend on this
function instead of getnstimeofday() since the timekeeping subsystem
is suspended when we want to do omap_device timing measurements.

 arch/arm/plat-omap/common.c |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/arch/arm/plat-omap/common.c b/arch/arm/plat-omap/common.c
index cc050b3..8057966 100644
--- a/arch/arm/plat-omap/common.c
+++ b/arch/arm/plat-omap/common.c
@@ -172,6 +172,25 @@ unsigned long long sched_clock(void)
 				  clocksource_32k.mult, clocksource_32k.shift);
 }
 
+/**
+ * read_persistent_clock -  Return time from the persistent clock.
+ *
+ * Reads the time from a source which isn't disabled during PM: 32k sync
+ * Returns a timespec with tv_sec=0 and tv_nsec=0 if unsupported.
+ *
+ */
+void read_persistent_clock(struct timespec *ts)
+{
+	unsigned long long nsecs;
+	cycle_t cycles;
+
+	ts->tv_sec = ts->tv_nsec = 0;
+	cycles = clocksource_32k.read(&clocksource_32k);
+	nsecs = clocksource_cyc2ns(cycles,
+				   clocksource_32k.mult, clocksource_32k.shift);
+	timespec_add_ns(ts, nsecs);
+}
+
 static int __init omap_init_clocksource_32k(void)
 {
 	static char err[] __initdata = KERN_ERR
-- 
1.6.5.1


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

* Re: [PATCH v2] OMAP: timekeeping: time should not stop during suspend
  2009-11-17 23:41 [PATCH v2] OMAP: timekeeping: time should not stop during suspend Kevin Hilman
@ 2009-11-18 18:58 ` Tony Lindgren
  2009-11-18 21:51   ` Kevin Hilman
  0 siblings, 1 reply; 3+ messages in thread
From: Tony Lindgren @ 2009-11-18 18:58 UTC (permalink / raw
  To: Kevin Hilman; +Cc: linux-omap, Jon Hunter

* Kevin Hilman <khilman@deeprootsystems.com> [091117 15:41]:
> During suspend, the kernel timekeeping subsystem is shut down.  Before
> suspend and upon resume, it uses a weak function
> read_persistent_clock() to determine the amount of time that elapsed
> during suspend.
> 
> This function was not implemented on OMAP, so from the timekeeping
> subsystem perspective (and thus userspace as well) it appeared that no
> time elapsed during suspend.
> 
> This patch uses the 32k sync timer as a the persistent clock the 32k
> sync timer value converted to seconds.
> 
> NOTE: This does *NOT* handle wrapping of the 32k sync timer, so
>       wrapping of the 32k sync timer during suspend may cause
>       problems.  Also, there are not interrupts when the 32k sync
>       timer wraps, so something else has to be done.

Kevin, are you planning to queue this in your PM series for the next
merge window? In that case Acked-by: Tony Lindgren <tony@atomide.com>

If you want me to queue this as a fix for the -rc series, let me know.

Regards,

Tony
 
> Reported-by: Jon Hunter <jon-hunter@ti.com>
> Signed-off-by: Kevin Hilman <khilman@deeprootsystems.com>
> ---
> Since v1 of this patch, the signature of this function changed.
> 
> Also note that forthcoming omap_device patches will depend on this
> function instead of getnstimeofday() since the timekeeping subsystem
> is suspended when we want to do omap_device timing measurements.
> 
>  arch/arm/plat-omap/common.c |   19 +++++++++++++++++++
>  1 files changed, 19 insertions(+), 0 deletions(-)
> 
> diff --git a/arch/arm/plat-omap/common.c b/arch/arm/plat-omap/common.c
> index cc050b3..8057966 100644
> --- a/arch/arm/plat-omap/common.c
> +++ b/arch/arm/plat-omap/common.c
> @@ -172,6 +172,25 @@ unsigned long long sched_clock(void)
>  				  clocksource_32k.mult, clocksource_32k.shift);
>  }
>  
> +/**
> + * read_persistent_clock -  Return time from the persistent clock.
> + *
> + * Reads the time from a source which isn't disabled during PM: 32k sync
> + * Returns a timespec with tv_sec=0 and tv_nsec=0 if unsupported.
> + *
> + */
> +void read_persistent_clock(struct timespec *ts)
> +{
> +	unsigned long long nsecs;
> +	cycle_t cycles;
> +
> +	ts->tv_sec = ts->tv_nsec = 0;
> +	cycles = clocksource_32k.read(&clocksource_32k);
> +	nsecs = clocksource_cyc2ns(cycles,
> +				   clocksource_32k.mult, clocksource_32k.shift);
> +	timespec_add_ns(ts, nsecs);
> +}
> +
>  static int __init omap_init_clocksource_32k(void)
>  {
>  	static char err[] __initdata = KERN_ERR
> -- 
> 1.6.5.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-omap" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH v2] OMAP: timekeeping: time should not stop during suspend
  2009-11-18 18:58 ` Tony Lindgren
@ 2009-11-18 21:51   ` Kevin Hilman
  0 siblings, 0 replies; 3+ messages in thread
From: Kevin Hilman @ 2009-11-18 21:51 UTC (permalink / raw
  To: Tony Lindgren; +Cc: linux-omap, Jon Hunter

Tony Lindgren <tony@atomide.com> writes:

> * Kevin Hilman <khilman@deeprootsystems.com> [091117 15:41]:
>> During suspend, the kernel timekeeping subsystem is shut down.  Before
>> suspend and upon resume, it uses a weak function
>> read_persistent_clock() to determine the amount of time that elapsed
>> during suspend.
>> 
>> This function was not implemented on OMAP, so from the timekeeping
>> subsystem perspective (and thus userspace as well) it appeared that no
>> time elapsed during suspend.
>> 
>> This patch uses the 32k sync timer as a the persistent clock the 32k
>> sync timer value converted to seconds.
>> 
>> NOTE: This does *NOT* handle wrapping of the 32k sync timer, so
>>       wrapping of the 32k sync timer during suspend may cause
>>       problems.  Also, there are not interrupts when the 32k sync
>>       timer wraps, so something else has to be done.
>
> Kevin, are you planning to queue this in your PM series for the next
> merge window? In that case Acked-by: Tony Lindgren <tony@atomide.com>
>
> If you want me to queue this as a fix for the -rc series, let me know.

I'll queue it for next merge window, thanks.

Kevin

>  
>> Reported-by: Jon Hunter <jon-hunter@ti.com>
>> Signed-off-by: Kevin Hilman <khilman@deeprootsystems.com>
>> ---
>> Since v1 of this patch, the signature of this function changed.
>> 
>> Also note that forthcoming omap_device patches will depend on this
>> function instead of getnstimeofday() since the timekeeping subsystem
>> is suspended when we want to do omap_device timing measurements.
>> 
>>  arch/arm/plat-omap/common.c |   19 +++++++++++++++++++
>>  1 files changed, 19 insertions(+), 0 deletions(-)
>> 
>> diff --git a/arch/arm/plat-omap/common.c b/arch/arm/plat-omap/common.c
>> index cc050b3..8057966 100644
>> --- a/arch/arm/plat-omap/common.c
>> +++ b/arch/arm/plat-omap/common.c
>> @@ -172,6 +172,25 @@ unsigned long long sched_clock(void)
>>  				  clocksource_32k.mult, clocksource_32k.shift);
>>  }
>>  
>> +/**
>> + * read_persistent_clock -  Return time from the persistent clock.
>> + *
>> + * Reads the time from a source which isn't disabled during PM: 32k sync
>> + * Returns a timespec with tv_sec=0 and tv_nsec=0 if unsupported.
>> + *
>> + */
>> +void read_persistent_clock(struct timespec *ts)
>> +{
>> +	unsigned long long nsecs;
>> +	cycle_t cycles;
>> +
>> +	ts->tv_sec = ts->tv_nsec = 0;
>> +	cycles = clocksource_32k.read(&clocksource_32k);
>> +	nsecs = clocksource_cyc2ns(cycles,
>> +				   clocksource_32k.mult, clocksource_32k.shift);
>> +	timespec_add_ns(ts, nsecs);
>> +}
>> +
>>  static int __init omap_init_clocksource_32k(void)
>>  {
>>  	static char err[] __initdata = KERN_ERR
>> -- 
>> 1.6.5.1
>> 
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-omap" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

end of thread, other threads:[~2009-11-18 21:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-17 23:41 [PATCH v2] OMAP: timekeeping: time should not stop during suspend Kevin Hilman
2009-11-18 18:58 ` Tony Lindgren
2009-11-18 21:51   ` Kevin Hilman

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.