Skip to content

Commit e2ef167

Browse files
quic-philbermstsirkin
authored andcommitted
virtio_rtc: Add Arm Generic Timer cross-timestamping
For platforms using the Arm Generic Timer, add precise cross-timestamping support to virtio_rtc. Always report the CP15 virtual counter as the HW counter in use by arm_arch_timer, since the Linux kernel's usage of the Arm Generic Timer should always be compatible with this. Signed-off-by: Peter Hilber <quic_philber@quicinc.com> Message-Id: <20250509160734.1772-4-quic_philber@quicinc.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
1 parent 9a17125 commit e2ef167

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

drivers/virtio/Kconfig

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,19 @@ config VIRTIO_RTC_PTP
221221

222222
If unsure, say Y.
223223

224+
config VIRTIO_RTC_ARM
225+
bool "Virtio RTC cross-timestamping using Arm Generic Timer"
226+
default y
227+
depends on VIRTIO_RTC_PTP && ARM_ARCH_TIMER
228+
help
229+
This enables Virtio RTC cross-timestamping using the Arm Generic Timer.
230+
It only has an effect if the Virtio RTC device also supports this. The
231+
cross-timestamp is available through the PTP clock driver precise
232+
cross-timestamp ioctl (PTP_SYS_OFFSET_PRECISE2 aka
233+
PTP_SYS_OFFSET_PRECISE).
234+
235+
If unsure, say Y.
236+
224237
endif # VIRTIO_RTC
225238

226239
endif # VIRTIO_MENU

drivers/virtio/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,4 @@ obj-$(CONFIG_VIRTIO_DEBUG) += virtio_debug.o
1717
obj-$(CONFIG_VIRTIO_RTC) += virtio_rtc.o
1818
virtio_rtc-y := virtio_rtc_driver.o
1919
virtio_rtc-$(CONFIG_VIRTIO_RTC_PTP) += virtio_rtc_ptp.o
20+
virtio_rtc-$(CONFIG_VIRTIO_RTC_ARM) += virtio_rtc_arm.o

drivers/virtio/virtio_rtc_arm.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// SPDX-License-Identifier: GPL-2.0-or-later
2+
/*
3+
* Provides cross-timestamp params for Arm.
4+
*
5+
* Copyright (C) 2022-2023 OpenSynergy GmbH
6+
* Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved.
7+
*/
8+
9+
#include <linux/clocksource_ids.h>
10+
11+
#include <uapi/linux/virtio_rtc.h>
12+
13+
#include "virtio_rtc_internal.h"
14+
15+
/* see header for doc */
16+
17+
int viortc_hw_xtstamp_params(u8 *hw_counter, enum clocksource_ids *cs_id)
18+
{
19+
*hw_counter = VIRTIO_RTC_COUNTER_ARM_VCT;
20+
*cs_id = CSID_ARM_ARCH_COUNTER;
21+
22+
return 0;
23+
}

0 commit comments

Comments
 (0)