DPDK-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Ciara Loftus <ciara.loftus@intel.com>
To: dev@dpdk.org
Cc: Ciara Loftus <ciara.loftus@intel.com>, stable@dpdk.org
Subject: [PATCH v4 4/4] net/iavf: fix watchdog enable racing disable
Date: Fri,  6 Nov 2026 09:40:12 +0000	[thread overview]
Message-ID: <20261106094014.28784-5-ciara.loftus@intel.com> (raw)
In-Reply-To: <20261106094014.28784-1-ciara.loftus@intel.com>

iavf_dev_watchdog_enable() runs on the interrupt thread from the link
change and reset impending handlers, while iavf_dev_watchdog_disable()
runs on a control thread from dev_stop and dev_close. Disable clears
`watchdog_enabled` before cancelling the alarm. An enable landing in
between sets the flag again and arms a new alarm, which the cancel then
removes. The flag is left set with no alarm armed, so every later enable
is a no-op and the watchdog is dead until the port is re-probed.

Serialise enable and disable with a spinlock held across the flag
update and the alarm set or cancel.

Fixes: 4c9b1d2ff616 ("net/iavf: refactor watchdog")
Cc: stable@dpdk.org

Signed-off-by: Ciara Loftus <ciara.loftus@intel.com>
---
 drivers/net/intel/iavf/iavf.h        |  1 +
 drivers/net/intel/iavf/iavf_ethdev.c | 37 +++++++++++++++++-----------
 2 files changed, 23 insertions(+), 15 deletions(-)

diff --git a/drivers/net/intel/iavf/iavf.h b/drivers/net/intel/iavf/iavf.h
index 04c2900afe..0c98ae28e1 100644
--- a/drivers/net/intel/iavf/iavf.h
+++ b/drivers/net/intel/iavf/iavf.h
@@ -247,6 +247,7 @@ struct iavf_info {
 
 	/** iAVF watchdog enable */
 	bool watchdog_enabled;
+	rte_spinlock_t watchdog_lock;
 
 	/* Event from pf */
 	bool dev_closed;
diff --git a/drivers/net/intel/iavf/iavf_ethdev.c b/drivers/net/intel/iavf/iavf_ethdev.c
index 83470a636d..10069feae2 100644
--- a/drivers/net/intel/iavf/iavf_ethdev.c
+++ b/drivers/net/intel/iavf/iavf_ethdev.c
@@ -374,16 +374,19 @@ iavf_dev_watchdog_enable(struct iavf_adapter *adapter)
 {
 	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");
-		}
+		return;
+	}
+
+	rte_spinlock_lock(&adapter->vf.watchdog_lock);
+	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");
 	}
+	rte_spinlock_unlock(&adapter->vf.watchdog_lock);
 }
 
 void
@@ -391,13 +394,16 @@ iavf_dev_watchdog_disable(struct iavf_adapter *adapter)
 {
 	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);
-		}
+		return;
+	}
+
+	rte_spinlock_lock(&adapter->vf.watchdog_lock);
+	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);
 	}
+	rte_spinlock_unlock(&adapter->vf.watchdog_lock);
 }
 
 static int
@@ -3077,6 +3083,7 @@ iavf_dev_init(struct rte_eth_dev *eth_dev)
 	adapter->mac_primary_set = false;
 	adapter->tpid = RTE_ETHER_TYPE_VLAN; /* VLAN TPID set to 0x8100 by default */
 	rte_spinlock_init(&adapter->phc_sync_lock);
+	rte_spinlock_init(&vf->watchdog_lock);
 
 	if (!rte_atomic_load_explicit(&vf->in_reset_recovery, rte_memory_order_relaxed) &&
 	    iavf_dev_event_handler_init())
-- 
2.43.0


  parent reply	other threads:[~2026-11-06  9:40 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-04  9:55 [PATCH v2 0/3] iavf reset path fixes Ciara Loftus
2026-11-04  9:55 ` [PATCH v2 1/3] net/iavf: fix crash in Tx drain on PF reset Ciara Loftus
2026-11-04 17:51   ` Bruce Richardson
2026-11-04  9:55 ` [PATCH v2 2/3] net/iavf: fix event handler leak on init failure Ciara Loftus
2026-11-04 17:52   ` Bruce Richardson
2026-11-04  9:55 ` [PATCH v2 3/3] net/iavf: fix watchdog clearing reset state during recovery Ciara Loftus
2026-11-04 18:00   ` Bruce Richardson
2026-11-05 12:32 ` [PATCH v3 0/4] iavf reset path fixes Ciara Loftus
2026-11-05 12:32   ` [PATCH v3 1/4] net/iavf: fix crash in Tx drain on PF reset Ciara Loftus
2026-11-05 12:32   ` [PATCH v3 2/4] net/iavf: fix event handler leak on init failure Ciara Loftus
2026-11-05 12:32   ` [PATCH v3 3/4] net/iavf: fix watchdog clearing reset state during recovery Ciara Loftus
2026-11-05 12:32   ` [PATCH v3 4/4] net/iavf: fix watchdog enable racing disable Ciara Loftus
2026-11-06  9:40   ` [PATCH v4 0/4] iavf reset path fixes Ciara Loftus
2026-11-06  9:40     ` [PATCH v4 1/4] net/iavf: fix crash in Tx drain on PF reset Ciara Loftus
2026-11-06  9:40     ` [PATCH v4 2/4] net/iavf: fix event handler leak on init failure Ciara Loftus
2026-11-06  9:40     ` [PATCH v4 3/4] net/iavf: fix watchdog clearing reset state during recovery Ciara Loftus
2026-11-10 10:47       ` Bruce Richardson
2026-11-06  9:40     ` Ciara Loftus [this message]
2026-11-10 10:48       ` [PATCH v4 4/4] net/iavf: fix watchdog enable racing disable Bruce Richardson
2026-11-10 10:51     ` [PATCH v4 0/4] iavf reset path fixes Bruce Richardson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261106094014.28784-5-ciara.loftus@intel.com \
    --to=ciara.loftus@intel.com \
    --cc=dev@dpdk.org \
    --cc=stable@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox