net/iavf: fix ASan error caused by watchdog

Message ID 20230802071521.1842377-1-zhichaox.zeng@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Qi Zhang
Headers
Series net/iavf: fix ASan error caused by watchdog |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-aarch-unit-testing success Testing PASS
ci/iol-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-unit-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/github-robot: build success github build: passed
ci/iol-broadcom-Functional success Functional Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/intel-Functional success Functional PASS

Commit Message

Zhichao Zeng Aug. 2, 2023, 7:15 a.m. UTC
  Cancel rte alarm when closing the watchdog at the same time to avoid
ASan error, and optimize the prompt when opening and closing
the watchdog.

Fixes: af801b0374e3 ("net/iavf: add devargs to control watchdog")
Signed-off-by: Zhichao Zeng <zhichaox.zeng@intel.com>
---
 drivers/net/iavf/iavf_ethdev.c | 29 ++++++++++++++++++-----------
 1 file changed, 18 insertions(+), 11 deletions(-)
  

Patch

diff --git a/drivers/net/iavf/iavf_ethdev.c b/drivers/net/iavf/iavf_ethdev.c
index f2fc5a5621..c0ca733c67 100644
--- a/drivers/net/iavf/iavf_ethdev.c
+++ b/drivers/net/iavf/iavf_ethdev.c
@@ -324,24 +324,31 @@  iavf_dev_watchdog(void *cb_arg)
 void
 iavf_dev_watchdog_enable(struct iavf_adapter *adapter)
 {
-	if (adapter->devargs.watchdog_period && !adapter->vf.watchdog_enabled) {
-		PMD_DRV_LOG(INFO, "Enabling device watchdog, period is %dμs",
-					adapter->devargs.watchdog_period);
-		adapter->vf.watchdog_enabled = true;
-		if (rte_eal_alarm_set(adapter->devargs.watchdog_period,
-					&iavf_dev_watchdog, (void *)adapter))
-			PMD_DRV_LOG(ERR, "Failed to enabled device watchdog");
-	} else {
+	if (!adapter->devargs.watchdog_period) {
 		PMD_DRV_LOG(INFO, "Device watchdog is disabled");
+	} else {
+		if (!adapter->vf.watchdog_enabled) {
+			PMD_DRV_LOG(INFO, "Enabling device watchdog, period is %dμs",
+						adapter->devargs.watchdog_period);
+			adapter->vf.watchdog_enabled = true;
+			if (rte_eal_alarm_set(adapter->devargs.watchdog_period,
+						&iavf_dev_watchdog, (void *)adapter))
+				PMD_DRV_LOG(ERR, "Failed to enable device watchdog");
+		}
 	}
 }
 
 void
 iavf_dev_watchdog_disable(struct iavf_adapter *adapter)
 {
-	if (adapter->devargs.watchdog_period && adapter->vf.watchdog_enabled) {
-		PMD_DRV_LOG(INFO, "Disabling device watchdog");
-		adapter->vf.watchdog_enabled = false;
+	if (!adapter->devargs.watchdog_period) {
+		PMD_DRV_LOG(INFO, "Device watchdog is not enabled");
+	} else {
+		if (adapter->vf.watchdog_enabled) {
+			PMD_DRV_LOG(INFO, "Disabling device watchdog");
+			adapter->vf.watchdog_enabled = false;
+			rte_eal_alarm_cancel(&iavf_dev_watchdog, (void *)adapter);
+		}
 	}
 }