]> git.karo-electronics.de Git - linux-beck.git/commitdiff
Drivers: hv: utils: Use TimeSync samples to adjust the clock after boot.
authorAlex Ng <alexng@messages.microsoft.com>
Thu, 8 Sep 2016 12:24:13 +0000 (05:24 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 8 Sep 2016 11:53:07 +0000 (13:53 +0200)
Only the first 50 samples after boot were being used to discipline the
clock. After the first 50 samples, any samples from the host were ignored
and the guest clock would eventually drift from the host clock.

This patch allows TimeSync-enabled guests to continuously synchronize the
clock with the host clock, even after the first 50 samples.

Signed-off-by: Alex Ng <alexng@messages.microsoft.com>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/hv/hv_util.c

index b27a8ee3de57fef51e07cb812e06cfddda5efd43..4002b717c7772406886437c9ba54453381dfc67e 100644 (file)
@@ -198,29 +198,23 @@ static void hv_set_host_time(struct work_struct *work)
  * ICTIMESYNCFLAG_SYNC flag bit indicates reboot, restore events of the VM.
  * After reboot the flag ICTIMESYNCFLAG_SYNC is included in the first time
  * message after the timesync channel is opened. Since the hv_utils module is
- * loaded after hv_vmbus, the first message is usually missed. The other
- * thing is, systime is automatically set to emulated hardware clock which may
- * not be UTC time or in the same time zone. So, to override these effects, we
- * use the first 50 time samples for initial system time setting.
+ * loaded after hv_vmbus, the first message is usually missed. This bit is
+ * considered a hard request to discipline the clock.
+ *
+ * ICTIMESYNCFLAG_SAMPLE bit indicates a time sample from host. This is
+ * typically used as a hint to the guest. The guest is under no obligation
+ * to discipline the clock.
  */
 static inline void adj_guesttime(u64 hosttime, u8 flags)
 {
        struct adj_time_work    *wrk;
-       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) {
-               INIT_WORK(&wrk->work, hv_set_host_time);
-               schedule_work(&wrk->work);
-               return;
-       }
-
-       if ((flags & ICTIMESYNCFLAG_SAMPLE) != 0 && scnt > 0) {
-               scnt--;
+       if ((flags & (ICTIMESYNCFLAG_SYNC | ICTIMESYNCFLAG_SAMPLE)) != 0) {
                INIT_WORK(&wrk->work, hv_set_host_time);
                schedule_work(&wrk->work);
        } else