PtP driver for s390 clocks
Subsystems (5)
Sven Schnelle
maintainercover PtP driver for s390 clocks
Hi,
these patches add support for using the s390 physical and TOD clock as ptp clock. To do so, the first patch adds a clock id to the s390 TOD clock, while the second patch adds the PtP driver itself.
Changes in v2:
- add missing MODULE_DESCRIPTION()
- drop udev event patch
- simplify eitod_to_ns()
- use store_tod_clock_ext() instead of store_tod_clock_ext_cc()
- move stp_enabled() declaration to stp.h
- use s390 instead of 'Z' in clock names
- defconfig symbol should be default-n
Sven Schnelle (2):
s390/time: Add clocksource id to TOD clock
s390/time: Add PtP driver
MAINTAINERS | 6 ++ arch/s390/include/asm/stp.h | 1 + arch/s390/include/asm/timex.h | 6 ++ arch/s390/kernel/time.c | 7 ++ drivers/ptp/Kconfig | 11 +++ drivers/ptp/Makefile | 1 + drivers/ptp/ptp_s390.c | 129 ++++++++++++++++++++++++++++++++ include/linux/clocksource_ids.h | 1 + 8 files changed, 162 insertions(+) create mode 100644 drivers/ptp/ptp_s390.c
Signature · 1 line
2.43.0
Sven Schnelle
maintainerPATCH 1/2 s390/time: Add clocksource id to TOD clock
To allow specifying the clock source in the upcoming PtP driver, add a clocksource ID to the s390 TOD clock.
--- arch/s390/kernel/time.c | 1 + include/linux/clocksource_ids.h | 1 + 2 files changed, 2 insertions(+)
arch/s390/kernel/time.c +1 -0
@@ -255,6 +255,7 @@ static struct clocksource clocksource_tod = { .shift = 24, .flags = CLOCK_SOURCE_IS_CONTINUOUS, .vdso_clock_mode = VDSO_CLOCKMODE_TOD, + .id = CSID_S390_TOD, };struct clocksource *__init clocksource_default_clock (void )
include/linux/clocksource_ids.h +1 -0
@@ -6,6 +6,7 @@enum clocksource_ids {CSID_GENERIC =0 ,CSID_ARM_ARCH_COUNTER , +CSID_S390_TOD ,CSID_X86_TSC_EARLY ,CSID_X86_TSC ,CSID_X86_KVM_CLK ,
Signature · 1 line
2.43.0
Sven Schnelle
maintainerPATCH 2/2 s390/time: Add PtP driver
In reply to Sven SchnelleAdd a small PtP driver which allows user space to get the values of the physical and tod clock. This allows programs like chrony to use STP as clock source and steer the kernel clock. The physical clock can be used as a debugging aid to get the clock without any additional offsets like STP steering or LPAR offset.
--- MAINTAINERS | 6 ++ arch/s390/include/asm/stp.h | 1 + arch/s390/include/asm/timex.h | 6 ++ arch/s390/kernel/time.c | 6 ++ drivers/ptp/Kconfig | 11 +++ drivers/ptp/Makefile | 1 + drivers/ptp/ptp_s390.c | 129 ++++++++++++++++++++++++++++++++++ 7 files changed, 160 insertions(+) create mode 100644 drivers/ptp/ptp_s390.c
MAINTAINERS +6 -0
@@ -20328,6 +20328,12 @@ F: Documentation/arch/s390/pci.rst F: arch/s390/pci/ F: drivers/pci/hotplug/s390_pci_hpc.c +S390 PTP DRIVER +M: Sven Schnelle <[email protected]> +L: [email protected] +S: Supported +F: drivers/ptp/ptp_s390.c + S390 SCM DRIVER M: Vineeth Vijayan <[email protected]> L: [email protected]
arch/s390/include/asm/stp.h +1 -0
@@ -94,5 +94,6 @@ struct stp_stzi {int stp_sync_check (void );int stp_island_check (void );void stp_queue_work (void ); +bool stp_enabled (void );#endif /* __S390_STP_H */
arch/s390/include/asm/timex.h +6 -0
@@ -93,6 +93,7 @@ extern unsigned char ptff_function_mask[16];#define PTFF_QAF 0x00/* query available functions */ #define PTFF_QTO 0x01/* query tod offset */ #define PTFF_QSI 0x02/* query steering information */ +#define PTFF_QPT 0x03/* query physical clock */ #define PTFF_QUI 0x04/* query UTC information */ #define PTFF_ATO 0x40/* adjust tod offset */ #define PTFF_STO 0x41/* set tod offset */
@@ -250,6 +251,11 @@ static __always_inline unsigned long tod_to_ns(unsigned long todval)return ((todval >>9 ) *125 ) + (((todval &0x1ff ) *125 ) >>9 ); } +static __always_inline unsigned long eitod_to_ns (u128 todval) +{ +return (todval *125 ) >>9 ; +} +/** * tod_after - compare two 64 bit TOD values * @a: first 64 bit TOD timestamp
arch/s390/kernel/time.c +6 -0
@@ -469,6 +469,12 @@ static void __init stp_reset(void) } } +bool stp_enabled (void ) +{ +return test_bit (CLOCK_SYNC_HAS_STP , &clock_sync_flags) && stp_online; +} +EXPORT_SYMBOL (stp_enabled); +static void stp_timeout (struct timer_list *unused) {queue_work (time_sync_wq, &stp_work);
drivers/ptp/Kconfig +11 -0
@@ -224,4 +224,15 @@ config PTP_DFL_TOD To compile this driver as a module, choose M here: the module will be called ptp_dfl_tod. +config PTP_S390 + tristate "S390 PTP driver" + depends on PTP_1588_CLOCK + depends on S390 + help + This driver adds support for S390 time steering via the PtP + interface. This works by adding a in-kernel clock delta value, + which is always added to time values used in the kernel. The PtP + driver provides the raw clock value without the delta to + userspace. That way userspace programs like chrony could steer + the kernel clock. endmenu
drivers/ptp/Makefile +1 -0
@@ -21,3 +21,4 @@ obj-$(CONFIG_PTP_1588_CLOCK_MOCK) += ptp_mock.o obj-$(CONFIG_PTP_1588_CLOCK_VMW) += ptp_vmw.o obj-$(CONFIG_PTP_1588_CLOCK_OCP) += ptp_ocp.o obj-$(CONFIG_PTP_DFL_TOD) += ptp_dfl_tod.o +obj-$(CONFIG_PTP_S390) += ptp_s390.o
drivers/ptp/ptp_s390.c new file +129 -0
129 lines not on this page · raw message
Signature · 1 line
2.43.0