clocksource: SuperH CMT driver resume changes
[PATCH 01/02] clocksource: Add argument to resume callback
[PATCH 02/02] clocksource: Start CMT at clocksource resume
These patches modify the clocksource code so the CMT
driver can be resumed properly. Trivial stuff, but may
cause slight breakage if I managed to miss any clocksource
drivers that use the resume callback.
Signed-off-by: Magnus Damm <[email protected]>
---
arch/ia64/kernel/time.c | 4 ++--
arch/x86/kernel/hpet.c | 4 ++--
arch/x86/kernel/tsc.c | 4 ++--
drivers/clocksource/sh_cmt.c | 16 ++++++++++++++++
include/linux/clocksource.h | 4 ++--
kernel/time/clocksource.c | 4 ++--
6 files changed, 26 insertions(+), 10 deletions(-)
From: Magnus Damm <[email protected]>
Pass the clocksource as an argument to the clocksource
resume callback. Needed so we can point out which CMT
channel the sh_cmt.c driver shall resume.
Signed-off-by: Magnus Damm <[email protected]>
---
Applies to linux-next 20091124
Compile tested on x86.
arch/ia64/kernel/time.c | 2 +-
arch/x86/kernel/hpet.c | 2 +-
arch/x86/kernel/tsc.c | 2 +-
include/linux/clocksource.h | 2 +-
kernel/time/clocksource.c | 2 +-
5 files changed, 5 insertions(+), 5 deletions(-)
--- 0001/arch/ia64/kernel/time.c
+++ work/arch/ia64/kernel/time.c 2009-11-25 15:45:01.000000000 +0900
@@ -61,7 +61,7 @@ unsigned long long sched_clock(void)
#ifdef CONFIG_PARAVIRT
static void
-paravirt_clocksource_resume(void)
+paravirt_clocksource_resume(struct clocksource *cs)
{
if (pv_time_ops.clocksource_resume)
pv_time_ops.clocksource_resume();
--- 0001/arch/x86/kernel/hpet.c
+++ work/arch/x86/kernel/hpet.c 2009-11-25 15:45:01.000000000 +0900
@@ -264,7 +264,7 @@ static void hpet_resume_device(void)
force_hpet_resume();
}
-static void hpet_resume_counter(void)
+static void hpet_resume_counter(struct clocksource *cs)
{
hpet_resume_device();
hpet_restart_counter();
--- 0001/arch/x86/kernel/tsc.c
+++ work/arch/x86/kernel/tsc.c 2009-11-25 15:45:01.000000000 +0900
@@ -740,7 +740,7 @@ static cycle_t __vsyscall_fn vread_tsc(v
}
#endif
-static void resume_tsc(void)
+static void resume_tsc(struct clocksource *cs)
{
clocksource_tsc.cycle_last = 0;
}
--- 0001/include/linux/clocksource.h
+++ work/include/linux/clocksource.h 2009-11-25 15:45:01.000000000 +0900
@@ -172,7 +172,7 @@ struct clocksource {
u64 max_idle_ns;
unsigned long flags;
cycle_t (*vread)(void);
- void (*resume)(void);
+ void (*resume)(struct clocksource *cs);
#ifdef CONFIG_IA64
void *fsys_mmio; /* used by fsyscall asm code */
#define CLKSRC_FSYS_MMIO_SET(mmio, addr) ((mmio) = (addr))
--- 0001/kernel/time/clocksource.c
+++ work/kernel/time/clocksource.c 2009-11-25 15:45:01.000000000 +0900
@@ -449,7 +449,7 @@ void clocksource_resume(void)
list_for_each_entry(cs, &clocksource_list, list)
if (cs->resume)
- cs->resume();
+ cs->resume(cs);
clocksource_resume_watchdog();
}
From: Magnus Damm <[email protected]>
Add code to start the CMT timer on clocksource resume.
This makes sure the timer is started during sysdev_resume().
Without this patch the clocksource may be read as suspended,
this after sysdev resume but before platform device resume.
Signed-off-by: Magnus Damm <[email protected]>
---
drivers/clocksource/sh_cmt.c | 8 ++++++++
1 file changed, 8 insertions(+)
--- 0001/drivers/clocksource/sh_cmt.c
+++ work/drivers/clocksource/sh_cmt.c 2009-11-25 16:02:52.000000000 +0900
@@ -432,6 +432,13 @@ static void sh_cmt_clocksource_disable(s
sh_cmt_stop(cs_to_sh_cmt(cs), FLAG_CLOCKSOURCE);
}
+static void sh_cmt_clocksource_resume(struct clocksource *cs)
+{
+ struct sh_cmt_priv *p = cs_to_sh_cmt(cs);
+
+ sh_cmt_start(p, FLAG_CLOCKSOURCE);
+}
+
static int sh_cmt_register_clocksource(struct sh_cmt_priv *p,
char *name, unsigned long rating)
{
@@ -442,6 +449,7 @@ static int sh_cmt_register_clocksource(s
cs->read = sh_cmt_clocksource_read;
cs->enable = sh_cmt_clocksource_enable;
cs->disable = sh_cmt_clocksource_disable;
+ cs->resume = sh_cmt_clocksource_resume;
cs->mask = CLOCKSOURCE_MASK(sizeof(unsigned long) * 8);
cs->flags = CLOCK_SOURCE_IS_CONTINUOUS;
pr_info("sh_cmt: %s used as clock source\n", cs->name);
On Wed, 25 Nov 2009, Magnus Damm wrote:
> From: Magnus Damm <[email protected]>
>
> Add code to start the CMT timer on clocksource resume.
>
> This makes sure the timer is started during sysdev_resume().
> Without this patch the clocksource may be read as suspended,
> this after sysdev resume but before platform device resume.
Hmm, don't you have the same situation on suspend ?
platform device suspend stops the clock, but the generic code expects
it to be running until sysdev shutdown.
Another thing is that you now run both, the sysdev and the platform
resume. Is that by design or accident ?
Thanks,
tglx
> Signed-off-by: Magnus Damm <[email protected]>
> ---
>
> drivers/clocksource/sh_cmt.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> --- 0001/drivers/clocksource/sh_cmt.c
> +++ work/drivers/clocksource/sh_cmt.c 2009-11-25 16:02:52.000000000 +0900
> @@ -432,6 +432,13 @@ static void sh_cmt_clocksource_disable(s
> sh_cmt_stop(cs_to_sh_cmt(cs), FLAG_CLOCKSOURCE);
> }
>
> +static void sh_cmt_clocksource_resume(struct clocksource *cs)
> +{
> + struct sh_cmt_priv *p = cs_to_sh_cmt(cs);
> +
> + sh_cmt_start(p, FLAG_CLOCKSOURCE);
> +}
> +
> static int sh_cmt_register_clocksource(struct sh_cmt_priv *p,
> char *name, unsigned long rating)
> {
> @@ -442,6 +449,7 @@ static int sh_cmt_register_clocksource(s
> cs->read = sh_cmt_clocksource_read;
> cs->enable = sh_cmt_clocksource_enable;
> cs->disable = sh_cmt_clocksource_disable;
> + cs->resume = sh_cmt_clocksource_resume;
> cs->mask = CLOCKSOURCE_MASK(sizeof(unsigned long) * 8);
> cs->flags = CLOCK_SOURCE_IS_CONTINUOUS;
> pr_info("sh_cmt: %s used as clock source\n", cs->name);
>
Hi Thomas,
On Sat, Nov 28, 2009 at 11:00 PM, Thomas Gleixner <[email protected]> wrote:
> On Wed, 25 Nov 2009, Magnus Damm wrote:
>
>> From: Magnus Damm <[email protected]>
>>
>> Add code to start the CMT timer on clocksource resume.
>>
>> This makes sure the timer is started during sysdev_resume().
>> Without this patch the clocksource may be read as suspended,
>> this after sysdev resume but before platform device resume.
>
> Hmm, don't you have the same situation on suspend ?
>
> platform device suspend stops the clock, but the generic code expects
> it to be running until sysdev shutdown.
You are correct, the same situation exists on suspend.
> Another thing is that you now run both, the sysdev and the platform
> resume. Is that by design or accident ?
By incorrect design. =)
To fix this properly I was thinking of adding a clocksource suspend()
callback and ditch the platform ops all together. If you don't mind
then I'll post a patch for that tomorrow!
Thank you!
/ magnus