From: Sasha Levin Date: Fri, 10 Jan 2025 00:09:16 +0000 (-0500) Subject: Fixes for 6.6 X-Git-Tag: v6.6.71~3^2~3 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9af74fded874ebe33b7708e567ef83fc64e276fe;p=thirdparty%2Fkernel%2Fstable-queue.git Fixes for 6.6 Signed-off-by: Sasha Levin --- diff --git a/queue-6.6/asoc-mediatek-disable-buffer-pre-allocation.patch b/queue-6.6/asoc-mediatek-disable-buffer-pre-allocation.patch new file mode 100644 index 00000000000..630033f3c70 --- /dev/null +++ b/queue-6.6/asoc-mediatek-disable-buffer-pre-allocation.patch @@ -0,0 +1,57 @@ +From 07d689528c6ed317cbaef268fd165e802c29ea05 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.6/asoc-rt722-add-delay-time-to-wait-for-the-calibratio.patch b/queue-6.6/asoc-rt722-add-delay-time-to-wait-for-the-calibratio.patch new file mode 100644 index 00000000000..ab7fc1e6a37 --- /dev/null +++ b/queue-6.6/asoc-rt722-add-delay-time-to-wait-for-the-calibratio.patch @@ -0,0 +1,47 @@ +From d0c0a6c80a3d8e61b8bb56b109567d71d723a74c Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 18 Dec 2024 17:13:07 +0800 +Subject: ASoC: rt722: add delay time to wait for the calibration procedure + +From: Shuming Fan + +[ Upstream commit c9e3ebdc52ebe028f238c9df5162ae92483bedd5 ] + +The calibration procedure needs some time to finish. +This patch adds the delay time to ensure the calibration procedure is completed correctly. + +Signed-off-by: Shuming Fan +Link: https://patch.msgid.link/20241218091307.96656-1-shumingf@realtek.com +Signed-off-by: Mark Brown +Signed-off-by: Sasha Levin +--- + sound/soc/codecs/rt722-sdca.c | 7 ++++++- + 1 file changed, 6 insertions(+), 1 deletion(-) + +diff --git a/sound/soc/codecs/rt722-sdca.c b/sound/soc/codecs/rt722-sdca.c +index b9b330375add..0f9f592744ad 100644 +--- a/sound/soc/codecs/rt722-sdca.c ++++ b/sound/soc/codecs/rt722-sdca.c +@@ -1466,13 +1466,18 @@ static void rt722_sdca_jack_preset(struct rt722_sdca_priv *rt722) + 0x008d); + /* check HP calibration FSM status */ + for (loop_check = 0; loop_check < chk_cnt; loop_check++) { ++ usleep_range(10000, 11000); + ret = rt722_sdca_index_read(rt722, RT722_VENDOR_CALI, + RT722_DAC_DC_CALI_CTL3, &calib_status); +- if (ret < 0 || loop_check == chk_cnt) ++ if (ret < 0) + dev_dbg(&rt722->slave->dev, "calibration failed!, ret=%d\n", ret); + if ((calib_status & 0x0040) == 0x0) + break; + } ++ ++ if (loop_check == chk_cnt) ++ dev_dbg(&rt722->slave->dev, "%s, calibration time-out!\n", __func__); ++ + /* Set ADC09 power entity floating control */ + rt722_sdca_index_write(rt722, RT722_VENDOR_HDA_CTL, RT722_ADC0A_08_PDE_FLOAT_CTL, + 0x2a12); +-- +2.39.5 + diff --git a/queue-6.6/erofs-fix-psi-memstall-accounting.patch b/queue-6.6/erofs-fix-psi-memstall-accounting.patch new file mode 100644 index 00000000000..60b18c786f2 --- /dev/null +++ b/queue-6.6/erofs-fix-psi-memstall-accounting.patch @@ -0,0 +1,49 @@ +From 73afd319f58d689c71421d3d335ed8b0a861e0ff Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 8 Jan 2025 23:15:20 +0800 +Subject: erofs: fix PSI memstall accounting + +From: Gao Xiang + +commit 1a2180f6859c73c674809f9f82e36c94084682ba upstream. + +Max Kellermann recently reported psi_group_cpu.tasks[NR_MEMSTALL] is +incorrect in the 6.11.9 kernel. + +The root cause appears to be that, since the problematic commit, bio +can be NULL, causing psi_memstall_leave() to be skipped in +z_erofs_submit_queue(). + +Reported-by: Max Kellermann +Closes: https://lore.kernel.org/r/CAKPOu+8tvSowiJADW2RuKyofL_CSkm_SuyZA7ME5vMLWmL6pqw@mail.gmail.com +Fixes: 9e2f9d34dd12 ("erofs: handle overlapped pclusters out of crafted images properly") +Reviewed-by: Chao Yu +Link: https://lore.kernel.org/r/20241127085236.3538334-1-hsiangkao@linux.alibaba.com +Signed-off-by: Gao Xiang +Signed-off-by: Sasha Levin +--- + fs/erofs/zdata.c | 7 +++---- + 1 file changed, 3 insertions(+), 4 deletions(-) + +diff --git a/fs/erofs/zdata.c b/fs/erofs/zdata.c +index 9fa07436a4da..496e4c7c52a4 100644 +--- a/fs/erofs/zdata.c ++++ b/fs/erofs/zdata.c +@@ -1730,11 +1730,10 @@ static void z_erofs_submit_queue(struct z_erofs_decompress_frontend *f, + move_to_bypass_jobqueue(pcl, qtail, owned_head); + } while (owned_head != Z_EROFS_PCLUSTER_TAIL); + +- if (bio) { ++ if (bio) + submit_bio(bio); +- if (memstall) +- psi_memstall_leave(&pflags); +- } ++ if (memstall) ++ psi_memstall_leave(&pflags); + + /* + * although background is preferred, no one is pending for submission. +-- +2.39.5 + diff --git a/queue-6.6/erofs-handle-overlapped-pclusters-out-of-crafted-ima.patch b/queue-6.6/erofs-handle-overlapped-pclusters-out-of-crafted-ima.patch new file mode 100644 index 00000000000..8628cb8303a --- /dev/null +++ b/queue-6.6/erofs-handle-overlapped-pclusters-out-of-crafted-ima.patch @@ -0,0 +1,164 @@ +From a75e6d956c70acff371ab0768d13d41c85cb6df7 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 8 Jan 2025 23:15:19 +0800 +Subject: erofs: handle overlapped pclusters out of crafted images properly + +From: Gao Xiang + +commit 9e2f9d34dd12e6e5b244ec488bcebd0c2d566c50 upstream. + +syzbot reported a task hang issue due to a deadlock case where it is +waiting for the folio lock of a cached folio that will be used for +cache I/Os. + +After looking into the crafted fuzzed image, I found it's formed with +several overlapped big pclusters as below: + + Ext: logical offset | length : physical offset | length + 0: 0.. 16384 | 16384 : 151552.. 167936 | 16384 + 1: 16384.. 32768 | 16384 : 155648.. 172032 | 16384 + 2: 32768.. 49152 | 16384 : 537223168.. 537239552 | 16384 +... + +Here, extent 0/1 are physically overlapped although it's entirely +_impossible_ for normal filesystem images generated by mkfs. + +First, managed folios containing compressed data will be marked as +up-to-date and then unlocked immediately (unlike in-place folios) when +compressed I/Os are complete. If physical blocks are not submitted in +the incremental order, there should be separate BIOs to avoid dependency +issues. However, the current code mis-arranges z_erofs_fill_bio_vec() +and BIO submission which causes unexpected BIO waits. + +Second, managed folios will be connected to their own pclusters for +efficient inter-queries. However, this is somewhat hard to implement +easily if overlapped big pclusters exist. Again, these only appear in +fuzzed images so let's simply fall back to temporary short-lived pages +for correctness. + +Additionally, it justifies that referenced managed folios cannot be +truncated for now and reverts part of commit 2080ca1ed3e4 ("erofs: tidy +up `struct z_erofs_bvec`") for simplicity although it shouldn't be any +difference. + +Reported-by: syzbot+4fc98ed414ae63d1ada2@syzkaller.appspotmail.com +Reported-by: syzbot+de04e06b28cfecf2281c@syzkaller.appspotmail.com +Reported-by: syzbot+c8c8238b394be4a1087d@syzkaller.appspotmail.com +Tested-by: syzbot+4fc98ed414ae63d1ada2@syzkaller.appspotmail.com +Closes: https://lore.kernel.org/r/0000000000002fda01061e334873@google.com +Fixes: 8e6c8fa9f2e9 ("erofs: enable big pcluster feature") +Link: https://lore.kernel.org/r/20240910070847.3356592-1-hsiangkao@linux.alibaba.com +Signed-off-by: Gao Xiang +Signed-off-by: Sasha Levin +--- + fs/erofs/zdata.c | 59 +++++++++++++++++++++++++----------------------- + 1 file changed, 31 insertions(+), 28 deletions(-) + +diff --git a/fs/erofs/zdata.c b/fs/erofs/zdata.c +index 1c0e6167d8e7..9fa07436a4da 100644 +--- a/fs/erofs/zdata.c ++++ b/fs/erofs/zdata.c +@@ -1483,14 +1483,13 @@ static struct page *pickup_page_for_submission(struct z_erofs_pcluster *pcl, + goto out; + + lock_page(page); +- +- /* only true if page reclaim goes wrong, should never happen */ +- DBG_BUGON(justfound && PagePrivate(page)); +- +- /* the page is still in manage cache */ +- if (page->mapping == mc) { ++ if (likely(page->mapping == mc)) { + WRITE_ONCE(pcl->compressed_bvecs[nr].page, page); + ++ /* ++ * The cached folio is still in managed cache but without ++ * a valid `->private` pcluster hint. Let's reconnect them. ++ */ + if (!PagePrivate(page)) { + /* + * impossible to be !PagePrivate(page) for +@@ -1504,22 +1503,24 @@ static struct page *pickup_page_for_submission(struct z_erofs_pcluster *pcl, + SetPagePrivate(page); + } + +- /* no need to submit io if it is already up-to-date */ +- if (PageUptodate(page)) { +- unlock_page(page); +- page = NULL; ++ if (likely(page->private == (unsigned long)pcl)) { ++ /* don't submit cache I/Os again if already uptodate */ ++ if (PageUptodate(page)) { ++ unlock_page(page); ++ page = NULL; ++ ++ } ++ goto out; + } +- goto out; ++ /* ++ * Already linked with another pcluster, which only appears in ++ * crafted images by fuzzers for now. But handle this anyway. ++ */ ++ tocache = false; /* use temporary short-lived pages */ ++ } else { ++ DBG_BUGON(1); /* referenced managed folios can't be truncated */ ++ tocache = true; + } +- +- /* +- * the managed page has been truncated, it's unsafe to +- * reuse this one, let's allocate a new cache-managed page. +- */ +- DBG_BUGON(page->mapping); +- DBG_BUGON(!justfound); +- +- tocache = true; + unlock_page(page); + put_page(page); + out_allocpage: +@@ -1677,16 +1678,11 @@ static void z_erofs_submit_queue(struct z_erofs_decompress_frontend *f, + end = cur + pcl->pclusterpages; + + do { +- struct page *page; +- +- page = pickup_page_for_submission(pcl, i++, +- &f->pagepool, mc); +- if (!page) +- continue; ++ struct page *page = NULL; + + if (bio && (cur != last_index + 1 || + last_bdev != mdev.m_bdev)) { +-submit_bio_retry: ++drain_io: + submit_bio(bio); + if (memstall) { + psi_memstall_leave(&pflags); +@@ -1695,6 +1691,13 @@ static void z_erofs_submit_queue(struct z_erofs_decompress_frontend *f, + bio = NULL; + } + ++ if (!page) { ++ page = pickup_page_for_submission(pcl, i++, ++ &f->pagepool, mc); ++ if (!page) ++ continue; ++ } ++ + if (unlikely(PageWorkingset(page)) && !memstall) { + psi_memstall_enter(&pflags); + memstall = 1; +@@ -1715,7 +1718,7 @@ static void z_erofs_submit_queue(struct z_erofs_decompress_frontend *f, + } + + if (bio_add_page(bio, page, PAGE_SIZE, 0) < PAGE_SIZE) +- goto submit_bio_retry; ++ goto drain_io; + + last_index = cur; + bypass = false; +-- +2.39.5 + diff --git a/queue-6.6/selftests-alsa-fix-circular-dependency-involving-glo.patch b/queue-6.6/selftests-alsa-fix-circular-dependency-involving-glo.patch new file mode 100644 index 00000000000..a9fae95e0d6 --- /dev/null +++ b/queue-6.6/selftests-alsa-fix-circular-dependency-involving-glo.patch @@ -0,0 +1,52 @@ +From fce5899a3db4bcabfff00b178cbad685f4de9b2c Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 18 Dec 2024 10:59:31 +0800 +Subject: selftests/alsa: Fix circular dependency involving global-timer + +From: Li Zhijian + +[ Upstream commit 55853cb829dc707427c3519f6b8686682a204368 ] + +The pattern rule `$(OUTPUT)/%: %.c` inadvertently included a circular +dependency on the global-timer target due to its inclusion in +$(TEST_GEN_PROGS_EXTENDED). This resulted in a circular dependency +warning during the build process. + +To resolve this, the dependency on $(TEST_GEN_PROGS_EXTENDED) has been +replaced with an explicit dependency on $(OUTPUT)/libatest.so. This change +ensures that libatest.so is built before any other targets that require it, +without creating a circular dependency. + +This fix addresses the following warning: + +make[4]: Entering directory 'tools/testing/selftests/alsa' +make[4]: Circular default_modconfig/kselftest/alsa/global-timer <- default_modconfig/kselftest/alsa/global-timer dependency dropped. +make[4]: Nothing to be done for 'all'. +make[4]: Leaving directory 'tools/testing/selftests/alsa' + +Cc: Mark Brown +Cc: Jaroslav Kysela +Cc: Takashi Iwai +Cc: Shuah Khan +Signed-off-by: Li Zhijian +Link: https://patch.msgid.link/20241218025931.914164-1-lizhijian@fujitsu.com +Signed-off-by: Takashi Iwai +Signed-off-by: Sasha Levin +--- + tools/testing/selftests/alsa/Makefile | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/tools/testing/selftests/alsa/Makefile b/tools/testing/selftests/alsa/Makefile +index 5af9ba8a4645..140c7f821727 100644 +--- a/tools/testing/selftests/alsa/Makefile ++++ b/tools/testing/selftests/alsa/Makefile +@@ -23,5 +23,5 @@ include ../lib.mk + $(OUTPUT)/libatest.so: conf.c alsa-local.h + $(CC) $(CFLAGS) -shared -fPIC $< $(LDLIBS) -o $@ + +-$(OUTPUT)/%: %.c $(TEST_GEN_PROGS_EXTENDED) alsa-local.h ++$(OUTPUT)/%: %.c $(OUTPUT)/libatest.so alsa-local.h + $(CC) $(CFLAGS) $< $(LDLIBS) -latest -o $@ +-- +2.39.5 + diff --git a/queue-6.6/series b/queue-6.6/series index bb22e195411..8d2b0e0ecbf 100644 --- a/queue-6.6/series +++ b/queue-6.6/series @@ -10,3 +10,8 @@ exfat-fix-the-infinite-loop-in-__exfat_free_cluster.patch ovl-do-not-encode-lower-fh-with-upper-sb_writers-hel.patch ovl-pass-realinode-to-ovl_encode_real_fh-instead-of-.patch ovl-support-encoding-fid-from-inode-with-no-alias.patch +erofs-handle-overlapped-pclusters-out-of-crafted-ima.patch +erofs-fix-psi-memstall-accounting.patch +asoc-rt722-add-delay-time-to-wait-for-the-calibratio.patch +asoc-mediatek-disable-buffer-pre-allocation.patch +selftests-alsa-fix-circular-dependency-involving-glo.patch