Skip to content

Commit 722e563

Browse files
ujfalusibardliao
authored andcommitted
ASoC: SOF: Intel: Use guard() for spinlocks where it makes sense
Replace the manual spinlock lock/unlock pairs with guard(). Only code refactoring, and no behavior change. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
1 parent c2252fd commit 722e563

7 files changed

Lines changed: 12 additions & 43 deletions

File tree

sound/soc/sof/intel/atom.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -143,21 +143,16 @@ irqreturn_t atom_irq_thread(int irq, void *context)
143143

144144
/* reply message from DSP */
145145
if (ipcx & SHIM_BYT_IPCX_DONE) {
146-
147-
spin_lock_irq(&sdev->ipc_lock);
148-
149146
/*
150147
* handle immediate reply from DSP core. If the msg is
151148
* found, set done bit in cmd_done which is called at the
152149
* end of message processing function, else set it here
153150
* because the done bit can't be set in cmd_done function
154151
* which is triggered by msg
155152
*/
153+
guard(spinlock_irq)(&sdev->ipc_lock);
156154
snd_sof_ipc_process_reply(sdev, ipcx);
157-
158155
atom_dsp_done(sdev);
159-
160-
spin_unlock_irq(&sdev->ipc_lock);
161156
}
162157

163158
/* new message from DSP */

sound/soc/sof/intel/bdw.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -315,21 +315,16 @@ static irqreturn_t bdw_irq_thread(int irq, void *context)
315315
snd_sof_dsp_update_bits_unlocked(sdev, BDW_DSP_BAR,
316316
SHIM_IMRX, SHIM_IMRX_DONE,
317317
SHIM_IMRX_DONE);
318-
319-
spin_lock_irq(&sdev->ipc_lock);
320-
321318
/*
322319
* handle immediate reply from DSP core. If the msg is
323320
* found, set done bit in cmd_done which is called at the
324321
* end of message processing function, else set it here
325322
* because the done bit can't be set in cmd_done function
326323
* which is triggered by msg
327324
*/
325+
guard(spinlock_irq)(&sdev->ipc_lock);
328326
snd_sof_ipc_process_reply(sdev, ipcx);
329-
330327
bdw_dsp_done(sdev);
331-
332-
spin_unlock_irq(&sdev->ipc_lock);
333328
}
334329

335330
ipcd = snd_sof_dsp_read(sdev, BDW_DSP_BAR, SHIM_IPCD);

sound/soc/sof/intel/cnl.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,10 @@ irqreturn_t cnl_ipc4_irq_thread(int irq, void *context)
6969
data->primary = primary;
7070
data->extension = extension;
7171

72-
spin_lock_irq(&sdev->ipc_lock);
73-
72+
guard(spinlock_irq)(&sdev->ipc_lock);
7473
snd_sof_ipc_get_reply(sdev);
7574
cnl_ipc_host_done(sdev);
7675
snd_sof_ipc_reply(sdev, data->primary);
77-
78-
spin_unlock_irq(&sdev->ipc_lock);
7976
} else {
8077
dev_dbg_ratelimited(sdev->dev,
8178
"IPC reply before FW_READY: %#x|%#x\n",
@@ -141,15 +138,11 @@ irqreturn_t cnl_ipc_irq_thread(int irq, void *context)
141138
CNL_DSP_REG_HIPCCTL_DONE, 0);
142139

143140
if (likely(sdev->fw_state == SOF_FW_BOOT_COMPLETE)) {
144-
spin_lock_irq(&sdev->ipc_lock);
145-
146141
/* handle immediate reply from DSP core */
142+
guard(spinlock_irq)(&sdev->ipc_lock);
147143
hda_dsp_ipc_get_reply(sdev);
148144
snd_sof_ipc_reply(sdev, msg);
149-
150145
cnl_ipc_dsp_done(sdev);
151-
152-
spin_unlock_irq(&sdev->ipc_lock);
153146
} else {
154147
dev_dbg_ratelimited(sdev->dev, "IPC reply before FW_READY: %#x\n",
155148
msg);

sound/soc/sof/intel/hda-dai-ops.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ hda_link_stream_assign(struct hdac_bus *bus, struct snd_pcm_substream *substream
5858
return NULL;
5959
}
6060

61-
spin_lock_irq(&bus->reg_lock);
61+
guard(spinlock_irq)(&bus->reg_lock);
6262
list_for_each_entry(hstream, &bus->stream_list, list) {
6363
struct hdac_ext_stream *hext_stream =
6464
stream_to_hdac_ext_stream(hstream);
@@ -110,7 +110,6 @@ hda_link_stream_assign(struct hdac_bus *bus, struct snd_pcm_substream *substream
110110
res->link_locked = 1;
111111
res->link_substream = substream;
112112
}
113-
spin_unlock_irq(&bus->reg_lock);
114113

115114
return res;
116115
}

sound/soc/sof/intel/hda-ipc.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -204,13 +204,10 @@ irqreturn_t hda_dsp_ipc4_irq_thread(int irq, void *context)
204204
data->primary = primary;
205205
data->extension = extension;
206206

207-
spin_lock_irq(&sdev->ipc_lock);
208-
207+
guard(spinlock_irq)(&sdev->ipc_lock);
209208
snd_sof_ipc_get_reply(sdev);
210209
hda_dsp_ipc_host_done(sdev);
211210
snd_sof_ipc_reply(sdev, data->primary);
212-
213-
spin_unlock_irq(&sdev->ipc_lock);
214211
} else {
215212
dev_dbg_ratelimited(sdev->dev,
216213
"IPC reply before FW_READY: %#x|%#x\n",
@@ -289,16 +286,12 @@ irqreturn_t hda_dsp_ipc_irq_thread(int irq, void *context)
289286
* reply.
290287
*/
291288
if (likely(sdev->fw_state == SOF_FW_BOOT_COMPLETE)) {
292-
spin_lock_irq(&sdev->ipc_lock);
293-
294289
/* handle immediate reply from DSP core */
290+
guard(spinlock_irq)(&sdev->ipc_lock);
295291
hda_dsp_ipc_get_reply(sdev);
296292
snd_sof_ipc_reply(sdev, msg);
297-
298293
/* set the done bit */
299294
hda_dsp_ipc_dsp_done(sdev);
300-
301-
spin_unlock_irq(&sdev->ipc_lock);
302295
} else {
303296
dev_dbg_ratelimited(sdev->dev, "IPC reply before FW_READY: %#x\n",
304297
msg);

sound/soc/sof/intel/hda-stream.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -724,12 +724,12 @@ int hda_dsp_stream_hw_free(struct snd_sof_dev *sdev,
724724
struct hdac_bus *bus = sof_to_bus(sdev);
725725
u32 mask = BIT(hstream->index);
726726

727-
spin_lock_irq(&bus->reg_lock);
727+
guard(spinlock_irq)(&bus->reg_lock);
728+
728729
/* couple host and link DMA if link DMA channel is idle */
729730
if (!hext_stream->link_locked)
730731
snd_sof_dsp_update_bits(sdev, HDA_DSP_PP_BAR,
731732
SOF_HDA_REG_PP_PPCTL, mask, 0);
732-
spin_unlock_irq(&bus->reg_lock);
733733
}
734734

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

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

752752
status = snd_sof_dsp_read(sdev, HDA_DSP_HDA_BAR, SOF_HDA_INTSTS);
753753

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

760-
spin_unlock_irq(&bus->reg_lock);
761-
762760
return ret;
763761
}
764762
EXPORT_SYMBOL_NS(hda_dsp_check_stream_irq, "SND_SOC_SOF_INTEL_HDA_COMMON");
@@ -842,7 +840,7 @@ irqreturn_t hda_dsp_stream_threaded_handler(int irq, void *context)
842840
* unsolicited responses from the codec
843841
*/
844842
for (i = 0, active = true; i < 10 && active; i++) {
845-
spin_lock_irq(&bus->reg_lock);
843+
guard(spinlock_irq)(&bus->reg_lock);
846844

847845
status = snd_sof_dsp_read(sdev, HDA_DSP_HDA_BAR, SOF_HDA_INTSTS);
848846

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

859856
return IRQ_HANDLED;

sound/soc/sof/intel/mtl.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -599,13 +599,10 @@ static irqreturn_t mtl_ipc_irq_thread(int irq, void *context)
599599
data->primary = primary;
600600
data->extension = extension;
601601

602-
spin_lock_irq(&sdev->ipc_lock);
603-
602+
guard(spinlock_irq)(&sdev->ipc_lock);
604603
snd_sof_ipc_get_reply(sdev);
605604
mtl_ipc_host_done(sdev);
606605
snd_sof_ipc_reply(sdev, data->primary);
607-
608-
spin_unlock_irq(&sdev->ipc_lock);
609606
} else {
610607
dev_dbg_ratelimited(sdev->dev,
611608
"IPC reply before FW_READY: %#x|%#x\n",

0 commit comments

Comments
 (0)