Skip to content

Commit 5e84d5b

Browse files
abinJoseph25k07kuba-moo
authored andcommitted
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]>
1 parent 48c15e9 commit 5e84d5b

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

drivers/net/ethernet/cadence/macb_main.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5654,6 +5654,20 @@ static int __maybe_unused macb_runtime_resume(struct device *dev)
56545654
return 0;
56555655
}
56565656

5657+
static void macb_shutdown(struct platform_device *pdev)
5658+
{
5659+
struct net_device *netdev = platform_get_drvdata(pdev);
5660+
5661+
rtnl_lock();
5662+
5663+
if (netif_running(netdev))
5664+
dev_close(netdev);
5665+
5666+
netif_device_detach(netdev);
5667+
5668+
rtnl_unlock();
5669+
}
5670+
56575671
static const struct dev_pm_ops macb_pm_ops = {
56585672
SET_SYSTEM_SLEEP_PM_OPS(macb_suspend, macb_resume)
56595673
SET_RUNTIME_PM_OPS(macb_runtime_suspend, macb_runtime_resume, NULL)
@@ -5667,6 +5681,7 @@ static struct platform_driver macb_driver = {
56675681
.of_match_table = of_match_ptr(macb_dt_ids),
56685682
.pm = &macb_pm_ops,
56695683
},
5684+
.shutdown = macb_shutdown,
56705685
};
56715686

56725687
module_platform_driver(macb_driver);

0 commit comments

Comments
 (0)