Skip to contentSkip to conversation

net:fec: Add fec_enet_deinit()

PATCH Applied Xiaolei Wang 3 participants 3 messages May 24, 2024 – May 28, 2024

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 net:fec: Add fec_enet_deinit()

When fec_probe() fails or fec_drv_remove() needs to release the fec queue and remove a NAPI context, therefore add a function corresponding to fec_enet_init() and call fec_enet_deinit() which does the opposite to release memory and remove a NAPI context.

Fixes 59d0f7465644 ("net: fec: init multi queue date structure")

---
v1 -> v2
- Add fec_enet_free_queue() in fec_drv_remove()
v2 -> v3
- Add fec_enet_deinit()

 drivers/net/ethernet/freescale/fec_main.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
drivers/net/ethernet/freescale/fec_main.c +10 -0
index a72d8a2eb0b3..881ece735dcf 100644
@@ -4130,6 +4130,14 @@ static int fec_enet_init(struct net_device *ndev)
 	return ret;
 }
 
+static void fec_enet_deinit(struct net_device *ndev)
+{
+	struct fec_enet_private *fep = netdev_priv(ndev);
+
+	netif_napi_del(&fep->napi);
+	fec_enet_free_queue(ndev);
+}
+
 #ifdef CONFIG_OF
 static int fec_reset_phy(struct platform_device *pdev)
 {
@@ -4524,6 +4532,7 @@ fec_probe(struct platform_device *pdev)
 	fec_enet_mii_remove(fep);
 failed_mii_init:
 failed_irq:
+	fec_enet_deinit(ndev);
 failed_init:
 	fec_ptp_stop(pdev);
 failed_reset:
@@ -4587,6 +4596,7 @@ fec_drv_remove(struct platform_device *pdev)
 	pm_runtime_put_noidle(&pdev->dev);
 	pm_runtime_disable(&pdev->dev);
 
+	fec_enet_deinit(ndev);
 	free_netdev(ndev);
 }
 
Signature · 1 line
2.25.1
Reviewed-by on v3 1/1
#1 lore raw
Quoted 22 lines · Xiaolei Wang

When fec_probe() fails or fec_drv_remove() needs to release the fec queue and remove a NAPI context, therefore add a function corresponding to fec_enet_init() and call fec_enet_deinit() which does the opposite to release memory and remove a NAPI context.

Fixes 59d0f7465644 ("net: fec: init multi queue date structure")

---
v1 -> v2
- Add fec_enet_free_queue() in fec_drv_remove()
v2 -> v3
- Add fec_enet_deinit()

 drivers/net/ethernet/freescale/fec_main.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
drivers/net/ethernet/freescale/fec_main.c +0 -0
index a72d8a2eb0b3..881ece735dcf 100644

drivers/net/ethernet/freescale/fec_main.c static int fec_enet_init(struct net_device *ndev) · line 4139

Quoted 10 lines
drivers/net/ethernet/freescale/fec_main.c +7 -0
@@ -4130,6 +4130,14 @@ static int fec_enet_init(struct net_device *ndev)
 	return ret;
 }
 
+static void fec_enet_deinit(struct net_device *ndev)
+{
+	struct fec_enet_private *fep = netdev_priv(ndev);
+
+	netif_napi_del(&fep->napi);
+	fec_enet_free_queue(ndev);
+}

That is much better, and using the correct structure helped you find other bug....

Andrew

#2 lore raw
In reply to Xiaolei Wang
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:

Quoted 10 lines · On Fri, 24 May 2024 13:05:28 +0800 you wrote:

When fec_probe() fails or fec_drv_remove() needs to release the fec queue and remove a NAPI context, therefore add a function corresponding to fec_enet_init() and call fec_enet_deinit() which does the opposite to release memory and remove a NAPI context.

Fixes 59d0f7465644 ("net: fec: init multi queue date structure")

[...]

Here is the summary with links:
- [net,v3] net:fec: Add fec_enet_deinit()

    https://git.kernel.org/netdev/net/c/bf0497f53c85

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html