From 7cf98e614af3145072eee3bfcea15cab9dfb31e5 Mon Sep 17 00:00:00 2001 From: Bhadram Varka Date: Tue, 11 Jul 2023 15:26:48 +0530 Subject: [PATCH] nvethernet: return error from ether_get_tx_ts ether_get_tx_ts, pdata->tx_ts_ref_cnt is an atomic variable that is used as a mutex in this function and should not return 0 if the function fails to acquire the mutex. The workqueue is scheduled when the return value of the judgment function is <0. If one CPU core execution softirq is running in ether_get_tx_ts function and another CPU core softirq also calls ether_get_tx_ts function to get hardware timestamp, then the acquisition of mutex fails and return 0. After returning 0, the workqueue is not scheduled. The timestamp cannot be obtained in time. So ether_get_tx_ts should returns -1 on failure to acquire the mutex. Bug 4150416 Change-Id: Icffd409b349d8bb8dbf5a483124b3bd3d7ef6cc8 Signed-off-by: Bhadram Varka Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2934350 Reviewed-by: Bitan Biswas GVS: Gerrit_Virtual_Submit --- drivers/net/ethernet/nvidia/nvethernet/ether_linux.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/nvidia/nvethernet/ether_linux.c b/drivers/net/ethernet/nvidia/nvethernet/ether_linux.c index 50198026..29df17c1 100644 --- a/drivers/net/ethernet/nvidia/nvethernet/ether_linux.c +++ b/drivers/net/ethernet/nvidia/nvethernet/ether_linux.c @@ -49,7 +49,7 @@ int ether_get_tx_ts(struct ether_priv_data *pdata) if (!atomic_inc_and_test(&pdata->tx_ts_ref_cnt)) { /* Tx time stamp consumption already going on either from workq or func */ - return 0; + return -1; } if (list_empty(&pdata->tx_ts_skb_head)) {