From: Sasha Levin Date: Fri, 1 Nov 2024 03:01:28 +0000 (-0400) Subject: Fixes for 6.11 X-Git-Tag: v4.19.323~132 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3263c0d64e4ee98b7079729051d318ab925f08ec;p=thirdparty%2Fkernel%2Fstable-queue.git Fixes for 6.11 Signed-off-by: Sasha Levin --- diff --git a/queue-6.11/cgroup-fix-potential-overflow-issue-when-checking-ma.patch b/queue-6.11/cgroup-fix-potential-overflow-issue-when-checking-ma.patch new file mode 100644 index 00000000000..e1a084d06e2 --- /dev/null +++ b/queue-6.11/cgroup-fix-potential-overflow-issue-when-checking-ma.patch @@ -0,0 +1,59 @@ +From 7ad057a687c45a760d6e283c37469342ec9406b2 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sat, 12 Oct 2024 07:22:46 +0000 +Subject: cgroup: Fix potential overflow issue when checking max_depth +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Xiu Jianfeng + +[ Upstream commit 3cc4e13bb1617f6a13e5e6882465984148743cf4 ] + +cgroup.max.depth is the maximum allowed descent depth below the current +cgroup. If the actual descent depth is equal or larger, an attempt to +create a new child cgroup will fail. However due to the cgroup->max_depth +is of int type and having the default value INT_MAX, the condition +'level > cgroup->max_depth' will never be satisfied, and it will cause +an overflow of the level after it reaches to INT_MAX. + +Fix it by starting the level from 0 and using '>=' instead. + +It's worth mentioning that this issue is unlikely to occur in reality, +as it's impossible to have a depth of INT_MAX hierarchy, but should be +be avoided logically. + +Fixes: 1a926e0bbab8 ("cgroup: implement hierarchy limits") +Signed-off-by: Xiu Jianfeng +Reviewed-by: Michal Koutný +Signed-off-by: Tejun Heo +Signed-off-by: Sasha Levin +--- + kernel/cgroup/cgroup.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c +index c8e4b62b436a4..6ba7dd2ab771d 100644 +--- a/kernel/cgroup/cgroup.c ++++ b/kernel/cgroup/cgroup.c +@@ -5722,7 +5722,7 @@ static bool cgroup_check_hierarchy_limits(struct cgroup *parent) + { + struct cgroup *cgroup; + int ret = false; +- int level = 1; ++ int level = 0; + + lockdep_assert_held(&cgroup_mutex); + +@@ -5730,7 +5730,7 @@ static bool cgroup_check_hierarchy_limits(struct cgroup *parent) + if (cgroup->nr_descendants >= cgroup->max_descendants) + goto fail; + +- if (level > cgroup->max_depth) ++ if (level >= cgroup->max_depth) + goto fail; + + level++; +-- +2.43.0 + diff --git a/queue-6.11/drm-amdgpu-fix-random-data-corruption-for-sdma-7.patch b/queue-6.11/drm-amdgpu-fix-random-data-corruption-for-sdma-7.patch new file mode 100644 index 00000000000..610d82efcd5 --- /dev/null +++ b/queue-6.11/drm-amdgpu-fix-random-data-corruption-for-sdma-7.patch @@ -0,0 +1,54 @@ +From 79a5aa1cdadc04b72b5ce885738ef94ab6a1c4a6 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 10 Oct 2024 16:41:32 +0800 +Subject: drm/amdgpu: fix random data corruption for sdma 7 + +From: Frank Min + +[ Upstream commit 108bc59fe817686a59d2008f217bad38a5cf4427 ] + +There is random data corruption caused by const fill, this is caused by +write compression mode not correctly configured. + +So correct compression mode for const fill. + +Signed-off-by: Frank Min +Reviewed-by: Alex Deucher +Signed-off-by: Alex Deucher +(cherry picked from commit 75400f8d6e36afc88d59db8a1f3e4b7d90d836ad) +Cc: stable@vger.kernel.org # 6.11.x +Signed-off-by: Sasha Levin +--- + drivers/gpu/drm/amd/amdgpu/sdma_v7_0.c | 9 ++++++++- + 1 file changed, 8 insertions(+), 1 deletion(-) + +diff --git a/drivers/gpu/drm/amd/amdgpu/sdma_v7_0.c b/drivers/gpu/drm/amd/amdgpu/sdma_v7_0.c +index 403c177f24349..bbf43e668c1c4 100644 +--- a/drivers/gpu/drm/amd/amdgpu/sdma_v7_0.c ++++ b/drivers/gpu/drm/amd/amdgpu/sdma_v7_0.c +@@ -51,6 +51,12 @@ MODULE_FIRMWARE("amdgpu/sdma_7_0_1.bin"); + #define SDMA0_HYP_DEC_REG_END 0x589a + #define SDMA1_HYP_DEC_REG_OFFSET 0x20 + ++/*define for compression field for sdma7*/ ++#define SDMA_PKT_CONSTANT_FILL_HEADER_compress_offset 0 ++#define SDMA_PKT_CONSTANT_FILL_HEADER_compress_mask 0x00000001 ++#define SDMA_PKT_CONSTANT_FILL_HEADER_compress_shift 16 ++#define SDMA_PKT_CONSTANT_FILL_HEADER_COMPRESS(x) (((x) & SDMA_PKT_CONSTANT_FILL_HEADER_compress_mask) << SDMA_PKT_CONSTANT_FILL_HEADER_compress_shift) ++ + static void sdma_v7_0_set_ring_funcs(struct amdgpu_device *adev); + static void sdma_v7_0_set_buffer_funcs(struct amdgpu_device *adev); + static void sdma_v7_0_set_vm_pte_funcs(struct amdgpu_device *adev); +@@ -1611,7 +1617,8 @@ static void sdma_v7_0_emit_fill_buffer(struct amdgpu_ib *ib, + uint64_t dst_offset, + uint32_t byte_count) + { +- ib->ptr[ib->length_dw++] = SDMA_PKT_COPY_LINEAR_HEADER_OP(SDMA_OP_CONST_FILL); ++ ib->ptr[ib->length_dw++] = SDMA_PKT_CONSTANT_FILL_HEADER_OP(SDMA_OP_CONST_FILL) | ++ SDMA_PKT_CONSTANT_FILL_HEADER_COMPRESS(1); + ib->ptr[ib->length_dw++] = lower_32_bits(dst_offset); + ib->ptr[ib->length_dw++] = upper_32_bits(dst_offset); + ib->ptr[ib->length_dw++] = src_data; +-- +2.43.0 + diff --git a/queue-6.11/lib-alloc_tag_module_unload-must-wait-for-pending-kf.patch b/queue-6.11/lib-alloc_tag_module_unload-must-wait-for-pending-kf.patch new file mode 100644 index 00000000000..2a435cb2941 --- /dev/null +++ b/queue-6.11/lib-alloc_tag_module_unload-must-wait-for-pending-kf.patch @@ -0,0 +1,66 @@ +From 536dfe685ebd28b27ebfbc3d4b9168207b7e28a3 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 7 Oct 2024 22:52:24 +0200 +Subject: lib: alloc_tag_module_unload must wait for pending kfree_rcu calls + +From: Florian Westphal + +[ Upstream commit dc783ba4b9df3fb3e76e968b2cbeb9960069263c ] + +Ben Greear reports following splat: + ------------[ cut here ]------------ + net/netfilter/nf_nat_core.c:1114 module nf_nat func:nf_nat_register_fn has 256 allocated at module unload + WARNING: CPU: 1 PID: 10421 at lib/alloc_tag.c:168 alloc_tag_module_unload+0x22b/0x3f0 + Modules linked in: nf_nat(-) btrfs ufs qnx4 hfsplus hfs minix vfat msdos fat +... + Hardware name: Default string Default string/SKYBAY, BIOS 5.12 08/04/2020 + RIP: 0010:alloc_tag_module_unload+0x22b/0x3f0 + codetag_unload_module+0x19b/0x2a0 + ? codetag_load_module+0x80/0x80 + +nf_nat module exit calls kfree_rcu on those addresses, but the free +operation is likely still pending by the time alloc_tag checks for leaks. + +Wait for outstanding kfree_rcu operations to complete before checking +resolves this warning. + +Reproducer: +unshare -n iptables-nft -t nat -A PREROUTING -p tcp +grep nf_nat /proc/allocinfo # will list 4 allocations +rmmod nft_chain_nat +rmmod nf_nat # will WARN. + +[akpm@linux-foundation.org: add comment] +Link: https://lkml.kernel.org/r/20241007205236.11847-1-fw@strlen.de +Fixes: a473573964e5 ("lib: code tagging module support") +Signed-off-by: Florian Westphal +Reported-by: Ben Greear +Closes: https://lore.kernel.org/netdev/bdaaef9d-4364-4171-b82b-bcfc12e207eb@candelatech.com/ +Cc: Uladzislau Rezki +Cc: Vlastimil Babka +Cc: Suren Baghdasaryan +Cc: Kent Overstreet +Cc: +Signed-off-by: Andrew Morton +Signed-off-by: Sasha Levin +--- + lib/codetag.c | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/lib/codetag.c b/lib/codetag.c +index afa8a2d4f3173..d1fbbb7c2ec3d 100644 +--- a/lib/codetag.c ++++ b/lib/codetag.c +@@ -228,6 +228,9 @@ bool codetag_unload_module(struct module *mod) + if (!mod) + return true; + ++ /* await any module's kfree_rcu() operations to complete */ ++ kvfree_rcu_barrier(); ++ + mutex_lock(&codetag_lock); + list_for_each_entry(cttype, &codetag_types, link) { + struct codetag_module *found = NULL; +-- +2.43.0 + diff --git a/queue-6.11/perf-python-fix-up-the-build-on-architectures-withou.patch b/queue-6.11/perf-python-fix-up-the-build-on-architectures-withou.patch new file mode 100644 index 00000000000..16708694152 --- /dev/null +++ b/queue-6.11/perf-python-fix-up-the-build-on-architectures-withou.patch @@ -0,0 +1,73 @@ +From 072a7f105b21bdfa3bdc3e5047a99f61a6a25474 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 23 Oct 2024 16:12:57 -0300 +Subject: perf python: Fix up the build on architectures without + HAVE_KVM_STAT_SUPPORT +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Arnaldo Carvalho de Melo + +[ Upstream commit 758f18158952a6287ac23679ec04c32d44ca5368 ] + +Noticed while building on a raspbian arm 32-bit system. + +There was also this other case, fixed by adding a missing util/stat.h +with the prototypes: + + /tmp/tmp.MbiSHoF3dj/perf-6.12.0-rc3/tools/perf/util/python.c:1396:6: error: no previous prototype for ‘perf_stat__set_no_csv_summary’ [-Werror=missing-prototypes] + 1396 | void perf_stat__set_no_csv_summary(int set __maybe_unused) + | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + /tmp/tmp.MbiSHoF3dj/perf-6.12.0-rc3/tools/perf/util/python.c:1400:6: error: no previous prototype for ‘perf_stat__set_big_num’ [-Werror=missing-prototypes] + 1400 | void perf_stat__set_big_num(int set __maybe_unused) + | ^~~~~~~~~~~~~~~~~~~~~~ + cc1: all warnings being treated as errors + +In other architectures this must be building due to some lucky indirect +inclusion of that header. + +Fixes: 9dabf4003423c8d3 ("perf python: Switch module to linking libraries from building source") +Reviewed-by: Ian Rogers +Cc: Adrian Hunter +Cc: Jiri Olsa +Cc: Kan Liang +Cc: Namhyung Kim +Link: https://lore.kernel.org/lkml/ZxllAtpmEw5fg9oy@x1 +Signed-off-by: Arnaldo Carvalho de Melo +Signed-off-by: Sasha Levin +--- + tools/perf/util/python.c | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c +index 31a223eaf8e65..ee3d43a7ba457 100644 +--- a/tools/perf/util/python.c ++++ b/tools/perf/util/python.c +@@ -19,6 +19,7 @@ + #include "util/bpf-filter.h" + #include "util/env.h" + #include "util/kvm-stat.h" ++#include "util/stat.h" + #include "util/kwork.h" + #include "util/sample.h" + #include "util/lock-contention.h" +@@ -1355,6 +1356,7 @@ PyMODINIT_FUNC PyInit_perf(void) + + unsigned int scripting_max_stack = PERF_MAX_STACK_DEPTH; + ++#ifdef HAVE_KVM_STAT_SUPPORT + bool kvm_entry_event(struct evsel *evsel __maybe_unused) + { + return false; +@@ -1384,6 +1386,7 @@ void exit_event_decode_key(struct perf_kvm_stat *kvm __maybe_unused, + char *decode __maybe_unused) + { + } ++#endif // HAVE_KVM_STAT_SUPPORT + + int find_scripts(char **scripts_array __maybe_unused, char **scripts_path_array __maybe_unused, + int num __maybe_unused, int pathlen __maybe_unused) +-- +2.43.0 + diff --git a/queue-6.11/perf-trace-fix-non-listed-archs-in-the-syscalltbl-ro.patch b/queue-6.11/perf-trace-fix-non-listed-archs-in-the-syscalltbl-ro.patch new file mode 100644 index 00000000000..60983ebb732 --- /dev/null +++ b/queue-6.11/perf-trace-fix-non-listed-archs-in-the-syscalltbl-ro.patch @@ -0,0 +1,66 @@ +From 51c6f64e197b3b9a639df7c0a8d18ec1c9a08065 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 22 Oct 2024 17:22:36 -0300 +Subject: perf trace: Fix non-listed archs in the syscalltbl routines + +From: Jiri Slaby + +[ Upstream commit 5d35634ecc2d2c3938bd7dc23df0ad046da1b303 ] + +This fixes a build breakage on 32-bit arm, where the +syscalltbl__id_at_idx() function was missing. + +Committer notes: + +Generating a proper syscall table from a copy of +arch/arm/tools/syscall.tbl ends up being too big a patch for this rc +stage, I started doing it but while testing noticed some other problems +with using BPF to collect pointer args on arm7 (32-bit) will maybe +continue trying to make it work on the next cycle... + +Fixes: 7a2fb5619cc1fb53 ("perf trace: Fix iteration of syscall ids in syscalltbl->entries") +Suggested-by: Howard Chu +Signed-off-by: +Acked-by: Namhyung Kim +Cc: Adrian Hunter +Cc: Howard Chu +Cc: Ian Rogers +Cc: Jiri Olsa +Link: https://lore.kernel.org/lkml/3a592835-a14f-40be-8961-c0cee7720a94@kernel.org +Signed-off-by: Arnaldo Carvalho de Melo +Signed-off-by: Sasha Levin +--- + tools/perf/util/syscalltbl.c | 10 ++++++++++ + 1 file changed, 10 insertions(+) + +diff --git a/tools/perf/util/syscalltbl.c b/tools/perf/util/syscalltbl.c +index 0dd26b991b3fb..351da249f1cc6 100644 +--- a/tools/perf/util/syscalltbl.c ++++ b/tools/perf/util/syscalltbl.c +@@ -42,6 +42,11 @@ static const char *const *syscalltbl_native = syscalltbl_mips_n64; + #include + const int syscalltbl_native_max_id = SYSCALLTBL_LOONGARCH_MAX_ID; + static const char *const *syscalltbl_native = syscalltbl_loongarch; ++#else ++const int syscalltbl_native_max_id = 0; ++static const char *const syscalltbl_native[] = { ++ [0] = "unknown", ++}; + #endif + + struct syscall { +@@ -178,6 +183,11 @@ int syscalltbl__id(struct syscalltbl *tbl, const char *name) + return audit_name_to_syscall(name, tbl->audit_machine); + } + ++int syscalltbl__id_at_idx(struct syscalltbl *tbl __maybe_unused, int idx) ++{ ++ return idx; ++} ++ + int syscalltbl__strglobmatch_next(struct syscalltbl *tbl __maybe_unused, + const char *syscall_glob __maybe_unused, int *idx __maybe_unused) + { +-- +2.43.0 + diff --git a/queue-6.11/scsi-scsi_debug-fix-do_device_access-handling-of-une.patch b/queue-6.11/scsi-scsi_debug-fix-do_device_access-handling-of-une.patch new file mode 100644 index 00000000000..4b42b7bef96 --- /dev/null +++ b/queue-6.11/scsi-scsi_debug-fix-do_device_access-handling-of-une.patch @@ -0,0 +1,67 @@ +From 3c5b0af653c45c40b7e92d060006a2e7c93126f4 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 18 Oct 2024 10:16:55 +0000 +Subject: scsi: scsi_debug: Fix do_device_access() handling of unexpected SG + copy length + +From: John Garry + +[ Upstream commit d28d17a845600dd9f7de241de9b1528a1b138716 ] + +If the sg_copy_buffer() call returns less than sdebug_sector_size, then +we drop out of the copy loop. However, we still report that we copied +the full expected amount, which is not proper. + +Fix by keeping a running total and return that value. + +Fixes: 84f3a3c01d70 ("scsi: scsi_debug: Atomic write support") +Reported-by: Colin Ian King +Suggested-by: Dan Carpenter +Signed-off-by: John Garry +Link: https://lore.kernel.org/r/20241018101655.4207-1-john.g.garry@oracle.com +Reviewed-by: Dan Carpenter +Reviewed-by: Colin Ian King +Signed-off-by: Martin K. Petersen +Signed-off-by: Sasha Levin +--- + drivers/scsi/scsi_debug.c | 10 ++++------ + 1 file changed, 4 insertions(+), 6 deletions(-) + +diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c +index a9d8a9c62663e..e41698218e62f 100644 +--- a/drivers/scsi/scsi_debug.c ++++ b/drivers/scsi/scsi_debug.c +@@ -3652,7 +3652,7 @@ static int do_device_access(struct sdeb_store_info *sip, struct scsi_cmnd *scp, + enum dma_data_direction dir; + struct scsi_data_buffer *sdb = &scp->sdb; + u8 *fsp; +- int i; ++ int i, total = 0; + + /* + * Even though reads are inherently atomic (in this driver), we expect +@@ -3689,18 +3689,16 @@ static int do_device_access(struct sdeb_store_info *sip, struct scsi_cmnd *scp, + fsp + (block * sdebug_sector_size), + sdebug_sector_size, sg_skip, do_write); + sdeb_data_sector_unlock(sip, do_write); +- if (ret != sdebug_sector_size) { +- ret += (i * sdebug_sector_size); ++ total += ret; ++ if (ret != sdebug_sector_size) + break; +- } + sg_skip += sdebug_sector_size; + if (++block >= sdebug_store_sectors) + block = 0; + } +- ret = num * sdebug_sector_size; + sdeb_data_unlock(sip, atomic); + +- return ret; ++ return total; + } + + /* Returns number of bytes copied or -1 if error. */ +-- +2.43.0 + diff --git a/queue-6.11/series b/queue-6.11/series new file mode 100644 index 00000000000..b1729851d2c --- /dev/null +++ b/queue-6.11/series @@ -0,0 +1,8 @@ +lib-alloc_tag_module_unload-must-wait-for-pending-kf.patch +drm-amdgpu-fix-random-data-corruption-for-sdma-7.patch +cgroup-fix-potential-overflow-issue-when-checking-ma.patch +spi-geni-qcom-fix-boot-warning-related-to-pm_runtime.patch +slub-kunit-fix-a-warning-due-to-unwrapped-__kmalloc_.patch +perf-trace-fix-non-listed-archs-in-the-syscalltbl-ro.patch +perf-python-fix-up-the-build-on-architectures-withou.patch +scsi-scsi_debug-fix-do_device_access-handling-of-une.patch diff --git a/queue-6.11/slub-kunit-fix-a-warning-due-to-unwrapped-__kmalloc_.patch b/queue-6.11/slub-kunit-fix-a-warning-due-to-unwrapped-__kmalloc_.patch new file mode 100644 index 00000000000..ac5edc24790 --- /dev/null +++ b/queue-6.11/slub-kunit-fix-a-warning-due-to-unwrapped-__kmalloc_.patch @@ -0,0 +1,54 @@ +From da719a7ef62a08aadd760b6f0cd966fd63242629 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 23 Oct 2024 14:21:17 +0800 +Subject: slub/kunit: fix a WARNING due to unwrapped __kmalloc_cache_noprof + +From: Pei Xiao + +[ Upstream commit 2b059d0d1e624adc6e69a754bc48057f8bf459dc ] + +'modprobe slub_kunit' will have a warning as shown below. The root cause +is that __kmalloc_cache_noprof was directly used, which resulted in no +alloc_tag being allocated. This caused current->alloc_tag to be null, +leading to a warning in alloc_tag_add_check. + +Let's add an alloc_hook layer to __kmalloc_cache_noprof specifically +within lib/slub_kunit.c, which is the only user of this internal slub +function outside kmalloc implementation itself. + +[58162.947016] WARNING: CPU: 2 PID: 6210 at +./include/linux/alloc_tag.h:125 alloc_tagging_slab_alloc_hook+0x268/0x27c +[58162.957721] Call trace: +[58162.957919] alloc_tagging_slab_alloc_hook+0x268/0x27c +[58162.958286] __kmalloc_cache_noprof+0x14c/0x344 +[58162.958615] test_kmalloc_redzone_access+0x50/0x10c [slub_kunit] +[58162.959045] kunit_try_run_case+0x74/0x184 [kunit] +[58162.959401] kunit_generic_run_threadfn_adapter+0x2c/0x4c [kunit] +[58162.959841] kthread+0x10c/0x118 +[58162.960093] ret_from_fork+0x10/0x20 +[58162.960363] ---[ end trace 0000000000000000 ]--- + +Signed-off-by: Pei Xiao +Fixes: a0a44d9175b3 ("mm, slab: don't wrap internal functions with alloc_hooks()") +Signed-off-by: Vlastimil Babka +Signed-off-by: Sasha Levin +--- + lib/slub_kunit.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/lib/slub_kunit.c b/lib/slub_kunit.c +index e6667a28c0149..af5b9c41d5b30 100644 +--- a/lib/slub_kunit.c ++++ b/lib/slub_kunit.c +@@ -140,7 +140,7 @@ static void test_kmalloc_redzone_access(struct kunit *test) + { + struct kmem_cache *s = test_kmem_cache_create("TestSlub_RZ_kmalloc", 32, + SLAB_KMALLOC|SLAB_STORE_USER|SLAB_RED_ZONE); +- u8 *p = __kmalloc_cache_noprof(s, GFP_KERNEL, 18); ++ u8 *p = alloc_hooks(__kmalloc_cache_noprof(s, GFP_KERNEL, 18)); + + kasan_disable_current(); + +-- +2.43.0 + diff --git a/queue-6.11/spi-geni-qcom-fix-boot-warning-related-to-pm_runtime.patch b/queue-6.11/spi-geni-qcom-fix-boot-warning-related-to-pm_runtime.patch new file mode 100644 index 00000000000..dab9de3ce4b --- /dev/null +++ b/queue-6.11/spi-geni-qcom-fix-boot-warning-related-to-pm_runtime.patch @@ -0,0 +1,87 @@ +From dcfb458ae7f15f70d2ff5aba80d3eb384f4c4839 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 9 Oct 2024 02:16:15 +0300 +Subject: spi: geni-qcom: Fix boot warning related to pm_runtime and devres + +From: Georgi Djakov + +[ Upstream commit d0ccf760a405d243a49485be0a43bd5b66ed17e2 ] + +During boot, users sometimes observe the following warning: + +[7.841431] WARNING: CPU: 4 PID: 492 at +drivers/interconnect/core.c:685 __icc_enable +(drivers/interconnect/core.c:685 (discriminator 7)) +[..] +[7.841541] Call trace: +[7.841542] __icc_enable (drivers/interconnect/core.c:685 (discriminator 7)) +[7.841545] icc_disable (drivers/interconnect/core.c:708) +[7.841547] geni_icc_disable (drivers/soc/qcom/qcom-geni-se.c:862) +[7.841553] spi_geni_runtime_suspend+0x3c/0x4c spi_geni_qcom + +This occurs when the spi-geni driver receives an -EPROBE_DEFER error +from spi_geni_grab_gpi_chan(), causing devres to start releasing all +resources as shown below: + +[7.138679] geni_spi 880000.spi: DEVRES REL ffff800081443800 devm_icc_release (8 bytes) +[7.138751] geni_spi 880000.spi: DEVRES REL ffff800081443800 devm_icc_release (8 bytes) +[7.138827] geni_spi 880000.spi: DEVRES REL ffff800081443800 pm_runtime_disable_action (16 bytes) +[7.139494] geni_spi 880000.spi: DEVRES REL ffff800081443800 devm_pm_opp_config_release (16 bytes) +[7.139512] geni_spi 880000.spi: DEVRES REL ffff800081443800 devm_spi_release_controller (8 bytes) +[7.139516] geni_spi 880000.spi: DEVRES REL ffff800081443800 devm_clk_release (16 bytes) +[7.139519] geni_spi 880000.spi: DEVRES REL ffff800081443800 devm_ioremap_release (8 bytes) +[7.139524] geni_spi 880000.spi: DEVRES REL ffff800081443800 devm_region_release (24 bytes) +[7.139527] geni_spi 880000.spi: DEVRES REL ffff800081443800 devm_kzalloc_release (22 bytes) +[7.139530] geni_spi 880000.spi: DEVRES REL ffff800081443800 devm_pinctrl_release (8 bytes) +[7.139539] geni_spi 880000.spi: DEVRES REL ffff800081443800 devm_kzalloc_release (40 bytes) + +The issue here is that pm_runtime_disable_action() results in a call to +spi_geni_runtime_suspend(), which attempts to suspend the device and +disable an interconnect path that devm_icc_release() has just released. + +Resolve this by calling geni_icc_get() before enabling runtime PM. This +approach ensures that when devres releases resources in reverse order, +it will start with pm_runtime_disable_action(), suspending the device, +and then proceed to free the remaining resources. + +Reported-by: Naresh Kamboju +Reported-by: Linux Kernel Functional Testing +Closes: https://lore.kernel.org/r/CA+G9fYtsjFtddG8i+k-SpV8U6okL0p4zpsTiwGfNH5GUA8dWAA@mail.gmail.com +Fixes: 89e362c883c6 ("spi: geni-qcom: Undo runtime PM changes at driver exit time") +Signed-off-by: Georgi Djakov +Link: https://patch.msgid.link/20241008231615.430073-1-djakov@kernel.org +Signed-off-by: Mark Brown +Signed-off-by: Sasha Levin +--- + drivers/spi/spi-geni-qcom.c | 8 +++++--- + 1 file changed, 5 insertions(+), 3 deletions(-) + +diff --git a/drivers/spi/spi-geni-qcom.c b/drivers/spi/spi-geni-qcom.c +index 6f4057330444d..fa967be4f9a17 100644 +--- a/drivers/spi/spi-geni-qcom.c ++++ b/drivers/spi/spi-geni-qcom.c +@@ -1108,6 +1108,11 @@ static int spi_geni_probe(struct platform_device *pdev) + init_completion(&mas->tx_reset_done); + init_completion(&mas->rx_reset_done); + spin_lock_init(&mas->lock); ++ ++ ret = geni_icc_get(&mas->se, NULL); ++ if (ret) ++ return ret; ++ + pm_runtime_use_autosuspend(&pdev->dev); + pm_runtime_set_autosuspend_delay(&pdev->dev, 250); + ret = devm_pm_runtime_enable(dev); +@@ -1117,9 +1122,6 @@ static int spi_geni_probe(struct platform_device *pdev) + if (device_property_read_bool(&pdev->dev, "spi-slave")) + spi->target = true; + +- ret = geni_icc_get(&mas->se, NULL); +- if (ret) +- return ret; + /* Set the bus quota to a reasonable value for register access */ + mas->se.icc_paths[GENI_TO_CORE].avg_bw = Bps_to_icc(CORE_2X_50_MHZ); + mas->se.icc_paths[CPU_TO_GENI].avg_bw = GENI_DEFAULT_BW; +-- +2.43.0 +