aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAbin Joseph <[email protected]>2025-06-10 11:41:11 +0000
committerJakub Kicinski <[email protected]>2025-06-12 00:39:56 +0000
commit5e84d5b36b5b0e8552fbbdfbfd9c81bb79ab0947 (patch)
treea2411aa2d00a23ccdbe6662b58630adb8649eefb
parentMerge branch 'net-phy-micrel-add-extended-phy-support-for-ksz9477-class-devices' (diff)
downloadkernel-5e84d5b36b5b0e8552fbbdfbfd9c81bb79ab0947.tar.gz
kernel-5e84d5b36b5b0e8552fbbdfbfd9c81bb79ab0947.zip
net: macb: Add shutdown operation support
Implement the shutdown hook to ensure clean and complete deactivation of MACB controller. The shutdown sequence is protected with 'rtnl_lock()' to serialize access and prevent race conditions while detaching and closing the network device. This ensure a safe transition when the Kexec utility calls the shutdown hook, facilitating seamless loading and booting of a new kernel from the currently running one. Signed-off-by: Abin Joseph <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
-rw-r--r--drivers/net/ethernet/cadence/macb_main.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
index d1f1ae5ea161..53aaf6b08e39 100644
--- a/drivers/net/ethernet/cadence/macb_main.c
+++ b/drivers/net/ethernet/cadence/macb_main.c
@@ -5654,6 +5654,20 @@ static int __maybe_unused macb_runtime_resume(struct device *dev)
return 0;
}
+static void macb_shutdown(struct platform_device *pdev)
+{
+ struct net_device *netdev = platform_get_drvdata(pdev);
+
+ rtnl_lock();
+
+ if (netif_running(netdev))
+ dev_close(netdev);
+
+ netif_device_detach(netdev);
+
+ rtnl_unlock();
+}
+
static const struct dev_pm_ops macb_pm_ops = {
SET_SYSTEM_SLEEP_PM_OPS(macb_suspend, macb_resume)
SET_RUNTIME_PM_OPS(macb_runtime_suspend, macb_runtime_resume, NULL)
@@ -5667,6 +5681,7 @@ static struct platform_driver macb_driver = {
.of_match_table = of_match_ptr(macb_dt_ids),
.pm = &macb_pm_ops,
},
+ .shutdown = macb_shutdown,
};
module_platform_driver(macb_driver);