[PATCH net] net: stmmac: report phc_index as -1 when no PTP clock is registered

Subsystems: networking drivers, stmmac ethernet driver, the rest

COLD27d

5 messages, 4 authors, 27d ago · open the first message on its own page

[PATCH net] net: stmmac: report phc_index as -1 when no PTP clock is registered

From: Lorenzo Bianconi <hidden>
Date: 2026-09-12 21:17:15

When hardware timestamping is supported but no PTP clock has been
registered yet (e.g. while the interface is down), stmmac_get_ts_info()
currently reports phc_index as 0. Zero is a valid PHC index and would
make userspace resolve the wrong clock; the absence of a clock should
be reported as -1, matching ethtool_init_tsinfo() and
ethtool_op_get_ts_info().

Report -1 when no PTP clock is available.

Fixes: 9364fa7fcf12 ("net: stmmac: Remove setting of RX software timestamp")
Signed-off-by: Lorenzo Bianconi <redacted>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c
index 154cc0c7623d..eced707131cd 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c
@@ -1017,7 +1017,7 @@ static int stmmac_get_ts_info(struct net_device *dev,
 		if (priv->ptp_clock)
 			info->phc_index = ptp_clock_index(priv->ptp_clock);
 		else
-			info->phc_index = 0;
+			info->phc_index = -1;
 
 		info->tx_types = (1 << HWTSTAMP_TX_OFF) | (1 << HWTSTAMP_TX_ON);
 
---
base-commit: 78445023439506ebd83b86d40b1e428a3b309d4a
change-id: 20260912-stmmac-fix-phc_index-1ebf19cce076

Best regards,
-- 
Lorenzo Bianconi [off-list ref]

Re: [PATCH net] net: stmmac: report phc_index as -1 when no PTP clock is registered

From: Maxime Chevallier <maxime.chevallier@bootlin.com>
Date: 2026-09-12 21:39:22

Hi Lorenzo,

On 9/12/26 23:16, Lorenzo Bianconi wrote:
When hardware timestamping is supported but no PTP clock has been
registered yet (e.g. while the interface is down), stmmac_get_ts_info()
currently reports phc_index as 0. Zero is a valid PHC index and would
make userspace resolve the wrong clock; the absence of a clock should
be reported as -1, matching ethtool_init_tsinfo() and
ethtool_op_get_ts_info().

Report -1 when no PTP clock is available.

Fixes: 9364fa7fcf12 ("net: stmmac: Remove setting of RX software timestamp")
Signed-off-by: Lorenzo Bianconi <redacted>
Ah nice, I've briefly saw that just yesterday but haven't started digging,
thanks for fixing this :)

Reviewed-by: Maxime Chevallier <maxime.chevallier@bootlin.com>

Maxime

Re: [PATCH net] net: stmmac: report phc_index as -1 when no PTP clock is registered

From: Rahul Rameshbabu <rrameshbabu@nvidia.com>
Date: 2026-09-13 00:35:26

On Sat, 12 Sep, 2026 23:39:02 +0200 Maxime Chevallier [off-list ref] wrote:
Hi Lorenzo,

On 9/12/26 23:16, Lorenzo Bianconi wrote:
quoted
When hardware timestamping is supported but no PTP clock has been
registered yet (e.g. while the interface is down), stmmac_get_ts_info()
currently reports phc_index as 0. Zero is a valid PHC index and would
make userspace resolve the wrong clock; the absence of a clock should
be reported as -1, matching ethtool_init_tsinfo() and
ethtool_op_get_ts_info().

Report -1 when no PTP clock is available.

Fixes: 9364fa7fcf12 ("net: stmmac: Remove setting of RX software timestamp")
Signed-off-by: Lorenzo Bianconi <redacted>
Ah nice, I've briefly saw that just yesterday but haven't started digging,
thanks for fixing this :)

Reviewed-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
Thanks for the change. Good catch.

Reviewed-by: Rahul Rameshbabu <rrameshbabu@nvidia.com>
Maxime

Re: [PATCH net] net: stmmac: report phc_index as -1 when no PTP clock is registered

From: Gal Pressman <hidden>
Date: 2026-09-14 06:33:30

On 13/09/2026 0:16, Lorenzo Bianconi wrote:
When hardware timestamping is supported but no PTP clock has been
registered yet (e.g. while the interface is down), stmmac_get_ts_info()
currently reports phc_index as 0. Zero is a valid PHC index and would
make userspace resolve the wrong clock; the absence of a clock should
be reported as -1, matching ethtool_init_tsinfo() and
ethtool_op_get_ts_info().

Report -1 when no PTP clock is available.

Fixes: 9364fa7fcf12 ("net: stmmac: Remove setting of RX software timestamp")
Signed-off-by: Lorenzo Bianconi <redacted>
In all other drivers I just removed the assignment, why not do the same
here?

Re: [PATCH net] net: stmmac: report phc_index as -1 when no PTP clock is registered

From: Lorenzo Bianconi <hidden>
Date: 2026-09-14 07:11:16

On Sep 14, Gal Pressman wrote:
On 13/09/2026 0:16, Lorenzo Bianconi wrote:
quoted
When hardware timestamping is supported but no PTP clock has been
registered yet (e.g. while the interface is down), stmmac_get_ts_info()
currently reports phc_index as 0. Zero is a valid PHC index and would
make userspace resolve the wrong clock; the absence of a clock should
be reported as -1, matching ethtool_init_tsinfo() and
ethtool_op_get_ts_info().

Report -1 when no PTP clock is available.

Fixes: 9364fa7fcf12 ("net: stmmac: Remove setting of RX software timestamp")
Signed-off-by: Lorenzo Bianconi <redacted>
In all other drivers I just removed the assignment, why not do the same
here?
Ack, I agree. Since we run ethtool_init_tsinfo() before running the
get_ts_info() callback, we can drop phc_index initialization to -1.
I will fix it in v2.

Regards,
Lorenzo
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help