From 25ff96a9dc9c6a5a21778c36cb1e7175128d2071 Mon Sep 17 00:00:00 2001 From: "Lendacky, Thomas" Date: Fri, 18 Aug 2017 09:02:40 -0500 Subject: [PATCH] amd-xgbe: Be sure driver shuts down cleanly on module removal Sometimes when the driver is being unloaded while the devices are still up the driver can issue errors. This is based on timing and the double invocation of some routines. The phy_exit() call needs to be run after the network device has been closed and unregistered from the system. Also, the phy_exit() does not need to invoke phy_stop() since that will be called as part of the device closing, so remove that call. Signed-off-by: Tom Lendacky Signed-off-by: David S. Miller --- drivers/net/ethernet/amd/xgbe/xgbe-main.c | 4 ++-- drivers/net/ethernet/amd/xgbe/xgbe-mdio.c | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-main.c b/drivers/net/ethernet/amd/xgbe/xgbe-main.c index 500147d9e3c8..53a425cc7a2d 100644 --- a/drivers/net/ethernet/amd/xgbe/xgbe-main.c +++ b/drivers/net/ethernet/amd/xgbe/xgbe-main.c @@ -458,6 +458,8 @@ void xgbe_deconfig_netdev(struct xgbe_prv_data *pdata) if (IS_REACHABLE(CONFIG_PTP_1588_CLOCK)) xgbe_ptp_unregister(pdata); + unregister_netdev(netdev); + pdata->phy_if.phy_exit(pdata); flush_workqueue(pdata->an_workqueue); @@ -465,8 +467,6 @@ void xgbe_deconfig_netdev(struct xgbe_prv_data *pdata) flush_workqueue(pdata->dev_workqueue); destroy_workqueue(pdata->dev_workqueue); - - unregister_netdev(netdev); } static int __init xgbe_mod_init(void) diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-mdio.c b/drivers/net/ethernet/amd/xgbe/xgbe-mdio.c index 2222bbf8d0a4..24092020f119 100644 --- a/drivers/net/ethernet/amd/xgbe/xgbe-mdio.c +++ b/drivers/net/ethernet/amd/xgbe/xgbe-mdio.c @@ -1533,8 +1533,6 @@ static int xgbe_phy_best_advertised_speed(struct xgbe_prv_data *pdata) static void xgbe_phy_exit(struct xgbe_prv_data *pdata) { - xgbe_phy_stop(pdata); - pdata->phy_if.phy_impl.exit(pdata); } -- 2.20.1