Lines Matching +full:enable +full:- +full:frequency +full:- +full:shift

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>
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()
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()
373 while (mftb() - start < loops) in __delay()
392 return regs->link; in profile_pc()
402 * 64-bit uses a byte in the PACA, 32-bit uses a per-cpu variable...
429 #else /* 32-bit */
442 * 64-bit code that uses irq soft-mask can just cause an immediate in arch_irq_work_raise()
448 * level manipulations of irq soft-mask state (e.g., trace_hardirqs_on) in arch_irq_work_raise()
486 local_paca->irq_happened |= PACA_IRQ_DEC; in timer_rearm_host_dec()
488 now = *next_tb - now; in timer_rearm_host_dec()
498 * timer_interrupt - gets called when the decrementer overflows,
517 /* Conditionally hard-enable interrupts. */ in DEFINE_INTERRUPT_HANDLER_ASYNC()
552 evt->event_handler(evt); in DEFINE_INTERRUPT_HANDLER_ASYNC()
555 now = *next_tb - now; in DEFINE_INTERRUPT_HANDLER_ASYNC()
609 * Scheduler clock - returns current time in nanosec units.
613 * are 64-bit unsigned numbers.
617 return mulhdu(get_tb() - boot_tb, tb_to_ns_scale) << tb_to_ns_shift; in sched_clock()
624 * Running clock - attempts to give a view of time passing for a virtualised
640 return mulhdu(get_vtb() - boot_tb, tb_to_ns_scale) << tb_to_ns_shift; in running_clock()
648 return local_clock() - kcpustat_this_cpu->cpustat[CPUTIME_STEAL]; in running_clock()
658 /* The cpu node should have timebase and clock frequency properties */ in get_freq()
684 * The watchdog may have already been enabled by u-boot. So leave in start_cpu_decrementer()
688 tcr |= TCR_DIE; /* Enable decrementer */ in start_cpu_decrementer()
697 if (!get_freq("ibm,extended-timebase-frequency", 2, &ppc_tb_freq) && in generic_calibrate_decr()
698 !get_freq("timebase-frequency", 1, &ppc_tb_freq)) { in generic_calibrate_decr()
700 printk(KERN_ERR "WARNING: Estimating decrementer frequency " in generic_calibrate_decr()
706 if (!get_freq("ibm,extended-clock-frequency", 2, &ppc_proc_freq) && in generic_calibrate_decr()
707 !get_freq("clock-frequency", 1, &ppc_proc_freq)) { in generic_calibrate_decr()
709 printk(KERN_ERR "WARNING: Estimating processor frequency " in generic_calibrate_decr()
719 return -ENODEV; in update_persistent_clock64()
731 ts->tv_nsec = 0; in __read_persistent_clock()
740 ts->tv_sec = ppc_md.get_boot_time() - timezone_offset; in __read_persistent_clock()
745 ts->tv_sec = 0; in __read_persistent_clock()
750 ts->tv_sec = rtc_tm_to_time64(&tm); in __read_persistent_clock()
758 if (ts->tv_sec < 0) { in read_persistent_clock64()
759 ts->tv_sec = 0; in read_persistent_clock64()
760 ts->tv_nsec = 0; in read_persistent_clock64()
777 clock->name); in clocksource_init()
781 printk(KERN_INFO "clocksource: %s mult[%x] shift[%d] registered\n", in clocksource_init()
782 clock->name, clock->mult, clock->shift); in clocksource_init()
807 dec->cpumask = cpumask_of(cpu); in register_decrementer_clockevent()
811 printk_once(KERN_DEBUG "clockevent: %s mult[%x] shift[%d] cpu[%d]\n", in register_decrementer_clockevent()
812 dec->name, dec->mult, dec->shift, cpu); in register_decrementer_clockevent()
815 decrementer_clockevent.mult = dec->mult; in register_decrementer_clockevent()
816 decrementer_clockevent.shift = dec->shift; in register_decrementer_clockevent()
828 * If we're running as the hypervisor we need to enable the LD manually in enable_large_decrementer()
846 if (of_property_read_u32(cpu, "ibm,dec-bits", &bits) == 0) { in set_decrementer_max()
848 pr_warn("time_init: firmware supplied invalid ibm,dec-bits"); in set_decrementer_max()
853 decrementer_max = (1ul << (bits - 1)) - 1; in set_decrementer_max()
869 /* Enable and test the large decrementer for this cpu */ in secondary_cpu_time_init()
887 unsigned shift; in time_init() local
895 printk(KERN_DEBUG "time_init: decrementer frequency = %lu.%.6lu MHz\n", in time_init()
897 printk(KERN_DEBUG "time_init: processor frequency = %lu.%.6lu MHz\n", in time_init()
907 * which is the timebase frequency. in time_init()
909 * the 128-bit result as a 64.64 fixed-point number. in time_init()
910 * We then shift that number right until it is less than 1.0, in time_init()
911 * giving us the scale factor and shift count to use in in time_init()
916 for (shift = 0; res.result_high != 0; ++shift) { in time_init()
921 tb_to_ns_shift = shift; in time_init()
927 sys_tz.tz_minuteswest = -timezone_offset / 60; in time_init()
931 vdso_data->tb_ticks_per_sec = tb_ticks_per_sec; in time_init()
933 /* initialise and enable the large decrementer (if we have one) */ in time_init()
953 * Divide a 128-bit dividend by a 32-bit divisor, leaving a 128 bit
969 ra = ((u64)(a - (w * divisor)) << 32) + b; in div128_by_32()
980 dr->result_high = ((u64)w << 32) + x; in div128_by_32()
981 dr->result_low = ((u64)y << 32) + z; in div128_by_32()
1004 return -EOPNOTSUPP; in rtc_generic_set_time()
1007 return -EOPNOTSUPP; in rtc_generic_set_time()
1022 return -ENODEV; in rtc_init()
1024 pdev = platform_device_register_data(NULL, "rtc-generic", -1, in rtc_init()