Skip to content

Commit 4c38f87

Browse files
committed
ASoC DPCM lockdep fixes
Merge series from Takashi Iwai <[email protected]>: This is the revised patches for addressing ASoC lockdep warnings due to the recent DPCM locking refactoring.
2 parents 4045daf + 9f62068 commit 4c38f87

File tree

3 files changed

+40
-6
lines changed

3 files changed

+40
-6
lines changed

include/sound/pcm.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -614,6 +614,7 @@ void snd_pcm_stream_unlock(struct snd_pcm_substream *substream);
614614
void snd_pcm_stream_lock_irq(struct snd_pcm_substream *substream);
615615
void snd_pcm_stream_unlock_irq(struct snd_pcm_substream *substream);
616616
unsigned long _snd_pcm_stream_lock_irqsave(struct snd_pcm_substream *substream);
617+
unsigned long _snd_pcm_stream_lock_irqsave_nested(struct snd_pcm_substream *substream);
617618

618619
/**
619620
* snd_pcm_stream_lock_irqsave - Lock the PCM stream
@@ -632,6 +633,20 @@ unsigned long _snd_pcm_stream_lock_irqsave(struct snd_pcm_substream *substream);
632633
void snd_pcm_stream_unlock_irqrestore(struct snd_pcm_substream *substream,
633634
unsigned long flags);
634635

636+
/**
637+
* snd_pcm_stream_lock_irqsave_nested - Single-nested PCM stream locking
638+
* @substream: PCM substream
639+
* @flags: irq flags
640+
*
641+
* This locks the PCM stream like snd_pcm_stream_lock_irqsave() but with
642+
* the single-depth lockdep subclass.
643+
*/
644+
#define snd_pcm_stream_lock_irqsave_nested(substream, flags) \
645+
do { \
646+
typecheck(unsigned long, flags); \
647+
flags = _snd_pcm_stream_lock_irqsave_nested(substream); \
648+
} while (0)
649+
635650
/**
636651
* snd_pcm_group_for_each_entry - iterate over the linked substreams
637652
* @s: the iterator

sound/core/pcm_native.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,19 @@ unsigned long _snd_pcm_stream_lock_irqsave(struct snd_pcm_substream *substream)
172172
}
173173
EXPORT_SYMBOL_GPL(_snd_pcm_stream_lock_irqsave);
174174

175+
unsigned long _snd_pcm_stream_lock_irqsave_nested(struct snd_pcm_substream *substream)
176+
{
177+
unsigned long flags = 0;
178+
if (substream->pcm->nonatomic)
179+
mutex_lock_nested(&substream->self_group.mutex,
180+
SINGLE_DEPTH_NESTING);
181+
else
182+
spin_lock_irqsave_nested(&substream->self_group.lock, flags,
183+
SINGLE_DEPTH_NESTING);
184+
return flags;
185+
}
186+
EXPORT_SYMBOL_GPL(_snd_pcm_stream_lock_irqsave_nested);
187+
175188
/**
176189
* snd_pcm_stream_unlock_irqrestore - Unlock the PCM stream
177190
* @substream: PCM substream

sound/soc/soc-pcm.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ static inline void snd_soc_dpcm_stream_lock_irq(struct snd_soc_pcm_runtime *rtd,
4646
snd_pcm_stream_lock_irq(snd_soc_dpcm_get_substream(rtd, stream));
4747
}
4848

49-
#define snd_soc_dpcm_stream_lock_irqsave(rtd, stream, flags) \
50-
snd_pcm_stream_lock_irqsave(snd_soc_dpcm_get_substream(rtd, stream), flags)
49+
#define snd_soc_dpcm_stream_lock_irqsave_nested(rtd, stream, flags) \
50+
snd_pcm_stream_lock_irqsave_nested(snd_soc_dpcm_get_substream(rtd, stream), flags)
5151

5252
static inline void snd_soc_dpcm_stream_unlock_irq(struct snd_soc_pcm_runtime *rtd,
5353
int stream)
@@ -1268,6 +1268,7 @@ static void dpcm_be_reparent(struct snd_soc_pcm_runtime *fe,
12681268
void dpcm_be_disconnect(struct snd_soc_pcm_runtime *fe, int stream)
12691269
{
12701270
struct snd_soc_dpcm *dpcm, *d;
1271+
LIST_HEAD(deleted_dpcms);
12711272

12721273
snd_soc_dpcm_mutex_assert_held(fe);
12731274

@@ -1287,13 +1288,18 @@ void dpcm_be_disconnect(struct snd_soc_pcm_runtime *fe, int stream)
12871288
/* BEs still alive need new FE */
12881289
dpcm_be_reparent(fe, dpcm->be, stream);
12891290

1290-
dpcm_remove_debugfs_state(dpcm);
1291-
12921291
list_del(&dpcm->list_be);
1292+
list_move(&dpcm->list_fe, &deleted_dpcms);
1293+
}
1294+
snd_soc_dpcm_stream_unlock_irq(fe, stream);
1295+
1296+
while (!list_empty(&deleted_dpcms)) {
1297+
dpcm = list_first_entry(&deleted_dpcms, struct snd_soc_dpcm,
1298+
list_fe);
12931299
list_del(&dpcm->list_fe);
1300+
dpcm_remove_debugfs_state(dpcm);
12941301
kfree(dpcm);
12951302
}
1296-
snd_soc_dpcm_stream_unlock_irq(fe, stream);
12971303
}
12981304

12991305
/* get BE for DAI widget and stream */
@@ -2094,7 +2100,7 @@ int dpcm_be_dai_trigger(struct snd_soc_pcm_runtime *fe, int stream,
20942100
be = dpcm->be;
20952101
be_substream = snd_soc_dpcm_get_substream(be, stream);
20962102

2097-
snd_soc_dpcm_stream_lock_irqsave(be, stream, flags);
2103+
snd_soc_dpcm_stream_lock_irqsave_nested(be, stream, flags);
20982104

20992105
/* is this op for this BE ? */
21002106
if (!snd_soc_dpcm_be_can_update(fe, be, stream))

0 commit comments

Comments
 (0)