Skip to content

Commit

Permalink
hv: timer: pass timer callback function parameter by pointer
Browse files Browse the repository at this point in the history
Signed-off-by: Li, Fei1 <fei1.li@intel.com>
Reviewed-by: Zhao Yakui <yakui.zhao@intel.com>
Reviewed-by: Jason Chen CJ <jason.cj.chen@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
  • Loading branch information
lifeix authored and jren1 committed May 15, 2018
1 parent dace32e commit be9f4ee
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions hypervisor/arch/x86/guest/vlapic.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down
10 changes: 5 additions & 5 deletions hypervisor/arch/x86/timer.c
Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions hypervisor/debug/console.c
Expand Up @@ -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();
Expand All @@ -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");
}
6 changes: 3 additions & 3 deletions hypervisor/include/arch/x86/timer.h
Expand Up @@ -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);
Expand Down

0 comments on commit be9f4ee

Please sign in to comment.