MIPS: Synchronize MIPS count one CPU at a time
The current implementation of synchronise_count_{master,slave} blocks
slave CPUs in early boot until all of them come up. This no longer
works because blocking a CPU with interrupts off after notifying the
CPU to be online causes problems with the current kernel.
Specifically, after the workqueue changes
(commit a08489c569
"Pull workqueue changes from Tejun Heo")
the CPU_ONLINE notification callback workqueue_cpu_up_callback()
will hang on wait_for_completion(&idle_rebind.done), if the slave
CPUs are blocked for synchronize_count_slave().
The changes are to update synchronize_count_{master,slave}() to handle
one CPU at a time and to call synchronise_count_master() in __cpu_up()
so that the CPU_ONLINE notification goes out only after the COP0 COUNT
register is synchronized.
[ralf@linux-mips.org: This matter only to those few platforms which are
using the cp0 counter as their clocksource which are XLP, XLR and MIPS'
CMP solution.]
Signed-off-by: Jayachandran C <jchandra@broadcom.com>
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/4216/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
This commit is contained in:
parent
5a6704454a
commit
cf9bfe55f2
|
@ -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)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
@ -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() */
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
/*
|
||||
|
@ -43,8 +42,7 @@ 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);
|
||||
|
||||
|
@ -52,7 +50,7 @@ void __cpuinit synchronise_count_master(void)
|
|||
* 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 */
|
||||
|
@ -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();
|
||||
|
@ -89,7 +86,7 @@ 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();
|
||||
|
@ -97,6 +94,7 @@ void __cpuinit synchronise_count_master(void)
|
|||
}
|
||||
/* 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);
|
||||
|
||||
|
@ -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
|
||||
/*
|
||||
|
@ -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();
|
||||
|
||||
/*
|
||||
|
@ -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 */
|
||||
|
|
Loading…
Reference in New Issue