Re: [PATCH v2 08/10] selftests/vfio: igb: Factor hardware programming into igb_hw_init()
From: David Matlack
Date: Mon Jul 06 2026 - 17:16:23 EST
On 2026-05-26 11:54 PM, Josh Hilke wrote:
> From: Alex Williamson <alex.williamson@xxxxxxxxxx>
>
> Split the device register programming out of igb_init() into a new
> igb_hw_init() helper so that the same sequence can be re-run after a
> VFIO_DEVICE_RESET to restore the registers that CTRL.RST clears. No
> functional change for the initial path.
>
> igb_init() now performs the one-shot setup: region size assertion, BAR
> mapping, CTRL.RST + IMC mask-all to put the device into a known state,
> and vfio_pci_msix_enable() to set up the kernel-side IRQ trigger.
> igb_hw_init() does the rest: ring pointer setup and IOVA calc,
> CTRL_EXT, PCI bus master, GCR, PHY loopback, descriptor rings, RCTL,
> TCTL, GPIE/EIAC/EIAM/EIMS/IVAR, and driver-state initialization.
>
> vfio_pci_msix_enable() moves from after RCTL/TCTL to before all
> device-side programming. Its only side effects are the VFIO kernel
> IRQ trigger setup and the PCI MSI-X capability bits in config space;
> neither has any ordering dependency on the 82576 device register
> writes performed in igb_hw_init(). Performing it once in igb_init()
> keeps igb_hw_init() reusable from the reset recovery path (which uses
> vfio_pci_irq_reenable() to re-arm the existing trigger).
>
> Assisted-by: Claude:claude-opus-4-7
> Signed-off-by: Alex Williamson <alex.williamson@xxxxxxxxxx>
Reviewed-by: David Matlack <dmatlack@xxxxxxxxxx>