ptp: Alibaba CIPU PTP clock driver
Subsystems (3)
v5 cover ptp: Alibaba CIPU PTP clock driver
This adds a driver for Alibaba CIPU PTP clock.
The CIPU, an underlying infrastructure of Alibaba Cloud, synchronizes time with atomic clocks via the network and provides microsecond or sub-microsecond precision timestamps for VMs and bare metals on cloud.
User space processes, such as chrony, running in VMs or on bare metals can get the high precision time through the ptp device exposed by this driver.
In addition, this driver exposes sysfs files for obtaining device attributes and event statistics, as described in the documentation.
---v5->v4:
- add documentation describing sysfs files.
v4->v3:
https://lore.kernel.org/netdev/[email protected]/
- use disable_* variant helpers as suggested by Paolo.
- minor nit: make PTP_CIPU_REG macro one line.
v3->v2:
https://lore.kernel.org/netdev/[email protected]/
- follow the sysfs convention of one value per file;
- rename enum constants for brevity;
- improve macros for printing;
- add more comments;
v2->v1:
https://lore.kernel.org/netdev/[email protected]/
- add Kconfig dependency on CONFIG_PCI to fix kernel test robot's complaint.
v1:
https://lore.kernel.org/netdev/[email protected]/
Wen Gu (2):
ptp: introduce Alibaba CIPU PHC driver
ptp: add sysfs documentation for Alibaba CIPU PHC driver
.../ABI/testing/sysfs-ptp-devices-cipu | 227 +++++ MAINTAINERS | 8 + drivers/ptp/Kconfig | 12 + drivers/ptp/Makefile | 1 + drivers/ptp/ptp_cipu.c | 946 ++++++++++++++++++ 5 files changed, 1194 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-ptp-devices-cipu create mode 100644 drivers/ptp/ptp_cipu.c
Signature · 1 line
2.43.5
PATCH v5 1/2 ptp: introduce Alibaba CIPU PHC driver
This adds a driver for Alibaba CIPU PTP clock. The CIPU, an underlying infrastructure of Alibaba Cloud, synchronizes time with atomic clocks via the network and provides microsecond or sub-microsecond precision timestamps for VMs and bare metals on cloud.
User space processes, such as chrony, running in VMs or on bare metals can get the high precision time through the PTP device exposed by this driver.
--- MAINTAINERS | 7 + drivers/ptp/Kconfig | 12 + drivers/ptp/Makefile | 1 + drivers/ptp/ptp_cipu.c | 946 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 966 insertions(+) create mode 100644 drivers/ptp/ptp_cipu.c
MAINTAINERS +7 -0
@@ -795,6 +795,13 @@ S: Maintained F: Documentation/i2c/busses/i2c-ali1563.rst F: drivers/i2c/busses/i2c-ali1563.c +ALIBABA CIPU PTP DRIVER +M: Wen Gu <[email protected]> +M: Xuan Zhuo <[email protected]> +L: [email protected] +S: Supported +F: drivers/ptp/ptp_cipu.c + ALIBABA ELASTIC RDMA DRIVER M: Cheng Xu <[email protected]> M: Kai Shen <[email protected]>
drivers/ptp/Kconfig +12 -0
@@ -263,4 +263,16 @@ config PTP_NETC_V4_TIMER synchronization. It also supports periodic output signal (e.g. PPS) and external trigger timestamping. +config PTP_1588_CLOCK_CIPU + tristate "Alibaba CIPU PTP clock" + depends on PTP_1588_CLOCK + depends on 64BIT + depends on PCI + help + This driver adds support for using the Alibaba CIPU PHC device + as a PTP clock. This is only useful with the Alibaba Cloud CIPU + infrastructure. + + To compile this driver as a module, choose M here: the module + will be called ptp_cipu. endmenu
drivers/ptp/Makefile +1 -0
@@ -22,3 +22,4 @@ 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 obj-$(CONFIG_PTP_NETC_V4_TIMER) += ptp_netc.o +obj-$(CONFIG_PTP_1588_CLOCK_CIPU) += ptp_cipu.o
drivers/ptp/ptp_cipu.c new file +946 -0
946 lines not on this page · raw message
Signature · 1 line
2.43.5
Jakub Kicinski
maintainerRe: [PATCH net-next v5 1/2] ptp: introduce Alibaba CIPU PHC driver
Quoted 8 lines · On Thu, 30 Oct 2025 20:13:13 +0800 Wen Gu wrote:
This adds a driver for Alibaba CIPU PTP clock. The CIPU, an underlying infrastructure of Alibaba Cloud, synchronizes time with atomic clocks via the network and provides microsecond or sub-microsecond precision timestamps for VMs and bare metals on cloud.
User space processes, such as chrony, running in VMs or on bare metals can get the high precision time through the PTP device exposed by this driver.
As mentioned on previous revisions this is a pure clock device which has nothing to do with networking and PTP. There should be a separate class for "hypervisor clocks", if not a common driver.
Signature · 1 line
pw-bot: cr
Re: [PATCH net-next v5 1/2] ptp: introduce Alibaba CIPU PHC driver
Quoted 6 lines · Jakub Kicinski
Quoted 5 lines · On Thu, 30 Oct 2025 20:13:13 +0800 Wen Gu wrote:
This adds a driver for Alibaba CIPU PTP clock. The CIPU, an underlying infrastructure of Alibaba Cloud, synchronizes time with atomic clocks via the network and provides microsecond or sub-microsecond precision timestamps for VMs and bare metals on cloud.
Quoted 6 lines
Quoted 3 lines
User space processes, such as chrony, running in VMs or on bare metals can get the high precision time through the PTP device exposed by this driver.
As mentioned on previous revisions this is a pure clock device which has nothing to do with networking and PTP.
I don't quite agree that this has nothing to do with PTP.
What is the difference between this CIPU PTP driver and other PTP drivers under drivers/ptp? such as ptp_s390, ptp_vmw, ptp_pch, and others. Most of these PTP drivers do not directly involve IEEE 1588 or networking as well.
Quoted 2 lines
There should be a separate class
for "hypervisor clocks", if not a common driver.
'hypervisor clock' is not very accurate. CIPU PTP can be used in VM and bare metal scenarios, and bare metals do not need hypervisors.
Regards.
Jakub Kicinski
maintainerRe: [PATCH net-next v5 1/2] ptp: introduce Alibaba CIPU PHC driver
Quoted 11 lines · On Wed, 5 Nov 2025 18:22:19 +0800 Wen Gu wrote:
Quoted 10 lines · Jakub Kicinski
Quoted 8 lines · On Thu, 30 Oct 2025 20:13:13 +0800 Wen Gu wrote:
This adds a driver for Alibaba CIPU PTP clock. The CIPU, an underlying infrastructure of Alibaba Cloud, synchronizes time with atomic clocks via the network and provides microsecond or sub-microsecond precision timestamps for VMs and bare metals on cloud.
User space processes, such as chrony, running in VMs or on bare metals can get the high precision time through the PTP device exposed by this driver.
Quoted 8 lines
Quoted 2 lines
As mentioned on previous revisions this is a pure clock device which has nothing to do with networking and PTP.
I don't quite agree that this has nothing to do with PTP.
What is the difference between this CIPU PTP driver and other PTP drivers under
drivers/ptp? such asptp_s390,ptp_vmw,ptp_pch, and others. Most of these PTP drivers do not directly involve IEEE 1588 or networking as well.
We can't delete existing drivers. It used to be far less annoying until every cloud vendor under the sun decided to hack up their own implementation of something as simple as the clock.
Quoted 5 lines
Quoted 2 lines
There should be a separate class
for "hypervisor clocks", if not a common driver.'hypervisor clock' is not very accurate. CIPU PTP can be used in VM and bare metal scenarios, and bare metals do not need hypervisors.
I know.
Re: [PATCH net-next v5 1/2] ptp: introduce Alibaba CIPU PHC driver
Quoted 12 lines · Jakub Kicinski
Quoted 11 lines · On Wed, 5 Nov 2025 18:22:19 +0800 Wen Gu wrote:
Quoted 10 lines · Jakub Kicinski
Quoted 8 lines · On Thu, 30 Oct 2025 20:13:13 +0800 Wen Gu wrote:
This adds a driver for Alibaba CIPU PTP clock. The CIPU, an underlying infrastructure of Alibaba Cloud, synchronizes time with atomic clocks via the network and provides microsecond or sub-microsecond precision timestamps for VMs and bare metals on cloud.
User space processes, such as chrony, running in VMs or on bare metals can get the high precision time through the PTP device exposed by this driver.
Quoted 9 lines
Quoted 8 lines
Quoted 2 lines
As mentioned on previous revisions this is a pure clock device which has nothing to do with networking and PTP.
I don't quite agree that this has nothing to do with PTP.
What is the difference between this CIPU PTP driver and other PTP drivers under
drivers/ptp? such asptp_s390,ptp_vmw,ptp_pch, and others. Most of these PTP drivers do not directly involve IEEE 1588 or networking as well.
Sorry for the late reply due to a vacation.
Quoted 4 lines
We can't delete existing drivers. It used to be far less annoying until every cloud vendor under the sun decided to hack up their own implementation of something as simple as the clock.
So what kind of drivers do you think are qualified to be placed in the drivers/ptp? I checked some docs, e.g.[1], and codes in drivers/ptp, but I am not sure what the deciding factor is, assuming that exposing a PTP character device is not sufficient.
[1] https://docs.kernel.org/driver-api/ptp.html
Regards.
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
There should be a separate class
for "hypervisor clocks", if not a common driver.'hypervisor clock' is not very accurate. CIPU PTP can be used in VM and bare metal scenarios, and bare metals do not need hypervisors.
I know.
Jakub Kicinski
maintainerRe: [PATCH net-next v5 1/2] ptp: introduce Alibaba CIPU PHC driver
Quoted 10 lines · On Thu, 27 Nov 2025 13:48:47 +0800 Wen Gu wrote:
Quoted 3 lines
We can't delete existing drivers. It used to be far less annoying until every cloud vendor under the sun decided to hack up their own implementation of something as simple as the clock.
So what kind of drivers do you think are qualified to be placed in the
drivers/ptp? I checked some docs, e.g.[1], and codes indrivers/ptp, but I am not sure what the deciding factor is, assuming that exposing a PTP character device is not sufficient.
Networking ones? I don't have a great answer. My point is basically that we are networking maintainers. I have a good understanding of PTP (the actual protocol) and TSN as these are networking technologies. But I don't feel qualified to review purely time / clock related code. I don't even know the UNIX/Linux clock API very well.
Sorry to put you in this position but the VM clocks should have some other tree. Or at the very least some clock expert needs to review them.
Could you go complain to clock people? Or virtualization people?
Re: [PATCH net-next v5 1/2] ptp: introduce Alibaba CIPU PHC driver
Quoted 10 lines · Jakub Kicinski
Quoted 9 lines · On Thu, 27 Nov 2025 13:48:47 +0800 Wen Gu wrote:
Quoted 3 lines
We can't delete existing drivers. It used to be far less annoying until every cloud vendor under the sun decided to hack up their own implementation of something as simple as the clock.
So what kind of drivers do you think are qualified to be placed in the
drivers/ptp? I checked some docs, e.g.[1], and codes indrivers/ptp, but I am not sure what the deciding factor is, assuming that exposing a PTP character device is not sufficient.
Quoted 8 lines
Quoted 1 line
Networking ones? I don't have a great answer. My point is basically that we are networking maintainers. I have a good understanding of PTP (the actual protocol) and TSN as these are networking technologies. But I don't feel qualified to review purely time / clock related code. I don't even know the UNIX/Linux clock API very well.
Searching the codebase for ptp_clock_register() shows that the PTP implementations that related to the networking (IEEE 1588) are directly embedded in the NIC drivers (drivers/net), e.g. ena_phc.c, ice_ptp.c, igb_ptp.c, instead of being in drivers/ptp.
Most drivers under drivers/ptp are not directly related to networking and operate independently of NICs. They maintain accuracy through their own mechanisms.
Quoted 3 lines
Sorry to put you in this position but the VM clocks should have some other tree. Or at the very least some clock expert needs to review them.
I noticed you emphasized 'VM clock', but I don’t think it really matters whether it’s a VM/cloud scenario or not. IMHO whether the PHC is provided by a chip, FPGA, hypervisor or CIPU makes no fundamental difference.
Quoted 1 line
Could you go complain to clock people? Or virtualization people?
I understand that the PTP implementations in drivers/ptp aren't closely related to networking though drivers/ptp is included in NETWORKING DRIVERS in the MAINTAINER file.
I noticed that drivers/ptp/* is also inclued in PTP HARDWARE CLOCK SUPPORT. This attribution seems more about 'clock'.
Hi @Richard Cochran, could you please review this? Thanks! :)
Regards.
Jakub Kicinski
maintainerRe: [PATCH net-next v5 1/2] ptp: introduce Alibaba CIPU PHC driver
Quoted 10 lines · On Fri, 28 Nov 2025 14:22:21 +0800 Wen Gu wrote:
Quoted 1 line
Could you go complain to clock people? Or virtualization people?
I understand that the PTP implementations in
drivers/ptparen't closely related to networking thoughdrivers/ptpis included in NETWORKING DRIVERS in the MAINTAINER file.I noticed that
drivers/ptp/*is also inclued in PTP HARDWARE CLOCK SUPPORT. This attribution seems more about 'clock'.Hi @Richard Cochran, could you please review this? Thanks! :)
It's Thanksgiving weekend in the US, Richard may be AFK so excuse my speaking for him, but he mentioned in the past that he is also not interested in becoming a maintainer for general clocks, unrelated to PTP.
Search the mailing list, there are at least 3 drivers like yours being proposed. Maybe you can get together with also the KVM and VMclock authors and form a new subsystem?
Re: [PATCH net-next v5 1/2] ptp: introduce Alibaba CIPU PHC driver
Quoted 10 lines · Jakub Kicinski
Quoted 9 lines · On Fri, 28 Nov 2025 14:22:21 +0800 Wen Gu wrote:
Quoted 1 line
Could you go complain to clock people? Or virtualization people?
I understand that the PTP implementations in
drivers/ptparen't closely related to networking thoughdrivers/ptpis included in NETWORKING DRIVERS in the MAINTAINER file.I noticed that
drivers/ptp/*is also inclued in PTP HARDWARE CLOCK SUPPORT. This attribution seems more about 'clock'.
Quoted 7 lines
Quoted 1 line
Hi @Richard Cochran, could you please review this? Thanks! :)
It's Thanksgiving weekend in the US, Richard may be AFK so excuse my speaking for him, but he mentioned in the past that he is also not interested in becoming a maintainer for general clocks, unrelated to PTP.
Wishing you a Happy Thanksgiving!
I think you misunderstood. I didn't encourage Richard to maintain general clocks unrelated to PTP. Rather, I believe this driver should belong to the PTP subsystem, and here are my reasons (which have been mentioned in previous emails):
1. CIPU provides high-precision PHCs for VMs or bare metals, which are exposed as ptp_clock according to the definition in [1]. its usage is no different from other ptp devices. So this is a PTP driver.
[1] https://docs.kernel.org/driver-api/ptp.html
2. The PTP implementations that are independent of networking and NICs are placed under drivers/ptp. These devices are provided from chip/FPGA/hypervisor and maintain clock accuracy in their own unique ways. CIPU ptp driver is no different and should also be placed under the drivers/ptp from this perspective.
According to the MAINTAINERS file, drivers/ptp/* is maintained by the NETWORKING DRIVERS and PTP HARDWARE CLOCK SUPPORT subsystems. Considering you mentioned that drivers/ptp is not closely related to networking, I think it might be more appropriate for the PTP HARDWARE CLOCK SUPPORT subsystem maintainer to review it. After it merges into the upstream, we will be its maintainers.
Quoted 3 lines
Search the mailing list, there are at least 3 drivers like yours being proposed. Maybe you can get together with also the KVM and VMclock authors and form a new subsystem?
I think drivers under drivers/ptp are all similar. But aside from the fact that they are all exposed as PTP devices and therefore classified in the PTP subsystem, I haven't been able to find a way to classify them into another class (note that CIPU ptp can't be considered a VM/hypervisor clock class since bare metal scenario is also applicable).
Regards.
Re: [PATCH net-next v5 1/2] ptp: introduce Alibaba CIPU PHC driver
Quoted 52 lines · Wen Gu
Quoted 10 lines · Jakub Kicinski
Quoted 9 lines · On Fri, 28 Nov 2025 14:22:21 +0800 Wen Gu wrote:
Quoted 1 line
Could you go complain to clock people? Or virtualization people?
I understand that the PTP implementations in
drivers/ptparen't closely related to networking thoughdrivers/ptpis included in NETWORKING DRIVERS in the MAINTAINER file.I noticed that
drivers/ptp/*is also inclued in PTP HARDWARE CLOCK SUPPORT. This attribution seems more about 'clock'.Quoted 7 lines
Quoted 1 line
Hi @Richard Cochran, could you please review this? Thanks! :)
It's Thanksgiving weekend in the US, Richard may be AFK so excuse my speaking for him, but he mentioned in the past that he is also not interested in becoming a maintainer for general clocks, unrelated to PTP.
Wishing you a Happy Thanksgiving!
I think you misunderstood. I didn't encourage Richard to maintain general clocks unrelated to PTP. Rather, I believe this driver should belong to the PTP subsystem, and here are my reasons (which have been mentioned in previous emails):
1. CIPU provides high-precision PHCs for VMs or bare metals, which are exposed as
ptp_clockaccording to the definition in [1]. its usage is no different from other ptp devices. So this is a PTP driver.[1] https://docs.kernel.org/driver-api/ptp.html
2. The PTP implementations that are independent of networking and NICs are placed under
drivers/ptp. These devices are provided from chip/FPGA/hypervisor and maintain clock accuracy in their own unique ways. CIPU ptp driver is no different and should also be placed under thedrivers/ptpfrom this perspective.According to the
MAINTAINERSfile,drivers/ptp/*is maintained by the NETWORKING DRIVERS and PTP HARDWARE CLOCK SUPPORT subsystems. Considering you mentioned thatdrivers/ptpis not closely related to networking, I think it might be more appropriate for the PTP HARDWARE CLOCK SUPPORT subsystem maintainer to review it. After it merges into the upstream, we will be its maintainers.Quoted 3 lines
Search the mailing list, there are at least 3 drivers like yours being proposed. Maybe you can get together with also the KVM and VMclock authors and form a new subsystem?
Quoted 7 lines
I think drivers under
drivers/ptpare all similar. But aside from the fact that they are all exposed as PTP devices and therefore classified in the PTP subsystem, I haven't been able to find a way to classify them into another class (note that CIPU ptp can't be considered a VM/hypervisor clock class since bare metal scenario is also applicable).Regards.
Given that net-next is closed and the EOY break is here, I was wondering whether the review discussion might continue during this period or should wait until after the break.
Thanks.
Jakub Kicinski
maintainerRe: [PATCH net-next v5 1/2] ptp: introduce Alibaba CIPU PHC driver
Quoted 3 lines · On Fri, 12 Dec 2025 14:50:13 +0800 Wen Gu wrote:
Given that net-next is closed and the EOY break is here, I was wondering whether the review discussion might continue during this period or should wait until after the break.
This is a somewhat frustrating thing to hear. My position is that net-next is not the right home for this work, so its status should be irrelevant.
Re: [PATCH net-next v5 1/2] ptp: introduce Alibaba CIPU PHC driver
Quoted 8 lines · Jakub Kicinski
Quoted 3 lines · On Fri, 12 Dec 2025 14:50:13 +0800 Wen Gu wrote:
Given that net-next is closed and the EOY break is here, I was wondering whether the review discussion might continue during this period or should wait until after the break.
This is a somewhat frustrating thing to hear. My position is that net-next is not the right home for this work, so its status should be irrelevant.
Hi Jakub, I'm sorry, but I still don't understand why you object to this being a PTP clock driver and to placing it under drivers/ptp. Could you please explain your reasons?
You mentioned that it's unrelated to networking, but most of the drivers under drivers/ptp are also unrelated to networking. PTP implementations that are independent of network drivers are placed here.
If the PTP HARDWARE CLOCK SUPPORT maintainers don't review it, which subsystem should I go to?
If you're suggesting creating a new subsystem, I think we should first answer this question: why can't it be part of the current ptp subsystem, and what are the differences between the drivers under drivers/ptp and those in the new subsystem?
Thanks, and sorry for bothering you during your EOY break.
Regards.
Jakub Kicinski
maintainerRe: [PATCH net-next v5 1/2] ptp: introduce Alibaba CIPU PHC driver
Quoted 4 lines · On Sun, 14 Dec 2025 22:03:57 +0800 Wen Gu wrote:
If you're suggesting creating a new subsystem, I think we should first answer this question: why can't it be part of the current ptp subsystem, and what are the differences between the drivers under
drivers/ptpand those in the new subsystem?
I can't explain it any better than I already did here:
https://lore.kernel.org/all/[email protected]/
I talked to Thomas Gleixner (added to CC) during LPC and he seemed open to creating a PHC subsystem for pure time devices in virtualized environments. Please work with him and other vendors trying to upstream similar drivers.
Re: [PATCH net-next v5 1/2] ptp: introduce Alibaba CIPU PHC driver
Quoted 4 lines · Jakub Kicinski
I talked to Thomas Gleixner (added to CC) during LPC and he seemed open to creating a PHC subsystem for pure time devices in virtualized environments. Please work with him and other vendors trying to upstream similar drivers.
Thank you for your patience and help.
I’ll work with Thomas and other potential vendors, likely starting with an RFC to collect ideas and reach consensus on a dedicated subsystem for PHC in non-NIC scenarios.
Regards.
Re: [PATCH net-next v5 1/2] ptp: introduce Alibaba CIPU PHC driver
In reply to Jakub KicinskiQuoted 6 lines · Jakub Kicinski
Quoted 4 lines · On Sun, 14 Dec 2025 22:03:57 +0800 Wen Gu wrote:
If you're suggesting creating a new subsystem, I think we should first answer this question: why can't it be part of the current ptp subsystem, and what are the differences between the drivers under
drivers/ptpand those in the new subsystem?
Quoted 7 lines
I can't explain it any better than I already did here:
https://lore.kernel.org/all/[email protected]/I talked to Thomas Gleixner (added to CC) during LPC and he seemed open to creating a PHC subsystem for pure time devices in virtualized environments. Please work with him and other vendors trying to upstream similar drivers.
Hi Jakub and Thomas,
I thought about it a bit more. If we create a new clock class (say a "ptc"), its helpers and structure would likely end up being almost identical to the current ptp ones, since the pure phc drivers under drivers/ptp (e.g. ptp_kvm, ptp_vmw, ptp_s390, ptp_cipu) are implemented on top of the existing ptp helpers. That would give us two near-identical classes, which may be confusing.
Also, changing the userspace device node for existing pure phc drivers from /dev/ptpX to something else (e.g. /dev/ptcX) seems impractical. The same applies to ptp_cipu, since it is already used and relies on exposing /dev/ptpX.
Given the historical baggage, it seems better to keep using the existing ptp framework, but separate these pure phc drivers into a new subsystem with a dedicated directory (e.g. drivers/phc/) and a MAINTAINERS entry, moving them out of the netdev maintenance scope. This should also address the concern that these pure phc drivers are not a good fit to be maintained under the networking subsystem.
If this works for you, I'll send an RFC about this.
Regards.
Jakub Kicinski
maintainerRe: [PATCH net-next v5 1/2] ptp: introduce Alibaba CIPU PHC driver
Quoted 2 lines · On Mon, 22 Dec 2025 15:18:19 +0800 Wen Gu wrote:
The same applies to
ptp_cipu, since it is already used and relies on exposing/dev/ptpX.
IIUC you mean that the driver is already used downstream and abandoning PTP will break the OOT users? This is a non-argument upstream.
Quoted 6 lines
Given the historical baggage, it seems better to keep using the existing ptp framework, but separate these pure phc drivers into a new subsystem with a dedicated directory (e.g.
drivers/phc/) and aMAINTAINERSentry, moving them out of the netdev maintenance scope. This should also address the concern that these pure phc drivers are not a good fit to be maintained under the networking subsystem.
I'd rather you left PTP completely alone with your funny read only clocks. Please and thank you.
Re: [PATCH net-next v5 1/2] ptp: introduce Alibaba CIPU PHC driver
Quoted 7 lines · Jakub Kicinski
Quoted 2 lines · On Mon, 22 Dec 2025 15:18:19 +0800 Wen Gu wrote:
The same applies to
ptp_cipu, since it is already used and relies on exposing/dev/ptpX.IIUC you mean that the driver is already used downstream and abandoning PTP will break the OOT users? This is a non-argument upstream.
I know.
My point is that I hope ptp_cipu can use the PTP interface as these existing drivers, because many user programs and their ecosystems depend on the PTP interface, such as chrony, or other user programs based on /dev/ptp*. A new clock class device node will break this, requiring changes to all these user programs, otherwise they can't use the clock.
Quoted 9 lines
Quoted 6 lines
Given the historical baggage, it seems better to keep using the existing ptp framework, but separate these pure phc drivers into a new subsystem with a dedicated directory (e.g.
drivers/phc/) and aMAINTAINERSentry, moving them out of the netdev maintenance scope. This should also address the concern that these pure phc drivers are not a good fit to be maintained under the networking subsystem.I'd rather you left PTP completely alone with your funny read only clocks. Please and thank you.
What you call 'funny' read only clocks have existed as PTP clocks for a long time, and there are many examples, such as ptp_kvm, ptp_vmw and ptp_s390. It also exists outside the drivers/ptp directory, such as drivers/hv/hv_util.c[1]. And there are also recent examples, such as drivers/virtio/virtio_rtc_ptp.c[2]. Even the PTP interface definition does not require that the ability to set the time must be supported. So I think the clock itself, as well as the use of the PTP interface is reasonable and not funny.
IIUC, the main block is that you don't want to maintain these pure phc clocks, as you mentioned in [3]. I agree with this as well. So I propose to group these pure phc drivers together (e.g. drivers/phc) and move them from the network maintenance domain to the clock maintenance domain.
What's your new concern?
[1] https://lore.kernel.org/all/[email protected]/
[2] https://lore.kernel.org/all/[email protected]/
[3] https://lore.kernel.org/all/[email protected]/
Regards.
Re: [PATCH net-next v5 1/2] ptp: introduce Alibaba CIPU PHC driver
Quoted 39 lines · Wen Gu
Quoted 7 lines · Jakub Kicinski
Quoted 2 lines · On Mon, 22 Dec 2025 15:18:19 +0800 Wen Gu wrote:
The same applies to
ptp_cipu, since it is already used and relies on exposing/dev/ptpX.IIUC you mean that the driver is already used downstream and abandoning PTP will break the OOT users? This is a non-argument upstream.
I know.
My point is that I hope
ptp_cipucan use the PTP interface as these existing drivers, because many user programs and their ecosystems depend on the PTP interface, such as chrony, or other user programs based on/dev/ptp*. A new clock class device node will break this, requiring changes to all these user programs, otherwise they can't use the clock.Quoted 9 lines
Quoted 6 lines
Given the historical baggage, it seems better to keep using the existing ptp framework, but separate these pure phc drivers into a new subsystem with a dedicated directory (e.g.
drivers/phc/) and aMAINTAINERSentry, moving them out of the netdev maintenance scope. This should also address the concern that these pure phc drivers are not a good fit to be maintained under the networking subsystem.I'd rather you left PTP completely alone with your funny read only clocks. Please and thank you.
What you call 'funny' read only clocks have existed as PTP clocks for a long time, and there are many examples, such as
ptp_kvm,ptp_vmwandptp_s390. It also exists outside thedrivers/ptpdirectory, such as drivers/hv/hv_util.c[1]. And there are also recent examples, such as drivers/virtio/virtio_rtc_ptp.c[2]. Even the PTP interface definition does not require that the ability to set the time must be supported. So I think the clock itself, as well as the use of the PTP interface is reasonable and not funny.
Quoted 5 lines
IIUC, the main block is that you don't want to maintain these pure phc clocks, as you mentioned in [3]. I agree with this as well. So I propose to group these pure phc drivers together (e.g.
drivers/phc) and move them from the network maintenance domain to the clock maintenance domain.
I think that makes sense. These clocks can still be registered as PTP clocks because that's one of the most sensible interfaces to userspace, but the implementations can live elsewhere outside the networking maintenance domain.
In a lot of cases we'd want to use them for RTC too, so that the kernel's CLOCK_REALTIME can be initialised from them. And especially for microvms I'd like to *synchronize* the kernel's clock from them automatically too.
Re: [PATCH net-next v5 1/2] ptp: introduce Alibaba CIPU PHC driver
Quoted 8 lines · David Woodhouse
Quoted 6 lines · Wen Gu
IIUC, the main block is that you don't want to maintain these pure phc clocks, as you mentioned in [3]. I agree with this as well. So I propose to group these pure phc drivers together (e.g.
drivers/phc) and move them from the network maintenance domain to the clock maintenance domain.
Quoted 5 lines
I think that makes sense. These clocks can still be registered as PTP clocks because that's one of the most sensible interfaces to userspace, but the implementations can live elsewhere outside the networking maintenance domain.
Yes. The PTP interface has become a common choice for exposing these clocks to userspace, and it is not limited to NIC-based implementations.
I have posted an RFC to reach a consensus on organizing these clocks:
https://lore.kernel.org/netdev/[email protected]/
Quoted 5 lines
In a lot of cases we'd want to use them for RTC too, so that the kernel's
CLOCK_REALTIMEcan be initialised from them. And especially for microvms I'd like to *synchronize* the kernel's clock from them automatically too.
This is also a good use-case that supports having these clocks available.
Regards.
Re: [PATCH net-next v5 1/2] ptp: introduce Alibaba CIPU PHC driver
In reply to Jakub KicinskiQuoted 17 lines · Jakub Kicinski
Quoted 16 lines · On Wed, 5 Nov 2025 18:22:19 +0800 Wen Gu wrote:
Quoted 6 lines · Jakub Kicinski
Quoted 5 lines · On Thu, 30 Oct 2025 20:13:13 +0800 Wen Gu wrote:
This adds a driver for Alibaba CIPU PTP clock. The CIPU, an underlying infrastructure of Alibaba Cloud, synchronizes time with atomic clocks via the network and provides microsecond or sub-microsecond precision timestamps for VMs and bare metals on cloud.
Quoted 6 lines
Quoted 3 lines
User space processes, such as chrony, running in VMs or on bare metals can get the high precision time through the PTP device exposed by this driver.
As mentioned on previous revisions this is a pure clock device which has nothing to do with networking and PTP.
I don't quite agree that this has nothing to do with PTP.
Quoted 7 lines
Quoted 3 lines
What is the difference between this CIPU PTP driver and other PTP drivers under
drivers/ptp? such asptp_s390,ptp_vmw,ptp_pch, and others. Most of these PTP drivers do not directly involve IEEE 1588 or networking as well.We can't delete existing drivers. It used to be far less annoying until every cloud vendor under the sun decided to hack up their own implementation of something as simple as the clock.
Heh. In my defence, I hacked up a new one because none of the existing options (including the KVM abomination) were any use. None of them allow guests to rely on accurate time across live migration.
VMClock is designed specifically to solve that problem. It's now published at https://uapi-group.org/specifications/specs/vmclock/ and although the primary target is virtual machines, it discusses how it could be used to build a hardware implementation using PCIe PTM.
As well as obviously implementing it in $DAYJOB, we added it to QEMU.
Although it *can* be used as a PHC providing a paired TAI timestamp, it actually provides a y=mx+c relationship between the CPU counter (e.g. TSC) and real time, not just a timestamp at a given point in time.
I'd like to integrate it as a first-class citizen in kernel timekeeping, so that the kernel can directly both consume it, *and* export the kernel's CLOCK_REALTIME to KVM guests.
I don't care what happens to the legacy snapshot-only ones though; those can all go away as far as I'm concerned. I'd suggest that now it's possible to do it *right*, there shouldn't be any *more* of the legacy ones.
Having said that, it does seem rather harsh to refuse to accept this one when there are so many other examples already in the tree. I'd suggest that we accept it and then it can be moved to the new setup, whatever that is, along with the other legacy snapshot-only PHCs.
Re: [PATCH net-next v5 1/2] ptp: introduce Alibaba CIPU PHC driver
Quoted 6 lines · David Woodhouse
Having said that, it does seem rather harsh to refuse to accept this one when there are so many other examples already in the tree. I'd suggest that we accept it and then it can be moved to the new setup, whatever that is, along with the other legacy snapshot-only PHCs.
That's also my thought.
That said, I'm open to either: accept it and re-home these similar drivers when we have a better setup, or agree on a dedicated "pure PHC" subsystem now and then merge it there.
Regards.
PATCH v5 2/2 ptp: add sysfs documentation for Alibaba CIPU PHC driver
In reply to Wen GuThis adds documentation for the sysfs files exposed by the Alibaba CIPU PHC driver.
--- .../ABI/testing/sysfs-ptp-devices-cipu | 227 ++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 228 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-ptp-devices-cipu
Documentation/ABI/testing/sysfs-ptp-devices-cipu new file +227 -0
@@ -0,0 +1,227 @@ +What: /sys/class/ptp/ptp<N>/device/cipu/ptp_gettm +Date: October 2025 +Contact: Wen Gu <[email protected]> +Description: + Count of PTP gettime64 and gettimex64 operations performed + on the Alibaba CIPU PTP device. + +What: /sys/class/ptp/ptp<N>/device/cipu/ptp_gettm_inval_err +Date: October 2025 +Contact: Wen Gu <[email protected]> +Description: + Count of failed PTP gettime64 or gettimex64 operations due + to invalid timestamp. + + Invalid timestamps are indicated by bit63 (PTP_CIPU_M_TS_ABN) + in the timestamp register being set. + + The driver will also trigger device status check when this + occurs. + +What: /sys/class/ptp/ptp<N>/device/cipu/ptp_gettm_tout_err +Date: October 2025 +Contact: Wen Gu <[email protected]> +Description: + Count of failed PTP gettime64 or gettimex64 operations due + to register read timeout (exceeding max_lat_ns). + +What: /sys/class/ptp/ptp<N>/device/cipu/ptp_gettm_excd_thresh +Date: October 2025 +Contact: Wen Gu <[email protected]> +Description: + Count of times system time and PHC time offset exceeded + the configured threshold (thresh_us). + + This is only recorded and does not affect the returned + timestamp. + +What: /sys/class/ptp/ptp<N>/device/cipu/dev_clk_abn +Date: October 2025 +Contact: Wen Gu <[email protected]> +Description: + Count of atomic clock abnormal events (bit1 set in sync_stat). + +What: /sys/class/ptp/ptp<N>/device/cipu/dev_clk_abn_rec +Date: October 2025 +Contact: Wen Gu <[email protected]> +Description: + Count of recovery from atomic clock abnormal events (bit1 + cleared in sync_stat after being set). + +What: /sys/class/ptp/ptp<N>/device/cipu/dev_maint +Date: October 2025 +Contact: Wen Gu <[email protected]> +Description: + Count of maintenance events (bit0 set in sync_stat). + +What: /sys/class/ptp/ptp<N>/device/cipu/dev_maint_rec +Date: October 2025 +Contact: Wen Gu <[email protected]> +Description: + Count of recovery from maintenance events (bit0 cleared + in sync_stat). + +What: /sys/class/ptp/ptp<N>/device/cipu/dev_maint_tout +Date: October 2025 +Contact: Wen Gu <[email protected]> +Description: + Count of maintenance events that failed to recover within + mt_tout_us timeout. + +What: /sys/class/ptp/ptp<N>/device/cipu/dev_busy +Date: October 2025 +Contact: Wen Gu <[email protected]> +Description: + Count of device busy events (bit4 set in sync_stat). + +What: /sys/class/ptp/ptp<N>/device/cipu/dev_busy_rec +Date: October 2025 +Contact: Wen Gu <[email protected]> +Description: + Count of recovery from device busy events (bit4 cleared + in sync_stat). + +What: /sys/class/ptp/ptp<N>/device/cipu/dev_err +Date: October 2025 +Contact: Wen Gu <[email protected]> +Description: + Count of device error events (bit7 set in sync_stat). + +What: /sys/class/ptp/ptp<N>/device/cipu/dev_err_rec +Date: October 2025 +Contact: Wen Gu <[email protected]> +Description: + Count of recovery from device error events (bit7 cleared + in sync_stat). + +What: /sys/class/ptp/ptp<N>/device/cipu/drv_cap +Date: October 2025 +Contact: Wen Gu <[email protected]> +Description: + Driver capabilities bitmask (u32): + + ======== ============================ + bit 0 support TAI time mode + bit 1 support epoch base time mode + bit 2 support abnormal event IRQ + bit 3 support recovery event IRQ + bit 31:4 reserved + ======== ============================ + + Currently TAI time mode (bit0) is not supported. + +What: /sys/class/ptp/ptp<N>/device/cipu/reg_dev_feat +Date: October 2025 +Contact: Wen Gu <[email protected]> +Description: + Device feature bitmask, same bit definitions as drv_cap. + +What: /sys/class/ptp/ptp<N>/device/cipu/reg_gst_feat +Date: October 2025 +Contact: Wen Gu <[email protected]> +Description: + Feature bitmask negotiated by driver and device, same + bit definitions as drv_cap but only features supported + by both device and driver are set. + +What: /sys/class/ptp/ptp<N>/device/cipu/reg_drv_ver +Date: October 2025 +Contact: Wen Gu <[email protected]> +Description: + Driver version encoding (u32): + + ========= =================== + bit 7:0 subminor version + bit 15:8 minor version + bit 23:16 major version + bit 24 0 for intree driver + bit 31:25 reserved + ========= =================== + +What: /sys/class/ptp/ptp<N>/device/cipu/reg_env_ver +Date: October 2025 +Contact: Wen Gu <[email protected]> +Description: + Environment encoding (u32): + + ========= ======================= + bit 7:0 kernel patchlevel + bit 15:8 kernel sublevel + bit 23:16 kernel version + bit 26:24 reserved + bit 31:27 0x1F for Linux upstream + ========= ======================= + +What: /sys/class/ptp/ptp<N>/device/cipu/reg_dev_stat +Date: October 2025 +Contact: Wen Gu <[email protected]> +Description: + Device status (u8): + + = ========================================= + 0 RESET, device reset + 1 FEATURE_OK, feature negotiation complete + 2 DRIVER_OK, fully configured, ready to use + = ========================================= + +What: /sys/class/ptp/ptp<N>/device/cipu/reg_sync_stat +Date: October 2025 +Contact: Wen Gu <[email protected]> +Description: + Device sync status bitmask (u8): + + ===== ===================== + bit 0 maintenance + bit 1 atomic clock abnormal + bit 4 device busy + bit 7 device error + ===== ===================== + + other bits are reserved. + +What: /sys/class/ptp/ptp<N>/device/cipu/reg_tm_prec_ns +Date: October 2025 +Contact: Wen Gu <[email protected]> +Description: + Time precision reported by device, in nanoseconds (u32). + +What: /sys/class/ptp/ptp<N>/device/cipu/reg_epo_base_yr +Date: October 2025 +Contact: Wen Gu <[email protected]> +Description: + Epoch base year used when epoch mode is enabled (u32). + +What: /sys/class/ptp/ptp<N>/device/cipu/reg_leap_sec +Date: October 2025 +Contact: Wen Gu <[email protected]> +Description: + Leap seconds offset reported by device, in seconds (u32). + +What: /sys/class/ptp/ptp<N>/device/cipu/reg_max_lat_ns +Date: October 2025 +Contact: Wen Gu <[email protected]> +Description: + Maximum device register read latency tolerated, + in nanoseconds (u32). + + Exceeding this is treated as timeout. e.g. see + ptp_gettm_tout_err. + +What: /sys/class/ptp/ptp<N>/device/cipu/reg_mt_tout_us +Date: October 2025 +Contact: Wen Gu <[email protected]> +Description: + Maintenance recovery timeout in microseconds (u32). + + If exceeded while maintenance status is set, reported as + dev_maint_tout event. + +What: /sys/class/ptp/ptp<N>/device/cipu/reg_thresh_us +Date: October 2025 +Contact: Wen Gu <[email protected]> +Description: + Threshold (u32, in microseconds) for acceptable + PHC vs system time offset. + + Exceeding this only increments ptp_gettm_excd_thresh + counter.
MAINTAINERS +1 -0
@@ -800,6 +800,7 @@ M: Wen Gu <[email protected]> M: Xuan Zhuo <[email protected]> L: [email protected] S: Supported +F: Documentation/ABI/testing/sysfs-ptp-devices-cipu F: drivers/ptp/ptp_cipu.c ALIBABA ELASTIC RDMA DRIVER
Signature · 1 line
2.43.5