From 05e0c8f037207dd8992e6a2810d41070c0ecca5b Mon Sep 17 00:00:00 2001 From: Srinivas Ramachandran Date: Mon, 30 Sep 2019 13:55:03 -0700 Subject: [PATCH] driver: net: nvethernet: Re-order functions in ether_open() Issue: In ether_open(), following issues are noted: 1. ether_ptp_init() is called after starting MAC, which could cause some PTP packets to be missed. 2. napi handlers are not enabled before requesting irq/starting MAC. This can cause issues if irq is raised immediately (if irq becomes shared in some platform) after it is requested. 3. ether_request_irq() is called before DMA resources are initialized. This will also cause problem if irq is raised immediately. Fix: Move and re-order function invocations in ether_open() so that driver is ready to go (DMA resources allocated, napi handlers enabled etc.) by the time irq is requested/ MAC is started for Rx/Tx. Bug 2715330 Change-Id: I491251c8e749ccad2890ad0d113c87aaf3d87b42 Signed-off-by: Srinivas Ramachandran Reviewed-on: https://git-master.nvidia.com/r/2211091 Reviewed-by: Bitan Biswas Tested-by: Bitan Biswas Reviewed-by: mobile promotions Tested-by: mobile promotions --- .../ethernet/nvidia/nvethernet/ether_linux.c | 34 ++++++++++--------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/drivers/net/ethernet/nvidia/nvethernet/ether_linux.c b/drivers/net/ethernet/nvidia/nvethernet/ether_linux.c index c58368ca..9fcd90fc 100644 --- a/drivers/net/ethernet/nvidia/nvethernet/ether_linux.c +++ b/drivers/net/ethernet/nvidia/nvethernet/ether_linux.c @@ -1212,15 +1212,6 @@ static int ether_open(struct net_device *dev) goto err_phy_init; } - /* request tx/rx/common irq */ - ret = ether_request_irqs(pdata); - if (ret < 0) { - dev_err(&dev->dev, - "%s: failed to get tx rx irqs with reason %d\n", - __func__, ret); - goto err_r_irq; - } - osi_set_rx_buf_len(pdata->osi_dma); ret = ether_allocate_dma_resources(pdata); @@ -1265,9 +1256,6 @@ static int ether_open(struct net_device *dev) pdata->l3_l4_filter = OSI_DISABLE; pdata->l2_filtering_mode = OSI_PERFECT_FILTER_MODE; - /* Start the MAC */ - osi_start_mac(pdata->osi_core); - /* Initialize PTP */ ret = ether_ptp_init(pdata); if (ret < 0) { @@ -1277,8 +1265,21 @@ static int ether_open(struct net_device *dev) goto err_hw_init; } + /* Enable napi before requesting irq to be ready to handle it */ ether_napi_enable(pdata); + /* request tx/rx/common irq */ + ret = ether_request_irqs(pdata); + if (ret < 0) { + dev_err(&dev->dev, + "%s: failed to get tx rx irqs with reason %d\n", + __func__, ret); + goto err_r_irq; + } + + /* Start the MAC */ + osi_start_mac(pdata->osi_core); + /* start PHY */ phy_start(pdata->phydev); @@ -1290,6 +1291,9 @@ static int ether_open(struct net_device *dev) return ret; +err_r_irq: + ether_napi_disable(pdata); + ether_ptp_remove(pdata); err_hw_init: #ifdef THERMAL_CAL thermal_cooling_device_unregister(pdata->tcd); @@ -1297,8 +1301,6 @@ err_therm: #endif /* THERMAL_CAL */ free_dma_resources(pdata->osi_dma, pdata->dev); err_alloc: - ether_free_irqs(pdata); -err_r_irq: if (pdata->phydev) { phy_disconnect(pdata->phydev); } @@ -3650,10 +3652,10 @@ static int ether_resume(struct ether_priv_data *pdata) goto err_dma; } - /* start the mac */ - osi_start_mac(osi_core); /* enable NAPI */ ether_napi_enable(pdata); + /* start the mac */ + osi_start_mac(osi_core); /* start phy */ phy_start(pdata->phydev); /* start network queues */