Commit 802134c8 authored by Venkata Prasad Potturu's avatar Venkata Prasad Potturu Committed by Mark Brown

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: default avatarVenkata Prasad Potturu <venkataprasad.potturu@amd.com>
Link: https://msgid.link/r/20231219112416.3334928-1-venkataprasad.potturu@amd.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 8b69dba1
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
// This file is provided under a dual BSD/GPLv2 license. When using or // This file is provided under a dual BSD/GPLv2 license. When using or
// redistributing this file, you may do so under either license. // redistributing this file, you may do so under either license.
// //
// Copyright(c) 2021 Advanced Micro Devices, Inc. // Copyright(c) 2021, 2023 Advanced Micro Devices, Inc.
// //
// Authors: Balakishore Pati <Balakishore.pati@amd.com> // Authors: Balakishore Pati <Balakishore.pati@amd.com>
// Ajit Kumar Pandey <AjitKumar.Pandey@amd.com> // Ajit Kumar Pandey <AjitKumar.Pandey@amd.com>
...@@ -188,13 +188,11 @@ irqreturn_t acp_sof_ipc_irq_thread(int irq, void *context) ...@@ -188,13 +188,11 @@ irqreturn_t acp_sof_ipc_irq_thread(int irq, void *context)
dsp_ack = snd_sof_dsp_read(sdev, ACP_DSP_BAR, ACP_SCRATCH_REG_0 + dsp_ack_write); dsp_ack = snd_sof_dsp_read(sdev, ACP_DSP_BAR, ACP_SCRATCH_REG_0 + dsp_ack_write);
if (dsp_ack) { if (dsp_ack) {
spin_lock_irq(&sdev->ipc_lock);
/* handle immediate reply from DSP core */ /* handle immediate reply from DSP core */
acp_dsp_ipc_get_reply(sdev); acp_dsp_ipc_get_reply(sdev);
snd_sof_ipc_reply(sdev, 0); snd_sof_ipc_reply(sdev, 0);
/* set the done bit */ /* set the done bit */
acp_dsp_ipc_dsp_done(sdev); acp_dsp_ipc_dsp_done(sdev);
spin_unlock_irq(&sdev->ipc_lock);
ipc_irq = true; ipc_irq = true;
} }
......
...@@ -343,11 +343,13 @@ static irqreturn_t acp_irq_thread(int irq, void *context) ...@@ -343,11 +343,13 @@ static irqreturn_t acp_irq_thread(int irq, void *context)
const struct sof_amd_acp_desc *desc = get_chip_info(sdev->pdata); const struct sof_amd_acp_desc *desc = get_chip_info(sdev->pdata);
unsigned int count = ACP_HW_SEM_RETRY_COUNT; unsigned int count = ACP_HW_SEM_RETRY_COUNT;
spin_lock_irq(&sdev->ipc_lock);
while (snd_sof_dsp_read(sdev, ACP_DSP_BAR, desc->hw_semaphore_offset)) { while (snd_sof_dsp_read(sdev, ACP_DSP_BAR, desc->hw_semaphore_offset)) {
/* Wait until acquired HW Semaphore lock or timeout */ /* Wait until acquired HW Semaphore lock or timeout */
count--; count--;
if (!count) { if (!count) {
dev_err(sdev->dev, "%s: Failed to acquire HW lock\n", __func__); dev_err(sdev->dev, "%s: Failed to acquire HW lock\n", __func__);
spin_unlock_irq(&sdev->ipc_lock);
return IRQ_NONE; return IRQ_NONE;
} }
} }
...@@ -356,6 +358,7 @@ static irqreturn_t acp_irq_thread(int irq, void *context) ...@@ -356,6 +358,7 @@ static irqreturn_t acp_irq_thread(int irq, void *context)
/* Unlock or Release HW Semaphore */ /* Unlock or Release HW Semaphore */
snd_sof_dsp_write(sdev, ACP_DSP_BAR, desc->hw_semaphore_offset, 0x0); snd_sof_dsp_write(sdev, ACP_DSP_BAR, desc->hw_semaphore_offset, 0x0);
spin_unlock_irq(&sdev->ipc_lock);
return IRQ_HANDLED; return IRQ_HANDLED;
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment