From: Brett Creeley 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. Another commit uses this return value to help signal that a deferred probe should be performed due to the firmware not being ready, which is why it would return EAGAIN. 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 Signed-off-by: Eric Joyner --- drivers/net/ethernet/pensando/ionic/ionic_main.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/pensando/ionic/ionic_main.c b/drivers/net/ethernet/pensando/ionic/ionic_main.c index 3c5200e2fdb7..a81b14e6a591 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_main.c +++ b/drivers/net/ethernet/pensando/ionic/ionic_main.c @@ -518,10 +518,10 @@ static int __ionic_dev_cmd_wait(struct ionic *ionic, unsigned long max_seconds, unsigned long start_time; unsigned long max_wait; unsigned long duration; + int err = 0; bool fw_up; int opcode; bool done; - int err; /* Wait for dev cmd to complete, retrying if we get EAGAIN, * but don't wait any longer than max_seconds. @@ -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; @@ -562,13 +567,13 @@ static int __ionic_dev_cmd_wait(struct ionic *ionic, unsigned long max_seconds, err = ionic_dev_cmd_status(&ionic->idev); if (err) { if (err == IONIC_RC_EAGAIN && - time_before(jiffies, (max_wait - HZ))) { + time_before(jiffies, max_wait - msecs_to_jiffies(50))) { dev_dbg(ionic->dev, "DEV_CMD %s (%d), %s (%d) retrying...\n", ionic_opcode_to_str(opcode), opcode, 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