]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
pds_core: fix error handling in pdsc_devcmd_wait
authorNikhil P. Rao <nikhil.rao@amd.com>
Fri, 15 May 2026 21:29:05 +0000 (21:29 +0000)
committerJakub Kicinski <kuba@kernel.org>
Wed, 20 May 2026 02:12:42 +0000 (19:12 -0700)
Fix two cases where pdsc_devcmd_wait() returns stale success from
the completion register instead of an error:

1. FW crash: If firmware stops running, the wait loop breaks early with
   running=false. The condition "if ((!done || timeout) && running)" is
   false, so error handling is bypassed and stale status is returned.
   Check !running first and return -ENXIO.

2. Timeout: If a command times out, err is set to -ETIMEDOUT but then
   overwritten by pdsc_err_to_errno(status) which reads stale status.
   Return -ETIMEDOUT immediately after cleaning up.

Both errors now propagate to pdsc_devcmd_locked() which queues
health_work for recovery.

Fixes: 45d76f492938 ("pds_core: set up device and adminq")
Signed-off-by: Nikhil P. Rao <nikhil.rao@amd.com>
Link: https://patch.msgid.link/20260515212907.998028-1-nikhil.rao@amd.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/amd/pds_core/dev.c

index 2e1d0d01d03af7af50e5534b348de50294077c91..bded6b33289ce0ea8c48265a1265a240a9cdd847 100644 (file)
@@ -162,12 +162,19 @@ static int pdsc_devcmd_wait(struct pdsc *pdsc, u8 opcode, int max_seconds)
                dev_dbg(dev, "DEVCMD %d %s after %ld secs\n",
                        opcode, pdsc_devcmd_str(opcode), duration / HZ);
 
-       if ((!done || timeout) && running) {
+       if (!running) {
+               dev_err(dev, "DEVCMD %d %s fw not running\n",
+                       opcode, pdsc_devcmd_str(opcode));
+               pdsc_devcmd_clean(pdsc);
+               return -ENXIO;
+       }
+
+       if (!done || timeout) {
                dev_err(dev, "DEVCMD %d %s timeout, done %d timeout %d max_seconds=%d\n",
                        opcode, pdsc_devcmd_str(opcode), done, timeout,
                        max_seconds);
-               err = -ETIMEDOUT;
                pdsc_devcmd_clean(pdsc);
+               return -ETIMEDOUT;
        }
 
        status = pdsc_devcmd_status(pdsc);