From: Greg Kroah-Hartman Date: Sat, 13 May 2023 13:06:48 +0000 (+0900) Subject: 5.15-stable patches X-Git-Tag: v4.14.315~62 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=cca5096468f753904e496087f53eef1e1be8407d;p=thirdparty%2Fkernel%2Fstable-queue.git 5.15-stable patches added patches: asoc-dpcm-don-t-pick-up-be-without-substream.patch asoc-soc-compress-inherit-atomicity-from-dai-link-for-compress-fe.patch asoc-soc-pcm-fix-dpcm-lockdep-warning-due-to-nested-stream-locks.patch asoc-soc-pcm-move-debugfs-removal-out-of-spinlock.patch asoc-soc-pcm.c-call-__soc_pcm_close-in-soc_pcm_close.patch --- diff --git a/queue-5.15/asoc-dpcm-don-t-pick-up-be-without-substream.patch b/queue-5.15/asoc-dpcm-don-t-pick-up-be-without-substream.patch new file mode 100644 index 00000000000..723b13985f4 --- /dev/null +++ b/queue-5.15/asoc-dpcm-don-t-pick-up-be-without-substream.patch @@ -0,0 +1,53 @@ +From 754590651ccbbcc74a7c20907be4bb15d642bde3 Mon Sep 17 00:00:00 2001 +From: Takashi Iwai +Date: Mon, 1 Aug 2022 19:05:10 +0200 +Subject: ASoC: DPCM: Don't pick up BE without substream +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Takashi Iwai + +commit 754590651ccbbcc74a7c20907be4bb15d642bde3 upstream. + +When DPCM tries to add valid BE connections at dpcm_add_paths(), it +doesn't check whether the picked BE actually supports for the given +stream direction. Due to that, when an asymmetric BE stream is +present, it picks up wrongly and this may result in a NULL dereference +at a later point where the code assumes the existence of a +corresponding BE substream. + +This patch adds the check for the presence of the substream for the +target BE for avoiding the problem above. + +Note that we have already some fix for non-existing BE substream at +commit 6246f283d5e0 ("ASoC: dpcm: skip missing substream while +applying symmetry"). But the code path we've hit recently is rather +happening before the previous fix. So this patch tries to fix at +picking up a BE instead of parsing BE lists. + +Fixes: bbf7d3b1c4f4 ("ASoC: soc-pcm: align BE 'atomicity' with that of the FE") +Reported-by: Alex Natalsson +Cc: Pierre-Louis Bossart +Cc: Péter Ujfalusi +Link: https://lore.kernel.org/r/CADs9LoPZH_D+eJ9qjTxSLE5jGyhKsjMN7g2NighZ16biVxsyKw@mail.gmail.com +Signed-off-by: Takashi Iwai +Link: https://lore.kernel.org/r/20220801170510.26582-1-tiwai@suse.de +Signed-off-by: Mark Brown +Signed-off-by: Greg Kroah-Hartman +--- + sound/soc/soc-pcm.c | 3 +++ + 1 file changed, 3 insertions(+) + +--- a/sound/soc/soc-pcm.c ++++ b/sound/soc/soc-pcm.c +@@ -1339,6 +1339,9 @@ static struct snd_soc_pcm_runtime *dpcm_ + if (!be->dai_link->no_pcm) + continue; + ++ if (!snd_soc_dpcm_get_substream(be, stream)) ++ continue; ++ + for_each_rtd_dais(be, i, dai) { + w = snd_soc_dai_get_widget(dai, stream); + diff --git a/queue-5.15/asoc-soc-compress-inherit-atomicity-from-dai-link-for-compress-fe.patch b/queue-5.15/asoc-soc-compress-inherit-atomicity-from-dai-link-for-compress-fe.patch new file mode 100644 index 00000000000..5fafa07e858 --- /dev/null +++ b/queue-5.15/asoc-soc-compress-inherit-atomicity-from-dai-link-for-compress-fe.patch @@ -0,0 +1,44 @@ +From 37b58becc1cee4d591024f2056d7ffa99c6089e0 Mon Sep 17 00:00:00 2001 +From: Daniel Baluta +Date: Fri, 24 Mar 2023 14:40:19 +0200 +Subject: ASoC: soc-compress: Inherit atomicity from DAI link for Compress FE + +From: Daniel Baluta + +commit 37b58becc1cee4d591024f2056d7ffa99c6089e0 upstream. + +After commit bbf7d3b1c4f40 ("ASoC: soc-pcm: align BE 'atomicity' with +that of the FE") BE and FE atomicity must match. + +In the case of Compress PCM there is a mismatch in atomicity between FE +and BE and we get errors like this: + +[ 36.434566] sai1-wm8960-hifi: dpcm_be_connect: FE is atomic but BE +is nonatomic, invalid configuration +[ 36.444278] PCM Deep Buffer: ASoC: can't connect SAI1.OUT + +In order to fix this we must inherit the atomicity from DAI link +associated with current PCM Compress FE. + +Fixes: bbf7d3b1c4f4 ("ASoC: soc-pcm: align BE 'atomicity' with that of the FE") +Signed-off-by: Daniel Baluta +Reviewed-by: Pierre-Louis Bossart +Link: https://lore.kernel.org/r/20230324124019.30826-1-daniel.baluta@oss.nxp.com +Signed-off-by: Mark Brown +Signed-off-by: Greg Kroah-Hartman +--- + sound/soc/soc-compress.c | 3 +++ + 1 file changed, 3 insertions(+) + +--- a/sound/soc/soc-compress.c ++++ b/sound/soc/soc-compress.c +@@ -589,6 +589,9 @@ int snd_soc_new_compress(struct snd_soc_ + return ret; + } + ++ /* inherit atomicity from DAI link */ ++ be_pcm->nonatomic = rtd->dai_link->nonatomic; ++ + rtd->pcm = be_pcm; + rtd->fe_compr = 1; + if (rtd->dai_link->dpcm_playback) diff --git a/queue-5.15/asoc-soc-pcm-fix-dpcm-lockdep-warning-due-to-nested-stream-locks.patch b/queue-5.15/asoc-soc-pcm-fix-dpcm-lockdep-warning-due-to-nested-stream-locks.patch new file mode 100644 index 00000000000..518db9cc2fe --- /dev/null +++ b/queue-5.15/asoc-soc-pcm-fix-dpcm-lockdep-warning-due-to-nested-stream-locks.patch @@ -0,0 +1,111 @@ +From 3c75c0ea5da749bd1efebd1387f2e5011b8c7d78 Mon Sep 17 00:00:00 2001 +From: Takashi Iwai +Date: Wed, 19 Jan 2022 16:52:48 +0100 +Subject: ASoC: soc-pcm: Fix DPCM lockdep warning due to nested stream locks + +From: Takashi Iwai + +commit 3c75c0ea5da749bd1efebd1387f2e5011b8c7d78 upstream. + +The recent change for DPCM locking caused spurious lockdep warnings. +Actually the warnings are false-positive, as those are triggered due +to the nested stream locks for FE and BE. Since both locks belong to +the same lock class, lockdep sees it as if a deadlock. + +For fixing this, we need to take PCM stream locks for BE with the +nested lock primitives. Since currently snd_pcm_stream_lock*() helper +assumes only the top-level single locking, a new helper function +snd_pcm_stream_lock_irqsave_nested() is defined for a single-depth +nested lock, which is now used in the BE DAI trigger that is always +performed inside a FE stream lock. + +Fixes: b2ae80663008 ("ASoC: soc-pcm: serialize BE triggers") +Reported-and-tested-by: Hans de Goede +Reported-and-tested-by: Marek Szyprowski +Link: https://lore.kernel.org/r/73018f3c-9769-72ea-0325-b3f8e2381e30@redhat.com +Link: https://lore.kernel.org/alsa-devel/9a0abddd-49e9-872d-2f00-a1697340f786@samsung.com +Signed-off-by: Takashi Iwai +Link: https://lore.kernel.org/r/20220119155249.26754-2-tiwai@suse.de +Signed-off-by: Mark Brown +Signed-off-by: Greg Kroah-Hartman +--- + include/sound/pcm.h | 15 +++++++++++++++ + sound/core/pcm_native.c | 13 +++++++++++++ + sound/soc/soc-pcm.c | 6 +++--- + 3 files changed, 31 insertions(+), 3 deletions(-) + +--- a/include/sound/pcm.h ++++ b/include/sound/pcm.h +@@ -616,6 +616,7 @@ void snd_pcm_stream_unlock(struct snd_pc + void snd_pcm_stream_lock_irq(struct snd_pcm_substream *substream); + void snd_pcm_stream_unlock_irq(struct snd_pcm_substream *substream); + unsigned long _snd_pcm_stream_lock_irqsave(struct snd_pcm_substream *substream); ++unsigned long _snd_pcm_stream_lock_irqsave_nested(struct snd_pcm_substream *substream); + + /** + * snd_pcm_stream_lock_irqsave - Lock the PCM stream +@@ -635,6 +636,20 @@ void snd_pcm_stream_unlock_irqrestore(st + unsigned long flags); + + /** ++ * snd_pcm_stream_lock_irqsave_nested - Single-nested PCM stream locking ++ * @substream: PCM substream ++ * @flags: irq flags ++ * ++ * This locks the PCM stream like snd_pcm_stream_lock_irqsave() but with ++ * the single-depth lockdep subclass. ++ */ ++#define snd_pcm_stream_lock_irqsave_nested(substream, flags) \ ++ do { \ ++ typecheck(unsigned long, flags); \ ++ flags = _snd_pcm_stream_lock_irqsave_nested(substream); \ ++ } while (0) ++ ++/** + * snd_pcm_group_for_each_entry - iterate over the linked substreams + * @s: the iterator + * @substream: the substream +--- a/sound/core/pcm_native.c ++++ b/sound/core/pcm_native.c +@@ -172,6 +172,19 @@ unsigned long _snd_pcm_stream_lock_irqsa + } + EXPORT_SYMBOL_GPL(_snd_pcm_stream_lock_irqsave); + ++unsigned long _snd_pcm_stream_lock_irqsave_nested(struct snd_pcm_substream *substream) ++{ ++ unsigned long flags = 0; ++ if (substream->pcm->nonatomic) ++ mutex_lock_nested(&substream->self_group.mutex, ++ SINGLE_DEPTH_NESTING); ++ else ++ spin_lock_irqsave_nested(&substream->self_group.lock, flags, ++ SINGLE_DEPTH_NESTING); ++ return flags; ++} ++EXPORT_SYMBOL_GPL(_snd_pcm_stream_lock_irqsave_nested); ++ + /** + * snd_pcm_stream_unlock_irqrestore - Unlock the PCM stream + * @substream: PCM substream +--- a/sound/soc/soc-pcm.c ++++ b/sound/soc/soc-pcm.c +@@ -46,8 +46,8 @@ static inline void snd_soc_dpcm_stream_l + snd_pcm_stream_lock_irq(snd_soc_dpcm_get_substream(rtd, stream)); + } + +-#define snd_soc_dpcm_stream_lock_irqsave(rtd, stream, flags) \ +- snd_pcm_stream_lock_irqsave(snd_soc_dpcm_get_substream(rtd, stream), flags) ++#define snd_soc_dpcm_stream_lock_irqsave_nested(rtd, stream, flags) \ ++ snd_pcm_stream_lock_irqsave_nested(snd_soc_dpcm_get_substream(rtd, stream), flags) + + static inline void snd_soc_dpcm_stream_unlock_irq(struct snd_soc_pcm_runtime *rtd, + int stream) +@@ -2109,7 +2109,7 @@ int dpcm_be_dai_trigger(struct snd_soc_p + be = dpcm->be; + be_substream = snd_soc_dpcm_get_substream(be, stream); + +- snd_soc_dpcm_stream_lock_irqsave(be, stream, flags); ++ snd_soc_dpcm_stream_lock_irqsave_nested(be, stream, flags); + + /* is this op for this BE ? */ + if (!snd_soc_dpcm_be_can_update(fe, be, stream)) diff --git a/queue-5.15/asoc-soc-pcm-move-debugfs-removal-out-of-spinlock.patch b/queue-5.15/asoc-soc-pcm-move-debugfs-removal-out-of-spinlock.patch new file mode 100644 index 00000000000..02263a22888 --- /dev/null +++ b/queue-5.15/asoc-soc-pcm-move-debugfs-removal-out-of-spinlock.patch @@ -0,0 +1,61 @@ +From 9f620684c1ef5a002b6622ecc7b5818e81252f48 Mon Sep 17 00:00:00 2001 +From: Takashi Iwai +Date: Wed, 19 Jan 2022 16:52:49 +0100 +Subject: ASoC: soc-pcm: Move debugfs removal out of spinlock + +From: Takashi Iwai + +commit 9f620684c1ef5a002b6622ecc7b5818e81252f48 upstream. + +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: b7898396f4bb ("ASoC: soc-pcm: Fix and cleanup DPCM locking") +Reported-and-tested-by: Marek Szyprowski +Signed-off-by: Takashi Iwai +Link: https://lore.kernel.org/r/20220119155249.26754-3-tiwai@suse.de +Signed-off-by: Mark Brown +Signed-off-by: Greg Kroah-Hartman +--- + sound/soc/soc-pcm.c | 12 +++++++++--- + 1 file changed, 9 insertions(+), 3 deletions(-) + +--- a/sound/soc/soc-pcm.c ++++ b/sound/soc/soc-pcm.c +@@ -1289,6 +1289,7 @@ static void dpcm_be_reparent(struct snd_ + void dpcm_be_disconnect(struct snd_soc_pcm_runtime *fe, int stream) + { + struct snd_soc_dpcm *dpcm, *d; ++ LIST_HEAD(deleted_dpcms); + + snd_soc_dpcm_mutex_assert_held(fe); + +@@ -1308,13 +1309,18 @@ void dpcm_be_disconnect(struct snd_soc_p + /* BEs still alive need new FE */ + dpcm_be_reparent(fe, dpcm->be, stream); + +- dpcm_remove_debugfs_state(dpcm); +- + list_del(&dpcm->list_be); ++ list_move(&dpcm->list_fe, &deleted_dpcms); ++ } ++ snd_soc_dpcm_stream_unlock_irq(fe, stream); ++ ++ while (!list_empty(&deleted_dpcms)) { ++ dpcm = list_first_entry(&deleted_dpcms, struct snd_soc_dpcm, ++ list_fe); + list_del(&dpcm->list_fe); ++ dpcm_remove_debugfs_state(dpcm); + kfree(dpcm); + } +- snd_soc_dpcm_stream_unlock_irq(fe, stream); + } + + /* get BE for DAI widget and stream */ diff --git a/queue-5.15/asoc-soc-pcm.c-call-__soc_pcm_close-in-soc_pcm_close.patch b/queue-5.15/asoc-soc-pcm.c-call-__soc_pcm_close-in-soc_pcm_close.patch new file mode 100644 index 00000000000..356eba8bb65 --- /dev/null +++ b/queue-5.15/asoc-soc-pcm.c-call-__soc_pcm_close-in-soc_pcm_close.patch @@ -0,0 +1,50 @@ +From 6bbabd28805f36baf6d0f3eb082db032a638f612 Mon Sep 17 00:00:00 2001 +From: Kuninori Morimoto +Date: Mon, 22 Aug 2022 02:35:32 +0000 +Subject: ASoC: soc-pcm.c: call __soc_pcm_close() in soc_pcm_close() + +From: Kuninori Morimoto + +commit 6bbabd28805f36baf6d0f3eb082db032a638f612 upstream. + +commit b7898396f4bbe16 ("ASoC: soc-pcm: Fix and cleanup DPCM locking") +added __soc_pcm_close() for non-lock version of soc_pcm_close(). +But soc_pcm_close() is not using it. It is no problem, but confusable. + + static int __soc_pcm_close(...) + { +=> return soc_pcm_clean(rtd, substream, 0); + } + + static int soc_pcm_close(...) + { + ... + snd_soc_dpcm_mutex_lock(rtd); +=> soc_pcm_clean(rtd, substream, 0); + snd_soc_dpcm_mutex_unlock(rtd); + return 0; + } + +This patch use it. + +Fixes: b7898396f4bbe16 ("ASoC: soc-pcm: Fix and cleanup DPCM locking") +Cc: Takashi Iwai +Signed-off-by: Kuninori Morimoto +Link: https://lore.kernel.org/r/87czctgg3w.wl-kuninori.morimoto.gx@renesas.com +Signed-off-by: Mark Brown +Signed-off-by: Greg Kroah-Hartman +--- + sound/soc/soc-pcm.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/sound/soc/soc-pcm.c ++++ b/sound/soc/soc-pcm.c +@@ -723,7 +723,7 @@ static int soc_pcm_close(struct snd_pcm_ + struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); + + snd_soc_dpcm_mutex_lock(rtd); +- soc_pcm_clean(rtd, substream, 0); ++ __soc_pcm_close(rtd, substream); + snd_soc_dpcm_mutex_unlock(rtd); + return 0; + } diff --git a/queue-5.15/series b/queue-5.15/series index bf20fbb9e23..7174a93a87b 100644 --- a/queue-5.15/series +++ b/queue-5.15/series @@ -98,3 +98,8 @@ hid-wacom-set-a-default-resolution-for-older-tablets.patch hid-wacom-insert-timestamp-to-packed-bluetooth-bt-events.patch fs-ntfs3-fix-null-ptr-deref-on-inode-i_op-in-ntfs_lookup.patch fs-ntfs3-refactoring-of-various-minor-issues.patch +asoc-soc-pcm-fix-dpcm-lockdep-warning-due-to-nested-stream-locks.patch +asoc-soc-compress-inherit-atomicity-from-dai-link-for-compress-fe.patch +asoc-soc-pcm-move-debugfs-removal-out-of-spinlock.patch +asoc-dpcm-don-t-pick-up-be-without-substream.patch +asoc-soc-pcm.c-call-__soc_pcm_close-in-soc_pcm_close.patch