Signed-off-by: Andrew Jones <drjones@xxxxxxxxxx> --- x86/hyperv_stimer.c | 41 ++++++++--------------------------------- 1 file changed, 8 insertions(+), 33 deletions(-) diff --git a/x86/hyperv_stimer.c b/x86/hyperv_stimer.c index 5292523709ea..a067c5097f88 100644 --- a/x86/hyperv_stimer.c +++ b/x86/hyperv_stimer.c @@ -19,8 +19,6 @@ #define SINT2_NUM 3 #define ONE_MS_IN_100NS 10000 -static atomic_t g_cpus_comp_count; -static int g_cpus_count; static struct spinlock g_synic_alloc_lock; struct stimer { @@ -216,10 +214,6 @@ static void synic_disable(void) synic_free_page(svcpu->msg_page); } -static void cpu_comp(void) -{ - atomic_inc(&g_cpus_comp_count); -} static void stimer_test_prepare(void *ctx) { @@ -229,7 +223,6 @@ static void stimer_test_prepare(void *ctx) synic_enable(); synic_sint_create(vcpu, SINT1_NUM, SINT1_VEC, false); synic_sint_create(vcpu, SINT2_NUM, SINT2_VEC, true); - cpu_comp(); } static void stimer_test_periodic(int vcpu, struct stimer *timer1, @@ -297,7 +290,6 @@ static void stimer_test(void *ctx) stimer_test_auto_enable_periodic(vcpu, timer1); irq_disable(); - cpu_comp(); } static void stimer_test_cleanup(void *ctx) @@ -308,20 +300,6 @@ static void stimer_test_cleanup(void *ctx) synic_sint_destroy(vcpu, SINT1_NUM); synic_sint_destroy(vcpu, SINT2_NUM); synic_disable(); - cpu_comp(); -} - -static void on_each_cpu_async_wait(void (*func)(void *ctx), void *ctx) -{ - int i; - - atomic_set(&g_cpus_comp_count, 0); - for (i = 0; i < g_cpus_count; i++) { - on_cpu_async(i, func, ctx); - } - while (atomic_read(&g_cpus_comp_count) != g_cpus_count) { - pause(); - } } static void stimer_test_all(void) @@ -332,20 +310,17 @@ static void stimer_test_all(void) smp_init(); enable_apic(); - handle_irq(SINT1_VEC, stimer_isr); - handle_irq(SINT2_VEC, stimer_isr_auto_eoi); - ncpus = cpu_count(); - if (ncpus > MAX_CPUS) { - ncpus = MAX_CPUS; - } - + if (ncpus > MAX_CPUS) + report_abort("number cpus exceeds %d", MAX_CPUS); printf("cpus = %d\n", ncpus); - g_cpus_count = ncpus; - on_each_cpu_async_wait(stimer_test_prepare, (void *)read_cr3()); - on_each_cpu_async_wait(stimer_test, NULL); - on_each_cpu_async_wait(stimer_test_cleanup, NULL); + handle_irq(SINT1_VEC, stimer_isr); + handle_irq(SINT2_VEC, stimer_isr_auto_eoi); + + on_cpus(stimer_test_prepare, (void *)read_cr3()); + on_cpus(stimer_test, NULL); + on_cpus(stimer_test_cleanup, NULL); } int main(int ac, char **av) -- 2.9.4