}
/* Only UTC, or TAI with offset */
- if (!tai_adjust(st->clk, NULL))
+ if (!tai_adjust(st->clk, NULL)) {
+ dev_info(dev, "vmclock does not provide unambiguous UTC\n");
st->cs_id = CSID_GENERIC;
+ }
if (st->cs_id) {
st->sys_cs_id = st->cs_id;
st->ptp_clock_info = ptp_vmclock_info;
- strncpy(st->ptp_clock_info.name, st->name, sizeof(st->ptp_clock_info.name));
+ strscpy(st->ptp_clock_info.name, st->name, sizeof(st->ptp_clock_info.name));
st->ptp_clock = ptp_clock_register(&st->ptp_clock_info, dev);
if (IS_ERR(st->ptp_clock)) {
vmclock_remove(pdev);
goto out;
}
+ } else if (!st->miscdev.minor) {
+ /* Neither miscdev nor PTP registered */
+ dev_info(dev, "vmclock: Neither miscdev nor PTP available; not registering\n");
+ ret = -ENODEV;
+ goto out;
}
+ dev_info(dev, "%s: registered %s%s%s\n", st->name,
+ st->miscdev.minor ? "miscdev" : "",
+ (st->miscdev.minor && st->ptp_clock) ? ", " : "",
+ st->ptp_clock ? "PTP" : "");
+
dev_set_drvdata(dev, st);
out:
#define VMCLOCK_STATUS_FREERUNNING 3
#define VMCLOCK_STATUS_UNRELIABLE 4
- uint8_t counter_id;
-#define VMCLOCK_COUNTER_INVALID 0
+ uint8_t counter_id; /* VIRTIO_RTC_COUNTER_xxx */
+#define VMCLOCK_COUNTER_ARM_VCNT 0
#define VMCLOCK_COUNTER_X86_TSC 1
-#define VMCLOCK_COUNTER_ARM_VCNT 2
-#define VMCLOCK_COUNTER_X86_ART 3
+#define VMCLOCK_COUNTER_X86_ART 2
+#define VMCLOCK_COUNTER_INVALID 0xff
/*
* By providing the offset from UTC to TAI, the guest can know both
* it may do so in a fashion consistent with the other systems
* in the nearby environment.
*/
- uint8_t leap_second_smearing_hint;
+ uint8_t leap_second_smearing_hint; /* Not quite VIRTIO_RTC_SUBTYPE_xxx */
/* Provide true UTC to users, unsmeared. */;
#define VMCLOCK_SMEARING_NONE 0
/*
* https://aws.amazon.com/blogs/aws/look-before-you-leap-the-coming-leap-second-and-aws/
+ * https://developers.google.com/time/smear
+ *
* From noon on the day before to noon on the day after, smear the
* clock by a linear 1/86400s per second.
*/
-#define VMCLOCK_SMEARING_LINEAR_86400 1
+#define VMCLOCK_SMEARING_NOON_LINEAR 2
/*
* draft-kuhn-leapsecond-00
* For the 1000s leading up to the leap second, smear the clock by
* clock by a linear 1ms per second.
*/
-#define VMCLOCK_SMEARING_UTC_SLS 2
+#define VMCLOCK_SMEARING_UTC_SLS 4
/*
* What time is exposed in the time_sec/time_frac_sec fields?
*/
- uint8_t time_type;
-#define VMCLOCK_TIME_UNKNOWN 0 /* Invalid / no time exposed */
-#define VMCLOCK_TIME_UTC 1 /* Since 1970-01-01 00:00:00z */
-#define VMCLOCK_TIME_TAI 2 /* Since 1970-01-01 00:00:00z */
-#define VMCLOCK_TIME_MONOTONIC 3 /* Since undefined epoch */
+ uint8_t time_type; /* VIRTIO_RTC_TYPE_xxx */
+#define VMCLOCK_TIME_UTC 0 /* Since 1970-01-01 00:00:00z */
+#define VMCLOCK_TIME_TAI 1 /* Since 1970-01-01 00:00:00z */
+#define VMCLOCK_TIME_MONOTONIC 2 /* Since undefined epoch */
+#define VMCLOCK_TIME_SMEARED_INVALID 3 /* UTC but with smeared leap seconds */
/* Bit shift for counter_period_frac_sec and its error rate */
uint8_t counter_period_shift;