[PATCH] pci/doe: add a 1 second retry window to pci_doe

From: Gregory Price
Date: Fri Sep 13 2024 - 14:33:57 EST


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@xxxxxxxxxx>
---
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