net: stmmac: remove unnecessary initialisation of 1µs TIC counter
Subsystems (4)
cover net: stmmac: remove unnecessary initialisation of 1µs TIC counter
Hi,
In commit 8efbdbfa9938 ("net: stmmac: Initialize MAC_ONEUS_TIC_COUNTER register"), code to initialise the LPI 1us counter in dwmac4's initialisation was added, making the initialisation in glue drivers unnecessary. This series cleans up the now redundant initialisation.
.../ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c | 24 +--------------------- .../net/ethernet/stmicro/stmmac/dwmac-intel-plat.c | 9 -------- drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c | 8 -------- drivers/net/ethernet/stmicro/stmmac/dwmac4.h | 1 - include/linux/stmmac.h | 1 - 5 files changed, 1 insertion(+), 42 deletions(-)
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
PATCH 1/5 net: stmmac: dwc-qos: remove tegra_eqos_init()
tegra_eqos_init() initialises the 1US TIC counter for the EEE timers. However, the DWGMAC core is reset after this write, which clears this register to its default.
However, dwmac4_core_init() configures this register using the same clock, which happens after reset - thus this is the write which ensures that the register is correctly configured.
Therefore, tegra_eqos_init() is not required and is removed. This also means eqos->clk_slave can also be removed.
--- .../stmicro/stmmac/dwmac-dwc-qos-eth.c | 24 +------------------ 1 file changed, 1 insertion(+), 23 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c +1 -23
@@ -29,7 +29,6 @@ struct tegra_eqos {void __iomem *regs;struct reset_control *rst; -struct clk *clk_slave;struct gpio_desc *reset; };
@@ -199,20 +198,6 @@ static void tegra_eqos_fix_speed(void *priv, int speed, unsigned int mode) } } -static int tegra_eqos_init (struct platform_device *pdev,void *priv) -{ -struct tegra_eqos *eqos = priv; -unsigned long rate; -u32 value; - - rate =clk_get_rate (eqos->clk_slave); - - value = (rate /1000000 ) -1 ; -writel (value, eqos->regs +GMAC_1US_TIC_COUNTER ); - -return 0 ; -} -static int tegra_eqos_probe (struct platform_device *pdev,struct plat_stmmacenet_data *plat_dat,struct stmmac_resources *res)
@@ -227,7 +212,6 @@ static int tegra_eqos_probe(struct platform_device *pdev, eqos->dev = &pdev->dev; eqos->regs = res->addr; - eqos->clk_slave = plat_dat->stmmac_clk;if (!is_of_node (dev->fwnode)) goto bypass_clk_reset_gpio;
@@ -267,18 +251,12 @@ static int tegra_eqos_probe(struct platform_device *pdev, bypass_clk_reset_gpio: plat_dat->fix_mac_speed = tegra_eqos_fix_speed; plat_dat->set_clk_tx_rate = stmmac_set_clk_tx_rate; - plat_dat->init = tegra_eqos_init; plat_dat->bsp_priv = eqos; plat_dat->flags |=STMMAC_FLAG_SPH_DISABLE |STMMAC_FLAG_EN_TX_LPI_CLK_PHY_CAP ; - err =tegra_eqos_init (pdev, eqos); -if (err <0 ) - goto reset; -return 0 ; -reset: -reset_control_assert (eqos->rst); + reset_phy:gpiod_set_value (eqos->reset,1 );
Signature · 1 line
2.30.2
PATCH 2/5 net: stmmac: intel: remove eee_usecs_rate and hardware write
In reply to Russell King (Oracle)Remove the write to GMAC_1US_TIC_COUNTER for two reasons:
1. during initialisation or reinitialisation of the DWMAC core, the core is reset, which sets this register back to its default value. Writing it prior to stmmac_dvr_probe() has no effect.
2. Since commit 8efbdbfa9938 ("net: stmmac: Initialize MAC_ONEUS_TIC_COUNTER register"), GMAC4/5 core code will set this register based on the rate of plat->stmmac_clk. This clock is created by the same code which initialises plat->eee_usecs_rate, which is also created to run at this same rate. Since Marek's commit, this will set this register appropriately using the rate of this clock.
Therefore, dwmac-intel.c writing GMAC_1US_TIC_COUNTER serves no useful purpose and can be removed.
--- drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c | 8 -------- 1 file changed, 8 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c +0 -8
@@ -682,7 +682,6 @@ static int intel_mgbe_common_data(struct pci_dev *pdev, plat->axi->axi_blen[2 ] =16 ; plat->ptp_max_adj = plat->clk_ptp_rate; - plat->eee_usecs_rate = plat->clk_ptp_rate;/* Set system clock */ sprintf (clk_name,"%s-%s" ,"stmmac" ,pci_name (pdev));
@@ -1313,13 +1312,6 @@ static int intel_eth_pci_probe(struct pci_dev *pdev,memset (&res,0 ,sizeof (res)); res.addr =pcim_iomap_table (pdev)[0 ]; -if (plat->eee_usecs_rate >0 ) { -u32 tx_lpi_usec; - - tx_lpi_usec = (plat->eee_usecs_rate /1000000 ) -1 ; -writel (tx_lpi_usec, res.addr +GMAC_1US_TIC_COUNTER ); - } - ret =stmmac_config_multi_msi (pdev, plat, &res);if (ret) { ret =stmmac_config_single_msi (pdev, plat, &res);
Signature · 1 line
2.30.2
PATCH 3/5 net: stmmac: intel-plat: remove eee_usecs_rate and hardware write
In reply to Russell King (Oracle)Remove the write to GMAC_1US_TIC_COUNTER for two reasons:
1. during initialisation or reinitialisation of the DWMAC core, the core is reset, which sets this register back to its default value. Writing it prior to stmmac_dvr_probe() has no effect.
2. Since commit 8efbdbfa9938 ("net: stmmac: Initialize MAC_ONEUS_TIC_COUNTER register"), GMAC4/5 core code will set this register based on the rate of plat->stmmac_clk. This clock is fetched by devm_stmmac_probe_config_dt(), and plat->clk_ptp_rate will be set to its rate profided a "ptp_ref" clock is not provided. In any case, Marek's commit will set the effectual value of this register.
Therefore, dwmac-intel-plat.c writing GMAC_1US_TIC_COUNTER serves no useful purpose and can be removed.
--- drivers/net/ethernet/stmicro/stmmac/dwmac-intel-plat.c | 9 --------- 1 file changed, 9 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-intel-plat.c +0 -9
@@ -113,16 +113,7 @@ static int intel_eth_plat_probe(struct platform_device *pdev) plat_dat->clk_tx_i = dwmac->tx_clk; plat_dat->set_clk_tx_rate = stmmac_set_clk_tx_rate; - plat_dat->bsp_priv = dwmac; - plat_dat->eee_usecs_rate = plat_dat->clk_ptp_rate; - -if (plat_dat->eee_usecs_rate >0 ) { -u32 tx_lpi_usec; - - tx_lpi_usec = (plat_dat->eee_usecs_rate /1000000 ) -1 ; -writel (tx_lpi_usec, stmmac_res.addr +GMAC_1US_TIC_COUNTER ); - } ret =stmmac_dvr_probe (&pdev->dev, plat_dat, &stmmac_res);if (ret)
Signature · 1 line
2.30.2
PATCH 4/5 net: stmmac: remove eee_usecs_rate
In reply to Russell King (Oracle)plat_dat->eee_users_rate is now unused, so remove this member.
--- include/linux/stmmac.h | 1 - 1 file changed, 1 deletion(-)
include/linux/stmmac.h +0 -1
@@ -276,7 +276,6 @@ struct plat_stmmacenet_data {int mac_port_sel_speed;int has_xgmac;u8 vlan_fail_q; -unsigned long eee_usecs_rate;struct pci_dev *pdev;int int_snapshot_num;int msi_mac_vec;
Signature · 1 line
2.30.2
PATCH 5/5 net: stmmac: remove GMAC_1US_TIC_COUNTER definition
In reply to Russell King (Oracle)GMAC_1US_TIC_COUNTER is now no longer used, so remove the definition. This was duplicated by GMAC4_MAC_ONEUS_TIC_COUNTER further down in the same file.
--- drivers/net/ethernet/stmicro/stmmac/dwmac4.h | 1 - 1 file changed, 1 deletion(-)
drivers/net/ethernet/stmicro/stmmac/dwmac4.h +0 -1
@@ -31,7 +31,6 @@#define GMAC_RXQ_CTRL3 0x000000ac#define GMAC_INT_STATUS 0x000000b0#define GMAC_INT_EN 0x000000b4 -#define GMAC_1US_TIC_COUNTER 0x000000dc#define GMAC_PCS_BASE 0x000000e0#define GMAC_PHYIF_CONTROL_STATUS 0x000000f8#define GMAC_PMT 0x000000c0
Signature · 1 line
2.30.2
Re: [PATCH net-next 1/5] net: stmmac: dwc-qos: remove tegra_eqos_init()
In reply to Russell King (Oracle)Quoted 4 lines · Russell King (Oracle)
tegra_eqos_init()initialises the 1US TIC counter for the EEE timers. However, the DWGMAC core is reset after this write, which clears this register to its default.
Quoted 8 lines
However,
dwmac4_core_init()configures this register using the same clock, which happens after reset - thus this is the write which ensures that the register is correctly configured.Therefore,
tegra_eqos_init()is not required and is removed. This also meanseqos->clk_slavecan also be removed.Signed-off-by Russell King (Oracle) <[email protected]>
Andrew
Re: [PATCH net-next 2/5] net: stmmac: intel: remove eee_usecs_rate and hardware write
In reply to Russell King (Oracle)Quoted 14 lines · Russell King (Oracle)
Remove the write to
GMAC_1US_TIC_COUNTERfor two reasons:1. during initialisation or reinitialisation of the DWMAC core, the core is reset, which sets this register back to its default value. Writing it prior to
stmmac_dvr_probe()has no effect.2. Since commit
8efbdbfa9938("net: stmmac: InitializeMAC_ONEUS_TIC_COUNTERregister"), GMAC4/5 core code will set this register based on the rate ofplat->stmmac_clk. This clock is created by the same code which initialisesplat->eee_usecs_rate, which is also created to run at this same rate. Since Marek's commit, this will set this register appropriately using the rate of this clock.
Quoted 4 lines
Therefore,
dwmac-intel.cwritingGMAC_1US_TIC_COUNTERserves no useful purpose and can be removed.Signed-off-by Russell King (Oracle) <[email protected]>
Andrew
Re: [PATCH net-next 3/5] net: stmmac: intel-plat: remove eee_usecs_rate and hardware write
In reply to Russell King (Oracle)Quoted 14 lines · Russell King (Oracle)
Remove the write to
GMAC_1US_TIC_COUNTERfor two reasons:1. during initialisation or reinitialisation of the DWMAC core, the core is reset, which sets this register back to its default value. Writing it prior to
stmmac_dvr_probe()has no effect.2. Since commit
8efbdbfa9938("net: stmmac: InitializeMAC_ONEUS_TIC_COUNTERregister"), GMAC4/5 core code will set this register based on the rate ofplat->stmmac_clk. This clock is fetched bydevm_stmmac_probe_config_dt(), andplat->clk_ptp_ratewill be set to its rate profided a "ptp_ref" clock is not provided. In any case, Marek's commit will set the effectual value of this register.
Quoted 4 lines
Therefore,
dwmac-intel-plat.cwritingGMAC_1US_TIC_COUNTERserves no useful purpose and can be removed.Signed-off-by Russell King (Oracle) <[email protected]>
Andrew
Re: [PATCH net-next 4/5] net: stmmac: remove eee_usecs_rate
In reply to Russell King (Oracle)Quoted 3 lines · Russell King (Oracle)
plat_dat->eee_users_rateis now unused, so remove this member.Signed-off-by Russell King (Oracle) <[email protected]>
Andrew
Re: [PATCH net-next 5/5] net: stmmac: remove GMAC_1US_TIC_COUNTER definition
In reply to Russell King (Oracle)Quoted 5 lines · Russell King (Oracle)
GMAC_1US_TIC_COUNTERis now no longer used, so remove the definition. This was duplicated byGMAC4_MAC_ONEUS_TIC_COUNTERfurther down in the same file.Signed-off-by Russell King (Oracle) <[email protected]>
Andrew
Jakub Kicinski
maintainerQuoted 4 lines · On Mon, 7 Apr 2025 19:58:01 +0100 Russell King (Oracle) wrote:
In commit
8efbdbfa9938("net: stmmac: InitializeMAC_ONEUS_TIC_COUNTERregister"), code to initialise the LPI 1us counter in dwmac4's initialisation was added, making the initialisation in glue drivers unnecessary. This series cleans up the now redundant initialisation.
Failed to apply patch:
Applying: net: stmmac: dwc-qos: remove tegra_eqos_init()
error: sha1 information is lacking or useless (drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c).
error: could not build fake ancestor
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
Patch failed at 0001 net: stmmac: dwc-qos: remove tegra_eqos_init()
Signature · 1 line
pw-bot: cr