* [PATCH 1/3] s390/time: Add clocksource id to TOD clock [not found] <20241015084728.1833876-1-svens@linux.ibm.com> @ 2024-10-15 8:47 ` Sven Schnelle 2024-10-15 8:47 ` [PATCH 2/3] ptp: Add clock name to uevent Sven Schnelle 2024-10-15 8:47 ` [PATCH 3/3] s390/time: Add PtP driver Sven Schnelle 2 siblings, 0 replies; 12+ messages in thread From: Sven Schnelle @ 2024-10-15 8:47 UTC (permalink / raw) To: Heiko Carstens, Vasily Gorbik, Alexander Gordeev, Christian Borntraeger Cc: linux-s390, Yangbo Lu, linux-kernel To allow specifying the clock source in the upcoming PtP driver, add a clocksource ID to the s390 TOD clock. Signed-off-by: Sven Schnelle <svens@linux.ibm.com> --- arch/s390/kernel/time.c | 1 + include/linux/clocksource_ids.h | 1 + 2 files changed, 2 insertions(+) diff --git a/arch/s390/kernel/time.c b/arch/s390/kernel/time.c index b713effe0579..4214901c3ab0 100644 --- a/arch/s390/kernel/time.c +++ b/arch/s390/kernel/time.c @@ -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) diff --git a/include/linux/clocksource_ids.h b/include/linux/clocksource_ids.h index 2bb4d8c2f1b0..c4ef4ae2eded 100644 --- a/include/linux/clocksource_ids.h +++ b/include/linux/clocksource_ids.h @@ -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, -- 2.43.0 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 2/3] ptp: Add clock name to uevent [not found] <20241015084728.1833876-1-svens@linux.ibm.com> 2024-10-15 8:47 ` [PATCH 1/3] s390/time: Add clocksource id to TOD clock Sven Schnelle @ 2024-10-15 8:47 ` Sven Schnelle 2024-10-15 12:43 ` Andrew Lunn 2024-10-15 8:47 ` [PATCH 3/3] s390/time: Add PtP driver Sven Schnelle 2 siblings, 1 reply; 12+ messages in thread From: Sven Schnelle @ 2024-10-15 8:47 UTC (permalink / raw) To: Richard Cochran; +Cc: linux-s390, Yangbo Lu, netdev, linux-kernel To allow users to have stable device names with the help of udev, add the name to the udev event that is sent when a new PtP clock is available. The key is called 'PTP_CLOCK_NAME'. Signed-off-by: Sven Schnelle <svens@linux.ibm.com> --- drivers/ptp/ptp_clock.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/ptp/ptp_clock.c b/drivers/ptp/ptp_clock.c index c56cd0f63909..15937acb79c6 100644 --- a/drivers/ptp/ptp_clock.c +++ b/drivers/ptp/ptp_clock.c @@ -25,9 +25,11 @@ #define PTP_PPS_EVENT PPS_CAPTUREASSERT #define PTP_PPS_MODE (PTP_PPS_DEFAULTS | PPS_CANWAIT | PPS_TSFMT_TSPEC) +static int ptp_udev_uevent(const struct device *dev, struct kobj_uevent_env *env); const struct class ptp_class = { .name = "ptp", - .dev_groups = ptp_groups + .dev_groups = ptp_groups, + .dev_uevent = ptp_udev_uevent }; /* private globals */ @@ -514,6 +516,13 @@ EXPORT_SYMBOL(ptp_cancel_worker_sync); /* module operations */ +static int ptp_udev_uevent(const struct device *dev, struct kobj_uevent_env *env) +{ + struct ptp_clock *ptp = container_of(dev, struct ptp_clock, dev); + + return add_uevent_var(env, "PTP_CLOCK_NAME=%s", ptp->info->name); +} + static void __exit ptp_exit(void) { class_unregister(&ptp_class); -- 2.43.0 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH 2/3] ptp: Add clock name to uevent 2024-10-15 8:47 ` [PATCH 2/3] ptp: Add clock name to uevent Sven Schnelle @ 2024-10-15 12:43 ` Andrew Lunn 2024-10-16 3:38 ` Richard Cochran 0 siblings, 1 reply; 12+ messages in thread From: Andrew Lunn @ 2024-10-15 12:43 UTC (permalink / raw) To: Sven Schnelle Cc: Richard Cochran, linux-s390, Yangbo Lu, netdev, linux-kernel > > +static int ptp_udev_uevent(const struct device *dev, struct kobj_uevent_env *env); No forward declarations please. Put the code in the correct order. > const struct class ptp_class = { > .name = "ptp", > - .dev_groups = ptp_groups > + .dev_groups = ptp_groups, > + .dev_uevent = ptp_udev_uevent > }; > > /* private globals */ > @@ -514,6 +516,13 @@ EXPORT_SYMBOL(ptp_cancel_worker_sync); > > /* module operations */ > > +static int ptp_udev_uevent(const struct device *dev, struct kobj_uevent_env *env) > +{ > + struct ptp_clock *ptp = container_of(dev, struct ptp_clock, dev); > + > + return add_uevent_var(env, "PTP_CLOCK_NAME=%s", ptp->info->name); > +} https://elixir.bootlin.com/linux/v6.11.3/source/include/linux/ptp_clock_kernel.h#L60 * @name: A short "friendly name" to identify the clock and to * help distinguish PHY based devices from MAC based ones. * The string is not meant to be a unique id. If the name is not unique, you probably should not be using it for udev naming. Andrew ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 2/3] ptp: Add clock name to uevent 2024-10-15 12:43 ` Andrew Lunn @ 2024-10-16 3:38 ` Richard Cochran 2024-10-16 5:20 ` Sven Schnelle 0 siblings, 1 reply; 12+ messages in thread From: Richard Cochran @ 2024-10-16 3:38 UTC (permalink / raw) To: Andrew Lunn; +Cc: Sven Schnelle, linux-s390, Yangbo Lu, netdev, linux-kernel On Tue, Oct 15, 2024 at 02:43:28PM +0200, Andrew Lunn wrote: > * @name: A short "friendly name" to identify the clock and to > * help distinguish PHY based devices from MAC based ones. > * The string is not meant to be a unique id. > > If the name is not unique, you probably should not be using it for > udev naming. +1 Maybe the name is unique for s390, but it will not be in general. Thanks, Richard ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 2/3] ptp: Add clock name to uevent 2024-10-16 3:38 ` Richard Cochran @ 2024-10-16 5:20 ` Sven Schnelle 0 siblings, 0 replies; 12+ messages in thread From: Sven Schnelle @ 2024-10-16 5:20 UTC (permalink / raw) To: Richard Cochran; +Cc: Andrew Lunn, linux-s390, Yangbo Lu, netdev, linux-kernel Richard Cochran <richardcochran@gmail.com> writes: > On Tue, Oct 15, 2024 at 02:43:28PM +0200, Andrew Lunn wrote: >> * @name: A short "friendly name" to identify the clock and to >> * help distinguish PHY based devices from MAC based ones. >> * The string is not meant to be a unique id. >> >> If the name is not unique, you probably should not be using it for >> udev naming. > > +1 > > Maybe the name is unique for s390, but it will not be in general. As already written to Greg, i will drop this Patch. The name is unique, i was just not aware that the clock_name attribute is present in sysfs. ^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 3/3] s390/time: Add PtP driver [not found] <20241015084728.1833876-1-svens@linux.ibm.com> 2024-10-15 8:47 ` [PATCH 1/3] s390/time: Add clocksource id to TOD clock Sven Schnelle 2024-10-15 8:47 ` [PATCH 2/3] ptp: Add clock name to uevent Sven Schnelle @ 2024-10-15 8:47 ` Sven Schnelle 2024-10-15 22:13 ` Jeff Johnson 2 siblings, 1 reply; 12+ messages in thread From: Sven Schnelle @ 2024-10-15 8:47 UTC (permalink / raw) To: Heiko Carstens, Vasily Gorbik, Alexander Gordeev, Christian Borntraeger, Richard Cochran Cc: linux-s390, Yangbo Lu, linux-kernel, netdev Add 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. Signed-off-by: Sven Schnelle <svens@linux.ibm.com> --- MAINTAINERS | 6 ++ arch/s390/include/asm/timex.h | 8 +++ arch/s390/kernel/time.c | 7 ++ drivers/ptp/Kconfig | 11 +++ drivers/ptp/Makefile | 1 + drivers/ptp/ptp_s390.c | 127 ++++++++++++++++++++++++++++++++++ 6 files changed, 160 insertions(+) create mode 100644 drivers/ptp/ptp_s390.c diff --git a/MAINTAINERS b/MAINTAINERS index 7ad507f49324..94793c935e86 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -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 <svens@linux.ibm.com> +L: linux-s390@vger.kernel.org +S: Supported +F: drivers/ptp/ptp_s390.c + S390 SCM DRIVER M: Vineeth Vijayan <vneethv@linux.ibm.com> L: linux-s390@vger.kernel.org diff --git a/arch/s390/include/asm/timex.h b/arch/s390/include/asm/timex.h index 640901f2fbc3..4fc88a1493f0 100644 --- a/arch/s390/include/asm/timex.h +++ b/arch/s390/include/asm/timex.h @@ -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,12 @@ 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(union tod_clock *clk) +{ + clk->eitod -= TOD_UNIX_EPOCH; + return ((clk->eitod >> 9) * 125) + (((clk->eitod & 0x1ff) * 125) >> 9); +} + /** * tod_after - compare two 64 bit TOD values * @a: first 64 bit TOD timestamp @@ -278,4 +285,5 @@ static inline int tod_after_eq(unsigned long a, unsigned long b) return a >= b; } +bool stp_enabled(void); #endif diff --git a/arch/s390/kernel/time.c b/arch/s390/kernel/time.c index 4214901c3ab0..47b20235953c 100644 --- a/arch/s390/kernel/time.c +++ b/arch/s390/kernel/time.c @@ -469,6 +469,13 @@ 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); diff --git a/drivers/ptp/Kconfig b/drivers/ptp/Kconfig index 604541dcb320..907330413ef8 100644 --- a/drivers/ptp/Kconfig +++ b/drivers/ptp/Kconfig @@ -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 + default y + 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 diff --git a/drivers/ptp/Makefile b/drivers/ptp/Makefile index 68bf02078053..4dd9f35eb0cf 100644 --- a/drivers/ptp/Makefile +++ b/drivers/ptp/Makefile @@ -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 diff --git a/drivers/ptp/ptp_s390.c b/drivers/ptp/ptp_s390.c new file mode 100644 index 000000000000..4edccebcf2b5 --- /dev/null +++ b/drivers/ptp/ptp_s390.c @@ -0,0 +1,126 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * s390 PTP clock driver + * + */ + +#include "ptp_private.h" +#include <linux/time.h> +static struct ptp_clock *ptp_stcke_clock, *ptp_qpt_clock; + +static int ptp_s390_adjfine(struct ptp_clock_info *ptp, long scaled_ppm) +{ + return -EOPNOTSUPP; +} + +static int ptp_s390_adjtime(struct ptp_clock_info *ptp, s64 delta) +{ + return -EOPNOTSUPP; +} + +static struct timespec64 eitod_to_timespec64(union tod_clock *clk) +{ + return ns_to_timespec64(eitod_to_ns(clk)); +} + +static struct timespec64 tod_to_timespec64(unsigned long tod) +{ + return ns_to_timespec64(tod_to_ns(tod - TOD_UNIX_EPOCH)); +} + +static int ptp_s390_stcke_gettime(struct ptp_clock_info *ptp, + struct timespec64 *ts) +{ + union tod_clock tod; + + if (!stp_enabled()) + return -EOPNOTSUPP; + + store_tod_clock_ext_cc(&tod); + *ts = eitod_to_timespec64(&tod); + return 0; +} + +static int ptp_s390_qpt_gettime(struct ptp_clock_info *ptp, + struct timespec64 *ts) +{ + unsigned long tod; + + ptff(&tod, sizeof(tod), PTFF_QPT); + *ts = tod_to_timespec64(tod); + return 0; +} + +static int ptp_s390_settime(struct ptp_clock_info *ptp, + const struct timespec64 *ts) +{ + return -EOPNOTSUPP; +} + +static int s390_arch_ptp_get_crosststamp(ktime_t *device_time, + struct system_counterval_t *system_counter, + void *ctx) +{ + union tod_clock clk; + + store_tod_clock_ext_cc(&clk); + *device_time = ns_to_ktime(tod_to_ns(clk.tod - TOD_UNIX_EPOCH)); + system_counter->cycles = clk.tod; + system_counter->cs_id = CSID_S390_TOD; + return 0; +} + +static int ptp_s390_getcrosststamp(struct ptp_clock_info *ptp, + struct system_device_crosststamp *xtstamp) +{ + if (!stp_enabled()) + return -EOPNOTSUPP; + return get_device_system_crosststamp(s390_arch_ptp_get_crosststamp, NULL, NULL, xtstamp); +} + +static struct ptp_clock_info ptp_s390_stcke_info = { + .owner = THIS_MODULE, + .name = "IBM Z STCKE Clock", + .max_adj = 0, + .adjfine = ptp_s390_adjfine, + .adjtime = ptp_s390_adjtime, + .gettime64 = ptp_s390_stcke_gettime, + .settime64 = ptp_s390_settime, + .getcrosststamp = ptp_s390_getcrosststamp, +}; + +static struct ptp_clock_info ptp_s390_qpt_info = { + .owner = THIS_MODULE, + .name = "IBM Z Physical Clock", + .max_adj = 0, + .adjfine = ptp_s390_adjfine, + .adjtime = ptp_s390_adjtime, + .gettime64 = ptp_s390_qpt_gettime, + .settime64 = ptp_s390_settime, +}; + +static __init int ptp_s390_init(void) +{ + ptp_stcke_clock = ptp_clock_register(&ptp_s390_stcke_info, NULL); + if (IS_ERR(ptp_stcke_clock)) + return PTR_ERR(ptp_stcke_clock); + + ptp_qpt_clock = ptp_clock_register(&ptp_s390_qpt_info, NULL); + if (IS_ERR(ptp_qpt_clock)) { + ptp_clock_unregister(ptp_stcke_clock); + return PTR_ERR(ptp_qpt_clock); + } + return 0; +} + +static __exit void ptp_s390_exit(void) +{ + ptp_clock_unregister(ptp_qpt_clock); + ptp_clock_unregister(ptp_stcke_clock); +} + +module_init(ptp_s390_init); +module_exit(ptp_s390_exit); + +MODULE_AUTHOR("Sven Schnelle <svens@linux.ibm.com>"); +MODULE_LICENSE("GPL"); -- 2.43.0 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH 3/3] s390/time: Add PtP driver 2024-10-15 8:47 ` [PATCH 3/3] s390/time: Add PtP driver Sven Schnelle @ 2024-10-15 22:13 ` Jeff Johnson 0 siblings, 0 replies; 12+ messages in thread From: Jeff Johnson @ 2024-10-15 22:13 UTC (permalink / raw) To: Sven Schnelle, Heiko Carstens, Vasily Gorbik, Alexander Gordeev, Christian Borntraeger, Richard Cochran Cc: linux-s390, Yangbo Lu, linux-kernel, netdev On 10/15/24 01:47, Sven Schnelle wrote: ... > +module_init(ptp_s390_init); > +module_exit(ptp_s390_exit); > + > +MODULE_AUTHOR("Sven Schnelle <svens@linux.ibm.com>"); > +MODULE_LICENSE("GPL"); Since commit 1fffe7a34c89 ("script: modpost: emit a warning when the description is missing"), a module without a MODULE_DESCRIPTION() will result in a warning when built with make W=1. Recently, multiple developers have been eradicating these warnings treewide, and very few (if any) are left, so please don't introduce a new one :) Please add the missing MODULE_DESCRIPTION() /jeff ^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH RESEND 0/3] PtP driver for s390 clocks @ 2024-10-15 10:54 Sven Schnelle 2024-10-15 10:54 ` [PATCH 2/3] ptp: Add clock name to uevent Sven Schnelle 0 siblings, 1 reply; 12+ messages in thread From: Sven Schnelle @ 2024-10-15 10:54 UTC (permalink / raw) To: Heiko Carstens, Vasily Gorbik, Alexander Gordeev, Christian Borntraeger, Sven Schnelle, Richard Cochran, Greg Kroah-Hartman, Ricardo B. Marliere Cc: linux-kernel, linux-s390, netdev 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. The second patch adds sending a udev event when a ptp device is added, so that userspace is able to generate stable device names for virtual ptp devices. The last patch adds the PtP driver itself. Sven Schnelle (3): s390/time: Add clocksource id to TOD clock ptp: Add clock name to uevent s390/time: Add PtP driver MAINTAINERS | 6 ++ arch/s390/include/asm/timex.h | 8 ++ arch/s390/kernel/time.c | 8 ++ drivers/ptp/Kconfig | 11 +++ drivers/ptp/Makefile | 1 + drivers/ptp/ptp_clock.c | 11 ++- drivers/ptp/ptp_s390.c | 127 ++++++++++++++++++++++++++++++++ include/linux/clocksource_ids.h | 1 + 8 files changed, 172 insertions(+), 1 deletion(-) create mode 100644 drivers/ptp/ptp_s390.c -- 2.43.0 ^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 2/3] ptp: Add clock name to uevent 2024-10-15 10:54 [PATCH RESEND 0/3] PtP driver for s390 clocks Sven Schnelle @ 2024-10-15 10:54 ` Sven Schnelle 2024-10-15 10:59 ` Greg Kroah-Hartman 0 siblings, 1 reply; 12+ messages in thread From: Sven Schnelle @ 2024-10-15 10:54 UTC (permalink / raw) To: Heiko Carstens, Vasily Gorbik, Alexander Gordeev, Christian Borntraeger, Sven Schnelle, Richard Cochran, Greg Kroah-Hartman, Ricardo B. Marliere Cc: linux-kernel, linux-s390, netdev To allow users to have stable device names with the help of udev, add the name to the udev event that is sent when a new PtP clock is available. The key is called 'PTP_CLOCK_NAME'. Signed-off-by: Sven Schnelle <svens@linux.ibm.com> --- drivers/ptp/ptp_clock.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/ptp/ptp_clock.c b/drivers/ptp/ptp_clock.c index c56cd0f63909..15937acb79c6 100644 --- a/drivers/ptp/ptp_clock.c +++ b/drivers/ptp/ptp_clock.c @@ -25,9 +25,11 @@ #define PTP_PPS_EVENT PPS_CAPTUREASSERT #define PTP_PPS_MODE (PTP_PPS_DEFAULTS | PPS_CANWAIT | PPS_TSFMT_TSPEC) +static int ptp_udev_uevent(const struct device *dev, struct kobj_uevent_env *env); const struct class ptp_class = { .name = "ptp", - .dev_groups = ptp_groups + .dev_groups = ptp_groups, + .dev_uevent = ptp_udev_uevent }; /* private globals */ @@ -514,6 +516,13 @@ EXPORT_SYMBOL(ptp_cancel_worker_sync); /* module operations */ +static int ptp_udev_uevent(const struct device *dev, struct kobj_uevent_env *env) +{ + struct ptp_clock *ptp = container_of(dev, struct ptp_clock, dev); + + return add_uevent_var(env, "PTP_CLOCK_NAME=%s", ptp->info->name); +} + static void __exit ptp_exit(void) { class_unregister(&ptp_class); -- 2.43.0 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH 2/3] ptp: Add clock name to uevent 2024-10-15 10:54 ` [PATCH 2/3] ptp: Add clock name to uevent Sven Schnelle @ 2024-10-15 10:59 ` Greg Kroah-Hartman 2024-10-15 12:02 ` Sven Schnelle 0 siblings, 1 reply; 12+ messages in thread From: Greg Kroah-Hartman @ 2024-10-15 10:59 UTC (permalink / raw) To: Sven Schnelle Cc: Heiko Carstens, Vasily Gorbik, Alexander Gordeev, Christian Borntraeger, Richard Cochran, Ricardo B. Marliere, linux-kernel, linux-s390, netdev On Tue, Oct 15, 2024 at 12:54:13PM +0200, Sven Schnelle wrote: > To allow users to have stable device names with the help of udev, > add the name to the udev event that is sent when a new PtP clock > is available. The key is called 'PTP_CLOCK_NAME'. Where are you documenting this new user/kernel api you are adding? > > Signed-off-by: Sven Schnelle <svens@linux.ibm.com> > --- > drivers/ptp/ptp_clock.c | 11 ++++++++++- > 1 file changed, 10 insertions(+), 1 deletion(-) > > diff --git a/drivers/ptp/ptp_clock.c b/drivers/ptp/ptp_clock.c > index c56cd0f63909..15937acb79c6 100644 > --- a/drivers/ptp/ptp_clock.c > +++ b/drivers/ptp/ptp_clock.c > @@ -25,9 +25,11 @@ > #define PTP_PPS_EVENT PPS_CAPTUREASSERT > #define PTP_PPS_MODE (PTP_PPS_DEFAULTS | PPS_CANWAIT | PPS_TSFMT_TSPEC) > > +static int ptp_udev_uevent(const struct device *dev, struct kobj_uevent_env *env); > const struct class ptp_class = { > .name = "ptp", > - .dev_groups = ptp_groups > + .dev_groups = ptp_groups, > + .dev_uevent = ptp_udev_uevent > }; > > /* private globals */ > @@ -514,6 +516,13 @@ EXPORT_SYMBOL(ptp_cancel_worker_sync); > > /* module operations */ > > +static int ptp_udev_uevent(const struct device *dev, struct kobj_uevent_env *env) > +{ > + struct ptp_clock *ptp = container_of(dev, struct ptp_clock, dev); > + > + return add_uevent_var(env, "PTP_CLOCK_NAME=%s", ptp->info->name); Why is this needed? Can't you get the name from the sysfs paths, the symlink should be there already. thanks, greg k-h ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 2/3] ptp: Add clock name to uevent 2024-10-15 10:59 ` Greg Kroah-Hartman @ 2024-10-15 12:02 ` Sven Schnelle 2024-10-15 12:16 ` Greg Kroah-Hartman 0 siblings, 1 reply; 12+ messages in thread From: Sven Schnelle @ 2024-10-15 12:02 UTC (permalink / raw) To: Greg Kroah-Hartman Cc: Heiko Carstens, Vasily Gorbik, Alexander Gordeev, Christian Borntraeger, Richard Cochran, Ricardo B. Marliere, linux-kernel, linux-s390, netdev Greg Kroah-Hartman <gregkh@linuxfoundation.org> writes: > On Tue, Oct 15, 2024 at 12:54:13PM +0200, Sven Schnelle wrote: >> To allow users to have stable device names with the help of udev, >> add the name to the udev event that is sent when a new PtP clock >> is available. The key is called 'PTP_CLOCK_NAME'. > > Where are you documenting this new user/kernel api you are adding? > >> >> Signed-off-by: Sven Schnelle <svens@linux.ibm.com> >> --- >> drivers/ptp/ptp_clock.c | 11 ++++++++++- >> 1 file changed, 10 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/ptp/ptp_clock.c b/drivers/ptp/ptp_clock.c >> index c56cd0f63909..15937acb79c6 100644 >> --- a/drivers/ptp/ptp_clock.c >> +++ b/drivers/ptp/ptp_clock.c >> @@ -25,9 +25,11 @@ >> #define PTP_PPS_EVENT PPS_CAPTUREASSERT >> #define PTP_PPS_MODE (PTP_PPS_DEFAULTS | PPS_CANWAIT | PPS_TSFMT_TSPEC) >> >> +static int ptp_udev_uevent(const struct device *dev, struct kobj_uevent_env *env); >> const struct class ptp_class = { >> .name = "ptp", >> - .dev_groups = ptp_groups >> + .dev_groups = ptp_groups, >> + .dev_uevent = ptp_udev_uevent >> }; >> >> /* private globals */ >> @@ -514,6 +516,13 @@ EXPORT_SYMBOL(ptp_cancel_worker_sync); >> >> /* module operations */ >> >> +static int ptp_udev_uevent(const struct device *dev, struct kobj_uevent_env *env) >> +{ >> + struct ptp_clock *ptp = container_of(dev, struct ptp_clock, dev); >> + >> + return add_uevent_var(env, "PTP_CLOCK_NAME=%s", ptp->info->name); > > Why is this needed? Can't you get the name from the sysfs paths, the > symlink should be there already. You mean the 'clock_name' attribute in sysfs? That would require to write some script to iterate over all ptp devices and check the name, or is there a way to match that in udev? ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 2/3] ptp: Add clock name to uevent 2024-10-15 12:02 ` Sven Schnelle @ 2024-10-15 12:16 ` Greg Kroah-Hartman 2024-10-15 12:19 ` Sven Schnelle 0 siblings, 1 reply; 12+ messages in thread From: Greg Kroah-Hartman @ 2024-10-15 12:16 UTC (permalink / raw) To: Sven Schnelle Cc: Heiko Carstens, Vasily Gorbik, Alexander Gordeev, Christian Borntraeger, Richard Cochran, Ricardo B. Marliere, linux-kernel, linux-s390, netdev On Tue, Oct 15, 2024 at 02:02:17PM +0200, Sven Schnelle wrote: > Greg Kroah-Hartman <gregkh@linuxfoundation.org> writes: > > > On Tue, Oct 15, 2024 at 12:54:13PM +0200, Sven Schnelle wrote: > >> To allow users to have stable device names with the help of udev, > >> add the name to the udev event that is sent when a new PtP clock > >> is available. The key is called 'PTP_CLOCK_NAME'. > > > > Where are you documenting this new user/kernel api you are adding? > > > >> > >> Signed-off-by: Sven Schnelle <svens@linux.ibm.com> > >> --- > >> drivers/ptp/ptp_clock.c | 11 ++++++++++- > >> 1 file changed, 10 insertions(+), 1 deletion(-) > >> > >> diff --git a/drivers/ptp/ptp_clock.c b/drivers/ptp/ptp_clock.c > >> index c56cd0f63909..15937acb79c6 100644 > >> --- a/drivers/ptp/ptp_clock.c > >> +++ b/drivers/ptp/ptp_clock.c > >> @@ -25,9 +25,11 @@ > >> #define PTP_PPS_EVENT PPS_CAPTUREASSERT > >> #define PTP_PPS_MODE (PTP_PPS_DEFAULTS | PPS_CANWAIT | PPS_TSFMT_TSPEC) > >> > >> +static int ptp_udev_uevent(const struct device *dev, struct kobj_uevent_env *env); > >> const struct class ptp_class = { > >> .name = "ptp", > >> - .dev_groups = ptp_groups > >> + .dev_groups = ptp_groups, > >> + .dev_uevent = ptp_udev_uevent > >> }; > >> > >> /* private globals */ > >> @@ -514,6 +516,13 @@ EXPORT_SYMBOL(ptp_cancel_worker_sync); > >> > >> /* module operations */ > >> > >> +static int ptp_udev_uevent(const struct device *dev, struct kobj_uevent_env *env) > >> +{ > >> + struct ptp_clock *ptp = container_of(dev, struct ptp_clock, dev); > >> + > >> + return add_uevent_var(env, "PTP_CLOCK_NAME=%s", ptp->info->name); > > > > Why is this needed? Can't you get the name from the sysfs paths, the > > symlink should be there already. > > You mean the 'clock_name' attribute in sysfs? Great, yes, it's right there. > That would require to > write some script to iterate over all ptp devices and check the name, > or is there a way to match that in udev? Yes there is. Please use that :) thanks, greg k-h ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 2/3] ptp: Add clock name to uevent 2024-10-15 12:16 ` Greg Kroah-Hartman @ 2024-10-15 12:19 ` Sven Schnelle 0 siblings, 0 replies; 12+ messages in thread From: Sven Schnelle @ 2024-10-15 12:19 UTC (permalink / raw) To: Greg Kroah-Hartman Cc: Heiko Carstens, Vasily Gorbik, Alexander Gordeev, Christian Borntraeger, Richard Cochran, Ricardo B. Marliere, linux-kernel, linux-s390, netdev Greg Kroah-Hartman <gregkh@linuxfoundation.org> writes: > On Tue, Oct 15, 2024 at 02:02:17PM +0200, Sven Schnelle wrote: >> Greg Kroah-Hartman <gregkh@linuxfoundation.org> writes: >> >> > On Tue, Oct 15, 2024 at 12:54:13PM +0200, Sven Schnelle wrote: >> >> To allow users to have stable device names with the help of udev, >> >> add the name to the udev event that is sent when a new PtP clock >> >> is available. The key is called 'PTP_CLOCK_NAME'. >> > >> > Where are you documenting this new user/kernel api you are adding? >> > >> >> >> >> Signed-off-by: Sven Schnelle <svens@linux.ibm.com> >> >> --- >> >> drivers/ptp/ptp_clock.c | 11 ++++++++++- >> >> 1 file changed, 10 insertions(+), 1 deletion(-) >> >> >> >> diff --git a/drivers/ptp/ptp_clock.c b/drivers/ptp/ptp_clock.c >> >> index c56cd0f63909..15937acb79c6 100644 >> >> --- a/drivers/ptp/ptp_clock.c >> >> +++ b/drivers/ptp/ptp_clock.c >> >> @@ -25,9 +25,11 @@ >> >> #define PTP_PPS_EVENT PPS_CAPTUREASSERT >> >> #define PTP_PPS_MODE (PTP_PPS_DEFAULTS | PPS_CANWAIT | PPS_TSFMT_TSPEC) >> >> >> >> +static int ptp_udev_uevent(const struct device *dev, struct kobj_uevent_env *env); >> >> const struct class ptp_class = { >> >> .name = "ptp", >> >> - .dev_groups = ptp_groups >> >> + .dev_groups = ptp_groups, >> >> + .dev_uevent = ptp_udev_uevent >> >> }; >> >> >> >> /* private globals */ >> >> @@ -514,6 +516,13 @@ EXPORT_SYMBOL(ptp_cancel_worker_sync); >> >> >> >> /* module operations */ >> >> >> >> +static int ptp_udev_uevent(const struct device *dev, struct kobj_uevent_env *env) >> >> +{ >> >> + struct ptp_clock *ptp = container_of(dev, struct ptp_clock, dev); >> >> + >> >> + return add_uevent_var(env, "PTP_CLOCK_NAME=%s", ptp->info->name); >> > >> > Why is this needed? Can't you get the name from the sysfs paths, the >> > symlink should be there already. >> >> You mean the 'clock_name' attribute in sysfs? > > Great, yes, it's right there. > >> That would require to >> write some script to iterate over all ptp devices and check the name, >> or is there a way to match that in udev? > > Yes there is. Please use that :) Indeed. Sorry, will drop the patch. ^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2024-10-16 5:20 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20241015084728.1833876-1-svens@linux.ibm.com>
2024-10-15 8:47 ` [PATCH 1/3] s390/time: Add clocksource id to TOD clock Sven Schnelle
2024-10-15 8:47 ` [PATCH 2/3] ptp: Add clock name to uevent Sven Schnelle
2024-10-15 12:43 ` Andrew Lunn
2024-10-16 3:38 ` Richard Cochran
2024-10-16 5:20 ` Sven Schnelle
2024-10-15 8:47 ` [PATCH 3/3] s390/time: Add PtP driver Sven Schnelle
2024-10-15 22:13 ` Jeff Johnson
2024-10-15 10:54 [PATCH RESEND 0/3] PtP driver for s390 clocks Sven Schnelle
2024-10-15 10:54 ` [PATCH 2/3] ptp: Add clock name to uevent Sven Schnelle
2024-10-15 10:59 ` Greg Kroah-Hartman
2024-10-15 12:02 ` Sven Schnelle
2024-10-15 12:16 ` Greg Kroah-Hartman
2024-10-15 12:19 ` Sven Schnelle
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox