aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/alpha/Kconfig8
-rw-r--r--arch/alpha/kernel/time.c79
2 files changed, 15 insertions, 72 deletions
diff --git a/arch/alpha/Kconfig b/arch/alpha/Kconfig
index 9fb8aae5c391..443448154f32 100644
--- a/arch/alpha/Kconfig
+++ b/arch/alpha/Kconfig
@@ -45,6 +45,14 @@ config GENERIC_CALIBRATE_DELAY
45 bool 45 bool
46 default y 46 default y
47 47
48config GENERIC_TIME
49 bool
50 default y
51
52config ARCH_USES_GETTIMEOFFSET
53 bool
54 default y
55
48config ZONE_DMA 56config ZONE_DMA
49 bool 57 bool
50 default y 58 default y
diff --git a/arch/alpha/kernel/time.c b/arch/alpha/kernel/time.c
index b04e2cbf23a4..5d0826654c61 100644
--- a/arch/alpha/kernel/time.c
+++ b/arch/alpha/kernel/time.c
@@ -408,28 +408,17 @@ time_init(void)
408 * part. So we can't do the "find absolute time in terms of cycles" thing 408 * part. So we can't do the "find absolute time in terms of cycles" thing
409 * that the other ports do. 409 * that the other ports do.
410 */ 410 */
411void 411u32 arch_gettimeoffset(void)
412do_gettimeofday(struct timeval *tv)
413{ 412{
414 unsigned long flags;
415 unsigned long sec, usec, seq;
416 unsigned long delta_cycles, delta_usec, partial_tick;
417
418 do {
419 seq = read_seqbegin_irqsave(&xtime_lock, flags);
420
421 delta_cycles = rpcc() - state.last_time;
422 sec = xtime.tv_sec;
423 usec = (xtime.tv_nsec / 1000);
424 partial_tick = state.partial_tick;
425
426 } while (read_seqretry_irqrestore(&xtime_lock, seq, flags));
427
428#ifdef CONFIG_SMP 413#ifdef CONFIG_SMP
429 /* Until and unless we figure out how to get cpu cycle counters 414 /* Until and unless we figure out how to get cpu cycle counters
430 in sync and keep them there, we can't use the rpcc tricks. */ 415 in sync and keep them there, we can't use the rpcc tricks. */
431 delta_usec = 0; 416 return 0;
432#else 417#else
418 unsigned long delta_cycles, delta_usec, partial_tick;
419
420 delta_cycles = rpcc() - state.last_time;
421 partial_tick = state.partial_tick;
433 /* 422 /*
434 * usec = cycles * ticks_per_cycle * 2**48 * 1e6 / (2**48 * ticks) 423 * usec = cycles * ticks_per_cycle * 2**48 * 1e6 / (2**48 * ticks)
435 * = cycles * (s_t_p_c) * 1e6 / (2**48 * ticks) 424 * = cycles * (s_t_p_c) * 1e6 / (2**48 * ticks)
@@ -446,64 +435,10 @@ do_gettimeofday(struct timeval *tv)
446 delta_usec = (delta_cycles * state.scaled_ticks_per_cycle 435 delta_usec = (delta_cycles * state.scaled_ticks_per_cycle
447 + partial_tick) * 15625; 436 + partial_tick) * 15625;
448 delta_usec = ((delta_usec / ((1UL << (FIX_SHIFT-6-1)) * HZ)) + 1) / 2; 437 delta_usec = ((delta_usec / ((1UL << (FIX_SHIFT-6-1)) * HZ)) + 1) / 2;
438 return delta_usec * 1000;
449#endif 439#endif
450
451 usec += delta_usec;
452 if (usec >= 1000000) {
453 sec += 1;
454 usec -= 1000000;
455 }
456
457 tv->tv_sec = sec;
458 tv->tv_usec = usec;
459} 440}
460 441
461EXPORT_SYMBOL(do_gettimeofday);
462
463int
464do_settimeofday(struct timespec *tv)
465{
466 time_t wtm_sec, sec = tv->tv_sec;
467 long wtm_nsec, nsec = tv->tv_nsec;
468 unsigned long delta_nsec;
469
470 if ((unsigned long)tv->tv_nsec >= NSEC_PER_SEC)
471 return -EINVAL;
472
473 write_seqlock_irq(&xtime_lock);
474
475 /* The offset that is added into time in do_gettimeofday above
476 must be subtracted out here to keep a coherent view of the
477 time. Without this, a full-tick error is possible. */
478
479#ifdef CONFIG_SMP
480 delta_nsec = 0;
481#else
482 delta_nsec = rpcc() - state.last_time;
483 delta_nsec = (delta_nsec * state.scaled_ticks_per_cycle
484 + state.partial_tick) * 15625;
485 delta_nsec = ((delta_nsec / ((1UL << (FIX_SHIFT-6-1)) * HZ)) + 1) / 2;
486 delta_nsec *= 1000;
487#endif
488
489 nsec -= delta_nsec;
490
491 wtm_sec = wall_to_monotonic.tv_sec + (xtime.tv_sec - sec);
492 wtm_nsec = wall_to_monotonic.tv_nsec + (xtime.tv_nsec - nsec);
493
494 set_normalized_timespec(&xtime, sec, nsec);
495 set_normalized_timespec(&wall_to_monotonic, wtm_sec, wtm_nsec);
496
497 ntp_clear();
498
499 write_sequnlock_irq(&xtime_lock);
500 clock_was_set();
501 return 0;
502}
503
504EXPORT_SYMBOL(do_settimeofday);
505
506
507/* 442/*
508 * In order to set the CMOS clock precisely, set_rtc_mmss has to be 443 * In order to set the CMOS clock precisely, set_rtc_mmss has to be
509 * called 500 ms after the second nowtime has started, because when 444 * called 500 ms after the second nowtime has started, because when