Skip to contentSkip to conversation

net: ethernet: ti: cpts: fix ethtool output when no ptp_clock registered

PATCH Applied Grygorii Strashko 3 participants 3 messages Dec 24, 2020 – Dec 28, 2020

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

PATCH 1/1 net: ethernet: ti: cpts: fix ethtool output when no ptp_clock registered

The CPTS driver registers PTP PHC clock when first netif is going up and unregister it when all netif are down. Now ethtool will show:
- PTP PHC clock index 0 after boot until first netif is up;
- the last assigned PTP PHC clock index even if PTP PHC clock is not
registered any more after all netifs are down.

This patch ensures that -1 is returned by ethtool when PTP PHC clock is not registered any more.

Fixes 8a2c9a5ab4b9 ("net: ethernet: ti: cpts: rework initialization/deinitialization")
---
 drivers/net/ethernet/ti/cpts.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/ethernet/ti/cpts.c +2 -0
index d1fc7955d422..43222a34cba0 100644
@@ -599,6 +599,7 @@ void cpts_unregister(struct cpts *cpts)
 
 	ptp_clock_unregister(cpts->clock);
 	cpts->clock = NULL;
+	cpts->phc_index = -1;
 
 	cpts_write32(cpts, 0, int_enable);
 	cpts_write32(cpts, 0, control);
@@ -784,6 +785,7 @@ struct cpts *cpts_create(struct device *dev, void __iomem *regs,
 	cpts->cc.read = cpts_systim_read;
 	cpts->cc.mask = CLOCKSOURCE_MASK(32);
 	cpts->info = cpts_info;
+	cpts->phc_index = -1;
 
 	if (n_ext_ts)
 		cpts->info.n_ext_ts = n_ext_ts;
Signature · 1 line
2.17.1
Acked-by on v1 1/1
#1 lore raw
Quoted 11 lines · Grygorii Strashko

The CPTS driver registers PTP PHC clock when first netif is going up and unregister it when all netif are down. Now ethtool will show:
- PTP PHC clock index 0 after boot until first netif is up;
- the last assigned PTP PHC clock index even if PTP PHC clock is not
registered any more after all netifs are down.

This patch ensures that -1 is returned by ethtool when PTP PHC clock is not registered any more.

Fixes 8a2c9a5ab4b9 ("net: ethernet: ti: cpts: rework initialization/deinitialization")
maintainer Applied
#2 lore raw
Quoted 7 lines · On Thu, 24 Dec 2020 13:21:36 -0800 Richard Cochran wrote:
Quoted 6 lines · Grygorii Strashko

The CPTS driver registers PTP PHC clock when first netif is going up and unregister it when all netif are down. Now ethtool will show:
- PTP PHC clock index 0 after boot until first netif is up;
- the last assigned PTP PHC clock index even if PTP PHC clock is not
registered any more after all netifs are down.

Quoted 7 lines
Quoted 5 lines

This patch ensures that -1 is returned by ethtool when PTP PHC clock is not registered any more.

Fixes 8a2c9a5ab4b9 ("net: ethernet: ti: cpts: rework initialization/deinitialization")

Applied, thank you!