vdpa/snet: Don't discard the DPU error in snet_send_ctrl_msg()
Subsystems (3)
PATCH 1/1 vdpa/snet: Don't discard the DPU error in snet_send_ctrl_msg()
snet_send_ctrl_msg() reads the error code the DPU reports when it ACKs a control message, but then overwrites it with the return value of snet_wait_for_dpu_completion(). As a result, a DESTROY, SUSPEND or RESUME that the DPU rejects is reported to the caller as a success as long as the DPU clears the opcode register in time.
For SUSPEND this means vhost-vdpa marks the device as suspended and lets userspace reprogram the vrings while the DPU is still running them; for DESTROY, snet_reset_dev() never even sees that the device failed to stop.
Return the error from the saved ACK value once the completion wait itself has succeeded.
---
Compile-tested only (x86_64 defconfig + SNET_VDPA, W=1, sparse).
drivers/vdpa/solidrun/snet_ctrl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/vdpa/solidrun/snet_ctrl.c +2 -1
@@ -291,7 +291,6 @@ static int snet_send_ctrl_msg(struct snet *snet, u16 opcode, u16 vq_idx)/* Check for errors */ val =snet_read_ctrl (regs); - ret =SNET_VAL_TO_ERR (val);/* Clear the chunk ready bit */ val &= ~SNET_CTRL_CHUNK_RDY_MASK ;
@@ -301,6 +300,8 @@ static int snet_send_ctrl_msg(struct snet *snet, u16 opcode, u16 vq_idx)if (ret)SNET_WARN (pdev,"Timeout waiting for DPU to complete a control command, err %d\n" , ret); +else + ret =SNET_VAL_TO_ERR (val); exit:mutex_unlock (&snet->ctrl_lock);
base-commit: 7704c4c5bb127673b4f0ead839919db573559e38
Signature · 1 line
2.43.0
[email protected]
AI reviewSashiko has reviewed this patch and found no issues. It looks great!
Quoted 11 lines
snet_send_ctrl_msg()reads the error code the DPU reports when it ACKs a control message, but then overwrites it with the return value ofsnet_wait_for_dpu_completion(). As a result, a DESTROY, SUSPEND or RESUME that the DPU rejects is reported to the caller as a success as long as the DPU clears the opcode register in time.For SUSPEND this means vhost-vdpa marks the device as suspended and lets userspace reprogram the vrings while the DPU is still running them; for DESTROY,
snet_reset_dev()never even sees that the device failed to stop.
Quoted 6 lines
Return the error from the saved ACK value once the completion wait itself has succeeded.
Fixes 3f3a1675b731 ("vdpa/snet: support getting and setting VQ state")Signed-off-by Yuho Choi <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1