2024-02-01 01:09:43

by Peter Hilber

[permalink] [raw]
Subject: [PATCH v3 2/8] timekeeping: Add clocksource ID to struct system_counterval_t

Clocksource pointers can be problematic to obtain for drivers which are not
clocksource drivers themselves. In particular, the RFC virtio_rtc driver
[1] would require a new helper function to obtain a pointer to the Arm
Generic Timer clocksource. The ptp_kvm driver also required a similar
workaround.

Add a clocksource ID member to struct system_counterval_t, which in the
future shall identify the clocksource, and which shall replace the struct
clocksource * member. By this, get_device_system_crosststamp() callers
(such as virtio_rtc and ptp_kvm) will be able to supply easily accessible
clocksource ids instead of clocksource pointers.

[1] https://lore.kernel.org/lkml/[email protected]/

Signed-off-by: Peter Hilber <[email protected]>
---

Notes:
v2:

- Refer to clocksource IDs as such in comments (Thomas Gleixner).

include/linux/timekeeping.h | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/include/linux/timekeeping.h b/include/linux/timekeeping.h
index 7c43e98cf211..ca234fa4cc04 100644
--- a/include/linux/timekeeping.h
+++ b/include/linux/timekeeping.h
@@ -273,10 +273,15 @@ struct system_device_crosststamp {
* @cycles: System counter value
* @cs: Clocksource corresponding to system counter value. Used by
* timekeeping code to verify comparibility of two cycle values
+ * @cs_id: Clocksource ID corresponding to system counter value. To be
+ * used instead of cs in the future.
+ * The default ID, CSID_GENERIC, does not identify a specific
+ * clocksource.
*/
struct system_counterval_t {
u64 cycles;
struct clocksource *cs;
+ enum clocksource_ids cs_id;
};

/*
--
2.40.1



2024-02-11 08:42:36

by tip-bot2 for Jacob Pan

[permalink] [raw]
Subject: [tip: timers/ptp] timekeeping: Add clocksource ID to struct system_counterval_t

The following commit has been merged into the timers/ptp branch of tip:

Commit-ID: 93630d6df7507fa4e664110b1878c06a0c00b0b9
Gitweb: https://git.kernel.org/tip/93630d6df7507fa4e664110b1878c06a0c00b0b9
Author: Peter Hilber <[email protected]>
AuthorDate: Thu, 01 Feb 2024 02:04:47 +01:00
Committer: Thomas Gleixner <[email protected]>
CommitterDate: Wed, 07 Feb 2024 17:05:21 +01:00

timekeeping: Add clocksource ID to struct system_counterval_t

Clocksource pointers can be problematic to obtain for drivers which are not
clocksource drivers themselves. In particular, the RFC virtio_rtc driver
[1] would require a new helper function to obtain a pointer to the ARM
Generic Timer clocksource. The ptp_kvm driver also required a similar
workaround.

Add a clocksource ID member to struct system_counterval_t, which in the
future shall identify the clocksource, and which shall replace the struct
clocksource * member. By this, get_device_system_crosststamp() callers
(such as virtio_rtc and ptp_kvm) will be able to supply easily accessible
clocksource ids instead of clocksource pointers.

[1] https://lore.kernel.org/lkml/[email protected]/

Signed-off-by: Peter Hilber <[email protected]>
Signed-off-by: Thomas Gleixner <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
---
include/linux/timekeeping.h | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/include/linux/timekeeping.h b/include/linux/timekeeping.h
index 7c43e98..ca234fa 100644
--- a/include/linux/timekeeping.h
+++ b/include/linux/timekeeping.h
@@ -273,10 +273,15 @@ struct system_device_crosststamp {
* @cycles: System counter value
* @cs: Clocksource corresponding to system counter value. Used by
* timekeeping code to verify comparibility of two cycle values
+ * @cs_id: Clocksource ID corresponding to system counter value. To be
+ * used instead of cs in the future.
+ * The default ID, CSID_GENERIC, does not identify a specific
+ * clocksource.
*/
struct system_counterval_t {
u64 cycles;
struct clocksource *cs;
+ enum clocksource_ids cs_id;
};

/*