Re: [PATCH v2 09/10] selftests/vfio: igb: Recover after DMA-read faults

From: David Matlack

Date: Mon Jul 06 2026 - 17:21:35 EST


On 2026-05-26 11:54 PM, Josh Hilke wrote:
> From: Alex Williamson <alex.williamson@xxxxxxxxxx>
>
> The mix_and_match test intentionally submits a TX descriptor with an
> unmapped source IOVA so that the DMA read fails. On real 82576
> hardware the resulting fault leaves the descriptor engine unable to
> service subsequent valid descriptors, so the next memcpy in the same
> test iteration times out.
>
> The 82576 datasheet (section 4.2.1.6.1) describes CTRL.RST as the
> software mechanism to recover from a hung device. Empirically
> CTRL.RST alone is not sufficient in this state: the visible queue
> registers are reinitialized, but the next valid memcpy still posts
> descriptors without any TDH/TDT progress in the same process. A
> fresh device open after the failure works, which points to a reset
> scope broader than CTRL.RST being required. The 82576 advertises
> PCIe FLR; VFIO_DEVICE_RESET drives FLR and supplies that scope while
> preserving the selftest process and its DMA mappings.
>
> Add igb_error_reset_and_reinit() implementing the recovery sequence:
> issue VFIO_DEVICE_RESET, re-arm the kernel-side MSI-X trigger against
> the still-valid eventfd via vfio_pci_irq_reenable() (this does not
> touch the eventfd, which test fixtures may have cached), and
> re-program the device via igb_hw_init(). FLR clears EICR and leaves
> EIMS=0, so no explicit interrupt mask or cause writes are needed.
> igb_hw_init() resets tx_tail/rx_tail to 0 and igb_memcpy_start() zeros
> each descriptor before submission, so no ring memset is needed either.
>
> Call this from igb_memcpy_wait() on completion timeout, preceded by a
> 10 ms delay so that PCIe/IOMMU/AER error handling triggered by the
> just-observed DMA fault can release the device lock VFIO_DEVICE_RESET
> contends for. The delay is heuristic and tied to the fault path, so
> it lives at the call site rather than inside the reset helper. The
> failed memcpy still returns -ETIMEDOUT; reset recovery only ensures
> the next operation starts from a usable device state.
>
> Assisted-by: Claude:claude-opus-4-7
> Signed-off-by: Alex Williamson <alex.williamson@xxxxxxxxxx>

Reviewed-by: David Matlack <dmatlack@xxxxxxxxxx>