7.3.6-rc1 review
Subsystems (4)
Greg Kroah-Hartman
maintainerPATCH 1752/2651 clk: qcom: rcg2: Clear force enable after rate failure
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Konrad Dybcio <[email protected]>
[ Upstream commit d4e8c6b9aef42d06cf5755543ad10097b2217990 ]
Shared RCG rate changes assert force-enable before programming the new configuration. If programming fails, the function returns without clearing force-enable, leaving the root running while CCF can release temporary parent and resource references.
Attempt to clear force-enable on the configuration error path before returning the original programming error. This restores the same cleanup performed after a successful configuration while preserving the primary failure for callers.
--- drivers/clk/qcom/clk-rcg2.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/clk/qcom/clk-rcg2.c +3 -1
@@ -1364,8 +1364,10 @@ clk_rcg2_shared_force_enable_clear(struct clk_hw *hw, const struct freq_tbl *f)return ret; ret =clk_rcg2_configure (rcg, f); -if (ret) +if (ret) { +clk_rcg2_clear_force_enable (hw);return ret; + }return clk_rcg2_clear_force_enable (hw); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1753/2651 clk: qcom: Fix camera rivian PLL configuration settings
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jagadeesh Kona <[email protected]>
[ Upstream commit 6666c03f2348886774d6441350fbe0e7a782f471 ]
clk_alpha_pll_write_config() in the PLL configure function skips writes to PLL registers when the configured value is 0. However, hardware requires USER_CTL_U and CONFIG_CTL_U2 to be explicitly programmed to 0 for a few rivian PLLs.
Add a clk_regs_configure() callback to ensure these rivian PLL registers are correctly initialized on Glymur, SM8750, and Kaanapali platforms.
--- drivers/clk/qcom/cambistmclkcc-kaanapali.c | 7 +++++++ drivers/clk/qcom/cambistmclkcc-sm8750.c | 7 +++++++ drivers/clk/qcom/camcc-glymur.c | 7 +++++++ 3 files changed, 21 insertions(+)
drivers/clk/qcom/cambistmclkcc-kaanapali.c +7 -0
@@ -394,11 +394,18 @@ static const struct regmap_config cam_bist_mclk_cc_kaanapali_regmap_config = { .fast_io = true, }; +static void cam_bist_mclk_cc_kaanapali_regs_configure (struct device *dev,struct regmap *regmap) +{ +regmap_write (regmap,0x18 ,0 );/* CAM_BIST_MCLK_CC_PLL0_USER_CTL_U */ +regmap_write (regmap,0x28 ,0 );/* CAM_BIST_MCLK_CC_PLL0_CONFIG_CTL_U2 */ +} +static const struct qcom_cc_driver_data cam_bist_mclk_cc_kaanapali_driver_data = { .alpha_plls = cam_bist_mclk_cc_kaanapali_plls, .num_alpha_plls =ARRAY_SIZE (cam_bist_mclk_cc_kaanapali_plls), .clk_cbcrs = cam_bist_mclk_cc_kaanapali_critical_cbcrs, .num_clk_cbcrs =ARRAY_SIZE (cam_bist_mclk_cc_kaanapali_critical_cbcrs), + .clk_regs_configure = cam_bist_mclk_cc_kaanapali_regs_configure, };static const struct qcom_cc_desc cam_bist_mclk_cc_kaanapali_desc = {
drivers/clk/qcom/cambistmclkcc-sm8750.c +7 -0
@@ -413,11 +413,18 @@ static const struct regmap_config cam_bist_mclk_cc_sm8750_regmap_config = { .fast_io = true, }; +static void cam_bist_mclk_cc_sm8750_regs_configure (struct device *dev,struct regmap *regmap) +{ +regmap_write (regmap,0x18 ,0 );/* CAM_BIST_MCLK_CC_PLL0_USER_CTL_U */ +regmap_write (regmap,0x28 ,0 );/* CAM_BIST_MCLK_CC_PLL0_CONFIG_CTL_U2 */ +} +static const struct qcom_cc_driver_data cam_bist_mclk_cc_sm8750_driver_data = { .alpha_plls = cam_bist_mclk_cc_sm8750_plls, .num_alpha_plls =ARRAY_SIZE (cam_bist_mclk_cc_sm8750_plls), .clk_cbcrs = cam_bist_mclk_cc_sm8750_critical_cbcrs, .num_clk_cbcrs =ARRAY_SIZE (cam_bist_mclk_cc_sm8750_critical_cbcrs), + .clk_regs_configure = cam_bist_mclk_cc_sm8750_regs_configure, };static const struct qcom_cc_desc cam_bist_mclk_cc_sm8750_desc = {
drivers/clk/qcom/camcc-glymur.c +7 -0
@@ -2235,11 +2235,18 @@ static const struct regmap_config cam_cc_glymur_regmap_config = { .fast_io = true, }; +static void cam_cc_glymur_regs_configure (struct device *dev,struct regmap *regmap) +{ +regmap_write (regmap,0x2018 ,0 );/* CAM_CC_PLL2_PLL_USER_CTL_U */ +regmap_write (regmap,0x2028 ,0 );/* CAM_CC_PLL2_PLL_CONFIG_CTL_U2 */ +} +static const struct qcom_cc_driver_data cam_cc_glymur_driver_data = { .alpha_plls = cam_cc_glymur_plls, .num_alpha_plls =ARRAY_SIZE (cam_cc_glymur_plls), .clk_cbcrs = cam_cc_glymur_critical_cbcrs, .num_clk_cbcrs =ARRAY_SIZE (cam_cc_glymur_critical_cbcrs), + .clk_regs_configure = cam_cc_glymur_regs_configure, };static const struct qcom_cc_desc cam_cc_glymur_desc = {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1754/2651 iomap: follow the alignment requirement for iomap_dio_hole_iter()
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qu Wenruo <[email protected]>
[ Upstream commit 4025185cf953e3f52ab63cf5fec50c1485ee7bb7 ]
[BUG]
On the latest development branch, btrfs with 8K block size on 4K page sized systems will fail all test cases that run fsstress.
One very short example would be:
# $fsstress -n 4 -d $mnt -s 1785675805 -v
0/0: dwrite - no filename
0/1: creat f0 x:0 0 0
0/1: creat add id=0,parent=-1
0/2: write dontcache f0[259 1 0 0 0 0] [816411,3620] 0
0/3: dread - xfsctl(XFS_IOC_DIOINFO) f0[259 1 0 0 32 820031] return 25, fallback to stat() 0/3: dread f0[259 1 0 0 32 820031] [483328,81920] 0
Which triggered the following ASSERT():
assertion failed: IS_ALIGNED(state->start, blocksize) && IS_ALIGNED(state->end + 1, blocksize), in fs/btrfs/extent-io-tree.c:346 (unaligned extent state, blocksize=8192 start=487424 end=565247 state=0x0)
------------[ cut here ]------------ kernel BUG at fs/btrfs/extent-io-tree.c:346! Oops: invalid opcode: 0000 [#1] SMP CPU: 4 UID: 0 PID: 648 Comm: fsstress Tainted: G E 7.2.0-rc5-custom+ #431 PREEMPT(full) 7c507bd40d65e4d871e698b22d80f1306bbec543 Tainted: [E]=UNSIGNED_MODULE Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS unknown 02/02/2022 RIP: 0010:validate_extent_state.part.0.isra.0.cold+0x24/0x26 [btrfs] Call Trace: <TASK> insert_state+0x34/0x1a0 [btrfs 6924944583e4bc91a7c5183a1e7908e745a9b0c8] set_extent_bit+0x440/0x8d0 [btrfs 6924944583e4bc91a7c5183a1e7908e745a9b0c8] btrfs_lock_extent_bits+0x58/0x380 [btrfs 6924944583e4bc91a7c5183a1e7908e745a9b0c8] btrfs_dio_iomap_begin+0x319/0xb70 [btrfs 6924944583e4bc91a7c5183a1e7908e745a9b0c8] iomap_iter+0x1a2/0x370 __iomap_dio_rw+0x236/0x8d0 iomap_dio_rw+0x12/0x30 btrfs_direct_read+0x15f/0x290 [btrfs 6924944583e4bc91a7c5183a1e7908e745a9b0c8] btrfs_file_read_iter+0x42/0x90 [btrfs 6924944583e4bc91a7c5183a1e7908e745a9b0c8] vfs_read+0x25e/0x380 ksys_read+0x73/0xe0 do_syscall_64+0xe1/0x790 entry_SYSCALL_64_after_hwframe+0x4b/0x53 RIP: 0033:0x7fc3f129318e </TASK>
[CAUSE]iomap_dio_hole_iter() is responsible for zeroing out the buffer for a hole, which calls iov_iter_zero() to zero the range.
However btrfs disables page fault during its __iomap_dio_rw() call, so iov_iter_zero() can fail at any page boundary.
When the fs block size is larger than page size, iov_iter_zero() may only have zeroed one page, which is not aligned to the fs block size.
Such one page long range is passed back to btrfs, which triggers the above ASSERT().
[FIX]
For iomap_dio_hole_iter() round down the copied length, and revert any excessive range that is beyond the aligned copied length. Also use @aligned_copied for the size increment and iter advancement.
This should only affect btrfs, which is the only fs utilizing iomap dio with page fault disabled.
--- fs/iomap/direct-io.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
fs/iomap/direct-io.c +11 -4
@@ -589,12 +589,19 @@ static int iomap_dio_bio_iter(struct iomap_iter *iter, struct iomap_dio *dio)static int iomap_dio_hole_iter (struct iomap_iter *iter,struct iomap_dio *dio) { -loff_t length =iov_iter_zero (iomap_length (iter), dio->submit.iter); +loff_t copied =iov_iter_zero (iomap_length (iter), dio->submit.iter); +unsigned int bs =i_blocksize (iter->inode); +loff_t aligned_copied =round_down (copied, bs); - dio->size += length; -if (!length) +/* +* If fs block size is larger than page size, page fault failure +* can cause @copied to be page aligned but not fs block aligned. +*/ +iov_iter_revert (dio->submit.iter, copied - aligned_copied); + dio->size += aligned_copied; +if (!aligned_copied)return -EFAULT ; -return iomap_iter_advance (iter, length); +return iomap_iter_advance (iter, aligned_copied); }static int iomap_dio_inline_iter (struct iomap_iter *iomi,struct iomap_dio *dio)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1755/2651 s390/ptrace: Preserve ILC when updating system call number
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Heiko Carstens <[email protected]>
[ Upstream commit 946b9dcff33bd4669464674ae1c00683b875be55 ]
When an attached debugger changes gpr2 via PTRACE_POKEUSR while the traced process has PIF_SYSCALL set, the int_code in pt_regs is also updated. In case of an svc it contains the instruction length code (ILC), as well as the system call number.
The ptrace code sets the ILC unconditionally to a value which matches the svc instruction. However the svc instruction also may have been executed via the execute or execute relative long instruction, which have a different length. Therefore preserve the ILC and only change the system call number using syscall_set_nr().
This makes sure that in case of a PSW rewind the instruction address points to the correct instruction.
--- arch/s390/kernel/ptrace.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
arch/s390/kernel/ptrace.c +4 -5
@@ -34,6 +34,7 @@#include <asm/ptrace.h> #include <asm/rwonce.h> #include <asm/fpu.h> +#include <asm/syscall.h> #include "entry.h"
@@ -345,11 +346,9 @@ static int __poke_user(struct task_struct *child, addr_t addr, addr_t data)return -EINVAL ; } -if (test_pt_regs_flag (regs,PIF_SYSCALL ) && - addr == offsetof(struct user, regs.gprs[2])) { -struct pt_regs *regs =task_pt_regs (child); - - regs->int_code =0x20000 | (data &0xffff ); + if (addr == offsetof(struct user, regs.gprs[2])) { +if (test_pt_regs_flag (regs,PIF_SYSCALL )) +syscall_set_nr (child, regs, data); } *(addr_t *)((addr_t ) ®s->psw + addr) = data; } else if (addr < offsetof(struct user, regs.orig_gpr2)) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1756/2651 s390/uprobes: Fix off-by-one bug in emulated PER handling
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Heiko Carstens <[email protected]>
[ Upstream commit 2ba01cf7b2598571486425a0605f1434909b532d ]
The uprobes code emulates some instructions, and with that also PER storage-alteration handling, in case a debugger is attached.
The PER storage-alteration handling contains an off-by-one bug, which may lead to PER traps which should not happen. Adjust the comparison in sim_stor_event() to fix that.
--- arch/s390/kernel/uprobes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/s390/kernel/uprobes.c +1 -1
@@ -241,7 +241,7 @@ static void sim_stor_event(struct pt_regs *regs, void *addr, int len)return ;if (!(current->thread.per_user.control &PER_EVENT_STORE ))return ; -if ((void *)current->thread.per_user.start > (addr + len)) +if ((void *)current->thread.per_user.start > (addr + len -1 ))return ;if ((void *)current->thread.per_user.end < addr)return ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1757/2651 s390/early: Fix early warning handling
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Heiko Carstens <[email protected]>
[ Upstream commit 646dc01d634bc182529d7cd5f5346869aa7d58ee ]
When adding support for __WARN_printf() the early program check handler was not taken into account. Add the missing support to the early program check handler. This avoids that the kernel crashes instead of printing a warning.
--- arch/s390/kernel/early.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
arch/s390/kernel/early.c +12 -3
@@ -153,16 +153,25 @@ static __init void setup_topology(void)void __init __do_early_pgm_check (struct pt_regs *regs) {struct lowcore *lc =get_lowcore (); -unsigned long ip; regs->int_code = lc->pgm_int_code; regs->int_parm_long = lc->trans_exc_code; regs->last_break = lc->pgm_last_break; - ip =__rewind_psw (regs->psw, regs->int_code >>16 ); + regs->monitor_code = lc->monitor_code;/* Monitor Event? Might be a warning */ if ((regs->int_code &PGM_INT_CODE_MASK ) ==0x40 ) { -if (report_bug (ip, regs) ==BUG_TRAP_TYPE_WARN ) +enum bug_trap_type btt; +unsigned long ip; + +if (regs->monitor_code ==MONCODE_BUG_ARG ) { + regs->psw.addr = regs->gprs[14 ]; + btt =report_bug_entry ((struct bug_entry *)regs->gprs[2 ], regs); + }else { + ip =__rewind_psw (regs->psw, regs->int_code >>16 ); + btt =report_bug (ip, regs); + } +if (btt ==BUG_TRAP_TYPE_WARN )return ; }if (fixup_exception (regs))
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1758/2651 s390/percpu: Add sanity check to GEN_MVIY macro
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Heiko Carstens <[email protected]>
[ Upstream commit 965869bd2a4f2df44c84fc44f2d2038d14b45978 ]
Emit an error if the GEN_MVIY macro fails to parse the passed register string. This will make it more obvious if something similar which was fixed with [1] happens again.
[1] commit 101782f8945a ("s390/percpu: Fix MVIY_PERCPU() with older binutils")
Stable-dep-of: 10f9cf286ec3 ("s390/percpu: Use asm_inline for arch_this_cpu_add()")
--- arch/s390/include/asm/percpu.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
arch/s390/include/asm/percpu.h +7 -2
@@ -100,12 +100,17 @@*/ #define MVIY_PERCPU (disp, dispalt, reg) \ - ".macro GEN_MVIY disp reg\n" \ + ".macro GEN_MVIY disp, reg\n" \ + ".set .Lreg,255\n" \ ".irp rs,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15\n" \ " .ifc \\reg,%%r\\rs\n" \ - " mviy \\disp(%%r0),\\rs\n" \ + " .set .Lreg,\\rs\n" \ " .endif\n" \ ".endr\n" \ + ".if .Lreg == 255\n" \ + " .error \"Illegal register number\"\n" \ + ".endif\n" \ + "mviy \\disp(%%r0),.Lreg\n" \ ".endm\n" \ ALTERNATIVE("GEN_MVIY " disp ", " reg "\n", \ "GEN_MVIY " dispalt ", " reg "\n", \
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1759/2651 s390/percpu: Let MVIY_PERCPU() calculate alternative displacement
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Heiko Carstens <[email protected]>
[ Upstream commit d6fe39764bd690949ae640c49164cca07b99d7c9 ]
Let MVIY_PERCPU() calculate the alternative lowcore displacement instead of passing the same value(s) again and again in all percpu inline assemblies.
This shortens the inline assemblies and makes them a bit more readable.
Stable-dep-of: 10f9cf286ec3 ("s390/percpu: Use asm_inline for arch_this_cpu_add()")
--- arch/s390/include/asm/percpu.h | 68 +++++++++++++++------------------- 1 file changed, 29 insertions(+), 39 deletions(-)
arch/s390/include/asm/percpu.h +29 -39
@@ -99,7 +99,9 @@* MVIY_ALT(...) <- end of percpu code section */ -#define MVIY_PERCPU (disp, dispalt, reg) \ +#define LC_ALT_ADDR __stringify(LOWCORE_ALT_ADDRESS) + +#define MVIY_PERCPU (disp, reg) \ ".macro GEN_MVIY disp, reg\n" \ ".set .Lreg,255\n" \ ".irp rs,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15\n" \
@@ -112,19 +114,19 @@".endif\n" \"mviy \\disp(%%r0),.Lreg\n" \".endm\n" \ -ALTERNATIVE ("GEN_MVIY " disp", " reg"\n" , \ -"GEN_MVIY " dispalt", " reg"\n" , \ +ALTERNATIVE ("GEN_MVIY " disp" , " reg"\n" , \ +"GEN_MVIY " disp"+" LC_ALT_ADDR " , " reg"\n" , \ ALT_FEATURE(MFEATURE_LOWCORE)) \ ".purgem GEN_MVIY\n" -#define MVIY_ALT (disp, dispalt) \ - ALTERNATIVE(" mviy " disp "(%%r0),0\n", \ - " mviy " dispalt "(%%r0),0\n", \ +#define MVIY_ALT (disp) \ + ALTERNATIVE(" mviy " disp "(%%r0),0\n", \ + " mviy " disp "+" LC_ALT_ADDR "(%%r0),0\n", \ ALT_FEATURE(MFEATURE_LOWCORE)) -#define AG_ALT (disp, dispalt, reg) \ - ALTERNATIVE(" ag " reg ", " disp "(%%r0)\n", \ - " ag " reg ", " dispalt "(%%r0)\n", \ +#define AG_ALT (disp, reg) \ + ALTERNATIVE(" ag " reg ", " disp "(%%r0)\n", \ + " ag " reg ", " disp "+" LC_ALT_ADDR "(%%r0)\n", \ ALT_FEATURE(MFEATURE_LOWCORE))#ifndef MARCH_HAS_Z196_FEATURES
@@ -153,33 +155,29 @@ do { \if (__builtin_constant_p (val__) && \ ((szcast )val__ >-129 ) && ((szcast )val__ <128 )) { \ asmvolatile ( \ - MVIY_PERCPU("%[disppcpr]", "%[dispaltpcpr]", "%[ptr__]")\ - AG_ALT("%[disppcpo]", "%[dispaltpcpo]", "%[ptr__]") \ + MVIY_PERCPU("%[disppcpr]","%[ptr__]") \ + AG_ALT("%[disppcpo]", "%[ptr__]") \ op2" 0(%[ptr__]),%[val__]\n" \ - MVIY_ALT("%[disppcpr]", "%[dispaltpcpr]") \ +MVIY_ALT ("%[disppcpr]" ) \ : [ptr__] "+&a" (ptr__), "+m" (*ptr__), \ "=m" (((struct lowcore *)0)->percpu_register) \ : [val__] "i" ((szcast)val__), \ [disppcpr] "i" (lc_pcpr), \ [disppcpo] "i" (lc_pcpo), \ - [dispaltpcpr] "i" (lc_pcpr + LOWCORE_ALT_ADDRESS), \ - [dispaltpcpo] "i" (lc_pcpo + LOWCORE_ALT_ADDRESS), \ "m" (((struct lowcore *)0)->percpu_offset) \ : "cc"); \ } else { \ asm volatile( \ - MVIY_PERCPU("%[disppcpr]", "%[dispaltpcpr]", "%[ptr__]")\ - AG_ALT("%[disppcpo]", "%[dispaltpcpo]", "%[ptr__]") \ + MVIY_PERCPU("%[disppcpr]", "%[ptr__]") \ + AG_ALT("%[disppcpo]", "%[ptr__]") \ op1 " %[old__],%[val__],0(%[ptr__])\n" \ - MVIY_ALT("%[disppcpr]", "%[dispaltpcpr]") \ +MVIY_ALT ("%[disppcpr]" ) \ : [old__] "=&d" (old__), \ [ptr__] "+&a" (ptr__), "+m" (*ptr__), \ "=m" (((struct lowcore *)0)->percpu_register) \: [val__] " d" (val__), \ [disppcpr] " i" (lc_pcpr), \ [disppcpo] " i" (lc_pcpo), \ -[dispaltpcpr] " i" (lc_pcpr + LOWCORE_ALT_ADDRESS), \ -[dispaltpcpo] " i" (lc_pcpo + LOWCORE_ALT_ADDRESS), \ " m" (((struct lowcore *)0)->percpu_offset) \ : " cc"); \ } \
@@ -199,18 +197,16 @@ do { \ lc_pcpo = offsetof(struct lowcore , percpu_offset); \ ptr__ =PERCPU_PTR (&(pcp)); \ asm_inline volatile( \ - MVIY_PERCPU("%[disppcpr]", "%[dispaltpcpr]", "%[ptr__]")\ - AG_ALT("%[disppcpo]", "%[dispaltpcpo]", "%[ptr__]") \ + MVIY_PERCPU("%[disppcpr]","%[ptr__]") \ + AG_ALT("%[disppcpo]","%[ptr__]") \ op " %[old__],%[val__],0(%[ptr__])\n" \ -MVIY_ALT ("%[disppcpr]" ,"%[dispaltpcpr]" ) \ +MVIY_ALT ("%[disppcpr]" ) \ : [old__] "=&d" (old__), \ [ptr__] "+&a" (ptr__), "+m" (*ptr__), \ "=m" (((struct lowcore *)0)->percpu_register) \: [val__] " d" (val__), \ [disppcpr] " i" (lc_pcpr), \ [disppcpo] " i" (lc_pcpo), \ -[dispaltpcpr] " i" (lc_pcpr + LOWCORE_ALT_ADDRESS), \ -[dispaltpcpo] " i" (lc_pcpo + LOWCORE_ALT_ADDRESS), \ " m" (((struct lowcore *)0)->percpu_offset) \ : " cc"); \ old__ + val__; \
@@ -230,18 +226,16 @@ do { \ lc_pcpo = offsetof(struct lowcore , percpu_offset); \ ptr__ =PERCPU_PTR (&(pcp)); \ asm_inline volatile( \ - MVIY_PERCPU("%[disppcpr]", "%[dispaltpcpr]", "%[ptr__]")\ - AG_ALT("%[disppcpo]", "%[dispaltpcpo]", "%[ptr__]") \ + MVIY_PERCPU("%[disppcpr]","%[ptr__]") \ + AG_ALT("%[disppcpo]","%[ptr__]") \ op " %[old__],%[val__],0(%[ptr__])\n" \ -MVIY_ALT ("%[disppcpr]" ,"%[dispaltpcpr]" ) \ +MVIY_ALT ("%[disppcpr]" ) \ : [old__] "=&d" (old__), \ [ptr__] "+&a" (ptr__), "+m" (*ptr__), \ "=m" (((struct lowcore *)0)->percpu_register) \: [val__] " d" (val__), \ [disppcpr] " i" (lc_pcpr), \ [disppcpo] " i" (lc_pcpo), \ -[dispaltpcpr] " i" (lc_pcpr + LOWCORE_ALT_ADDRESS), \ -[dispaltpcpo] " i" (lc_pcpo + LOWCORE_ALT_ADDRESS), \ " m" (((struct lowcore *)0)->percpu_offset) \ : " cc"); \ } while (0)
@@ -263,16 +257,14 @@ do { \ lc_pcpo = offsetof(struct lowcore , percpu_offset); \ ptr__ =PERCPU_PTR (&(pcp)); \ asm_inline volatile( \ - MVIY_PERCPU("%[disppcpr]", "%[dispaltpcpr]", "%[ptr__]")\ - AG_ALT("%[disppcpo]", "%[dispaltpcpo]", "%[ptr__]") \ + MVIY_PERCPU("%[disppcpr]","%[ptr__]") \ + AG_ALT("%[disppcpo]","%[ptr__]") \ op " %[res__],0(%[ptr__])\n" \ -MVIY_ALT ("%[disppcpr]" ,"%[dispaltpcpr]" ) \ +MVIY_ALT ("%[disppcpr]" ) \ : [res__] "=&d" (res__), [ptr__] "+&a" (ptr__), \" =m" (((struct lowcore *)0)->percpu_register) \ : [disppcpr] " i" (lc_pcpr), \ [disppcpo] " i" (lc_pcpo), \ -[dispaltpcpr] " i" (lc_pcpr + LOWCORE_ALT_ADDRESS), \ -[dispaltpcpo] " i" (lc_pcpo + LOWCORE_ALT_ADDRESS), \ " m" (*ptr__), \ " m" (((struct lowcore *)0)->percpu_offset) \ : " cc"); \
@@ -294,17 +286,15 @@ do { \ lc_pcpo = offsetof(struct lowcore , percpu_offset); \ ptr__ =PERCPU_PTR (&(pcp)); \ asm_inline volatile( \ - MVIY_PERCPU("%[disppcpr]", "%[dispaltpcpr]", "%[ptr__]")\ - AG_ALT("%[disppcpo]", "%[dispaltpcpo]", "%[ptr__]") \ + MVIY_PERCPU("%[disppcpr]","%[ptr__]") \ + AG_ALT("%[disppcpo]","%[ptr__]") \ op " %[val__],0(%[ptr__])\n" \ -MVIY_ALT ("%[disppcpr]" ,"%[dispaltpcpr]" ) \ +MVIY_ALT ("%[disppcpr]" ) \ : [ptr__] "+&a" (ptr__), "=m" (*ptr__), \ "=m" (((struct lowcore *)0)->percpu_register) \ : [val__] "d" (val__), \[disppcpr] " i" (lc_pcpr), \ [disppcpo] " i" (lc_pcpo), \ -[dispaltpcpr] " i" (lc_pcpr + LOWCORE_ALT_ADDRESS), \ -[dispaltpcpo] " i" (lc_pcpo + LOWCORE_ALT_ADDRESS), \ " m" (((struct lowcore *)0)->percpu_offset) \ : " cc"); \ } while (0)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1760/2651 s390/percpu/lowcore: Add and use LC_PERCPU lowcore offset defines
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Heiko Carstens <[email protected]>
[ Upstream commit 301e3a0776511ed60cca1f7d4b14b6b44827c6f4 ]
Define LC_PERCPU_OFFSET and LC_PERCPU_REGISTER offset defines and use them in percpu code. This shortens the percpu inline assemblies and makes them a bit more readable.
Note that because of header dependencies it is not possible to use asm-offsets. However to avoid adding more dependencies to asm-offsets it seems to be preferable to use the current approach in any way.
Stable-dep-of: 10f9cf286ec3 ("s390/percpu: Use asm_inline for arch_this_cpu_add()")
--- arch/s390/include/asm/entry-percpu.h | 2 +- arch/s390/include/asm/lowcore.h | 3 ++ arch/s390/include/asm/percpu.h | 47 ++++++++++------------------ 3 files changed, 20 insertions(+), 32 deletions(-)
arch/s390/include/asm/entry-percpu.h +1 -1
@@ -49,7 +49,7 @@ static __always_inline bool percpu_code_check(struct pt_regs *regs) }if ((insn &0xff0f ) !=0xe300 )return true; - disp = offsetof(struct lowcore , percpu_offset); + disp =LC_PERCPU_OFFSET ;if (machine_has_relocated_lowcore ()) disp +=LOWCORE_ALT_ADDRESS ; insn = (disp &0xff000 ) >>4 | (disp &0x00fff ) <<16 |0x8 ;
arch/s390/include/asm/lowcore.h +3 -0
@@ -222,6 +222,9 @@ struct lowcore {__u8 pad_0x1900[0x2000 -0x1900 ];/* 0x1900 */ } __packed__aligned(8192) ; +#define LC_PERCPU_OFFSET offsetof(struct lowcore, percpu_offset) +#define LC_PERCPU_REGISTER offsetof(struct lowcore, percpu_register) + static __always_inline struct lowcore *get_lowcore(void) {struct lowcore *lc;
arch/s390/include/asm/percpu.h +16 -31
144 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1761/2651 s390/percpu: Rename inline assembly symbolic names
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Heiko Carstens <[email protected]>
[ Upstream commit 02a8ff0f894f6960d5d5fb47169140a1ae5c024d ]
Rename percpu inline assembly symbolic names so they match (more) what is specified with input operands. A trivial change which is supposed to make the code a bit more readable.
Stable-dep-of: 10f9cf286ec3 ("s390/percpu: Use asm_inline for arch_this_cpu_add()")
--- arch/s390/include/asm/percpu.h | 60 +++++++++++++++++----------------- 1 file changed, 30 insertions(+), 30 deletions(-)
arch/s390/include/asm/percpu.h +30 -30
@@ -151,29 +151,29 @@ do { \if (__builtin_constant_p (val__) && \ ((szcast )val__ >-129 ) && ((szcast )val__ <128 )) { \ asmvolatile ( \ - MVIY_PERCPU("%[disppcpr]","%[ptr__]") \ - AG_ALT("%[disppcpo]", "%[ptr__]") \ + MVIY_PERCPU("%[lcreg]","%[ptr__]") \ + AG_ALT("%[lcoff]", "%[ptr__]") \ op2" 0(%[ptr__]),%[val__]\n" \ -MVIY_ALT ("%[disppcpr]" ) \ +MVIY_ALT ("%[lcreg]" ) \ : [ptr__] "+&a" (ptr__), "+m" (*ptr__), \ "=m" (((struct lowcore *)0)->percpu_register) \ : [val__] "i" ((szcast)val__), \ - [disppcpr] "i" (LC_PERCPU_REGISTER), \ - [disppcpo] "i" (LC_PERCPU_OFFSET), \ + [lcreg] "i" (LC_PERCPU_REGISTER), \ + [lcoff] "i" (LC_PERCPU_OFFSET), \ "m" (((struct lowcore *)0)->percpu_offset) \ : "cc"); \ } else { \ asm volatile( \ - MVIY_PERCPU("%[disppcpr]", "%[ptr__]") \ - AG_ALT("%[disppcpo]", "%[ptr__]") \ + MVIY_PERCPU("%[lcreg]", "%[ptr__]") \ + AG_ALT("%[lcoff]", "%[ptr__]") \ op1 " %[old__],%[val__],0(%[ptr__])\n" \ -MVIY_ALT ("%[disppcpr]" ) \ +MVIY_ALT ("%[lcreg]" ) \ : [old__] "=&d" (old__), \ [ptr__] "+&a" (ptr__), "+m" (*ptr__), \ "=m" (((struct lowcore *)0)->percpu_register) \: [val__] " d" (val__), \ -[disppcpr] " i" (LC_PERCPU_REGISTER), \ -[disppcpo] " i" (LC_PERCPU_OFFSET), \ +[lcreg] " i" (LC_PERCPU_REGISTER), \ +[lcoff] " i" (LC_PERCPU_OFFSET), \ " m" (((struct lowcore *)0)->percpu_offset) \ : " cc"); \ } \
@@ -190,16 +190,16 @@ do { \ \ ptr__ =PERCPU_PTR (&(pcp)); \ asm_inline volatile( \ - MVIY_PERCPU("%[disppcpr]","%[ptr__]") \ - AG_ALT("%[disppcpo]","%[ptr__]") \ + MVIY_PERCPU("%[lcreg]","%[ptr__]") \ + AG_ALT("%[lcoff]","%[ptr__]") \ op " %[old__],%[val__],0(%[ptr__])\n" \ -MVIY_ALT ("%[disppcpr]" ) \ +MVIY_ALT ("%[lcreg]" ) \ : [old__] "=&d" (old__), \ [ptr__] "+&a" (ptr__), "+m" (*ptr__), \ "=m" (((struct lowcore *)0)->percpu_register) \: [val__] " d" (val__), \ -[disppcpr] " i" (LC_PERCPU_REGISTER), \ -[disppcpo] " i" (LC_PERCPU_OFFSET), \ +[lcreg] " i" (LC_PERCPU_REGISTER), \ +[lcoff] " i" (LC_PERCPU_OFFSET), \ " m" (((struct lowcore *)0)->percpu_offset) \ : " cc"); \ old__ + val__; \
@@ -216,16 +216,16 @@ do { \ \ ptr__ =PERCPU_PTR (&(pcp)); \ asm_inline volatile( \ - MVIY_PERCPU("%[disppcpr]","%[ptr__]") \ - AG_ALT("%[disppcpo]","%[ptr__]") \ + MVIY_PERCPU("%[lcreg]","%[ptr__]") \ + AG_ALT("%[lcoff]","%[ptr__]") \ op " %[old__],%[val__],0(%[ptr__])\n" \ -MVIY_ALT ("%[disppcpr]" ) \ +MVIY_ALT ("%[lcreg]" ) \ : [old__] "=&d" (old__), \ [ptr__] "+&a" (ptr__), "+m" (*ptr__), \ "=m" (((struct lowcore *)0)->percpu_register) \: [val__] " d" (val__), \ -[disppcpr] " i" (LC_PERCPU_REGISTER), \ -[disppcpo] " i" (LC_PERCPU_OFFSET), \ +[lcreg] " i" (LC_PERCPU_REGISTER), \ +[lcoff] " i" (LC_PERCPU_OFFSET), \ " m" (((struct lowcore *)0)->percpu_offset) \ : " cc"); \ } while (0)
@@ -245,14 +245,14 @@ do { \ \ ptr__ =PERCPU_PTR (&(pcp)); \ asm_inline volatile( \ - MVIY_PERCPU("%[disppcpr]","%[ptr__]") \ - AG_ALT("%[disppcpo]","%[ptr__]") \ + MVIY_PERCPU("%[lcreg]","%[ptr__]") \ + AG_ALT("%[lcoff]","%[ptr__]") \ op " %[res__],0(%[ptr__])\n" \ -MVIY_ALT ("%[disppcpr]" ) \ +MVIY_ALT ("%[lcreg]" ) \ : [res__] "=&d" (res__), [ptr__] "+&a" (ptr__), \" =m" (((struct lowcore *)0)->percpu_register) \ -: [disppcpr] " i" (LC_PERCPU_REGISTER), \ -[disppcpo] " i" (LC_PERCPU_OFFSET), \ +: [lcreg] " i" (LC_PERCPU_REGISTER), \ +[lcoff] " i" (LC_PERCPU_OFFSET), \ " m" (*ptr__), \ " m" (((struct lowcore *)0)->percpu_offset) \ : " cc"); \
@@ -271,15 +271,15 @@ do { \ \ ptr__ =PERCPU_PTR (&(pcp)); \ asm_inline volatile( \ - MVIY_PERCPU("%[disppcpr]","%[ptr__]") \ - AG_ALT("%[disppcpo]","%[ptr__]") \ + MVIY_PERCPU("%[lcreg]","%[ptr__]") \ + AG_ALT("%[lcoff]","%[ptr__]") \ op " %[val__],0(%[ptr__])\n" \ -MVIY_ALT ("%[disppcpr]" ) \ +MVIY_ALT ("%[lcreg]" ) \ : [ptr__] "+&a" (ptr__), "=m" (*ptr__), \ "=m" (((struct lowcore *)0)->percpu_register) \ : [val__] "d" (val__), \ -[disppcpr] " i" (LC_PERCPU_REGISTER), \ -[disppcpo] " i" (LC_PERCPU_OFFSET), \ +[lcreg] " i" (LC_PERCPU_REGISTER), \ +[lcoff] " i" (LC_PERCPU_OFFSET), \ " m" (((struct lowcore *)0)->percpu_offset) \ : " cc"); \ } while (0)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1762/2651 s390/percpu: Use __PCPU_BEGIN() and __PCPU_END() for inline assemblies
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Heiko Carstens <[email protected]>
[ Upstream commit da9af84e66c3ace4f1a95421c1152f9df4e6abc5 ]
Replace the use of MVIY_PERCPU(), AG_ALT(), and MVIY_ALT() within all percpu inline assemblies with __PCPU_BEGIN() and __PCPU_END(), since the begin and end of each inline assembly is the same.
Also use consistent names: e.g. __PCPU_MVIY() and __PCPU_AG() instead of the previous MVIY_PERCPU() and AG_ALT().
Furthermore extract DEFINE_GR_NUM and UNDEF_GR_NUM which are used to convert register strings to register numbers.
All of this should make the code more readable. No functional change.
Stable-dep-of: 10f9cf286ec3 ("s390/percpu: Use asm_inline for arch_this_cpu_add()")
--- arch/s390/include/asm/percpu.h | 85 +++++++++++++++++----------------- 1 file changed, 43 insertions(+), 42 deletions(-)
arch/s390/include/asm/percpu.h +43 -42
@@ -92,42 +92,49 @@* * Inline assemblies making use of this typically have a code sequence like: * -* MVIY_PERCPU(...) <- start of percpu code section -* AG_ALT(...) <- add percpu offset; must be the second instruction -* atomic_op <- atomic op -* MVIY_ALT(...) <- end of percpu code section +* __PCPU_BEGIN(...) <- start of percpu code section +* atomic_op <- atomic op +* __PCPU_END(...) <- end of percpu code section */ #define LC_ALT_ADDR __stringify(LOWCORE_ALT_ADDRESS) -#define MVIY_PERCPU (disp, reg) \ - ".macro GEN_MVIY disp, reg\n" \ - ".set .Lreg,255\n" \ - ".irp rs,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15\n" \ - " .ifc \\reg,%%r\\rs\n" \ - " .set .Lreg,\\rs\n" \ +#define DEFINE_GR_NUM \ + ".macro _GR_NUM opd, gr\n" \ + ".set \\opd,255\n" \ + ".irp rs,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15\n" \ + " .ifc \\gr,%%r\\rs\n" \ + " \\opd = \\rs\n" \ " .endif\n" \ ".endr\n" \ - ".if .Lreg == 255\n" \ + ".if \\opd == 255\n" \ " .error \"Illegal register number\"\n" \ ".endif\n" \ - "mviy \\disp(%%r0),.Lreg\n" \ - ".endm\n" \ - ALTERNATIVE("GEN_MVIY " disp " , " reg "\n", \ - "GEN_MVIY " disp "+" LC_ALT_ADDR " , " reg "\n", \ - ALT_FEATURE(MFEATURE_LOWCORE)) \ - ".purgem GEN_MVIY\n" - -#define MVIY_ALT (disp) \ - ALTERNATIVE(" mviy " disp "(%%r0),0\n", \ - " mviy " disp "+" LC_ALT_ADDR "(%%r0),0\n", \ + ".endm\n" + +#define UNDEF_GR_NUM \ + ".purgem _GR_NUM\n" + +#define __PCPU_MVIY (lcreg, imm) \ + ALTERNATIVE(" mviy " lcreg "(%%r0)," imm "\n", \ + " mviy " lcreg "+" LC_ALT_ADDR "(%%r0)," imm "\n", \ ALT_FEATURE(MFEATURE_LOWCORE)) -#define AG_ALT (disp, reg) \ - ALTERNATIVE(" ag " reg ", " disp "(%%r0)\n", \ - " ag " reg ", " disp "+" LC_ALT_ADDR "(%%r0)\n", \ +#define __PCPU_AG (reg, lcoff) \ + ALTERNATIVE(" ag " reg ", " lcoff "(%%r0)\n", \ + " ag " reg ", " lcoff "+" LC_ALT_ADDR "(%%r0)\n", \ ALT_FEATURE(MFEATURE_LOWCORE)) +#define __PCPU_BEGIN (lcreg, lcoff, reg) \ + DEFINE_GR_NUM \ + "_GR_NUM .Lreg, " reg "\n" \ + UNDEF_GR_NUM \ + __PCPU_MVIY(lcreg, ".Lreg") \ + __PCPU_AG(reg, lcoff) + +#define __PCPU_END (lcreg) \ + __PCPU_MVIY(lcreg, "0") +#ifndef MARCH_HAS_Z196_FEATURES #define this_cpu_add_4 (pcp, val) arch_this_cpu_to_op_simple(pcp, val, +)
@@ -151,10 +158,9 @@ do { \if (__builtin_constant_p (val__) && \ ((szcast )val__ >-129 ) && ((szcast )val__ <128 )) { \ asm volatile( \ - MVIY_PERCPU("%[lcreg]","%[ptr__]") \ - AG_ALT("%[lcoff]", "%[ptr__]") \ + __PCPU_BEGIN("%[lcreg]","%[lcoff]","%[ptr__]") \ op2 " 0(%[ptr__]),%[val__]\n" \ -MVIY_ALT ("%[lcreg]" ) \ + __PCPU_END("%[lcreg]") \ : [ptr__] "+&a" (ptr__), "+m" (*ptr__), \ "=m" (((struct lowcore *)0)->percpu_register) \ : [val__] "i" ((szcast)val__), \
@@ -164,10 +170,9 @@ do { \ : "cc"); \ }else { \ asm volatile( \ - MVIY_PERCPU("%[lcreg]", "%[ptr__]") \ - AG_ALT("%[lcoff]", "%[ptr__]") \ + __PCPU_BEGIN("%[lcreg]","%[lcoff]","%[ptr__]") \ op1 " %[old__],%[val__],0(%[ptr__])\n" \ -MVIY_ALT ("%[lcreg]" ) \ + __PCPU_END("%[lcreg]") \ : [old__] "=&d" (old__), \ [ptr__] "+&a" (ptr__), "+m" (*ptr__), \"=m" (((struct lowcore *)0 )->percpu_register) \
@@ -190,10 +195,9 @@ do { \ \ ptr__ =PERCPU_PTR (&(pcp)); \ asm_inline volatile( \ - MVIY_PERCPU("%[lcreg]","%[ptr__]") \ - AG_ALT("%[lcoff]","%[ptr__]") \ + __PCPU_BEGIN("%[lcreg]","%[lcoff]","%[ptr__]") \ op" %[old__],%[val__],0(%[ptr__])\n" \ -MVIY_ALT ("%[lcreg]" ) \ + __PCPU_END("%[lcreg]" ) \ : [old__] "=&d" (old__), \ [ptr__] "+&a" (ptr__), "+m" (*ptr__), \ "=m" (((struct lowcore *)0)->percpu_register) \
@@ -216,10 +220,9 @@ do { \ \ ptr__ =PERCPU_PTR (&(pcp)); \ asm_inline volatile( \ - MVIY_PERCPU("%[lcreg]","%[ptr__]") \ - AG_ALT("%[lcoff]","%[ptr__]") \ + __PCPU_BEGIN("%[lcreg]","%[lcoff]","%[ptr__]") \ op" %[old__],%[val__],0(%[ptr__])\n" \ -MVIY_ALT ("%[lcreg]" ) \ + __PCPU_END("%[lcreg]" ) \ : [old__] "=&d" (old__), \ [ptr__] "+&a" (ptr__), "+m" (*ptr__), \ "=m" (((struct lowcore *)0)->percpu_register) \
@@ -245,10 +248,9 @@ do { \ \ ptr__ =PERCPU_PTR (&(pcp)); \ asm_inline volatile( \ - MVIY_PERCPU("%[lcreg]","%[ptr__]") \ - AG_ALT("%[lcoff]","%[ptr__]") \ + __PCPU_BEGIN("%[lcreg]","%[lcoff]","%[ptr__]") \ op" %[res__],0(%[ptr__])\n" \ -MVIY_ALT ("%[lcreg]" ) \ + __PCPU_END("%[lcreg]" ) \ : [res__] "=&d" (res__), [ptr__] "+&a" (ptr__), \" =m" (((struct lowcore *)0)->percpu_register) \ : [lcreg] " i" (LC_PERCPU_REGISTER), \
@@ -271,10 +273,9 @@ do { \ \ ptr__ =PERCPU_PTR (&(pcp)); \ asm_inline volatile( \ - MVIY_PERCPU("%[lcreg]","%[ptr__]") \ - AG_ALT("%[lcoff]","%[ptr__]") \ + __PCPU_BEGIN("%[lcreg]","%[lcoff]","%[ptr__]") \ op" %[val__],0(%[ptr__])\n" \ -MVIY_ALT ("%[lcreg]" ) \ + __PCPU_END("%[lcreg]" ) \ : [ptr__] "+&a" (ptr__), "=m" (*ptr__), \ "=m" (((struct lowcore *)0)->percpu_register) \ : [val__] "d" (val__), \
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1763/2651 s390/percpu: Use percpu code section for this_cpu_cmpxchg128()
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Heiko Carstens <[email protected]>
[ Upstream commit e8b55c9982df6dc5f28c427e4debabb4da3a5e64 ]
Convert this_cpu_cmpxchg128() to make use of percpu code section functionality. This is just for the sake of completeness, since currently there is no in-kernel user of this_cpu_cmpxchg128().
Stable-dep-of: 10f9cf286ec3 ("s390/percpu: Use asm_inline for arch_this_cpu_add()")
--- arch/s390/include/asm/percpu.h | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-)
arch/s390/include/asm/percpu.h +16 -8
@@ -312,15 +312,23 @@ do { \#define this_cpu_cmpxchg128 (pcp, oval, nval) \ ({ \ typedef typeof(pcp) pcp_op_T__; \ - u128 old__, new__, ret__; \ + u128 old__ = (oval), new__ = (nval); \ pcp_op_T__ *ptr__; \ - old__ = oval; \ - new__ = nval; \ - preempt_disable_notrace(); \ - ptr__ = raw_cpu_ptr(&(pcp)); \ - ret__ = cmpxchg128((void *)ptr__, old__, new__); \ - preempt_enable_notrace(); \ - ret__; \ + \ + ptr__ = PERCPU_PTR(&(pcp)); \ + asm_inline volatile( \ + __PCPU_BEGIN("%[lcreg]","%[lcoff]","%[ptr__]") \ + " cdsg %[old__],%[new__],0(%[ptr__])\n" \ + __PCPU_END("%[lcreg]") \ + : [old__] "+&d" (old__), [ptr__] "+&a" (ptr__), \ + "+m" (*ptr__), \ + "=m" (((struct lowcore *)0)->percpu_register) \ + : [new__] "d" (new__), \ + [lcreg] "i" (LC_PERCPU_REGISTER), \ + [lcoff] "i" (LC_PERCPU_OFFSET), \ + "m" (((struct lowcore *)0)->percpu_offset) \ + : "memory", "cc"); \ + old__; \ })#define arch_this_cpu_xchg (pcp, nval) \
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1764/2651 s390/percpu: Use percpu code section for this_cpu_xchg()
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Heiko Carstens <[email protected]>
[ Upstream commit d83b5cf355ca762ef19aa3a424af44e3e275ff52 ]
Convert this_cpu_xchg() to make use of percpu code section functionality in order to get rid of preempt_disable() and preempt_enable() calls.
Consider only four and eight byte usages, since there are no compare and swap instructions for one and two bytes available. For one and two byte use the previous simple implementation.
Stable-dep-of: 10f9cf286ec3 ("s390/percpu: Use asm_inline for arch_this_cpu_add()")
--- arch/s390/include/asm/percpu.h | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-)
arch/s390/include/asm/percpu.h +29 -5
@@ -331,7 +331,7 @@ do { \ old__; \ }) -#define arch_this_cpu_xchg (pcp, nval) \ +#define arch_this_cpu_xchg_simple (pcp, nval) \ ({ \ typeof(pcp) *ptr__; \ typeof(pcp) ret__; \
@@ -342,10 +342,34 @@ do { \ ret__; \ }) -#define this_cpu_xchg_1 (pcp, nval) arch_this_cpu_xchg(pcp, nval) -#define this_cpu_xchg_2 (pcp, nval) arch_this_cpu_xchg(pcp, nval) -#define this_cpu_xchg_4 (pcp, nval) arch_this_cpu_xchg(pcp, nval) -#define this_cpu_xchg_8 (pcp, nval) arch_this_cpu_xchg(pcp, nval) +#define arch_this_cpu_xchg (pcp, nval, ldop, csop) \ +({ \ + typedef typeof(pcp) pcp_op_T__; \ + pcp_op_T__ old__, new__ = (nval); \ + pcp_op_T__ *ptr__; \ + \ + ptr__ = PERCPU_PTR(&(pcp)); \ + asm_inline volatile( \ + __PCPU_BEGIN("%[lcreg]","%[lcoff]","%[ptr__]") \ + " " ldop " %[old__],0(%[ptr__])\n" \ + "0: " csop " %[old__],%[new__],0(%[ptr__])\n"\ + " jnz 0b\n" \ + __PCPU_END("%[lcreg]") \ + : [old__] "=&d" (old__), \ + [ptr__] "+&a" (ptr__), "+m" (*ptr__), \ + "=m" (((struct lowcore *)0)->percpu_register) \ + : [new__] "d" (new__), \ + [lcreg] "i" (LC_PERCPU_REGISTER), \ + [lcoff] "i" (LC_PERCPU_OFFSET), \ + "m" (((struct lowcore *)0)->percpu_offset) \ + : "memory", "cc"); \ + old__; \ +}) + +#define this_cpu_xchg_1 (pcp, nval) arch_this_cpu_xchg_simple(pcp, nval) +#define this_cpu_xchg_2 (pcp, nval) arch_this_cpu_xchg_simple(pcp, nval) +#define this_cpu_xchg_4 (pcp, nval) arch_this_cpu_xchg(pcp, nval, "l", "cs") +#define this_cpu_xchg_8 (pcp, nval) arch_this_cpu_xchg(pcp, nval, "lg", "csg")#include <asm-generic/percpu.h>
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1765/2651 s390/percpu: Use percpu code section for this_cpu_cmpxchg()
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Heiko Carstens <[email protected]>
[ Upstream commit 45b0097302d87a42189abe0b33d69fe18f6c7cb0 ]
Convert this_cpu_cmpxchg() to make use of percpu code section functionality in order to get rid of preempt_disable() and preempt_enable() calls.
Consider only four and eight byte usages, since there are no compare and swap instructions for one and two bytes available. For one and two bytes use the previous simple implementation.
Stable-dep-of: 10f9cf286ec3 ("s390/percpu: Use asm_inline for arch_this_cpu_add()")
--- arch/s390/include/asm/percpu.h | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-)
arch/s390/include/asm/percpu.h +27 -5
@@ -290,7 +290,7 @@ do { \#define this_cpu_write_4 (pcp, val) arch_this_cpu_write(pcp, val, "st")#define this_cpu_write_8 (pcp, val) arch_this_cpu_write(pcp, val, "stg") -#define arch_this_cpu_cmpxchg (pcp, oval, nval) \ +#define arch_this_cpu_cmpxchg_simple (pcp, oval, nval) \ ({ \ typedef typeof(pcp) pcp_op_T__; \ pcp_op_T__ ret__; \
@@ -302,10 +302,32 @@ do { \ ret__; \ }) -#define this_cpu_cmpxchg_1 (pcp, oval, nval) arch_this_cpu_cmpxchg(pcp, oval, nval) -#define this_cpu_cmpxchg_2 (pcp, oval, nval) arch_this_cpu_cmpxchg(pcp, oval, nval) -#define this_cpu_cmpxchg_4 (pcp, oval, nval) arch_this_cpu_cmpxchg(pcp, oval, nval) -#define this_cpu_cmpxchg_8 (pcp, oval, nval) arch_this_cpu_cmpxchg(pcp, oval, nval) +#define arch_this_cpu_cmpxchg (pcp, oval, nval, op) \ +({ \ + typedef typeof(pcp) pcp_op_T__; \ + pcp_op_T__ old__ = (oval), new__ = (nval); \ + pcp_op_T__ *ptr__; \ + \ + ptr__ = PERCPU_PTR(&(pcp)); \ + asm_inline volatile( \ + __PCPU_BEGIN("%[lcreg]","%[lcoff]","%[ptr__]") \ + op " %[old__],%[new__],0(%[ptr__])\n" \ + __PCPU_END("%[lcreg]") \ + : [old__] "+&d" (old__), \ + [ptr__] "+&a" (ptr__), "+m" (*ptr__), \ + "=m" (((struct lowcore *)0)->percpu_register) \ + : [new__] "d" (new__), \ + [lcreg] "i" (LC_PERCPU_REGISTER), \ + [lcoff] "i" (LC_PERCPU_OFFSET), \ + "m" (((struct lowcore *)0)->percpu_offset) \ + : "memory", "cc"); \ + old__; \ +}) + +#define this_cpu_cmpxchg_1 (pcp, oval, nval) arch_this_cpu_cmpxchg_simple(pcp, oval, nval) +#define this_cpu_cmpxchg_2 (pcp, oval, nval) arch_this_cpu_cmpxchg_simple(pcp, oval, nval) +#define this_cpu_cmpxchg_4 (pcp, oval, nval) arch_this_cpu_cmpxchg(pcp, oval, nval, "cs") +#define this_cpu_cmpxchg_8 (pcp, oval, nval) arch_this_cpu_cmpxchg(pcp, oval, nval, "csg")#define this_cpu_cmpxchg64 (pcp, o, n) this_cpu_cmpxchg_8(pcp, o, n)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1766/2651 s390/percpu: Rework to simplify percpu_entry() and percpu_exit()
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Heiko Carstens <[email protected]>
[ Upstream commit 7849fb83e4cf814710003e4c83e161f97cf7ab1c ]
The percpu code section functionality uses a rather complex method to figure out if the register, which contains the address of the current cpu's percpu variable, needs to be adjusted.
If an interrupt happens within a percpu code section (indicated by a lowcore field), the instruction at the interrupted location is checked. If it is not a specific AG instruction, the register needs to be updated. This mechanism needs to take kprobes into account, and enforces a specific instruction ordering.
Mark Rutland provided a different solution for arm64 [1] which comes without such limitations, but requires to use one more instruction, and two more registers. Given that this simplifies percpu_entry() and percpu_exit() it seems to be worth to go that route.
Change s390 to implement a similar approach. This requires to encode three register numbers into the "percpu_register" field, which is used to indicate if a percpu code section is executed.
The used mviy instruction can write only one byte, which allows to encode only two register numbers. Use a register pair for the inline assemblies, and only encode the even register number of the register pair to work around this.
The generated code changes like this for e.g. a simple this_cpu_inc():
Old:
c0 20 00 00 00 00 larl %r2,c6 <foo+0x6> <-- load address of percpu var
b9 04 00 32 lgr %r3,%r2 <-- pointless copy of address
eb 03 03 c0 00 52 mviy 960,3 <-- start of percpu code section
- gpr 3 contains percpu var address
e3 30 03 b8 00 08 ag %r3,952 <-- add percpu offset
eb 01 30 00 00 7a agsi 0(%r3),1 <-- atomic inc
eb 00 03 c0 00 52 mviy 960,0 <-- end of percpu code sectionNew:
c0 10 00 00 00 00 larl %r1,c6 <foo+0x6> <-- load address of percpu var
eb 21 03 c0 00 52 mviy 960,33 <-- start of percpu code section
33 == 0x21:
- gpr 1 contains percpu var address
- gpr 2 used for percpu offset
- gpr 2+1 == 3 used for current cpu's percpu var address
e3 20 03 b8 00 04 lg %r2,952 <-- load percpu offset
41 32 10 00 la %r3,0(%r2,%r1) <-- generate current cpu's percpu var address
eb 01 30 00 00 7a agsi 0(%r3),1 <-- atomic inc
eb 00 03 c0 00 52 mviy 960,0 <-- end of percpu code sectionIn the above "new" code example 33 (0x21) is used as indicator value to mark that a percpu code section is executed. This value implies that registers 2 and 3 will (only) hold the percpu offset and the current cpu's percpu var address. Those registers will be updated by percpu_exit() if the process was migrated to a different cpu to contain the percpu offset and percpu var address of the new cpu.
Note that because of the pointless lgr instruction in the "old" code example the two code sequences have identical size, and it looks like only one more register is used. However this is because of suboptimal gcc code generation.
[1] https://lore.kernel.org/all/[email protected]/
Stable-dep-of: 10f9cf286ec3 ("s390/percpu: Use asm_inline for arch_this_cpu_add()")
--- arch/s390/include/asm/entry-percpu.h | 71 +++-------- arch/s390/include/asm/percpu.h | 177 +++++++++++++++++---------- arch/s390/kernel/irq.c | 10 +- arch/s390/kernel/nmi.c | 4 +- arch/s390/kernel/traps.c | 4 +- 5 files changed, 138 insertions(+), 128 deletions(-)
arch/s390/include/asm/entry-percpu.h +17 -54
@@ -2,79 +2,42 @@#ifndef ARCH_S390_ENTRY_PERCPU_H #define ARCH_S390_ENTRY_PERCPU_H -#include <linux/kprobes.h> +#include <linux/bitfield.h> #include <linux/percpu.h> #include <asm/lowcore.h> #include <asm/ptrace.h> -#include <asm/asm-offsets.h> static __always_inline void percpu_entry(struct pt_regs *regs) {struct lowcore *lc =get_lowcore (); -if (user_mode (regs)) -return ; regs->cpu = lc->cpu_nr; regs->percpu_register = lc->percpu_register; lc->percpu_register =0 ; } -static __always_inline bool percpu_code_check(struct pt_regs *regs) -{ -unsigned int insn, disp; -struct kprobe *p; - -if (likely (user_mode (regs) || !regs->percpu_register)) -return false; -/* -* Within a percpu code section - check if the percpu base register -* needs to be updated. This is the case if the PSW does not point to -* the ADD instruction within the section. -* - AG %rx,percpu_offset_in_lowcore(%r0,%r0) -* which adds the percpu offset to the percpu base register. -*/ -lockdep_assert_preemption_disabled (); -again: - insn =READ_ONCE (*(u16 *)psw_bits (regs->psw).ia); -if (unlikely (insn ==BREAKPOINT_INSTRUCTION )) { - p =get_kprobe ((void *)psw_bits (regs->psw).ia); -/* -* If the kprobe is concurrently removed on a different CPU -* it might not be found anymore. However text must have -* been restored - try again. -*/ -if (!p) - goto again; - insn = p->opcode; - } -if ((insn &0xff0f ) !=0xe300 ) -return true; - disp =LC_PERCPU_OFFSET ; -if (machine_has_relocated_lowcore ()) - disp +=LOWCORE_ALT_ADDRESS ; - insn = (disp &0xff000 ) >>4 | (disp &0x00fff ) <<16 |0x8 ; -if (*(u32 *)(psw_bits (regs->psw).ia +2 ) != insn) -return true; -return false; -} - -static __always_inline void percpu_exit(struct pt_regs *regs, bool needs_fixup) +static __always_inline void percpu_exit(struct pt_regs *regs) { +unsigned char regval, regpcp, regoff, regptr;struct lowcore *lc =get_lowcore (); -unsigned char reg; -if (user_mode (regs)) -return ; - reg = regs->percpu_register; - lc->percpu_register = reg; -if (likely (!needs_fixup)) +if (!regs->percpu_register)return ; -/* Check if process has been migrated to a different CPU. */ + regval = regs->percpu_register; + lc->percpu_register = regval; +/* Migrated to a different CPU? */ if (regs->cpu == lc->cpu_nr)return ; -/* Fixup percpu base register */ - regs->gprs[reg] -= __per_cpu_offset[regs->cpu]; - regs->gprs[reg] += lc->percpu_offset; + regpcp =FIELD_GET (PCPU_REG_PCP , regval); + regoff =FIELD_GET (PCPU_REG_OFF , regval); + regptr = regoff +1 ; +/* +* Update register 'regoff' with the current CPU's percpu offset, +* and recalculate and update current CPU's percpu variable address +* contained in register 'regptr'. +*/ + regs->gprs[regoff] = lc->percpu_offset; + regs->gprs[regptr] = regs->gprs[regpcp] + regs->gprs[regoff]; }#endif
arch/s390/include/asm/percpu.h +115 -62
318 lines not on this page · raw message
arch/s390/kernel/irq.c +4 -6
@@ -144,9 +144,9 @@ static int irq_pending(struct pt_regs *regs) void noinstr do_io_irq(struct pt_regs *regs) { -bool from_idle, percpu_needs_fixup;struct pt_regs *old_regs;irqentry_state_t state; +bool from_idle;percpu_entry (regs); state =irqentry_enter (regs);
@@ -174,21 +174,20 @@ void noinstr do_io_irq(struct pt_regs *regs)do_irq_async (regs,IO_INTERRUPT ); }while (machine_is_lpar () &&irq_pending (regs)); - percpu_needs_fixup =percpu_code_check (regs);irq_exit_rcu ();set_irq_regs (old_regs);irqentry_exit (regs, state);if (from_idle) regs->psw.mask &= ~(PSW_MASK_EXT |PSW_MASK_IO |PSW_MASK_WAIT ); -percpu_exit (regs, percpu_needs_fixup); +percpu_exit (regs); } void noinstr do_ext_irq(struct pt_regs *regs) { -bool from_idle, percpu_needs_fixup;struct pt_regs *old_regs;irqentry_state_t state; +bool from_idle;percpu_entry (regs); state =irqentry_enter (regs);
@@ -214,14 +213,13 @@ void noinstr do_ext_irq(struct pt_regs *regs)do_irq_async (regs,EXT_INTERRUPT ); - percpu_needs_fixup =percpu_code_check (regs);irq_exit_rcu ();set_irq_regs (old_regs);irqentry_exit (regs, state);if (from_idle) regs->psw.mask &= ~(PSW_MASK_EXT |PSW_MASK_IO |PSW_MASK_WAIT ); -percpu_exit (regs, percpu_needs_fixup); +percpu_exit (regs); }static void show_msi_interrupt (struct seq_file *p,int irq)
arch/s390/kernel/nmi.c +1 -3
@@ -361,7 +361,6 @@ NOKPROBE_SYMBOL(s390_backup_mcck_info);*/ void notrace s390_do_machine_check(struct pt_regs *regs) { -bool percpu_needs_fixup;static int ipd_count;static DEFINE_SPINLOCK (ipd_lock);static unsigned long long last_ipd;
@@ -495,9 +494,8 @@ void notrace s390_do_machine_check(struct pt_regs *regs)if (mcck_pending)schedule_mcck_handler (); - percpu_needs_fixup =percpu_code_check (regs);irqentry_nmi_exit (regs, irq_state); -percpu_exit (regs, percpu_needs_fixup); +percpu_exit (regs); }NOKPROBE_SYMBOL (s390_do_machine_check);
arch/s390/kernel/traps.c +1 -3
@@ -338,7 +338,6 @@ static void (*pgm_check_table[128])(struct pt_regs *regs); void noinstr __do_pgm_check(struct pt_regs *regs, unsigned long flags) {struct lowcore *lc =get_lowcore (); -bool percpu_needs_fixup;irqentry_state_t state;struct pgm_stat *stat;unsigned int trapnr;
@@ -400,9 +399,8 @@ void noinstr __do_pgm_check(struct pt_regs *regs, unsigned long flags) pgm_check_table[trapnr](regs); out:local_irq_disable (); - percpu_needs_fixup =percpu_code_check (regs);irqentry_exit (regs, state); -percpu_exit (regs, percpu_needs_fixup); +percpu_exit (regs); }static int pgm_check_stat_show (struct seq_file *p,void *v)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1767/2651 s390/percpu: Use asm_inline for arch_this_cpu_add()
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Heiko Carstens <[email protected]>
[ Upstream commit 10f9cf286ec3e6f99569e5ce3e99afbeb77b962f ]
When converting to preemptible percpu operations the arch_this_cpu_add() inline assemblies were not converted to use asm_inline instead of a plain asm statement.
With all the macro usage the inline assemblies grow significantly, and the compiler may decide to not inline even small functions. This can be observed with gcc16 and a defconfig build where many calls to __srcu_read_lock_fast() are not inlined anymore, even though it is basically only a this_cpu_inc().
Use asm_inline to address this.
--- arch/s390/include/asm/percpu.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/s390/include/asm/percpu.h +2 -2
@@ -193,7 +193,7 @@ do { \ ptr__ =PERCPU_PTR (&(pcp)); \if (__builtin_constant_p (val__) && \ ((szcast )val__ >-129 ) && ((szcast )val__ <128 )) { \ - asm volatile( \ + asm_inline volatile( \ __PCPU_BEGIN("%[lcreg]","%[lcoff]","%[ptr__]", \ "%[pair__]","%N[pair__]") \ op2" 0(%N[pair__]),%[val__]\n" \
@@ -206,7 +206,7 @@ do { \ "m" (((struct lowcore *)0)->percpu_offset) \ : "cc"); \ } else { \ - asm volatile( \ + asm_inline volatile( \ __PCPU_BEGIN("%[lcreg]","%[lcoff]","%[ptr__]", \ "%[pair__]","%N[pair__]") \ op1 " %[old__],%[val__],0(%N[pair__])\n" \
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1768/2651 RDMA/bnxt_re: Use kvzalloc for QP table allocation
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abhishek Mohapatra <[email protected]>
[ Upstream commit 724a39b36af94787d32094da87729f24a28888b7 ]
The QP table size depends on the firmware reported max_qp, so it can be large and a physically contiguous kzalloc may fail. Use kvzalloc_objs() and free it with kvfree().
--- drivers/infiniband/hw/bnxt_re/qplib_res.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/infiniband/hw/bnxt_re/qplib_res.c +3 -3
@@ -910,7 +910,7 @@ int bnxt_qplib_init_res(struct bnxt_qplib_res *res)void bnxt_qplib_free_res (struct bnxt_qplib_res *res) { -kfree (res->rcfw->qp_tbl); +kvfree (res->rcfw->qp_tbl);bnxt_qplib_free_sgid_tbl (res, &res->sgid_tbl);bnxt_qplib_free_pd_tbl (&res->pd_tbl);bnxt_qplib_free_dpi_tbl (res, &res->dpi_tbl);
@@ -927,8 +927,8 @@ int bnxt_qplib_alloc_res(struct bnxt_qplib_res *res, struct net_device *netdev)/* Allocate one extra to hold the QP1 entries */ rcfw->qp_tbl_size =max_t (u32,BNXT_RE_MAX_QPC_COUNT +1 , dev_attr->max_qp); - rcfw->qp_tbl = kzalloc_objs(struct bnxt_qplib_qp_node, - rcfw->qp_tbl_size); + rcfw->qp_tbl = kvzalloc_objs(struct bnxt_qplib_qp_node, + rcfw->qp_tbl_size);if (!rcfw->qp_tbl)return -ENOMEM ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1769/2651 RDMA/bnxt_re: Unpublish QP table before freeing it
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Selvin Xavier <[email protected]>
[ Upstream commit 978361dd2ccff357d4fe6aac6ce057d1bfae8312 ]
bnxt_re_dev_uninit() frees the QP table before the RCFW channel is disabled, so the CREQ tasklet can still look up rcfw->qp_tbl while it is being freed.
Clear rcfw->qp_tbl under tbl_lock before freeing it, and have the QP error notification handler bail out if the table is gone.
--- drivers/infiniband/hw/bnxt_re/qplib_rcfw.c | 4 ++++ drivers/infiniband/hw/bnxt_re/qplib_res.c | 10 +++++++++- 2 files changed, 13 insertions(+), 1 deletion(-)
drivers/infiniband/hw/bnxt_re/qplib_rcfw.c +4 -0
@@ -638,6 +638,10 @@ static int bnxt_qplib_process_qp_event(struct bnxt_qplib_rcfw *rcfw, err_event = (struct creq_qp_error_notification *)qp_event; qp_id =le32_to_cpu (err_event->xid);spin_lock (&rcfw->tbl_lock); +if (!rcfw->qp_tbl) { +spin_unlock (&rcfw->tbl_lock); +break ; + } tbl_indx =map_qp_id_to_tbl_indx (qp_id, rcfw); qp = rcfw->qp_tbl[tbl_indx].qp_handle;if (!qp) {
drivers/infiniband/hw/bnxt_re/qplib_res.c +9 -1
@@ -910,7 +910,15 @@ int bnxt_qplib_init_res(struct bnxt_qplib_res *res)void bnxt_qplib_free_res (struct bnxt_qplib_res *res) { -kvfree (res->rcfw->qp_tbl); +struct bnxt_qplib_rcfw *rcfw = res->rcfw; +struct bnxt_qplib_qp_node *qp_tbl; + +/* The CREQ tasklet may still be running; unpublish the table first */ +spin_lock_bh (&rcfw->tbl_lock); + qp_tbl = rcfw->qp_tbl; + rcfw->qp_tbl =NULL ; +spin_unlock_bh (&rcfw->tbl_lock); +kvfree (qp_tbl);bnxt_qplib_free_sgid_tbl (res, &res->sgid_tbl);bnxt_qplib_free_pd_tbl (&res->pd_tbl);bnxt_qplib_free_dpi_tbl (res, &res->dpi_tbl);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1770/2651 hisi_acc_vfio_pci: fix NULL dereference in reset_prepare on PF passthrough
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Longfang Liu <[email protected]>
[ Upstream commit e1d2d60b1f50296828d3f7ff26c45d1a90f142ef ]
When a PF is bound to the driver via driver_override and passed through to a VM, its pf_qm stays NULL. The PCI error handler reset_prepare() runs during open_device through pci_try_reset_function(), before the mig_ops gate, and dereferences the NULL pf_qm for the timeout log, crashing the kernel.
Move the mig_ops check to the entry of reset_prepare() and aer_reset_done() so non-migration devices skip the QM_RESETTING coordination. The dev local resolved &qm->pdev->dev before the gate, so open code it at the dev_err() call where qm is known valid. Also clear set_reset_flag together with QM_RESETTING in aer_reset_done(); the flag was never cleared before, so a later timed-out reset could release a foreign lock.
--- drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.c +9 -5
@@ -1154,14 +1154,16 @@ static void hisi_acc_vf_pci_reset_prepare(struct pci_dev *pdev) {struct hisi_acc_vf_core_device *hisi_acc_vdev =hisi_acc_drvdata (pdev);struct hisi_qm *qm = hisi_acc_vdev->pf_qm; -struct device *dev = &qm->pdev->dev;u32 delay =0 ; +if (!hisi_acc_vdev->core_device.vdev.mig_ops) +return ; +/* All reset requests need to be queued for processing */ while (test_and_set_bit (QM_RESETTING , &qm->misc_ctl)) {msleep (1 );if (++delay >QM_RESET_WAIT_TIMEOUT ) { -dev_err (dev,"reset prepare failed\n" ); +dev_err (&qm->pdev->dev,"reset prepare failed\n" );return ; } }
@@ -1174,12 +1176,14 @@ static void hisi_acc_vf_pci_aer_reset_done(struct pci_dev *pdev)struct hisi_acc_vf_core_device *hisi_acc_vdev =hisi_acc_drvdata (pdev);struct hisi_qm *qm = hisi_acc_vdev->pf_qm; -if (hisi_acc_vdev->set_reset_flag) -clear_bit (QM_RESETTING , &qm->misc_ctl); -if (!hisi_acc_vdev->core_device.vdev.mig_ops)return ; +if (hisi_acc_vdev->set_reset_flag) { +clear_bit (QM_RESETTING , &qm->misc_ctl); + hisi_acc_vdev->set_reset_flag = false; + } +mutex_lock (&hisi_acc_vdev->state_mutex);hisi_acc_vf_reset (hisi_acc_vdev);mutex_unlock (&hisi_acc_vdev->state_mutex);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1771/2651 vfio/pci: Remove the core dependency on driver data
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Simon Song <[email protected]>
[ Upstream commit 6a5f427bee12c82beaf13efbd133416da1541c39 ]
vfio-pci-core currently has runtime functions that interpret pci driver_data as a pointer to vfio_pci_core_device, and enforce vfio variant drivers must set vfio_pci_core_device to their pci driver_data. This constrains variant drivers' private-data layout, including the typed driver data used by the Rust PCI infrastructure.
Add VFIO_PCI_CORE_DEFINE_CALLBACKS macro to generate wrapper code for each vfio variant driver, update vfio variant drivers to store their private structures in driver_data and use generated wrapper to pass the vfio core device to helpers.
[VGA chunks and commit log reference dropped with rebase to
commit 93d41424caf7 ("PCI/VGA: pass a data pointer to be used in the decode callback (v2)")]
Stable-dep-of: a80597900b8a ("hisi_acc_vfio_pci: reject live migration on 64KB page with QM_HW_V3 hardware")
--- .../vfio/pci/hisilicon/hisi_acc_vfio_pci.c | 27 ++++++------ drivers/vfio/pci/ism/main.c | 19 +++++---- drivers/vfio/pci/mlx5/main.c | 13 +++--- drivers/vfio/pci/nvgrace-gpu/main.c | 19 +++++---- drivers/vfio/pci/pds/pci_drv.c | 8 +++- drivers/vfio/pci/pds/vfio_dev.c | 5 +-- drivers/vfio/pci/qat/main.c | 12 +++--- drivers/vfio/pci/vfio_pci.c | 33 ++++++++++++++- drivers/vfio/pci/vfio_pci_core.c | 36 +++------------- drivers/vfio/pci/virtio/main.c | 8 +++- drivers/vfio/pci/xe/main.c | 8 +++- include/linux/vfio_pci_core.h | 41 +++++++++++++++++-- 12 files changed, 141 insertions(+), 88 deletions(-)
drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.c +12 -15
@@ -16,6 +16,9 @@#include "hisi_acc_vfio_pci.h" +VFIO_PCI_CORE_DEFINE_CALLBACKS(hisi_acc_vf, struct hisi_acc_vf_core_device, + core_device) + /* Return 0 on VM acc device ready, -ETIMEDOUT hardware timeout */static int qm_wait_dev_not_ready (struct hisi_qm *qm) {
@@ -588,10 +591,7 @@ static int vf_qm_state_save(struct hisi_acc_vf_core_device *hisi_acc_vdev,static struct hisi_acc_vf_core_device *hisi_acc_drvdata (struct pci_dev *pdev) { -struct vfio_pci_core_device *core_device =dev_get_drvdata (&pdev->dev); - - return container_of(core_device, struct hisi_acc_vf_core_device, - core_device); +return pci_get_drvdata (pdev); }/* Check the PF's RAS state and Function INT state */
@@ -1420,9 +1420,8 @@ static int hisi_acc_vf_debug_check(struct seq_file *seq, struct vfio_device *vdestatic int hisi_acc_vf_debug_cmd (struct seq_file *seq,void *data) {struct device *vf_dev = seq->private; -struct vfio_pci_core_device *core_device =dev_get_drvdata (vf_dev); -struct vfio_device *vdev = &core_device->vdev; -struct hisi_acc_vf_core_device *hisi_acc_vdev =hisi_acc_get_vf_dev (vdev); +struct hisi_acc_vf_core_device *hisi_acc_vdev =dev_get_drvdata (vf_dev); +struct vfio_device *vdev = &hisi_acc_vdev->core_device.vdev;struct hisi_qm *vf_qm = &hisi_acc_vdev->vf_qm;u64 value;int ret;
@@ -1449,9 +1448,8 @@ static int hisi_acc_vf_debug_cmd(struct seq_file *seq, void *data)static int hisi_acc_vf_dev_read (struct seq_file *seq,void *data) {struct device *vf_dev = seq->private; -struct vfio_pci_core_device *core_device =dev_get_drvdata (vf_dev); -struct vfio_device *vdev = &core_device->vdev; -struct hisi_acc_vf_core_device *hisi_acc_vdev =hisi_acc_get_vf_dev (vdev); +struct hisi_acc_vf_core_device *hisi_acc_vdev =dev_get_drvdata (vf_dev); +struct vfio_device *vdev = &hisi_acc_vdev->core_device.vdev; size_t vf_data_sz = offsetofend(struct acc_vf_data, padding);struct acc_vf_data *vf_data;int ret;
@@ -1496,9 +1494,7 @@ static int hisi_acc_vf_dev_read(struct seq_file *seq, void *data)static int hisi_acc_vf_migf_read (struct seq_file *seq,void *data) {struct device *vf_dev = seq->private; -struct vfio_pci_core_device *core_device =dev_get_drvdata (vf_dev); -struct vfio_device *vdev = &core_device->vdev; -struct hisi_acc_vf_core_device *hisi_acc_vdev =hisi_acc_get_vf_dev (vdev); +struct hisi_acc_vf_core_device *hisi_acc_vdev =dev_get_drvdata (vf_dev); size_t vf_data_sz = offsetofend(struct acc_vf_data, padding);struct hisi_acc_vf_migration_file *debug_migf = hisi_acc_vdev->debug_migf;
@@ -1691,7 +1687,7 @@ static int hisi_acc_vfio_pci_probe(struct pci_dev *pdev, const struct pci_deviceif (IS_ERR (hisi_acc_vdev))return PTR_ERR (hisi_acc_vdev); -dev_set_drvdata (&pdev->dev, &hisi_acc_vdev->core_device); +dev_set_drvdata (&pdev->dev, hisi_acc_vdev); ret =vfio_pci_core_register_device (&hisi_acc_vdev->core_device);if (ret) goto out_put_vdev;
@@ -1725,7 +1721,7 @@ MODULE_DEVICE_TABLE(pci, hisi_acc_vfio_pci_table);static const struct pci_error_handlers hisi_acc_vf_err_handlers = { .reset_prepare = hisi_acc_vf_pci_reset_prepare, .reset_done = hisi_acc_vf_pci_aer_reset_done, - .error_detected = vfio_pci_core_aer_err_detected, + .error_detected = hisi_acc_vf_aer_err_detected, };static struct pci_driver hisi_acc_vfio_pci_driver = {
@@ -1733,6 +1729,7 @@ static struct pci_driver hisi_acc_vfio_pci_driver = { .id_table = hisi_acc_vfio_pci_table, .probe = hisi_acc_vfio_pci_probe, .remove = hisi_acc_vfio_pci_remove, + .driver = { .pm = pm_ptr(&hisi_acc_vf_pm_ops) }, .err_handler = &hisi_acc_vf_err_handlers, .driver_managed_dma = true, };
drivers/vfio/pci/ism/main.c +11 -8
@@ -47,6 +47,9 @@ struct ism_vfio_pci_core_device {struct kmem_cache *store_block_cache; }; +VFIO_PCI_CORE_DEFINE_CALLBACKS(ism_vfio, struct ism_vfio_pci_core_device, + core_device) +static int ism_vfio_pci_open_device (struct vfio_device *core_vdev) {struct ism_vfio_pci_core_device *ivpcd;
@@ -363,7 +366,7 @@ static int ism_vfio_pci_probe(struct pci_dev *pdev,if (IS_ERR (ivpcd))return PTR_ERR (ivpcd); -dev_set_drvdata (&pdev->dev, &ivpcd->core_device); +dev_set_drvdata (&pdev->dev, ivpcd); ret =vfio_pci_core_register_device (&ivpcd->core_device);if (ret)
@@ -374,12 +377,7 @@ static int ism_vfio_pci_probe(struct pci_dev *pdev,static void ism_vfio_pci_remove (struct pci_dev *pdev) { -struct vfio_pci_core_device *core_device; -struct ism_vfio_pci_core_device *ivpcd; - - core_device =dev_get_drvdata (&pdev->dev); - ivpcd = container_of(core_device, struct ism_vfio_pci_core_device, - core_device); +struct ism_vfio_pci_core_device *ivpcd =pci_get_drvdata (pdev);vfio_pci_core_unregister_device (&ivpcd->core_device);vfio_put_device (&ivpcd->core_device.vdev);
@@ -392,12 +390,17 @@ static const struct pci_device_id ism_device_table[] = { };MODULE_DEVICE_TABLE (pci, ism_device_table); +static const struct pci_error_handlers ism_vfio_err_handlers = { + .error_detected = ism_vfio_aer_err_detected, +}; +static struct pci_driver ism_vfio_pci_driver = { .name =KBUILD_MODNAME , .id_table = ism_device_table, .probe = ism_vfio_pci_probe, .remove = ism_vfio_pci_remove, - .err_handler = &vfio_pci_core_err_handlers, + .driver = { .pm =pm_ptr (&ism_vfio_pm_ops) }, + .err_handler = &ism_vfio_err_handlers, .driver_managed_dma = true, };
drivers/vfio/pci/mlx5/main.c +7 -6
@@ -21,6 +21,9 @@#include "cmd.h" +VFIO_PCI_CORE_DEFINE_CALLBACKS(mlx5vf, struct mlx5vf_pci_core_device, + core_device) + /* Device specification max LOAD size */#define MAX_LOAD_SIZE (BIT_ULL(__mlx5_bit_sz(load_vhca_state_in, size)) - 1)
@@ -28,10 +31,7 @@static struct mlx5vf_pci_core_device *mlx5vf_drvdata (struct pci_dev *pdev) { -struct vfio_pci_core_device *core_device =dev_get_drvdata (&pdev->dev); - - return container_of(core_device, struct mlx5vf_pci_core_device, - core_device); +return pci_get_drvdata (pdev); }static void mlx5vf_disable_fd (struct mlx5_vf_migration_file *migf)
@@ -1415,7 +1415,7 @@ static int mlx5vf_pci_probe(struct pci_dev *pdev,if (IS_ERR (mvdev))return PTR_ERR (mvdev); -dev_set_drvdata (&pdev->dev, &mvdev->core_device); +dev_set_drvdata (&pdev->dev, mvdev); ret =vfio_pci_core_register_device (&mvdev->core_device);if (ret) goto out_put_vdev;
@@ -1443,7 +1443,7 @@ MODULE_DEVICE_TABLE(pci, mlx5vf_pci_table);static const struct pci_error_handlers mlx5vf_err_handlers = { .reset_done = mlx5vf_pci_aer_reset_done, - .error_detected = vfio_pci_core_aer_err_detected, + .error_detected = mlx5vf_aer_err_detected, };static struct pci_driver mlx5vf_pci_driver = {
@@ -1451,6 +1451,7 @@ static struct pci_driver mlx5vf_pci_driver = { .id_table = mlx5vf_pci_table, .probe = mlx5vf_pci_probe, .remove = mlx5vf_pci_remove, + .driver = { .pm = pm_ptr(&mlx5vf_pm_ops) }, .err_handler = &mlx5vf_err_handlers, .driver_managed_dma = true, };
drivers/vfio/pci/nvgrace-gpu/main.c +10 -9
@@ -73,6 +73,9 @@ struct nvgrace_gpu_pci_core_device {int cxl_dvsec; }; +VFIO_PCI_CORE_DEFINE_CALLBACKS(nvgrace_gpu, struct nvgrace_gpu_pci_core_device, + core_device) +static void nvgrace_gpu_init_fake_bar_emu_regs (struct vfio_device *core_vdev) { struct nvgrace_gpu_pci_core_device *nvdev =
@@ -1356,7 +1359,7 @@ static int nvgrace_gpu_probe(struct pci_dev *pdev,if (ret) goto out_put_vdev; -dev_set_drvdata (&pdev->dev, &nvdev->core_device); +dev_set_drvdata (&pdev->dev, nvdev);if (ops == &nvgrace_gpu_pci_ops) { nvdev->has_mig_hw_bug =nvgrace_gpu_has_mig_hw_bug (pdev);
@@ -1387,10 +1390,10 @@ static int nvgrace_gpu_probe(struct pci_dev *pdev,static void nvgrace_gpu_remove (struct pci_dev *pdev) { -struct vfio_pci_core_device *core_device =dev_get_drvdata (&pdev->dev); +struct nvgrace_gpu_pci_core_device *nvdev =pci_get_drvdata (pdev); -vfio_pci_core_unregister_device (core_device); -vfio_put_device (&core_device->vdev); +vfio_pci_core_unregister_device (&nvdev->core_device); +vfio_put_device (&nvdev->core_device.vdev); }static const struct pci_device_id nvgrace_gpu_vfio_pci_table[] = {
@@ -1422,17 +1425,14 @@ MODULE_DEVICE_TABLE(pci, nvgrace_gpu_vfio_pci_table);*/ static void nvgrace_gpu_vfio_pci_reset_done (struct pci_dev *pdev) { -struct vfio_pci_core_device *core_device =dev_get_drvdata (&pdev->dev); -struct nvgrace_gpu_pci_core_device *nvdev = - container_of(core_device, struct nvgrace_gpu_pci_core_device, - core_device); +struct nvgrace_gpu_pci_core_device *nvdev =pci_get_drvdata (pdev); nvdev->reset_done = true; }static const struct pci_error_handlers nvgrace_gpu_vfio_pci_err_handlers = { .reset_done = nvgrace_gpu_vfio_pci_reset_done, - .error_detected = vfio_pci_core_aer_err_detected, + .error_detected = nvgrace_gpu_aer_err_detected, };static struct pci_driver nvgrace_gpu_vfio_pci_driver = {
@@ -1440,6 +1440,7 @@ static struct pci_driver nvgrace_gpu_vfio_pci_driver = { .id_table = nvgrace_gpu_vfio_pci_table, .probe = nvgrace_gpu_probe, .remove = nvgrace_gpu_remove, + .driver = { .pm = pm_ptr(&nvgrace_gpu_pm_ops) }, .err_handler = &nvgrace_gpu_vfio_pci_err_handlers, .driver_managed_dma = true, };
drivers/vfio/pci/pds/pci_drv.c +6 -2
@@ -16,6 +16,9 @@#include "pci_drv.h" #include "cmds.h" +VFIO_PCI_CORE_DEFINE_CALLBACKS(pds_vfio, struct pds_vfio_pci_device, + vfio_coredev) +#define PDS_VFIO_DRV_DESCRIPTION "AMD/Pensando VFIO Device Driver"#define PCI_VENDOR_ID_PENSANDO 0x1dd8
@@ -118,7 +121,7 @@ static int pds_vfio_pci_probe(struct pci_dev *pdev,if (IS_ERR (pds_vfio))return PTR_ERR (pds_vfio); -dev_set_drvdata (&pdev->dev, &pds_vfio->vfio_coredev); +dev_set_drvdata (&pdev->dev, pds_vfio); err =vfio_pci_core_register_device (&pds_vfio->vfio_coredev);if (err)
@@ -173,7 +176,7 @@ static void pds_vfio_pci_aer_reset_done(struct pci_dev *pdev)static const struct pci_error_handlers pds_vfio_pci_err_handlers = { .reset_done = pds_vfio_pci_aer_reset_done, - .error_detected = vfio_pci_core_aer_err_detected, + .error_detected = pds_vfio_aer_err_detected, };static struct pci_driver pds_vfio_pci_driver = {
@@ -181,6 +184,7 @@ static struct pci_driver pds_vfio_pci_driver = { .id_table = pds_vfio_pci_table, .probe = pds_vfio_pci_probe, .remove = pds_vfio_pci_remove, + .driver = { .pm = pm_ptr(&pds_vfio_pm_ops) }, .err_handler = &pds_vfio_pci_err_handlers, .driver_managed_dma = true, };
drivers/vfio/pci/pds/vfio_dev.c +1 -4
@@ -20,10 +20,7 @@ struct device *pds_vfio_to_dev(struct pds_vfio_pci_device *pds_vfio)struct pds_vfio_pci_device *pds_vfio_pci_drvdata (struct pci_dev *pdev) { -struct vfio_pci_core_device *core_device =dev_get_drvdata (&pdev->dev); - - return container_of(core_device, struct pds_vfio_pci_device, - vfio_coredev); +return pci_get_drvdata (pdev); } void pds_vfio_reset(struct pds_vfio_pci_device *pds_vfio,
drivers/vfio/pci/qat/main.c +7 -5
@@ -55,6 +55,9 @@ struct qat_vf_core_device {struct qat_vf_migration_file *saving_migf; }; +VFIO_PCI_CORE_DEFINE_CALLBACKS(qat_vf, struct qat_vf_core_device, + core_device) +static int qat_vf_pci_open_device (struct vfio_device *core_vdev) { struct qat_vf_core_device *qat_vdev =
@@ -623,9 +626,7 @@ static const struct vfio_device_ops qat_vf_pci_ops = {static struct qat_vf_core_device *qat_vf_drvdata (struct pci_dev *pdev) { -struct vfio_pci_core_device *core_device =pci_get_drvdata (pdev); - - return container_of(core_device, struct qat_vf_core_device, core_device); +return pci_get_drvdata (pdev); }static void qat_vf_pci_aer_reset_done (struct pci_dev *pdev)
@@ -651,7 +652,7 @@ qat_vf_vfio_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)if (IS_ERR (qat_vdev))return PTR_ERR (qat_vdev); -pci_set_drvdata (pdev, &qat_vdev->core_device); +pci_set_drvdata (pdev, qat_vdev); ret =vfio_pci_core_register_device (&qat_vdev->core_device);if (ret) goto out_put_device;
@@ -686,7 +687,7 @@ MODULE_DEVICE_TABLE(pci, qat_vf_vfio_pci_table);static const struct pci_error_handlers qat_vf_err_handlers = { .reset_done = qat_vf_pci_aer_reset_done, - .error_detected = vfio_pci_core_aer_err_detected, + .error_detected = qat_vf_aer_err_detected, };static struct pci_driver qat_vf_vfio_pci_driver = {
@@ -694,6 +695,7 @@ static struct pci_driver qat_vf_vfio_pci_driver = { .id_table = qat_vf_vfio_pci_table, .probe = qat_vf_vfio_pci_probe, .remove = qat_vf_vfio_pci_remove, + .driver = { .pm = pm_ptr(&qat_vf_pm_ops) }, .err_handler = &qat_vf_err_handlers, .driver_managed_dma = true, };
drivers/vfio/pci/vfio_pci.c +32 -1
@@ -223,13 +223,44 @@ static const struct pci_device_id vfio_pci_table[] = {MODULE_DEVICE_TABLE (pci, vfio_pci_table); +static int __maybe_unused vfio_pci_pm_suspend (struct device *dev) +{ +struct vfio_pci_core_device *vdev =dev_get_drvdata (dev); + +return vfio_pci_core_runtime_suspend (vdev); +} + +static int __maybe_unused vfio_pci_pm_resume (struct device *dev) +{ +struct vfio_pci_core_device *vdev =dev_get_drvdata (dev); + +return vfio_pci_core_runtime_resume (vdev); +} + +static const struct dev_pm_ops vfio_pci_pm_ops = { +SET_RUNTIME_PM_OPS (vfio_pci_pm_suspend, vfio_pci_pm_resume,NULL ) +}; + +static pci_ers_result_t vfio_pci_aer_err_detected (struct pci_dev *pdev, +pci_channel_state_t state) +{ +struct vfio_pci_core_device *vdev =pci_get_drvdata (pdev); + +return vfio_pci_core_aer_err_detected (vdev); +} + +static const struct pci_error_handlers vfio_pci_err_handlers = { + .error_detected = vfio_pci_aer_err_detected, +}; +static struct pci_driver vfio_pci_driver = { .name ="vfio-pci" , .id_table = vfio_pci_table, .probe = vfio_pci_probe, .remove = vfio_pci_remove, .sriov_configure = vfio_pci_sriov_configure, - .err_handler = &vfio_pci_core_err_handlers, + .err_handler = &vfio_pci_err_handlers, + .driver = { .pm =pm_ptr (&vfio_pci_pm_ops) }, .driver_managed_dma = true, };
drivers/vfio/pci/vfio_pci_core.c +5 -31
@@ -488,10 +488,8 @@ static int vfio_pci_core_pm_exit(struct vfio_pci_core_device *vdev, u32 flags, }#ifdef CONFIG_PM -static int vfio_pci_core_runtime_suspend (struct device *dev) +int vfio_pci_core_runtime_suspend (struct vfio_pci_core_device *vdev) { -struct vfio_pci_core_device *vdev =dev_get_drvdata (dev); -down_write (&vdev->memory_lock);/* * The user can move the device into D3hot state before invoking
@@ -516,11 +514,10 @@ static int vfio_pci_core_runtime_suspend(struct device *dev)return 0 ; } +EXPORT_SYMBOL_GPL (vfio_pci_core_runtime_suspend); -static int vfio_pci_core_runtime_resume (struct device *dev) +int vfio_pci_core_runtime_resume (struct vfio_pci_core_device *vdev) { -struct vfio_pci_core_device *vdev =dev_get_drvdata (dev); -/* * Resume with a pm_wake_eventfd_ctx signals the eventfd and exit * low power mode.
@@ -537,6 +534,7 @@ static int vfio_pci_core_runtime_resume(struct device *dev) return 0; } +EXPORT_SYMBOL_GPL (vfio_pci_core_runtime_resume);#endif /* CONFIG_PM */ /*
@@ -576,18 +574,6 @@ static void vfio_pci_core_map_bars(struct vfio_pci_core_device *vdev) } } -/* -* The pci-driver core runtime PM routines always save the device state -* before going into suspended state. If the device is going into low power -* state with only with runtime PM ops, then no explicit handling is needed -* for the devices which have NoSoftRst-. -*/ -static const struct dev_pm_ops vfio_pci_core_pm_ops = { -SET_RUNTIME_PM_OPS (vfio_pci_core_runtime_suspend, - vfio_pci_core_runtime_resume, -NULL ) -}; -int vfio_pci_core_enable (struct vfio_pci_core_device *vdev) {struct pci_dev *pdev = vdev->pdev;
@@ -2221,10 +2207,6 @@ int vfio_pci_core_register_device(struct vfio_pci_core_device *vdev)struct device *dev = &pdev->dev;int ret; -/* Drivers must set the vfio_pci_core_device to their drvdata */ -if (WARN_ON (vdev !=dev_get_drvdata (dev))) -return -EINVAL ; -/* Drivers must set a name. Required for sequestering SR-IOV VFs */ if (WARN_ON (!vdev->vdev.ops->name))return -EINVAL ;
@@ -2292,7 +2274,6 @@ int vfio_pci_core_register_device(struct vfio_pci_core_device *vdev)*/ vfio_pci_set_power_state (vdev,PCI_D0 ); - dev->driver->pm = &vfio_pci_core_pm_ops;pm_runtime_allow (dev);if (!vdev->disable_idle_d3)pm_runtime_put (dev);
@@ -2333,10 +2314,8 @@ void vfio_pci_core_unregister_device(struct vfio_pci_core_device *vdev) }EXPORT_SYMBOL_GPL (vfio_pci_core_unregister_device); -pci_ers_result_t vfio_pci_core_aer_err_detected (struct pci_dev *pdev, -pci_channel_state_t state) +pci_ers_result_t vfio_pci_core_aer_err_detected (struct vfio_pci_core_device *vdev) { -struct vfio_pci_core_device *vdev =dev_get_drvdata (&pdev->dev);struct vfio_pci_eventfd *eventfd;rcu_read_lock ();
@@ -2419,11 +2398,6 @@ int vfio_pci_core_sriov_configure(struct vfio_pci_core_device *vdev, }EXPORT_SYMBOL_GPL (vfio_pci_core_sriov_configure); -const struct pci_error_handlers vfio_pci_core_err_handlers = { - .error_detected = vfio_pci_core_aer_err_detected, -}; -EXPORT_SYMBOL_GPL (vfio_pci_core_err_handlers); -static bool vfio_dev_in_groups (struct vfio_device *vdev,struct vfio_pci_group_info *groups) {
drivers/vfio/pci/virtio/main.c +6 -2
@@ -18,6 +18,9 @@#include "common.h" +VFIO_PCI_CORE_DEFINE_CALLBACKS(virtiovf, struct virtiovf_pci_core_device, + core_device) +static int virtiovf_pci_open_device (struct vfio_device *core_vdev) { struct virtiovf_pci_core_device *virtvdev = container_of(core_vdev,
@@ -174,7 +177,7 @@ static int virtiovf_pci_probe(struct pci_dev *pdev,if (sup_lm)virtiovf_set_migratable (virtvdev); -dev_set_drvdata (&pdev->dev, &virtvdev->core_device); +dev_set_drvdata (&pdev->dev, virtvdev); ret =vfio_pci_core_register_device (&virtvdev->core_device);if (ret) goto out;
@@ -211,7 +214,7 @@ static void virtiovf_pci_aer_reset_done(struct pci_dev *pdev)static const struct pci_error_handlers virtiovf_err_handlers = { .reset_done = virtiovf_pci_aer_reset_done, - .error_detected = vfio_pci_core_aer_err_detected, + .error_detected = virtiovf_aer_err_detected, };static struct pci_driver virtiovf_pci_driver = {
@@ -219,6 +222,7 @@ static struct pci_driver virtiovf_pci_driver = { .id_table = virtiovf_pci_table, .probe = virtiovf_pci_probe, .remove = virtiovf_pci_remove, + .driver = { .pm = pm_ptr(&virtiovf_pm_ops) }, .err_handler = &virtiovf_err_handlers, .driver_managed_dma = true, };
drivers/vfio/pci/xe/main.c +6 -2
@@ -38,6 +38,9 @@ struct xe_vfio_pci_core_device {struct xe_vfio_pci_migration_file *migf; }; +VFIO_PCI_CORE_DEFINE_CALLBACKS(xe_vfio, struct xe_vfio_pci_core_device, + core_device) +#define xe_vdev_to_dev (xe_vdev) (&(xe_vdev)->core_device.pdev->dev)static void xe_vfio_pci_disable_file (struct xe_vfio_pci_migration_file *migf)
@@ -140,7 +143,7 @@ static void xe_vfio_pci_reset_done(struct pci_dev *pdev)static const struct pci_error_handlers xe_vfio_pci_err_handlers = { .reset_prepare = xe_vfio_pci_reset_prepare, .reset_done = xe_vfio_pci_reset_done, - .error_detected = vfio_pci_core_aer_err_detected, + .error_detected = xe_vfio_aer_err_detected, };static int xe_vfio_pci_open_device (struct vfio_device *core_vdev)
@@ -550,7 +553,7 @@ static int xe_vfio_pci_probe(struct pci_dev *pdev, const struct pci_device_id *iif (IS_ERR (xe_vdev))return PTR_ERR (xe_vdev); -dev_set_drvdata (&pdev->dev, &xe_vdev->core_device); +dev_set_drvdata (&pdev->dev, xe_vdev); ret =vfio_pci_core_register_device (&xe_vdev->core_device);if (ret) {
@@ -586,6 +589,7 @@ static struct pci_driver xe_vfio_pci_driver = { .id_table = xe_vfio_pci_table, .probe = xe_vfio_pci_probe, .remove = xe_vfio_pci_remove, + .driver = { .pm = pm_ptr(&xe_vfio_pm_ops) }, .err_handler = &xe_vfio_pci_err_handlers, .driver_managed_dma = true, };
include/linux/vfio_pci_core.h +38 -3
69 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1772/2651 hisi_acc_vfio_pci: reject live migration on 64KB page with QM_HW_V3 hardware
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Longfang Liu <[email protected]>
[ Upstream commit a80597900b8a0f1a9e87360164695f6a0a10556c ]
On QM_HW_V3 (VF_CTRL mode) hardware with 64KB pages, the functional region and migration registers share one BAR2 physical page with no isolation, which leaks migration registers to the guest and causes guest kernel calltrace under the KVM emulated device scheme.
The previous fix rejected the device in hisi_acc_vf_qm_init() during open_device, returning -EINVAL and breaking passthrough entirely. Move the drv_mode check into a helper called from probe() so that a VF_CTRL device on a 64KB page is bound to the generic ops, keeping passthrough working while disabling live migration.
--- .../vfio/pci/hisilicon/hisi_acc_vfio_pci.c | 32 ++++++++++++------- 1 file changed, 20 insertions(+), 12 deletions(-)
drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.c +20 -12
@@ -1195,13 +1195,6 @@ static int hisi_acc_vf_qm_init(struct hisi_acc_vf_core_device *hisi_acc_vdev)struct hisi_qm *vf_qm = &hisi_acc_vdev->vf_qm;struct hisi_qm *pf_qm = hisi_acc_vdev->pf_qm;struct pci_dev *vf_dev = vdev->pdev; -u32 val; - - val =readl (pf_qm->io_base +QM_MIG_REGION_SEL ); -if (pf_qm->ver >QM_HW_V3 && (val &QM_MIG_REGION_EN )) - hisi_acc_vdev->drv_mode =HW_ACC_MIG_PF_CTRL ; -else - hisi_acc_vdev->drv_mode =HW_ACC_MIG_VF_CTRL ;if (hisi_acc_vdev->drv_mode ==HW_ACC_MIG_PF_CTRL ) {/*
@@ -1665,21 +1658,34 @@ static void hisi_acc_vf_debugfs_exit(struct hisi_acc_vf_core_device *hisi_acc_vd hisi_acc_vdev->debug_migf =NULL ; } +static enum hw_drv_mode hisi_acc_vf_get_drv_mode (struct hisi_qm *pf_qm) +{ +u32 val; + + val =readl (pf_qm->io_base +QM_MIG_REGION_SEL ); +if (pf_qm->ver >QM_HW_V3 && (val &QM_MIG_REGION_EN )) +return HW_ACC_MIG_PF_CTRL ; + +return HW_ACC_MIG_VF_CTRL ; +} +static int hisi_acc_vfio_pci_probe (struct pci_dev *pdev,const struct pci_device_id *id) {struct hisi_acc_vf_core_device *hisi_acc_vdev;const struct vfio_device_ops *ops = &hisi_acc_vfio_pci_ops; +enum hw_drv_mode drv_mode =HW_ACC_MIG_VF_CTRL ; +resource_size_t func_len;struct hisi_qm *pf_qm; -int vf_id;int ret; pf_qm =hisi_acc_get_pf_qm (pdev);if (pf_qm && pf_qm->ver >=QM_HW_V3 ) { - vf_id =pci_iov_vf_id (pdev); -if (vf_id >=0 ) - ops = &hisi_acc_vfio_pci_migrn_ops; + func_len =pci_resource_len (pdev,VFIO_PCI_BAR2_REGION_INDEX ) >>1 ; + drv_mode =hisi_acc_vf_get_drv_mode (pf_qm); +if (drv_mode ==HW_ACC_MIG_VF_CTRL && func_len <PAGE_SIZE ) +pci_warn (pdev,"migration not supported on 64KB pages with QM_HW_V3\n" );else -pci_warn (pdev,"migration support failed, continue with generic interface\n" ); + ops = &hisi_acc_vfio_pci_migrn_ops; } hisi_acc_vdev = vfio_alloc_device(hisi_acc_vf_core_device,
@@ -1687,6 +1693,8 @@ static int hisi_acc_vfio_pci_probe(struct pci_dev *pdev, const struct pci_deviceif (IS_ERR (hisi_acc_vdev))return PTR_ERR (hisi_acc_vdev); + hisi_acc_vdev->drv_mode = drv_mode; +dev_set_drvdata (&pdev->dev, hisi_acc_vdev); ret =vfio_pci_core_register_device (&hisi_acc_vdev->core_device);if (ret)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1773/2651 nvmet-fc: dont drop the last assoc reference in nvmet_fc_delete_ctrl()
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Palla Raghunath <[email protected]>
[ Upstream commit 165301b5e2fd765fa05ea1044bbca8ba79820197 ]
syzbot hit a recursive locking report on subsys->lock when a subsystem is unlinked from an FC port.
nvmet_port_del_ctrls() holds subsys->lock while it calls ->delete_ctrl() for each controller. nvmet_fc_delete_ctrl() grabs a reference on the association, queues del_work and then drops the reference. If del_work gets to run to completion before that put, ours is the last reference. Freeing the assoc tears down the queues, the last nvmet_cq_put() drops the last ctrl reference, and nvmet_ctrl_free() goes for subsys->lock again:
WARNING: possible recursive locking detected
...
nvmet_ctrl_free+0xa6/0x8e0 drivers/nvme/target/core.c:1766 nvmet_cq_put+0x158/0x200 drivers/nvme/target/core.c:848 nvmet_fc_target_assoc_free+0x418/0x2220 drivers/nvme/target/fc.c:1173 nvmet_fc_delete_ctrl+0x717/0x7e0 drivers/nvme/target/fc.c:1581 nvmet_port_del_ctrls+0xfb/0x150 drivers/nvme/target/core.c:311 nvmet_port_subsys_drop_link+0x1e8/0x310 drivers/nvme/target/configfs.c:1119
It's a real hang, not only a lockdep warning. I reproduced it with fcloop by putting an msleep() before the put: rm on the configfs link gets stuck in D state for good.
I don't think we need that reference at all. del_work does list_del_rcu() and synchronize_rcu() before it drops the initial reference, so an assoc we find on assoc_list can't go away before rcu_read_unlock(). nvmet_fc_schedule_delete_assoc() doesn't sleep, so just call it inside the RCU section and get rid of the get/put. If the assoc is already being deleted, terminating is set and the call is a no-op, which matches what happened before when the get failed.
With the same msleep() in place the patched kernel unlinks cleanly and the assoc is freed from the workqueue.
--- drivers/nvme/target/fc.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
drivers/nvme/target/fc.c +9 -6
@@ -1567,8 +1567,14 @@ nvmet_fc_delete_ctrl(struct nvmet_ctrl *ctrl)list_for_each_entry_rcu (assoc, &tgtport->assoc_list, a_list) { queue = assoc->queues[0 ];if (queue && queue->nvme_sq.ctrl == ctrl) { -if (nvmet_fc_tgt_a_get (assoc)) - found_ctrl = true; +/* +* No assoc reference here: we're called with +* subsys->lock held, and if del_work beat us, +* our put would free the ctrl under that lock. +* RCU keeps the assoc alive until unlock. +*/ +nvmet_fc_schedule_delete_assoc (assoc); + found_ctrl = true;break ; } }
@@ -1576,11 +1582,8 @@ nvmet_fc_delete_ctrl(struct nvmet_ctrl *ctrl)nvmet_fc_tgtport_put (tgtport); -if (found_ctrl) { -nvmet_fc_schedule_delete_assoc (assoc); -nvmet_fc_tgt_a_put (assoc); +if (found_ctrl)return ; - }spin_lock_irqsave (&nvmet_fc_tgtlock, flags); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1774/2651 nvmet-auth: reject undersized AUTH_SEND payloads
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sung Byeongchan <[email protected]>
[ Upstream commit c9359401036e8294c007a10e8c8d8da7030fcc76 ]
nvmet_execute_auth_send() allocates and copies the initiator-supplied transfer length, then reads auth_type and auth_id through a common DHCHAP message pointer. The existing zero and transfer-length checks do not ensure that both common-header bytes are present.
An unauthenticated NVMe/TCP initiator can complete ICReq and admin CONNECT, then send AUTH_SEND with tl equal to one. KASAN reports a one-byte slab out-of-bounds read when auth_id is loaded.
Reject payloads that do not cover the common auth_type/auth_id header before allocating or parsing them. The one-byte trigger and header-minus-one boundary were cleanly rejected in three fixed fresh-boot runs. Exact-header, valid DHCHAP, wrong-type, mismatch, and zero-length controls remained clean, and a following valid AUTH_SEND on the same connection received a response. The touched source is unchanged at 0c2669a9f4a1d607e7591ae50ccf3c432a0aff08, where the patch applies and builds cleanly.
The demonstrated impact is unauthenticated pre-authentication target-kernel denial of service. No disclosure, controlled write, RCE, or LPE was demonstrated. The source reproducer and complete logs are available on request and are not included in this public report.
OpenAI Codex assisted source inspection, test design, patch drafting, and evidence organization.
--- drivers/nvme/target/fabrics-cmd-auth.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/nvme/target/fabrics-cmd-auth.c +6 -0
@@ -301,6 +301,12 @@ void nvmet_execute_auth_send(struct nvmet_req *req)nvmet_check_transfer_len (req, tl);return ; } +if (tl < offsetof(struct nvmf_auth_dhchap_success2_data , rsvd1)) { + status =NVME_SC_INVALID_FIELD |NVME_STATUS_DNR ; + req->error_loc = + offsetof(struct nvmf_auth_send_command , tl); + goto done; + } d =kmalloc (tl,GFP_KERNEL );if (!d) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1775/2651 nvme: pass partition flags to passthrough checks
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yao Sang <[email protected]>
[ Upstream commit 6908a702955929b0876baac9fdc57070780a76f0 ]
nvme_user_cmd() handles NVME_IOCTL_IO_CMD on namespace block devices, including partitions. It receives flags identifying a partition, but passes 0 to nvme_cmd_allowed(), bypassing the partition guard and allowing unprivileged passthrough commands to access sectors outside the partition.
Pass flags to the permission check, rejecting unprivileged commands on partitions.
--- drivers/nvme/host/ioctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvme/host/ioctl.c +1 -1
@@ -343,7 +343,7 @@ static int nvme_user_cmd(struct nvme_ctrl *ctrl, struct nvme_ns *ns, c.common.cdw14 =cpu_to_le32 (cmd.cdw14); c.common.cdw15 =cpu_to_le32 (cmd.cdw15); -if (!nvme_cmd_allowed (ctrl, ns, &c,0 , open_for_write)) +if (!nvme_cmd_allowed (ctrl, ns, &c, flags, open_for_write))return -EACCES ;if (cmd.timeout_ms)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1776/2651 firmware: cs_dsp: clear dsp->running on the cs_dsp_run() error path
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mingxuan Guo <[email protected]>
[ Upstream commit ad6be54d13496a0b5c6d1edeea99504e438cdb7a ]
cs_dsp_run() sets dsp->running = true once the core has been started, but the error path below it only stops and disables the core, leaving the flag set. The first thing that can fail after that point is the post_run client hook, and it is reachable in mainline: wm_adsp registers wm_adsp_event_post_run(), which can fail in wm_adsp_buffer_init().
The core is then stopped and disabled, but dsp->running still reads true, and that stale state is acted on elsewhere: cs_dsp_coeff_write_ctrl() and cs_dsp_coeff_read_ctrl() talk to the DSP when ctl->dsp->running is set, and client drivers use the flag to decide whether the firmware is up (cs35l41 checks cs_dsp.running before its early events and on hibernate/resume).
The flag cannot simply be moved below the hook: post_run hooks such as wm_adsp_event_post_run() read controls while they run, and cs_dsp_coeff_read_ctrl() only goes to the DSP when the flag is set.
Clear the flag on the error path, before the core is stopped - the order cs_dsp_stop() already uses.
--- drivers/firmware/cirrus/cs_dsp.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/firmware/cirrus/cs_dsp.c +2 -0
@@ -2960,6 +2960,8 @@ int cs_dsp_run(struct cs_dsp *dsp)return 0 ; err: + dsp->running = false; +if (dsp->ops->stop_core) dsp->ops->stop_core (dsp);if (dsp->ops->disable_core)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1777/2651 ASoC: amd: acp: Fix .close() being skipped on rollback
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit 2c3400aa9f397da48a6760f5e84438973e01a00c ]
snd_pcm_hw_constraint_integer() may return 1, which is then returned from acp_dma_open(). ASoC only marks the component as opened when .open() returns 0, so .close() can be skipped on rollback.
Return 0 explicitly on success.
--- sound/soc/amd/acp/acp-platform.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/amd/acp/acp-platform.c +1 -1
@@ -248,7 +248,7 @@ static int acp_dma_open(struct snd_soc_component *component, struct snd_pcm_subslist_add_tail (&stream->list, &chip->stream_list);spin_unlock_irq (&chip->acp_lock); -return ret; +return 0 ; } static int acp_dma_hw_params(struct snd_soc_component *component,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1778/2651 ASoC: amd: ps: Fix acp63_pdm_dma_close() being skipped on rollback
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit 172888114dda96492d40e4a6e0ed16146cb76e2b ]
snd_pcm_hw_constraint_integer() may return 1, which is then returned from acp63_pdm_dma_open(). ASoC only marks the component as opened when .open() returns 0, so .close() can be skipped on rollback.
Return 0 explicitly on success.
--- sound/soc/amd/ps/ps-pdm-dma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/amd/ps/ps-pdm-dma.c +1 -1
@@ -211,7 +211,7 @@ static int acp63_pdm_dma_open(struct snd_soc_component *component, pdm_data->acp63_base = adata->acp63_base; runtime->private_data = pdm_data; -return ret; +return 0 ; } static int acp63_pdm_dma_hw_params(struct snd_soc_component *component,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1779/2651 ASoC: amd: ps: Fix acp63_sdw_dma_close() being skipped on rollback
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit 45dd2b22ea8934ed69dd05e6ecbf3c66ac3baebf ]
snd_pcm_hw_constraint_integer() may return 1, which is then returned from acp63_sdw_dma_open(). ASoC only marks the component as opened when .open() returns 0, so .close() can be skipped on rollback.
Return 0 explicitly on success.
--- sound/soc/amd/ps/ps-sdw-dma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/amd/ps/ps-sdw-dma.c +1 -1
@@ -337,7 +337,7 @@ static int acp63_sdw_dma_open(struct snd_soc_component *component, stream->stream_id = cpu_dai->id; stream->instance = amd_manager->instance; runtime->private_data = stream; -return ret; +return 0 ; } static int acp63_sdw_dma_hw_params(struct snd_soc_component *component,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1780/2651 ASoC: amd: raven: Fix acp3x_dma_close() being skipped on rollback
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit 37ceef26df57c4a86a5e984b1951995aa96d4342 ]
snd_pcm_hw_constraint_integer() may return 1, which is then returned from acp3x_dma_open(). ASoC only marks the component as opened when .open() returns 0, so .close() can be skipped on rollback.
Return 0 explicitly on success.
--- sound/soc/amd/raven/acp3x-pcm-dma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/amd/raven/acp3x-pcm-dma.c +1 -1
@@ -237,7 +237,7 @@ static int acp3x_dma_open(struct snd_soc_component *component, i2s_data->acp3x_base = adata->acp3x_base; runtime->private_data = i2s_data; -return ret; +return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1781/2651 ASoC: amd: renoir: Fix acp_pdm_dma_close() being skipped on rollback
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit a92571113ef297840270e4d8d4263a842302c9c4 ]
snd_pcm_hw_constraint_integer() may return 1, which is then returned from acp_pdm_dma_open(). ASoC only marks the component as opened when .open() returns 0, so .close() can be skipped on rollback.
Return 0 explicitly on success.
--- sound/soc/amd/renoir/acp3x-pdm-dma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/amd/renoir/acp3x-pdm-dma.c +1 -1
@@ -233,7 +233,7 @@ static int acp_pdm_dma_open(struct snd_soc_component *component, pdm_data->acp_base = adata->acp_base; runtime->private_data = pdm_data; -return ret; +return 0 ; } static int acp_pdm_dma_hw_params(struct snd_soc_component *component,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1782/2651 ASoC: amd: vangogh: Fix acp5x_dma_close() being skipped on rollback
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit 38559fcd1c518a33055ef0a2cf7c04b57bfa9215 ]
snd_pcm_hw_constraint_integer() may return 1, which is then returned from acp5x_dma_open(). ASoC only marks the component as opened when .open() returns 0, so .close() can be skipped on rollback.
Return 0 explicitly on success.
--- sound/soc/amd/vangogh/acp5x-pcm-dma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/amd/vangogh/acp5x-pcm-dma.c +1 -1
@@ -231,7 +231,7 @@ static int acp5x_dma_open(struct snd_soc_component *component, } i2s_data->acp5x_base = adata->acp5x_base; runtime->private_data = i2s_data; -return ret; +return 0 ; } static int acp5x_dma_hw_params(struct snd_soc_component *component,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1783/2651 ASoC: amd: yc: Fix acp6x_pdm_dma_close() being skipped on rollback
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit 06654a3ef5137719be880a6cd12bd453050eafc5 ]
snd_pcm_hw_constraint_integer() may return 1, which is then returned from acp6x_pdm_dma_open(). ASoC only marks the component as opened when .open() returns 0, so .close() can be skipped on rollback.
Return 0 explicitly on success.
--- sound/soc/amd/yc/acp6x-pdm-dma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/amd/yc/acp6x-pdm-dma.c +1 -1
@@ -209,7 +209,7 @@ static int acp6x_pdm_dma_open(struct snd_soc_component *component, pdm_data->acp6x_base = adata->acp6x_base; runtime->private_data = pdm_data; -return ret; +return 0 ; } static int acp6x_pdm_dma_hw_params(struct snd_soc_component *component,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1784/2651 ASoC: atmel: atmel-pcm-pdc: Fix atmel_pcm_close() being skipped on rollback
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit 50aaca643038774b6779c911c4f96bc7e0d607e9 ]
snd_pcm_hw_constraint_integer() may return 1, which is then returned from atmel_pcm_open(). ASoC only marks the component as opened when .open() returns 0, so .close() can be skipped on rollback.
Return 0 explicitly on success.
--- sound/soc/atmel/atmel-pcm-pdc.c | 2 ++ 1 file changed, 2 insertions(+)
sound/soc/atmel/atmel-pcm-pdc.c +2 -0
@@ -295,6 +295,8 @@ static int atmel_pcm_open(struct snd_soc_component *component, } runtime->private_data = prtd; +return 0 ; + out:return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1785/2651 ASoC: imx-pcm-rpmsg: Fix imx_rpmsg_pcm_close() being skipped on rollback
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit 85e56c3bbb7e8ea4626f8653afaef0d79d9cb7ba ]
snd_pcm_hw_constraint_integer() may return 1, which is then returned from imx_rpmsg_pcm_open(). ASoC only marks the component as opened when .open() returns 0, so .close() can be skipped on rollback.
Return 0 explicitly on success.
--- sound/soc/fsl/imx-pcm-rpmsg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/fsl/imx-pcm-rpmsg.c +1 -1
@@ -269,7 +269,7 @@ static int imx_rpmsg_pcm_open(struct snd_soc_component *component, info->stream_timer[substream->stream].substream = substream;timer_setup (&info->stream_timer[substream->stream].timer, imx_rpmsg_timer_callback,0 ); -return ret; +return 0 ; } static int imx_rpmsg_pcm_close(struct snd_soc_component *component,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1786/2651 ASoC: intel: atom: Fix .shutdown() being skipped on rollback
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit e3bb575811042ca30ac9b7b4dacc74aab8efa512 ]
snd_pcm_hw_constraint_integer() may return 1, which is then returned from sst_media_open(). ASoC only marks the DAI as started when .startup() returns 0, so .shutdown() can be skipped on rollback.
Return 0 explicitly on success.
--- sound/soc/intel/atom/sst-mfld-platform-pcm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/intel/atom/sst-mfld-platform-pcm.c +1 -1
@@ -341,7 +341,7 @@ static int sst_media_open(struct snd_pcm_substream *substream, stream =NULL ; -return ret_val; +return 0 ; } static void sst_media_close(struct snd_pcm_substream *substream,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1787/2651 ASoC: renesas: msiof: Fix msiof_close() being skipped on rollback
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit b7c58a55fd9b71c0b11b0365fdf53f49702c39b5 ]
snd_pcm_hw_constraint_integer() may return 1, which is then returned from msiof_open(). ASoC only marks the component as opened when .open() returns 0, so .close() can be skipped on rollback.
Return 0 explicitly on success.
--- sound/soc/renesas/rcar/msiof.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
sound/soc/renesas/rcar/msiof.c +4 -2
@@ -427,10 +427,12 @@ static int msiof_open(struct snd_soc_component *component, ret =snd_pcm_hw_constraint_integer (substream->runtime,SNDRV_PCM_HW_PARAM_PERIODS ); open_err_dma: -if (ret <0 ) +if (ret <0 ) {dma_release_channel (chan); +return ret; + } -return ret; +return 0 ; } static int msiof_close(struct snd_soc_component *component,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1788/2651 ASoC: atmel-i2s: fix MCK generator error handling
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit 2e2da92de9bffd2cdbb9a2558fe60de7f1bb09e3 ]
Disable the gclk and reset the MCK configuration when an error occurs while enabling the MCK generator.
This prevents the gclk from remaining enabled after a failed clock configuration.
--- sound/soc/atmel/atmel-i2s.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)
sound/soc/atmel/atmel-i2s.c +13 -3
@@ -466,11 +466,21 @@ static int atmel_i2s_switch_mck_generator(struct atmel_i2s_dev *dev, mr |=ATMEL_I2SC_MR_IMCKMODE_I2SMCK ; ret =regmap_update_bits (dev->regmap,ATMEL_I2SC_MR , mr_mask, mr);if (ret) -return ret; + goto err_disable_gclk;/* Finally enable the I2S Master Clock generator. */ -return regmap_write (dev->regmap,ATMEL_I2SC_CR , -ATMEL_I2SC_CR_CKEN ); + ret =regmap_write (dev->regmap,ATMEL_I2SC_CR ,ATMEL_I2SC_CR_CKEN ); +if (ret) + goto err_reset_mr; + +return 0 ; + +err_reset_mr: +regmap_update_bits (dev->regmap,ATMEL_I2SC_MR , mr_mask,0 ); +err_disable_gclk: +clk_disable_unprepare (dev->gclk); + +return ret; } static int atmel_i2s_trigger(struct snd_pcm_substream *substream, int cmd,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1789/2651 ASoC: atmel-i2s: use optional API for muxclk
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit be952abd69c1f2c845e42e72147751e4c910cd81 ]
The muxclk is an optional clock according to the device tree binding.
Use devm_clk_get_optional() to handle the optional muxclk instead of handling the missing clock explicitly.
When muxclk is not available, devm_clk_get_optional() returns NULL. clk_set_parent() returns 0 when passed NULL, preserving the existing behavior.
Unlike the existing code, errors other than -EPROBE_DEFER are now returned instead of being silently ignored.
--- sound/soc/atmel/atmel-i2s.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-)
sound/soc/atmel/atmel-i2s.c +5 -11
@@ -589,21 +589,15 @@ static int atmel_i2s_sama5d2_mck_init(struct atmel_i2s_dev *dev, struct device_node *np) {struct clk *muxclk; -int err;if (!dev->gclk)return 0 ; -/* muxclk is optional, so we return error for probe defer only */ - muxclk =devm_clk_get (dev->dev,"muxclk" ); -if (IS_ERR (muxclk)) { - err =PTR_ERR (muxclk); -if (err == -EPROBE_DEFER ) -return -EPROBE_DEFER ; -dev_dbg (dev->dev, -"failed to get the I2S clock control: %d\n" , err); -return 0 ; - } +/* muxclk is optional */ + muxclk =devm_clk_get_optional (dev->dev,"muxclk" ); +if (IS_ERR (muxclk)) +return dev_err_probe (dev->dev,PTR_ERR (muxclk), +"failed to get the I2S clock control\n" );return clk_set_parent (muxclk, dev->gclk); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1790/2651 ASoC: atmel-i2s: use optional API for gclk
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit b431a055fb7688c0d3725fa3c55aeef852991178 ]
The gclk is an optional clock according to the device tree binding.
Use devm_clk_get_optional() to handle the optional gclk directly.
Unlike the existing code, errors other than -EPROBE_DEFER are now returned instead of being silently ignored.
--- sound/soc/atmel/atmel-i2s.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
sound/soc/atmel/atmel-i2s.c +4 -7
@@ -670,13 +670,10 @@ static int atmel_i2s_probe(struct platform_device *pdev) }/* Get audio clock to generate the I2S Master Clock (I2S_MCK) */ - dev->gclk =devm_clk_get (&pdev->dev,"gclk" ); -if (IS_ERR (dev->gclk)) { -if (PTR_ERR (dev->gclk) == -EPROBE_DEFER ) -return -EPROBE_DEFER ; -/* Master Mode not supported */ - dev->gclk =NULL ; - } + dev->gclk =devm_clk_get_optional (&pdev->dev,"gclk" ); +if (IS_ERR (dev->gclk)) +return PTR_ERR (dev->gclk); + dev->dev = &pdev->dev; dev->regmap = regmap;platform_set_drvdata (pdev, dev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1791/2651 ASoC: mediatek: mt8196: fix APLL mux error handling
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit 5a0caca149f2938cd82b96b631c5a144329bd30e ]
Propagate errors from clock operations in the enable path and clean up previously enabled clocks when a later operation fails.
For the disable path, continue disabling all clocks even if a clock operation fails. Do not propagate the errors so that the disable path can perform as much cleanup as possible.
--- sound/soc/mediatek/mt8196/mt8196-afe-clk.c | 56 +++++++++++++--------- 1 file changed, 34 insertions(+), 22 deletions(-)
sound/soc/mediatek/mt8196/mt8196-afe-clk.c +34 -22
@@ -220,33 +220,39 @@ static int apll1_mux_setting(struct mtk_base_afe *afe, bool enable) ret =mt8196_afe_set_clk_rate (afe, afe_priv->clk[MT8196_CLK_VLP_MUX_AUD_ENG1 ],MT8196_AUD_ENG1_CLK );if (ret) -return ret; + goto err_disable_eng1; ret =mt8196_afe_enable_clk (afe, afe_priv->clk[MT8196_CLK_VLP_MUX_AUDIO_H ]);if (ret) -return ret; + goto err_restore_eng1; ret =mt8196_afe_set_clk_rate (afe, afe_priv->clk[MT8196_CLK_VLP_MUX_AUDIO_H ], apll_rate);if (ret) -return ret; + goto err_disable_audio_h; }else { - ret =mt8196_afe_set_clk_rate (afe, afe_priv->clk[MT8196_CLK_VLP_MUX_AUD_ENG1 ], -MT8196_AFE_26M ); -if (ret) -return ret; +mt8196_afe_set_clk_rate (afe, afe_priv->clk[MT8196_CLK_VLP_MUX_AUD_ENG1 ], +MT8196_AFE_26M );mt8196_afe_disable_clk (afe, afe_priv->clk[MT8196_CLK_VLP_MUX_AUD_ENG1 ]); - ret =mt8196_afe_set_clk_rate (afe, afe_priv->clk[MT8196_CLK_VLP_MUX_AUDIO_H ], -MT8196_AFE_26M ); -if (ret) -return ret; +mt8196_afe_set_clk_rate (afe, afe_priv->clk[MT8196_CLK_VLP_MUX_AUDIO_H ], +MT8196_AFE_26M );mt8196_afe_disable_clk (afe, afe_priv->clk[MT8196_CLK_VLP_MUX_AUDIO_H ]); }return 0 ; + +err_disable_audio_h: +mt8196_afe_disable_clk (afe, afe_priv->clk[MT8196_CLK_VLP_MUX_AUDIO_H ]); +err_restore_eng1: +mt8196_afe_set_clk_rate (afe, afe_priv->clk[MT8196_CLK_VLP_MUX_AUD_ENG1 ], +MT8196_AFE_26M ); +err_disable_eng1: +mt8196_afe_disable_clk (afe, afe_priv->clk[MT8196_CLK_VLP_MUX_AUD_ENG1 ]); + +return ret; }static int apll2_mux_setting (struct mtk_base_afe *afe,bool enable)
@@ -268,33 +274,39 @@ static int apll2_mux_setting(struct mtk_base_afe *afe, bool enable) ret =mt8196_afe_set_clk_rate (afe, afe_priv->clk[MT8196_CLK_VLP_MUX_AUD_ENG2 ],MT8196_AUD_ENG2_CLK );if (ret) -return ret; + goto err_disable_eng2; ret =mt8196_afe_enable_clk (afe, afe_priv->clk[MT8196_CLK_VLP_MUX_AUDIO_H ]);if (ret) -return ret; + goto err_restore_eng2; ret =mt8196_afe_set_clk_rate (afe, afe_priv->clk[MT8196_CLK_VLP_MUX_AUDIO_H ], apll_rate);if (ret) -return ret; + goto err_disable_audio_h; }else { - ret =mt8196_afe_set_clk_rate (afe, afe_priv->clk[MT8196_CLK_VLP_MUX_AUD_ENG2 ], -MT8196_AFE_26M ); -if (ret) -return ret; +mt8196_afe_set_clk_rate (afe, afe_priv->clk[MT8196_CLK_VLP_MUX_AUD_ENG2 ], +MT8196_AFE_26M );mt8196_afe_disable_clk (afe, afe_priv->clk[MT8196_CLK_VLP_MUX_AUD_ENG2 ]); - ret =mt8196_afe_set_clk_rate (afe, afe_priv->clk[MT8196_CLK_VLP_MUX_AUDIO_H ], -MT8196_AFE_26M ); -if (ret) -return ret; +mt8196_afe_set_clk_rate (afe, afe_priv->clk[MT8196_CLK_VLP_MUX_AUDIO_H ], +MT8196_AFE_26M );mt8196_afe_disable_clk (afe, afe_priv->clk[MT8196_CLK_VLP_MUX_AUDIO_H ]); }return 0 ; + +err_disable_audio_h: +mt8196_afe_disable_clk (afe, afe_priv->clk[MT8196_CLK_VLP_MUX_AUDIO_H ]); +err_restore_eng2: +mt8196_afe_set_clk_rate (afe, afe_priv->clk[MT8196_CLK_VLP_MUX_AUD_ENG2 ], +MT8196_AFE_26M ); +err_disable_eng2: +mt8196_afe_disable_clk (afe, afe_priv->clk[MT8196_CLK_VLP_MUX_AUD_ENG2 ]); + +return ret; }int mt8196_apll1_enable (struct mtk_base_afe *afe)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1792/2651 ASoC: mediatek: mt8196: fix APLL enable error handling
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit 23239cabb6d130c81d2c5389ed2dbdcfc239a939 ]
Propagate errors from the APLL mux and clock enable operations instead of ignoring them or returning success on failure.
Clean up previously enabled clocks and disable the APLL tuner when a later clock operation fails, restoring the APLL mux state before returning the error.
--- sound/soc/mediatek/mt8196/mt8196-afe-clk.c | 47 ++++++++++++++++------ 1 file changed, 34 insertions(+), 13 deletions(-)
sound/soc/mediatek/mt8196/mt8196-afe-clk.c +34 -13
@@ -314,15 +314,17 @@ int mt8196_apll1_enable(struct mtk_base_afe *afe)int ret;/* setting for APLL */ -apll1_mux_setting (afe, true); + ret =apll1_mux_setting (afe, true); +if (ret) +return ret; ret =mt8196_afe_enable_top_cg (afe,MT8196_CG_APLL1_CK );if (ret) - goto err_clk_apll1; + goto err_disable_mux; ret =mt8196_afe_enable_top_cg (afe,MT8196_PDN_APLL_TUNER1 );if (ret) - goto err_clk_apll1_tuner; + goto err_disable_apll1_ck;/* sel 44.1kHz:1, apll_div:7, upper bound:3 */ regmap_update_bits(afe->regmap, AFE_APLL1_TUNER_CFG,
@@ -336,14 +338,22 @@ int mt8196_apll1_enable(struct mtk_base_afe *afe) 0x1 << FREQ_TUNER_EN_SFT);/* audio apll1 on */ -mt8196_afe_enable_top_cg (afe,MT8196_AUDIO_APLL1_EN_ON ); + ret =mt8196_afe_enable_top_cg (afe,MT8196_AUDIO_APLL1_EN_ON ); +if (ret) + goto err_disable_tuner;return 0 ; -err_clk_apll1_tuner: +err_disable_tuner: +regmap_update_bits (afe->regmap,AFE_APLL1_TUNER_CFG , +FREQ_TUNER_EN_MASK_SFT , +0x0 );mt8196_afe_disable_top_cg (afe,MT8196_PDN_APLL_TUNER1 ); -err_clk_apll1: +err_disable_apll1_ck:mt8196_afe_disable_top_cg (afe,MT8196_CG_APLL1_CK ); +err_disable_mux: +apll1_mux_setting (afe, false); +return ret; }
@@ -367,15 +377,17 @@ int mt8196_apll2_enable(struct mtk_base_afe *afe)int ret;/* setting for APLL */ -apll2_mux_setting (afe, true); + ret =apll2_mux_setting (afe, true); +if (ret) +return ret; ret =mt8196_afe_enable_top_cg (afe,MT8196_CG_APLL2_CK );if (ret) - goto err_clk_apll2; + goto err_disable_mux; ret =mt8196_afe_enable_top_cg (afe,MT8196_PDN_APLL_TUNER2 );if (ret) - goto err_clk_apll2_tuner; + goto err_disable_apll2_ck;/* sel 48kHz: 2, apll_div: 7, upper bound: 3*/ regmap_update_bits(afe->regmap, AFE_APLL2_TUNER_CFG,
@@ -389,14 +401,23 @@ int mt8196_apll2_enable(struct mtk_base_afe *afe) 0x1 << FREQ_TUNER_EN_SFT);/* audio apll2 on */ -mt8196_afe_enable_top_cg (afe,MT8196_AUDIO_APLL2_EN_ON ); + ret =mt8196_afe_enable_top_cg (afe,MT8196_AUDIO_APLL2_EN_ON ); +if (ret) + goto err_disable_tuner2; +return 0 ; -err_clk_apll2_tuner: +err_disable_tuner2: +regmap_update_bits (afe->regmap,AFE_APLL2_TUNER_CFG , +FREQ_TUNER_EN_MASK_SFT , +0x0 );mt8196_afe_disable_top_cg (afe,MT8196_PDN_APLL_TUNER2 ); -err_clk_apll2: +err_disable_apll2_ck:mt8196_afe_disable_top_cg (afe,MT8196_CG_APLL2_CK ); -return 0 ; +err_disable_mux: +apll2_mux_setting (afe, false); + +return ret; }void mt8196_apll2_disable (struct mtk_base_afe *afe)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1793/2651 ASoC: mediatek: mt8196: fix MCK error handling
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit bc0cd0eb030389a78885561dc92f087e7595458a ]
Disable the clock if setting its rate fails after the clock has been enabled, preventing it from being left enabled on the error path.
--- sound/soc/mediatek/mt8196/mt8196-afe-clk.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
sound/soc/mediatek/mt8196/mt8196-afe-clk.c +3 -1
@@ -502,8 +502,10 @@ int mt8196_mck_enable(struct mtk_base_afe *afe, int mck_id, int rate)return ret; ret =mt8196_afe_set_clk_rate (afe, afe_priv->clk[div_clk_id], rate); -if (ret) +if (ret) { +mt8196_afe_disable_clk (afe, afe_priv->clk[div_clk_id]);return ret; + }return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1794/2651 ASoC: mediatek: mt8196: fix register access clock error handling
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit 2844ba593741a9c9061b8c99790a47ffeed4114d ]
Propagate errors from clock operations and disable previously enabled clocks when a later operation fails.
This ensures that the register access clocks are properly cleaned up on the error path.
--- sound/soc/mediatek/mt8196/mt8196-afe-clk.c | 25 +++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-)
sound/soc/mediatek/mt8196/mt8196-afe-clk.c +20 -5
@@ -546,26 +546,41 @@ int mt8196_afe_enable_reg_rw_clk(struct mtk_base_afe *afe)int ret;/* bus clock for AFE external access, like DRAM */ -mt8196_afe_enable_clk (afe, afe_priv->clk[MT8196_CLK_TOP_ADSP_SEL ]); + ret =mt8196_afe_enable_clk (afe, afe_priv->clk[MT8196_CLK_TOP_ADSP_SEL ]); +if (ret) +return ret;/* bus clock for AFE internal access, like AFE SRAM */ -mt8196_afe_enable_clk (afe, afe_priv->clk[MT8196_CLK_VLP_MUX_AUDIOINTBUS ]); + ret =mt8196_afe_enable_clk (afe, afe_priv->clk[MT8196_CLK_VLP_MUX_AUDIOINTBUS ]); +if (ret) + goto err_disable_adsp_sel; ret =mt8196_afe_set_clk_rate (afe, afe_priv->clk[MT8196_CLK_VLP_MUX_AUDIOINTBUS ],MT8196_AFE_26M );if (ret) -return ret; + goto err_disable_audiointbus;/* enable audio h clock */ -mt8196_afe_enable_clk (afe, afe_priv->clk[MT8196_CLK_VLP_MUX_AUDIO_H ]); + ret =mt8196_afe_enable_clk (afe, afe_priv->clk[MT8196_CLK_VLP_MUX_AUDIO_H ]); +if (ret) + goto err_disable_audiointbus; ret =mt8196_afe_set_clk_rate (afe, afe_priv->clk[MT8196_CLK_VLP_MUX_AUDIO_H ],MT8196_AFE_26M );if (ret) -return ret; + goto err_disable_audio_h;/* AFE hw clock */ /* IPM2.0: USE HOPPING & 26M */ /* set in the regmap_register_patch */ return 0 ; + +err_disable_audio_h: +mt8196_afe_disable_clk (afe, afe_priv->clk[MT8196_CLK_VLP_MUX_AUDIO_H ]); +err_disable_audiointbus: +mt8196_afe_disable_clk (afe, afe_priv->clk[MT8196_CLK_VLP_MUX_AUDIOINTBUS ]); +err_disable_adsp_sel: +mt8196_afe_disable_clk (afe, afe_priv->clk[MT8196_CLK_TOP_ADSP_SEL ]); + +return ret; }int mt8196_afe_disable_reg_rw_clk (struct mtk_base_afe *afe)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1795/2651 ASoC: mediatek: mt8196: propagate main clock errors
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit c33bc2dd217d249de7b1ddffb80b8e4a0c597cf3 ]
Propagate errors from the main clock enable and disable operations instead of always returning success.
--- sound/soc/mediatek/mt8196/mt8196-afe-clk.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
sound/soc/mediatek/mt8196/mt8196-afe-clk.c +2 -4
@@ -598,14 +598,12 @@ int mt8196_afe_disable_reg_rw_clk(struct mtk_base_afe *afe)int mt8196_afe_enable_main_clock (struct mtk_base_afe *afe) { -mt8196_afe_enable_top_cg (afe,MT8196_AUDIO_26M_EN_ON ); -return 0 ; +return mt8196_afe_enable_top_cg (afe,MT8196_AUDIO_26M_EN_ON ); }int mt8196_afe_disable_main_clock (struct mtk_base_afe *afe) { -mt8196_afe_disable_top_cg (afe,MT8196_AUDIO_26M_EN_ON ); -return 0 ; +return mt8196_afe_disable_top_cg (afe,MT8196_AUDIO_26M_EN_ON ); }int mt8196_init_clock (struct mtk_base_afe *afe)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1796/2651 ASoC: mediatek: mt8196: fix runtime resume error handling
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit 3a9a93cafb376541fecac10c5bb734cd2f26bfc8 ]
Propagate errors from regcache_sync() and main clock enable operations instead of ignoring them.
On failure, restore cache-only mode, disable register access clocks, and clear the 26M clock request as needed to clean up the runtime resume state.
--- sound/soc/mediatek/mt8196/mt8196-afe-pcm.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-)
sound/soc/mediatek/mt8196/mt8196-afe-pcm.c +15 -3
@@ -2211,7 +2211,7 @@ static int mt8196_afe_runtime_suspend(struct device *dev)static int mt8196_afe_runtime_resume (struct device *dev) {struct mtk_base_afe *afe =dev_get_drvdata (dev); -int ret =0 ; +int ret; ret =mt8196_afe_enable_reg_rw_clk (afe);if (ret)
@@ -2222,7 +2222,9 @@ static int mt8196_afe_runtime_resume(struct device *dev) goto skip_regmap; }regcache_cache_only (afe->regmap, false); -regcache_sync (afe->regmap); + ret =regcache_sync (afe->regmap); +if (ret) + goto err_set_cache_only;/* set audio 26M request */ regmap_update_bits (afe->regmap,AFE_SPM_CONTROL_REQ ,0x1 ,0x1 );
@@ -2233,10 +2235,20 @@ static int mt8196_afe_runtime_resume(struct device *dev) CPU_HD_ALIGN_MASK_SFT, 0 << CPU_HD_ALIGN_SFT);/* enable AFE */ -mt8196_afe_enable_main_clock (afe); + ret =mt8196_afe_enable_main_clock (afe); +if (ret) + goto err_reset_26m_req; skip_regmap:return 0 ; + +err_reset_26m_req: +regmap_update_bits (afe->regmap,AFE_SPM_CONTROL_REQ ,0x1 ,0x0 ); +err_set_cache_only: +regcache_cache_only (afe->regmap, true); +mt8196_afe_disable_reg_rw_clk (afe); + +return ret; }static int mt8196_afe_component_probe (struct snd_soc_component *component)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1797/2651 ASoC: mediatek: mt8196: propagate I2S clock errors
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit 6c14a59bc503fc9aa599f1ebc50777460145e8b4 ]
Propagate errors from APLL and MCK clock operations in the DAPM event callbacks instead of always returning success.
--- sound/soc/mediatek/mt8196/mt8196-dai-i2s.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-)
sound/soc/mediatek/mt8196/mt8196-dai-i2s.c +11 -6
@@ -985,27 +985,30 @@ static int mtk_apll_event(struct snd_soc_dapm_widget *w, {struct snd_soc_component *cmpnt =snd_soc_dapm_to_component (w->dapm);struct mtk_base_afe *afe =snd_soc_component_get_drvdata (cmpnt); +int ret;dev_dbg (cmpnt->dev,"name %s, event 0x%x\n" , w->name, event);switch (event) {case SND_SOC_DAPM_PRE_PMU :if (strcmp (w->name,APLL1_W_NAME ) ==0 ) -mt8196_apll1_enable (afe); + ret =mt8196_apll1_enable (afe);else -mt8196_apll2_enable (afe); + ret =mt8196_apll2_enable (afe);break ;case SND_SOC_DAPM_POST_PMD :if (strcmp (w->name,APLL1_W_NAME ) ==0 )mt8196_apll1_disable (afe);else mt8196_apll2_disable (afe); + ret =0 ;break ;default : + ret =0 ;break ; } -return 0 ; +return ret; } static int mtk_mclk_en_event(struct snd_soc_dapm_widget *w,
@@ -1015,6 +1018,7 @@ static int mtk_mclk_en_event(struct snd_soc_dapm_widget *w,struct snd_soc_component *cmpnt =snd_soc_dapm_to_component (w->dapm);struct mtk_base_afe *afe =snd_soc_component_get_drvdata (cmpnt);struct mtk_afe_i2s_priv *i2s_priv; +int ret;dev_dbg (cmpnt->dev,"name %s, event 0x%x\n" , w->name, event);
@@ -1025,17 +1029,18 @@ static int mtk_mclk_en_event(struct snd_soc_dapm_widget *w,switch (event) {case SND_SOC_DAPM_PRE_PMU : -mt8196_mck_enable (afe, i2s_priv->mclk_id, i2s_priv->mclk_rate); + ret =mt8196_mck_enable (afe, i2s_priv->mclk_id, i2s_priv->mclk_rate);break ;case SND_SOC_DAPM_POST_PMD : i2s_priv->mclk_rate =0 ; -mt8196_mck_disable (afe, i2s_priv->mclk_id); + ret =mt8196_mck_disable (afe, i2s_priv->mclk_id);break ;default : + ret =0 ;break ; } -return 0 ; +return ret; }static const struct snd_soc_dapm_widget mtk_dai_i2s_widgets[] = {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1798/2651 ASoC: mediatek: mt8196: propagate TDM clock errors
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit d09412f79d70402c44bb92d19eff5b9aea3087e6 ]
Propagate errors from BCK and MCK clock operations in the DAPM event callbacks instead of always returning success.
--- sound/soc/mediatek/mt8196/mt8196-dai-tdm.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
sound/soc/mediatek/mt8196/mt8196-dai-tdm.c +10 -6
@@ -256,22 +256,24 @@ static int mtk_tdm_bck_en_event(struct snd_soc_dapm_widget *w,struct mt8196_afe_private *afe_priv = afe->platform_priv;int dai_id =get_tdm_id_by_name (w->name);struct mtk_afe_tdm_priv *tdm_priv = afe_priv->dai_priv[dai_id]; +int ret;dev_dbg (cmpnt->dev,"name %s, event 0x%x, dai_id %d\n" , w->name, event, dai_id);switch (event) {case SND_SOC_DAPM_PRE_PMU : -mt8196_mck_enable (afe, tdm_priv->bck_id, tdm_priv->bck_rate); + ret =mt8196_mck_enable (afe, tdm_priv->bck_id, tdm_priv->bck_rate);break ;case SND_SOC_DAPM_POST_PMD : -mt8196_mck_disable (afe, tdm_priv->bck_id); + ret =mt8196_mck_disable (afe, tdm_priv->bck_id);break ;default : + ret =0 ;break ; } -return 0 ; +return ret; } static int mtk_tdm_mck_en_event(struct snd_soc_dapm_widget *w,
@@ -283,23 +285,25 @@ static int mtk_tdm_mck_en_event(struct snd_soc_dapm_widget *w,struct mt8196_afe_private *afe_priv = afe->platform_priv;int dai_id =get_tdm_id_by_name (w->name);struct mtk_afe_tdm_priv *tdm_priv = afe_priv->dai_priv[dai_id]; +int ret;dev_dbg (cmpnt->dev,"name %s, event 0x%x, dai_id %d\n" , w->name, event, dai_id);switch (event) {case SND_SOC_DAPM_PRE_PMU : -mt8196_mck_enable (afe, tdm_priv->mclk_id, tdm_priv->mclk_rate); + ret =mt8196_mck_enable (afe, tdm_priv->mclk_id, tdm_priv->mclk_rate);break ;case SND_SOC_DAPM_POST_PMD : tdm_priv->mclk_rate =0 ; -mt8196_mck_disable (afe, tdm_priv->mclk_id); + ret =mt8196_mck_disable (afe, tdm_priv->mclk_id);break ;default : + ret =0 ;break ; } -return 0 ; +return ret; }static const struct snd_soc_dapm_widget mtk_dai_tdm_widgets[] = {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1799/2651 sh: sh7785lcr: Register the PCA9564 controller as I2C bus 0
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 3b8386ffc0c33b6b5a6a8e64e1487c1adec57dc9 ]
Before commit 44454baa7ca7 ("i2c: Dynamically assign adapter id if it wasn't explictly specified"), a negative ID was replaced by zero, and I2C bus zero was instantiated. Since that commit, a negative ID is passed verbatim, instantiating an I2C bus with a dynamic number. As SH boards still use i2c_register_board_info(0, ...) to register I2C devices, they rely on the I2C bus being bus zero.
The SH7785LCR is the only SH board whose I2C adapter has a negative ID and its PCA9564 controller becomes i2c-1, causing registration of the R2025S/D RTC to fail and hwclock not detecting /dev/rtc0.
Set the platform device ID to 0 so that the adapter is registered as bus zero again.
--- arch/sh/boards/board-sh7785lcr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/sh/boards/board-sh7785lcr.c +1 -1
@@ -256,7 +256,7 @@ static struct i2c_pca9564_pf_platform_data i2c_platform_data = {static struct platform_device i2c_device = { .name ="i2c-pca-platform" , - .id =-1 , + .id =0 , .dev = { .platform_data = &i2c_platform_data, },
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1800/2651 spi: spi-qpic-snand: skip BBM copy on regular raw reads
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gabor Juhos <[email protected]>
[ Upstream commit 2da46f1e9b980a38bc6afd417322ca4963725e16 ]
Trying to read the raw flash contents with nanddump, the second byte of the OOB area contains 0xff instead of the real data in the flash. This happens because the qcom_spi_read_last_cw() function unconditionally copies the bad block marker into the second byte of the output buffer.
Add a new flag to the controller's private data structure, and set it when only the first two bytes of the OOB area being read in raw mode. Also change the bad block copying code to run only when the flag is set.
This ensures that the SPI NAND framework still can read the BBM bytes, but on regular raw read, the output does not contain the duplicated marker byte.
--- drivers/spi/spi-qpic-snand.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
drivers/spi/spi-qpic-snand.c +13 -1
@@ -117,6 +117,7 @@ struct qpic_spi_nand {__le32 addr2;__le32 cmd;u32 num_cw; +bool bbm_read;bool oob_rw;bool page_rw;bool raw_rw;
@@ -453,6 +454,16 @@ static int qcom_spi_ecc_prepare_io_req_pipelined(struct nand_device *nand,if (req->mode ==MTD_OPS_RAW ) snandc->qspi->raw_rw = true; +/* +* Try to detect when the SPI NAND framework reads the first +* two bytes of the OOB area searching for bad block marker +* bytes. +*/ + snandc->qspi->bbm_read = req->mode ==MTD_OPS_RAW && + req->type ==NAND_PAGE_READ && + req->dataoffs ==0 && req->datalen ==0 && + req->ooboffs ==0 && req->ooblen ==2 ; +return 0 ; }
@@ -657,7 +668,8 @@ static int qcom_spi_read_last_cw(struct qcom_nand_controller *snandc,* This can be removed once single-byte bad block marker support * gets implemented in the SPINAND code. */ - snandc->data_buffer[bbpos +1 ] = snandc->data_buffer[bbpos]; +if (snandc->qspi->bbm_read) + snandc->data_buffer[bbpos +1 ] = snandc->data_buffer[bbpos];memcpy (op->data.buf.in, snandc->data_buffer + bbpos, op->data.nbytes);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1801/2651 perf symbol: Fix symbol loading from libbfd
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Namhyung Kim <[email protected]>
[ Upstream commit f814d9e6cdbef6413a72d6dd6d5e4e79e815cf44 ]
The dso__load() should return a positive number (number of symbols loaded) when it succeded to load symbols. But dso__load_bfd_symbols() only returns 0 and it's hard to check if it actually loaded symbols or not. Let's return the value of dso__has_symbol() and check it in dso__load() so that it can return 1 for success.
--- tools/perf/tests/pe-file-parsing.c | 2 +- tools/perf/util/libbfd.c | 2 +- tools/perf/util/symbol.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-)
tools/perf/tests/pe-file-parsing.c +1 -1
@@ -59,7 +59,7 @@ static int run_dir(const char *d)TEST_ASSERT_VAL ("Failed to get dso" , dso); ret =dso__load_bfd_symbols (dso, debugfile); -TEST_ASSERT_VAL ("Failed to load symbols" , ret ==0 ); +TEST_ASSERT_VAL ("Failed to load symbols" , ret >0 );dso__sort_by_name (dso); sym =dso__find_symbol_by_name (dso,"main" , &idx);
tools/perf/util/libbfd.c +1 -1
@@ -451,7 +451,7 @@ int dso__load_bfd_symbols(struct dso *dso, const char *debugfile)symbols__fixup_duplicate (dso__symbols (dso));dso__set_adjust_symbols (dso, true); - err =0 ; + err =dso__has_symbols (dso); out_free:free (symbols); out_close:
tools/perf/util/symbol.c +2 -2
@@ -1929,8 +1929,8 @@ int dso__load(struct dso *dso, struct map *map)if (nsexit)nsinfo__mountns_enter (dso__nsinfo (dso), &nsc); -if (bfdrc ==0 ) { - ret =0 ; +if (bfdrc >0 ) { + ret =1 ;break ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1802/2651 perf symbol: Add missing symsrc__destroy() for libbfd
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Namhyung Kim <[email protected]>
[ Upstream commit 35477b351e6a697c85dc7d37e5081621889f8e40 ]
When libbfd loaded symbols and there's a pending syms_ss, it'd be lost or overwrite existing symbols. Let's destroy it before breaking the loop so that it can safely return from the function.
--- tools/perf/util/symbol.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tools/perf/util/symbol.c +2 -1
@@ -1931,7 +1931,7 @@ int dso__load(struct dso *dso, struct map *map)if (bfdrc >0 ) { ret =1 ; -break ; + goto out_destroy; }if (!is_reg || sirc <0 )
@@ -1996,6 +1996,7 @@ int dso__load(struct dso *dso, struct map *map) ret += nr_plt; } +out_destroy:for (; ss_pos >0 ; ss_pos--)symsrc__destroy (&ss_[ss_pos -1 ]); out_free:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1803/2651 spi: axi-spi-engine: fix stale SYNC IRQ pending
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jonathan Santos <[email protected]>
[ Upstream commit ea29c686f96adcb505071ef228ba8047dc951fac ]
spi_engine_setup() sends a SYNC(1) command and polls SYNC_ID to confirm it was parsed by the FPGA, but never clears the corresponding interrupt pending bit (INT_PENDING[SYNC]). When the first real SPI transfer starts and INT_SYNC is enabled, that stale pending bit fires immediately, causing the IRQ handler to see the leftover SYNC_ID from setup, match it against the current transfer's ID, and prematurely signal completion before the hardware finishes.
This race manifests at low SPI clock frequencies (~2-3 MHz), where the FPGA takes long enough to execute the transfer that handler is parsed before it finishes. At higher SCLK rates the transfer completes fast enough that the issue is masked.
Fix this by clearing INT_PENDING[SYNC] after the polled SYNC, ensuring no stale interrupt is left pending.
--- drivers/spi/spi-axi-spi-engine.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/spi/spi-axi-spi-engine.c +10 -2
@@ -887,6 +887,7 @@ static int spi_engine_setup(struct spi_device *device)struct spi_controller *host = device->controller;struct spi_engine *spi_engine =spi_controller_get_devdata (host);unsigned int reg; +int ret;if (device->mode &SPI_CS_HIGH ) spi_engine->cs_inv |=BIT (spi_get_chipselect (device,0 ));
@@ -922,8 +923,15 @@ static int spi_engine_setup(struct spi_device *device)writel_relaxed (SPI_ENGINE_CMD_SYNC (1 ), spi_engine->base +SPI_ENGINE_REG_CMD_FIFO ); -return readl_relaxed_poll_timeout (spi_engine->base +SPI_ENGINE_REG_SYNC_ID , - reg, reg ==1 ,1 ,1000 ); + ret =readl_relaxed_poll_timeout (spi_engine->base +SPI_ENGINE_REG_SYNC_ID , + reg, reg ==1 ,1 ,1 *USEC_PER_MSEC ); + +/* Clear the stale SYNC pending bit so it doesn't fire when the IRQ is later enabled. */ +writel_relaxed (SPI_ENGINE_INT_SYNC , spi_engine->base +SPI_ENGINE_REG_INT_PENDING ); +/* Read back to flush posted write. */ +readl_relaxed (spi_engine->base +SPI_ENGINE_REG_INT_PENDING ); + +return ret; } static int spi_engine_transfer_one_message(struct spi_controller *host,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1804/2651 spi: axi-spi-engine: fix stale SYNC IRQ pending in trigger_enable
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jonathan Santos <[email protected]>
[ Upstream commit 18febc10a3538b9baa2f6e4481b434f20fdbd93c ]
spi_engine_trigger_enable() sends SYNC(1) and polls SYNC_ID, it never clears the INT_PENDING[SYNC] bit afterward. This leaves a stale pending interrupt that can fire spuriously when INT_SYNC is later enabled.
Simillarly to the fix on spi_engine_setup(), clear INT_PENDING[SYNC] after polling the SYNC_ID.
--- drivers/spi/spi-axi-spi-engine.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/spi/spi-axi-spi-engine.c +7 -1
@@ -1036,7 +1036,13 @@ static int spi_engine_trigger_enable(struct spi_offload *offload) spi_engine->base + SPI_ENGINE_REG_CMD_FIFO); ret =readl_relaxed_poll_timeout (spi_engine->base +SPI_ENGINE_REG_SYNC_ID , - reg, reg ==1 ,1 ,1000 ); + reg, reg ==1 ,1 ,1 *USEC_PER_MSEC ); + +/* Clear the stale SYNC pending bit so it doesn't fire when the IRQ is later enabled */ +writel_relaxed (SPI_ENGINE_INT_SYNC , spi_engine->base +SPI_ENGINE_REG_INT_PENDING ); +/* Read back to flush posted write. */ +readl_relaxed (spi_engine->base +SPI_ENGINE_REG_INT_PENDING ); +if (ret)return ret;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1805/2651 accel/qaic: Protect perf stats BO state with bo->lock
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shuvam Pandey <[email protected]>
[ Upstream commit 1c50c57717c013ca63363eecb4154049cc727767 ]
qaic_perf_stats_bo_ioctl() validates each BO by checking bo->sliced and bo->dbc before returning its perf stats. These fields are changed by the detach paths while holding bo->lock, but the perf stats ioctl reads them without that lock.
A concurrent detach can clear bo->dbc and mark the BO unsliced while the perf stats ioctl is validating the BO. Take bo->lock while checking the BO state and copying the per-BO stats into the temporary result buffer.
--- drivers/accel/qaic/qaic_data.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
drivers/accel/qaic/qaic_data.c +10 -4
@@ -1840,15 +1840,16 @@ int qaic_perf_stats_bo_ioctl(struct drm_device *dev, void *data, struct drm_file goto free_ent; } bo =to_qaic_bo (obj); + ret =mutex_lock_interruptible (&bo->lock); +if (ret) + goto put_obj;if (!bo->sliced) { -drm_gem_object_put (obj); ret = -EINVAL ; - goto free_ent; + goto unlock_bo; }if (bo->dbc->id != args->hdr.dbc_id) { -drm_gem_object_put (obj); ret = -EINVAL ; - goto free_ent; + goto unlock_bo; }/* * perf stats ioctl is called before wait ioctl is complete then
@@ -1864,7 +1865,12 @@ int qaic_perf_stats_bo_ioctl(struct drm_device *dev, void *data, struct drm_file bo->perf_stats.req_received_ts), 1000); ent[i].queue_level_before = bo->perf_stats.queue_level_before; ent[i].num_queue_element = bo->total_slice_nents; +unlock_bo: +mutex_unlock (&bo->lock); +put_obj:drm_gem_object_put (obj); +if (ret) + goto free_ent; }if (copy_to_user (u64_to_user_ptr (args->data), ent, args->hdr.count *sizeof (*ent)))
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1806/2651 ASoC: mediatek: mt8365: Fix out-of-bounds read in get_iir_coef()
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Priyanka Mani <[email protected]>
[ Upstream commit e913917febd31998e3d0b9e8c861e538a6185045 ]
get_iir_coef() looks up a resampling coefficient set by reading an index "k" from iir_coef_tbl_matrix[][] and using it to index iir_coef_tbl_list[], which has 8 entries (valid indices 0..7).
Before the lookup, "k" is only rejected when it is >= IIR_NO_NEED (11), or equal to IIR_RATIOVER (9) or IIR_INV_COEF (10). The value 8 is neither a sentinel nor a valid table index, so it falls through to the else branch and iir_coef_tbl_list[8] is read one element past the end of the array. The bogus coef pointer and count are then returned to mt8365_dai_set_config(), which dereferences coef.
The current matrix never produces 8, so this cannot be triggered today, but the bounds check is wrong: it relies on the matrix contents instead of the size of the array it guards. Bound the lookup with the actual array size so only valid indices reach the table.
This was found by Smatch:
sound/soc/mediatek/mt8365/mt8365-dai-i2s.c:271 get_iir_coef()
error: buffer overflow 'iir_coef_tbl_list' 8 <= 8
--- sound/soc/mediatek/mt8365/mt8365-dai-i2s.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/mediatek/mt8365/mt8365-dai-i2s.c +1 -1
@@ -267,7 +267,7 @@ static const u32 *get_iir_coef(unsigned int input_fs,if (k >=IIR_NO_NEED ) { }else if (k ==IIR_RATIOVER ) { }else if (k ==IIR_INV_COEF ) { - }else { + }else if (k <ARRAY_SIZE (iir_coef_tbl_list)) { coef = iir_coef_tbl_list[k].coef; cnt = iir_coef_tbl_list[k].cnt; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1807/2651 ASoC: codecs: wcd937x: request watchdog IRQs without devm
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Runyu Xiao <[email protected]>
[ Upstream commit b3f17433a1eb9f89b79f8459d7661207abce0b9c ]
The watchdog IRQs are requested from the codec component probe and released from its remove callback. Use the same non-devm lifetime for both operations.
Use request_threaded_irq() and keep free_irq() in the component remove callback. Return errors from each request and unwind only IRQs that were successfully requested, including failures later in component probe.
--- sound/soc/codecs/wcd937x.c | 44 +++++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 17 deletions(-)
sound/soc/codecs/wcd937x.c +27 -17
@@ -2536,23 +2536,23 @@ static int wcd937x_soc_codec_probe(struct snd_soc_component *component) WCD937X_IRQ_AUX_PDM_WD_INT);/* Request for watchdog interrupt */ - ret =devm_request_threaded_irq (dev, wcd937x->hphr_pdm_wd_int,NULL , wcd937x_wd_handle_irq, -IRQF_ONESHOT |IRQF_TRIGGER_RISING , -"HPHR PDM WDOG INT" , wcd937x); + ret =request_threaded_irq (wcd937x->hphr_pdm_wd_int,NULL , wcd937x_wd_handle_irq, +IRQF_ONESHOT |IRQF_TRIGGER_RISING , +"HPHR PDM WDOG INT" , wcd937x);if (ret) -dev_err (dev,"Failed to request HPHR watchdog interrupt (%d)\n" , ret); + goto err_free_clsh; - ret =devm_request_threaded_irq (dev, wcd937x->hphl_pdm_wd_int,NULL , wcd937x_wd_handle_irq, -IRQF_ONESHOT |IRQF_TRIGGER_RISING , -"HPHL PDM WDOG INT" , wcd937x); + ret =request_threaded_irq (wcd937x->hphl_pdm_wd_int,NULL , wcd937x_wd_handle_irq, +IRQF_ONESHOT |IRQF_TRIGGER_RISING , +"HPHL PDM WDOG INT" , wcd937x);if (ret) -dev_err (dev,"Failed to request HPHL watchdog interrupt (%d)\n" , ret); + goto err_free_hphr_irq; - ret =devm_request_threaded_irq (dev, wcd937x->aux_pdm_wd_int,NULL , wcd937x_wd_handle_irq, -IRQF_ONESHOT |IRQF_TRIGGER_RISING , -"AUX PDM WDOG INT" , wcd937x); + ret =request_threaded_irq (wcd937x->aux_pdm_wd_int,NULL , wcd937x_wd_handle_irq, +IRQF_ONESHOT |IRQF_TRIGGER_RISING , +"AUX PDM WDOG INT" , wcd937x);if (ret) -dev_err (dev,"Failed to request Aux watchdog interrupt (%d)\n" , ret); + goto err_free_hphl_irq;/* Disable watchdog interrupt for HPH and AUX */ disable_irq_nosync (wcd937x->hphr_pdm_wd_int);
@@ -2564,23 +2564,33 @@ static int wcd937x_soc_codec_probe(struct snd_soc_component *component) ARRAY_SIZE(wcd9375_dapm_widgets));if (ret <0 ) {dev_err (component->dev,"Failed to add snd_ctls\n" ); -wcd_clsh_ctrl_free (wcd937x->clsh_info); -return ret; + goto err_free_irqs; } ret =snd_soc_dapm_add_routes (dapm, wcd9375_audio_map,ARRAY_SIZE (wcd9375_audio_map));if (ret <0 ) {dev_err (component->dev,"Failed to add routes\n" ); -wcd_clsh_ctrl_free (wcd937x->clsh_info); -return ret; + goto err_free_irqs; } } ret =wcd937x_mbhc_init (component); -if (ret) +if (ret) {dev_err (component->dev,"mbhc initialization failed\n" ); + goto err_free_irqs; + } + +return ret; +err_free_irqs: +free_irq (wcd937x->aux_pdm_wd_int, wcd937x); +err_free_hphl_irq: +free_irq (wcd937x->hphl_pdm_wd_int, wcd937x); +err_free_hphr_irq: +free_irq (wcd937x->hphr_pdm_wd_int, wcd937x); +err_free_clsh: +wcd_clsh_ctrl_free (wcd937x->clsh_info);return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1808/2651 spi: meson-spicc: fix invalid DMA unmap on mapping failure
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hongjian Dai <[email protected]>
[ Upstream commit 9d71f9fe5b5de916bded51343138b09b1eb103ed ]
meson_spicc_dma_unmap() decided whether a buffer had to be unmapped by testing its DMA address for non-zero. On a mapping failure dma_map_single() returns DMA_MAPPING_ERROR (typically non-zero), so the error path in meson_spicc_transfer_one() passed that error value to dma_unmap_single(), unmapping an address which was never mapped. The same happened for t->rx_dma on TX mapping failure, which is not written at all.
Initialize both addresses to DMA_MAPPING_ERROR before mapping and use dma_mapping_error() to decide, so only buffers which were actually mapped are unmapped.
--- drivers/spi/spi-meson-spicc.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/spi/spi-meson-spicc.c +9 -2
@@ -235,6 +235,13 @@ static int meson_spicc_dma_map(struct meson_spicc_device *spicc, {struct device *dev = spicc->host->dev.parent; +/* +* Mark the DMA addresses as invalid so that meson_spicc_dma_unmap() +* will not try to unmap a buffer which was not (successfully) mapped. +*/ + t->tx_dma =DMA_MAPPING_ERROR ; + t->rx_dma =DMA_MAPPING_ERROR ; +if (!(t->tx_buf && t->rx_buf))return -EINVAL ;
@@ -257,9 +264,9 @@ static void meson_spicc_dma_unmap(struct meson_spicc_device *spicc, {struct device *dev = spicc->host->dev.parent; -if (t->tx_dma) +if (!dma_mapping_error (dev, t->tx_dma))dma_unmap_single (dev, t->tx_dma, t->len,DMA_TO_DEVICE ); -if (t->rx_dma) +if (!dma_mapping_error (dev, t->rx_dma))dma_unmap_single (dev, t->rx_dma, t->len,DMA_FROM_DEVICE ); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1809/2651 scsi: scsi_debug: Fix a locking bug in resp_write_same()
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bart Van Assche <[email protected]>
[ Upstream commit 2f50ca3d46b4d5916874ba19612498c0a9c1f5f9 ]
If fetch_to_dev_buffer() fails in resp_write_same(), the function jumps to 'out' without releasing the data write lock acquired earlier via sdeb_data_write_lock(). Jump to 'unlock' instead so that sdeb_data_write_unlock() is called on the error path. This bug has been discovered by building the scsi_debug driver with Clang and modified lock context annotations. The modified lock context annotations are available in patch "scsi: scsi_debug: Improve lock context annotations".
--- drivers/scsi/scsi_debug.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/scsi/scsi_debug.c +3 -2
@@ -5255,7 +5255,7 @@ static int resp_write_same(struct scsi_cmnd *scp, u64 lba, u32 num,if (-1 == ret) { ret =DID_ERROR <<16 ; - goto out; + goto unlock; }else if (sdebug_verbose && !ndob && (ret < lb_size)) sdev_printk(KERN_INFO, scp->device, "%s: %s: lb size=%u, IO sent=%d bytes\n",
@@ -5272,8 +5272,9 @@ static int resp_write_same(struct scsi_cmnd *scp, u64 lba, u32 num,/* If ZBC zone then bump its write pointer */ if (sdebug_dev_is_zoned (devip))zbc_inc_wp (devip, lba, num); -sdeb_data_write_unlock (sip); ret =0 ; +unlock: +sdeb_data_write_unlock (sip); out:if (meta_data_locked)sdeb_meta_write_unlock (sip);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1810/2651 lib: validate in-memory LZ4 chunk length
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhiling Zou <[email protected]>
[ Upstream commit 138a84817df01eda67bb23032ab49c23fe2ffc16 ]
We found and validated an issue in lib/decompress_unlz4.c. The bug is reachable by a root user through kexec_file_load() with a crafted external initrd.
unlz4() reads the compressed chunk length from an in-memory initrd and passes it to LZ4_decompress_safe(). It only checks the chunk length against the allocation size when the input is filled by a callback.
Reject an in-memory chunk that extends past the remaining input before calling the LZ4 decoder. This prevents malformed initrds from making the decoder read past the mapped archive.
--- lib/decompress_unlz4.c | 4 ++++ 1 file changed, 4 insertions(+)
lib/decompress_unlz4.c +4 -0
@@ -139,6 +139,10 @@ STATIC inline int INIT unlz4(u8 *input, long in_len,if (!fill) { inp +=4 ; size -=4 ; +if (chunksize > size) { +error ("data corrupted" ); + goto exit_2; + } }else {if (chunksize >LZ4_compressBound (uncomp_chunksize)) {error ("chunk length is longer than allocated" );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1811/2651 ocfs2: retain all security xattrs during inode creation
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joseph Qi <[email protected]>
[ Upstream commit d637475617d8468c2740a3436428681bcc8d3572 ]
When creating a new inode, ocfs2_init_security_get() stores the security xattr returned by the LSM framework in ocfs2_security_xattr_info so that it can be written later within the same transaction. But ocfs2_initxattrs() only ever looks at the first element of the xattr array, and it keeps the name as a bare pointer into memory owned by the security layer instead of copying it. The value, by contrast, is already duplicated with kmemdup().
With stacked LSMs, security_inode_init_security() provides one xattr per LSM, so all labels but the first are silently dropped and never written to disk, leaving newly created files without the security xattrs the other LSMs rely on.
The borrowed name is not an outright bug with the LSMs in tree today:security_inode_init_security() frees only ->value once the callback returns, and documents ->name as the attribute name suffix, so the pointer stays valid for as long as ocfs2 uses it. It is fragile though, as an LSM that allocates the name together with the value would turn it into a use-after-free, so the rework below copies the names as well.
Fix this by storing copies of all the security xattrs: allocate an array in ocfs2_initxattrs(), copy the names and values, account for all of them in the credit calculations, and write each one in ocfs2_init_security_set().
While at it, switch the allocations from GFP_KERNEL to GFP_NOFS. The callback runs in the inode creation path with the parent directory locked, and the security layer allocates the very same xattr array with GFP_NOFS, so direct reclaim must not be allowed to recurse into the filesystem from here.
--- fs/ocfs2/namei.c | 6 +-- fs/ocfs2/xattr.c | 133 +++++++++++++++++++++++++++++++++++++---------- fs/ocfs2/xattr.h | 12 +++-- 3 files changed, 116 insertions(+), 35 deletions(-)
fs/ocfs2/namei.c +2 -4
@@ -248,7 +248,6 @@ static int ocfs2_mknod(struct mnt_idmap *idmap,int want_meta =0 ;int xattr_credits =0 ;struct ocfs2_security_xattr_info si = { - .name =NULL , .enable =1 , };int did_quota_inode =0 ;
@@ -475,7 +474,7 @@ static int ocfs2_mknod(struct mnt_idmap *idmap,brelse (new_fe_bh);brelse (parent_fe_bh); -kfree (si.value); +ocfs2_free_security_xattrs (&si);ocfs2_acl_init_release (&acl_state);
@@ -1831,7 +1830,6 @@ static int ocfs2_symlink(struct mnt_idmap *idmap,int want_clusters =0 ;int xattr_credits =0 ;struct ocfs2_security_xattr_info si = { - .name =NULL , .enable =1 , };int did_quota =0 , did_quota_inode =0 ;
@@ -2063,7 +2061,7 @@ static int ocfs2_symlink(struct mnt_idmap *idmap,brelse (new_fe_bh);brelse (parent_fe_bh); -kfree (si.value); +ocfs2_free_security_xattrs (&si);ocfs2_free_dir_lookup_result (&lookup);if (inode_ac)ocfs2_free_alloc_context (inode_ac);
fs/ocfs2/xattr.c +105 -28
193 lines not on this page · raw message
fs/ocfs2/xattr.h +9 -3
@@ -20,13 +20,18 @@ enum ocfs2_xattr_type { OCFS2_XATTR_MAX }; -struct ocfs2_security_xattr_info { -int enable; -const char *name; +struct ocfs2_security_xattr { +char *name;void *value;size_t value_len; }; +struct ocfs2_security_xattr_info { +int enable; +struct ocfs2_security_xattr *xattrs; +int count; +}; +extern const struct xattr_handler ocfs2_xattr_user_handler;extern const struct xattr_handler ocfs2_xattr_trusted_handler;extern const struct xattr_handler ocfs2_xattr_security_handler;
@@ -49,6 +54,7 @@ int ocfs2_xattr_remove(struct inode *, struct buffer_head *);int ocfs2_init_security_get (struct inode *,struct inode *,const struct qstr *,struct ocfs2_security_xattr_info *); +void ocfs2_free_security_xattrs (struct ocfs2_security_xattr_info *); int ocfs2_init_security_set(handle_t *, struct inode *, struct buffer_head *, struct ocfs2_security_xattr_info *,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1812/2651 ocfs2: fix possible deadlock between nfs_sync_rwlock and fs_reclaim
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joseph Qi <[email protected]>
[ Upstream commit 169bc4d16a8efa7852b101fdaa4c028505cd6750 ]
syzbot detected a circular locking dependency on &osb->nfs_sync_rwlock:
CPU0 CPU1
---- ----
lock(fs_reclaim);
lock(&ocfs2_sysfile_lock_key[INODE_ALLOC_SYSTEM_INODE]);
lock(fs_reclaim); rlock(&osb->nfs_sync_rwlock);
*** DEADLOCK ***
Chain exists of: &osb->nfs_sync_rwlock --> &ocfs2_sysfile_lock_key[INODE_ALLOC_SYSTEM_INODE] --> fs_reclaim
CPU0 is kswapd. The dentry shrinker runs under fs_reclaim and reaches ocfs2_delete_inode() through ->evict_inode():
kswapd
balance_pgdat
shrink_node
shrink_slab
super_cache_scan
prune_dcache_sb
shrink_dentry_list
dentry_kill
ocfs2_dentry_iput
evict
ocfs2_evict_inode
ocfs2_delete_inode
ocfs2_nfs_sync_lock
down_read(&osb->nfs_sync_rwlock) //C0: grabbingCPU1 is a task deleting an inode. It takes nfs_sync_rwlock first, then the orphan dir and inode alloc system inode i_rwsems, and allocates the metadata reservation with GFP_KERNEL while holding them:
evict
ocfs2_evict_inode
ocfs2_delete_inode
+ ocfs2_nfs_sync_lock
| down_read(&osb->nfs_sync_rwlock) //C1: hold
+ ocfs2_wipe_inode
+ inode_lock(orphan_dir_inode) //C1: hold
+ ocfs2_truncate_for_delete
| ocfs2_commit_truncate
| ocfs2_remove_btree_range
| ocfs2_reserve_blocks_for_rec_trunc
| ocfs2_reserve_new_metadata_blocks
| kzalloc_obj() //C1: grabbing
| // GFP_KERNEL -> might_alloc -> fs_reclaim_acquire
+ ocfs2_remove_inode
inode_lock(inode_alloc_inode)
jbd2 pins allocations to GFP_NOFS for the lifetime of a transaction handle, but these reservations are made before ocfs2_start_trans(), so fs_reclaim is acquired with ocfs2 locks still held and the cycle closes.
The same cycle is reachable from ocfs2_get_dentry() and ocfs2_get_parent(), which hold nfs_sync_rwlock for write across ocfs2_test_inode_bit() and ocfs2_iget().
This is more than a lockdep artifact. A GFP_KERNEL allocation under the orphan dir i_rwsem enters direct reclaim, which runs the shrinkers, which can evict another ocfs2 inode and re-enter ocfs2_wipe_inode() on the same task; the second inode_lock() on the singleton orphan dir inode then self-deadlocks, since i_rwsem is not recursive.
Establish a GFP_NOFS allocation context for the whole nfs_sync_rwlock critical section so that nothing holding it can recurse into filesystem reclaim. Do it in ocfs2_nfs_sync_lock()/ocfs2_nfs_sync_unlock() rather than at the call sites, so that future callers cannot forget it.
--- fs/ocfs2/dlmglue.c | 29 +++++++++++++++++++++++++---- fs/ocfs2/dlmglue.h | 5 +++-- fs/ocfs2/export.c | 10 ++++++---- fs/ocfs2/inode.c | 5 +++-- 4 files changed, 37 insertions(+), 12 deletions(-)
fs/ocfs2/dlmglue.c +25 -4
@@ -19,6 +19,7 @@#include <linux/time.h> #include <linux/delay.h> #include <linux/quotaops.h> +#include <linux/sched/mm.h> #include <linux/sched/signal.h> #include <linux/string_choices.h>
@@ -2854,21 +2855,34 @@ void ocfs2_rename_unlock(struct ocfs2_super *osb)ocfs2_cluster_unlock (osb, lockres,DLM_LOCK_EX ); } -int ocfs2_nfs_sync_lock (struct ocfs2_super *osb,int ex) +int ocfs2_nfs_sync_lock (struct ocfs2_super *osb,int ex,unsigned int *nofs_flag) {int status; +unsigned int flags;struct ocfs2_lock_res *lockres = &osb->osb_nfs_sync_lockres;if (ocfs2_is_hard_readonly (osb))return -EROFS ; +/* +* ocfs2_delete_inode() takes this lock from ->evict_inode(), which the +* dentry shrinker reaches while holding fs_reclaim. Anything allocated +* under the lock must therefore stay out of filesystem reclaim, or +* reclaim recurses back into the shrinker and tries to take this lock +* again. Cover the whole critical section, including the cluster lock +* and the sysfile inode locks the callers take below it. +*/ + flags =memalloc_nofs_save (); +if (ex)down_write (&osb->nfs_sync_rwlock);else down_read (&osb->nfs_sync_rwlock); -if (ocfs2_mount_local (osb)) +if (ocfs2_mount_local (osb)) { + *nofs_flag = flags;return 0 ; + } status =ocfs2_cluster_lock (osb, lockres, ex ?LKM_EXMODE :LKM_PRMODE ,0 ,0 );
@@ -2879,12 +2893,17 @@ int ocfs2_nfs_sync_lock(struct ocfs2_super *osb, int ex)up_write (&osb->nfs_sync_rwlock); else up_read(&osb->nfs_sync_rwlock); +memalloc_nofs_restore (flags); +return status; } -return status; + *nofs_flag = flags; + +return 0 ; } -void ocfs2_nfs_sync_unlock (struct ocfs2_super *osb,int ex) +void ocfs2_nfs_sync_unlock (struct ocfs2_super *osb,int ex, +unsigned int nofs_flag) {struct ocfs2_lock_res *lockres = &osb->osb_nfs_sync_lockres;
@@ -2895,6 +2914,8 @@ void ocfs2_nfs_sync_unlock(struct ocfs2_super *osb, int ex)up_write (&osb->nfs_sync_rwlock); else up_read(&osb->nfs_sync_rwlock); + +memalloc_nofs_restore (nofs_flag); } int ocfs2_trim_fs_lock(struct ocfs2_super *osb,
fs/ocfs2/dlmglue.h +3 -2
@@ -161,8 +161,9 @@ void ocfs2_orphan_scan_unlock(struct ocfs2_super *osb, u32 seqno);int ocfs2_rename_lock (struct ocfs2_super *osb);void ocfs2_rename_unlock (struct ocfs2_super *osb); -int ocfs2_nfs_sync_lock (struct ocfs2_super *osb,int ex); -void ocfs2_nfs_sync_unlock (struct ocfs2_super *osb,int ex); +int ocfs2_nfs_sync_lock (struct ocfs2_super *osb,int ex,unsigned int *nofs_flag); +void ocfs2_nfs_sync_unlock (struct ocfs2_super *osb,int ex, +unsigned int nofs_flag);void ocfs2_trim_fs_lock_res_init (struct ocfs2_super *osb);void ocfs2_trim_fs_lock_res_uninit (struct ocfs2_super *osb); int ocfs2_trim_fs_lock(struct ocfs2_super *osb,
fs/ocfs2/export.c +6 -4
@@ -37,6 +37,7 @@ static struct dentry *ocfs2_get_dentry(struct super_block *sb,struct inode *inode;struct ocfs2_super *osb =OCFS2_SB (sb);u64 blkno = handle->ih_blkno; +unsigned int nofs_flag =0 ;int status, set;struct dentry *result;
@@ -59,7 +60,7 @@ static struct dentry *ocfs2_get_dentry(struct super_block *sb,* This will synchronize us against ocfs2_delete_inode() on * all nodes */ - status =ocfs2_nfs_sync_lock (osb,1 ); + status =ocfs2_nfs_sync_lock (osb,1 , &nofs_flag);if (status <0 ) {mlog (ML_ERROR ,"getting nfs sync lock(EX) failed %d\n" , status); goto check_err;
@@ -90,7 +91,7 @@ static struct dentry *ocfs2_get_dentry(struct super_block *sb, inode =ocfs2_iget (osb, blkno,0 ,0 ); unlock_nfs_sync: -ocfs2_nfs_sync_unlock (osb,1 ); +ocfs2_nfs_sync_unlock (osb,1 , nofs_flag); check_err:if (status <0 ) {
@@ -133,12 +134,13 @@ static struct dentry *ocfs2_get_parent(struct dentry *child)u64 blkno;struct dentry *parent;struct inode *dir =d_inode (child); +unsigned int nofs_flag =0 ;int set;trace_ocfs2_get_parent (child, child->d_name.len, child->d_name.name, (unsigned long long )OCFS2_I (dir)->ip_blkno); - status =ocfs2_nfs_sync_lock (OCFS2_SB (dir->i_sb),1 ); + status =ocfs2_nfs_sync_lock (OCFS2_SB (dir->i_sb),1 , &nofs_flag);if (status <0 ) {mlog (ML_ERROR ,"getting nfs sync lock(EX) failed %d\n" , status); parent =ERR_PTR (status);
@@ -183,7 +185,7 @@ static struct dentry *ocfs2_get_parent(struct dentry *child)ocfs2_inode_unlock (dir,0 ); unlock_nfs_sync: -ocfs2_nfs_sync_unlock (OCFS2_SB (dir->i_sb),1 ); +ocfs2_nfs_sync_unlock (OCFS2_SB (dir->i_sb),1 , nofs_flag); bail:trace_ocfs2_get_parent_end (parent);
fs/ocfs2/inode.c +3 -2
@@ -1109,6 +1109,7 @@ static void ocfs2_delete_inode(struct inode *inode) {int wipe, status;sigset_t oldset; +unsigned int nofs_flag =0 ;struct buffer_head *di_bh =NULL ;struct ocfs2_dinode *di =NULL ;
@@ -1143,7 +1144,7 @@ static void ocfs2_delete_inode(struct inode *inode)* shared mode so that all nodes can still concurrently * process deletes. */ - status =ocfs2_nfs_sync_lock (OCFS2_SB (inode->i_sb),0 ); + status =ocfs2_nfs_sync_lock (OCFS2_SB (inode->i_sb),0 , &nofs_flag);if (status <0 ) {mlog (ML_ERROR ,"getting nfs sync lock(PR) failed %d\n" , status);ocfs2_cleanup_delete_inode (inode,0 );
@@ -1215,7 +1216,7 @@ static void ocfs2_delete_inode(struct inode *inode)brelse (di_bh); bail_unlock_nfs_sync: -ocfs2_nfs_sync_unlock (OCFS2_SB (inode->i_sb),0 ); +ocfs2_nfs_sync_unlock (OCFS2_SB (inode->i_sb),0 , nofs_flag); bail_unblock:ocfs2_unblock_signals (&oldset);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1813/2651 ocfs2: validate chunk and block counts of the local quota file
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nguyen Ngoc Thang <[email protected]>
[ Upstream commit b10ef5d2c2083ea4c40e963c10a73a154793c5d4 ]
ocfs2_local_read_info() trusts dqi_chunks and dqi_blocks from the local quota file header. If dqi_blocks is too small, ocfs2_extend_local_quota_file() computes a bogus chunk length, extends the file, and maps logical block dqi_blocks, which is already in the inode's metadata cache (the header or a chunk header read at mount). sb_getblk() returns that cached buffer and ocfs2_set_new_buffer_uptodate() hits BUG_ON(ocfs2_buffer_cached()):
kernel BUG at fs/ocfs2/uptodate.c:509!
ocfs2_extend_local_quota_file+0x45c/0x1100 ocfs2_create_local_dquot+0x8ac/0xb50 ocfs2_acquire_dquot+0x614/0xae0 ocfs2_get_init_inode+0xe9/0x1b0 ocfs2_mkdir+0x174/0x430
ocfs2_local_quota_add_chunk() has the same exposure.
Reject a header whose counts don't fit the chunk layout or exceed i_size.
Reproduced with a crafted image (dqi_blocks = 1, chunk 0 dqc_free = 0); syzbot has no reproducer for this report.
--- fs/ocfs2/quota_local.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
fs/ocfs2/quota_local.c +24 -0
@@ -245,6 +245,25 @@ static void ocfs2_release_local_quota_bitmaps(struct list_head *head) } } +/* Check that the on-disk chunk and block counts match the file layout */ +static int ocfs2_check_local_quota_info (struct inode *inode, +unsigned int chunks, +unsigned int blocks) +{ +u64 chunk_len =ol_chunk_blocks (inode->i_sb) +1 ; +u64 min_blocks = chunks ?1 + chunk_len * (chunks -1 ) +1 :1 ; +u64 max_blocks =1 + chunk_len * chunks; + +if (blocks >= min_blocks && blocks <= max_blocks && + blocks <=i_size_read (inode) >> inode->i_sb->s_blocksize_bits) +return 0 ; + +return ocfs2_error (inode->i_sb, +"Quota file %llu has bad info: %u chunks, %u blocks\n" , + (unsigned long long )OCFS2_I (inode)->ip_blkno, + chunks, blocks); +} +/* Load quota bitmaps into memory */ static int ocfs2_load_local_quota_bitmaps(struct inode *inode, struct ocfs2_local_disk_dqinfo *ldinfo,
@@ -733,6 +752,11 @@ static int ocfs2_local_read_info(struct super_block *sb, int type) oinfo->dqi_blocks =le32_to_cpu (ldinfo->dqi_blocks); oinfo->dqi_libh = bh; + status =ocfs2_check_local_quota_info (lqinode, oinfo->dqi_chunks, + oinfo->dqi_blocks); +if (status <0 ) + goto out_err; +/* We crashed when using local quota file? */ if (!(oinfo->dqi_flags &OLQF_CLEAN )) { rec =OCFS2_SB (sb)->quota_rec;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1814/2651 kselftest/filelock: plan for the five ofdlocks tests
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Danish Khateeb <[email protected]>
[ Upstream commit d05de2360a3e25aa3ec24f460802755a95e8e6e9 ]
ofdlocks reports five results but plans for four, so even when they all pass it ends with
# Planned tests != run tests (4 != 5)
and exits with KSFT_FAIL, which run_kselftest.sh reports as a failure.
--- tools/testing/selftests/filelock/ofdlocks.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/filelock/ofdlocks.c +1 -1
@@ -40,7 +40,7 @@ int main(void)int fd2 =open ("/tmp/aa" ,O_RDONLY );ksft_print_header (); -ksft_set_plan (4 ); +ksft_set_plan (5 );unlink ("/tmp/aa" );assert (fd !=-1 );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1815/2651 resource, kunit: stop selecting GET_FREE_REGION
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 7c3f4d699f34535285d0ceb184927d71543d0064 ]
RESOURCE_KUNIT_TEST selects GET_FREE_REGION even when no other option needs it. Remove the selection to follow the dependency rule in Documentation/dev-tools/kunit/style.rst.
Skip resource_test_region_intersects() when GET_FREE_REGION is disabled. GET_FREE_REGION has no prompt, so configurations without a production consumer cannot enable it. Most configurations will therefore skip this case; this is intentional. The union and intersection tests remain available.
Since kunit_skip() does not return, the compiler drops the reference to the unavailable alloc_free_mem_region(), as in the CONFIG_OF_ADDRESS check in drivers/of/of_test.c.
--- kernel/resource_kunit.c | 3 +++ lib/Kconfig.debug | 1 - 2 files changed, 3 insertions(+), 1 deletion(-)
kernel/resource_kunit.c +3 -0
@@ -225,6 +225,9 @@ static void resource_test_region_intersects(struct kunit *test)struct resource *parent;resource_size_t start; +if (!IS_ENABLED (CONFIG_GET_FREE_REGION )) +kunit_skip (test,"CONFIG_GET_FREE_REGION is disabled" ); +/* Find an iomem_resource hole to hold test resources */ parent =alloc_free_mem_region (&iomem_resource,RES_TEST_TOTAL_SIZE ,SZ_1M ,"test resources" );
lib/Kconfig.debug +0 -1
@@ -2776,7 +2776,6 @@ config RESOURCE_KUNIT_TEST tristate "KUnit test for resource API" if !KUNIT_ALL_TESTS depends on KUNIT default KUNIT_ALL_TESTS - select GET_FREE_REGION help This builds the resource API unit test. Tests the logic of API provided by resource.c and ioport.h.
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1816/2651 kcov: report spurious PCs in the interrupt selftest
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 5d9f31ed855fa89e533b222d0365da81ad3b10cc ]
The KCOV interrupt selftest enables KCOV_MODE_TRACE_PC without a coverage area so that spurious coverage causes a fault. If the fault path is instrumented, the coverage callback faults recursively. Observed failure modes include a stack overflow on x86_64 and arm32 getting stuck in abort handling, neither of which identifies the original coverage event.
The recursive failure is not new, but commit 9a79524d1420 ("kcov: use WRITE_ONCE() for selftest mode stores") made the selftest effective on configurations where the compiler had previously removed the mode store, exposing it more broadly.
Replace the open-coded kcov_mode stores with kcov_start() and kcov_stop(), passing a 16-word buffer that records up to 15 spurious PCs, with the first word holding the count. Keep KCOV enabled for the original 300 ms window, then disable it, print all recorded PCs and panic if any were recorded. Once the buffer fills, further PCs are discarded by the existing coverage callback. This preserves the selftest's hard failure while avoiding the recursive fault path.
Add decanonicalize_ip() as the inverse of canonicalize_ip(), which subtracts kaslr_offset() from recorded PCs. Restore that offset before printing the PCs with %pB, since KCOV records return addresses.
--- kernel/kcov.c | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-)
kernel/kcov.c +29 -6
@@ -198,6 +198,16 @@ static notrace unsigned long canonicalize_ip(unsigned long ip)return ip; } +#ifdef CONFIG_KCOV_SELFTEST +static unsigned long __init decanonicalize_ip (unsigned long ip) +{ +#ifdef CONFIG_RANDOMIZE_BASE + ip +=kaslr_offset (); +#endif +return ip; +} +#endif +/* * Entry point from instrumented code. * This is called once per basic-block/edge.
@@ -1107,9 +1117,11 @@ struct kcov_common_handle_id kcov_common_handle(void)EXPORT_SYMBOL (kcov_common_handle);#ifdef CONFIG_KCOV_SELFTEST +static unsigned long selftest_area[16 ]__initdata ; +static void __init selftest (void ) { -unsigned long start; +unsigned long start, i, ip, count;pr_err ("running self test\n" );/*
@@ -1119,15 +1131,26 @@ static void __init selftest(void)* leaks out of that section and leads to spurious coverage. * It's hard to call the actual interrupt handler directly, * so we just loop here for a bit waiting for a timer interrupt. -* We set kcov_mode to enable tracing, but don't setup the area, -* so any attempt to trace will crash. Note: we must not call any +* A small coverage area records the PCs of any leaks. The first word +* holds the count, leaving room for 15 PCs. Note: we must not call any * potentially traced functions in this region. */ +kcov_start (current,NULL ,ARRAY_SIZE (selftest_area), + selftest_area,KCOV_MODE_TRACE_PC ,0 ); start = jiffies; -WRITE_ONCE (current->kcov_mode,KCOV_MODE_TRACE_PC );while ((jiffies - start) *MSEC_PER_SEC /HZ <300 ) - ; -WRITE_ONCE (current->kcov_mode,0 ); +cpu_relax (); +kcov_stop (current); + + count =READ_ONCE (selftest_area[0 ]); +if (count) { +pr_err ("spurious coverage detected during interrupt selftest:\n" ); +for (i =1 ; i <= count; i++) { + ip =decanonicalize_ip (selftest_area[i]); +pr_err (" %pB\n" , (void *)ip); + } +panic ("kcov: interrupt selftest detected spurious coverage" ); + } pr_err("done running self test\n"); }#endif
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1817/2651 watchdog/perf: one digit too short in the raw event config copy
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bradley Morgan <[email protected]>
[ Upstream commit b682d597aa273cad6e99e665e0fd2a7eb8aa2cef ]
Commit 6164be01f179 ("watchdog/perf: optimize bytes copied and remove manual NUL-termination") swapped strscpy(buf, str, sizeof(buf)) plus a manual buf[len] = 0 for strscpy(buf, str, len), and that count is one short. strscpy() keeps the last byte of the destination for the NUL, so the config loses its final digit, nmi_watchdog=r300,panic for example ends up with buf = "30" and arms the raw event with the wrong config.
The empty case falls over too, strscpy() with a zero count writes nothing at all, so nmi_watchdog=r,1 leaves buf uninitialized and kstrtoull() reads whatever stack garbage is sitting there.
The old code was safe on both by accident, it filled the whole buffer first and buf[len] = 0 then stomped the comma position, so the worst you got was a truncated parse failure.
Pass len + 1 so the copy includes the character the NUL replaces, and reject len >= sizeof(buf) like it was before the optimization, which also turns an empty config back into a clean parse failure.
--- kernel/watchdog_perf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/watchdog_perf.c +2 -2
@@ -301,10 +301,10 @@ void __init hardlockup_config_perf_event(const char *str) }else {unsigned int len = comma - str; -if (len >sizeof (buf)) +if (len >=sizeof (buf))return ; -strscpy (buf, str, len); +strscpy (buf, str, len +1 );if (kstrtoull (buf,16 , &config))return ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1818/2651 ALSA: pcm: Fix driver_tstamp value reporting
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Amadeusz Sławiński <[email protected]>
[ Upstream commit 8ff1161ac5aa02f3261e00f07d6212be2b12384b ]
In some cases (system32 and compat64) due to incorrect assignment wrong value is being reported. Fix it.
--- sound/core/pcm_compat.c | 4 ++-- sound/core/pcm_native.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
sound/core/pcm_compat.c +2 -2
@@ -219,8 +219,8 @@ static int snd_pcm_status_user_compat64(struct snd_pcm_substream *substream, .audio_tstamp_data = status.audio_tstamp_data, .audio_tstamp_sec = status.audio_tstamp_sec, .audio_tstamp_nsec = status.audio_tstamp_nsec, - .driver_tstamp_sec = status.audio_tstamp_sec, - .driver_tstamp_nsec = status.audio_tstamp_nsec, + .driver_tstamp_sec = status.driver_tstamp_sec, + .driver_tstamp_nsec = status.driver_tstamp_nsec, .audio_tstamp_accuracy = status.audio_tstamp_accuracy, };
sound/core/pcm_native.c +2 -2
@@ -1200,8 +1200,8 @@ static int snd_pcm_status_user32(struct snd_pcm_substream *substream, .audio_tstamp_data = status64.audio_tstamp_data, .audio_tstamp_sec = status64.audio_tstamp_sec, .audio_tstamp_nsec = status64.audio_tstamp_nsec, - .driver_tstamp_sec = status64.audio_tstamp_sec, - .driver_tstamp_nsec = status64.audio_tstamp_nsec, + .driver_tstamp_sec = status64.driver_tstamp_sec, + .driver_tstamp_nsec = status64.driver_tstamp_nsec, .audio_tstamp_accuracy = status64.audio_tstamp_accuracy, };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1819/2651 ALSA: jack: Fix kctl free at error in snd_jack_kctl_new()
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit f421be924fec67f74bb0b6988ea8f0a3480df2a7 ]
When an error happens in snd_jack_kctl_new(), it tries to free the new kcontrol element via snd_ctl_free_one(). But snd_ctl_free_one() releases only the memories, and the internal linked list and hash entries still remain, which may lead to bogus accesses to user.
Replace with the correct destructor, snd_ctl_remove(), for clearing the whole resources of the given kcontrol, instead.
--- sound/core/jack.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/core/jack.c +1 -1
@@ -453,7 +453,7 @@ static struct snd_jack_kctl * snd_jack_kctl_new(struct snd_card *card, const chareturn jack_kctl; error: -snd_ctl_free_one (kctl); +snd_ctl_remove (card, kctl);return NULL ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1820/2651 ALSA: pcm: Protect delay DMA sync in forward and rewind, too
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit d5096bb9beacb448091c1c9541432021dd5c1fcd ]
Like the previous fix for snd_pcm_delay() (in the commit 50f413b83b31 "ALSA: pcm: Protect delay DMA sync against concurrent HW_FREE"), the snd_pcm_dma_buffer_sync() call in snd_pcm_forward() and snd_pcm_rewind() needs the similar protection against the concurrent hw_free action for avoiding potential UAFs.
--- sound/core/pcm_native.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
sound/core/pcm_native.c +10 -0
@@ -3072,11 +3072,15 @@ static snd_pcm_sframes_t rewind_appl_ptr(struct snd_pcm_substream *substream,static snd_pcm_sframes_t snd_pcm_rewind (struct snd_pcm_substream *substream,snd_pcm_uframes_t frames) { +struct snd_pcm_runtime *runtime = substream->runtime;snd_pcm_sframes_t ret;if (frames ==0 )return 0 ; +/* Keep the DMA buffer alive through the sync below. */ +if (!atomic_inc_unless_negative (&runtime->buffer_accessing)) +return -EBUSY ; scoped_guard(pcm_stream_lock_irq, substream) { ret =do_pcm_hwsync (substream);if (!ret)
@@ -3085,17 +3089,22 @@ static snd_pcm_sframes_t snd_pcm_rewind(struct snd_pcm_substream *substream, }if (ret >=0 )snd_pcm_dma_buffer_sync (substream,SNDRV_DMA_SYNC_DEVICE ); +atomic_dec (&runtime->buffer_accessing);return ret; }static snd_pcm_sframes_t snd_pcm_forward (struct snd_pcm_substream *substream,snd_pcm_uframes_t frames) { +struct snd_pcm_runtime *runtime = substream->runtime;snd_pcm_sframes_t ret;if (frames ==0 )return 0 ; +/* Keep the DMA buffer alive through the sync below. */ +if (!atomic_inc_unless_negative (&runtime->buffer_accessing)) +return -EBUSY ; scoped_guard(pcm_stream_lock_irq, substream) { ret =do_pcm_hwsync (substream);if (!ret)
@@ -3104,6 +3113,7 @@ static snd_pcm_sframes_t snd_pcm_forward(struct snd_pcm_substream *substream, }if (ret >=0 )snd_pcm_dma_buffer_sync (substream,SNDRV_DMA_SYNC_DEVICE ); +atomic_dec (&runtime->buffer_accessing);return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1821/2651 ALSA: line6: Use kzalloc() for PCM buffer allocation
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit 9ec633573c1d162bfc82cae52d14c220c875612f ]
LINE6 driver allocates the PCM buffer via kmalloc(), and this might leave some bytes uninitialized that are out of the actual ring buffer size, while it's still exposed via mmap.
For avoiding the leak of the uninitialized kernel memory, simply replace it with kzalloc().
--- sound/usb/line6/pcm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/usb/line6/pcm.c +1 -1
@@ -155,7 +155,7 @@ static int line6_buffer_acquire(struct snd_line6_pcm *line6pcm,/* Invoked multiple times in a row so allocate once only */ if (!test_and_set_bit (type, &pstr->opened) && !pstr->buffer) { pstr->buffer = -kmalloc (array3_size (line6pcm->line6->iso_buffers, +kzalloc (array3_size (line6pcm->line6->iso_buffers,LINE6_ISO_PACKETS , pkt_size),GFP_KERNEL );if (!pstr->buffer)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1822/2651 ALSA: vmaster: Serialize hook registration with control callbacks
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cen Zhang <[email protected]>
[ Upstream commit 6215cf3ff5b0ff1ca5ab66b79021f9e28b02eae1 ]
An HDA virtual-master hook must have its private argument initialized before a control callback can invoke it. snd_hda_add_vmaster_hook() installs the trampoline through snd_ctl_add_vmaster_hook(), which stores master->hook before master->hook_private_data without serialization.
When a codec with a vmaster mute hook binds to an already registered card, snd_hda_gen_build_controls() publishes and initializes the Master Playback Switch before installing the hook. A native write that changes the switch can then run in the following order:
1. The codec bind path publishes and initializes the master control in __snd_hda_add_vmaster(), then calls snd_hda_add_vmaster_hook().
2. The hook setter stores master->hook, but has not yet stored its private argument.
3. SNDRV_CTL_IOCTL_ELEM_WRITE takes controls_rwsem and calls master_put() while the setter remains between those stores.
4. master_put() sees the callback and invokes vmaster_hook() with a NULL argument. The trampoline dereferences it before the setter can complete publication.
The write lock held by snd_ctl_elem_write() does not exclude the hook setter, so this can cause a NULL pointer dereference. Take the same controls_rwsem for writing inside snd_ctl_add_vmaster_hook() so the callback and its argument are installed together with respect to native control callbacks. Pass the card into the helper and update the HDA caller, keeping the lock in the ALSA core. Release it when registration returns, before the caller synchronizes the hook.
KASAN report as below:
Oops: general protection fault, probably for non-canonical address 0xdffffc0000000001: 0000 [#1] SMP KASAN NOPTI
KASAN: null-ptr-deref in range [0x0000000000000008-0x000000000000000f]
CPU: 1 UID: 0 PID: 499 Comm: alsa-vmaster-tr Not tainted 7.2.0-rc6-pmb-bt-functional-v1+ #1 PREEMPT(lazy)
Hardware name: QEMU Ubuntu 24.04 PC v2 (i440FX + PIIX, arch_caps fix, 1996), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
RIP: 0010:vmaster_hook+0x35/0xb0
Code: f5 53 48 89 fb 48 83 ec 08 e8 57 f0 9a fc eb 50 e8 50 f0 9a fc 48 8d 7b 08 48 b8 00 00 00 00 00 fc ff df 48 89 fa 48 c1 ea 03 <80> 3c 02 00 75 59 48 8d 7b 10 48 8b 43 08 48 ba 00 00 00 00 00 fc
RSP: 0018:ffff888117647cd0 EFLAGS: 00010212
RAX: dffffc0000000000 RBX: 0000000000000000 RCX: ffffffff84e9ff50
RDX: 0000000000000001 RSI: 0000000000000000 RDI: 0000000000000008
RBP: 0000000000000001 R08: 0000000000000001 R09: 0000000000000001
R10: ffffffff89427457 R11: ffff888115ad1d00 R12: ffffffff84e9ff30
R13: ffff888114943ca0 R14: 0000000000000000 R15: 0000000000000001
FS: 00007fe8167b3780(0000) GS:ffff88826b7e3000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000557c8c2842a8 CR3: 000000011579f005 CR4: 0000000000770ef0
PKRU: 55555554
Call Trace:
<TASK>
master_put+0x20e/0x2b0
snd_ctl_elem_write+0x37f/0x5e0
snd_ctl_ioctl+0x997/0xdd0
? __pfx_snd_ctl_ioctl+0x10/0x10
? srso_alias_return_thunk+0x5/0xfbef5
? selinux_file_ioctl+0xaa/0x280
? __pfx_snd_ctl_ioctl+0x10/0x10
__x64_sys_ioctl+0x163/0x1d0
do_syscall_64+0x115/0x6a0
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7fe8168c291b
Code: 00 48 89 44 24 18 31 c0 48 8d 44 24 60 c7 04 24 10 00 00 00 48 89 44 24 08 48 8d 44 24 20 48 89 44 24 10 b8 10 00 00 00 0f 05 <89> c2 3d 00 f0 ff ff 77 1c 48 8b 44 24 18 64 48 2b 04 25 28 00 00
RSP: 002b:00007fffab0cb150 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 00007fe8168c291b
RDX: 00007fffab0cb310 RSI: 00000000c4c85513 RDI: 0000000000000003
RBP: 00007fffab0cb310 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000001
R13: 00007fffab0cb1c0 R14: 0000000000000001 R15: 0000557c4f71fd10
</TASK>
Modules linked in:
---[ end trace 0000000000000000 ]------ include/sound/control.h | 2 +- sound/core/vmaster.c | 7 ++++++- sound/hda/common/codec.c | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-)
include/sound/control.h +1 -1
@@ -289,7 +289,7 @@ snd_ctl_add_follower_uncached(struct snd_kcontrol *master,return _snd_ctl_add_follower (master, follower,SND_CTL_FOLLOWER_NEED_UPDATE ); } -int snd_ctl_add_vmaster_hook (struct snd_kcontrol *kctl, +int snd_ctl_add_vmaster_hook (struct snd_card *card,struct snd_kcontrol *kctl,void (*hook)(void *private_data,int ),void *private_data);void snd_ctl_sync_vmaster (struct snd_kcontrol *kctl,bool hook_only);
sound/core/vmaster.c +6 -1
@@ -463,6 +463,7 @@ EXPORT_SYMBOL(snd_ctl_make_virtual_master);/** * snd_ctl_add_vmaster_hook - Add a hook to a vmaster control +* @card: the card instance * @kcontrol: vmaster kctl element * @hook: the hook function * @private_data: the private_data pointer to be saved
@@ -470,13 +471,17 @@ EXPORT_SYMBOL(snd_ctl_make_virtual_master);* Adds the given hook to the vmaster control element so that it's called * at each time when the value is changed. * +* Takes the card's controls_rwsem lock internally. +* * Return: Zero. */ -int snd_ctl_add_vmaster_hook (struct snd_kcontrol *kcontrol, +int snd_ctl_add_vmaster_hook (struct snd_card *card,struct snd_kcontrol *kcontrol,void (*hook)(void *private_data,int ),void *private_data) {struct link_master *master =snd_kcontrol_chip (kcontrol); + +guard (rwsem_write)(&card->controls_rwsem); master->hook = hook; master->hook_private_data = private_data;return 0 ;
sound/hda/common/codec.c +1 -1
@@ -2023,7 +2023,7 @@ int snd_hda_add_vmaster_hook(struct hda_codec *codec,if (!hook->hook || !hook->sw_kctl)return 0 ; hook->codec = codec; -snd_ctl_add_vmaster_hook (hook->sw_kctl, vmaster_hook, hook); +snd_ctl_add_vmaster_hook (codec->card, hook->sw_kctl, vmaster_hook, hook);return 0 ; }EXPORT_SYMBOL_GPL (snd_hda_add_vmaster_hook);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1823/2651 wifi: nxpwifi: return timeout error from nxpwifi_sdio_poll_card_status()
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit f86bc8a7421defdff701addfb66b286c13abf024 ]
nxpwifi_sdio_poll_card_status() returns the result of the last register read when polling times out.
If the final register read succeeds, the timeout is incorrectly reported as success.
Return -ETIMEDOUT when polling runs out of retries.
--- drivers/net/wireless/nxp/nxpwifi/sdio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/nxp/nxpwifi/sdio.c +1 -1
@@ -665,7 +665,7 @@ nxpwifi_sdio_poll_card_status(struct nxpwifi_adapter *adapter, u8 bits)nxpwifi_dbg (adapter,ERROR ,"poll card status failed, tries = %d\n" , tries); -return ret; +return ret ?: -ETIMEDOUT ; }/* Disable SDIO host interrupt and release IRQ. */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1824/2651 ALSA: usb-audio: Use fixed control index for us16x08 mixer elements
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit a68a688ce220f1b359bec53fa38d1504314dc70f ]
The callbacks for us16x08 mixer elements assume that id.index points to the channel to be operated, and the assumption is correct for now. However, since the kctls are added via snd_usb_mixer_add_control() and it looks for the empty slot if the same control name is already present, in theory, the index can become more than the channel numbers (if a conflicting name really happens).
Since the mixer code in us16x08 doesn't need the search for an empty slot but requires the fixed index, this patch changes slightly how to assign the kcontrols. Now, a new argument is added to snd_usb_mixer_add_list() in order to disable the empty slot search, and use it in us16x08's add_new_ctl() helper function, instead.
--- sound/usb/mixer.c | 13 +++++++++---- sound/usb/mixer.h | 5 +++-- sound/usb/mixer_quirks.c | 2 +- sound/usb/mixer_us16x08.c | 3 ++- 4 files changed, 15 insertions(+), 8 deletions(-)
sound/usb/mixer.c +9 -4
@@ -596,20 +596,25 @@ static int check_matrix_bitmap(unsigned char *bmap,/* * add an alsa control element -* search and increment the index until an empty slot is found. +* when @look_for_empty is set, search and increment the index until an empty +* slot is found. * * if failed, give up and free the control instance. */ int snd_usb_mixer_add_list (struct usb_mixer_elem_list *list,struct snd_kcontrol *kctl, -bool is_std_info) +bool is_std_info, +bool look_for_empty) {struct usb_mixer_interface *mixer = list->mixer;int err; -while (snd_ctl_find_id (mixer->chip->card, &kctl->id)) - kctl->id.index++; +if (look_for_empty) { +while (snd_ctl_find_id (mixer->chip->card, &kctl->id)) + kctl->id.index++; + } + err =snd_ctl_add (mixer->chip->card, kctl);if (err <0 ) { usb_audio_dbg(mixer->chip, "cannot add control (err = %d)\n",
sound/usb/mixer.h +3 -2
@@ -113,10 +113,11 @@ int snd_usb_mixer_set_ctl_value(struct usb_mixer_elem_info *cval,int snd_usb_mixer_add_list (struct usb_mixer_elem_list *list,struct snd_kcontrol *kctl, -bool is_std_info); +bool is_std_info, +bool look_for_empty);#define snd_usb_mixer_add_control (list, kctl) \ - snd_usb_mixer_add_list(list, kctl, true) + snd_usb_mixer_add_list(list, kctl, true, true) void snd_usb_mixer_elem_init_std(struct usb_mixer_elem_list *list, struct usb_mixer_interface *mixer,
sound/usb/mixer_quirks.c +1 -1
@@ -166,7 +166,7 @@ static int add_single_ctl_with_resume(struct usb_mixer_interface *mixer, } kctl->private_free = snd_usb_mixer_elem_free;/* don't use snd_usb_mixer_add_control() here, this is a special list element */ -return snd_usb_mixer_add_list (list, kctl, false); +return snd_usb_mixer_add_list (list, kctl, false, true); }/*
sound/usb/mixer_us16x08.c +2 -1
@@ -1134,7 +1134,8 @@ static int add_new_ctl(struct usb_mixer_interface *mixer,strscpy (kctl->id.name, name,sizeof (kctl->id.name)); - err =snd_usb_mixer_add_control (&elem->head, kctl); +/* look_for_empty=false, as we want the fixed id.index as channel */ + err =snd_usb_mixer_add_list (&elem->head, kctl, true, false);if (err <0 )return err;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1825/2651 thermal/drivers/sprd: validate the sensor id from the device tree
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Weigang He <[email protected]>
[ Upstream commit b17d799ce49bfaad68be5ff3df995b3bd021a9d7 ]
sprd_thm_probe() reads each sensor child node's "reg" property into sen->id and uses it without validation: to compute the sensor's register offsets in sprd_thm_sensor_init(), as the thermal zone id, and finally as an index into thm->sensor[], which has SPRD_THM_MAX_SENSOR
(8) entries:
ret = of_property_read_u32(sen_child, "reg", &sen->id); ... thm->sensor[sen->id] = sen;
Only the number of sensor nodes is checked against SPRD_THM_MAX_SENSOR. A "reg" value of 8 or more, or one that is negative once stored in the int sen->id, makes the register offsets point outside the sensor range and the final store land outside thm->sensor[], overwriting the fields that follow it in struct sprd_thermal_data or other memory.
Reject an out-of-range id right after reading it, before it is used.
This does not address sparse ids, such as a single sensor with id 7:
they leave holes in thm->sensor[] that the later loops over 0..nr_sensors-1 dereference. That needs a separate fix.
Found by static analysis tool CodeQL.
--- drivers/thermal/sprd_thermal.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/thermal/sprd_thermal.c +6 -0
@@ -396,6 +396,12 @@ static int sprd_thm_probe(struct platform_device *pdev) goto of_put; } +if (sen->id <0 || sen->id >=SPRD_THM_MAX_SENSOR ) { +dev_err (&pdev->dev,"invalid sensor id %d\n" , sen->id); + ret = -EINVAL ; + goto of_put; + } + ret =sprd_thm_sensor_calibration (sen_child, thm, sen);if (ret) {dev_err (&pdev->dev,"efuse cal analysis failed" );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1826/2651 thermal/drivers/airoha: Fix AN7583 ADC mux field mapping
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vitaliy Sochnev <[email protected]>
[ Upstream commit 4a0f3193c68eb41882ccf7c298f5cd0b17efb8ab ]
On AN7583, bits 3:1 of 0x2e4 select the sensor (0 bandgap, 5 GbE, 6 CPU) and bits 3:2 of 0x2a0 select the diode (0 D0, 1 ZERO, 2 D1). The driver names them the other way round: MUX_TADC is 0x2e4, MUX_SENSOR is 0x2a0.
v5 of the AN7583 series swapped the airoha_set_thermal_mux() arguments to match these names. The diode index now goes to the sensor selector, so the zone reads mux positions 1, 0 and 2 (PAD_AVS, bandgap, core voltage) instead of the bandgap diodes. On a Nokia XG-040G-MF the result crosses the critical trip and the board powers off during boot.
Swap the field definitions. MUX_TADC then selects the diode, as on EN7581, and the existing call order is correct.
--- drivers/thermal/airoha_thermal.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/thermal/airoha_thermal.c +5 -5
@@ -18,10 +18,10 @@#define EN7581_DOUT_TADC 0x2f8#define EN7581_DOUT_TADC_MASK GENMASK(15, 0) -#define AN7583_MUX_SENSOR 0x2a0 +#define AN7583_MUX_TADC 0x2a0#define AN7583_LOAD_ADJ GENMASK(3, 2) -#define AN7583_MUX_TADC 0x2e4 -#define AN7583_MUX_TADC_MASK GENMASK(3, 1) +#define AN7583_MUX_SENSOR 0x2e4 +#define AN7583_MUX_SENSOR_MASK GENMASK(3, 1)#define AN7583_DOUT_TADC 0x2f0/* PTP_THERMAL regs */
@@ -636,8 +636,8 @@ static const struct thermal_zone_device_ops an7583_tz_ops = {static const struct reg_field an7583_chip_scu_fields[AIROHA_THERMAL_FIELD_MAX ] = { [AIROHA_THERMAL_DOUT_TADC ] =REG_FIELD (AN7583_DOUT_TADC ,0 ,31 ), - [AIROHA_THERMAL_MUX_TADC ] =REG_FIELD (AN7583_MUX_TADC ,1 ,3 ), - [AIROHA_THERMAL_MUX_SENSOR ] =REG_FIELD (AN7583_MUX_SENSOR ,2 ,3 ), + [AIROHA_THERMAL_MUX_TADC ] =REG_FIELD (AN7583_MUX_TADC ,2 ,3 ), + [AIROHA_THERMAL_MUX_SENSOR ] =REG_FIELD (AN7583_MUX_SENSOR ,1 ,3 ), }; static int an7583_thermal_probe(struct platform_device *pdev,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1827/2651 tools/thermal/tmon: Fix string truncation warning in optarg copy
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Fainelli <[email protected]>
[ Upstream commit 602da762f7a7c494a95cb204ac005965b214e556 ]
GCC warns about possible string truncation with -Wstringop-truncation:
tmon.c: In function ‘main’:
tmon.c:233:25: warning: ‘__builtin_strncpy’ specified bound 20 equals
destination size [-Wstringop-truncation]
233 | strncpy(ctrl_cdev, optarg,
CDEV_NAME_SIZE);
|^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Replace strncpy() with snprintf() to guarantee NUL-termination and silence the compiler warning.
--- tools/thermal/tmon/tmon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/thermal/tmon/tmon.c +1 -1
@@ -230,7 +230,7 @@ int main(int argc, char **argv)switch (c) {case 'c' : no_control =0 ; -strncpy (ctrl_cdev, optarg,CDEV_NAME_SIZE ); +snprintf (ctrl_cdev,sizeof (ctrl_cdev),"%s" , optarg);break ;case 'd' :start_daemon_mode ();
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1828/2651 dt-bindings: thermal: amlogic: describe bus clock for t7-thermal
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ronald Claveau <[email protected]>
[ Upstream commit 8195b945794ca3a917131b8a5368bb61e687c927 ]
The t7 thermal sensor needs a bus clock, in addition to the existing functional clock, to gate register access to the sensor. This bus clock is specific to each sensor, unlike the functional clock which is shared between sensors. The current binding only describes a single unnamed clock and therefore cannot represent this hardware requirement, so add a second clock entry and clock-names for clarity. Make the second clock mandatory for the t7-thermal compatible only, via an additional if/then/else, to avoid breaking other Amlogic SoCs that still use a single clock. Update the t7 example to match.
--- .../bindings/thermal/amlogic,thermal.yaml | 29 +++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/thermal/amlogic,thermal.yaml +27 -2
@@ -32,7 +32,15 @@ properties: maxItems: 1 clocks: - maxItems: 1 + minItems: 1 + items: + - description: Bus clock, gates register access to the sensor. + - description: Functional clock of the temperature sensor, shared between sensors. + + clock-names: + items: + - const: bus + - const: core power-domains: maxItems: 1
@@ -72,6 +80,22 @@ allOf: else: required: - amlogic,secure-monitor + - if: + properties: + compatible: + contains: + const: amlogic,t7-thermal + then: + properties: + clocks: + minItems: 2 + required: + - clock-names + else: + properties: + clocks: + maxItems: 1 + clock-names: false unevaluatedProperties: false
@@ -94,7 +118,8 @@ examples: compatible = "amlogic,t7-thermal"; reg = <0x20000 0x50>; interrupts = <GIC_SPI 31 IRQ_TYPE_LEVEL_HIGH>; - clocks = <&clkc_periphs CLKID_TS>; + clocks = <&clkc_periphs CLKID_SYS_TS_A73>, <&clkc_periphs CLKID_TS>; + clock-names = "bus", "core"; #thermal-sensor-cells = <0>; amlogic,secure-monitor = <&sm 1>; };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1829/2651 thermal/drivers/amlogic: Switch to clk_bulk API to support multiple clocks
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ronald Claveau <[email protected]>
[ Upstream commit 44b39b4fb0f069a3bbe6bfb21a34d2d3730f393a ]
The t7-thermal variant now exposes two clocks (bus and core) in its devicetree binding, but the driver only knows how to get and manage a single struct clk. Using devm_clk_get() would silently ignore the second clock, so switch to devm_clk_bulk_get_all() and the matching clk_bulk_prepare_enable()/clk_bulk_disable_unprepare() calls. This lets the driver transparently handle however many clocks a given compatible declares, without needing per-variant clock-handling code, and keeps working for existing SoCs that only have one.
--- drivers/thermal/amlogic_thermal.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
drivers/thermal/amlogic_thermal.c +8 -6
@@ -100,7 +100,8 @@ struct amlogic_thermal {const struct amlogic_thermal_data *data;struct regmap *regmap;struct regmap *sec_ao_map; -struct clk *clk; +struct clk_bulk_data *clks; +int num_clks;struct thermal_zone_device *tzd;u32 trim_info;struct meson_sm_firmware *sm_fw;
@@ -142,7 +143,7 @@ static int amlogic_thermal_enable(struct amlogic_thermal *data) {int ret; - ret =clk_prepare_enable (data->clk); + ret =clk_bulk_prepare_enable (data->num_clks, data->clks);if (ret)return ret;
@@ -156,7 +157,7 @@ static void amlogic_thermal_disable(struct amlogic_thermal *data) {regmap_update_bits (data->regmap,TSENSOR_CFG_REG1 ,TSENSOR_CFG_REG1_ENABLE ,0 ); -clk_disable_unprepare (data->clk); +clk_bulk_disable_unprepare (data->num_clks, data->clks); }static int amlogic_thermal_get_temp (struct thermal_zone_device *tz,int *temp)
@@ -323,9 +324,10 @@ static int amlogic_thermal_probe(struct platform_device *pdev)if (IS_ERR (pdata->regmap))return PTR_ERR (pdata->regmap); - pdata->clk =devm_clk_get (dev,NULL ); -if (IS_ERR (pdata->clk)) -return dev_err_probe (dev,PTR_ERR (pdata->clk),"failed to get clock\n" ); + ret =devm_clk_bulk_get_all (dev, &pdata->clks); +if (ret <=0 ) +return dev_err_probe (dev, ret ?: -ENOENT ,"failed to get clocks\n" ); + pdata->num_clks = ret;if (pdata->data->use_sm) ret =amlogic_thermal_probe_sm (pdev, pdata);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1830/2651 thermal: ti-soc-thermal: Fix the return value in ti_bandgap_get_sensor_data() kernel-doc
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 82bb005cd9cf5a9df4cfe4a52db90346ac5fd17a ]
ti_bandgap_get_sensor_data() returns an ERR_PTR() if the bandgap instance or sensor ID is invalid. Otherwise it returns the stored sensor data, which can be NULL if no data has been set or the stored value has been cleared.
This mismatch was already present in omap_bandgap_get_sensor_data() when the driver was introduced in staging.
Document the validation errors while retaining NULL as a possible stored value.
--- drivers/thermal/ti-soc-thermal/ti-bandgap.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/thermal/ti-soc-thermal/ti-bandgap.c +2 -1
@@ -576,7 +576,8 @@ int ti_bandgap_set_sensor_data(struct ti_bandgap *bgp, int id, void *data)* @bgp: pointer to bandgap instance * @id: sensor id * -* Return: data stored by set function with sensor id on success or NULL +* Return: the stored sensor data, which may be %NULL, or an ERR_PTR() +* if @bgp or @id is invalid. */ void *ti_bandgap_get_sensor_data (struct ti_bandgap *bgp,int id) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1831/2651 thermal/drivers/rzg3e: Propagate reset assertion failure from suspend
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pengpeng Hou <[email protected]>
[ Upstream commit 2dc1f296b5754dd2441fc8b6613a362a47f6b98f ]
rzg3e_thermal_suspend() powers off an active sensor and then ignores failure to assert its reset. System sleep can therefore continue without the clean reset state expected by resume.
Return the reset error and, when the sensor had been active, try to restore power before failing suspend. This is best-effort recovery:
reset assertion failure may leave partial hardware state, so restoring power is not guaranteed to succeed. Preserve the original reset error.
The issue was found by our static-analysis tool and manually reviewed.
--- drivers/thermal/renesas/rzg3e_thermal.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/thermal/renesas/rzg3e_thermal.c +7 -3
@@ -519,15 +519,19 @@ static int rzg3e_thermal_runtime_resume(struct device *dev)static int rzg3e_thermal_suspend (struct device *dev) {struct rzg3e_thermal_priv *priv =dev_get_drvdata (dev); +bool active =pm_runtime_active (dev); +int ret;/* If device is active, power it off */ -if (pm_runtime_active (dev)) +if (active)rzg3e_thermal_power_off (priv);/* Assert reset to ensure clean state after resume */ -reset_control_assert (priv->rstc); + ret =reset_control_assert (priv->rstc); +if (ret && active) +rzg3e_thermal_power_on (priv); -return 0 ; +return ret; }static int rzg3e_thermal_resume (struct device *dev)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1832/2651 mm/slab: Mark the kmem_buckets_create() context as a Context: section
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kees Cook <[email protected]>
[ Upstream commit 655668f0caf32a42fef10aaf31137e52f46a0260 ]
kmem_buckets_create() had the same sentence about calling context as kmem_cache_create(), but lacked the "Context:" prefix, so kernel-doc rendered in the body instead of as a "context" section.
Give it the missing prefix. Additionally fix the "a interrupt" typo __kmem_cache_create_args() had.
--- mm/slab_common.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
mm/slab_common.c +2 -2
@@ -311,7 +311,7 @@ __kmem_cache_alias(const char *name, unsigned int size, slab_flags_t flags,* &SLAB_TYPESAFE_BY_RCU - Slab page (not individual objects) freeing delayed * by a grace period - see the full description before using. * -* Context: Cannot be called within a interrupt, but can be interrupted. +* Context: Cannot be called within an interrupt, but can be interrupted. * * Return: a pointer to the cache on success, NULL on failure. */
@@ -422,7 +422,7 @@ static struct kmem_cache *kmem_buckets_cache __ro_after_init;* to/from userspace. * @ctor: A constructor for the objects, run when new allocations are made. * -* Cannot be called within an interrupt, but can be interrupted. +* Context: Cannot be called within an interrupt, but can be interrupted. * * Return: a pointer to the cache on success, NULL on failure. When * CONFIG_SLAB_BUCKETS is not enabled, ZERO_SIZE_PTR is returned, and
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1833/2651 module: Fix uninitialized count read of unloaded taint tracking record
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Binbin Deng <[email protected]>
[ Upstream commit 7a5c13cfdfcb1871050fdbe00ac223993f8925fa ]
try_add_tainted_module() allocates the tracking record without zeroing it and initializes the fields in this order:
mod_taint = kmalloc_obj(*mod_taint); strscpy(mod_taint->name, mod->name, MODULE_NAME_LEN); mod_taint->taints = mod->taints; list_add_rcu(&mod_taint->list, &unloaded_tainted_modules); mod_taint->count = 1;
The record is published by list_add_rcu() before the count field is written. The readers, unloaded_tainted_modules_seq_show() (debugfs, under rcu_read_lock()) and print_unloaded_tainted_modules() (panic path, under guard(rcu)), traverse the list under RCU and read mod_taint->count. module_mutex, which the writer holds, does not exclude RCU readers.
A reader that observes the new node between the list_add_rcu() and the count store reads an uninitialized u64 left over from previous slab use. This is a data race and leaks kernel heap residue through the debugfs file and the panic message.
The race window is two adjacent instructions; it is reachable when a tainted module is unloaded (rmmod) concurrently with a read of /sys/kernel/debug/module/unloaded_tainted, or with the module list printout of an oops on another CPU.
Fix this by initializing count before the record is published.
Found during a static-analysis-assisted audit: candidate sites were surfaced by a Coccinelle rule, and the reader/writer paths were confirmed by LLM-assisted (GLM-5.3) code inspection. The issue was not observed at runtime; it is identified by code inspection only.
--- kernel/module/tracking.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/module/tracking.c +1 -1
@@ -38,8 +38,8 @@ int try_add_tainted_module(struct module *mod)return -ENOMEM ;strscpy (mod_taint->name, mod->name,MODULE_NAME_LEN ); mod_taint->taints = mod->taints; -list_add_rcu (&mod_taint->list, &unloaded_tainted_modules); mod_taint->count =1 ; +list_add_rcu (&mod_taint->list, &unloaded_tainted_modules); out:return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1834/2651 wifi: iwlwifi: mvm: fix the VHT MCS sent to a v1 firmware
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Emmanuel Grumbach <[email protected]>
[ Upstream commit a2f60db1c1514c7d083b5c0c8b9510b1adf0cc2c ]
When converting a v3 rate to the v1 format, the MCS index was read from the mask of the NSS field and written into the mask of the MCS field. This is obviously wrong, we must not mix the NSS and the MCS.
--- drivers/net/wireless/intel/iwlwifi/mvm/utils.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireless/intel/iwlwifi/mvm/utils.c +2 -2
@@ -1356,8 +1356,8 @@ __le32 iwl_mvm_v3_rate_to_fw(u32 rate, u8 rate_ver)case RATE_MCS_MOD_TYPE_VHT : result =RATE_MCS_VHT_MSK_V1 ; result |=u32_encode_bits (u32_get_bits (rate, -RATE_VHT_MCS_NSS_MSK ), -RATE_MCS_CODE_MSK ); +RATE_MCS_CODE_MSK ), +RATE_VHT_MCS_RATE_CODE_MSK ); result |=u32_encode_bits (u32_get_bits (rate,RATE_MCS_NSS_MSK ),RATE_VHT_MCS_NSS_MSK );break ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1835/2651 wifi: iwlwifi: mld: include VI packets in low latency detection
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Endrik Einberg <[email protected]>
[ Upstream commit 3627924ed81fd7783394fb2555ea179c6606a231 ]
iwl_mld_is_vo_vi_pkt() checks whether the mapped access category is less than IEEE80211_AC_VI.
Since mac80211 defines IEEE80211_AC_VO as 0 and IEEE80211_AC_VI as 1, this only matches voice traffic and excludes video traffic.
Synthetic video-priority UDP traffic does not automatically activate low-latency mode, whereas voice-priority traffic does
Include IEEE80211_AC_VI as intended.
--- drivers/net/wireless/intel/iwlwifi/mld/low_latency.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/wireless/intel/iwlwifi/mld/low_latency.c +2 -1
@@ -257,7 +257,8 @@ static bool iwl_mld_is_vo_vi_pkt(struct ieee80211_hdr *hdr)if (tid >=IWL_MAX_TID_COUNT )return false; -return tid_to_mac80211_ac[tid] <IEEE80211_AC_VI ; +return tid_to_mac80211_ac[tid] ==IEEE80211_AC_VI || + tid_to_mac80211_ac[tid] ==IEEE80211_AC_VO ; } void iwl_mld_low_latency_update_counters(struct iwl_mld *mld,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1836/2651 ipvs: fix buffer overflow when sending sync messages
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Julian Anastasov <[email protected]>
[ Upstream commit 3e3fe49e8678c1a3d535ed02f32a9a6e80674263 ]
Sashiko reports for possible heap buffer overflow when generating sync message for the v0 and v1 message formats. We should read the cp->flags only once because another CPU can concurrently set the SEQ_MASK between the two reads.
Note that IPVS does not set the SEQ_MASK anymore for the ip_vs_ftp.c helper starting from commit 7f1c40757951 ("IPVS: make FTP work with full NAT support") (2.6.36+), so the problem should not be reproducible.
--- net/netfilter/ipvs/ip_vs_sync.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-)
net/netfilter/ipvs/ip_vs_sync.c +14 -9
@@ -543,13 +543,15 @@ static void ip_vs_sync_conn_v0(struct netns_ipvs *ipvs, struct ip_vs_conn *cp,struct ip_vs_sync_conn_v0 *s;struct ip_vs_sync_buff *buff;struct ipvs_master_sync_state *ms; -int id; +u32 flags, seq_mask;unsigned int len; +int id;if (unlikely (cp->af !=AF_INET ))return ; + flags =READ_ONCE (cp->flags);/* Do not sync ONE PACKET */ -if (cp->flags &IP_VS_CONN_F_ONE_PACKET ) +if (flags &IP_VS_CONN_F_ONE_PACKET )return ;if (!ip_vs_sync_conn_needed (ipvs, cp, pkts))
@@ -564,8 +566,8 @@ static void ip_vs_sync_conn_v0(struct netns_ipvs *ipvs, struct ip_vs_conn *cp, id =select_master_thread_id (ipvs, cp); ms = &ipvs->ms[id]; buff = ms->sync_buff; - len = (cp->flags &IP_VS_CONN_F_SEQ_MASK ) ?FULL_CONN_SIZE : -SIMPLE_CONN_SIZE ; + seq_mask = flags &IP_VS_CONN_F_SEQ_MASK ; + len = seq_mask ?FULL_CONN_SIZE :SIMPLE_CONN_SIZE ;if (buff) { m = (struct ip_vs_sync_mesg_v0 *) buff->mesg;/* Send buffer if it is for v1 */
@@ -597,9 +599,9 @@ static void ip_vs_sync_conn_v0(struct netns_ipvs *ipvs, struct ip_vs_conn *cp, s->caddr = cp->caddr.ip; s->vaddr = cp->vaddr.ip; s->daddr = cp->daddr.ip; - s->flags =htons (cp->flags & ~IP_VS_CONN_F_HASHED ); + s->flags =htons (flags & ~IP_VS_CONN_F_HASHED ); s->state =htons (cp->state); -if (cp->flags &IP_VS_CONN_F_SEQ_MASK ) { +if (seq_mask) {struct ip_vs_sync_conn_options *opt = (struct ip_vs_sync_conn_options *)&s[1 ];memcpy (opt, &cp->sync_conn_opt,sizeof (*opt));
@@ -635,6 +637,7 @@ void ip_vs_sync_conn(struct netns_ipvs *ipvs, struct ip_vs_conn *cp, int pkts)int id;__u8 *p;unsigned int len, pe_name_len, pad; +u32 flags, seq_mask;/* Handle old version of the protocol */ if (sysctl_sync_ver (ipvs) ==0 ) {
@@ -647,6 +650,7 @@ void ip_vs_sync_conn(struct netns_ipvs *ipvs, struct ip_vs_conn *cp, int pkts) sloop:if (!ip_vs_sync_conn_needed (ipvs, cp, pkts)) goto control; + flags =READ_ONCE (cp->flags);/* Sanity checks */ pe_name_len =0 ;
@@ -674,7 +678,8 @@ void ip_vs_sync_conn(struct netns_ipvs *ipvs, struct ip_vs_conn *cp, int pkts)#endif len =sizeof (struct ip_vs_sync_v4 ); -if (cp->flags &IP_VS_CONN_F_SEQ_MASK ) + seq_mask = flags &IP_VS_CONN_F_SEQ_MASK ; +if (seq_mask) len +=sizeof (struct ip_vs_sync_conn_options ) +2 ;if (cp->pe_data_len)
@@ -720,7 +725,7 @@ void ip_vs_sync_conn(struct netns_ipvs *ipvs, struct ip_vs_conn *cp, int pkts)/* Set message type & copy members */ s->v4.type = (cp->af ==AF_INET6 ?STYPE_F_INET6 :0 ); s->v4.ver_size =htons (len &SVER_MASK );/* Version 0 */ - s->v4.flags =htonl (cp->flags & ~IP_VS_CONN_F_HASHED ); + s->v4.flags =htonl (flags & ~IP_VS_CONN_F_HASHED ); s->v4.state =htons (cp->state); s->v4.protocol = cp->protocol; s->v4.cport = cp->cport;
@@ -744,7 +749,7 @@ void ip_vs_sync_conn(struct netns_ipvs *ipvs, struct ip_vs_conn *cp, int pkts) s->v4.vaddr = cp->vaddr.ip; s->v4.daddr = cp->daddr.ip; } -if (cp->flags &IP_VS_CONN_F_SEQ_MASK ) { +if (seq_mask) { *(p++) =IPVS_OPT_SEQ_DATA ; *(p++) =sizeof (struct ip_vs_sync_conn_options );hton_seq (&cp->in_seq, (struct ip_vs_seq *)p);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1837/2651 platform/x86: hp-wmi: Fix hwmon keep-alive teardown
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shang En Sim <[email protected]>
[ Upstream commit 574245e62cb09e159b4c37e1a9091c100448b5c3 ]
hp_wmi_hwmon_init() initialises keep_alive_dwork with INIT_DELAYED_WORK() and relies on hp_wmi_bios_remove() to cancel it. Nothing cancels the work if probe fails after hp_wmi_hwmon_init() has run, so the devm-managed priv can be freed while the work is still pending.
The ordering is also wrong on both ends. The work is initialised only after the hwmon device is registered, so a sysfs write to pwm1_enable can schedule an uninitialised work item. On removal, the work is cancelled in .remove(), before devres unregisters the hwmon device, so a sysfs write can requeue it after the cancel.
Use devm_delayed_work_autocancel() and set it up before registering the hwmon device. devres then cancels the work on every teardown path, after the hwmon sysfs interface has been removed and before priv and its mutex are released. Drop the now-unneeded cancel in hp_wmi_bios_remove() and the platform drvdata that was only used for it.
--- drivers/platform/x86/hp/hp-wmi.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-)
drivers/platform/x86/hp/hp-wmi.c +12 -7
@@ -18,6 +18,7 @@#include <linux/bits.h> #include <linux/cleanup.h> #include <linux/compiler_attributes.h> +#include <linux/devm-helpers.h> #include <linux/dmi.h> #include <linux/fixp-arith.h> #include <linux/hwmon.h>
@@ -2549,7 +2550,6 @@ static int __init hp_wmi_bios_setup(struct platform_device *device) static void __exit hp_wmi_bios_remove(struct platform_device *device) {int i; -struct hp_wmi_hwmon_priv *priv;for (i =0 ; i < rfkill2_count; i++) {rfkill_unregister (rfkill2[i].rfkill);
@@ -2568,10 +2568,6 @@ static void __exit hp_wmi_bios_remove(struct platform_device *device)rfkill_unregister (wwan_rfkill);rfkill_destroy (wwan_rfkill); } - - priv =platform_get_drvdata (device); -if (priv) -cancel_delayed_work_sync (&priv->keep_alive_dwork); }static int hp_wmi_resume_handler (struct device *device)
@@ -2919,6 +2915,17 @@ static int hp_wmi_hwmon_init(void) ret =hp_wmi_setup_fan_settings (priv);if (ret)return ret; + +/* +* Set up the work before registering hwmon so that, on teardown, +* it is cancelled only after the sysfs writers that schedule it +* are gone. +*/ + ret =devm_delayed_work_autocancel (dev, &priv->keep_alive_dwork, + hp_wmi_hwmon_keep_alive_handler); +if (ret) +return ret; + hwmon =devm_hwmon_device_register_with_info (dev,"hp" , priv, &chip_info,NULL );
@@ -2927,8 +2934,6 @@ static int hp_wmi_hwmon_init(void)return PTR_ERR (hwmon); } -INIT_DELAYED_WORK (&priv->keep_alive_dwork, hp_wmi_hwmon_keep_alive_handler); -platform_set_drvdata (hp_wmi_platform_dev, priv); ret =hp_wmi_apply_fan_settings (priv);if (ret)dev_warn (dev,"Failed to apply initial fan settings: %d\n" , ret);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1838/2651 wifi: cfg80211: track SSID regardless of country data
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
[ Upstream commit 577f690ce5dc641d9d8646d15bb8e99ff4a8280e ]
If the country data cannot be found, the function exits and then doesn't track the SSID. Move the SSID tracking up to fix that.
--- net/wireless/sme.c | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-)
net/wireless/sme.c +19 -19
@@ -872,6 +872,25 @@ void __cfg80211_connect_result(struct net_device *dev,cfg80211_upload_connect_keys (wdev); +if (!wdev->u.client.ssid_len) { +rcu_read_lock (); +for_each_valid_link (cr, link) { +u32 ssid_len; + + ssid =ieee80211_bss_get_elem (cr->links[link].bss, +WLAN_EID_SSID ); + +if (!ssid || !ssid->datalen) +continue ; + + ssid_len =min (ssid->datalen,IEEE80211_MAX_SSID_LEN ); +memcpy (wdev->u.client.ssid, ssid->data, ssid_len); + wdev->u.client.ssid_len = ssid_len; +break ; + } +rcu_read_unlock (); + } +rcu_read_lock ();for_each_valid_link (cr, link) { country_elem =
@@ -897,25 +916,6 @@ void __cfg80211_connect_result(struct net_device *dev, country_data, country_datalen);kfree (country_data); -if (!wdev->u.client.ssid_len) { -rcu_read_lock (); -for_each_valid_link (cr, link) { -u32 ssid_len; - - ssid =ieee80211_bss_get_elem (cr->links[link].bss, -WLAN_EID_SSID ); - -if (!ssid || !ssid->datalen) -continue ; - - ssid_len =min (ssid->datalen,IEEE80211_MAX_SSID_LEN ); -memcpy (wdev->u.client.ssid, ssid->data, ssid_len); - wdev->u.client.ssid_len = ssid_len; -break ; - } -rcu_read_unlock (); - } -return ; out:for_each_valid_link (cr, link)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1839/2651 arm64: rsi: Correct type of realm_config::hash_algo
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kohei Enju <[email protected]>
[ Upstream commit c83237edf0adb8f8cbd9859841bbca5acc00fc11 ]
The RMM specification (DEN0137, B5.5.10 and B5.5.19) defines RsiHashAlgorithm as an 8-bit enumeration, stored at offset 0x8 of RsiRealmConfig, with the unused bits of the structure being MBZ. However, realm_config::hash_algo is declared as unsigned long.
For an RMM that zeroes the unused bits, the wider type gives the same value. An RMM that only writes the low byte (as TF-RMM currently does) leaves bytes 1-7 with whatever the guest buffer contained, so a comparison of the 64-bit field against RSI_HASH_SHA_* can fail. Nothing in mainline reads the field yet, but the proposed Realm measurement register support does.
Declare the field as u8 so the guest only depends on the byte the specification defines. The struct size and the offsets of the other fields do not change.
--- arch/arm64/include/asm/rsi_smc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/include/asm/rsi_smc.h +1 -1
@@ -128,7 +128,7 @@ struct realm_config {union {struct {unsigned long ipa_bits;/* Width of IPA in bits */ -unsigned long hash_algo;/* Hash algorithm */ +u8 hash_algo;/* Hash algorithm */ };u8 pad[0x200 ]; };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1840/2651 ALSA: pcm: Unlink substreams before releasing them
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cen Zhang <[email protected]>
[ Upstream commit d1e57f8fb7a6b6d32a4aaa31fd6fc4c77339608f ]
A closing PCM substream can remain in its linked group after the driver close callback has freed its private data. With two configured dummy capture substreams on the same PCM device, linked with LINK, PREPARE on the surviving substream can still visit the closing member:
Final close of A PREPARE on linked B
---------------- -------------------
snd_pcm_drop(): group -> SETUP
do_hw_free(A)
dummy_pcm_close(A): free dpcm
Take snd_pcm_link_rwsem for reading Walk the group, including A dummy_pcm_prepare(A)
Read freed timer_ops
pcm_release_private(A)
snd_pcm_unlink(A)
Unlink at the start of final substream release, before dropping the stream or releasing driver resources. The link write lock waits for an existing group PREPARE, and unlink removes the closing member from later group actions. Keep the existing stop synchronization in do_hw_free() before the driver resources are freed.
Make unlink independent of the pcm_release callback so OSS substreams are covered too. Remove the native-only unlink callback and its registration, while retaining the callback hook for OSS cleanup.
The existing KASAN report below records the freed timer_ops read in dummy_pcm_prepare().
KASAN report as below:
BUG: KASAN: slab-use-after-free in dummy_pcm_prepare+0xb7/0xc0
Read of size 8 at addr ffff888106b35f00 by task alsa_pcm_fixtur/491
Call Trace:
<TASK>
dump_stack_lvl+0x93/0xd0
print_report+0xce/0x630
? dummy_pcm_prepare+0xb7/0xc0
? srso_alias_return_thunk+0x5/0xfbef5
? __virt_addr_valid+0x20d/0x410
? dummy_pcm_prepare+0xb7/0xc0
kasan_report+0xe0/0x110
? dummy_pcm_prepare+0xb7/0xc0
dummy_pcm_prepare+0xb7/0xc0
snd_pcm_do_prepare+0x71/0xb0
snd_pcm_action_group+0x505/0xb30
snd_pcm_action_nonatomic+0xab/0x150
snd_pcm_common_ioctl+0x1bf5/0x3a50
? srso_alias_return_thunk+0x5/0xfbef5
? do_vfs_ioctl+0x1f5/0x1280
? __pfx_do_vfs_ioctl+0x10/0x10
? ioctl_has_perm.constprop.0.isra.0+0x34f/0x500
? __pfx_snd_pcm_common_ioctl+0x10/0x10
? __fput+0x5ba/0xa60
? srso_alias_return_thunk+0x5/0xfbef5
snd_pcm_ioctl+0x76/0xb0
? __pfx_snd_pcm_ioctl+0x10/0x10
__x64_sys_ioctl+0x163/0x1d0
do_syscall_64+0x115/0x6a0
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x41ee8d
Code: 04 25 28 00 00 00 48 89 45 c8 31 c0 48 8d 45 10 c7 45 b0 10 00 00 00 48 89 45 b8 48 8d 45 d0 48 89 45 c0 b8 10 00 00 00 0f 05 <89> c2 3d 00 f0 ff ff 77 1a 48 8b 45 c8 64 48 2b 04 25 28 00 00 00
RSP: 002b:00007ffcfa72fb60 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 0000000000000004 RCX: 000000000041ee8d
RDX: 0000000000000000 RSI: 0000000000004140 RDI: 0000000000000004
RBP: 00007ffcfa72fbb0 R08: 00007ffcfa72fb98 R09: 0000000000000110
R10: 0000000000000001 R11: 0000000000000246 R12: 00007ffcfa72fcd8
R13: 00007ffcfa72fcf0 R14: 00000000004a8f28 R15: 0000000000000001
</TASK>
Allocated by task 488:
kasan_save_stack+0x33/0x60
kasan_save_track+0x14/0x30
__kasan_kmalloc+0xaa/0xb0
__kmalloc_cache_noprof+0x251/0x610
dummy_hrtimer_create+0x4a/0x170
dummy_pcm_open+0xe7/0x730
snd_pcm_open_substream+0x926/0x1580
snd_pcm_open+0x28d/0x6d0
snd_pcm_capture_open+0x82/0xe0
snd_open+0x1ec/0x3e0
chrdev_open+0x21f/0x660
do_dentry_open+0x5c8/0x1300
vfs_open+0x87/0x390
path_openat+0x2460/0x3cd0
do_file_open+0x21e/0x470
do_sys_openat2+0xf4/0x1b0
__x64_sys_openat+0x136/0x1e0
do_syscall_64+0x115/0x6a0
entry_SYSCALL_64_after_hwframe+0x77/0x7f
Freed by task 490:
kasan_save_stack+0x33/0x60
kasan_save_track+0x14/0x30
kasan_save_free_info+0x3b/0x60
__kasan_slab_free+0x5f/0x80
kfree+0x307/0x580
dummy_hrtimer_free+0x72/0xe0
dummy_pcm_close+0x9f/0xd0
snd_pcm_release_substream.part.0+0x104/0x310
snd_pcm_release+0x106/0x240
__fput+0x39f/0xa60
fput_close_sync+0xff/0x200
__x64_sys_close+0x8c/0xf0
do_syscall_64+0x115/0x6a0
entry_SYSCALL_64_after_hwframe+0x77/0x7f
==================================================================--- sound/core/pcm_native.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)
sound/core/pcm_native.c +2 -8
@@ -2786,18 +2786,14 @@ static int snd_pcm_hw_constraints_complete(struct snd_pcm_substream *substream)return 0 ; } -static void pcm_release_private (struct snd_pcm_substream *substream) -{ -if (snd_pcm_stream_linked (substream)) -snd_pcm_unlink (substream); -} -void snd_pcm_release_substream (struct snd_pcm_substream *substream) { substream->ref_count--;if (substream->ref_count >0 )return ; +snd_pcm_unlink (substream); +snd_pcm_drop (substream);if (substream->hw_opened) {if (substream->runtime->state !=SNDRV_PCM_STATE_OPEN )
@@ -2881,8 +2877,6 @@ static int snd_pcm_open_file(struct file *file,return -ENOMEM ; } pcm_file->substream = substream; -if (substream->ref_count ==1 ) - substream->pcm_release = pcm_release_private; file->private_data = pcm_file;return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1841/2651 dma-debug: Skip cacheline tracking for MMIO mappings
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Leon Romanovsky <[email protected]>
[ Upstream commit 4733f2966433b7f926f70c9dc461c33cd5c10835 ]
Mapping one MMIO dma-buf for many RDMA importers overflows dma-debug's cacheline overlap counter and triggers a warning. DMA_ATTR_MMIO mappings must never be CPU-cacheable, so CPU cacheline overlap tracking does not apply to them.
Skip MMIO entries in both cacheline insertion and removal. Keep them in the DMA entry hash so mapping and unmapping checks still run.
The reported warning was:
------------[ cut here ]------------ DMA-API: exceeded 7 overlapping mappings of cacheline 0x000000e040000400 WARNING: kernel/dma/debug.c:465 at add_dma_entry+0x3b5/0x470, CPU#58: dtr/5264 Modules linked in: xt_conntrack xt_MASQUERADE ip6table_nat ip6table_filter ip6_tables iptable_nat nf_nat xt_addrtype rpcsec_gss_krb5 krb5 auth_rpcgss oid_registry overlay rpcrdma rdma_ucm ib_uverbs ib_iser libiscsi scsi_transport_iscsi ib_umad rdma_cm ib_ipoib iw_cm ib_cm nvidia(O) mlx5_fwctl nvidia_drm(O) mlx5_ib ib_uverbs_support ib_core zram zsmalloc fuse mlx5_core CPU: 58 UID: 0 PID: 5264 Comm: dtr Tainted: G O J 7.3.0-rc6_for_upstream_debug_2026_10_08_13_46 #1.fc40 PREEMPTLAZY Tainted: [O]=OOT_MODULE, [J]=FWCTL Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.16.3-0-ga6ed6b701f0a-prebuilt.qemu.org 04/01/2014 RIP: 0010:add_dma_entry+0x3bf/0x470 Code: ac e8 f5 89 6e 00 e9 47 fe ff ff 41 f7 c6 00 18 00 00 75 9f 83 fb 07 7e 9a 48 8d 3d eb 02 5f 04 be 07 00 00 00 48 8d 54 24 30 <67> 48 0f b9 3a eb 82 0f 0b 48 c7 c7 80 d3 2a 85 4c 89 e6 e8 a9 1f RSP: 0018:ff110001bcb7f230 EFLAGS: 00010002 RAX: 0000000000000006 RBX: 0000000000000008 RCX: 0000000000000000 RDX: ff110001bcb7f260 RSI: 0000000000000007 RDI: ffffffff85cfd070 RBP: 000000e040000400 R08: 0000000000000000 R09: ffe21c0044b8abf5 R10: ff11000225c55faf R11: 0000000000000000 R12: 0000000000000246 R13: 1fe220003796fe48 R14: 0000000000000400 R15: 00000000ffffffff FS: 00007fa8f91e6b80(0000) GS:ff11000eb81cc000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007fa8f5ca80f0 CR3: 0000000164871004 CR4: 0000000000373eb0 Call Trace: <TASK> ? check_sync+0x2070/0x2070 ? find_held_lock+0x2b/0x80 ? debug_dma_map_phys+0x588/0x840 debug_dma_map_phys+0x267/0x840 ? dma_debug_add_bus+0xd0/0xd0 ? __sg_alloc_table+0x2b7/0x4d0 dma_map_phys+0x10a/0x330 ? sg_miter_start+0x130/0x130 dma_buf_phys_vec_to_sgt+0x565/0xed0 uverbs_dmabuf_map+0x158/0x340 [ib_uverbs] ? uverbs_dmabuf_unpin+0x10/0x10 [ib_uverbs] dma_buf_map_attachment+0x138/0x690 ib_umem_dmabuf_map_pages+0x249/0xc90 [ib_core] pagefault_dmabuf_mr+0x172/0xf80 [mlx5_ib] ? do_raw_spin_unlock+0x54/0x210 mlx5_ib_init_dmabuf_mr+0x13e/0x200 [mlx5_ib] [... '?' frames and user-space registers omitted ...] reg_user_mr_dmabuf+0x3bf/0x760 [mlx5_ib] mlx5_ib_reg_user_mr_dmabuf+0x2dd/0x13b0 [mlx5_ib] ib_uverbs_handler_UVERBS_METHOD_REG_MR+0x76d/0xd90 [ib_uverbs] ib_uverbs_cmd_verbs+0x2337/0x31c0 [ib_uverbs] ib_uverbs_ioctl+0x1c7/0x350 [ib_uverbs] __x64_sys_ioctl+0x72c/0x11f0 do_syscall_64+0xa1/0x4f0 entry_SYSCALL_64_after_hwframe+0x4b/0x53 </TASK> ---[ end trace 0000000000000000 ]---
--- kernel/dma/debug.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
kernel/dma/debug.c +5 -2
@@ -489,8 +489,10 @@ static int active_cacheline_insert(struct dma_debug_entry *entry,/* If the device is not writing memory then we don't have any * concerns about the cpu consuming stale data. This mitigates * legitimate usages of overlapping mappings. +* MMIO mappings are never CPU-cacheable and do not need tracking either. */ -if (entry->direction ==DMA_TO_DEVICE ) +if (entry->direction ==DMA_TO_DEVICE || + entry->attrs &DMA_ATTR_MMIO )return 0 ;spin_lock_irqsave (&radix_lock, flags);
@@ -519,7 +521,8 @@ static void active_cacheline_remove(struct dma_debug_entry *entry)unsigned long flags;/* ...mirror the insert case */ -if (entry->direction ==DMA_TO_DEVICE ) +if (entry->direction ==DMA_TO_DEVICE || + entry->attrs &DMA_ATTR_MMIO )return ;spin_lock_irqsave (&radix_lock, flags);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1842/2651 platform/x86: hp-bioscfg: fix off-by-one in password length check
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Muhammad Bilal <[email protected]>
[ Upstream commit 0c22178524864af85ea380be4b2d36078c0edc9c ]
current_password and new_password hold MAX_PASSWD_SIZE bytes including the NUL, but validate_password_input() accepts a password of exactly MAX_PASSWD_SIZE characters when the firmware limits allow it. strscpy() then truncates it and fails with -E2BIG, which store_password_instance() ignores, so the write reports success with a truncated password stored.
For example, with a max_password_length of 64 or more, writing 64 characters succeeds but only 63 are stored.
Reject lengths of MAX_PASSWD_SIZE or more.
Compile tested only.
--- drivers/platform/x86/hp/hp-bioscfg/passwdobj-attributes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/platform/x86/hp/hp-bioscfg/passwdobj-attributes.c +1 -1
@@ -74,7 +74,7 @@ static int validate_password_input(int instance_id, const char *buf,if (is_current && !length)return 0 ; -if (length >MAX_PASSWD_SIZE ) +if (length >=MAX_PASSWD_SIZE )return -E2BIG ; if (password_data->min_password_length > length ||
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1843/2651 platform/x86: hp-bioscfg: validate SPM state returned by firmware
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Muhammad Bilal <[email protected]>
[ Upstream commit 35fb43f1576e1352077afc33a535007e0568480c ]
status_show() indexes the 3-entry spm_state_types[] with the state byte returned by firmware. update_spm_state() stores the same byte, which key_mechanism_show() uses to index the 3-entry spm_mechanism_types[]. Neither is range checked, so a state above 2 makes the world-readable status and key_mechanism files print a string from a pointer read past the array.
Return -EIO for an out of range state.
Compile tested only.
--- drivers/platform/x86/hp/hp-bioscfg/spmobj-attributes.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/platform/x86/hp/hp-bioscfg/spmobj-attributes.c +7 -0
@@ -6,6 +6,7 @@* Copyright (c) 2022 HP Development Company, L.P. */ +#include <linux/array_size.h> #include "bioscfg.h" static const char *const spm_state_types[] = {
@@ -115,6 +116,9 @@ static ssize_t update_spm_state(void)if (ret <0 )return ret; +if (data.state >=ARRAY_SIZE (spm_mechanism_types)) +return -EIO ; + bioscfg_drv.spm_data.mechanism = data.state;if (bioscfg_drv.spm_data.mechanism) bioscfg_drv.spm_data.is_enabled =1 ;
@@ -150,6 +154,9 @@ static ssize_t status_show(struct kobject *kobj, struct kobj_attributeif (ret <0 )return ret; +if (data.state >=ARRAY_SIZE (spm_state_types)) +return -EIO ; +/* * 'status' is a read-only file that returns ASCII text in * JSON format reporting the status information.
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1844/2651 platform/x86: hp-bioscfg: fix oops on short integer attribute buffer
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Muhammad Bilal <[email protected]>
[ Upstream commit fd7545cd398adc09ec2f9b603d72671560ee6bf9 ]
hp_populate_integer_elements_from_buffer() ignores the return value of hp_get_string_from_buffer(). When fewer than 2 bytes are left in the buffer, dst_size is 0, kcalloc() returns ZERO_SIZE_PTR and hp_get_string_from_buffer() fails without writing to it, so kstrtoint() faults on address 0x10.
Return the error instead.
Compile tested only.
--- drivers/platform/x86/hp/hp-bioscfg/int-attributes.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/platform/x86/hp/hp-bioscfg/int-attributes.c +6 -1
@@ -331,7 +331,12 @@ static int hp_populate_integer_elements_from_buffer(u8 *buffer_ptr, u32 *buffer_// VALUE: integer_data->current_value =0 ; -hp_get_string_from_buffer (&buffer_ptr, buffer_size, dst, dst_size); + ret =hp_get_string_from_buffer (&buffer_ptr, buffer_size, dst, dst_size); +if (ret <0 ) { +kfree (dst); +return ret; + } + ret =kstrtoint (dst,10 , &integer_data->current_value);if (ret)pr_warn ("Unable to convert string to integer: %s\n" , dst);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1845/2651 serial: ma35d1: Do not force-enable an unselected console
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 171bb8a67cc1af7c88a65961adfb028430e0b783 ]
When another console is selected and there is no matching ttyNVT console argument, the core accepts the MA35D1 console without calling its setup function because it has CON_ENABLED set before registration. Its index remains -1 and printk repeatedly reports an invalid port, flooding the console and preventing boot.
Let the console core enable it after successful setup.
--- drivers/tty/serial/ma35d1_serial.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/serial/ma35d1_serial.c +1 -1
@@ -639,7 +639,7 @@ static struct console ma35d1serial_console = { .write = ma35d1serial_console_write, .device = uart_console_device, .setup = ma35d1serial_console_setup, - .flags = CON_PRINTBUFFER | CON_ENABLED, + .flags = CON_PRINTBUFFER, .index = -1, .data = &ma35d1serial_reg, };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1846/2651 serial: pmac_zilog: report received breaks
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tim Douglas <[email protected]>
[ Upstream commit 8db79ea07a67b126c773da6efdc00066000daeb8 ]
pmz_status_handle() sets PMACZILOG_FLAG_BREAK from RR0, and pmz_receive_chars() clears it on the null character that ends the break without marking that character, then tests BRK_ABRT in RR1, where the SCC does not set it in asynchronous mode. Breaks therefore arrive as plain NULs: brk is never counted and BRKINT, PARMRK and SysRq never see them.
Set BRK_ABRT in r1 for that character, as sunzilog does.
--- drivers/tty/serial/pmac_zilog.c | 1 + 1 file changed, 1 insertion(+)
drivers/tty/serial/pmac_zilog.c +1 -0
@@ -233,6 +233,7 @@ static bool pmz_receive_chars(struct uart_pmac_port *uap) ch &= uap->parity_mask;if (ch ==0 && uap->flags &PMACZILOG_FLAG_BREAK ) { uap->flags &= ~PMACZILOG_FLAG_BREAK ; + r1 |=BRK_ABRT ; }#if defined(CONFIG_MAGIC_SYSRQ ) && defined(CONFIG_SERIAL_CORE_CONSOLE )
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1847/2651 PCI: eswin: Publish the platform driver OF alias
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pengpeng Hou <[email protected]>
[ Upstream commit e564a064a2d61641d6c5068d41e677e6180aa5b8 ]
PCIE_ESWIN is tristate and eswin_pcie_driver uses an OF match table, but the table is not exported. The resulting module lacks the OF alias needed for automatic loading on an ESWIN PCIe host controller.
Export the OF table. Keep builtin_platform_driver() and the intentional absence of an unregister path unchanged; module alias publication does not require making this interrupt-controller driver unloadable.
The issue was found by our static-analysis tool.
--- drivers/pci/controller/dwc/pcie-eswin.c | 1 + 1 file changed, 1 insertion(+)
drivers/pci/controller/dwc/pcie-eswin.c +1 -0
@@ -388,6 +388,7 @@ static const struct of_device_id eswin_pcie_of_match[] = { { .compatible = "eswin,eic7700-pcie", .data = &eswin_eic7700_data }, {} }; +MODULE_DEVICE_TABLE (of, eswin_pcie_of_match);static struct platform_driver eswin_pcie_driver = { .probe = eswin_pcie_probe,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1848/2651 ASoC: codecs: wm8990: Fix definition of right input PGA controls
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: HyeongJun An <[email protected]>
[ Upstream commit 5bd6d05197affaf5a2d7fae0e06e7373fd839b7c ]
The right input PGA boost (R12MNBST, R34MNBST) and routing (R12MNB, R34MNB) bits are in Input Mixer4 (R42), not in Input Mixer3 (R41), where these controls write the left channel bits.
--- sound/soc/codecs/wm8990.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
sound/soc/codecs/wm8990.c +4 -4
@@ -97,8 +97,8 @@ static const struct snd_kcontrol_new wm8990_snd_controls[] = {SOC_SINGLE ("LIN12 PGA Boost" ,WM8990_INPUT_MIXER3 ,WM8990_L12MNBST_BIT ,1 ,0 ),SOC_SINGLE ("LIN34 PGA Boost" ,WM8990_INPUT_MIXER3 ,WM8990_L34MNBST_BIT ,1 ,0 ),/* INMIXR */ -SOC_SINGLE ("RIN12 PGA Boost" ,WM8990_INPUT_MIXER3 ,WM8990_R12MNBST_BIT ,1 ,0 ), -SOC_SINGLE ("RIN34 PGA Boost" ,WM8990_INPUT_MIXER3 ,WM8990_R34MNBST_BIT ,1 ,0 ), +SOC_SINGLE ("RIN12 PGA Boost" ,WM8990_INPUT_MIXER4 ,WM8990_R12MNBST_BIT ,1 ,0 ), +SOC_SINGLE ("RIN34 PGA Boost" ,WM8990_INPUT_MIXER4 ,WM8990_R34MNBST_BIT ,1 ,0 ),/* LOMIX */ SOC_SINGLE_TLV("LOMIX LIN3 Bypass Volume", WM8990_OUTPUT_MIXER3,
@@ -377,9 +377,9 @@ SOC_DAPM_SINGLE_TLV("Record Right Volume", WM8990_INPUT_MIXER4, WM8990_RDBVOL_SHIFT, WM8990_RDBVOL_MASK, 0, in_mix_tlv),SOC_DAPM_SINGLE_TLV ("RIN2 Volume" ,WM8990_INPUT_MIXER6 ,WM8990_RI2BVOL_SHIFT ,7 ,0 , in_mix_tlv), -SOC_DAPM_SINGLE ("RINPGA12 Switch" ,WM8990_INPUT_MIXER3 ,WM8990_L12MNB_BIT , +SOC_DAPM_SINGLE ("RINPGA12 Switch" ,WM8990_INPUT_MIXER4 ,WM8990_R12MNB_BIT ,1 ,0 ), -SOC_DAPM_SINGLE ("RINPGA34 Switch" ,WM8990_INPUT_MIXER3 ,WM8990_L34MNB_BIT , +SOC_DAPM_SINGLE ("RINPGA34 Switch" ,WM8990_INPUT_MIXER4 ,WM8990_R34MNB_BIT , 1, 0), };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1849/2651 ASoC: codecs: wm8990: Fix definition of LOMIX AINLMUX Bypass Volume control
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: HyeongJun An <[email protected]>
[ Upstream commit 75e0b607e3456c9eb15dfb783984f814a89cbcaf ]
The LOMIX AINLMUX bypass volume (LLBLOVOL) is at bits 2:0 of Output Mixer5, not at bits 5:3, which hold the AINRMUX bypass volume (LRBLOVOL).
--- sound/soc/codecs/wm8990.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/wm8990.c +1 -1
@@ -112,7 +112,7 @@ SOC_SINGLE_TLV("LOMIX RIN3 Bypass Volume", WM8990_OUTPUT_MIXER5,SOC_SINGLE_TLV ("LOMIX AINRMUX Bypass Volume" ,WM8990_OUTPUT_MIXER5 ,WM8990_LRBLOVOL_SHIFT ,WM8990_LRBLOVOL_MASK ,1 , out_mix_tlv),SOC_SINGLE_TLV ("LOMIX AINLMUX Bypass Volume" ,WM8990_OUTPUT_MIXER5 , -WM8990_LRBLOVOL_SHIFT ,WM8990_LRBLOVOL_MASK ,1 , out_mix_tlv), +WM8990_LLBLOVOL_SHIFT ,WM8990_LLBLOVOL_MASK ,1 , out_mix_tlv),/* ROMIX */ SOC_SINGLE_TLV("ROMIX RIN3 Bypass Volume", WM8990_OUTPUT_MIXER4,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1850/2651 ASoC: codecs: wm8991: Fix definition of right input PGA controls
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: HyeongJun An <[email protected]>
[ Upstream commit 2dfecdc25d4937a36675c0c36ee0addc99e1e7f9 ]
The right input PGA boost (R12MNBST, R34MNBST) and routing (R12MNB, R34MNB) bits are in Input Mixer4 (R42), not in Input Mixer3 (R41), where these controls write the left channel bits.
--- sound/soc/codecs/wm8991.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
sound/soc/codecs/wm8991.c +4 -4
@@ -169,8 +169,8 @@ static const struct snd_kcontrol_new wm8991_snd_controls[] = {SOC_SINGLE ("LIN12 PGA Boost" ,WM8991_INPUT_MIXER3 ,WM8991_L12MNBST_BIT ,1 ,0 ),SOC_SINGLE ("LIN34 PGA Boost" ,WM8991_INPUT_MIXER3 ,WM8991_L34MNBST_BIT ,1 ,0 ),/* INMIXR */ -SOC_SINGLE ("RIN12 PGA Boost" ,WM8991_INPUT_MIXER3 ,WM8991_R12MNBST_BIT ,1 ,0 ), -SOC_SINGLE ("RIN34 PGA Boost" ,WM8991_INPUT_MIXER3 ,WM8991_R34MNBST_BIT ,1 ,0 ), +SOC_SINGLE ("RIN12 PGA Boost" ,WM8991_INPUT_MIXER4 ,WM8991_R12MNBST_BIT ,1 ,0 ), +SOC_SINGLE ("RIN34 PGA Boost" ,WM8991_INPUT_MIXER4 ,WM8991_R34MNBST_BIT ,1 ,0 ),/* LOMIX */ SOC_SINGLE_TLV("LOMIX LIN3 Bypass Volume", WM8991_OUTPUT_MIXER3,
@@ -446,9 +446,9 @@ static const struct snd_kcontrol_new wm8991_dapm_inmixr_controls[] = { WM8991_RDBVOL_SHIFT, WM8991_RDBVOL_MASK, 0, in_mix_tlv),SOC_DAPM_SINGLE_TLV ("RIN2 Volume" ,WM8991_INPUT_MIXER6 ,WM8991_RI2BVOL_SHIFT ,7 ,0 , in_mix_tlv), -SOC_DAPM_SINGLE ("RINPGA12 Switch" ,WM8991_INPUT_MIXER3 ,WM8991_L12MNB_BIT , +SOC_DAPM_SINGLE ("RINPGA12 Switch" ,WM8991_INPUT_MIXER4 ,WM8991_R12MNB_BIT ,1 ,0 ), -SOC_DAPM_SINGLE ("RINPGA34 Switch" ,WM8991_INPUT_MIXER3 ,WM8991_L34MNB_BIT , +SOC_DAPM_SINGLE ("RINPGA34 Switch" ,WM8991_INPUT_MIXER4 ,WM8991_R34MNB_BIT , 1, 0), };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1851/2651 ASoC: codecs: wm8991: Fix definition of LOMIX AINLMUX Bypass Volume control
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: HyeongJun An <[email protected]>
[ Upstream commit fee722db39c2a1f18c944f747271fd1e131910a6 ]
The LOMIX AINLMUX bypass volume (LLBLOVOL) is at bits 2:0 of Output Mixer5, not at bits 5:3, which hold the AINRMUX bypass volume (LRBLOVOL).
--- sound/soc/codecs/wm8991.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/wm8991.c +1 -1
@@ -184,7 +184,7 @@ static const struct snd_kcontrol_new wm8991_snd_controls[] = {SOC_SINGLE_TLV ("LOMIX AINRMUX Bypass Volume" ,WM8991_OUTPUT_MIXER5 ,WM8991_LRBLOVOL_SHIFT ,WM8991_LRBLOVOL_MASK ,1 , out_mix_tlv),SOC_SINGLE_TLV ("LOMIX AINLMUX Bypass Volume" ,WM8991_OUTPUT_MIXER5 , -WM8991_LRBLOVOL_SHIFT ,WM8991_LRBLOVOL_MASK ,1 , out_mix_tlv), +WM8991_LLBLOVOL_SHIFT ,WM8991_LLBLOVOL_MASK ,1 , out_mix_tlv),/* ROMIX */ SOC_SINGLE_TLV("ROMIX RIN3 Bypass Volume", WM8991_OUTPUT_MIXER4,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1852/2651 ASoC: codecs: wm8983: Fix definition of ADC 128x Oversampling control
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: HyeongJun An <[email protected]>
[ Upstream commit c1af9e2272f025ff75be76e03413074d5e7801c9 ]
ADC 128x oversampling (ADCOSR128) is at bit 3 of ADC Control, not at bit 8, which is the high pass filter enable (HPFEN).
--- sound/soc/codecs/wm8983.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/wm8983.c +1 -1
@@ -234,7 +234,7 @@ static const struct snd_kcontrol_new wm8983_snd_controls[] = { 8, 1, 0, pga_boost_tlv),SOC_DOUBLE ("ADC Inversion Switch" ,WM8983_ADC_CONTROL ,0 ,1 ,1 ,0 ), -SOC_SINGLE ("ADC 128x Oversampling Switch" ,WM8983_ADC_CONTROL ,8 ,1 ,0 ), +SOC_SINGLE ("ADC 128x Oversampling Switch" ,WM8983_ADC_CONTROL ,3 ,1 ,0 ),SOC_DOUBLE_R_TLV ("Playback Volume" ,WM8983_LEFT_DAC_DIGITAL_VOL , WM8983_RIGHT_DAC_DIGITAL_VOL, 0, 255, 0, dac_tlv),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1853/2651 ASoC: codecs: wm8985: Fix definition of ADC 128x Oversampling control
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: HyeongJun An <[email protected]>
[ Upstream commit a747ec6e12cf7a71e42567a479af18b930890d9d ]
ADC 128x oversampling (ADCOSR128) is at bit 3 of ADC Control, not at bit 8, which is the high pass filter enable (HPFEN).
--- sound/soc/codecs/wm8985.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/wm8985.c +1 -1
@@ -327,7 +327,7 @@ static const struct snd_kcontrol_new wm8985_common_snd_controls[] = { 8, 1, 0, pga_boost_tlv),SOC_DOUBLE ("ADC Inversion Switch" ,WM8985_ADC_CONTROL ,0 ,1 ,1 ,0 ), -SOC_SINGLE ("ADC 128x Oversampling Switch" ,WM8985_ADC_CONTROL ,8 ,1 ,0 ), +SOC_SINGLE ("ADC 128x Oversampling Switch" ,WM8985_ADC_CONTROL ,3 ,1 ,0 ),SOC_DOUBLE_R_TLV ("Playback Volume" ,WM8985_LEFT_DAC_DIGITAL_VOL , WM8985_RIGHT_DAC_DIGITAL_VOL, 0, 255, 0, dac_tlv),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1854/2651 ASoC: codecs: wm8994: Fix definition of WM8958 noise gate hold time controls
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: HyeongJun An <[email protected]>
[ Upstream commit 291d81d628f3453026b029507a26b856056e4fdc ]
The noise gate hold time (NG_HLD) is at bits 6:5 of each WM8958 DAC noise gate register, not at bits 3:1, which hold the threshold (NG_THR).
--- sound/soc/codecs/wm8994.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
sound/soc/codecs/wm8994.c +3 -3
@@ -701,17 +701,17 @@ static const char *wm8958_ng_text[] = { static SOC_ENUM_SINGLE_DECL(wm8958_aif1dac1_ng_hold, WM8958_AIF1_DAC1_NOISE_GATE, - WM8958_AIF1DAC1_NG_THR_SHIFT, + WM8958_AIF1DAC1_NG_HLD_SHIFT, wm8958_ng_text); static SOC_ENUM_SINGLE_DECL(wm8958_aif1dac2_ng_hold, WM8958_AIF1_DAC2_NOISE_GATE, - WM8958_AIF1DAC2_NG_THR_SHIFT, + WM8958_AIF1DAC2_NG_HLD_SHIFT, wm8958_ng_text); static SOC_ENUM_SINGLE_DECL(wm8958_aif2dac_ng_hold, WM8958_AIF2_DAC_NOISE_GATE, - WM8958_AIF2DAC_NG_THR_SHIFT, + WM8958_AIF2DAC_NG_HLD_SHIFT, wm8958_ng_text);static const struct snd_kcontrol_new wm8958_snd_controls[] = {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1855/2651 ASoC: codecs: wm8955: Fix definition of Treble Cutoff control
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: HyeongJun An <[email protected]>
[ Upstream commit 71911bf5bb3fe97da2124d17fc1dd3dbb9379e03 ]
Treble cutoff (TC) is at bit 6 of Treble Control, not at bit 2, which is part of the treble volume (TRBL[3:0]).
--- sound/soc/codecs/wm8955.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/wm8955.c +1 -1
@@ -426,7 +426,7 @@ static const char *treble_cutoff_text[] = {"High" ,"Low" }; -static SOC_ENUM_SINGLE_DECL(treble_cutoff, WM8955_TREBLE_CONTROL, 2, +static SOC_ENUM_SINGLE_DECL(treble_cutoff, WM8955_TREBLE_CONTROL, 6, treble_cutoff_text); static const DECLARE_TLV_DB_SCALE(digital_tlv, -12750, 50, 1);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1856/2651 ASoC: codecs: wm_hubs: Fix definition of MIXINR to MIXOUTR volume control
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: HyeongJun An <[email protected]>
[ Upstream commit 22bfcedd3febd6acc63ecf8bfd9638210e4b9a5e ]
The Right Output Mixer Right Input Volume (MIXINR_MIXOUTR_VOL) is at bits 2:0 of Output Mixer6, not at bits 8:6, which hold the IN2LN volume (IN2LN_MIXOUTR_VOL).
--- sound/soc/codecs/wm_hubs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/wm_hubs.c +1 -1
@@ -427,7 +427,7 @@ SOC_SINGLE_TLV("Right Output Mixer IN2RP Volume",SOC_SINGLE_TLV ("Right Output Mixer Left Input Volume" ,WM8993_OUTPUT_MIXER6 ,3 ,7 ,1 , outmix_tlv),SOC_SINGLE_TLV ("Right Output Mixer Right Input Volume" , -WM8993_OUTPUT_MIXER6 ,6 ,7 ,1 , outmix_tlv), +WM8993_OUTPUT_MIXER6 ,0 ,7 ,1 , outmix_tlv),SOC_SINGLE_TLV ("Right Output Mixer DAC Volume" , WM8993_OUTPUT_MIXER6, 9, 7, 1, outmix_tlv),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1857/2651 ASoC: codecs: wm8737: Fix definition of zero cross switches
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: HyeongJun An <[email protected]>
[ Upstream commit 121963197200ca89050f05a704f53c281702ec16 ]
The mic (xMZC) and PGA (xPZC) zero cross bits are bits 3 and 2 of each channel's Audio Path register. SOC_DOUBLE takes one register and two shifts, so both controls only write the left register. Use SOC_DOUBLE_R, as the Mic Boost Switch next to them does.
--- sound/soc/codecs/wm8737.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
sound/soc/codecs/wm8737.c +4 -4
@@ -148,13 +148,13 @@ SOC_DOUBLE_R_TLV("Mic Boost Volume", WM8737_AUDIO_PATH_L, WM8737_AUDIO_PATH_R, 6, 3, 0, micboost_tlv),SOC_DOUBLE_R ("Mic Boost Switch" ,WM8737_AUDIO_PATH_L ,WM8737_AUDIO_PATH_R ,4 ,1 ,0 ), -SOC_DOUBLE ("Mic ZC Switch" ,WM8737_AUDIO_PATH_L ,WM8737_AUDIO_PATH_R , -3 ,1 ,0 ), +SOC_DOUBLE_R ("Mic ZC Switch" ,WM8737_AUDIO_PATH_L ,WM8737_AUDIO_PATH_R , +3 ,1 ,0 ),SOC_DOUBLE_R_TLV ("Capture Volume" ,WM8737_LEFT_PGA_VOLUME ,WM8737_RIGHT_PGA_VOLUME ,0 ,255 ,0 , pga_tlv), -SOC_DOUBLE ("Capture ZC Switch" ,WM8737_AUDIO_PATH_L ,WM8737_AUDIO_PATH_R , -2 ,1 ,0 ), +SOC_DOUBLE_R ("Capture ZC Switch" ,WM8737_AUDIO_PATH_L ,WM8737_AUDIO_PATH_R , +2 ,1 ,0 ), SOC_DOUBLE("INPUT1 DC Bias Switch", WM8737_MISC_BIAS_CONTROL, 0, 1, 1, 0),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1858/2651 ASoC: codecs: wm5100: Fix definition of EQ3 Band 1 Volume control
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: HyeongJun An <[email protected]>
[ Upstream commit 96d30816a9a4fa6b3cc470f82d0f53e8a6425ab9 ]
The EQ3 band 1 gain is in WM5100_EQ3_1, not in WM5100_EQ1_1, which holds the EQ1 band 1 gain.
--- sound/soc/codecs/wm5100.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/wm5100.c +1 -1
@@ -658,7 +658,7 @@ SOC_SINGLE_TLV("EQ2 Band 4 Volume", WM5100_EQ2_2, WM5100_EQ2_B4_GAIN_SHIFT,SOC_SINGLE_TLV ("EQ2 Band 5 Volume" ,WM5100_EQ2_2 ,WM5100_EQ2_B5_GAIN_SHIFT ,24 ,0 , eq_tlv), -SOC_SINGLE_TLV ("EQ3 Band 1 Volume" ,WM5100_EQ1_1 ,WM5100_EQ3_B1_GAIN_SHIFT , +SOC_SINGLE_TLV ("EQ3 Band 1 Volume" ,WM5100_EQ3_1 ,WM5100_EQ3_B1_GAIN_SHIFT ,24 ,0 , eq_tlv),SOC_SINGLE_TLV ("EQ3 Band 2 Volume" ,WM5100_EQ3_1 ,WM5100_EQ3_B2_GAIN_SHIFT , 24, 0, eq_tlv),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1859/2651 ASoC: codecs: wm8750: Fix definition of ALC Capture NG Type control
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: HyeongJun An <[email protected]>
[ Upstream commit 8c299077c787c151c5c88928467d8e8d85cebdb7 ]
The noise gate type is wm8750_enum[7], bit 1 of WM8750_NGATE, not wm8750_enum[4], which is the 3D upper cut-off.
--- sound/soc/codecs/wm8750.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/wm8750.c +1 -1
@@ -171,7 +171,7 @@ SOC_SINGLE("ALC Capture Hold Time", WM8750_ALC2, 0, 15, 0),SOC_SINGLE ("ALC Capture Decay Time" ,WM8750_ALC3 ,4 ,15 ,0 ),SOC_SINGLE ("ALC Capture Attack Time" ,WM8750_ALC3 ,0 ,15 ,0 ),SOC_SINGLE ("ALC Capture NG Threshold" ,WM8750_NGATE ,3 ,31 ,0 ), -SOC_ENUM ("ALC Capture NG Type" , wm8750_enum[4 ]), +SOC_ENUM ("ALC Capture NG Type" , wm8750_enum[7 ]),SOC_SINGLE ("ALC Capture NG Switch" ,WM8750_NGATE ,0 ,1 ,0 ), SOC_SINGLE("Left ADC Capture Volume", WM8750_LADC, 0, 255, 0),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1860/2651 ASoC: codecs: wm8510: Fix definition of ADC Inversion Switch control
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: HyeongJun An <[email protected]>
[ Upstream commit 22d50113078dfbeff0d005d64fd9cc680249831c ]
ADC polarity is bit 0 of WM8510_ADC, not bit 0 of WM8510_COMP, which is the loopback enable. wm8974, which has the same register layout, already uses WM8974_ADC for this control.
--- sound/soc/codecs/wm8510.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/wm8510.c +1 -1
@@ -134,7 +134,7 @@ SOC_SINGLE("Master Playback Volume", WM8510_DACVOL, 0, 127, 0),SOC_SINGLE ("High Pass Filter Switch" ,WM8510_ADC ,8 ,1 ,0 ),SOC_SINGLE ("High Pass Cut Off" ,WM8510_ADC ,4 ,7 ,0 ), -SOC_SINGLE ("ADC Inversion Switch" ,WM8510_COMP ,0 ,1 ,0 ), +SOC_SINGLE ("ADC Inversion Switch" ,WM8510_ADC ,0 ,1 ,0 ), SOC_SINGLE("Capture Volume", WM8510_ADCVOL, 0, 127, 0),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1861/2651 ASoC: codecs: da7213: Get MCLK in I2C probe
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Le Qi <[email protected]>
[ Upstream commit 2923259d08b097bb3c39733f67e635a542ad8917 ]
With deferrable card binding, a card that fails to bind is retried only when a new ASoC component is registered. da7213 requests its MCLK in the component probe callback, so if the clock provider registers late, the card bind defers and the provider's later registration never triggers a rebind, leaving the sound card unregistered.
Request MCLK in the I2C probe instead, so a missing clock defers the codec driver probe through the driver core before the component is registered.
--- sound/soc/codecs/da7213.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-)
sound/soc/codecs/da7213.c +13 -10
@@ -2091,16 +2091,6 @@ static int da7213_probe(struct snd_soc_component *component)pm_runtime_put_sync (component->dev); -/* Check if MCLK provided */ - da7213->mclk =devm_clk_get_optional (component->dev,"mclk" ); -if (IS_ERR (da7213->mclk)) -return PTR_ERR (da7213->mclk); -if (da7213->mclk) -/* Do automatic PLL handling assuming fixed clock until -* set_pll() has been called. This makes the codec usable -* with the simple-audio-card driver. */ - da7213->fixed_clk_auto_pll = true; -/* Default infinite tone gen, start/stop by Kcontrol */ snd_soc_component_write (component,DA7213_TONE_GEN_CYCLES ,DA7213_BEEP_CYCLES_MASK );
@@ -2229,6 +2219,19 @@ static int da7213_i2c_probe(struct i2c_client *i2c)mutex_init (&da7213->ctrl_lock); +/* Check if MCLK provided */ + da7213->mclk =devm_clk_get_optional (&i2c->dev,"mclk" ); +if (IS_ERR (da7213->mclk)) +return dev_err_probe (&i2c->dev,PTR_ERR (da7213->mclk), +"failed to get mclk\n" ); +if (da7213->mclk) +/* +* Do automatic PLL handling assuming fixed clock until +* set_pll() has been called. This makes the codec usable +* with the simple-audio-card driver. +*/ + da7213->fixed_clk_auto_pll = true; +pm_runtime_set_autosuspend_delay (&i2c->dev,100 );pm_runtime_use_autosuspend (&i2c->dev);pm_runtime_set_active (&i2c->dev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1862/2651 rpmsg: mtk: release channel OF node on device teardown
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Avi Weiss <[email protected]>
[ Upstream commit 00e100cfbf7bc159e462df16832cddeaf2cab770 ]
mtk_rpmsg_match_device_subnode() returns a referenced OF child node, which is stored in rpdev->dev.of_node.
mtk_rpmsg_release_device() later frees the containing allocation without dropping that ref.
Release the OF node when the RPMsg device is destroyed.
--- drivers/rpmsg/mtk_rpmsg.c | 1 + 1 file changed, 1 insertion(+)
drivers/rpmsg/mtk_rpmsg.c +1 -0
@@ -168,6 +168,7 @@ static void mtk_rpmsg_release_device(struct device *dev)struct rpmsg_device *rpdev =to_rpmsg_device (dev);struct mtk_rpmsg_device *mdev =to_mtk_rpmsg_device (rpdev); +of_node_put (dev->of_node);kfree (mdev); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1863/2651 rpmsg: virtio: fix error handling in TX buffer wait
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Atul Akella <[email protected]>
[ Upstream commit 7dd4cffdf4c2a496ccf783303a03d687a2127baf ]
The TX buffer wait loop in rpmsg_send_offchannel_raw() ignores the possibility of wait_event_interruptible_timeout() returning a negative value, which happens when the wait is interrupted by a signal. In that case the loop spins back around and re-arms the wait instead of propagating the signal, which can stall a task that is trying to be killed.
Separately, on a genuine timeout (return value 0) the function returns -ERESTARTSYS, which is reserved for signal-interrupted syscalls that the kernel may restart. A timeout is not a signal and should not be treated as restartable; return -ETIMEDOUT instead.
Handle both cases explicitly: return err directly when negative, and return -ETIMEDOUT on timeout.
--- drivers/rpmsg/virtio_rpmsg_bus.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/rpmsg/virtio_rpmsg_bus.c +4 -1
@@ -536,10 +536,13 @@ static int rpmsg_send_offchannel_raw(struct rpmsg_device *rpdev, (msg =get_a_tx_buf (vrp)), msecs_to_jiffies(15000)); +if (err <0 ) +return err; +/* timeout ? */ if (!err) {dev_err (dev,"timeout waiting for a tx buffer\n" ); -return -ERESTARTSYS ; +return -ETIMEDOUT ; } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1864/2651 ARM: 9486/1: set !LPAE MAX_PHYSMEM_BITS to 32 and remove supersection mappings
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 787a3446cafee59e31deaec662d74f86bff38999 ]
An ARM randconfig with CONFIG_GET_FREE_REGION=y and CONFIG_WERROR=y fails to build:
include/linux/minmax.h:86:37: error: conversion from 'long long unsigned int' to 'resource_size_t' {aka 'unsigned int'} changes value from '68719476735' to '4294967295' [-Werror=overflow]
Commit 14b80582c43e ("resource: Introduce alloc_free_mem_region()") made kernel/resource.c clamp against
(1ULL << MAX_PHYSMEM_BITS) - 1. resource_size_t is 32-bit without LPAE, but ARM's default MAX_PHYSMEM_BITS is 36.
That default was added by commit db57f88e4ccb ("ARM: 8411/1: Add default SPARSEMEM settings") because several platforms needed at least 36 physical address bits. !LPAE could map addresses above 32 bits only through supersections.
CONFIG_IO_36, added by commit 23bdf86aa06e ("[ARM] 3377/2: add support for intel xsc3 core"), enabled these for XSC3 I/O. IXP23xx placed static I/O mappings above 4GiB until its removal in 2012, and IOP13xx ioremap()ed its PCIe windows there until its removal in 2019. The only remaining XSC3 platform, PXA3xx, has nothing above 4GiB.
Supersection address bits overlap the descriptor domain field, so IO_36 also renumbered the domains to make DOMAIN_IO zero. Remove IO_36, the alternate domain numbering, and ioremap()'s supersection path. Reject !LPAE ioremap ranges extending past 4GiB before phys_addr_t truncation, drop the now-unneeded high static-mapping exclusion, and reduce ioremap alignment from 16MiB to the 2MiB covered by a PMD's pair of sections.
The other supersection user, create_36bit_mapping(), was added by commit 0b7cd62ecdc1 ("[ARM] 3017/1: Add support for 36-bit addresses to create_mapping()") for IXP2350 and carried IXP23xx's high static mappings. Before this change, its only remaining call path was efi_create_mapping() -> create_mapping_late(), for an EFI runtime region above 4GiB.
No real-world user of this !LPAE path is known. AArch32 UEFI requires RAM described by its memory map to be identity-mapped during boot services, which a 32-bit virtual address space cannot provide above 4GiB. Systems needing wider physical addressing are expected to use LPAE.
Remove create_36bit_mapping() and the supersection definitions. If firmware nevertheless advertises such a region on !LPAE, efi_create_mapping() rejects it before __pfn_to_phys() truncates its address to a low alias. EFI runtime services remain disabled, but the kernel continues to boot. LPAE kernels are unaffected.
With no remaining !LPAE mappings above 4GiB, set MAX_PHYSMEM_BITS to 32 for !LPAE and retain 36 for LPAE, where phys_addr_t is 64-bit.
--- arch/arm/include/asm/domain.h | 17 ----- arch/arm/include/asm/memory.h | 4 +- arch/arm/include/asm/pgtable-2level-hwdef.h | 1 - arch/arm/include/asm/pgtable-2level.h | 7 -- arch/arm/include/asm/sparsemem.h | 4 ++ arch/arm/kernel/efi.c | 13 ++++ arch/arm/mm/Kconfig | 7 -- arch/arm/mm/ioremap.c | 53 ++------------ arch/arm/mm/mmu.c | 76 +-------------------- 9 files changed, 27 insertions(+), 155 deletions(-)
arch/arm/include/asm/domain.h +0 -17
@@ -18,27 +18,10 @@* DOMAIN_IO - domain 2 includes all IO only * DOMAIN_USER - domain 1 includes all user memory only * DOMAIN_KERNEL - domain 0 includes all kernel memory only -* -* The domain numbering depends on whether we support 36 physical -* address for I/O or not. Addresses above the 32 bit boundary can -* only be mapped using supersections and supersections can only -* be set for domain 0. We could just default to DOMAIN_IO as zero, -* but there may be systems with supersection support and no 36-bit -* addressing. In such cases, we want to map system memory with -* supersections to reduce TLB misses and footprint. -* -* 36-bit addressing and supersections are only available on -* CPUs based on ARMv6+ or the Intel XSC3 core. */ -#ifndef CONFIG_IO_36 #define DOMAIN_KERNEL 0#define DOMAIN_USER 1#define DOMAIN_IO 2 -#else -#define DOMAIN_KERNEL 2 -#define DOMAIN_USER 1 -#define DOMAIN_IO 0 -#endif #define DOMAIN_VECTORS 3/*
arch/arm/include/asm/memory.h +2 -2
@@ -89,9 +89,9 @@#if !defined(CONFIG_SMP ) && !defined(CONFIG_ARM_LPAE )/* -* Allow 16MB-aligned ioremap pages +* Allow 2MB-aligned ioremap pages */ -#define IOREMAP_MAX_ORDER 24 +#define IOREMAP_MAX_ORDER 21#endif #define VECTORS_BASE UL(0xffff0000)
arch/arm/include/asm/pgtable-2level-hwdef.h +0 -1
@@ -35,7 +35,6 @@#define PMD_SECT_APX (_AT(pmdval_t, 1) << 15)/* v6 */ #define PMD_SECT_S (_AT(pmdval_t, 1) << 16)/* v6 */ #define PMD_SECT_nG (_AT(pmdval_t, 1) << 17)/* v6 */ -#define PMD_SECT_SUPER (_AT(pmdval_t, 1) << 18)/* v6 */ #define PMD_SECT_AF (_AT(pmdval_t, 0))#define PMD_SECT_UNCACHED (_AT(pmdval_t, 0))
arch/arm/include/asm/pgtable-2level.h +0 -7
@@ -96,13 +96,6 @@#define SECTION_SIZE (1UL << SECTION_SHIFT)#define SECTION_MASK (~(SECTION_SIZE-1)) -/* -* ARMv6 supersection address mask and size definitions. -*/ -#define SUPERSECTION_SHIFT 24 -#define SUPERSECTION_SIZE (1UL << SUPERSECTION_SHIFT) -#define SUPERSECTION_MASK (~(SUPERSECTION_SIZE-1)) -#define USER_PTRS_PER_PGD (TASK_SIZE / PGDIR_SIZE)/*
arch/arm/include/asm/sparsemem.h +4 -0
@@ -19,7 +19,11 @@* These can be overridden in your mach/memory.h. */ #if !defined(MAX_PHYSMEM_BITS ) || !defined(SECTION_SIZE_BITS ) +#ifdef CONFIG_ARM_LPAE #define MAX_PHYSMEM_BITS 36 +#else +#define MAX_PHYSMEM_BITS 32 +#endif #define SECTION_SIZE_BITS 28#endif
arch/arm/kernel/efi.c +13 -0
@@ -6,6 +6,7 @@#include <linux/efi.h> #include <linux/memblock.h> #include <linux/screen_info.h> +#include <linux/sizes.h> #include <asm/efi.h> #include <asm/mach/map.h>
@@ -54,6 +55,18 @@ int __init efi_create_mapping(struct mm_struct *mm, efi_memory_desc_t *md) .length = md->num_pages * EFI_PAGE_SIZE, }; +/* +* Non-LPAE page tables cannot map EFI runtime regions extending +* beyond the 32-bit physical address space. +*/ +if (!IS_ENABLED (CONFIG_ARM_LPAE ) && + (md->phys_addr >=SZ_4G || + md->num_pages > (SZ_4G - md->phys_addr) /EFI_PAGE_SIZE )) { +pr_warn ("EFI runtime region at 0x%llx exceeds 32-bit physical address space\n" , + md->phys_addr); +return -ERANGE ; + } +/* * Order is important here: memory regions may have all of the * bits below set (and usually do), so we check them in order of
arch/arm/mm/Kconfig +0 -7
@@ -328,7 +328,6 @@ config CPU_XSC3 select CPU_PABRT_LEGACY select CPU_THUMB_CAPABLE select CPU_TLB_V4WBI if MMU - select IO_36 # Marvell PJ1 (Mohawk) config CPU_MOHAWK
@@ -676,12 +675,6 @@ config CPU_V7M_NUM_IRQ If unsure, keep default value. -# -# CPU supports 36-bit I/O -# -config IO_36 - bool - comment "Processor Features" config ARM_LPAE
arch/arm/mm/ioremap.c +7 -46
89 lines not on this page · raw message
arch/arm/mm/mmu.c +1 -75
94 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1865/2651 ARM: 9492/1: alignment: fix LSR #32 and ASR #32 offset decoding
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 9f878a6c2207f0c12f34a715a6a05cfc95f47460 ]
The register-offset form of LDR/STR may apply a shift to Rm. Per DecodeImmShift() (ARM ARM DDI0406C section A8.4.3, "Pseudocode details of instruction-specified shifts and rotates"), an imm5 of 0 encodes a shift of 32 for LSR and ASR; only LSL treats 0 as "no shift", and ROR with 0 encodes RRX.
do_alignment() special-cases RRX but not LSR or ASR, and IS_SHIFT() does not filter these encodings out, so the block is entered with shiftval == 0 and the offset becomes Rm instead of 0 (LSR #32) or the replicated sign of Rm (ASR #32).
do_alignment_finish_ldst() applies the offset to the base-register writeback of the post-indexed form, so the emulated access itself uses the correct faulting address but Rn is left holding the wrong value.
Reproduced on ARM926EJ-S (versatile_defconfig, CONFIG_ALIGNMENT_TRAP=y, gcc 13.3.0) with a misaligned base and Rm = 0x1000:
ldr r0, [r1], r2, lsr #32 Rn advanced by 0x1000, must be unchanged ldr r0, [r1], r2, asr #32 Rn advanced by 0x1000, must be unchanged ldr r0, [r1], r2, asr #32 with Rm negative, Rn must decrease by 1
All three are correct with the patch applied, while a lsr #1 control case is emulated correctly both before and after.
--- arch/arm/mm/alignment.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
arch/arm/mm/alignment.c +8 -2
@@ -915,11 +915,17 @@ do_alignment(unsigned long addr, unsigned int fsr, struct pt_regs *regs)break ;case SHIFT_LSR : - offset.un >>= shiftval; +if (shiftval ==0 ) + offset.un =0 ; +else + offset.un >>= shiftval;break ;case SHIFT_ASR : - offset.sn >>= shiftval; +if (shiftval ==0 ) + offset.sn >>=31 ; +else + offset.sn >>= shiftval;break ;case SHIFT_RORRRX :
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1866/2651 ARM: 9519/1: dma-mapping: Fix wrong free function in __iommu_alloc_simple() error path
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marek Szyprowski <[email protected]>
[ Upstream commit 74f79365839720bdb0c6bb4fe85c5b2a929ff5d1 ]
In __iommu_alloc_simple(), when IOMMU mapping creation fails, the error path unconditionally called __free_from_pool() regardless of the allocation path taken.
For the COHERENT case, memory is allocated via __alloc_simple_buffer(), which does not use the atomic pool. Calling __free_from_pool() on such memory silently returns without freeing, causing a page memory leak.
Fix this by matching the free function to the allocation path:
- COHERENT: use __dma_free_buffer(virt_to_page(addr), size)
- non-COHERENT: use __free_from_pool(addr, size)
--- arch/arm/mm/dma-mapping.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
arch/arm/mm/dma-mapping.c +4 -1
@@ -1056,7 +1056,10 @@ static void *__iommu_alloc_simple(struct device *dev, size_t size, gfp_t gfp,return addr; err_mapping: -__free_from_pool (addr, size); +if (coherent_flag ==COHERENT ) +__dma_free_buffer (virt_to_page (addr), size); +else +__free_from_pool (addr, size);return NULL ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1867/2651 PCI: Fix out-of-bounds MMIO read in nvme_disable_and_flr()
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mohamad Raizudeen <[email protected]>
[ Upstream commit 6aaa3f42e3410ea8e26c857477260159f724cb1d ]
In nvme_disable_and_flr(), the PCI bar is mapped using NVME_REG_CC + sizeof(cfg) which is (0x14 + 4 = 0x18 bytes)
However, the function later reads the controller status from NVME_REG_CSTS - offset 0x1C, which is outside the mapped 0x18 byte boundary. This violates the API contract.
Fix this by increasing the mapping size to include NVME_REG_CSTS. Also change sizeof(cfg) to sizeof(u32) to make the intent clearer.
--- drivers/pci/quirks.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/quirks.c +1 -1
@@ -4128,7 +4128,7 @@ static int nvme_disable_and_flr(struct pci_dev *dev, bool probe)if (probe)return 0 ; - bar =pci_iomap (dev,0 ,NVME_REG_CC +sizeof (cfg)); + bar =pci_iomap (dev,0 ,NVME_REG_CSTS +sizeof (u32));if (!bar)return -ENOTTY ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1868/2651 Bluetooth: btmtksdio: Remove redundant firmware filename override
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chris Lu <[email protected]>
[ Upstream commit 8c947cd1c27d6493ed7e6630e168222454f53edb ]
btmtksdio_setup() derives the firmware filename with btmtk_fw_get_filename() and then overwrites it with an snprintf() that open-codes that helper's fallback format. Commit 7f935b21bee4 ("Bluetooth:
btmtk: apply the common btmtk_fw_get_filename") added the helper call without removing the snprintf() it was meant to replace.
None of the device ids the helper special-cases can appear here: 0x6639, 0x7925 and the flavored 0x7961 belong to parts with no SDIO interface, and btmtksdio_setup() passes a flavor of 0 accordingly. The helper always falls through to the snprintf()'s own format, so both produce the same string and removing it is a no-op.
Remove it anyway, since it silently defeats the helper for any device id the helper special-cases.
Stable-dep-of: a2bb734c3687 ("Bluetooth: btmtksdio: Pass the hardware device id to mt79xx_setup()")
--- drivers/bluetooth/btmtksdio.c | 3 --- 1 file changed, 3 deletions(-)
drivers/bluetooth/btmtksdio.c +0 -3
@@ -1172,9 +1172,6 @@ static int btmtksdio_setup(struct hci_dev *hdev)btmtk_fw_get_filename (fwname,sizeof (fwname), dev_id, fw_version,0 ); -snprintf (fwname,sizeof (fwname), -"mediatek/BT_RAM_CODE_MT%04x_1_%x_hdr.bin" , - dev_id &0xffff , (fw_version &0xff ) +1 ); err =mt79xx_setup (hdev, fwname);if (err <0 )return err;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1869/2651 Bluetooth: btmtksdio: Pass the hardware device id to mt79xx_setup()
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chris Lu <[email protected]>
[ Upstream commit a2bb734c368766a2499ed00590ea838cac13c76e ]
mt79xx_setup() passes a hardcoded 0 to btmtk_setup_firmware_79xx(), discarding the device id that btmtksdio_setup() has just read from register 0x70010200. That argument only gates the section filtering for MT6639, which has no SDIO interface, so this is a no-op on supported hardware and carries no Fixes: tag.
Pass the value that has already been read, matching the USB path. Declare dev_id as u32 while at it, since that is what btmtksdio_mtk_reg_read() writes through the pointer.
--- drivers/bluetooth/btmtksdio.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/bluetooth/btmtksdio.c +5 -5
@@ -909,14 +909,14 @@ static int mt76xx_setup(struct hci_dev *hdev, const char *fwname)return 0 ; } -static int mt79xx_setup (struct hci_dev *hdev,const char *fwname) +static int mt79xx_setup (struct hci_dev *hdev,const char *fwname,u32 dev_id) {struct btmtksdio_dev *bdev =hci_get_drvdata (hdev);struct btmtk_hci_wmt_params wmt_params;u8 param =0x1 ;int err; - err =btmtk_setup_firmware_79xx (hdev, fwname, mtk_hci_wmt_sync,0 ); + err =btmtk_setup_firmware_79xx (hdev, fwname, mtk_hci_wmt_sync, dev_id);if (err <0 ) {bt_dev_err (hdev,"Failed to setup 79xx firmware (%d)" , err);return err;
@@ -1129,8 +1129,8 @@ static int btmtksdio_setup(struct hci_dev *hdev)ktime_t calltime, delta, rettime;unsigned long long duration;char fwname[64 ]; -int err, dev_id; -u32 fw_version =0 , val; +int err; +u32 dev_id, fw_version =0 , val; calltime =ktime_get ();set_bit (BTMTKSDIO_HW_TX_READY , &bdev->tx_state);
@@ -1172,7 +1172,7 @@ static int btmtksdio_setup(struct hci_dev *hdev)btmtk_fw_get_filename (fwname,sizeof (fwname), dev_id, fw_version,0 ); - err =mt79xx_setup (hdev, fwname); + err =mt79xx_setup (hdev, fwname, dev_id);if (err <0 )return err;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1870/2651 Bluetooth: L2CAP: take chan->lock for l2cap_chan_add/ready/del
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pauli Virtanen <[email protected]>
[ Upstream commit 385c0829e09e7a6380ae67998ac6ef6f4dfd5303 ]
chan->lock must be held for __l2cap_chan_add as eg. calls to l2cap_chan_close assume chan->conn writes are guarded by it.
It must be held for l2cap_chan_del() due to l2cap_sock.c:l2cap_chan_conn, l2cap_monitor_timeout, etc.
Similarly it should be held for l2cap_ops::ready (assumed in 6lowpan.c). Also teardown usually has chan->lock held, it should always have it held to have the same locking context.
The lock is not correctly held by l2cap_core in several places.
Add the missing locks for l2cap_chan_del/add/ready(), except in l2cap_ecred_rsp_defer() which needs separate fix as it needs lock nesting.
--- include/net/bluetooth/l2cap.h | 3 ++- net/bluetooth/l2cap_core.c | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-)
include/net/bluetooth/l2cap.h +2 -1
@@ -971,7 +971,8 @@ int l2cap_chan_check_security(struct l2cap_chan *chan, bool initiator);void l2cap_chan_set_defaults (struct l2cap_chan *chan,struct l2cap_chan *pchan);int l2cap_ertm_init (struct l2cap_chan *chan);void l2cap_chan_add (struct l2cap_conn *conn,struct l2cap_chan *chan); -void __l2cap_chan_add (struct l2cap_conn *conn,struct l2cap_chan *chan); +void __l2cap_chan_add(struct l2cap_conn *conn, struct l2cap_chan *chan) + __must_hold(&chan->lock);typedef void (*l2cap_chan_func_t )(struct l2cap_chan *chan,void *data);void l2cap_chan_list (struct l2cap_conn *conn,l2cap_chan_func_t func,void *data);
net/bluetooth/l2cap_core.c +15 -0
@@ -703,7 +703,9 @@ void __l2cap_chan_add(struct l2cap_conn *conn, struct l2cap_chan *chan)void l2cap_chan_add (struct l2cap_conn *conn,struct l2cap_chan *chan) {mutex_lock (&conn->lock); +l2cap_chan_lock (chan);__l2cap_chan_add (conn, chan); +l2cap_chan_unlock (chan);mutex_unlock (&conn->lock); }
@@ -4136,6 +4138,8 @@ static struct l2cap_chan *l2cap_new_connection(struct l2cap_conn *conn,if (!chan)return NULL ; +l2cap_chan_lock (chan); +l2cap_chan_set_defaults (chan, pchan); chan->ops = pchan->ops;
@@ -4144,10 +4148,13 @@ static struct l2cap_chan *l2cap_new_connection(struct l2cap_conn *conn,if (pchan->ops->new_connection && pchan->ops->new_connection (pchan, chan) <0 ) {l2cap_chan_del (chan,0 ); +l2cap_chan_unlock (chan);l2cap_chan_put (chan);return NULL ; } +l2cap_chan_unlock (chan); +return chan; }
@@ -5130,6 +5137,8 @@ static int l2cap_le_connect_req(struct l2cap_conn *conn, goto response_unlock; } +l2cap_chan_lock (chan); +bacpy (&chan->src, &conn->hcon->src);bacpy (&chan->dst, &conn->hcon->dst); chan->src_type =bdaddr_src_type (conn->hcon);
@@ -5163,6 +5172,8 @@ static int l2cap_le_connect_req(struct l2cap_conn *conn, result =L2CAP_CR_LE_SUCCESS ; } +l2cap_chan_unlock (chan); + response_unlock:l2cap_chan_unlock (pchan);l2cap_chan_put (pchan);
@@ -5353,6 +5364,8 @@ static inline int l2cap_ecred_conn_req(struct l2cap_conn *conn,continue ; } +l2cap_chan_lock (chan); +bacpy (&chan->src, &conn->hcon->src);bacpy (&chan->dst, &conn->hcon->dst); chan->src_type =bdaddr_src_type (conn->hcon);
@@ -5385,6 +5398,8 @@ static inline int l2cap_ecred_conn_req(struct l2cap_conn *conn, }else {l2cap_chan_ready (chan); } + +l2cap_chan_unlock (chan); } unlock:
Signature · 1 line
2.53.0
Re: [PATCH 7.3 1870/2651] Bluetooth: L2CAP: take chan->lock for l2cap_chan_add/ready/del
Quoted 114 lines · Greg Kroah-Hartman
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pauli Virtanen <[email protected]>
[ Upstream commit
385c0829e09e7a6380ae67998ac6ef6f4dfd5303]
chan->lockmust be held for__l2cap_chan_addas eg. calls tol2cap_chan_closeassumechan->connwrites are guarded by it.It must be held for
l2cap_chan_del()due to l2cap_sock.c:l2cap_chan_conn,l2cap_monitor_timeout, etc.Similarly it should be held for
l2cap_ops::ready(assumed in6lowpan.c). Also teardown usually haschan->lockheld, it should always have it held to have the same locking context.The lock is not correctly held by
l2cap_corein several places.Add the missing locks for l2cap_chan_del/add/ready(), except in
l2cap_ecred_rsp_defer()which needs separate fix as it needs lock nesting.Fixes 6fef032af009 ("Bluetooth: L2CAP: Fix use-after-free in l2cap_sock_new_connection_cb()")Signed-off-by Pauli Virtanen <[email protected]>Reported-by Eulgyu Kim <[email protected]>Reported-by Jaeyoung Chung <[email protected]>Signed-off-by Luiz Augusto von Dentz <[email protected]>Signed-off-by Sasha Levin <[email protected]>--- include/net/bluetooth/l2cap.h | 3 ++- net/bluetooth/l2cap_core.c | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-)include/net/bluetooth/l2cap.h +2
-1@@ -971,7 +971,8 @@ int l2cap_chan_check_security(struct l2cap_chan *chan, bool initiator);void l2cap_chan_set_defaults (struct l2cap_chan *chan,struct l2cap_chan *pchan);int l2cap_ertm_init (struct l2cap_chan *chan);void l2cap_chan_add (struct l2cap_conn *conn,struct l2cap_chan *chan); -void __l2cap_chan_add (struct l2cap_conn *conn,struct l2cap_chan *chan); +void __l2cap_chan_add(struct l2cap_conn *conn, struct l2cap_chan *chan) + __must_hold(&chan->lock);typedef void (*l2cap_chan_func_t )(struct l2cap_chan *chan,void *data);void l2cap_chan_list (struct l2cap_conn *conn,l2cap_chan_func_t func,void *data);net/bluetooth/l2cap_core.c +13
-0@@ -703,7 +703,9 @@ void __l2cap_chan_add(struct l2cap_conn *conn, struct l2cap_chan *chan)void l2cap_chan_add (struct l2cap_conn *conn,struct l2cap_chan *chan) {mutex_lock (&conn->lock); +l2cap_chan_lock (chan);__l2cap_chan_add (conn, chan); +l2cap_chan_unlock (chan);mutex_unlock (&conn->lock); }@@ -4136,6 +4138,8 @@ static struct l2cap_chan *l2cap_new_connection(struct l2cap_conn *conn,if (!chan)return NULL ; +l2cap_chan_lock (chan); +l2cap_chan_set_defaults (chan, pchan); chan->ops = pchan->ops;@@ -4144,10 +4148,13 @@ static struct l2cap_chan *l2cap_new_connection(struct l2cap_conn *conn,if (pchan->ops->new_connection && pchan->ops->new_connection (pchan, chan) <0 ) {l2cap_chan_del (chan,0 ); +l2cap_chan_unlock (chan);l2cap_chan_put (chan);return NULL ; } +l2cap_chan_unlock (chan); +return chan; }@@ -5130,6 +5137,8 @@ static int l2cap_le_connect_req(struct l2cap_conn *conn, goto response_unlock; } +l2cap_chan_lock (chan); +bacpy (&chan->src, &conn->hcon->src);bacpy (&chan->dst, &conn->hcon->dst); chan->src_type =bdaddr_src_type (conn->hcon);@@ -5163,6 +5172,8 @@ static int l2cap_le_connect_req(struct l2cap_conn *conn, result =L2CAP_CR_LE_SUCCESS ; } +l2cap_chan_unlock (chan); + response_unlock:l2cap_chan_unlock (pchan);l2cap_chan_put (pchan);@@ -5353,6 +5364,8 @@ static inline int l2cap_ecred_conn_req(struct l2cap_conn *conn,continue ; } +l2cap_chan_lock (chan); +bacpy (&chan->src, &conn->hcon->src);bacpy (&chan->dst, &conn->hcon->dst); chan->src_type =bdaddr_src_type (conn->hcon);
net/bluetooth/l2cap_core.c static inline int l2cap_ecred_conn_req(struct l2cap_conn *conn, · line 5405
Quoted 8 lines
net/bluetooth/l2cap_core.c +2
-0@@ -5385,6 +5398,8 @@ static inline int l2cap_ecred_conn_req(struct l2cap_conn *conn, }else {l2cap_chan_ready (chan); } + +l2cap_chan_unlock (chan); } unlock:
This is breaking the build for me with clang 23.1.6 (also 23.1.5) for arm64, amd64 and i386:
net/bluetooth/l2cap_core.c:708:2: error: calling function '__l2cap_chan_add'
requires holding mutex 'chan->lock' exclusively
[-Werror,-Wthread-safety-analysis]
708 | __l2cap_chan_add(conn, chan);
| ^
net/bluetooth/l2cap_core.c:969:1: error: mutex 'chan->lock' is still held at the
end of function [-Werror,-Wthread-safety-analysis]
969 | }
| ^net/bluetooth/l2cap_core.c:966:14: note: mutex acquired here
966 | have_conn = l2cap_chan_lock_conn(chan);
| ^net/bluetooth/l2cap_core.c:4197:2: error: calling function '__l2cap_chan_add'
requires holding mutex 'l2cap_chan_create().lock' exclusively [-Werror,-Wthread-safety-analysis]
4197 | __l2cap_chan_add(conn, chan);
| ^
net/bluetooth/l2cap_core.c:7571:2: error: calling function '__l2cap_chan_add'
requires holding mutex 'chan->lock' exclusively
[-Werror,-Wthread-safety-analysis]
7571 | __l2cap_chan_add(conn, chan);
| ^The following creates a minimal config to reproduce this:
# First set the LLVM environment variable appropriately, then:
make tinyconfig./scripts/config --enable CONFIG_NET ./scripts/config --enable CONFIG_BT./scripts/config --enable CONFIG_WARN_CONTEXT_ANALYSIS ./scripts/config --enable CONFIG_WERROR
make olddefconfig
git bisect says:
# first bad commit: [2fab5322c15581b8506e622327e16e005f506308] Bluetooth: L2CAP: take chan->lock for l2cap_chan_add/ready/del
This build failure does not occur on 7.4-rc3, so perhaps there's a missing dependency.
Signature · 1 line
-Barry K. Nathan <[email protected]>
Re: [PATCH 7.3 1870/2651] Bluetooth: L2CAP: take chan->lock for l2cap_chan_add/ready/del
Quoted 3 lines
This is breaking the build for me with clang 23.1.6 (also 23.1.5) for arm64, amd64 and i386:
net/bluetooth/l2cap_core.c:708:2: error: calling function '__l2cap_chan_add' requires holding mutex 'chan->lock' exclusively
Queued the missing annotations patch for 7.3, thanks.
Signature · 2 lines
Thanks, Sasha
Re: [PATCH 7.3 1870/2651] Bluetooth: L2CAP: take chan->lock for l2cap_chan_add/ready/del
Quoted 5 lines · Sasha Levin
Quoted 3 lines
This is breaking the build for me with clang 23.1.6 (also 23.1.5) for arm64, amd64 and i386:
net/bluetooth/l2cap_core.c:708:2: error: calling function '__l2cap_chan_add' requires holding mutex 'chan->lock' exclusivelyQueued the missing annotations patch for 7.3, thanks.
Now I get the following when building the current 7.3 stable-queue (commit 5252483124e6cf016c4a6f41fe1e44f5e1949648) with clang 23.1.6, same config as before:
net/bluetooth/l2cap_core.c:128:9: error: mutex
'l2cap_chan_hold_unless_zero(c).lock' is not held on every path through here [-Werror,-Wthread-safety-analysis]
128 | return c;
| ^net/bluetooth/l2cap_core.c:125:4: note: mutex acquired here
125 | l2cap_chan_lock(c);
| ^net/bluetooth/l2cap_core.c:147:9: error: mutex
'l2cap_chan_hold_unless_zero(c).lock' is not held on every path through here [-Werror,-Wthread-safety-analysis]
147 | return c;
| ^net/bluetooth/l2cap_core.c:144:4: note: mutex acquired here
144 | l2cap_chan_lock(c);
| ^
net/bluetooth/l2cap_core.c:4589:2: error: releasing mutex
'l2cap_get_chan_by_scid(conn, dcid).lock' that was not held
[-Werror,-Wthread-safety-analysis]
4589 | l2cap_chan_unlock(chan);
| ^
net/bluetooth/l2cap_core.c:4703:2: error: releasing mutex
'l2cap_get_chan_by_scid(conn, scid).lock' that was not held
[-Werror,-Wthread-safety-analysis]
4703 | l2cap_chan_unlock(chan);
| ^
net/bluetooth/l2cap_core.c:4741:2: error: releasing mutex
'l2cap_get_chan_by_scid(conn, dcid).lock' that was not held
[-Werror,-Wthread-safety-analysis]
4741 | l2cap_chan_unlock(chan);
| ^
net/bluetooth/l2cap_core.c:4769:3: error: releasing mutex
'l2cap_get_chan_by_scid(conn, scid).lock' that was not held
[-Werror,-Wthread-safety-analysis]
4769 | l2cap_chan_unlock(chan);
| ^
net/bluetooth/l2cap_core.c:4778:2: error: releasing mutex
'l2cap_get_chan_by_scid(conn, scid).lock' that was not held
[-Werror,-Wthread-safety-analysis]
4778 | l2cap_chan_unlock(chan);
| ^
net/bluetooth/l2cap_core.c:5295:2: error: releasing mutex
'l2cap_get_chan_by_dcid(conn, cid).lock' that was not held
[-Werror,-Wthread-safety-analysis]
5295 | l2cap_chan_unlock(chan);
| ^
net/bluetooth/l2cap_core.c:7200:2: error: releasing mutex
'l2cap_get_chan_by_scid(conn, cid).lock' that was not held
[-Werror,-Wthread-safety-analysis]
7200 | l2cap_chan_unlock(chan);
| ^9 errors generated.
Signature · 1 line
-Barry K. Nathan <[email protected]>
Sasha Levin
maintainerRe: [PATCH 7.3 1870/2651] Bluetooth: L2CAP: take chan->lock for l2cap_chan_add/ready/del
Quoted 2 lines · Barry K. Nathan
Now I get the following when building the current 7.3 stable-queue (commit
5252483124e6cf016c4a6f41fe1e44f5e1949648) with clang 23.1.6,
The remaining errors need 15ad901d92a2 ("Bluetooth: L2CAP: avoid maybe-return-locked in l2cap_get_chan_by_scid/dcid"), which does not apply cleanly to 7.3. I dropped these from the 7.3 queue:
- 385c0829e09e ("Bluetooth: L2CAP: take chan->lock for
l2cap_chan_add/ready/del")
- 987935a58d28 ("Bluetooth: L2CAP: add locking annotations for
l2cap_chan_lock/unlock")
- 608e0b7a675b ("Bluetooth: L2CAP: add l2cap_chan_close_unlocked() and
locking helpers")
- 79ff49a72c06 ("Bluetooth: L2CAP: fix race condition in
l2cap_sock_shutdown()")
- a69dd52612ea ("Bluetooth: 6lowpan: use l2cap_chan_close_unlocked()")
- df5175dfcf48 ("Bluetooth: 6lowpan: avoid concurrent peer_del() in
bt_6lowpan_disconnect")
- 32d86e048d8e ("Bluetooth: L2CAP: hold conn->lock for
__l2cap_ecred_conn_rsp_defer")They will be requeued together with 15ad901d92a2. 6.18, 6.12 and 6.6 keep 385c0829e09e.
Signature · 2 lines
Thanks, Sasha
Sasha Levin
maintainerRe: [PATCH 7.3 1870/2651] Bluetooth: L2CAP: take chan->lock for l2cap_chan_add/ready/del
In reply to Barry K. NathanQuoted 7 lines
Now I get the following when building the current 7.3 stable-queue (commit
5252483124e6cf016c4a6f41fe1e44f5e1949648) with clang 23.1.6, same config as before:
net/bluetooth/l2cap_core.c:128:9: error: mutex
'l2cap_chan_hold_unless_zero(c).lock' is not held on every path through here [-Werror,-Wthread-safety-analysis]
Requeued the L2CAP/6lowpan patches for 7.3 together with 15ad901d92a2 ("Bluetooth: L2CAP: avoid maybe-return-locked in l2cap_get_chan_by_scid/dcid"), thanks.
Signature · 2 lines
Thanks, Sasha
Barry K. Nathan
Tested-byRe: [PATCH 7.3 1870/2651] Bluetooth: L2CAP: take chan->lock for l2cap_chan_add/ready/del
Quoted 10 lines · Sasha Levin
Quoted 7 lines
Now I get the following when building the current 7.3 stable-queue (commit
5252483124e6cf016c4a6f41fe1e44f5e1949648) with clang 23.1.6, same config as before:
net/bluetooth/l2cap_core.c:128:9: error: mutex
'l2cap_chan_hold_unless_zero(c).lock' is not held on every path through here [-Werror,-Wthread-safety-analysis]Requeued the L2CAP/6lowpan patches for 7.3 together with
15ad901d92a2("Bluetooth: L2CAP: avoid maybe-return-locked in l2cap_get_chan_by_scid/dcid"), thanks.
I have now retested 7.3.5 + the current stable-queue (commit 3dd4b2d3c1f7915277082781d6dfbe71d7d41800) on my ThinkPad T14 Gen 1 and my arm64 VM. Builds successfully, works well, no regressions observed. Thanks!
Signature · 1 line
-Barry K. Nathan <[email protected]>
Greg Kroah-Hartman
maintainerPATCH 1871/2651 Bluetooth: L2CAP: add l2cap_chan_close_unlocked() and locking helpers
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pauli Virtanen <[email protected]>
[ Upstream commit 608e0b7a675b2affbbf38167cad0fa63d8e064f7 ]
l2cap_chan_close() requires holding chan->lock and chan->conn->lock if associated chan->conn exists, to guard eg. conn->chan_l. Taking the locks with right ordering requires handling a race condition.
Add helper function l2cap_chan_(un)lock_conn that do the locking right.
Add l2cap_chan_close_unlocked() that does not require locks to be held, as all callsites do this lock -> close -> unlock pattern.
Stable-dep-of: 79ff49a72c06 ("Bluetooth: L2CAP: fix race condition in l2cap_sock_shutdown()")
--- include/net/bluetooth/l2cap.h | 17 ++++++++++ net/bluetooth/l2cap_core.c | 61 ++++++++++++++++++++++++++++++++--- 2 files changed, 73 insertions(+), 5 deletions(-)
include/net/bluetooth/l2cap.h +17 -0
@@ -960,6 +960,8 @@ int l2cap_add_scid(struct l2cap_chan *chan, __u16 scid);struct l2cap_chan *l2cap_chan_create (void );void l2cap_chan_close (struct l2cap_chan *chan,int reason); +void l2cap_chan_close_unlocked(struct l2cap_chan *chan, int reason) + __must_not_hold(&chan->lock);int l2cap_chan_connect (struct l2cap_chan *chan,__le16 psm,u16 cid,bdaddr_t *dst,u8 dst_type,u16 timeout);int l2cap_chan_reconfigure (struct l2cap_chan *chan,__u16 mtu);
@@ -986,4 +988,19 @@ void l2cap_conn_put(struct l2cap_conn *conn);int l2cap_register_user (struct l2cap_conn *conn,struct l2cap_user *user);void l2cap_unregister_user (struct l2cap_conn *conn,struct l2cap_user *user); +bool l2cap_chan_lock_conn(struct l2cap_chan *chan) + __acquires(&chan->lock) __cond_acquires(true, &chan->conn->lock); + +/* Release macro for l2cap_chan_lock_conn, so context analysis understands it */ +#define l2cap_chan_unlock_conn (chan, conn_locked) \ + ({ \ + struct l2cap_chan *__chan = (chan); \ + struct l2cap_conn *__conn = __chan->conn; \ + l2cap_chan_unlock(__chan); \ + if (conn_locked) { \ + mutex_unlock(&__conn->lock); \ + l2cap_conn_put(__conn); \ + } \ + }) +#endif /* __L2CAP_H */
net/bluetooth/l2cap_core.c +56 -5
105 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1872/2651 Bluetooth: L2CAP: fix race condition in l2cap_sock_shutdown()
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pauli Virtanen <[email protected]>
[ Upstream commit 79ff49a72c06abdf76872dccc687e2a83c4f407f ]
l2cap_sock_shutdown() has the race condition
[Task 1] [Task 2]
l2cap_sock_shutdown l2cap_sock_connect
l2cap_chan_lock l2cap_chan_connect
conn = ... /* == NULL*/
l2cap_chan_unlock ------------> l2cap_chan_lock
if (conn) /* false */
__l2cap_chan_add(conn, chan)
l2cap_chan_lock <-------------- l2cap_chan_unlock
l2cap_chan_close /* chan->conn->lock not held! */conn->lock protects conn->chan_l and is not properly held here.
Use the l2cap_chan_close_unlocked() helper that ensures conn->lock is held for l2cap_chan_close().
--- net/bluetooth/l2cap_sock.c | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-)
net/bluetooth/l2cap_sock.c +1 -18
@@ -1412,7 +1412,6 @@ static int l2cap_sock_shutdown(struct socket *sock, int how) {struct sock *sk = sock->sk;struct l2cap_chan *chan; -struct l2cap_conn *conn;int err =0 ;BT_DBG ("sock %p, sk %p, how %d" , sock, sk, how);
@@ -1469,23 +1468,7 @@ static int l2cap_sock_shutdown(struct socket *sock, int how) sk->sk_shutdown |=SEND_SHUTDOWN ;release_sock (sk); -l2cap_chan_lock (chan); -/* prevent conn structure from being freed */ - conn =l2cap_conn_hold_unless_zero (chan->conn); -l2cap_chan_unlock (chan); - -if (conn) -/* mutex lock must be taken before l2cap_chan_lock() */ -mutex_lock (&conn->lock); - -l2cap_chan_lock (chan); -l2cap_chan_close (chan,0 ); -l2cap_chan_unlock (chan); - -if (conn) { -mutex_unlock (&conn->lock); -l2cap_conn_put (conn); - } +l2cap_chan_close_unlocked (chan,0 );lock_sock (sk);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1873/2651 Bluetooth: 6lowpan: use l2cap_chan_close_unlocked()
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pauli Virtanen <[email protected]>
[ Upstream commit a69dd52612ea6c763f76553e355ee03b981b4ed4 ]
6lowpan.c is using l2cap_chan_close() without taking chan->conn->lock, so it may modify conn->chan_l without holding the guarding lock.
Fix the locking by using the l2cap_chan_close_unlocked() helper that acquires the necessary locks.
--- net/bluetooth/6lowpan.c | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-)
net/bluetooth/6lowpan.c +9 -18
@@ -921,9 +921,7 @@ static int bt_6lowpan_disconnect(struct l2cap_conn *conn, u8 dst_type)BT_DBG ("peer %p chan %p" , peer, peer->chan); -l2cap_chan_lock (peer->chan); -l2cap_chan_close (peer->chan,ENOENT ); -l2cap_chan_unlock (peer->chan); +l2cap_chan_close_unlocked (peer->chan,ENOENT );return 0 ; }
@@ -1025,9 +1023,9 @@ static void disconnect_all_peers(void)struct lowpan_peer *peer;int nchans; -/* l2cap_chan_close() cannot be called from RCU, and lock ordering -* chan->lock > devices_lock prevents taking write side lock, so copy -* then close. +/* l2cap_chan_close_unlocked() cannot be called from RCU, and lock +* ordering chan->lock > devices_lock prevents taking write side lock, +* so copy then close. */ rcu_read_lock ();
@@ -1062,9 +1060,7 @@ static void disconnect_all_peers(void)spin_unlock (&devices_lock);for (i =0 ; i < nchans; ++i) { -l2cap_chan_lock (chans[i]); -l2cap_chan_close (chans[i],ENOENT ); -l2cap_chan_unlock (chans[i]); +l2cap_chan_close_unlocked (chans[i],ENOENT );l2cap_chan_put (chans[i]); } }while (nchans);
@@ -1082,9 +1078,7 @@ static void do_enable_set(bool flag)mutex_lock (&set_lock);if (listen_chan) { -l2cap_chan_lock (listen_chan); -l2cap_chan_close (listen_chan,0 ); -l2cap_chan_unlock (listen_chan); +l2cap_chan_close_unlocked (listen_chan,0 );l2cap_chan_put (listen_chan); }
@@ -1132,9 +1126,7 @@ static ssize_t lowpan_control_write(struct file *fp,mutex_lock (&set_lock);if (listen_chan) { -l2cap_chan_lock (listen_chan); -l2cap_chan_close (listen_chan,0 ); -l2cap_chan_unlock (listen_chan); +l2cap_chan_close_unlocked (listen_chan,0 );l2cap_chan_put (listen_chan); listen_chan =NULL ; }
@@ -1304,10 +1296,9 @@ static void __exit bt_6lowpan_exit(void)debugfs_remove (lowpan_control_debugfs);if (listen_chan) { -l2cap_chan_lock (listen_chan); -l2cap_chan_close (listen_chan,0 ); -l2cap_chan_unlock (listen_chan); +l2cap_chan_close_unlocked (listen_chan,0 );l2cap_chan_put (listen_chan); + listen_chan =NULL ; }disconnect_devices ();
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1874/2651 Bluetooth: 6lowpan: avoid concurrent peer_del() in bt_6lowpan_disconnect
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pauli Virtanen <[email protected]>
[ Upstream commit df5175dfcf4879f6bcdadee614ac089e5627b721 ]
bt_6lowpan_disconnect() looks up and accesses peer->chan, without holding locks guaranteeing peer_del() cannot free the peer concurrently.
Take devices_lock to ensure peer can be dereferenced safely.
--- net/bluetooth/6lowpan.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)
net/bluetooth/6lowpan.c +14 -3
@@ -912,16 +912,27 @@ static int bt_6lowpan_connect(bdaddr_t *addr, u8 dst_type)static int bt_6lowpan_disconnect (struct l2cap_conn *conn,u8 dst_type) {struct lowpan_peer *peer; +struct l2cap_chan *chan;BT_DBG ("conn %p dst type %u" , conn, dst_type); +spin_lock (&devices_lock); + peer =lookup_peer (conn); -if (!peer) +if (!peer) { +spin_unlock (&devices_lock);return -ENOENT ; + } + + chan = peer->chan; +l2cap_chan_hold (chan); + +spin_unlock (&devices_lock); -BT_DBG ("peer %p chan %p" , peer, peer->chan); +BT_DBG ("peer %p chan %p" , peer, chan); -l2cap_chan_close_unlocked (peer->chan,ENOENT ); +l2cap_chan_close_unlocked (chan,ENOENT ); +l2cap_chan_put (chan);return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1875/2651 Bluetooth: L2CAP: hold conn->lock for __l2cap_ecred_conn_rsp_defer
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pauli Virtanen <[email protected]>
[ Upstream commit 32d86e048d8efedb7aa6cbbd3c36c3c435401c92 ]
__l2cap_ecred_conn_rsp_defer() > __l2cap_chan_list_id() accesses conn->chan_l which is guarded by conn->lock. The lock fails to be held when calling from l2cap_sock.c.
Fix by using l2cap_chan_conn_lock(), and taking the locks in required order l2cap_conn::lock > l2cap_chan::lock > sk. Leave fast path with sk->sk_state precheck. Move the L2CAP defer handling to l2cap_sock_defer().
The code should also take l2cap_chan_lock() for sibling channels, but that needs separate fix due to lock nesting.
--- net/bluetooth/l2cap_sock.c | 68 +++++++++++++++++++++++++++----------- 1 file changed, 48 insertions(+), 20 deletions(-)
net/bluetooth/l2cap_sock.c +48 -20
@@ -1249,40 +1249,68 @@ static void l2cap_publish_rx_avail(struct l2cap_chan *chan)l2cap_chan_rx_avail (chan,-1 ); } -static int l2cap_sock_recvmsg (struct socket *sock,struct msghdr *msg, -size_t len,int flags) +static int l2cap_sock_defer (struct sock *sk) { -struct sock *sk = sock->sk; -struct l2cap_pinfo *pi =l2cap_pi (sk); -int err; +struct l2cap_chan *chan =l2cap_pi (sk)->chan; +bool have_conn; +int err =0 ; -if (unlikely (flags &MSG_ERRQUEUE )) -return sock_recv_errqueue (sk, msg, len,SOL_BLUETOOTH , -BT_SCM_ERROR ); +/* Fast path check */ +lock_sock (sk); +if (sk->sk_state !=BT_CONNECT2 ) { +release_sock (sk); +return 0 ; + } +release_sock (sk); + have_conn =l2cap_chan_lock_conn (chan);lock_sock (sk);if (sk->sk_state ==BT_CONNECT2 &&test_bit (BT_SK_DEFER_SETUP , &bt_sk (sk)->flags)) { -if (pi->chan->mode ==L2CAP_MODE_EXT_FLOWCTL ) { + err =1 ; + +if (!have_conn) { +release_sock (sk); + err = -ENOTCONN ; + }else if (chan->mode ==L2CAP_MODE_EXT_FLOWCTL ) { sk->sk_state =BT_CONNECTED ; - pi->chan->state =BT_CONNECTED ; -__l2cap_ecred_conn_rsp_defer (pi->chan); - }else if (bdaddr_type_is_le (pi->chan->src_type)) { + chan->state =BT_CONNECTED ; +release_sock (sk); +__l2cap_ecred_conn_rsp_defer (chan); + }else if (bdaddr_type_is_le (chan->src_type)) { sk->sk_state =BT_CONNECTED ; - pi->chan->state =BT_CONNECTED ; -__l2cap_le_connect_rsp_defer (pi->chan); + chan->state =BT_CONNECTED ; +release_sock (sk); +__l2cap_le_connect_rsp_defer (chan); }else { sk->sk_state =BT_CONFIG ; - pi->chan->state =BT_CONFIG ; -__l2cap_connect_rsp_defer (pi->chan); + chan->state =BT_CONFIG ; +release_sock (sk); +__l2cap_connect_rsp_defer (chan); } - - err =0 ; - goto done; + }else { +release_sock (sk); } -release_sock (sk); +l2cap_chan_unlock_conn (chan, have_conn); +return err; +} + +static int l2cap_sock_recvmsg (struct socket *sock,struct msghdr *msg, +size_t len,int flags) +{ +struct sock *sk = sock->sk; +struct l2cap_pinfo *pi =l2cap_pi (sk); +int err; + +if (unlikely (flags &MSG_ERRQUEUE )) +return sock_recv_errqueue (sk, msg, len,SOL_BLUETOOTH , +BT_SCM_ERROR ); + + err =l2cap_sock_defer (sk); +if (err) +return err <0 ? err :0 ;if (sock->type ==SOCK_STREAM ) err =bt_sock_stream_recvmsg (sock, msg, len, flags);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1876/2651 Bluetooth: L2CAP: hold l2cap_conn::lock in l2cap_connect_cfm()
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pauli Virtanen <[email protected]>
[ Upstream commit 115e6a21c88a5f708b2b025f7567ab78a782a74f ]
l2cap_new_connection() -> __l2cap_chan_add() modifies l2cap_conn::chan_l, which is guarded by l2cap_conn::lock. The lock is not held in l2cap_connect_cfm().
Fix by holding conn->lock in l2cap_connect_cfm() to make the locking systematic.
--- net/bluetooth/l2cap_core.c | 4 ++++ 1 file changed, 4 insertions(+)
net/bluetooth/l2cap_core.c +4 -0
@@ -7728,6 +7728,8 @@ static void l2cap_connect_cfm(struct hci_conn *hcon, u8 status)* we left off, because the list lock would prevent calling the * potentially sleeping l2cap_chan_lock() function. */ +mutex_lock (&conn->lock); + pchan =l2cap_global_fixed_chan (NULL , hcon);while (pchan) {struct l2cap_chan *chan, *next;
@@ -7752,6 +7754,8 @@ static void l2cap_connect_cfm(struct hci_conn *hcon, u8 status) pchan = next; } +mutex_unlock (&conn->lock); +l2cap_conn_ready (conn); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1877/2651 Bluetooth: L2CAP: hold chan in l2cap_ecred_conn_rsp()
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pauli Virtanen <[email protected]>
[ Upstream commit b508a2a2d846ccc4c8f691e4e3dfca6f97dfe85a ]
l2cap_chan_del() calls l2cap_chan_put() to drop the conn->chan_l reference. If this was the last reference, UAF follows.
l2cap_ecred_conn_rsp() iterates chan_l list and calls l2cap_chan_del() on some members, without holding chan reference.
Fix by holding refcount while using chan after l2cap_chan_del().
Since orig is looked up by dcid provided by remote, it's also possible orig == chan, so reference needs to be held also after orig use.
--- net/bluetooth/l2cap_core.c | 5 +++++ 1 file changed, 5 insertions(+)
net/bluetooth/l2cap_core.c +5 -0
@@ -5502,12 +5502,14 @@ static inline int l2cap_ecred_conn_rsp(struct l2cap_conn *conn, chan->state == BT_CONNECTED)continue ; +l2cap_chan_hold (chan);l2cap_chan_lock (chan);/* Check that there is a dcid for each pending channel */ if (cmd_len <sizeof (dcid)) {l2cap_chan_del (chan,ECONNREFUSED );l2cap_chan_unlock (chan); +l2cap_chan_put (chan);continue ; }
@@ -5546,6 +5548,8 @@ static inline int l2cap_ecred_conn_rsp(struct l2cap_conn *conn,__set_chan_timer (orig,0 );l2cap_chan_unlock (orig); } + +l2cap_chan_put (chan);continue ; }
@@ -5591,6 +5595,7 @@ static inline int l2cap_ecred_conn_rsp(struct l2cap_conn *conn, }l2cap_chan_unlock (chan); +l2cap_chan_put (chan); }return err;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1878/2651 Bluetooth: btintel_pcie: parse FW memory addresses via mailbox TLV
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chandrashekar Devegowda <[email protected]>
[ Upstream commit a504dcdb0b574a2bb00cd09378b6dee6d551f4a4 ]
Implement GP1 mailbox interrupt handling to receive memory region addresses from firmware via a TLV-based protocol. When firmware sends a BUILD_SPECIFIC_RESOURCES_MAPPING mailbox message, the driver reads a TLV table from device memory containing addresses and sizes of debug memory regions (exception dump, DCCM, SDS, ECL, SMEM).
This enables the driver to dynamically discover dump region locations instead of using hardcoded addresses, supporting current and future Intel BT PCIe controller variants.
Replace per-device hardcoded exception memory address and size constants in btintel_pcie_read_hwexp() with the dynamically populated values from dump_info, making exception dump handling consistent with other dump regions.
Key changes:
- Rewrite GP1 handler to parse mailbox registers and queue TLV work
- Add btintel_parse_mbox_tlv() for parsing FW-provided TLV data
- Add mbox_work workqueue for deferred TLV processing
- Store parsed region addresses in btintel_pcie_dump_mem_info
- Add cnvi_bt field to btintel_data for HW variant identification
- Rename fw_git_sha1 to fw_sha for consistency
- Remove hardcoded HWEXP address/size macros and use dump_info
Stable-dep-of: 937363063afd ("Bluetooth: btintel_pcie: remove duplicate BTINTEL_PCIE_MAGIC_NUM definition")
--- drivers/bluetooth/btintel.c | 7 + drivers/bluetooth/btintel.h | 1 + drivers/bluetooth/btintel_pcie.c | 349 +++++++++++++++++++++++++++++-- drivers/bluetooth/btintel_pcie.h | 53 ++++- 4 files changed, 387 insertions(+), 23 deletions(-)
drivers/bluetooth/btintel.c +7 -0
@@ -66,6 +66,7 @@ static struct {const char *driver_name;u8 hw_variant;u32 fw_build_num; +u32 fw_sha; } coredump_info; const guid_t btintel_guid_dsm =
@@ -569,6 +570,7 @@ int btintel_version_info_tlv(struct hci_dev *hdev, coredump_info.hw_variant =INTEL_HW_VARIANT (version->cnvi_bt); coredump_info.fw_build_num = version->build_num; + coredump_info.fw_sha = version->git_sha1; bt_dev_info(hdev, "%s timestamp %u.%u buildtype %u build %u", variant, 2000 + (version->timestamp >> 8), version->timestamp & 0xff,
@@ -2382,6 +2384,7 @@ static int btintel_prepare_fw_download_tlv(struct hci_dev *hdev,struct intel_version_tlv *ver, u32 *boot_param) { + struct btintel_data *intel_data = hci_get_priv(hdev);const struct firmware *fw;char fwname[128 ];int err;
@@ -2494,6 +2497,7 @@ static int btintel_prepare_fw_download_tlv(struct hci_dev *hdev,btintel_reset_to_bootloader (hdev); done: + intel_data->cnvi_bt = ver->cnvi_bt;release_firmware (fw);return err; }
@@ -3531,6 +3535,9 @@ int btintel_bootloader_setup_tlv(struct hci_dev *hdev,btintel_version_info_tlv (hdev, &new_ver); +/* Update ver with the operational firmware version */ + *ver = new_ver; + finish:/* Set the event mask for Intel specific vendor events. This enables * a few extra events that are useful during general operation. It
drivers/bluetooth/btintel.h +1 -0
@@ -247,6 +247,7 @@ enum {struct btintel_data { DECLARE_BITMAP(flags, __INTEL_NUM_FLAGS);int (*acpi_reset_method)(struct hci_dev *hdev); +u32 cnvi_bt; };#define btintel_set_flag (hdev, nr) \
drivers/bluetooth/btintel_pcie.c +328 -21
443 lines not on this page · raw message
drivers/bluetooth/btintel_pcie.h +51 -2
107 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1879/2651 Bluetooth: btintel_pcie: remove duplicate BTINTEL_PCIE_MAGIC_NUM definition
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chandrashekar Devegowda <[email protected]>
[ Upstream commit 937363063afde2dce1f45d8f22514db99b9eba6b ]
Two identical definitions of BTINTEL_PCIE_MAGIC_NUM were present in btintel_pcie.c, one indented with spaces and one with a tab. Remove the space-indented duplicate and the surrounding blank lines. Kernel coding style requires tabs for indentation, so keep the tab-indented copy.
No functional change.
--- drivers/bluetooth/btintel_pcie.c | 5 ----- 1 file changed, 5 deletions(-)
drivers/bluetooth/btintel_pcie.c +0 -5
@@ -73,11 +73,6 @@ struct btintel_pcie_dev_recovery {#define BTINTEL_PCIE_HCI_EVT_PKT 0x00000004#define BTINTEL_PCIE_HCI_ISO_PKT 0x00000005 -#define BTINTEL_PCIE_MAGIC_NUM 0xA5A5A5A5 - - - -#define BTINTEL_PCIE_MAGIC_NUM 0xA5A5A5A5#define BTINTEL_PCIE_TRIGGER_REASON_USER_TRIGGER 0x17A2
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1880/2651 Bluetooth: btmtk: Validate the firmware layout before parsing it
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chris Lu <[email protected]>
[ Upstream commit 760ac9d02dce001f2e20c17deb18e7bb63d8355e ]
btmtk_setup_firmware_79xx() reads the section count out of the firmware's global descriptor, then walks a 64-byte section map per section and hands each section's file-supplied offset and length to the WMT download path. None of that is checked against fw->size, so a truncated or corrupted file makes the driver read past the end of request_firmware()'s buffer. On 32-bit the section count can also wrap the section map size calculation.
Add btmtk_fw_validate_layout() to check that the header, global descriptor and section map array all fit, and btmtk_fw_validate_section() to check one section's offset and length, both written so the size arithmetic cannot wrap. A section count of zero is rejected as well: it passes every size check but leaves the download loop with nothing to do, so the function would report success on hardware it never programmed. They are helpers rather than open-coded because the MT7928 CBMCU download path added later needs the same arithmetic.
This is hardening against a corrupted /lib/firmware rather than a bug an unprivileged user can trigger, hence bluetooth-next and no Fixes: tag. Well-formed firmware files are unaffected.
--- drivers/bluetooth/btmtk.c | 74 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 71 insertions(+), 3 deletions(-)
drivers/bluetooth/btmtk.c +71 -3
@@ -6,6 +6,7 @@#include <linux/firmware.h> #include <linux/usb.h> #include <linux/iopoll.h> +#include <linux/overflow.h> #include <linux/unaligned.h> #include <net/bluetooth/bluetooth.h>
@@ -59,6 +60,67 @@ struct btmtk_section_map { }; } __packed; +/* Reject a firmware image whose header, global descriptor or section map +* array does not fit in the file, and hand back the validated section +* count, so that the section map walks stay inside the firmware buffer. +*/ +static int btmtk_fw_validate_layout (struct hci_dev *hdev, +const struct firmware *fw, +u32 *section_num) +{ +const struct btmtk_global_desc *globaldesc; +size_t need; + +if (fw->size <MTK_FW_ROM_PATCH_HEADER_SIZE +MTK_FW_ROM_PATCH_GD_SIZE ) { +bt_dev_err (hdev,"Firmware too small: %zu bytes, need at least %u" , + fw->size, +MTK_FW_ROM_PATCH_HEADER_SIZE +MTK_FW_ROM_PATCH_GD_SIZE ); +return -EINVAL ; + } + + globaldesc = (const struct btmtk_global_desc *)(fw->data + +MTK_FW_ROM_PATCH_HEADER_SIZE ); + *section_num =le32_to_cpu (globaldesc->section_num); + +if (!*section_num) { +bt_dev_err (hdev,"Firmware declares no sections" ); +return -EINVAL ; + } + +if (check_mul_overflow ((size_t )MTK_FW_ROM_PATCH_SEC_MAP_SIZE , + (size_t )*section_num, &need) || +check_add_overflow (need, + (size_t )(MTK_FW_ROM_PATCH_HEADER_SIZE + +MTK_FW_ROM_PATCH_GD_SIZE ), + &need)) { +bt_dev_err (hdev,"Firmware section count too large: %u" , + *section_num); +return -EINVAL ; + } + +if (fw->size < need) { +bt_dev_err (hdev,"Firmware truncated: %zu bytes, need %zu for %u sections" , + fw->size, need, *section_num); +return -EINVAL ; + } + +return 0 ; +} + +/* Reject a section whose payload does not lie within the firmware file. */ +static int btmtk_fw_validate_section (struct hci_dev *hdev, +const struct firmware *fw,int index, +u32 offset,u32 size) +{ +if (offset > fw->size || size > fw->size - offset) { +bt_dev_err (hdev,"Firmware section %d out of bounds: offset=%u, size=%u, fw_size=%zu" , + index, offset, size, fw->size); +return -EINVAL ; + } + +return 0 ; +} +static void btmtk_coredump (struct hci_dev *hdev) {int err;
@@ -137,7 +199,6 @@ int btmtk_setup_firmware_79xx(struct hci_dev *hdev, const char *fwname, {struct btmtk_hci_wmt_params wmt_params;struct btmtk_patch_header *hdr; -struct btmtk_global_desc *globaldesc =NULL ;struct btmtk_section_map *sectionmap;const struct firmware *fw;const u8 *fw_ptr;
@@ -153,11 +214,13 @@ int btmtk_setup_firmware_79xx(struct hci_dev *hdev, const char *fwname,return err; } + err =btmtk_fw_validate_layout (hdev, fw, §ion_num); +if (err <0 ) + goto err_release_fw; + fw_ptr = fw->data; fw_bin_ptr = fw_ptr; hdr = (struct btmtk_patch_header *)fw_ptr; - globaldesc = (struct btmtk_global_desc *)(fw_ptr +MTK_FW_ROM_PATCH_HEADER_SIZE ); - section_num =le32_to_cpu (globaldesc->section_num);bt_dev_info (hdev,"HW/SW Version: 0x%04x%04x, Build Time: %s" ,le16_to_cpu (hdr->hwver),le16_to_cpu (hdr->swver), hdr->datetime);
@@ -180,6 +243,11 @@ int btmtk_setup_firmware_79xx(struct hci_dev *hdev, const char *fwname,continue ;if (dl_size >0 ) { + err =btmtk_fw_validate_section (hdev, fw, i, + section_offset, dl_size); +if (err <0 ) + goto err_release_fw; + retry =20 ;while (retry >0 ) { cmd[0 ] =0 ;/* 0 means legacy dl mode. */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1881/2651 Bluetooth: btmtk: Improve BT firmware logging
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chris Lu <[email protected]>
[ Upstream commit 046fa20e9c7abbafb166b431fe446c49b71cb15a ]
The firmware log line in btmtk_setup_firmware_79xx() never says which file was requested, which matters because btmtk_fw_get_filename() derives the name from the device id and firmware version at runtime. It reports the firmware's own hwver field as the HW version, when the device id the driver read from the chip is the more useful value and is already available as dev_id. And it prints datetime, a u8[16] with no guaranteed NUL terminator, with %s.
Log the filename before the image is parsed, so a file that fails validation still says which file it was, report dev_id as the HW version, and bound datetime with %.16s.
The datetime change is hardening rather than a fix, hence no Fixes: tag:
every file in linux-firmware terminates the field, and provoking the over-read needs a malformed file in /lib/firmware.
Log output on MT7922 after the change:
[ 365.245951] Bluetooth: hci0: Loading BT firmware: mediatek/BT_RAM_CODE_MT7922_1_1_hdr.bin [ 365.245956] Bluetooth: hci0: BT HW ver: 0x7922, SW ver: 0x008a, Build Time: 20260605203811
--- drivers/bluetooth/btmtk.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/bluetooth/btmtk.c +4 -2
@@ -214,6 +214,8 @@ int btmtk_setup_firmware_79xx(struct hci_dev *hdev, const char *fwname,return err; } +bt_dev_info (hdev,"Loading BT firmware: %s" , fwname); + err =btmtk_fw_validate_layout (hdev, fw, §ion_num);if (err <0 ) goto err_release_fw;
@@ -222,8 +224,8 @@ int btmtk_setup_firmware_79xx(struct hci_dev *hdev, const char *fwname, fw_bin_ptr = fw_ptr; hdr = (struct btmtk_patch_header *)fw_ptr; -bt_dev_info (hdev,"HW/SW Version: 0x%04x%04x, Build Time: %s" , -le16_to_cpu (hdr->hwver),le16_to_cpu (hdr->swver), hdr->datetime); +bt_dev_info (hdev,"BT HW ver: 0x%04x, SW ver: 0x%04x, Build Time: %.16s" , + dev_id &0xffff ,le16_to_cpu (hdr->swver), hdr->datetime);for (i =0 ; i < section_num; i++) { first_block =1 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1882/2651 Bluetooth: btintel_pcie: fix stale cache in set_dxstate fallback check
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vladimir V. Kondratyev <[email protected]>
[ Upstream commit 12997a385f7140c66f733128b76845fd906c270a ]
btintel_pcie returns -16 (EBUSY) during suspend, causing the entire suspend operation to abort on Intel Lunar Lake hardware. The system immediately resumes after every suspend attempt:
Bluetooth: hci0: Timeout (200 ms) on alive interrupt for D2 entry, retry count 0
Bluetooth: hci0: Timeout (200 ms) on alive interrupt for D2 entry, retry count 1
Bluetooth: hci0: Timeout (200 ms) on alive interrupt for D2 entry, retry count 2 btintel_pcie 0000:00:14.7: PM: pci_pm_suspend(): btintel_pcie_suspend [btintel_pcie] returns -16 btintel_pcie 0000:00:14.7: PM: dpm_run_callback(): pci_pm_suspend returns -16 btintel_pcie 0000:00:14.7: PM: failed to suspend async: error -16
PM: Some devices failed to suspend, or early wake event detected
btintel_pcie_set_dxstate() falls back to checking the controller state via btintel_pcie_in_d3/d0() when the alive interrupt is missed. However, these helpers read boot_stage_cache, which is only updated by the interrupt handler. As such, if the interrupt was missed, the cache is stale and the fallback check always fails, exhausting all retries and returning -EBUSY, causing suspend to abort.
The fix involves re-reading the hardware register before the fallback state check, consistent with btintel_pcie_resume().
--- drivers/bluetooth/btintel_pcie.c | 8 +++++--- drivers/bluetooth/btintel_pcie.h | 1 + 2 files changed, 6 insertions(+), 3 deletions(-)
drivers/bluetooth/btintel_pcie.c +5 -3
@@ -3507,10 +3507,12 @@ static int btintel_pcie_set_dxstate(struct btintel_pcie_data *data, u32 dxstate)BTINTEL_PCIE_CSR_MSIX_HW_INT_CAUSES , BTINTEL_PCIE_MSIX_HW_INT_CAUSES_GP0); -/* A hardware bug may cause the alive interrupt to be missed. -* Check if the controller reached the expected state and retry -* the operation only if it hasn't. +/* A hardware bug may cause the alive interrupt to be missed. Refresh +* boot_stage_cache from hardware, since only the interrupt handler +* updates it. Finally retry only if the state check still fails. */ + data->boot_stage_cache =btintel_pcie_rd_reg32 (data, +BTINTEL_PCIE_CSR_BOOT_STAGE_REG );if (dxstate ==BTINTEL_PCIE_STATE_D0 ) {if (btintel_pcie_in_d0 (data))return 0 ;
drivers/bluetooth/btintel_pcie.h +1 -0
@@ -51,6 +51,7 @@#define BTINTEL_PCIE_CSR_BOOT_STAGE_DEVICE_HALTED (BIT(14))#define BTINTEL_PCIE_CSR_BOOT_STAGE_MAC_ACCESS_ON (BIT(16))#define BTINTEL_PCIE_CSR_BOOT_STAGE_ALIVE (BIT(23)) +/* Reflects live D-state. Updated by hardware on every D-state transition. */ #define BTINTEL_PCIE_CSR_BOOT_STAGE_D3_STATE_READY (BIT(24))#define BTINTEL_PCIE_CSR_DOORBELL_MBOX_READ_CONFIRM (BIT(4))
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1883/2651 Bluetooth: btintel_pcie: fix PM flow for S0ix, S3 and S4
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ravindra <[email protected]>
[ Upstream commit 2926eb396711f1f843a0aafee6778822f50e9021 ]
Fix two issues in the PM suspend/resume path:
1. S3 was handled the same as S0ix, keeping the controller on the D3hot-style path. That caused resume instability because S3 can remove power from the controller, unlike s2idle/S0ix. Use pm_suspend_target_state to distinguish them: D3_HOT for S0ix and D3_COLD for S3/S4. Add .restore to force FLR-based firmware recovery after S4 and S3 (PM_SUSPEND_MEM), as power is lost. S0ix resumes via a normal D0 transition.
2. During hibernation, .freeze() puts the controller into the D3cold state without any loss of power, and the flow normally continues to .poweroff(). If hibernation instead fails, .thaw() is called to bring the controller back up, and the old code routed it through btintel_pcie_resume(), which forced FLR-based firmware recovery whenever data->pm_sx_event was PM_EVENT_FREEZE. That check was
incorrect: since the controller's power was never actually removed on this failed-hibernation path, FLR-based recovery is unnecessary. Remove pm_sx_event and route .thaw through a normal D0 transition instead; FLR-based recovery is retained only in .restore, where genuine S4 power loss requires it.
Tested with:
S0ix: sudo sh -c 'echo "+40" > /sys/class/rtc/rtc0/wakealarm' && \
echo freeze | sudo tee /sys/power/state
S3: sudo rtcwake -m mem -s 60
S4: sudo rtcwake -m disk -s 60
--- drivers/bluetooth/btintel_pcie.c | 58 +++++++++++++++++++++----------- drivers/bluetooth/btintel_pcie.h | 2 -- 2 files changed, 39 insertions(+), 21 deletions(-)
drivers/bluetooth/btintel_pcie.c +39 -19
@@ -16,6 +16,7 @@#include <linux/delay.h> #include <linux/interrupt.h> #include <linux/acpi.h> +#include <linux/suspend.h> #include <linux/unaligned.h> #include <linux/devcoredump.h>
@@ -3484,7 +3485,8 @@ static void btintel_pcie_coredump(struct device *dev)static int btintel_pcie_set_dxstate (struct btintel_pcie_data *data,u32 dxstate) { -int retry =0 , status; +int retry =0 ; +long status;u32 dx_intr_timeout_ms =200 ; do {
@@ -3536,18 +3538,23 @@ static int btintel_pcie_suspend_late(struct device *dev, pm_message_t mesg) data =pci_get_drvdata (pdev); - dxstate = (mesg.event ==PM_EVENT_SUSPEND ? -BTINTEL_PCIE_STATE_D3_HOT :BTINTEL_PCIE_STATE_D3_COLD ); - - data->pm_sx_event = mesg.event; +/* S0ix (s2idle) uses D3_HOT; S3, freeze and hibernate use D3_COLD. */ +if (mesg.event ==PM_EVENT_SUSPEND && + pm_suspend_target_state ==PM_SUSPEND_TO_IDLE ) + dxstate =BTINTEL_PCIE_STATE_D3_HOT ; +else + dxstate =BTINTEL_PCIE_STATE_D3_COLD ; start =ktime_get ();/* Refer: 6.4.11.7 -> Platform power management */ err =btintel_pcie_set_dxstate (data, dxstate); -if (err) +if (err) { +bt_dev_err (data->hdev,"Failed to set dxstate:%u (%d)" , + dxstate, err);return err; + } bt_dev_dbg(data->hdev, "device entered into d3 state from d0 in %lld us",
@@ -3570,7 +3577,7 @@ static int btintel_pcie_freeze(struct device *dev)return btintel_pcie_suspend_late (dev,PMSG_FREEZE ); } -static int btintel_pcie_resume (struct device *dev) +static int btintel_pcie_resume_event (struct device *dev,pm_message_t mesg) {struct pci_dev *pdev =to_pci_dev (dev);struct btintel_pcie_data *data;
@@ -3578,19 +3585,15 @@ static int btintel_pcie_resume(struct device *dev)int err; data =pci_get_drvdata (pdev); - data->gp0_received = false; start =ktime_get (); -/* When the system enters S4 (hibernate) mode, bluetooth device loses -* power, which results in the erasure of its loaded firmware. -* Consequently, function level reset (flr) is required on system -* resume to bring the controller back into an operational state by -* initiating a new firmware download. +/* S3 and S4 may cut power, erasing the firmware. Force FLR to recover +* instead of a normal D0 transition. */ - -if (data->pm_sx_event ==PM_EVENT_FREEZE || - data->pm_sx_event ==PM_EVENT_HIBERNATE ) { +if (mesg.event ==PM_EVENT_RESTORE || + (mesg.event ==PM_EVENT_RESUME && + pm_suspend_target_state ==PM_SUSPEND_MEM )) {set_bit (BTINTEL_PCIE_CORE_HALTED , &data->flags);btintel_pcie_request_reset (data,BTINTEL_PCIE_IOSF_PRR_FLR );return 0 ;
@@ -3599,7 +3602,9 @@ static int btintel_pcie_resume(struct device *dev)/* Refer: 6.4.11.7 -> Platform power management */ err =btintel_pcie_set_dxstate (data,BTINTEL_PCIE_STATE_D0 ); -if (err ==0 ) { +if (err) { +bt_dev_err (data->hdev,"Failed to set D0 state (%d)" , err); + }else {bt_dev_dbg (data->hdev,"device entered into d0 state from d3 in %lld us" ,ktime_to_us (ktime_get () - start));
@@ -3624,13 +3629,28 @@ static int btintel_pcie_resume(struct device *dev)return err; } +static int btintel_pcie_resume (struct device *dev) +{ +return btintel_pcie_resume_event (dev,PMSG_RESUME ); +} + +static int btintel_pcie_restore (struct device *dev) +{ +return btintel_pcie_resume_event (dev,PMSG_RESTORE ); +} + +static int btintel_pcie_thaw (struct device *dev) +{ +return btintel_pcie_resume_event (dev,PMSG_THAW ); +} +static const struct dev_pm_ops btintel_pcie_pm_ops = { .suspend = btintel_pcie_suspend, .resume = btintel_pcie_resume, .freeze = btintel_pcie_freeze, - .thaw = btintel_pcie_resume, + .thaw = btintel_pcie_thaw, .poweroff = btintel_pcie_hibernate, - .restore = btintel_pcie_resume, + .restore = btintel_pcie_restore, };static struct pci_driver btintel_pcie_driver = {
drivers/bluetooth/btintel_pcie.h +0 -2
@@ -524,7 +524,6 @@ struct btintel_pcie_dump_header {* @txq: TX Queue struct * @rxq: RX Queue struct * @alive_intr_ctxt: Alive interrupt context -* @pm_sx_event: PM event on which system got suspended */ struct btintel_pcie_data {struct pci_dev *pdev;
@@ -582,7 +581,6 @@ struct btintel_pcie_data {enum btintel_pcie_reset_type reset_type;struct btintel_pcie_dbgc dbgc;struct btintel_pcie_dump_header dmp_hdr; -u8 pm_sx_event;u32 debug_evt_addr;u32 debug_evt_size;dma_addr_t debug_table_addr;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1884/2651 Bluetooth: btintel_pcie: sync mbox tlv parsing with GP0 alive interrupt
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kiran K <[email protected]>
[ Upstream commit d572ea4b621ce60279da5179a0c338660c8b7331 ]
Performing a target access to read the mbox TLV table while the driver is concurrently posting RX buffers to the firmware causes the hardware to return 0 for the target address, resulting in an invalid/empty TLV parse.
Add a synchronization handshake between the mbox TLV read operation performed by the mbox worker and the GP0 (alive) MSI-X interrupt (which signals completion of RX buffer posting). The worker now waits for the alive interrupt before initiating the target access, ensuring the hardware returns valid data.
Stable-dep-of: 4f6ead67b93b ("Bluetooth: btintel_pcie: verify and serialize D-state transitions")
--- drivers/bluetooth/btintel_pcie.c | 42 +++++++++++++++++++++++++++++--- drivers/bluetooth/btintel_pcie.h | 10 +++++++- 2 files changed, 48 insertions(+), 4 deletions(-)
drivers/bluetooth/btintel_pcie.c +39 -3
@@ -989,6 +989,24 @@ static int btintel_parse_mbox_tlv(struct btintel_pcie_data *data)struct mbox_tlv *tlv;struct btintel_data *cnvi_data =hci_get_priv (data->hdev);u8 hw_variant =INTEL_HW_VARIANT (cnvi_data->cnvi_bt); +long t; + +/* Wait for GP0 alive interrupt to post RX buffers */ + t =wait_event_timeout (data->mbox_parse_wait_q, +test_bit (BTINTEL_PCIE_MBOX_PARSE_READY , &data->flags), +msecs_to_jiffies (BTINTEL_PCIE_MBOX_INTR_TIMEOUT_MS )); +if (!t) { +bt_dev_warn (data->hdev, +"Timeout (%u ms) waiting for alive interrupt before mbox TLV parse; skipping" , +BTINTEL_PCIE_MBOX_INTR_TIMEOUT_MS ); +return 0 ; + } +clear_bit (BTINTEL_PCIE_MBOX_PARSE_READY , &data->flags); + +bt_dev_info (data->hdev, +"mbox TLV parse started at %lld ns (%lld us after mbox interrupt)" , +ktime_to_ns (ktime_get ()), +ktime_to_us (ktime_sub (ktime_get (), data->mbox_intr_ts)));memset (&data->dump_info,0 ,sizeof (data->dump_info));
@@ -1232,12 +1250,22 @@ static void btintel_pcie_msix_gp1_handler(struct btintel_pcie_data *data)if (target_access && !test_and_set_bit (BTINTEL_PCIE_MAIL_BOX_INTR , &data->flags)) { +/* Arm the mbox<->alive handshake */ +clear_bit (BTINTEL_PCIE_MBOX_PARSE_READY , &data->flags); +set_bit (BTINTEL_PCIE_MBOX_PARSE_PENDING , &data->flags); + data->mbox_intr_ts =ktime_get (); + +bt_dev_info (data->hdev, +"mbox interrupt received at %lld ns; queuing mbox_work" , +ktime_to_ns (data->mbox_intr_ts)); +WRITE_ONCE (data->debug_table_addr, addr);WRITE_ONCE (data->debug_table_size, size);if (!queue_work (data->dump_workqueue, - &data->mbox_work)) -clear_bit (BTINTEL_PCIE_MAIL_BOX_INTR , - &data->flags); + &data->mbox_work)) { +clear_bit (BTINTEL_PCIE_MAIL_BOX_INTR , &data->flags); +clear_bit (BTINTEL_PCIE_MBOX_PARSE_PENDING , &data->flags); + } }/* Mailbox is read, ack to FW */
@@ -1347,6 +1375,12 @@ static void btintel_pcie_msix_gp0_handler(struct btintel_pcie_data *data)if (submit_rx) {btintel_pcie_reset_ia (data);btintel_pcie_start_rx (data); + +/* Complete the mbox<->alive handshake */ +if (test_and_clear_bit (BTINTEL_PCIE_MBOX_PARSE_PENDING , &data->flags)) { +set_bit (BTINTEL_PCIE_MBOX_PARSE_READY , &data->flags); +wake_up (&data->mbox_parse_wait_q); + } }if (signal_waitq) {
@@ -3345,6 +3379,8 @@ static int btintel_pcie_probe(struct pci_dev *pdev,init_waitqueue_head (&data->tx_wait_q); data->tx_wait_done = false; +init_waitqueue_head (&data->mbox_parse_wait_q); + data->workqueue =alloc_ordered_workqueue (KBUILD_MODNAME ,WQ_HIGHPRI );if (!data->workqueue)return -ENOMEM ;
drivers/bluetooth/btintel_pcie.h +9 -1
@@ -126,7 +126,9 @@ enum {BTINTEL_PCIE_FWTRIGGER_DUMP_INPROGRESS ,BTINTEL_PCIE_RECOVERY_IN_PROGRESS ,BTINTEL_PCIE_SETUP_DONE , -BTINTEL_PCIE_MAIL_BOX_INTR +BTINTEL_PCIE_MAIL_BOX_INTR , +BTINTEL_PCIE_MBOX_PARSE_PENDING , +BTINTEL_PCIE_MBOX_PARSE_READY }; enum btintel_pcie_tlv_type {
@@ -179,6 +181,7 @@ enum btintel_pcie_mbox_msg {/* Default interrupt timeout in msec */ #define BTINTEL_DEFAULT_INTR_TIMEOUT_MS 3000 +#define BTINTEL_PCIE_MBOX_INTR_TIMEOUT_MS 500#define BTINTEL_PCIE_DX_TRANSITION_MAX_RETRIES 3
@@ -587,6 +590,11 @@ struct btintel_pcie_data {u32 debug_table_size;struct btintel_pcie_dump_mem_info dump_info;struct btintel_pcie_mbox mbox; + +/* Wait queue for mbox_worker to wait for GP0 alive interrupt */ +wait_queue_head_t mbox_parse_wait_q; +/* Timestamp captured in GP1 handler when mbox interrupt is received */ +ktime_t mbox_intr_ts; }; static inline u32 btintel_pcie_rd_reg32(struct btintel_pcie_data *data,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1885/2651 Bluetooth: btintel_pcie: verify and serialize D-state transitions
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sergey Lebedev <[email protected]>
[ Upstream commit 4f6ead67b93bcc4ba1fbbf97c7c8bc5a0c45b80b ]
The gp0_received flag only reports that the GP0 handler ran. It does not contain proof that the handler completed the requested D-state transition:
a matched case can leave the state unchanged.
Refresh the boot-stage register before treating the transition as successful. When the controller is in D0 but the handler did not re-arm the interface, restore the alive context, reset the IA, restart RX, and complete the mailbox/alive handshake. Propagate RX setup failures to the PM caller. Likewise, when the controller is in D3 but the handler did not record it, restore the alive context so the next transition dispatches correctly.
Serialize the alive-context claim between the GP0 handler and the set_dxstate() fallback with irq_lock. Only the path that claims the D0 transition resets the IA and rearms RX, avoiding concurrent updates to the shared ring state.
--- drivers/bluetooth/btintel_pcie.c | 80 +++++++++++++++++++++++++------- 1 file changed, 64 insertions(+), 16 deletions(-)
drivers/bluetooth/btintel_pcie.c +64 -16
@@ -1316,6 +1316,10 @@ static void btintel_pcie_msix_gp0_handler(struct btintel_pcie_data *data) submit_rx = false; signal_waitq = false; +/* Serialize the alive_intr_ctxt claim against set_dxstate()'s +* register-based fallback, which can run concurrently. +*/ +spin_lock (&data->irq_lock);switch (data->alive_intr_ctxt) {case BTINTEL_PCIE_ROM : data->alive_intr_ctxt =BTINTEL_PCIE_FW_DL ;
@@ -1371,6 +1375,7 @@ static void btintel_pcie_msix_gp0_handler(struct btintel_pcie_data *data) data->alive_intr_ctxt);break ; } +spin_unlock (&data->irq_lock);if (submit_rx) {btintel_pcie_reset_ia (data);
@@ -3521,7 +3526,7 @@ static void btintel_pcie_coredump(struct device *dev)static int btintel_pcie_set_dxstate (struct btintel_pcie_data *data,u32 dxstate) { -int retry =0 ; +int retry =0 , err;long status;u32 dx_intr_timeout_ms =200 ;
@@ -3533,30 +3538,73 @@ static int btintel_pcie_set_dxstate(struct btintel_pcie_data *data, u32 dxstate) status =wait_event_timeout (data->gp0_wait_q, data->gp0_received,msecs_to_jiffies (dx_intr_timeout_ms)); -if (status) -return 0 ; - -bt_dev_warn (data->hdev, -"Timeout (%u ms) on alive interrupt for D%d entry, retry count %d" , - dx_intr_timeout_ms, dxstate, retry); +if (!status) { +bt_dev_warn (data->hdev, +"Timeout (%u ms) on alive interrupt for D%d entry, retry count %d" , + dx_intr_timeout_ms, dxstate, retry); -/* clear gp0 cause */ -btintel_pcie_clr_reg_bits (data, -BTINTEL_PCIE_CSR_MSIX_HW_INT_CAUSES , -BTINTEL_PCIE_MSIX_HW_INT_CAUSES_GP0 ); +/* clear gp0 cause */ +btintel_pcie_clr_reg_bits (data, +BTINTEL_PCIE_CSR_MSIX_HW_INT_CAUSES , +BTINTEL_PCIE_MSIX_HW_INT_CAUSES_GP0 ); + } -/* A hardware bug may cause the alive interrupt to be missed. Refresh -* boot_stage_cache from hardware, since only the interrupt handler -* updates it. Finally retry only if the state check still fails. +/* gp0_received is set at the top of the handler, before the switch on +* alive_intr_ctxt. Error and lockdown are filtered out above it, but a +* matched case can still complete without doing anything - D3 breaks +* unchanged while the controller has not reached D0 - and a hardware +* bug may drop the interrupt outright. Either way the flag says a gp0 +* was handled, not that the transition completed, and only the register +* knows. Refresh the cache here and retry only if the state check still +* fails. */ data->boot_stage_cache =btintel_pcie_rd_reg32 (data,BTINTEL_PCIE_CSR_BOOT_STAGE_REG );if (dxstate ==BTINTEL_PCIE_STATE_D0 ) { -if (btintel_pcie_in_d0 (data)) +if (btintel_pcie_in_d0 (data)) { +bool armed; + +/* Claim the transition under irq_lock so a +* concurrent gp0 handler run cannot also arm RX. +*/ +spin_lock (&data->irq_lock); + armed = data->alive_intr_ctxt ==BTINTEL_PCIE_D0 ; +if (!armed) + data->alive_intr_ctxt =BTINTEL_PCIE_D0 ; +spin_unlock (&data->irq_lock); + +if (armed) +return 0 ; + +/* Do what the handler's D3 -> D0 branch +* would have done, unless it already has. +*/ +btintel_pcie_reset_ia (data); + err =btintel_pcie_start_rx (data); +if (err) +return err; + +/* Complete the mbox<->alive handshake */ +if (test_and_clear_bit (BTINTEL_PCIE_MBOX_PARSE_PENDING , + &data->flags)) { +set_bit (BTINTEL_PCIE_MBOX_PARSE_READY , &data->flags); +wake_up (&data->mbox_parse_wait_q); + } +return 0 ; + } }else { -if (btintel_pcie_in_d3 (data)) +if (btintel_pcie_in_d3 (data)) { +/* Do what the handler's D0 -> D3 branch +* would have done, unless it already has. +*/ +spin_lock (&data->irq_lock); +if (data->alive_intr_ctxt !=BTINTEL_PCIE_D3 ) + data->alive_intr_ctxt =BTINTEL_PCIE_D3 ; +spin_unlock (&data->irq_lock); +return 0 ; + } } }while (++retry <BTINTEL_PCIE_DX_TRANSITION_MAX_RETRIES );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1886/2651 Bluetooth: btintel_pcie: clear the GP0 cause with a W1C write
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ravindra <[email protected]>
[ Upstream commit f2cee6e2aa35a6a701ce3f4bedf20273c808361f ]
MSIX_HW_INT_CAUSES is a write-one-to-clear register. Using a read-modify-write helper writes zero to GP0, leaving the cause uncleared, and can acknowledge unrelated pending causes through the read value.
Write only the GP0 bit directly, matching the interrupt handler's W1C acknowledgment convention.
--- drivers/bluetooth/btintel_pcie.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/bluetooth/btintel_pcie.c +6 -4
@@ -3543,10 +3543,12 @@ static int btintel_pcie_set_dxstate(struct btintel_pcie_data *data, u32 dxstate)"Timeout (%u ms) on alive interrupt for D%d entry, retry count %d" , dx_intr_timeout_ms, dxstate, retry); -/* clear gp0 cause */ -btintel_pcie_clr_reg_bits (data, -BTINTEL_PCIE_CSR_MSIX_HW_INT_CAUSES , -BTINTEL_PCIE_MSIX_HW_INT_CAUSES_GP0 ); +/* MSIX_HW_INT_CAUSES is W1C. Write only GP0 so other +* pending causes are not acknowledged here. +*/ +btintel_pcie_wr_reg32 (data, +BTINTEL_PCIE_CSR_MSIX_HW_INT_CAUSES , +BTINTEL_PCIE_MSIX_HW_INT_CAUSES_GP0 ); }/* gp0_received is set at the top of the handler, before the switch on
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1887/2651 Bluetooth: btusb: Preserve event and ACL packet ordering
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kiran K <[email protected]>
[ Upstream commit fa96916cfd05ceb1c26af0b2ea73daf5481cad2d ]
When force_poll_sync is enabled, commit 800fe5ec302e ("Bluetooth:
btusb: Add support for queuing during polling interval") defers ACL delivery to the RX worker. The event path currently wakes that worker before delivering the event, so queued ACL data can reach HCI first.
Deliver the event before waking the worker. This preserves the intended event-first ordering and the event callback's return value.
--- drivers/bluetooth/btusb_main.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/bluetooth/btusb_main.c +4 -1
@@ -1279,13 +1279,16 @@ static inline void btusb_free_frags(struct btusb_data *data)static int btusb_recv_event (struct hci_dev *hdev,struct sk_buff *skb) {struct btusb_data *data =hci_get_drvdata (hdev); +int err; + + err = data->recv_event (hdev, skb);if (data->intr_interval) {/* Trigger dequeue immediately if an event is received */ schedule_delayed_work (&data->rx_work,0 ); } -return data->recv_event (hdev, skb); +return err; }static int btusb_recv_intr (struct btusb_data *data,void *buffer,int count)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1888/2651 Bluetooth: hci_sync: fix mesh adv timeout units
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pauli Virtanen <[email protected]>
[ Upstream commit 8a8d51eeedebfa5aaaae7720f2fb2aa1a67b8587 ]
Mesh adv instance timeout and duration are in milliseconds, see mesh_send_sync, hci_add_adv_instance. hci_schedule_adv_instance_sync() and hci_enable_ext_advertising_sync() ignore this, and scale the timeout wrong.
Fix for mesh instances by using msecs_to_jiffies() in hci_schedule_adv_instance_sync and fixing the scaling in hci_enable_ext_advertising_sync.
Fixes BlueZ "Mesh - Send cancel" test failures.
--- net/bluetooth/hci_sync.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
net/bluetooth/hci_sync.c +4 -2
@@ -1672,7 +1672,8 @@ int hci_enable_ext_advertising_sync(struct hci_dev *hdev, u8 instance)* scheduling it. */ if (adv && adv->timeout) { -u16 duration = adv->timeout *MSEC_PER_SEC ; +u16 duration = adv->mesh ? adv->timeout : + adv->timeout *MSEC_PER_SEC ;/* Time = N * 10 ms */ set->duration =cpu_to_le16 (duration /10 );
@@ -2103,7 +2104,8 @@ int hci_schedule_adv_instance_sync(struct hci_dev *hdev, u8 instance, hdev->adv_instance_timeout = timeout;queue_delayed_work (hdev->req_workqueue, &hdev->adv_instance_expire, -secs_to_jiffies (timeout)); + adv->mesh ?msecs_to_jiffies (timeout) : +secs_to_jiffies (timeout)); }/* If we're just re-scheduling the same instance again then do not
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1889/2651 Bluetooth: MGMT: Fix advertising instances with Global Advertising
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luiz Augusto von Dentz <[email protected]>
[ Upstream commit 0ad48c88a2ed3b58164fa771977868503b0abac3 ]
Global Advertising, enabled with MGMT_OP_SET_ADVERTISING, uses instance 0 and with extended advertising it has its own advertising set, but instances were still being treated as if they shared the same set:
- Add Advertising and Add Extended Advertising Data would return success without ever enabling the instance.
- Removing the last instance would disable all advertising sets, stopping Global Advertising while leaving its setting enabled.
- Disabling Global Advertising would disable all sets, including active instances.
Fix this by only overriding instances that share the advertising set of Global Advertising, and by tracking HCI_LE_ADV_0 rather than HCI_LE_ADV to determine the state of Global Advertising.
--- include/net/bluetooth/hci_sync.h | 1 + net/bluetooth/hci_event.c | 11 ++++- net/bluetooth/hci_sync.c | 2 +- net/bluetooth/mgmt.c | 83 +++++++++++++++++++++++++++----- 4 files changed, 83 insertions(+), 14 deletions(-)
include/net/bluetooth/hci_sync.h +1 -0
@@ -122,6 +122,7 @@ int hci_disable_per_advertising_sync(struct hci_dev *hdev, u8 instance);int hci_remove_advertising_sync (struct hci_dev *hdev,struct sock *sk,u8 instance,bool force);int hci_disable_advertising_sync (struct hci_dev *hdev); +int hci_disable_ext_adv_legacy_instance_sync (struct hci_dev *hdev);int hci_clear_adv_instance_sync (struct hci_dev *hdev,struct sock *sk,u8 instance,bool force);int hci_update_passive_scan_sync (struct hci_dev *hdev);
net/bluetooth/hci_event.c +9 -2
@@ -1664,15 +1664,22 @@ static u8 hci_cc_le_set_ext_adv_enable(struct hci_dev *hdev, void *data,hci_dev_clear_flag (hdev,HCI_LE_ADV_0 );/* If just one instance was disabled check if there are -* any other instance enabled before clearing HCI_LE_ADV +* any other instance enabled, including instance 0, +* before clearing HCI_LE_ADV */ +if (hci_dev_test_flag (hdev,HCI_LE_ADV_0 )) + goto unlock; +list_for_each_entry_safe (adv, n, &hdev->adv_instances, list) {if (adv->enabled) goto unlock; } }else { -/* All instances shall be considered disabled */ +/* All instances shall be considered disabled, except +* instance 0 whose state is preserved so it can be +* re-enabled by hci_resume_advertising_sync. +*/ list_for_each_entry_safe (adv, n, &hdev->adv_instances, list) adv->enabled = false;
net/bluetooth/hci_sync.c +1 -1
@@ -1158,7 +1158,7 @@ int hci_update_random_address_sync(struct hci_dev *hdev, bool require_privacy,return 0 ; } -static int hci_disable_ext_adv_legacy_instance_sync (struct hci_dev *hdev) +int hci_disable_ext_adv_legacy_instance_sync (struct hci_dev *hdev) {struct hci_cp_le_set_ext_adv_enable *cp;struct hci_cp_ext_adv_set *set;
net/bluetooth/mgmt.c +72 -11
135 lines not on this page · raw message
Signature · 1 line
2.53.0