Skip to content

Commit

Permalink
Merge branch 'merge' of git://git.kernel.org/pub/scm/linux/kernel/git…
Browse files Browse the repository at this point in the history
…/paulus/powerpc

* 'merge' of git://git.kernel.org/pub/scm/linux/kernel/git/paulus/powerpc:
  [POWERPC] Fix timekeeping on PowerPC 601
  [POWERPC] Don't expose clock vDSO functions when CPU has no timebase
  [POWERPC] spusched: Fix null pointer dereference in find_victim
  • Loading branch information
Linus Torvalds committed Sep 19, 2007
2 parents dbe3ed1 + c27da33 commit f15f413
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 5 deletions.
8 changes: 5 additions & 3 deletions arch/powerpc/kernel/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ static void snapshot_tb_and_purr(void *data)
struct cpu_purr_data *p = &__get_cpu_var(cpu_purr_data);

local_irq_save(flags);
p->tb = mftb();
p->tb = get_tb_or_rtc();
p->purr = mfspr(SPRN_PURR);
wmb();
p->initialized = 1;
Expand Down Expand Up @@ -317,7 +317,7 @@ static void snapshot_purr(void)
*/
void snapshot_timebase(void)
{
__get_cpu_var(last_jiffy) = get_tb();
__get_cpu_var(last_jiffy) = get_tb_or_rtc();
snapshot_purr();
}

Expand Down Expand Up @@ -684,6 +684,8 @@ void timer_interrupt(struct pt_regs * regs)

write_seqlock(&xtime_lock);
tb_next_jiffy = tb_last_jiffy + tb_ticks_per_jiffy;
if (__USE_RTC() && tb_next_jiffy >= 1000000000)
tb_next_jiffy -= 1000000000;
if (per_cpu(last_jiffy, cpu) >= tb_next_jiffy) {
tb_last_jiffy = tb_next_jiffy;
do_timer(1);
Expand Down Expand Up @@ -977,7 +979,7 @@ void __init time_init(void)
tb_to_ns_scale = scale;
tb_to_ns_shift = shift;
/* Save the current timebase to pretty up CONFIG_PRINTK_TIME */
boot_tb = get_tb();
boot_tb = get_tb_or_rtc();

tm = get_boot_time();

Expand Down
12 changes: 12 additions & 0 deletions arch/powerpc/kernel/vdso.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,18 @@ static struct vdso_patch_def vdso_patches[] = {
CPU_FTR_USE_TB, 0,
"__kernel_gettimeofday", NULL
},
{
CPU_FTR_USE_TB, 0,
"__kernel_clock_gettime", NULL
},
{
CPU_FTR_USE_TB, 0,
"__kernel_clock_getres", NULL
},
{
CPU_FTR_USE_TB, 0,
"__kernel_get_tbfreq", NULL
},
};

/*
Expand Down
4 changes: 2 additions & 2 deletions arch/powerpc/platforms/cell/spufs/sched.c
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ static struct spu *find_victim(struct spu_context *ctx)
list_for_each_entry(spu, &cbe_spu_info[node].spus, cbe_list) {
struct spu_context *tmp = spu->ctx;

if (tmp->prio > ctx->prio &&
if (tmp && tmp->prio > ctx->prio &&
(!victim || tmp->prio > victim->prio))
victim = spu->ctx;
}
Expand Down Expand Up @@ -611,9 +611,9 @@ static struct spu *find_victim(struct spu_context *ctx)

mutex_lock(&cbe_spu_info[node].list_mutex);
cbe_spu_info[node].nr_active--;
spu_unbind_context(spu, victim);
mutex_unlock(&cbe_spu_info[node].list_mutex);

spu_unbind_context(spu, victim);
victim->stats.invol_ctx_switch++;
spu->stats.invol_ctx_switch++;
mutex_unlock(&victim->state_mutex);
Expand Down
5 changes: 5 additions & 0 deletions include/asm-powerpc/time.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,11 @@ static inline u64 get_tb(void)
}
#endif /* !CONFIG_PPC64 */

static inline u64 get_tb_or_rtc(void)
{
return __USE_RTC() ? get_rtc() : get_tb();
}

static inline void set_tb(unsigned int upper, unsigned int lower)
{
mtspr(SPRN_TBWL, 0);
Expand Down

0 comments on commit f15f413

Please sign in to comment.