From f87b6efd44461ccc9485fd3a0737aec96d9bf92d Mon Sep 17 00:00:00 2001 From: Sushil Singh Date: Mon, 20 Sep 2021 22:14:46 +0530 Subject: [PATCH] nvethernet: Add .shutdown routine for eqos driver Issue: During system shutdown ethernet controller still accessed system memory which resulted in memory fault irq causing kernel panic. Fix: register .shutdown driver ops for eqos which gets called during system shutdown and deinits the dma, mac and clocks hw and sw allocated resources. Bug 200763727 Change-Id: Ic2eeacbf17c2cf500a051f2608e3d30a9b1e806b Signed-off-by: Sushil Singh Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2597538 Reviewed-by: Narayan Reddy Reviewed-by: svcacv Reviewed-by: svc-mobile-coverity Reviewed-by: svc-mobile-cert Reviewed-by: svc_kernel_abi Reviewed-by: Bhadram Varka Reviewed-by: Bibek Basu GVS: Gerrit_Virtual_Submit --- .../ethernet/nvidia/nvethernet/ether_linux.c | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/drivers/net/ethernet/nvidia/nvethernet/ether_linux.c b/drivers/net/ethernet/nvidia/nvethernet/ether_linux.c index ff31c38e..5deaeb21 100644 --- a/drivers/net/ethernet/nvidia/nvethernet/ether_linux.c +++ b/drivers/net/ethernet/nvidia/nvethernet/ether_linux.c @@ -6526,6 +6526,28 @@ static int ether_remove(struct platform_device *pdev) return 0; } +/** + * @brief Ethernet platform driver shutdown. + * + * Alogorithm: Stops and Deinits PHY, MAC, DMA and Clks hardware and + * release SW allocated resources(buffers, workqueues etc). + * + * @param[in] pdev: Platform device associated with platform driver. + */ +static void ether_shutdown(struct platform_device *pdev) +{ + struct net_device *ndev = platform_get_drvdata(pdev); + struct ether_priv_data *pdata = netdev_priv(ndev); + int ret = -1; + + if (!netif_running(ndev)) + return; + + ret = ether_close(ndev); + if (ret) + dev_err(pdata->dev, "Failure in ether_close"); +} + #ifdef CONFIG_PM /** * @brief Ethernet platform driver suspend noirq callback. @@ -6845,6 +6867,7 @@ MODULE_DEVICE_TABLE(of, ether_of_match); static struct platform_driver ether_driver = { .probe = ether_probe, .remove = ether_remove, + .shutdown = ether_shutdown, .driver = { .name = "nvethernet", .of_match_table = ether_of_match,