mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/7] clocksource_register_khz/hz cleanups(for 2.6.37?)
@ 2010-10-20 23:44 John Stultz
  2010-10-20 23:44 ` [PATCH 1/7] x86: Convert remaining clocksources to clocksource_register_hz/khz John Stultz
  0 siblings, 1 reply; 11+ messages in thread
From: John Stultz @ 2010-10-20 23:44 UTC (permalink / raw)
  To: LKML
  Cc: John Stultz, jacob.jun.pan, Glauber Costa, Dimitri Sivanich,
	Alok N Kataria, Rusty Russell, Jeremy Fitzhardinge,
	Chris McDermott, Thomas Gleixner, Magnus Damm, Paul Mundt,
	Tony Luck, David S. Miller, Haavard Skinnemoen, Ralf Baechle,
	Mike Frysinger

So the common x86 clocksources have switched over to using 
clocksource_register_khz/hz() and so far I've seen no bug
reports, so I wanted to post the conversion for a few more
architectures so they can be queued up for 2.6.37 (or later
if the maintainer feels more testing would be good).

These changes greatly simplify clocksource registration,
removing much of the copy/paste voodoo surrounding how
to calculate good mult and shift values for clocksources.

While the patch set is numbered here, the patches are not
dependent on each other. So each maintainer can make an 
independent call on merging for 2.6.37.

The conversion is fairly straight forward. However, I have 
not been able to test these, so I'd appreciate any testing 
or feedback. Any assistance from the maintainers in getting
these into their trees would also be greatly appreciated.

thanks
-john


CC: jacob.jun.pan@intel.com
CC: Glauber Costa <glommer@redhat.com>
CC: Dimitri Sivanich <sivanich@sgi.com>
CC: Alok N Kataria <akataria@vmware.com>
CC: Rusty Russell <rusty@rustcorp.com.au>
CC: Jeremy Fitzhardinge <jeremy@xensource.com>
CC: Chris McDermott <lcm@us.ibm.com>
CC: Thomas Gleixner <tglx@linutronix.de>
CC: Magnus Damm <magnus.damm@gmail.com>
CC: Paul Mundt <lethal@linux-sh.org>
CC: Tony Luck <tony.luck@intel.com>
CC: "David S. Miller" <davem@davemloft.net>
CC: Haavard Skinnemoen <hskinnemoen@atmel.com>
CC: Ralf Baechle <ralf@linux-mips.org>
CC: Mike Frysinger <vapier@gentoo.org>


John Stultz (7):
  x86: Convert remaining clocksources to clocksource_register_hz/khz
  sh: convert to clocksource_register_hz
  ia64: convert to clocksource_register_hz/khz
  sparc: convert to clocksource_register_hz/khz
  avr32: Convert to clocksource_register_hz
  mips: convert to clocksource_register_hz/khz
  blackfin: convert to clocksource_register_hz

 arch/avr32/kernel/time.c                        |    5 +--
 arch/blackfin/kernel/time-ts.c                  |   35 +---------------------
 arch/ia64/kernel/cyclone.c                      |    6 +---
 arch/ia64/kernel/time.c                         |    9 +----
 arch/ia64/sn/kernel/sn2/timer.c                 |    6 +---
 arch/mips/alchemy/common/time.c                 |    3 +-
 arch/mips/cavium-octeon/csrc-octeon.c           |    3 +-
 arch/mips/include/asm/time.h                    |    6 ----
 arch/mips/jz4740/time.c                         |    3 +-
 arch/mips/kernel/cevt-txx9.c                    |    3 +-
 arch/mips/kernel/csrc-bcm1480.c                 |    3 +-
 arch/mips/kernel/csrc-ioasic.c                  |    4 +--
 arch/mips/kernel/csrc-powertv.c                 |   35 ++---------------------
 arch/mips/kernel/csrc-r4k.c                     |    4 +--
 arch/mips/kernel/csrc-sb1250.c                  |    3 +-
 arch/mips/kernel/i8253.c                        |    5 +--
 arch/mips/loongson/common/cs5536/cs5536_mfgpt.c |    5 +--
 arch/mips/sgi-ip27/ip27-timer.c                 |    3 +-
 arch/sparc/kernel/time_64.c                     |    4 +--
 arch/x86/kernel/apb_timer.c                     |   10 +------
 arch/x86/kernel/i8253.c                         |    6 +---
 arch/x86/kernel/kvmclock.c                      |    6 +---
 arch/x86/kernel/uv_time.c                       |    6 +---
 arch/x86/kernel/vmiclock_32.c                   |    9 +-----
 arch/x86/lguest/boot.c                          |    4 +--
 arch/x86/xen/time.c                             |    6 +---
 drivers/char/hpet.c                             |    6 +---
 drivers/clocksource/cyclone.c                   |   10 +-----
 drivers/clocksource/sh_cmt.c                    |   14 ++++----
 drivers/clocksource/sh_tmu.c                    |   12 ++++----
 30 files changed, 45 insertions(+), 189 deletions(-)


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

* [PATCH 1/7] x86: Convert remaining clocksources to clocksource_register_hz/khz
  2010-10-20 23:44 [PATCH 0/7] clocksource_register_khz/hz cleanups(for 2.6.37?) John Stultz
@ 2010-10-20 23:44 ` John Stultz
  2010-10-20 23:44   ` [PATCH 2/7] sh: convert to clocksource_register_hz John Stultz
  2010-10-21 19:16   ` [PATCH 1/7] x86: Convert remaining clocksources " Alok Kataria
  0 siblings, 2 replies; 11+ messages in thread
From: John Stultz @ 2010-10-20 23:44 UTC (permalink / raw)
  To: LKML
  Cc: John Stultz, jacob.jun.pan, Glauber Costa, Dimitri Sivanich,
	Alok N Kataria, Rusty Russell, Jeremy Fitzhardinge,
	Chris McDermott, Thomas Gleixner

This converts the remaining x86 clocksources to use
clocksource_register_hz/khz. I was not able to test them, so
any extra assistance to make sure time functions properly with
the clocksources changeed here would be appreciated!

CC: jacob.jun.pan@intel.com
CC: Glauber Costa <glommer@redhat.com>
CC: Dimitri Sivanich <sivanich@sgi.com>
CC: Alok N Kataria <akataria@vmware.com>
CC: Rusty Russell <rusty@rustcorp.com.au>
CC: Jeremy Fitzhardinge <jeremy@xensource.com>
CC: Chris McDermott <lcm@us.ibm.com>
CC: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: John Stultz <johnstul@us.ibm.com>
---
 arch/x86/kernel/apb_timer.c   |   10 +---------
 arch/x86/kernel/i8253.c       |    6 +-----
 arch/x86/kernel/kvmclock.c    |    6 +-----
 arch/x86/kernel/uv_time.c     |    6 +-----
 arch/x86/kernel/vmiclock_32.c |    9 +--------
 arch/x86/lguest/boot.c        |    4 +---
 arch/x86/xen/time.c           |    6 +-----
 drivers/clocksource/cyclone.c |   10 ++--------
 8 files changed, 9 insertions(+), 48 deletions(-)

diff --git a/arch/x86/kernel/apb_timer.c b/arch/x86/kernel/apb_timer.c
index 8dd7780..c5ad23c 100644
--- a/arch/x86/kernel/apb_timer.c
+++ b/arch/x86/kernel/apb_timer.c
@@ -177,7 +177,6 @@ static struct clocksource clocksource_apbt = {
 	.rating		= APBT_CLOCKSOURCE_RATING,
 	.read		= apbt_read_clocksource,
 	.mask		= APBT_MASK,
-	.shift		= APBT_SHIFT,
 	.flags		= CLOCK_SOURCE_IS_CONTINUOUS,
 	.resume		= apbt_restart_clocksource,
 };
@@ -598,14 +597,7 @@ static int apbt_clocksource_register(void)
 	if (t1 == apbt_read_clocksource(&clocksource_apbt))
 		panic("APBT counter not counting. APBT disabled\n");
 
-	/*
-	 * initialize and register APBT clocksource
-	 * convert that to ns/clock cycle
-	 * mult = (ns/c) * 2^APBT_SHIFT
-	 */
-	clocksource_apbt.mult = div_sc(MSEC_PER_SEC,
-				       (unsigned long) apbt_freq, APBT_SHIFT);
-	clocksource_register(&clocksource_apbt);
+	clocksource_register_khz(&clocksource_apbt,(u32)apbt_freq*1000);
 
 	return 0;
 }
diff --git a/arch/x86/kernel/i8253.c b/arch/x86/kernel/i8253.c
index 2dfd315..212fe65 100644
--- a/arch/x86/kernel/i8253.c
+++ b/arch/x86/kernel/i8253.c
@@ -188,8 +188,6 @@ static struct clocksource pit_cs = {
 	.rating		= 110,
 	.read		= pit_read,
 	.mask		= CLOCKSOURCE_MASK(32),
-	.mult		= 0,
-	.shift		= 20,
 };
 
 static int __init init_pit_clocksource(void)
@@ -205,9 +203,7 @@ static int __init init_pit_clocksource(void)
 	    pit_ce.mode != CLOCK_EVT_MODE_PERIODIC)
 		return 0;
 
-	pit_cs.mult = clocksource_hz2mult(CLOCK_TICK_RATE, pit_cs.shift);
-
-	return clocksource_register(&pit_cs);
+	return clocksource_register_hz(&pit_cs, CLOCK_TICK_RATE);
 }
 arch_initcall(init_pit_clocksource);
 
diff --git a/arch/x86/kernel/kvmclock.c b/arch/x86/kernel/kvmclock.c
index eb9b76c..532fa9b 100644
--- a/arch/x86/kernel/kvmclock.c
+++ b/arch/x86/kernel/kvmclock.c
@@ -26,8 +26,6 @@
 #include <asm/x86_init.h>
 #include <asm/reboot.h>
 
-#define KVM_SCALE 22
-
 static int kvmclock = 1;
 static int msr_kvm_system_time = MSR_KVM_SYSTEM_TIME;
 static int msr_kvm_wall_clock = MSR_KVM_WALL_CLOCK;
@@ -120,8 +118,6 @@ static struct clocksource kvm_clock = {
 	.read = kvm_clock_get_cycles,
 	.rating = 400,
 	.mask = CLOCKSOURCE_MASK(64),
-	.mult = 1 << KVM_SCALE,
-	.shift = KVM_SCALE,
 	.flags = CLOCK_SOURCE_IS_CONTINUOUS,
 };
 
@@ -212,7 +208,7 @@ void __init kvmclock_init(void)
 	machine_ops.crash_shutdown  = kvm_crash_shutdown;
 #endif
 	kvm_get_preset_lpj();
-	clocksource_register(&kvm_clock);
+	clocksource_register_hz(&kvm_clock, NSEC_PER_SEC);
 	pv_info.paravirt_enabled = 1;
 	pv_info.name = "KVM";
 
diff --git a/arch/x86/kernel/uv_time.c b/arch/x86/kernel/uv_time.c
index 56e421b..6f86d74 100644
--- a/arch/x86/kernel/uv_time.c
+++ b/arch/x86/kernel/uv_time.c
@@ -40,7 +40,6 @@ static struct clocksource clocksource_uv = {
 	.rating		= 400,
 	.read		= uv_read_rtc,
 	.mask		= (cycle_t)UVH_RTC_REAL_TIME_CLOCK_MASK,
-	.shift		= 10,
 	.flags		= CLOCK_SOURCE_IS_CONTINUOUS,
 };
 
@@ -370,14 +369,11 @@ static __init int uv_rtc_setup_clock(void)
 	if (!is_uv_system())
 		return -ENODEV;
 
-	clocksource_uv.mult = clocksource_hz2mult(sn_rtc_cycles_per_second,
-				clocksource_uv.shift);
-
 	/* If single blade, prefer tsc */
 	if (uv_num_possible_blades() == 1)
 		clocksource_uv.rating = 250;
 
-	rc = clocksource_register(&clocksource_uv);
+	rc = clocksource_register_hz(&clocksource_uv, sn_rtc_cycles_per_second);
 	if (rc)
 		printk(KERN_INFO "UV RTC clocksource failed rc %d\n", rc);
 	else
diff --git a/arch/x86/kernel/vmiclock_32.c b/arch/x86/kernel/vmiclock_32.c
index 5e1ff66..e3401ec 100644
--- a/arch/x86/kernel/vmiclock_32.c
+++ b/arch/x86/kernel/vmiclock_32.c
@@ -290,8 +290,6 @@ static struct clocksource clocksource_vmi = {
 	.rating			= 450,
 	.read			= read_real_cycles,
 	.mask			= CLOCKSOURCE_MASK(64),
-	.mult			= 0, /* to be set */
-	.shift			= 22,
 	.flags			= CLOCK_SOURCE_IS_CONTINUOUS,
 };
 
@@ -305,13 +303,8 @@ static int __init init_vmi_clocksource(void)
 	cycles_per_msec = vmi_timer_ops.get_cycle_frequency();
 	(void)do_div(cycles_per_msec, 1000);
 
-	/* Note that clocksource.{mult, shift} converts in the opposite direction
-	 * as clockevents.  */
-	clocksource_vmi.mult = clocksource_khz2mult(cycles_per_msec,
-						    clocksource_vmi.shift);
-
 	printk(KERN_WARNING "vmi: registering clock source khz=%lld\n", cycles_per_msec);
-	return clocksource_register(&clocksource_vmi);
+	return clocksource_register_khz(&clocksource_vmi, cycles_per_msec);
 
 }
 module_init(init_vmi_clocksource);
diff --git a/arch/x86/lguest/boot.c b/arch/x86/lguest/boot.c
index 9d5f558..3f2fd65 100644
--- a/arch/x86/lguest/boot.c
+++ b/arch/x86/lguest/boot.c
@@ -910,8 +910,6 @@ static struct clocksource lguest_clock = {
 	.rating		= 200,
 	.read		= lguest_clock_read,
 	.mask		= CLOCKSOURCE_MASK(64),
-	.mult		= 1 << 22,
-	.shift		= 22,
 	.flags		= CLOCK_SOURCE_IS_CONTINUOUS,
 };
 
@@ -994,7 +992,7 @@ static void lguest_time_init(void)
 	/* Set up the timer interrupt (0) to go to our simple timer routine */
 	set_irq_handler(0, lguest_time_irq);
 
-	clocksource_register(&lguest_clock);
+	clocksource_register_hz(&lguest_clock, NSEC_PER_SEC);
 
 	/* We can't set cpumask in the initializer: damn C limitations!  Set it
 	 * here and register our timer device. */
diff --git a/arch/x86/xen/time.c b/arch/x86/xen/time.c
index b2bb5aa..ce02ef8 100644
--- a/arch/x86/xen/time.c
+++ b/arch/x86/xen/time.c
@@ -26,8 +26,6 @@
 
 #include "xen-ops.h"
 
-#define XEN_SHIFT 22
-
 /* Xen may fire a timer up to this many ns early */
 #define TIMER_SLOP	100000
 #define NS_PER_TICK	(1000000000LL / HZ)
@@ -211,8 +209,6 @@ static struct clocksource xen_clocksource __read_mostly = {
 	.rating = 400,
 	.read = xen_clocksource_get_cycles,
 	.mask = ~0,
-	.mult = 1<<XEN_SHIFT,		/* time directly in nanoseconds */
-	.shift = XEN_SHIFT,
 	.flags = CLOCK_SOURCE_IS_CONTINUOUS,
 };
 
@@ -444,7 +440,7 @@ static __init void xen_time_init(void)
 	int cpu = smp_processor_id();
 	struct timespec tp;
 
-	clocksource_register(&xen_clocksource);
+	clocksource_register_hz(&xen_clocksource, NSEC_PER_SEC);
 
 	if (HYPERVISOR_vcpu_op(VCPUOP_stop_periodic_timer, cpu, NULL) == 0) {
 		/* Successfully turned off 100Hz tick, so we have the
diff --git a/drivers/clocksource/cyclone.c b/drivers/clocksource/cyclone.c
index 64e528e..72f811f 100644
--- a/drivers/clocksource/cyclone.c
+++ b/drivers/clocksource/cyclone.c
@@ -29,8 +29,6 @@ static struct clocksource clocksource_cyclone = {
 	.rating		= 250,
 	.read		= read_cyclone,
 	.mask		= CYCLONE_TIMER_MASK,
-	.mult		= 10,
-	.shift		= 0,
 	.flags		= CLOCK_SOURCE_IS_CONTINUOUS,
 };
 
@@ -108,12 +106,8 @@ static int __init init_cyclone_clocksource(void)
 	}
 	cyclone_ptr = cyclone_timer;
 
-	/* sort out mult/shift values: */
-	clocksource_cyclone.shift = 22;
-	clocksource_cyclone.mult = clocksource_hz2mult(CYCLONE_TIMER_FREQ,
-						clocksource_cyclone.shift);
-
-	return clocksource_register(&clocksource_cyclone);
+	return clocksource_register_hz(&clocksource_cyclone,
+					CYCLONE_TIMER_FREQ);
 }
 
 arch_initcall(init_cyclone_clocksource);
-- 
1.6.0.4


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

* [PATCH 2/7] sh: convert to clocksource_register_hz
  2010-10-20 23:44 ` [PATCH 1/7] x86: Convert remaining clocksources to clocksource_register_hz/khz John Stultz
@ 2010-10-20 23:44   ` John Stultz
  2010-10-20 23:44     ` [PATCH 3/7] ia64: convert to clocksource_register_hz/khz John Stultz
  2010-10-21 19:16   ` [PATCH 1/7] x86: Convert remaining clocksources " Alok Kataria
  1 sibling, 1 reply; 11+ messages in thread
From: John Stultz @ 2010-10-20 23:44 UTC (permalink / raw)
  To: LKML; +Cc: John Stultz, Magnus Damm, Paul Mundt, Thomas Gleixner

Convert sh_tmu/sh_cmt clocksources to clocksource_register_hz

I was unable to test these, so any help from maintainers would
be appreciated!

Signed-off-by: John Stultz <johnstul@us.ibm.com>
CC: Magnus Damm <magnus.damm@gmail.com>
CC: Paul Mundt <lethal@linux-sh.org>
CC: Thomas Gleixner <tglx@linutronix.de>
---
 drivers/clocksource/sh_cmt.c |   14 +++++++-------
 drivers/clocksource/sh_tmu.c |   12 ++++++------
 2 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/drivers/clocksource/sh_cmt.c b/drivers/clocksource/sh_cmt.c
index 717305d..aeee6ac 100644
--- a/drivers/clocksource/sh_cmt.c
+++ b/drivers/clocksource/sh_cmt.c
@@ -411,11 +411,16 @@ static cycle_t sh_cmt_clocksource_read(struct clocksource *cs)
 
 static int sh_cmt_clocksource_enable(struct clocksource *cs)
 {
+	int ret;
 	struct sh_cmt_priv *p = cs_to_sh_cmt(cs);
 
 	p->total_cycles = 0;
 
-	return sh_cmt_start(p, FLAG_CLOCKSOURCE);
+	ret = sh_cmt_start(p, FLAG_CLOCKSOURCE);
+	p->rate = clk_get_rate(p->clk) / (p->width == 16) ? 512 : 8;
+	
+	__clocksource_updatefreq_hz(cs, p->rate);
+	return ret;
 }
 
 static void sh_cmt_clocksource_disable(struct clocksource *cs)
@@ -448,14 +453,9 @@ static int sh_cmt_register_clocksource(struct sh_cmt_priv *p,
 	p->rate = clk_get_rate(p->clk) / (p->width == 16) ? 512 : 8;
 	clk_disable(p->clk);
 
-	/* TODO: calculate good shift from rate and counter bit width */
-	cs->shift = 0;
-	cs->mult = clocksource_hz2mult(p->rate, cs->shift);
-
 	dev_info(&p->pdev->dev, "used as clock source\n");
 
-	clocksource_register(cs);
-
+	clocksource_register_hz(cs, p->rate);
 	return 0;
 }
 
diff --git a/drivers/clocksource/sh_tmu.c b/drivers/clocksource/sh_tmu.c
index de71590..09831d9 100644
--- a/drivers/clocksource/sh_tmu.c
+++ b/drivers/clocksource/sh_tmu.c
@@ -199,8 +199,11 @@ static cycle_t sh_tmu_clocksource_read(struct clocksource *cs)
 static int sh_tmu_clocksource_enable(struct clocksource *cs)
 {
 	struct sh_tmu_priv *p = cs_to_sh_tmu(cs);
-
-	return sh_tmu_enable(p);
+	int ret = sh_tmu_enable(p);
+	p->rate = clk_get_rate(p->clk) / (p->width == 16) ? 512 : 8;
+	
+	__clocksource_updatefreq_hz(cs, p->rate);
+	return ret;
 }
 
 static void sh_tmu_clocksource_disable(struct clocksource *cs)
@@ -226,12 +229,9 @@ static int sh_tmu_register_clocksource(struct sh_tmu_priv *p,
 	/* channel will be configured at parent clock / 4 */
 	p->rate = clk_get_rate(p->clk) / 4;
 	clk_disable(p->clk);
-	/* TODO: calculate good shift from rate and counter bit width */
-	cs->shift = 10;
-	cs->mult = clocksource_hz2mult(p->rate, cs->shift);
 
 	dev_info(&p->pdev->dev, "used as clock source\n");
-	clocksource_register(cs);
+	clocksource_register_hz(cs, p->rate);
 	return 0;
 }
 
-- 
1.6.0.4


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

* [PATCH 3/7] ia64: convert to clocksource_register_hz/khz
  2010-10-20 23:44   ` [PATCH 2/7] sh: convert to clocksource_register_hz John Stultz
@ 2010-10-20 23:44     ` John Stultz
  2010-10-20 23:44       ` [PATCH 4/7] sparc: " John Stultz
  0 siblings, 1 reply; 11+ messages in thread
From: John Stultz @ 2010-10-20 23:44 UTC (permalink / raw)
  To: LKML; +Cc: John Stultz, Tony Luck, Thomas Gleixner

This converts the ia64 clocksources to use clocksource_register_hz/khz

This is untested, so any assistance in testing would be appreciated!

Signed-off-by: John Stultz <johnstul@us.ibm.com>
CC: Tony Luck <tony.luck@intel.com>
CC: Thomas Gleixner <tglx@linutronix.de>
---
 arch/ia64/kernel/cyclone.c      |    6 +-----
 arch/ia64/kernel/time.c         |    9 ++-------
 arch/ia64/sn/kernel/sn2/timer.c |    6 +-----
 drivers/char/hpet.c             |    6 +-----
 4 files changed, 5 insertions(+), 22 deletions(-)

diff --git a/arch/ia64/kernel/cyclone.c b/arch/ia64/kernel/cyclone.c
index 71e3586..6f76be4 100644
--- a/arch/ia64/kernel/cyclone.c
+++ b/arch/ia64/kernel/cyclone.c
@@ -31,8 +31,6 @@ static struct clocksource clocksource_cyclone = {
         .rating         = 300,
         .read           = read_cyclone,
         .mask           = (1LL << 40) - 1,
-        .mult           = 0, /*to be caluclated*/
-        .shift          = 16,
         .flags          = CLOCK_SOURCE_IS_CONTINUOUS,
 };
 
@@ -118,9 +116,7 @@ int __init init_cyclone_clock(void)
 	/* initialize last tick */
 	cyclone_mc = cyclone_timer;
 	clocksource_cyclone.fsys_mmio = cyclone_timer;
-	clocksource_cyclone.mult = clocksource_hz2mult(CYCLONE_TIMER_FREQ,
-						clocksource_cyclone.shift);
-	clocksource_register(&clocksource_cyclone);
+	clocksource_register_hz(&clocksource_cyclone, CYCLONE_TIMER_FREQ);
 
 	return 0;
 }
diff --git a/arch/ia64/kernel/time.c b/arch/ia64/kernel/time.c
index ed6f22e..4b981e5 100644
--- a/arch/ia64/kernel/time.c
+++ b/arch/ia64/kernel/time.c
@@ -73,8 +73,6 @@ static struct clocksource clocksource_itc = {
 	.rating         = 350,
 	.read           = itc_get_cycles,
 	.mask           = CLOCKSOURCE_MASK(64),
-	.mult           = 0, /*to be calculated*/
-	.shift          = 16,
 	.flags          = CLOCK_SOURCE_IS_CONTINUOUS,
 #ifdef CONFIG_PARAVIRT
 	.resume		= paravirt_clocksource_resume,
@@ -374,11 +372,8 @@ ia64_init_itm (void)
 	ia64_cpu_local_tick();
 
 	if (!itc_clocksource) {
-		/* Sort out mult/shift values: */
-		clocksource_itc.mult =
-			clocksource_hz2mult(local_cpu_data->itc_freq,
-						clocksource_itc.shift);
-		clocksource_register(&clocksource_itc);
+		clocksource_register_hz(&clocksource_itc,
+						local_cpu_data->itc_freq );
 		itc_clocksource = &clocksource_itc;
 	}
 }
diff --git a/arch/ia64/sn/kernel/sn2/timer.c b/arch/ia64/sn/kernel/sn2/timer.c
index 21d6f09..c34efda 100644
--- a/arch/ia64/sn/kernel/sn2/timer.c
+++ b/arch/ia64/sn/kernel/sn2/timer.c
@@ -33,8 +33,6 @@ static struct clocksource clocksource_sn2 = {
         .rating         = 450,
         .read           = read_sn2,
         .mask           = (1LL << 55) - 1,
-        .mult           = 0,
-        .shift          = 10,
         .flags          = CLOCK_SOURCE_IS_CONTINUOUS,
 };
 
@@ -57,9 +55,7 @@ ia64_sn_udelay (unsigned long usecs)
 void __init sn_timer_init(void)
 {
 	clocksource_sn2.fsys_mmio = RTC_COUNTER_ADDR;
-	clocksource_sn2.mult = clocksource_hz2mult(sn_rtc_cycles_per_second,
-							clocksource_sn2.shift);
-	clocksource_register(&clocksource_sn2);
+	clocksource_register_hz(&clocksource_sn2, sn_rtc_cycles_per_second);
 
 	ia64_udelay = &ia64_sn_udelay;
 }
diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
index a0a1829..a6b2d09 100644
--- a/drivers/char/hpet.c
+++ b/drivers/char/hpet.c
@@ -83,8 +83,6 @@ static struct clocksource clocksource_hpet = {
         .rating         = 250,
         .read           = read_hpet,
         .mask           = CLOCKSOURCE_MASK(64),
-	.mult		= 0, /* to be calculated */
-        .shift          = 10,
         .flags          = CLOCK_SOURCE_IS_CONTINUOUS,
 };
 static struct clocksource *hpet_clocksource;
@@ -891,9 +889,7 @@ int hpet_alloc(struct hpet_data *hdp)
 	if (!hpet_clocksource) {
 		hpet_mctr = (void __iomem *)&hpetp->hp_hpet->hpet_mc;
 		CLKSRC_FSYS_MMIO_SET(clocksource_hpet.fsys_mmio, hpet_mctr);
-		clocksource_hpet.mult = clocksource_hz2mult(hpetp->hp_tick_freq,
-						clocksource_hpet.shift);
-		clocksource_register(&clocksource_hpet);
+		clocksource_register_hz(&clocksource_hpet, hpetp->hp_tick_freq);
 		hpetp->hp_clocksource = &clocksource_hpet;
 		hpet_clocksource = &clocksource_hpet;
 	}
-- 
1.6.0.4


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

* [PATCH 4/7] sparc: convert to clocksource_register_hz/khz
  2010-10-20 23:44     ` [PATCH 3/7] ia64: convert to clocksource_register_hz/khz John Stultz
@ 2010-10-20 23:44       ` John Stultz
  2010-10-20 23:44         ` [PATCH 5/7] avr32: Convert to clocksource_register_hz John Stultz
  2010-10-21  8:33         ` [PATCH 4/7] sparc: convert to clocksource_register_hz/khz David Miller
  0 siblings, 2 replies; 11+ messages in thread
From: John Stultz @ 2010-10-20 23:44 UTC (permalink / raw)
  To: LKML; +Cc: John Stultz, David S. Miller, Thomas Gleixner

This converts the sparc clocksources to use clocksource_register_hz/khz

This is untested, so any assistance in testing would be appreciated!

Signed-off-by: John Stultz <johnstul@us.ibm.com>
CC: "David S. Miller" <davem@davemloft.net>
CC: Thomas Gleixner <tglx@linutronix.de>
---
 arch/sparc/kernel/time_64.c |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)

diff --git a/arch/sparc/kernel/time_64.c b/arch/sparc/kernel/time_64.c
index 3bc9c99..58aa27b 100644
--- a/arch/sparc/kernel/time_64.c
+++ b/arch/sparc/kernel/time_64.c
@@ -816,14 +816,12 @@ void __init time_init(void)
 		clocksource_hz2mult(freq, SPARC64_NSEC_PER_CYC_SHIFT);
 
 	clocksource_tick.name = tick_ops->name;
-	clocksource_calc_mult_shift(&clocksource_tick, freq, 4);
 	clocksource_tick.read = clocksource_tick_read;
 
+	clocksource_register_hz(&clocksource_tick, freq);
 	printk("clocksource: mult[%x] shift[%d]\n",
 	       clocksource_tick.mult, clocksource_tick.shift);
 
-	clocksource_register(&clocksource_tick);
-
 	sparc64_clockevent.name = tick_ops->name;
 	clockevents_calc_mult_shift(&sparc64_clockevent, freq, 4);
 
-- 
1.6.0.4


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

* [PATCH 5/7] avr32: Convert to clocksource_register_hz
  2010-10-20 23:44       ` [PATCH 4/7] sparc: " John Stultz
@ 2010-10-20 23:44         ` John Stultz
  2010-10-20 23:44           ` [PATCH 6/7] mips: convert to clocksource_register_hz/khz John Stultz
  2010-10-21  8:33         ` [PATCH 4/7] sparc: convert to clocksource_register_hz/khz David Miller
  1 sibling, 1 reply; 11+ messages in thread
From: John Stultz @ 2010-10-20 23:44 UTC (permalink / raw)
  To: LKML; +Cc: John Stultz, Haavard Skinnemoen, Thomas Gleixner

This converts the avr32 clocksource to use clocksource_register_hz.

This is untested, so any assistance in testing would be appreciated!

Signed-off-by: John Stultz <johnstul@us.ibm.com>
CC: Haavard Skinnemoen <hskinnemoen@atmel.com>
CC: Thomas Gleixner <tglx@linutronix.de>
---
 arch/avr32/kernel/time.c |    5 +----
 1 files changed, 1 insertions(+), 4 deletions(-)

diff --git a/arch/avr32/kernel/time.c b/arch/avr32/kernel/time.c
index 668ed28..05ad291 100644
--- a/arch/avr32/kernel/time.c
+++ b/arch/avr32/kernel/time.c
@@ -35,7 +35,6 @@ static struct clocksource counter = {
 	.rating		= 50,
 	.read		= read_cycle_count,
 	.mask		= CLOCKSOURCE_MASK(32),
-	.shift		= 16,
 	.flags		= CLOCK_SOURCE_IS_CONTINUOUS,
 };
 
@@ -123,9 +122,7 @@ void __init time_init(void)
 
 	/* figure rate for counter */
 	counter_hz = clk_get_rate(boot_cpu_data.clk);
-	counter.mult = clocksource_hz2mult(counter_hz, counter.shift);
-
-	ret = clocksource_register(&counter);
+	ret = clocksource_register_hz(&counter, counter_hz);
 	if (ret)
 		pr_debug("timer: could not register clocksource: %d\n", ret);
 
-- 
1.6.0.4


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

* [PATCH 6/7] mips: convert to clocksource_register_hz/khz
  2010-10-20 23:44         ` [PATCH 5/7] avr32: Convert to clocksource_register_hz John Stultz
@ 2010-10-20 23:44           ` John Stultz
  2010-10-20 23:44             ` [PATCH 7/7] blackfin: convert to clocksource_register_hz John Stultz
  0 siblings, 1 reply; 11+ messages in thread
From: John Stultz @ 2010-10-20 23:44 UTC (permalink / raw)
  To: LKML; +Cc: John Stultz, Ralf Baechle, Thomas Gleixner

This converts the mips clocksources to use clocksource_register_hz/khz

This is untested, so any assistance in testing would be appreciated!

Signed-off-by: John Stultz <johnstul@us.ibm.com>
CC: Ralf Baechle <ralf@linux-mips.org>
CC: Thomas Gleixner <tglx@linutronix.de>
---
 arch/mips/alchemy/common/time.c                 |    3 +-
 arch/mips/cavium-octeon/csrc-octeon.c           |    3 +-
 arch/mips/include/asm/time.h                    |    6 ----
 arch/mips/jz4740/time.c                         |    3 +-
 arch/mips/kernel/cevt-txx9.c                    |    3 +-
 arch/mips/kernel/csrc-bcm1480.c                 |    3 +-
 arch/mips/kernel/csrc-ioasic.c                  |    4 +--
 arch/mips/kernel/csrc-powertv.c                 |   35 ++---------------------
 arch/mips/kernel/csrc-r4k.c                     |    4 +--
 arch/mips/kernel/csrc-sb1250.c                  |    3 +-
 arch/mips/kernel/i8253.c                        |    5 +--
 arch/mips/loongson/common/cs5536/cs5536_mfgpt.c |    5 +--
 arch/mips/sgi-ip27/ip27-timer.c                 |    3 +-
 13 files changed, 14 insertions(+), 66 deletions(-)

diff --git a/arch/mips/alchemy/common/time.c b/arch/mips/alchemy/common/time.c
index 2aecb2f..d5da6ad 100644
--- a/arch/mips/alchemy/common/time.c
+++ b/arch/mips/alchemy/common/time.c
@@ -141,8 +141,7 @@ static int __init alchemy_time_init(unsigned int m2int)
 		goto cntr_err;
 
 	/* register counter1 clocksource and event device */
-	clocksource_set_clock(&au1x_counter1_clocksource, 32768);
-	clocksource_register(&au1x_counter1_clocksource);
+	clocksource_register_hz(&au1x_counter1_clocksource, 32768);
 
 	cd->shift = 32;
 	cd->mult = div_sc(32768, NSEC_PER_SEC, cd->shift);
diff --git a/arch/mips/cavium-octeon/csrc-octeon.c b/arch/mips/cavium-octeon/csrc-octeon.c
index b6847c8..28f0697 100644
--- a/arch/mips/cavium-octeon/csrc-octeon.c
+++ b/arch/mips/cavium-octeon/csrc-octeon.c
@@ -77,8 +77,7 @@ unsigned long long notrace sched_clock(void)
 void __init plat_time_init(void)
 {
 	clocksource_mips.rating = 300;
-	clocksource_set_clock(&clocksource_mips, mips_hpt_frequency);
-	clocksource_register(&clocksource_mips);
+	clocksource_register_hz(&clocksource_mips, mips_hpt_frequency);
 }
 
 static u64 octeon_udelay_factor;
diff --git a/arch/mips/include/asm/time.h b/arch/mips/include/asm/time.h
index c7f1bfe..bc14447 100644
--- a/arch/mips/include/asm/time.h
+++ b/arch/mips/include/asm/time.h
@@ -84,12 +84,6 @@ static inline int init_mips_clocksource(void)
 #endif
 }
 
-static inline void clocksource_set_clock(struct clocksource *cs,
-					 unsigned int clock)
-{
-	clocksource_calc_mult_shift(cs, clock, 4);
-}
-
 static inline void clockevent_set_clock(struct clock_event_device *cd,
 					unsigned int clock)
 {
diff --git a/arch/mips/jz4740/time.c b/arch/mips/jz4740/time.c
index fe01678..03dfd4e 100644
--- a/arch/mips/jz4740/time.c
+++ b/arch/mips/jz4740/time.c
@@ -121,8 +121,7 @@ void __init plat_time_init(void)
 
 	clockevents_register_device(&jz4740_clockevent);
 
-	clocksource_set_clock(&jz4740_clocksource, clk_rate);
-	ret = clocksource_register(&jz4740_clocksource);
+	ret = clocksource_register_hz(&jz4740_clocksource, clk_rate);
 
 	if (ret)
 		printk(KERN_ERR "Failed to register clocksource: %d\n", ret);
diff --git a/arch/mips/kernel/cevt-txx9.c b/arch/mips/kernel/cevt-txx9.c
index 218ee6b..ae8093d 100644
--- a/arch/mips/kernel/cevt-txx9.c
+++ b/arch/mips/kernel/cevt-txx9.c
@@ -50,8 +50,7 @@ void __init txx9_clocksource_init(unsigned long baseaddr,
 {
 	struct txx9_tmr_reg __iomem *tmrptr;
 
-	clocksource_set_clock(&txx9_clocksource.cs, TIMER_CLK(imbusclk));
-	clocksource_register(&txx9_clocksource.cs);
+	clocksource_register_hz(&txx9_clocksource.cs, TIMER_CLK(imbusclk));
 
 	tmrptr = ioremap(baseaddr, sizeof(struct txx9_tmr_reg));
 	__raw_writel(TCR_BASE, &tmrptr->tcr);
diff --git a/arch/mips/kernel/csrc-bcm1480.c b/arch/mips/kernel/csrc-bcm1480.c
index 51489f8..f96f99c 100644
--- a/arch/mips/kernel/csrc-bcm1480.c
+++ b/arch/mips/kernel/csrc-bcm1480.c
@@ -49,6 +49,5 @@ void __init sb1480_clocksource_init(void)
 
 	plldiv = G_BCM1480_SYS_PLL_DIV(__raw_readq(IOADDR(A_SCD_SYSTEM_CFG)));
 	zbbus = ((plldiv >> 1) * 50000000) + ((plldiv & 1) * 25000000);
-	clocksource_set_clock(cs, zbbus);
-	clocksource_register(cs);
+	clocksource_register_hz(cs, zbbus);
 }
diff --git a/arch/mips/kernel/csrc-ioasic.c b/arch/mips/kernel/csrc-ioasic.c
index 23da108..46bd7fa 100644
--- a/arch/mips/kernel/csrc-ioasic.c
+++ b/arch/mips/kernel/csrc-ioasic.c
@@ -59,7 +59,5 @@ void __init dec_ioasic_clocksource_init(void)
 	printk(KERN_INFO "I/O ASIC clock frequency %dHz\n", freq);
 
 	clocksource_dec.rating = 200 + freq / 10000000;
-	clocksource_set_clock(&clocksource_dec, freq);
-
-	clocksource_register(&clocksource_dec);
+	clocksource_register_hz(&clocksource_dec, freq);
 }
diff --git a/arch/mips/kernel/csrc-powertv.c b/arch/mips/kernel/csrc-powertv.c
index a27c16c..2e7c523 100644
--- a/arch/mips/kernel/csrc-powertv.c
+++ b/arch/mips/kernel/csrc-powertv.c
@@ -78,9 +78,7 @@ static void __init powertv_c0_hpt_clocksource_init(void)
 
 	clocksource_mips.rating = 200 + mips_hpt_frequency / 10000000;
 
-	clocksource_set_clock(&clocksource_mips, mips_hpt_frequency);
-
-	clocksource_register(&clocksource_mips);
+	clocksource_register_hz(&clocksource_mips, mips_hpt_frequency);
 }
 
 /**
@@ -130,43 +128,16 @@ static struct clocksource clocksource_tim_c = {
 /**
  * powertv_tim_c_clocksource_init - set up a clock source for the TIM_C clock
  *
- * The hard part here is coming up with a constant k and shift s such that
- * the 48-bit TIM_C value multiplied by k doesn't overflow and that value,
- * when shifted right by s, yields the corresponding number of nanoseconds.
  * We know that TIM_C counts at 27 MHz/8, so each cycle corresponds to
- * 1 / (27,000,000/8) seconds. Multiply that by a billion and you get the
- * number of nanoseconds. Since the TIM_C value has 48 bits and the math is
- * done in 64 bits, avoiding an overflow means that k must be less than
- * 64 - 48 = 16 bits.
+ * 1 / (27,000,000/8) seconds.
  */
 static void __init powertv_tim_c_clocksource_init(void)
 {
-	int			prescale;
-	unsigned long		dividend;
-	unsigned long		k;
-	int			s;
-	const int		max_k_bits = (64 - 48) - 1;
-	const unsigned long	billion = 1000000000;
 	const unsigned long	counts_per_second = 27000000 / 8;
 
-	prescale = BITS_PER_LONG - ilog2(billion) - 1;
-	dividend = billion << prescale;
-	k = dividend / counts_per_second;
-	s = ilog2(k) - max_k_bits;
-
-	if (s < 0)
-		s = prescale;
-
-	else {
-		k >>= s;
-		s += prescale;
-	}
-
-	clocksource_tim_c.mult = k;
-	clocksource_tim_c.shift = s;
 	clocksource_tim_c.rating = 200;
 
-	clocksource_register(&clocksource_tim_c);
+	clocksource_register_hz(&clocksource_tim_c, counts_per_second);
 	tim_c = (struct tim_c *) asic_reg_addr(tim_ch);
 }
 
diff --git a/arch/mips/kernel/csrc-r4k.c b/arch/mips/kernel/csrc-r4k.c
index e95a3cd..decd1fa 100644
--- a/arch/mips/kernel/csrc-r4k.c
+++ b/arch/mips/kernel/csrc-r4k.c
@@ -30,9 +30,7 @@ int __init init_r4k_clocksource(void)
 	/* Calculate a somewhat reasonable rating value */
 	clocksource_mips.rating = 200 + mips_hpt_frequency / 10000000;
 
-	clocksource_set_clock(&clocksource_mips, mips_hpt_frequency);
-
-	clocksource_register(&clocksource_mips);
+	clocksource_register_hz(&clocksource_mips, mips_hpt_frequency);
 
 	return 0;
 }
diff --git a/arch/mips/kernel/csrc-sb1250.c b/arch/mips/kernel/csrc-sb1250.c
index d14d3d1..e9606d9 100644
--- a/arch/mips/kernel/csrc-sb1250.c
+++ b/arch/mips/kernel/csrc-sb1250.c
@@ -65,6 +65,5 @@ void __init sb1250_clocksource_init(void)
 		     IOADDR(A_SCD_TIMER_REGISTER(SB1250_HPT_NUM,
 						 R_SCD_TIMER_CFG)));
 
-	clocksource_set_clock(cs, V_SCD_TIMER_FREQ);
-	clocksource_register(cs);
+	clocksource_register_hz(cs, V_SCD_TIMER_FREQ);
 }
diff --git a/arch/mips/kernel/i8253.c b/arch/mips/kernel/i8253.c
index 9479406..1a08239 100644
--- a/arch/mips/kernel/i8253.c
+++ b/arch/mips/kernel/i8253.c
@@ -195,8 +195,6 @@ static struct clocksource clocksource_pit = {
 	.rating = 110,
 	.read	= pit_read,
 	.mask	= CLOCKSOURCE_MASK(32),
-	.mult	= 0,
-	.shift	= 20,
 };
 
 static int __init init_pit_clocksource(void)
@@ -204,7 +202,6 @@ static int __init init_pit_clocksource(void)
 	if (num_possible_cpus() > 1) /* PIT does not scale! */
 		return 0;
 
-	clocksource_pit.mult = clocksource_hz2mult(CLOCK_TICK_RATE, 20);
-	return clocksource_register(&clocksource_pit);
+	return clocksource_register_hz(&clocksource_pit, CLOCK_TICK_RATE);
 }
 arch_initcall(init_pit_clocksource);
diff --git a/arch/mips/loongson/common/cs5536/cs5536_mfgpt.c b/arch/mips/loongson/common/cs5536/cs5536_mfgpt.c
index 8c807c9..0cb1b97 100644
--- a/arch/mips/loongson/common/cs5536/cs5536_mfgpt.c
+++ b/arch/mips/loongson/common/cs5536/cs5536_mfgpt.c
@@ -201,8 +201,6 @@ static struct clocksource clocksource_mfgpt = {
 	.rating = 120, /* Functional for real use, but not desired */
 	.read = mfgpt_read,
 	.mask = CLOCKSOURCE_MASK(32),
-	.mult = 0,
-	.shift = 22,
 };
 
 int __init init_mfgpt_clocksource(void)
@@ -210,8 +208,7 @@ int __init init_mfgpt_clocksource(void)
 	if (num_possible_cpus() > 1)	/* MFGPT does not scale! */
 		return 0;
 
-	clocksource_mfgpt.mult = clocksource_hz2mult(MFGPT_TICK_RATE, 22);
-	return clocksource_register(&clocksource_mfgpt);
+	return clocksource_register_hz(&clocksource_mfgpt, MFGPT_TICK_RATE);
 }
 
 arch_initcall(init_mfgpt_clocksource);
diff --git a/arch/mips/sgi-ip27/ip27-timer.c b/arch/mips/sgi-ip27/ip27-timer.c
index d6802d6..3cac883 100644
--- a/arch/mips/sgi-ip27/ip27-timer.c
+++ b/arch/mips/sgi-ip27/ip27-timer.c
@@ -177,8 +177,7 @@ static void __init hub_rt_clocksource_init(void)
 {
 	struct clocksource *cs = &hub_rt_clocksource;
 
-	clocksource_set_clock(cs, CYCLES_PER_SEC);
-	clocksource_register(cs);
+	clocksource_register_hz(cs, CYCLES_PER_SEC);
 }
 
 void __init plat_time_init(void)
-- 
1.6.0.4


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

* [PATCH 7/7] blackfin: convert to clocksource_register_hz
  2010-10-20 23:44           ` [PATCH 6/7] mips: convert to clocksource_register_hz/khz John Stultz
@ 2010-10-20 23:44             ` John Stultz
  0 siblings, 0 replies; 11+ messages in thread
From: John Stultz @ 2010-10-20 23:44 UTC (permalink / raw)
  To: LKML; +Cc: John Stultz, Mike Frysinger, Thomas Gleixner

This converts the blackfin clocksource to use clocksource_register_hz.

This is untested, so any assistance in testing would be appreciated!

Signed-off-by: John Stultz <johnstul@us.ibm.com>
CC: Mike Frysinger <vapier@gentoo.org>
CC: Thomas Gleixner <tglx@linutronix.de>
---
 arch/blackfin/kernel/time-ts.c |   35 ++---------------------------------
 1 files changed, 2 insertions(+), 33 deletions(-)

diff --git a/arch/blackfin/kernel/time-ts.c b/arch/blackfin/kernel/time-ts.c
index 8c9a43d..4a01371 100644
--- a/arch/blackfin/kernel/time-ts.c
+++ b/arch/blackfin/kernel/time-ts.c
@@ -23,29 +23,6 @@
 #include <asm/gptimers.h>
 #include <asm/nmi.h>
 
-/* Accelerators for sched_clock()
- * convert from cycles(64bits) => nanoseconds (64bits)
- *  basic equation:
- *		ns = cycles / (freq / ns_per_sec)
- *		ns = cycles * (ns_per_sec / freq)
- *		ns = cycles * (10^9 / (cpu_khz * 10^3))
- *		ns = cycles * (10^6 / cpu_khz)
- *
- *	Then we use scaling math (suggested by george@mvista.com) to get:
- *		ns = cycles * (10^6 * SC / cpu_khz) / SC
- *		ns = cycles * cyc2ns_scale / SC
- *
- *	And since SC is a constant power of two, we can convert the div
- *  into a shift.
- *
- *  We can use khz divisor instead of mhz to keep a better precision, since
- *  cyc2ns_scale is limited to 10^6 * 2^10, which fits in 32 bits.
- *  (mathieu.desnoyers@polymtl.ca)
- *
- *			-johnstul@us.ibm.com "math is hard, lets go shopping!"
- */
-
-#define CYC2NS_SCALE_FACTOR 10 /* 2^10, carefully chosen */
 
 #if defined(CONFIG_CYCLES_CLOCKSOURCE)
 
@@ -63,7 +40,6 @@ static struct clocksource bfin_cs_cycles = {
 	.rating		= 400,
 	.read		= bfin_read_cycles,
 	.mask		= CLOCKSOURCE_MASK(64),
-	.shift		= CYC2NS_SCALE_FACTOR,
 	.flags		= CLOCK_SOURCE_IS_CONTINUOUS,
 };
 
@@ -75,10 +51,7 @@ static inline unsigned long long bfin_cs_cycles_sched_clock(void)
 
 static int __init bfin_cs_cycles_init(void)
 {
-	bfin_cs_cycles.mult = \
-		clocksource_hz2mult(get_cclk(), bfin_cs_cycles.shift);
-
-	if (clocksource_register(&bfin_cs_cycles))
+	if (clocksource_register_hz(&bfin_cs_cycles, get_cclk()))
 		panic("failed to register clocksource");
 
 	return 0;
@@ -111,7 +84,6 @@ static struct clocksource bfin_cs_gptimer0 = {
 	.rating		= 350,
 	.read		= bfin_read_gptimer0,
 	.mask		= CLOCKSOURCE_MASK(32),
-	.shift		= CYC2NS_SCALE_FACTOR,
 	.flags		= CLOCK_SOURCE_IS_CONTINUOUS,
 };
 
@@ -125,10 +97,7 @@ static int __init bfin_cs_gptimer0_init(void)
 {
 	setup_gptimer0();
 
-	bfin_cs_gptimer0.mult = \
-		clocksource_hz2mult(get_sclk(), bfin_cs_gptimer0.shift);
-
-	if (clocksource_register(&bfin_cs_gptimer0))
+	if (clocksource_register_hz(&bfin_cs_gptimer0, get_sclk()))
 		panic("failed to register clocksource");
 
 	return 0;
-- 
1.6.0.4


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

* Re: [PATCH 4/7] sparc: convert to clocksource_register_hz/khz
  2010-10-20 23:44       ` [PATCH 4/7] sparc: " John Stultz
  2010-10-20 23:44         ` [PATCH 5/7] avr32: Convert to clocksource_register_hz John Stultz
@ 2010-10-21  8:33         ` David Miller
  1 sibling, 0 replies; 11+ messages in thread
From: David Miller @ 2010-10-21  8:33 UTC (permalink / raw)
  To: johnstul; +Cc: linux-kernel, tglx

From: John Stultz <johnstul@us.ibm.com>
Date: Wed, 20 Oct 2010 16:44:10 -0700

> This converts the sparc clocksources to use clocksource_register_hz/khz
> 
> This is untested, so any assistance in testing would be appreciated!
> 
> Signed-off-by: John Stultz <johnstul@us.ibm.com>

Acked-by: David S. Miller <davem@davemloft.net>

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

* Re: [PATCH 1/7] x86: Convert remaining clocksources to clocksource_register_hz/khz
  2010-10-20 23:44 ` [PATCH 1/7] x86: Convert remaining clocksources to clocksource_register_hz/khz John Stultz
  2010-10-20 23:44   ` [PATCH 2/7] sh: convert to clocksource_register_hz John Stultz
@ 2010-10-21 19:16   ` Alok Kataria
  2010-10-21 19:39     ` john stultz
  1 sibling, 1 reply; 11+ messages in thread
From: Alok Kataria @ 2010-10-21 19:16 UTC (permalink / raw)
  To: John Stultz
  Cc: LKML, jacob.jun.pan, Glauber Costa, Dimitri Sivanich,
	Rusty Russell, Jeremy Fitzhardinge, Chris McDermott,
	Thomas Gleixner

Hi John,

vmiclock_32.c doesn't exist anymore in tip and pretty soon should
disappear from mainline too. 

Alok

On Wed, 2010-10-20 at 16:44 -0700, John Stultz wrote:
> This converts the remaining x86 clocksources to use
> clocksource_register_hz/khz. I was not able to test them, so
> any extra assistance to make sure time functions properly with
> the clocksources changeed here would be appreciated!
> 
> CC: jacob.jun.pan@intel.com
> CC: Glauber Costa <glommer@redhat.com>
> CC: Dimitri Sivanich <sivanich@sgi.com>
> CC: Alok N Kataria <akataria@vmware.com>
> CC: Rusty Russell <rusty@rustcorp.com.au>
> CC: Jeremy Fitzhardinge <jeremy@xensource.com>
> CC: Chris McDermott <lcm@us.ibm.com>
> CC: Thomas Gleixner <tglx@linutronix.de>
> Signed-off-by: John Stultz <johnstul@us.ibm.com>
> ---
>  arch/x86/kernel/apb_timer.c   |   10 +---------
>  arch/x86/kernel/i8253.c       |    6 +-----
>  arch/x86/kernel/kvmclock.c    |    6 +-----
>  arch/x86/kernel/uv_time.c     |    6 +-----
>  arch/x86/kernel/vmiclock_32.c |    9 +--------
>  arch/x86/lguest/boot.c        |    4 +---
>  arch/x86/xen/time.c           |    6 +-----
>  drivers/clocksource/cyclone.c |   10 ++--------
>  8 files changed, 9 insertions(+), 48 deletions(-)
> 
> diff --git a/arch/x86/kernel/apb_timer.c b/arch/x86/kernel/apb_timer.c
> index 8dd7780..c5ad23c 100644
> --- a/arch/x86/kernel/apb_timer.c
> +++ b/arch/x86/kernel/apb_timer.c
> @@ -177,7 +177,6 @@ static struct clocksource clocksource_apbt = {
>  	.rating		= APBT_CLOCKSOURCE_RATING,
>  	.read		= apbt_read_clocksource,
>  	.mask		= APBT_MASK,
> -	.shift		= APBT_SHIFT,
>  	.flags		= CLOCK_SOURCE_IS_CONTINUOUS,
>  	.resume		= apbt_restart_clocksource,
>  };
> @@ -598,14 +597,7 @@ static int apbt_clocksource_register(void)
>  	if (t1 == apbt_read_clocksource(&clocksource_apbt))
>  		panic("APBT counter not counting. APBT disabled\n");
>  
> -	/*
> -	 * initialize and register APBT clocksource
> -	 * convert that to ns/clock cycle
> -	 * mult = (ns/c) * 2^APBT_SHIFT
> -	 */
> -	clocksource_apbt.mult = div_sc(MSEC_PER_SEC,
> -				       (unsigned long) apbt_freq, APBT_SHIFT);
> -	clocksource_register(&clocksource_apbt);
> +	clocksource_register_khz(&clocksource_apbt,(u32)apbt_freq*1000);
>  
>  	return 0;
>  }
> diff --git a/arch/x86/kernel/i8253.c b/arch/x86/kernel/i8253.c
> index 2dfd315..212fe65 100644
> --- a/arch/x86/kernel/i8253.c
> +++ b/arch/x86/kernel/i8253.c
> @@ -188,8 +188,6 @@ static struct clocksource pit_cs = {
>  	.rating		= 110,
>  	.read		= pit_read,
>  	.mask		= CLOCKSOURCE_MASK(32),
> -	.mult		= 0,
> -	.shift		= 20,
>  };
>  
>  static int __init init_pit_clocksource(void)
> @@ -205,9 +203,7 @@ static int __init init_pit_clocksource(void)
>  	    pit_ce.mode != CLOCK_EVT_MODE_PERIODIC)
>  		return 0;
>  
> -	pit_cs.mult = clocksource_hz2mult(CLOCK_TICK_RATE, pit_cs.shift);
> -
> -	return clocksource_register(&pit_cs);
> +	return clocksource_register_hz(&pit_cs, CLOCK_TICK_RATE);
>  }
>  arch_initcall(init_pit_clocksource);
>  
> diff --git a/arch/x86/kernel/kvmclock.c b/arch/x86/kernel/kvmclock.c
> index eb9b76c..532fa9b 100644
> --- a/arch/x86/kernel/kvmclock.c
> +++ b/arch/x86/kernel/kvmclock.c
> @@ -26,8 +26,6 @@
>  #include <asm/x86_init.h>
>  #include <asm/reboot.h>
>  
> -#define KVM_SCALE 22
> -
>  static int kvmclock = 1;
>  static int msr_kvm_system_time = MSR_KVM_SYSTEM_TIME;
>  static int msr_kvm_wall_clock = MSR_KVM_WALL_CLOCK;
> @@ -120,8 +118,6 @@ static struct clocksource kvm_clock = {
>  	.read = kvm_clock_get_cycles,
>  	.rating = 400,
>  	.mask = CLOCKSOURCE_MASK(64),
> -	.mult = 1 << KVM_SCALE,
> -	.shift = KVM_SCALE,
>  	.flags = CLOCK_SOURCE_IS_CONTINUOUS,
>  };
>  
> @@ -212,7 +208,7 @@ void __init kvmclock_init(void)
>  	machine_ops.crash_shutdown  = kvm_crash_shutdown;
>  #endif
>  	kvm_get_preset_lpj();
> -	clocksource_register(&kvm_clock);
> +	clocksource_register_hz(&kvm_clock, NSEC_PER_SEC);
>  	pv_info.paravirt_enabled = 1;
>  	pv_info.name = "KVM";
>  
> diff --git a/arch/x86/kernel/uv_time.c b/arch/x86/kernel/uv_time.c
> index 56e421b..6f86d74 100644
> --- a/arch/x86/kernel/uv_time.c
> +++ b/arch/x86/kernel/uv_time.c
> @@ -40,7 +40,6 @@ static struct clocksource clocksource_uv = {
>  	.rating		= 400,
>  	.read		= uv_read_rtc,
>  	.mask		= (cycle_t)UVH_RTC_REAL_TIME_CLOCK_MASK,
> -	.shift		= 10,
>  	.flags		= CLOCK_SOURCE_IS_CONTINUOUS,
>  };
>  
> @@ -370,14 +369,11 @@ static __init int uv_rtc_setup_clock(void)
>  	if (!is_uv_system())
>  		return -ENODEV;
>  
> -	clocksource_uv.mult = clocksource_hz2mult(sn_rtc_cycles_per_second,
> -				clocksource_uv.shift);
> -
>  	/* If single blade, prefer tsc */
>  	if (uv_num_possible_blades() == 1)
>  		clocksource_uv.rating = 250;
>  
> -	rc = clocksource_register(&clocksource_uv);
> +	rc = clocksource_register_hz(&clocksource_uv, sn_rtc_cycles_per_second);
>  	if (rc)
>  		printk(KERN_INFO "UV RTC clocksource failed rc %d\n", rc);
>  	else
> diff --git a/arch/x86/kernel/vmiclock_32.c b/arch/x86/kernel/vmiclock_32.c
> index 5e1ff66..e3401ec 100644
> --- a/arch/x86/kernel/vmiclock_32.c
> +++ b/arch/x86/kernel/vmiclock_32.c
> @@ -290,8 +290,6 @@ static struct clocksource clocksource_vmi = {
>  	.rating			= 450,
>  	.read			= read_real_cycles,
>  	.mask			= CLOCKSOURCE_MASK(64),
> -	.mult			= 0, /* to be set */
> -	.shift			= 22,
>  	.flags			= CLOCK_SOURCE_IS_CONTINUOUS,
>  };
>  
> @@ -305,13 +303,8 @@ static int __init init_vmi_clocksource(void)
>  	cycles_per_msec = vmi_timer_ops.get_cycle_frequency();
>  	(void)do_div(cycles_per_msec, 1000);
>  
> -	/* Note that clocksource.{mult, shift} converts in the opposite direction
> -	 * as clockevents.  */
> -	clocksource_vmi.mult = clocksource_khz2mult(cycles_per_msec,
> -						    clocksource_vmi.shift);
> -
>  	printk(KERN_WARNING "vmi: registering clock source khz=%lld\n", cycles_per_msec);
> -	return clocksource_register(&clocksource_vmi);
> +	return clocksource_register_khz(&clocksource_vmi, cycles_per_msec);
>  
>  }
>  module_init(init_vmi_clocksource);
> diff --git a/arch/x86/lguest/boot.c b/arch/x86/lguest/boot.c
> index 9d5f558..3f2fd65 100644
> --- a/arch/x86/lguest/boot.c
> +++ b/arch/x86/lguest/boot.c
> @@ -910,8 +910,6 @@ static struct clocksource lguest_clock = {
>  	.rating		= 200,
>  	.read		= lguest_clock_read,
>  	.mask		= CLOCKSOURCE_MASK(64),
> -	.mult		= 1 << 22,
> -	.shift		= 22,
>  	.flags		= CLOCK_SOURCE_IS_CONTINUOUS,
>  };
>  
> @@ -994,7 +992,7 @@ static void lguest_time_init(void)
>  	/* Set up the timer interrupt (0) to go to our simple timer routine */
>  	set_irq_handler(0, lguest_time_irq);
>  
> -	clocksource_register(&lguest_clock);
> +	clocksource_register_hz(&lguest_clock, NSEC_PER_SEC);
>  
>  	/* We can't set cpumask in the initializer: damn C limitations!  Set it
>  	 * here and register our timer device. */
> diff --git a/arch/x86/xen/time.c b/arch/x86/xen/time.c
> index b2bb5aa..ce02ef8 100644
> --- a/arch/x86/xen/time.c
> +++ b/arch/x86/xen/time.c
> @@ -26,8 +26,6 @@
>  
>  #include "xen-ops.h"
>  
> -#define XEN_SHIFT 22
> -
>  /* Xen may fire a timer up to this many ns early */
>  #define TIMER_SLOP	100000
>  #define NS_PER_TICK	(1000000000LL / HZ)
> @@ -211,8 +209,6 @@ static struct clocksource xen_clocksource __read_mostly = {
>  	.rating = 400,
>  	.read = xen_clocksource_get_cycles,
>  	.mask = ~0,
> -	.mult = 1<<XEN_SHIFT,		/* time directly in nanoseconds */
> -	.shift = XEN_SHIFT,
>  	.flags = CLOCK_SOURCE_IS_CONTINUOUS,
>  };
>  
> @@ -444,7 +440,7 @@ static __init void xen_time_init(void)
>  	int cpu = smp_processor_id();
>  	struct timespec tp;
>  
> -	clocksource_register(&xen_clocksource);
> +	clocksource_register_hz(&xen_clocksource, NSEC_PER_SEC);
>  
>  	if (HYPERVISOR_vcpu_op(VCPUOP_stop_periodic_timer, cpu, NULL) == 0) {
>  		/* Successfully turned off 100Hz tick, so we have the
> diff --git a/drivers/clocksource/cyclone.c b/drivers/clocksource/cyclone.c
> index 64e528e..72f811f 100644
> --- a/drivers/clocksource/cyclone.c
> +++ b/drivers/clocksource/cyclone.c
> @@ -29,8 +29,6 @@ static struct clocksource clocksource_cyclone = {
>  	.rating		= 250,
>  	.read		= read_cyclone,
>  	.mask		= CYCLONE_TIMER_MASK,
> -	.mult		= 10,
> -	.shift		= 0,
>  	.flags		= CLOCK_SOURCE_IS_CONTINUOUS,
>  };
>  
> @@ -108,12 +106,8 @@ static int __init init_cyclone_clocksource(void)
>  	}
>  	cyclone_ptr = cyclone_timer;
>  
> -	/* sort out mult/shift values: */
> -	clocksource_cyclone.shift = 22;
> -	clocksource_cyclone.mult = clocksource_hz2mult(CYCLONE_TIMER_FREQ,
> -						clocksource_cyclone.shift);
> -
> -	return clocksource_register(&clocksource_cyclone);
> +	return clocksource_register_hz(&clocksource_cyclone,
> +					CYCLONE_TIMER_FREQ);
>  }
>  
>  arch_initcall(init_cyclone_clocksource);


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

* Re: [PATCH 1/7] x86: Convert remaining clocksources to clocksource_register_hz/khz
  2010-10-21 19:16   ` [PATCH 1/7] x86: Convert remaining clocksources " Alok Kataria
@ 2010-10-21 19:39     ` john stultz
  0 siblings, 0 replies; 11+ messages in thread
From: john stultz @ 2010-10-21 19:39 UTC (permalink / raw)
  To: akataria
  Cc: LKML, jacob.jun.pan, Glauber Costa, Dimitri Sivanich,
	Rusty Russell, Jeremy Fitzhardinge, Chris McDermott,
	Thomas Gleixner

On Thu, 2010-10-21 at 12:16 -0700, Alok Kataria wrote:
> Hi John,
> 
> vmiclock_32.c doesn't exist anymore in tip and pretty soon should
> disappear from mainline too. 

Ah. Thanks for the heads up!

-john



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

end of thread, other threads:[~2010-10-21 19:39 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-20 23:44 [PATCH 0/7] clocksource_register_khz/hz cleanups(for 2.6.37?) John Stultz
2010-10-20 23:44 ` [PATCH 1/7] x86: Convert remaining clocksources to clocksource_register_hz/khz John Stultz
2010-10-20 23:44   ` [PATCH 2/7] sh: convert to clocksource_register_hz John Stultz
2010-10-20 23:44     ` [PATCH 3/7] ia64: convert to clocksource_register_hz/khz John Stultz
2010-10-20 23:44       ` [PATCH 4/7] sparc: " John Stultz
2010-10-20 23:44         ` [PATCH 5/7] avr32: Convert to clocksource_register_hz John Stultz
2010-10-20 23:44           ` [PATCH 6/7] mips: convert to clocksource_register_hz/khz John Stultz
2010-10-20 23:44             ` [PATCH 7/7] blackfin: convert to clocksource_register_hz John Stultz
2010-10-21  8:33         ` [PATCH 4/7] sparc: convert to clocksource_register_hz/khz David Miller
2010-10-21 19:16   ` [PATCH 1/7] x86: Convert remaining clocksources " Alok Kataria
2010-10-21 19:39     ` john stultz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome