* [PATCH] pci: pci_vfio: Retry vfio setup device reset, if device is busy
@ 2025-08-20 14:00 Thanushree Sreerama
0 siblings, 0 replies; only message in thread
From: Thanushree Sreerama @ 2025-08-20 14:00 UTC (permalink / raw)
To: thanushree.sreerama; +Cc: stable
From: "Thanushree.Sreerama" <thanushree.sreerama@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@dpdk.org
Change-Id: Ib0a55719dfd55b06ccc1dd6683dcd0ef1bd002ca
Signed-off-by: Thanushree Sreerama <thanushree.sreerama@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);
+ continue;
+ }
+
RTE_LOG(ERR, EAL, "Unable to reset device! Error: %d (%s)\n",
errno, strerror(errno));
return -1;
--
2.42.0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2025-08-21 9:07 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-08-20 14:00 [PATCH] pci: pci_vfio: Retry vfio setup device reset, if device is busy Thanushree Sreerama
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).