Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 322248
b: refs/heads/master
c: cf9bfe5
h: refs/heads/master
v: v3
  • Loading branch information
Jayachandran C authored and Ralf Baechle committed Aug 17, 2012
1 parent 6f39879 commit 3370681
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 22 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: 5a6704454a68ab6e27e4fc5b82818a8c5733bf29
refs/heads/master: cf9bfe55f24973a8f40e2c922a7e82cf09e486fd
8 changes: 4 additions & 4 deletions trunk/arch/mips/include/asm/r4k-timer.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@

#ifdef CONFIG_SYNC_R4K

extern void synchronise_count_master(void);
extern void synchronise_count_slave(void);
extern void synchronise_count_master(int cpu);
extern void synchronise_count_slave(int cpu);

#else

static inline void synchronise_count_master(void)
static inline void synchronise_count_master(int cpu)
{
}

static inline void synchronise_count_slave(void)
static inline void synchronise_count_slave(int cpu)
{
}

Expand Down
4 changes: 2 additions & 2 deletions trunk/arch/mips/kernel/smp.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ asmlinkage __cpuinit void start_secondary(void)

cpu_set(cpu, cpu_callin_map);

synchronise_count_slave();
synchronise_count_slave(cpu);

/*
* irq will be enabled in ->smp_finish(), enabling it too early
Expand Down Expand Up @@ -173,7 +173,6 @@ void smp_send_stop(void)
void __init smp_cpus_done(unsigned int max_cpus)
{
mp_ops->cpus_done();
synchronise_count_master();
}

/* called from main before smp_init() */
Expand Down Expand Up @@ -206,6 +205,7 @@ int __cpuinit __cpu_up(unsigned int cpu, struct task_struct *tidle)
while (!cpu_isset(cpu, cpu_callin_map))
udelay(100);

synchronise_count_master(cpu);
return 0;
}

Expand Down
26 changes: 11 additions & 15 deletions trunk/arch/mips/kernel/sync-r4k.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,11 @@ static atomic_t __cpuinitdata count_reference = ATOMIC_INIT(0);
#define COUNTON 100
#define NR_LOOPS 5

void __cpuinit synchronise_count_master(void)
void __cpuinit synchronise_count_master(int cpu)
{
int i;
unsigned long flags;
unsigned int initcount;
int nslaves;

#ifdef CONFIG_MIPS_MT_SMTC
/*
Expand All @@ -43,16 +42,15 @@ void __cpuinit synchronise_count_master(void)
return;
#endif

printk(KERN_INFO "Synchronize counters across %u CPUs: ",
num_online_cpus());
printk(KERN_INFO "Synchronize counters for CPU %u: ", cpu);

local_irq_save(flags);

/*
* Notify the slaves that it's time to start
*/
atomic_set(&count_reference, read_c0_count());
atomic_set(&count_start_flag, 1);
atomic_set(&count_start_flag, cpu);
smp_wmb();

/* Count will be initialised to current timer for all CPU's */
Expand All @@ -69,10 +67,9 @@ void __cpuinit synchronise_count_master(void)
* two CPUs.
*/

nslaves = num_online_cpus()-1;
for (i = 0; i < NR_LOOPS; i++) {
/* slaves loop on '!= ncpus' */
while (atomic_read(&count_count_start) != nslaves)
/* slaves loop on '!= 2' */
while (atomic_read(&count_count_start) != 1)
mb();
atomic_set(&count_count_stop, 0);
smp_wmb();
Expand All @@ -89,14 +86,15 @@ void __cpuinit synchronise_count_master(void)
/*
* Wait for all slaves to leave the synchronization point:
*/
while (atomic_read(&count_count_stop) != nslaves)
while (atomic_read(&count_count_stop) != 1)
mb();
atomic_set(&count_count_start, 0);
smp_wmb();
atomic_inc(&count_count_stop);
}
/* Arrange for an interrupt in a short while */
write_c0_compare(read_c0_count() + COUNTON);
atomic_set(&count_start_flag, 0);

local_irq_restore(flags);

Expand All @@ -108,11 +106,10 @@ void __cpuinit synchronise_count_master(void)
printk("done.\n");
}

void __cpuinit synchronise_count_slave(void)
void __cpuinit synchronise_count_slave(int cpu)
{
int i;
unsigned int initcount;
int ncpus;

#ifdef CONFIG_MIPS_MT_SMTC
/*
Expand All @@ -127,16 +124,15 @@ void __cpuinit synchronise_count_slave(void)
* so we first wait for the master to say everyone is ready
*/

while (!atomic_read(&count_start_flag))
while (atomic_read(&count_start_flag) != cpu)
mb();

/* Count will be initialised to next expire for all CPU's */
initcount = atomic_read(&count_reference);

ncpus = num_online_cpus();
for (i = 0; i < NR_LOOPS; i++) {
atomic_inc(&count_count_start);
while (atomic_read(&count_count_start) != ncpus)
while (atomic_read(&count_count_start) != 2)
mb();

/*
Expand All @@ -146,7 +142,7 @@ void __cpuinit synchronise_count_slave(void)
write_c0_count(initcount);

atomic_inc(&count_count_stop);
while (atomic_read(&count_count_stop) != ncpus)
while (atomic_read(&count_count_stop) != 2)
mb();
}
/* Arrange for an interrupt in a short while */
Expand Down

0 comments on commit 3370681

Please sign in to comment.