net: stmmac: cleanups
Subsystems (4)
cover net: stmmac: cleanups
Hi,
This series removes various redundant items in the stmmac driver:
- the unused TBI and RTBI PCS flags
- the NULL pointer initialisations for PCS methods in dwxgmac2
- the stmmac_pcs_rane() method which is never called, and it's associated implementations
- the redundant netif_carrier_off()s
Finally, it replaces asm/io.h with the preferred linux/io.h.
drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c | 8 +------- drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c | 8 -------- drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c | 6 ------ drivers/net/ethernet/stmicro/stmmac/hwif.h | 3 --- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 8 +------- drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h | 17 ----------------- 6 files changed, 2 insertions(+), 48 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: Drop TBI/RTBI PCS flags
From: Serge Semin <[email protected]>
First of all the flags are never set by any of the driver parts. If nobody have them set then the respective statements will always have the same result. Thus the statements can be simplified or even dropped with no risk to break things.
Secondly shall any of the TBI or RTBI flag is set the MDIO-bus registration will be bypassed. Why? It really seems weird. It's perfectly fine to have a TBI/RTBI-capable PHY configured over the MDIO bus interface.
Based on the notes above the TBI/RTBI PCS flags can be freely dropped thus simplifying the driver code.
--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +1 -4
@@ -7833,10 +7833,7 @@ void stmmac_dvr_remove(struct device *dev)reset_control_assert (priv->plat->stmmac_ahb_rst);stmmac_pcs_clean (ndev); - -if (priv->hw->pcs !=STMMAC_PCS_TBI && - priv->hw->pcs !=STMMAC_PCS_RTBI ) -stmmac_mdio_unregister (ndev); +stmmac_mdio_unregister (ndev);destroy_workqueue (priv->wq);mutex_destroy (&priv->lock);bitmap_free (priv->af_xdp_zc_qps);
Signature · 1 line
2.30.2
PATCH 2/5 net: stmmac: dwxgmac2: remove useless NULL pointer initialisations
In reply to Russell King (Oracle)Remove useless NULL pointer initialisations for "PCS" methods from the dwxgmac2 code.
--- drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c | 6 ------ 1 file changed, 6 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c +0 -6
@@ -1554,9 +1554,6 @@ const struct stmmac_ops dwxgmac210_ops = { .reset_eee_mode = dwxgmac2_reset_eee_mode, .set_eee_timer = dwxgmac2_set_eee_timer, .set_eee_pls = dwxgmac2_set_eee_pls, - .pcs_ctrl_ane = NULL, - .pcs_rane = NULL, - .pcs_get_adv_lp = NULL, .debug = NULL, .set_filter = dwxgmac2_set_filter, .safety_feat_config = dwxgmac3_safety_feat_config,
@@ -1614,9 +1611,6 @@ const struct stmmac_ops dwxlgmac2_ops = { .reset_eee_mode = dwxgmac2_reset_eee_mode, .set_eee_timer = dwxgmac2_set_eee_timer, .set_eee_pls = dwxgmac2_set_eee_pls, - .pcs_ctrl_ane = NULL, - .pcs_rane = NULL, - .pcs_get_adv_lp = NULL, .debug = NULL, .set_filter = dwxgmac2_set_filter, .safety_feat_config = dwxgmac3_safety_feat_config,
Signature · 1 line
2.30.2
PATCH 3/5 net: stmmac: remove pcs_rane() method
In reply to Russell King (Oracle)The pcs_rane() method is not called, so lets just remove this redundant code.
--- .../ethernet/stmicro/stmmac/dwmac1000_core.c | 6 ------ .../net/ethernet/stmicro/stmmac/dwmac4_core.c | 8 -------- drivers/net/ethernet/stmicro/stmmac/hwif.h | 3 --- .../net/ethernet/stmicro/stmmac/stmmac_pcs.h | 17 ----------------- 4 files changed, 34 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c +0 -6
@@ -404,11 +404,6 @@ static void dwmac1000_ctrl_ane(void __iomem *ioaddr, bool ane, bool srgmi_ral,dwmac_ctrl_ane (ioaddr,GMAC_PCS_BASE , ane, srgmi_ral, loopback); } -static void dwmac1000_rane (void __iomem *ioaddr,bool restart) -{ -dwmac_rane (ioaddr,GMAC_PCS_BASE , restart); -} -static void dwmac1000_get_adv_lp (void __iomem *ioaddr,struct rgmii_adv *adv) {dwmac_get_adv_lp (ioaddr,GMAC_PCS_BASE , adv);
@@ -519,7 +514,6 @@ const struct stmmac_ops dwmac1000_ops = { .set_eee_pls = dwmac1000_set_eee_pls, .debug = dwmac1000_debug, .pcs_ctrl_ane = dwmac1000_ctrl_ane, - .pcs_rane = dwmac1000_rane, .pcs_get_adv_lp = dwmac1000_get_adv_lp, .set_mac_loopback = dwmac1000_set_mac_loopback, };
drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c +0 -8
@@ -758,11 +758,6 @@ static void dwmac4_ctrl_ane(void __iomem *ioaddr, bool ane, bool srgmi_ral,dwmac_ctrl_ane (ioaddr,GMAC_PCS_BASE , ane, srgmi_ral, loopback); } -static void dwmac4_rane (void __iomem *ioaddr,bool restart) -{ -dwmac_rane (ioaddr,GMAC_PCS_BASE , restart); -} -static void dwmac4_get_adv_lp (void __iomem *ioaddr,struct rgmii_adv *adv) {dwmac_get_adv_lp (ioaddr,GMAC_PCS_BASE , adv);
@@ -1215,7 +1210,6 @@ const struct stmmac_ops dwmac4_ops = { .set_eee_timer = dwmac4_set_eee_timer, .set_eee_pls = dwmac4_set_eee_pls, .pcs_ctrl_ane = dwmac4_ctrl_ane, - .pcs_rane = dwmac4_rane, .pcs_get_adv_lp = dwmac4_get_adv_lp, .debug = dwmac4_debug, .set_filter = dwmac4_set_filter,
@@ -1260,7 +1254,6 @@ const struct stmmac_ops dwmac410_ops = { .set_eee_timer = dwmac4_set_eee_timer, .set_eee_pls = dwmac4_set_eee_pls, .pcs_ctrl_ane = dwmac4_ctrl_ane, - .pcs_rane = dwmac4_rane, .pcs_get_adv_lp = dwmac4_get_adv_lp, .debug = dwmac4_debug, .set_filter = dwmac4_set_filter,
@@ -1309,7 +1302,6 @@ const struct stmmac_ops dwmac510_ops = { .set_eee_timer = dwmac4_set_eee_timer, .set_eee_pls = dwmac4_set_eee_pls, .pcs_ctrl_ane = dwmac4_ctrl_ane, - .pcs_rane = dwmac4_rane, .pcs_get_adv_lp = dwmac4_get_adv_lp, .debug = dwmac4_debug, .set_filter = dwmac4_set_filter,
drivers/net/ethernet/stmicro/stmmac/hwif.h +0 -3
@@ -370,7 +370,6 @@ struct stmmac_ops {/* PCS calls */ void (*pcs_ctrl_ane)(void __iomem *ioaddr,bool ane,bool srgmi_ral,bool loopback); -void (*pcs_rane)(void __iomem *ioaddr,bool restart);void (*pcs_get_adv_lp)(void __iomem *ioaddr,struct rgmii_adv *adv);/* Safety Features */ int (*safety_feat_config)(void __iomem *ioaddr, unsigned int asp,
@@ -484,8 +483,6 @@ struct stmmac_ops { stmmac_do_void_callback(__priv, mac, debug, __priv, __args) #define stmmac_pcs_ctrl_ane(__priv, __args...) \ stmmac_do_void_callback(__priv, mac, pcs_ctrl_ane, __args) -#define stmmac_pcs_rane(__priv, __args...) \ - stmmac_do_void_callback(__priv, mac, pcs_rane, __priv, __args) #define stmmac_pcs_get_adv_lp(__priv, __args...) \ stmmac_do_void_callback(__priv, mac, pcs_get_adv_lp, __args) #define stmmac_safety_feat_config(__priv, __args...) \
drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h +0 -17
@@ -74,23 +74,6 @@ static inline void dwmac_pcs_isr(void __iomem *ioaddr, u32 reg, } } -/** -* dwmac_rane - To restart ANE -* @ioaddr: IO registers pointer -* @reg: Base address of the AN Control Register. -* @restart: to restart ANE -* Description: this is to just restart the Auto-Negotiation. -*/ -static inline void dwmac_rane (void __iomem *ioaddr,u32 reg,bool restart) -{ -u32 value =readl (ioaddr +GMAC_AN_CTRL (reg)); - -if (restart) - value |=GMAC_AN_CTRL_RAN ; - -writel (value, ioaddr +GMAC_AN_CTRL (reg)); -} -/** * dwmac_ctrl_ane - To program the AN Control Register. * @ioaddr: IO registers pointer
Signature · 1 line
2.30.2
PATCH 4/5 net: stmmac: remove unnecessary netif_carrier_off()
In reply to Russell King (Oracle)It is incorrect to call netif_carrier_off(), or in fact any driver teardown, before unregister_netdev() has been called.
unregister_netdev() unpublishes the network device from userspace, and takes the interface down if it was up prior to returning. Therefore, once the call has returned, we are guaranteed that .ndo_stop() will have been called for an interface that was up. Phylink will take the carrier down via phylink_stop(), making any manipulation of the carrier in the remove path unnecessary.
In the stmmac_release() path, the netif_carrier_off() call follows the call to phylink_stop(), so this call is redundant.
--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 3 --- 1 file changed, 3 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +0 -3
@@ -4097,8 +4097,6 @@ static int stmmac_release(struct net_device *dev)if (priv->plat->serdes_powerdown) priv->plat->serdes_powerdown (dev, priv->plat->bsp_priv); -netif_carrier_off (dev); -stmmac_release_ptp (priv);pm_runtime_put (priv->device);
@@ -7821,7 +7819,6 @@ void stmmac_dvr_remove(struct device *dev)stmmac_stop_all_dma (priv);stmmac_mac_set (priv, priv->ioaddr, false); -netif_carrier_off (ndev);unregister_netdev (ndev);#ifdef CONFIG_DEBUG_FS
Signature · 1 line
2.30.2
PATCH 5/5 net: stmmac: include linux/io.h rather than asm/io.h
In reply to Russell King (Oracle)Include linux/io.h instead of asm/io.h since linux/ includes are preferred.
--- drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c +1 -1
@@ -15,7 +15,7 @@#include <linux/crc32.h> #include <linux/slab.h> #include <linux/ethtool.h> -#include <asm/io.h> +#include <linux/io.h> #include "stmmac.h" #include "stmmac_pcs.h" #include "dwmac1000.h"
Signature · 1 line
2.30.2
Re: [PATCH net-next 1/5] net: stmmac: Drop TBI/RTBI PCS flags
In reply to Russell King (Oracle)Quoted 7 lines · Russell King
From: Serge Semin <[email protected]>
First of all the flags are never set by any of the driver parts. If nobody have them set then the respective statements will always have the same result. Thus the statements can be simplified or even dropped with no risk to break things.
Quoted 7 lines
Secondly shall any of the TBI or RTBI flag is set the MDIO-bus registration will be bypassed. Why? It really seems weird. It's perfectly fine to have a TBI/RTBI-capable PHY configured over the MDIO bus interface.
Based on the notes above the TBI/RTBI PCS flags can be freely dropped thus simplifying the driver code.
Likely by mistake the vast majority of the original patch content has been missing here:
https://lore.kernel.org/netdev/[email protected]/
-Serge(y)
Quoted 26 lines
Signed-off-by Serge Semin <[email protected]>Signed-off-by Russell King (Oracle) <[email protected]>--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +1
-4@@ -7833,10 +7833,7 @@ void stmmac_dvr_remove(struct device *dev)reset_control_assert (priv->plat->stmmac_ahb_rst);stmmac_pcs_clean (ndev); - -if (priv->hw->pcs !=STMMAC_PCS_TBI && - priv->hw->pcs !=STMMAC_PCS_RTBI ) -stmmac_mdio_unregister (ndev); +stmmac_mdio_unregister (ndev);destroy_workqueue (priv->wq);mutex_destroy (&priv->lock);bitmap_free (priv->af_xdp_zc_qps);Signature · 1 line
2.30.2
Re: [PATCH net-next 1/5] net: stmmac: Drop TBI/RTBI PCS flags
Quoted 13 lines · Serge Semin
Quoted 12 lines · Russell King
From: Serge Semin <[email protected]>
First of all the flags are never set by any of the driver parts. If nobody have them set then the respective statements will always have the same result. Thus the statements can be simplified or even dropped with no risk to break things.
Secondly shall any of the TBI or RTBI flag is set the MDIO-bus registration will be bypassed. Why? It really seems weird. It's perfectly fine to have a TBI/RTBI-capable PHY configured over the MDIO bus interface.
Quoted 6 lines
Quoted 2 lines
Based on the notes above the TBI/RTBI PCS flags can be freely dropped thus simplifying the driver code.
Likely by mistake the vast majority of the original patch content has been missing here:
https://lore.kernel.org/netdev/[email protected]/
I really can't explain this, other than git doing something weird. There is no reason that just one hunk that conflicted from a patch would've appeared. Should've been as per the below, which it will be when I post v2. Thanks for spotting!
8<===
From: Serge Semin <[email protected]>
Subject: [PATCH net-next] net: stmmac: Drop TBI/RTBI PCS flags
First of all the flags are never set by any of the driver parts. If nobody have them set then the respective statements will always have the same result. Thus the statements can be simplified or even dropped with no risk to break things.
Secondly shall any of the TBI or RTBI flag is set the MDIO-bus registration will be bypassed. Why? It really seems weird. It's perfectly fine to have a TBI/RTBI-capable PHY configured over the MDIO bus interface.
Based on the notes above the TBI/RTBI PCS flags can be freely dropped thus simplifying the driver code.
--- drivers/net/ethernet/stmicro/stmmac/common.h | 2 -- .../net/ethernet/stmicro/stmmac/stmmac_main.c | 35 +++++-------------- 2 files changed, 9 insertions(+), 28 deletions(-)
drivers/net/ethernet/stmicro/stmmac/common.h +0 -2
@@ -271,8 +271,6 @@ struct stmmac_safety_stats {/* PCS defines */ #define STMMAC_PCS_RGMII (1 << 0)#define STMMAC_PCS_SGMII (1 << 1) -#define STMMAC_PCS_TBI (1 << 2) -#define STMMAC_PCS_RTBI (1 << 3)#define SF_DMA_MODE 1/* DMA STORE-AND-FORWARD Operation Mode */
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +9 -26
@@ -471,13 +471,6 @@ bool stmmac_eee_init(struct stmmac_priv *priv) {int eee_tw_timer = priv->eee_tw_timer; -/* Using PCS we cannot dial with the phy registers at this stage -* so we do not support extra feature like EEE. -*/ -if (priv->hw->pcs ==STMMAC_PCS_TBI || - priv->hw->pcs ==STMMAC_PCS_RTBI ) -return false; -/* Check if MAC core supports the EEE feature. */ if (!priv->dma_cap.eee)return false;
@@ -3953,9 +3946,7 @@ static int __stmmac_open(struct net_device *dev,if (ret <0 )return ret; -if (priv->hw->pcs !=STMMAC_PCS_TBI && - priv->hw->pcs !=STMMAC_PCS_RTBI && - (!priv->hw->xpcs || +if ((!priv->hw->xpcs ||xpcs_get_an_mode (priv->hw->xpcs, mode) !=DW_AN_C73 )) { ret =stmmac_init_phy (dev);if (ret) {
@@ -7739,16 +7730,12 @@ int stmmac_dvr_probe(struct device *device,if (!pm_runtime_enabled (device))pm_runtime_enable (device); -if (priv->hw->pcs !=STMMAC_PCS_TBI && - priv->hw->pcs !=STMMAC_PCS_RTBI ) { -/* MDIO bus Registration */ - ret =stmmac_mdio_register (ndev); -if (ret <0 ) { -dev_err_probe (priv->device, ret, -"%s: MDIO bus (id: %d) registration failed\n" , - __func__, priv->plat->bus_id); - goto error_mdio_register; - } + ret =stmmac_mdio_register (ndev); +if (ret <0 ) { +dev_err_probe (priv->device, ret, +"MDIO bus (id: %d) registration failed\n" , + priv->plat->bus_id); + goto error_mdio_register; }if (priv->plat->speed_mode_2500)
@@ -7790,9 +7777,7 @@ int stmmac_dvr_probe(struct device *device, error_phy_setup:stmmac_pcs_clean (ndev); error_pcs_setup: -if (priv->hw->pcs !=STMMAC_PCS_TBI && - priv->hw->pcs !=STMMAC_PCS_RTBI ) -stmmac_mdio_unregister (ndev); +stmmac_mdio_unregister (ndev); error_mdio_register:stmmac_napi_del (ndev); error_hw_init:
@@ -7833,10 +7818,8 @@ void stmmac_dvr_remove(struct device *dev)reset_control_assert (priv->plat->stmmac_ahb_rst);stmmac_pcs_clean (ndev); +stmmac_mdio_unregister (ndev); -if (priv->hw->pcs !=STMMAC_PCS_TBI && - priv->hw->pcs !=STMMAC_PCS_RTBI ) -stmmac_mdio_unregister (ndev);destroy_workqueue (priv->wq);mutex_destroy (&priv->lock);bitmap_free (priv->af_xdp_zc_qps);
Signature · 6 lines
2.30.2 -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
Andrew Halaney
Reviewed-byRe: [PATCH net-next 1/5] net: stmmac: Drop TBI/RTBI PCS flags
Quoted 40 lines · Russell King (Oracle)
Quoted 13 lines · Serge Semin
Quoted 12 lines · Russell King
From: Serge Semin <[email protected]>
First of all the flags are never set by any of the driver parts. If nobody have them set then the respective statements will always have the same result. Thus the statements can be simplified or even dropped with no risk to break things.
Secondly shall any of the TBI or RTBI flag is set the MDIO-bus registration will be bypassed. Why? It really seems weird. It's perfectly fine to have a TBI/RTBI-capable PHY configured over the MDIO bus interface.
Quoted 6 lines
Quoted 2 lines
Based on the notes above the TBI/RTBI PCS flags can be freely dropped thus simplifying the driver code.
Likely by mistake the vast majority of the original patch content has been missing here:
https://lore.kernel.org/netdev/[email protected]/I really can't explain this, other than git doing something weird. There is no reason that just one hunk that conflicted from a patch would've appeared. Should've been as per the below, which it will be when I post v2. Thanks for spotting!
8<===
From: Serge Semin <[email protected]>
Subject: [PATCH net-next] net: stmmac: Drop TBI/RTBI PCS flagsFirst of all the flags are never set by any of the driver parts. If nobody have them set then the respective statements will always have the same result. Thus the statements can be simplified or even dropped with no risk to break things.
Secondly shall any of the TBI or RTBI flag is set the MDIO-bus registration will be bypassed. Why? It really seems weird. It's perfectly fine to have a TBI/RTBI-capable PHY configured over the MDIO bus interface.
Quoted 5 lines
Based on the notes above the TBI/RTBI PCS flags can be freely dropped thus simplifying the driver code.
Signed-off-by Serge Semin <[email protected]>Signed-off-by Russell King (Oracle) <[email protected]>
Re: [PATCH net-next 2/5] net: stmmac: dwxgmac2: remove useless NULL pointer initialisations
In reply to Russell King (Oracle)Quoted 4 lines · Russell King (Oracle)
Remove useless NULL pointer initialisations for "PCS" methods from the dwxgmac2 code.
Signed-off-by Russell King (Oracle) <[email protected]>
Re: [PATCH net-next 3/5] net: stmmac: remove pcs_rane() method
In reply to Russell King (Oracle)Quoted 4 lines · Russell King (Oracle)
The
pcs_rane()method is not called, so lets just remove this redundant code.Signed-off-by Russell King (Oracle) <[email protected]>
Re: [PATCH net-next 4/5] net: stmmac: remove unnecessary netif_carrier_off()
In reply to Russell King (Oracle)Quoted 10 lines · Russell King (Oracle)
It is incorrect to call
netif_carrier_off(), or in fact any driver teardown, beforeunregister_netdev()has been called.
unregister_netdev()unpublishes the network device from userspace, and takes the interface down if it was up prior to returning. Therefore, once the call has returned, we are guaranteed that .ndo_stop() will have been called for an interface that was up. Phylink will take the carrier down viaphylink_stop(), making any manipulation of the carrier in the remove path unnecessary.
Quoted 4 lines
In the
stmmac_release()path, thenetif_carrier_off()call follows the call tophylink_stop(), so this call is redundant.Signed-off-by Russell King (Oracle) <[email protected]>
Re: [PATCH net-next 5/5] net: stmmac: include linux/io.h rather than asm/io.h
In reply to Russell King (Oracle)Quoted 4 lines · Russell King (Oracle)
Include
linux/io.hinstead ofasm/io.hsince linux/ includes are preferred.Signed-off-by Russell King (Oracle) <[email protected]>
drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c
Quoted 8 lines
--- drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c +0
-0
Any reason you didn't wanna treat the other examples of this similarly?
ahalaney@x1gen2nano ~/git/linux-next (git)-[tags/next-20240528] % git grep "asm/io.h" drivers/net/ethernet/stmicro/stmmac/
drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c:#include <asm/io.h>
drivers/net/ethernet/stmicro/stmmac/dwmac1000_dma.c:#include <asm/io.h>
drivers/net/ethernet/stmicro/stmmac/dwmac100_core.c:#include <asm/io.h>
drivers/net/ethernet/stmicro/stmmac/dwmac100_dma.c:#include <asm/io.h>
drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c:#include <asm/io.h>
ahalaney@x1gen2nano ~/git/linux-next (git)-[tags/next-20240528] % Thanks for the series,
Andrew
Quoted 12 lines
drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c +1
-1@@ -15,7 +15,7 @@#include <linux/crc32.h> #include <linux/slab.h> #include <linux/ethtool.h> -#include <asm/io.h> +#include <linux/io.h> #include "stmmac.h" #include "stmmac_pcs.h" #include "dwmac1000.h" Signature · 1 line
2.30.2