From 4901365614ba183f9aed7cf6e563738c43d928b4 Mon Sep 17 00:00:00 2001 From: rakesh goyal Date: Tue, 17 Dec 2019 14:31:54 +0530 Subject: [PATCH] nvethernet: fix hrtimer bug Issue: 1) hrtimer code is using index instead of chan number (TX_NAPI[] instead of TX_NAPI[chan]) Fix: 1) update code to use channel number Bug 200529168 Change-Id: I4a554ae3426910dd19b5d481957f41e32b6ff063 Signed-off-by: rakesh goyal Reviewed-on: https://git-master.nvidia.com/r/2263933 Reviewed-by: mobile promotions Tested-by: mobile promotions --- .../ethernet/nvidia/nvethernet/ether_linux.c | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/drivers/net/ethernet/nvidia/nvethernet/ether_linux.c b/drivers/net/ethernet/nvidia/nvethernet/ether_linux.c index 4eec8a78..18e8c0e7 100644 --- a/drivers/net/ethernet/nvidia/nvethernet/ether_linux.c +++ b/drivers/net/ethernet/nvidia/nvethernet/ether_linux.c @@ -1452,10 +1452,7 @@ static int ether_close(struct net_device *ndev) { struct ether_priv_data *pdata = netdev_priv(ndev); int ret = 0, i; - - /* Cancel hrtimer */ - for (i = 0; i < pdata->osi_dma->num_dma_chans; i++) - hrtimer_cancel(&pdata->tx_napi[i]->tx_usecs_timer); + unsigned int chan = 0x0; /* Unregister broadcasting MAC timestamp to clients */ tegra_unregister_hwtime_source(); @@ -1489,6 +1486,15 @@ static int ether_close(struct net_device *ndev) /* Free tx rx and common irqs */ ether_free_irqs(pdata); + /* Cancel hrtimer */ + for (i = 0; i < pdata->osi_dma->num_dma_chans; i++) { + chan = pdata->osi_dma->dma_chans[i]; + if (atomic_read(&pdata->tx_napi[chan]->tx_usecs_timer_armed) + == OSI_ENABLE) { + hrtimer_cancel(&pdata->tx_napi[chan]->tx_usecs_timer); + } + } + /* DMA De init */ osi_hw_dma_deinit(pdata->osi_dma); @@ -3685,7 +3691,7 @@ static void init_filter_values(struct ether_priv_data *pdata) static int ether_probe(struct platform_device *pdev) { struct ether_priv_data *pdata; - unsigned int num_dma_chans, mac, num_mtl_queues; + unsigned int num_dma_chans, mac, num_mtl_queues, chan; struct osi_core_priv_data *osi_core; struct osi_dma_priv_data *osi_dma; struct net_device *ndev; @@ -3801,11 +3807,12 @@ static int ether_probe(struct platform_device *pdev) /* Setup the tx_usecs timer */ for (i = 0; i < osi_dma->num_dma_chans; i++) { - atomic_set(&pdata->tx_napi[i]->tx_usecs_timer_armed, + chan = osi_dma->dma_chans[i]; + atomic_set(&pdata->tx_napi[chan]->tx_usecs_timer_armed, OSI_DISABLE); - hrtimer_init(&pdata->tx_napi[i]->tx_usecs_timer, + hrtimer_init(&pdata->tx_napi[chan]->tx_usecs_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); - pdata->tx_napi[i]->tx_usecs_timer.function = + pdata->tx_napi[chan]->tx_usecs_timer.function = ether_tx_usecs_hrtimer; }