6.4.4-rc1 review
Subsystems (13)
Greg Kroah-Hartman
maintainerPATCH 500/800 modpost: remove broken calculation of exception_table_entry size
In reply to Greg Kroah-HartmanFrom: Masahiro Yamada <[email protected]>
[ Upstream commit d0acc76a49aa917c1a455d11d32d34a01e8b2835 ]
find_extable_entry_size() is completely broken. It has awesome comments about how to calculate sizeof(struct exception_table_entry).
It was based on these assumptions:
- struct exception_table_entry has two fields
- both of the fields have the same size
Then, we came up with this equation:
(offset of the second field) * 2 == (size of struct)
It was true for all architectures when commit 52dc0595d540 ("modpost:
handle relocations mismatch in __ex_table.") was applied.
Our mathematics broke when commit 548acf19234d ("x86/mm: Expand the exception table logic to allow new handling options") introduced the third field.
Now, the definition of exception_table_entry is highly arch-dependent.
For x86, sizeof(struct exception_table_entry) is apparently 12, but find_extable_entry_size() sets extable_entry_size to 8.
I could fix it, but I do not see much value in this code.
extable_entry_size is used just for selecting a slightly different error message.
If the first field ("insn") references to a non-executable section,
The relocation at %s+0x%lx references section "%s" which is not executable, IOW it is not possible for the kernel to fault at that address. Something is seriously wrong and should be fixed.
If the second field ("fixup") references to a non-executable section,
The relocation at %s+0x%lx references
section "%s" which is not executable, IOW
the kernel will fault if it ever tries to
jump to it. Something is seriously wrong
and should be fixed.
Merge the two error messages rather than adding even more complexity.
Change fatal() to error() to make it continue running and catch more possible errors.
--- scripts/mod/modpost.c | 60 +++---------------------------------------- 1 file changed, 3 insertions(+), 57 deletions(-)
scripts/mod/modpost.c +3 -57
@@ -1292,43 +1292,6 @@ static int is_executable_section(struct elf_info* elf, unsigned int section_indereturn ((elf->sechdrs[section_index].sh_flags &SHF_EXECINSTR ) ==SHF_EXECINSTR ); } -/* -* We rely on a gross hack in section_rel[a]() calling find_extable_entry_size() -* to know the sizeof(struct exception_table_entry) for the target architecture. -*/ -static unsigned int extable_entry_size =0 ; -static void find_extable_entry_size (const char *const sec,const Elf_Rela * r) -{ -/* -* If we're currently checking the second relocation within __ex_table, -* that relocation offset tells us the offsetof(struct -* exception_table_entry, fixup) which is equal to sizeof(struct -* exception_table_entry) divided by two. We use that to our advantage -* since there's no portable way to get that size as every architecture -* seems to go with different sized types. Not pretty but better than -* hard-coding the size for every architecture.. -*/ -if (!extable_entry_size) - extable_entry_size = r->r_offset *2 ; -} - -static inline bool is_extable_fault_address (Elf_Rela *r) -{ -/* -* extable_entry_size is only discovered after we've handled the -* _second_ relocation in __ex_table, so only abort when we're not -* handling the first reloc and extable_entry_size is zero. -*/ -if (r->r_offset && extable_entry_size ==0 ) -fatal ("extable_entry size hasn't been discovered!\n" ); - -return ((r->r_offset ==0 ) || - (r->r_offset % extable_entry_size ==0 )); -} - -#define is_second_extable_reloc (Start, Cur, Sec) \ - (((Cur) == (Start) + 1) && (strcmp("__ex_table", (Sec)) == 0)) - static void report_extable_warnings(const char* modname, struct elf_info* elf, const struct sectioncheck* const mismatch, Elf_Rela* r, Elf_Sym* sym,
@@ -1384,22 +1347,9 @@ static void extable_mismatch_handler(const char* modname, struct elf_info *elf,"You might get more information about where this is\n" "coming from by using scripts/check_extable.sh %s\n" , fromsec, (long)r->r_offset, tosec, modname); - else if (!is_executable_section(elf, get_secindex(elf, sym))) { -if (is_extable_fault_address (r)) -fatal ("The relocation at %s+0x%lx references\n" -"section \"%s\" which is not executable, IOW\n" -"it is not possible for the kernel to fault\n" -"at that address. Something is seriously wrong\n" -"and should be fixed.\n" , - fromsec, (long )r->r_offset, tosec); -else -fatal ("The relocation at %s+0x%lx references\n" -"section \"%s\" which is not executable, IOW\n" -"the kernel will fault if it ever tries to\n" -"jump to it. Something is seriously wrong\n" -"and should be fixed.\n" , - fromsec, (long )r->r_offset, tosec); - } + else if (!is_executable_section(elf, get_secindex(elf, sym))) + error("%s+0x%lx references non-executable section '%s'\n", + fromsec, (long)r->r_offset, tosec); } static void check_section_mismatch(const char *modname, struct elf_info *elf,
@@ -1574,8 +1524,6 @@ static void section_rela(const char *modname, struct elf_info *elf,/* Skip special sections */ if (is_shndx_special (sym->st_shndx))continue ; -if (is_second_extable_reloc (start, rela, fromsec)) -find_extable_entry_size (fromsec, &r);check_section_mismatch (modname, elf, &r, sym, fromsec); } }
@@ -1633,8 +1581,6 @@ static void section_rel(const char *modname, struct elf_info *elf,/* Skip special sections */ if (is_shndx_special (sym->st_shndx))continue ; -if (is_second_extable_reloc (start, rel, fromsec)) -find_extable_entry_size (fromsec, &r);check_section_mismatch (modname, elf, &r, sym, fromsec); } }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 501/800 crypto: nx - fix build warnings when DEBUG_FS is not enabled
In reply to Greg Kroah-HartmanFrom: Randy Dunlap <[email protected]>
[ Upstream commit b04b076fb56560b39d695ac3744db457e12278fd ]
Fix build warnings when DEBUG_FS is not enabled by using an empty do-while loop instead of a value:
In file included from ../drivers/crypto/nx/nx.c:27:../drivers/crypto/nx/nx.c: In function 'nx_register_algs':../drivers/crypto/nx/nx.h:173:33: warning: statement with no effect [-Wunused-value]
173 | #define NX_DEBUGFS_INIT(drv) (0)../drivers/crypto/nx/nx.c:573:9: note: in expansion of macro 'NX_DEBUGFS_INIT'
573 | NX_DEBUGFS_INIT(&nx_driver);../drivers/crypto/nx/nx.c: In function 'nx_remove':../drivers/crypto/nx/nx.h:174:33: warning: statement with no effect [-Wunused-value]
174 | #define NX_DEBUGFS_FINI(drv) (0)../drivers/crypto/nx/nx.c:793:17: note: in expansion of macro 'NX_DEBUGFS_FINI'
793 | NX_DEBUGFS_FINI(&nx_driver);
Also, there is no need to build nx_debugfs.o when DEBUG_FS is not enabled, so change the Makefile to accommodate that.
--- drivers/crypto/nx/Makefile | 2 +- drivers/crypto/nx/nx.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/crypto/nx/Makefile +1 -1
@@ -1,7 +1,6 @@ # SPDX-License-Identifier: GPL-2.0 obj-$(CONFIG_CRYPTO_DEV_NX_ENCRYPT) += nx-crypto.o nx-crypto-objs := nx.o \ - nx_debugfs.o \ nx-aes-cbc.o \ nx-aes-ecb.o \ nx-aes-gcm.o \
@@ -11,6 +10,7 @@ nx-crypto-objs := nx.o \ nx-sha256.o \ nx-sha512.o +nx-crypto-$(CONFIG_DEBUG_FS) += nx_debugfs.o obj-$(CONFIG_CRYPTO_DEV_NX_COMPRESS_PSERIES) += nx-compress-pseries.o nx-compress.o obj-$(CONFIG_CRYPTO_DEV_NX_COMPRESS_POWERNV) += nx-compress-powernv.o nx-compress.o nx-compress-objs := nx-842.o
drivers/crypto/nx/nx.h +2 -2
@@ -170,8 +170,8 @@ struct nx_sg *nx_walk_and_build(struct nx_sg *, unsigned int,void nx_debugfs_init (struct nx_crypto_driver *);void nx_debugfs_fini (struct nx_crypto_driver *);#else -#define NX_DEBUGFS_INIT (drv) (0) -#define NX_DEBUGFS_FINI (drv) (0) +#define NX_DEBUGFS_INIT (drv) do {} while (0) +#define NX_DEBUGFS_FINI (drv) do {} while (0)#endif #define NX_PAGE_NUM (x) ((u64)(x) & 0xfffffffffffff000ULL)
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 502/800 modpost: fix section mismatch message for R_ARM_ABS32
In reply to Greg Kroah-HartmanFrom: Masahiro Yamada <[email protected]>
[ Upstream commit b7c63520f6703a25eebb4f8138fed764fcae1c6f ]
addend_arm_rel() processes R_ARM_ABS32 in a wrong way.
Here, test code.
[test code 1]
#include <linux/init.h>
int __initdata foo;
int get_foo(void) { return foo; }If you compile it with ARM versatile_defconfig, modpost will show the symbol name, (unknown).
WARNING: modpost: vmlinux.o: section mismatch in reference: get_foo (section: .text) -> (unknown) (section: .init.data)
(You need to use GNU linker instead of LLD to reproduce it.)
If you compile it for other architectures, modpost will show the correct symbol name.
WARNING: modpost: vmlinux.o: section mismatch in reference: get_foo (section: .text) -> foo (section: .init.data)
For R_ARM_ABS32, addend_arm_rel() sets r->r_addend to a wrong value.
I just mimicked the code in arch/arm/kernel/module.c.
However, there is more difficulty for ARM.
Here, test code.
[test code 2]
#include <linux/init.h>
int __initdata foo;
int get_foo(void) { return foo; }
int __initdata bar;
int get_bar(void) { return bar; }With this commit applied, modpost will show the following messages for ARM versatile_defconfig:
WARNING: modpost: vmlinux.o: section mismatch in reference: get_foo (section: .text) -> foo (section: .init.data)
WARNING: modpost: vmlinux.o: section mismatch in reference: get_bar (section: .text) -> foo (section: .init.data)
The reference from 'get_bar' to 'foo' seems wrong.
I have no solution for this because it is true in assembly level.
In the following output, relocation at 0x1c is no longer associated with 'bar'. The two relocation entries point to the same symbol, and the offset to 'bar' is encoded in the instruction 'r0, [r3, #4]'.
Disassembly of section .text:
00000000 <get_foo>:
0: e59f3004 ldr r3, [pc, #4] @ c <get_foo+0xc>
4: e5930000 ldr r0, [r3]
8: e12fff1e bx lr
c: 00000000 .word 0x00000000 00000010 <get_bar>:
10: e59f3004 ldr r3, [pc, #4] @ 1c <get_bar+0xc>
14: e5930004 ldr r0, [r3, #4]
18: e12fff1e bx lr
1c: 00000000 .word 0x00000000 Relocation section '.rel.text' at offset 0x244 contains 2 entries:
Offset Info Type Sym.Value Sym. Name
0000000c 00000c02 R_ARM_ABS32 00000000 .init.data 0000001c 00000c02 R_ARM_ABS32 00000000 .init.data
When find_elf_symbol() gets into a situation where relsym->st_name is zero, there is no guarantee to get the symbol name as written in C.
I am keeping the current logic because it is useful in many architectures, but the symbol name is not always correct depending on the optimization. I left some comments in find_tosym().
--- scripts/mod/modpost.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
scripts/mod/modpost.c +9 -3
@@ -1150,6 +1150,10 @@ static Elf_Sym *find_elf_symbol(struct elf_info *elf, Elf64_Sword addr,if (relsym->st_name !=0 )return relsym; +/* +* Strive to find a better symbol name, but the resulting name may not +* match the symbol referenced in the original code. +*/ relsym_secindex =get_secindex (elf, relsym);for (sym = elf->symtab_start; sym < elf->symtab_stop; sym++) {if (get_secindex (elf, sym) != relsym_secindex)
@@ -1410,12 +1414,14 @@ static int addend_386_rel(struct elf_info *elf, Elf_Shdr *sechdr, Elf_Rela *r)static int addend_arm_rel (struct elf_info *elf,Elf_Shdr *sechdr,Elf_Rela *r) {unsigned int r_typ =ELF_R_TYPE (r->r_info); +Elf_Sym *sym = elf->symtab_start +ELF_R_SYM (r->r_info); +void *loc =reloc_location (elf, sechdr, r); +uint32_t inst;switch (r_typ) {case R_ARM_ABS32 : -/* From ARM ABI: (S + A) | T */ - r->r_addend = (int )(long ) - (elf->symtab_start +ELF_R_SYM (r->r_info)); + inst =TO_NATIVE (*(uint32_t *)loc); + r->r_addend = inst + sym->st_value;break ;case R_ARM_PC24 :case R_ARM_CALL :
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 503/800 modpost: fix section mismatch message for R_ARM_{PC24,CALL,JUMP24}
In reply to Greg Kroah-HartmanFrom: Masahiro Yamada <[email protected]>
[ Upstream commit 56a24b8ce6a7f9c4a21b2276a8644f6f3d8fc14d ]
addend_arm_rel() processes R_ARM_PC24, R_ARM_CALL, R_ARM_JUMP24 in a wrong way.
Here, test code.
[test code for R_ARM_JUMP24]
.section .init.text,"ax"
bar:
bx lr
.section .text,"ax"
.globl foo
foo:
b bar
[test code for R_ARM_CALL]
.section .init.text,"ax"
bar:
bx lr
.section .text,"ax"
.globl foo
foo:
push {lr}
bl bar
pop {pc}If you compile it with ARM multi_v7_defconfig, modpost will show the symbol name, (unknown).
WARNING: modpost: vmlinux.o: section mismatch in reference: foo (section: .text) -> (unknown) (section: .init.text)
(You need to use GNU linker instead of LLD to reproduce it.)
Fix the code to make modpost show the correct symbol name.
I imported (with adjustment) sign_extend32() from include/linux/bitops.h.
The '+8' is the compensation for pc-relative instruction. It is documented in "ELF for the Arm Architecture" [1].
"If the relocation is pc-relative then compensation for the PC bias (the PC value is 8 bytes ahead of the executing instruction in Arm state and 4 bytes in Thumb state) must be encoded in the relocation by the object producer."
[1]: https://github.com/ARM-software/abi-aa/blob/main/aaelf32/aaelf32.rst
--- scripts/mod/modpost.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
scripts/mod/modpost.c +12 -0
@@ -1411,12 +1411,20 @@ static int addend_386_rel(struct elf_info *elf, Elf_Shdr *sechdr, Elf_Rela *r)#define R_ARM_THM_JUMP19 51#endif +static int32_t sign_extend32 (int32_t value,int index) +{ +uint8_t shift =31 - index; + +return (int32_t )(value << shift) >> shift; +} +static int addend_arm_rel (struct elf_info *elf,Elf_Shdr *sechdr,Elf_Rela *r) {unsigned int r_typ =ELF_R_TYPE (r->r_info);Elf_Sym *sym = elf->symtab_start +ELF_R_SYM (r->r_info);void *loc =reloc_location (elf, sechdr, r);uint32_t inst; +int32_t offset;switch (r_typ) {case R_ARM_ABS32 :
@@ -1426,6 +1434,10 @@ static int addend_arm_rel(struct elf_info *elf, Elf_Shdr *sechdr, Elf_Rela *r)case R_ARM_PC24 :case R_ARM_CALL :case R_ARM_JUMP24 : + inst =TO_NATIVE (*(uint32_t *)loc); + offset =sign_extend32 ((inst &0x00ffffff ) <<2 ,25 ); + r->r_addend = offset + sym->st_value +8 ; +break ;case R_ARM_THM_CALL :case R_ARM_THM_JUMP24 :case R_ARM_THM_JUMP19 :
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 504/800 crypto: marvell/cesa - Fix type mismatch warning
In reply to Greg Kroah-HartmanFrom: Arnd Bergmann <[email protected]>
[ Upstream commit efbc7764c4446566edb76ca05e903b5905673d2e ]
Commit df8fc4e934c1 ("kbuild: Enable -fstrict-flex-arrays=3") uncovered a type mismatch in cesa 3des support that leads to a memcpy beyond the end of a structure:
In function 'fortify_memcpy_chk',
inlined from 'mv_cesa_des3_ede_setkey' at drivers/crypto/marvell/cesa/cipher.c:307:2:include/linux/fortify-string.h:583:25: error: call to '__write_overflow_field' declared with attribute warning: detected write beyond size of field (1st parameter); maybe use struct_group()? [-Werror=attribute-warning]
583 | __write_overflow_field(p_size_field, size);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~This is probably harmless as the actual data that is copied has the correct type, but clearly worth fixing nonetheless.
--- drivers/crypto/marvell/cesa/cipher.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/crypto/marvell/cesa/cipher.c +1 -1
@@ -297,7 +297,7 @@ static int mv_cesa_des_setkey(struct crypto_skcipher *cipher, const u8 *key,static int mv_cesa_des3_ede_setkey (struct crypto_skcipher *cipher,const u8 *key,unsigned int len) { -struct mv_cesa_des_ctx *ctx =crypto_skcipher_ctx (cipher); +struct mv_cesa_des3_ctx *ctx =crypto_skcipher_ctx (cipher);int err; err =verify_skcipher_des3_key (cipher, key);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 505/800 crypto: jitter - correct health test during initialization
In reply to Greg Kroah-HartmanFrom: Stephan Müller <[email protected]>
[ Upstream commit d23659769ad1bf2cbafaa0efcbae20ef1a74f77e ]
With the update of the permanent and intermittent health errors, the actual indicator for the health test indicates a potential error only for the one offending time stamp gathered in the current iteration round. The next iteration round will "overwrite" the health test result.
Thus, the entropy collection loop in jent_gen_entropy checks for the health test failure upon each loop iteration. However, the initialization operation checked for the APT health test once for an APT window which implies it would not catch most errors.
Thus, the check for all health errors is now invoked unconditionally during each loop iteration for the startup test.
With the change, the error JENT_ERCT becomes unused as all health errors are only reported with the JENT_HEALTH return code. This allows the removal of the error indicator.
)
--- crypto/jitterentropy.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
crypto/jitterentropy.c +3 -6
@@ -117,7 +117,6 @@ struct rand_data {* zero). */ #define JENT_ESTUCK 8/* Too many stuck results during init. */ #define JENT_EHEALTH 9/* Health test failed during initialization */ -#define JENT_ERCT 10/* RCT failed during initialization */ /* * The output n bits can receive more than n bits of min entropy, of course,
@@ -762,14 +761,12 @@ int jent_entropy_init(void)if ((nonstuck %JENT_APT_WINDOW_SIZE ) ==0 ) {jent_apt_reset (&ec, delta &JENT_APT_WORD_MASK ); -if (jent_health_failure (&ec)) -return JENT_EHEALTH ; } } -/* Validate RCT */ -if (jent_rct_failure (&ec)) -return JENT_ERCT ; +/* Validate health test result */ +if (jent_health_failure (&ec)) +return JENT_EHEALTH ;/* test whether we have an increasing timer */ if (!(time2 > time))
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 506/800 dt-bindings: qcom-qce: Fix compatible combinations for SM8150 and IPQ4019 SoCs
In reply to Greg Kroah-HartmanFrom: Bhupesh Sharma <[email protected]>
[ Upstream commit b3b266fa15552ba342831653f2b8b02c91451e73 ]
Currently the compatible list available in 'qce' dt-bindings does not support SM8150 and IPQ4019 SoCs directly which may lead to potential 'dtbs_check' error(s).
Fix the same.
--- Documentation/devicetree/bindings/crypto/qcom-qce.yaml | 6 ++++++ 1 file changed, 6 insertions(+)
Documentation/devicetree/bindings/crypto/qcom-qce.yaml +6 -0
@@ -24,6 +24,12 @@ properties: deprecated: true description: Kept only for ABI backward compatibility + - items: + - enum: + - qcom,ipq4019-qce + - qcom,sm8150-qce + - const: qcom,qce + - items: - enum: - qcom,ipq6018-qce
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 507/800 scripts/mksysmap: Fix badly escaped $
In reply to Greg Kroah-HartmanFrom: Pierre-Clément Tosi <[email protected]>
[ Upstream commit ec336aa83162fe0f3d554baed2d4e2589b69ec6e ]
The backslash characters escaping '$' in the command to sed (intended to prevent it from interpreting '$' as "end-of-line") are currently being consumed by the Shell (where they mean that sh should not evaluate what follows '$' as a variable name). This means that
sed -e "/ \$/d"
executes the script
/ $/d
instead of the intended
/ \$/d
So escape twice in mksysmap any '$' that actually needs to reach sed escaped so that the backslash survives the Shell.
--- scripts/mksysmap | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
scripts/mksysmap +2 -2
@@ -32,7 +32,7 @@ ${NM} -n ${1} | sed >${2} -e " # (do not forget a space before each pattern) # local symbols for ARM, MIPS, etc. -/ \$/d +/ \\$/d # local labels, .LBB, .Ltmpxxx, .L__unnamed_xx, .LASANPC, etc. / \.L/d
@@ -41,7 +41,7 @@ ${NM} -n ${1} | sed >${2} -e " / __efistub_/d # arm64 local symbols in non-VHE KVM namespace -/ __kvm_nvhe_\$/d +/ __kvm_nvhe_\\$/d / __kvm_nvhe_\.L/d # arm64 lld
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 508/800 modpost: fix off by one in is_executable_section()
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit 3a3f1e573a105328a2cca45a7cfbebabbf5e3192 ]
The > comparison should be >= to prevent an out of bounds array access.
--- scripts/mod/modpost.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/mod/modpost.c +1 -1
@@ -1290,7 +1290,7 @@ static void default_mismatch_handler(const char *modname, struct elf_info *elf,static int is_executable_section (struct elf_info * elf,unsigned int section_index) { -if (section_index > elf->num_sections) +if (section_index >= elf->num_sections)fatal ("section_index is outside elf->num_sections!\n" );return ((elf->sechdrs[section_index].sh_flags &SHF_EXECINSTR ) ==SHF_EXECINSTR );
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 509/800 ARC: define ASM_NL and __ALIGN(_STR) outside #ifdef __ASSEMBLY__ guard
In reply to Greg Kroah-HartmanFrom: Masahiro Yamada <[email protected]>
[ Upstream commit 92e2921eeafdfca9acd9b83f07d2b7ca099bac24 ]
ASM_NL is useful not only in *.S files but also in .c files for using inline assembler in C code.
On ARC, however, ASM_NL is evaluated inconsistently. It is expanded to a backquote (`) in *.S files, but a semicolon (;) in *.c files because arch/arc/include/asm/linkage.h defines it inside #ifdef __ASSEMBLY__, so the definition for C code falls back to the default value defined in include/linux/linkage.h.
If ASM_NL is used in inline assembler in .c files, it will result in wrong assembly code because a semicolon is not an instruction separator, but the start of a comment for ARC.
Move ASM_NL (also __ALIGN and __ALIGN_STR) out of the #ifdef.
--- arch/arc/include/asm/linkage.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
arch/arc/include/asm/linkage.h +4 -4
@@ -8,6 +8,10 @@#include <asm/dwarf.h> +#define ASM_NL `/* use '`' to mark new line in macro */ +#define __ALIGN .align 4 +#define __ALIGN_STR __stringify(__ALIGN) +#ifdef __ASSEMBLY__ .macro ST2 e, o, off
@@ -28,10 +32,6 @@#endif .endm -#define ASM_NL `/* use '`' to mark new line in macro */ -#define __ALIGN .align 4 -#define __ALIGN_STR __stringify(__ALIGN) - /* annotation for data we want in DCCM - if enabled in .config */ .macro ARCFP_DATA nm #ifdef CONFIG_ARC_HAS_DCCM
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 510/800 crypto: qat - unmap buffer before free for DH
In reply to Greg Kroah-HartmanFrom: Hareshx Sankar Raj <[email protected]>
[ Upstream commit eb7713f5ca97697b92f225127440d1525119b8de ]
The callback function for DH frees the memory allocated for the destination buffer before unmapping it.
This sequence is wrong.
Change the cleanup sequence to unmap the buffer before freeing it.
--- drivers/crypto/intel/qat/qat_common/qat_asym_algs.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/crypto/intel/qat/qat_common/qat_asym_algs.c +2 -3
@@ -170,15 +170,14 @@ static void qat_dh_cb(struct icp_qat_fw_pke_resp *resp) } areq->dst_len = req->ctx.dh->p_size; +dma_unmap_single (dev, req->out.dh.r, req->ctx.dh->p_size, +DMA_FROM_DEVICE );if (req->dst_align) {scatterwalk_map_and_copy (req->dst_align, areq->dst,0 , areq->dst_len,1 );kfree_sensitive (req->dst_align); } -dma_unmap_single (dev, req->out.dh.r, req->ctx.dh->p_size, -DMA_FROM_DEVICE ); -dma_unmap_single (dev, req->phy_in,sizeof (struct qat_dh_input_params ),DMA_TO_DEVICE ); dma_unmap_single(dev, req->phy_out,
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 511/800 crypto: qat - unmap buffers before free for RSA
In reply to Greg Kroah-HartmanFrom: Hareshx Sankar Raj <[email protected]>
[ Upstream commit d776b25495f2c71b9dbf1f5e53b642215ba72f3c ]
The callback function for RSA frees the memory allocated for the source and destination buffers before unmapping them.
This sequence is wrong.
Change the cleanup sequence to unmap the buffers before freeing them.
--- drivers/crypto/intel/qat/qat_common/qat_asym_algs.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/crypto/intel/qat/qat_common/qat_asym_algs.c +4 -5
@@ -520,12 +520,14 @@ static void qat_rsa_cb(struct icp_qat_fw_pke_resp *resp) err = (err ==ICP_QAT_FW_COMN_STATUS_FLAG_OK ) ?0 : -EINVAL ; -kfree_sensitive (req->src_align); -dma_unmap_single (dev, req->in.rsa.enc.m, req->ctx.rsa->key_sz,DMA_TO_DEVICE ); +kfree_sensitive (req->src_align); + areq->dst_len = req->ctx.rsa->key_sz; +dma_unmap_single (dev, req->out.rsa.enc.c, req->ctx.rsa->key_sz, +DMA_FROM_DEVICE );if (req->dst_align) {scatterwalk_map_and_copy (req->dst_align, areq->dst,0 , areq->dst_len,1 );
@@ -533,9 +535,6 @@ static void qat_rsa_cb(struct icp_qat_fw_pke_resp *resp)kfree_sensitive (req->dst_align); } -dma_unmap_single (dev, req->out.rsa.enc.c, req->ctx.rsa->key_sz, -DMA_FROM_DEVICE ); -dma_unmap_single (dev, req->phy_in,sizeof (struct qat_rsa_input_params ),DMA_TO_DEVICE ); dma_unmap_single(dev, req->phy_out,
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 512/800 NFSv4.2: fix wrong shrinker_id
In reply to Greg Kroah-HartmanFrom: Qi Zheng <[email protected]>
[ Upstream commit 7f7ab336898f281e58540ef781a8fb375acc32a9 ]
Currently, the list_lru::shrinker_id corresponding to the nfs4_xattr shrinkers is wrong:
Quoted 1 line
Quoted 1 line
Quoted 1 line
prog["nfs4_xattr_cache_lru"].shrinker_id
(int)0
Quoted 1 line
Quoted 1 line
Quoted 1 line
prog["nfs4_xattr_entry_lru"].shrinker_id
(int)0
Quoted 1 line
Quoted 1 line
Quoted 1 line
prog["nfs4_xattr_large_entry_lru"].shrinker_id
(int)0
Quoted 1 line
Quoted 1 line
Quoted 1 line
prog["nfs4_xattr_cache_shrinker"].id
(int)18
Quoted 1 line
Quoted 1 line
Quoted 1 line
prog["nfs4_xattr_entry_shrinker"].id
(int)19
Quoted 1 line
Quoted 1 line
Quoted 1 line
prog["nfs4_xattr_large_entry_shrinker"].id
(int)20
This is not what we expect, which will cause these shrinkers not to be found in shrink_slab_memcg().
We should assign shrinker::id before calling list_lru_init_memcg(), so that the corresponding list_lru::shrinker_id will be assigned the correct value like below:
Quoted 1 line
Quoted 1 line
Quoted 1 line
prog["nfs4_xattr_cache_lru"].shrinker_id
(int)16
Quoted 1 line
Quoted 1 line
Quoted 1 line
prog["nfs4_xattr_entry_lru"].shrinker_id
(int)17
Quoted 1 line
Quoted 1 line
Quoted 1 line
prog["nfs4_xattr_large_entry_lru"].shrinker_id
(int)18
Quoted 1 line
Quoted 1 line
Quoted 1 line
prog["nfs4_xattr_cache_shrinker"].id
(int)16
Quoted 1 line
Quoted 1 line
Quoted 1 line
prog["nfs4_xattr_entry_shrinker"].id
(int)17
Quoted 1 line
Quoted 1 line
Quoted 1 line
prog["nfs4_xattr_large_entry_shrinker"].id
(int)18
So just do it.
--- fs/nfs/nfs42xattr.c | 79 +++++++++++++++++++++++++-------------------- 1 file changed, 44 insertions(+), 35 deletions(-)
fs/nfs/nfs42xattr.c +44 -35
@@ -991,6 +991,29 @@ static void nfs4_xattr_cache_init_once(void *p)INIT_LIST_HEAD (&cache->dispose); } +static int nfs4_xattr_shrinker_init (struct shrinker *shrinker, +struct list_lru *lru,const char *name) +{ +int ret =0 ; + + ret =register_shrinker (shrinker, name); +if (ret) +return ret; + + ret =list_lru_init_memcg (lru, shrinker); +if (ret) +unregister_shrinker (shrinker); + +return ret; +} + +static void nfs4_xattr_shrinker_destroy (struct shrinker *shrinker, +struct list_lru *lru) +{ +unregister_shrinker (shrinker); +list_lru_destroy (lru); +} +int __init nfs4_xattr_cache_init (void ) {int ret =0 ;
@@ -1002,44 +1025,30 @@ int __init nfs4_xattr_cache_init(void)if (nfs4_xattr_cache_cachep ==NULL )return -ENOMEM ; - ret =list_lru_init_memcg (&nfs4_xattr_large_entry_lru, - &nfs4_xattr_large_entry_shrinker); -if (ret) - goto out4; - - ret =list_lru_init_memcg (&nfs4_xattr_entry_lru, - &nfs4_xattr_entry_shrinker); -if (ret) - goto out3; - - ret =list_lru_init_memcg (&nfs4_xattr_cache_lru, - &nfs4_xattr_cache_shrinker); -if (ret) - goto out2; - - ret =register_shrinker (&nfs4_xattr_cache_shrinker,"nfs-xattr_cache" ); + ret =nfs4_xattr_shrinker_init (&nfs4_xattr_cache_shrinker, + &nfs4_xattr_cache_lru, +"nfs-xattr_cache" );if (ret) goto out1; - ret =register_shrinker (&nfs4_xattr_entry_shrinker,"nfs-xattr_entry" ); + ret =nfs4_xattr_shrinker_init (&nfs4_xattr_entry_shrinker, + &nfs4_xattr_entry_lru, +"nfs-xattr_entry" );if (ret) - goto out; + goto out2; - ret =register_shrinker (&nfs4_xattr_large_entry_shrinker, -"nfs-xattr_large_entry" ); + ret =nfs4_xattr_shrinker_init (&nfs4_xattr_large_entry_shrinker, + &nfs4_xattr_large_entry_lru, +"nfs-xattr_large_entry" );if (!ret)return 0 ; -unregister_shrinker (&nfs4_xattr_entry_shrinker); -out: -unregister_shrinker (&nfs4_xattr_cache_shrinker); -out1: -list_lru_destroy (&nfs4_xattr_cache_lru); +nfs4_xattr_shrinker_destroy (&nfs4_xattr_entry_shrinker, + &nfs4_xattr_entry_lru); out2: -list_lru_destroy (&nfs4_xattr_entry_lru); -out3: -list_lru_destroy (&nfs4_xattr_large_entry_lru); -out4: +nfs4_xattr_shrinker_destroy (&nfs4_xattr_cache_shrinker, + &nfs4_xattr_cache_lru); +out1:kmem_cache_destroy (nfs4_xattr_cache_cachep);return ret;
@@ -1047,11 +1056,11 @@ int __init nfs4_xattr_cache_init(void)void nfs4_xattr_cache_exit (void ) { -unregister_shrinker (&nfs4_xattr_large_entry_shrinker); -unregister_shrinker (&nfs4_xattr_entry_shrinker); -unregister_shrinker (&nfs4_xattr_cache_shrinker); -list_lru_destroy (&nfs4_xattr_large_entry_lru); -list_lru_destroy (&nfs4_xattr_entry_lru); -list_lru_destroy (&nfs4_xattr_cache_lru); +nfs4_xattr_shrinker_destroy (&nfs4_xattr_large_entry_shrinker, + &nfs4_xattr_large_entry_lru); +nfs4_xattr_shrinker_destroy (&nfs4_xattr_entry_shrinker, + &nfs4_xattr_entry_lru); +nfs4_xattr_shrinker_destroy (&nfs4_xattr_cache_shrinker, + &nfs4_xattr_cache_lru);kmem_cache_destroy (nfs4_xattr_cache_cachep); }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 513/800 NFSv4.1: freeze the session table upon receiving NFS4ERR_BADSESSION
In reply to Greg Kroah-HartmanFrom: Olga Kornievskaia <[email protected]>
[ Upstream commit c907e72f58ed979a24a9fdcadfbc447c51d5e509 ]
When the client received NFS4ERR_BADSESSION, it schedules recovery and start the state manager thread which in turn freezes the session table and does not allow for any new requests to use the no-longer valid session. However, it is possible that before the state manager thread runs, a new operation would use the released slot that received BADSESSION and was therefore not updated its sequence number. Such re-use of the slot can lead the application errors.
--- fs/nfs/nfs4proc.c | 1 + 1 file changed, 1 insertion(+)
fs/nfs/nfs4proc.c +1 -0
@@ -921,6 +921,7 @@ static int nfs41_sequence_process(struct rpc_task *task, out_noaction:return ret; session_recover: +set_bit (NFS4_SLOT_TBL_DRAINING , &session->fc_slot_table.slot_tbl_state);nfs4_schedule_session_recovery (session, status);dprintk ("%s ERROR: %d Reset session\n" , __func__, status);nfs41_sequence_free_slot (res);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 514/800 SMB3: Do not send lease break acknowledgment if all file handles have been closed
In reply to Greg Kroah-HartmanFrom: Bharath SM <[email protected]>
[ Upstream commit da787d5b74983f7525d1eb4b9c0b4aff2821511a ]
In case if all existing file handles are deferred handles and if all of them gets closed due to handle lease break then we dont need to send lease break acknowledgment to server, because last handle close will be considered as lease break ack.
After closing deferred handels, we check for openfile list of inode, if its empty then we skip sending lease break ack.
--- fs/smb/client/file.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-)
fs/smb/client/file.c +12 -13
@@ -4936,20 +4936,19 @@ void cifs_oplock_break(struct work_struct *work)_cifsFileInfo_put (cfile, false/* do not wait for ourself */ , false);/* -* releasing stale oplock after recent reconnect of smb session using -* a now incorrect file handle is not a data integrity issue but do -* not bother sending an oplock release if session to server still is -* disconnected since oplock already released by the server +* MS-SMB2 3.2.5.19.1 and 3.2.5.19.2 (and MS-CIFS 3.2.5.42) do not require +* an acknowledgment to be sent when the file has already been closed. +* check for server null, since can race with kill_sb calling tree disconnect. */ -if (!oplock_break_cancelled) { -/* check for server null since can race with kill_sb calling tree disconnect */ -if (tcon->ses && tcon->ses->server) { - rc = tcon->ses->server->ops->oplock_response (tcon, persistent_fid, - volatile_fid, net_fid, cinode); -cifs_dbg (FYI ,"Oplock release rc = %d\n" , rc); - }else -pr_warn_once ("lease break not sent for unmounted share\n" ); - } +spin_lock (&cinode->open_file_lock); +if (tcon->ses && tcon->ses->server && !oplock_break_cancelled && + !list_empty (&cinode->openFileList)) { +spin_unlock (&cinode->open_file_lock); + rc = tcon->ses->server->ops->oplock_response (tcon, persistent_fid, + volatile_fid, net_fid, cinode); +cifs_dbg (FYI ,"Oplock release rc = %d\n" , rc); + }else +spin_unlock (&cinode->open_file_lock);cifs_done_oplock_break (cinode); }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 515/800 dax: Fix dax_mapping_release() use after free
In reply to Greg Kroah-HartmanFrom: Dan Williams <[email protected]>
[ Upstream commit 6d24b170a9db0456f577b1ab01226a2254c016a8 ]
A CONFIG_DEBUG_KOBJECT_RELEASE test of removing a device-dax region provider (like modprobe -r dax_hmem) yields:
kobject: 'mapping0' (ffff93eb460e8800): kobject_release, parent 0000000000000000 (delayed 2000) [..]
DEBUG_LOCKS_WARN_ON(1)
WARNING: CPU: 23 PID: 282 at kernel/locking/lockdep.c:232 __lock_acquire+0x9fc/0x2260 [..] RIP: 0010:__lock_acquire+0x9fc/0x2260 [..] Call Trace: <TASK> [..] lock_acquire+0xd4/0x2c0 ? ida_free+0x62/0x130 _raw_spin_lock_irqsave+0x47/0x70 ? ida_free+0x62/0x130 ida_free+0x62/0x130 dax_mapping_release+0x1f/0x30 device_release+0x36/0x90 kobject_delayed_cleanup+0x46/0x150
Due to attempting ida_free() on an ida object that has already been freed. Devices typically only hold a reference on their parent while registered. If a child needs a parent object to complete its release it needs to hold a reference that it drops from its release callback. Arrange for a dax_mapping to pin its parent dev_dax instance until dax_mapping_release().
--- drivers/dax/bus.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/dax/bus.c +4 -1
@@ -635,10 +635,12 @@ EXPORT_SYMBOL_GPL(alloc_dax_region);static void dax_mapping_release (struct device *dev) {struct dax_mapping *mapping =to_dax_mapping (dev); -struct dev_dax *dev_dax =to_dev_dax (dev->parent); +struct device *parent = dev->parent; +struct dev_dax *dev_dax =to_dev_dax (parent);ida_free (&dev_dax->ida, mapping->id);kfree (mapping); +put_device (parent); }static void unregister_dax_mapping (void *data)
@@ -778,6 +780,7 @@ static int devm_register_dax_mapping(struct dev_dax *dev_dax, int range_id) dev = &mapping->dev;device_initialize (dev); dev->parent = &dev_dax->dev; +get_device (dev->parent); dev->type = &dax_mapping_type;dev_set_name (dev,"mapping%d" , mapping->id); rc =device_add (dev);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 516/800 dax: Introduce alloc_dev_dax_id()
In reply to Greg Kroah-HartmanFrom: Dan Williams <[email protected]>
[ Upstream commit 70aab281e18c68a1284bc387de127c2fc0bed3f8 ]
The reference counting of dax_region objects is needlessly complicated, has lead to confusion [1], and has hidden a bug [2]. Towards cleaning up that mess introduce alloc_dev_dax_id() to minimize the holding of a dax_region reference to only what dev_dax_release() needs, the dax_region->ida.
Part of the reason for the mess was the design to dereference a dax_region in all cases in free_dev_dax_id() even if the id was statically assigned by the upper level dax_region driver. Remove the need to call "is_static(dax_region)" by tracking whether the id is dynamic directly in the dev_dax instance itself.
With that flag the dax_region pinning and release per dev_dax instance can move to alloc_dev_dax_id() and free_dev_dax_id() respectively.
A follow-on cleanup address the unnecessary references in the dax_region setup and drivers.
--- drivers/dax/bus.c | 56 ++++++++++++++++++++++++--------------- drivers/dax/dax-private.h | 4 ++- 2 files changed, 37 insertions(+), 23 deletions(-)
drivers/dax/bus.c +34 -22
@@ -446,18 +446,34 @@ static void unregister_dev_dax(void *dev)put_device (dev); } +static void dax_region_free (struct kref *kref) +{ +struct dax_region *dax_region; + + dax_region = container_of(kref, struct dax_region, kref); +kfree (dax_region); +} + +void dax_region_put (struct dax_region *dax_region) +{ +kref_put (&dax_region->kref, dax_region_free); +} +EXPORT_SYMBOL_GPL (dax_region_put); +/* a return value >= 0 indicates this invocation invalidated the id */ static int __free_dev_dax_id (struct dev_dax *dev_dax) { -struct dax_region *dax_region = dev_dax->region;struct device *dev = &dev_dax->dev; +struct dax_region *dax_region;int rc = dev_dax->id;device_lock_assert (dev); -if (is_static (dax_region) || dev_dax->id <0 ) +if (!dev_dax->dyn_id || dev_dax->id <0 )return -1 ; + dax_region = dev_dax->region;ida_free (&dax_region->ida, dev_dax->id); +dax_region_put (dax_region); dev_dax->id =-1 ;return rc; }
@@ -473,6 +489,20 @@ static int free_dev_dax_id(struct dev_dax *dev_dax)return rc; } +static int alloc_dev_dax_id (struct dev_dax *dev_dax) +{ +struct dax_region *dax_region = dev_dax->region; +int id; + + id =ida_alloc (&dax_region->ida,GFP_KERNEL ); +if (id <0 ) +return id; +kref_get (&dax_region->kref); + dev_dax->dyn_id = true; + dev_dax->id = id; +return id; +} +static ssize_t delete_store (struct device *dev,struct device_attribute *attr,const char *buf,size_t len) {
@@ -560,20 +590,6 @@ static const struct attribute_group *dax_region_attribute_groups[] = { NULL, }; -static void dax_region_free (struct kref *kref) -{ -struct dax_region *dax_region; - - dax_region = container_of(kref, struct dax_region, kref); -kfree (dax_region); -} - -void dax_region_put (struct dax_region *dax_region) -{ -kref_put (&dax_region->kref, dax_region_free); -} -EXPORT_SYMBOL_GPL (dax_region_put); -static void dax_region_unregister (void *region) {struct dax_region *dax_region = region;
@@ -1298,12 +1314,10 @@ static const struct attribute_group *dax_attribute_groups[] = {static void dev_dax_release (struct device *dev) {struct dev_dax *dev_dax =to_dev_dax (dev); -struct dax_region *dax_region = dev_dax->region;struct dax_device *dax_dev = dev_dax->dax_dev;put_dax (dax_dev);free_dev_dax_id (dev_dax); -dax_region_put (dax_region);kfree (dev_dax->pgmap);kfree (dev_dax); }
@@ -1327,6 +1341,7 @@ struct dev_dax *devm_create_dev_dax(struct dev_dax_data *data)if (!dev_dax)return ERR_PTR (-ENOMEM ); + dev_dax->region = dax_region;if (is_static (dax_region)) {if (dev_WARN_ONCE (parent, data->id <0 ,"dynamic id specified to static region\n" )) {
@@ -1342,13 +1357,11 @@ struct dev_dax *devm_create_dev_dax(struct dev_dax_data *data) goto err_id; } - rc =ida_alloc (&dax_region->ida,GFP_KERNEL ); + rc =alloc_dev_dax_id (dev_dax);if (rc <0 ) goto err_id; - dev_dax->id = rc; } - dev_dax->region = dax_region; dev = &dev_dax->dev;device_initialize (dev);dev_set_name (dev,"dax%d.%d" , dax_region->id, dev_dax->id);
@@ -1389,7 +1402,6 @@ struct dev_dax *devm_create_dev_dax(struct dev_dax_data *data) dev_dax->target_node = dax_region->target_node; dev_dax->align = dax_region->align;ida_init (&dev_dax->ida); -kref_get (&dax_region->kref); inode =dax_inode (dax_dev); dev->devt = inode->i_rdev;
drivers/dax/dax-private.h +3 -1
@@ -52,7 +52,8 @@ struct dax_mapping {* @region - parent region * @dax_dev - core dax functionality * @target_node: effective numa node if dev_dax memory range is onlined -* @id: ida allocated id +* @dyn_id: is this a dynamic or statically created instance +* @id: ida allocated id when the dax_region is not static * @ida: mapping id allocator * @dev - device core * @pgmap - pgmap for memmap setup / lifetime (driver owned)
@@ -64,6 +65,7 @@ struct dev_dax {struct dax_device *dax_dev;unsigned int align;int target_node; +bool dyn_id;int id;struct ida ida;struct device dev;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 517/800 dax/kmem: Pass valid argument to memory_group_register_static
In reply to Greg Kroah-HartmanFrom: Tarun Sahu <[email protected]>
[ Upstream commit 46e66dab8565f742374e9cc4ff7d35f344d774e2 ]
memory_group_register_static takes maximum number of pages as the argument while dev_dax_kmem_probe passes total_len (in bytes) as the argument.
IIUC, I don't see any crash/panic impact as such. As, memory_group_register_static just set the max_pages limit which is used in auto_movable_zone_for_pfn to determine the zone.
which might cause these condition to behave differently,
This will be true always so jump will happen to kernel_zone
...
if (!auto_movable_can_online_movable(NUMA_NO_NODE, group, nr_pages))
goto kernel_zone;
...
kernel_zone:
return default_kernel_zone_for_pfn(nid, pfn, nr_pages);Here, In below, zone_intersects compare range will be larger as nr_pages will be higher (derived from total_len passed in dev_dax_kmem_probe).
...
static struct zone *default_kernel_zone_for_pfn(int nid, unsigned long start_pfn,
unsigned long nr_pages)
{
struct pglist_data *pgdat = NODE_DATA(nid);
int zid;
for (zid = 0; zid < ZONE_NORMAL; zid++) {
struct zone *zone = &pgdat->node_zones[zid];
if (zone_intersects(zone, start_pfn, nr_pages))
return zone;
}
return &pgdat->node_zones[ZONE_NORMAL];
}Incorrect zone will be returned here, which in later time might cause bigger problem.
--- drivers/dax/kmem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dax/kmem.c +1 -1
@@ -99,7 +99,7 @@ static int dev_dax_kmem_probe(struct dev_dax *dev_dax)if (!data->res_name) goto err_res_name; - rc =memory_group_register_static (numa_node, total_len); + rc =memory_group_register_static (numa_node,PFN_UP (total_len));if (rc <0 ) goto err_reg_mgid; data->mgid = rc;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 518/800 hwrng: st - keep clock enabled while hwrng is registered
In reply to Greg Kroah-HartmanFrom: Martin Kaiser <[email protected]>
[ Upstream commit 501e197a02d4aef157f53ba3a0b9049c3e52fedc ]
The st-rng driver uses devres to register itself with the hwrng core, the driver will be unregistered from hwrng when its device goes out of scope. This happens after the driver's remove function is called.
However, st-rng's clock is disabled in the remove function. There's a short timeframe where st-rng is still registered with the hwrng core although its clock is disabled. I suppose the clock must be active to access the hardware and serve requests from the hwrng core.
Switch to devm_clk_get_enabled and let devres disable the clock and unregister the hwrng. This avoids the race condition.
--- drivers/char/hw_random/st-rng.c | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-)
drivers/char/hw_random/st-rng.c +1 -20
@@ -42,7 +42,6 @@struct st_rng_data {void __iomem *base; -struct clk *clk;struct hwrng ops; };
@@ -85,26 +84,18 @@ static int st_rng_probe(struct platform_device *pdev)if (IS_ERR (base))return PTR_ERR (base); - clk =devm_clk_get (&pdev->dev,NULL ); + clk =devm_clk_get_enabled (&pdev->dev,NULL );if (IS_ERR (clk))return PTR_ERR (clk); - ret =clk_prepare_enable (clk); -if (ret) -return ret; - ddata->ops.priv = (unsigned long )ddata; ddata->ops.read = st_rng_read; ddata->ops.name = pdev->name; ddata->base = base; - ddata->clk = clk; - -dev_set_drvdata (&pdev->dev, ddata); ret =devm_hwrng_register (&pdev->dev, &ddata->ops);if (ret) {dev_err (&pdev->dev,"Failed to register HW RNG\n" ); -clk_disable_unprepare (clk);return ret; }
@@ -113,15 +104,6 @@ static int st_rng_probe(struct platform_device *pdev)return 0 ; } -static int st_rng_remove (struct platform_device *pdev) -{ -struct st_rng_data *ddata =dev_get_drvdata (&pdev->dev); - -clk_disable_unprepare (ddata->clk); - -return 0 ; -} -static const struct of_device_id st_rng_match[]__maybe_unused = { { .compatible ="st,rng" }, {},
@@ -134,7 +116,6 @@ static struct platform_driver st_rng_driver = { .of_match_table = of_match_ptr(st_rng_match), }, .probe = st_rng_probe, - .remove = st_rng_remove };module_platform_driver (st_rng_driver);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 519/800 ALSA: hda/realtek: Enable mute/micmute LEDs and limit mic boost on EliteBook
In reply to Greg Kroah-HartmanFrom: Andy Chi <[email protected]>
commit e94f1f96f108ba96c0ed8bf3fbdd8ee6a6703880 upstream.
On HP EliteBook 835/845/845W G10, the audio LEDs can be enabled by ALC285_FIXUP_HP_MUTE_LED. So use it accordingly.
--- sound/pci/hda/patch_realtek.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
sound/pci/hda/patch_realtek.c +3 -3
@@ -9490,9 +9490,9 @@ static const struct snd_pci_quirk alc269SND_PCI_QUIRK (0x103c ,0x8b63 ,"HP Elite Dragonfly 13.5 inch G4" ,ALC245_FIXUP_CS35L41_SPI_4_HP_GPIO_LED ),SND_PCI_QUIRK (0x103c ,0x8b65 ,"HP ProBook 455 15.6 inch G10 Notebook PC" ,ALC236_FIXUP_HP_MUTE_LED_MICMUTE_VREF ),SND_PCI_QUIRK (0x103c ,0x8b66 ,"HP" ,ALC236_FIXUP_HP_MUTE_LED_MICMUTE_VREF ), -SND_PCI_QUIRK (0x103c ,0x8b70 ,"HP EliteBook 835 G10" ,ALC287_FIXUP_CS35L41_I2C_2 ), -SND_PCI_QUIRK (0x103c ,0x8b72 ,"HP EliteBook 845 G10" ,ALC287_FIXUP_CS35L41_I2C_2 ), -SND_PCI_QUIRK (0x103c ,0x8b74 ,"HP EliteBook 845W G10" ,ALC287_FIXUP_CS35L41_I2C_2 ), +SND_PCI_QUIRK (0x103c ,0x8b70 ,"HP EliteBook 835 G10" ,ALC287_FIXUP_CS35L41_I2C_2_HP_GPIO_LED ), +SND_PCI_QUIRK (0x103c ,0x8b72 ,"HP EliteBook 845 G10" ,ALC287_FIXUP_CS35L41_I2C_2_HP_GPIO_LED ), +SND_PCI_QUIRK (0x103c ,0x8b74 ,"HP EliteBook 845W G10" ,ALC287_FIXUP_CS35L41_I2C_2_HP_GPIO_LED ),SND_PCI_QUIRK (0x103c ,0x8b77 ,"HP ElieBook 865 G10" ,ALC287_FIXUP_CS35L41_I2C_2 ),SND_PCI_QUIRK (0x103c ,0x8b7a ,"HP" ,ALC236_FIXUP_HP_GPIO_LED ), SND_PCI_QUIRK(0x103c, 0x8b7d, "HP", ALC236_FIXUP_HP_GPIO_LED),
Greg Kroah-Hartman
maintainerPATCH 520/800 ALSA: hda/realtek: Add quirk for Clevo NPx0SNx
In reply to Greg Kroah-HartmanFrom: Werner Sembach <[email protected]>
commit 22065e4214c1196b54fc164892c2e193a743caf3 upstream.
This applies a SND_PCI_QUIRK(...) to the Clevo NPx0SNx barebones fixing the microphone not being detected on the headset combo port.
--- sound/pci/hda/patch_realtek.c | 1 + 1 file changed, 1 insertion(+)
sound/pci/hda/patch_realtek.c +1 -0
@@ -9682,6 +9682,7 @@ static const struct snd_pci_quirk alc269SND_PCI_QUIRK (0x1558 ,0x971d ,"Clevo N970T[CDF]" ,ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE ),SND_PCI_QUIRK (0x1558 ,0xa500 ,"Clevo NL5[03]RU" ,ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE ),SND_PCI_QUIRK (0x1558 ,0xa600 ,"Clevo NL50NU" ,ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE ), +SND_PCI_QUIRK (0x1558 ,0xa650 ,"Clevo NP[567]0SN[CD]" ,ALC256_FIXUP_SYSTEM76_MIC_NO_PRESENCE ),SND_PCI_QUIRK (0x1558 ,0xa671 ,"Clevo NP70SN[CDE]" ,ALC256_FIXUP_SYSTEM76_MIC_NO_PRESENCE ),SND_PCI_QUIRK (0x1558 ,0xb018 ,"Clevo NP50D[BE]" ,ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE ), SND_PCI_QUIRK(0x1558, 0xb019, "Clevo NH77D[BE]Q", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
Greg Kroah-Hartman
maintainerPATCH 521/800 ALSA: jack: Fix mutex call in snd_jack_report()
In reply to Greg Kroah-HartmanFrom: Takashi Iwai <[email protected]>
commit 89dbb335cb6a627a4067bc42caa09c8bc3326d40 upstream.
snd_jack_report() is supposed to be callable from an IRQ context, too, and it's indeed used in that way from virtsnd driver. The fix for input_dev race in commit 1b6a6fc5280e ("ALSA: jack: Access input_dev under mutex"), however, introduced a mutex lock in snd_jack_report(), and this resulted in a potential sleep-in-atomic.
For addressing that problem, this patch changes the relevant code to use the object get/put and removes the mutex usage. That is, snd_jack_report(), it takes input_get_device() and leaves with input_put_device() for assuring the input_dev being assigned.
Although the whole mutex could be reduced, we keep it because it can be still a protection for potential races between creation and deletion.
--- sound/core/jack.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)
sound/core/jack.c +7 -8
@@ -654,6 +654,7 @@ void snd_jack_report(struct snd_jack *jastruct snd_jack_kctl *jack_kctl;unsigned int mask_bits =0 ;#ifdef CONFIG_SND_JACK_INPUT_DEV +struct input_dev *idev;int i;#endif
@@ -670,17 +671,15 @@ void snd_jack_report(struct snd_jack *ja status & jack_kctl->mask_bits);#ifdef CONFIG_SND_JACK_INPUT_DEV -mutex_lock (&jack->input_dev_lock); -if (!jack->input_dev) { -mutex_unlock (&jack->input_dev_lock); + idev =input_get_device (jack->input_dev); +if (!idev)return ; - }for (i =0 ; i <ARRAY_SIZE (jack->key); i++) {int testbit = ((SND_JACK_BTN_0 >> i) & ~mask_bits);if (jack->type & testbit) -input_report_key (jack->input_dev, jack->key[i], +input_report_key (idev, jack->key[i], status & testbit); }
@@ -688,13 +687,13 @@ void snd_jack_report(struct snd_jack *jaint testbit = ((1 << i) & ~mask_bits);if (jack->type & testbit) -input_report_switch (jack->input_dev, +input_report_switch (idev, jack_switch_types[i], status & testbit); } -input_sync (jack->input_dev); -mutex_unlock (&jack->input_dev_lock); +input_sync (idev); +input_put_device (idev);#endif /* CONFIG_SND_JACK_INPUT_DEV */ }EXPORT_SYMBOL (snd_jack_report);
Greg Kroah-Hartman
maintainerPATCH 522/800 ALSA: pcm: Fix potential data race at PCM memory allocation helpers
In reply to Greg Kroah-HartmanFrom: Takashi Iwai <[email protected]>
commit bd55842ed998a622ba6611fe59b3358c9f76773d upstream.
The PCM memory allocation helpers have a sanity check against too many buffer allocations. However, the check is performed without a proper lock and the allocation isn't serialized; this allows user to allocate more memories than predefined max size.
Practically seen, this isn't really a big problem, as it's more or less some "soft limit" as a sanity check, and it's not possible to allocate unlimitedly. But it's still better to address this for more consistent behavior.
The patch covers the size check in do_alloc_pages() with the card->memory_mutex, and increases the allocated size there for preventing the further overflow. When the actual allocation fails, the size is decreased accordingly.
--- sound/core/pcm_memory.c | 44 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 36 insertions(+), 8 deletions(-)
sound/core/pcm_memory.c +36 -8
@@ -31,15 +31,41 @@ static unsigned long max_alloc_per_cardmodule_param (max_alloc_per_card, ulong,0644 );MODULE_PARM_DESC (max_alloc_per_card,"Max total allocation bytes per card." ); +static void __update_allocated_size (struct snd_card *card,ssize_t bytes) +{ + card->total_pcm_alloc_bytes += bytes; +} + +static void update_allocated_size (struct snd_card *card,ssize_t bytes) +{ +mutex_lock (&card->memory_mutex); +__update_allocated_size (card, bytes); +mutex_unlock (&card->memory_mutex); +} + +static void decrease_allocated_size (struct snd_card *card,size_t bytes) +{ +mutex_lock (&card->memory_mutex); +WARN_ON (card->total_pcm_alloc_bytes < bytes); +__update_allocated_size (card, -(ssize_t )bytes); +mutex_unlock (&card->memory_mutex); +} +static int do_alloc_pages (struct snd_card *card,int type,struct device *dev,int str,size_t size,struct snd_dma_buffer *dmab) {enum dma_data_direction dir;int err; +/* check and reserve the requested size */ +mutex_lock (&card->memory_mutex);if (max_alloc_per_card && - card->total_pcm_alloc_bytes + size > max_alloc_per_card) + card->total_pcm_alloc_bytes + size > max_alloc_per_card) { +mutex_unlock (&card->memory_mutex);return -ENOMEM ; + } +__update_allocated_size (card, size); +mutex_unlock (&card->memory_mutex);if (str ==SNDRV_PCM_STREAM_PLAYBACK ) dir =DMA_TO_DEVICE ;
@@ -47,9 +73,14 @@ static int do_alloc_pages(struct snd_car dir =DMA_FROM_DEVICE ; err =snd_dma_alloc_dir_pages (type, dev, dir, size, dmab);if (!err) { -mutex_lock (&card->memory_mutex); - card->total_pcm_alloc_bytes += dmab->bytes; -mutex_unlock (&card->memory_mutex); +/* the actual allocation size might be bigger than requested, +* and we need to correct the account +*/ +if (dmab->bytes != size) +update_allocated_size (card, dmab->bytes - size); + }else { +/* take back on allocation failure */ +decrease_allocated_size (card, size); }return err; }
@@ -58,10 +89,7 @@ static void do_free_pages(struct snd_car {if (!dmab->area)return ; -mutex_lock (&card->memory_mutex); -WARN_ON (card->total_pcm_alloc_bytes < dmab->bytes); - card->total_pcm_alloc_bytes -= dmab->bytes; -mutex_unlock (&card->memory_mutex); +decrease_allocated_size (card, dmab->bytes);snd_dma_free_pages (dmab); dmab->area =NULL ; }
Greg Kroah-Hartman
maintainerPATCH 523/800 apparmor: fix: kzalloc perms tables for shared dfas
In reply to Greg Kroah-HartmanFrom: John Johansen <[email protected]>
commit ec6851ae0ab4587e610e260ddda75f92f3389f91 upstream.
Currently the permstables of the shared dfas are not shared, and need to be allocated and copied. In the future this should be addressed with a larger rework on dfa and pdb ref counts and structure sharing.
--- security/apparmor/policy.c | 13 +++++++++++++ security/apparmor/policy_unpack.c | 26 ++++++++++++++++++++++---- 2 files changed, 35 insertions(+), 4 deletions(-)
security/apparmor/policy.c +13 -0
@@ -591,7 +591,15 @@ struct aa_profile *aa_alloc_null(struct profile->label.flags |=FLAG_NULL ; rules =list_first_entry (&profile->rules,typeof (*rules), list); rules->file.dfa =aa_get_dfa (nulldfa); + rules->file.perms =kcalloc (2 ,sizeof (struct aa_perms ),GFP_KERNEL ); +if (!rules->file.perms) + goto fail; + rules->file.size =2 ; rules->policy.dfa =aa_get_dfa (nulldfa); + rules->policy.perms =kcalloc (2 ,sizeof (struct aa_perms ),GFP_KERNEL ); +if (!rules->policy.perms) + goto fail; + rules->policy.size =2 ;if (parent) { profile->path_flags = parent->path_flags;
@@ -602,6 +610,11 @@ struct aa_profile *aa_alloc_null(struct }return profile; + +fail: +aa_free_profile (profile); + +return NULL ; }/**
security/apparmor/policy_unpack.c +22 -4
@@ -988,9 +988,14 @@ static struct aa_profile *unpack_profile info ="failed to remap policydb permission table" ; goto fail; } - }else + }else { rules->policy.dfa =aa_get_dfa (nulldfa); - + rules->policy.perms =kcalloc (2 ,sizeof (struct aa_perms ), +GFP_KERNEL ); +if (!rules->policy.perms) + goto fail; + rules->policy.size =2 ; + }/* get file rules */ error =unpack_pdb (e, &rules->file, false, true, &info);if (error) {
@@ -1005,9 +1010,22 @@ static struct aa_profile *unpack_profile rules->policy.start[AA_CLASS_FILE]) { rules->file.dfa =aa_get_dfa (rules->policy.dfa); rules->file.start[AA_CLASS_FILE ] = rules->policy.start[AA_CLASS_FILE ]; - } else + rules->file.perms =kcalloc (rules->policy.size, +sizeof (struct aa_perms ), +GFP_KERNEL ); +if (!rules->file.perms) + goto fail; +memcpy (rules->file.perms, rules->policy.perms, + rules->policy.size *sizeof (struct aa_perms )); + rules->file.size = rules->policy.size; + } else { rules->file.dfa =aa_get_dfa (nulldfa); - + rules->file.perms =kcalloc (2 ,sizeof (struct aa_perms ), +GFP_KERNEL ); +if (!rules->file.perms) + goto fail; + rules->file.size =2 ; + } error = -EPROTO ;if (aa_unpack_nameX (e,AA_STRUCT ,"data" )) { info ="out of memory" ;
Greg Kroah-Hartman
maintainerPATCH 524/800 block: fix signed int overflow in Amiga partition support
In reply to Greg Kroah-HartmanFrom: Michael Schmitz <[email protected]>
commit fc3d092c6bb48d5865fec15ed5b333c12f36288c upstream.
The Amiga partition parser module uses signed int for partition sector address and count, which will overflow for disks larger than 1 TB.
Use sector_t as type for sector address and size to allow using disks up to 2 TB without LBD support, and disks larger than 2 TB with LBD.
This bug was reported originally in 2012, and the fix was created by the RDB author, Joanne Dow <[email protected]>. A patch had been discussed and reviewed on linux-m68k at that time but never officially submitted. This patch differs from Joanne's patch only in its use of sector_t instead of unsigned int. No checking for overflows is done (see patch 3 of this series for that).
Message-ID: <[email protected]>
--- block/partitions/amiga.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
block/partitions/amiga.c +5 -4
@@ -31,7 +31,8 @@ int amiga_partition(struct parsed_partitunsigned char *data;struct RigidDiskBlock *rdb;struct PartitionBlock *pb; -int start_sect, nr_sects, blk, part, res =0 ; +sector_t start_sect, nr_sects; +int blk, part, res =0 ;int blksize =1 ;/* Multiplier for disk block size */ int slot =1 ;
@@ -96,14 +97,14 @@ int amiga_partition(struct parsed_partit/* Tell Kernel about it */ - nr_sects = (be32_to_cpu (pb->pb_Environment[10 ]) +1 - -be32_to_cpu (pb->pb_Environment[9 ])) * + nr_sects = ((sector_t )be32_to_cpu (pb->pb_Environment[10 ]) +1 - +be32_to_cpu (pb->pb_Environment[9 ])) *be32_to_cpu (pb->pb_Environment[3 ]) *be32_to_cpu (pb->pb_Environment[5 ]) * blksize;if (!nr_sects)continue ; - start_sect =be32_to_cpu (pb->pb_Environment[9 ]) * + start_sect = (sector_t )be32_to_cpu (pb->pb_Environment[9 ]) *be32_to_cpu (pb->pb_Environment[3 ]) *be32_to_cpu (pb->pb_Environment[5 ]) * blksize;
Greg Kroah-Hartman
maintainerPATCH 525/800 block: add overflow checks for Amiga partition support
In reply to Greg Kroah-HartmanFrom: Michael Schmitz <[email protected]>
commit b6f3f28f604ba3de4724ad82bea6adb1300c0b5f upstream.
The Amiga partition parser module uses signed int for partition sector address and count, which will overflow for disks larger than 1 TB.
Use u64 as type for sector address and size to allow using disks up to 2 TB without LBD support, and disks larger than 2 TB with LBD. The RBD format allows to specify disk sizes up to 2^128 bytes (though native OS limitations reduce this somewhat, to max 2^68 bytes), so check for u64 overflow carefully to protect against overflowing sector_t.
Bail out if sector addresses overflow 32 bits on kernels without LBD support.
This bug was reported originally in 2012, and the fix was created by the RDB author, Joanne Dow <[email protected]>. A patch had been discussed and reviewed on linux-m68k at that time but never officially submitted (now resubmitted as patch 1 in this series).
This patch adds additional error checking and warning messages.
Message-ID: <[email protected]>
--- block/partitions/amiga.c | 103 ++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 85 insertions(+), 18 deletions(-)
block/partitions/amiga.c +85 -18
@@ -11,10 +11,18 @@#define pr_fmt (fmt) fmt#include <linux/types.h> +#include <linux/mm_types.h> +#include <linux/overflow.h> #include <linux/affs_hardblocks.h> #include "check.h" +/* magic offsets in partition DosEnvVec */ +#define NR_HD 3 +#define NR_SECT 5 +#define LO_CYL 9 +#define HI_CYL 10 +static __inline__u32 checksum_block (__be32 *m,int size) {
@@ -31,9 +39,12 @@ int amiga_partition(struct parsed_partitunsigned char *data;struct RigidDiskBlock *rdb;struct PartitionBlock *pb; -sector_t start_sect, nr_sects; -int blk, part, res =0 ; -int blksize =1 ;/* Multiplier for disk block size */ +u64 start_sect, nr_sects; +sector_t blk, end_sect; +u32 cylblk;/* rdb_CylBlocks = nr_heads*sect_per_track */ +u32 nr_hd, nr_sect, lo_cyl, hi_cyl; +int part, res =0 ; +unsigned int blksize =1 ;/* Multiplier for disk block size */ int slot =1 ;for (blk =0 ; ; blk++,put_dev_sector (sect)) {
@@ -41,7 +52,7 @@ int amiga_partition(struct parsed_partit goto rdb_done; data =read_part_sector (state, blk, §);if (!data) { -pr_err ("Dev %s: unable to read RDB block %d\n" , +pr_err ("Dev %s: unable to read RDB block %llu\n" , state->disk->disk_name, blk); res =-1 ; goto rdb_done;
@@ -58,12 +69,12 @@ int amiga_partition(struct parsed_partit *(__be32 *)(data+0xdc ) =0 ;if (checksum_block ((__be32 *)data,be32_to_cpu (rdb->rdb_SummedLongs) &0x7F )==0 ) { -pr_err ("Trashed word at 0xd0 in block %d ignored in checksum calculation\n" , +pr_err ("Trashed word at 0xd0 in block %llu ignored in checksum calculation\n" , blk);break ; } -pr_err ("Dev %s: RDB in block %d has bad checksum\n" , +pr_err ("Dev %s: RDB in block %llu has bad checksum\n" , state->disk->disk_name, blk); }
@@ -80,10 +91,15 @@ int amiga_partition(struct parsed_partit blk =be32_to_cpu (rdb->rdb_PartitionList);put_dev_sector (sect);for (part =1 ; blk>0 && part<=16 ; part++,put_dev_sector (sect)) { - blk *= blksize;/* Read in terms partition table understands */ +/* Read in terms partition table understands */ +if (check_mul_overflow (blk, (sector_t ) blksize, &blk)) { +pr_err ("Dev %s: overflow calculating partition block %llu! Skipping partitions %u and beyond\n" , + state->disk->disk_name, blk, part); +break ; + } data =read_part_sector (state, blk, §);if (!data) { -pr_err ("Dev %s: unable to read partition block %d\n" , +pr_err ("Dev %s: unable to read partition block %llu\n" , state->disk->disk_name, blk); res =-1 ; goto rdb_done;
@@ -95,19 +111,70 @@ int amiga_partition(struct parsed_partitif (checksum_block ((__be32 *)pb,be32_to_cpu (pb->pb_SummedLongs) &0x7F ) !=0 )continue ; -/* Tell Kernel about it */ +/* RDB gives us more than enough rope to hang ourselves with, +* many times over (2^128 bytes if all fields max out). +* Some careful checks are in order, so check for potential +* overflows. +* We are multiplying four 32 bit numbers to one sector_t! +*/ + + nr_hd =be32_to_cpu (pb->pb_Environment[NR_HD ]); + nr_sect =be32_to_cpu (pb->pb_Environment[NR_SECT ]); + +/* CylBlocks is total number of blocks per cylinder */ +if (check_mul_overflow (nr_hd, nr_sect, &cylblk)) { +pr_err ("Dev %s: heads*sects %u overflows u32, skipping partition!\n" , + state->disk->disk_name, cylblk); +continue ; + } + +/* check for consistency with RDB defined CylBlocks */ +if (cylblk >be32_to_cpu (rdb->rdb_CylBlocks)) { +pr_warn ("Dev %s: cylblk %u > rdb_CylBlocks %u!\n" , + state->disk->disk_name, cylblk, +be32_to_cpu (rdb->rdb_CylBlocks)); + } + +/* RDB allows for variable logical block size - +* normalize to 512 byte blocks and check result. +*/ + +if (check_mul_overflow (cylblk, blksize, &cylblk)) { +pr_err ("Dev %s: partition %u bytes per cyl. overflows u32, skipping partition!\n" , + state->disk->disk_name, part); +continue ; + } + +/* Calculate partition start and end. Limit of 32 bit on cylblk +* guarantees no overflow occurs if LBD support is enabled. +*/ + + lo_cyl =be32_to_cpu (pb->pb_Environment[LO_CYL ]); + start_sect = ((u64 ) lo_cyl * cylblk); + + hi_cyl =be32_to_cpu (pb->pb_Environment[HI_CYL ]); + nr_sects = (((u64 ) hi_cyl - lo_cyl +1 ) * cylblk); - nr_sects = ((sector_t )be32_to_cpu (pb->pb_Environment[10 ]) +1 - -be32_to_cpu (pb->pb_Environment[9 ])) * -be32_to_cpu (pb->pb_Environment[3 ]) * -be32_to_cpu (pb->pb_Environment[5 ]) * - blksize;if (!nr_sects)continue ; - start_sect = (sector_t )be32_to_cpu (pb->pb_Environment[9 ]) * -be32_to_cpu (pb->pb_Environment[3 ]) * -be32_to_cpu (pb->pb_Environment[5 ]) * - blksize; + +/* Warn user if partition end overflows u32 (AmigaDOS limit) */ + +if ((start_sect + nr_sects) >UINT_MAX ) { +pr_warn ("Dev %s: partition %u (%llu-%llu) needs 64 bit device support!\n" , + state->disk->disk_name, part, + start_sect, start_sect + nr_sects); + } + +if (check_add_overflow (start_sect, nr_sects, &end_sect)) { +pr_err ("Dev %s: partition %u (%llu-%llu) needs LBD device support, skipping partition!\n" , + state->disk->disk_name, part, + start_sect, end_sect); +continue ; + } + +/* Tell Kernel about it */ +put_partition (state,slot++,start_sect,nr_sects); {/* Be even more informative to aid mounting */
Greg Kroah-Hartman
maintainerPATCH 526/800 block: change all __u32 annotations to __be32 in affs_hardblocks.h
In reply to Greg Kroah-HartmanFrom: Michael Schmitz <[email protected]>
commit 95a55437dc49fb3342c82e61f5472a71c63d9ed0 upstream.
The Amiga partition parser module uses signed int for partition sector address and count, which will overflow for disks larger than 1 TB.
Use u64 as type for sector address and size to allow using disks up to 2 TB without LBD support, and disks larger than 2 TB with LBD. The RBD format allows to specify disk sizes up to 2^128 bytes (though native OS limitations reduce this somewhat, to max 2^68 bytes), so check for u64 overflow carefully to protect against overflowing sector_t.
This bug was reported originally in 2012, and the fix was created by the RDB author, Joanne Dow <[email protected]>. A patch had been discussed and reviewed on linux-m68k at that time but never officially submitted (now resubmitted as patch 1 of this series).
Patch 3 (this series) adds additional error checking and warning messages. One of the error checks now makes use of the previously unused rdb_CylBlocks field, which causes a 'sparse' warning (cast to restricted __be32).
Annotate all 32 bit fields in affs_hardblocks.h as __be32, as the on-disk format of RDB and partition blocks is always big endian.
Message-ID: <[email protected]>
--- include/uapi/linux/affs_hardblocks.h | 68 +++++++++++++++++------------------ 1 file changed, 34 insertions(+), 34 deletions(-)
include/uapi/linux/affs_hardblocks.h +34 -34
@@ -7,42 +7,42 @@/* Just the needed definitions for the RDB of an Amiga HD. */ struct RigidDiskBlock { -__u32 rdb_ID; +__be32 rdb_ID;__be32 rdb_SummedLongs; -__s32 rdb_ChkSum; -__u32 rdb_HostID; +__be32 rdb_ChkSum; +__be32 rdb_HostID;__be32 rdb_BlockBytes; -__u32 rdb_Flags; -__u32 rdb_BadBlockList; +__be32 rdb_Flags; +__be32 rdb_BadBlockList;__be32 rdb_PartitionList; -__u32 rdb_FileSysHeaderList; -__u32 rdb_DriveInit; -__u32 rdb_Reserved1[6 ]; -__u32 rdb_Cylinders; -__u32 rdb_Sectors; -__u32 rdb_Heads; -__u32 rdb_Interleave; -__u32 rdb_Park; -__u32 rdb_Reserved2[3 ]; -__u32 rdb_WritePreComp; -__u32 rdb_ReducedWrite; -__u32 rdb_StepRate; -__u32 rdb_Reserved3[5 ]; -__u32 rdb_RDBBlocksLo; -__u32 rdb_RDBBlocksHi; -__u32 rdb_LoCylinder; -__u32 rdb_HiCylinder; -__u32 rdb_CylBlocks; -__u32 rdb_AutoParkSeconds; -__u32 rdb_HighRDSKBlock; -__u32 rdb_Reserved4; +__be32 rdb_FileSysHeaderList; +__be32 rdb_DriveInit; +__be32 rdb_Reserved1[6 ]; +__be32 rdb_Cylinders; +__be32 rdb_Sectors; +__be32 rdb_Heads; +__be32 rdb_Interleave; +__be32 rdb_Park; +__be32 rdb_Reserved2[3 ]; +__be32 rdb_WritePreComp; +__be32 rdb_ReducedWrite; +__be32 rdb_StepRate; +__be32 rdb_Reserved3[5 ]; +__be32 rdb_RDBBlocksLo; +__be32 rdb_RDBBlocksHi; +__be32 rdb_LoCylinder; +__be32 rdb_HiCylinder; +__be32 rdb_CylBlocks; +__be32 rdb_AutoParkSeconds; +__be32 rdb_HighRDSKBlock; +__be32 rdb_Reserved4;char rdb_DiskVendor[8 ];char rdb_DiskProduct[16 ];char rdb_DiskRevision[4 ];char rdb_ControllerVendor[8 ];char rdb_ControllerProduct[16 ];char rdb_ControllerRevision[4 ]; -__u32 rdb_Reserved5[10 ]; +__be32 rdb_Reserved5[10 ]; };#define IDNAME_RIGIDDISK 0x5244534B/* "RDSK" */
@@ -50,16 +50,16 @@ struct RigidDiskBlock {struct PartitionBlock {__be32 pb_ID;__be32 pb_SummedLongs; -__s32 pb_ChkSum; -__u32 pb_HostID; +__be32 pb_ChkSum; +__be32 pb_HostID;__be32 pb_Next; -__u32 pb_Flags; -__u32 pb_Reserved1[2 ]; -__u32 pb_DevFlags; +__be32 pb_Flags; +__be32 pb_Reserved1[2 ]; +__be32 pb_DevFlags;__u8 pb_DriveName[32 ]; -__u32 pb_Reserved2[15 ]; +__be32 pb_Reserved2[15 ];__be32 pb_Environment[17 ]; -__u32 pb_EReserved[15 ]; +__be32 pb_EReserved[15 ]; };#define IDNAME_PARTITION 0x50415254/* "PART" */
Greg Kroah-Hartman
maintainerPATCH 527/800 block: increment diskseq on all media change events
In reply to Greg Kroah-HartmanFrom: Demi Marie Obenour <[email protected]>
commit b90ecc0379eb7bbe79337b0c7289390a98752646 upstream.
Currently, associating a loop device with a different file descriptor does not increment its diskseq. This allows the following race condition:
1. Program X opens a loop device
2. Program X gets the diskseq of the loop device.
3. Program X associates a file with the loop device.
4. Program X passes the loop device major, minor, and diskseq to something.
5. Program X exits.
6. Program Y detaches the file from the loop device.
7. Program Y attaches a different file to the loop device.
8. The opener finally gets around to opening the loop device and checks that the diskseq is what it expects it to be. Even though the diskseq is the expected value, the result is that the opener is accessing the wrong file.
Quoted 1 line
From discussions with Christoph Hellwig, it appears that
disk_force_media_change() was supposed to call inc_diskseq(), but in fact it does not. Adding a Fixes: tag to indicate this. Christoph's Reported-by is because he stated that disk_force_media_change() calls inc_diskseq(), which is what led me to discover that it should but does not.
--- block/disk-events.c | 1 + 1 file changed, 1 insertion(+)
block/disk-events.c +1 -0
@@ -307,6 +307,7 @@ bool disk_force_media_change(struct gendif (!(events &DISK_EVENT_MEDIA_CHANGE ))return false; +inc_diskseq (disk);if (__invalidate_device (disk->part0, true))pr_warn ("VFS: busy inodes on changed media %s\n" , disk->disk_name);
Greg Kroah-Hartman
maintainerPATCH 528/800 mmc: block: ioctl: do write error check for spi
In reply to Greg Kroah-HartmanFrom: Christian Loehle <[email protected]>
commit 568898cbc8b570311b3b94a3202b8233f4168144 upstream.
SPI doesn't have the usual PROG path we can check for error bits after moving back to TRAN. Instead it holds the line LOW until completion. We can then check if the card shows any errors or is in IDLE state, indicating the line is no longer LOW because the card was reset.
--- drivers/mmc/core/block.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/mmc/core/block.c +6 -0
@@ -178,6 +178,7 @@ static void mmc_blk_rw_rq_prep(struct mmint recovery_mode, struct mmc_queue *mq);static void mmc_blk_hsq_req_done (struct mmc_request *mrq); +static int mmc_spi_err_check (struct mmc_card *card);static struct mmc_blk_data *mmc_blk_get (struct gendisk *disk) {
@@ -608,6 +609,11 @@ static int __mmc_blk_ioctl_cmd(struct mmif ((card->host->caps &MMC_CAP_WAIT_WHILE_BUSY ) && use_r1b_resp)return 0 ; +if (mmc_host_is_spi (card->host)) { +if (idata->ic.write_flag || r1b_resp || cmd.flags &MMC_RSP_SPI_BUSY ) +return mmc_spi_err_check (card); +return err; + }/* Ensure RPMB/R1B command has completed by polling with CMD13. */ if (idata->rpmb || r1b_resp) err = mmc_poll_for_busy(card, busy_timeout_ms, false,
Greg Kroah-Hartman
maintainerPATCH 529/800 btrfs: fix race when deleting free space root from the dirty cow roots list
In reply to Greg Kroah-HartmanFrom: Filipe Manana <[email protected]>
commit babebf023e661b90b1c78b2baa384fb03a226879 upstream.
When deleting the free space tree we are deleting the free space root from the list fs_info->dirty_cowonly_roots without taking the lock that protects it, which is struct btrfs_fs_info::trans_lock.
This unsynchronized list manipulation may cause chaos if there's another concurrent manipulation of this list, such as when adding a root to it with ctree.c:add_root_to_dirty_list().
This can result in all sorts of weird failures caused by a race, such as the following crash:
[337571.278245] general protection fault, probably for non-canonical address 0xdead000000000108: 0000 [#1] PREEMPT SMP PTI [337571.278933] CPU: 1 PID: 115447 Comm: btrfs Tainted: G W 6.4.0-rc6-btrfs-next-134+ #1 [337571.279153] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.14.0-0-g155821a1990b-prebuilt.qemu.org 04/01/2014 [337571.279572] RIP: 0010:commit_cowonly_roots+0x11f/0x250 [btrfs] [337571.279928] Code: 85 38 06 00 (...) [337571.280363] RSP: 0018:ffff9f63446efba0 EFLAGS: 00010206 [337571.280582] RAX: ffff942d98ec2638 RBX: ffff9430b82b4c30 RCX: 0000000449e1c000 [337571.280798] RDX: dead000000000100 RSI: ffff9430021e4900 RDI: 0000000000036070 [337571.281015] RBP: ffff942d98ec2000 R08: ffff942d98ec2000 R09: 000000000000015b [337571.281254] R10: 0000000000000009 R11: 0000000000000001 R12: ffff942fe8fbf600 [337571.281476] R13: ffff942dabe23040 R14: ffff942dabe20800 R15: ffff942d92cf3b48 [337571.281723] FS: 00007f478adb7340(0000) GS:ffff94349fa40000(0000) knlGS:0000000000000000 [337571.281950] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [337571.282184] CR2: 00007f478ab9a3d5 CR3: 000000001e02c001 CR4: 0000000000370ee0 [337571.282416] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [337571.282647] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 [337571.282874] Call Trace: [337571.283101] <TASK> [337571.283327] ? __die_body+0x1b/0x60 [337571.283570] ? die_addr+0x39/0x60 [337571.283796] ? exc_general_protection+0x22e/0x430 [337571.284022] ? asm_exc_general_protection+0x22/0x30 [337571.284251] ? commit_cowonly_roots+0x11f/0x250 [btrfs] [337571.284531] btrfs_commit_transaction+0x42e/0xf90 [btrfs] [337571.284803] ? _raw_spin_unlock+0x15/0x30 [337571.285031] ? release_extent_buffer+0x103/0x130 [btrfs] [337571.285305] reset_balance_state+0x152/0x1b0 [btrfs] [337571.285578] btrfs_balance+0xa50/0x11e0 [btrfs] [337571.285864] ? __kmem_cache_alloc_node+0x14a/0x410 [337571.286086] btrfs_ioctl+0x249a/0x3320 [btrfs] [337571.286358] ? mod_objcg_state+0xd2/0x360 [337571.286577] ? refill_obj_stock+0xb0/0x160 [337571.286798] ? seq_release+0x25/0x30 [337571.287016] ? __rseq_handle_notify_resume+0x3ba/0x4b0 [337571.287235] ? percpu_counter_add_batch+0x2e/0xa0 [337571.287455] ? __x64_sys_ioctl+0x88/0xc0 [337571.287675] __x64_sys_ioctl+0x88/0xc0 [337571.287901] do_syscall_64+0x38/0x90 [337571.288126] entry_SYSCALL_64_after_hwframe+0x72/0xdc [337571.288352] RIP: 0033:0x7f478aaffe9b
So fix this by locking struct btrfs_fs_info::trans_lock before deleting the free space root from that list.
--- fs/btrfs/free-space-tree.c | 3 +++ 1 file changed, 3 insertions(+)
fs/btrfs/free-space-tree.c +3 -0
@@ -1280,7 +1280,10 @@ int btrfs_delete_free_space_tree(struct goto abort;btrfs_global_root_delete (free_space_root); + +spin_lock (&fs_info->trans_lock);list_del (&free_space_root->dirty_list); +spin_unlock (&fs_info->trans_lock);btrfs_tree_lock (free_space_root->node);btrfs_clear_buffer_dirty (trans, free_space_root->node);
Greg Kroah-Hartman
maintainerPATCH 530/800 btrfs: do not BUG_ON() on tree mod log failure at balance_level()
In reply to Greg Kroah-HartmanFrom: Filipe Manana <[email protected]>
commit 39020d8abc7ec62c4de9b260e3d10d4a1c2478ce upstream.
At balance_level(), instead of doing a BUG_ON() in case we fail to record tree mod log operations, do a transaction abort and return the error to the callers. There's really no need for the BUG_ON() as we can release all resources in this context, and we have to abort because other future tree searches that use the tree mod log (btrfs_search_old_slot()) may get inconsistent results if other operations modify the tree after that failure and before the tree mod log based search.
--- fs/btrfs/ctree.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)
fs/btrfs/ctree.c +14 -3
@@ -1042,7 +1042,12 @@ static noinline int balance_level(struct } ret =btrfs_tree_mod_log_insert_root (root->node, child, true); -BUG_ON (ret <0 ); +if (ret <0 ) { +btrfs_tree_unlock (child); +free_extent_buffer (child); +btrfs_abort_transaction (trans, ret); + goto enospc; + }rcu_assign_pointer (root->node, child);add_root_to_dirty_list (root);
@@ -1130,7 +1135,10 @@ static noinline int balance_level(structbtrfs_node_key (right, &right_key,0 ); ret =btrfs_tree_mod_log_insert_key (parent, pslot +1 ,BTRFS_MOD_LOG_KEY_REPLACE ); -BUG_ON (ret <0 ); +if (ret <0 ) { +btrfs_abort_transaction (trans, ret); + goto enospc; + }btrfs_set_node_key (parent, &right_key, pslot +1 );btrfs_mark_buffer_dirty (parent); }
@@ -1176,7 +1184,10 @@ static noinline int balance_level(structbtrfs_node_key (mid, &mid_key,0 ); ret =btrfs_tree_mod_log_insert_key (parent, pslot,BTRFS_MOD_LOG_KEY_REPLACE ); -BUG_ON (ret <0 ); +if (ret <0 ) { +btrfs_abort_transaction (trans, ret); + goto enospc; + }btrfs_set_node_key (parent, &mid_key, pslot);btrfs_mark_buffer_dirty (parent); }
Greg Kroah-Hartman
maintainerPATCH 531/800 SUNRPC: Fix UAF in svc_tcp_listen_data_ready()
In reply to Greg Kroah-HartmanFrom: Ding Hui <[email protected]>
commit fc80fc2d4e39137869da3150ee169b40bf879287 upstream.
After the listener svc_sock is freed, and before invoking svc_tcp_accept() for the established child sock, there is a window that the newsock retaining a freed listener svc_sock in sk_user_data which cloning from parent. In the race window, if data is received on the newsock, we will observe use-after-free report in svc_tcp_listen_data_ready().
Reproduce by two tasks:
1. while :; do rpc.nfsd 0 ; rpc.nfsd; done
2. while :; do echo "" | ncat -4 127.0.0.1 2049 ; done
KASAN report:
==================================================================
BUG: KASAN: slab-use-after-free in svc_tcp_listen_data_ready+0x1cf/0x1f0 [sunrpc] Read of size 8 at addr ffff888139d96228 by task nc/102553 CPU: 7 PID: 102553 Comm: nc Not tainted 6.3.0+ #18 Hardware name: VMware, Inc. VMware Virtual Platform/440BX Desktop Reference Platform, BIOS 6.00 11/12/2020 Call Trace: <IRQ> dump_stack_lvl+0x33/0x50 print_address_description.constprop.0+0x27/0x310 print_report+0x3e/0x70 kasan_report+0xae/0xe0 svc_tcp_listen_data_ready+0x1cf/0x1f0 [sunrpc] tcp_data_queue+0x9f4/0x20e0 tcp_rcv_established+0x666/0x1f60 tcp_v4_do_rcv+0x51c/0x850 tcp_v4_rcv+0x23fc/0x2e80 ip_protocol_deliver_rcu+0x62/0x300 ip_local_deliver_finish+0x267/0x350 ip_local_deliver+0x18b/0x2d0 ip_rcv+0x2fb/0x370 __netif_receive_skb_one_core+0x166/0x1b0 process_backlog+0x24c/0x5e0 __napi_poll+0xa2/0x500 net_rx_action+0x854/0xc90 __do_softirq+0x1bb/0x5de do_softirq+0xcb/0x100 </IRQ> <TASK> ... </TASK> Allocated by task 102371: kasan_save_stack+0x1e/0x40 kasan_set_track+0x21/0x30 __kasan_kmalloc+0x7b/0x90 svc_setup_socket+0x52/0x4f0 [sunrpc] svc_addsock+0x20d/0x400 [sunrpc] __write_ports_addfd+0x209/0x390 [nfsd] write_ports+0x239/0x2c0 [nfsd] nfsctl_transaction_write+0xac/0x110 [nfsd] vfs_write+0x1c3/0xae0 ksys_write+0xed/0x1c0 do_syscall_64+0x38/0x90 entry_SYSCALL_64_after_hwframe+0x72/0xdc Freed by task 102551: kasan_save_stack+0x1e/0x40 kasan_set_track+0x21/0x30 kasan_save_free_info+0x2a/0x50 __kasan_slab_free+0x106/0x190 __kmem_cache_free+0x133/0x270 svc_xprt_free+0x1e2/0x350 [sunrpc] svc_xprt_destroy_all+0x25a/0x440 [sunrpc] nfsd_put+0x125/0x240 [nfsd] nfsd_svc+0x2cb/0x3c0 [nfsd] write_threads+0x1ac/0x2a0 [nfsd] nfsctl_transaction_write+0xac/0x110 [nfsd] vfs_write+0x1c3/0xae0 ksys_write+0xed/0x1c0 do_syscall_64+0x38/0x90 entry_SYSCALL_64_after_hwframe+0x72/0xdc
Fix the UAF by simply doing nothing in svc_tcp_listen_data_ready() if state != TCP_LISTEN, that will avoid dereferencing svsk for all child socket.
--- net/sunrpc/svcsock.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-)
net/sunrpc/svcsock.c +11 -12
@@ -826,12 +826,6 @@ static void svc_tcp_listen_data_ready(sttrace_sk_data_ready (sk); -if (svsk) { -/* Refer to svc_setup_socket() for details. */ -rmb (); - svsk->sk_odata (sk); - } -/* * This callback may called twice when a new connection * is established as a child socket inherits everything
@@ -840,13 +834,18 @@ static void svc_tcp_listen_data_ready(st* when one of child sockets become ESTABLISHED. * 2) data_ready method of the child socket may be called * when it receives data before the socket is accepted. -* In case of 2, we should ignore it silently. +* In case of 2, we should ignore it silently and DO NOT +* dereference svsk. */ -if (sk->sk_state ==TCP_LISTEN ) { -if (svsk) { -set_bit (XPT_CONN , &svsk->sk_xprt.xpt_flags); -svc_xprt_enqueue (&svsk->sk_xprt); - } +if (sk->sk_state !=TCP_LISTEN ) +return ; + +if (svsk) { +/* Refer to svc_setup_socket() for details. */ +rmb (); + svsk->sk_odata (sk); +set_bit (XPT_CONN , &svsk->sk_xprt.xpt_flags); +svc_xprt_enqueue (&svsk->sk_xprt); } }
Greg Kroah-Hartman
maintainerPATCH 532/800 kbuild: Fix CFI failures with GCOV
In reply to Greg Kroah-HartmanFrom: Sami Tolvanen <[email protected]>
[ Upstream commit ddf56288eebd1fe82c46fc9f693b5b18045cddb6 ]
With GCOV_PROFILE_ALL, Clang injects __llvm_gcov_* functions to each object file, and the functions are indirectly called during boot. However, when code is injected to object files that are not part of vmlinux.o, it's also not processed by objtool, which breaks CFI hash randomization as the hashes in these files won't be included in the .cfi_sites section and thus won't be randomized.
Similarly to commit 42633ed852de ("kbuild: Fix CFI hash randomization with KASAN"), disable GCOV for .vmlinux.export.o and init/version-timestamp.o to avoid emitting unnecessary functions to object files that don't otherwise have executable code.
--- init/Makefile | 1 + scripts/Makefile.vmlinux | 1 + 2 files changed, 2 insertions(+)
init/Makefile +1 -0
@@ -60,3 +60,4 @@ include/generated/utsversion.h: FORCE $(obj)/version-timestamp.o: include/generated/utsversion.h CFLAGS_version-timestamp.o := -include include/generated/utsversion.h KASAN_SANITIZE_version-timestamp.o := n +GCOV_PROFILE_version-timestamp.o := n
scripts/Makefile.vmlinux +1 -0
@@ -19,6 +19,7 @@ quiet_cmd_cc_o_c = CC $@ ifdef CONFIG_MODULES KASAN_SANITIZE_.vmlinux.export.o := n +GCOV_PROFILE_.vmlinux.export.o := n targets += .vmlinux.export.o vmlinux: .vmlinux.export.o endif
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 533/800 kbuild: Disable GCOV for *.mod.o
In reply to Greg Kroah-HartmanFrom: Sami Tolvanen <[email protected]>
[ Upstream commit 25a21fbb934a0d989e1858f83c2ddf4cfb2ebe30 ]
With GCOV_PROFILE_ALL, Clang injects __llvm_gcov_* functions to each object file, including the *.mod.o. As we filter out CC_FLAGS_CFI for *.mod.o, the compiler won't generate type hashes for the injected functions, and therefore indirectly calling them during module loading trips indirect call checking.
Enabling CFI for *.mod.o isn't sufficient to fix this issue after commit 0c3e806ec0f9 ("x86/cfi: Add boot time hash randomization"), as *.mod.o aren't processed by objtool, which means any hashes emitted there won't be randomized. Therefore, in addition to disabling CFI for *.mod.o, also disable GCOV, as the object files don't otherwise contain any executable code.
--- scripts/Makefile.modfinal | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/Makefile.modfinal +1 -1
@@ -23,7 +23,7 @@ modname = $(notdir $(@:.mod.o=)) part-of-module = y quiet_cmd_cc_o_c = CC [M] $@ - cmd_cc_o_c = $(CC) $(filter-out $(CC_FLAGS_CFI), $(c_flags)) -c -o $@ $< + cmd_cc_o_c = $(CC) $(filter-out $(CC_FLAGS_CFI) $(CFLAGS_GCOV), $(c_flags)) -c -o $@ $< %.mod.o: %.mod.c FORCE $(call if_changed_dep,cc_o_c)
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 534/800 cxl/region: Move cache invalidation before region teardown, and before setup
In reply to Greg Kroah-HartmanFrom: Dan Williams <[email protected]>
[ Upstream commit d1257d098a5a38753a0736a50db0a26a62377ad7 ]
Vikram raised a concern with the theoretical case of a CPU sending MemClnEvict to a device that is not prepared to receive. MemClnEvict is a message that is sent after a CPU has taken ownership of a cacheline from accelerator memory (HDM-DB). In the case of hotplug or HDM decoder reconfiguration it is possible that the CPU is holding old contents for a new device that has taken over the physical address range being cached by the CPU.
To avoid this scenario, invalidate caches prior to tearing down an HDM decoder configuration.
Now, this poses another problem that it is possible for something to speculate into that space while the decode configuration is still up, so to close that gap also invalidate prior to establish new contents behind a given physical address range.
With this change the cache invalidation is now explicit and need not be checked in cxl_region_probe(), and that obviates the need for CXL_REGION_F_INCOHERENT.
--- drivers/cxl/core/region.c | 66 ++++++++++++++++++++++----------------- drivers/cxl/cxl.h | 8 +---- 2 files changed, 38 insertions(+), 36 deletions(-)
drivers/cxl/core/region.c +37 -29
@@ -125,10 +125,38 @@ static struct cxl_region_ref *cxl_rr_load(struct cxl_port *port,return xa_load (&port->regions, (unsigned long )cxlr); } +static int cxl_region_invalidate_memregion (struct cxl_region *cxlr) +{ +if (!cpu_cache_has_invalidate_memregion ()) { +if (IS_ENABLED (CONFIG_CXL_REGION_INVALIDATION_TEST )) { +dev_warn_once ( + &cxlr->dev, +"Bypassing cpu_cache_invalidate_memregion() for testing!\n" ); +return 0 ; + }else { +dev_err (&cxlr->dev, +"Failed to synchronize CPU cache state\n" ); +return -ENXIO ; + } + } + +cpu_cache_invalidate_memregion (IORES_DESC_CXL ); +return 0 ; +} +static int cxl_region_decode_reset (struct cxl_region *cxlr,int count) {struct cxl_region_params *p = &cxlr->params; -int i; +int i, rc =0 ; + +/* +* Before region teardown attempt to flush, and if the flush +* fails cancel the region teardown for data consistency +* concerns +*/ + rc =cxl_region_invalidate_memregion (cxlr); +if (rc) +return rc;for (i = count -1 ; i >=0 ; i--) {struct cxl_endpoint_decoder *cxled = p->targets[i];
@@ -136,7 +164,6 @@ static int cxl_region_decode_reset(struct cxl_region *cxlr, int count)struct cxl_port *iter =cxled_to_port (cxled);struct cxl_dev_state *cxlds = cxlmd->cxlds;struct cxl_ep *ep; -int rc =0 ;if (cxlds->rcd) goto endpoint_reset;
@@ -256,6 +283,14 @@ static ssize_t commit_store(struct device *dev, struct device_attribute *attr, goto out; } +/* +* Invalidate caches before region setup to drop any speculative +* consumption of this address space +*/ + rc =cxl_region_invalidate_memregion (cxlr); +if (rc) +return rc; +if (commit) rc =cxl_region_decode_commit (cxlr);else {
@@ -1674,7 +1709,6 @@ static int cxl_region_attach(struct cxl_region *cxlr,if (rc) goto err_decrement; p->state =CXL_CONFIG_ACTIVE ; -set_bit (CXL_REGION_F_INCOHERENT , &cxlr->flags); } cxled->cxld.interleave_ways = p->interleave_ways;
@@ -2803,30 +2837,6 @@ int cxl_add_to_region(struct cxl_port *root, struct cxl_endpoint_decoder *cxled) }EXPORT_SYMBOL_NS_GPL (cxl_add_to_region,CXL ); -static int cxl_region_invalidate_memregion (struct cxl_region *cxlr) -{ -if (!test_bit (CXL_REGION_F_INCOHERENT , &cxlr->flags)) -return 0 ; - -if (!cpu_cache_has_invalidate_memregion ()) { -if (IS_ENABLED (CONFIG_CXL_REGION_INVALIDATION_TEST )) { -dev_warn_once ( - &cxlr->dev, -"Bypassing cpu_cache_invalidate_memregion() for testing!\n" ); -clear_bit (CXL_REGION_F_INCOHERENT , &cxlr->flags); -return 0 ; - }else { -dev_err (&cxlr->dev, -"Failed to synchronize CPU cache state\n" ); -return -ENXIO ; - } - } - -cpu_cache_invalidate_memregion (IORES_DESC_CXL ); -clear_bit (CXL_REGION_F_INCOHERENT , &cxlr->flags); -return 0 ; -} -static int is_system_ram (struct resource *res,void *arg) {struct cxl_region *cxlr = arg;
@@ -2854,8 +2864,6 @@ static int cxl_region_probe(struct device *dev) goto out; } - rc =cxl_region_invalidate_memregion (cxlr); -/* * From this point on any path that changes the region's state away from * CXL_CONFIG_COMMIT is also responsible for releasing the driver.
drivers/cxl/cxl.h +1 -7
@@ -462,18 +462,12 @@ struct cxl_region_params {int nr_targets; }; -/* -* Flag whether this region needs to have its HPA span synchronized with -* CPU cache state at region activation time. -*/ -#define CXL_REGION_F_INCOHERENT 0 -/* * Indicate whether this region has been assembled by autodetection or * userspace assembly. Prevent endpoint decoders outside of automatic * detection from being added to the region. */ -#define CXL_REGION_F_AUTO 1 +#define CXL_REGION_F_AUTO 0/** * struct cxl_region - CXL region
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 535/800 cxl/region: Flag partially torn down regions as unusable
In reply to Greg Kroah-HartmanFrom: Dan Williams <[email protected]>
[ Upstream commit 2ab47045ac96a605e3037d479a7d5854570ee5bf ]
cxl_region_decode_reset() walks all the decoders associated with a given region and disables them. Due to decoder ordering rules it is possible that a switch in the topology notices that a given decoder can not be shutdown before another region with a higher HPA is shutdown first. That can leave the region in a partially committed state.
Capture that state in a new CXL_REGION_F_NEEDS_RESET flag and require that a successful cxl_region_decode_reset() attempt must be completed before cxl_region_probe() accepts the region.
This is a corollary for the bug that Jonathan identified in "CXL/region : commit reset of out of order region appears to succeed." [1].
--- drivers/cxl/core/region.c | 12 ++++++++++++ drivers/cxl/cxl.h | 8 ++++++++ 2 files changed, 20 insertions(+)
drivers/cxl/core/region.c +12 -0
@@ -182,14 +182,19 @@ static int cxl_region_decode_reset(struct cxl_region *cxlr, int count) rc = cxld->reset (cxld);if (rc)return rc; +set_bit (CXL_REGION_F_NEEDS_RESET , &cxlr->flags); } endpoint_reset: rc = cxled->cxld.reset (&cxled->cxld);if (rc)return rc; +set_bit (CXL_REGION_F_NEEDS_RESET , &cxlr->flags); } +/* all decoders associated with this region have been torn down */ +clear_bit (CXL_REGION_F_NEEDS_RESET , &cxlr->flags); +return 0 ; }
@@ -2864,6 +2869,13 @@ static int cxl_region_probe(struct device *dev) goto out; } +if (test_bit (CXL_REGION_F_NEEDS_RESET , &cxlr->flags)) { +dev_err (&cxlr->dev, +"failed to activate, re-commit region and retry\n" ); + rc = -ENXIO ; + goto out; + } +/* * From this point on any path that changes the region's state away from * CXL_CONFIG_COMMIT is also responsible for releasing the driver.
drivers/cxl/cxl.h +8 -0
@@ -469,6 +469,14 @@ struct cxl_region_params {*/ #define CXL_REGION_F_AUTO 0 +/* +* Require that a committed region successfully complete a teardown once +* any of its associated decoders have been torn down. This maintains +* the commit state for the region since there are committed decoders, +* but blocks cxl_region_probe(). +*/ +#define CXL_REGION_F_NEEDS_RESET 1 +/** * struct cxl_region - CXL region * @dev: This region's device
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 536/800 cxl/region: Fix state transitions after reset failure
In reply to Greg Kroah-HartmanFrom: Dan Williams <[email protected]>
[ Upstream commit adfe19738b71a893da62cb2e30bd6bdb4299ea67 ]
Jonathan reports that failed attempts to reset a region (teardown its HDM decoder configuration) mistakenly advance the state of the region to "not committed". Revert to the previous state of the region on reset failure so that the reset can be re-attempted.
--- drivers/cxl/core/region.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-)
drivers/cxl/core/region.c +15 -11
@@ -296,9 +296,11 @@ static ssize_t commit_store(struct device *dev, struct device_attribute *attr,if (rc)return rc; -if (commit) +if (commit) { rc =cxl_region_decode_commit (cxlr); -else { +if (rc ==0 ) + p->state =CXL_CONFIG_COMMIT ; + }else { p->state =CXL_CONFIG_RESET_PENDING ;up_write (&cxl_region_rwsem);device_release_driver (&cxlr->dev);
@@ -308,18 +310,20 @@ static ssize_t commit_store(struct device *dev, struct device_attribute *attr,* The lock was dropped, so need to revalidate that the reset is * still pending. */ -if (p->state ==CXL_CONFIG_RESET_PENDING ) +if (p->state ==CXL_CONFIG_RESET_PENDING ) { rc =cxl_region_decode_reset (cxlr, p->interleave_ways); +/* +* Revert to committed since there may still be active +* decoders associated with this region, or move forward +* to active to mark the reset successful +*/ +if (rc) + p->state =CXL_CONFIG_COMMIT ; +else + p->state =CXL_CONFIG_ACTIVE ; + } } -if (rc) - goto out; - -if (commit) - p->state =CXL_CONFIG_COMMIT ; -else if (p->state ==CXL_CONFIG_RESET_PENDING ) - p->state =CXL_CONFIG_ACTIVE ; - out:up_write (&cxl_region_rwsem);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 537/800 tools/testing/cxl: Fix command effects for inject/clear poison
In reply to Greg Kroah-HartmanFrom: Vishal Verma <[email protected]>
[ Upstream commit b46c5fa57cc60692412f616ac66ab624a941fdb3 ]
The CXL spec (3.0, section 8.2.9.8.4) Lists Inject Poison and Clear Poison as having the effects of "Immediate Data Change". Fix this in the mock driver so that the command effect log is populated correctly.
--- tools/testing/cxl/test/mem.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/testing/cxl/test/mem.c +2 -2
@@ -52,11 +52,11 @@ static struct cxl_cel_entry mock_cel[] = { }, { .opcode = cpu_to_le16(CXL_MBOX_OP_INJECT_POISON), - .effect = cpu_to_le16(0), + .effect = cpu_to_le16(EFFECT(2)), }, { .opcode = cpu_to_le16(CXL_MBOX_OP_CLEAR_POISON), - .effect = cpu_to_le16(0), + .effect = cpu_to_le16(EFFECT(2)), }, };
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 538/800 kbuild: builddeb: always make modules_install, to install modules.builtin*
In reply to Greg Kroah-HartmanFrom: Josh Triplett <[email protected]>
[ Upstream commit 4243afdb932677a03770753be8c54b3190a512e8 ]
Even for a non-modular kernel, the kernel builds modules.builtin and modules.builtin.modinfo, with information about the built-in modules. Tools such as initramfs-tools need these files to build a working initramfs on some systems, such as those requiring firmware.
Now that make modules_install works even in non-modular kernels and installs these files, unconditionally invoke it when building a Debian package.
Stable-dep-of: 1240dabe8d58 ("kbuild: deb-pkg: remove the CONFIG_MODULES check in buildeb")
--- scripts/package/builddeb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/package/builddeb +1 -1
@@ -62,8 +62,8 @@ install_linux_image () { ${MAKE} -f ${srctree}/Makefile INSTALL_DTBS_PATH="${pdir}/usr/lib/linux-image-${KERNELRELEASE}" dtbs_install fi + ${MAKE} -f ${srctree}/Makefile INSTALL_MOD_PATH="${pdir}" modules_install if is_enabled CONFIG_MODULES; then - ${MAKE} -f ${srctree}/Makefile INSTALL_MOD_PATH="${pdir}" modules_install rm -f "${pdir}/lib/modules/${KERNELRELEASE}/build" rm -f "${pdir}/lib/modules/${KERNELRELEASE}/source" if [ "${SRCARCH}" = um ] ; then
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 539/800 kbuild: deb-pkg: remove the CONFIG_MODULES check in buildeb
In reply to Greg Kroah-HartmanFrom: Masahiro Yamada <[email protected]>
[ Upstream commit 1240dabe8d58b4eff09e7edf1560da0360f997aa ]
When CONFIG_MODULES is disabled for ARCH=um, 'make (bin)deb-pkg' fails with an error like follows:
cp: cannot create regular file 'debian/linux-image/usr/lib/uml/modules/6.4.0-rc2+/System.map': No such file or directory
Remove the CONFIG_MODULES check completely so ${pdir}/usr/lib/uml/modules will always be created and modules.builtin.(modinfo) will be installed under it for ARCH=um.
--- scripts/package/builddeb | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
scripts/package/builddeb +4 -8
@@ -63,17 +63,13 @@ install_linux_image () { fi ${MAKE} -f ${srctree}/Makefile INSTALL_MOD_PATH="${pdir}" modules_install - if is_enabled CONFIG_MODULES; then - rm -f "${pdir}/lib/modules/${KERNELRELEASE}/build" - rm -f "${pdir}/lib/modules/${KERNELRELEASE}/source" - if [ "${SRCARCH}" = um ] ; then - mkdir -p "${pdir}/usr/lib/uml/modules" - mv "${pdir}/lib/modules/${KERNELRELEASE}" "${pdir}/usr/lib/uml/modules/${KERNELRELEASE}" - fi - fi + rm -f "${pdir}/lib/modules/${KERNELRELEASE}/build" + rm -f "${pdir}/lib/modules/${KERNELRELEASE}/source" # Install the kernel if [ "${ARCH}" = um ] ; then + mkdir -p "${pdir}/usr/lib/uml/modules" + mv "${pdir}/lib/modules/${KERNELRELEASE}" "${pdir}/usr/lib/uml/modules/${KERNELRELEASE}" mkdir -p "${pdir}/usr/bin" "${pdir}/usr/share/doc/${pname}" cp System.map "${pdir}/usr/lib/uml/modules/${KERNELRELEASE}/System.map" cp ${KCONFIG_CONFIG} "${pdir}/usr/share/doc/${pname}/config"
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 540/800 efi/libstub: Disable PCI DMA before grabbing the EFI memory map
In reply to Greg Kroah-HartmanFrom: Ard Biesheuvel <[email protected]>
[ Upstream commit 2e28a798c3092ea42b968fa16ac835969d124898 ]
Currently, the EFI stub will disable PCI DMA as the very last thing it does before calling ExitBootServices(), to avoid interfering with the firmware's normal operation as much as possible.
However, the stub will invoke DisconnectController() on all endpoints downstream of the PCI bridges it disables, and this may affect the layout of the EFI memory map, making it substantially more likely that ExitBootServices() will fail the first time around, and that the EFI memory map needs to be reloaded.
This, in turn, increases the likelihood that the slack space we allocated is insufficient (and we can no longer allocate memory via boot services after having called ExitBootServices() once), causing the second call to GetMemoryMap (and therefore the boot) to fail. This makes the PCI DMA disable feature a bit more fragile than it already is, so let's make it more robust, by allocating the space for the EFI memory map after disabling PCI DMA.
--- drivers/firmware/efi/libstub/efi-stub-helper.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/firmware/efi/libstub/efi-stub-helper.c +3 -3
@@ -378,6 +378,9 @@ efi_status_t efi_exit_boot_services(void *handle, void *priv,struct efi_boot_memmap *map;efi_status_t status; +if (efi_disable_pci_dma) +efi_pci_disable_bridge_busmaster (); + status =efi_get_memory_map (&map, true);if (status !=EFI_SUCCESS )return status;
@@ -388,9 +391,6 @@ efi_status_t efi_exit_boot_services(void *handle, void *priv,return status; } -if (efi_disable_pci_dma) -efi_pci_disable_bridge_busmaster (); - status =efi_bs_call (exit_boot_services, handle, map->map_key);if (status ==EFI_INVALID_PARAMETER ) {
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 541/800 cifs: prevent use-after-free by freeing the cfile later
In reply to Greg Kroah-HartmanFrom: Shyam Prasad N <[email protected]>
[ Upstream commit 33f736187d08f6bc822117629f263b97d3df4165 ]
In smb2_compound_op we have a possible use-after-free which can cause hard to debug problems later on.
This was revealed during stress testing with KASAN enabled kernel. Fixing it by moving the cfile free call to a few lines below, after the usage.
--- fs/smb/client/smb2inode.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
fs/smb/client/smb2inode.c +3 -3
@@ -398,9 +398,6 @@ static int smb2_compound_op(const unsigned int xid, struct cifs_tcon *tcon, rsp_iov); finished: -if (cfile) -cifsFileInfo_put (cfile); -SMB2_open_free (&rqst[0 ]);if (rc == -EREMCHG ) {pr_warn_once ("server share %s deleted\n" , tcon->tree_name);
@@ -529,6 +526,9 @@ static int smb2_compound_op(const unsigned int xid, struct cifs_tcon *tcon,break ; } +if (cfile) +cifsFileInfo_put (cfile); +if (rc && err_iov && err_buftype) {memcpy (err_iov, rsp_iov,3 *sizeof (*err_iov));memcpy (err_buftype, resp_buftype,3 *sizeof (*err_buftype));
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 542/800 cifs: do all necessary checks for credits within or before locking
In reply to Greg Kroah-HartmanFrom: Shyam Prasad N <[email protected]>
[ Upstream commit 326a8d04f147e2bf393f6f9cdb74126ee6900607 ]
All the server credits and in-flight info is protected by req_lock. Once the req_lock is held, and we've determined that we have enough credits to continue, this lock cannot be dropped till we've made the changes to credits and in-flight count.
However, we used to drop the lock in order to avoid deadlock with the recent srv_lock. This could cause the checks already made to be invalidated.
Fixed it by moving the server status check to before locking req_lock.
--- fs/smb/client/smb2ops.c | 19 ++++++++++--------- fs/smb/client/transport.c | 20 ++++++++++---------- 2 files changed, 20 insertions(+), 19 deletions(-)
fs/smb/client/smb2ops.c +10 -9
@@ -211,6 +211,16 @@ smb2_wait_mtu_credits(struct TCP_Server_Info *server, unsigned int size,spin_lock (&server->req_lock);while (1 ) { +spin_unlock (&server->req_lock); + +spin_lock (&server->srv_lock); +if (server->tcpStatus == CifsExiting) { +spin_unlock (&server->srv_lock); +return -ENOENT ; + } +spin_unlock (&server->srv_lock); + +spin_lock (&server->req_lock);if (server->credits <=0 ) {spin_unlock (&server->req_lock);cifs_num_waiters_inc (server);
@@ -221,15 +231,6 @@ smb2_wait_mtu_credits(struct TCP_Server_Info *server, unsigned int size,return rc;spin_lock (&server->req_lock); }else { -spin_unlock (&server->req_lock); -spin_lock (&server->srv_lock); -if (server->tcpStatus == CifsExiting) { -spin_unlock (&server->srv_lock); -return -ENOENT ; - } -spin_unlock (&server->srv_lock); - -spin_lock (&server->req_lock); scredits = server->credits;/* can deadlock with reopen */ if (scredits <=8 ) {
fs/smb/client/transport.c +10 -10
@@ -522,6 +522,16 @@ wait_for_free_credits(struct TCP_Server_Info *server, const int num_credits, }while (1 ) { +spin_unlock (&server->req_lock); + +spin_lock (&server->srv_lock); +if (server->tcpStatus == CifsExiting) { +spin_unlock (&server->srv_lock); +return -ENOENT ; + } +spin_unlock (&server->srv_lock); + +spin_lock (&server->req_lock);if (*credits < num_credits) { scredits = *credits;spin_unlock (&server->req_lock);
@@ -547,15 +557,6 @@ wait_for_free_credits(struct TCP_Server_Info *server, const int num_credits,return -ERESTARTSYS ;spin_lock (&server->req_lock); }else { -spin_unlock (&server->req_lock); - -spin_lock (&server->srv_lock); -if (server->tcpStatus == CifsExiting) { -spin_unlock (&server->srv_lock); -return -ENOENT ; - } -spin_unlock (&server->srv_lock); -/* * For normal commands, reserve the last MAX_COMPOUND * credits to compound requests.
@@ -569,7 +570,6 @@ wait_for_free_credits(struct TCP_Server_Info *server, const int num_credits,* for servers that are slow to hand out credits on * new sessions. */ -spin_lock (&server->req_lock);if (!optype && num_credits ==1 && server->in_flight >2 *MAX_COMPOUND && *credits <=MAX_COMPOUND ) {
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 543/800 smb: client: fix broken file attrs with nodfs mounts
In reply to Greg Kroah-HartmanFrom: Paulo Alcantara <[email protected]>
[ Upstream commit d439b29057e26464120fc6c18f97433aa003b5fe ]
*_get_inode_info() functions expect -EREMOTE when query path info calls find a DFS link, regardless whether !CONFIG_CIFS_DFS_UPCALL or 'nodfs' mount option. Otherwise, those files will miss the fake DFS file attributes.
Before patch
$ mount.cifs //srv/dfs /mnt/1 -o ...,nodfs $ ls -l /mnt/1 ls: cannot access '/mnt/1/link': Operation not supported total 0 -rwxr-xr-x 1 root root 0 Jul 26 2022 dfstest2_file1.txt drwxr-xr-x 2 root root 0 Aug 8 2022 dir1 d????????? ? ? ? ? ? link
After patch
$ mount.cifs //srv/dfs /mnt/1 -o ...,nodfs $ ls -l /mnt/1 total 0 -rwxr-xr-x 1 root root 0 Jul 26 2022 dfstest2_file1.txt drwxr-xr-x 2 root root 0 Aug 8 2022 dir1 drwx--x--x 2 root root 0 Jun 26 20:29 link
--- fs/smb/client/smb2inode.c | 3 --- 1 file changed, 3 deletions(-)
fs/smb/client/smb2inode.c +0 -3
@@ -609,9 +609,6 @@ int smb2_query_path_info(const unsigned int xid, struct cifs_tcon *tcon,if (islink) rc = -EREMOTE ; } -if (rc == -EREMOTE &&IS_ENABLED (CONFIG_CIFS_DFS_UPCALL ) && cifs_sb && - (cifs_sb->mnt_cifs_flags &CIFS_MOUNT_NO_DFS )) - rc = -EOPNOTSUPP ; } out:
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 544/800 smb: client: fix shared DFS root mounts with different prefixes
In reply to Greg Kroah-HartmanFrom: Paulo Alcantara <[email protected]>
[ Upstream commit 3ae872de410751fe5e629e04da491a632d95201c ]
When having two DFS root mounts that are connected to same namespace, same mount options but different prefix paths, we can't really use the shared @server->origin_fullpath when chasing DFS links in them.
Move the origin_fullpath field to cifs_tcon structure so when having shared DFS root mounts with different prefix paths, and we need to chase any DFS links, dfs_get_automount_devname() will pick up the correct full path out of the @tcon that will be used for the new mount.
Before patch
mount.cifs //dom/dfs/dir /mnt/1 -o ...
mount.cifs //dom/dfs /mnt/2 -o ...
# shared server, ses, tcon # server: origin_fullpath=//dom/dfs/dir
# @server->origin_fullpath + '/dir/link1'
$ ls /mnt/2/dir/link1 ls: cannot open directory '/mnt/2/dir/link1': No such file or directory
After patch
mount.cifs //dom/dfs/dir /mnt/1 -o ...
mount.cifs //dom/dfs /mnt/2 -o ...
# shared server & ses # tcon_1: origin_fullpath=//dom/dfs/dir # tcon_2: origin_fullpath=//dom/dfs
# @tcon_2->origin_fullpath + '/dir/link1'
$ ls /mnt/2/dir/link1 dir0 dir1 dir10 dir3 dir5 dir6 dir7 dir9 target2_file.txt tsub
--- fs/smb/client/cifs_debug.c | 16 +++++---- fs/smb/client/cifsglob.h | 10 +++--- fs/smb/client/cifsproto.h | 2 +- fs/smb/client/connect.c | 70 ++++++++++++++++++++++---------------- fs/smb/client/dfs.c | 55 ++++++++++++------------------ fs/smb/client/dfs.h | 19 +++++------ fs/smb/client/dfs_cache.c | 8 +++-- fs/smb/client/misc.c | 38 ++++++++++++++++----- 8 files changed, 118 insertions(+), 100 deletions(-)
fs/smb/client/cifs_debug.c +9 -7
@@ -122,6 +122,12 @@ static void cifs_debug_tcon(struct seq_file *m, struct cifs_tcon *tcon)seq_puts (m," nosparse" );if (tcon->need_reconnect)seq_puts (m,"\tDISCONNECTED " ); +spin_lock (&tcon->tc_lock); +if (tcon->origin_fullpath) { +seq_printf (m,"\n\tDFS origin fullpath: %s" , + tcon->origin_fullpath); + } +spin_unlock (&tcon->tc_lock);seq_putc (m,'\n' ); }
@@ -427,13 +433,9 @@ static int cifs_debug_data_proc_show(struct seq_file *m, void *v)seq_printf (m,"\nIn Send: %d In MaxReq Wait: %d" ,atomic_read (&server->in_send),atomic_read (&server->num_waiters)); -if (IS_ENABLED (CONFIG_CIFS_DFS_UPCALL )) { -if (server->origin_fullpath) -seq_printf (m,"\nDFS origin full path: %s" , - server->origin_fullpath); -if (server->leaf_fullpath) -seq_printf (m,"\nDFS leaf full path: %s" , - server->leaf_fullpath); +if (server->leaf_fullpath) { +seq_printf (m,"\nDFS leaf full path: %s" , + server->leaf_fullpath); }seq_printf (m,"\n\n\tSessions: " );
fs/smb/client/cifsglob.h +4 -6
@@ -736,23 +736,20 @@ struct TCP_Server_Info {#endif struct mutex refpath_lock;/* protects leaf_fullpath */ /* -* origin_fullpath: Canonical copy of smb3_fs_context::source. -* It is used for matching existing DFS tcons. -* * leaf_fullpath: Canonical DFS referral path related to this * connection. * It is used in DFS cache refresher, reconnect and may * change due to nested DFS links. * -* Both protected by @refpath_lock and @srv_lock. The @refpath_lock is -* mosly used for not requiring a copy of @leaf_fullpath when getting +* Protected by @refpath_lock and @srv_lock. The @refpath_lock is +* mostly used for not requiring a copy of @leaf_fullpath when getting * cached or new DFS referrals (which might also sleep during I/O). * While @srv_lock is held for making string and NULL comparions against * both fields as in mount(2) and cache refresh. * * format: \\HOST\SHARE[\OPTIONAL PATH] */ -char *origin_fullpath, *leaf_fullpath; +char *leaf_fullpath; };static inline bool is_smb1 (struct TCP_Server_Info *server)
@@ -1205,6 +1202,7 @@ struct cifs_tcon {struct delayed_work dfs_cache_work;#endif struct delayed_work query_interfaces;/* query interfaces workqueue job */ +char *origin_fullpath;/* canonical copy of smb3_fs_context::source */ };/*
fs/smb/client/cifsproto.h +1 -1
@@ -650,7 +650,7 @@ int smb2_parse_query_directory(struct cifs_tcon *tcon, struct kvec *rsp_iov,int resp_buftype, struct cifs_search_info *srch_inf); -struct super_block *cifs_get_tcp_super (struct TCP_Server_Info *server); +struct super_block *cifs_get_dfs_tcon_super (struct cifs_tcon *tcon);void cifs_put_tcp_super (struct super_block *sb);int cifs_update_super_prepath (struct cifs_sb_info *cifs_sb,char *prefix);char *extract_hostname (const char *unc);
fs/smb/client/connect.c +40 -30
132 lines not on this page · raw message
fs/smb/client/dfs.c +21 -34
109 lines not on this page · raw message
fs/smb/client/dfs.h +9 -10
@@ -39,16 +39,15 @@ static inline char *dfs_get_automount_devname(struct dentry *dentry, void *page) {struct cifs_sb_info *cifs_sb =CIFS_SB (dentry->d_sb);struct cifs_tcon *tcon =cifs_sb_master_tcon (cifs_sb); -struct TCP_Server_Info *server = tcon->ses->server;size_t len;char *s; -spin_lock (&server->srv_lock); -if (unlikely (!server->origin_fullpath)) { -spin_unlock (&server->srv_lock); +spin_lock (&tcon->tc_lock); +if (unlikely (!tcon->origin_fullpath)) { +spin_unlock (&tcon->tc_lock);return ERR_PTR (-EREMOTE ); } -spin_unlock (&server->srv_lock); +spin_unlock (&tcon->tc_lock); s =dentry_path_raw (dentry, page,PATH_MAX );if (IS_ERR (s))
@@ -57,16 +56,16 @@ static inline char *dfs_get_automount_devname(struct dentry *dentry, void *page)if (!s[1 ]) s++; -spin_lock (&server->srv_lock); - len =strlen (server->origin_fullpath); +spin_lock (&tcon->tc_lock); + len =strlen (tcon->origin_fullpath);if (s < (char *)page + len) { -spin_unlock (&server->srv_lock); +spin_unlock (&tcon->tc_lock);return ERR_PTR (-ENAMETOOLONG ); } s -= len; -memcpy (s, server->origin_fullpath, len); -spin_unlock (&server->srv_lock); +memcpy (s, tcon->origin_fullpath, len); +spin_unlock (&tcon->tc_lock);convert_delimiter (s,'/' );return s;
fs/smb/client/dfs_cache.c +5 -3
@@ -1248,18 +1248,20 @@ static int refresh_tcon(struct cifs_tcon *tcon, bool force_refresh)int dfs_cache_remount_fs (struct cifs_sb_info *cifs_sb) {struct cifs_tcon *tcon; -struct TCP_Server_Info *server;if (!cifs_sb || !cifs_sb->master_tlink)return -EINVAL ; tcon =cifs_sb_master_tcon (cifs_sb); - server = tcon->ses->server; -if (!server->origin_fullpath) { +spin_lock (&tcon->tc_lock); +if (!tcon->origin_fullpath) { +spin_unlock (&tcon->tc_lock);cifs_dbg (FYI ,"%s: not a dfs mount\n" , __func__);return 0 ; } +spin_unlock (&tcon->tc_lock); +/* * After reconnecting to a different server, unique ids won't match anymore, so we disable * serverino. This prevents dentry revalidation to think the dentry are stale (ESTALE).
fs/smb/client/misc.c +29 -9
@@ -156,6 +156,7 @@ tconInfoFree(struct cifs_tcon *tcon)#ifdef CONFIG_CIFS_DFS_UPCALL dfs_put_root_smb_sessions (&tcon->dfs_ses_list);#endif +kfree (tcon->origin_fullpath);kfree (tcon); }
@@ -1106,20 +1107,25 @@ struct super_cb_data {struct super_block *sb; }; -static void tcp_super_cb (struct super_block *sb,void *arg) +static void tcon_super_cb (struct super_block *sb,void *arg) {struct super_cb_data *sd = arg; -struct TCP_Server_Info *server = sd->data;struct cifs_sb_info *cifs_sb; -struct cifs_tcon *tcon; +struct cifs_tcon *t1 = sd->data, *t2;if (sd->sb)return ; cifs_sb =CIFS_SB (sb); - tcon =cifs_sb_master_tcon (cifs_sb); -if (tcon->ses->server == server) + t2 =cifs_sb_master_tcon (cifs_sb); + +spin_lock (&t2->tc_lock); +if (t1->ses == t2->ses && + t1->ses->server == t2->ses->server && + t2->origin_fullpath && +dfs_src_pathname_equal (t2->origin_fullpath, t1->origin_fullpath)) sd->sb = sb; +spin_unlock (&t2->tc_lock); } static struct super_block *__cifs_get_super(void (*f)(struct super_block *, void *),
@@ -1145,6 +1151,7 @@ static struct super_block *__cifs_get_super(void (*f)(struct super_block *, voidreturn sd.sb; } } +pr_warn_once ("%s: could not find dfs superblock\n" , __func__);return ERR_PTR (-EINVAL ); }
@@ -1154,9 +1161,15 @@ static void __cifs_put_super(struct super_block *sb)cifs_sb_deactive (sb); } -struct super_block *cifs_get_tcp_super (struct TCP_Server_Info *server) +struct super_block *cifs_get_dfs_tcon_super (struct cifs_tcon *tcon) { -return __cifs_get_super (tcp_super_cb, server); +spin_lock (&tcon->tc_lock); +if (!tcon->origin_fullpath) { +spin_unlock (&tcon->tc_lock); +return ERR_PTR (-ENOENT ); + } +spin_unlock (&tcon->tc_lock); +return __cifs_get_super (tcon_super_cb, tcon); }void cifs_put_tcp_super (struct super_block *sb)
@@ -1238,9 +1251,16 @@ int cifs_inval_name_dfs_link_error(const unsigned int xid,*/ if (strlen (full_path) <2 || !cifs_sb || (cifs_sb->mnt_cifs_flags &CIFS_MOUNT_NO_DFS ) || - !is_tcon_dfs (tcon) || !ses->server->origin_fullpath) + !is_tcon_dfs (tcon))return 0 ; +spin_lock (&tcon->tc_lock); +if (!tcon->origin_fullpath) { +spin_unlock (&tcon->tc_lock); +return 0 ; + } +spin_unlock (&tcon->tc_lock); +/* * Slow path - tcon is DFS and @full_path has prefix path, so attempt * to get a referral to figure out whether it is an DFS link.
@@ -1264,7 +1284,7 @@ int cifs_inval_name_dfs_link_error(const unsigned int xid,/* * XXX: we are not using dfs_cache_find() here because we might -* end filling all the DFS cache and thus potentially +* end up filling all the DFS cache and thus potentially * removing cached DFS targets that the client would eventually * need during failover. */
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 545/800 ksmbd: avoid field overflow warning
In reply to Greg Kroah-HartmanFrom: Arnd Bergmann <[email protected]>
[ Upstream commit 9cedc58bdbe9fff9aacd0ca19ee5777659f28fd7 ]
clang warns about a possible field overflow in a memcpy:
In file included from fs/smb/server/smb_common.c:7:include/linux/fortify-string.h:583:4: error: call to '__write_overflow_field' declared with 'warning' attribute: detected write beyond size of field (1st parameter); maybe use struct_group()? [-Werror,-Wattribute-warning]
__write_overflow_field(p_size_field, size);
It appears to interpret the "&out[baselen + 4]" as referring to a single byte of the character array, while the equivalen "out + baselen + 4" is seen as an offset into the array.
I don't see that kind of warning elsewhere, so just go with the simple rework.
--- fs/smb/server/smb_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/smb/server/smb_common.c +1 -1
@@ -536,7 +536,7 @@ int ksmbd_extract_shortname(struct ksmbd_conn *conn, const char *longname, out[baselen +3 ] =PERIOD ;if (dot_present) -memcpy (&out[baselen +4 ], extension,4 ); +memcpy (out + baselen +4 , extension,4 );else out[baselen +4 ] ='\0' ; smbConvertToUTF16((__le16 *)shortname, out, PATH_MAX,
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 546/800 arm64: sme: Use STR P to clear FFR context field in streaming SVE mode
In reply to Greg Kroah-HartmanFrom: Will Deacon <[email protected]>
[ Upstream commit 893b24181b4c4bf1fa2841b1ed192e5413a97cb1 ]
The FFR is a predicate register which can vary between 16 and 256 bits in size depending upon the configured vector length. When saving the SVE state in streaming SVE mode, the FFR register is inaccessible and so commit 9f5848665788 ("arm64/sve: Make access to FFR optional") simply clears the FFR field of the in-memory context structure. Unfortunately, it achieves this using an unconditional 8-byte store and so if the SME vector length is anything other than 64 bytes in size we will either fail to clear the entire field or, worse, we will corrupt memory immediately following the structure. This has led to intermittent kfence splats in CI [1] and can trigger kmalloc Redzone corruption messages when running the 'fp-stress' kselftest:
| ============================================================================= | BUG kmalloc-1k (Not tainted): kmalloc Redzone overwritten | ----------------------------------------------------------------------------- | | 0xffff000809bf1e22-0xffff000809bf1e27 @offset=7714. First byte 0x0 instead of 0xcc | Allocated in do_sme_acc+0x9c/0x220 age=2613 cpu=1 pid=531 | __kmalloc+0x8c/0xcc | do_sme_acc+0x9c/0x220 | ...
Replace the 8-byte store with a store of a predicate register which has been zero-initialised with PFALSE, ensuring that the entire field is cleared in memory.
[1] https://lore.kernel.org/r/CA+G9fYtU7HsV0R0dp4XEH5xXHSJFw8KyDf5VQrLLfMxWfxQkag@mail.gmail.com
--- arch/arm64/include/asm/fpsimdmacros.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/arm64/include/asm/fpsimdmacros.h +3 -3
@@ -316,12 +316,12 @@ _for n, 0, 15, _sve_str_p \n, \nxbase, \n - 16 cbz \save_ffr, 921f _sve_rdffr 0 - _sve_str_p 0, \nxbase - _sve_ldr_p 0, \nxbase, -16 b 922f 921: - str xzr, [x\nxbase] // Zero out FFR + _sve_pfalse 0 // Zero out FFR 922: + _sve_str_p 0, \nxbase + _sve_ldr_p 0, \nxbase, -16 mrs x\nxtmp, fpsr str w\nxtmp, [\xpfpsr] mrs x\nxtmp, fpcr
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 547/800 x86/efi: Make efi_set_virtual_address_map IBT safe
In reply to Greg Kroah-HartmanFrom: Thomas Gleixner <[email protected]>
[ Upstream commit 0303c9729afc4094ef53e552b7b8cff7436028d6 ]
Niklāvs reported a boot regression on an Alderlake machine and bisected it to commit 9df9d2f0471b ("init: Invoke arch_cpu_finalize_init() earlier").
By moving the invocation of arch_cpu_finalize_init() further down he identified that efi_enter_virtual_mode() is the function which causes the boot hang.
The main difference of the earlier invocation is that the boot CPU is already fully initialized and mitigations and alternatives are applied.
But the only really interesting change turned out to be IBT, which is now enabled before efi_enter_virtual_mode(). "ibt=off" on the kernel command line cured the problem.
Inspection of the involved calls in efi_enter_virtual_mode() unearthed that efi_set_virtual_address_map() is the only place in the kernel which invokes an EFI call without the IBT safe wrapper. This went obviously unnoticed so far as IBT was enabled later.
Use arch_efi_call_virt() instead of efi_call() to cure that.
--- arch/x86/platform/efi/efi_64.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/x86/platform/efi/efi_64.c +3 -3
@@ -853,9 +853,9 @@ efi_set_virtual_address_map(unsigned long memory_map_size,/* Disable interrupts around EFI calls: */ local_irq_save (flags); - status =efi_call (efi.runtime->set_virtual_address_map, - memory_map_size, descriptor_size, - descriptor_version, virtual_map); + status =arch_efi_call_virt (efi.runtime, set_virtual_address_map, + memory_map_size, descriptor_size, + descriptor_version, virtual_map);local_irq_restore (flags);efi_fpu_end ();
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 548/800 w1: w1_therm: fix locking behavior in convert_t
In reply to Greg Kroah-HartmanFrom: Stefan Wahren <[email protected]>
[ Upstream commit dca5480ab7b77a889088ab7cac81934604510ac7 ]
The commit 67b392f7b8ed ("w1_therm: optimizing temperature read timings") accidentially inverted the logic for lock handling of the bus mutex.
Before:
pullup -> release lock before sleep
no pullup -> release lock after sleep
After:
pullup -> release lock after sleep
no pullup -> release lock before sleep
This cause spurious measurements of 85 degree (powerup value) on the Tarragon board with connected 1-w temperature sensor (w1_therm.w1_strong_pull=0).
In the meantime a new feature for polling the conversion completion has been integrated in these branches with commit 021da53e65fd ("w1: w1_therm: Add sysfs entries to control conversion time and driver features"). But this feature isn't available for parasite power mode, so handle this separately.
--- drivers/w1/slaves/w1_therm.c | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-)
drivers/w1/slaves/w1_therm.c +14 -17
@@ -1159,29 +1159,26 @@ static int convert_t(struct w1_slave *sl, struct therm_info *info)w1_write_8 (dev_master,W1_CONVERT_TEMP ); -if (strong_pullup) {/*some device need pullup */ +if (SLAVE_FEATURES (sl) &W1_THERM_POLL_COMPLETION ) { + ret =w1_poll_completion (dev_master,W1_POLL_CONVERT_TEMP ); +if (ret) { +dev_dbg (&sl->dev,"%s: Timeout\n" , __func__); + goto mt_unlock; + } +mutex_unlock (&dev_master->bus_mutex); + }else if (!strong_pullup) {/*no device need pullup */ sleep_rem =msleep_interruptible (t_conv);if (sleep_rem !=0 ) { ret = -EINTR ; goto mt_unlock; }mutex_unlock (&dev_master->bus_mutex); - }else {/*no device need pullup */ -if (SLAVE_FEATURES (sl) &W1_THERM_POLL_COMPLETION ) { - ret =w1_poll_completion (dev_master,W1_POLL_CONVERT_TEMP ); -if (ret) { -dev_dbg (&sl->dev,"%s: Timeout\n" , __func__); - goto mt_unlock; - } -mutex_unlock (&dev_master->bus_mutex); - }else { -/* Fixed delay */ -mutex_unlock (&dev_master->bus_mutex); - sleep_rem =msleep_interruptible (t_conv); -if (sleep_rem !=0 ) { - ret = -EINTR ; - goto dec_refcnt; - } + }else {/*some device need pullup */ +mutex_unlock (&dev_master->bus_mutex); + sleep_rem =msleep_interruptible (t_conv); +if (sleep_rem !=0 ) { + ret = -EINTR ; + goto dec_refcnt; } } ret =read_scratchpad (sl, info);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 549/800 w1: fix loop in w1_fini()
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit 83f3fcf96fcc7e5405b37d9424c7ef26bfa203f8 ]
The __w1_remove_master_device() function calls:
list_del(&dev->w1_master_entry);
So presumably this can cause an endless loop.
--- drivers/w1/w1.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/w1/w1.c +2 -2
@@ -1263,10 +1263,10 @@ static int __init w1_init(void) static void __exit w1_fini(void) { -struct w1_master *dev; +struct w1_master *dev, *n;/* Set netlink removal messages and some cleanup */ -list_for_each_entry (dev, &w1_masters, w1_master_entry) +list_for_each_entry_safe (dev, n, &w1_masters, w1_master_entry)__w1_remove_master_device (dev);w1_fini_netlink ();
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 550/800 dt-bindings: power: reset: qcom-pon: Only allow reboot-mode pre-pmk8350
In reply to Greg Kroah-HartmanFrom: Konrad Dybcio <[email protected]>
[ Upstream commit d41dab4c031edaa460a484113394327aa52dc0bd ]
As pointed out by Shazad [1], PMICs using a separate HLOS+PBS scheme (so PMK8350 and newer) are expected to pass reboot mode data through SDAM, as the reboot mode registers are absent in the HLOS reg space.
Limit the reboot-mode.yaml inclusion to PMICs without a separate PBS region.
[1] https://lore.kernel.org/linux-arm-msm/[email protected]/
--- Documentation/devicetree/bindings/power/reset/qcom,pon.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/power/reset/qcom,pon.yaml +3 -1
@@ -56,7 +56,6 @@ required: unevaluatedProperties: false allOf: - - $ref: reboot-mode.yaml# - if: properties: compatible:
@@ -66,6 +65,9 @@ allOf: - qcom,pms405-pon - qcom,pm8998-pon then: + allOf: + - $ref: reboot-mode.yaml# + properties: reg: maxItems: 1
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 551/800 f2fs: do not allow to defragment files have FI_COMPRESS_RELEASED
In reply to Greg Kroah-HartmanFrom: Yangtao Li <[email protected]>
[ Upstream commit 7cd2e5f75b86a1befa99834f3ed1d735eeff69e6 ]
If a file has FI_COMPRESS_RELEASED, all writes for it should not be allowed.
--- fs/f2fs/file.c | 6 ++++++ 1 file changed, 6 insertions(+)
fs/f2fs/file.c +6 -0
@@ -2593,6 +2593,11 @@ static int f2fs_defragment_range(struct f2fs_sb_info *sbi,inode_lock (inode); +if (is_inode_flag_set (inode,FI_COMPRESS_RELEASED )) { + err = -EINVAL ; + goto unlock_out; + } +/* if in-place-update policy is enabled, don't waste time here */ set_inode_flag (inode,FI_OPU_WRITE );if (f2fs_should_update_inplace (inode,NULL )) {
@@ -2717,6 +2722,7 @@ static int f2fs_defragment_range(struct f2fs_sb_info *sbi,clear_inode_flag (inode,FI_SKIP_WRITES ); out:clear_inode_flag (inode,FI_OPU_WRITE ); +unlock_out:inode_unlock (inode);if (!err) range->len = (u64 )total <<PAGE_SHIFT ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 552/800 sh: j2: Use ioremap() to translate device tree address into kernel memory
In reply to Greg Kroah-HartmanFrom: John Paul Adrian Glaubitz <[email protected]>
[ Upstream commit bc9d1f0cecd2407cfb2364a7d4be2f52d1d46a9d ]
Addresses the following warning when building j2_defconfig:
arch/sh/kernel/cpu/sh2/probe.c: In function 'scan_cache':arch/sh/kernel/cpu/sh2/probe.c:24:16: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
24 | j2_ccr_base = (u32 __iomem *)of_flat_dt_translate_address(node);
|--- arch/sh/kernel/cpu/sh2/probe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/sh/kernel/cpu/sh2/probe.c +1 -1
@@ -21,7 +21,7 @@ static int __init scan_cache(unsigned long node, const char *uname,if (!of_flat_dt_is_compatible (node,"jcore,cache" ))return 0 ; - j2_ccr_base = (u32 __iomem *)of_flat_dt_translate_address (node); + j2_ccr_base =ioremap (of_flat_dt_translate_address (node),4 );return 1 ; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 553/800 cpufreq: tegra194: Fix an error handling path in tegra194_cpufreq_probe()
In reply to Greg Kroah-HartmanFrom: Christophe JAILLET <[email protected]>
[ Upstream commit 9ab24b0486681ecc059ee766e00d9570c6311e08 ]
If the probe needs to be deferred, some resources still need to be released. So branch to the error handling path instead of returning directly.
--- drivers/cpufreq/tegra194-cpufreq.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/cpufreq/tegra194-cpufreq.c +4 -2
@@ -686,8 +686,10 @@ static int tegra194_cpufreq_probe(struct platform_device *pdev)/* Check for optional OPPv2 and interconnect paths on CPU0 to enable ICC scaling */ cpu_dev =get_cpu_device (0 ); -if (!cpu_dev) -return -EPROBE_DEFER ; +if (!cpu_dev) { + err = -EPROBE_DEFER ; + goto err_free_res; + }if (dev_pm_opp_of_get_opp_desc_node (cpu_dev)) { err =dev_pm_opp_of_find_icc_paths (cpu_dev,NULL );
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 554/800 USB: Extend pci resume function to handle PM events
In reply to Greg Kroah-HartmanFrom: Basavaraj Natikar <[email protected]>
[ Upstream commit 1f7d5520719dd1fed1a2947679f6cc26a55f1e6b ]
Currently, the pci_resume method has only a flag indicating whether the system is resuming from hibernation. In order to handle all PM events like AUTO_RESUME (runtime resume from device in D3), RESUME (system resume from s2idle, S3 or S4 states) etc change the pci_resume method to handle all PM events.
Stable-dep-of: 1c024241d018 ("xhci: Improve the XHCI system resume time")
--- drivers/usb/core/hcd-pci.c | 24 +++++++++++++----------- drivers/usb/host/ehci-pci.c | 3 ++- drivers/usb/host/ohci-pci.c | 8 +++++++- drivers/usb/host/uhci-pci.c | 7 ++++--- drivers/usb/host/xhci-histb.c | 2 +- drivers/usb/host/xhci-pci.c | 4 ++-- drivers/usb/host/xhci-plat.c | 4 ++-- drivers/usb/host/xhci-tegra.c | 2 +- drivers/usb/host/xhci.c | 3 ++- drivers/usb/host/xhci.h | 2 +- include/linux/usb/hcd.h | 2 +- 11 files changed, 36 insertions(+), 25 deletions(-)
drivers/usb/core/hcd-pci.c +13 -11
@@ -415,12 +415,15 @@ static int check_root_hub_suspended(struct device *dev)return 0 ; } -static int suspend_common (struct device *dev,bool do_wakeup) +static int suspend_common (struct device *dev,pm_message_t msg) {struct pci_dev *pci_dev =to_pci_dev (dev);struct usb_hcd *hcd =pci_get_drvdata (pci_dev); +bool do_wakeup;int retval; + do_wakeup =PMSG_IS_AUTO (msg) ? true :device_may_wakeup (dev); +/* Root hub suspend should have stopped all downstream traffic, * and all bus master traffic. And done so for both the interface * and the stub usb_device (which we check here). But maybe it
@@ -447,7 +450,7 @@ static int suspend_common(struct device *dev, bool do_wakeup) (retval == 0 && do_wakeup && hcd->shared_hcd && HCD_WAKEUP_PENDING(hcd->shared_hcd))) {if (hcd->driver->pci_resume) - hcd->driver->pci_resume (hcd, false); + hcd->driver->pci_resume (hcd, msg); retval = -EBUSY ; }if (retval)
@@ -470,7 +473,7 @@ static int suspend_common(struct device *dev, bool do_wakeup)return retval; } -static int resume_common (struct device *dev,int event) +static int resume_common (struct device *dev,pm_message_t msg) {struct pci_dev *pci_dev =to_pci_dev (dev);struct usb_hcd *hcd =pci_get_drvdata (pci_dev);
@@ -498,12 +501,11 @@ static int resume_common(struct device *dev, int event)* No locking is needed because PCI controller drivers do not * get unbound during system resume. */ -if (pci_dev->class ==CL_EHCI && event !=PM_EVENT_AUTO_RESUME ) +if (pci_dev->class ==CL_EHCI && msg.event !=PM_EVENT_AUTO_RESUME )for_each_companion (pci_dev, hcd, ehci_wait_for_companions); - retval = hcd->driver->pci_resume (hcd, - event ==PM_EVENT_RESTORE ); + retval = hcd->driver->pci_resume (hcd, msg);if (retval) {dev_err (dev,"PCI post-resume error %d!\n" , retval);usb_hc_died (hcd);
@@ -516,7 +518,7 @@ static int resume_common(struct device *dev, int event)static int hcd_pci_suspend (struct device *dev) { -return suspend_common (dev,device_may_wakeup (dev)); +return suspend_common (dev,PMSG_SUSPEND ); }static int hcd_pci_suspend_noirq (struct device *dev)
@@ -577,12 +579,12 @@ static int hcd_pci_resume_noirq(struct device *dev)static int hcd_pci_resume (struct device *dev) { -return resume_common (dev,PM_EVENT_RESUME ); +return resume_common (dev,PMSG_RESUME ); }static int hcd_pci_restore (struct device *dev) { -return resume_common (dev,PM_EVENT_RESTORE ); +return resume_common (dev,PMSG_RESTORE ); }#else
@@ -600,7 +602,7 @@ static int hcd_pci_runtime_suspend(struct device *dev) {int retval; - retval =suspend_common (dev, true); + retval =suspend_common (dev,PMSG_AUTO_SUSPEND );if (retval ==0 )powermac_set_asic (to_pci_dev (dev),0 );dev_dbg (dev,"hcd_pci_runtime_suspend: %d\n" , retval);
@@ -612,7 +614,7 @@ static int hcd_pci_runtime_resume(struct device *dev)int retval;powermac_set_asic (to_pci_dev (dev),1 ); - retval =resume_common (dev,PM_EVENT_AUTO_RESUME ); + retval =resume_common (dev,PMSG_AUTO_RESUME );dev_dbg (dev,"hcd_pci_runtime_resume: %d\n" , retval);return retval; }
drivers/usb/host/ehci-pci.c +2 -1
@@ -354,10 +354,11 @@ static int ehci_pci_setup(struct usb_hcd *hcd)* Also they depend on separate root hub suspend/resume. */ -static int ehci_pci_resume (struct usb_hcd *hcd,bool hibernated) +static int ehci_pci_resume (struct usb_hcd *hcd,pm_message_t msg) {struct ehci_hcd *ehci =hcd_to_ehci (hcd);struct pci_dev *pdev =to_pci_dev (hcd->self.controller); +bool hibernated = (msg.event ==PM_EVENT_RESTORE );if (ehci_resume (hcd, hibernated) !=0 ) (void )ehci_pci_reinit (ehci, pdev);
drivers/usb/host/ohci-pci.c +7 -1
@@ -301,6 +301,12 @@ static struct pci_driver ohci_pci_driver = {#endif }; +#ifdef CONFIG_PM +static int ohci_pci_resume (struct usb_hcd *hcd,pm_message_t msg) +{ +return ohci_resume (hcd, msg.event ==PM_EVENT_RESTORE ); +} +#endif static int __init ohci_pci_init (void ) {if (usb_disabled ())
@@ -311,7 +317,7 @@ static int __init ohci_pci_init(void)#ifdef CONFIG_PM /* Entries for the PCI suspend/resume callbacks are special */ ohci_pci_hc_driver.pci_suspend = ohci_suspend; - ohci_pci_hc_driver.pci_resume = ohci_resume; + ohci_pci_hc_driver.pci_resume = ohci_pci_resume;#endif return pci_register_driver (&ohci_pci_driver);
drivers/usb/host/uhci-pci.c +4 -3
@@ -169,7 +169,7 @@ static void uhci_shutdown(struct pci_dev *pdev)#ifdef CONFIG_PM -static int uhci_pci_resume (struct usb_hcd *hcd,bool hibernated); +static int uhci_pci_resume (struct usb_hcd *hcd,pm_message_t state);static int uhci_pci_suspend (struct usb_hcd *hcd,bool do_wakeup) {
@@ -204,14 +204,15 @@ static int uhci_pci_suspend(struct usb_hcd *hcd, bool do_wakeup)/* Check for race with a wakeup request */ if (do_wakeup &&HCD_WAKEUP_PENDING (hcd)) { -uhci_pci_resume (hcd, false); +uhci_pci_resume (hcd,PMSG_SUSPEND ); rc = -EBUSY ; }return rc; } -static int uhci_pci_resume (struct usb_hcd *hcd,bool hibernated) +static int uhci_pci_resume (struct usb_hcd *hcd,pm_message_t msg) { +bool hibernated = (msg.event ==PM_EVENT_RESTORE );struct uhci_hcd *uhci =hcd_to_uhci (hcd);dev_dbg (uhci_dev (uhci),"%s\n" , __func__);
drivers/usb/host/xhci-histb.c +1 -1
@@ -367,7 +367,7 @@ static int __maybe_unused xhci_histb_resume(struct device *dev)if (!device_may_wakeup (dev))xhci_histb_host_enable (histb); -return xhci_resume (xhci,0 ); +return xhci_resume (xhci,PMSG_RESUME ); }static const struct dev_pm_ops xhci_histb_pm_ops = {
drivers/usb/host/xhci-pci.c +2 -2
@@ -832,7 +832,7 @@ static int xhci_pci_suspend(struct usb_hcd *hcd, bool do_wakeup)return ret; } -static int xhci_pci_resume (struct usb_hcd *hcd,bool hibernated) +static int xhci_pci_resume (struct usb_hcd *hcd,pm_message_t msg) {struct xhci_hcd *xhci =hcd_to_xhci (hcd);struct pci_dev *pdev =to_pci_dev (hcd->self.controller);
@@ -867,7 +867,7 @@ static int xhci_pci_resume(struct usb_hcd *hcd, bool hibernated)if (xhci->quirks &XHCI_PME_STUCK_QUIRK )xhci_pme_quirk (hcd); - retval =xhci_resume (xhci, hibernated); + retval =xhci_resume (xhci, msg);return retval; }
drivers/usb/host/xhci-plat.c +2 -2
@@ -478,7 +478,7 @@ static int __maybe_unused xhci_plat_resume(struct device *dev)if (ret)return ret; - ret =xhci_resume (xhci,0 ); + ret =xhci_resume (xhci,PMSG_RESUME );if (ret)return ret;
@@ -507,7 +507,7 @@ static int __maybe_unused xhci_plat_runtime_resume(struct device *dev)struct usb_hcd *hcd =dev_get_drvdata (dev);struct xhci_hcd *xhci =hcd_to_xhci (hcd); -return xhci_resume (xhci,0 ); +return xhci_resume (xhci,PMSG_AUTO_RESUME ); }const struct dev_pm_ops xhci_plat_pm_ops = {
drivers/usb/host/xhci-tegra.c +1 -1
@@ -2272,7 +2272,7 @@ static int tegra_xusb_exit_elpg(struct tegra_xusb *tegra, bool runtime)if (wakeup)tegra_xhci_disable_phy_sleepwalk (tegra); - err =xhci_resume (xhci,0 ); + err =xhci_resume (xhci, runtime ?PMSG_AUTO_RESUME :PMSG_RESUME );if (err <0 ) {dev_err (tegra->dev,"failed to resume XHCI: %d\n" , err); goto disable_phy;
drivers/usb/host/xhci.c +2 -1
@@ -960,8 +960,9 @@ EXPORT_SYMBOL_GPL(xhci_suspend);* This is called when the machine transition from S3/S4 mode. * */ -int xhci_resume (struct xhci_hcd *xhci,bool hibernated) +int xhci_resume (struct xhci_hcd *xhci,pm_message_t msg) { +bool hibernated = (msg.event ==PM_EVENT_RESTORE );u32 command, temp =0 ;struct usb_hcd *hcd =xhci_to_hcd (xhci);int retval =0 ;
drivers/usb/host/xhci.h +1 -1
@@ -2140,7 +2140,7 @@ int xhci_disable_slot(struct xhci_hcd *xhci, u32 slot_id);int xhci_ext_cap_init (struct xhci_hcd *xhci);int xhci_suspend (struct xhci_hcd *xhci,bool do_wakeup); -int xhci_resume (struct xhci_hcd *xhci,bool hibernated); +int xhci_resume (struct xhci_hcd *xhci,pm_message_t msg);irqreturn_t xhci_irq (struct usb_hcd *hcd);irqreturn_t xhci_msi_irq (int irq,void *hcd);
include/linux/usb/hcd.h +1 -1
@@ -267,7 +267,7 @@ struct hc_driver {int (*pci_suspend)(struct usb_hcd *hcd,bool do_wakeup);/* called after entering D0 (etc), before resuming the hub */ -int (*pci_resume)(struct usb_hcd *hcd,bool hibernated); +int (*pci_resume)(struct usb_hcd *hcd,pm_message_t state);/* called just before hibernate final D3 state, allows host to poweroff parts */ int (*pci_poweroff_late)(struct usb_hcd *hcd,bool do_wakeup);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 555/800 xhci: Improve the XHCI system resume time
In reply to Greg Kroah-HartmanFrom: Basavaraj Natikar <[email protected]>
[ Upstream commit 1c024241d018cf9fc17aa8d95c3fe77d671d7142 ]
Avoid extra 120ms delay during system resume.
The xHC controller may signal wake up to 120ms before showing which usb device caused the wake on the xHC port registers.
The xhci driver therefore checks for port activity up to 120ms during resume, making sure that the hub driver can see the port change, and won't immediately runtime suspend back due to no port activity.
This is however only needed for runtime resume as system resume will resume all child hubs and other child usb devices anyway.
--- drivers/usb/host/xhci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/host/xhci.c +1 -1
@@ -1117,7 +1117,7 @@ int xhci_resume(struct xhci_hcd *xhci, pm_message_t msg)* the first wake signalling failed, give it that chance. */ pending_portevent =xhci_pending_portevent (xhci); -if (!pending_portevent) { +if (!pending_portevent && msg.event ==PM_EVENT_AUTO_RESUME ) {msleep (120 ); pending_portevent =xhci_pending_portevent (xhci); }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 556/800 usb: dwc2: Fix some error handling paths
In reply to Greg Kroah-HartmanFrom: Christophe JAILLET <[email protected]>
[ Upstream commit ada050c69108bc34be13ecc11f7fad0f20ebadc4 ]
dwc2_driver_probe() calls dwc2_lowlevel_hw_init() which deassert some reset lines.
Should an error happen in dwc2_lowlevel_hw_init() after calling reset_control_deassert() or in the probe after calling dwc2_lowlevel_hw_init(), the reset lines remain deasserted.
Add some devm_add_action_or_reset() calls to re-assert the lines if needed.
Update the remove function accordingly.
This change is compile-tested only.
--- drivers/usb/dwc2/platform.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)
drivers/usb/dwc2/platform.c +13 -3
@@ -203,6 +203,11 @@ int dwc2_lowlevel_hw_disable(struct dwc2_hsotg *hsotg)return ret; } +static void dwc2_reset_control_assert (void *data) +{ +reset_control_assert (data); +} +static int dwc2_lowlevel_hw_init (struct dwc2_hsotg *hsotg) {int i, ret;
@@ -213,6 +218,10 @@ static int dwc2_lowlevel_hw_init(struct dwc2_hsotg *hsotg) "error getting reset control\n");reset_control_deassert (hsotg->reset); + ret =devm_add_action_or_reset (hsotg->dev, dwc2_reset_control_assert, + hsotg->reset); +if (ret) +return ret; hsotg->reset_ecc =devm_reset_control_get_optional (hsotg->dev,"dwc2-ecc" );if (IS_ERR (hsotg->reset_ecc))
@@ -220,6 +229,10 @@ static int dwc2_lowlevel_hw_init(struct dwc2_hsotg *hsotg) "error getting reset control for ecc\n");reset_control_deassert (hsotg->reset_ecc); + ret =devm_add_action_or_reset (hsotg->dev, dwc2_reset_control_assert, + hsotg->reset_ecc); +if (ret) +return ret;/* * Attempt to find a generic PHY, then look for an old style
@@ -339,9 +352,6 @@ static int dwc2_driver_remove(struct platform_device *dev)if (hsotg->ll_hw_enabled)dwc2_lowlevel_hw_disable (hsotg); -reset_control_assert (hsotg->reset); -reset_control_assert (hsotg->reset_ecc); -return 0 ; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 557/800 serial: 8250: omap: Fix freeing of resources on failed register
In reply to Greg Kroah-HartmanFrom: Tony Lindgren <[email protected]>
[ Upstream commit b9ab22c2bc8652324a803b3e2be69838920b4025 ]
If serial8250_register_8250_port() fails, the SoC can hang as the deferred PMQoS work will still run as is not flushed and removed.
--- drivers/tty/serial/8250/8250_omap.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/tty/serial/8250/8250_omap.c +2 -0
@@ -1532,7 +1532,9 @@ static int omap8250_probe(struct platform_device *pdev) err:pm_runtime_dont_use_autosuspend (&pdev->dev);pm_runtime_put_sync (&pdev->dev); +flush_work (&priv->qos_work);pm_runtime_disable (&pdev->dev); +cpu_latency_qos_remove_request (&priv->pm_qos_request);return ret; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 558/800 interconnect: qcom: rpm: Rename icc provider num_clocks to num_bus_clocks
In reply to Greg Kroah-HartmanFrom: Konrad Dybcio <[email protected]>
[ Upstream commit 1a12928e25627e02126ad2d1c12cfdba79d6bd94 ]
In preparation for handling non-scaling clocks that we still have to enable, rename num_clocks to more descriptive num_bus_clocks.
Stable-dep-of: 1ff7aedcdcdd ("interconnect: qcom: rpm: Don't use clk_get_optional for bus clocks anymore")
--- drivers/interconnect/qcom/icc-rpm.c | 12 ++++++------ drivers/interconnect/qcom/icc-rpm.h | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-)
drivers/interconnect/qcom/icc-rpm.c +6 -6
@@ -379,7 +379,7 @@ static int qcom_icc_set(struct icc_node *src, struct icc_node *dst)return ret; } -for (i =0 ; i < qp->num_clks; i++) { +for (i =0 ; i < qp->num_bus_clks; i++) {/* * Use WAKE bucket for active clock, otherwise, use SLEEP bucket * for other clocks. If a platform doesn't set interconnect
@@ -464,7 +464,7 @@ int qnoc_probe(struct platform_device *pdev)for (i =0 ; i < cd_num; i++) qp->bus_clks[i].id = cds[i]; - qp->num_clks = cd_num; + qp->num_bus_clks = cd_num; qp->type = desc->type; qp->qos_offset = desc->qos_offset;
@@ -494,11 +494,11 @@ int qnoc_probe(struct platform_device *pdev) } regmap_done: - ret =devm_clk_bulk_get_optional (dev, qp->num_clks, qp->bus_clks); + ret =devm_clk_bulk_get_optional (dev, qp->num_bus_clks, qp->bus_clks);if (ret)return ret; - ret =clk_bulk_prepare_enable (qp->num_clks, qp->bus_clks); + ret =clk_bulk_prepare_enable (qp->num_bus_clks, qp->bus_clks);if (ret)return ret;
@@ -551,7 +551,7 @@ int qnoc_probe(struct platform_device *pdev)icc_provider_deregister (provider); err_remove_nodes:icc_nodes_remove (provider); -clk_bulk_disable_unprepare (qp->num_clks, qp->bus_clks); +clk_bulk_disable_unprepare (qp->num_bus_clks, qp->bus_clks);return ret; }
@@ -563,7 +563,7 @@ int qnoc_remove(struct platform_device *pdev)icc_provider_deregister (&qp->provider);icc_nodes_remove (&qp->provider); -clk_bulk_disable_unprepare (qp->num_clks, qp->bus_clks); +clk_bulk_disable_unprepare (qp->num_bus_clks, qp->bus_clks);return 0 ; }
drivers/interconnect/qcom/icc-rpm.h +2 -2
@@ -23,7 +23,7 @@ enum qcom_icc_type {/** * struct qcom_icc_provider - Qualcomm specific interconnect provider * @provider: generic interconnect provider -* @num_clks: the total number of clk_bulk_data entries +* @num_bus_clks: the total number of bus_clks clk_bulk_data entries * @type: the ICC provider type * @regmap: regmap for QoS registers read/write access * @qos_offset: offset to QoS registers
@@ -32,7 +32,7 @@ enum qcom_icc_type {*/ struct qcom_icc_provider {struct icc_provider provider; -int num_clks; +int num_bus_clks;enum qcom_icc_type type;struct regmap *regmap;unsigned int qos_offset;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 559/800 interconnect: qcom: rpm: Dont use clk_get_optional for bus clocks anymore
In reply to Greg Kroah-HartmanFrom: Konrad Dybcio <[email protected]>
[ Upstream commit 1ff7aedcdcdd4fe02201269ab428b09491e5cf6e ]
Commit dd42ec8ea5b9 ("interconnect: qcom: rpm: Use _optional func for provider clocks") relaxed the requirements around probing bus clocks. This was a decent solution for making sure MSM8996 would still boot with old DTs, but
now that there's a proper fix in place that both old and new DTs
will be happy about, revert back to the safer variant of the
function.
--- drivers/interconnect/qcom/icc-rpm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/interconnect/qcom/icc-rpm.c +1 -1
@@ -494,7 +494,7 @@ int qnoc_probe(struct platform_device *pdev) } regmap_done: - ret =devm_clk_bulk_get_optional (dev, qp->num_bus_clks, qp->bus_clks); + ret =devm_clk_bulk_get (dev, qp->num_bus_clks, qp->bus_clks);if (ret)return ret;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 560/800 clk: qcom: gcc: ipq5332: Use floor ops for SDCC clocks
In reply to Greg Kroah-HartmanFrom: Kathiravan T <[email protected]>
[ Upstream commit a30e62bf6bf4d3230fa9164c7e174e32b9be7ba5 ]
SDCC clocks must be rounded down to avoid overclocking the controller.
--- drivers/clk/qcom/gcc-ipq5332.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/qcom/gcc-ipq5332.c +1 -1
@@ -963,7 +963,7 @@ static struct clk_rcg2 gcc_sdcc1_apps_clk_src = { .name = "gcc_sdcc1_apps_clk_src", .parent_data = gcc_parent_data_9, .num_parents = ARRAY_SIZE(gcc_parent_data_9), - .ops = &clk_rcg2_ops, + .ops = &clk_rcg2_floor_ops, }, };
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 561/800 clk: qcom: mmcc-msm8974: remove oxili_ocmemgx_clk
In reply to Greg Kroah-HartmanFrom: Dmitry Baryshkov <[email protected]>
[ Upstream commit 853c064b57491d739bfd0cc35ff75c5ea9c5e8f5 ]
After the internal discussions, it looks like this clock is managed by RPM itself. Linux kernel should not touch it on its own, as this causes disagreement with RPM. Shutting down this clock causes the OCMEM<->GPU interface to stop working, resulting in GPU hangchecks/timeouts.
--- drivers/clk/qcom/mmcc-msm8974.c | 19 ------------------- 1 file changed, 19 deletions(-)
drivers/clk/qcom/mmcc-msm8974.c +0 -19
@@ -2204,23 +2204,6 @@ static struct clk_branch ocmemcx_ocmemnoc_clk = { }, }; -static struct clk_branch oxili_ocmemgx_clk = { - .halt_reg =0x402c , - .clkr = { - .enable_reg =0x402c , - .enable_mask =BIT (0 ), - .hw.init = &(struct clk_init_data ){ - .name ="oxili_ocmemgx_clk" , - .parent_data = (const struct clk_parent_data []){ - { .fw_name ="gfx3d_clk_src" , .name ="gfx3d_clk_src" }, - }, - .num_parents =1 , - .flags =CLK_SET_RATE_PARENT , - .ops = &clk_branch2_ops, - }, - }, -}; -static struct clk_branch ocmemnoc_clk = { .halt_reg =0x50b4 , .clkr = {
@@ -2512,7 +2495,6 @@ static struct clk_regmap *mmcc_msm8226_clocks[] = { [MMSS_MMSSNOC_AXI_CLK] = &mmss_mmssnoc_axi_clk.clkr, [MMSS_S0_AXI_CLK] = &mmss_s0_axi_clk.clkr, [OCMEMCX_AHB_CLK] = &ocmemcx_ahb_clk.clkr, - [OXILI_OCMEMGX_CLK] = &oxili_ocmemgx_clk.clkr, [OXILI_GFX3D_CLK] = &oxili_gfx3d_clk.clkr, [OXILICX_AHB_CLK] = &oxilicx_ahb_clk.clkr, [OXILICX_AXI_CLK] = &oxilicx_axi_clk.clkr,
@@ -2670,7 +2652,6 @@ static struct clk_regmap *mmcc_msm8974_clocks[] = { [MMSS_S0_AXI_CLK] = &mmss_s0_axi_clk.clkr, [OCMEMCX_AHB_CLK] = &ocmemcx_ahb_clk.clkr, [OCMEMCX_OCMEMNOC_CLK] = &ocmemcx_ocmemnoc_clk.clkr, - [OXILI_OCMEMGX_CLK] = &oxili_ocmemgx_clk.clkr, [OCMEMNOC_CLK] = &ocmemnoc_clk.clkr, [OXILI_GFX3D_CLK] = &oxili_gfx3d_clk.clkr, [OXILICX_AHB_CLK] = &oxilicx_ahb_clk.clkr,
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 562/800 clk: qcom: camcc-sc7180: Add parent dependency to all camera GDSCs
In reply to Greg Kroah-HartmanFrom: Taniya Das <[email protected]>
[ Upstream commit 3e4d179532423f299554cd0dedabdd9d2fdd238d ]
Camera titan top GDSC is a parent supply to all other camera GDSCs. Titan top GDSC is required to be enabled before enabling any other camera GDSCs and it should be disabled only after all other camera GDSCs are disabled. Ensure this behavior by marking titan top GDSC as parent of all other camera GDSCs.
--- drivers/clk/qcom/camcc-sc7180.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-)
drivers/clk/qcom/camcc-sc7180.c +12 -7
@@ -1480,12 +1480,21 @@ static struct clk_branch cam_cc_sys_tmr_clk = { }, }; +static struct gdsc titan_top_gdsc = { + .gdscr =0xb134 , + .pd = { + .name ="titan_top_gdsc" , + }, + .pwrsts =PWRSTS_OFF_ON , +}; +static struct gdsc bps_gdsc = { .gdscr =0x6004 , .pd = { .name ="bps_gdsc" , }, .pwrsts =PWRSTS_OFF_ON , + .parent = &titan_top_gdsc.pd, .flags =HW_CTRL , };
@@ -1495,6 +1504,7 @@ static struct gdsc ife_0_gdsc = { .name = "ife_0_gdsc", }, .pwrsts = PWRSTS_OFF_ON, + .parent = &titan_top_gdsc.pd, }; static struct gdsc ife_1_gdsc = {
@@ -1503,6 +1513,7 @@ static struct gdsc ife_1_gdsc = { .name = "ife_1_gdsc", }, .pwrsts = PWRSTS_OFF_ON, + .parent = &titan_top_gdsc.pd, }; static struct gdsc ipe_0_gdsc = {
@@ -1512,15 +1523,9 @@ static struct gdsc ipe_0_gdsc = { }, .pwrsts = PWRSTS_OFF_ON, .flags = HW_CTRL, + .parent = &titan_top_gdsc.pd, }; -static struct gdsc titan_top_gdsc = { - .gdscr =0xb134 , - .pd = { - .name ="titan_top_gdsc" , - }, - .pwrsts =PWRSTS_OFF_ON , -};static struct clk_hw *cam_cc_sc7180_hws[] = { [CAM_CC_PLL2_OUT_EARLY ] = &cam_cc_pll2_out_early.hw,
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 563/800 clk: qcom: gcc-ipq6018: Use floor ops for sdcc clocks
In reply to Greg Kroah-HartmanFrom: Mantas Pucka <[email protected]>
[ Upstream commit 56e5ae0116aef87273cf1812d608645b076e4f02 ]
SDCC clocks must be rounded down to avoid overclocking the controller.
--- drivers/clk/qcom/gcc-ipq6018.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/qcom/gcc-ipq6018.c +1 -1
@@ -1654,7 +1654,7 @@ static struct clk_rcg2 sdcc1_apps_clk_src = { .name = "sdcc1_apps_clk_src", .parent_data = gcc_xo_gpll0_gpll2_gpll0_out_main_div2, .num_parents = 4, - .ops = &clk_rcg2_ops, + .ops = &clk_rcg2_floor_ops, }, };
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 564/800 clk: qcom: gcc-qcm2290: Mark RCGs shared where applicable
In reply to Greg Kroah-HartmanFrom: Konrad Dybcio <[email protected]>
[ Upstream commit 7bf654a0d95e75b415f454e10627309d650762d0 ]
The vast majority of shared RCGs were not marked as such. Fix it.
--- drivers/clk/qcom/gcc-qcm2290.c | 62 +++++++++++++++++----------------- 1 file changed, 31 insertions(+), 31 deletions(-)
drivers/clk/qcom/gcc-qcm2290.c +31 -31
@@ -650,7 +650,7 @@ static struct clk_rcg2 gcc_usb30_prim_mock_utmi_clk_src = { .name = "gcc_usb30_prim_mock_utmi_clk_src", .parent_data = gcc_parents_0, .num_parents = ARRAY_SIZE(gcc_parents_0), - .ops = &clk_rcg2_ops, + .ops = &clk_rcg2_shared_ops, }, };
@@ -686,7 +686,7 @@ static struct clk_rcg2 gcc_camss_axi_clk_src = { .name = "gcc_camss_axi_clk_src", .parent_data = gcc_parents_4, .num_parents = ARRAY_SIZE(gcc_parents_4), - .ops = &clk_rcg2_ops, + .ops = &clk_rcg2_shared_ops, }, };
@@ -706,7 +706,7 @@ static struct clk_rcg2 gcc_camss_cci_clk_src = { .name = "gcc_camss_cci_clk_src", .parent_data = gcc_parents_9, .num_parents = ARRAY_SIZE(gcc_parents_9), - .ops = &clk_rcg2_ops, + .ops = &clk_rcg2_shared_ops, }, };
@@ -728,7 +728,7 @@ static struct clk_rcg2 gcc_camss_csi0phytimer_clk_src = { .name = "gcc_camss_csi0phytimer_clk_src", .parent_data = gcc_parents_5, .num_parents = ARRAY_SIZE(gcc_parents_5), - .ops = &clk_rcg2_ops, + .ops = &clk_rcg2_shared_ops, }, };
@@ -742,7 +742,7 @@ static struct clk_rcg2 gcc_camss_csi1phytimer_clk_src = { .name = "gcc_camss_csi1phytimer_clk_src", .parent_data = gcc_parents_5, .num_parents = ARRAY_SIZE(gcc_parents_5), - .ops = &clk_rcg2_ops, + .ops = &clk_rcg2_shared_ops, }, };
@@ -764,7 +764,7 @@ static struct clk_rcg2 gcc_camss_mclk0_clk_src = { .parent_data = gcc_parents_3, .num_parents = ARRAY_SIZE(gcc_parents_3), .flags = CLK_OPS_PARENT_ENABLE, - .ops = &clk_rcg2_ops, + .ops = &clk_rcg2_shared_ops, }, };
@@ -779,7 +779,7 @@ static struct clk_rcg2 gcc_camss_mclk1_clk_src = { .parent_data = gcc_parents_3, .num_parents = ARRAY_SIZE(gcc_parents_3), .flags = CLK_OPS_PARENT_ENABLE, - .ops = &clk_rcg2_ops, + .ops = &clk_rcg2_shared_ops, }, };
@@ -794,7 +794,7 @@ static struct clk_rcg2 gcc_camss_mclk2_clk_src = { .parent_data = gcc_parents_3, .num_parents = ARRAY_SIZE(gcc_parents_3), .flags = CLK_OPS_PARENT_ENABLE, - .ops = &clk_rcg2_ops, + .ops = &clk_rcg2_shared_ops, }, };
@@ -809,7 +809,7 @@ static struct clk_rcg2 gcc_camss_mclk3_clk_src = { .parent_data = gcc_parents_3, .num_parents = ARRAY_SIZE(gcc_parents_3), .flags = CLK_OPS_PARENT_ENABLE, - .ops = &clk_rcg2_ops, + .ops = &clk_rcg2_shared_ops, }, };
@@ -830,7 +830,7 @@ static struct clk_rcg2 gcc_camss_ope_ahb_clk_src = { .name = "gcc_camss_ope_ahb_clk_src", .parent_data = gcc_parents_6, .num_parents = ARRAY_SIZE(gcc_parents_6), - .ops = &clk_rcg2_ops, + .ops = &clk_rcg2_shared_ops, }, };
@@ -854,7 +854,7 @@ static struct clk_rcg2 gcc_camss_ope_clk_src = { .parent_data = gcc_parents_6, .num_parents = ARRAY_SIZE(gcc_parents_6), .flags = CLK_SET_RATE_PARENT, - .ops = &clk_rcg2_ops, + .ops = &clk_rcg2_shared_ops, }, };
@@ -888,7 +888,7 @@ static struct clk_rcg2 gcc_camss_tfe_0_clk_src = { .name = "gcc_camss_tfe_0_clk_src", .parent_data = gcc_parents_7, .num_parents = ARRAY_SIZE(gcc_parents_7), - .ops = &clk_rcg2_ops, + .ops = &clk_rcg2_shared_ops, }, };
@@ -912,7 +912,7 @@ static struct clk_rcg2 gcc_camss_tfe_0_csid_clk_src = { .name = "gcc_camss_tfe_0_csid_clk_src", .parent_data = gcc_parents_8, .num_parents = ARRAY_SIZE(gcc_parents_8), - .ops = &clk_rcg2_ops, + .ops = &clk_rcg2_shared_ops, }, };
@@ -926,7 +926,7 @@ static struct clk_rcg2 gcc_camss_tfe_1_clk_src = { .name = "gcc_camss_tfe_1_clk_src", .parent_data = gcc_parents_7, .num_parents = ARRAY_SIZE(gcc_parents_7), - .ops = &clk_rcg2_ops, + .ops = &clk_rcg2_shared_ops, }, };
@@ -940,7 +940,7 @@ static struct clk_rcg2 gcc_camss_tfe_1_csid_clk_src = { .name = "gcc_camss_tfe_1_csid_clk_src", .parent_data = gcc_parents_8, .num_parents = ARRAY_SIZE(gcc_parents_8), - .ops = &clk_rcg2_ops, + .ops = &clk_rcg2_shared_ops, }, };
@@ -963,7 +963,7 @@ static struct clk_rcg2 gcc_camss_tfe_cphy_rx_clk_src = { .parent_data = gcc_parents_10, .num_parents = ARRAY_SIZE(gcc_parents_10), .flags = CLK_OPS_PARENT_ENABLE, - .ops = &clk_rcg2_ops, + .ops = &clk_rcg2_shared_ops, }, };
@@ -984,7 +984,7 @@ static struct clk_rcg2 gcc_camss_top_ahb_clk_src = { .name = "gcc_camss_top_ahb_clk_src", .parent_data = gcc_parents_4, .num_parents = ARRAY_SIZE(gcc_parents_4), - .ops = &clk_rcg2_ops, + .ops = &clk_rcg2_shared_ops, }, };
@@ -1006,7 +1006,7 @@ static struct clk_rcg2 gcc_gp1_clk_src = { .name = "gcc_gp1_clk_src", .parent_data = gcc_parents_2, .num_parents = ARRAY_SIZE(gcc_parents_2), - .ops = &clk_rcg2_ops, + .ops = &clk_rcg2_shared_ops, }, };
@@ -1020,7 +1020,7 @@ static struct clk_rcg2 gcc_gp2_clk_src = { .name = "gcc_gp2_clk_src", .parent_data = gcc_parents_2, .num_parents = ARRAY_SIZE(gcc_parents_2), - .ops = &clk_rcg2_ops, + .ops = &clk_rcg2_shared_ops, }, };
@@ -1034,7 +1034,7 @@ static struct clk_rcg2 gcc_gp3_clk_src = { .name = "gcc_gp3_clk_src", .parent_data = gcc_parents_2, .num_parents = ARRAY_SIZE(gcc_parents_2), - .ops = &clk_rcg2_ops, + .ops = &clk_rcg2_shared_ops, }, };
@@ -1054,7 +1054,7 @@ static struct clk_rcg2 gcc_pdm2_clk_src = { .name = "gcc_pdm2_clk_src", .parent_data = gcc_parents_0, .num_parents = ARRAY_SIZE(gcc_parents_0), - .ops = &clk_rcg2_ops, + .ops = &clk_rcg2_shared_ops, }, };
@@ -1082,7 +1082,7 @@ static struct clk_init_data gcc_qupv3_wrap0_s0_clk_src_init = { .name = "gcc_qupv3_wrap0_s0_clk_src", .parent_data = gcc_parents_1, .num_parents = ARRAY_SIZE(gcc_parents_1), - .ops = &clk_rcg2_ops, + .ops = &clk_rcg2_shared_ops, };static struct clk_rcg2 gcc_qupv3_wrap0_s0_clk_src = {
@@ -1098,7 +1098,7 @@ static struct clk_init_data gcc_qupv3_wrap0_s1_clk_src_init = { .name = "gcc_qupv3_wrap0_s1_clk_src", .parent_data = gcc_parents_1, .num_parents = ARRAY_SIZE(gcc_parents_1), - .ops = &clk_rcg2_ops, + .ops = &clk_rcg2_shared_ops, };static struct clk_rcg2 gcc_qupv3_wrap0_s1_clk_src = {
@@ -1114,7 +1114,7 @@ static struct clk_init_data gcc_qupv3_wrap0_s2_clk_src_init = { .name = "gcc_qupv3_wrap0_s2_clk_src", .parent_data = gcc_parents_1, .num_parents = ARRAY_SIZE(gcc_parents_1), - .ops = &clk_rcg2_ops, + .ops = &clk_rcg2_shared_ops, };static struct clk_rcg2 gcc_qupv3_wrap0_s2_clk_src = {
@@ -1130,7 +1130,7 @@ static struct clk_init_data gcc_qupv3_wrap0_s3_clk_src_init = { .name = "gcc_qupv3_wrap0_s3_clk_src", .parent_data = gcc_parents_1, .num_parents = ARRAY_SIZE(gcc_parents_1), - .ops = &clk_rcg2_ops, + .ops = &clk_rcg2_shared_ops, };static struct clk_rcg2 gcc_qupv3_wrap0_s3_clk_src = {
@@ -1146,7 +1146,7 @@ static struct clk_init_data gcc_qupv3_wrap0_s4_clk_src_init = { .name = "gcc_qupv3_wrap0_s4_clk_src", .parent_data = gcc_parents_1, .num_parents = ARRAY_SIZE(gcc_parents_1), - .ops = &clk_rcg2_ops, + .ops = &clk_rcg2_shared_ops, };static struct clk_rcg2 gcc_qupv3_wrap0_s4_clk_src = {
@@ -1162,7 +1162,7 @@ static struct clk_init_data gcc_qupv3_wrap0_s5_clk_src_init = { .name = "gcc_qupv3_wrap0_s5_clk_src", .parent_data = gcc_parents_1, .num_parents = ARRAY_SIZE(gcc_parents_1), - .ops = &clk_rcg2_ops, + .ops = &clk_rcg2_shared_ops, };static struct clk_rcg2 gcc_qupv3_wrap0_s5_clk_src = {
@@ -1219,7 +1219,7 @@ static struct clk_rcg2 gcc_sdcc1_ice_core_clk_src = { .name = "gcc_sdcc1_ice_core_clk_src", .parent_data = gcc_parents_0, .num_parents = ARRAY_SIZE(gcc_parents_0), - .ops = &clk_rcg2_ops, + .ops = &clk_rcg2_shared_ops, }, };
@@ -1266,7 +1266,7 @@ static struct clk_rcg2 gcc_usb30_prim_master_clk_src = { .name = "gcc_usb30_prim_master_clk_src", .parent_data = gcc_parents_0, .num_parents = ARRAY_SIZE(gcc_parents_0), - .ops = &clk_rcg2_ops, + .ops = &clk_rcg2_shared_ops, }, };
@@ -1280,7 +1280,7 @@ static struct clk_rcg2 gcc_usb3_prim_phy_aux_clk_src = { .name = "gcc_usb3_prim_phy_aux_clk_src", .parent_data = gcc_parents_13, .num_parents = ARRAY_SIZE(gcc_parents_13), - .ops = &clk_rcg2_ops, + .ops = &clk_rcg2_shared_ops, }, };
@@ -1303,7 +1303,7 @@ static struct clk_rcg2 gcc_video_venus_clk_src = { .parent_data = gcc_parents_14, .num_parents = ARRAY_SIZE(gcc_parents_14), .flags = CLK_SET_RATE_PARENT, - .ops = &clk_rcg2_ops, + .ops = &clk_rcg2_shared_ops, }, };
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 565/800 media: usb: Check az6007_read() return value
In reply to Greg Kroah-HartmanFrom: Daniil Dulov <[email protected]>
[ Upstream commit fdaca63186f59fc664b346c45b76576624b48e57 ]
If az6007_read() returns error, there is no sence to continue.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- drivers/media/usb/dvb-usb-v2/az6007.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/media/usb/dvb-usb-v2/az6007.c +2 -1
@@ -202,7 +202,8 @@ static int az6007_rc_query(struct dvb_usb_device *d)unsigned code;enum rc_proto proto; -az6007_read (d,AZ6007_READ_IR ,0 ,0 , st->data,10 ); +if (az6007_read (d,AZ6007_READ_IR ,0 ,0 , st->data,10 ) <0 ) +return -EIO ;if (st->data[1 ] ==0x44 )return 0 ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 566/800 media: amphion: drop repeated codec data for vc1l format
In reply to Greg Kroah-HartmanFrom: Ming Qian <[email protected]>
[ Upstream commit 668ee1a3a1870381225002c246972419b98e4253 ]
For format V4L2_PIX_FMT_VC1_ANNEX_L,
the codec data is replaced with startcode,
and then driver drop it, otherwise it may led to decoding error.
It's amphion vpu's limitation
Driver has dropped the first codec data,
but need to drop the repeated codec data too.
--- drivers/media/platform/amphion/vpu_malone.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/media/platform/amphion/vpu_malone.c +2 -0
@@ -1344,6 +1344,8 @@ static int vpu_malone_insert_scode_vc1_l_seq(struct malone_scode_t *scode)int size =0 ;u8 rcv_seqhdr[MALONE_VC1_RCV_SEQ_HEADER_LEN ]; +if (vpu_vb_is_codecconfig (to_vb2_v4l2_buffer (scode->vb))) + scode->need_data =0 ;if (scode->inst->total_input_count)return 0 ; scode->need_data =0 ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 567/800 media: amphion: drop repeated codec data for vc1g format
In reply to Greg Kroah-HartmanFrom: Ming Qian <[email protected]>
[ Upstream commit e1d2ccc2cdd6333584aa3d5386dc667d0837c48f ]
For format V4L2_PIX_FMT_VC1_ANNEX_G,
the separate codec data is required only once. The repeated codec data may introduce some decoding error. so drop the repeated codec data.
It's amphion vpu's limitation
--- drivers/media/platform/amphion/vpu_malone.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/media/platform/amphion/vpu_malone.c +10 -0
@@ -1313,6 +1313,15 @@ static int vpu_malone_insert_scode_pic(struct malone_scode_t *scode, u32 codec_ireturn sizeof (hdr); } +static int vpu_malone_insert_scode_vc1_g_seq (struct malone_scode_t *scode) +{ +if (!scode->inst->total_input_count) +return 0 ; +if (vpu_vb_is_codecconfig (to_vb2_v4l2_buffer (scode->vb))) + scode->need_data =0 ; +return 0 ; +} +static int vpu_malone_insert_scode_vc1_g_pic (struct malone_scode_t *scode) {struct vb2_v4l2_buffer *vbuf;
@@ -1460,6 +1469,7 @@ static const struct malone_scode_handler scode_handlers[] = { }, { .pixelformat = V4L2_PIX_FMT_VC1_ANNEX_G, + .insert_scode_seq = vpu_malone_insert_scode_vc1_g_seq, .insert_scode_pic = vpu_malone_insert_scode_vc1_g_pic, }, {
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 568/800 media: common: saa7146: Avoid a leak in vmalloc_to_sg()
In reply to Greg Kroah-HartmanFrom: Christophe JAILLET <[email protected]>
[ Upstream commit b2aa8ac6f97e26d788948fb60dcc5625c9633f4e ]
Commit in Fixes turned a BUG() into a "normal" memory allocation failure. While at it, it introduced a memory leak.
So fix it.
Also update the comment on top of the function to reflect what has been change by the commit in Fixes.
--- drivers/media/common/saa7146/saa7146_core.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/media/common/saa7146/saa7146_core.c +3 -3
@@ -133,8 +133,8 @@ int saa7146_wait_for_debi_done(struct saa7146_dev *dev, int nobusyloop)****************************************************************************/ /* this is videobuf_vmalloc_to_sg() from videobuf-dma-sg.c -make sure virt has been allocated with vmalloc_32(), otherwise the BUG() -may be triggered on highmem machines */ +make sure virt has been allocated with vmalloc_32(), otherwise return NULL +on highmem machines */ static struct scatterlist *vmalloc_to_sg (unsigned char *virt,int nr_pages) {struct scatterlist *sglist;
@@ -150,7 +150,7 @@ static struct scatterlist* vmalloc_to_sg(unsigned char *virt, int nr_pages)if (NULL == pg) goto err;if (WARN_ON (PageHighMem (pg))) -return NULL ; + goto err;sg_set_page (&sglist[i], pg,PAGE_SIZE ,0 ); }return sglist;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 569/800 media: videodev2.h: Fix p_s32 and p_s64 pointer types
In reply to Greg Kroah-HartmanFrom: Daniel Lundberg Pedersen <[email protected]>
[ Upstream commit 3f6375a2d1956739c6c8ffa3a862c9278d346940 ]
Use the intended pointer types for p_s32 and p_64 in the union of the struct v4l2_ext_control.
--- include/uapi/linux/videodev2.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
include/uapi/linux/videodev2.h +2 -2
@@ -1807,8 +1807,8 @@ struct v4l2_ext_control {__u8 __user *p_u8;__u16 __user *p_u16;__u32 __user *p_u32; -__u32 __user *p_s32; -__u32 __user *p_s64; +__s32 __user *p_s32; +__s64 __user *p_s64;struct v4l2_area __user *p_area;struct v4l2_ctrl_h264_sps __user *p_h264_sps;struct v4l2_ctrl_h264_pps *p_h264_pps;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 570/800 media: amphion: initiate a drain of the capture queue in dynamic resolution change
In reply to Greg Kroah-HartmanFrom: Ming Qian <[email protected]>
[ Upstream commit 076b6289b2c12d76fab248659896682830fa7766 ]
The last buffer from before the change must be marked with the V4L2_BUF_FLAG_LAST flag,
similarly to the Drain sequence above.
initiate a drain of the capture queue in dynamic resolution change
--- drivers/media/platform/amphion/vdec.c | 7 ++++--- drivers/media/platform/amphion/venc.c | 4 ++-- drivers/media/platform/amphion/vpu_v4l2.c | 5 +++-- drivers/media/platform/amphion/vpu_v4l2.h | 2 +- 4 files changed, 10 insertions(+), 8 deletions(-)
drivers/media/platform/amphion/vdec.c +4 -3
@@ -279,6 +279,7 @@ static void vdec_handle_resolution_change(struct vpu_inst *inst) vdec->source_change--;vpu_notify_source_change (inst); +vpu_set_last_buffer_dequeued (inst, false); }static int vdec_update_state (struct vpu_inst *inst,enum vpu_codec_state state,u32 force)
@@ -314,7 +315,7 @@ static void vdec_set_last_buffer_dequeued(struct vpu_inst *inst)return ;if (vdec->eos_received) { -if (!vpu_set_last_buffer_dequeued (inst)) { +if (!vpu_set_last_buffer_dequeued (inst, true)) { vdec->eos_received--;vdec_update_state (inst,VPU_CODEC_STATE_DRAIN ,0 ); }
@@ -569,7 +570,7 @@ static int vdec_drain(struct vpu_inst *inst)return 0 ;if (!vdec->params.frame_count) { -vpu_set_last_buffer_dequeued (inst); +vpu_set_last_buffer_dequeued (inst, true);return 0 ; }
@@ -608,7 +609,7 @@ static int vdec_cmd_stop(struct vpu_inst *inst)vpu_trace (inst->dev,"[%d]\n" , inst->id);if (inst->state ==VPU_CODEC_STATE_DEINIT ) { -vpu_set_last_buffer_dequeued (inst); +vpu_set_last_buffer_dequeued (inst, true); }else { vdec->drain =1 ;vdec_drain (inst);
drivers/media/platform/amphion/venc.c +2 -2
@@ -458,7 +458,7 @@ static int venc_encoder_cmd(struct file *file, void *fh, struct v4l2_encoder_cmdvpu_inst_lock (inst);if (cmd->cmd ==V4L2_ENC_CMD_STOP ) {if (inst->state ==VPU_CODEC_STATE_DEINIT ) -vpu_set_last_buffer_dequeued (inst); +vpu_set_last_buffer_dequeued (inst, true);else venc_request_eos (inst); }
@@ -878,7 +878,7 @@ static void venc_set_last_buffer_dequeued(struct vpu_inst *inst)struct venc_t *venc = inst->priv;if (venc->stopped &&list_empty (&venc->frames)) -vpu_set_last_buffer_dequeued (inst); +vpu_set_last_buffer_dequeued (inst, true); }static void venc_stop_done (struct vpu_inst *inst)
drivers/media/platform/amphion/vpu_v4l2.c +3 -2
@@ -100,7 +100,7 @@ int vpu_notify_source_change(struct vpu_inst *inst)return 0 ; } -int vpu_set_last_buffer_dequeued (struct vpu_inst *inst) +int vpu_set_last_buffer_dequeued (struct vpu_inst *inst,bool eos) {struct vb2_queue *q;
@@ -116,7 +116,8 @@ int vpu_set_last_buffer_dequeued(struct vpu_inst *inst)vpu_trace (inst->dev,"last buffer dequeued\n" ); q->last_buffer_dequeued = true;wake_up (&q->done_wq); -vpu_notify_eos (inst); +if (eos) +vpu_notify_eos (inst);return 0 ; }
drivers/media/platform/amphion/vpu_v4l2.h +1 -1
@@ -27,7 +27,7 @@ struct vb2_v4l2_buffer *vpu_find_buf_by_idx(struct vpu_inst *inst, u32 type, u32void vpu_v4l2_set_error (struct vpu_inst *inst);int vpu_notify_eos (struct vpu_inst *inst);int vpu_notify_source_change (struct vpu_inst *inst); -int vpu_set_last_buffer_dequeued (struct vpu_inst *inst); +int vpu_set_last_buffer_dequeued (struct vpu_inst *inst,bool eos);void vpu_vb2_buffers_return (struct vpu_inst *inst,unsigned int type,enum vb2_buffer_state state);int vpu_get_num_buffers (struct vpu_inst *inst,u32 type);bool vpu_is_source_empty (struct vpu_inst *inst);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 571/800 media: videodev2.h: Fix struct v4l2_input tuner index comment
In reply to Greg Kroah-HartmanFrom: Marek Vasut <[email protected]>
[ Upstream commit 26ae58f65e64fa7ba61d64bae752e59e08380c6a ]
VIDIOC_ENUMINPUT documentation describes the tuner field of struct v4l2_input as index:
Documentation/userspace-api/media/v4l/vidioc-enuminput.rst "
* - __u32
- ``tuner``
- Capture devices can have zero or more tuners (RF demodulators). When the ``type`` is set to ``V4L2_INPUT_TYPE_TUNER`` this is an RF connector and this field identifies the tuner. It corresponds to struct :c:type:v4l2_tuner field ``index``. For details on tuners see :ref:tuner.
"
Drivers I could find also use the 'tuner' field as an index, e.g.:drivers/media/pci/bt8xx/bttv-driver.c bttv_enum_input() drivers/media/usb/go7007/go7007-v4l2.c vidioc_enum_input()
However, the UAPI comment claims this field is 'enum v4l2_tuner_type':include/uapi/linux/videodev2.h
This field being 'enum v4l2_tuner_type' is unlikely as it seems to be never used that way in drivers, and documentation confirms it. It seem this comment got in accidentally in the commit which this patch fixes. Fix the UAPI comment to stop confusion.
This was pointed out by Dmitry while reviewing VIDIOC_ENUMINPUT support for strace.
--- include/uapi/linux/videodev2.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/uapi/linux/videodev2.h +1 -1
@@ -1720,7 +1720,7 @@ struct v4l2_input {__u8 name[32 ];/* Label */ __u32 type;/* Type of input */ __u32 audioset;/* Associated audios (bitfield) */ -__u32 tuner;/* enum v4l2_tuner_type */ +__u32 tuner;/* Tuner index */ v4l2_std_id std;__u32 status;__u32 capabilities;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 572/800 media: usb: siano: Fix warning due to null work_func_t function pointer
In reply to Greg Kroah-HartmanFrom: Duoming Zhou <[email protected]>
[ Upstream commit 6f489a966fbeb0da63d45c2c66a8957eab604bf6 ]
The previous commit ebad8e731c1c ("media: usb: siano: Fix use after free bugs caused by do_submit_urb") adds cancel_work_sync() in smsusb_stop_streaming(). But smsusb_stop_streaming() may be called, even if the work_struct surb->wq has not been initialized. As a result, the warning will occur. One of the processes that could lead to warning is shown below:
smsusb_probe()
smsusb_init_device()
if (!dev->in_ep || !dev->out_ep || align < 0) {
smsusb_term_device(intf);
smsusb_stop_streaming()
cancel_work_sync(&dev->surbs[i].wq);
__cancel_work_timer()
__flush_work()
if (WARN_ON(!work->func)) // work->func is nullThe log reported by syzbot is shown below:
WARNING: CPU: 0 PID: 897 at kernel/workqueue.c:3066 __flush_work+0x798/0xa80 kernel/workqueue.c:3063 Modules linked in: CPU: 0 PID: 897 Comm: kworker/0:2 Not tainted 6.2.0-rc1-syzkaller #0 RIP: 0010:__flush_work+0x798/0xa80 kernel/workqueue.c:3066 ... RSP: 0018:ffffc9000464ebf8 EFLAGS: 00010246 RAX: 1ffff11002dbb420 RBX: 0000000000000021 RCX: 1ffffffff204fa4e RDX: dffffc0000000000 RSI: 0000000000000001 RDI: ffff888016dda0e8 RBP: ffffc9000464ed98 R08: 0000000000000001 R09: ffffffff90253b2f R10: 0000000000000001 R11: 0000000000000000 R12: ffff888016dda0e8 R13: ffff888016dda0e8 R14: ffff888016dda100 R15: 0000000000000001 FS: 0000000000000000(0000) GS:ffff8880b9a00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007ffd4331efe8 CR3: 000000000b48e000 CR4: 00000000003506f0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: <TASK> __cancel_work_timer+0x315/0x460 kernel/workqueue.c:3160 smsusb_stop_streaming drivers/media/usb/siano/smsusb.c:182 [inline] smsusb_term_device+0xda/0x2d0 drivers/media/usb/siano/smsusb.c:344 smsusb_init_device+0x400/0x9ce drivers/media/usb/siano/smsusb.c:419 smsusb_probe+0xbbd/0xc55 drivers/media/usb/siano/smsusb.c:567
...
This patch adds check before cancel_work_sync(). If surb->wq has not been initialized, the cancel_work_sync() will not be executed.
--- drivers/media/usb/siano/smsusb.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/media/usb/siano/smsusb.c +2 -1
@@ -179,7 +179,8 @@ static void smsusb_stop_streaming(struct smsusb_device_t *dev)for (i =0 ; i <MAX_URBS ; i++) {usb_kill_urb (&dev->surbs[i].urb); -cancel_work_sync (&dev->surbs[i].wq); +if (dev->surbs[i].wq.func) +cancel_work_sync (&dev->surbs[i].wq);if (dev->surbs[i].cb) {smscore_putbuffer (dev->coredev, dev->surbs[i].cb);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 573/800 media: i2c: imx296: fix error checking in imx296_read_temperature()
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit 1b3565dbc6aa124f34674e3dcf6966f663817e05 ]
The "& IMX296_TMDOUT_MASK" means that "tmdout" can't be negative so the error checking will not work.
--- drivers/media/i2c/imx296.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/media/i2c/imx296.c +3 -1
@@ -922,10 +922,12 @@ static int imx296_read_temperature(struct imx296 *sensor, int *temp)if (ret <0 )return ret; - tmdout =imx296_read (sensor,IMX296_TMDOUT ) &IMX296_TMDOUT_MASK ; + tmdout =imx296_read (sensor,IMX296_TMDOUT );if (tmdout <0 )return tmdout; + tmdout &=IMX296_TMDOUT_MASK ; +/* T(°C) = 246.312 - 0.304 * TMDOUT */ ; *temp =246312 -304 * tmdout;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 574/800 media: i2c: Correct format propagation for st-mipid02
In reply to Greg Kroah-HartmanFrom: Daniel Scally <[email protected]>
[ Upstream commit 306c3190b30d4d6a098888b9d7d4cefaa0ddcb91 ]
Format propagation in the st-mipid02 driver is incorrect in that when setting format for V4L2_SUBDEV_FORMAT_TRY on the source pad, the _active_ rather than _try_ format from the sink pad is propagated. This causes problems with format negotiation - update the function to propagate the correct format.
--- drivers/media/i2c/st-mipid02.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/media/i2c/st-mipid02.c +7 -2
@@ -736,8 +736,13 @@ static void mipid02_set_fmt_source(struct v4l2_subdev *sd, {struct mipid02_dev *bridge =to_mipid02_dev (sd); -/* source pad mirror active sink pad */ - format->format = bridge->fmt; +/* source pad mirror sink pad */ +if (format->which ==V4L2_SUBDEV_FORMAT_ACTIVE ) + format->format = bridge->fmt; +else + format->format = *v4l2_subdev_get_try_format (sd, sd_state, +MIPID02_SINK_0 ); +/* but code may need to be converted */ format->format.code =serial_to_parallel_code (format->format.code);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 575/800 media: renesas: fdp1: Identify R-Car Gen2 versions
In reply to Greg Kroah-HartmanFrom: Geert Uytterhoeven <[email protected]>
[ Upstream commit 59a95979638664a905cd46845e7cac1b3ff942f7 ]
On R-Car M2-W:
rcar_fdp1 fe940000.fdp1: FDP1 Unidentifiable (0x02010101)
rcar_fdp1 fe944000.fdp1: FDP1 Unidentifiable (0x02010101)Although the IP Internal Data Register on R-Car Gen2 is documented to contain all zeros, the actual register contents seem to match the FDP1 version ID of R-Car H3 ES1.*, which has just been removed. Fortunately this version is not used for any other purposes yet.
Fix this by re-adding the ID, now using an R-Car Gen2-specific name.
--- drivers/media/platform/renesas/rcar_fdp1.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/media/platform/renesas/rcar_fdp1.c +5 -0
@@ -254,6 +254,8 @@ MODULE_PARM_DESC(debug, "activate debug info");/* Internal Data (HW Version) */ #define FD1_IP_INTDATA 0x0800 +/* R-Car Gen2 HW manual says zero, but actual value matches R-Car H3 ES1.x */ +#define FD1_IP_GEN2 0x02010101#define FD1_IP_M3W 0x02010202#define FD1_IP_H3 0x02010203#define FD1_IP_M3N 0x02010204
@@ -2360,6 +2362,9 @@ static int fdp1_probe(struct platform_device *pdev) hw_version =fdp1_read (fdp1,FD1_IP_INTDATA );switch (hw_version) { +case FD1_IP_GEN2 : +dprintk (fdp1,"FDP1 Version R-Car Gen2\n" ); +break ;case FD1_IP_M3W :dprintk (fdp1,"FDP1 Version R-Car M3-W\n" );break ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 576/800 media: hi846: fix usage of pm_runtime_get_if_in_use()
In reply to Greg Kroah-HartmanFrom: Martin Kepplinger <[email protected]>
[ Upstream commit 04fc06f6dc1592ed5d675311ac50d8fba5db62ab ]
pm_runtime_get_if_in_use() does not only return nonzero values when the device is in use, it can return a negative errno too.
And especially during resuming from system suspend, when runtime pm is not yet up again, -EAGAIN is being returned, so the subsequent pm_runtime_put() call results in a refcount underflow.
Fix system-resume by handling -EAGAIN of pm_runtime_get_if_in_use().
--- drivers/media/i2c/hi846.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/media/i2c/hi846.c +2 -1
@@ -1353,7 +1353,8 @@ static int hi846_set_ctrl(struct v4l2_ctrl *ctrl) exposure_max); } -if (!pm_runtime_get_if_in_use (&client->dev)) + ret =pm_runtime_get_if_in_use (&client->dev); +if (!ret || ret == -EAGAIN )return 0 ;switch (ctrl->id) {
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 577/800 media: mediatek: vcodec: using decoder status instead of core work count
In reply to Greg Kroah-HartmanFrom: Yunfei Dong <[email protected]>
[ Upstream commit 2864e304faec04c2674328aad0e820a9cd84cdec ]
Adding the definition of decoder status to separate different decoder period for core hardware.
core_work_cnt is the number of core work queued to work queue, the control is very complex, leading to some unreasonable test result.
Using parameter status to indicate whether queue core work to work queue.
--- .../platform/mediatek/vcodec/vdec_msg_queue.c | 33 ++++++++----------- .../platform/mediatek/vcodec/vdec_msg_queue.h | 16 +++++++-- 2 files changed, 28 insertions(+), 21 deletions(-)
drivers/media/platform/mediatek/vcodec/vdec_msg_queue.c +14 -19
@@ -71,7 +71,6 @@ static void vdec_msg_queue_dec(struct vdec_msg_queue *msg_queue, int hardware_inint vdec_msg_queue_qbuf (struct vdec_msg_queue_ctx *msg_ctx,struct vdec_lat_buf *buf) {struct list_head *head; -int status; head =vdec_get_buf_list (msg_ctx->hardware_index, buf);if (!head) {
@@ -87,12 +86,9 @@ int vdec_msg_queue_qbuf(struct vdec_msg_queue_ctx *msg_ctx, struct vdec_lat_bufif (msg_ctx->hardware_index !=MTK_VDEC_CORE ) {wake_up_all (&msg_ctx->ready_to_use); }else { -if (buf->ctx->msg_queue.core_work_cnt < -atomic_read (&buf->ctx->msg_queue.core_list_cnt)) { - status =queue_work (buf->ctx->dev->core_workqueue, - &buf->ctx->msg_queue.core_work); -if (status) - buf->ctx->msg_queue.core_work_cnt++; +if (!(buf->ctx->msg_queue.status &CONTEXT_LIST_QUEUED )) { +queue_work (buf->ctx->dev->core_workqueue, &buf->ctx->msg_queue.core_work); + buf->ctx->msg_queue.status |=CONTEXT_LIST_QUEUED ; } }
@@ -261,7 +257,10 @@ static void vdec_msg_queue_core_work(struct work_struct *work) container_of(msg_queue, struct mtk_vcodec_ctx, msg_queue);struct mtk_vcodec_dev *dev = ctx->dev;struct vdec_lat_buf *lat_buf; -int status; + +spin_lock (&ctx->dev->msg_queue_core_ctx.ready_lock); + ctx->msg_queue.status &= ~CONTEXT_LIST_QUEUED ; +spin_unlock (&ctx->dev->msg_queue_core_ctx.ready_lock); lat_buf =vdec_msg_queue_dqbuf (&dev->msg_queue_core_ctx);if (!lat_buf)
@@ -278,17 +277,13 @@ static void vdec_msg_queue_core_work(struct work_struct *work)vdec_msg_queue_qbuf (&ctx->msg_queue.lat_ctx, lat_buf);wake_up_all (&ctx->msg_queue.core_dec_done); -spin_lock (&dev->msg_queue_core_ctx.ready_lock); - lat_buf->ctx->msg_queue.core_work_cnt--; - -if (lat_buf->ctx->msg_queue.core_work_cnt < -atomic_read (&lat_buf->ctx->msg_queue.core_list_cnt)) { - status =queue_work (lat_buf->ctx->dev->core_workqueue, - &lat_buf->ctx->msg_queue.core_work); -if (status) - lat_buf->ctx->msg_queue.core_work_cnt++; +if (!(ctx->msg_queue.status &CONTEXT_LIST_QUEUED ) && +atomic_read (&msg_queue->core_list_cnt)) { +spin_lock (&ctx->dev->msg_queue_core_ctx.ready_lock); + ctx->msg_queue.status |=CONTEXT_LIST_QUEUED ; +spin_unlock (&ctx->dev->msg_queue_core_ctx.ready_lock); +queue_work (ctx->dev->core_workqueue, &msg_queue->core_work); } -spin_unlock (&dev->msg_queue_core_ctx.ready_lock); } int vdec_msg_queue_init(struct vdec_msg_queue *msg_queue,
@@ -303,13 +298,13 @@ int vdec_msg_queue_init(struct vdec_msg_queue *msg_queue,return 0 ; msg_queue->ctx = ctx; - msg_queue->core_work_cnt =0 ;vdec_msg_queue_init_ctx (&msg_queue->lat_ctx,MTK_VDEC_LAT0 );INIT_WORK (&msg_queue->core_work, vdec_msg_queue_core_work);atomic_set (&msg_queue->lat_list_cnt,0 );atomic_set (&msg_queue->core_list_cnt,0 );init_waitqueue_head (&msg_queue->core_dec_done); + msg_queue->status =CONTEXT_LIST_EMPTY ; msg_queue->wdma_addr.size = vde_msg_queue_get_trans_size(ctx->picinfo.buf_w,
drivers/media/platform/mediatek/vcodec/vdec_msg_queue.h +14 -2
@@ -21,6 +21,18 @@ struct mtk_vcodec_ctx;struct mtk_vcodec_dev ;typedef int (*core_decode_cb_t )(struct vdec_lat_buf *lat_buf); +/** +* enum core_ctx_status - Context decode status for core hardwre. +* @CONTEXT_LIST_EMPTY: No buffer queued on core hardware(must always be 0) +* @CONTEXT_LIST_QUEUED: Buffer queued to core work list +* @CONTEXT_LIST_DEC_DONE: context decode done +*/ +enum core_ctx_status { +CONTEXT_LIST_EMPTY =0 , +CONTEXT_LIST_QUEUED , +CONTEXT_LIST_DEC_DONE , +}; +/** * struct vdec_msg_queue_ctx - represents a queue for buffers ready to be processed * @ready_to_use: ready used queue used to signalize when get a job queue
@@ -77,7 +89,7 @@ struct vdec_lat_buf {* @lat_list_cnt: used to record each instance lat list count * @core_list_cnt: used to record each instance core list count * @core_dec_done: core work queue decode done event -* @core_work_cnt: the number of core work in work queue +* @status: current context decode status for core hardware */ struct vdec_msg_queue {struct vdec_lat_buf lat_buf[NUM_BUFFER_COUNT ];
@@ -93,7 +105,7 @@ struct vdec_msg_queue {atomic_t lat_list_cnt;atomic_t core_list_cnt;wait_queue_head_t core_dec_done; -int core_work_cnt; +int status; };/**
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 578/800 clk: qcom: ipq6018: fix networking resets
In reply to Greg Kroah-HartmanFrom: Robert Marko <[email protected]>
[ Upstream commit 349b5bed539b491b7894a5186a895751fd8ba6c7 ]
Networking resets in IPQ6018 all use bitmask as they require multiple bits to be set and cleared instead of a single bit.
So, current networking resets have the same register and bit 0 set which is clearly incorrect.
--- drivers/clk/qcom/gcc-ipq6018.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-)
drivers/clk/qcom/gcc-ipq6018.c +16 -16
@@ -4517,24 +4517,24 @@ static const struct qcom_reset_map gcc_ipq6018_resets[] = { [GCC_PCIE0_AHB_ARES] = { 0x75040, 5 }, [GCC_PCIE0_AXI_MASTER_STICKY_ARES] = { 0x75040, 6 }, [GCC_PCIE0_AXI_SLAVE_STICKY_ARES] = { 0x75040, 7 }, - [GCC_PPE_FULL_RESET] = { 0x68014, 0 }, - [GCC_UNIPHY0_SOFT_RESET] = { 0x56004, 0 }, + [GCC_PPE_FULL_RESET] = { .reg = 0x68014, .bitmask = 0xf0000 }, + [GCC_UNIPHY0_SOFT_RESET] = { .reg = 0x56004, .bitmask = 0x3ff2 }, [GCC_UNIPHY0_XPCS_RESET] = { 0x56004, 2 }, - [GCC_UNIPHY1_SOFT_RESET] = { 0x56104, 0 }, + [GCC_UNIPHY1_SOFT_RESET] = { .reg = 0x56104, .bitmask = 0x32 }, [GCC_UNIPHY1_XPCS_RESET] = { 0x56104, 2 }, - [GCC_EDMA_HW_RESET] = { 0x68014, 0 }, - [GCC_NSSPORT1_RESET] = { 0x68014, 0 }, - [GCC_NSSPORT2_RESET] = { 0x68014, 0 }, - [GCC_NSSPORT3_RESET] = { 0x68014, 0 }, - [GCC_NSSPORT4_RESET] = { 0x68014, 0 }, - [GCC_NSSPORT5_RESET] = { 0x68014, 0 }, - [GCC_UNIPHY0_PORT1_ARES] = { 0x56004, 0 }, - [GCC_UNIPHY0_PORT2_ARES] = { 0x56004, 0 }, - [GCC_UNIPHY0_PORT3_ARES] = { 0x56004, 0 }, - [GCC_UNIPHY0_PORT4_ARES] = { 0x56004, 0 }, - [GCC_UNIPHY0_PORT5_ARES] = { 0x56004, 0 }, - [GCC_UNIPHY0_PORT_4_5_RESET] = { 0x56004, 0 }, - [GCC_UNIPHY0_PORT_4_RESET] = { 0x56004, 0 }, + [GCC_EDMA_HW_RESET] = { .reg = 0x68014, .bitmask = 0x300000 }, + [GCC_NSSPORT1_RESET] = { .reg = 0x68014, .bitmask = 0x1000003 }, + [GCC_NSSPORT2_RESET] = { .reg = 0x68014, .bitmask = 0x200000c }, + [GCC_NSSPORT3_RESET] = { .reg = 0x68014, .bitmask = 0x4000030 }, + [GCC_NSSPORT4_RESET] = { .reg = 0x68014, .bitmask = 0x8000300 }, + [GCC_NSSPORT5_RESET] = { .reg = 0x68014, .bitmask = 0x10000c00 }, + [GCC_UNIPHY0_PORT1_ARES] = { .reg = 0x56004, .bitmask = 0x30 }, + [GCC_UNIPHY0_PORT2_ARES] = { .reg = 0x56004, .bitmask = 0xc0 }, + [GCC_UNIPHY0_PORT3_ARES] = { .reg = 0x56004, .bitmask = 0x300 }, + [GCC_UNIPHY0_PORT4_ARES] = { .reg = 0x56004, .bitmask = 0xc00 }, + [GCC_UNIPHY0_PORT5_ARES] = { .reg = 0x56004, .bitmask = 0x3000 }, + [GCC_UNIPHY0_PORT_4_5_RESET] = { .reg = 0x56004, .bitmask = 0x3c02 }, + [GCC_UNIPHY0_PORT_4_RESET] = { .reg = 0x56004, .bitmask = 0xc02 }, [GCC_LPASS_BCR] = {0x1F000, 0}, [GCC_UBI32_TBU_BCR] = {0x65000, 0}, [GCC_LPASS_TBU_BCR] = {0x6C000, 0},
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 579/800 clk: qcom: dispcc-qcm2290: Fix BI_TCXO_AO handling
In reply to Greg Kroah-HartmanFrom: Konrad Dybcio <[email protected]>
[ Upstream commit 92dfee0fc889b5b00ffb6b1de87ce64c483bcb7b ]
BI_TCXO_AO (.fw_name = "bi_tcxo_ao") was previously made to reuse the same parent enum entry as BI_TCXO (.fw_name = "bi_tcxo") in parent_map_2.
Resolve it by introducing its own entry in the parent enum and correctly assigning it in disp_cc_parent_map_2[].
--- drivers/clk/qcom/dispcc-qcm2290.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/clk/qcom/dispcc-qcm2290.c +3 -2
@@ -24,6 +24,7 @@enum {P_BI_TCXO , +P_BI_TCXO_AO ,P_DISP_CC_PLL0_OUT_MAIN ,P_DSI0_PHY_PLL_OUT_BYTECLK ,P_DSI0_PHY_PLL_OUT_DSICLK ,
@@ -82,7 +83,7 @@ static const struct clk_parent_data disp_cc_parent_data_1[] = { };static const struct parent_map disp_cc_parent_map_2[] = { - {P_BI_TCXO ,0 }, + {P_BI_TCXO_AO ,0 }, {P_GPLL0_OUT_MAIN ,4 }, };
@@ -151,7 +152,7 @@ static struct clk_regmap_div disp_cc_mdss_byte0_div_clk_src = { };static const struct freq_tbl ftbl_disp_cc_mdss_ahb_clk_src[] = { -F (19200000 ,P_BI_TCXO ,1 ,0 ,0 ), +F (19200000 ,P_BI_TCXO_AO ,1 ,0 ,0 ),F (37500000 ,P_GPLL0_OUT_MAIN ,8 ,0 ,0 ),F (75000000 ,P_GPLL0_OUT_MAIN ,4 ,0 ,0 ), { }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 580/800 clk: qcom: dispcc-qcm2290: Fix GPLL0_OUT_DIV handling
In reply to Greg Kroah-HartmanFrom: Konrad Dybcio <[email protected]>
[ Upstream commit 63d56adf04b5795e54440dc5b7afddecb2966863 ]
GPLL0_OUT_DIV (.fw_name = "gcc_disp_gpll0_div_clk_src") was previously made to reuse the same parent enum entry as GPLL0_OUT_MAIN (.fw_name = "gcc_disp_gpll0_clk_src") in parent_map_2.
Resolve it by introducing its own entry in the parent enum and correctly assigning it in disp_cc_parent_map_2[].
--- drivers/clk/qcom/dispcc-qcm2290.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/clk/qcom/dispcc-qcm2290.c +4 -3
@@ -28,6 +28,7 @@ enum {P_DISP_CC_PLL0_OUT_MAIN ,P_DSI0_PHY_PLL_OUT_BYTECLK ,P_DSI0_PHY_PLL_OUT_DSICLK , +P_GPLL0_OUT_DIV ,P_GPLL0_OUT_MAIN , P_SLEEP_CLK, };
@@ -84,7 +85,7 @@ static const struct clk_parent_data disp_cc_parent_data_1[] = {static const struct parent_map disp_cc_parent_map_2[] = { {P_BI_TCXO_AO ,0 }, - {P_GPLL0_OUT_MAIN ,4 }, + {P_GPLL0_OUT_DIV ,4 }, };static const struct clk_parent_data disp_cc_parent_data_2[] = {
@@ -153,8 +154,8 @@ static struct clk_regmap_div disp_cc_mdss_byte0_div_clk_src = {static const struct freq_tbl ftbl_disp_cc_mdss_ahb_clk_src[] = {F (19200000 ,P_BI_TCXO_AO ,1 ,0 ,0 ), -F (37500000 ,P_GPLL0_OUT_MAIN ,8 ,0 ,0 ), -F (75000000 ,P_GPLL0_OUT_MAIN ,4 ,0 ,0 ), +F (37500000 ,P_GPLL0_OUT_DIV ,8 ,0 ,0 ), +F (75000000 ,P_GPLL0_OUT_DIV ,4 ,0 ,0 ), { } };
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 581/800 clk: qcom: ipq5332: fix the src parameter in ftbl_gcc_apss_axi_clk_src
In reply to Greg Kroah-HartmanFrom: Kathiravan T <[email protected]>
[ Upstream commit 81c1ef89a45eccd5603f1e27e281d14fefcb81f9 ]
480MHz is derived from P_GPLL4_OUT_AUX not from P_GPLL4_OUT_MAIN. Update the freq_tbl with the correct src.
--- drivers/clk/qcom/gcc-ipq5332.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/qcom/gcc-ipq5332.c +1 -1
@@ -366,7 +366,7 @@ static struct clk_rcg2 gcc_adss_pwm_clk_src = { };static const struct freq_tbl ftbl_gcc_apss_axi_clk_src[] = { -F (480000000 ,P_GPLL4_OUT_MAIN ,2.5 ,0 ,0 ), +F (480000000 ,P_GPLL4_OUT_AUX ,2.5 ,0 ,0 ),F (533333333 ,P_GPLL0_OUT_MAIN ,1.5 ,0 ,0 ), { } };
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 582/800 clk: qcom: ipq5332: fix the order of SLEEP_CLK and XO clock
In reply to Greg Kroah-HartmanFrom: Kathiravan T <[email protected]>
[ Upstream commit 7510e80f4ac707efc7e964120525ef759a02f171 ]
The order of DT_SLEEP_CLK and DT_XO are swapped and it is incorrect. Due to which the clocks for which the parent should be XO is having parent as SLEEP_CLK and vice versa. So fix the same by re-ordering the entries.
--- drivers/clk/qcom/gcc-ipq5332.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/qcom/gcc-ipq5332.c +1 -1
@@ -20,8 +20,8 @@#include "reset.h" enum { -DT_SLEEP_CLK ,DT_XO , +DT_SLEEP_CLK ,DT_PCIE_2LANE_PHY_PIPE_CLK ,DT_PCIE_2LANE_PHY_PIPE_CLK_X1 ,DT_USB_PCIE_WRAPPER_PIPE_CLK ,
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 583/800 clk: qcom: mmcc-msm8974: use clk_rcg2_shared_ops for mdp_clk_src clock
In reply to Greg Kroah-HartmanFrom: Dmitry Baryshkov <[email protected]>
[ Upstream commit 8fd492e77ff71f68f7311c22f7bc960182465cd7 ]
The mdp_clk_src clock should not be turned off. Instead it should be 'parked' to the XO, as most of other mdp_clk_src clocks. Fix that by using the clk_rcg2_shared_ops.
--- drivers/clk/qcom/mmcc-msm8974.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/qcom/mmcc-msm8974.c +1 -1
@@ -485,7 +485,7 @@ static struct clk_rcg2 mdp_clk_src = { .name = "mdp_clk_src", .parent_data = mmcc_xo_mmpll0_dsi_hdmi_gpll0, .num_parents = ARRAY_SIZE(mmcc_xo_mmpll0_dsi_hdmi_gpll0), - .ops = &clk_rcg2_ops, + .ops = &clk_rcg2_shared_ops, }, };
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 584/800 staging: vchiq_arm: mark vchiq_platform_init() static
In reply to Greg Kroah-HartmanFrom: Arnd Bergmann <[email protected]>
[ Upstream commit e152c58d7a48194d6b530d8e004d650fd01568b6 ]
This function has no callers from other files, and the declaration was removed a while ago, causing a W=1 warning:
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c:465:5: error: no previous prototype for 'vchiq_platform_init'
Marking it static solves this problem but introduces a new warning since gcc determines that 'g_fragments_base' is never initialized in some kernel configurations:
In file included from include/linux/string.h:254,
from include/linux/bitmap.h:11,
from include/linux/cpumask.h:12,
from include/linux/mm_types_task.h:14,
from include/linux/mm_types.h:5,
from include/linux/buildid.h:5,
from include/linux/module.h:14,
from drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c:8:
In function 'memcpy_to_page',
inlined from 'free_pagelist' at drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c:433:4:include/linux/fortify-string.h:57:33: error: argument 2 null where non-null expected [-Werror=nonnull] include/linux/highmem.h:427:9: note: in expansion of macro 'memcpy'
427 | memcpy(to + offset, from, len);
| ^~~~~~Add a NULL pointer check for this in addition to the static annotation to avoid both.
--- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +2 -2
@@ -415,7 +415,7 @@ free_pagelist(struct vchiq_instance *instance, struct vchiq_pagelist_info *pagel pagelistinfo->scatterlist_mapped =0 ;/* Deal with any partial cache lines (fragments) */ -if (pagelist->type >=PAGELIST_READ_WITH_FRAGMENTS ) { +if (pagelist->type >=PAGELIST_READ_WITH_FRAGMENTS && g_fragments_base) {char *fragments = g_fragments_base + (pagelist->type -PAGELIST_READ_WITH_FRAGMENTS ) * g_fragments_size;
@@ -462,7 +462,7 @@ free_pagelist(struct vchiq_instance *instance, struct vchiq_pagelist_info *pagelcleanup_pagelistinfo (instance, pagelistinfo); } -int vchiq_platform_init (struct platform_device *pdev,struct vchiq_state *state) +static int vchiq_platform_init (struct platform_device *pdev,struct vchiq_state *state) {struct device *dev = &pdev->dev;struct vchiq_drvdata *drvdata =platform_get_drvdata (pdev);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 585/800 soundwire: qcom: use consistently ctrl as state variable name
In reply to Greg Kroah-HartmanFrom: Krzysztof Kozlowski <[email protected]>
[ Upstream commit 6f76e79153d588ebb00becbfc200ec3b983e353e ]
The pointer to 'struct qcom_swrm_ctrl' was called sometimes 'swrm' and sometimes 'ctrl' variable. Choose one - 'ctrl' - so the code will be consistent and easier to read.
No functional change.
Stable-dep-of: 9f9914b178a7 ("soundwire: qcom: fix unbalanced pm_runtime_put()")
--- drivers/soundwire/qcom.c | 168 +++++++++++++++++++-------------------- 1 file changed, 84 insertions(+), 84 deletions(-)
drivers/soundwire/qcom.c +84 -84
@@ -278,14 +278,14 @@ static u32 swrm_get_packed_reg_val(u8 *cmd_id, u8 cmd_data,return val; } -static int swrm_wait_for_rd_fifo_avail (struct qcom_swrm_ctrl *swrm) +static int swrm_wait_for_rd_fifo_avail (struct qcom_swrm_ctrl *ctrl) {u32 fifo_outstanding_data, value;int fifo_retry_count =SWR_OVERFLOW_RETRY_COUNT ; do { /* Check for fifo underflow during read */ - swrm->reg_read(swrm, SWRM_CMD_FIFO_STATUS, &value); + ctrl->reg_read(ctrl, SWRM_CMD_FIFO_STATUS, &value); fifo_outstanding_data = FIELD_GET(SWRM_RD_CMD_FIFO_CNT_MASK, value); /* Check if read data is available in read fifo */
@@ -296,39 +296,39 @@ static int swrm_wait_for_rd_fifo_avail(struct qcom_swrm_ctrl *swrm) }while (fifo_retry_count--);if (fifo_outstanding_data ==0 ) { -dev_err_ratelimited (swrm->dev,"%s err read underflow\n" , __func__); +dev_err_ratelimited (ctrl->dev,"%s err read underflow\n" , __func__);return -EIO ; }return 0 ; } -static int swrm_wait_for_wr_fifo_avail (struct qcom_swrm_ctrl *swrm) +static int swrm_wait_for_wr_fifo_avail (struct qcom_swrm_ctrl *ctrl) {u32 fifo_outstanding_cmds, value;int fifo_retry_count =SWR_OVERFLOW_RETRY_COUNT ;do {/* Check for fifo overflow during write */ - swrm->reg_read (swrm,SWRM_CMD_FIFO_STATUS , &value); + ctrl->reg_read (ctrl,SWRM_CMD_FIFO_STATUS , &value); fifo_outstanding_cmds =FIELD_GET (SWRM_WR_CMD_FIFO_CNT_MASK , value);/* Check for space in write fifo before writing */ -if (fifo_outstanding_cmds < swrm->wr_fifo_depth) +if (fifo_outstanding_cmds < ctrl->wr_fifo_depth)return 0 ;usleep_range (500 ,510 ); }while (fifo_retry_count--); -if (fifo_outstanding_cmds == swrm->wr_fifo_depth) { -dev_err_ratelimited (swrm->dev,"%s err write overflow\n" , __func__); +if (fifo_outstanding_cmds == ctrl->wr_fifo_depth) { +dev_err_ratelimited (ctrl->dev,"%s err write overflow\n" , __func__);return -EIO ; }return 0 ; } -static int qcom_swrm_cmd_fifo_wr_cmd (struct qcom_swrm_ctrl *swrm,u8 cmd_data, +static int qcom_swrm_cmd_fifo_wr_cmd (struct qcom_swrm_ctrl *ctrl,u8 cmd_data,u8 dev_addr,u16 reg_addr) {
@@ -341,20 +341,20 @@ static int qcom_swrm_cmd_fifo_wr_cmd(struct qcom_swrm_ctrl *swrm, u8 cmd_data, val =swrm_get_packed_reg_val (&cmd_id, cmd_data, dev_addr, reg_addr); }else { - val =swrm_get_packed_reg_val (&swrm->wcmd_id, cmd_data, + val =swrm_get_packed_reg_val (&ctrl->wcmd_id, cmd_data, dev_addr, reg_addr); } -if (swrm_wait_for_wr_fifo_avail (swrm)) +if (swrm_wait_for_wr_fifo_avail (ctrl))return SDW_CMD_FAIL_OTHER ;if (cmd_id ==SWR_BROADCAST_CMD_ID ) -reinit_completion (&swrm->broadcast); +reinit_completion (&ctrl->broadcast);/* Its assumed that write is okay as we do not get any status back */ - swrm->reg_write (swrm,SWRM_CMD_FIFO_WR_CMD , val); + ctrl->reg_write (ctrl,SWRM_CMD_FIFO_WR_CMD , val); -if (swrm->version <=SWRM_VERSION_1_3_0 ) +if (ctrl->version <=SWRM_VERSION_1_3_0 )usleep_range (150 ,155 );if (cmd_id ==SWR_BROADCAST_CMD_ID ) {
@@ -362,7 +362,7 @@ static int qcom_swrm_cmd_fifo_wr_cmd(struct qcom_swrm_ctrl *swrm, u8 cmd_data,* sleep for 10ms for MSM soundwire variant to allow broadcast * command to complete. */ - ret =wait_for_completion_timeout (&swrm->broadcast, + ret =wait_for_completion_timeout (&ctrl->broadcast,msecs_to_jiffies (TIMEOUT_MS ));if (!ret) ret =SDW_CMD_IGNORED ;
@@ -375,41 +375,41 @@ static int qcom_swrm_cmd_fifo_wr_cmd(struct qcom_swrm_ctrl *swrm, u8 cmd_data,return ret; } -static int qcom_swrm_cmd_fifo_rd_cmd (struct qcom_swrm_ctrl *swrm, +static int qcom_swrm_cmd_fifo_rd_cmd (struct qcom_swrm_ctrl *ctrl,u8 dev_addr,u16 reg_addr,u32 len,u8 *rval) {u32 cmd_data, cmd_id, val, retry_attempt =0 ; - val =swrm_get_packed_reg_val (&swrm->rcmd_id, len, dev_addr, reg_addr); + val =swrm_get_packed_reg_val (&ctrl->rcmd_id, len, dev_addr, reg_addr);/* * Check for outstanding cmd wrt. write fifo depth to avoid * overflow as read will also increase write fifo cnt. */ -swrm_wait_for_wr_fifo_avail (swrm); +swrm_wait_for_wr_fifo_avail (ctrl);/* wait for FIFO RD to complete to avoid overflow */ usleep_range (100 ,105 ); - swrm->reg_write (swrm,SWRM_CMD_FIFO_RD_CMD , val); + ctrl->reg_write (ctrl,SWRM_CMD_FIFO_RD_CMD , val);/* wait for FIFO RD CMD complete to avoid overflow */ usleep_range (250 ,255 ); -if (swrm_wait_for_rd_fifo_avail (swrm)) +if (swrm_wait_for_rd_fifo_avail (ctrl))return SDW_CMD_FAIL_OTHER ; do { - swrm->reg_read(swrm, SWRM_CMD_FIFO_RD_FIFO_ADDR, &cmd_data); + ctrl->reg_read(ctrl, SWRM_CMD_FIFO_RD_FIFO_ADDR, &cmd_data); rval[0] = cmd_data & 0xFF; cmd_id = FIELD_GET(SWRM_RD_FIFO_CMD_ID_MASK, cmd_data); - if (cmd_id != swrm->rcmd_id) { + if (cmd_id != ctrl->rcmd_id) { if (retry_attempt < (MAX_FIFO_RD_RETRY - 1)) { /* wait 500 us before retry on fifo read failure */ usleep_range(500, 505); - swrm->reg_write(swrm, SWRM_CMD_FIFO_CMD, + ctrl->reg_write(ctrl, SWRM_CMD_FIFO_CMD, SWRM_CMD_FIFO_FLUSH); - swrm->reg_write(swrm, SWRM_CMD_FIFO_RD_CMD, val); + ctrl->reg_write(ctrl, SWRM_CMD_FIFO_RD_CMD, val); } retry_attempt++; } else {
@@ -418,9 +418,9 @@ static int qcom_swrm_cmd_fifo_rd_cmd(struct qcom_swrm_ctrl *swrm, }while (retry_attempt <MAX_FIFO_RD_RETRY ); -dev_err (swrm->dev,"failed to read fifo: reg: 0x%x, rcmd_id: 0x%x,\ +dev_err (ctrl->dev,"failed to read fifo: reg: 0x%x, rcmd_id: 0x%x,\ dev_num: 0x%x, cmd_data: 0x%x\n" , - reg_addr, swrm->rcmd_id, dev_addr, cmd_data); + reg_addr, ctrl->rcmd_id, dev_addr, cmd_data);return SDW_CMD_IGNORED ; }
@@ -532,39 +532,39 @@ static int qcom_swrm_enumerate(struct sdw_bus *bus)static irqreturn_t qcom_swrm_wake_irq_handler (int irq,void *dev_id) { -struct qcom_swrm_ctrl *swrm = dev_id; +struct qcom_swrm_ctrl *ctrl = dev_id;int ret; - ret =pm_runtime_resume_and_get (swrm->dev); + ret =pm_runtime_resume_and_get (ctrl->dev);if (ret <0 && ret != -EACCES ) { -dev_err_ratelimited (swrm->dev, +dev_err_ratelimited (ctrl->dev,"pm_runtime_resume_and_get failed in %s, ret %d\n" , __func__, ret);return ret; } -if (swrm->wake_irq >0 ) { -if (!irqd_irq_disabled (irq_get_irq_data (swrm->wake_irq))) -disable_irq_nosync (swrm->wake_irq); +if (ctrl->wake_irq >0 ) { +if (!irqd_irq_disabled (irq_get_irq_data (ctrl->wake_irq))) +disable_irq_nosync (ctrl->wake_irq); } -pm_runtime_mark_last_busy (swrm->dev); -pm_runtime_put_autosuspend (swrm->dev); +pm_runtime_mark_last_busy (ctrl->dev); +pm_runtime_put_autosuspend (ctrl->dev);return IRQ_HANDLED ; }static irqreturn_t qcom_swrm_irq_handler (int irq,void *dev_id) { -struct qcom_swrm_ctrl *swrm = dev_id; +struct qcom_swrm_ctrl *ctrl = dev_id;u32 value, intr_sts, intr_sts_masked, slave_status;u32 i;int devnum;int ret =IRQ_HANDLED ; -clk_prepare_enable (swrm->hclk); +clk_prepare_enable (ctrl->hclk); - swrm->reg_read (swrm,SWRM_INTERRUPT_STATUS , &intr_sts); - intr_sts_masked = intr_sts & swrm->intr_mask; + ctrl->reg_read (ctrl,SWRM_INTERRUPT_STATUS , &intr_sts); + intr_sts_masked = intr_sts & ctrl->intr_mask; do { for (i = 0; i < SWRM_INTERRUPT_MAX; i++) {
@@ -574,80 +574,80 @@ static irqreturn_t qcom_swrm_irq_handler(int irq, void *dev_id)switch (value) {case SWRM_INTERRUPT_STATUS_SLAVE_PEND_IRQ : - devnum =qcom_swrm_get_alert_slave_dev_num (swrm); + devnum =qcom_swrm_get_alert_slave_dev_num (ctrl);if (devnum <0 ) { -dev_err_ratelimited (swrm->dev, +dev_err_ratelimited (ctrl->dev,"no slave alert found.spurious interrupt\n" ); }else { -sdw_handle_slave_status (&swrm->bus, swrm->status); +sdw_handle_slave_status (&ctrl->bus, ctrl->status); }break ;case SWRM_INTERRUPT_STATUS_NEW_SLAVE_ATTACHED :case SWRM_INTERRUPT_STATUS_CHANGE_ENUM_SLAVE_STATUS : -dev_dbg_ratelimited (swrm->dev,"SWR new slave attached\n" ); - swrm->reg_read (swrm,SWRM_MCP_SLV_STATUS , &slave_status); -if (swrm->slave_status == slave_status) { -dev_dbg (swrm->dev,"Slave status not changed %x\n" , +dev_dbg_ratelimited (ctrl->dev,"SWR new slave attached\n" ); + ctrl->reg_read (ctrl,SWRM_MCP_SLV_STATUS , &slave_status); +if (ctrl->slave_status == slave_status) { +dev_dbg (ctrl->dev,"Slave status not changed %x\n" , slave_status); }else { -qcom_swrm_get_device_status (swrm); -qcom_swrm_enumerate (&swrm->bus); -sdw_handle_slave_status (&swrm->bus, swrm->status); +qcom_swrm_get_device_status (ctrl); +qcom_swrm_enumerate (&ctrl->bus); +sdw_handle_slave_status (&ctrl->bus, ctrl->status); }break ;case SWRM_INTERRUPT_STATUS_MASTER_CLASH_DET : -dev_err_ratelimited (swrm->dev, +dev_err_ratelimited (ctrl->dev,"%s: SWR bus clsh detected\n" , __func__); - swrm->intr_mask &= ~SWRM_INTERRUPT_STATUS_MASTER_CLASH_DET ; - swrm->reg_write (swrm,SWRM_INTERRUPT_CPU_EN , swrm->intr_mask); + ctrl->intr_mask &= ~SWRM_INTERRUPT_STATUS_MASTER_CLASH_DET ; + ctrl->reg_write (ctrl,SWRM_INTERRUPT_CPU_EN , ctrl->intr_mask);break ;case SWRM_INTERRUPT_STATUS_RD_FIFO_OVERFLOW : - swrm->reg_read (swrm,SWRM_CMD_FIFO_STATUS , &value); -dev_err_ratelimited (swrm->dev, + ctrl->reg_read (ctrl,SWRM_CMD_FIFO_STATUS , &value); +dev_err_ratelimited (ctrl->dev,"%s: SWR read FIFO overflow fifo status 0x%x\n" , __func__, value);break ;case SWRM_INTERRUPT_STATUS_RD_FIFO_UNDERFLOW : - swrm->reg_read (swrm,SWRM_CMD_FIFO_STATUS , &value); -dev_err_ratelimited (swrm->dev, + ctrl->reg_read (ctrl,SWRM_CMD_FIFO_STATUS , &value); +dev_err_ratelimited (ctrl->dev,"%s: SWR read FIFO underflow fifo status 0x%x\n" , __func__, value);break ;case SWRM_INTERRUPT_STATUS_WR_CMD_FIFO_OVERFLOW : - swrm->reg_read (swrm,SWRM_CMD_FIFO_STATUS , &value); -dev_err (swrm->dev, + ctrl->reg_read (ctrl,SWRM_CMD_FIFO_STATUS , &value); +dev_err (ctrl->dev,"%s: SWR write FIFO overflow fifo status %x\n" , __func__, value); - swrm->reg_write (swrm,SWRM_CMD_FIFO_CMD ,0x1 ); + ctrl->reg_write (ctrl,SWRM_CMD_FIFO_CMD ,0x1 );break ;case SWRM_INTERRUPT_STATUS_CMD_ERROR : - swrm->reg_read (swrm,SWRM_CMD_FIFO_STATUS , &value); -dev_err_ratelimited (swrm->dev, + ctrl->reg_read (ctrl,SWRM_CMD_FIFO_STATUS , &value); +dev_err_ratelimited (ctrl->dev,"%s: SWR CMD error, fifo status 0x%x, flushing fifo\n" , __func__, value); - swrm->reg_write (swrm,SWRM_CMD_FIFO_CMD ,0x1 ); + ctrl->reg_write (ctrl,SWRM_CMD_FIFO_CMD ,0x1 );break ;case SWRM_INTERRUPT_STATUS_DOUT_PORT_COLLISION : -dev_err_ratelimited (swrm->dev, +dev_err_ratelimited (ctrl->dev,"%s: SWR Port collision detected\n" , __func__); - swrm->intr_mask &= ~SWRM_INTERRUPT_STATUS_DOUT_PORT_COLLISION ; - swrm->reg_write (swrm, -SWRM_INTERRUPT_CPU_EN , swrm->intr_mask); + ctrl->intr_mask &= ~SWRM_INTERRUPT_STATUS_DOUT_PORT_COLLISION ; + ctrl->reg_write (ctrl, +SWRM_INTERRUPT_CPU_EN , ctrl->intr_mask);break ;case SWRM_INTERRUPT_STATUS_READ_EN_RD_VALID_MISMATCH : -dev_err_ratelimited (swrm->dev, +dev_err_ratelimited (ctrl->dev,"%s: SWR read enable valid mismatch\n" , __func__); - swrm->intr_mask &= + ctrl->intr_mask &= ~SWRM_INTERRUPT_STATUS_READ_EN_RD_VALID_MISMATCH ; - swrm->reg_write (swrm, -SWRM_INTERRUPT_CPU_EN , swrm->intr_mask); + ctrl->reg_write (ctrl, +SWRM_INTERRUPT_CPU_EN , ctrl->intr_mask);break ;case SWRM_INTERRUPT_STATUS_SPECIAL_CMD_ID_FINISHED : -complete (&swrm->broadcast); +complete (&ctrl->broadcast);break ;case SWRM_INTERRUPT_STATUS_BUS_RESET_FINISHED_V2 :break ;
@@ -656,19 +656,19 @@ static irqreturn_t qcom_swrm_irq_handler(int irq, void *dev_id)case SWRM_INTERRUPT_STATUS_EXT_CLK_STOP_WAKEUP :break ;default : -dev_err_ratelimited (swrm->dev, +dev_err_ratelimited (ctrl->dev,"%s: SWR unknown interrupt value: %d\n" , __func__, value); ret =IRQ_NONE ;break ; } } - swrm->reg_write (swrm,SWRM_INTERRUPT_CLEAR , intr_sts); - swrm->reg_read (swrm,SWRM_INTERRUPT_STATUS , &intr_sts); - intr_sts_masked = intr_sts & swrm->intr_mask; + ctrl->reg_write (ctrl,SWRM_INTERRUPT_CLEAR , intr_sts); + ctrl->reg_read (ctrl,SWRM_INTERRUPT_STATUS , &intr_sts); + intr_sts_masked = intr_sts & ctrl->intr_mask; }while (intr_sts_masked); -clk_disable_unprepare (swrm->hclk); +clk_disable_unprepare (ctrl->hclk);return ret; }
@@ -1292,23 +1292,23 @@ static int qcom_swrm_get_port_config(struct qcom_swrm_ctrl *ctrl)#ifdef CONFIG_DEBUG_FS static int swrm_reg_show (struct seq_file *s_file,void *data) { -struct qcom_swrm_ctrl *swrm = s_file->private; +struct qcom_swrm_ctrl *ctrl = s_file->private;int reg, reg_val, ret; - ret =pm_runtime_resume_and_get (swrm->dev); + ret =pm_runtime_resume_and_get (ctrl->dev);if (ret <0 && ret != -EACCES ) { -dev_err_ratelimited (swrm->dev, +dev_err_ratelimited (ctrl->dev,"pm_runtime_resume_and_get failed in %s, ret %d\n" , __func__, ret);return ret; }for (reg =0 ; reg <=SWR_MSTR_MAX_REG_ADDR ; reg +=4 ) { - swrm->reg_read (swrm, reg, ®_val); + ctrl->reg_read (ctrl, reg, ®_val);seq_printf (s_file,"0x%.3x: 0x%.2x\n" , reg, reg_val); } -pm_runtime_mark_last_busy (swrm->dev); -pm_runtime_put_autosuspend (swrm->dev); +pm_runtime_mark_last_busy (ctrl->dev); +pm_runtime_put_autosuspend (ctrl->dev);return 0 ;
@@ -1489,13 +1489,13 @@ static int qcom_swrm_remove(struct platform_device *pdev)return 0 ; } -static bool swrm_wait_for_frame_gen_enabled (struct qcom_swrm_ctrl *swrm) +static bool swrm_wait_for_frame_gen_enabled (struct qcom_swrm_ctrl *ctrl) {int retry =SWRM_LINK_STATUS_RETRY_CNT ;int comp_sts; do { - swrm->reg_read(swrm, SWRM_COMP_STATUS, &comp_sts); + ctrl->reg_read(ctrl, SWRM_COMP_STATUS, &comp_sts); if (comp_sts & SWRM_FRM_GEN_ENABLED) return true;
@@ -1503,7 +1503,7 @@ static bool swrm_wait_for_frame_gen_enabled(struct qcom_swrm_ctrl *swrm)usleep_range (500 ,510 ); }while (retry--); -dev_err (swrm->dev,"%s: link status not %s\n" , __func__, +dev_err (ctrl->dev,"%s: link status not %s\n" , __func__, comp_sts &SWRM_FRM_GEN_ENABLED ?"connected" :"disconnected" );return false;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 586/800 soundwire: qcom: fix unbalanced pm_runtime_put()
In reply to Greg Kroah-HartmanFrom: Krzysztof Kozlowski <[email protected]>
[ Upstream commit 9f9914b178a7935d2d94ee3e1bf55f2b42b18528 ]
This reverts commit 57ed510b0547 ("soundwire: qcom: use pm_runtime_resume_and_get()") which introduced unbalanced pm_runtime_put(), when device did not have runtime PM enabled.
If pm_runtime_resume_and_get() failed with -EACCES, the driver continued execution and finally called pm_runtime_put_autosuspend(). Since pm_runtime_resume_and_get() drops the usage counter on every error, this lead to double decrement of that counter visible in certain debugfs actions on unattached devices (still in reset state):
$ cat /sys/kernel/debug/soundwire/master-0-0/sdw:0:0217:f001:00:0/registers qcom-soundwire 3210000.soundwire-controller: swrm_wait_for_wr_fifo_avail err write overflow soundwire sdw-master-0: trf on Slave 1 failed:-5 read addr e36 count 1 soundwire sdw:0:0217:f001:00:0: Runtime PM usage count underflow!
--- drivers/soundwire/qcom.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
drivers/soundwire/qcom.c +9 -6
@@ -535,11 +535,12 @@ static irqreturn_t qcom_swrm_wake_irq_handler(int irq, void *dev_id)struct qcom_swrm_ctrl *ctrl = dev_id;int ret; - ret =pm_runtime_resume_and_get (ctrl->dev); + ret =pm_runtime_get_sync (ctrl->dev);if (ret <0 && ret != -EACCES ) {dev_err_ratelimited (ctrl->dev, -"pm_runtime_resume_and_get failed in %s, ret %d\n" , +"pm_runtime_get_sync failed in %s, ret %d\n" , __func__, ret); +pm_runtime_put_noidle (ctrl->dev);return ret; }
@@ -1090,11 +1091,12 @@ static int qcom_swrm_startup(struct snd_pcm_substream *substream,struct snd_soc_dai *codec_dai;int ret, i; - ret =pm_runtime_resume_and_get (ctrl->dev); + ret =pm_runtime_get_sync (ctrl->dev);if (ret <0 && ret != -EACCES ) {dev_err_ratelimited (ctrl->dev, -"pm_runtime_resume_and_get failed in %s, ret %d\n" , +"pm_runtime_get_sync failed in %s, ret %d\n" , __func__, ret); +pm_runtime_put_noidle (ctrl->dev);return ret; }
@@ -1295,11 +1297,12 @@ static int swrm_reg_show(struct seq_file *s_file, void *data)struct qcom_swrm_ctrl *ctrl = s_file->private;int reg, reg_val, ret; - ret =pm_runtime_resume_and_get (ctrl->dev); + ret =pm_runtime_get_sync (ctrl->dev);if (ret <0 && ret != -EACCES ) {dev_err_ratelimited (ctrl->dev, -"pm_runtime_resume_and_get failed in %s, ret %d\n" , +"pm_runtime_get_sync failed in %s, ret %d\n" , __func__, ret); +pm_runtime_put_noidle (ctrl->dev);return ret; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 587/800 soundwire: debugfs: fix unbalanced pm_runtime_put()
In reply to Greg Kroah-HartmanFrom: Krzysztof Kozlowski <[email protected]>
[ Upstream commit 217f5e0de397fafc94d25a8f7baf71920bea4a04 ]
If pm_runtime_resume_and_get() failed with -EACCES, the driver continued execution and finally called pm_runtime_put_autosuspend(). Since pm_runtime_resume_and_get() drops the usage counter on every error, this lead to double decrement of that counter.
--- drivers/soundwire/debugfs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/soundwire/debugfs.c +2 -1
@@ -56,8 +56,9 @@ static int sdw_slave_reg_show(struct seq_file *s_file, void *data)if (!buf)return -ENOMEM ; - ret =pm_runtime_resume_and_get (&slave->dev); + ret =pm_runtime_get_sync (&slave->dev);if (ret <0 && ret != -EACCES ) { +pm_runtime_put_noidle (&slave->dev);kfree (buf);return ret; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 588/800 usb: dwc3: qcom: Fix potential memory leak
In reply to Greg Kroah-HartmanFrom: Vladislav Efanov <[email protected]>
[ Upstream commit 097fb3ee710d4de83b8d4f5589e8ee13e0f0541e ]
Function dwc3_qcom_probe() allocates memory for resource structure which is pointed by parent_res pointer. This memory is not freed. This leads to memory leak. Use stack memory to prevent memory leak.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- drivers/usb/dwc3/dwc3-qcom.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/usb/dwc3/dwc3-qcom.c +3 -3
@@ -800,6 +800,7 @@ static int dwc3_qcom_probe(struct platform_device *pdev)struct device *dev = &pdev->dev;struct dwc3_qcom *qcom;struct resource *res, *parent_res =NULL ; +struct resource local_res;int ret, i;bool ignore_pipe_clk;bool wakeup_source;
@@ -851,9 +852,8 @@ static int dwc3_qcom_probe(struct platform_device *pdev)if (np) { parent_res = res; }else { - parent_res =kmemdup (res,sizeof (struct resource ),GFP_KERNEL ); -if (!parent_res) -return -ENOMEM ; +memcpy (&local_res, res,sizeof (struct resource )); + parent_res = &local_res; parent_res->start = res->start + qcom->acpi_pdata->qscratch_base_offset;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 589/800 usb: gadget: u_serial: Add null pointer check in gserial_suspend
In reply to Greg Kroah-HartmanFrom: Prashanth K <[email protected]>
[ Upstream commit 2f6ecb89fe8feb2b60a53325b0eeb9866d88909a ]
Consider a case where gserial_disconnect has already cleared gser->ioport. And if gserial_suspend gets called afterwards, it will lead to accessing of gser->ioport and thus causing null pointer dereference.
Avoid this by adding a null pointer check. Added a static spinlock to prevent gser->ioport from becoming null after the newly added null pointer check.
--- drivers/usb/gadget/function/u_serial.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
drivers/usb/gadget/function/u_serial.c +11 -2
@@ -1420,10 +1420,19 @@ EXPORT_SYMBOL_GPL(gserial_disconnect);void gserial_suspend (struct gserial *gser) { -struct gs_port *port = gser->ioport; +struct gs_port *port;unsigned long flags; -spin_lock_irqsave (&port->port_lock, flags); +spin_lock_irqsave (&serial_port_lock, flags); + port = gser->ioport; + +if (!port) { +spin_unlock_irqrestore (&serial_port_lock, flags); +return ; + } + +spin_lock (&port->port_lock); +spin_unlock (&serial_port_lock); port->suspended = true;spin_unlock_irqrestore (&port->port_lock, flags); }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 590/800 extcon: Fix kernel doc of property fields to avoid warnings
In reply to Greg Kroah-HartmanFrom: Andy Shevchenko <[email protected]>
[ Upstream commit 7e77e0b7a9f4cdf91cb0950749b40c840ea63efc ]
Kernel documentation has to be synchronized with a code, otherwise the validator is not happy:
Function parameter or member 'usb_propval' not described in 'extcon_cable' Function parameter or member 'chg_propval' not described in 'extcon_cable' Function parameter or member 'jack_propval' not described in 'extcon_cable' Function parameter or member 'disp_propval' not described in 'extcon_cable'
Describe the fields added in the past.
--- drivers/extcon/extcon.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/extcon/extcon.c +4 -0
@@ -206,6 +206,10 @@ static const struct __extcon_info {* @attr_name: "name" sysfs entry * @attr_state: "state" sysfs entry * @attrs: the array pointing to attr_name and attr_state for attr_g +* @usb_propval: the array of USB connector properties +* @chg_propval: the array of charger connector properties +* @jack_propval: the array of jack connector properties +* @disp_propval: the array of display connector properties */ struct extcon_cable {struct extcon_dev *edev;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 591/800 extcon: Fix kernel doc of property capability fields to avoid warnings
In reply to Greg Kroah-HartmanFrom: Andy Shevchenko <[email protected]>
[ Upstream commit 73346b9965ebda2feb7fef8629e9b28baee820e3 ]
Kernel documentation has to be synchronized with a code, otherwise the validator is not happy:
Function parameter or member 'usb_bits' not described in 'extcon_cable' Function parameter or member 'chg_bits' not described in 'extcon_cable' Function parameter or member 'jack_bits' not described in 'extcon_cable' Function parameter or member 'disp_bits' not described in 'extcon_cable'
Describe the fields added in the past.
--- drivers/extcon/extcon.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/extcon/extcon.c +4 -0
@@ -210,6 +210,10 @@ static const struct __extcon_info {* @chg_propval: the array of charger connector properties * @jack_propval: the array of jack connector properties * @disp_propval: the array of display connector properties +* @usb_bits: the bit array of the USB connector property capabilities +* @chg_bits: the bit array of the charger connector property capabilities +* @jack_bits: the bit array of the jack connector property capabilities +* @disp_bits: the bit array of the display connector property capabilities */ struct extcon_cable {struct extcon_dev *edev;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 592/800 usb: phy: phy-tahvo: fix memory leak in tahvo_usb_probe()
In reply to Greg Kroah-HartmanFrom: Li Yang <[email protected]>
[ Upstream commit 342161c11403ea00e9febc16baab1d883d589d04 ]
Smatch reports:drivers/usb/phy/phy-tahvo.c: tahvo_usb_probe()
warn: missing unwind goto?
After geting irq, if ret < 0, it will return without error handling to free memory.
Just add error handling to fix this problem.
--- drivers/usb/phy/phy-tahvo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/phy/phy-tahvo.c +1 -1
@@ -391,7 +391,7 @@ static int tahvo_usb_probe(struct platform_device *pdev) tu->irq = ret =platform_get_irq (pdev,0 );if (ret <0 ) -return ret; + goto err_remove_phy; ret =request_threaded_irq (tu->irq,NULL , tahvo_usb_vbus_interrupt,IRQF_ONESHOT ,"tahvo-vbus" , tu);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 593/800 usb: hide unused usbfs_notify_suspend/resume functions
In reply to Greg Kroah-HartmanFrom: Arnd Bergmann <[email protected]>
[ Upstream commit 8e6bd945e6dde64fbc60ec3fe252164493a8d3a2 ]
The declaration is in an #ifdef, which causes warnings when building with 'make W=1' and without CONFIG_PM:
drivers/usb/core/devio.c:742:6: error: no previous prototype for 'usbfs_notify_suspend' drivers/usb/core/devio.c:747:6: error: no previous prototype for 'usbfs_notify_resume'
Use the same #ifdef check around the function definitions to avoid the warnings and slightly shrink the USB core.
--- drivers/usb/core/devio.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/usb/core/devio.c +2 -0
@@ -746,6 +746,7 @@ static int driver_resume(struct usb_interface *intf)return 0 ; } +#ifdef CONFIG_PM /* The following routines apply to the entire device, not interfaces */ void usbfs_notify_suspend (struct usb_device *udev) {
@@ -764,6 +765,7 @@ void usbfs_notify_resume(struct usb_device *udev) }mutex_unlock (&usbfs_mutex); } +#endif struct usb_driver usbfs_driver = { .name ="usbfs" ,
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 594/800 usb: misc: eud: Fix eud sysfs path (use qcom_eud)
In reply to Greg Kroah-HartmanFrom: Bhupesh Sharma <[email protected]>
[ Upstream commit f16135918b5f8b510db014ecf0a069e34c02382e ]
The eud sysfs enablement path is currently mentioned in the Documentation as:
/sys/bus/platform/drivers/eud/.../enable
Instead it should be:
/sys/bus/platform/drivers/qcom_eud/.../enable
Fix the same.
--- Documentation/ABI/testing/sysfs-driver-eud | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/ABI/testing/sysfs-driver-eud +1 -1
@@ -1,4 +1,4 @@ -What: /sys/bus/platform/drivers/eud/.../enable +What: /sys/bus/platform/drivers/qcom_eud/.../enable Date: February 2022 Contact: Souradeep Chowdhury <[email protected]> Description:
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 595/800 serial: core: lock port for stop_rx() in uart_suspend_port()
In reply to Greg Kroah-HartmanFrom: John Ogness <[email protected]>
[ Upstream commit abcb0cf1f5b2d99b1d117a4dbce334120e358d6d ]
The uarts_ops stop_rx() callback expects that the port->lock is taken and interrupts are disabled.
--- drivers/tty/serial/serial_core.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/tty/serial/serial_core.c +4 -1
@@ -2333,8 +2333,11 @@ int uart_suspend_port(struct uart_driver *drv, struct uart_port *uport)* able to Re-start_rx later. */ if (!console_suspend_enabled &&uart_console (uport)) { -if (uport->ops->start_rx) +if (uport->ops->start_rx) { +spin_lock_irq (&uport->lock); uport->ops->stop_rx (uport); +spin_unlock_irq (&uport->lock); + } goto unlock; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 596/800 serial: 8250: lock port for stop_rx() in omap8250_irq()
In reply to Greg Kroah-HartmanFrom: John Ogness <[email protected]>
[ Upstream commit ca73a892c5bec4b08a2fa22b3015e98ed905abb7 ]
The uarts_ops stop_rx() callback expects that the port->lock is taken and interrupts are disabled.
--- drivers/tty/serial/8250/8250_omap.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/tty/serial/8250/8250_omap.c +2 -0
@@ -651,7 +651,9 @@ static irqreturn_t omap8250_irq(int irq, void *dev_id) up->ier = port->serial_in (port,UART_IER );if (up->ier & (UART_IER_RLSI |UART_IER_RDI )) { +spin_lock (&port->lock); port->ops->stop_rx (port); +spin_unlock (&port->lock); }else {/* Keep restarting the timer until * the input overrun subsides.
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 597/800 serial: core: lock port for start_rx() in uart_resume_port()
In reply to Greg Kroah-HartmanFrom: John Ogness <[email protected]>
[ Upstream commit 51e45fba14bf08b66bca764a083c7f2e2ff62f01 ]
The only user of the start_rx() callback (qcom_geni) directly calls its own stop_rx() callback. Since stop_rx() requires that the port->lock is taken and interrupts are disabled, the start_rx() callback has the same requirement.
--- drivers/tty/serial/serial_core.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/tty/serial/serial_core.c +4 -1
@@ -2430,8 +2430,11 @@ int uart_resume_port(struct uart_driver *drv, struct uart_port *uport)if (console_suspend_enabled)uart_change_pm (state,UART_PM_STATE_ON ); uport->ops->set_termios (uport, &termios,NULL ); -if (!console_suspend_enabled && uport->ops->start_rx) +if (!console_suspend_enabled && uport->ops->start_rx) { +spin_lock_irq (&uport->lock); uport->ops->start_rx (uport); +spin_unlock_irq (&uport->lock); + }if (console_suspend_enabled)console_start (uport->cons); }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 598/800 serial: 8250: lock port for UART_IER access in omap8250_irq()
In reply to Greg Kroah-HartmanFrom: John Ogness <[email protected]>
[ Upstream commit 25614735a647693c1260f253dc3ab32127697806 ]
omap8250_irq() accesses UART_IER. This register is modified twice by each console write (serial8250_console_write()) under the port lock. omap8250_irq() must also take the port lock to guanentee synchronized access to UART_IER.
Since the port lock is already being taken for the stop_rx() callback and since it is safe to call cancel_delayed_work() while holding the port lock, simply extend the port lock region to include UART_IER access.
--- drivers/tty/serial/8250/8250_omap.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/tty/serial/8250/8250_omap.c +3 -2
@@ -649,17 +649,18 @@ static irqreturn_t omap8250_irq(int irq, void *dev_id)if ((lsr &UART_LSR_OE ) && up->overrun_backoff_time_ms >0 ) {unsigned long delay; +/* Synchronize UART_IER access against the console. */ +spin_lock (&port->lock); up->ier = port->serial_in (port,UART_IER );if (up->ier & (UART_IER_RLSI |UART_IER_RDI )) { -spin_lock (&port->lock); port->ops->stop_rx (port); -spin_unlock (&port->lock); }else {/* Keep restarting the timer until * the input overrun subsides. */ cancel_delayed_work (&up->overrun_backoff); } +spin_unlock (&port->lock); delay =msecs_to_jiffies (up->overrun_backoff_time_ms);schedule_delayed_work (&up->overrun_backoff, delay);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 599/800 kernfs: fix missing kernfs_idr_lock to remove an ID from the IDR
In reply to Greg Kroah-HartmanFrom: Muchun Song <[email protected]>
[ Upstream commit 30480b988f88c279752f3202a26b6fee5f586aef ]
The root->ino_idr is supposed to be protected by kernfs_idr_lock, fix it.
--- fs/kernfs/dir.c | 2 ++ 1 file changed, 2 insertions(+)
fs/kernfs/dir.c +2 -0
@@ -655,7 +655,9 @@ static struct kernfs_node *__kernfs_new_node(struct kernfs_root *root,return kn; err_out3: +spin_lock (&kernfs_idr_lock);idr_remove (&root->ino_idr, (u32 )kernfs_ino (kn)); +spin_unlock (&kernfs_idr_lock); err_out2:kmem_cache_free (kernfs_node_cache, kn); err_out1:
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 600/800 lkdtm: replace ll_rw_block with submit_bh
In reply to Greg Kroah-HartmanFrom: Yue Zhao <[email protected]>
[ Upstream commit b290df06811852d4cc36f4b8a2a30c2063197a74 ]
Function ll_rw_block was removed in commit 79f597842069 ("fs/buffer:
remove ll_rw_block() helper"). There is no unified function to sumbit read or write buffer in block layer for now. Consider similar sematics, we can choose submit_bh() to replace ll_rw_block() as predefined crash point. In submit_bh(), it also takes read or write flag as the first argument and invoke submit_bio() to submit I/O request to block layer.
--- Documentation/fault-injection/provoke-crashes.rst | 2 +- drivers/misc/lkdtm/core.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
Documentation/fault-injection/provoke-crashes.rst +1 -1
@@ -29,7 +29,7 @@ recur_count cpoint_name Where in the kernel to trigger the action. It can be one of INT_HARDWARE_ENTRY, INT_HW_IRQ_EN, INT_TASKLET_ENTRY, - FS_DEVRW, MEM_SWAPOUT, TIMERADD, SCSI_QUEUE_RQ, or DIRECT. + FS_SUBMIT_BH, MEM_SWAPOUT, TIMERADD, SCSI_QUEUE_RQ, or DIRECT. cpoint_type Indicates the action to be taken on hitting the crash point.
drivers/misc/lkdtm/core.c +1 -1
@@ -79,7 +79,7 @@ static struct crashpoint crashpoints[] = {CRASHPOINT ("INT_HARDWARE_ENTRY" ,"do_IRQ" ),CRASHPOINT ("INT_HW_IRQ_EN" ,"handle_irq_event" ),CRASHPOINT ("INT_TASKLET_ENTRY" ,"tasklet_action" ), -CRASHPOINT ("FS_DEVRW" ,"ll_rw_block" ), +CRASHPOINT ("FS_SUBMIT_BH" ,"submit_bh" ),CRASHPOINT ("MEM_SWAPOUT" ,"shrink_inactive_list" ),CRASHPOINT ("TIMERADD" ,"hrtimer_start" ), CRASHPOINT("SCSI_QUEUE_RQ", "scsi_queue_rq"),
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 601/800 i3c: master: svc: fix cpu schedule in spin lock
In reply to Greg Kroah-HartmanFrom: Clark Wang <[email protected]>
[ Upstream commit 33beadb3b1ab74e69db2c49d9663f3a93a273943 ]
pm_runtime_resume_and_get() may call sleep(). It cannot be used in svc_i3c_master_start_xfer_locked(), because it is in a spin lock.
Move the pm runtime operations to svc_i3c_master_enqueue_xfer().
--- drivers/i3c/master/svc-i3c-master.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-)
drivers/i3c/master/svc-i3c-master.c +10 -9
@@ -1090,12 +1090,6 @@ static void svc_i3c_master_start_xfer_locked(struct svc_i3c_master *master)if (!xfer)return ; - ret =pm_runtime_resume_and_get (master->dev); -if (ret <0 ) { -dev_err (master->dev,"<%s> Cannot get runtime PM.\n" , __func__); -return ; - } -svc_i3c_master_clear_merrwarn (master);svc_i3c_master_flush_fifo (master);
@@ -1110,9 +1104,6 @@ static void svc_i3c_master_start_xfer_locked(struct svc_i3c_master *master)break ; } -pm_runtime_mark_last_busy (master->dev); -pm_runtime_put_autosuspend (master->dev); - xfer->ret = ret;complete (&xfer->comp);
@@ -1133,6 +1124,13 @@ static void svc_i3c_master_enqueue_xfer(struct svc_i3c_master *master, struct svc_i3c_xfer *xfer) {unsigned long flags; +int ret; + + ret =pm_runtime_resume_and_get (master->dev); +if (ret <0 ) { +dev_err (master->dev,"<%s> Cannot get runtime PM.\n" , __func__); +return ; + }init_completion (&xfer->comp);spin_lock_irqsave (&master->xferqueue.lock, flags);
@@ -1143,6 +1141,9 @@ static void svc_i3c_master_enqueue_xfer(struct svc_i3c_master *master,svc_i3c_master_start_xfer_locked (master); }spin_unlock_irqrestore (&master->xferqueue.lock, flags); + +pm_runtime_mark_last_busy (master->dev); +pm_runtime_put_autosuspend (master->dev); } static bool
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 602/800 coresight: Fix loss of connection info when a module is unloaded
In reply to Greg Kroah-HartmanFrom: James Clark <[email protected]>
[ Upstream commit c45b2835e7b205783bdfe08cc98fa86a7c5eeb74 ]
child_fwnode should be a read only property based on the DT or ACPI. If it's cleared on the parent device when a child is unloaded, then when the child is loaded again the connection won't be remade.
child_dev should be cleared instead which signifies that the connection should be remade when the child_fwnode registers a new coresight_device.
Similarly the reference count shouldn't be decremented as long as the parent device exists. The correct place to drop the reference is in coresight_release_platform_data() which is already done.
Reproducible on Juno with the following steps:
# load all coresight modules. $ cd /sys/bus/coresight/devices/ $ echo 1 > tmc_etr0/enable_sink $ echo 1 > etm0/enable_source # Works fine ^
$ echo 0 > etm0/enable_source $ rmmod coresight-funnel $ modprobe coresight-funnel $ echo 1 > etm0/enable_source -bash: echo: write error: Invalid argument
--- drivers/hwtracing/coresight/coresight-core.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)
drivers/hwtracing/coresight/coresight-core.c +2 -7
@@ -1419,13 +1419,8 @@ static int coresight_remove_match(struct device *dev, void *data)if (csdev->dev.fwnode == conn->child_fwnode) { iterator->orphan = true;coresight_remove_links (iterator, conn); -/* -* Drop the reference to the handle for the remote -* device acquired in parsing the connections from -* platform data. -*/ -fwnode_handle_put (conn->child_fwnode); - conn->child_fwnode =NULL ; + + conn->child_dev =NULL ;/* No need to continue */ break ; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 603/800 coresight: etm4x: Fix missing trctraceidr file in sysfs
In reply to Greg Kroah-HartmanFrom: Mike Leach <[email protected]>
[ Upstream commit 9f37d3798026f9a7447d851a2cb356610852e426 ]
The trace ID patchset adjusted the handling of the TRCTRACEIDR register sysfs to allocate on read.
Although this was initally correct, the final version of the patch series introduced an error which resulted in the mgmt/trctraceidr file in sysfs not being visible.
This patch fixes that issue.
--- .../coresight/coresight-etm4x-sysfs.c | 27 ++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-)
drivers/hwtracing/coresight/coresight-etm4x-sysfs.c +18 -9
@@ -2411,7 +2411,6 @@ static ssize_t trctraceid_show(struct device *dev,return sysfs_emit (buf,"0x%x\n" , trace_id); } -static DEVICE_ATTR_RO (trctraceid);struct etmv4_reg {struct coresight_device *csdev;
@@ -2528,13 +2527,23 @@ coresight_etm4x_attr_reg_implemented(struct kobject *kobj,return 0 ; } -#define coresight_etm4x_reg (name, offset) \ - &((struct dev_ext_attribute[]) { \ - { \ - __ATTR(name, 0444, coresight_etm4x_reg_show, NULL), \ - (void *)(unsigned long)offset \ - } \ - })[0].attr.attr +/* +* Macro to set an RO ext attribute with offset and show function. +* Offset is used in mgmt group to ensure only correct registers for +* the ETM / ETE variant are visible. +*/ +#define coresight_etm4x_reg_showfn (name, offset, showfn) ( \ + &((struct dev_ext_attribute[]) { \ + { \ + __ATTR(name, 0444, showfn, NULL), \ + (void *)(unsigned long)offset \ + } \ + })[0].attr.attr \ + ) + +/* macro using the default coresight_etm4x_reg_show function */ +#define coresight_etm4x_reg (name, offset) \ + coresight_etm4x_reg_showfn(name, offset, coresight_etm4x_reg_show)static struct attribute *coresight_etmv4_mgmt_attrs[] = {coresight_etm4x_reg (trcpdcr,TRCPDCR ),
@@ -2549,7 +2558,7 @@ static struct attribute *coresight_etmv4_mgmt_attrs[] = {coresight_etm4x_reg (trcpidr3,TRCPIDR3 ),coresight_etm4x_reg (trcoslsr,TRCOSLSR ),coresight_etm4x_reg (trcconfig,TRCCONFIGR ), - &dev_attr_trctraceid.attr, +coresight_etm4x_reg_showfn (trctraceid,TRCTRACEIDR , trctraceid_show),coresight_etm4x_reg (trcdevarch,TRCDEVARCH ), NULL, };
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 604/800 power: supply: rt9467: Make charger-enable control as logic level
In reply to Greg Kroah-HartmanFrom: ChiYuan Huang <[email protected]>
[ Upstream commit 5d80a86a99d524b0d89ff3906c6200b9f57b66f8 ]
The current coding make 'charger-enable-gpio' control as real hardware level. This conflicts with the default binding example. For driver behavior, no need to use real hardware level, just logic level is enough. This change can make this flexibility keep in dts gpio active level about this pin.
--- drivers/power/supply/rt9467-charger.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/power/supply/rt9467-charger.c +1 -1
@@ -1192,7 +1192,7 @@ static int rt9467_charger_probe(struct i2c_client *i2c)i2c_set_clientdata (i2c, data);/* Default pull charge enable gpio to make 'CHG_EN' by SW control only */ - ceb_gpio =devm_gpiod_get_optional (dev,"charge-enable" ,GPIOD_OUT_LOW ); + ceb_gpio =devm_gpiod_get_optional (dev,"charge-enable" ,GPIOD_OUT_HIGH );if (IS_ERR (ceb_gpio))return dev_err_probe (dev,PTR_ERR (ceb_gpio),"Failed to config charge enable gpio\n" );
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 605/800 mfd: rt5033: Drop rt5033-battery sub-device
In reply to Greg Kroah-HartmanFrom: Stephan Gerhold <[email protected]>
[ Upstream commit 43db1344e0f8c1eb687a1d6cd5b0de3009ab66cb ]
The fuel gauge in the RT5033 PMIC (rt5033-battery) has its own I2C bus and interrupt lines. Therefore, it is not part of the MFD device and needs to be specified separately in the device tree.
--- drivers/mfd/rt5033.c | 3 --- 1 file changed, 3 deletions(-)
drivers/mfd/rt5033.c +0 -3
@@ -40,9 +40,6 @@ static const struct mfd_cell rt5033_devs[] = { { .name = "rt5033-charger", .of_compatible = "richtek,rt5033-charger", - }, { - .name = "rt5033-battery", - .of_compatible = "richtek,rt5033-battery", }, { .name = "rt5033-led", .of_compatible = "richtek,rt5033-led",
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 606/800 media: venus: helpers: Fix ALIGN() of non power of two
In reply to Greg Kroah-HartmanFrom: Rikard Falkeborn <[email protected]>
[ Upstream commit 927e78ac8bc58155316cf6f46026e1912bbbbcfc ]
ALIGN() expects its second argument to be a power of 2, otherwise incorrect results are produced for some inputs. The output can be both larger or smaller than what is expected.
For example, ALIGN(304, 192) equals 320 instead of 384, and ALIGN(65, 192) equals 256 instead of 192.
However, nestling two ALIGN() as is done in this case seem to only produce results equal to or bigger than the expected result if ALIGN() had handled non powers of two, and that in turn results in framesizes that are either the correct size or too large.
Fortunately, since 192 * 4 / 3 equals 256, it turns out that one ALIGN() is sufficient.
--- drivers/media/platform/qcom/venus/helpers.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/media/platform/qcom/venus/helpers.c +2 -2
@@ -1036,8 +1036,8 @@ static u32 get_framesize_raw_yuv420_tp10_ubwc(u32 width, u32 height)u32 extradata =SZ_16K ;u32 size; - y_stride =ALIGN (ALIGN (width,192 ) *4 /3 ,256 ); - uv_stride =ALIGN (ALIGN (width,192 ) *4 /3 ,256 ); + y_stride =ALIGN (width *4 /3 ,256 ); + uv_stride =ALIGN (width *4 /3 ,256 ); y_sclines =ALIGN (height,16 ); uv_sclines =ALIGN ((height +1 ) >>1 ,16 );
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 607/800 media: atomisp: gc0310: Fix double free in gc0310_remove()
In reply to Greg Kroah-HartmanFrom: Hans de Goede <[email protected]>
[ Upstream commit 2746a966f9f05fdb0727f4e1e8f2d51ec79e071d ]
gc0310_remove() must not call kfree(dev) since the gc0310_device struct is devm managed so explicitly freeing it causes a double free.
While at it add a missing mutex_destroy() call for the input_lock.
--- drivers/staging/media/atomisp/i2c/atomisp-gc0310.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/media/atomisp/i2c/atomisp-gc0310.c +1 -1
@@ -377,8 +377,8 @@ static void gc0310_remove(struct i2c_client *client)v4l2_device_unregister_subdev (sd);media_entity_cleanup (&dev->sd.entity);v4l2_ctrl_handler_free (&dev->ctrls.handler); +mutex_destroy (&dev->input_lock);pm_runtime_disable (&client->dev); -kfree (dev); }static int gc0310_probe (struct i2c_client *client)
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 608/800 media: atomisp: gmin_platform: fix out_len in gmin_get_config_dsm_var()
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit 1657f2934daf89e8d9fa4b2697008909eb22c73e ]
Ideally, strlen(cur->string.pointer) and strlen(out) would be the same. But this code is using strscpy() to avoid a potential buffer overflow. So in the same way we should take the strlen() of the smaller string to avoid a buffer overflow in the caller, gmin_get_var_int().
--- drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c +1 -1
@@ -1357,7 +1357,7 @@ static int gmin_get_config_dsm_var(struct device *dev,dev_info (dev,"found _DSM entry for '%s': %s\n" , var, cur->string.pointer);strscpy (out, cur->string.pointer, *out_len); - *out_len =strlen (cur->string.pointer); + *out_len =strlen (out);ACPI_FREE (obj);return 0 ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 609/800 media: atomisp: ov2680: Stop using half pixelclock for binned modes
In reply to Greg Kroah-HartmanFrom: Hans de Goede <[email protected]>
[ Upstream commit 7d45a432251a30ed0252655177e708229b163291 ]
Stop using half pixelclock for binned modes this fixes:
1. The exposure being twice as high for binned mods (due to the half clk)
2. The framerate being 15 fps instead of 30 fps
The original code with fixed per mode register lists did use half pixel clk, but this should be combined with using half for the VTS value too.
Using half VTS fixes the framerate issue, but this has the undesired side-effect of change the exposure ctrl range (half the range, double the amount of exposure per step).
--- drivers/staging/media/atomisp/i2c/atomisp-ov2680.c | 8 +------- drivers/staging/media/atomisp/i2c/ov2680.h | 1 + 2 files changed, 2 insertions(+), 7 deletions(-)
drivers/staging/media/atomisp/i2c/atomisp-ov2680.c +1 -7
@@ -239,27 +239,21 @@ static void ov2680_calc_mode(struct ov2680_device *sensor, int width, int heightstatic int ov2680_set_mode (struct ov2680_device *sensor) {struct i2c_client *client = sensor->client; -u8 pll_div, unknown, inc, fmt1, fmt2; +u8 unknown, inc, fmt1, fmt2;int ret;if (sensor->mode.binning) { - pll_div =1 ; unknown =0x23 ; inc =0x31 ; fmt1 =0xc2 ; fmt2 =0x01 ; }else { - pll_div =0 ; unknown =0x21 ; inc =0x11 ; fmt1 =0xc0 ; fmt2 =0x00 ; } - ret =ov_write_reg8 (client,0x3086 , pll_div); -if (ret) -return ret; - ret =ov_write_reg8 (client,0x370a , unknown);if (ret)return ret;
drivers/staging/media/atomisp/i2c/ov2680.h +1 -0
@@ -172,6 +172,7 @@ static struct ov2680_reg const ov2680_global_setting[] = { {0x3082, 0x45}, {0x3084, 0x09}, {0x3085, 0x04}, + {0x3086, 0x00}, {0x3503, 0x03}, {0x350b, 0x36}, {0x3600, 0xb4},
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 610/800 sh: Avoid using IRQ0 on SH3 and SH4
In reply to Greg Kroah-HartmanFrom: Sergey Shtylyov <[email protected]>
[ Upstream commit a8ac2961148e8c720dc760f2e06627cd5c55a154 ]
IRQ0 is no longer returned by platform_get_irq() and its ilk -- they now return -EINVAL instead. However, the kernel code supporting SH3/4-based SoCs still maps the IRQ #s starting at 0 -- modify that code to start the IRQ #s from 16 instead.
The patch should mostly affect the AP-SH4A-3A/AP-SH4AD-0A boards as they indeed are using IRQ0 for the SMSC911x compatible Ethernet chip.
--- arch/sh/include/mach-common/mach/highlander.h | 2 +- arch/sh/include/mach-common/mach/r2d.h | 2 +- arch/sh/include/mach-dreamcast/mach/sysasic.h | 2 +- arch/sh/include/mach-se/mach/se7724.h | 2 +- arch/sh/kernel/cpu/sh3/entry.S | 4 ++-- include/linux/sh_intc.h | 6 +++--- 6 files changed, 9 insertions(+), 9 deletions(-)
arch/sh/include/mach-common/mach/highlander.h +1 -1
@@ -176,7 +176,7 @@#define IVDR_CK_ON 4/* iVDR Clock ON */ #endif -#define HL_FPGA_IRQ_BASE 200 +#define HL_FPGA_IRQ_BASE (200 + 16)#define HL_NR_IRL 15#define IRQ_AX88796 (HL_FPGA_IRQ_BASE + 0)
arch/sh/include/mach-common/mach/r2d.h +1 -1
@@ -47,7 +47,7 @@#define IRLCNTR1 (PA_BCR + 0)/* Interrupt Control Register1 */ -#define R2D_FPGA_IRQ_BASE 100 +#define R2D_FPGA_IRQ_BASE (100 + 16)#define IRQ_VOYAGER (R2D_FPGA_IRQ_BASE + 0)#define IRQ_EXT (R2D_FPGA_IRQ_BASE + 1)
arch/sh/include/mach-dreamcast/mach/sysasic.h +1 -1
@@ -22,7 +22,7 @@takes. */ -#define HW_EVENT_IRQ_BASE 48 +#define HW_EVENT_IRQ_BASE (48 + 16)/* IRQ 13 */ #define HW_EVENT_VSYNC (HW_EVENT_IRQ_BASE + 5)/* VSync */
arch/sh/include/mach-se/mach/se7724.h +1 -1
@@ -37,7 +37,7 @@#define IRQ2_IRQ evt2irq(0x640)/* Bits in IRQ012 registers */ -#define SE7724_FPGA_IRQ_BASE 220 +#define SE7724_FPGA_IRQ_BASE (220 + 16)/* IRQ0 */ #define IRQ0_BASE SE7724_FPGA_IRQ_BASE
arch/sh/kernel/cpu/sh3/entry.S +2 -2
@@ -470,9 +470,9 @@ ENTRY(handle_interrupt) mov r4, r0 ! save vector->jmp table offset for later shlr2 r4 ! vector to IRQ# conversion - add #-0x10, r4 - cmp/pz r4 ! is it a valid IRQ? + mov #0x10, r5 + cmp/hs r5, r4 ! is it a valid IRQ? bt 10f /*
include/linux/sh_intc.h +3 -3
@@ -13,9 +13,9 @@/* * Convert back and forth between INTEVT and IRQ values. */ -#ifdef CONFIG_CPU_HAS_INTEVT -#define evt2irq (evt) (((evt) >> 5) - 16) -#define irq2evt (irq) (((irq) + 16) << 5) +#ifdef CONFIG_CPU_HAS_INTEVT /* Avoid IRQ0 (invalid for platform devices) */ +#define evt2irq (evt) ((evt) >> 5) +#define irq2evt (irq) ((irq) << 5)#else #define evt2irq (evt) (evt)#define irq2evt (irq) (irq)
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 611/800 gfs2: Fix duplicate should_fault_in_pages() call
In reply to Greg Kroah-HartmanFrom: Bob Peterson <[email protected]>
[ Upstream commit c8ed1b35931245087968fd95b2ec3dfc50f77769 ]
In gfs2_file_buffered_write(), we currently jump from the second call of function should_fault_in_pages() to above the first call, so should_fault_in_pages() is getting called twice in a row, causing it to accidentally fall back to single-page writes rather than trying the more efficient multi-page writes first.
Fix that by moving the retry label to the correct place, behind the first call to should_fault_in_pages().
--- fs/gfs2/file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/gfs2/file.c +1 -1
@@ -1030,8 +1030,8 @@ static ssize_t gfs2_file_buffered_write(struct kiocb *iocb, }gfs2_holder_init (ip->i_gl,LM_ST_EXCLUSIVE ,0 , gh); -retry:if (should_fault_in_pages (from, iocb, &prev_count, &window_size)) { +retry: window_size -=fault_in_iov_iter_readable (from, window_size);if (!window_size) { ret = -EFAULT ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 612/800 f2fs: fix potential deadlock due to unpaired node_write lock use
In reply to Greg Kroah-HartmanFrom: Chao Yu <[email protected]>
[ Upstream commit f082c6b205a06953f26c40bdc7621cc5a58ceb7c ]
If S_NOQUOTA is cleared from inode during data page writeback of quota file, it may miss to unlock node_write lock, result in potential deadlock, fix to use the lock in paired.
Kworker Thread
- writepage
if (IS_NOQUOTA())
f2fs_down_read(&sbi->node_write);
- vfs_cleanup_quota_inode
- inode->i_flags &= ~S_NOQUOTA;
if (IS_NOQUOTA())
f2fs_up_read(&sbi->node_write);
--- fs/f2fs/compress.c | 7 ++++--- fs/f2fs/data.c | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-)
fs/f2fs/compress.c +4 -3
@@ -1215,6 +1215,7 @@ static int f2fs_write_compressed_pages(struct compress_ctx *cc,unsigned int last_index = cc->cluster_size -1 ;loff_t psize;int i, err; +bool quota_inode =IS_NOQUOTA (inode);/* we should bypass data pages to proceed the kworker jobs */ if (unlikely (f2fs_cp_error (sbi))) {
@@ -1222,7 +1223,7 @@ static int f2fs_write_compressed_pages(struct compress_ctx *cc, goto out_free; } -if (IS_NOQUOTA (inode)) { +if (quota_inode) {/* * We need to wait for node_write to avoid block allocation during * checkpoint. This can only happen to quota writes which can cause
@@ -1344,7 +1345,7 @@ static int f2fs_write_compressed_pages(struct compress_ctx *cc,set_inode_flag (inode,FI_FIRST_BLOCK_WRITTEN );f2fs_put_dnode (&dn); -if (IS_NOQUOTA (inode)) +if (quota_inode)f2fs_up_read (&sbi->node_write);else f2fs_unlock_op (sbi);
@@ -1370,7 +1371,7 @@ static int f2fs_write_compressed_pages(struct compress_ctx *cc, out_put_dnode:f2fs_put_dnode (&dn); out_unlock_op: -if (IS_NOQUOTA (inode)) +if (quota_inode)f2fs_up_read (&sbi->node_write);else f2fs_unlock_op (sbi);
fs/f2fs/data.c +4 -3
@@ -2775,6 +2775,7 @@ int f2fs_write_single_data_page(struct page *page, int *submitted,loff_t psize = (loff_t)(page->index +1 ) <<PAGE_SHIFT ;unsigned offset =0 ;bool need_balance_fs = false; +bool quota_inode =IS_NOQUOTA (inode);int err =0 ;struct f2fs_io_info fio = { .sbi = sbi,
@@ -2832,19 +2833,19 @@ int f2fs_write_single_data_page(struct page *page, int *submitted, goto out;/* Dentry/quota blocks are controlled by checkpoint */ -if (S_ISDIR (inode->i_mode) ||IS_NOQUOTA (inode)) { +if (S_ISDIR (inode->i_mode) || quota_inode) {/* * We need to wait for node_write to avoid block allocation during * checkpoint. This can only happen to quota writes which can cause * the below discard race condition. */ -if (IS_NOQUOTA (inode)) +if (quota_inode)f2fs_down_read (&sbi->node_write); fio.need_lock =LOCK_DONE ; err =f2fs_do_write_data_page (&fio); -if (IS_NOQUOTA (inode)) +if (quota_inode)f2fs_up_read (&sbi->node_write); goto done;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 613/800 f2fs: fix to avoid NULL pointer dereference f2fs_write_end_io()
In reply to Greg Kroah-HartmanFrom: Chao Yu <[email protected]>
[ Upstream commit d8189834d4348ae608083e1f1f53792cfcc2a9bc ]
butt3rflyh4ck reports a bug as below:
When a thread always calls F2FS_IOC_RESIZE_FS to resize fs, if resize fs is failed, f2fs kernel thread would invoke callback function to update f2fs io info, it would call f2fs_write_end_io and may trigger null-ptr-deref in NODE_MAPPING.
general protection fault, probably for non-canonical address KASAN: null-ptr-deref in range [0x0000000000000030-0x0000000000000037] RIP: 0010:NODE_MAPPING fs/f2fs/f2fs.h:1972 [inline] RIP: 0010:f2fs_write_end_io+0x727/0x1050 fs/f2fs/data.c:370 <TASK> bio_endio+0x5af/0x6c0 block/bio.c:1608 req_bio_endio block/blk-mq.c:761 [inline] blk_update_request+0x5cc/0x1690 block/blk-mq.c:906 blk_mq_end_request+0x59/0x4c0 block/blk-mq.c:1023 lo_complete_rq+0x1c6/0x280 drivers/block/loop.c:370 blk_complete_reqs+0xad/0xe0 block/blk-mq.c:1101 __do_softirq+0x1d4/0x8ef kernel/softirq.c:571 run_ksoftirqd kernel/softirq.c:939 [inline] run_ksoftirqd+0x31/0x60 kernel/softirq.c:931 smpboot_thread_fn+0x659/0x9e0 kernel/smpboot.c:164 kthread+0x33e/0x440 kernel/kthread.c:379 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:308
The root cause is below race case can cause leaving dirty metadata in f2fs after filesystem is remount as ro:
Thread A Thread B
- f2fs_ioc_resize_fs
- f2fs_readonly --- return false
- f2fs_resize_fs
- f2fs_remount
- write_checkpoint
- set f2fs as ro
- free_segment_range
- update meta_inode's data
Then, if f2fs_put_super() fails to write_checkpoint due to readonly status, and meta_inode's dirty data will be writebacked after node_inode is put, finally, f2fs_write_end_io will access NULL pointer on sbi->node_inode.
Thread A IRQ context
- f2fs_put_super
- write_checkpoint fails
- iput(node_inode)
- node_inode = NULL
- iput(meta_inode)
- write_inode_now
- f2fs_write_meta_page
- f2fs_write_end_io
- NODE_MAPPING(sbi)
: access NULL pointer on node_inode
--- fs/f2fs/f2fs.h | 2 +- fs/f2fs/file.c | 2 +- fs/f2fs/gc.c | 21 ++++++++++++++++++--- 3 files changed, 20 insertions(+), 5 deletions(-)
fs/f2fs/f2fs.h +1 -1
@@ -3815,7 +3815,7 @@ void f2fs_stop_gc_thread(struct f2fs_sb_info *sbi);block_t f2fs_start_bidx_of_node (unsigned int node_ofs,struct inode *inode);int f2fs_gc (struct f2fs_sb_info *sbi,struct f2fs_gc_control *gc_control);void f2fs_build_gc_manager (struct f2fs_sb_info *sbi); -int f2fs_resize_fs (struct f2fs_sb_info *sbi,__u64 block_count); +int f2fs_resize_fs (struct file *filp,__u64 block_count);int __init f2fs_create_garbage_collection_cache (void );void f2fs_destroy_garbage_collection_cache (void );/* victim selection function for cleaning and SSR */
fs/f2fs/file.c +1 -1
@@ -3284,7 +3284,7 @@ static int f2fs_ioc_resize_fs(struct file *filp, unsigned long arg) sizeof(block_count)))return -EFAULT ; -return f2fs_resize_fs (sbi, block_count); +return f2fs_resize_fs (filp, block_count); }static int f2fs_ioc_enable_verity (struct file *filp,unsigned long arg)
fs/f2fs/gc.c +18 -3
@@ -2099,8 +2099,9 @@ static void update_fs_metadata(struct f2fs_sb_info *sbi, int secs) } } -int f2fs_resize_fs (struct f2fs_sb_info *sbi,__u64 block_count) +int f2fs_resize_fs (struct file *filp,__u64 block_count) { +struct f2fs_sb_info *sbi =F2FS_I_SB (file_inode (filp));__u64 old_block_count, shrunk_blocks;struct cp_control cpc = {CP_RESIZE ,0 ,0 ,0 };unsigned int secs;
@@ -2138,12 +2139,18 @@ int f2fs_resize_fs(struct f2fs_sb_info *sbi, __u64 block_count)return -EINVAL ; } + err =mnt_want_write_file (filp); +if (err) +return err; + shrunk_blocks = old_block_count - block_count; secs =div_u64 (shrunk_blocks,BLKS_PER_SEC (sbi));/* stop other GC */ -if (!f2fs_down_write_trylock (&sbi->gc_lock)) -return -EAGAIN ; +if (!f2fs_down_write_trylock (&sbi->gc_lock)) { + err = -EAGAIN ; + goto out_drop_write; + }/* stop CP to protect MAIN_SEC in free_segment_range */ f2fs_lock_op (sbi);
@@ -2163,10 +2170,18 @@ int f2fs_resize_fs(struct f2fs_sb_info *sbi, __u64 block_count) out_unlock:f2fs_unlock_op (sbi);f2fs_up_write (&sbi->gc_lock); +out_drop_write: +mnt_drop_write_file (filp);if (err)return err;freeze_super (sbi->sb); + +if (f2fs_readonly (sbi->sb)) { +thaw_super (sbi->sb); +return -EROFS ; + } +f2fs_down_write (&sbi->gc_lock);f2fs_down_write (&sbi->cp_global_sem);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 614/800 f2fs: support errors=remount-ro|continue|panic mountoption
In reply to Greg Kroah-HartmanFrom: Chao Yu <[email protected]>
[ Upstream commit b62e71be2110d8b52bf5faf3c3ed7ca1a0c113a5 ]
This patch supports errors=remount-ro|continue|panic mount option for f2fs.
f2fs behaves as below in three different modes:
mode continue remount-ro panic
access ops normal noraml N/A
syscall errors -EIO -EROFS N/A
mount option rw ro N/A
pending dir write keep keep N/A
pending non-dir write drop keep N/A
pending node write drop keep N/A
pending meta write keep keep N/A
By default it uses "continue" mode.
Stable-dep-of: 901c12d14457 ("f2fs: flush error flags in workqueue")
--- Documentation/filesystems/f2fs.rst | 16 ++++ fs/f2fs/checkpoint.c | 7 +- fs/f2fs/data.c | 4 + fs/f2fs/f2fs.h | 20 ++++- fs/f2fs/file.c | 5 -- fs/f2fs/gc.c | 2 +- fs/f2fs/node.c | 3 + fs/f2fs/super.c | 134 ++++++++++++++++++++++++++--- 8 files changed, 167 insertions(+), 24 deletions(-)
Documentation/filesystems/f2fs.rst +16 -0
@@ -351,6 +351,22 @@ age_extent_cache Enable an age extent cache based on rb-tree. It records data block update frequency of the extent per inode, in order to provide better temperature hints for data block allocation. +errors=%s Specify f2fs behavior on critical errors. This supports modes: + "panic", "continue" and "remount-ro", respectively, trigger + panic immediately, continue without doing anything, and remount + the partition in read-only mode. By default it uses "continue" + mode. + ====================== =============== =============== ======== + mode continue remount-ro panic + ====================== =============== =============== ======== + access ops normal noraml N/A + syscall errors -EIO -EROFS N/A + mount option rw ro N/A + pending dir write keep keep N/A + pending non-dir write drop keep N/A + pending node write drop keep N/A + pending meta write keep keep N/A + ====================== =============== =============== ======== ======================== ============================================================ Debugfs Entries
fs/f2fs/checkpoint.c +2 -5
@@ -30,12 +30,9 @@ void f2fs_stop_checkpoint(struct f2fs_sb_info *sbi, bool end_io, unsigned char reason) {f2fs_build_fault_attr (sbi,0 ,0 ); -set_ckpt_flags (sbi,CP_ERROR_FLAG ); -if (!end_io) { +if (!end_io)f2fs_flush_merged_writes (sbi); - -f2fs_handle_stop (sbi, reason); - } +f2fs_handle_critical_error (sbi, reason, end_io); }/*
fs/f2fs/data.c +4 -0
@@ -2808,6 +2808,10 @@ int f2fs_write_single_data_page(struct page *page, int *submitted,if (S_ISDIR (inode->i_mode) && !is_sbi_flag_set (sbi,SBI_IS_CLOSE )) goto redirty_out; + +/* keep data pages in remount-ro mode */ +if (F2FS_OPTION (sbi).errors ==MOUNT_ERRORS_READONLY ) + goto redirty_out; goto out; }
fs/f2fs/f2fs.h +17 -3
@@ -162,6 +162,7 @@ struct f2fs_mount_info {int fs_mode;/* fs mode: LFS or ADAPTIVE */ int bggc_mode;/* bggc mode: off, on or sync */ int memory_mode;/* memory mode */ +int errors;/* errors parameter */ int discard_unit;/* * discard command's offset/size should * be aligned to this unit: block,
@@ -1370,6 +1371,12 @@ enum { MEMORY_MODE_LOW, /* memory mode for low memry devices */ }; +enum errors_option { +MOUNT_ERRORS_READONLY ,/* remount fs ro on errors */ +MOUNT_ERRORS_CONTINUE ,/* continue on errors */ +MOUNT_ERRORS_PANIC ,/* panic on errors */ +}; +static inline int f2fs_test_bit (unsigned int nr,char *addr);static inline void f2fs_set_bit (unsigned int nr,char *addr);static inline void f2fs_clear_bit (unsigned int nr,char *addr);
@@ -1721,8 +1728,14 @@ struct f2fs_sb_info {struct workqueue_struct *post_read_wq;/* post read workqueue */ -unsigned char errors[MAX_F2FS_ERRORS ];/* error flags */ -spinlock_t error_lock;/* protect errors array */ +/* +* If we are in irq context, let's update error information into +* on-disk superblock in the work. +*/ +struct work_struct s_error_work; +unsigned char errors[MAX_F2FS_ERRORS ];/* error flags */ +unsigned char stop_reason[MAX_STOP_REASON ];/* stop reason */ +spinlock_t error_lock;/* protect errors/stop_reason array */ bool error_dirty;/* errors of sb is dirty */ struct kmem_cache *inline_xattr_slab;/* inline xattr entry */
@@ -3541,8 +3554,9 @@ int f2fs_enable_quota_files(struct f2fs_sb_info *sbi, bool rdonly);int f2fs_quota_sync (struct super_block *sb,int type);loff_t max_file_blocks (struct inode *inode);void f2fs_quota_off_umount (struct super_block *sb); -void f2fs_handle_stop (struct f2fs_sb_info *sbi,unsigned char reason);void f2fs_save_errors (struct f2fs_sb_info *sbi,unsigned char flag); +void f2fs_handle_critical_error (struct f2fs_sb_info *sbi,unsigned char reason, +bool irq_context);void f2fs_handle_error (struct f2fs_sb_info *sbi,unsigned char error);int f2fs_commit_super (struct f2fs_sb_info *sbi,bool recover);int f2fs_sync_fs (struct super_block *sb,int sync);
fs/f2fs/file.c +0 -5
@@ -2225,7 +2225,6 @@ static int f2fs_ioc_shutdown(struct file *filp, unsigned long arg) ret =0 ;f2fs_stop_checkpoint (sbi, false,STOP_CP_REASON_SHUTDOWN ); -set_sbi_flag (sbi,SBI_IS_SHUTDOWN );trace_f2fs_shutdown (sbi, in, ret); }return ret;
@@ -2238,7 +2237,6 @@ static int f2fs_ioc_shutdown(struct file *filp, unsigned long arg)if (ret) goto out;f2fs_stop_checkpoint (sbi, false,STOP_CP_REASON_SHUTDOWN ); -set_sbi_flag (sbi,SBI_IS_SHUTDOWN );thaw_bdev (sb->s_bdev);break ;case F2FS_GOING_DOWN_METASYNC :
@@ -2247,16 +2245,13 @@ static int f2fs_ioc_shutdown(struct file *filp, unsigned long arg)if (ret) goto out;f2fs_stop_checkpoint (sbi, false,STOP_CP_REASON_SHUTDOWN ); -set_sbi_flag (sbi,SBI_IS_SHUTDOWN );break ;case F2FS_GOING_DOWN_NOSYNC :f2fs_stop_checkpoint (sbi, false,STOP_CP_REASON_SHUTDOWN ); -set_sbi_flag (sbi,SBI_IS_SHUTDOWN );break ;case F2FS_GOING_DOWN_METAFLUSH :f2fs_sync_meta_pages (sbi,META ,LONG_MAX ,FS_META_IO );f2fs_stop_checkpoint (sbi, false,STOP_CP_REASON_SHUTDOWN ); -set_sbi_flag (sbi,SBI_IS_SHUTDOWN );break ;case F2FS_GOING_DOWN_NEED_FSCK :set_sbi_flag (sbi,SBI_NEED_FSCK );
fs/f2fs/gc.c +1 -1
@@ -59,7 +59,7 @@ static int gc_thread_func(void *data)if (gc_th->gc_wake) gc_th->gc_wake = false; -if (try_to_freeze ()) { +if (try_to_freeze () ||f2fs_readonly (sbi->sb)) {stat_other_skip_bggc_count (sbi);continue ; }
fs/f2fs/node.c +3 -0
@@ -1596,6 +1596,9 @@ static int __write_node_page(struct page *page, bool atomic, bool *submitted,trace_f2fs_writepage (page,NODE );if (unlikely (f2fs_cp_error (sbi))) { +/* keep node pages in remount-ro mode */ +if (F2FS_OPTION (sbi).errors ==MOUNT_ERRORS_READONLY ) + goto redirty_out;ClearPageUptodate (page);dec_page_count (sbi,F2FS_DIRTY_NODES );unlock_page (page);
fs/f2fs/super.c +124 -10
230 lines not on this page · raw message
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 615/800 f2fs: fix the wrong condition to determine atomic context
In reply to Greg Kroah-HartmanFrom: Jaegeuk Kim <[email protected]>
[ Upstream commit 633c8b9409f564ce4b7f7944c595ffac27ed1ff4 ]
Should use !in_task for irq context.
Stable-dep-of: 901c12d14457 ("f2fs: flush error flags in workqueue")
--- fs/f2fs/compress.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/f2fs/compress.c +1 -1
@@ -743,7 +743,7 @@ void f2fs_decompress_cluster(struct decompress_io_ctx *dic, bool in_task) ret = -EFSCORRUPTED ;/* Avoid f2fs_commit_super in irq context */ -if (in_task) +if (!in_task)f2fs_save_errors (sbi,ERROR_FAIL_DECOMPRESSION );else f2fs_handle_error (sbi,ERROR_FAIL_DECOMPRESSION );
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 616/800 f2fs: flush error flags in workqueue
In reply to Greg Kroah-HartmanFrom: Chao Yu <[email protected]>
[ Upstream commit 901c12d144570ed2558f4a6806201453c5b01bea ]
In IRQ context, it wakes up workqueue to record errors into on-disk superblock fields rather than in-memory fields.
--- fs/f2fs/compress.c | 2 +- fs/f2fs/f2fs.h | 1 + fs/f2fs/super.c | 26 +++++++++++++++++++++++--- 3 files changed, 25 insertions(+), 4 deletions(-)
fs/f2fs/compress.c +1 -1
@@ -744,7 +744,7 @@ void f2fs_decompress_cluster(struct decompress_io_ctx *dic, bool in_task)/* Avoid f2fs_commit_super in irq context */ if (!in_task) -f2fs_save_errors (sbi,ERROR_FAIL_DECOMPRESSION ); +f2fs_handle_error_async (sbi,ERROR_FAIL_DECOMPRESSION );else f2fs_handle_error (sbi,ERROR_FAIL_DECOMPRESSION ); goto out_release;
fs/f2fs/f2fs.h +1 -0
@@ -3558,6 +3558,7 @@ void f2fs_save_errors(struct f2fs_sb_info *sbi, unsigned char flag);void f2fs_handle_critical_error (struct f2fs_sb_info *sbi,unsigned char reason,bool irq_context);void f2fs_handle_error (struct f2fs_sb_info *sbi,unsigned char error); +void f2fs_handle_error_async (struct f2fs_sb_info *sbi,unsigned char error);int f2fs_commit_super (struct f2fs_sb_info *sbi,bool recover);int f2fs_sync_fs (struct super_block *sb,int sync);int f2fs_sanity_check_ckpt (struct f2fs_sb_info *sbi);
fs/f2fs/super.c +23 -3
@@ -3980,6 +3980,11 @@ static void f2fs_record_stop_reason(struct f2fs_sb_info *sbi)f2fs_down_write (&sbi->sb_lock);spin_lock_irqsave (&sbi->error_lock, flags); +if (sbi->error_dirty) { +memcpy (F2FS_RAW_SUPER (sbi)->s_errors, sbi->errors, +MAX_F2FS_ERRORS ); + sbi->error_dirty = false; + }memcpy (raw_super->s_stop_reason, sbi->stop_reason,MAX_STOP_REASON );spin_unlock_irqrestore (&sbi->error_lock, flags);
@@ -4019,12 +4024,10 @@ static bool f2fs_update_errors(struct f2fs_sb_info *sbi)return need_update; } -void f2fs_handle_error (struct f2fs_sb_info *sbi,unsigned char error) +static void f2fs_record_errors (struct f2fs_sb_info *sbi,unsigned char error) {int err; -f2fs_save_errors (sbi, error); -f2fs_down_write (&sbi->sb_lock);if (!f2fs_update_errors (sbi))
@@ -4038,6 +4041,23 @@ void f2fs_handle_error(struct f2fs_sb_info *sbi, unsigned char error)f2fs_up_write (&sbi->sb_lock); } +void f2fs_handle_error (struct f2fs_sb_info *sbi,unsigned char error) +{ +f2fs_save_errors (sbi, error); +f2fs_record_errors (sbi, error); +} + +void f2fs_handle_error_async (struct f2fs_sb_info *sbi,unsigned char error) +{ +f2fs_save_errors (sbi, error); + +if (!sbi->error_dirty) +return ; +if (!test_bit (error, (unsigned long *)sbi->errors)) +return ; +schedule_work (&sbi->s_error_work); +} +static bool system_going_down (void ) {return system_state ==SYSTEM_HALT || system_state ==SYSTEM_POWER_OFF
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 617/800 KVM: s390: fix KVM_S390_GET_CMMA_BITS for GFNs in memslot holes
In reply to Greg Kroah-HartmanFrom: Nico Boehr <[email protected]>
[ Upstream commit 285cff4c0454340a4dc53f46e67f2cb1c293bd74 ]
The KVM_S390_GET_CMMA_BITS ioctl may return incorrect values when userspace specifies a start_gfn outside of memslots.
This can occur when a VM has multiple memslots with a hole in between:
+-----+----------+--------+--------+
| ... | Slot N-1 | <hole> | Slot N |
+-----+----------+--------+--------+
^ ^ ^ ^
| | | |
GFN A A+B | |
A+B+C |
A+B+C+DWhen userspace specifies a GFN in [A+B, A+B+C), it would expect to get the CMMA values of the first dirty page in Slot N. However, userspace may get a start_gfn of A+B+C+D with a count of 0, hence completely skipping over any dirty pages in slot N.
The error is in kvm_s390_next_dirty_cmma(), which assumes gfn_to_memslot_approx() will return the memslot _below_ the specified GFN when the specified GFN lies outside a memslot. In reality it may return either the memslot below or above the specified GFN.
When a memslot above the specified GFN is returned this happens:
- ofs is calculated, but since the memslot's base_gfn is larger than the specified cur_gfn, ofs will underflow to a huge number.
- ofs is passed to find_next_bit(). Since ofs will exceed the memslot's number of pages, the number of pages in the memslot is returned, completely skipping over all bits in the memslot userspace would be interested in.
Fix this by resetting ofs to zero when a memslot _above_ cur_gfn is returned (cur_gfn < ms->base_gfn).
Message-Id: <[email protected]>
--- arch/s390/kvm/kvm-s390.c | 4 ++++ 1 file changed, 4 insertions(+)
arch/s390/kvm/kvm-s390.c +4 -0
@@ -2156,6 +2156,10 @@ static unsigned long kvm_s390_next_dirty_cmma(struct kvm_memslots *slots, ms = container_of(mnode, struct kvm_memory_slot, gfn_node[slots->node_idx]); ofs =0 ; } + +if (cur_gfn < ms->base_gfn) + ofs =0 ; + ofs =find_next_bit (kvm_second_dirty_bitmap (ms), ms->npages, ofs);while (ofs >= ms->npages && (mnode =rb_next (mnode))) { ms = container_of(mnode, struct kvm_memory_slot, gfn_node[slots->node_idx]);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 618/800 usb: dwc3: qcom: Release the correct resources in dwc3_qcom_remove()
In reply to Greg Kroah-HartmanFrom: Christophe JAILLET <[email protected]>
[ Upstream commit 8fd95da2cfb5046c4bb5a3cdc9eb7963ba8b10dd ]
In the probe, some resources are allocated with dwc3_qcom_of_register_core() or dwc3_qcom_acpi_register_core(). The corresponding resources are already coorectly freed in the error handling path of the probe, but not in the remove function.
Fix it.
Message-ID: <c0215a84cdf18fb3514c81842783ec53cf149deb.1685891059.git.christophe.jaillet@wanadoo.fr>
--- drivers/usb/dwc3/dwc3-qcom.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/usb/dwc3/dwc3-qcom.c +5 -1
@@ -950,11 +950,15 @@ static int dwc3_qcom_probe(struct platform_device *pdev)static int dwc3_qcom_remove (struct platform_device *pdev) {struct dwc3_qcom *qcom =platform_get_drvdata (pdev); +struct device_node *np = pdev->dev.of_node;struct device *dev = &pdev->dev;int i;device_remove_software_node (&qcom->dwc3->dev); -of_platform_depopulate (dev); +if (np) +of_platform_depopulate (&pdev->dev); +else +platform_device_put (pdev);for (i = qcom->num_clocks -1 ; i >=0 ; i--) {clk_disable_unprepare (qcom->clks[i]);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 619/800 usb: dwc3: qcom: Fix an error handling path in dwc3_qcom_probe()
In reply to Greg Kroah-HartmanFrom: Christophe JAILLET <[email protected]>
[ Upstream commit 4a944da707123686d372ec01ea60056902fadf35 ]
If dwc3_qcom_create_urs_usb_platdev() fails, some resources still need to be released, as already done in the other error handling path of the probe.
Message-ID: <b69fa8dd68d816e7d24c88d3eda776ceb28c5dc5.1685890571.git.christophe.jaillet@wanadoo.fr>
--- drivers/usb/dwc3/dwc3-qcom.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/usb/dwc3/dwc3-qcom.c +3 -2
@@ -865,9 +865,10 @@ static int dwc3_qcom_probe(struct platform_device *pdev)if (IS_ERR_OR_NULL (qcom->urs_usb)) {dev_err (dev,"failed to create URS USB platdev\n" );if (!qcom->urs_usb) -return -ENODEV ; + ret = -ENODEV ;else -return PTR_ERR (qcom->urs_usb); + ret =PTR_ERR (qcom->urs_usb); + goto clk_disable; } } }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 620/800 usb: common: usb-conn-gpio: Set last role to unknown before initial detection
In reply to Greg Kroah-HartmanFrom: Prashanth K <[email protected]>
[ Upstream commit edd60d24bd858cef165274e4cd6cab43bdc58d15 ]
Currently if we bootup a device without cable connected, then usb-conn-gpio won't call set_role() since last_role is same as current role. This happens because during probe last_role gets initialised to zero.
To avoid this, added a new constant in enum usb_role, last_role is set to USB_ROLE_UNKNOWN before performing initial detection.
While at it, also handle default case for the usb_role switch in cdns3, intel-xhci-usb-role-switch & musb/jz4740 to avoid build warnings.
Message-ID: <[email protected]>
--- drivers/usb/cdns3/core.c | 2 ++ drivers/usb/common/usb-conn-gpio.c | 3 +++ drivers/usb/musb/jz4740.c | 2 ++ drivers/usb/roles/intel-xhci-usb-role-switch.c | 2 ++ include/linux/usb/role.h | 1 + 5 files changed, 10 insertions(+)
drivers/usb/cdns3/core.c +2 -0
@@ -252,6 +252,8 @@ static enum usb_role cdns_hw_role_state_machine(struct cdns *cdns)if (!vbus) role =USB_ROLE_NONE ;break ; +default : +break ; }dev_dbg (cdns->dev,"role %d -> %d\n" , cdns->role, role);
drivers/usb/common/usb-conn-gpio.c +3 -0
@@ -257,6 +257,9 @@ static int usb_conn_probe(struct platform_device *pdev)platform_set_drvdata (pdev, info);device_set_wakeup_capable (&pdev->dev, true); +/* Set last role to unknown before performing the initial detection */ + info->last_role =USB_ROLE_UNKNOWN ; +/* Perform initial detection */ usb_conn_queue_dwork (info,0 );
drivers/usb/musb/jz4740.c +2 -0
@@ -95,6 +95,8 @@ static int jz4740_musb_role_switch_set(struct usb_role_switch *sw,case USB_ROLE_HOST :atomic_notifier_call_chain (&phy->notifier,USB_EVENT_ID , phy);break ; +default : +break ; }return 0 ;
drivers/usb/roles/intel-xhci-usb-role-switch.c +2 -0
@@ -97,6 +97,8 @@ static int intel_xhci_usb_set_role(struct usb_role_switch *sw, val |=SW_VBUS_VALID ; drd_config =DRD_CONFIG_STATIC_DEVICE ;break ; +default : +break ; } val |=SW_IDPIN_EN ;if (data->enable_sw_switch) {
include/linux/usb/role.h +1 -0
@@ -11,6 +11,7 @@ enum usb_role {USB_ROLE_NONE ,USB_ROLE_HOST ,USB_ROLE_DEVICE , + USB_ROLE_UNKNOWN, }; typedef int (*usb_role_switch_set_t)(struct usb_role_switch *sw,
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 621/800 usb: dwc3-meson-g12a: Fix an error handling path in dwc3_meson_g12a_probe()
In reply to Greg Kroah-HartmanFrom: Christophe JAILLET <[email protected]>
[ Upstream commit 01052b91c9808e3c3b068ae2721cb728ec9aa4c0 ]
If dwc3_meson_g12a_otg_init() fails, resources allocated by the previous of_platform_populate() call should be released, as already done in the error handling path.
Message-ID: <9d28466de1808ccc756b4cc25fc72c482d133d13.1686403934.git.christophe.jaillet@wanadoo.fr>
--- drivers/usb/dwc3/dwc3-meson-g12a.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/usb/dwc3/dwc3-meson-g12a.c +4 -1
@@ -805,7 +805,7 @@ static int dwc3_meson_g12a_probe(struct platform_device *pdev) ret =dwc3_meson_g12a_otg_init (pdev, priv);if (ret) - goto err_phys_power; + goto err_plat_depopulate;pm_runtime_set_active (dev);pm_runtime_enable (dev);
@@ -813,6 +813,9 @@ static int dwc3_meson_g12a_probe(struct platform_device *pdev)return 0 ; +err_plat_depopulate: +of_platform_depopulate (dev); + err_phys_power:for (i =0 ; i <PHY_COUNT ; ++i)phy_power_off (priv->phys[i]);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 622/800 rtla/hwnoise: Reduce runtime to 75%
In reply to Greg Kroah-HartmanFrom: Daniel Bristot de Oliveira <[email protected]>
[ Upstream commit 7bc4d3089a50050d4df0af63423a5d907c3bdb1a ]
osnoise runs 100% of time by default. It makes sense because osnoise is preemptive. hwnoise checks preemption once a second, so it reduces system progress.
Reduce runtime to 75% to avoid problems by default. I added a Fixes as it might avoid problems for first time users as it lands on distros.
--- tools/tracing/rtla/src/osnoise_top.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
tools/tracing/rtla/src/osnoise_top.c +7 -1
@@ -340,8 +340,14 @@ struct osnoise_top_params *osnoise_top_parse_args(int argc, char **argv)if (!params)exit (1 ); -if (strcmp (argv[0 ],"hwnoise" ) ==0 ) +if (strcmp (argv[0 ],"hwnoise" ) ==0 ) { params->mode =MODE_HWNOISE ; +/* +* Reduce CPU usage for 75% to avoid killing the system. +*/ + params->runtime =750000 ; + params->period =1000000 ; + }while (1 ) {static struct option long_options[] = {
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 623/800 mfd: wcd934x: Fix an error handling path in wcd934x_slim_probe()
In reply to Greg Kroah-HartmanFrom: Christophe JAILLET <[email protected]>
[ Upstream commit f190b4891a3f9fac123a7afd378d4143a2723313 ]
If devm_gpiod_get_optional() fails, some resources need to be released, as already done in the .remove() function.
While at it, remove the unneeded error code from a dev_err_probe() call. It is already added in a human readable way by dev_err_probe() itself.
--- drivers/mfd/wcd934x.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/mfd/wcd934x.c +7 -2
@@ -258,8 +258,9 @@ static int wcd934x_slim_probe(struct slim_device *sdev)usleep_range (600 ,650 ); reset_gpio =devm_gpiod_get_optional (dev,"reset" ,GPIOD_OUT_LOW );if (IS_ERR (reset_gpio)) { -return dev_err_probe (dev,PTR_ERR (reset_gpio), -"Failed to get reset gpio: err = %ld\n" ,PTR_ERR (reset_gpio)); + ret =dev_err_probe (dev,PTR_ERR (reset_gpio), +"Failed to get reset gpio\n" ); + goto err_disable_regulators; }msleep (20 );gpiod_set_value (reset_gpio,1 );
@@ -269,6 +270,10 @@ static int wcd934x_slim_probe(struct slim_device *sdev)dev_set_drvdata (dev, ddata);return 0 ; + +err_disable_regulators: +regulator_bulk_disable (WCD934X_MAX_SUPPLY , ddata->supplies); +return ret; }static void wcd934x_slim_remove (struct slim_device *sdev)
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 624/800 mfd: intel-lpss: Add missing check for platform_get_resource
In reply to Greg Kroah-HartmanFrom: Jiasheng Jiang <[email protected]>
[ Upstream commit d918e0d5824495a75d00b879118b098fcab36fdb ]
Add the missing check for platform_get_resource and return error if it fails.
--- drivers/mfd/intel-lpss-acpi.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/mfd/intel-lpss-acpi.c +3 -0
@@ -183,6 +183,9 @@ static int intel_lpss_acpi_probe(struct platform_device *pdev)return -ENOMEM ; info->mem =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); +if (!info->mem) +return -ENODEV ; + info->irq =platform_get_irq (pdev,0 ); ret =intel_lpss_probe (&pdev->dev, info);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 625/800 Revert "usb: common: usb-conn-gpio: Set last role to unknown before initial detection"
In reply to Greg Kroah-HartmanFrom: Greg Kroah-Hartman <[email protected]>
[ Upstream commit df49f2a0ac4a34c0cb4b5c233fcfa0add644c43c ]
This reverts commit edd60d24bd858cef165274e4cd6cab43bdc58d15.
Heikki reports that this should not be a global flag just to work around one broken driver and should be fixed differently, so revert it.
--- drivers/usb/cdns3/core.c | 2 -- drivers/usb/common/usb-conn-gpio.c | 3 --- drivers/usb/musb/jz4740.c | 2 -- drivers/usb/roles/intel-xhci-usb-role-switch.c | 2 -- include/linux/usb/role.h | 1 - 5 files changed, 10 deletions(-)
drivers/usb/cdns3/core.c +0 -2
@@ -252,8 +252,6 @@ static enum usb_role cdns_hw_role_state_machine(struct cdns *cdns)if (!vbus) role =USB_ROLE_NONE ;break ; -default : -break ; }dev_dbg (cdns->dev,"role %d -> %d\n" , cdns->role, role);
drivers/usb/common/usb-conn-gpio.c +0 -3
@@ -257,9 +257,6 @@ static int usb_conn_probe(struct platform_device *pdev)platform_set_drvdata (pdev, info);device_set_wakeup_capable (&pdev->dev, true); -/* Set last role to unknown before performing the initial detection */ - info->last_role =USB_ROLE_UNKNOWN ; -/* Perform initial detection */ usb_conn_queue_dwork (info,0 );
drivers/usb/musb/jz4740.c +0 -2
@@ -95,8 +95,6 @@ static int jz4740_musb_role_switch_set(struct usb_role_switch *sw,case USB_ROLE_HOST :atomic_notifier_call_chain (&phy->notifier,USB_EVENT_ID , phy);break ; -default : -break ; }return 0 ;
drivers/usb/roles/intel-xhci-usb-role-switch.c +0 -2
@@ -97,8 +97,6 @@ static int intel_xhci_usb_set_role(struct usb_role_switch *sw, val |=SW_VBUS_VALID ; drd_config =DRD_CONFIG_STATIC_DEVICE ;break ; -default : -break ; } val |=SW_IDPIN_EN ;if (data->enable_sw_switch) {
include/linux/usb/role.h +0 -1
@@ -11,7 +11,6 @@ enum usb_role {USB_ROLE_NONE ,USB_ROLE_HOST , USB_ROLE_DEVICE, - USB_ROLE_UNKNOWN, }; typedef int (*usb_role_switch_set_t)(struct usb_role_switch *sw,
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 626/800 serial: 8250_omap: Use force_suspend and resume for system suspend
In reply to Greg Kroah-HartmanFrom: Tony Lindgren <[email protected]>
[ Upstream commit 20a41a62618df85f3a2981008edec5cadd785e0a ]
We should not rely on autosuspend timeout for system suspend. Instead, let's use force_suspend and force_resume functions. Otherwise the serial port controller device may not be idled on suspend.
As we are doing a register write on suspend to configure the serial port, we still need to runtime PM resume the port on suspend.
While at it, let's switch to pm_runtime_resume_and_get() and check for errors returned. And let's add the missing line break before return to the suspend function while at it.
Message-ID: <[email protected]>
--- drivers/tty/serial/8250/8250_omap.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-)
drivers/tty/serial/8250/8250_omap.c +15 -5
@@ -1584,25 +1584,35 @@ static int omap8250_suspend(struct device *dev) {struct omap8250_priv *priv =dev_get_drvdata (dev);struct uart_8250_port *up =serial8250_get_port (priv->line); +int err;serial8250_suspend_port (priv->line); -pm_runtime_get_sync (dev); + err =pm_runtime_resume_and_get (dev); +if (err) +return err;if (!device_may_wakeup (dev)) priv->wer =0 ;serial_out (up,UART_OMAP_WER , priv->wer); -pm_runtime_mark_last_busy (dev); -pm_runtime_put_autosuspend (dev); - + err =pm_runtime_force_suspend (dev);flush_work (&priv->qos_work); -return 0 ; + +return err; }static int omap8250_resume (struct device *dev) {struct omap8250_priv *priv =dev_get_drvdata (dev); +int err; + err =pm_runtime_force_resume (dev); +if (err) +return err;serial8250_resume_port (priv->line); +/* Paired with pm_runtime_resume_and_get() in omap8250_suspend() */ +pm_runtime_mark_last_busy (dev); +pm_runtime_put_autosuspend (dev); +return 0 ; }#else
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 627/800 drivers: fwnode: fix fwnode_irq_get[_byname]()
In reply to Greg Kroah-HartmanFrom: Matti Vaittinen <[email protected]>
[ Upstream commit 39d422555e43379516d4d13f5b7162a3dee6e646 ]
The fwnode_irq_get() and the fwnode_irq_get_byname() return 0 upon device-tree IRQ mapping failure. This is contradicting the fwnode_irq_get_byname() function documentation and can potentially be a source of errors like:
int probe(...) {
...
irq = fwnode_irq_get_byname();
if (irq <= 0)
return irq;
...
}Here we do correctly check the return value from fwnode_irq_get_byname() but the driver probe will now return success. (There was already one such user in-tree).
Change the fwnode_irq_get_byname() to work as documented and make also the fwnode_irq_get() follow same common convention returning a negative errno upon failure.
Message-ID: <3e64fe592dc99e27ef9a0b247fc49fa26b6b8a58.1685340157.git.mazziesaccount@gmail.com>
--- drivers/base/property.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/base/property.c +9 -3
@@ -987,12 +987,18 @@ EXPORT_SYMBOL(fwnode_iomap);* @fwnode: Pointer to the firmware node * @index: Zero-based index of the IRQ * -* Return: Linux IRQ number on success. Other values are determined -* according to acpi_irq_get() or of_irq_get() operation. +* Return: Linux IRQ number on success. Negative errno on failure. */ int fwnode_irq_get (const struct fwnode_handle *fwnode,unsigned int index) { -return fwnode_call_int_op (fwnode, irq_get, index); +int ret; + + ret =fwnode_call_int_op (fwnode, irq_get, index); +/* We treat mapping errors as invalid case */ +if (ret ==0 ) +return -EINVAL ; + +return ret; }EXPORT_SYMBOL (fwnode_irq_get);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 628/800 cdx: fix driver managed dma support
In reply to Greg Kroah-HartmanFrom: Nipun Gupta <[email protected]>
[ Upstream commit b8c5ff76059ded3758de3db83e04189a072ac01f ]
The devices on cdx could be bound to drivers with the device DMA managed by kernel drivers or user-space applications. As multiple devices can be placed in the same IOMMU group, the DMA on these devices must either be entirely under kernel control or userspace control. Fix the CDX bus driver to acknowlege the driver_managed_dma flag and call the appropriate iommu APIs.
Message-ID: <[email protected]>
--- drivers/cdx/cdx.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
drivers/cdx/cdx.c +18 -0
@@ -62,6 +62,8 @@#include <linux/mm.h> #include <linux/xarray.h> #include <linux/cdx/cdx_bus.h> +#include <linux/iommu.h> +#include <linux/dma-map-ops.h> #include "cdx.h" /* Default DMA mask for devices on a CDX bus */
@@ -257,6 +259,7 @@ static void cdx_shutdown(struct device *dev)static int cdx_dma_configure (struct device *dev) { +struct cdx_driver *cdx_drv =to_cdx_driver (dev->driver);struct cdx_device *cdx_dev =to_cdx_device (dev);u32 input_id = cdx_dev->req_id;int ret;
@@ -267,9 +270,23 @@ static int cdx_dma_configure(struct device *dev)return ret; } +if (!ret && !cdx_drv->driver_managed_dma) { + ret =iommu_device_use_default_domain (dev); +if (ret) +arch_teardown_dma_ops (dev); + } +return 0 ; } +static void cdx_dma_cleanup (struct device *dev) +{ +struct cdx_driver *cdx_drv =to_cdx_driver (dev->driver); + +if (!cdx_drv->driver_managed_dma) +iommu_device_unuse_default_domain (dev); +} +/* show configuration fields */ #define cdx_config_attr (field, format_string) \ static ssize_t \
@@ -405,6 +422,7 @@ struct bus_type cdx_bus_type = { .remove = cdx_remove, .shutdown = cdx_shutdown, .dma_configure = cdx_dma_configure, + .dma_cleanup = cdx_dma_cleanup, .bus_groups = cdx_bus_groups, .dev_groups = cdx_dev_groups, };
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 629/800 nvmem: sunplus-ocotp: release otp->clk before return
In reply to Greg Kroah-HartmanFrom: Yi Yingao <[email protected]>
[ Upstream commit 095bb8ba45f28ed15296eb5b7662e03e57d5e34e ]
Smatch reports:drivers/nvmem/sunplus-ocotp.c:205 sp_ocotp_probe()
warn: 'otp->clk' from clk_prepare() not released on lines: 196.
In the function sp_ocotp_probe(struct platform_device *pdev), otp->clk may not be released before return.
To fix this issue, using function clk_unprepare() to release otp->clk.
Message-ID: <[email protected]>
--- drivers/nvmem/sunplus-ocotp.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/nvmem/sunplus-ocotp.c +7 -2
@@ -192,9 +192,11 @@ static int sp_ocotp_probe(struct platform_device *pdev) sp_ocotp_nvmem_config.dev = dev; nvmem =devm_nvmem_register (dev, &sp_ocotp_nvmem_config); -if (IS_ERR (nvmem)) -return dev_err_probe (&pdev->dev,PTR_ERR (nvmem), +if (IS_ERR (nvmem)) { + ret =dev_err_probe (&pdev->dev,PTR_ERR (nvmem),"register nvmem device fail\n" ); + goto err; + }platform_set_drvdata (pdev, nvmem);
@@ -203,6 +205,9 @@ static int sp_ocotp_probe(struct platform_device *pdev) (int)OTP_WORD_SIZE, (int)QAC628_OTP_SIZE);return 0 ; +err: +clk_unprepare (otp->clk); +return ret; }static const struct of_device_id sp_ocotp_dt_ids[] = {
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 630/800 nvmem: imx-ocotp: Reverse MAC addresses on all i.MX derivates
In reply to Greg Kroah-HartmanFrom: Alexander Stein <[email protected]>
[ Upstream commit 8a00fc606312c68b98add8fe8e6f7a013ce29e78 ]
Not just i.MX8M, but all i.MX6/7 (and subtypes) need to reverse the MAC address read from fuses. Exceptions are i.MX6SLL and i.MX7ULP which do not support ethernet at all.
Message-ID: <[email protected]>
--- drivers/nvmem/imx-ocotp.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)
drivers/nvmem/imx-ocotp.c +1 -7
@@ -97,7 +97,6 @@ struct ocotp_params {unsigned int bank_address_words;void (*set_timing)(struct ocotp_priv *priv);struct ocotp_ctrl_reg ctrl; -bool reverse_mac_address; };static int imx_ocotp_wait_for_busy (struct ocotp_priv *priv,u32 flags)
@@ -545,7 +544,6 @@ static const struct ocotp_params imx8mq_params = { .bank_address_words = 0, .set_timing = imx_ocotp_set_imx6_timing, .ctrl = IMX_OCOTP_BM_CTRL_DEFAULT, - .reverse_mac_address = true, };static const struct ocotp_params imx8mm_params = {
@@ -553,7 +551,6 @@ static const struct ocotp_params imx8mm_params = { .bank_address_words = 0, .set_timing = imx_ocotp_set_imx6_timing, .ctrl = IMX_OCOTP_BM_CTRL_DEFAULT, - .reverse_mac_address = true, };static const struct ocotp_params imx8mn_params = {
@@ -561,7 +558,6 @@ static const struct ocotp_params imx8mn_params = { .bank_address_words = 0, .set_timing = imx_ocotp_set_imx6_timing, .ctrl = IMX_OCOTP_BM_CTRL_DEFAULT, - .reverse_mac_address = true, };static const struct ocotp_params imx8mp_params = {
@@ -569,7 +565,6 @@ static const struct ocotp_params imx8mp_params = { .bank_address_words = 0, .set_timing = imx_ocotp_set_imx6_timing, .ctrl = IMX_OCOTP_BM_CTRL_8MP, - .reverse_mac_address = true, };static const struct of_device_id imx_ocotp_dt_ids[] = {
@@ -624,8 +619,7 @@ static int imx_ocotp_probe(struct platform_device *pdev) imx_ocotp_nvmem_config.size =4 * priv->params->nregs; imx_ocotp_nvmem_config.dev = dev; imx_ocotp_nvmem_config.priv = priv; -if (priv->params->reverse_mac_address) - imx_ocotp_nvmem_config.layout = &imx_ocotp_layout; + imx_ocotp_nvmem_config.layout = &imx_ocotp_layout; priv->config = &imx_ocotp_nvmem_config;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 631/800 test_firmware: return ENOMEM instead of ENOSPC on failed memory allocation
In reply to Greg Kroah-HartmanFrom: Mirsad Goran Todorovac <[email protected]>
[ Upstream commit 7dae593cd226a0bca61201cf85ceb9335cf63682 ]
In a couple of situations like
name = kstrndup(buf, count, GFP_KERNEL); if (!name) return -ENOSPC;
the error is not actually "No space left on device", but "Out of memory".
It is semantically correct to return -ENOMEM in all failed kstrndup() and kzalloc() cases in this driver, as it is not a problem with disk space, but with kernel memory allocator failing allocation.
The semantically correct should be:
name = kstrndup(buf, count, GFP_KERNEL);
if (!name)
return -ENOMEM;Message-ID: <[email protected]>
--- lib/test_firmware.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
lib/test_firmware.c +6 -6
@@ -214,7 +214,7 @@ static int __kstrncpy(char **dst, const char *name, size_t count, gfp_t gfp) { *dst =kstrndup (name, count, gfp);if (!*dst) -return -ENOSPC ; +return -ENOMEM ;return count; }
@@ -671,7 +671,7 @@ static ssize_t trigger_request_store(struct device *dev, name =kstrndup (buf, count,GFP_KERNEL );if (!name) -return -ENOSPC ; +return -ENOMEM ;pr_info ("loading '%s'\n" , name);
@@ -719,7 +719,7 @@ static ssize_t trigger_request_platform_store(struct device *dev, name =kstrndup (buf, count,GFP_KERNEL );if (!name) -return -ENOSPC ; +return -ENOMEM ;pr_info ("inserting test platform fw '%s'\n" , name); efi_embedded_fw.name = name;
@@ -772,7 +772,7 @@ static ssize_t trigger_async_request_store(struct device *dev, name =kstrndup (buf, count,GFP_KERNEL );if (!name) -return -ENOSPC ; +return -ENOMEM ;pr_info ("loading '%s'\n" , name);
@@ -817,7 +817,7 @@ static ssize_t trigger_custom_fallback_store(struct device *dev, name =kstrndup (buf, count,GFP_KERNEL );if (!name) -return -ENOSPC ; +return -ENOMEM ;pr_info ("loading '%s' using custom fallback mechanism\n" , name);
@@ -868,7 +868,7 @@ static int test_fw_run_batch_request(void *data) test_buf =kzalloc (TEST_FIRMWARE_BUF_SIZE ,GFP_KERNEL );if (!test_buf) -return -ENOSPC ; +return -ENOMEM ;if (test_fw_config->partial) req->rc = request_partial_firmware_into_buf
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 632/800 nvmem: rmem: Use NVMEM_DEVID_AUTO
In reply to Greg Kroah-HartmanFrom: Phil Elwell <[email protected]>
[ Upstream commit 09dd7b993eddb3b48634fd5ddf27aa799785a9ee ]
It is reasonable to declare multiple nvmem blocks. Unless a unique 'id' is passed in for each block there may be name clashes.
Avoid this by using the magic token NVMEM_DEVID_AUTO.
Message-ID: <[email protected]>
--- drivers/nvmem/rmem.c | 1 + 1 file changed, 1 insertion(+)
drivers/nvmem/rmem.c +1 -0
@@ -71,6 +71,7 @@ static int rmem_probe(struct platform_device *pdev) config.dev = dev; config.priv = priv; config.name ="rmem" ; + config.id =NVMEM_DEVID_AUTO ; config.size = mem->size; config.reg_read = rmem_read;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 633/800 bus: fsl-mc: dont assume child devices are all fsl-mc devices
In reply to Greg Kroah-HartmanFrom: Laurentiu Tudor <[email protected]>
[ Upstream commit 303c9c63abb9390e906052863f82bb4e9824e5c0 ]
Changes in VFIO caused a pseudo-device to be created as child of fsl-mc devices causing a crash [1] when trying to bind a fsl-mc device to VFIO. Fix this by checking the device type when enumerating fsl-mc child devices.
[1]
Modules linked in: Internal error: Oops: 0000000096000004 [#1] PREEMPT SMP CPU: 6 PID: 1289 Comm: sh Not tainted 6.2.0-rc5-00047-g7c46948a6e9c #2 Hardware name: NXP Layerscape LX2160ARDB (DT) pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--) pc : mc_send_command+0x24/0x1f0 lr : dprc_get_obj_region+0xfc/0x1c0
sp : ffff80000a88b900
x29: ffff80000a88b900 x28: ffff48a9429e1400 x27: 00000000000002b2
x26: ffff48a9429e1718 x25: 0000000000000000 x24: 0000000000000000
x23: ffffd59331ba3918 x22: ffffd59331ba3000 x21: 0000000000000000
x20: ffff80000a88b9b8 x19: 0000000000000000 x18: 0000000000000001
x17: 7270642f636d2d6c x16: 73662e3030303030 x15: ffffffffffffffff
x14: ffffd59330f1d668 x13: ffff48a8727dc389 x12: ffff48a8727dc386
x11: 0000000000000002 x10: 00008ceaf02f35d4 x9 : 0000000000000012 x8 : 0000000000000000 x7 : 0000000000000006 x6 : ffff80000a88bab0 x5 : 0000000000000000 x4 : 0000000000000000 x3 : ffff80000a88b9e8 x2 : ffff80000a88b9e8 x1 : 0000000000000000 x0 : ffff48a945142b80
Call trace: mc_send_command+0x24/0x1f0 dprc_get_obj_region+0xfc/0x1c0 fsl_mc_device_add+0x340/0x590 fsl_mc_obj_device_add+0xd0/0xf8 dprc_scan_objects+0x1c4/0x340 dprc_scan_container+0x38/0x60 vfio_fsl_mc_probe+0x9c/0xf8 fsl_mc_driver_probe+0x24/0x70 really_probe+0xbc/0x2a8 __driver_probe_device+0x78/0xe0 device_driver_attach+0x30/0x68 bind_store+0xa8/0x130 drv_attr_store+0x24/0x38 sysfs_kf_write+0x44/0x60 kernfs_fop_write_iter+0x128/0x1b8 vfs_write+0x334/0x448 ksys_write+0x68/0xf0 __arm64_sys_write+0x1c/0x28 invoke_syscall+0x44/0x108 el0_svc_common.constprop.1+0x94/0xf8 do_el0_svc+0x38/0xb0 el0_svc+0x20/0x50 el0t_64_sync_handler+0x98/0xc0 el0t_64_sync+0x174/0x178 Code: aa0103f4 a9025bf5 d5384100 b9400801 (79401260) ---[ end trace 0000000000000000 ]---
Message-ID: <[email protected]>
--- drivers/bus/fsl-mc/dprc-driver.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/bus/fsl-mc/dprc-driver.c +6 -0
@@ -45,6 +45,9 @@ static int __fsl_mc_device_remove_if_not_in_mc(struct device *dev, void *data)struct fsl_mc_child_objs *objs;struct fsl_mc_device *mc_dev; +if (!dev_is_fsl_mc (dev)) +return 0 ; + mc_dev =to_fsl_mc_device (dev); objs = data;
@@ -64,6 +67,9 @@ static int __fsl_mc_device_remove_if_not_in_mc(struct device *dev, void *data)static int __fsl_mc_device_remove (struct device *dev,void *data) { +if (!dev_is_fsl_mc (dev)) +return 0 ; +fsl_mc_device_remove (to_fsl_mc_device (dev));return 0 ; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 634/800 mfd: stmfx: Fix error path in stmfx_chip_init
In reply to Greg Kroah-HartmanFrom: Amelie Delaunay <[email protected]>
[ Upstream commit f592cf624531286f8b52e40dcfc157a5a7fb115c ]
In error path, disable vdd regulator if it exists, but don't overload ret. Because if regulator_disable() is successful, stmfx_chip_init will exit successfully while chip init failed.
--- drivers/mfd/stmfx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mfd/stmfx.c +1 -1
@@ -387,7 +387,7 @@ static int stmfx_chip_init(struct i2c_client *client) err:if (stmfx->vdd) -return regulator_disable (stmfx->vdd); +regulator_disable (stmfx->vdd);return ret; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 635/800 mfd: stmfx: Nullify stmfx->vdd in case of error
In reply to Greg Kroah-HartmanFrom: Amelie Delaunay <[email protected]>
[ Upstream commit 7c81582c0bccb4757186176f0ee12834597066ad ]
Nullify stmfx->vdd in case devm_regulator_get_optional() returns an error. And simplify code by returning an error only if return code is not -ENODEV, which means there is no vdd regulator and it is not an issue.
--- drivers/mfd/stmfx.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/mfd/stmfx.c +2 -3
@@ -330,9 +330,8 @@ static int stmfx_chip_init(struct i2c_client *client) stmfx->vdd =devm_regulator_get_optional (&client->dev,"vdd" ); ret =PTR_ERR_OR_ZERO (stmfx->vdd);if (ret) { -if (ret == -ENODEV ) - stmfx->vdd =NULL ; -else + stmfx->vdd =NULL ; +if (ret != -ENODEV )return dev_err_probe (&client->dev, ret,"Failed to get VDD regulator\n" ); }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 636/800 KVM: s390: vsie: fix the length of APCB bitmap
In reply to Greg Kroah-HartmanFrom: Pierre Morel <[email protected]>
[ Upstream commit 246be7d2720ea9a795b576067ecc5e5c7a1e7848 ]
bit_and() uses the count of bits as the woking length. Fix the previous implementation and effectively use the right bitmap size.
--- arch/s390/kvm/vsie.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
arch/s390/kvm/vsie.c +4 -2
@@ -177,7 +177,8 @@ static int setup_apcb00(struct kvm_vcpu *vcpu, unsigned long *apcb_s, sizeof(struct kvm_s390_apcb0)))return -EFAULT ; -bitmap_and (apcb_s, apcb_s, apcb_h,sizeof (struct kvm_s390_apcb0 )); +bitmap_and (apcb_s, apcb_s, apcb_h, +BITS_PER_BYTE *sizeof (struct kvm_s390_apcb0 ));return 0 ; }
@@ -203,7 +204,8 @@ static int setup_apcb11(struct kvm_vcpu *vcpu, unsigned long *apcb_s, sizeof(struct kvm_s390_apcb1)))return -EFAULT ; -bitmap_and (apcb_s, apcb_s, apcb_h,sizeof (struct kvm_s390_apcb1 )); +bitmap_and (apcb_s, apcb_s, apcb_h, +BITS_PER_BYTE *sizeof (struct kvm_s390_apcb1 ));return 0 ; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 637/800 KVM: s390/diag: fix racy access of physical cpu number in diag 9c handler
In reply to Greg Kroah-HartmanFrom: Christian Borntraeger <[email protected]>
[ Upstream commit 0bc380beb78aa352eadbc21d934dd9606fcee808 ]
We do check for target CPU == -1, but this might change at the time we are going to use it. Hold the physical target CPU in a local variable to avoid out-of-bound accesses to the cpu arrays.
--- arch/s390/kvm/diag.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
arch/s390/kvm/diag.c +5 -3
@@ -166,6 +166,7 @@ static int diag9c_forwarding_overrun(void)static int __diag_time_slice_end_directed (struct kvm_vcpu *vcpu) {struct kvm_vcpu *tcpu; +int tcpu_cpu;int tid; tid = vcpu->run->s.regs.gprs[(vcpu->arch.sie_block->ipa &0xf0 ) >>4 ];
@@ -181,14 +182,15 @@ static int __diag_time_slice_end_directed(struct kvm_vcpu *vcpu) goto no_yield;/* target guest VCPU already running */ -if (READ_ONCE (tcpu->cpu) >=0 ) { + tcpu_cpu =READ_ONCE (tcpu->cpu); +if (tcpu_cpu >=0 ) {if (!diag9c_forwarding_hz ||diag9c_forwarding_overrun ()) goto no_yield;/* target host CPU already running */ -if (!vcpu_is_preempted (tcpu->cpu)) +if (!vcpu_is_preempted (tcpu_cpu)) goto no_yield; -smp_yield_cpu (tcpu->cpu); +smp_yield_cpu (tcpu_cpu);VCPU_EVENT (vcpu,5 ,"diag time slice end directed to %d: yield forwarded" , tid);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 638/800 cpufreq: mediatek: correct voltages for MT7622 and MT7623
In reply to Greg Kroah-HartmanFrom: Daniel Golle <[email protected]>
[ Upstream commit f85534113f5ae90a52521cdb9e9977a43ee42626 ]
The MT6380 regulator typically used together with MT7622 does not support the current maximum processor and SRAM voltage in the cpufreq driver (1360000uV).
For MT7622 limit processor and SRAM supply voltages to 1350000uV to avoid having the tracking algorithm request unsupported voltages from the regulator.
On MT7623 there is no separate SRAM supply and the maximum voltage used is 1300000uV. Create dedicated platform data for MT7623 to cover that case as well.
--- drivers/cpufreq/mediatek-cpufreq.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
drivers/cpufreq/mediatek-cpufreq.c +10 -3
@@ -696,9 +696,16 @@ static const struct mtk_cpufreq_platform_data mt2701_platform_data = {static const struct mtk_cpufreq_platform_data mt7622_platform_data = { .min_volt_shift =100000 , .max_volt_shift =200000 , - .proc_max_volt =1360000 , + .proc_max_volt =1350000 , .sram_min_volt =0 , - .sram_max_volt =1360000 , + .sram_max_volt =1350000 , + .ccifreq_supported = false, +}; + +static const struct mtk_cpufreq_platform_data mt7623_platform_data = { + .min_volt_shift =100000 , + .max_volt_shift =200000 , + .proc_max_volt =1300000 , .ccifreq_supported = false, };
@@ -734,7 +741,7 @@ static const struct of_device_id mtk_cpufreq_machines[] __initconst = { { .compatible = "mediatek,mt2701", .data = &mt2701_platform_data }, { .compatible = "mediatek,mt2712", .data = &mt2701_platform_data }, { .compatible = "mediatek,mt7622", .data = &mt7622_platform_data }, - { .compatible = "mediatek,mt7623", .data = &mt7622_platform_data }, + { .compatible = "mediatek,mt7623", .data = &mt7623_platform_data }, { .compatible = "mediatek,mt8167", .data = &mt8516_platform_data }, { .compatible = "mediatek,mt817x", .data = &mt2701_platform_data }, { .compatible = "mediatek,mt8173", .data = &mt2701_platform_data },
Signature · 1 line
2.39.2