linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] pci/doe: add a 1 second retry window to pci_doe
@ 2024-09-13 18:32 Gregory Price
  2024-09-14  5:32 ` Dan Williams
  0 siblings, 1 reply; 7+ messages in thread
From: Gregory Price @ 2024-09-13 18:32 UTC (permalink / raw)
  To: linux-pci
  Cc: linux-cxl, linux-kernel, bhelgaas, dan.j.williams, dave,
	jonathan.cameron, dave.jiang, vishal.l.verma

Depending on the device, sometimes firmware clears the busy flag
later than expected.  This can cause the device to appear busy when
calling multiple commands in quick sucession. Add a 1 second retry
window to all doe commands that end with -EBUSY.

Signed-off-by: Gregory Price <gourry@gourry.net>
---
 drivers/pci/doe.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/pci/doe.c b/drivers/pci/doe.c
index 652d63df9d22..5573fa1a0008 100644
--- a/drivers/pci/doe.c
+++ b/drivers/pci/doe.c
@@ -647,12 +647,16 @@ int pci_doe(struct pci_doe_mb *doe_mb, u16 vendor, u8 type,
 		.private = &c,
 	};
 	int rc;
+	unsigned long timeout_jiffies = jiffies + (PCI_DOE_TIMEOUT * 1);
 
-	rc = pci_doe_submit_task(doe_mb, &task);
-	if (rc)
-		return rc;
+	do {
+		rc = pci_doe_submit_task(doe_mb, &task);
+
+		if (rc)
+			return rc;
 
-	wait_for_completion(&c);
+		wait_for_completion(&c);
+	} while (task.rv == -EBUSY && !time_after(jiffies, timeout_jiffies));
 
 	return task.rv;
 }
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-10-04 11:32 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-13 18:32 [PATCH] pci/doe: add a 1 second retry window to pci_doe Gregory Price
2024-09-14  5:32 ` Dan Williams
2024-09-16  9:15   ` Jonathan Cameron
2024-10-01 15:13     ` Gregory Price
2024-10-01 15:47       ` Lukas Wunner
2024-10-01 16:04         ` Gregory Price
2024-10-04 11:32         ` Jonathan Cameron

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).