Lines 408-414
powermac_register_timebase(device_t dev, powermac_tb_disable_t cb)
Link Here
|
408 |
static void |
408 |
static void |
409 |
powermac_smp_timebase_sync(platform_t plat, u_long tb, int ap) |
409 |
powermac_smp_timebase_sync(platform_t plat, u_long tb, int ap) |
410 |
{ |
410 |
{ |
411 |
static volatile bool tb_ready; |
411 |
static volatile int tb_ready; |
412 |
static volatile int cpu_done; |
412 |
static volatile int cpu_done; |
413 |
|
413 |
|
414 |
/* |
414 |
/* |
Lines 424-450
powermac_smp_timebase_sync(platform_t plat, u_long tb, int ap)
Link Here
|
424 |
if (ap) { |
424 |
if (ap) { |
425 |
/* APs. Hold off until we get a stable timebase. */ |
425 |
/* APs. Hold off until we get a stable timebase. */ |
426 |
critical_enter(); |
426 |
critical_enter(); |
427 |
while (!tb_ready) |
427 |
while (atomic_load_acq_int(&tb_ready) < 1) |
428 |
atomic_thread_fence_seq_cst(); |
428 |
atomic_thread_fence_seq_cst(); |
429 |
mttb(tb); |
429 |
mttb(tb); |
430 |
atomic_add_int(&cpu_done, 1); |
430 |
atomic_add_rel_int(&cpu_done, 1); |
431 |
while (cpu_done < mp_ncpus) |
431 |
while (atomic_load_acq_int(&cpu_done) < mp_ncpus) |
432 |
atomic_thread_fence_seq_cst(); |
432 |
atomic_thread_fence_seq_cst(); |
433 |
critical_exit(); |
433 |
critical_exit(); |
434 |
} else { |
434 |
} else { |
435 |
/* BSP */ |
435 |
/* BSP */ |
436 |
critical_enter(); |
436 |
critical_enter(); |
437 |
/* Ensure cpu_done is zeroed so we can resync at runtime */ |
437 |
/* Ensure cpu_done is zeroed so we can resync at runtime */ |
438 |
atomic_set_int(&cpu_done, 0); |
438 |
atomic_set_rel_int(&cpu_done, 0); |
439 |
freeze_timebase(powermac_tb_dev, true); |
439 |
freeze_timebase(powermac_tb_dev, true); |
440 |
tb_ready = true; |
440 |
atomic_set_rel_int(&tb_ready, 1); |
441 |
mttb(tb); |
441 |
mttb(tb); |
442 |
atomic_add_int(&cpu_done, 1); |
442 |
atomic_add_rel_int(&cpu_done, 1); |
443 |
while (cpu_done < mp_ncpus) |
443 |
while (atomic_load_acq_int(&cpu_done) < mp_ncpus) |
444 |
atomic_thread_fence_seq_cst(); |
444 |
atomic_thread_fence_seq_cst(); |
445 |
freeze_timebase(powermac_tb_dev, false); |
445 |
freeze_timebase(powermac_tb_dev, false); |
446 |
/* Reset tb_ready so we can resync at runtime */ |
446 |
/* Reset tb_ready so we can resync at runtime */ |
447 |
tb_ready = false; |
447 |
atomic_set_rel_int(&tb_ready, 0); |
448 |
critical_exit(); |
448 |
critical_exit(); |
449 |
} |
449 |
} |
450 |
} |
450 |
} |