[PATCH] pci: pci_vfio: Retry vfio setup device reset, if device is busy

Burakov, Anatoly anatoly.burakov at intel.com
Wed Sep 3 16:16:45 CEST 2025


On 9/3/2025 1:17 PM, Thanushree Sreerama wrote:
> From: "Thanushree.Sreerama" <thanushree.sreerama at nokia.com>
> 
> Add proper EAGAIN handling for the device setup by retrying the device reset
> 
> Issue:
> asc-0a Disp_0[18237]: EAL: Unable to reset device! Error: 11 (Resource temporarily unavailable)
> asc-0a Disp_0[18237]: EAL: 0000:f4:02.3 setup device failed
> asc-0a Disp_0[18237]: EAL: Requested device 0000:f4:02.3 cannot be used
> 
> Caused due to:
> 92d847a35e1 ("Revert "driver core: Fix uevent_show() vs driver detach race"")
> Cc: stable at dpdk.org
> 
> Change-Id: Ic3ae8701fccdbf1e8e2a575d48e707b4c58e939a
> Signed-off-by: Thanushree Sreerama <thanushree.sreerama at nokia.com>
> ---
>   drivers/bus/pci/linux/pci_vfio.c | 16 +++++++++++++++-
>   1 file changed, 15 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/bus/pci/linux/pci_vfio.c b/drivers/bus/pci/linux/pci_vfio.c
> index fab3483d9f..20e212c9f1 100644
> --- a/drivers/bus/pci/linux/pci_vfio.c
> +++ b/drivers/bus/pci/linux/pci_vfio.c
> @@ -478,6 +478,8 @@ pci_vfio_is_ioport_bar(int vfio_dev_fd, int bar_index)
>   static int
>   pci_rte_vfio_setup_device(struct rte_pci_device *dev, int vfio_dev_fd)
>   {
> +	int i, ret = 0, max_retries = 5, retry_delay_ms = 20;
> +
>   	if (pci_vfio_setup_interrupts(dev, vfio_dev_fd) != 0) {
>   		RTE_LOG(ERR, EAL, "Error setting up interrupts!\n");
>   		return -1;
> @@ -498,7 +500,19 @@ pci_rte_vfio_setup_device(struct rte_pci_device *dev, int vfio_dev_fd)
>   	 * Reset the device. If the device is not capable of resetting,
>   	 * then it updates errno as EINVAL.
>   	 */
> -	if (ioctl(vfio_dev_fd, VFIO_DEVICE_RESET) && errno != EINVAL) {
> +	for (i = 0; i < max_retries; i++) {
> +		errno = 0;
> +		ret = ioctl(vfio_dev_fd, VFIO_DEVICE_RESET);
> +		if (!ret || errno == EINVAL)
> +			break;
> +
> +		if (errno == EAGAIN) {
> +			RTE_LOG(DEBUG, EAL, "Device busy, sleep %d ms and retry to reset %d of %d times\n",
> +				retry_delay_ms, i + 1, max_retries);
> +			usleep(retry_delay_ms * 1000);

Perhaps use one of the rte_delay_* functions for portability?

> +			continue;
> +		}
> +
>   		RTE_LOG(ERR, EAL, "Unable to reset device! Error: %d (%s)\n",
>   				errno, strerror(errno));
>   		return -1;


-- 
Thanks,
Anatoly


More information about the dev mailing list