Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 20443
b: refs/heads/master
c: defbb2c
h: refs/heads/master
i:
  20441: 9a2d9ea
  20439: e0b48bb
v: v3
  • Loading branch information
hawkes@sgi.com authored and Tony Luck committed Feb 15, 2006
1 parent a21514d commit c4ec055
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 23 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 4c2cd96696ae0896ce4bcf725b9f0eaffafeb640
refs/heads/master: defbb2c929cbe89dc92239b303cd33d3c85e9a83
39 changes: 17 additions & 22 deletions trunk/arch/ia64/kernel/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -250,32 +250,27 @@ time_init (void)
set_normalized_timespec(&wall_to_monotonic, -xtime.tv_sec, -xtime.tv_nsec);
}

#define SMALLUSECS 100

void
udelay (unsigned long usecs)
/*
* Generic udelay assumes that if preemption is allowed and the thread
* migrates to another CPU, that the ITC values are synchronized across
* all CPUs.
*/
static void
ia64_itc_udelay (unsigned long usecs)
{
unsigned long start;
unsigned long cycles;
unsigned long smallusecs;
unsigned long start = ia64_get_itc();
unsigned long end = start + usecs*local_cpu_data->cyc_per_usec;

/*
* Execute the non-preemptible delay loop (because the ITC might
* not be synchronized between CPUS) in relatively short time
* chunks, allowing preemption between the chunks.
*/
while (usecs > 0) {
smallusecs = (usecs > SMALLUSECS) ? SMALLUSECS : usecs;
preempt_disable();
cycles = smallusecs*local_cpu_data->cyc_per_usec;
start = ia64_get_itc();
while (time_before(ia64_get_itc(), end))
cpu_relax();
}

while (ia64_get_itc() - start < cycles)
cpu_relax();
void (*ia64_udelay)(unsigned long usecs) = &ia64_itc_udelay;

preempt_enable();
usecs -= smallusecs;
}
void
udelay (unsigned long usecs)
{
(*ia64_udelay)(usecs);
}
EXPORT_SYMBOL(udelay);

Expand Down
19 changes: 19 additions & 0 deletions trunk/arch/ia64/sn/kernel/sn2/timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#include <asm/hw_irq.h>
#include <asm/system.h>
#include <asm/timex.h>

#include <asm/sn/leds.h>
#include <asm/sn/shub_mmr.h>
Expand All @@ -28,9 +29,27 @@ static struct time_interpolator sn2_interpolator = {
.source = TIME_SOURCE_MMIO64
};

/*
* sn udelay uses the RTC instead of the ITC because the ITC is not
* synchronized across all CPUs, and the thread may migrate to another CPU
* if preemption is enabled.
*/
static void
ia64_sn_udelay (unsigned long usecs)
{
unsigned long start = rtc_time();
unsigned long end = start +
usecs * sn_rtc_cycles_per_second / 1000000;

while (time_before((unsigned long)rtc_time(), end))
cpu_relax();
}

void __init sn_timer_init(void)
{
sn2_interpolator.frequency = sn_rtc_cycles_per_second;
sn2_interpolator.addr = RTC_COUNTER_ADDR;
register_time_interpolator(&sn2_interpolator);

ia64_udelay = &ia64_sn_udelay;
}
2 changes: 2 additions & 0 deletions trunk/include/asm-ia64/timex.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

typedef unsigned long cycles_t;

extern void (*ia64_udelay)(unsigned long usecs);

/*
* For performance reasons, we don't want to define CLOCK_TICK_TRATE as
* local_cpu_data->itc_rate. Fortunately, we don't have to, either: according to George
Expand Down

0 comments on commit c4ec055

Please sign in to comment.