Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions sound/soc/sof/amd/acp-ipc.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,15 +190,13 @@ 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);
if (dsp_ack) {
if (likely(sdev->fw_state == SOF_FW_BOOT_COMPLETE)) {
spin_lock_irq(&sdev->ipc_lock);
guard(spinlock_irq)(&sdev->ipc_lock);

/* handle immediate reply from DSP core */
acp_dsp_ipc_get_reply(sdev);
snd_sof_ipc_reply(sdev, 0);
/* set the done bit */
acp_dsp_ipc_dsp_done(sdev);

spin_unlock_irq(&sdev->ipc_lock);
} else {
dev_dbg_ratelimited(sdev->dev, "IPC reply before FW_BOOT_COMPLETE: %#x\n",
dsp_ack);
Expand Down
8 changes: 2 additions & 6 deletions sound/soc/sof/imx/imx-common.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,10 @@ EXPORT_SYMBOL(imx8_dump);

static void imx_handle_reply(struct imx_dsp_ipc *ipc)
{
struct snd_sof_dev *sdev;
unsigned long flags;

sdev = imx_dsp_get_data(ipc);
struct snd_sof_dev *sdev = imx_dsp_get_data(ipc);

spin_lock_irqsave(&sdev->ipc_lock, flags);
guard(spinlock_irqsave)(&sdev->ipc_lock);
snd_sof_ipc_process_reply(sdev, 0);
spin_unlock_irqrestore(&sdev->ipc_lock, flags);
}

static void imx_handle_request(struct imx_dsp_ipc *ipc)
Expand Down
7 changes: 1 addition & 6 deletions sound/soc/sof/intel/atom.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,21 +143,16 @@ irqreturn_t atom_irq_thread(int irq, void *context)

/* reply message from DSP */
if (ipcx & SHIM_BYT_IPCX_DONE) {

spin_lock_irq(&sdev->ipc_lock);

/*
* handle immediate reply from DSP core. If the msg is
* found, set done bit in cmd_done which is called at the
* end of message processing function, else set it here
* because the done bit can't be set in cmd_done function
* which is triggered by msg
*/
guard(spinlock_irq)(&sdev->ipc_lock);
snd_sof_ipc_process_reply(sdev, ipcx);

atom_dsp_done(sdev);

spin_unlock_irq(&sdev->ipc_lock);
}

/* new message from DSP */
Expand Down
7 changes: 1 addition & 6 deletions sound/soc/sof/intel/bdw.c
Original file line number Diff line number Diff line change
Expand Up @@ -315,21 +315,16 @@ static irqreturn_t bdw_irq_thread(int irq, void *context)
snd_sof_dsp_update_bits_unlocked(sdev, BDW_DSP_BAR,
SHIM_IMRX, SHIM_IMRX_DONE,
SHIM_IMRX_DONE);

spin_lock_irq(&sdev->ipc_lock);

/*
* handle immediate reply from DSP core. If the msg is
* found, set done bit in cmd_done which is called at the
* end of message processing function, else set it here
* because the done bit can't be set in cmd_done function
* which is triggered by msg
*/
guard(spinlock_irq)(&sdev->ipc_lock);
snd_sof_ipc_process_reply(sdev, ipcx);

bdw_dsp_done(sdev);

spin_unlock_irq(&sdev->ipc_lock);
}

ipcd = snd_sof_dsp_read(sdev, BDW_DSP_BAR, SHIM_IPCD);
Expand Down
11 changes: 2 additions & 9 deletions sound/soc/sof/intel/cnl.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,10 @@ irqreturn_t cnl_ipc4_irq_thread(int irq, void *context)
data->primary = primary;
data->extension = extension;

spin_lock_irq(&sdev->ipc_lock);

guard(spinlock_irq)(&sdev->ipc_lock);
snd_sof_ipc_get_reply(sdev);
cnl_ipc_host_done(sdev);
snd_sof_ipc_reply(sdev, data->primary);

spin_unlock_irq(&sdev->ipc_lock);
} else {
dev_dbg_ratelimited(sdev->dev,
"IPC reply before FW_READY: %#x|%#x\n",
Expand Down Expand Up @@ -141,15 +138,11 @@ irqreturn_t cnl_ipc_irq_thread(int irq, void *context)
CNL_DSP_REG_HIPCCTL_DONE, 0);

if (likely(sdev->fw_state == SOF_FW_BOOT_COMPLETE)) {
spin_lock_irq(&sdev->ipc_lock);

/* handle immediate reply from DSP core */
guard(spinlock_irq)(&sdev->ipc_lock);
hda_dsp_ipc_get_reply(sdev);
snd_sof_ipc_reply(sdev, msg);

cnl_ipc_dsp_done(sdev);

spin_unlock_irq(&sdev->ipc_lock);
} else {
dev_dbg_ratelimited(sdev->dev, "IPC reply before FW_READY: %#x\n",
msg);
Expand Down
25 changes: 13 additions & 12 deletions sound/soc/sof/intel/hda-dai-ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ hda_link_stream_assign(struct hdac_bus *bus, struct snd_pcm_substream *substream
return NULL;
}

spin_lock_irq(&bus->reg_lock);
guard(spinlock_irq)(&bus->reg_lock);
list_for_each_entry(hstream, &bus->stream_list, list) {
struct hdac_ext_stream *hext_stream =
stream_to_hdac_ext_stream(hstream);
Expand Down Expand Up @@ -110,7 +110,6 @@ hda_link_stream_assign(struct hdac_bus *bus, struct snd_pcm_substream *substream
res->link_locked = 1;
res->link_substream = substream;
}
spin_unlock_irq(&bus->reg_lock);

return res;
}
Expand Down Expand Up @@ -311,7 +310,7 @@ static int hda_ipc4_pre_trigger(struct snd_sof_dev *sdev, struct snd_soc_dai *cp
if (pipe_widget->instance_id < 0)
return 0;

mutex_lock(&ipc4_data->pipeline_state_mutex);
guard(mutex)(&ipc4_data->pipeline_state_mutex);

switch (cmd) {
case SNDRV_PCM_TRIGGER_START:
Expand All @@ -323,16 +322,16 @@ static int hda_ipc4_pre_trigger(struct snd_sof_dev *sdev, struct snd_soc_dai *cp
ret = sof_ipc4_set_pipeline_state(sdev, pipe_widget->instance_id,
SOF_IPC4_PIPE_PAUSED);
if (ret < 0)
goto out;
return ret;

pipeline->state = SOF_IPC4_PIPE_PAUSED;

break;
default:
dev_err(sdev->dev, "unknown trigger command %d\n", cmd);
ret = -EINVAL;
}
out:
mutex_unlock(&ipc4_data->pipeline_state_mutex);

return ret;
}

Expand Down Expand Up @@ -388,30 +387,33 @@ static int hda_ipc4_post_trigger(struct snd_sof_dev *sdev, struct snd_soc_dai *c
if (pipe_widget->instance_id < 0)
return 0;

mutex_lock(&ipc4_data->pipeline_state_mutex);
guard(mutex)(&ipc4_data->pipeline_state_mutex);

switch (cmd) {
case SNDRV_PCM_TRIGGER_START:
if (pipeline->state != SOF_IPC4_PIPE_PAUSED) {
ret = sof_ipc4_set_pipeline_state(sdev, pipe_widget->instance_id,
SOF_IPC4_PIPE_PAUSED);
if (ret < 0)
goto out;
return ret;

pipeline->state = SOF_IPC4_PIPE_PAUSED;
}

ret = sof_ipc4_set_pipeline_state(sdev, pipe_widget->instance_id,
SOF_IPC4_PIPE_RUNNING);
if (ret < 0)
goto out;
return ret;

pipeline->state = SOF_IPC4_PIPE_RUNNING;
swidget->spipe->started_count++;
break;
case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
ret = sof_ipc4_set_pipeline_state(sdev, pipe_widget->instance_id,
SOF_IPC4_PIPE_RUNNING);
if (ret < 0)
goto out;
return ret;

pipeline->state = SOF_IPC4_PIPE_RUNNING;
break;
case SNDRV_PCM_TRIGGER_SUSPEND:
Expand All @@ -429,8 +431,7 @@ static int hda_ipc4_post_trigger(struct snd_sof_dev *sdev, struct snd_soc_dai *c
ret = -EINVAL;
break;
}
out:
mutex_unlock(&ipc4_data->pipeline_state_mutex);

return ret;
}

Expand Down
11 changes: 2 additions & 9 deletions sound/soc/sof/intel/hda-ipc.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,13 +204,10 @@ irqreturn_t hda_dsp_ipc4_irq_thread(int irq, void *context)
data->primary = primary;
data->extension = extension;

spin_lock_irq(&sdev->ipc_lock);

guard(spinlock_irq)(&sdev->ipc_lock);
snd_sof_ipc_get_reply(sdev);
hda_dsp_ipc_host_done(sdev);
snd_sof_ipc_reply(sdev, data->primary);

spin_unlock_irq(&sdev->ipc_lock);
} else {
dev_dbg_ratelimited(sdev->dev,
"IPC reply before FW_READY: %#x|%#x\n",
Expand Down Expand Up @@ -289,16 +286,12 @@ irqreturn_t hda_dsp_ipc_irq_thread(int irq, void *context)
* reply.
*/
if (likely(sdev->fw_state == SOF_FW_BOOT_COMPLETE)) {
spin_lock_irq(&sdev->ipc_lock);

/* handle immediate reply from DSP core */
guard(spinlock_irq)(&sdev->ipc_lock);
hda_dsp_ipc_get_reply(sdev);
snd_sof_ipc_reply(sdev, msg);

/* set the done bit */
hda_dsp_ipc_dsp_done(sdev);

spin_unlock_irq(&sdev->ipc_lock);
} else {
dev_dbg_ratelimited(sdev->dev, "IPC reply before FW_READY: %#x\n",
msg);
Expand Down
29 changes: 8 additions & 21 deletions sound/soc/sof/intel/hda-mlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -524,11 +524,8 @@ void hdac_bus_eml_enable_interrupt(struct hdac_bus *bus, bool alt, int elid, boo

hlink = &h2link->hext_link;

mutex_lock(&h2link->eml_lock);

hdaml_link_enable_interrupt(hlink->ml_addr + AZX_REG_ML_LCTL, enable);

mutex_unlock(&h2link->eml_lock);
scoped_guard(mutex, &h2link->eml_lock)
hdaml_link_enable_interrupt(hlink->ml_addr + AZX_REG_ML_LCTL, enable);
}
EXPORT_SYMBOL_NS(hdac_bus_eml_enable_interrupt, "SND_SOC_SOF_HDA_MLINK");

Expand Down Expand Up @@ -837,11 +834,8 @@ int hdac_bus_eml_sdw_set_lsdiid(struct hdac_bus *bus, int sublink, int dev_num)

hlink = &h2link->hext_link;

mutex_lock(&h2link->eml_lock);

hdaml_link_set_lsdiid(hlink->ml_addr + AZX_REG_ML_LSDIID_OFFSET(sublink), dev_num);

mutex_unlock(&h2link->eml_lock);
scoped_guard(mutex, &h2link->eml_lock)
hdaml_link_set_lsdiid(hlink->ml_addr + AZX_REG_ML_LSDIID_OFFSET(sublink), dev_num);

return 0;
} EXPORT_SYMBOL_NS(hdac_bus_eml_sdw_set_lsdiid, "SND_SOC_SOF_HDA_MLINK");
Expand Down Expand Up @@ -875,12 +869,8 @@ int hdac_bus_eml_sdw_map_stream_ch(struct hdac_bus *bus, int sublink, int y,
lchan = 0;
}

mutex_lock(&h2link->eml_lock);

hdaml_shim_map_stream_ch(pcmsycm, lchan, hchan,
stream_id, dir);

mutex_unlock(&h2link->eml_lock);
scoped_guard(mutex, &h2link->eml_lock)
hdaml_shim_map_stream_ch(pcmsycm, lchan, hchan, stream_id, dir);

val = readw(pcmsycm);

Expand Down Expand Up @@ -1012,11 +1002,8 @@ int hdac_bus_eml_enable_offload(struct hdac_bus *bus, bool alt, int elid, bool e

hlink = &h2link->hext_link;

mutex_lock(&h2link->eml_lock);

hdaml_lctl_offload_enable(hlink->ml_addr + AZX_REG_ML_LCTL, enable);

mutex_unlock(&h2link->eml_lock);
scoped_guard(mutex, &h2link->eml_lock)
hdaml_lctl_offload_enable(hlink->ml_addr + AZX_REG_ML_LCTL, enable);

return 0;
}
Expand Down
11 changes: 4 additions & 7 deletions sound/soc/sof/intel/hda-stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -724,12 +724,12 @@ int hda_dsp_stream_hw_free(struct snd_sof_dev *sdev,
struct hdac_bus *bus = sof_to_bus(sdev);
u32 mask = BIT(hstream->index);

spin_lock_irq(&bus->reg_lock);
guard(spinlock_irq)(&bus->reg_lock);

/* couple host and link DMA if link DMA channel is idle */
if (!hext_stream->link_locked)
snd_sof_dsp_update_bits(sdev, HDA_DSP_PP_BAR,
SOF_HDA_REG_PP_PPCTL, mask, 0);
spin_unlock_irq(&bus->reg_lock);
}

hda_dsp_stream_spib_config(sdev, hext_stream, HDA_DSP_SPIB_DISABLE, 0);
Expand All @@ -747,7 +747,7 @@ bool hda_dsp_check_stream_irq(struct snd_sof_dev *sdev)
u32 status;

/* The function can be called at irq thread, so use spin_lock_irq */
spin_lock_irq(&bus->reg_lock);
guard(spinlock_irq)(&bus->reg_lock);

status = snd_sof_dsp_read(sdev, HDA_DSP_HDA_BAR, SOF_HDA_INTSTS);

Expand All @@ -757,8 +757,6 @@ bool hda_dsp_check_stream_irq(struct snd_sof_dev *sdev)
if (status != 0xffffffff)
ret = true;

spin_unlock_irq(&bus->reg_lock);

return ret;
}
EXPORT_SYMBOL_NS(hda_dsp_check_stream_irq, "SND_SOC_SOF_INTEL_HDA_COMMON");
Expand Down Expand Up @@ -842,7 +840,7 @@ irqreturn_t hda_dsp_stream_threaded_handler(int irq, void *context)
* unsolicited responses from the codec
*/
for (i = 0, active = true; i < 10 && active; i++) {
spin_lock_irq(&bus->reg_lock);
guard(spinlock_irq)(&bus->reg_lock);

status = snd_sof_dsp_read(sdev, HDA_DSP_HDA_BAR, SOF_HDA_INTSTS);

Expand All @@ -853,7 +851,6 @@ irqreturn_t hda_dsp_stream_threaded_handler(int irq, void *context)
if (status & AZX_INT_CTRL_EN) {
active |= hda_codec_check_rirb_status(sdev);
}
spin_unlock_irq(&bus->reg_lock);
}

return IRQ_HANDLED;
Expand Down
5 changes: 1 addition & 4 deletions sound/soc/sof/intel/mtl.c
Original file line number Diff line number Diff line change
Expand Up @@ -599,13 +599,10 @@ static irqreturn_t mtl_ipc_irq_thread(int irq, void *context)
data->primary = primary;
data->extension = extension;

spin_lock_irq(&sdev->ipc_lock);

guard(spinlock_irq)(&sdev->ipc_lock);
snd_sof_ipc_get_reply(sdev);
mtl_ipc_host_done(sdev);
snd_sof_ipc_reply(sdev, data->primary);

spin_unlock_irq(&sdev->ipc_lock);
} else {
dev_dbg_ratelimited(sdev->dev,
"IPC reply before FW_READY: %#x|%#x\n",
Expand Down
9 changes: 3 additions & 6 deletions sound/soc/sof/ipc.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ int sof_ipc_send_msg(struct snd_sof_dev *sdev, void *msg_data, size_t msg_bytes,
* The spin-lock is needed to protect message objects against other
* atomic contexts.
*/
spin_lock_irq(&sdev->ipc_lock);
guard(spinlock_irq)(&sdev->ipc_lock);

/* initialise the message */
msg = &ipc->msg;
Expand All @@ -66,8 +66,6 @@ int sof_ipc_send_msg(struct snd_sof_dev *sdev, void *msg_data, size_t msg_bytes,
if (!ret)
msg->ipc_complete = false;

spin_unlock_irq(&sdev->ipc_lock);

return ret;
}

Expand Down Expand Up @@ -225,9 +223,8 @@ void snd_sof_ipc_free(struct snd_sof_dev *sdev)
return;

/* disable sending of ipc's */
mutex_lock(&ipc->tx_mutex);
ipc->disable_ipc_tx = true;
mutex_unlock(&ipc->tx_mutex);
scoped_guard(mutex, &ipc->tx_mutex)
ipc->disable_ipc_tx = true;

if (ipc->ops->exit)
ipc->ops->exit(sdev);
Expand Down
Loading
Loading