[PATCH net v2 4/5] ionic: fix ethtool coalesce updates racing a reset
From: Nikhil P. Rao
Date: Fri Dec 04 2026 - 17:05:41 EST
ionic_set_coalesce() runs under rtnl only. It saves the new settings,
tests LIF_F_UP and writes each queue's interrupt control register in
BAR0. A PCI reset or a firmware reset clears LIF_F_UP and frees the
queues without rtnl, and the PCI reset also unmaps BAR0, so an update
that passed the test just before the reset reads freed queues and can
write the unmapped BAR. The restart after either reset also programs
the new queues from the saved settings without rtnl, so it can pick up
a half-written update.
The teardown and the restart of both resets run under queue_lock, so
take it for the whole update. ethtool's ring and channel changes
already take queue_lock under rtnl.
Found by an AI code review of this series and confirmed by reading the
code. Not reproduced, as there is no call between the test and the
register write where a test module could hold the update. Tested on an
AMD Pensando NIC, on a kernel with KASAN and lockdep, with ethtool -C
running during 30 PCI resets.
Fixes: c672412f6172 ("ionic: remove lifs on fw reset")
Fixes: a79b559e99be ("ionic: add FLR recovery support")
Cc: <stable@xxxxxxxxxxxxxxx> # 5.10.x: 2624d95972db: ionic: widen queue_lock use around lif init and deinit
Cc: <stable@xxxxxxxxxxxxxxx> # 5.10.x
Reviewed-by: Brett Creeley <brett.creeley@xxxxxxx>
Signed-off-by: Nikhil P. Rao <nikhil.rao@xxxxxxx>
---
drivers/net/ethernet/pensando/ionic/ionic_ethtool.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/net/ethernet/pensando/ionic/ionic_ethtool.c b/drivers/net/ethernet/pensando/ionic/ionic_ethtool.c
index 1360a3dfb7c6..bc0601dbcf63 100644
--- a/drivers/net/ethernet/pensando/ionic/ionic_ethtool.c
+++ b/drivers/net/ethernet/pensando/ionic/ionic_ethtool.c
@@ -555,6 +555,8 @@ static int ionic_set_coalesce(struct net_device *netdev,
tx_coal > IONIC_INTR_CTRL_COAL_MAX)
return -ERANGE;
+ mutex_lock(&lif->queue_lock);
+
/* Save the new values */
lif->rx_coalesce_usecs = coalesce->rx_coalesce_usecs;
lif->rx_coalesce_hw = rx_coal;
@@ -598,6 +600,7 @@ static int ionic_set_coalesce(struct net_device *netdev,
}
}
}
+ mutex_unlock(&lif->queue_lock);
return 0;
}
--
2.43.0