Skip to content

Commit 9f62068

Browse files
tiwaibroonie
authored andcommitted
ASoC: soc-pcm: Move debugfs removal out of spinlock
The recent fix for DPCM locking also covered the loop in dpcm_be_disconnect() with the FE stream lock. This caused an unexpected side effect, thought: calling debugfs_remove_recursive() in the spinlock may lead to lockdep splats as the code there assumes the SOFTIRQ-safe context. For avoiding the problem, this patch changes the disconnection procedure to two phases: at first, the matching entries are removed from the linked list, then the resources are freed outside the lock. Fixes: b789839 ("ASoC: soc-pcm: Fix and cleanup DPCM locking") Reported-and-tested-by: Marek Szyprowski <[email protected]> Signed-off-by: Takashi Iwai <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 3c75c0e commit 9f62068

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

sound/soc/soc-pcm.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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 */

0 commit comments

Comments
 (0)