Lines Matching +full:timebase +full:- +full:frequency
1 // SPDX-License-Identifier: GPL-2.0-or-later
8 * Converted for 64-bit by Mike Corrigan (mikejc@us.ibm.com)
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",
154 * Factor for converting from cputime_t (timebase ticks) to
155 * microseconds. This is stored as 0.64 fixed-point binary fraction.
170 * or if that doesn't exist return the timebase value passed in.
194 deltascaled = nowscaled - acct->startspurr; in vtime_delta_scaled()
195 acct->startspurr = nowscaled; in vtime_delta_scaled()
196 utime = acct->utime - acct->utime_sspurr; in vtime_delta_scaled()
197 acct->utime_sspurr = acct->utime; in vtime_delta_scaled()
204 * and user time (udelta) values obtained from the timebase in vtime_delta_scaled()
206 * the user ticks get saved up in paca->user_time_scaled to be in vtime_delta_scaled()
214 utime_scaled = deltascaled - stime_scaled; in vtime_delta_scaled()
219 acct->utime_scaled += utime_scaled; in vtime_delta_scaled()
234 stime = now - acct->starttime; in vtime_delta()
235 acct->starttime = now; in vtime_delta()
254 *stime -= min(*stime, steal_time); in vtime_delta_kernel()
255 acct->steal_time += steal_time; in vtime_delta_kernel()
265 if (tsk->flags & PF_VCPU) { in vtime_account_kernel()
266 acct->gtime += stime; in vtime_account_kernel()
268 acct->utime_scaled += stime_scaled; in vtime_account_kernel()
271 acct->stime += stime; in vtime_account_kernel()
273 acct->stime_scaled += stime_scaled; in vtime_account_kernel()
285 acct->idle_time += stime + steal_time; in vtime_account_idle()
296 acct->stime_scaled += stime_scaled; in vtime_account_irq_field()
303 vtime_account_irq_field(acct, &acct->softirq_time); in vtime_account_softirq()
309 vtime_account_irq_field(acct, &acct->hardirq_time); in vtime_account_hardirq()
316 if (acct->utime_scaled) in vtime_flush_scaled()
317 tsk->utimescaled += cputime_to_nsecs(acct->utime_scaled); in vtime_flush_scaled()
318 if (acct->stime_scaled) in vtime_flush_scaled()
319 tsk->stimescaled += cputime_to_nsecs(acct->stime_scaled); in vtime_flush_scaled()
321 acct->utime_scaled = 0; in vtime_flush_scaled()
322 acct->utime_sspurr = 0; in vtime_flush_scaled()
323 acct->stime_scaled = 0; in vtime_flush_scaled()
332 * get_paca()->user_time_scaled is up to date.
338 if (acct->utime) in vtime_flush()
339 account_user_time(tsk, cputime_to_nsecs(acct->utime)); in vtime_flush()
341 if (acct->gtime) in vtime_flush()
342 account_guest_time(tsk, cputime_to_nsecs(acct->gtime)); in vtime_flush()
344 if (IS_ENABLED(CONFIG_PPC_SPLPAR) && acct->steal_time) { in vtime_flush()
345 account_steal_time(cputime_to_nsecs(acct->steal_time)); in vtime_flush()
346 acct->steal_time = 0; in vtime_flush()
349 if (acct->idle_time) in vtime_flush()
350 account_idle_time(cputime_to_nsecs(acct->idle_time)); in vtime_flush()
352 if (acct->stime) in vtime_flush()
353 account_system_index_time(tsk, cputime_to_nsecs(acct->stime), in vtime_flush()
356 if (acct->hardirq_time) in vtime_flush()
357 account_system_index_time(tsk, cputime_to_nsecs(acct->hardirq_time), in vtime_flush()
359 if (acct->softirq_time) in vtime_flush()
360 account_system_index_time(tsk, cputime_to_nsecs(acct->softirq_time), in vtime_flush()
365 acct->utime = 0; in vtime_flush()
366 acct->gtime = 0; in vtime_flush()
367 acct->idle_time = 0; in vtime_flush()
368 acct->stime = 0; in vtime_flush()
369 acct->hardirq_time = 0; in vtime_flush()
370 acct->softirq_time = 0; in vtime_flush()
391 while (mftb() - start < loops) in __delay()
410 return regs->link; in profile_pc()
420 * 64-bit uses a byte in the PACA, 32-bit uses a per-cpu variable...
447 #else /* 32-bit */
460 * 64-bit code that uses irq soft-mask can just cause an immediate in arch_irq_work_raise()
466 * level manipulations of irq soft-mask state (e.g., trace_hardirqs_on) in arch_irq_work_raise()
504 local_paca->irq_happened |= PACA_IRQ_DEC; in timer_rearm_host_dec()
506 now = *next_tb - now; in timer_rearm_host_dec()
516 * timer_interrupt - gets called when the decrementer overflows,
535 /* Conditionally hard-enable interrupts. */ in DEFINE_INTERRUPT_HANDLER_ASYNC()
570 evt->event_handler(evt); in DEFINE_INTERRUPT_HANDLER_ASYNC()
573 now = *next_tb - now; in DEFINE_INTERRUPT_HANDLER_ASYNC()
627 * Scheduler clock - returns current time in nanosec units.
631 * are 64-bit unsigned numbers.
635 return mulhdu(get_tb() - boot_tb, tb_to_ns_scale) << tb_to_ns_shift; in sched_clock()
642 * Running clock - attempts to give a view of time passing for a virtualised
650 * timebase into the VTB when it takes a guest off the CPU, reading the in running_clock()
658 return mulhdu(get_vtb() - boot_tb, tb_to_ns_scale) << tb_to_ns_shift; in running_clock()
666 return local_clock() - kcpustat_this_cpu->cpustat[CPUTIME_STEAL]; in running_clock()
676 /* The cpu node should have timebase and clock frequency properties */ in get_freq()
702 * The watchdog may have already been enabled by u-boot. So leave in start_cpu_decrementer()
715 if (!get_freq("ibm,extended-timebase-frequency", 2, &ppc_tb_freq) && in generic_calibrate_decr()
716 !get_freq("timebase-frequency", 1, &ppc_tb_freq)) { in generic_calibrate_decr()
718 printk(KERN_ERR "WARNING: Estimating decrementer frequency " in generic_calibrate_decr()
724 if (!get_freq("ibm,extended-clock-frequency", 2, &ppc_proc_freq) && in generic_calibrate_decr()
725 !get_freq("clock-frequency", 1, &ppc_proc_freq)) { in generic_calibrate_decr()
727 printk(KERN_ERR "WARNING: Estimating processor frequency " in generic_calibrate_decr()
737 return -ENODEV; in update_persistent_clock64()
749 ts->tv_nsec = 0; in __read_persistent_clock()
758 ts->tv_sec = ppc_md.get_boot_time() - timezone_offset; in __read_persistent_clock()
763 ts->tv_sec = 0; in __read_persistent_clock()
768 ts->tv_sec = rtc_tm_to_time64(&tm); in __read_persistent_clock()
776 if (ts->tv_sec < 0) { in read_persistent_clock64()
777 ts->tv_sec = 0; in read_persistent_clock64()
778 ts->tv_nsec = 0; in read_persistent_clock64()
795 clock->name); in clocksource_init()
800 clock->name, clock->mult, clock->shift); in clocksource_init()
825 dec->cpumask = cpumask_of(cpu); in register_decrementer_clockevent()
830 dec->name, dec->mult, dec->shift, cpu); in register_decrementer_clockevent()
833 decrementer_clockevent.mult = dec->mult; in register_decrementer_clockevent()
834 decrementer_clockevent.shift = dec->shift; in register_decrementer_clockevent()
864 if (of_property_read_u32(cpu, "ibm,dec-bits", &bits) == 0) { in set_decrementer_max()
866 pr_warn("time_init: firmware supplied invalid ibm,dec-bits"); in set_decrementer_max()
871 decrementer_max = (1ul << (bits - 1)) - 1; in set_decrementer_max()
907 /* Normal PowerPC with timebase register */ in time_init()
909 printk(KERN_DEBUG "time_init: decrementer frequency = %lu.%.6lu MHz\n", in time_init()
911 printk(KERN_DEBUG "time_init: processor frequency = %lu.%.6lu MHz\n", in time_init()
922 * which is the timebase frequency. in time_init()
924 * the 128-bit result as a 64.64 fixed-point number. in time_init()
937 /* Save the current timebase to pretty up CONFIG_PRINTK_TIME */ in time_init()
942 sys_tz.tz_minuteswest = -timezone_offset / 60; in time_init()
946 vdso_data->tb_ticks_per_sec = tb_ticks_per_sec; in time_init()
968 * Divide a 128-bit dividend by a 32-bit divisor, leaving a 128 bit
984 ra = ((u64)(a - (w * divisor)) << 32) + b; in div128_by_32()
995 dr->result_high = ((u64)w << 32) + x; in div128_by_32()
996 dr->result_low = ((u64)y << 32) + z; in div128_by_32()
1000 /* We don't need to calibrate delay, we use the CPU timebase for that */
1019 return -EOPNOTSUPP; in rtc_generic_set_time()
1022 return -EOPNOTSUPP; in rtc_generic_set_time()
1037 return -ENODEV; in rtc_init()
1039 pdev = platform_device_register_data(NULL, "rtc-generic", -1, in rtc_init()