void udelay(unsigned int usec) { struct stopwatch sw; /* * As the timer granularity is in microseconds pad the * requested delay by one to get at least >= requested usec delay. */ usec += 1; if (!thread_yield_microseconds(usec)) return; stopwatch_init_usecs_expire(&sw, usec); while (!stopwatch_expired(&sw)) ; }
void udelay(unsigned us) { unsigned long long start; unsigned long long current; unsigned long long clocks; if (!thread_yield_microseconds(us)) return; start = rdtscll(); clocks = us; clocks *= get_clocks_per_usec(); current = rdtscll(); while((current - start) < clocks) { cpu_relax(); current = rdtscll(); } }
void udelay(u32 usecs) { u32 start, value, ticks, timer_fsb; if (!thread_yield_microseconds(usecs)) return; timer_fsb = get_timer_fsb(); if (!timer_fsb || (lapic_read(LAPIC_LVTT) & (LAPIC_LVT_TIMER_PERIODIC | LAPIC_LVT_MASKED)) != (LAPIC_LVT_TIMER_PERIODIC | LAPIC_LVT_MASKED)) { init_timer(); timer_fsb = get_timer_fsb(); } /* Calculate the number of ticks to run, our FSB runs at timer_fsb Mhz */ ticks = usecs * timer_fsb; start = lapic_read(LAPIC_TMCCT); do { value = lapic_read(LAPIC_TMCCT); } while((start - value) < ticks); }
/* delay x useconds */ void udelay(unsigned usec) { struct mono_time current, end; if (!thread_yield_microseconds(usec)) return; timer_monotonic_get(¤t); end = current; mono_time_add_usecs(&end, usec); if (mono_time_after(¤t, &end)) { printk(BIOS_EMERG, "udelay: 0x%08x is impossibly large\n", usec); /* There's not much we can do if usec is too big. Use a long, * paranoid delay value and hope for the best... */ end = current; mono_time_add_usecs(&end, USECS_PER_SEC); } while (mono_time_before(¤t, &end)) timer_monotonic_get(¤t); }