~ubuntu-branches/ubuntu/quantal/linux-linaro-mx51/quantal

« back to all changes in this revision

Viewing changes to kernel/time/clocksource.c

  • Committer: Package Import Robot
  • Author(s): John Rigby, John Rigby
  • Date: 2011-09-26 10:44:23 UTC
  • Revision ID: package-import@ubuntu.com-20110926104423-3o58a3c1bj7x00rs
Tags: 3.0.0-1007.9
[ John Rigby ]

Enable crypto modules and remove crypto-modules from
exclude-module files
LP: #826021

Show diffs side-by-side

added added

removed removed

Lines of Context:
185
185
static struct timer_list watchdog_timer;
186
186
static DECLARE_WORK(watchdog_work, clocksource_watchdog_work);
187
187
static DEFINE_SPINLOCK(watchdog_lock);
188
 
static cycle_t watchdog_last;
189
188
static int watchdog_running;
190
189
 
191
190
static int clocksource_watchdog_kthread(void *data);
254
253
        if (!watchdog_running)
255
254
                goto out;
256
255
 
257
 
        wdnow = watchdog->read(watchdog);
258
 
        wd_nsec = clocksource_cyc2ns((wdnow - watchdog_last) & watchdog->mask,
259
 
                                     watchdog->mult, watchdog->shift);
260
 
        watchdog_last = wdnow;
261
 
 
262
256
        list_for_each_entry(cs, &watchdog_list, wd_list) {
263
257
 
264
258
                /* Clocksource already marked unstable? */
268
262
                        continue;
269
263
                }
270
264
 
 
265
                local_irq_disable();
271
266
                csnow = cs->read(cs);
 
267
                wdnow = watchdog->read(watchdog);
 
268
                local_irq_enable();
272
269
 
273
270
                /* Clocksource initialized ? */
274
271
                if (!(cs->flags & CLOCK_SOURCE_WATCHDOG)) {
275
272
                        cs->flags |= CLOCK_SOURCE_WATCHDOG;
276
 
                        cs->wd_last = csnow;
 
273
                        cs->wd_last = wdnow;
 
274
                        cs->cs_last = csnow;
277
275
                        continue;
278
276
                }
279
277
 
 
278
                wd_nsec = clocksource_cyc2ns((wdnow - cs->wd_last) & watchdog->mask,
 
279
                                             watchdog->mult, watchdog->shift);
 
280
 
 
281
                cs_nsec = clocksource_cyc2ns((csnow - cs->cs_last) &
 
282
                                             cs->mask, cs->mult, cs->shift);
 
283
                cs->cs_last = csnow;
 
284
                cs->wd_last = wdnow;
 
285
 
280
286
                /* Check the deviation from the watchdog clocksource. */
281
 
                cs_nsec = clocksource_cyc2ns((csnow - cs->wd_last) &
282
 
                                             cs->mask, cs->mult, cs->shift);
283
 
                cs->wd_last = csnow;
284
287
                if (abs(cs_nsec - wd_nsec) > WATCHDOG_THRESHOLD) {
285
288
                        clocksource_unstable(cs, cs_nsec - wd_nsec);
286
289
                        continue;
318
321
                return;
319
322
        init_timer(&watchdog_timer);
320
323
        watchdog_timer.function = clocksource_watchdog;
321
 
        watchdog_last = watchdog->read(watchdog);
322
324
        watchdog_timer.expires = jiffies + WATCHDOG_INTERVAL;
323
325
        add_timer_on(&watchdog_timer, cpumask_first(cpu_online_mask));
324
326
        watchdog_running = 1;
626
628
        list_add(&cs->list, entry);
627
629
}
628
630
 
629
 
 
630
 
/*
631
 
 * Maximum time we expect to go between ticks. This includes idle
632
 
 * tickless time. It provides the trade off between selecting a
633
 
 * mult/shift pair that is very precise but can only handle a short
634
 
 * period of time, vs. a mult/shift pair that can handle long periods
635
 
 * of time but isn't as precise.
636
 
 *
637
 
 * This is a subsystem constant, and actual hardware limitations
638
 
 * may override it (ie: clocksources that wrap every 3 seconds).
639
 
 */
640
 
#define MAX_UPDATE_LENGTH 5 /* Seconds */
641
 
 
642
631
/**
643
632
 * __clocksource_updatefreq_scale - Used update clocksource with new freq
644
633
 * @t:          clocksource to be registered
652
641
 */
653
642
void __clocksource_updatefreq_scale(struct clocksource *cs, u32 scale, u32 freq)
654
643
{
 
644
        u64 sec;
 
645
 
655
646
        /*
656
 
         * Ideally we want to use  some of the limits used in
657
 
         * clocksource_max_deferment, to provide a more informed
658
 
         * MAX_UPDATE_LENGTH. But for now this just gets the
659
 
         * register interface working properly.
 
647
         * Calc the maximum number of seconds which we can run before
 
648
         * wrapping around. For clocksources which have a mask > 32bit
 
649
         * we need to limit the max sleep time to have a good
 
650
         * conversion precision. 10 minutes is still a reasonable
 
651
         * amount. That results in a shift value of 24 for a
 
652
         * clocksource with mask >= 40bit and f >= 4GHz. That maps to
 
653
         * ~ 0.06ppm granularity for NTP. We apply the same 12.5%
 
654
         * margin as we do in clocksource_max_deferment()
660
655
         */
 
656
        sec = (cs->mask - (cs->mask >> 5));
 
657
        do_div(sec, freq);
 
658
        do_div(sec, scale);
 
659
        if (!sec)
 
660
                sec = 1;
 
661
        else if (sec > 600 && cs->mask > UINT_MAX)
 
662
                sec = 600;
 
663
 
661
664
        clocks_calc_mult_shift(&cs->mult, &cs->shift, freq,
662
 
                                      NSEC_PER_SEC/scale,
663
 
                                      MAX_UPDATE_LENGTH*scale);
 
665
                               NSEC_PER_SEC / scale, sec * scale);
664
666
        cs->max_idle_ns = clocksource_max_deferment(cs);
665
667
}
666
668
EXPORT_SYMBOL_GPL(__clocksource_updatefreq_scale);