Skip to contentSkip to conversation

clocksource: SuperH CMT driver resume changes

PATCH In review Magnus Damm 2 participants 5 messages Nov 25, 2009 – Nov 30, 2009

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

cover clocksource: SuperH CMT driver resume changes

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.

---

 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(-)
#1 lore raw

PATCH 1/2 clocksource: Add argument to resume callback

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.

---

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(-)
arch/ia64/kernel/time.c +1 -1
@@ -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();
arch/x86/kernel/hpet.c +1 -1
@@ -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();
arch/x86/kernel/tsc.c +1 -1
@@ -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;
 }
include/linux/clocksource.h +1 -1
@@ -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))
kernel/time/clocksource.c +1 -1
@@ -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();
 }
#2 lore raw

PATCH 2/2 clocksource: Start CMT at clocksource resume

In reply to Magnus Damm

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.

---

 drivers/clocksource/sh_cmt.c |    8 ++++++++
 1 file changed, 8 insertions(+)
drivers/clocksource/sh_cmt.c +8 -0
@@ -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);
#3 lore raw

Re: [PATCH 02/02] clocksource: Start CMT at clocksource resume

Quoted 7 lines · Magnus Damm

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

Quoted 31 lines

---

 drivers/clocksource/sh_cmt.c |    8 ++++++++
 1 file changed, 8 insertions(+)
drivers/clocksource/sh_cmt.c +8 -0
@@ -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);
#4 lore raw

Re: [PATCH 02/02] clocksource: Start CMT at clocksource resume

Hi Thomas,

Quoted 6 lines · Thomas Gleixner
Quoted 4 lines · Magnus Damm

From: Magnus Damm <[email protected]>

Add code to start the CMT timer on clocksource resume.

Quoted 8 lines
Quoted 3 lines

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.

Quoted 2 lines

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