Skip to contentSkip to conversation

ionic: make the device command timeout configurable

PATCH Superseded Nikhil P. Rao 3 participants 8 messages Nov 2 – Nov 5

Subsystems (7)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover ionic: make the device command timeout configurable

ionic waits a fixed 5 seconds for device and admin queue commands, and the RDMA driver gives its admin queue 2 seconds. Some commands can take the firmware longer than that, for example while a PFC configuration change flaps the links. The firmware is alive but slow, yet the timed-out command and everything queued behind it fail, and an RDMA admin queue timeout resets the RDMA LIF so that later verbs fail with -ENODEV.

Patch 1 makes the timeout a per-device value without changing it. Patch 2 has the RDMA admin queue use the ionic command timeout instead of its own 2 seconds. Patch 3 adds a permanent devlink parameter, cmd_timeout, stored in device NVM, that lengthens the timeout on firmware that supports it.

Tested on an AMD Pensando adapter under KASAN and lockdep, including repeated PCI resets with concurrent parameter reads.

This series was developed with the help of an LLM-based coding assistant (Claude).

---
Arun Kumar Prakash (3):
ionic: make the command timeout per device RDMA/ionic: Use the ionic command timeout for the admin queue
ionic: add devlink param for command timeout

 Documentation/networking/devlink/ionic.rst         | 29 +++++++
 drivers/infiniband/hw/ionic/ionic_admin.c          |  9 ++-
 drivers/net/ethernet/pensando/ionic/ionic.h        | 15 +++-
 drivers/net/ethernet/pensando/ionic/ionic_api.h    |  8 ++
 drivers/net/ethernet/pensando/ionic/ionic_aux.c    |  8 +-
 .../net/ethernet/pensando/ionic/ionic_bus_pci.c    |  4 +
 drivers/net/ethernet/pensando/ionic/ionic_dev.c    | 90 ++++++++++++++++++++--
 drivers/net/ethernet/pensando/ionic/ionic_dev.h    |  3 +
 .../net/ethernet/pensando/ionic/ionic_devlink.c    | 89 +++++++++++++++++++++
 .../net/ethernet/pensando/ionic/ionic_devlink.h    |  2 +
 .../net/ethernet/pensando/ionic/ionic_ethtool.c    | 12 +--
 drivers/net/ethernet/pensando/ionic/ionic_fw.c     |  8 +-
 drivers/net/ethernet/pensando/ionic/ionic_if.h     |  8 ++
 drivers/net/ethernet/pensando/ionic/ionic_lif.c    | 13 ++--
 drivers/net/ethernet/pensando/ionic/ionic_main.c   | 17 ++--
 15 files changed, 281 insertions(+), 34 deletions(-)

---
base-commit: 4dd16e31135ea8437a720222df34e8745f385d6d
change-id: 20261102-b4-ionic-cmd-timeout-c704d5304b4f

Best regards,

Signature · 1 line
Nikhil P. Rao <[email protected]>
#1 lore raw

PATCH 1/3 ionic: make the command timeout per device

From: Arun Kumar Prakash <[email protected]>

Device and admin queue command waits, and the firmware heartbeat check interval, use the compile-time DEVCMD_TIMEOUT. Make the timeout a per-device value, so that it can be made configurable through a devlink parameter, and export it to the RDMA driver through ionic_cmd_timeout().

No functional change.

---
 drivers/net/ethernet/pensando/ionic/ionic.h         |  3 ++-
 drivers/net/ethernet/pensando/ionic/ionic_api.h     |  8 ++++++++
 drivers/net/ethernet/pensando/ionic/ionic_aux.c     |  8 +++++++-
 drivers/net/ethernet/pensando/ionic/ionic_bus_pci.c |  1 +
 drivers/net/ethernet/pensando/ionic/ionic_dev.c     | 11 ++++++-----
 drivers/net/ethernet/pensando/ionic/ionic_ethtool.c | 12 ++++++------
 drivers/net/ethernet/pensando/ionic/ionic_fw.c      |  8 ++++----
 drivers/net/ethernet/pensando/ionic/ionic_lif.c     | 10 +++++-----
 drivers/net/ethernet/pensando/ionic/ionic_main.c    | 16 ++++++++--------
 9 files changed, 47 insertions(+), 30 deletions(-)
drivers/net/ethernet/pensando/ionic/ionic.h +2 -1
index 85198e6a806e6..5c54a0ea10a55 100644
@@ -18,7 +18,7 @@ struct ionic_lif;
 #define PCI_DEVICE_ID_PENSANDO_IONIC_ETH_PF	0x1002
 #define PCI_DEVICE_ID_PENSANDO_IONIC_ETH_VF	0x1003
 
-#define DEVCMD_TIMEOUT			5
+#define IONIC_CMD_TIMEOUT_DEF		5
 #define IONIC_ADMINQ_TIME_SLICE		msecs_to_jiffies(100)
 
 #define IONIC_PHC_UPDATE_NS	10000000000	    /* 10s in nanoseconds */
@@ -63,6 +63,7 @@ struct ionic {
 	int num_vfs;
 	struct timer_list watchdog_timer;
 	int watchdog_period;
+	u8 cmd_timeout;
 };
 
 int ionic_adminq_post(struct ionic_lif *lif, struct ionic_admin_ctx *ctx);
drivers/net/ethernet/pensando/ionic/ionic_api.h +8 -0
index bd88666836b80..28e6b5e2a2cc0 100644
@@ -86,6 +86,14 @@ int ionic_error_to_errno(enum ionic_status_code code);
  */
 void ionic_request_rdma_reset(struct ionic_lif *lif);
 
+/**
+ * ionic_cmd_timeout - Get the device and admin queue command timeout
+ * @lif:        Logical interface
+ *
+ * Return: the command timeout in seconds
+ */
+u8 ionic_cmd_timeout(struct ionic_lif *lif);
+
 /**
  * ionic_intr_alloc - Reserve a device interrupt
  * @lif:        Logical interface
drivers/net/ethernet/pensando/ionic/ionic_aux.c +7 -1
index 4f193d0ee87ad..3b7cecc7f6dde 100644
@@ -92,7 +92,7 @@ void ionic_request_rdma_reset(struct ionic_lif *lif)
 	mutex_lock(&ionic->dev_cmd_lock);
 
 	ionic_dev_cmd_go(&ionic->idev, &cmd);
-	err = ionic_dev_cmd_wait(ionic, DEVCMD_TIMEOUT);
+	err = ionic_dev_cmd_wait(ionic, ionic->cmd_timeout);
 
 	mutex_unlock(&ionic->dev_cmd_lock);
 
@@ -100,3 +100,9 @@ void ionic_request_rdma_reset(struct ionic_lif *lif)
 		pr_warn("%s request_reset: error %d\n", __func__, err);
 }
 EXPORT_SYMBOL_NS(ionic_request_rdma_reset, "NET_IONIC");
+
+u8 ionic_cmd_timeout(struct ionic_lif *lif)
+{
+	return lif->ionic->cmd_timeout;
+}
+EXPORT_SYMBOL_NS(ionic_cmd_timeout, "NET_IONIC");
drivers/net/ethernet/pensando/ionic/ionic_bus_pci.c +1 -0
index ddc2f9770df45..74ba923a3f1b6 100644
@@ -237,6 +237,7 @@ static int ionic_setup_one(struct ionic *ionic)
 	struct device *dev = ionic->dev;
 	int err;
 
+	ionic->cmd_timeout = IONIC_CMD_TIMEOUT_DEF;
 	ionic_debugfs_add_dev(ionic);
 
 	/* Setup PCI device */
drivers/net/ethernet/pensando/ionic/ionic_dev.c +6 -5
index 648d9d24be856..f14fff4a74278 100644
@@ -212,7 +212,7 @@ static void ionic_map_disc_cmb(struct ionic *ionic)
 	mutex_lock(&ionic->dev_cmd_lock);
 
 	ionic_dev_cmd_discover_cmb(idev);
-	err = ionic_dev_cmd_wait(ionic, DEVCMD_TIMEOUT);
+	err = ionic_dev_cmd_wait(ionic, ionic->cmd_timeout);
 	if (!err) {
 		sz = min(sizeof(ident->cmb_layout),
 			 sizeof(idev->dev_cmd_regs->data));
@@ -590,10 +590,11 @@ int ionic_heartbeat_check(struct ionic *ionic)
 		return -ENXIO;
 
 	/* Because of some variability in the actual FW heartbeat, we
-	 * wait longer than the DEVCMD_TIMEOUT before checking again.
+	 * wait longer than the command timeout before checking again.
 	 */
 	last_check_time = idev->last_hb_time;
-	if (time_before(check_time, last_check_time + DEVCMD_TIMEOUT * 2 * HZ))
+	if (time_before(check_time,
+			last_check_time + ionic->cmd_timeout * 2 * HZ))
 		return 0;
 
 	fw_hb = ioread32(&idev->dev_info_regs->fw_heartbeat);
@@ -795,7 +796,7 @@ int ionic_set_vf_config(struct ionic *ionic, int vf,
 
 	mutex_lock(&ionic->dev_cmd_lock);
 	ionic_dev_cmd_go(&ionic->idev, &cmd);
-	err = ionic_dev_cmd_wait(ionic, DEVCMD_TIMEOUT);
+	err = ionic_dev_cmd_wait(ionic, ionic->cmd_timeout);
 	mutex_unlock(&ionic->dev_cmd_lock);
 
 	return err;
@@ -812,7 +813,7 @@ void ionic_vf_start(struct ionic *ionic)
 		return;
 
 	ionic_dev_cmd_go(&ionic->idev, &cmd);
-	ionic_dev_cmd_wait(ionic, DEVCMD_TIMEOUT);
+	ionic_dev_cmd_wait(ionic, ionic->cmd_timeout);
 }
 
 /* LIF commands */
drivers/net/ethernet/pensando/ionic/ionic_ethtool.c +6 -6
index 119ac720c0787..29b9a8502b8ed 100644
@@ -351,7 +351,7 @@ static int ionic_set_link_ksettings(struct net_device *netdev,
 	if (ks->base.autoneg != idev->port_info->config.an_enable) {
 		mutex_lock(&ionic->dev_cmd_lock);
 		ionic_dev_cmd_port_autoneg(idev, ks->base.autoneg);
-		err = ionic_dev_cmd_wait(ionic, DEVCMD_TIMEOUT);
+		err = ionic_dev_cmd_wait(ionic, ionic->cmd_timeout);
 		mutex_unlock(&ionic->dev_cmd_lock);
 		if (err)
 			return err;
@@ -361,7 +361,7 @@ static int ionic_set_link_ksettings(struct net_device *netdev,
 	if (ks->base.speed != le32_to_cpu(idev->port_info->config.speed)) {
 		mutex_lock(&ionic->dev_cmd_lock);
 		ionic_dev_cmd_port_speed(idev, ks->base.speed);
-		err = ionic_dev_cmd_wait(ionic, DEVCMD_TIMEOUT);
+		err = ionic_dev_cmd_wait(ionic, ionic->cmd_timeout);
 		mutex_unlock(&ionic->dev_cmd_lock);
 		if (err)
 			return err;
@@ -411,7 +411,7 @@ static int ionic_set_pauseparam(struct net_device *netdev,
 
 	mutex_lock(&ionic->dev_cmd_lock);
 	ionic_dev_cmd_port_pause(&lif->ionic->idev, requested_pause);
-	err = ionic_dev_cmd_wait(ionic, DEVCMD_TIMEOUT);
+	err = ionic_dev_cmd_wait(ionic, ionic->cmd_timeout);
 	mutex_unlock(&ionic->dev_cmd_lock);
 	if (err)
 		return err;
@@ -479,7 +479,7 @@ static int ionic_set_fecparam(struct net_device *netdev,
 	if (fec_type != lif->ionic->idev.port_info->config.fec_type) {
 		mutex_lock(&lif->ionic->dev_cmd_lock);
 		ionic_dev_cmd_port_fec(&lif->ionic->idev, fec_type);
-		ret = ionic_dev_cmd_wait(lif->ionic, DEVCMD_TIMEOUT);
+		ret = ionic_dev_cmd_wait(lif->ionic, lif->ionic->cmd_timeout);
 		mutex_unlock(&lif->ionic->dev_cmd_lock);
 	}
 
@@ -1131,11 +1131,11 @@ static int ionic_nway_reset(struct net_device *netdev)
 	mutex_lock(&ionic->dev_cmd_lock);
 
 	ionic_dev_cmd_port_state(&ionic->idev, IONIC_PORT_ADMIN_STATE_DOWN);
-	err = ionic_dev_cmd_wait(ionic, DEVCMD_TIMEOUT);
+	err = ionic_dev_cmd_wait(ionic, ionic->cmd_timeout);
 
 	if (!err) {
 		ionic_dev_cmd_port_state(&ionic->idev, IONIC_PORT_ADMIN_STATE_UP);
-		err = ionic_dev_cmd_wait(ionic, DEVCMD_TIMEOUT);
+		err = ionic_dev_cmd_wait(ionic, ionic->cmd_timeout);
 	}
 
 	mutex_unlock(&ionic->dev_cmd_lock);
drivers/net/ethernet/pensando/ionic/ionic_fw.c +4 -4
index 3c209c1a23373..ceb9751475088 100644
@@ -75,7 +75,7 @@ static int ionic_fw_status_long_wait(struct ionic *ionic,
 	do {
 		mutex_lock(&ionic->dev_cmd_lock);
 		ionic_dev_cmd_go(&ionic->idev, &cmd);
-		err = ionic_dev_cmd_wait(ionic, DEVCMD_TIMEOUT);
+		err = ionic_dev_cmd_wait(ionic, ionic->cmd_timeout);
 		mutex_unlock(&ionic->dev_cmd_lock);
 
 		msleep(20);
@@ -135,7 +135,7 @@ int ionic_firmware_update(struct ionic_lif *lif, const struct firmware *fw,
 		ionic_dev_cmd_firmware_download(idev,
 						offsetof(union ionic_dev_cmd_regs, data),
 						offset, copy_sz);
-		err = ionic_dev_cmd_wait(ionic, DEVCMD_TIMEOUT);
+		err = ionic_dev_cmd_wait(ionic, ionic->cmd_timeout);
 		mutex_unlock(&ionic->dev_cmd_lock);
 		if (err) {
 			netdev_err(netdev,
@@ -155,7 +155,7 @@ int ionic_firmware_update(struct ionic_lif *lif, const struct firmware *fw,
 
 	mutex_lock(&ionic->dev_cmd_lock);
 	ionic_dev_cmd_firmware_install(idev);
-	err = ionic_dev_cmd_wait(ionic, DEVCMD_TIMEOUT);
+	err = ionic_dev_cmd_wait(ionic, ionic->cmd_timeout);
 	ionic_dev_cmd_comp(idev, (union ionic_dev_cmd_comp *)&comp);
 	fw_slot = comp.fw_control.slot;
 	mutex_unlock(&ionic->dev_cmd_lock);
@@ -176,7 +176,7 @@ int ionic_firmware_update(struct ionic_lif *lif, const struct firmware *fw,
 
 	mutex_lock(&ionic->dev_cmd_lock);
 	ionic_dev_cmd_firmware_activate(idev, fw_slot);
-	err = ionic_dev_cmd_wait(ionic, DEVCMD_TIMEOUT);
+	err = ionic_dev_cmd_wait(ionic, ionic->cmd_timeout);
 	mutex_unlock(&ionic->dev_cmd_lock);
 	if (err) {
 		NL_SET_ERR_MSG_MOD(extack, "Failed to start firmware select");
drivers/net/ethernet/pensando/ionic/ionic_lif.c +5 -5
index 7f0da2b0defdf..b0868ab139dd5 100644
@@ -3382,7 +3382,7 @@ static void ionic_lif_reset(struct ionic_lif *lif)
 
 	mutex_lock(&lif->ionic->dev_cmd_lock);
 	ionic_dev_cmd_lif_reset(idev, lif->index);
-	ionic_dev_cmd_wait(lif->ionic, DEVCMD_TIMEOUT);
+	ionic_dev_cmd_wait(lif->ionic, lif->ionic->cmd_timeout);
 	mutex_unlock(&lif->ionic->dev_cmd_lock);
 }
 
@@ -3589,7 +3589,7 @@ static int ionic_lif_adminq_init(struct ionic_lif *lif)
 
 	mutex_lock(&lif->ionic->dev_cmd_lock);
 	ionic_dev_cmd_adminq_init(idev, qcq, lif->index, qcq->intr.index);
-	err = ionic_dev_cmd_wait(lif->ionic, DEVCMD_TIMEOUT);
+	err = ionic_dev_cmd_wait(lif->ionic, lif->ionic->cmd_timeout);
 	ionic_dev_cmd_comp(idev, (union ionic_dev_cmd_comp *)&comp);
 	mutex_unlock(&lif->ionic->dev_cmd_lock);
 	if (err) {
@@ -3749,7 +3749,7 @@ int ionic_lif_init(struct ionic_lif *lif)
 
 	mutex_lock(&lif->ionic->dev_cmd_lock);
 	ionic_dev_cmd_lif_init(idev, lif->index, lif->info_pa);
-	err = ionic_dev_cmd_wait(lif->ionic, DEVCMD_TIMEOUT);
+	err = ionic_dev_cmd_wait(lif->ionic, lif->ionic->cmd_timeout);
 	ionic_dev_cmd_comp(idev, (union ionic_dev_cmd_comp *)&comp);
 	mutex_unlock(&lif->ionic->dev_cmd_lock);
 	if (err)
@@ -3937,7 +3937,7 @@ static void ionic_lif_queue_identify(struct ionic_lif *lif)
 		mutex_lock(&ionic->dev_cmd_lock);
 		ionic_dev_cmd_queue_identify(idev, lif->lif_type, qtype,
 					     ionic_qtype_versions[qtype]);
-		err = ionic_dev_cmd_wait(ionic, DEVCMD_TIMEOUT);
+		err = ionic_dev_cmd_wait(ionic, ionic->cmd_timeout);
 		if (!err) {
 			qti->version   = readb(&q_ident->version);
 			qti->supported = readb(&q_ident->supported);
@@ -4003,7 +4003,7 @@ int ionic_lif_identify(struct ionic *ionic, u8 lif_type,
 
 	mutex_lock(&ionic->dev_cmd_lock);
 	ionic_dev_cmd_lif_identify(idev, lif_type, IONIC_IDENTITY_VERSION_1);
-	err = ionic_dev_cmd_wait(ionic, DEVCMD_TIMEOUT);
+	err = ionic_dev_cmd_wait(ionic, ionic->cmd_timeout);
 	memcpy_fromio(lid, &idev->dev_cmd_regs->data, sz);
 	mutex_unlock(&ionic->dev_cmd_lock);
 	if (err)
drivers/net/ethernet/pensando/ionic/ionic_main.c +8 -8
index 38b47b959a114..16df13f23c90d 100644
@@ -435,7 +435,7 @@ int ionic_adminq_wait(struct ionic_lif *lif, struct ionic_admin_ctx *ctx,
 	}
 
 	time_start = jiffies;
-	time_limit = time_start + HZ * (ulong)DEVCMD_TIMEOUT;
+	time_limit = time_start + HZ * (ulong)lif->ionic->cmd_timeout;
 	do {
 		remaining = wait_for_completion_timeout(&ctx->work,
 							IONIC_ADMINQ_TIME_SLICE);
@@ -631,7 +631,7 @@ int ionic_identify(struct ionic *ionic)
 	memcpy_toio(&idev->dev_cmd_regs->data, &ident->drv, sz);
 
 	ionic_dev_cmd_identify(idev, IONIC_DEV_IDENTITY_VERSION_2);
-	err = ionic_dev_cmd_wait(ionic, DEVCMD_TIMEOUT);
+	err = ionic_dev_cmd_wait(ionic, ionic->cmd_timeout);
 	if (!err) {
 		sz = min(sizeof(ident->dev), sizeof(idev->dev_cmd_regs->data));
 		memcpy_fromio(&ident->dev, &idev->dev_cmd_regs->data, sz);
@@ -675,7 +675,7 @@ int ionic_init(struct ionic *ionic)
 
 	mutex_lock(&ionic->dev_cmd_lock);
 	ionic_dev_cmd_init(idev);
-	err = ionic_dev_cmd_wait(ionic, DEVCMD_TIMEOUT);
+	err = ionic_dev_cmd_wait(ionic, ionic->cmd_timeout);
 	mutex_unlock(&ionic->dev_cmd_lock);
 
 	return err;
@@ -691,7 +691,7 @@ int ionic_reset(struct ionic *ionic)
 
 	mutex_lock(&ionic->dev_cmd_lock);
 	ionic_dev_cmd_reset(idev);
-	err = ionic_dev_cmd_wait(ionic, DEVCMD_TIMEOUT);
+	err = ionic_dev_cmd_wait(ionic, ionic->cmd_timeout);
 	mutex_unlock(&ionic->dev_cmd_lock);
 
 	return err;
@@ -707,7 +707,7 @@ int ionic_port_identify(struct ionic *ionic)
 	mutex_lock(&ionic->dev_cmd_lock);
 
 	ionic_dev_cmd_port_identify(idev);
-	err = ionic_dev_cmd_wait(ionic, DEVCMD_TIMEOUT);
+	err = ionic_dev_cmd_wait(ionic, ionic->cmd_timeout);
 	if (!err) {
 		sz = min(sizeof(ident->port), sizeof(idev->dev_cmd_regs->data));
 		memcpy_fromio(&ident->port, &idev->dev_cmd_regs->data, sz);
@@ -752,10 +752,10 @@ int ionic_port_init(struct ionic *ionic)
 
 	memcpy_toio(&idev->dev_cmd_regs->data, &ident->port.config, sz);
 	ionic_dev_cmd_port_init(idev);
-	err = ionic_dev_cmd_wait(ionic, DEVCMD_TIMEOUT);
+	err = ionic_dev_cmd_wait(ionic, ionic->cmd_timeout);
 
 	ionic_dev_cmd_port_state(&ionic->idev, IONIC_PORT_ADMIN_STATE_UP);
-	ionic_dev_cmd_wait(ionic, DEVCMD_TIMEOUT);
+	ionic_dev_cmd_wait(ionic, ionic->cmd_timeout);
 
 	mutex_unlock(&ionic->dev_cmd_lock);
 	if (err) {
@@ -782,7 +782,7 @@ int ionic_port_reset(struct ionic *ionic)
 	if (ionic_is_fw_running(idev)) {
 		mutex_lock(&ionic->dev_cmd_lock);
 		ionic_dev_cmd_port_reset(idev);
-		err = ionic_dev_cmd_wait(ionic, DEVCMD_TIMEOUT);
+		err = ionic_dev_cmd_wait(ionic, ionic->cmd_timeout);
 		mutex_unlock(&ionic->dev_cmd_lock);
 	}
 
Signature · 1 line
2.43.0
#5 lore raw

PATCH 3/3 ionic: add devlink param for command timeout

In reply to Nikhil P. Rao

From: Arun Kumar Prakash <[email protected]>

Some device and admin commands can take firmware longer than the driver allows to complete, for example while a PFC configuration change flaps the links. The firmware is alive but slow, yet the timed-out command and everything queued behind it fail.

Make the timeout configurable so it can be tuned to the firmware behaviour seen in production.

Add a permanent devlink parameter, cmd_timeout (u8, seconds), stored in device NVM via a new device attribute, on firmware that advertises the new IONIC_DEV_CAP_CMD_TIMEOUT capability. A non-zero value replaces the device command and admin queue timeouts, and the firmware heartbeat check interval derived from them; 0 restores the default. A new value takes effect on the next driver probe or device reset.

Back-date the initial heartbeat check time by the largest possible interval rather than the watchdog period, so that a larger value does not delay the first heartbeat sample after probe or reset.

Accept 0, or 5 to 255 seconds (the u8 range). Values below the 5 second default are rejected, as the parameter is only meant to lengthen the timeouts. On unresponsive firmware, a larger value also lets callers block for longer: each device or admin queue command can wait up to this value, other commands wait behind it, and RDMA verbs such as QP and CQ create can block for several times this value. A large setting may need a larger kernel.hung_task_timeout_secs.

---
 Documentation/networking/devlink/ionic.rst         | 29 +++++++
 drivers/net/ethernet/pensando/ionic/ionic.h        | 12 +++
 drivers/net/ethernet/pensando/ionic/ionic_aux.c    |  2 +-
 .../net/ethernet/pensando/ionic/ionic_bus_pci.c    |  3 +
 drivers/net/ethernet/pensando/ionic/ionic_dev.c    | 81 +++++++++++++++++++-
 drivers/net/ethernet/pensando/ionic/ionic_dev.h    |  3 +
 .../net/ethernet/pensando/ionic/ionic_devlink.c    | 89 ++++++++++++++++++++++
 .../net/ethernet/pensando/ionic/ionic_devlink.h    |  2 +
 drivers/net/ethernet/pensando/ionic/ionic_if.h     |  8 ++
 drivers/net/ethernet/pensando/ionic/ionic_lif.c    |  3 +
 drivers/net/ethernet/pensando/ionic/ionic_main.c   |  3 +-
 11 files changed, 231 insertions(+), 4 deletions(-)
Documentation/networking/devlink/ionic.rst +29 -0
index 48da9c92d5841..40b280bf15721 100644
@@ -7,6 +7,35 @@ ionic devlink support
 This document describes the devlink features implemented by the ``ionic``
 device driver.
 
+Parameters
+==========
+
+The ``ionic`` driver implements the following driver-specific parameters.
+
+.. list-table:: Driver-specific parameters implemented
+   :widths: 5 5 5 85
+
+   * - Name
+     - Type
+     - Mode
+     - Description
+   * - ``cmd_timeout``
+     - u8
+     - permanent
+     - Command timeout in seconds, 0, or 5 (the default) to 255; values below
+       the default are rejected, as the parameter is for cases where the
+       default does not suffice. When set to a non-zero value, replaces the
+       default timeout for device and admin queue commands, and the RDMA admin
+       queue watchdog. A value of 0 restores the default. A larger value delays
+       the firmware heartbeat stall check, which runs at twice this interval.
+       On unresponsive firmware, a larger value also lets callers block for
+       longer: each device or admin queue command can wait up to this value,
+       other commands wait behind it, and RDMA verbs such as QP and CQ create
+       can block for several times this value. A large setting may need a
+       larger kernel.hung_task_timeout_secs. The value is stored in device NVM
+       and takes effect on the next driver probe or device reset. Only
+       available when the device firmware supports it.
+
 Info versions
 =============
 
drivers/net/ethernet/pensando/ionic/ionic.h +12 -0
index 5c54a0ea10a55..db9800147b081 100644
@@ -64,8 +64,20 @@ struct ionic {
 	struct timer_list watchdog_timer;
 	int watchdog_period;
 	u8 cmd_timeout;
+	bool dl_params_registered;
 };
 
+static inline bool ionic_cmd_timeout_valid(u8 timeout)
+{
+	return !timeout || timeout >= IONIC_CMD_TIMEOUT_DEF;
+}
+
+static inline bool ionic_cmd_timeout_supported(struct ionic *ionic)
+{
+	return ionic->ident.dev.capabilities &
+	       cpu_to_le64(IONIC_DEV_CAP_CMD_TIMEOUT);
+}
+
 int ionic_adminq_post(struct ionic_lif *lif, struct ionic_admin_ctx *ctx);
 int ionic_adminq_wait(struct ionic_lif *lif, struct ionic_admin_ctx *ctx,
 		      const int err, const bool do_msg);
drivers/net/ethernet/pensando/ionic/ionic_aux.c +1 -1
index 3b7cecc7f6dde..50312c1ae9eac 100644
@@ -103,6 +103,6 @@ EXPORT_SYMBOL_NS(ionic_request_rdma_reset, "NET_IONIC");
 
 u8 ionic_cmd_timeout(struct ionic_lif *lif)
 {
-	return lif->ionic->cmd_timeout;
+	return READ_ONCE(lif->ionic->cmd_timeout);
 }
 EXPORT_SYMBOL_NS(ionic_cmd_timeout, "NET_IONIC");
drivers/net/ethernet/pensando/ionic/ionic_bus_pci.c +3 -0
index 74ba923a3f1b6..1ed7e6eb77652 100644
@@ -281,6 +281,8 @@ static int ionic_setup_one(struct ionic *ionic)
 		goto err_out_teardown;
 	}
 
+	ionic_update_cmd_timeout(ionic);
+
 	/* Configure the port */
 	err = ionic_port_identify(ionic);
 	if (err) {
@@ -455,6 +457,7 @@ static void ionic_reset_prepare(struct pci_dev *pdev)
 	cancel_work_sync(&lif->deferred.work);
 
 	ionic_auxbus_unregister(ionic->lif);
+	ionic_devlink_params_unregister(ionic);
 	mutex_lock(&lif->queue_lock);
 	ionic_stop_queues_reconfig(lif);
 	ionic_txrx_free(lif);
drivers/net/ethernet/pensando/ionic/ionic_dev.c +79 -2

99 lines not on this page · raw message

drivers/net/ethernet/pensando/ionic/ionic_dev.h +3 -0
index db90e39a1442d..06ca7584ee369 100644
@@ -340,6 +340,9 @@ void ionic_dev_cmd_comp(struct ionic_dev *idev, union ionic_dev_cmd_comp *comp);
 void ionic_dev_cmd_identify(struct ionic_dev *idev, u8 ver);
 void ionic_dev_cmd_init(struct ionic_dev *idev);
 void ionic_dev_cmd_reset(struct ionic_dev *idev);
+int ionic_dev_getattr_cmd_timeout(struct ionic *ionic, u8 *timeout);
+int ionic_dev_setattr_cmd_timeout(struct ionic *ionic, u8 timeout);
+void ionic_update_cmd_timeout(struct ionic *ionic);
 
 void ionic_dev_cmd_port_identify(struct ionic_dev *idev);
 void ionic_dev_cmd_port_init(struct ionic_dev *idev);
drivers/net/ethernet/pensando/ionic/ionic_devlink.c +89 -0

112 lines not on this page · raw message

drivers/net/ethernet/pensando/ionic/ionic_devlink.h +2 -0
index 0a77e8e810c5d..02e1ea559a0e6 100644
@@ -13,5 +13,7 @@ struct ionic *ionic_devlink_alloc(struct device *dev);
 void ionic_devlink_free(struct ionic *ionic);
 int ionic_devlink_register(struct ionic *ionic);
 void ionic_devlink_unregister(struct ionic *ionic);
+void ionic_devlink_params_register(struct ionic *ionic);
+void ionic_devlink_params_unregister(struct ionic *ionic);
 
 #endif /* _IONIC_DEVLINK_H_ */
drivers/net/ethernet/pensando/ionic/ionic_if.h +8 -0
index e911fad545d67..311d205c5b4b7 100644
@@ -275,11 +275,13 @@ union ionic_drv_identity {
  * @IONIC_DEV_CAP_VF_CTRL:     Device supports VF ctrl operations
  * @IONIC_DEV_CAP_DISC_CMB:    Device supports CMB discovery operations
  * @IONIC_DEV_CAP_EXTRA_STATS: Device supports extra stats schema
+ * @IONIC_DEV_CAP_CMD_TIMEOUT: Device supports the command timeout attribute
  */
 enum ionic_dev_capability {
 	IONIC_DEV_CAP_VF_CTRL        = BIT(0),
 	IONIC_DEV_CAP_DISC_CMB       = BIT(1),
 	IONIC_DEV_CAP_EXTRA_STATS    = BIT(4),
+	IONIC_DEV_CAP_CMD_TIMEOUT    = BIT(5),
 };
 
 /**
@@ -1778,11 +1780,13 @@ enum ionic_dev_state {
  * @IONIC_DEV_ATTR_STATE:     Device state attribute
  * @IONIC_DEV_ATTR_NAME:      Device name attribute
  * @IONIC_DEV_ATTR_FEATURES:  Device feature attributes
+ * @IONIC_DEV_ATTR_CMD_TIMEOUT: Command timeout
  */
 enum ionic_dev_attr {
 	IONIC_DEV_ATTR_STATE    = 0,
 	IONIC_DEV_ATTR_NAME     = 1,
 	IONIC_DEV_ATTR_FEATURES = 2,
+	IONIC_DEV_ATTR_CMD_TIMEOUT = 3,
 };
 
 /**
@@ -1793,6 +1797,7 @@ enum ionic_dev_attr {
  * @state:      Device state (enum ionic_dev_state)
  * @name:       The bus info, e.g. PCI slot-device-function, 0 terminated
  * @features:   Device features
+ * @cmd_timeout: Command timeout in seconds, 0 for the default
  * @rsvd2:      reserved byte(s)
  */
 struct ionic_dev_setattr_cmd {
@@ -1803,6 +1808,7 @@ struct ionic_dev_setattr_cmd {
 		u8      state;
 		char    name[IONIC_IFNAMSIZ];
 		__le64  features;
+		u8      cmd_timeout;
 		u8      rsvd2[60];
 	} __packed;
 };
@@ -1842,6 +1848,7 @@ struct ionic_dev_getattr_cmd {
  * @status:     Status of the command (enum ionic_status_code)
  * @rsvd:       reserved byte(s)
  * @features:   Device features
+ * @cmd_timeout: Command timeout in seconds, 0 for the default
  * @rsvd2:      reserved byte(s)
  * @color:      Color bit
  */
@@ -1850,6 +1857,7 @@ struct ionic_dev_getattr_comp {
 	u8     rsvd[3];
 	union {
 		__le64  features;
+		u8      cmd_timeout;
 		u8      rsvd2[11];
 	} __packed;
 	u8     color;
drivers/net/ethernet/pensando/ionic/ionic_lif.c +3 -0
index b0868ab139dd5..a89f9c72eb39d 100644
@@ -3398,6 +3398,7 @@ static void ionic_lif_handle_fw_down(struct ionic_lif *lif)
 	netif_device_detach(lif->netdev);
 
 	ionic_auxbus_unregister(ionic->lif);
+	ionic_devlink_params_unregister(ionic);
 	mutex_lock(&lif->queue_lock);
 	if (test_bit(IONIC_LIF_F_UP, lif->state)) {
 		dev_info(ionic->dev, "Surprise FW stop, stopping queues\n");
@@ -3460,6 +3461,7 @@ int ionic_restart_lif(struct ionic_lif *lif)
 	netif_device_attach(lif->netdev);
 	ionic_queue_doorbell_check(ionic, IONIC_NAPI_DEADLINE);
 
+	ionic_devlink_params_register(ionic);
 	ionic_auxbus_register(ionic->lif);
 
 	return 0;
@@ -3495,6 +3497,7 @@ static void ionic_lif_handle_fw_up(struct ionic_lif *lif)
 	err = ionic_identify(ionic);
 	if (err)
 		goto err_out;
+	ionic_update_cmd_timeout(ionic);
 	err = ionic_port_identify(ionic);
 	if (err)
 		goto err_out;
drivers/net/ethernet/pensando/ionic/ionic_main.c +2 -1
index 16df13f23c90d..a6a5206d6605b 100644
@@ -435,7 +435,8 @@ int ionic_adminq_wait(struct ionic_lif *lif, struct ionic_admin_ctx *ctx,
 	}
 
 	time_start = jiffies;
-	time_limit = time_start + HZ * (ulong)lif->ionic->cmd_timeout;
+	time_limit = time_start +
+		     HZ * (ulong)READ_ONCE(lif->ionic->cmd_timeout);
 	do {
 		remaining = wait_for_completion_timeout(&ctx->work,
 							IONIC_ADMINQ_TIME_SLICE);
Signature · 1 line
2.43.0
#3 lore raw

PATCH 2/3 RDMA/ionic: Use the ionic command timeout for the admin queue

In reply to Nikhil P. Rao

From: Arun Kumar Prakash <[email protected]>

Commit ec8ee714736e ("ionic: stretch heartbeat detection") notes that firmware can take more than 2 seconds to service a device or admin queue request, and is only expected to complete it within the ionic command timeout. The RDMA admin queue watchdog still uses 2 seconds, and when it fires it resets the RDMA LIF and every later verb fails with -ENODEV. Use the ionic command timeout, 5 seconds, instead. The AH create/destroy busy-wait keeps its fixed 2 second bound.

---
 drivers/infiniband/hw/ionic/ionic_admin.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/infiniband/hw/ionic/ionic_admin.c +6 -3
index 0ccd869ad8e6..b463ad8b4e80 100644
@@ -18,8 +18,6 @@
 #define IONIC_ADMIN_BUSY_RETRY_COUNT	2000
 #define IONIC_ADMIN_BUSY_RETRY_MS	1
 
-/* admin queue will be considered failed if a command takes longer */
-#define IONIC_ADMIN_TIMEOUT	(HZ * 2)
 #define IONIC_ADMIN_WARN	(HZ / 8)
 
 /* will poll for admin cq to tolerate and report from missed event */
@@ -28,6 +26,11 @@
 /* work queue for polling the event queue and admin cq */
 struct workqueue_struct *ionic_evt_workq;
 
+static unsigned long ionic_admin_timeout(struct ionic_ibdev *dev)
+{
+	return HZ * ionic_cmd_timeout(dev->lif_cfg.lif);
+}
+
 static void ionic_admin_timedout(struct ionic_aq *aq)
 {
 	struct ionic_ibdev *dev = aq->dev;
@@ -294,7 +297,7 @@ static void ionic_admin_dwork(struct work_struct *ws)
 		}
 
 		if (time_is_after_eq_jiffies(aq->stamp +
-					     IONIC_ADMIN_TIMEOUT)) {
+					     ionic_admin_timeout(dev))) {
 			/* Timeout threshold not met */
 			ibdev_dbg(&dev->ibdev, "no progress after %ums\n",
 				  (u32)jiffies_to_msecs(jiffies - aq->stamp));
Signature · 1 line
2.43.0
#2 lore raw

Re: [PATCH net-next 1/3] ionic: make the command timeout per device

In reply to Nikhil P. Rao
Sashiko has reviewed this patch and found no issues.
Quoted 8 lines

From: Arun Kumar Prakash <[email protected]>

Device and admin queue command waits, and the firmware heartbeat check interval, use the compile-time DEVCMD_TIMEOUT. Make the timeout a per-device value, so that it can be made configurable through a devlink parameter, and export it to the RDMA driver through ionic_cmd_timeout().

Quoted 5 lines

No functional change.

Sashiko has reviewed this patch and found no issues.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
#4 lore raw

Re: [PATCH net-next 2/3] RDMA/ionic: Use the ionic command timeout for the admin queue

In reply to Nikhil P. Rao
Sashiko has reviewed this patch and found no issues.
Quoted 10 lines

From: Arun Kumar Prakash <[email protected]>

Commit ec8ee714736e ("ionic: stretch heartbeat detection") notes that firmware can take more than 2 seconds to service a device or admin queue request, and is only expected to complete it within the ionic command timeout. The RDMA admin queue watchdog still uses 2 seconds, and when it fires it resets the RDMA LIF and every later verb fails with -ENODEV. Use the ionic command timeout, 5 seconds, instead. The AH create/destroy busy-wait keeps its fixed 2 second bound.

Quoted 4 lines

Sashiko has reviewed this patch and found no issues.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
#6 lore raw

Re: [PATCH net-next 3/3] ionic: add devlink param for command timeout

In reply to Nikhil P. Rao
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [Medium] ionic: hardware getattr issued during reset in ionic_dl_cmd_timeout_get() - [Medium] ionic…

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] ionic: hardware getattr issued during reset in ionic_dl_cmd_timeout_get()
- [Medium] ionic: last_hb_time not back-dated on reset in ionic_lif_handle_fw_up() --

commit 0a0b7719e75bbcb6ea7fc807a50ee80589eafae1
Author: Arun Kumar Prakash <[email protected]>

ionic: add devlink param for command timeout

This commit adds a permanent cmd_timeout devlink parameter stored in device NVM to configure device command, admin queue, and firmware heartbeat check timeouts on supported firmware.

Quoted 23 lines
drivers/net/ethernet/pensando/ionic/ionic_devlink.c +15 -0
index 4ec66a6be0738..d775fa5bb43d7 100644
@@ -51,6 +51,55 @@ static int ionic_dl_info_get(struct devlink *dl, struct devlink_info_req *req,
 	return err;
 }
 
+enum ionic_devlink_param_id {
+	IONIC_DEVLINK_PARAM_ID_BASE = DEVLINK_PARAM_GENERIC_ID_MAX,
+	IONIC_DEVLINK_PARAM_ID_CMD_TIMEOUT,
+};
+
+static int ionic_dl_cmd_timeout_get(struct devlink *dl, u32 id,
+				    struct devlink_param_gset_ctx *ctx,
+				    struct netlink_ext_ack *extack)
+{
+	struct ionic *ionic = devlink_priv(dl);
+
+	return ionic_dev_getattr_cmd_timeout(ionic, &ctx->val.vu8);
+}
+
+static int ionic_dl_cmd_timeout_set(struct devlink *dl, u32 id,

drivers/net/ethernet/pensando/ionic/ionic_devlink.c static int ionic_dl_info_get(struct devlink *dl, struct devlink_info_req *req, · line 78

Quoted 10 lines
drivers/net/ethernet/pensando/ionic/ionic_devlink.c +10 -0
+				    struct devlink_param_gset_ctx *ctx,
+				    struct netlink_ext_ack *extack)
+{
+	struct ionic *ionic = devlink_priv(dl);
+
+	if (test_bit(IONIC_LIF_F_FW_RESET, ionic->lif->state))
+		return -EBUSY;
+
+	return ionic_dev_setattr_cmd_timeout(ionic, ctx->val.vu8);
+}

[Severity: Medium]
Unlike ionic_dl_cmd_timeout_set(), ionic_dl_cmd_timeout_get() does not check IONIC_LIF_F_FW_RESET (or IONIC_LIF_F_FW_STOPPING) before calling ionic_dev_getattr_cmd_timeout().

During firmware down or PCI reset preparation in ionic_lif_handle_fw_down() and ionic_reset_prepare() (including when ionic_pci_error_detected() is called with pci_channel_io_frozen), IONIC_LIF_F_FW_RESET is set and then ionic_devlink_params_unregister() is called while the devlink instance is still registered:

ionic_lif_handle_fw_down() / ionic_reset_prepare()
ionic_devlink_params_unregister()
devl_params_unregister()
devlink_param_unregister()
devlink_param_notify(..., DEVLINK_CMD_PARAM_DEL)
devlink_nl_param_fill()
ionic_dl_cmd_timeout_get()
ionic_dev_getattr_cmd_timeout()

Similarly, ionic_devlink_unregister() calls devlink_unregister() before ionic_devlink_params_unregister(), which also invokes devlink_nl_param_fill() via devlink_params_notify_unregister().

If a userspace netlink listener is monitoring devlink events, or if a user queries devlink parameters during the window before the parameter is unregistered, won't ionic_dl_cmd_timeout_get() issue a synchronous MMIO IONIC_CMD_GETATTR command while the firmware is down, the device is in reset, or the PCI channel is frozen, potentially stalling reset recovery for up to cmd_timeout (255) seconds under devl_lock and dev_cmd_lock?

[ ... ]

Quoted 4 lines
drivers/net/ethernet/pensando/ionic/ionic_lif.c +0 -0
index b0868ab139dd5..a89f9c72eb39d 100644

[ ... ]

drivers/net/ethernet/pensando/ionic/ionic_lif.c static void ionic_lif_handle_fw_up(struct ionic_lif *lif) · line 3503

Quoted 8 lines
drivers/net/ethernet/pensando/ionic/ionic_lif.c +1 -0
@@ -3495,6 +3497,7 @@ static void ionic_lif_handle_fw_up(struct ionic_lif *lif)
 	err = ionic_identify(ionic);
 	if (err)
 		goto err_out;
+	ionic_update_cmd_timeout(ionic);
 	err = ionic_port_identify(ionic);
 	if (err)
 		goto err_out;

[Severity: Medium]
The commit message notes that idev->last_hb_time is back-dated by the largest possible interval so that a larger cmd_timeout value does not delay the first heartbeat sample after probe or reset.

However, ionic_watchdog_init() is only called from ionic_dev_setup() during initial probe and PCI function reset, and is not called when recovering from a firmware reset in ionic_lif_handle_fw_up().

When firmware comes back up in ionic_lif_handle_fw_up() and ionic_update_cmd_timeout() applies a large timeout, idev->last_hb_time still holds the timestamp from before the firmware reset. In ionic_heartbeat_check():

	last_check_time = idev->last_hb_time;
	if (time_before(check_time,
			last_check_time +
			READ_ONCE(ionic->cmd_timeout) * 2 * HZ))
		return 0;

Could this cause ionic_heartbeat_check() to skip sampling fw_heartbeat for up to 2 * cmd_timeout (510 seconds) after a firmware reset unless idev->last_hb_time is also back-dated in ionic_lif_handle_fw_up()?

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
#7 lore raw

Re: [PATCH net-next 3/3] ionic: add devlink param for command timeout

Quoted 42 lines · On 11/3/2026 2:28 PM, [email protected] wrote:

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

Quoted 10 lines
drivers/net/ethernet/pensando/ionic/ionic_devlink.c +10 -0
+static int ionic_dl_cmd_timeout_get(struct devlink *dl, u32 id,
+                                 struct devlink_param_gset_ctx *ctx,
+                                 struct netlink_ext_ack *extack)
+{
+     struct ionic *ionic = devlink_priv(dl);
+
+     return ionic_dev_getattr_cmd_timeout(ionic, &ctx->val.vu8);
+}
+
+static int ionic_dl_cmd_timeout_set(struct devlink *dl, u32 id,

drivers/net/ethernet/pensando/ionic/ionic_devlink.c static int ionic_dl_info_get(struct devlink *dl, struct devlink_info_req *req, · line 78

Quoted 10 lines
drivers/net/ethernet/pensando/ionic/ionic_devlink.c +10 -0
+                                 struct devlink_param_gset_ctx *ctx,
+                                 struct netlink_ext_ack *extack)
+{
+     struct ionic *ionic = devlink_priv(dl);
+
+     if (test_bit(IONIC_LIF_F_FW_RESET, ionic->lif->state))
+             return -EBUSY;
+
+     return ionic_dev_setattr_cmd_timeout(ionic, ctx->val.vu8);
+}

[Severity: Medium]
Unlike ionic_dl_cmd_timeout_set(), ionic_dl_cmd_timeout_get() does not check IONIC_LIF_F_FW_RESET (or IONIC_LIF_F_FW_STOPPING) before calling ionic_dev_getattr_cmd_timeout().

During firmware down or PCI reset preparation in ionic_lif_handle_fw_down() and ionic_reset_prepare() (including when ionic_pci_error_detected() is called with pci_channel_io_frozen), IONIC_LIF_F_FW_RESET is set and then ionic_devlink_params_unregister() is called while the devlink instance is still registered:

ionic_lif_handle_fw_down() / ionic_reset_prepare()
ionic_devlink_params_unregister()
devl_params_unregister()
devlink_param_unregister()
devlink_param_notify(..., DEVLINK_CMD_PARAM_DEL)
devlink_nl_param_fill()
ionic_dl_cmd_timeout_get()
ionic_dev_getattr_cmd_timeout()

Quoted 3 lines

Similarly, ionic_devlink_unregister() calls devlink_unregister() before ionic_devlink_params_unregister(), which also invokes devlink_nl_param_fill() via devlink_params_notify_unregister().

On remove, get runs from devlink_unregister() with the firmware running and completes, or fails immediately if the firmware is already down.

Quoted 8 lines

If a userspace netlink listener is monitoring devlink events, or if a user queries devlink parameters during the window before the parameter is unregistered, won't ionic_dl_cmd_timeout_get() issue a synchronous MMIO IONIC_CMD_GETATTR command while the firmware is down, the device is in reset, or the PCI channel is frozen, potentially stalling reset recovery for up to cmd_timeout (255) seconds under devl_lock and dev_cmd_lock?

__ionic_dev_cmd_wait() returns -ENXIO as soon as fw_status shows the firmware is not running, which is the case after firmware down (running bit clear) and with a frozen channel (reads return all-ones). For a PCI reset, get is only called from reset_prepare, before the reset starts and while the firmware is running, and the parameter stays unregistered until reset_done.

get has no FW_RESET check on purpose: devlink calls it from reset_prepare, while the firmware is still running, to fill the PARAM_DEL notification, and the check would make it fail there and drop that notification.

I'll send a v2 with a comment in get explaining why it has no FW_RESET check.

Quoted 29 lines

drivers/net/ethernet/pensando/ionic/ionic_lif.c static void ionic_lif_handle_fw_up(struct ionic_lif *lif) · line 3503

Quoted 8 lines
drivers/net/ethernet/pensando/ionic/ionic_lif.c +1 -0
@@ -3495,6 +3497,7 @@ static void ionic_lif_handle_fw_up(struct ionic_lif *lif)
       err = ionic_identify(ionic);
       if (err)
               goto err_out;
+     ionic_update_cmd_timeout(ionic);
       err = ionic_port_identify(ionic);
       if (err)
               goto err_out;

[Severity: Medium]
The commit message notes that idev->last_hb_time is back-dated by the largest possible interval so that a larger cmd_timeout value does not delay the first heartbeat sample after probe or reset.

However, ionic_watchdog_init() is only called from ionic_dev_setup() during initial probe and PCI function reset, and is not called when recovering from a firmware reset in ionic_lif_handle_fw_up().

When firmware comes back up in ionic_lif_handle_fw_up() and ionic_update_cmd_timeout() applies a large timeout, idev->last_hb_time still holds the timestamp from before the firmware reset. In ionic_heartbeat_check():

         last_check_time = idev->last_hb_time;
         if (time_before(check_time,
                         last_check_time +
                         READ_ONCE(ionic->cmd_timeout) * 2 * HZ))
                 return 0;
Quoted 4 lines

Could this cause ionic_heartbeat_check() to skip sampling fw_heartbeat for up to 2 * cmd_timeout (510 seconds) after a firmware reset unless idev->last_hb_time is also back-dated in ionic_lif_handle_fw_up()?

The next sample can be up to 2 * cmd_timeout away after firmware up, but that is the normal sampling interval.

The back-dating at probe and PCI reset exists because the first sample there only records a baseline (last_fw_hb is 0), so without it a stall would take 4 * cmd_timeout to detect.

After firmware up, last_fw_hb already holds a real reading, so the first sample can detect a stall and detection takes 2 * cmd_timeout, as in steady state.

v2 also changes the changelog's "after probe or reset" to "after probe or PCI reset".

Nikhil