Commit 95ff7cde authored by K. Y. Srinivasan's avatar K. Y. Srinivasan Committed by Greg Kroah-Hartman

Staging: hv: util: Adjust guest time in a process context

The current code was adjusting guest time in interrupt context; do this
in process context since we may have to initiate cross-processor
interrupts as part of setting time.
Signed-off-by: default avatarK. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: default avatarHaiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent ae2a0b42
...@@ -106,6 +106,24 @@ static inline void do_adj_guesttime(u64 hosttime) ...@@ -106,6 +106,24 @@ static inline void do_adj_guesttime(u64 hosttime)
do_settimeofday(&host_ts); do_settimeofday(&host_ts);
} }
/*
* Set the host time in a process context.
*/
struct adj_time_work {
struct work_struct work;
u64 host_time;
};
static void hv_set_host_time(struct work_struct *work)
{
struct adj_time_work *wrk;
wrk = container_of(work, struct adj_time_work, work);
do_adj_guesttime(wrk->host_time);
kfree(wrk);
}
/* /*
* Synchronize time with host after reboot, restore, etc. * Synchronize time with host after reboot, restore, etc.
* *
...@@ -119,17 +137,26 @@ static inline void do_adj_guesttime(u64 hosttime) ...@@ -119,17 +137,26 @@ static inline void do_adj_guesttime(u64 hosttime)
*/ */
static inline void adj_guesttime(u64 hosttime, u8 flags) static inline void adj_guesttime(u64 hosttime, u8 flags)
{ {
struct adj_time_work *wrk;
static s32 scnt = 50; static s32 scnt = 50;
wrk = kmalloc(sizeof(struct adj_time_work), GFP_ATOMIC);
if (wrk == NULL)
return;
wrk->host_time = hosttime;
if ((flags & ICTIMESYNCFLAG_SYNC) != 0) { if ((flags & ICTIMESYNCFLAG_SYNC) != 0) {
do_adj_guesttime(hosttime); INIT_WORK(&wrk->work, hv_set_host_time);
schedule_work(&wrk->work);
return; return;
} }
if ((flags & ICTIMESYNCFLAG_SAMPLE) != 0 && scnt > 0) { if ((flags & ICTIMESYNCFLAG_SAMPLE) != 0 && scnt > 0) {
scnt--; scnt--;
do_adj_guesttime(hosttime); INIT_WORK(&wrk->work, hv_set_host_time);
} schedule_work(&wrk->work);
} else
kfree(wrk);
} }
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment