kernel: smp_cpu_rendezvous(): Use counter instead of bitmap
This commit is contained in:
@@ -47,7 +47,7 @@ status_t smp_per_cpu_init(struct kernel_args *args, int32 cpu);
|
||||
status_t smp_init_post_generic_syscalls(void);
|
||||
bool smp_trap_non_boot_cpus(int32 cpu, uint32* rendezVous);
|
||||
void smp_wake_up_non_boot_cpus(void);
|
||||
void smp_cpu_rendezvous(uint32 *var, int current_cpu);
|
||||
void smp_cpu_rendezvous(uint32 *var);
|
||||
void smp_send_ici(int32 targetCPU, int32 message, addr_t data, addr_t data2, addr_t data3,
|
||||
void *data_ptr, uint32 flags);
|
||||
void smp_send_multicast_ici(cpu_mask_t cpuMask, int32 message, addr_t data,
|
||||
|
||||
@@ -189,7 +189,7 @@ set_mtrr(void* _parameter, int cpu)
|
||||
= (struct set_mtrr_parameter*)_parameter;
|
||||
|
||||
// wait until all CPUs have arrived here
|
||||
smp_cpu_rendezvous(&sCpuRendezvous, cpu);
|
||||
smp_cpu_rendezvous(&sCpuRendezvous);
|
||||
|
||||
// One CPU has to reset sCpuRendezvous3 -- it is needed to prevent the CPU
|
||||
// that initiated the call_all_cpus() from doing that again and clearing
|
||||
@@ -206,8 +206,8 @@ set_mtrr(void* _parameter, int cpu)
|
||||
enable_caches();
|
||||
|
||||
// wait until all CPUs have arrived here
|
||||
smp_cpu_rendezvous(&sCpuRendezvous2, cpu);
|
||||
smp_cpu_rendezvous(&sCpuRendezvous3, cpu);
|
||||
smp_cpu_rendezvous(&sCpuRendezvous2);
|
||||
smp_cpu_rendezvous(&sCpuRendezvous3);
|
||||
}
|
||||
|
||||
|
||||
@@ -217,7 +217,7 @@ set_mtrrs(void* _parameter, int cpu)
|
||||
set_mtrrs_parameter* parameter = (set_mtrrs_parameter*)_parameter;
|
||||
|
||||
// wait until all CPUs have arrived here
|
||||
smp_cpu_rendezvous(&sCpuRendezvous, cpu);
|
||||
smp_cpu_rendezvous(&sCpuRendezvous);
|
||||
|
||||
// One CPU has to reset sCpuRendezvous3 -- it is needed to prevent the CPU
|
||||
// that initiated the call_all_cpus() from doing that again and clearing
|
||||
@@ -234,8 +234,8 @@ set_mtrrs(void* _parameter, int cpu)
|
||||
enable_caches();
|
||||
|
||||
// wait until all CPUs have arrived here
|
||||
smp_cpu_rendezvous(&sCpuRendezvous2, cpu);
|
||||
smp_cpu_rendezvous(&sCpuRendezvous3, cpu);
|
||||
smp_cpu_rendezvous(&sCpuRendezvous2);
|
||||
smp_cpu_rendezvous(&sCpuRendezvous3);
|
||||
}
|
||||
|
||||
|
||||
@@ -243,7 +243,7 @@ static void
|
||||
init_mtrrs(void* _unused, int cpu)
|
||||
{
|
||||
// wait until all CPUs have arrived here
|
||||
smp_cpu_rendezvous(&sCpuRendezvous, cpu);
|
||||
smp_cpu_rendezvous(&sCpuRendezvous);
|
||||
|
||||
// One CPU has to reset sCpuRendezvous3 -- it is needed to prevent the CPU
|
||||
// that initiated the call_all_cpus() from doing that again and clearing
|
||||
@@ -259,8 +259,8 @@ init_mtrrs(void* _unused, int cpu)
|
||||
enable_caches();
|
||||
|
||||
// wait until all CPUs have arrived here
|
||||
smp_cpu_rendezvous(&sCpuRendezvous2, cpu);
|
||||
smp_cpu_rendezvous(&sCpuRendezvous3, cpu);
|
||||
smp_cpu_rendezvous(&sCpuRendezvous2);
|
||||
smp_cpu_rendezvous(&sCpuRendezvous3);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -100,13 +100,13 @@ _start(kernel_args *bootKernelArgs, int currentCPU)
|
||||
smp_set_num_cpus(bootKernelArgs->num_cpus);
|
||||
|
||||
// wait for all the cpus to get here
|
||||
smp_cpu_rendezvous(&sCpuRendezvous, currentCPU);
|
||||
smp_cpu_rendezvous(&sCpuRendezvous);
|
||||
|
||||
// the passed in kernel args are in a non-allocated range of memory
|
||||
if (currentCPU == 0)
|
||||
memcpy(&sKernelArgs, bootKernelArgs, sizeof(kernel_args));
|
||||
|
||||
smp_cpu_rendezvous(&sCpuRendezvous2, currentCPU);
|
||||
smp_cpu_rendezvous(&sCpuRendezvous2);
|
||||
|
||||
// do any pre-booting cpu config
|
||||
cpu_preboot_init_percpu(&sKernelArgs, currentCPU);
|
||||
@@ -221,13 +221,13 @@ _start(kernel_args *bootKernelArgs, int currentCPU)
|
||||
TRACE("waking up AP cpus\n");
|
||||
sCpuRendezvous = sCpuRendezvous2 = 0;
|
||||
smp_wake_up_non_boot_cpus();
|
||||
smp_cpu_rendezvous(&sCpuRendezvous, 0); // wait until they're booted
|
||||
smp_cpu_rendezvous(&sCpuRendezvous); // wait until they're booted
|
||||
|
||||
// exit the kernel startup phase (mutexes, etc work from now on out)
|
||||
TRACE("exiting kernel startup\n");
|
||||
gKernelStartup = false;
|
||||
|
||||
smp_cpu_rendezvous(&sCpuRendezvous2, 0);
|
||||
smp_cpu_rendezvous(&sCpuRendezvous2);
|
||||
// release the AP cpus to go enter the scheduler
|
||||
|
||||
TRACE("starting scheduler on cpu 0 and enabling interrupts\n");
|
||||
@@ -244,8 +244,8 @@ _start(kernel_args *bootKernelArgs, int currentCPU)
|
||||
smp_per_cpu_init(&sKernelArgs, currentCPU);
|
||||
|
||||
// wait for all other AP cpus to get to this point
|
||||
smp_cpu_rendezvous(&sCpuRendezvous, currentCPU);
|
||||
smp_cpu_rendezvous(&sCpuRendezvous2, currentCPU);
|
||||
smp_cpu_rendezvous(&sCpuRendezvous);
|
||||
smp_cpu_rendezvous(&sCpuRendezvous2);
|
||||
|
||||
// welcome to the machine
|
||||
scheduler_start();
|
||||
|
||||
@@ -1313,11 +1313,11 @@ bool
|
||||
smp_trap_non_boot_cpus(int32 cpu, uint32* rendezVous)
|
||||
{
|
||||
if (cpu == 0) {
|
||||
smp_cpu_rendezvous(rendezVous, cpu);
|
||||
smp_cpu_rendezvous(rendezVous);
|
||||
return true;
|
||||
}
|
||||
|
||||
smp_cpu_rendezvous(rendezVous, cpu);
|
||||
smp_cpu_rendezvous(rendezVous);
|
||||
|
||||
while (atomic_get(&sBootCPUSpin) == 0) {
|
||||
if ((atomic_get(&sEarlyCPUCall) & (1 << cpu)) != 0)
|
||||
@@ -1353,13 +1353,12 @@ smp_wake_up_non_boot_cpus()
|
||||
ensured via another rendez-vous) the variable can be reset.
|
||||
*/
|
||||
void
|
||||
smp_cpu_rendezvous(uint32* var, int current_cpu)
|
||||
smp_cpu_rendezvous(uint32* var)
|
||||
{
|
||||
atomic_or((int32*)var, 1 << current_cpu);
|
||||
atomic_add((int32*)var, 1);
|
||||
|
||||
uint32 allReady = ((uint32)1 << sNumCPUs) - 1;
|
||||
while ((uint32)atomic_get((int32*)var) != allReady)
|
||||
cpu_wait((int32*)var, allReady);
|
||||
while ((uint32)atomic_get((int32*)var) < sNumCPUs)
|
||||
cpu_wait((int32*)var, sNumCPUs);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user