[PATCH 13/21] soundwire: amd: Check ping command response for timeout

From: Lee Jones

Date: Fri Oct 30 2026 - 07:16:46 EST


When amd_sdw_send_cmd_get_resp() times out, it returns -ETIMEDOUT as a
sign-extended 64-bit value. amd_sdw_read_and_process_ping_status() and
amd_sdw_read_ping_status() extract peripheral status bits directly from
the returned value without checking for -ETIMEDOUT, interpreting the
error code bits as peripheral status values.

Check for -ETIMEDOUT before extracting peripheral status from the ping
response, matching amd_program_scp_addr() and amd_sdw_fill_msg_resp().

Fixes: d8f48fbdfd9a ("soundwire: amd: Add support for AMD Manager driver")
Closes: https://sashiko.dev/#/bug/linux-c3a53ed5-eb8f-4982-a3b6-db189e009b68
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Lee Jones <lee@xxxxxxxxxx>
---
drivers/soundwire/amd_manager.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/drivers/soundwire/amd_manager.c b/drivers/soundwire/amd_manager.c
index a3316efdf8ac..a8220235a2ae 100644
--- a/drivers/soundwire/amd_manager.c
+++ b/drivers/soundwire/amd_manager.c
@@ -448,6 +448,8 @@ static void amd_sdw_read_and_process_ping_status(struct amd_sdw_manager *amd_man
mutex_lock(&amd_manager->bus.msg_lock);
response = amd_sdw_send_cmd_get_resp(amd_manager, 0, 0);
mutex_unlock(&amd_manager->bus.msg_lock);
+ if (response == -ETIMEDOUT)
+ return;
amd_sdw_process_ping_status(response, amd_manager);
}

@@ -458,6 +460,8 @@ static u32 amd_sdw_read_ping_status(struct sdw_bus *bus)
u32 slave_stat;

response = amd_sdw_send_cmd_get_resp(amd_manager, 0, 0);
+ if (response == -ETIMEDOUT)
+ return 0;
/* slave status from ping response */
slave_stat = FIELD_GET(AMD_SDW_MCP_SLAVE_STAT_0_3, response);
slave_stat |= FIELD_GET(AMD_SDW_MCP_SLAVE_STAT_4_11, response) << 8;
--
2.56.0.317.g454f8302e1-goog