Skip to content

Commit 11a6bd4

Browse files
HoratiuVulturgregkh
authored andcommitted
phy: mscc: Fix when PTP clock is register and unregister
[ Upstream commit 882e57c ] It looks like that every time when the interface was set down and up the driver was creating a new ptp clock. On top of this the function ptp_clock_unregister was never called. Therefore fix this by calling ptp_clock_register and initialize the mii_ts struct inside the probe function and call ptp_clock_unregister when driver is removed. Fixes: 7d272e6 ("net: phy: mscc: timestamping and PHC support") Signed-off-by: Horatiu Vultur <horatiu.vultur@microchip.com> Reviewed-by: Vadim Fedorenko <vadim.fedorenko@linux.dev> Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com> Link: https://patch.msgid.link/20250825065543.2916334-1-horatiu.vultur@microchip.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 8dc9a2d commit 11a6bd4

File tree

3 files changed

+26
-16
lines changed

3 files changed

+26
-16
lines changed

drivers/net/phy/mscc/mscc.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,7 @@ static inline void vsc8584_config_macsec_intr(struct phy_device *phydev)
481481
void vsc85xx_link_change_notify(struct phy_device *phydev);
482482
void vsc8584_config_ts_intr(struct phy_device *phydev);
483483
int vsc8584_ptp_init(struct phy_device *phydev);
484+
void vsc8584_ptp_deinit(struct phy_device *phydev);
484485
int vsc8584_ptp_probe_once(struct phy_device *phydev);
485486
int vsc8584_ptp_probe(struct phy_device *phydev);
486487
irqreturn_t vsc8584_handle_ts_interrupt(struct phy_device *phydev);
@@ -495,6 +496,9 @@ static inline int vsc8584_ptp_init(struct phy_device *phydev)
495496
{
496497
return 0;
497498
}
499+
static inline void vsc8584_ptp_deinit(struct phy_device *phydev)
500+
{
501+
}
498502
static inline int vsc8584_ptp_probe_once(struct phy_device *phydev)
499503
{
500504
return 0;

drivers/net/phy/mscc/mscc_main.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2338,9 +2338,7 @@ static int vsc85xx_probe(struct phy_device *phydev)
23382338

23392339
static void vsc85xx_remove(struct phy_device *phydev)
23402340
{
2341-
struct vsc8531_private *priv = phydev->priv;
2342-
2343-
skb_queue_purge(&priv->rx_skbs_list);
2341+
vsc8584_ptp_deinit(phydev);
23442342
}
23452343

23462344
/* Microsemi VSC85xx PHYs */

drivers/net/phy/mscc/mscc_ptp.c

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1298,7 +1298,6 @@ static void vsc8584_set_input_clk_configured(struct phy_device *phydev)
12981298

12991299
static int __vsc8584_init_ptp(struct phy_device *phydev)
13001300
{
1301-
struct vsc8531_private *vsc8531 = phydev->priv;
13021301
static const u32 ltc_seq_e[] = { 0, 400000, 0, 0, 0 };
13031302
static const u8 ltc_seq_a[] = { 8, 6, 5, 4, 2 };
13041303
u32 val;
@@ -1515,17 +1514,7 @@ static int __vsc8584_init_ptp(struct phy_device *phydev)
15151514

15161515
vsc85xx_ts_eth_cmp1_sig(phydev);
15171516

1518-
vsc8531->mii_ts.rxtstamp = vsc85xx_rxtstamp;
1519-
vsc8531->mii_ts.txtstamp = vsc85xx_txtstamp;
1520-
vsc8531->mii_ts.hwtstamp = vsc85xx_hwtstamp;
1521-
vsc8531->mii_ts.ts_info = vsc85xx_ts_info;
1522-
phydev->mii_ts = &vsc8531->mii_ts;
1523-
1524-
memcpy(&vsc8531->ptp->caps, &vsc85xx_clk_caps, sizeof(vsc85xx_clk_caps));
1525-
1526-
vsc8531->ptp->ptp_clock = ptp_clock_register(&vsc8531->ptp->caps,
1527-
&phydev->mdio.dev);
1528-
return PTR_ERR_OR_ZERO(vsc8531->ptp->ptp_clock);
1517+
return 0;
15291518
}
15301519

15311520
void vsc8584_config_ts_intr(struct phy_device *phydev)
@@ -1552,6 +1541,16 @@ int vsc8584_ptp_init(struct phy_device *phydev)
15521541
return 0;
15531542
}
15541543

1544+
void vsc8584_ptp_deinit(struct phy_device *phydev)
1545+
{
1546+
struct vsc8531_private *vsc8531 = phydev->priv;
1547+
1548+
if (vsc8531->ptp->ptp_clock) {
1549+
ptp_clock_unregister(vsc8531->ptp->ptp_clock);
1550+
skb_queue_purge(&vsc8531->rx_skbs_list);
1551+
}
1552+
}
1553+
15551554
irqreturn_t vsc8584_handle_ts_interrupt(struct phy_device *phydev)
15561555
{
15571556
struct vsc8531_private *priv = phydev->priv;
@@ -1612,7 +1611,16 @@ int vsc8584_ptp_probe(struct phy_device *phydev)
16121611

16131612
vsc8531->ptp->phydev = phydev;
16141613

1615-
return 0;
1614+
vsc8531->mii_ts.rxtstamp = vsc85xx_rxtstamp;
1615+
vsc8531->mii_ts.txtstamp = vsc85xx_txtstamp;
1616+
vsc8531->mii_ts.hwtstamp = vsc85xx_hwtstamp;
1617+
vsc8531->mii_ts.ts_info = vsc85xx_ts_info;
1618+
phydev->mii_ts = &vsc8531->mii_ts;
1619+
1620+
memcpy(&vsc8531->ptp->caps, &vsc85xx_clk_caps, sizeof(vsc85xx_clk_caps));
1621+
vsc8531->ptp->ptp_clock = ptp_clock_register(&vsc8531->ptp->caps,
1622+
&phydev->mdio.dev);
1623+
return PTR_ERR_OR_ZERO(vsc8531->ptp->ptp_clock);
16161624
}
16171625

16181626
int vsc8584_ptp_probe_once(struct phy_device *phydev)

0 commit comments

Comments
 (0)