From be9f4ee9e6c8e8cbc0e091e8abd63df66bdf1cd0 Mon Sep 17 00:00:00 2001 From: "Li, Fei1" Date: Mon, 23 Apr 2018 13:48:22 +0800 Subject: [PATCH] hv: timer: pass timer callback function parameter by pointer Signed-off-by: Li, Fei1 Reviewed-by: Zhao Yakui Reviewed-by: Jason Chen CJ Acked-by: Eddie Dong --- hypervisor/arch/x86/guest/vlapic.c | 4 ++-- hypervisor/arch/x86/timer.c | 10 +++++----- hypervisor/debug/console.c | 4 ++-- hypervisor/include/arch/x86/timer.h | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/hypervisor/arch/x86/guest/vlapic.c b/hypervisor/arch/x86/guest/vlapic.c index 357ea41ec..6696c1ef5 100644 --- a/hypervisor/arch/x86/guest/vlapic.c +++ b/hypervisor/arch/x86/guest/vlapic.c @@ -1908,7 +1908,7 @@ vlapic_msr(uint32_t msr) } /* interrupt context */ -static int tsc_periodic_time(uint64_t data) +static int tsc_periodic_time(void *data) { struct vcpu *vcpu = (struct vcpu *)data; struct vlapic *vlapic; @@ -1979,7 +1979,7 @@ vlapic_wrmsr(struct vcpu *vcpu, uint32_t msr, uint64_t val) vlapic->last_timer = update_timer(vlapic->last_timer, tsc_periodic_time, - (long)vcpu, + (void *)vcpu, val); if (vlapic->last_timer < 0) { diff --git a/hypervisor/arch/x86/timer.c b/hypervisor/arch/x86/timer.c index 11e1ba18c..af41eb5a3 100644 --- a/hypervisor/arch/x86/timer.c +++ b/hypervisor/arch/x86/timer.c @@ -41,12 +41,12 @@ uint64_t tsc_hz = 1000000000; struct timer { timer_handle_t func; /* callback if time reached */ - uint64_t priv_data; /* func private data */ uint64_t deadline; /* tsc deadline to interrupt */ long handle; /* unique handle for user */ int pcpu_id; /* armed on which CPU */ int id; /* timer ID, used by release */ struct list_head node; /* link all timers */ + void *priv_data; /* func private data */ }; struct per_cpu_timers { @@ -95,7 +95,7 @@ static void release_timer(struct timer *timer) struct per_cpu_timers *cpu_timer; cpu_timer = &per_cpu(cpu_timers, timer->pcpu_id); - timer->priv_data = 0; + timer->priv_data = NULL; timer->func = NULL; timer->deadline = 0; bitmap_set(timer->id, &cpu_timer->free_bitmap); @@ -243,7 +243,7 @@ static void init_timer_pool(void) for (j = 0; j < MAX_TIMER_ACTIONS; j++) { timers_pool[j].id = j; timers_pool[j].pcpu_id = i; - timers_pool[j].priv_data = 0; + timers_pool[j].priv_data = NULL; timers_pool[j].func = NULL; timers_pool[j].deadline = 0; timers_pool[j].handle = -1UL; @@ -323,7 +323,7 @@ int timer_softirq(int pcpu_id) * return: handle, this handle is unique and can be used to find back * this added timer. handle will be invalid after timer expired */ -long add_timer(timer_handle_t func, uint64_t data, uint64_t deadline) +long add_timer(timer_handle_t func, void *data, uint64_t deadline) { struct timer *timer; struct per_cpu_timers *cpu_timer; @@ -357,7 +357,7 @@ long add_timer(timer_handle_t func, uint64_t data, uint64_t deadline) * update_timer existing timer. if not found, add new timer */ long -update_timer(long handle, timer_handle_t func, uint64_t data, +update_timer(long handle, timer_handle_t func, void *data, uint64_t deadline) { struct timer *timer; diff --git a/hypervisor/debug/console.c b/hypervisor/debug/console.c index cfdee6863..8cb758c0e 100644 --- a/hypervisor/debug/console.c +++ b/hypervisor/debug/console.c @@ -216,7 +216,7 @@ static void console_handler(void) shell_kick_session(); } -static int console_timer_callback(__unused uint64_t data) +static int console_timer_callback(__unused void *data) { /* Kick HV-Shell and Uart-Console tasks */ console_handler(); @@ -230,7 +230,7 @@ static int console_timer_callback(__unused uint64_t data) void console_setup_timer(void) { /* Start an one-shot timer */ - if (add_timer(console_timer_callback, 0, + if (add_timer(console_timer_callback, NULL, rdtsc() + CYCLES_PER_MS * CONSOLE_KICK_TIMER_TIMEOUT) < 0) pr_err("Failed to add console kick timer"); } diff --git a/hypervisor/include/arch/x86/timer.h b/hypervisor/include/arch/x86/timer.h index 62eb6d3e9..e7a9bbbc3 100644 --- a/hypervisor/include/arch/x86/timer.h +++ b/hypervisor/include/arch/x86/timer.h @@ -31,11 +31,11 @@ #ifndef TIMER_H #define TIMER_H -typedef int (*timer_handle_t)(uint64_t); +typedef int (*timer_handle_t)(void *); -long add_timer(timer_handle_t func, uint64_t data, uint64_t deadline); +long add_timer(timer_handle_t func, void *data, uint64_t deadline); bool cancel_timer(long handle, int pcpu_id); -long update_timer(long handle, timer_handle_t func, uint64_t data, +long update_timer(long handle, timer_handle_t func, void *data, uint64_t deadline); int timer_softirq(int pcpu_id);