patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Thanushree Sreerama <thanushree.sreerama@nokia.com>
To: thanushree.sreerama@nokia.com
Cc: stable@dpdk.org
Subject: [PATCH] pci: pci_vfio: Retry vfio setup device reset, if device is busy
Date: Wed, 20 Aug 2025 16:00:38 +0200	[thread overview]
Message-ID: <20250820140039.3540-1-thanushree.sreerama@nokia.com> (raw)

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


                 reply	other threads:[~2025-08-21  9:07 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250820140039.3540-1-thanushree.sreerama@nokia.com \
    --to=thanushree.sreerama@nokia.com \
    --cc=stable@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).