[PATCH net-next 1/5] ionic: Small improvements in devcmd retry logic

Eric Joyner
2026-05-01T03:16:29Z

From: Brett Creeley <brett.creeley@amd.com>

If the timeout time is hit when the last attempt returned EAGAIN, the
driver returns -ETIMEDOUT. This causes the -EAGAIN result to be lost.
Fix this by returning -EAGAIN if the timeout time is hit and the
previous result matches.

Also, reduce the sleep between the write to done and doorbell
registers. The msleep(1000) was initially added in an arbitrary
manner. However, this long of a sleep is problematic because
it reduces the number of retries when -EAGAIN is returned, which
may result in the devmcd giving up early due to the timeout. Fix
this by reducing the sleep to msleep(50).

Signed-off-by: Brett Creeley <brett.creeley@amd.com>
Signed-off-by: Eric Joyner <eric.joyner@amd.com>
---
drivers/net/ethernet/pensando/ionic/ionic_main.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/pensando/ionic/ionic_main.c b/drivers/net/ethernet/pensando/ionic/ionic_main.c
index 3c5200e2fdb7..92f2ec0bd5af 100644
--- a/drivers/net/ethernet/pensando/ionic/ionic_main.c
+++ b/drivers/net/ethernet/pensando/ionic/ionic_main.c
@@ -554,6 +554,11 @@ static int __ionic_dev_cmd_wait(struct ionic *ionic, unsigned long max_seconds,

if (!done && !time_before(jiffies, max_wait)) {
ionic_dev_cmd_clean(ionic);
+
+ /* allow caller to manage EAGAIN from previous attempt */
+ if (err == IONIC_RC_EAGAIN)
+ return -EAGAIN;
+
dev_warn(ionic->dev, "DEVCMD %s (%d) timeout after %ld secs\n",
ionic_opcode_to_str(opcode), opcode, max_seconds);
return -ETIMEDOUT;
@@ -568,7 +573,7 @@ static int __ionic_dev_cmd_wait(struct ionic *ionic, unsigned long max_seconds,
ionic_error_to_str(err), err);

iowrite32(0, &idev->dev_cmd_regs->done);
- msleep(1000);
+ msleep(50);
iowrite32(1, &idev->dev_cmd_regs->doorbell);
goto try_again;
}
--
2.17.1