|
@@ -37,7 +37,7 @@
|
|
|
* requested HZ value. It is also not recommended
|
|
|
* for "tick-less" systems.
|
|
|
*/
|
|
|
-#define NSEC_PER_JIFFY ((u32)((((u64)NSEC_PER_SEC)<<8)/SHIFTED_HZ))
|
|
|
+#define NSEC_PER_JIFFY ((NSEC_PER_SEC+HZ/2)/HZ)
|
|
|
|
|
|
/* Since jiffies uses a simple NSEC_PER_JIFFY multiplier
|
|
|
* conversion, the .shift value could be zero. However
|
|
@@ -95,3 +95,33 @@ struct clocksource * __init __weak clocksource_default_clock(void)
|
|
|
{
|
|
|
return &clocksource_jiffies;
|
|
|
}
|
|
|
+
|
|
|
+struct clocksource refined_jiffies;
|
|
|
+
|
|
|
+int register_refined_jiffies(long cycles_per_second)
|
|
|
+{
|
|
|
+ u64 nsec_per_tick, shift_hz;
|
|
|
+ long cycles_per_tick;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ refined_jiffies = clocksource_jiffies;
|
|
|
+ refined_jiffies.name = "refined-jiffies";
|
|
|
+ refined_jiffies.rating++;
|
|
|
+
|
|
|
+ /* Calc cycles per tick */
|
|
|
+ cycles_per_tick = (cycles_per_second + HZ/2)/HZ;
|
|
|
+ /* shift_hz stores hz<<8 for extra accuracy */
|
|
|
+ shift_hz = (u64)cycles_per_second << 8;
|
|
|
+ shift_hz += cycles_per_tick/2;
|
|
|
+ do_div(shift_hz, cycles_per_tick);
|
|
|
+ /* Calculate nsec_per_tick using shift_hz */
|
|
|
+ nsec_per_tick = (u64)NSEC_PER_SEC << 8;
|
|
|
+ nsec_per_tick += (u32)shift_hz/2;
|
|
|
+ do_div(nsec_per_tick, (u32)shift_hz);
|
|
|
+
|
|
|
+ refined_jiffies.mult = ((u32)nsec_per_tick) << JIFFIES_SHIFT;
|
|
|
+
|
|
|
+ clocksource_register(&refined_jiffies);
|
|
|
+ return 0;
|
|
|
+}
|