From: Sasha Levin Date: Fri, 10 Jan 2025 00:09:17 +0000 (-0500) Subject: Fixes for 6.1 X-Git-Tag: v6.6.71~3^2~2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e46308aaeb71b6c0c149231d9f70ab8562874ecd;p=thirdparty%2Fkernel%2Fstable-queue.git Fixes for 6.1 Signed-off-by: Sasha Levin --- 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 index 00000000000..fc7fb27b32a --- /dev/null +++ b/queue-6.1/asoc-mediatek-disable-buffer-pre-allocation.patch @@ -0,0 +1,57 @@ +From 4b21448b1a57b9bdf89ed59edede6bf7e383a19c Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 19 Dec 2024 18:53:02 +0800 +Subject: ASoC: mediatek: disable buffer pre-allocation + +From: Chen-Yu Tsai + +[ 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 +Reviewed-by: AngeloGioacchino Del Regno +Link: https://patch.msgid.link/20241219105303.548437-1-wenst@chromium.org +Signed-off-by: Mark Brown +Signed-off-by: Sasha Levin +--- + 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 index 00000000000..a4225d44a6f --- /dev/null +++ b/queue-6.1/scripts-sorttable-fix-orc_sort_cmp-to-maintain-symme.patch @@ -0,0 +1,69 @@ +From e095acfc09f0f768974a7da8d5e39f7f753e4092 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +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 + +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 +Cc: Ching-Chun (Jim) Huang +Cc: +Cc: Ingo Molnar +Cc: Josh Poimboeuf +Cc: Peter Zijlstra +Cc: Shile Zhang +Cc: Steven Rostedt +Cc: +Signed-off-by: Andrew Morton +(cherry picked from commit 0210d251162f4033350a94a43f95b1c39ec84a90) +Signed-off-by: Kuan-Wei Chiu +Signed-off-by: Sasha Levin +--- + 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 + diff --git a/queue-6.1/series b/queue-6.1/series index 746848cd253..3180901934b 100644 --- a/queue-6.1/series +++ b/queue-6.1/series @@ -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