Skip to contentSkip to conversation

net: ethernet: ti: am65-cpts: fix support for PTP_EXTTS_REQUEST2 ioctl

PATCH Applied James Clark 6 participants 8 messages Oct 20 – Oct 23

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: ethernet: ti: am65-cpts: fix support for PTP_EXTTS_REQUEST2 ioctl

Commit 7c571ac57d9d ("net: ptp: introduce .supported_extts_flags to ptp_clock_info") modified the PTP core to validate the supported flags of external timestamp requests, rather than relying on each driver to check them.

am65_cpts_extts_enable() ignores the flags, and am65-cpts was not given any .supported_extts_flags. Since PTP_EXTTS_REQUEST2 always implies PTP_STRICT_FLAGS, the core now rejects every PTP_EXTTS_REQUEST2 for this driver with -EOPNOTSUPP, where before that commit the same requests succeeded. Only the PTP_EXTTS_REQUEST ioctl still works.

Tests on a BeagleY-AI (J722S) show that the CPTS hardware timestamp push inputs timestamp just the rising edge. Encode this in .supported_extts_flags. A PTP_EXTTS_REQUEST2 for the rising edge then succeeds, and one for the falling edge or for both edges fails with -EOPNOTSUPP.

Fixes 7c571ac57d9d ("net: ptp: introduce .supported_extts_flags to ptp_clock_info")
---
 drivers/net/ethernet/ti/am65-cpts.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/ethernet/ti/am65-cpts.c +1 -0
index efbf2ef976a..df5659ead72 100644
@@ -779,6 +779,7 @@ static long am65_cpts_ts_work(struct ptp_clock_info *ptp);
 static struct ptp_clock_info am65_ptp_info = {
 	.owner		= THIS_MODULE,
 	.name		= "CTPS timer",
+	.supported_extts_flags = PTP_RISING_EDGE | PTP_STRICT_FLAGS,
 	.adjfine	= am65_cpts_ptp_adjfine,
 	.adjtime	= am65_cpts_ptp_adjtime,
 	.gettimex64	= am65_cpts_ptp_gettimex,
Signature · 1 line
2.56.0
#1 lore raw
Quoted 10 lines · James Clark

Commit 7c571ac57d9d ("net: ptp: introduce .supported_extts_flags to ptp_clock_info") modified the PTP core to validate the supported flags of external timestamp requests, rather than relying on each driver to check them.

am65_cpts_extts_enable() ignores the flags, and am65-cpts was not given any .supported_extts_flags. Since PTP_EXTTS_REQUEST2 always implies PTP_STRICT_FLAGS, the core now rejects every PTP_EXTTS_REQUEST2 for this driver with -EOPNOTSUPP, where before that commit the same requests succeeded.

Adding Aksh Garg and Sebastian Andrzej Siewior, whom I missed on the Cc list. The full patch is at
https://lore.kernel.org/all/[email protected]/

#2 lore raw
In reply to James Clark
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider.

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider.

Critical: 0 · High: 0 · Medium: 1 · Low: 0

If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough).

- [Medium] Adding PTP_STRICT_FLAGS to am65_ptp_info.supported_extts_flags in drivers/net/ethernet/ti/am65-cpts.c also changes the legacy…

--

net: ethernet: ti: am65-cpts: fix support for PTP_EXTTS_REQUEST2 ioctl

This patch sets .supported_extts_flags for am65-cpts to PTP_RISING_EDGE | PTP_STRICT_FLAGS. The PTP core then stops rejecting every PTP_EXTTS_REQUEST2 for this driver. After the change, PTP_EXTTS_REQUEST2 succeeds for the rising edge and fails with -EOPNOTSUPP for the falling edge or for both edges.

drivers/net/ethernet/ti/am65-cpts.c static long am65_cpts_ts_work(struct ptp_clock_info *ptp); · line 782

Quoted 9 lines
drivers/net/ethernet/ti/am65-cpts.c +1 -0
index efbf2ef976a3..df5659ead72f 100644
@@ -779,6 +779,7 @@ static long am65_cpts_ts_work(struct ptp_clock_info *ptp);
 static struct ptp_clock_info am65_ptp_info = {
 	.owner		= THIS_MODULE,
 	.name		= "CTPS timer",
+	.supported_extts_flags = PTP_RISING_EDGE | PTP_STRICT_FLAGS,

[Severity: Medium]
Does this also change what the legacy PTP_EXTTS_REQUEST ioctl accepts?

In ptp_extts_request(), the v1 branch keeps the edge bits and never sets PTP_STRICT_FLAGS. Whether the edge bits count only as hints depends just on the driver's mask:

drivers/ptp/ptp_chardev.c:ptp_extts_request() {
    ...
	} else {
		req.extts.flags &= PTP_EXTTS_V1_VALID_FLAGS;
		memset(req.extts.rsv, 0, sizeof(req.extts.rsv));
	}
    ...
	if (!(supported_extts_flags & PTP_STRICT_FLAGS))
		supported_extts_flags |= PTP_EXTTS_EDGES;
	/* Reject unsupported flags */
	if (req.extts.flags & ~supported_extts_flags)
		return -EOPNOTSUPP;
    ...
}

Before this patch, supported_extts_flags was 0 for am65-cpts. A v1 request with PTP_ENABLE_FEATURE | PTP_FALLING_EDGE, or with both edges set, was accepted and reached am65_cpts_extts_enable(), which ignores the flags.

Now the mask has PTP_STRICT_FLAGS but not PTP_FALLING_EDGE, so those same v1 requests return -EOPNOTSUPP before ops->enable() is ever called.

The same check runs when PTP_ENABLE_FEATURE is clear. Through either ioctl, a disable request that still carries PTP_FALLING_EDGE is now rejected.

One in-tree example is tools/testing/selftests/ptp/testptp.c run with -e N -E 2 or -E 3. That sends a legacy request with PTP_FALLING_EDGE set:

			extts_request.flags = PTP_ENABLE_FEATURE | edge;
			if (ioctl(fd, PTP_EXTTS_REQUEST, &extts_request)) {
				perror("PTP_EXTTS_REQUEST");

On am65-cpts this worked before the patch. It now fails with "PTP_EXTTS_REQUEST: Operation not supported".

Rejecting falling edge requests that the hardware can't honour matches how the core treats other strict, rising-only drivers. However, the commit message says:

Only the PTP_EXTTS_REQUEST ioctl still works.

This suggests v1 behaviour does not change. The patch has a Fixes: tag and is likely to go to stable. Could the commit message say that v1 requests carrying PTP_FALLING_EDGE are now rejected as well?

Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261020003525.1237742-1-jjc%40jclark.com
#3 lore raw
Quoted 6 lines · On Thu, 22 Oct 2026 03:37:13 +0000, [email protected] wrote:

Before this patch, supported_extts_flags was 0 for am65-cpts. A v1 request with PTP_ENABLE_FEATURE | PTP_FALLING_EDGE, or with both edges set, was accepted and reached am65_cpts_extts_enable(), which ignores the flags.

Now the mask has PTP_STRICT_FLAGS but not PTP_FALLING_EDGE, so those same v1 requests return -EOPNOTSUPP before ops->enable() is ever called.

[...]

Quoted 7 lines

However, the commit message says:

Only the PTP_EXTTS_REQUEST ioctl still works.

This suggests v1 behaviour does not change. The patch has a Fixes: tag and is likely to go to stable. Could the commit message say that v1 requests carrying PTP_FALLING_EDGE are now rejected as well?

The sentence that Sashiko quotes is part of the paragraph describing the state before this patch, so it has no such implication.

With this patch, PTP_EXTTS_REQUEST rejects a request for PTP_FALLING_EDGE instead of accepting it and reporting rising edges. This is part of the purpose of 7c571ac57d9d. The equivalent bcm-phy-ptp fix, 3200fdd4021d ("broadcom: fix support for PTP_EXTTS_REQUEST2 ioctl"), made the same change without mentioning it.

I don't plan to do a v2 for this.

Acked-by
#4 lore raw
Quoted 19 lines · James Clark
Quoted 6 lines · On Thu, 22 Oct 2026 03:37:13 +0000, [email protected] wrote:

Before this patch, supported_extts_flags was 0 for am65-cpts. A v1 request with PTP_ENABLE_FEATURE | PTP_FALLING_EDGE, or with both edges set, was accepted and reached am65_cpts_extts_enable(), which ignores the flags.

Now the mask has PTP_STRICT_FLAGS but not PTP_FALLING_EDGE, so those same v1 requests return -EOPNOTSUPP before ops->enable() is ever called.

[...]

Quoted 7 lines

However, the commit message says:

Only the PTP_EXTTS_REQUEST ioctl still works.

This suggests v1 behaviour does not change. The patch has a Fixes: tag and is likely to go to stable. Could the commit message say that v1 requests carrying PTP_FALLING_EDGE are now rejected as well?

The sentence that Sashiko quotes is part of the paragraph describing the state before this patch, so it has no such implication.

Quoted 7 lines

With this patch, PTP_EXTTS_REQUEST rejects a request for PTP_FALLING_EDGE instead of accepting it and reporting rising edges. This is part of the purpose of 7c571ac57d9d. The equivalent bcm-phy-ptp fix, 3200fdd4021d ("broadcom: fix support for PTP_EXTTS_REQUEST2 ioctl"), made the same change without mentioning it.

I don't plan to do a v2 for this.

Yep, I agree with this assessment.

Reviewed-by on v1 1/1
#5 lore raw
In reply to James Clark
Quoted 28 lines · James Clark

Commit 7c571ac57d9d ("net: ptp: introduce .supported_extts_flags to ptp_clock_info") modified the PTP core to validate the supported flags of external timestamp requests, rather than relying on each driver to check them.

am65_cpts_extts_enable() ignores the flags, and am65-cpts was not given any .supported_extts_flags. Since PTP_EXTTS_REQUEST2 always implies PTP_STRICT_FLAGS, the core now rejects every PTP_EXTTS_REQUEST2 for this driver with -EOPNOTSUPP, where before that commit the same requests succeeded. Only the PTP_EXTTS_REQUEST ioctl still works.

Tests on a BeagleY-AI (J722S) show that the CPTS hardware timestamp push inputs timestamp just the rising edge. Encode this in .supported_extts_flags. A PTP_EXTTS_REQUEST2 for the rising edge then succeeds, and one for the falling edge or for both edges fails with -EOPNOTSUPP.

Fixes 7c571ac57d9d ("net: ptp: introduce .supported_extts_flags to ptp_clock_info")
---
  drivers/net/ethernet/ti/am65-cpts.c | 1 +
  1 file changed, 1 insertion(+)
drivers/net/ethernet/ti/am65-cpts.c +0 -0
index efbf2ef976a..df5659ead72 100644

drivers/net/ethernet/ti/am65-cpts.c static long am65_cpts_ts_work(struct ptp_clock_info *ptp); · line 785

Quoted 7 lines
drivers/net/ethernet/ti/am65-cpts.c +1 -0
@@ -779,6 +779,7 @@ static long am65_cpts_ts_work(struct ptp_clock_info *ptp);
  static struct ptp_clock_info am65_ptp_info = {
  	.owner		= THIS_MODULE,
  	.name		= "CTPS timer",
+	.supported_extts_flags = PTP_RISING_EDGE | PTP_STRICT_FLAGS,
  	.adjfine	= am65_cpts_ptp_adjfine,
  	.adjtime	= am65_cpts_ptp_adjtime,
  	.gettimex64	= am65_cpts_ptp_gettimex,
Reviewed-by on v1 1/1
#6 lore raw
In reply to James Clark
Quoted 11 lines · James Clark

Commit 7c571ac57d9d ("net: ptp: introduce .supported_extts_flags to ptp_clock_info") modified the PTP core to validate the supported flags of external timestamp requests, rather than relying on each driver to check them.

am65_cpts_extts_enable() ignores the flags, and am65-cpts was not given any .supported_extts_flags. Since PTP_EXTTS_REQUEST2 always implies PTP_STRICT_FLAGS, the core now rejects every PTP_EXTTS_REQUEST2 for this driver with -EOPNOTSUPP, where before that commit the same requests succeeded. Only the PTP_EXTTS_REQUEST ioctl still works.

Quoted 5 lines

Tests on a BeagleY-AI (J722S) show that the CPTS hardware timestamp push inputs timestamp just the rising edge. Encode this in .supported_extts_flags. A PTP_EXTTS_REQUEST2 for the rising edge then succeeds, and one for the falling edge or for both edges fails with -EOPNOTSUPP.

Thank you!

Signature · 3 lines
Köry Maincent, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com
#7 lore raw
In reply to James Clark
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:

Quoted 5 lines · On Tue, 20 Oct 2026 07:35:25 +0700 you wrote:

Commit 7c571ac57d9d ("net: ptp: introduce .supported_extts_flags to ptp_clock_info") modified the PTP core to validate the supported flags of external timestamp requests, rather than relying on each driver to check them.

Quoted 7 lines

am65_cpts_extts_enable() ignores the flags, and am65-cpts was not given any .supported_extts_flags. Since PTP_EXTTS_REQUEST2 always implies PTP_STRICT_FLAGS, the core now rejects every PTP_EXTTS_REQUEST2 for this driver with -EOPNOTSUPP, where before that commit the same requests succeeded. Only the PTP_EXTTS_REQUEST ioctl still works.

[...]

Here is the summary with links:
- [net] net: ethernet: ti: am65-cpts: fix support for PTP_EXTTS_REQUEST2 ioctl
https://git.kernel.org/netdev/net/c/e3aaeebbef56

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html