]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
Fixes for 6.1
authorSasha Levin <sashal@kernel.org>
Fri, 10 Jan 2025 00:09:17 +0000 (19:09 -0500)
committerSasha Levin <sashal@kernel.org>
Fri, 10 Jan 2025 00:09:17 +0000 (19:09 -0500)
Signed-off-by: Sasha Levin <sashal@kernel.org>
queue-6.1/asoc-mediatek-disable-buffer-pre-allocation.patch [new file with mode: 0644]
queue-6.1/scripts-sorttable-fix-orc_sort_cmp-to-maintain-symme.patch [new file with mode: 0644]
queue-6.1/series

diff --git a/queue-6.1/asoc-mediatek-disable-buffer-pre-allocation.patch b/queue-6.1/asoc-mediatek-disable-buffer-pre-allocation.patch
new file mode 100644 (file)
index 0000000..fc7fb27
--- /dev/null
@@ -0,0 +1,57 @@
+From 4b21448b1a57b9bdf89ed59edede6bf7e383a19c Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 19 Dec 2024 18:53:02 +0800
+Subject: ASoC: mediatek: disable buffer pre-allocation
+
+From: Chen-Yu Tsai <wenst@chromium.org>
+
+[ Upstream commit 32c9c06adb5b157ef259233775a063a43746d699 ]
+
+On Chromebooks based on Mediatek MT8195 or MT8188, the audio frontend
+(AFE) is limited to accessing a very small window (1 MiB) of memory,
+which is described as a reserved memory region in the device tree.
+
+On these two platforms, the maximum buffer size is given as 512 KiB.
+The MediaTek common code uses the same value for preallocations. This
+means that only the first two PCM substreams get preallocations, and
+then the whole space is exhausted, barring any other substreams from
+working. Since the substreams used are not always the first two, this
+means audio won't work correctly.
+
+This is observed on the MT8188 Geralt Chromebooks, on which the
+"mediatek,dai-link" property was dropped when it was upstreamed. That
+property causes the driver to only register the PCM substreams listed
+in the property, and in the order given.
+
+Instead of trying to compute an optimal value and figuring out which
+streams are used, simply disable preallocation. The PCM buffers are
+managed by the core and are allocated and released on the fly. There
+should be no impact to any of the other MediaTek platforms.
+
+Signed-off-by: Chen-Yu Tsai <wenst@chromium.org>
+Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
+Link: https://patch.msgid.link/20241219105303.548437-1-wenst@chromium.org
+Signed-off-by: Mark Brown <broonie@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ sound/soc/mediatek/common/mtk-afe-platform-driver.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/sound/soc/mediatek/common/mtk-afe-platform-driver.c b/sound/soc/mediatek/common/mtk-afe-platform-driver.c
+index 01501d5747a7..52495c930ca3 100644
+--- a/sound/soc/mediatek/common/mtk-afe-platform-driver.c
++++ b/sound/soc/mediatek/common/mtk-afe-platform-driver.c
+@@ -120,8 +120,8 @@ int mtk_afe_pcm_new(struct snd_soc_component *component,
+       struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component);
+       size = afe->mtk_afe_hardware->buffer_bytes_max;
+-      snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV,
+-                                     afe->dev, size, size);
++      snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, afe->dev, 0, size);
++
+       return 0;
+ }
+ EXPORT_SYMBOL_GPL(mtk_afe_pcm_new);
+-- 
+2.39.5
+
diff --git a/queue-6.1/scripts-sorttable-fix-orc_sort_cmp-to-maintain-symme.patch b/queue-6.1/scripts-sorttable-fix-orc_sort_cmp-to-maintain-symme.patch
new file mode 100644 (file)
index 0000000..a4225d4
--- /dev/null
@@ -0,0 +1,69 @@
+From e095acfc09f0f768974a7da8d5e39f7f753e4092 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 7 Jan 2025 01:44:59 +0800
+Subject: scripts/sorttable: fix orc_sort_cmp() to maintain symmetry and
+ transitivity
+
+From: Kuan-Wei Chiu <visitorckw@gmail.com>
+
+The orc_sort_cmp() function, used with qsort(), previously violated the
+symmetry and transitivity rules required by the C standard.  Specifically,
+when both entries are ORC_REG_UNDEFINED, it could result in both a < b
+and b < a, which breaks the required symmetry and transitivity.  This can
+lead to undefined behavior and incorrect sorting results, potentially
+causing memory corruption in glibc implementations [1].
+
+Symmetry: If x < y, then y > x.
+Transitivity: If x < y and y < z, then x < z.
+
+Fix the comparison logic to return 0 when both entries are
+ORC_REG_UNDEFINED, ensuring compliance with qsort() requirements.
+
+Link: https://www.qualys.com/2024/01/30/qsort.txt [1]
+Link: https://lkml.kernel.org/r/20241226140332.2670689-1-visitorckw@gmail.com
+Fixes: 57fa18994285 ("scripts/sorttable: Implement build-time ORC unwind table sorting")
+Fixes: fb799447ae29 ("x86,objtool: Split UNWIND_HINT_EMPTY in two")
+Signed-off-by: Kuan-Wei Chiu <visitorckw@gmail.com>
+Cc: Ching-Chun (Jim) Huang <jserv@ccns.ncku.edu.tw>
+Cc: <chuang@cs.nycu.edu.tw>
+Cc: Ingo Molnar <mingo@kernel.org>
+Cc: Josh Poimboeuf <jpoimboe@kernel.org>
+Cc: Peter Zijlstra <peterz@infradead.org>
+Cc: Shile Zhang <shile.zhang@linux.alibaba.com>
+Cc: Steven Rostedt <rostedt@goodmis.org>
+Cc: <stable@vger.kernel.org>
+Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
+(cherry picked from commit 0210d251162f4033350a94a43f95b1c39ec84a90)
+Signed-off-by: Kuan-Wei Chiu <visitorckw@gmail.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ scripts/sorttable.h | 6 +++++-
+ 1 file changed, 5 insertions(+), 1 deletion(-)
+
+diff --git a/scripts/sorttable.h b/scripts/sorttable.h
+index deb7c1d3e979..f0ba2bf5a886 100644
+--- a/scripts/sorttable.h
++++ b/scripts/sorttable.h
+@@ -110,7 +110,7 @@ static inline unsigned long orc_ip(const int *ip)
+ static int orc_sort_cmp(const void *_a, const void *_b)
+ {
+-      struct orc_entry *orc_a;
++      struct orc_entry *orc_a, *orc_b;
+       const int *a = g_orc_ip_table + *(int *)_a;
+       const int *b = g_orc_ip_table + *(int *)_b;
+       unsigned long a_val = orc_ip(a);
+@@ -128,6 +128,10 @@ static int orc_sort_cmp(const void *_a, const void *_b)
+        * whitelisted .o files which didn't get objtool generation.
+        */
+       orc_a = g_orc_table + (a - g_orc_ip_table);
++      orc_b = g_orc_table + (b - g_orc_ip_table);
++      if (orc_a->sp_reg == ORC_REG_UNDEFINED && !orc_a->end &&
++          orc_b->sp_reg == ORC_REG_UNDEFINED && !orc_b->end)
++              return 0;
+       return orc_a->sp_reg == ORC_REG_UNDEFINED && !orc_a->end ? -1 : 1;
+ }
+-- 
+2.39.5
+
index 746848cd253ff8d9eaae53ae50336d4c336ff4dd..3180901934b0f8afa8c5632b26f5aff0025ca72e 100644 (file)
@@ -8,3 +8,5 @@ dm-array-fix-unreleased-btree-blocks-on-closing-a-fa.patch
 dm-array-fix-cursor-index-when-skipping-across-block.patch
 exfat-fix-the-infinite-loop-in-exfat_readdir.patch
 exfat-fix-the-infinite-loop-in-__exfat_free_cluster.patch
+scripts-sorttable-fix-orc_sort_cmp-to-maintain-symme.patch
+asoc-mediatek-disable-buffer-pre-allocation.patch