Skip to content

Commit 802134c

Browse files
Venkata-Prasad-Potturubroonie
authored andcommittedDec 19, 2023
ASoC: SOF: amd: Refactor spinlock_irq(&sdev->ipc_lock) sequence in irq_handler
Refactor spinlock_irq(&sdev->ipc_lock) sequence in irq_handler to avoid race conditions for acquiring hw_semaphore. Signed-off-by: Venkata Prasad Potturu <venkataprasad.potturu@amd.com> Link: https://msgid.link/r/20231219112416.3334928-1-venkataprasad.potturu@amd.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 8b69dba commit 802134c

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed
 

‎sound/soc/sof/amd/acp-ipc.c

+1-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// This file is provided under a dual BSD/GPLv2 license. When using or
44
// redistributing this file, you may do so under either license.
55
//
6-
// Copyright(c) 2021 Advanced Micro Devices, Inc.
6+
// Copyright(c) 2021, 2023 Advanced Micro Devices, Inc.
77
//
88
// Authors: Balakishore Pati <Balakishore.pati@amd.com>
99
// Ajit Kumar Pandey <AjitKumar.Pandey@amd.com>
@@ -188,13 +188,11 @@ irqreturn_t acp_sof_ipc_irq_thread(int irq, void *context)
188188

189189
dsp_ack = snd_sof_dsp_read(sdev, ACP_DSP_BAR, ACP_SCRATCH_REG_0 + dsp_ack_write);
190190
if (dsp_ack) {
191-
spin_lock_irq(&sdev->ipc_lock);
192191
/* handle immediate reply from DSP core */
193192
acp_dsp_ipc_get_reply(sdev);
194193
snd_sof_ipc_reply(sdev, 0);
195194
/* set the done bit */
196195
acp_dsp_ipc_dsp_done(sdev);
197-
spin_unlock_irq(&sdev->ipc_lock);
198196
ipc_irq = true;
199197
}
200198

‎sound/soc/sof/amd/acp.c

+3
Original file line numberDiff line numberDiff line change
@@ -343,11 +343,13 @@ static irqreturn_t acp_irq_thread(int irq, void *context)
343343
const struct sof_amd_acp_desc *desc = get_chip_info(sdev->pdata);
344344
unsigned int count = ACP_HW_SEM_RETRY_COUNT;
345345

346+
spin_lock_irq(&sdev->ipc_lock);
346347
while (snd_sof_dsp_read(sdev, ACP_DSP_BAR, desc->hw_semaphore_offset)) {
347348
/* Wait until acquired HW Semaphore lock or timeout */
348349
count--;
349350
if (!count) {
350351
dev_err(sdev->dev, "%s: Failed to acquire HW lock\n", __func__);
352+
spin_unlock_irq(&sdev->ipc_lock);
351353
return IRQ_NONE;
352354
}
353355
}
@@ -356,6 +358,7 @@ static irqreturn_t acp_irq_thread(int irq, void *context)
356358
/* Unlock or Release HW Semaphore */
357359
snd_sof_dsp_write(sdev, ACP_DSP_BAR, desc->hw_semaphore_offset, 0x0);
358360

361+
spin_unlock_irq(&sdev->ipc_lock);
359362
return IRQ_HANDLED;
360363
};
361364

0 commit comments

Comments
 (0)
Please sign in to comment.