Fix PTP issue in stmmac
Subsystems (5)
cover Fix PTP issue in stmmac
This patch series to fix PTP issue in stmmac related to:
1/ PTP clock source configuration during initialization. 2/ PTP initialization during resume from suspend.
Mohammad Athari Bin Ismail (2):
net: stmmac: configure PTP clock source prior to PTP initialization
net: stmmac: skip only stmmac_ptp_register when resume from suspend
.../net/ethernet/stmicro/stmmac/stmmac_main.c | 25 +++++++++++-------- .../net/ethernet/stmicro/stmmac/stmmac_ptp.c | 3 --- 2 files changed, 14 insertions(+), 14 deletions(-)
Signature · 7 lines
2.17.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH 1/2 net: stmmac: configure PTP clock source prior to PTP initialization
For Intel platform, it is required to configure PTP clock source prior PTP initialization in MAC. So, need to move ptp_clk_freq_config execution from stmmac_ptp_register() to stmmac_init_ptp().
--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 3 +++ drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c | 3 --- 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +3 -0
@@ -889,6 +889,9 @@ static int stmmac_init_ptp(struct stmmac_priv *priv)bool xmac = priv->plat->has_gmac4 || priv->plat->has_xgmac;int ret; +if (priv->plat->ptp_clk_freq_config) + priv->plat->ptp_clk_freq_config (priv); + ret =stmmac_init_tstamp_counter (priv,STMMAC_HWTS_ACTIVE );if (ret)return ret;
drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c +0 -3
@@ -297,9 +297,6 @@ void stmmac_ptp_register(struct stmmac_priv *priv) {int i; -if (priv->plat->ptp_clk_freq_config) - priv->plat->ptp_clk_freq_config (priv); -for (i =0 ; i < priv->dma_cap.pps_out_num; i++) {if (i >=STMMAC_PPS_MAX )break ;
Signature · 7 lines
2.17.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v2 2/2 net: stmmac: skip only stmmac_ptp_register when resume from suspend
In reply to Mohammad Athari Bin IsmailWhen resume from suspend, besides skipping PTP registration, it also skipping PTP HW initialization. This could cause PTP clock not able to operate properly when resume from suspend.
To fix this, only stmmac_ptp_register() is skipped when resume from suspend.
---
v2 changelog:
- Fix build warning related to "function parameter or member not described".
--- .../net/ethernet/stmicro/stmmac/stmmac_main.c | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +11 -11
@@ -880,11 +880,12 @@ EXPORT_SYMBOL_GPL(stmmac_init_tstamp_counter);/** * stmmac_init_ptp - init PTP * @priv: driver private structure +* @ptp_register: register PTP if set * Description: this is to verify if the HW supports the PTPv1 or PTPv2. * This is done by looking at the HW cap. register. * This function also registers the ptp driver. */ -static int stmmac_init_ptp (struct stmmac_priv *priv) +static int stmmac_init_ptp (struct stmmac_priv *priv,bool ptp_register) {bool xmac = priv->plat->has_gmac4 || priv->plat->has_xgmac;int ret;
@@ -914,7 +915,8 @@ static int stmmac_init_ptp(struct stmmac_priv *priv) priv->hwts_tx_en =0 ; priv->hwts_rx_en =0 ; -stmmac_ptp_register (priv); +if (ptp_register) +stmmac_ptp_register (priv);return 0 ; }
@@ -3241,7 +3243,7 @@ static int stmmac_fpe_start_wq(struct stmmac_priv *priv)/** * stmmac_hw_setup - setup mac in a usable state. * @dev : pointer to the device structure. -* @init_ptp: initialize PTP if set +* @ptp_register: register PTP if set * Description: * this is the main function to setup the HW in a usable state because the * dma engine is reset, the core registers are configured (e.g. AXI,
@@ -3251,7 +3253,7 @@ static int stmmac_fpe_start_wq(struct stmmac_priv *priv)* 0 on success and an appropriate (-)ve integer as defined in errno.h * file on failure. */ -static int stmmac_hw_setup (struct net_device *dev,bool init_ptp) +static int stmmac_hw_setup (struct net_device *dev,bool ptp_register) {struct stmmac_priv *priv =netdev_priv (dev);u32 rx_cnt = priv->plat->rx_queues_to_use;
@@ -3308,13 +3310,11 @@ static int stmmac_hw_setup(struct net_device *dev, bool init_ptp)stmmac_mmc_setup (priv); -if (init_ptp) { - ret =stmmac_init_ptp (priv); -if (ret == -EOPNOTSUPP ) -netdev_warn (priv->dev,"PTP not supported by HW\n" ); -else if (ret) -netdev_warn (priv->dev,"PTP init failed\n" ); - } + ret =stmmac_init_ptp (priv, ptp_register); +if (ret == -EOPNOTSUPP ) +netdev_warn (priv->dev,"PTP not supported by HW\n" ); +else if (ret) +netdev_warn (priv->dev,"PTP init failed\n" ); priv->eee_tw_timer =STMMAC_DEFAULT_TWT_LS ;
Signature · 7 lines
2.17.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Jakub Kicinski
maintainerRe: [PATCH net v2 2/2] net: stmmac: skip only stmmac_ptp_register when resume from suspend
Quoted 19 lines · On Tue, 25 Jan 2022 11:23:24 +0800 Mohammad Athari Bin Ismail wrote:
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +2
-1@@ -880,11 +880,12 @@ EXPORT_SYMBOL_GPL(stmmac_init_tstamp_counter);/** * stmmac_init_ptp - init PTP * @priv: driver private structure +* @ptp_register: register PTP if set * Description: this is to verify if the HW supports the PTPv1 or PTPv2. * This is done by looking at the HW cap. register. * This function also registers the ptp driver. */ -static int stmmac_init_ptp (struct stmmac_priv *priv) +static int stmmac_init_ptp (struct stmmac_priv *priv,bool ptp_register) {bool xmac = priv->plat->has_gmac4 || priv->plat->has_xgmac;int ret;
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c static int stmmac_init_ptp(struct stmmac_priv *priv) · line 919
Quoted 6 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +2
-1@@ -914,7 +915,8 @@ static int stmmac_init_ptp(struct stmmac_priv *priv) priv->hwts_tx_en =0 ; priv->hwts_rx_en =0 ; -stmmac_ptp_register (priv); +if (ptp_register) +stmmac_ptp_register (priv);
stmmac_init_ptp() only has one caller, and the registration step is last. Wouldn't it be better to move the stmmac_ptp_register() call out to stmmac_hw_setup()? That way we don't need to pass extra arguments to init.
Quoted 36 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +7
-9return 0 ; }@@ -3241,7 +3243,7 @@ static int stmmac_fpe_start_wq(struct stmmac_priv *priv)/** * stmmac_hw_setup - setup mac in a usable state. * @dev : pointer to the device structure. -* @init_ptp: initialize PTP if set +* @ptp_register: register PTP if set * Description: * this is the main function to setup the HW in a usable state because the * dma engine is reset, the core registers are configured (e.g. AXI, @@ -3251,7 +3253,7 @@ static int stmmac_fpe_start_wq(struct stmmac_priv *priv)* 0 on success and an appropriate (-)ve integer as defined in errno.h * file on failure. */ -static int stmmac_hw_setup (struct net_device *dev,bool init_ptp) +static int stmmac_hw_setup (struct net_device *dev,bool ptp_register) {struct stmmac_priv *priv =netdev_priv (dev);u32 rx_cnt = priv->plat->rx_queues_to_use;@@ -3308,13 +3310,11 @@ static int stmmac_hw_setup(struct net_device *dev, bool init_ptp)stmmac_mmc_setup (priv); -if (init_ptp) { - ret =stmmac_init_ptp (priv); -if (ret == -EOPNOTSUPP ) -netdev_warn (priv->dev,"PTP not supported by HW\n" ); -else if (ret) -netdev_warn (priv->dev,"PTP init failed\n" ); - } + ret =stmmac_init_ptp (priv, ptp_register); +if (ret == -EOPNOTSUPP ) +netdev_warn (priv->dev,"PTP not supported by HW\n" ); +else if (ret) +netdev_warn (priv->dev,"PTP init failed\n" );
RE: [PATCH net v2 2/2] net: stmmac: skip only stmmac_ptp_register when resume from suspend
Quoted 46 lines
-----Original Message-----
From: Jakub Kicinski <[email protected]>
Sent: Wednesday, January 26, 2022 12:18 PM
To: Ismail, Mohammad Athari <[email protected]>
Cc: Giuseppe Cavallaro <[email protected]>; Alexandre Torgue <[email protected]>; Jose Abreu <[email protected]>; David S . Miller <[email protected]>; Maxime Coquelin <[email protected]>; Ong, Boon Leong <[email protected]>; Voon, Weifeng <[email protected]>; Wong, Vee Khee <[email protected]>; Huacai Chen <[email protected]>; Alexandre Torgue <[email protected]>; [email protected]; linux-stm32@st- md-mailman.stormreply.com; [email protected]; linux- [email protected]; [email protected]
Subject: Re: [PATCH net v2 2/2] net: stmmac: skip onlystmmac_ptp_registerwhen resume from suspenddrivers/net/ethernet/stmicro/stmmac/stmmac_main.c
Quoted 6 lines · On Tue, 25 Jan 2022 11:23:24 +0800 Mohammad Athari Bin Ismail wrote:
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +0
-0@@ -880,11 +880,12 @@
EXPORT_SYMBOL_GPL(stmmac_init_tstamp_counter);drivers/net/ethernet/stmicro/stmmac/stmmac_main.c static int stmmac_init_ptp(struct stmmac_priv
Quoted 15 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +3
-1/** * stmmac_init_ptp - init PTP * @priv: driver private structure +* @ptp_register: register PTP if set * Description: this is to verify if the HW supports the PTPv1 or PTPv2. * This is done by looking at the HW cap. register. * This function also registers the ptp driver. */ -static int stmmac_init_ptp (struct stmmac_priv *priv) +static int stmmac_init_ptp (struct stmmac_priv *priv,bool +ptp_register) {bool xmac = priv->plat->has_gmac4 || priv->plat->has_xgmac;int ret;@@ -914,7 +915,8 @@ static int stmmac_init_ptp(struct stmmac_priv*priv)
Quoted 3 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +0
-0priv->hwts_tx_en =0 ; priv->hwts_rx_en =0 ;
Quoted 8 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c static int stmmac_init_ptp(struct stmmac_priv *priv) · line 919
Quoted 3 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +2
-1-stmmac_ptp_register (priv); +if (ptp_register) +stmmac_ptp_register (priv);
stmmac_init_ptp()only has one caller, and the registration step is last. Wouldn't it be better to move thestmmac_ptp_register()call out tostmmac_hw_setup()? That way we don't need to pass extra arguments to init.
Yes agree with you suggestion. Will fix it in v3. Thanks.
-Athari-
Quoted 41 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c static int stmmac_fpe_start_wq(struct
Quoted 14 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +1
-1return 0 ; }@@ -3241,7 +3243,7 @@ static int stmmac_fpe_start_wq(struct stmmac_priv *priv)/** * stmmac_hw_setup - setup mac in a usable state. * @dev : pointer to the device structure. -* @init_ptp: initialize PTP if set +* @ptp_register: register PTP if set * Description: * this is the main function to setup the HW in a usable state because the * dma engine is reset, the core registers are configured (e.g. AXI,
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +0
-0@@ -3251,7 +3253,7 @@ static int stmmac_fpe_start_wq(struct
stmmac_priv*priv)drivers/net/ethernet/stmicro/stmmac/stmmac_main.c static int stmmac_fpe_start_wq(struct stmmac_priv *priv)
Quoted 8 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +1
-1* 0 on success and an appropriate (-)ve integer as defined in errno.h * file on failure. */ -static int stmmac_hw_setup (struct net_device *dev,bool init_ptp) +static int stmmac_hw_setup (struct net_device *dev,bool ptp_register) {struct stmmac_priv *priv =netdev_priv (dev); u32 rx_cnt = priv->plat->rx_queues_to_use; @@ -3308,13 +3310,11@@
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c static int stmmac_hw_setup(struct net_device *dev, bool init_ptp)
Quoted 8 lines
static int
stmmac_hw_setup(struct net_device *dev, bool init_ptp)drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +0
-4stmmac_mmc_setup (priv); -if (init_ptp) { - ret =stmmac_init_ptp (priv); -if (ret == -EOPNOTSUPP ) - netdev_warn(priv->dev, "PTP not supported byHW\n");
Quoted 8 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +5
-3-else if (ret) -netdev_warn (priv->dev,"PTP init failed\n" ); - } + ret =stmmac_init_ptp (priv, ptp_register); +if (ret == -EOPNOTSUPP ) +netdev_warn (priv->dev,"PTP not supported by HW\n" ); +else if (ret) +netdev_warn (priv->dev,"PTP init failed\n" );