From: Alex Williamson <[email protected]> The submitted driver waits at most 1 ms (100 * 10 us) for the last RX descriptor to be written back. QEMU's emulated loopback is synchronous: by the time igb_memcpy_wait() runs, the receive descriptors are already written back. Real 82576 hardware processes the descriptor ring at line rate.
max_memcpy_size is (RING_SIZE - 1) * IGB_MAX_CHUNK_SIZE, approximately 4 MB, split into 4095 1 KB frames. At 1 Gb/s line rate (~125 MB/s), 4 MB takes ~32 ms on the wire, plus per-frame preamble, SFD, inter-frame gap and FCS overhead (~3%) and descriptor fetch/writeback latency. The 1 ms cap times out long before any valid transfer can complete. Wait up to ~200 ms (200 iterations * 1 ms) for descriptor writeback before returning -ETIMEDOUT. ~6x the line-rate floor leaves comfortable headroom for host scheduling jitter while keeping the intentional invalid-DMA tests (mix_and_match) so they recover quickly on real faults. Assisted-by: Claude:claude-opus-4-7 Signed-off-by: Alex Williamson <[email protected]> --- .../testing/selftests/vfio/lib/drivers/igb/igb.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/vfio/lib/drivers/igb/igb.c b/tools/testing/selftests/vfio/lib/drivers/igb/igb.c index a8f2072b6820..879c21780f5b 100644 --- a/tools/testing/selftests/vfio/lib/drivers/igb/igb.c +++ b/tools/testing/selftests/vfio/lib/drivers/igb/igb.c @@ -403,11 +403,22 @@ static int igb_memcpy_wait(struct vfio_pci_device *device) prev_tail = (igb->rx_tail + RING_SIZE - 1) % RING_SIZE; rx = &igb->rx_ring[prev_tail]; - retries = 100; + /* + * Real 82576 hardware processes the descriptor ring at line rate. + * max_memcpy_size = (RING_SIZE - 1) * IGB_MAX_CHUNK_SIZE ~= 4 MB, + * split into 4095 1 KB frames. At 1 Gb/s (~125 MB/s) the worst + * valid memcpy takes ~32 ms on the wire, plus per-frame preamble, + * SFD, IFG and FCS overhead (~3%) and descriptor fetch/writeback + * latency. Wait up to ~200 ms before declaring the device hung; + * ~6x the line-rate floor leaves comfortable headroom for host + * scheduling jitter while keeping the intentional invalid-DMA + * tests bounded. + */ + retries = 200; while (retries-- > 0) { if (rx->wb.status_error & 1) break; - usleep(10); + usleep(1000); } igb_irq_clear(igb); -- 2.54.0.794.g4f17f83d09-goog

