Lines Matching +full:timebase +full:- +full:frequency
1 // SPDX-License-Identifier: GPL-2.0-or-later
8 * Converted for 64-bit by Mike Corrigan ([email protected])
11 * to make clock more stable (2.4.0-test5). The only thing
20 * - improve precision and reproducibility of timebase frequency
22 * - for astronomical applications: add a new function to get
26 * 1997-09-10 Updated NTP code according to technical memorandum Jan '96
50 #include <linux/posix-timers.h>
82 .name = "timebase",
155 * or if that doesn't exist return the timebase value passed in.
179 deltascaled = nowscaled - acct->startspurr; in vtime_delta_scaled()
180 acct->startspurr = nowscaled; in vtime_delta_scaled()
181 utime = acct->utime - acct->utime_sspurr; in vtime_delta_scaled()
182 acct->utime_sspurr = acct->utime; in vtime_delta_scaled()
189 * and user time (udelta) values obtained from the timebase in vtime_delta_scaled()
191 * the user ticks get saved up in paca->user_time_scaled to be in vtime_delta_scaled()
199 utime_scaled = deltascaled - stime_scaled; in vtime_delta_scaled()
204 acct->utime_scaled += utime_scaled; in vtime_delta_scaled()
219 stime = now - acct->starttime; in vtime_delta()
220 acct->starttime = now; in vtime_delta()
239 *stime -= min(*stime, steal_time); in vtime_delta_kernel()
240 acct->steal_time += steal_time; in vtime_delta_kernel()
250 if (tsk->flags & PF_VCPU) { in vtime_account_kernel()
251 acct->gtime += stime; in vtime_account_kernel()
253 acct->utime_scaled += stime_scaled; in vtime_account_kernel()
256 acct->stime += stime; in vtime_account_kernel()
258 acct->stime_scaled += stime_scaled; in vtime_account_kernel()
270 acct->idle_time += stime + steal_time; in vtime_account_idle()
281 acct->stime_scaled += stime_scaled; in vtime_account_irq_field()
288 vtime_account_irq_field(acct, &acct->softirq_time); in vtime_account_softirq()
294 vtime_account_irq_field(acct, &acct->hardirq_time); in vtime_account_hardirq()
301 if (acct->utime_scaled) in vtime_flush_scaled()
302 tsk->utimescaled += cputime_to_nsecs(acct->utime_scaled); in vtime_flush_scaled()
303 if (acct->stime_scaled) in vtime_flush_scaled()
304 tsk->stimescaled += cputime_to_nsecs(acct->stime_scaled); in vtime_flush_scaled()
306 acct->utime_scaled = 0; in vtime_flush_scaled()
307 acct->utime_sspurr = 0; in vtime_flush_scaled()
308 acct->stime_scaled = 0; in vtime_flush_scaled()
317 * get_paca()->user_time_scaled is up to date.
323 if (acct->utime) in vtime_flush()
324 account_user_time(tsk, cputime_to_nsecs(acct->utime)); in vtime_flush()
326 if (acct->gtime) in vtime_flush()
327 account_guest_time(tsk, cputime_to_nsecs(acct->gtime)); in vtime_flush()
329 if (IS_ENABLED(CONFIG_PPC_SPLPAR) && acct->steal_time) { in vtime_flush()
330 account_steal_time(cputime_to_nsecs(acct->steal_time)); in vtime_flush()
331 acct->steal_time = 0; in vtime_flush()
334 if (acct->idle_time) in vtime_flush()
335 account_idle_time(cputime_to_nsecs(acct->idle_time)); in vtime_flush()
337 if (acct->stime) in vtime_flush()
338 account_system_index_time(tsk, cputime_to_nsecs(acct->stime), in vtime_flush()
341 if (acct->hardirq_time) in vtime_flush()
342 account_system_index_time(tsk, cputime_to_nsecs(acct->hardirq_time), in vtime_flush()
344 if (acct->softirq_time) in vtime_flush()
345 account_system_index_time(tsk, cputime_to_nsecs(acct->softirq_time), in vtime_flush()
350 acct->utime = 0; in vtime_flush()
351 acct->gtime = 0; in vtime_flush()
352 acct->idle_time = 0; in vtime_flush()
353 acct->stime = 0; in vtime_flush()
354 acct->hardirq_time = 0; in vtime_flush()
355 acct->softirq_time = 0; in vtime_flush()
376 acct->starttime = acct0->starttime; in vtime_task_switch()
395 while (mftb() - start < loops) in __delay()
414 return regs->link; in profile_pc()
424 * 64-bit uses a byte in the PACA, 32-bit uses a per-cpu variable...
451 #else /* 32-bit */
464 * 64-bit code that uses irq soft-mask can just cause an immediate in arch_irq_work_raise()
470 * level manipulations of irq soft-mask state (e.g., trace_hardirqs_on) in arch_irq_work_raise()
508 local_paca->irq_happened |= PACA_IRQ_DEC; in timer_rearm_host_dec()
510 now = *next_tb - now; in timer_rearm_host_dec()
520 * timer_interrupt - gets called when the decrementer overflows,
539 /* Conditionally hard-enable interrupts. */ in DEFINE_INTERRUPT_HANDLER_ASYNC()
574 evt->event_handler(evt); in DEFINE_INTERRUPT_HANDLER_ASYNC()
577 now = *next_tb - now; in DEFINE_INTERRUPT_HANDLER_ASYNC()
631 * Scheduler clock - returns current time in nanosec units.
635 * are 64-bit unsigned numbers.
639 return mulhdu(get_tb() - boot_tb, tb_to_ns_scale) << tb_to_ns_shift; in sched_clock()
646 * Running clock - attempts to give a view of time passing for a virtualised
654 * timebase into the VTB when it takes a guest off the CPU, reading the in running_clock()
662 return mulhdu(get_vtb() - boot_tb, tb_to_ns_scale) << tb_to_ns_shift; in running_clock()
670 return local_clock() - kcpustat_this_cpu->cpustat[CPUTIME_STEAL]; in running_clock()
680 /* The cpu node should have timebase and clock frequency properties */ in get_freq()
706 * The watchdog may have already been enabled by u-boot. So leave in start_cpu_decrementer()
719 if (!get_freq("ibm,extended-timebase-frequency", 2, &ppc_tb_freq) && in generic_calibrate_decr()
720 !get_freq("timebase-frequency", 1, &ppc_tb_freq)) { in generic_calibrate_decr()
722 printk(KERN_ERR "WARNING: Estimating decrementer frequency " in generic_calibrate_decr()
728 if (!get_freq("ibm,extended-clock-frequency", 2, &ppc_proc_freq) && in generic_calibrate_decr()
729 !get_freq("clock-frequency", 1, &ppc_proc_freq)) { in generic_calibrate_decr()
731 printk(KERN_ERR "WARNING: Estimating processor frequency " in generic_calibrate_decr()
741 return -ENODEV; in update_persistent_clock64()
753 ts->tv_nsec = 0; in __read_persistent_clock()
762 ts->tv_sec = ppc_md.get_boot_time() - timezone_offset; in __read_persistent_clock()
767 ts->tv_sec = 0; in __read_persistent_clock()
772 ts->tv_sec = rtc_tm_to_time64(&tm); in __read_persistent_clock()
780 if (ts->tv_sec < 0) { in read_persistent_clock64()
781 ts->tv_sec = 0; in read_persistent_clock64()
782 ts->tv_nsec = 0; in read_persistent_clock64()
799 clock->name); in clocksource_init()
804 clock->name, clock->mult, clock->shift); in clocksource_init()
829 dec->cpumask = cpumask_of(cpu); in register_decrementer_clockevent()
834 dec->name, dec->mult, dec->shift, cpu); in register_decrementer_clockevent()
837 decrementer_clockevent.mult = dec->mult; in register_decrementer_clockevent()
838 decrementer_clockevent.shift = dec->shift; in register_decrementer_clockevent()
868 if (of_property_read_u32(cpu, "ibm,dec-bits", &bits) == 0) { in set_decrementer_max()
870 pr_warn("time_init: firmware supplied invalid ibm,dec-bits"); in set_decrementer_max()
875 decrementer_max = (1ul << (bits - 1)) - 1; in set_decrementer_max()
911 /* Normal PowerPC with timebase register */ in time_init()
917 printk(KERN_DEBUG "time_init: decrementer frequency = %lu.%.6lu MHz\n", in time_init()
919 printk(KERN_DEBUG "time_init: processor frequency = %lu.%.6lu MHz\n", in time_init()
929 * which is the timebase frequency. in time_init()
931 * the 128-bit result as a 64.64 fixed-point number. in time_init()
944 /* Save the current timebase to pretty up CONFIG_PRINTK_TIME */ in time_init()
949 sys_tz.tz_minuteswest = -timezone_offset / 60; in time_init()
953 vdso_data->tb_ticks_per_sec = tb_ticks_per_sec; in time_init()
955 systemcfg->tb_ticks_per_sec = tb_ticks_per_sec; in time_init()
978 * Divide a 128-bit dividend by a 32-bit divisor, leaving a 128 bit
994 ra = ((u64)(a - (w * divisor)) << 32) + b; in div128_by_32()
1005 dr->result_high = ((u64)w << 32) + x; in div128_by_32()
1006 dr->result_low = ((u64)y << 32) + z; in div128_by_32()
1010 /* We don't need to calibrate delay, we use the CPU timebase for that */
1029 return -EOPNOTSUPP; in rtc_generic_set_time()
1032 return -EOPNOTSUPP; in rtc_generic_set_time()
1047 return -ENODEV; in rtc_init()
1049 pdev = platform_device_register_data(NULL, "rtc-generic", -1, in rtc_init()