Skip to content

Commit 576bd49

Browse files
x86/kvm, ptp/kvm: Add clocksource ID, set system_counterval_t.cs_id
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
1 parent a2c1fe7 commit 576bd49

File tree

3 files changed

+4
-0
lines changed

3 files changed

+4
-0
lines changed

arch/x86/kernel/kvmclock.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ struct clocksource kvm_clock = {
160160
.rating = 400,
161161
.mask = CLOCKSOURCE_MASK(64),
162162
.flags = CLOCK_SOURCE_IS_CONTINUOUS,
163+
.id = CSID_X86_KVM_CLK,
163164
.enable = kvm_cs_enable,
164165
};
165166
EXPORT_SYMBOL_GPL(kvm_clock);

drivers/ptp/ptp_kvm_common.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*
55
* Copyright (C) 2017 Red Hat Inc.
66
*/
7+
#include <linux/clocksource.h>
78
#include <linux/device.h>
89
#include <linux/err.h>
910
#include <linux/init.h>
@@ -47,6 +48,7 @@ static int ptp_kvm_get_time_fn(ktime_t *device_time,
4748

4849
system_counter->cycles = cycle;
4950
system_counter->cs = cs;
51+
system_counter->cs_id = cs->id;
5052

5153
*device_time = timespec64_to_ktime(tspec);
5254

include/linux/clocksource_ids.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ enum clocksource_ids {
88
CSID_ARM_ARCH_COUNTER,
99
CSID_X86_TSC_EARLY,
1010
CSID_X86_TSC,
11+
CSID_X86_KVM_CLK,
1112
CSID_MAX,
1213
};
1314

0 commit comments

Comments
 (0)