Re: [PATCH net-next] net/mlx5: Add reset_prepare and reset_done callbacks

From: Moshe Shemesh

Date: Wed Oct 14 2026 - 10:32:31 EST




On 10/14/2026 9:38 AM, Narcisa Vasile wrote:
On Sun, Oct 11, 2026 at 12:48:09PM +0300, Tariq Toukan wrote:
From: Akiva Goldberger <agoldberger@xxxxxxxxxx>

Currently, the mlx5_core driver registers only the error_detected,
slot_reset and resume PCI error handlers. Add the reset_prepare and
reset_done callbacks, which are triggered by the PCI core before and
after a PCI reset, respectively. These callbacks let mlx5 quiesce and
restore device resources and commands around a PCI reset, so the driver
no longer relies on the reset happening while the device is otherwise
idle.

Additionally, add a device flag to indicate when a PCI reset is in
progress to serialize PCI reset flows with other reset flows, namely FW
reset. This flag also indicates to the reset_prepare and reset_done
callbacks when to do a full unload/reload of the driver. When the
callbacks are triggered by the hot-reset FW reset method, they leave the
teardown and reload to the FW reset.

Signed-off-by: Akiva Goldberger <agoldberger@xxxxxxxxxx>
Reviewed-by: Moshe Shemesh <moshe@xxxxxxxxxx>
Signed-off-by: Tariq Toukan <tariqt@xxxxxxxxxx>
---

+static void mlx5_pci_reset_prepare(struct pci_dev *pdev)
+{
+ mlx5_drain_health_wq(dev);
+ mlx5_unload_one(dev, false);
+ mlx5_pci_disable_device(dev);
This disables bus-mastering, after which pci_save_state snapshots it in
the disabled state. reset_done() re-enables it but the snapshot remains
stale.


Good point, will send v2.
Thanks.

If a FW error later triggers the sw recovery through mlx5_pci_slot_reset(),
the stale snapshot is re-applied with pci_restore_state().
Would this disable bus mastering again and block the driver recovery?
Should pci_set_master(pdev); and pci_restore_state(pdev); be reordered
in mlx5_pci_slot_reset()?
+}
+
+static void mlx5_pci_reset_done(struct pci_dev *pdev)
+{
+ err = mlx5_pci_enable_device(dev);
+ if (err) {
+ mlx5_core_err(dev, "%s: mlx5_pci_enable_device failed, err = %d\n",
+ __func__, err);
nit: mlx5_core_err already prints __func__
+ goto clear_pci_reset_flag;
+ }