From: "Mukunda,Vijendar" <vijendar.mukunda@amd.com>
To: sashiko-reviews@lists.linux.dev
Cc: linux-sound@vger.kernel.org,
Syed Saba Kareem <syed.sabakareem@amd.com>,
"Dommati, Sunil-kumar" <Sunil-kumar.Dommati@amd.com>,
"Prasad, Prasad" <venkataprasad.potturu@amd.com>,
"N, Poojitha" <Poojitha.N@amd.com>,
Mario Limonciello <Mario.Limonciello@amd.com>,
Vinod Koul <vkoul@kernel.org>,
Pierre-Louis Bossart <pierre-louis.bossart@linux.dev>,
Bard Liao <yung-chuan.liao@linux.intel.com>
Subject: Re: [PATCH v4 02/13] soundwire: amd: return response on IMM status cleanup timeout
Date: Mon, 26 Oct 2026 19:15:57 +0530 [thread overview]
Message-ID: <e2d6b65a-9125-4938-a2b4-5ba032f1ec88@amd.com> (raw)
In-Reply-To: <b9a63395-16f0-46ee-9208-19b3b28d876c@amd.com>
On 10/26/26 17:43, Mukunda,Vijendar wrote:
>
>
> On 10/26/26 14:38, sashiko-bot@kernel.org wrote:
>> [You don't often get email from sashiko-bot@kernel.org. Learn why
>> this is important at https://aka.ms/LearnAboutSenderIdentification ]
>>
>> Thank you for your contribution! Sashiko AI review found 1 potential
>> issue(s) to consider:
>> - [High] soundwire: amd: unpolled IMM_RES_VALID clear in
>> amd_sdw_send_cmd_get_resp()
>> --
>>
>> commit 3a55a761f23cc08cf1a64f142c04e1aa78cc244d
>> Author: Vijendar Mukunda <Vijendar.Mukunda@amd.com>
>>
>> soundwire: amd: return response on IMM status cleanup timeout
>>
>> This commit changes amd_sdw_send_cmd_get_resp() to log an error,
>> store the
>> read response, and return 0 when polling for AMD_SDW_IMM_RES_VALID to
>> clear
>> times out. It relies on the bad-state check at the start of the next
>> invocation to clear the remaining AMD_SDW_IMM_RES_VALID bit.
>>
>>> diff --git a/drivers/soundwire/amd_manager.c
>>> b/drivers/soundwire/amd_manager.c
>>> index 307cbfdb94422..0b83126b5ce6c 100644
>>> --- a/drivers/soundwire/amd_manager.c
>>> +++ b/drivers/soundwire/amd_manager.c
>>> @@ -285,11 +285,9 @@ static int amd_sdw_send_cmd_get_resp(struct
>>> amd_sdw_manager *amd_manager, u32 lo
>>> writel(AMD_SDW_IMM_RES_VALID, amd_manager->mmio +
>>> ACP_SW_IMM_CMD_STS);
>>> ret = readl_poll_timeout(amd_manager->mmio +
>>> ACP_SW_IMM_CMD_STS, sts,
>>> !(sts & AMD_SDW_IMM_RES_VALID),
>>> ACP_DELAY_US, AMD_SDW_TIMEOUT);
>>> - if (ret) {
>>> + if (ret)
>>> dev_err(amd_manager->dev, "SDW%x cmd status retry
>>> failed\n",
>>> amd_manager->instance);
>>> - return ret;
>>> - }
>>> *response = ((u64)upper_resp << 32) | lower_resp;
>>> return 0;
>>> }
>> [Severity: High]
>> When this cleanup poll for !(sts & AMD_SDW_IMM_RES_VALID) times out and
>> amd_sdw_send_cmd_get_resp() in drivers/soundwire/amd_manager.c
>> returns 0,
>> can back-to-back commands read stale response data from
>> ACP_SW_IMM_RESP_UPPER_WORD and ACP_SW_IMM_RESP_LOWER_QWORD?
++
> No. The response for the current command has already been latched and
> read
> before the cleanup poll is performed.
>
> The first poll waits for AMD_SDW_IMM_RES_VALID to be set, indicating that
> the response is available. A timeout there is still returned as an error
> and this behavior is unchanged.
>
> The trailing poll only waits for AMD_SDW_IMM_RES_VALID to be cleared
> after
> the response has been read. Therefore, a timeout during this cleanup does
> not invalidate the response that was already obtained.
>>
>> Callers such as amd_program_scp_addr() and amd_sdw_xfer_msg() issue
>> multiple
>> commands in sequence:
>>
>> sdw_transfer()
>> do_transfer()
>> amd_sdw_xfer_msg()
>> amd_prep_msg()
>> amd_program_scp_addr()
>> amd_sdw_send_cmd_get_resp()
>> _amd_sdw_xfer_msg()
>> amd_sdw_send_cmd_get_resp()
>>
>> On the immediate next call to amd_sdw_send_cmd_get_resp(), the bad-state
>> guard writes AMD_SDW_IMM_RES_VALID to ACP_SW_IMM_CMD_STS without
>> polling for
>> !(sts & AMD_SDW_IMM_RES_VALID) before issuing the next command and
>> polling
>> for (sts & AMD_SDW_IMM_RES_VALID):
>>
>> if (sts & AMD_SDW_IMM_RES_VALID) {
>> dev_err(amd_manager->dev, "SDW%x manager is in bad
>> state\n", amd_manager->instance);
>> writel(AMD_SDW_IMM_RES_VALID, amd_manager->mmio +
>> ACP_SW_IMM_CMD_STS);
>> }
>> writel(upper_data, amd_manager->mmio +
>> ACP_SW_IMM_CMD_UPPER_WORD);
>> writel(lower_data, amd_manager->mmio +
>> ACP_SW_IMM_CMD_LOWER_QWORD);
>>
>> ret = readl_poll_timeout(amd_manager->mmio +
>> ACP_SW_IMM_CMD_STS, sts,
>> (sts & AMD_SDW_IMM_RES_VALID),
>> ACP_DELAY_US, AMD_SDW_TIMEOUT);
>>
>> Because clearing AMD_SDW_IMM_RES_VALID requires an asynchronous hardware
>> handshake that already failed to complete within AMD_SDW_TIMEOUT on the
>> previous command, won't AMD_SDW_IMM_RES_VALID still be set when
>> readl_poll_timeout() immediately checks (sts & AMD_SDW_IMM_RES_VALID),
>> causing it to succeed on the stale bit and read the previous command's
>> response registers? Should the bad-state guard also poll until
>> !(sts & AMD_SDW_IMM_RES_VALID) before writing the new command words?
> No. If AMD_SDW_IMM_RES_VALID is still set on the next invocation, the
> bad-state path clears it by writing AMD_SDW_IMM_RES_VALID to
> ACP_SW_IMM_CMD_STS before programming the next command.
>
> This behavior is also consistent with the hardware reference
> implementation, where the bad-state path uses the same write-1-to-clear
> sequence without polling again for the status bit to clear.
> Therefore, no additional change is required for this scenario.
>
>>
>> --
>> Sashiko AI review ·
>> https://sashiko.dev/#/patchset/20261026044507.2310694-1-Vijendar.Mukunda@amd.com?part=2
>
next prev parent reply other threads:[~2026-10-26 13:47 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-26 4:43 [PATCH v4 00/13] soundwire: amd: SoundWire manager driver bug fixes Vijendar Mukunda
2026-10-26 4:43 ` [PATCH v4 01/13] soundwire: amd: fix SDW command timeout return value handling Vijendar Mukunda
2026-10-26 4:43 ` [PATCH v4 02/13] soundwire: amd: return response on IMM status cleanup timeout Vijendar Mukunda
2026-10-26 9:08 ` sashiko-bot
2026-10-26 12:13 ` Mukunda,Vijendar
2026-10-26 13:45 ` Mukunda,Vijendar [this message]
2026-10-26 4:43 ` [PATCH v4 03/13] soundwire: amd: cache ping slave status to avoid spurious disconnect on timeout Vijendar Mukunda
2026-10-26 4:43 ` [PATCH v4 04/13] soundwire: amd: assert msg_lock is held in amd_sdw_read_ping_status() Vijendar Mukunda
2026-10-26 4:43 ` [PATCH v4 05/13] soundwire: amd: fix work drain ordering in remove path Vijendar Mukunda
2026-10-26 9:27 ` sashiko-bot
2026-10-27 8:18 ` Mukunda,Vijendar
2026-10-26 4:43 ` [PATCH v4 06/13] soundwire: amd: pm_runtime guard " Vijendar Mukunda
2026-10-26 4:43 ` [PATCH v4 07/13] soundwire: amd: fix ctx leak when sdw_amd_startup() fails Vijendar Mukunda
2026-10-26 9:48 ` sashiko-bot
2026-10-27 4:46 ` Mukunda,Vijendar
2026-10-26 4:43 ` [PATCH v4 08/13] soundwire: amd: propagate amd_init_sdw_manager() error on resume Vijendar Mukunda
2026-10-26 4:43 ` [PATCH v4 09/13] soundwire: amd: drop amd_deinit_sdw_manager() in POWER_OFF suspend Vijendar Mukunda
2026-10-26 4:43 ` [PATCH v4 10/13] soundwire: amd: replace >= ACP70 with explicit switch/case in PM paths Vijendar Mukunda
2026-10-26 4:43 ` [PATCH v4 11/13] soundwire: amd: fix interrupt gate and work drain ordering in PM ops Vijendar Mukunda
2026-10-26 10:27 ` sashiko-bot
2026-10-27 8:28 ` Mukunda,Vijendar
2026-10-26 4:43 ` [PATCH v4 12/13] soundwire: amd: fix IRQ thread dropping STATUS_0TO7 on simultaneous wake Vijendar Mukunda
2026-10-26 10:42 ` sashiko-bot
2026-10-27 3:48 ` Mukunda,Vijendar
2026-10-26 4:43 ` [PATCH v4 13/13] soundwire: amd: fix STATUS_8TO11 double-clear race in wake handler Vijendar Mukunda
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e2d6b65a-9125-4938-a2b4-5ba032f1ec88@amd.com \
--to=vijendar.mukunda@amd.com \
--cc=Mario.Limonciello@amd.com \
--cc=Poojitha.N@amd.com \
--cc=Sunil-kumar.Dommati@amd.com \
--cc=linux-sound@vger.kernel.org \
--cc=pierre-louis.bossart@linux.dev \
--cc=sashiko-reviews@lists.linux.dev \
--cc=syed.sabakareem@amd.com \
--cc=venkataprasad.potturu@amd.com \
--cc=vkoul@kernel.org \
--cc=yung-chuan.liao@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.