Fix kernel freeze when probing stmmac devices
Subsystems (3)
cover Fix kernel freeze when probing stmmac devices
Fix kernel freeze reproduced when probing stmmac devices on kernel 4.19:
Upstream commit 474a31e13a4e9749fb3ee55794d69d0f17ee0998 to fix freeze and upstream commit 8d72ab119f42f25abb393093472ae0ca275088b6 to apply the fix correctly.
PATCH 1/2 stmmac: no need to check return value of debugfs_create functions
From: Greg Kroah-Hartman <[email protected]>
[ Upstream commit 8d72ab119f42f25abb393093472ae0ca275088b6 ]
When calling debugfs functions, there is no need to ever check the return value. The function can work or not, but the code logic should never do something different based on this.
Because we don't care about the individual files, we can remove the stored dentry for the files, as they are not needed to be kept track of at all.
--- drivers/net/ethernet/stmicro/stmmac/stmmac.h | 2 - .../net/ethernet/stmicro/stmmac/stmmac_main.c | 52 +++---------------- 2 files changed, 8 insertions(+), 46 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac.h +0 -2
@@ -188,8 +188,6 @@ struct stmmac_priv {#ifdef CONFIG_DEBUG_FS struct dentry *dbgfs_dir; -struct dentry *dbgfs_rings_status; -struct dentry *dbgfs_dma_cap;#endif unsigned long state;
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +8 -44
88 lines not on this page · raw message
Signature · 1 line
2.25.1
Re: [PATCH stmmac 4.19 1/2] stmmac: no need to check return value of debugfs_create functions
Quoted 22 lines · On 2/15/2024 7:15 AM, [email protected] wrote:
From: Greg Kroah-Hartman <[email protected]>
[ Upstream commit
8d72ab119f42f25abb393093472ae0ca275088b6]When calling debugfs functions, there is no need to ever check the return value. The function can work or not, but the code logic should never do something different based on this.
Because we don't care about the individual files, we can remove the stored dentry for the files, as they are not needed to be kept track of at all.
Cc Giuseppe Cavallaro <[email protected]>Cc Alexandre Torgue <[email protected]>Cc Jose Abreu <[email protected]>Cc "David S. Miller" <[email protected]>Cc Maxime Coquelin <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>Signed-off-by David S. Miller <[email protected]>Signed-off-by Hugo SIMELIERE <[email protected]>
Quoted 1 line
---
PATCH 2/2 net: stmmac: fix notifier registration
In reply to [email protected]From: Aaro Koskinen <[email protected]>
[ Upstream commit 474a31e13a4e9749fb3ee55794d69d0f17ee0998 ]
We cannot register the same netdev notifier multiple times when probing stmmac devices. Register the notifier only once in module init, and also make debugfs creation/deletion safe against simultaneous notifier call.
--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +8 -5
@@ -4067,6 +4067,8 @@ static void stmmac_init_fs(struct net_device *dev) {struct stmmac_priv *priv =netdev_priv (dev); +rtnl_lock (); +/* Create per netdev entries */ priv->dbgfs_dir =debugfs_create_dir (dev->name, stmmac_fs_dir);
@@ -4078,14 +4080,13 @@ static void stmmac_init_fs(struct net_device *dev)debugfs_create_file ("dma_cap" ,0444 , priv->dbgfs_dir, dev, &stmmac_dma_cap_fops); - register_netdevice_notifier(&stmmac_notifier); + rtnl_unlock(); }static void stmmac_exit_fs (struct net_device *dev) {struct stmmac_priv *priv =netdev_priv (dev); -unregister_netdevice_notifier (&stmmac_notifier);debugfs_remove_recursive (priv->dbgfs_dir); }#endif /* CONFIG_DEBUG_FS */
@@ -4455,14 +4456,14 @@ int stmmac_dvr_remove(struct device *dev)netdev_info (priv->dev,"%s: removing driver" , __func__); -#ifdef CONFIG_DEBUG_FS -stmmac_exit_fs (ndev); -#endif stmmac_stop_all_dma (priv);stmmac_mac_set (priv, priv->ioaddr, false);netif_carrier_off (ndev);unregister_netdev (ndev); +#ifdef CONFIG_DEBUG_FS +stmmac_exit_fs (ndev); +#endif if (priv->plat->stmmac_rst)reset_control_assert (priv->plat->stmmac_rst);clk_disable_unprepare (priv->plat->pclk);
@@ -4679,6 +4680,7 @@ static int __init stmmac_init(void)/* Create debugfs main directory if it doesn't exist yet */ if (!stmmac_fs_dir) stmmac_fs_dir =debugfs_create_dir (STMMAC_RESOURCE_NAME ,NULL ); +register_netdevice_notifier (&stmmac_notifier);#endif return 0 ;
@@ -4687,6 +4689,7 @@ static int __init stmmac_init(void) static void __exit stmmac_exit(void) {#ifdef CONFIG_DEBUG_FS +unregister_netdevice_notifier (&stmmac_notifier);debugfs_remove_recursive (stmmac_fs_dir);#endif }
Signature · 1 line
2.25.1
Quoted 5 lines · On Thu, Feb 15, 2024 at 04:15:25PM +0100, [email protected]…
Fix kernel freeze reproduced when probing stmmac devices on kernel 4.19:
Upstream commit474a31e13a4e9749fb3ee55794d69d0f17ee0998to fix freeze and upstream commit8d72ab119f42f25abb393093472ae0ca275088b6to apply the fix correctly.
All now queued up, thanks.
greg k-h