x86/kvm, ptp/kvm: Add clocksource ID, set system_counterval_t.cs_id
authorPeter Hilber <peter.hilber@opensynergy.com>
Thu, 1 Feb 2024 01:04:49 +0000 (02:04 +0100)
committerThomas Gleixner <tglx@linutronix.de>
Wed, 7 Feb 2024 16:05:21 +0000 (17:05 +0100)
Add a clocksource ID for the x86 kvmclock.

Also, for ptp_kvm, set the recently added struct system_counterval_t member
cs_id to the clocksource ID (x86 kvmclock or ARM Generic Timer). In the
future, get_device_system_crosststamp() will compare the clocksource ID in
struct system_counterval_t, rather than the clocksource.

For now, to avoid touching too many subsystems at once, extract the
clocksource ID from the clocksource. The clocksource dereference will be
removed once everything is converted over..

Signed-off-by: Peter Hilber <peter.hilber@opensynergy.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/r/20240201010453.2212371-5-peter.hilber@opensynergy.com
arch/x86/kernel/kvmclock.c
drivers/ptp/ptp_kvm_common.c
include/linux/clocksource_ids.h

index 5bb395551c441ebc71c1e40ec355eac3f34dac69..2f1bbf730f455f2eb1f86ffa5efa4dc6c2599e36 100644 (file)
@@ -160,6 +160,7 @@ struct clocksource kvm_clock = {
        .rating = 400,
        .mask   = CLOCKSOURCE_MASK(64),
        .flags  = CLOCK_SOURCE_IS_CONTINUOUS,
+       .id     = CSID_X86_KVM_CLK,
        .enable = kvm_cs_enable,
 };
 EXPORT_SYMBOL_GPL(kvm_clock);
index 2418977989beb420a9587d9c013e61b950d09b85..b0b36f135347cb6b10c96502c2f733c1afe4d252 100644 (file)
@@ -4,6 +4,7 @@
  *
  * Copyright (C) 2017 Red Hat Inc.
  */
+#include <linux/clocksource.h>
 #include <linux/device.h>
 #include <linux/err.h>
 #include <linux/init.h>
@@ -47,6 +48,7 @@ static int ptp_kvm_get_time_fn(ktime_t *device_time,
 
        system_counter->cycles = cycle;
        system_counter->cs = cs;
+       system_counter->cs_id = cs->id;
 
        *device_time = timespec64_to_ktime(tspec);
 
index f8467946e9ee8ca97954211c8cfe3030213452c3..a4fa3436940c8fc9f5ab58884b890c6fa4a5a721 100644 (file)
@@ -8,6 +8,7 @@ enum clocksource_ids {
        CSID_ARM_ARCH_COUNTER,
        CSID_X86_TSC_EARLY,
        CSID_X86_TSC,
+       CSID_X86_KVM_CLK,
        CSID_MAX,
 };