6.8.3-rc1 review
Subsystems (6)
Greg Kroah-Hartman
maintainerPATCH 246/399 x86/efistub: Call mixed mode boot services on the firmwares stack
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ard Biesheuvel <[email protected]>
commit cefcd4fe2e3aaf792c14c9e56dab89e3d7a65d02 upstream.
Normally, the EFI stub calls into the EFI boot services using the stack that was live when the stub was entered. According to the UEFI spec, this stack needs to be at least 128k in size - this might seem large but all asynchronous processing and event handling in EFI runs from the same stack and so quite a lot of space may be used in practice.
In mixed mode, the situation is a bit different: the bootloader calls the 32-bit EFI stub entry point, which calls the decompressor's 32-bit entry point, where the boot stack is set up, using a fixed allocation of 16k. This stack is still in use when the EFI stub is started in 64-bit mode, and so all calls back into the EFI firmware will be using the decompressor's limited boot stack.
Due to the placement of the boot stack right after the boot heap, any stack overruns have gone unnoticed. However, commit
5c4feadb0011983b ("x86/decompressor: Move global symbol references to C code")
moved the definition of the boot heap into C code, and now the boot stack is placed right at the base of BSS, where any overruns will corrupt the end of the .data section.
While it would be possible to work around this by increasing the size of the boot stack, doing so would affect all x86 systems, and mixed mode systems are a tiny (and shrinking) fraction of the x86 installed base.
So instead, record the firmware stack pointer value when entering from the 32-bit firmware, and switch to this stack every time a EFI boot service call is made.
--- arch/x86/boot/compressed/efi_mixed.S | 9 +++++++++ 1 file changed, 9 insertions(+)
arch/x86/boot/compressed/efi_mixed.S +9 -0
@@ -49,6 +49,11 @@ SYM_FUNC_START(startup_64_mixed_mode) lea efi32_boot_args(%rip), %rdx mov 0(%rdx), %edi mov 4(%rdx), %esi + + /* Switch to the firmware's stack */ + movl efi32_boot_sp(%rip), %esp + andl $~7, %esp + #ifdef CONFIG_EFI_HANDOVER_PROTOCOL mov 8(%rdx), %edx // saved bootparams pointer test %edx, %edx
@@ -254,6 +259,9 @@ SYM_FUNC_START_LOCAL(efi32_entry) /* Store firmware IDT descriptor */ sidtl (efi32_boot_idt - 1b)(%ebx) + /* Store firmware stack pointer */ + movl %esp, (efi32_boot_sp - 1b)(%ebx) + /* Store boot arguments */ leal (efi32_boot_args - 1b)(%ebx), %ebx movl %ecx, 0(%ebx)
@@ -318,5 +326,6 @@ SYM_DATA_END(efi32_boot_idt) SYM_DATA_LOCAL(efi32_boot_cs, .word 0) SYM_DATA_LOCAL(efi32_boot_ds, .word 0) +SYM_DATA_LOCAL(efi32_boot_sp, .long 0) SYM_DATA_LOCAL(efi32_boot_args, .long 0, 0, 0) SYM_DATA(efi_is64, .byte 1)
Greg Kroah-Hartman
maintainerPATCH 247/399 ASoC: amd: yc: Revert "Fix non-functional mic on Lenovo 21J2"
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiawei Wang <[email protected]>
commit 861b3415e4dee06cc00cd1754808a7827b9105bf upstream.
This reverts commit ed00a6945dc32462c2d3744a3518d2316da66fcc, which added a quirk entry to enable the Yellow Carp (YC) driver for the Lenovo 21J2 laptop.
Although the microphone functioned with the YC driver, it resulted in incorrect driver usage. The Lenovo 21J2 is not a Yellow Carp platform, but a Pink Sardine platform, which already has an upstreamed driver.
The microphone on the Lenovo 21J2 operates correctly with the CONFIG_SND_SOC_AMD_PS flag enabled and does not require the quirk entry. So this patch removes the quirk entry.
Thanks to Mukunda Vijendar [1] for pointing this out.
--- sound/soc/amd/yc/acp6x-mach.c | 7 ------- 1 file changed, 7 deletions(-)
sound/soc/amd/yc/acp6x-mach.c +0 -7
@@ -203,13 +203,6 @@ static const struct dmi_system_id yc_acp .driver_data = &acp6x_card, .matches = {DMI_MATCH (DMI_BOARD_VENDOR ,"LENOVO" ), - DMI_MATCH(DMI_PRODUCT_NAME, "21J2"), - } - }, - { - .driver_data = &acp6x_card, - .matches = { -DMI_MATCH (DMI_BOARD_VENDOR ,"LENOVO" ), DMI_MATCH(DMI_PRODUCT_NAME, "21J0"), } },
Greg Kroah-Hartman
maintainerPATCH 248/399 ASoC: amd: yc: Revert "add new YC platform variant (0x63) support"
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiawei Wang <[email protected]>
commit 37bee1855d0e3b6dbeb8de71895f6f68cad137be upstream.
This reverts commit 316a784839b21b122e1761cdca54677bb19a47fa, that enabled Yellow Carp (YC) driver for PCI revision id 0x63.
Mukunda Vijendar [1] points out that revision 0x63 is Pink Sardine platform, not Yellow Carp. The YC driver should not be enabled for this platform. This patch prevents the YC driver from being incorrectly enabled.
--- sound/soc/amd/yc/pci-acp6x.c | 1 - 1 file changed, 1 deletion(-)
sound/soc/amd/yc/pci-acp6x.c +0 -1
@@ -162,7 +162,6 @@ static int snd_acp6x_probe(struct pci_de/* Yellow Carp device check */ switch (pci->revision) {case 0x60 : -case 0x63 :case 0x6f :break ;default :
Greg Kroah-Hartman
maintainerPATCH 249/399 Fix memory leak in posix_clock_open()
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Torvalds <[email protected]>
commit 5b4cdd9c5676559b8a7c944ac5269b914b8c0bb8 upstream.
If the clk ops.open() function returns an error, we don't release the pccontext we allocated for this clock.
Re-organize the code slightly to make it all more obvious.
--- kernel/time/posix-clock.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
kernel/time/posix-clock.c +9 -7
@@ -129,15 +129,17 @@ static int posix_clock_open(struct inode goto out; } pccontext->clk = clk; - fp->private_data = pccontext; -if (clk->ops.open) +if (clk->ops.open) { err = clk->ops.open (pccontext, fp->f_mode); -else - err =0 ; - -if (!err) { -get_device (clk->dev); +if (err) { +kfree (pccontext); + goto out; + } } + + fp->private_data = pccontext; +get_device (clk->dev); + err =0 ; out:up_read (&clk->rwsem);return err;
Greg Kroah-Hartman
maintainerPATCH 250/399 wifi: rtw88: 8821cu: Fix connection failure
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bitterblue Smith <[email protected]>
commit 605d7c0b05eecb985273b1647070497142c470d3 upstream.
Clear bit 8 of REG_SYS_STATUS1 after MAC power on.
Without this, some RTL8821CU and RTL8811CU cannot connect to any network:
Feb 19 13:33:11 ideapad2 kernel: wlp3s0f3u2: send auth to 90:55:de:__:__:__ (try 1/3) Feb 19 13:33:13 ideapad2 kernel: wlp3s0f3u2: send auth to 90:55:de:__:__:__ (try 2/3) Feb 19 13:33:14 ideapad2 kernel: wlp3s0f3u2: send auth to 90:55:de:__:__:__ (try 3/3) Feb 19 13:33:15 ideapad2 kernel: wlp3s0f3u2: authentication with 90:55:de:__:__:__ timed out
The RTL8822CU and RTL8822BU out-of-tree drivers do this as well, so do it for all three types of chips.
Tested with RTL8811CU (Tenda U9 V2.0).
--- drivers/net/wireless/realtek/rtw88/mac.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/net/wireless/realtek/rtw88/mac.c +7 -0
@@ -309,6 +309,13 @@ static int rtw_mac_power_switch(struct r pwr_seq = pwr_on ? chip->pwr_on_seq : chip->pwr_off_seq; ret =rtw_pwr_seq_parser (rtwdev, pwr_seq); +if (pwr_on &&rtw_hci_type (rtwdev) ==RTW_HCI_TYPE_USB ) { +if (chip->id ==RTW_CHIP_TYPE_8822C || + chip->id ==RTW_CHIP_TYPE_8822B || + chip->id ==RTW_CHIP_TYPE_8821C ) +rtw_write8_clr (rtwdev,REG_SYS_STATUS1 +1 ,BIT (0 )); + } +if (rtw_hci_type (rtwdev) ==RTW_HCI_TYPE_SDIO )rtw_write32 (rtwdev,REG_SDIO_HIMR , imr);
Greg Kroah-Hartman
maintainerPATCH 251/399 x86/Kconfig: Remove CONFIG_AMD_MEM_ENCRYPT_ACTIVE_BY_DEFAULT
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Borislav Petkov (AMD) <[email protected]>
commit 29956748339aa8757a7e2f927a8679dd08f24bb6 upstream.
It was meant well at the time but nothing's using it so get rid of it.
--- Documentation/admin-guide/kernel-parameters.txt | 4 +--- Documentation/arch/x86/amd-memory-encryption.rst | 16 ++++++++-------- arch/x86/Kconfig | 13 ------------- arch/x86/mm/mem_encrypt_identity.c | 11 +---------- 4 files changed, 10 insertions(+), 34 deletions(-)
Documentation/admin-guide/kernel-parameters.txt +1 -3
@@ -3340,9 +3340,7 @@ mem_encrypt= [X86-64] AMD Secure Memory Encryption (SME) control Valid arguments: on, off - Default (depends on kernel configuration option): - on (CONFIG_AMD_MEM_ENCRYPT_ACTIVE_BY_DEFAULT=y) - off (CONFIG_AMD_MEM_ENCRYPT_ACTIVE_BY_DEFAULT=n) + Default: off mem_encrypt=on: Activate SME mem_encrypt=off: Do not activate SME
Documentation/arch/x86/amd-memory-encryption.rst +8 -8
@@ -87,14 +87,14 @@ The state of SME in the Linux kernel can kernel is non-zero). SME can also be enabled and activated in the BIOS. If SME is enabled and -activated in the BIOS, then all memory accesses will be encrypted and it will -not be necessary to activate the Linux memory encryption support. If the BIOS -merely enables SME (sets bit 23 of the MSR_AMD64_SYSCFG), then Linux can activate -memory encryption by default (CONFIG_AMD_MEM_ENCRYPT_ACTIVE_BY_DEFAULT=y) or -by supplying mem_encrypt=on on the kernel command line. However, if BIOS does -not enable SME, then Linux will not be able to activate memory encryption, even -if configured to do so by default or the mem_encrypt=on command line parameter -is specified. +activated in the BIOS, then all memory accesses will be encrypted and it +will not be necessary to activate the Linux memory encryption support. + +If the BIOS merely enables SME (sets bit 23 of the MSR_AMD64_SYSCFG), +then memory encryption can be enabled by supplying mem_encrypt=on on the +kernel command line. However, if BIOS does not enable SME, then Linux +will not be able to activate memory encryption, even if configured to do +so by default or the mem_encrypt=on command line parameter is specified. Secure Nested Paging (SNP) ==========================
arch/x86/Kconfig +0 -13
@@ -1539,19 +1539,6 @@ config AMD_MEM_ENCRYPT This requires an AMD processor that supports Secure Memory Encryption (SME). -config AMD_MEM_ENCRYPT_ACTIVE_BY_DEFAULT - bool "Activate AMD Secure Memory Encryption (SME) by default" - depends on AMD_MEM_ENCRYPT - help - Say yes to have system memory encrypted by default if running on - an AMD processor that supports Secure Memory Encryption (SME). - - If set to Y, then the encryption of system memory can be - deactivated with the mem_encrypt=off command line option. - - If set to N, then the encryption of system memory can be - activated with the mem_encrypt=on command line option. - # Common NUMA Features config NUMA bool "NUMA Memory Allocation and Scheduler Support"
arch/x86/mm/mem_encrypt_identity.c +1 -10
@@ -97,7 +97,6 @@ static char sme_workarea[2 * PMD_SIZE] _static char sme_cmdline_arg[]__initdata ="mem_encrypt" ;static char sme_cmdline_on[]__initdata ="on" ; -static char sme_cmdline_off[]__initdata ="off" ;static void __init sme_clear_pgd (struct sme_populate_pgd_data *ppd) {
@@ -504,7 +503,7 @@ void __init sme_encrypt_kernel(struct bovoid __init sme_enable (struct boot_params *bp) { -const char *cmdline_ptr, *cmdline_arg, *cmdline_on, *cmdline_off; +const char *cmdline_ptr, *cmdline_arg, *cmdline_on;unsigned int eax, ebx, ecx, edx;unsigned long feature_mask;unsigned long me_mask;
@@ -587,12 +586,6 @@ void __init sme_enable(struct boot_param asm ("lea sme_cmdline_on(%%rip), %0" :"=r" (cmdline_on) :"p" (sme_cmdline_on)); - asm ("lea sme_cmdline_off(%%rip), %0" - :"=r" (cmdline_off) - :"p" (sme_cmdline_off)); - -if (IS_ENABLED (CONFIG_AMD_MEM_ENCRYPT_ACTIVE_BY_DEFAULT )) - sme_me_mask = me_mask; cmdline_ptr = (const char *)((u64 )bp->hdr.cmd_line_ptr | ((u64 )bp->ext_cmd_line_ptr <<32 ));
@@ -602,8 +595,6 @@ void __init sme_enable(struct boot_paramif (!strncmp (buffer, cmdline_on,sizeof (buffer))) sme_me_mask = me_mask; -else if (!strncmp (buffer, cmdline_off,sizeof (buffer))) - sme_me_mask =0 ; out:if (sme_me_mask) {
Greg Kroah-Hartman
maintainerPATCH 252/399 x86/sev: Fix position dependent variable references in startup code
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ard Biesheuvel <[email protected]>
commit 1c811d403afd73f04bde82b83b24c754011bd0e8 upstream.
The early startup code executes from a 1:1 mapping of memory, which differs from the mapping that the code was linked and/or relocated to run at. The latter mapping is not active yet at this point, and so symbol references that rely on it will fault.
Given that the core kernel is built without -fPIC, symbol references are typically emitted as absolute, and so any such references occuring in the early startup code will therefore crash the kernel.
While an attempt was made to work around this for the early SEV/SME startup code, by forcing RIP-relative addressing for certain global SEV/SME variables via inline assembly (see snp_cpuid_get_table() for example), RIP-relative addressing must be pervasively enforced for SEV/SME global variables when accessed prior to page table fixups.
__startup_64() already handles this issue for select non-SEV/SME global variables using fixup_pointer(), which adjusts the pointer relative to a physaddr argument. To avoid having to pass around this physaddr argument across all functions needing to apply pointer fixups, introduce a macro RIP_RELATIVE_REF() which generates a RIP-relative reference to a given global variable. It is used where necessary to force RIP-relative accesses to global variables.
For backporting purposes, this patch makes no attempt at cleaning up other occurrences of this pattern, involving either inline asm or fixup_pointer(). Those will be addressed later.
[ bp: Call it "rip_rel_ref" everywhere like other code shortens
"rIP-relative reference" and make the asm wrapper __always_inline. ]
--- arch/x86/coco/core.c | 7 +------ arch/x86/include/asm/asm.h | 14 ++++++++++++++ arch/x86/include/asm/coco.h | 8 +++++++- arch/x86/include/asm/mem_encrypt.h | 15 +++++++++------ arch/x86/kernel/sev-shared.c | 12 ++++++------ arch/x86/kernel/sev.c | 4 ++-- arch/x86/mm/mem_encrypt_identity.c | 27 ++++++++++++--------------- 7 files changed, 51 insertions(+), 36 deletions(-)
arch/x86/coco/core.c +1 -6
@@ -14,7 +14,7 @@#include <asm/processor.h> enum cc_vendor cc_vendor__ro_after_init =CC_VENDOR_NONE ; -static u64 cc_mask__ro_after_init ; +u64 cc_mask__ro_after_init ; static bool noinstr intel_cc_platform_has(enum cc_attr attr) {
@@ -148,8 +148,3 @@ u64 cc_mkdec(u64 val) } }EXPORT_SYMBOL_GPL (cc_mkdec); - -__init void cc_set_mask (u64 mask) -{ - cc_mask = mask; -}
arch/x86/include/asm/asm.h +14 -0
@@ -113,6 +113,20 @@#endif +#ifndef __ASSEMBLY__ +#ifndef __pic__ +static __always_inline __pure void *rip_rel_ptr(void *p) +{ + asm("leaq %c1(%%rip), %0" :"=r" (p) :"i" (p)); + +return p; +} +#define RIP_REL_REF (var) (*(typeof(&(var)))rip_rel_ptr(&(var))) +#else +#define RIP_REL_REF (var) (var) +#endif +#endif +/* * Macros to generate condition code outputs from inline assembly, * The output operand must be type "bool".
arch/x86/include/asm/coco.h +7 -1
@@ -2,6 +2,7 @@#ifndef _ASM_X86_COCO_H#define _ASM_X86_COCO_H +#include <asm/asm.h> #include <asm/types.h> enum cc_vendor {
@@ -12,7 +13,12 @@ enum cc_vendor {#ifdef CONFIG_ARCH_HAS_CC_PLATFORM extern enum cc_vendor cc_vendor; -void cc_set_mask (u64 mask); +extern u64 cc_mask; +static inline void cc_set_mask (u64 mask) +{ +RIP_REL_REF (cc_mask) = mask; +} +u64 cc_mkenc (u64 val);u64 cc_mkdec (u64 val);#else
arch/x86/include/asm/mem_encrypt.h +9 -6
@@ -15,7 +15,8 @@#include <linux/init.h> #include <linux/cc_platform.h> -#include <asm/bootparam.h> +#include <asm/asm.h> +struct boot_params ;#ifdef CONFIG_X86_MEM_ENCRYPT void __init mem_encrypt_init (void );
@@ -58,6 +59,11 @@ void __init mem_encrypt_free_decrypted_mvoid __init sev_es_init_vc_handling (void ); +static inline u64 sme_get_me_mask (void ) +{ +return RIP_REL_REF (sme_me_mask); +} +#define __bss_decrypted __section(".bss..decrypted")#else /* !CONFIG_AMD_MEM_ENCRYPT */
@@ -89,6 +95,8 @@ early_set_mem_enc_dec_hypercall(unsignedstatic inline void mem_encrypt_free_decrypted_mem (void ) { } +static inline u64 sme_get_me_mask (void ) {return 0 ; } +#define __bss_decrypted#endif /* CONFIG_AMD_MEM_ENCRYPT */
@@ -106,11 +114,6 @@ void add_encrypt_protection_map(void);extern char __start_bss_decrypted[], __end_bss_decrypted[], __start_bss_decrypted_unused[]; -static inline u64 sme_get_me_mask (void ) -{ -return sme_me_mask; -} -#endif /* __ASSEMBLY__ */ #endif /* __X86_MEM_ENCRYPT_H__ */
arch/x86/kernel/sev-shared.c +6 -6
@@ -556,9 +556,9 @@ static int snp_cpuid(struct ghcb *ghcb, leaf->eax = leaf->ebx = leaf->ecx = leaf->edx =0 ;/* Skip post-processing for out-of-range zero leafs. */ -if (!(leaf->fn <= cpuid_std_range_max || - (leaf->fn >=0x40000000 && leaf->fn <= cpuid_hyp_range_max) || - (leaf->fn >=0x80000000 && leaf->fn <= cpuid_ext_range_max))) +if (!(leaf->fn <=RIP_REL_REF (cpuid_std_range_max) || + (leaf->fn >=0x40000000 && leaf->fn <=RIP_REL_REF (cpuid_hyp_range_max)) || + (leaf->fn >=0x80000000 && leaf->fn <=RIP_REL_REF (cpuid_ext_range_max))))return 0 ; }
@@ -1063,11 +1063,11 @@ static void __init setup_cpuid_table(conconst struct snp_cpuid_fn *fn = &cpuid_table->fn[i];if (fn->eax_in ==0x0 ) - cpuid_std_range_max = fn->eax; +RIP_REL_REF (cpuid_std_range_max) = fn->eax;else if (fn->eax_in ==0x40000000 ) - cpuid_hyp_range_max = fn->eax; +RIP_REL_REF (cpuid_hyp_range_max) = fn->eax;else if (fn->eax_in ==0x80000000 ) - cpuid_ext_range_max = fn->eax; +RIP_REL_REF (cpuid_ext_range_max) = fn->eax; } }
arch/x86/kernel/sev.c +2 -2
@@ -748,7 +748,7 @@ void __init early_snp_set_memory_private* This eliminates worries about jump tables or checking boot_cpu_data * in the cc_platform_has() function. */ -if (!(sev_status &MSR_AMD64_SEV_SNP_ENABLED )) +if (!(RIP_REL_REF (sev_status) &MSR_AMD64_SEV_SNP_ENABLED ))return ;/*
@@ -767,7 +767,7 @@ void __init early_snp_set_memory_shared(* This eliminates worries about jump tables or checking boot_cpu_data * in the cc_platform_has() function. */ -if (!(sev_status &MSR_AMD64_SEV_SNP_ENABLED )) +if (!(RIP_REL_REF (sev_status) &MSR_AMD64_SEV_SNP_ENABLED ))return ;/* Ask hypervisor to mark the memory pages shared in the RMP table. */
arch/x86/mm/mem_encrypt_identity.c +12 -15
@@ -304,7 +304,8 @@ void __init sme_encrypt_kernel(struct bo* instrumentation or checking boot_cpu_data in the cc_platform_has() * function. */ -if (!sme_get_me_mask () || sev_status &MSR_AMD64_SEV_ENABLED ) +if (!sme_get_me_mask () || +RIP_REL_REF (sev_status) &MSR_AMD64_SEV_ENABLED )return ;/*
@@ -541,11 +542,11 @@ void __init sme_enable(struct boot_param me_mask =1UL << (ebx &0x3f );/* Check the SEV MSR whether SEV or SME is enabled */ - sev_status =__rdmsr (MSR_AMD64_SEV ); - feature_mask = (sev_status &MSR_AMD64_SEV_ENABLED ) ?AMD_SEV_BIT :AMD_SME_BIT ; +RIP_REL_REF (sev_status) = msr =__rdmsr (MSR_AMD64_SEV ); + feature_mask = (msr &MSR_AMD64_SEV_ENABLED ) ?AMD_SEV_BIT :AMD_SME_BIT ;/* The SEV-SNP CC blob should never be present unless SEV-SNP is enabled. */ -if (snp && !(sev_status &MSR_AMD64_SEV_SNP_ENABLED )) +if (snp && !(msr &MSR_AMD64_SEV_SNP_ENABLED ))snp_abort ();/* Check if memory encryption is enabled */
@@ -571,7 +572,6 @@ void __init sme_enable(struct boot_paramreturn ; }else {/* SEV state cannot be controlled by a command line option */ - sme_me_mask = me_mask; goto out; }
@@ -590,16 +590,13 @@ void __init sme_enable(struct boot_param cmdline_ptr = (const char *)((u64 )bp->hdr.cmd_line_ptr | ((u64 )bp->ext_cmd_line_ptr <<32 )); -if (cmdline_find_option (cmdline_ptr, cmdline_arg, buffer,sizeof (buffer)) <0 ) - goto out; - -if (!strncmp (buffer, cmdline_on,sizeof (buffer))) - sme_me_mask = me_mask; +if (cmdline_find_option (cmdline_ptr, cmdline_arg, buffer,sizeof (buffer)) <0 || +strncmp (buffer, cmdline_on,sizeof (buffer))) +return ; out: -if (sme_me_mask) { - physical_mask &= ~sme_me_mask; - cc_vendor =CC_VENDOR_AMD ; -cc_set_mask (sme_me_mask); - } +RIP_REL_REF (sme_me_mask) = me_mask; + physical_mask &= ~me_mask; + cc_vendor =CC_VENDOR_AMD ; +cc_set_mask (me_mask); }
Greg Kroah-Hartman
maintainerPATCH 253/399 clocksource/drivers/arm_global_timer: Fix maximum prescaler value
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Martin Blumenstingl <[email protected]>
[ Upstream commit b34b9547cee41575a4fddf390f615570759dc999 ]
The prescaler in the "Global Timer Control Register bit assignments" is documented to use bits [15:8], which means that the maximum prescaler register value is 0xff.
--- drivers/clocksource/arm_global_timer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clocksource/arm_global_timer.c +1 -1
@@ -32,7 +32,7 @@#define GT_CONTROL_IRQ_ENABLE BIT(2)/* banked */ #define GT_CONTROL_AUTO_INC BIT(3)/* banked */ #define GT_CONTROL_PRESCALER_SHIFT 8 -#define GT_CONTROL_PRESCALER_MAX 0xF +#define GT_CONTROL_PRESCALER_MAX 0xFF#define GT_CONTROL_PRESCALER_MASK (GT_CONTROL_PRESCALER_MAX << \ GT_CONTROL_PRESCALER_SHIFT)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 254/399 ARM: 9352/1: iwmmxt: Remove support for PJ4/PJ4B cores
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ard Biesheuvel <[email protected]>
[ Upstream commit b9920fdd5a751df129808e7fa512e9928223ee05 ]
PJ4 is a v7 core that incorporates a iWMMXt coprocessor. However, GCC does not support this combination (its iWMMXt configuration always implies v5te), and so there is no v6/v7 user space that actually makes use of this, beyond generic support for things like setjmp() that preserve/restore the iWMMXt register file using generic LDC/STC instructions emitted in assembler. As [0] appears to imply, this logic is triggered for the init process at boot, and so most user threads will have a iWMMXt register context associated with it, even though it is never used.
At this point, it is highly unlikely that such GCC support will ever materialize (and Clang does not implement support for iWMMXt to begin with).
This means that advertising iWMMXt support on these cores results in context switch overhead without any associated benefit, and so it is better to simply ignore the iWMMXt unit on these systems. So rip out the support. Doing so also fixes the issue reported in [0] related to UNDEF handling of co-processor #0/#1 instructions issued from user space running in Thumb2 mode.
The PJ4 cores are used in four platforms: Armada 370/xp, Dove (Cubox, d2plug), MMP2 (xo-1.75) and Berlin (Google TV). Out of these, only the first is still widely used, but that one actually doesn't have iWMMXt but instead has only VFPV3-D16, and so it is not impacted by this change.
--- arch/arm/Kconfig | 4 +- arch/arm/kernel/Makefile | 2 - arch/arm/kernel/iwmmxt.S | 51 ++++---------- arch/arm/kernel/pj4-cp0.c | 135 -------------------------------------- 4 files changed, 15 insertions(+), 177 deletions(-) delete mode 100644 arch/arm/kernel/pj4-cp0.c
arch/arm/Kconfig +2 -2
@@ -503,8 +503,8 @@ source "arch/arm/mm/Kconfig" config IWMMXT bool "Enable iWMMXt support" - depends on CPU_XSCALE || CPU_XSC3 || CPU_MOHAWK || CPU_PJ4 || CPU_PJ4B - default y if PXA27x || PXA3xx || ARCH_MMP || CPU_PJ4 || CPU_PJ4B + depends on CPU_XSCALE || CPU_XSC3 || CPU_MOHAWK + default y if PXA27x || PXA3xx || ARCH_MMP help Enable support for iWMMXt context switching at run time if running on a CPU that supports it.
arch/arm/kernel/Makefile +0 -2
@@ -75,8 +75,6 @@ obj-$(CONFIG_HAVE_HW_BREAKPOINT) += hw_breakpoint.o obj-$(CONFIG_CPU_XSCALE) += xscale-cp0.o obj-$(CONFIG_CPU_XSC3) += xscale-cp0.o obj-$(CONFIG_CPU_MOHAWK) += xscale-cp0.o -obj-$(CONFIG_CPU_PJ4) += pj4-cp0.o -obj-$(CONFIG_CPU_PJ4B) += pj4-cp0.o obj-$(CONFIG_IWMMXT) += iwmmxt.o obj-$(CONFIG_PERF_EVENTS) += perf_regs.o perf_callchain.o obj-$(CONFIG_HW_PERF_EVENTS) += perf_event_xscale.o perf_event_v6.o \
arch/arm/kernel/iwmmxt.S +13 -38
91 lines not on this page · raw message
arch/arm/kernel/pj4-cp0.c deleted +0 -135
135 lines not on this page · raw message
Signature · 1 line
2.43.0
Re: [PATCH 6.8 254/399] ARM: 9352/1: iwmmxt: Remove support for PJ4/PJ4B cores
Quoted 1 line · Greg Kroah-Hartman
6.8-stable review patch. If anyone has any objections, please let me know.
I think we should not backport the feature removal, this was intentionally done separately from the bugfix in 303d6da167dc ("ARM: iwmmxt: Use undef hook to enable coprocessor for task") that is indeed needed in stable kernels.
It still makes sense for everyone to just turn iwmmxt support off on pj4.
Arnd
Ard Biesheuvel
maintainerRe: [PATCH 6.8 254/399] ARM: 9352/1: iwmmxt: Remove support for PJ4/PJ4B cores
Quoted 9 lines · Arnd Bergmann
Quoted 1 line · Greg Kroah-Hartman
6.8-stable review patch. If anyone has any objections, please let me know.
I think we should not backport the feature removal, this was intentionally done separately from the bugfix in
303d6da167dc("ARM: iwmmxt: Use undef hook to enable coprocessor for task") that is indeed needed in stable kernels.
303d6da167dc is not a bugfix - it moves the undef handling into C code for PJ4 but only for ARM not Thumb.
Subsequently, 8bcba70cb5c22 removed the Thumb exception handling, leading to the regression.
So without this fix, the Thumb case remains broken unless iwmmxt support is disabled in Kconfig.
Quoted 3 lines
It still makes sense for everyone to just turn iwmmxt support off on pj4.
If that is deemed sufficient for stable kernels, then we can drop this backport. Otherwise, we need to do something else if this patch is not suitable for -stable
Re: [PATCH 6.8 254/399] ARM: 9352/1: iwmmxt: Remove support for PJ4/PJ4B cores
Quoted 20 lines · Ard Biesheuvel
Quoted 9 lines · Arnd Bergmann
Quoted 1 line · Greg Kroah-Hartman
6.8-stable review patch. If anyone has any objections, please let me know.
I think we should not backport the feature removal, this was intentionally done separately from the bugfix in
303d6da167dc("ARM: iwmmxt: Use undef hook to enable coprocessor for task") that is indeed needed in stable kernels.
303d6da167dcis not a bugfix - it moves the undef handling into C code for PJ4 but only for ARM not Thumb.Subsequently,
8bcba70cb5c22removed the Thumb exception handling, leading to the regression.So without this fix, the Thumb case remains broken unless iwmmxt support is disabled in
Kconfig.
Quoted 7 lines
Quoted 3 lines
It still makes sense for everyone to just turn iwmmxt support off on pj4.
If that is deemed sufficient for stable kernels, then we can drop this backport. Otherwise, we need to do something else if this patch is not suitable for -stable
My mistake, I misremembered what you did in the end. Let's keep this one in stable then.
Arnd
Greg Kroah-Hartman
maintainerPATCH 255/399 ARM: 9359/1: flush: check if the folio is reserved for no-mapping addresses
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yongqiang Liu <[email protected]>
[ Upstream commit 0c66c6f4e21cb22220cbd8821c5c73fc157d20dc ]
Since commit a4d5613c4dc6 ("arm: extend pfn_valid to take into account freed memory map alignment") changes the semantics of pfn_valid() to check presence of the memory map for a PFN. A valid page for an address which is reserved but not mapped by the kernel[1], the system crashed during some uio test with the following memory layout:
node 0: [mem 0x00000000c0a00000-0x00000000cc8fffff]
node 0: [mem 0x00000000d0000000-0x00000000da1fffff]
the uio layout is:0xc0900000, 0x100000
the crash backtrace like:
Unable to handle kernel paging request at virtual address bff00000 [...] CPU: 1 PID: 465 Comm: startapp.bin Tainted: G O 5.10.0 #1 Hardware name: Generic DT based system PC is at b15_flush_kern_dcache_area+0x24/0x3c LR is at __sync_icache_dcache+0x6c/0x98 [...] (b15_flush_kern_dcache_area) from (__sync_icache_dcache+0x6c/0x98) (__sync_icache_dcache) from (set_pte_at+0x28/0x54) (set_pte_at) from (remap_pfn_range+0x1a0/0x274) (remap_pfn_range) from (uio_mmap+0x184/0x1b8 [uio]) (uio_mmap [uio]) from (__mmap_region+0x264/0x5f4) (__mmap_region) from (__do_mmap_mm+0x3ec/0x440) (__do_mmap_mm) from (do_mmap+0x50/0x58) (do_mmap) from (vm_mmap_pgoff+0xfc/0x188) (vm_mmap_pgoff) from (ksys_mmap_pgoff+0xac/0xc4) (ksys_mmap_pgoff) from (ret_fast_syscall+0x0/0x5c) Code: e0801001 e2423001 e1c00003 f57ff04f (ee070f3e) ---[ end trace 09cf0734c3805d52 ]--- Kernel panic - not syncing: Fatal exception
So check if PG_reserved was set to solve this issue.
[1]: https://lore.kernel.org/lkml/[email protected]/
--- arch/arm/mm/flush.c | 3 +++ 1 file changed, 3 insertions(+)
arch/arm/mm/flush.c +3 -0
@@ -296,6 +296,9 @@ void __sync_icache_dcache(pte_t pteval)return ; folio =page_folio (pfn_to_page (pfn)); +if (folio_test_reserved (folio)) +return ; +if (cache_is_vipt_aliasing ()) mapping =folio_flush_mapping (folio);else
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 256/399 entry: Respect changes to system call number by trace_sys_enter()
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: André Rösti <[email protected]>
[ Upstream commit fb13b11d53875e28e7fbf0c26b288e4ea676aa9f ]
When a probe is registered at the trace_sys_enter() tracepoint, and that probe changes the system call number, the old system call still gets executed. This worked correctly until commit b6ec41346103 ("core/entry:
Report syscall correctly for trace and audit"), which removed the re-evaluation of the syscall number after the trace point.
Restore the original semantics by re-evaluating the system call number after trace_sys_enter().
The performance impact of this re-evaluation is minimal because it only takes place when a trace point is active, and compared to the actual trace point overhead the read from a cache hot variable is negligible.
--- kernel/entry/common.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
kernel/entry/common.c +7 -1
@@ -57,8 +57,14 @@ long syscall_trace_enter(struct pt_regs *regs, long syscall,/* Either of the above might have changed the syscall number */ syscall =syscall_get_nr (current, regs); -if (unlikely (work &SYSCALL_WORK_SYSCALL_TRACEPOINT )) +if (unlikely (work &SYSCALL_WORK_SYSCALL_TRACEPOINT )) {trace_sys_enter (regs, syscall); +/* +* Probes or BPF hooks in the tracepoint may have changed the +* system call number as well. +*/ + syscall =syscall_get_nr (current, regs); + }syscall_enter_audit (regs, syscall);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 257/399 swiotlb: Fix double-allocation of slots due to broken alignment handling
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Will Deacon <[email protected]>
[ Upstream commit 04867a7a33324c9c562ee7949dbcaab7aaad1fb4 ]
Commit bbb73a103fbb ("swiotlb: fix a braino in the alignment check fix"), which was a fix for commit 0eee5ae10256 ("swiotlb: fix slot alignment checks"), causes a functional regression with vsock in a virtual machine using bouncing via a restricted DMA SWIOTLB pool.
When virtio allocates the virtqueues for the vsock device using dma_alloc_coherent(), the SWIOTLB search can return page-unaligned allocations if 'area->index' was left unaligned by a previous allocation from the buffer:
# Final address in brackets is the SWIOTLB address returned to the caller
| virtio-pci 0000:00:07.0: orig_addr 0x0 alloc_size 0x2000, iotlb_align_mask 0x800 stride 0x2: got slot 1645-1649/7168 (0x98326800) | virtio-pci 0000:00:07.0: orig_addr 0x0 alloc_size 0x2000, iotlb_align_mask 0x800 stride 0x2: got slot 1649-1653/7168 (0x98328800) | virtio-pci 0000:00:07.0: orig_addr 0x0 alloc_size 0x2000, iotlb_align_mask 0x800 stride 0x2: got slot 1653-1657/7168 (0x9832a800)
This ends badly (typically buffer corruption and/or a hang) because swiotlb_alloc() is expecting a page-aligned allocation and so blindly returns a pointer to the 'struct page' corresponding to the allocation, therefore double-allocating the first half (2KiB slot) of the 4KiB page.
Fix the problem by treating the allocation alignment separately to any additional alignment requirements from the device, using the maximum of the two as the stride to search the buffer slots and taking care to ensure a minimum of page-alignment for buffers larger than a page.
This also resolves swiotlb allocation failures occuring due to the inclusion of ~PAGE_MASK in 'iotlb_align_mask' for large allocations and resulting in alignment requirements exceeding swiotlb_max_mapping_size().
--- kernel/dma/swiotlb.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-)
kernel/dma/swiotlb.c +14 -12
@@ -982,7 +982,7 @@ static int swiotlb_search_pool_area(struct device *dev, struct io_tlb_pool *poolphys_to_dma_unencrypted (dev, pool->start) & boundary_mask;unsigned long max_slots =get_max_slots (boundary_mask);unsigned int iotlb_align_mask = -dma_get_min_align_mask (dev) | alloc_align_mask; +dma_get_min_align_mask (dev) & ~(IO_TLB_SIZE -1 );unsigned int nslots =nr_slots (alloc_size), stride;unsigned int offset =swiotlb_align_offset (dev, orig_addr);unsigned int index, slots_checked, count =0 , i;
@@ -994,18 +994,17 @@ static int swiotlb_search_pool_area(struct device *dev, struct io_tlb_pool *poolBUG_ON (area_index >= pool->nareas);/* -* For allocations of PAGE_SIZE or larger only look for page aligned -* allocations. +* For mappings with an alignment requirement don't bother looping to +* unaligned slots once we found an aligned one. */ -if (alloc_size >=PAGE_SIZE ) - iotlb_align_mask |= ~PAGE_MASK ; - iotlb_align_mask &= ~(IO_TLB_SIZE -1 ); + stride =get_max_slots (max (alloc_align_mask, iotlb_align_mask));/* -* For mappings with an alignment requirement don't bother looping to -* unaligned slots once we found an aligned one. +* For allocations of PAGE_SIZE or larger only look for page aligned +* allocations. */ - stride = (iotlb_align_mask >>IO_TLB_SHIFT ) +1 ; +if (alloc_size >=PAGE_SIZE ) + stride =umax (stride,PAGE_SHIFT -IO_TLB_SHIFT +1 );spin_lock_irqsave (&area->lock, flags);if (unlikely (nslots > pool->area_nslabs - area->used))
@@ -1015,11 +1014,14 @@ static int swiotlb_search_pool_area(struct device *dev, struct io_tlb_pool *pool index = area->index;for (slots_checked =0 ; slots_checked < pool->area_nslabs; ) { +phys_addr_t tlb_addr; + slot_index = slot_base + index; + tlb_addr =slot_addr (tbl_dma_addr, slot_index); -if (orig_addr && - (slot_addr (tbl_dma_addr, slot_index) & - iotlb_align_mask) != (orig_addr & iotlb_align_mask)) { +if ((tlb_addr & alloc_align_mask) || + (orig_addr && (tlb_addr & iotlb_align_mask) != + (orig_addr & iotlb_align_mask))) { index =wrap_area_index (pool, index +1 ); slots_checked++;continue ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 258/399 swiotlb: Honour dma_alloc_coherent() alignment in swiotlb_alloc()
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Will Deacon <[email protected]>
[ Upstream commit cbf53074a528191df82b4dba1e3d21191102255e ]
core-api/dma-api-howto.rst states the following properties of dma_alloc_coherent():
| The CPU virtual address and the DMA address are both guaranteed to | be aligned to the smallest PAGE_SIZE order which is greater than or | equal to the requested size.
However, swiotlb_alloc() passes zero for the 'alloc_align_mask' parameter of swiotlb_find_slots() and so this property is not upheld. Instead, allocations larger than a page are aligned to PAGE_SIZE,
Calculate the mask corresponding to the page order suitable for holding the allocation and pass that to swiotlb_find_slots().
--- kernel/dma/swiotlb.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
kernel/dma/swiotlb.c +3 -1
@@ -1633,12 +1633,14 @@ struct page *swiotlb_alloc(struct device *dev, size_t size)struct io_tlb_mem *mem = dev->dma_io_tlb_mem;struct io_tlb_pool *pool;phys_addr_t tlb_addr; +unsigned int align;int index;if (!mem)return NULL ; - index =swiotlb_find_slots (dev,0 , size,0 , &pool); + align = (1 << (get_order (size) +PAGE_SHIFT )) -1 ; + index =swiotlb_find_slots (dev,0 , size, align, &pool);if (index ==-1 )return NULL ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 259/399 swiotlb: Fix alignment checks when both allocation and DMA masks are present
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Will Deacon <[email protected]>
[ Upstream commit 51b30ecb73b481d5fac6ccf2ecb4a309c9ee3310 ]
Nicolin reports that swiotlb buffer allocations fail for an NVME device behind an IOMMU using 64KiB pages. This is because we end up with a minimum allocation alignment of 64KiB (for the IOMMU to map the buffer safely) but a minimum DMA alignment mask corresponding to a 4KiB NVME page (i.e. preserving the 4KiB page offset from the original allocation). If the original address is not 4KiB-aligned, the allocation will fail because swiotlb_search_pool_area() erroneously compares these unmasked bits with the 64KiB-aligned candidate allocation.
Tweak swiotlb_search_pool_area() so that the DMA alignment mask is reduced based on the required alignment of the allocation.
--- kernel/dma/swiotlb.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
kernel/dma/swiotlb.c +9 -2
@@ -981,8 +981,7 @@ static int swiotlb_search_pool_area(struct device *dev, struct io_tlb_pool *pooldma_addr_t tbl_dma_addr =phys_to_dma_unencrypted (dev, pool->start) & boundary_mask;unsigned long max_slots =get_max_slots (boundary_mask); -unsigned int iotlb_align_mask = -dma_get_min_align_mask (dev) & ~(IO_TLB_SIZE -1 ); +unsigned int iotlb_align_mask =dma_get_min_align_mask (dev);unsigned int nslots =nr_slots (alloc_size), stride;unsigned int offset =swiotlb_align_offset (dev, orig_addr);unsigned int index, slots_checked, count =0 , i;
@@ -993,6 +992,14 @@ static int swiotlb_search_pool_area(struct device *dev, struct io_tlb_pool *poolBUG_ON (!nslots);BUG_ON (area_index >= pool->nareas); +/* +* Ensure that the allocation is at least slot-aligned and update +* 'iotlb_align_mask' to ignore bits that will be preserved when +* offsetting into the allocation. +*/ + alloc_align_mask |= (IO_TLB_SIZE -1 ); + iotlb_align_mask &= ~alloc_align_mask; +/* * For mappings with an alignment requirement don't bother looping to * unaligned slots once we found an aligned one.
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 260/399 iommu/dma: Force swiotlb_max_mapping_size on an untrusted device
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nicolin Chen <[email protected]>
[ Upstream commit afc5aa46ed560f01ceda897c053c6a40c77ce5c4 ]
The swiotlb does not support a mapping size > swiotlb_max_mapping_size().
On the other hand, with a 64KB PAGE_SIZE configuration, it's observed that
an NVME device can map a size between 300KB~512KB, which certainly failed
the swiotlb mappings, though the default pool of swiotlb has many slots:
systemd[1]: Started Journal Service.
=> nvme 0000:00:01.0: swiotlb buffer is full (sz: 327680 bytes), total 32768 (slots), used 32 (slots)
note: journal-offline[392] exited with irqs disabled
note: journal-offline[392] exited with preempt_count 1
Call trace: [ 3.099918] swiotlb_tbl_map_single+0x214/0x240 [ 3.099921] iommu_dma_map_page+0x218/0x328 [ 3.099928] dma_map_page_attrs+0x2e8/0x3a0 [ 3.101985] nvme_prep_rq.part.0+0x408/0x878 [nvme] [ 3.102308] nvme_queue_rqs+0xc0/0x300 [nvme] [ 3.102313] blk_mq_flush_plug_list.part.0+0x57c/0x600 [ 3.102321] blk_add_rq_to_plug+0x180/0x2a0 [ 3.102323] blk_mq_submit_bio+0x4c8/0x6b8 [ 3.103463] __submit_bio+0x44/0x220 [ 3.103468] submit_bio_noacct_nocheck+0x2b8/0x360 [ 3.103470] submit_bio_noacct+0x180/0x6c8 [ 3.103471] submit_bio+0x34/0x130 [ 3.103473] ext4_bio_write_folio+0x5a4/0x8c8 [ 3.104766] mpage_submit_folio+0xa0/0x100 [ 3.104769] mpage_map_and_submit_buffers+0x1a4/0x400 [ 3.104771] ext4_do_writepages+0x6a0/0xd78 [ 3.105615] ext4_writepages+0x80/0x118 [ 3.105616] do_writepages+0x90/0x1e8 [ 3.105619] filemap_fdatawrite_wbc+0x94/0xe0 [ 3.105622] __filemap_fdatawrite_range+0x68/0xb8 [ 3.106656] file_write_and_wait_range+0x84/0x120 [ 3.106658] ext4_sync_file+0x7c/0x4c0 [ 3.106660] vfs_fsync_range+0x3c/0xa8 [ 3.106663] do_fsync+0x44/0xc0
Since untrusted devices might go down the swiotlb pathway with dma-iommu, these devices should not map a size larger than swiotlb_max_mapping_size.
To fix this bug, add iommu_dma_max_mapping_size() for untrusted devices to take into account swiotlb_max_mapping_size() v.s. iova_rcache_range() from the iommu_dma_opt_mapping_size().
--- drivers/iommu/dma-iommu.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/iommu/dma-iommu.c +9 -0
@@ -1706,6 +1706,14 @@ static size_t iommu_dma_opt_mapping_size(void)return iova_rcache_range (); } +static size_t iommu_dma_max_mapping_size (struct device *dev) +{ +if (dev_is_untrusted (dev)) +return swiotlb_max_mapping_size (dev); + +return SIZE_MAX ; +} +static const struct dma_map_ops iommu_dma_ops = { .flags =DMA_F_PCI_P2PDMA_SUPPORTED , .alloc = iommu_dma_alloc,
@@ -1728,6 +1736,7 @@ static const struct dma_map_ops iommu_dma_ops = { .unmap_resource = iommu_dma_unmap_resource, .get_merge_boundary = iommu_dma_get_merge_boundary, .opt_mapping_size = iommu_dma_opt_mapping_size, + .max_mapping_size = iommu_dma_max_mapping_size, };/*
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 261/399 printk: Update @console_may_schedule in console_trylock_spinning()
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: John Ogness <[email protected]>
[ Upstream commit 8076972468584d4a21dab9aa50e388b3ea9ad8c7 ]
console_trylock_spinning() may takeover the console lock from a schedulable context. Update @console_may_schedule to make sure it reflects a trylock acquire.
--- kernel/printk/printk.c | 6 ++++++ 1 file changed, 6 insertions(+)
kernel/printk/printk.c +6 -0
@@ -2026,6 +2026,12 @@ static int console_trylock_spinning(void)*/ mutex_acquire (&console_lock_dep_map,0 ,1 , _THIS_IP_); +/* +* Update @console_may_schedule for trylock because the previous +* owner may have been schedulable. +*/ + console_may_schedule =0 ; +return 1 ; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 262/399 irqchip/renesas-rzg2l: Flush posted write in irq_eoi()
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Biju Das <[email protected]>
[ Upstream commit 9eec61df55c51415409c7cc47e9a1c8de94a0522 ]
The irq_eoi() callback of the RZ/G2L interrupt chip clears the relevant interrupt cause bit in the TSCR register by writing to it.
This write is not sufficient because the write is posted and therefore not guaranteed to immediately clear the bit. Due to that delay the CPU can raise the just handled interrupt again.
Prevent this by reading the register back which causes the posted write to be flushed to the hardware before the read completes.
--- drivers/irqchip/irq-renesas-rzg2l.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)
drivers/irqchip/irq-renesas-rzg2l.c +14 -2
@@ -99,8 +99,14 @@ static void rzg2l_irq_eoi(struct irq_data *d)* ISCR can only be cleared if the type is falling-edge, rising-edge or * falling/rising-edge. */ -if ((iscr & bit) && (iitsr &IITSR_IITSEL_MASK (hw_irq))) +if ((iscr & bit) && (iitsr &IITSR_IITSEL_MASK (hw_irq))) {writel_relaxed (iscr & ~bit, priv->base +ISCR ); +/* +* Enforce that the posted write is flushed to prevent that the +* just handled interrupt is raised again. +*/ +readl_relaxed (priv->base +ISCR ); + } }static void rzg2l_tint_eoi (struct irq_data *d)
@@ -111,8 +117,14 @@ static void rzg2l_tint_eoi(struct irq_data *d)u32 reg; reg =readl_relaxed (priv->base +TSCR ); -if (reg & bit) +if (reg & bit) {writel_relaxed (reg & ~bit, priv->base +TSCR ); +/* +* Enforce that the posted write is flushed to prevent that the +* just handled interrupt is raised again. +*/ +readl_relaxed (priv->base +TSCR ); + } }static void rzg2l_irqc_eoi (struct irq_data *d)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 263/399 irqchip/renesas-rzg2l: Rename rzg2l_tint_eoi()
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Biju Das <[email protected]>
[ Upstream commit 7cb6362c63df233172eaecddaf9ce2ce2f769112 ]
Rename rzg2l_tint_eoi()->rzg2l_clear_tint_int() and simplify the code by removing redundant priv and hw_irq local variables.
Stable-dep-of: 853a6030303f ("irqchip/renesas-rzg2l: Prevent spurious interrupts when setting trigger type")
--- drivers/irqchip/irq-renesas-rzg2l.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/irqchip/irq-renesas-rzg2l.c +3 -5
@@ -109,11 +109,9 @@ static void rzg2l_irq_eoi(struct irq_data *d) } } -static void rzg2l_tint_eoi (struct irq_data *d) +static void rzg2l_clear_tint_int (struct rzg2l_irqc_priv *priv,unsigned int hwirq) { -unsigned int hw_irq =irqd_to_hwirq (d) -IRQC_TINT_START ; -struct rzg2l_irqc_priv *priv =irq_data_to_priv (d); -u32 bit =BIT (hw_irq); +u32 bit =BIT (hwirq -IRQC_TINT_START );u32 reg; reg =readl_relaxed (priv->base +TSCR );
@@ -136,7 +134,7 @@ static void rzg2l_irqc_eoi(struct irq_data *d)if (hw_irq >=IRQC_IRQ_START && hw_irq <=IRQC_IRQ_COUNT )rzg2l_irq_eoi (d);else if (hw_irq >=IRQC_TINT_START && hw_irq <IRQC_NUM_IRQ ) -rzg2l_tint_eoi (d); +rzg2l_clear_tint_int (priv, hw_irq);raw_spin_unlock (&priv->lock);irq_chip_eoi_parent (d); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 264/399 irqchip/renesas-rzg2l: Rename rzg2l_irq_eoi()
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Biju Das <[email protected]>
[ Upstream commit b4b5cd61a6fdd92ede0dc39f0850a182affd1323 ]
Rename rzg2l_irq_eoi()->rzg2l_clear_irq_int() and simplify the code by removing redundant priv local variable.
Stable-dep-of: 853a6030303f ("irqchip/renesas-rzg2l: Prevent spurious interrupts when setting trigger type")
--- drivers/irqchip/irq-renesas-rzg2l.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/irqchip/irq-renesas-rzg2l.c +3 -4
@@ -85,10 +85,9 @@ static struct rzg2l_irqc_priv *irq_data_to_priv(struct irq_data *data)return data->domain->host_data; } -static void rzg2l_irq_eoi (struct irq_data *d) +static void rzg2l_clear_irq_int (struct rzg2l_irqc_priv *priv,unsigned int hwirq) { -unsigned int hw_irq =irqd_to_hwirq (d) -IRQC_IRQ_START ; -struct rzg2l_irqc_priv *priv =irq_data_to_priv (d); +unsigned int hw_irq = hwirq -IRQC_IRQ_START ;u32 bit =BIT (hw_irq);u32 iitsr, iscr;
@@ -132,7 +131,7 @@ static void rzg2l_irqc_eoi(struct irq_data *d)raw_spin_lock (&priv->lock);if (hw_irq >=IRQC_IRQ_START && hw_irq <=IRQC_IRQ_COUNT ) -rzg2l_irq_eoi (d); +rzg2l_clear_irq_int (priv, hw_irq);else if (hw_irq >=IRQC_TINT_START && hw_irq <IRQC_NUM_IRQ )rzg2l_clear_tint_int (priv, hw_irq);raw_spin_unlock (&priv->lock);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 265/399 irqchip/renesas-rzg2l: Prevent spurious interrupts when setting trigger type
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Biju Das <[email protected]>
[ Upstream commit 853a6030303f8a8fa54929b68e5665d9b21aa405 ]
RZ/G2L interrupt chips require that the interrupt is masked before changing the NMI, IRQ, TINT interrupt settings. Aside of that, after setting an edge trigger type it is required to clear the interrupt status register in order to avoid spurious interrupts.
The current implementation fails to do either of that and therefore is prone to generate spurious interrupts when setting the trigger type.
Address this by:
- Ensuring that the interrupt is masked at the chip level across the update for the TINT chip
- Clearing the interrupt status register after updating the trigger mode for edge type interrupts
[ tglx: Massaged changelog and reverted the spin_lock_irqsave() change as
the set_type() callback is always called with interrupts disabled. ]
--- drivers/irqchip/irq-renesas-rzg2l.c | 36 +++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-)
drivers/irqchip/irq-renesas-rzg2l.c +32 -4
@@ -181,8 +181,10 @@ static void rzg2l_irqc_irq_enable(struct irq_data *d)static int rzg2l_irq_set_type (struct irq_data *d,unsigned int type) { -unsigned int hw_irq =irqd_to_hwirq (d) -IRQC_IRQ_START ;struct rzg2l_irqc_priv *priv =irq_data_to_priv (d); +unsigned int hwirq =irqd_to_hwirq (d); +u32 iitseln = hwirq -IRQC_IRQ_START ; +bool clear_irq_int = false;u16 sense, tmp;switch (type &IRQ_TYPE_SENSE_MASK ) {
@@ -192,14 +194,17 @@ static int rzg2l_irq_set_type(struct irq_data *d, unsigned int type)case IRQ_TYPE_EDGE_FALLING : sense =IITSR_IITSEL_EDGE_FALLING ; + clear_irq_int = true;break ;case IRQ_TYPE_EDGE_RISING : sense =IITSR_IITSEL_EDGE_RISING ; + clear_irq_int = true;break ;case IRQ_TYPE_EDGE_BOTH : sense =IITSR_IITSEL_EDGE_BOTH ; + clear_irq_int = true;break ;default :
@@ -208,21 +213,40 @@ static int rzg2l_irq_set_type(struct irq_data *d, unsigned int type)raw_spin_lock (&priv->lock); tmp =readl_relaxed (priv->base +IITSR ); - tmp &= ~IITSR_IITSEL_MASK (hw_irq); - tmp |=IITSR_IITSEL (hw_irq, sense); + tmp &= ~IITSR_IITSEL_MASK (iitseln); + tmp |=IITSR_IITSEL (iitseln, sense); +if (clear_irq_int) +rzg2l_clear_irq_int (priv, hwirq);writel_relaxed (tmp, priv->base +IITSR );raw_spin_unlock (&priv->lock);return 0 ; } +static u32 rzg2l_disable_tint_and_set_tint_source (struct irq_data *d,struct rzg2l_irqc_priv *priv, +u32 reg,u32 tssr_offset,u8 tssr_index) +{ +u32 tint = (u32 )(uintptr_t )irq_data_get_irq_chip_data (d); +u32 tien = reg & (TIEN <<TSSEL_SHIFT (tssr_offset)); + +/* Clear the relevant byte in reg */ + reg &= ~(TSSEL_MASK <<TSSEL_SHIFT (tssr_offset)); +/* Set TINT and leave TIEN clear */ + reg |= tint <<TSSEL_SHIFT (tssr_offset); +writel_relaxed (reg, priv->base +TSSR (tssr_index)); + +return reg | tien; +} +static int rzg2l_tint_set_edge (struct irq_data *d,unsigned int type) {struct rzg2l_irqc_priv *priv =irq_data_to_priv (d);unsigned int hwirq =irqd_to_hwirq (d);u32 titseln = hwirq -IRQC_TINT_START ; +u32 tssr_offset =TSSR_OFFSET (titseln); +u8 tssr_index =TSSR_INDEX (titseln);u8 index, sense; -u32 reg; +u32 reg, tssr;switch (type &IRQ_TYPE_SENSE_MASK ) {case IRQ_TYPE_EDGE_RISING :
@@ -244,10 +268,14 @@ static int rzg2l_tint_set_edge(struct irq_data *d, unsigned int type) }raw_spin_lock (&priv->lock); + tssr =readl_relaxed (priv->base +TSSR (tssr_index)); + tssr =rzg2l_disable_tint_and_set_tint_source (d, priv, tssr, tssr_offset, tssr_index); reg =readl_relaxed (priv->base +TITSR (index)); reg &= ~(IRQ_MASK << (titseln *TITSEL_WIDTH )); reg |= sense << (titseln *TITSEL_WIDTH );writel_relaxed (reg, priv->base +TITSR (index)); +rzg2l_clear_tint_int (priv, hwirq); +writel_relaxed (tssr, priv->base +TSSR (tssr_index));raw_spin_unlock (&priv->lock);return 0 ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 266/399 kprobes/x86: Use copy_from_kernel_nofault() to read from unsafe address
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Masami Hiramatsu (Google) <[email protected]>
[ Upstream commit 4e51653d5d871f40f1bd5cf95cc7f2d8b33d063b ]
Read from an unsafe address with copy_from_kernel_nofault() in arch_adjust_kprobe_addr() because this function is used before checking the address is in text or not. Syzcaller bot found a bug and reported the case if user specifies inaccessible data area, arch_adjust_kprobe_addr() will cause a kernel panic.
[ mingo: Clarified the comment. ]
--- arch/x86/kernel/kprobes/core.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
arch/x86/kernel/kprobes/core.c +10 -1
@@ -335,7 +335,16 @@ static int can_probe(unsigned long paddr)kprobe_opcode_t *arch_adjust_kprobe_addr (unsigned long addr,unsigned long offset,bool *on_func_entry) { -if (is_endbr (*(u32 *)addr)) { +u32 insn; + +/* +* Since 'addr' is not guaranteed to be safe to access, use +* copy_from_kernel_nofault() to read the instruction: +*/ +if (copy_from_kernel_nofault (&insn, (void *)addr,sizeof (u32))) +return NULL ; + +if (is_endbr (insn)) { *on_func_entry = !offset || offset ==4 ;if (*on_func_entry) offset =4 ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 267/399 efi/libstub: fix efi_random_alloc() to allocate memory at alloc_min or higher address
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: KONDO KAZUMA(近藤 和真) <[email protected]>
[ Upstream commit 3cb4a4827596abc82e55b80364f509d0fefc3051 ]
Following warning is sometimes observed while booting my servers:
[ 3.594838] DMA: preallocated 4096 KiB GFP_KERNEL pool for atomic allocations [ 3.602918] swapper/0: page allocation failure: order:10, mode:0xcc1(GFP_KERNEL|GFP_DMA), nodemask=(null),cpuset=/,mems_allowed=0-1 ... [ 3.851862] DMA: preallocated 1024 KiB GFP_KERNEL|GFP_DMA pool for atomic allocation
If 'nokaslr' boot option is set, the warning always happens.
On x86, ZONE_DMA is small zone at the first 16MB of physical address space. When this problem happens, most of that space seems to be used by decompressed kernel. Thereby, there is not enough space at DMA_ZONE to meet the request of DMA pool allocation.
The commit 2f77465b05b1 ("x86/efistub: Avoid placing the kernel below LOAD_PHYSICAL_ADDR") tried to fix this problem by introducing lower bound of allocation.
But the fix is not complete.
efi_random_alloc() allocates pages by following steps.
1. Count total available slots ('total_slots')
2. Select a slot ('target_slot') to allocate randomly
3. Calculate a starting address ('target') to be included target_slot
4. Allocate pages, which starting address is 'target'
In step 1, 'alloc_min' is used to offset the starting address of memory chunk. But in step 3 'alloc_min' is not considered at all. As the result, 'target' can be miscalculated and become lower than 'alloc_min'.
When KASLR is disabled, 'target_slot' is always 0 and the problem happens everytime if the EFI memory map of the system meets the condition.
Fix this problem by calculating 'target' considering 'alloc_min'.
--- drivers/firmware/efi/libstub/randomalloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/firmware/efi/libstub/randomalloc.c +1 -1
@@ -120,7 +120,7 @@ efi_status_t efi_random_alloc(unsigned long size,continue ; } - target =round_up (md->phys_addr, align) + target_slot * align; + target =round_up (max (md->phys_addr, alloc_min), align) + target_slot * align; pages = size /EFI_PAGE_SIZE ; status = efi_bs_call(allocate_pages, EFI_ALLOCATE_ADDRESS,
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 268/399 x86/mpparse: Register APIC address only once
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Gleixner <[email protected]>
[ Upstream commit f2208aa12c27bfada3c15c550c03ca81d42dcac2 ]
The APIC address is registered twice. First during the early detection and afterwards when actually scanning the table for APIC IDs. The APIC and topology core warn about the second attempt.
Restrict it to the early detection call.
--- arch/x86/kernel/mpparse.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
arch/x86/kernel/mpparse.c +5 -5
@@ -196,12 +196,12 @@ static int __init smp_read_mpc(struct mpc_table *mpc, unsigned early)if (!smp_check_mpc (mpc, oem, str))return 0 ; -/* Initialize the lapic mapping */ -if (!acpi_lapic) -register_lapic_address (mpc->lapic); - -if (early) +if (early) { +/* Initialize the lapic mapping */ +if (!acpi_lapic) +register_lapic_address (mpc->lapic);return 1 ; + }/* Now process the configuration blocks. */ while (count < mpc->length) {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 269/399 x86/fpu: Keep xfd_state in sync with MSR_IA32_XFD
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Adamos Ttofari <[email protected]>
[ Upstream commit 10e4b5166df9ff7a2d5316138ca668b42d004422 ]
Commit 672365477ae8 ("x86/fpu: Update XFD state where required") and commit 8bf26758ca96 ("x86/fpu: Add XFD state to fpstate") introduced a per CPU variable xfd_state to keep the MSR_IA32_XFD value cached, in order to avoid unnecessary writes to the MSR.
On CPU hotplug MSR_IA32_XFD is reset to the init_fpstate.xfd, which wipes out any stale state. But the per CPU cached xfd value is not reset, which brings them out of sync.
As a consequence a subsequent xfd_update_state() might fail to update the MSR which in turn can result in XRSTOR raising a #NM in kernel space, which crashes the kernel.
To fix this, introduce xfd_set_state() to write xfd_state together with MSR_IA32_XFD, and use it in all places that set MSR_IA32_XFD.
--- arch/x86/kernel/fpu/xstate.c | 5 +++-- arch/x86/kernel/fpu/xstate.h | 14 ++++++++++---- 2 files changed, 13 insertions(+), 6 deletions(-)
arch/x86/kernel/fpu/xstate.c +3 -2
@@ -178,10 +178,11 @@ void fpu__init_cpu_xstate(void)* Must happen after CR4 setup and before xsetbv() to allow KVM * lazy passthrough. Write independent of the dynamic state static * key as that does not work on the boot CPU. This also ensures -* that any stale state is wiped out from XFD. +* that any stale state is wiped out from XFD. Reset the per CPU +* xfd cache too. */ if (cpu_feature_enabled (X86_FEATURE_XFD )) -wrmsrl (MSR_IA32_XFD , init_fpstate.xfd); +xfd_set_state (init_fpstate.xfd);/* * XCR_XFEATURE_ENABLED_MASK (aka. XCR0) sets user features
arch/x86/kernel/fpu/xstate.h +10 -4
@@ -148,20 +148,26 @@ static inline void xfd_validate_state(struct fpstate *fpstate, u64 mask, bool rs#endif #ifdef CONFIG_X86_64 +static inline void xfd_set_state (u64 xfd) +{ +wrmsrl (MSR_IA32_XFD , xfd); +__this_cpu_write (xfd_state, xfd); +} +static inline void xfd_update_state (struct fpstate *fpstate) {if (fpu_state_size_dynamic ()) {u64 xfd = fpstate->xfd; -if (__this_cpu_read (xfd_state) != xfd) { -wrmsrl (MSR_IA32_XFD , xfd); -__this_cpu_write (xfd_state, xfd); - } +if (__this_cpu_read (xfd_state) != xfd) +xfd_set_state (xfd); } }extern int __xfd_enable_feature (u64 which,struct fpu_guest *guest_fpu);#else +static inline void xfd_set_state (u64 xfd) { } +static inline void xfd_update_state (struct fpstate *fpstate) { }static inline int __xfd_enable_feature (u64 which,struct fpu_guest *guest_fpu) {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 270/399 efi: fix panic in kdump kernel
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Oleksandr Tymoshenko <[email protected]>
[ Upstream commit 62b71cd73d41ddac6b1760402bbe8c4932e23531 ]
Check if get_next_variable() is actually valid pointer before calling it. In kdump kernel this method is set to NULL that causes panic during the kexec-ed kernel boot.
Tested with QEMU and OVMF firmware.
--- drivers/firmware/efi/efi.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/firmware/efi/efi.c +2 -0
@@ -203,6 +203,8 @@ static bool generic_ops_supported(void) name_size =sizeof (name); +if (!efi.get_next_variable) +return false; status = efi.get_next_variable (&name_size, &name, &guid);if (status ==EFI_UNSUPPORTED )return false;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 271/399 pwm: img: fix pwm clock lookup
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zoltan HERPAI <[email protected]>
[ Upstream commit 9eb05877dbee03064d3d3483cd6702f610d5a358 ]
22e8e19 has introduced a regression in the imgchip->pwm_clk lookup, whereas the clock name has also been renamed to "imgchip". This causes the driver failing to load:
[ 0.546905] img-pwm 18101300.pwm: failed to get imgchip clock [ 0.553418] img-pwm: probe of 18101300.pwm failed with error -2
Fix this lookup by reverting the clock name back to "pwm".
--- drivers/pwm/pwm-img.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/pwm/pwm-img.c +2 -2
@@ -284,9 +284,9 @@ static int img_pwm_probe(struct platform_device *pdev)return PTR_ERR (imgchip->sys_clk); } - imgchip->pwm_clk =devm_clk_get (&pdev->dev,"imgchip" ); + imgchip->pwm_clk =devm_clk_get (&pdev->dev,"pwm" );if (IS_ERR (imgchip->pwm_clk)) { -dev_err (&pdev->dev,"failed to get imgchip clock\n" ); +dev_err (&pdev->dev,"failed to get pwm clock\n" );return PTR_ERR (imgchip->pwm_clk); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 272/399 selftests/mm: Fix build with _FORTIFY_SOURCE
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vitaly Chikunov <[email protected]>
[ Upstream commit 8b65ef5ad4862904e476a8f3d4e4418c950ddb90 ]
Add missing flags argument to open(2) call with O_CREAT.
Some tests fail to compile if _FORTIFY_SOURCE is defined (to any valid value) (together with -O), resulting in similar error messages such as:
In file included from /usr/include/fcntl.h:342,
from gup_test.c:1:
In function 'open',
inlined from 'main' at gup_test.c:206:10:
/usr/include/bits/fcntl2.h:50:11: error: call to '__open_missing_mode' declared with attribute error: open with O_CREAT or O_TMPFILE in second argument needs 3 arguments
50 | __open_missing_mode ();
| ^~~~~~~~~~~~~~~~~~~~~~_FORTIFY_SOURCE is enabled by default in some distributions, so the tests are not built by default and are skipped.
open(2) man-page warns about missing flags argument: "if it is not supplied, some arbitrary bytes from the stack will be applied as the file mode."
--- tools/testing/selftests/mm/gup_test.c | 2 +- tools/testing/selftests/mm/soft-dirty.c | 2 +- tools/testing/selftests/mm/split_huge_page_test.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
tools/testing/selftests/mm/gup_test.c +1 -1
@@ -203,7 +203,7 @@ int main(int argc, char **argv)ksft_print_header ();ksft_set_plan (nthreads); - filed =open (file,O_RDWR |O_CREAT ); + filed =open (file,O_RDWR |O_CREAT ,0664 );if (filed <0 )ksft_exit_fail_msg ("Unable to open %s: %s\n" , file,strerror (errno));
tools/testing/selftests/mm/soft-dirty.c +1 -1
@@ -137,7 +137,7 @@ static void test_mprotect(int pagemap_fd, int pagesize, bool anon)if (!map)ksft_exit_fail_msg ("anon mmap failed\n" ); }else { - test_fd =open (fname,O_RDWR |O_CREAT ); + test_fd =open (fname,O_RDWR |O_CREAT ,0664 );if (test_fd <0 ) {ksft_test_result_skip ("Test %s open() file failed\n" , __func__);return ;
tools/testing/selftests/mm/split_huge_page_test.c +1 -1
@@ -253,7 +253,7 @@ void split_file_backed_thp(void) goto cleanup; } - fd =open (testfile,O_CREAT |O_WRONLY ); + fd =open (testfile,O_CREAT |O_WRONLY ,0664 );if (fd ==-1 ) {perror ("Cannot open testing file\n" ); goto cleanup;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 273/399 btrfs: handle errors returned from unpin_extent_cache()
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Sterba <[email protected]>
[ Upstream commit c03c89f821e51325d0e592cf625cf5e0a26fa3a7 ]
We've had numerous attempts to let function unpin_extent_cache() return void as it only returns 0. There are still error cases to handle so do that, in addition to the verbose messages. The only caller btrfs_finish_one_ordered() will now abort the transaction, previously it let it continue which could lead to further problems.
Stable-dep-of: 4dc1d69c2b10 ("btrfs: fix warning messages not printing interval at unpin_extent_range()")
--- fs/btrfs/extent_map.c | 10 +++++++++- fs/btrfs/inode.c | 9 +++++++-- 2 files changed, 16 insertions(+), 3 deletions(-)
fs/btrfs/extent_map.c +9 -1
@@ -291,6 +291,10 @@ static void try_merge_map(struct extent_map_tree *tree, struct extent_map *em)* Called after an extent has been written to disk properly. Set the generation * to the generation that actually added the file item to the inode so we know * we need to sync this extent when we call fsync(). +* +* Returns: 0 on success +* -ENOENT when the extent is not found in the tree +* -EUCLEAN if the found extent does not match the expected start */ int unpin_extent_cache (struct btrfs_inode *inode,u64 start,u64 len,u64 gen) {
@@ -308,14 +312,18 @@ int unpin_extent_cache(struct btrfs_inode *inode, u64 start, u64 len, u64 gen)"no extent map found for inode %llu (root %lld) when unpinning extent range [%llu, %llu), generation %llu" ,btrfs_ino (inode),btrfs_root_id (inode->root), start, len, gen); + ret = -ENOENT ; goto out; } -if (WARN_ON (em->start != start)) +if (WARN_ON (em->start != start)) {btrfs_warn (fs_info,"found extent map for inode %llu (root %lld) with unexpected start offset %llu when unpinning extent range [%llu, %llu), generation %llu" ,btrfs_ino (inode),btrfs_root_id (inode->root), em->start, start, len, gen); + ret = -EUCLEAN ; + goto out; + } em->generation = gen; em->flags &= ~EXTENT_FLAG_PINNED ;
fs/btrfs/inode.c +7 -2
@@ -3127,8 +3127,13 @@ int btrfs_finish_one_ordered(struct btrfs_ordered_extent *ordered_extent) ordered_extent->disk_num_bytes); } } -unpin_extent_cache (inode, ordered_extent->file_offset, - ordered_extent->num_bytes, trans->transid); +if (ret <0 ) { +btrfs_abort_transaction (trans, ret); + goto out; + } + + ret =unpin_extent_cache (inode, ordered_extent->file_offset, + ordered_extent->num_bytes, trans->transid);if (ret <0 ) {btrfs_abort_transaction (trans, ret); goto out;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 274/399 btrfs: fix warning messages not printing interval at unpin_extent_range()
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Filipe Manana <[email protected]>
[ Upstream commit 4dc1d69c2b101eee0bf071187794ffed2f9c2596 ]
At unpin_extent_range() we print warning messages that are supposed to print an interval in the form "[X, Y)", with the first element being an inclusive start offset and the second element being the exclusive end offset of a range. However we end up printing the range's length instead of the range's exclusive end offset, so fix that to avoid having confusing and non-sense messages in case we hit one of these unexpected scenarios.
--- fs/btrfs/extent_map.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/btrfs/extent_map.c +2 -2
@@ -311,7 +311,7 @@ int unpin_extent_cache(struct btrfs_inode *inode, u64 start, u64 len, u64 gen)btrfs_warn (fs_info,"no extent map found for inode %llu (root %lld) when unpinning extent range [%llu, %llu), generation %llu" ,btrfs_ino (inode),btrfs_root_id (inode->root), - start, len, gen); + start, start + len, gen); ret = -ENOENT ; goto out; }
@@ -320,7 +320,7 @@ int unpin_extent_cache(struct btrfs_inode *inode, u64 start, u64 len, u64 gen)btrfs_warn (fs_info,"found extent map for inode %llu (root %lld) with unexpected start offset %llu when unpinning extent range [%llu, %llu), generation %llu" ,btrfs_ino (inode),btrfs_root_id (inode->root), - em->start, start, len, gen); + em->start, start, start + len, gen); ret = -EUCLEAN ; goto out; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 275/399 btrfs: do not skip re-registration for the mounted device
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Anand Jain <[email protected]>
commit d565fffa68560ac540bf3d62cc79719da50d5e7a upstream.
There are reports that since version 6.7 update-grub fails to find the device of the root on systems without initrd and on a single device.
This looks like the device name changed in the output of /proc/self/mountinfo:
6.5-rc5 working
18 1 0:16 / / rw,noatime - btrfs /dev/sda8 ...
6.7 not working:
17 1 0:15 / / rw,noatime - btrfs /dev/root ...
and "update-grub" shows this error:
/usr/sbin/grub-probe: error: cannot find a device for / (is /dev mounted?)
This looks like it's related to the device name, but grub-probe recognizes the "/dev/root" path and tries to find the underlying device. However there's a special case for some filesystems, for btrfs in particular.
The generic root device detection heuristic is not done and it all relies on reading the device infos by a btrfs specific ioctl. This ioctl returns the device name as it was saved at the time of device scan (in this case it's /dev/root).
The change in 6.7 for temp_fsid to allow several single device filesystem to exist with the same fsid (and transparently generate a new UUID at mount time) was to skip caching/registering such devices.
This also skipped mounted device. One step of scanning is to check if the device name hasn't changed, and if yes then update the cached value.
This broke the grub-probe as it always read the device /dev/root and couldn't find it in the system. A temporary workaround is to create a symlink but this does not survive reboot.
The right fix is to allow updating the device path of a mounted filesystem even if this is a single device one.
In the fix, check if the device's major:minor number matches with the cached device. If they do, then we can allow the scan to happen so that device_list_add() can take care of updating the device path. The file descriptor remains unchanged.
This does not affect the temp_fsid feature, the UUID of the mounted filesystem remains the same and the matching is based on device major:minor which is unique per mounted filesystem.
This covers the path when the device (that exists for all mounted devices) name changes, updating /dev/root to /dev/sdx. Any other single device with filesystem and is not mounted is still skipped.
Note that if a system is booted and initial mount is done on the /dev/root device, this will be the cached name of the device. Only after the command "btrfs device scan" it will change as it triggers the rename.
The fix was verified by users whose systems were affected.
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=218353
--- fs/btrfs/volumes.c | 57 +++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 47 insertions(+), 10 deletions(-)
fs/btrfs/volumes.c +47 -10
@@ -1301,6 +1301,47 @@ int btrfs_forget_devices(dev_t devt)return ret; } +static bool btrfs_skip_registration (struct btrfs_super_block *disk_super, +const char *path,dev_t devt, +bool mount_arg_dev) +{ +struct btrfs_fs_devices *fs_devices; + +/* +* Do not skip device registration for mounted devices with matching +* maj:min but different paths. Booting without initrd relies on +* /dev/root initially, later replaced with the actual root device. +* A successful scan ensures grub2-probe selects the correct device. +*/ +list_for_each_entry (fs_devices, &fs_uuids, fs_list) { +struct btrfs_device *device; + +mutex_lock (&fs_devices->device_list_mutex); + +if (!fs_devices->opened) { +mutex_unlock (&fs_devices->device_list_mutex); +continue ; + } + +list_for_each_entry (device, &fs_devices->devices, dev_list) { +if (device->bdev && (device->bdev->bd_dev == devt) && +strcmp (device->name->str, path) !=0 ) { +mutex_unlock (&fs_devices->device_list_mutex); + +/* Do not skip registration. */ +return false; + } + } +mutex_unlock (&fs_devices->device_list_mutex); + } + +if (!mount_arg_dev &&btrfs_super_num_devices (disk_super) ==1 && + !(btrfs_super_flags (disk_super) &BTRFS_SUPER_FLAG_SEEDING )) +return true; + +return false; +} +/* * Look for a btrfs signature on a device. This may be called out of the mount path * and we are not allowed to call set_blocksize during the scan. The superblock
@@ -1357,18 +1398,14 @@ struct btrfs_device *btrfs_scan_one_devi goto error_bdev_put; } -if (!mount_arg_dev &&btrfs_super_num_devices (disk_super) ==1 && - !(btrfs_super_flags (disk_super) &BTRFS_SUPER_FLAG_SEEDING )) { -dev_t devt; +if (btrfs_skip_registration (disk_super, path, bdev_handle->bdev->bd_dev, + mount_arg_dev)) { +pr_debug ("BTRFS: skip registering single non-seed device %s (%d:%d)\n" , + path,MAJOR (bdev_handle->bdev->bd_dev), +MINOR (bdev_handle->bdev->bd_dev)); - ret =lookup_bdev (path, &devt); -if (ret) -btrfs_warn (NULL ,"lookup bdev failed for path %s: %d" , - path, ret); -else -btrfs_free_stale_devices (devt,NULL ); +btrfs_free_stale_devices (bdev_handle->bdev->bd_dev,NULL ); -pr_debug ("BTRFS: skip registering single non-seed device %s\n" , path); device =NULL ; goto free_disk_super; }
Greg Kroah-Hartman
maintainerPATCH 276/399 mfd: intel-lpss: Switch to generalized quirk table
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aleksandrs Vinarskis <[email protected]>
commit ac9538f6007e1c80f1b8a62db7ecc391b4d78ae5 upstream.
Introduce generic quirk table, and port existing walkaround for select Microsoft devices to it. This is a preparation for QUIRK_CLOCK_DIVIDER_UNITY.
--- drivers/mfd/intel-lpss-pci.c | 23 +++++++++++++++-------- drivers/mfd/intel-lpss.c | 2 +- drivers/mfd/intel-lpss.h | 9 ++++++++- 3 files changed, 24 insertions(+), 10 deletions(-)
drivers/mfd/intel-lpss-pci.c +15 -8
@@ -23,12 +23,17 @@#include "intel-lpss.h" -/* Some DSDTs have an unused GEXP ACPI device conflicting with I2C4 resources */ -static const struct pci_device_id ignore_resource_conflicts_ids[] = { -/* Microsoft Surface Go (version 1) I2C4 */ - {PCI_DEVICE_SUB (PCI_VENDOR_ID_INTEL ,0x9d64 ,0x152d ,0x1182 ), }, -/* Microsoft Surface Go 2 I2C4 */ - {PCI_DEVICE_SUB (PCI_VENDOR_ID_INTEL ,0x9d64 ,0x152d ,0x1237 ), }, +static const struct pci_device_id quirk_ids[] = { + { +/* Microsoft Surface Go (version 1) I2C4 */ +PCI_DEVICE_SUB (PCI_VENDOR_ID_INTEL ,0x9d64 ,0x152d ,0x1182 ), + .driver_data =QUIRK_IGNORE_RESOURCE_CONFLICTS , + }, + { +/* Microsoft Surface Go 2 I2C4 */ +PCI_DEVICE_SUB (PCI_VENDOR_ID_INTEL ,0x9d64 ,0x152d ,0x1237 ), + .driver_data =QUIRK_IGNORE_RESOURCE_CONFLICTS , + }, { } };
@@ -36,6 +41,7 @@ static int intel_lpss_pci_probe(struct p const struct pci_device_id *id) {const struct intel_lpss_platform_info *data = (void *)id->driver_data; +const struct pci_device_id *quirk_pci_info;struct intel_lpss_platform_info *info;int ret;
@@ -55,8 +61,9 @@ static int intel_lpss_pci_probe(struct p info->mem =pci_resource_n (pdev,0 ); info->irq =pci_irq_vector (pdev,0 ); -if (pci_match_id (ignore_resource_conflicts_ids, pdev)) - info->ignore_resource_conflicts = true; + quirk_pci_info =pci_match_id (quirk_ids, pdev); +if (quirk_pci_info) + info->quirks = quirk_pci_info->driver_data; pdev->d3cold_delay =0 ;
drivers/mfd/intel-lpss.c +1 -1
@@ -412,7 +412,7 @@ int intel_lpss_probe(struct device *dev,return ret; lpss->cell->swnode = info->swnode; - lpss->cell->ignore_resource_conflicts = info->ignore_resource_conflicts; + lpss->cell->ignore_resource_conflicts = info->quirks &QUIRK_IGNORE_RESOURCE_CONFLICTS ;intel_lpss_init_dev (lpss);
drivers/mfd/intel-lpss.h +8 -1
@@ -11,16 +11,23 @@ #ifndef __MFD_INTEL_LPSS_H #define __MFD_INTEL_LPSS_H +#include <linux/bits.h> #include <linux/pm.h> +/* + * Some DSDTs have an unused GEXP ACPI device conflicting with I2C4 resources. + * Set to ignore resource conflicts with ACPI declared SystemMemory regions. + */ +#define QUIRK_IGNORE_RESOURCE_CONFLICTS BIT(0) + struct device; struct resource; struct software_node; struct intel_lpss_platform_info { struct resource *mem; - bool ignore_resource_conflicts; int irq; + unsigned int quirks; unsigned long clk_rate; const char *clk_con_id; const struct software_node *swnode;
Greg Kroah-Hartman
maintainerPATCH 277/399 mfd: intel-lpss: Introduce QUIRK_CLOCK_DIVIDER_UNITY for XPS 9530
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aleksandrs Vinarskis <[email protected]>
commit 1d8c51ed2ddcc4161e6496cf14fcd83921c50ec8 upstream.
Some devices (eg. Dell XPS 9530, 2023) due to a firmware bug have a misconfigured clock divider, which should've been 1:1. This introduces quirk which conditionally re-configures the clock divider to 1:1.
--- drivers/mfd/intel-lpss-pci.c | 5 +++++ drivers/mfd/intel-lpss.c | 7 +++++++ drivers/mfd/intel-lpss.h | 5 +++++ 3 files changed, 17 insertions(+)
drivers/mfd/intel-lpss-pci.c +5 -0
@@ -34,6 +34,11 @@ static const struct pci_device_id quirk_ PCI_DEVICE_SUB(PCI_VENDOR_ID_INTEL, 0x9d64, 0x152d, 0x1237), .driver_data = QUIRK_IGNORE_RESOURCE_CONFLICTS, }, + { +/* Dell XPS 9530 (2023) */ + PCI_DEVICE_SUB(PCI_VENDOR_ID_INTEL, 0x51fb, 0x1028, 0x0beb), + .driver_data = QUIRK_CLOCK_DIVIDER_UNITY, + }, { } };
drivers/mfd/intel-lpss.c +7 -0
@@ -300,6 +300,7 @@ static int intel_lpss_register_clock_div {char name[32 ];struct clk *tmp = *clk; +int ret;snprintf (name,sizeof (name),"%s-enable" , devname); tmp = clk_register_gate(NULL, name, __clk_get_name(tmp), 0,
@@ -316,6 +317,12 @@ static int intel_lpss_register_clock_divreturn PTR_ERR (tmp); *clk = tmp; +if (lpss->info->quirks &QUIRK_CLOCK_DIVIDER_UNITY ) { + ret =clk_set_rate (tmp, lpss->info->clk_rate); +if (ret) +return ret; + } +snprintf (name,sizeof (name),"%s-update" , devname); tmp =clk_register_gate (NULL , name,__clk_get_name (tmp),CLK_SET_RATE_PARENT , lpss->priv,31 ,0 ,NULL );
drivers/mfd/intel-lpss.h +5 -0
@@ -19,6 +19,11 @@* Set to ignore resource conflicts with ACPI declared SystemMemory regions. */ #define QUIRK_IGNORE_RESOURCE_CONFLICTS BIT(0) +/* +* Some devices have misconfigured clock divider due to a firmware bug. +* Set this to force the clock divider to 1:1 ratio. +*/ +#define QUIRK_CLOCK_DIVIDER_UNITY BIT(1)struct device ;struct resource ;
Greg Kroah-Hartman
maintainerPATCH 278/399 drm/i915: Replace a memset() with zero initialization
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ville Syrjälä <[email protected]>
commit 92b47c3b8b242a1f1b73d5c1181d5b678ac1382b upstream.
Declaring a struct and immediately zeroing it with memset() seems a bit silly to me. Just zero initialize the struct when declaring it.
--- drivers/gpu/drm/i915/display/intel_dpll_mgr.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/gpu/drm/i915/display/intel_dpll_mgr.c +1 -3
@@ -4465,12 +4465,10 @@ verify_single_dpll_state(struct drm_i915struct intel_crtc *crtc, const struct intel_crtc_state *new_crtc_state) { - struct intel_dpll_hw_state dpll_hw_state; + struct intel_dpll_hw_state dpll_hw_state = {};u8 pipe_mask;bool active; -memset (&dpll_hw_state,0 ,sizeof (dpll_hw_state)); -drm_dbg_kms (&i915->drm,"%s\n" , pll->info->name); active =intel_dpll_get_hw_state (i915, pll, &dpll_hw_state);
Greg Kroah-Hartman
maintainerPATCH 279/399 drm/i915: Try to preserve the current shared_dpll for fastset on type-c ports
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ville Syrjälä <[email protected]>
commit ba407525f8247ee4c270369f3371b9994c27bfda upstream.
Currently icl_compute_tc_phy_dplls() assumes that the active PLL will be the TC PLL (as opposed to the TBT PLL). The actual PLL will be selected during the modeset enable sequence, but we need to put *something* into the crtc_state->shared_dpll already during compute_config().
The downside of assuming one PLL or the other is that we'll fail to fastset if the assumption doesn't match what was in use previously. So let's instead keep the same PLL that was in use previously (assuming there was one). This should allow fastset to work again when using TBT PLL, at least in the steady state.
Now, assuming we want keep the same PLL may not be entirely correct either. But we should be covered by the type-c link reset handling which will force a full modeset by flagging connectors_changed=true which means the resulting modeset can't be converted into a fastset even if the full crtc state looks identical.
--- drivers/gpu/drm/i915/display/intel_dpll_mgr.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/display/intel_dpll_mgr.c +7 -1
@@ -3308,6 +3308,8 @@ static int icl_compute_tc_phy_dplls(strustruct drm_i915_private *i915 =to_i915 (state->base.dev);struct intel_crtc_state *crtc_state =intel_atomic_get_new_crtc_state (state, crtc); +const struct intel_crtc_state *old_crtc_state = +intel_atomic_get_old_crtc_state (state, crtc);struct icl_port_dpll *port_dpll = &crtc_state->icl_port_dplls[ICL_PORT_DPLL_DEFAULT ];struct skl_wrpll_params pll_params = {};
@@ -3326,7 +3328,11 @@ static int icl_compute_tc_phy_dplls(strureturn ret;/* this is mainly for the fastset check */ -icl_set_active_port_dpll (crtc_state,ICL_PORT_DPLL_MG_PHY ); +if (old_crtc_state->shared_dpll && + old_crtc_state->shared_dpll->info->id ==DPLL_ID_ICL_TBTPLL ) +icl_set_active_port_dpll (crtc_state,ICL_PORT_DPLL_DEFAULT ); +else +icl_set_active_port_dpll (crtc_state,ICL_PORT_DPLL_MG_PHY ); crtc_state->port_clock =icl_ddi_mg_pll_get_freq (i915,NULL , &port_dpll->hw_state);
Greg Kroah-Hartman
maintainerPATCH 280/399 drm/i915: Include the PLL name in the debug messages
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ville Syrjälä <[email protected]>
commit d283ee5662c6bf2f3771a36b926f6988e6dddfc6 upstream.
Make the log easier to parse by including the name of the PLL in the debug prints regarding said PLL.
--- drivers/gpu/drm/i915/display/intel_dpll_mgr.c | 39 +++++++++++++------------- 1 file changed, 20 insertions(+), 19 deletions(-)
drivers/gpu/drm/i915/display/intel_dpll_mgr.c +20 -19
@@ -4475,25 +4475,25 @@ verify_single_dpll_state(struct drm_i915u8 pipe_mask;bool active; -drm_dbg_kms (&i915->drm,"%s\n" , pll->info->name); - active =intel_dpll_get_hw_state (i915, pll, &dpll_hw_state);if (!(pll->info->flags &INTEL_DPLL_ALWAYS_ON )) {I915_STATE_WARN (i915, !pll->on && pll->active_mask, -"pll in active use but not on in sw tracking\n" ); +"%s: pll in active use but not on in sw tracking\n" , + pll->info->name);I915_STATE_WARN (i915, pll->on && !pll->active_mask, -"pll is on but not used by any active pipe\n" ); +"%s: pll is on but not used by any active pipe\n" , + pll->info->name);I915_STATE_WARN (i915, pll->on != active, -"pll on state mismatch (expected %i, found %i)\n" , - pll->on, active); +"%s: pll on state mismatch (expected %i, found %i)\n" , + pll->info->name, pll->on, active); }if (!crtc) {I915_STATE_WARN (i915, pll->active_mask & ~pll->state.pipe_mask, -"more active pll users than references: 0x%x vs 0x%x\n" , - pll->active_mask, pll->state.pipe_mask); +"%s: more active pll users than references: 0x%x vs 0x%x\n" , + pll->info->name, pll->active_mask, pll->state.pipe_mask);return ; }
@@ -4502,21 +4502,22 @@ verify_single_dpll_state(struct drm_i915if (new_crtc_state->hw.active)I915_STATE_WARN (i915, !(pll->active_mask & pipe_mask), -"pll active mismatch (expected pipe %c in active mask 0x%x)\n" , -pipe_name (crtc->pipe), pll->active_mask); +"%s: pll active mismatch (expected pipe %c in active mask 0x%x)\n" , + pll->info->name,pipe_name (crtc->pipe), pll->active_mask);else I915_STATE_WARN (i915, pll->active_mask & pipe_mask, -"pll active mismatch (didn't expect pipe %c in active mask 0x%x)\n" , -pipe_name (crtc->pipe), pll->active_mask); +"%s: pll active mismatch (didn't expect pipe %c in active mask 0x%x)\n" , + pll->info->name,pipe_name (crtc->pipe), pll->active_mask);I915_STATE_WARN (i915, !(pll->state.pipe_mask & pipe_mask), -"pll enabled crtcs mismatch (expected 0x%x in 0x%x)\n" , - pipe_mask, pll->state.pipe_mask); +"%s: pll enabled crtcs mismatch (expected 0x%x in 0x%x)\n" , + pll->info->name, pipe_mask, pll->state.pipe_mask);I915_STATE_WARN (i915, pll->on &&memcmp (&pll->state.hw_state, &dpll_hw_state,sizeof (dpll_hw_state)), -"pll hw state mismatch\n" ); +"%s: pll hw state mismatch\n" , + pll->info->name); } void intel_shared_dpll_state_verify(struct intel_atomic_state *state,
@@ -4538,11 +4539,11 @@ void intel_shared_dpll_state_verify(strustruct intel_shared_dpll *pll = old_crtc_state->shared_dpll;I915_STATE_WARN (i915, pll->active_mask & pipe_mask, -"pll active mismatch (didn't expect pipe %c in active mask (0x%x))\n" , -pipe_name (crtc->pipe), pll->active_mask); +"%s: pll active mismatch (didn't expect pipe %c in active mask (0x%x))\n" , + pll->info->name,pipe_name (crtc->pipe), pll->active_mask);I915_STATE_WARN (i915, pll->state.pipe_mask & pipe_mask, -"pll enabled crtcs mismatch (found pipe %c in enabled mask (0x%x))\n" , -pipe_name (crtc->pipe), pll->state.pipe_mask); +"%s: pll enabled crtcs mismatch (found pipe %c in enabled mask (0x%x))\n" , + pll->info->name,pipe_name (crtc->pipe), pll->state.pipe_mask); } }
Greg Kroah-Hartman
maintainerPATCH 281/399 drm/i915: Suppress old PLL pipe_mask checks for MG/TC/TBT PLLs
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ville Syrjälä <[email protected]>
commit 33c7760226c79ee8de6c0646640963a8a7ee794a upstream.
TC ports have both the MG/TC and TBT PLLs selected simultanously (so that we can switch from MG/TC to TBT as a fallback). This doesn't play well with the state checker that assumes that the old PLL shouldn't have the pipe in its pipe_mask anymore. Suppress that check for these PLLs to avoid spurious WARNs when you disconnect a TC port and a non-disabling modeset happens before actually disabling the port.
v2: Only suppress when one of the PLLs is the TBT PLL and the
other one is not
--- drivers/gpu/drm/i915/display/intel_dpll_mgr.c | 23 +++++++++++++++++++---- drivers/gpu/drm/i915/display/intel_dpll_mgr.h | 4 ++++ 2 files changed, 23 insertions(+), 4 deletions(-)
drivers/gpu/drm/i915/display/intel_dpll_mgr.c +19 -4
@@ -4029,7 +4029,8 @@ static const struct intel_shared_dpll_fustatic const struct dpll_info icl_plls[] = { { .name ="DPLL 0" , .funcs = &combo_pll_funcs, .id =DPLL_ID_ICL_DPLL0 , }, { .name ="DPLL 1" , .funcs = &combo_pll_funcs, .id =DPLL_ID_ICL_DPLL1 , }, - { .name ="TBT PLL" , .funcs = &tbt_pll_funcs, .id =DPLL_ID_ICL_TBTPLL , }, + { .name ="TBT PLL" , .funcs = &tbt_pll_funcs, .id =DPLL_ID_ICL_TBTPLL , + .flags =INTEL_DPLL_IS_ALT_PORT_DPLL , }, { .name ="MG PLL 1" , .funcs = &mg_pll_funcs, .id =DPLL_ID_ICL_MGPLL1 , }, { .name ="MG PLL 2" , .funcs = &mg_pll_funcs, .id =DPLL_ID_ICL_MGPLL2 , }, { .name ="MG PLL 3" , .funcs = &mg_pll_funcs, .id =DPLL_ID_ICL_MGPLL3 , },
@@ -4074,7 +4075,8 @@ static const struct intel_shared_dpll_fustatic const struct dpll_info tgl_plls[] = { { .name ="DPLL 0" , .funcs = &combo_pll_funcs, .id =DPLL_ID_ICL_DPLL0 , }, { .name ="DPLL 1" , .funcs = &combo_pll_funcs, .id =DPLL_ID_ICL_DPLL1 , }, - { .name ="TBT PLL" , .funcs = &tbt_pll_funcs, .id =DPLL_ID_ICL_TBTPLL , }, + { .name ="TBT PLL" , .funcs = &tbt_pll_funcs, .id =DPLL_ID_ICL_TBTPLL , + .flags =INTEL_DPLL_IS_ALT_PORT_DPLL , }, { .name ="TC PLL 1" , .funcs = &dkl_pll_funcs, .id =DPLL_ID_ICL_MGPLL1 , }, { .name ="TC PLL 2" , .funcs = &dkl_pll_funcs, .id =DPLL_ID_ICL_MGPLL2 , }, { .name ="TC PLL 3" , .funcs = &dkl_pll_funcs, .id =DPLL_ID_ICL_MGPLL3 , },
@@ -4147,7 +4149,8 @@ static const struct intel_dpll_mgr adls_static const struct dpll_info adlp_plls[] = { { .name ="DPLL 0" , .funcs = &combo_pll_funcs, .id =DPLL_ID_ICL_DPLL0 , }, { .name ="DPLL 1" , .funcs = &combo_pll_funcs, .id =DPLL_ID_ICL_DPLL1 , }, - { .name ="TBT PLL" , .funcs = &tbt_pll_funcs, .id =DPLL_ID_ICL_TBTPLL , }, + { .name ="TBT PLL" , .funcs = &tbt_pll_funcs, .id =DPLL_ID_ICL_TBTPLL , + .flags =INTEL_DPLL_IS_ALT_PORT_DPLL , }, { .name ="TC PLL 1" , .funcs = &dkl_pll_funcs, .id =DPLL_ID_ICL_MGPLL1 , }, { .name ="TC PLL 2" , .funcs = &dkl_pll_funcs, .id =DPLL_ID_ICL_MGPLL2 , }, { .name ="TC PLL 3" , .funcs = &dkl_pll_funcs, .id =DPLL_ID_ICL_MGPLL3 , },
@@ -4520,6 +4523,14 @@ verify_single_dpll_state(struct drm_i915 pll->info->name); } +static bool has_alt_port_dpll (const struct intel_shared_dpll *old_pll, +const struct intel_shared_dpll *new_pll) +{ +return old_pll && new_pll && old_pll != new_pll && + (old_pll->info->flags &INTEL_DPLL_IS_ALT_PORT_DPLL || + new_pll->info->flags &INTEL_DPLL_IS_ALT_PORT_DPLL ); +} +void intel_shared_dpll_state_verify (struct intel_atomic_state *state,struct intel_crtc *crtc) {
@@ -4541,7 +4552,11 @@ void intel_shared_dpll_state_verify(struI915_STATE_WARN (i915, pll->active_mask & pipe_mask,"%s: pll active mismatch (didn't expect pipe %c in active mask (0x%x))\n" , pll->info->name,pipe_name (crtc->pipe), pll->active_mask); -I915_STATE_WARN (i915, pll->state.pipe_mask & pipe_mask, + +/* TC ports have both MG/TC and TBT PLL referenced simultaneously */ +I915_STATE_WARN (i915, !has_alt_port_dpll (old_crtc_state->shared_dpll, + new_crtc_state->shared_dpll) && + pll->state.pipe_mask & pipe_mask,"%s: pll enabled crtcs mismatch (found pipe %c in enabled mask (0x%x))\n" , pll->info->name,pipe_name (crtc->pipe), pll->state.pipe_mask); }
drivers/gpu/drm/i915/display/intel_dpll_mgr.h +4 -0
@@ -277,12 +277,16 @@ struct dpll_info {enum intel_display_power_domain power_domain;#define INTEL_DPLL_ALWAYS_ON (1 << 0) +#define INTEL_DPLL_IS_ALT_PORT_DPLL (1 << 1)/** * @flags: * * INTEL_DPLL_ALWAYS_ON * Inform the state checker that the DPLL is kept enabled even if * not in use by any CRTC. +* INTEL_DPLL_IS_ALT_PORT_DPLL +* Inform the state checker that the DPLL can be used as a fallback +* (for TC->TBT fallback). */ u32 flags; };
Greg Kroah-Hartman
maintainerPATCH 282/399 crypto: iaa - Fix nr_cpus < nr_iaa case
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tom Zanussi <[email protected]>
commit 5a7e89d3315d1be86aff8a8bf849023cda6547f7 upstream.
If nr_cpus < nr_iaa, the calculated cpus_per_iaa will be 0, which causes a divide-by-0 in rebalance_wq_table().
Make sure cpus_per_iaa is 1 in that case, and also in the nr_iaa == 0 case, even though cpus_per_iaa is never used if nr_iaa == 0, for paranoia.
--- drivers/crypto/intel/iaa/iaa_crypto_main.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/crypto/intel/iaa/iaa_crypto_main.c +7 -3
@@ -908,6 +908,8 @@ static int save_iaa_wq(struct idxd_wq *wreturn -EINVAL ; cpus_per_iaa = (nr_nodes * nr_cpus_per_node) / nr_iaa; +if (!cpus_per_iaa) + cpus_per_iaa =1 ; out:return 0 ; }
@@ -923,10 +925,12 @@ static void remove_iaa_wq(struct idxd_wq } } -if (nr_iaa) +if (nr_iaa) { cpus_per_iaa = (nr_nodes * nr_cpus_per_node) / nr_iaa; -else - cpus_per_iaa =0 ; +if (!cpus_per_iaa) + cpus_per_iaa =1 ; + }else + cpus_per_iaa =1 ; }static int wq_table_add_wqs (int iaa,int cpu)
Greg Kroah-Hartman
maintainerPATCH 283/399 drm/amd/display: Prevent crash when disable stream
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chris Park <[email protected]>
commit 72d72e8fddbcd6c98e1b02d32cf6f2b04e10bd1c upstream.
[Why]
Disabling stream encoder invokes a function that no longer exists.
[How]
Check if the function declaration is NULL in disable stream encoder.
--- drivers/gpu/drm/amd/display/dc/hwss/dce110/dce110_hwseq.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/hwss/dce110/dce110_hwseq.c +2 -1
@@ -1185,7 +1185,8 @@ void dce110_disable_stream(struct pipe_cif (dccg) { dccg->funcs->disable_symclk32_se (dccg, dp_hpo_inst); dccg->funcs->set_dpstreamclk (dccg,REFCLK , tg->inst, dp_hpo_inst); - dccg->funcs->set_dtbclk_dto (dccg, &dto_params); +if (dccg && dccg->funcs->set_dtbclk_dto) + dccg->funcs->set_dtbclk_dto (dccg, &dto_params); } }else if (dccg && dccg->funcs->disable_symclk_se) { dccg->funcs->disable_symclk_se(dccg, stream_enc->stream_enc_inst,
Greg Kroah-Hartman
maintainerPATCH 284/399 ALSA: hda/tas2781: remove digital gain kcontrol
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gergo Koteles <[email protected]>
commit ae065d0ce9e36ca4efdfb9b96ce3395bd1c19372 upstream.
The "Speaker Digital Gain" kcontrol controls the TAS2781_DVC_LVL (0x1A) register. Unfortunately the tas2563 does not have DVC_LVL, but has INT_MASK0 in 0x1A, which has been misused so far.
Since commit c1947ce61ff4 ("ALSA: hda/realtek: tas2781: enable subwoofer volume control") the volume of the tas2781 amplifiers can be controlled by the master volume, so this digital gain kcontrol is not needed.
Remove it.
Message-ID: <741fc21db994efd58f83e7aef38931204961e5b2.1711469583.git.soyer@irl.hu>
--- sound/pci/hda/tas2781_hda_i2c.c | 37 +------------------------------------ 1 file changed, 1 insertion(+), 36 deletions(-)
sound/pci/hda/tas2781_hda_i2c.c +1 -36
@@ -89,7 +89,7 @@ struct tas2781_hda {struct snd_kcontrol *dsp_prog_ctl;struct snd_kcontrol *dsp_conf_ctl;struct snd_kcontrol *prof_ctl; -struct snd_kcontrol *snd_ctls[3 ]; +struct snd_kcontrol *snd_ctls[2 ]; };static int tas2781_get_i2c_res (struct acpi_resource *ares,void *data)
@@ -306,27 +306,6 @@ static int tasdevice_config_put(struct sreturn ret; } -/* -* tas2781_digital_getvol - get the volum control -* @kcontrol: control pointer -* @ucontrol: User data -* Customer Kcontrol for tas2781 is primarily for regmap booking, paging -* depends on internal regmap mechanism. -* tas2781 contains book and page two-level register map, especially -* book switching will set the register BXXP00R7F, after switching to the -* correct book, then leverage the mechanism for paging to access the -* register. -*/ -static int tas2781_digital_getvol (struct snd_kcontrol *kcontrol, -struct snd_ctl_elem_value *ucontrol) -{ -struct tasdevice_priv *tas_priv =snd_kcontrol_chip (kcontrol); -struct soc_mixer_control *mc = - (struct soc_mixer_control *)kcontrol->private_value; - -return tasdevice_digital_getvol (tas_priv, ucontrol, mc); -} -static int tas2781_amp_getvol (struct snd_kcontrol *kcontrol,struct snd_ctl_elem_value *ucontrol) {
@@ -337,17 +316,6 @@ static int tas2781_amp_getvol(struct sndreturn tasdevice_amp_getvol (tas_priv, ucontrol, mc); } -static int tas2781_digital_putvol (struct snd_kcontrol *kcontrol, -struct snd_ctl_elem_value *ucontrol) -{ -struct tasdevice_priv *tas_priv =snd_kcontrol_chip (kcontrol); -struct soc_mixer_control *mc = - (struct soc_mixer_control *)kcontrol->private_value; - -/* The check of the given value is in tasdevice_digital_putvol. */ -return tasdevice_digital_putvol (tas_priv, ucontrol, mc); -} -static int tas2781_amp_putvol (struct snd_kcontrol *kcontrol,struct snd_ctl_elem_value *ucontrol) {
@@ -393,9 +361,6 @@ static const struct snd_kcontrol_new tasACARD_SINGLE_RANGE_EXT_TLV ("Speaker Analog Gain" ,TAS2781_AMP_LEVEL ,1 ,0 ,20 ,0 , tas2781_amp_getvol, tas2781_amp_putvol, amp_vol_tlv), -ACARD_SINGLE_RANGE_EXT_TLV ("Speaker Digital Gain" ,TAS2781_DVC_LVL , -0 ,0 ,200 ,1 , tas2781_digital_getvol, - tas2781_digital_putvol, dvc_tlv),ACARD_SINGLE_BOOL_EXT ("Speaker Force Firmware Load" ,0 , tas2781_force_fwload_get, tas2781_force_fwload_put), };
Greg Kroah-Hartman
maintainerPATCH 285/399 ALSA: hda/tas2781: add locks to kcontrols
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gergo Koteles <[email protected]>
commit 15bc3066d2378eef1b45254be9df23b0dd7f1667 upstream.
The rcabin.profile_cfg_id, cur_prog, cur_conf, force_fwload_status variables are acccessible from multiple threads and therefore require locking.
Message-ID: <e35b867f6fe5fa1f869dd658a0a1f2118b737f57.1711469583.git.soyer@irl.hu>
--- sound/pci/hda/tas2781_hda_i2c.c | 50 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 2 deletions(-)
sound/pci/hda/tas2781_hda_i2c.c +48 -2
@@ -197,8 +197,12 @@ static int tasdevice_get_profile_id(stru {struct tasdevice_priv *tas_priv =snd_kcontrol_chip (kcontrol); +mutex_lock (&tas_priv->codec_lock); + ucontrol->value.integer.value[0 ] = tas_priv->rcabin.profile_cfg_id; +mutex_unlock (&tas_priv->codec_lock); +return 0 ; }
@@ -212,11 +216,15 @@ static int tasdevice_set_profile_id(stru val =clamp (nr_profile,0 , max); +mutex_lock (&tas_priv->codec_lock); +if (tas_priv->rcabin.profile_cfg_id != val) { tas_priv->rcabin.profile_cfg_id = val; ret =1 ; } +mutex_unlock (&tas_priv->codec_lock); +return ret; }
@@ -253,8 +261,12 @@ static int tasdevice_program_get(struct {struct tasdevice_priv *tas_priv =snd_kcontrol_chip (kcontrol); +mutex_lock (&tas_priv->codec_lock); + ucontrol->value.integer.value[0 ] = tas_priv->cur_prog; +mutex_unlock (&tas_priv->codec_lock); +return 0 ; }
@@ -269,11 +281,15 @@ static int tasdevice_program_put(struct val =clamp (nr_program,0 , max); +mutex_lock (&tas_priv->codec_lock); +if (tas_priv->cur_prog != val) { tas_priv->cur_prog = val; ret =1 ; } +mutex_unlock (&tas_priv->codec_lock); +return ret; }
@@ -282,8 +298,12 @@ static int tasdevice_config_get(struct s {struct tasdevice_priv *tas_priv =snd_kcontrol_chip (kcontrol); +mutex_lock (&tas_priv->codec_lock); + ucontrol->value.integer.value[0 ] = tas_priv->cur_conf; +mutex_unlock (&tas_priv->codec_lock); +return 0 ; }
@@ -298,11 +318,15 @@ static int tasdevice_config_put(struct s val =clamp (nr_config,0 , max); +mutex_lock (&tas_priv->codec_lock); +if (tas_priv->cur_conf != val) { tas_priv->cur_conf = val; ret =1 ; } +mutex_unlock (&tas_priv->codec_lock); +return ret; }
@@ -312,8 +336,15 @@ static int tas2781_amp_getvol(struct sndstruct tasdevice_priv *tas_priv =snd_kcontrol_chip (kcontrol);struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; +int ret; -return tasdevice_amp_getvol (tas_priv, ucontrol, mc); +mutex_lock (&tas_priv->codec_lock); + + ret =tasdevice_amp_getvol (tas_priv, ucontrol, mc); + +mutex_unlock (&tas_priv->codec_lock); + +return ret; } static int tas2781_amp_putvol(struct snd_kcontrol *kcontrol,
@@ -322,9 +353,16 @@ static int tas2781_amp_putvol(struct sndstruct tasdevice_priv *tas_priv =snd_kcontrol_chip (kcontrol);struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; +int ret; + +mutex_lock (&tas_priv->codec_lock);/* The check of the given value is in tasdevice_amp_putvol. */ -return tasdevice_amp_putvol (tas_priv, ucontrol, mc); + ret =tasdevice_amp_putvol (tas_priv, ucontrol, mc); + +mutex_unlock (&tas_priv->codec_lock); + +return ret; } static int tas2781_force_fwload_get(struct snd_kcontrol *kcontrol,
@@ -332,10 +370,14 @@ static int tas2781_force_fwload_get(stru {struct tasdevice_priv *tas_priv =snd_kcontrol_chip (kcontrol); +mutex_lock (&tas_priv->codec_lock); + ucontrol->value.integer.value[0 ] = (int )tas_priv->force_fwload_status;dev_dbg (tas_priv->dev,"%s : Force FWload %s\n" , __func__, tas_priv->force_fwload_status ?"ON" :"OFF" ); +mutex_unlock (&tas_priv->codec_lock); +return 0 ; }
@@ -345,6 +387,8 @@ static int tas2781_force_fwload_put(strustruct tasdevice_priv *tas_priv =snd_kcontrol_chip (kcontrol);bool change, val = (bool )ucontrol->value.integer.value[0 ]; +mutex_lock (&tas_priv->codec_lock); +if (tas_priv->force_fwload_status == val) change = false;else {
@@ -354,6 +398,8 @@ static int tas2781_force_fwload_put(strudev_dbg (tas_priv->dev,"%s : Force FWload %s\n" , __func__, tas_priv->force_fwload_status ?"ON" :"OFF" ); +mutex_unlock (&tas_priv->codec_lock); +return change; }
Greg Kroah-Hartman
maintainerPATCH 286/399 mm: zswap: fix writeback shinker GFP_NOIO/GFP_NOFS recursion
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Weiner <[email protected]>
commit 30fb6a8d9e3378919f378f9bf561142b4a6d2637 upstream.
Kent forwards this bug report of zswap re-entering the block layer from an IO request allocation and locking up:
[10264.128242] sysrq: Show Blocked State [10264.128268] task:kworker/20:0H state:D stack:0 pid:143 tgid:143 ppid:2 flags:0x00004000 [10264.128271] Workqueue: bcachefs_io btree_write_submit [bcachefs] [10264.128295] Call Trace: [10264.128295] <TASK> [10264.128297] __schedule+0x3e6/0x1520 [10264.128303] schedule+0x32/0xd0 [10264.128304] schedule_timeout+0x98/0x160 [10264.128308] io_schedule_timeout+0x50/0x80 [10264.128309] wait_for_completion_io_timeout+0x7f/0x180 [10264.128310] submit_bio_wait+0x78/0xb0 [10264.128313] swap_writepage_bdev_sync+0xf6/0x150 [10264.128317] zswap_writeback_entry+0xf2/0x180 [10264.128319] shrink_memcg_cb+0xe7/0x2f0 [10264.128322] __list_lru_walk_one+0xb9/0x1d0 [10264.128325] list_lru_walk_one+0x5d/0x90 [10264.128326] zswap_shrinker_scan+0xc4/0x130 [10264.128327] do_shrink_slab+0x13f/0x360 [10264.128328] shrink_slab+0x28e/0x3c0 [10264.128329] shrink_one+0x123/0x1b0 [10264.128331] shrink_node+0x97e/0xbc0 [10264.128332] do_try_to_free_pages+0xe7/0x5b0 [10264.128333] try_to_free_pages+0xe1/0x200 [10264.128334] __alloc_pages_slowpath.constprop.0+0x343/0xde0 [10264.128337] __alloc_pages+0x32d/0x350 [10264.128338] allocate_slab+0x400/0x460 [10264.128339] ___slab_alloc+0x40d/0xa40 [10264.128345] kmem_cache_alloc+0x2e7/0x330 [10264.128348] mempool_alloc+0x86/0x1b0 [10264.128349] bio_alloc_bioset+0x200/0x4f0 [10264.128352] bio_alloc_clone+0x23/0x60 [10264.128354] alloc_io+0x26/0xf0 [dm_mod 7e9e6b44df4927f93fb3e4b5c782767396f58382] [10264.128361] dm_submit_bio+0xb8/0x580 [dm_mod 7e9e6b44df4927f93fb3e4b5c782767396f58382] [10264.128366] __submit_bio+0xb0/0x170 [10264.128367] submit_bio_noacct_nocheck+0x159/0x370 [10264.128368] bch2_submit_wbio_replicas+0x21c/0x3a0 [bcachefs 85f1b9a7a824f272eff794653a06dde1a94439f2] [10264.128391] btree_write_submit+0x1cf/0x220 [bcachefs 85f1b9a7a824f272eff794653a06dde1a94439f2] [10264.128406] process_one_work+0x178/0x350 [10264.128408] worker_thread+0x30f/0x450 [10264.128409] kthread+0xe5/0x120
The zswap shrinker resumes the swap_writepage()s that were intercepted by the zswap store. This will enter the block layer, and may even enter the filesystem depending on the swap backing file.
Make it respect GFP_NOIO and GFP_NOFS.
--- mm/zswap.c | 8 ++++++++ 1 file changed, 8 insertions(+)
mm/zswap.c +8 -0
@@ -645,6 +645,14 @@ static unsigned long zswap_shrinker_counif (!zswap_shrinker_enabled || !mem_cgroup_zswap_writeback_enabled (memcg))return 0 ; +/* +* The shrinker resumes swap writeback, which will enter block +* and may enter fs. XXX: Harmonize with vmscan.c __GFP_FS +* rules (may_enter_fs()), which apply on a per-folio basis. +*/ +if (!gfp_has_io_fs (sc->gfp_mask)) +return 0 ; +#ifdef CONFIG_MEMCG_KMEM mem_cgroup_flush_stats (memcg); nr_backing =memcg_page_state (memcg,MEMCG_ZSWAP_B ) >>PAGE_SHIFT ;
Greg Kroah-Hartman
maintainerPATCH 287/399 init: open /initrd.image with O_LARGEFILE
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: John Sperbeck <[email protected]>
commit 4624b346cf67400ef46a31771011fb798dd2f999 upstream.
If initrd data is larger than 2Gb, we'll eventually fail to write to the /initrd.image file when we hit that limit, unless O_LARGEFILE is set.
--- init/initramfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
init/initramfs.c +1 -1
@@ -683,7 +683,7 @@ static void __init populate_initrd_imageprintk (KERN_INFO "rootfs image is not initramfs (%s); looks like an initrd\n" , err); - file =filp_open ("/initrd.image" ,O_WRONLY |O_CREAT ,0700 ); + file =filp_open ("/initrd.image" ,O_WRONLY |O_CREAT |O_LARGEFILE ,0700 );if (IS_ERR (file))return ;
Greg Kroah-Hartman
maintainerPATCH 288/399 x86/efistub: Add missing boot_params for mixed mode compat entry
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ard Biesheuvel <[email protected]>
commit d21f5a59ea773826cc489acb287811d690b703cc upstream.
The pure EFI stub entry point does not take a struct boot_params from the boot loader, but creates it from scratch, and populates only the fields that still have meaning in this context (command line, initrd base and size, etc)
The original mixed mode implementation used the EFI handover protocol instead, where the boot loader (i.e., GRUB) populates a boot_params struct and passes it to a special Linux specific EFI entry point that takes the boot_params pointer as its third argument.
When the new mixed mode implementation was introduced, using a special 32-bit PE entrypoint in the 64-bit kernel, it adopted the pure approach, and relied on the EFI stub to create the struct boot_params. This is preferred because it makes the bootloader side much easier to implement, as it does not need any x86-specific knowledge on how struct boot_params and struct setup_header are put together. This mixed mode implementation was adopted by systemd-boot version 252 and later.
When commit
e2ab9eab324c ("x86/boot/compressed: Move 32-bit entrypoint code into .text section")
refactored this code and moved it out of head_64.S, the fact that ESI was populated with the address of the base of the image was overlooked, and to simplify the code flow, ESI is now zeroed and stored to memory unconditionally in shared code, so that the NULL-ness of that variable can still be used later to determine which mixed mode boot protocol is in use.
With ESI pointing to the base of the image, it can serve as a struct boot_params pointer for startup_32(), which only accesses the init_data and kernel_alignment fields (and the scratch field as a temporary stack). Zeroing ESI means that those accesses produce garbage now, even though things appear to work if the first page of memory happens to be zeroed, and the region right before LOAD_PHYSICAL_ADDR (== 16 MiB) happens to be free.
The solution is to pass a special, temporary struct boot_params to startup_32() via ESI, one that is sufficient for getting it to create the page tables correctly and is discarded right after. This involves setting a minimal alignment of 4k, only to get the statically allocated page tables line up correctly, and setting init_size to the executable image size (_end - startup_32). This ensures that the page tables are covered by the static footprint of the PE image.
Given that EFI boot no longer calls the decompressor and no longer pads the image to permit the decompressor to execute in place, the same temporary struct boot_params should be used in the EFI handover protocol based mixed mode implementation as well, to prevent the page tables from being placed outside of allocated memory.
--- arch/x86/boot/compressed/efi_mixed.S | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-)
arch/x86/boot/compressed/efi_mixed.S +15 -5
@@ -15,10 +15,12 @@ */ #include <linux/linkage.h> +#include <asm/asm-offsets.h> #include <asm/msr.h> #include <asm/page_types.h> #include <asm/processor-flags.h> #include <asm/segment.h> +#include <asm/setup.h> .code64 .text
@@ -149,6 +151,7 @@ SYM_FUNC_END(__efi64_thunk) SYM_FUNC_START(efi32_stub_entry) call 1f 1: popl %ecx + leal (efi32_boot_args - 1b)(%ecx), %ebx /* Clear BSS */ xorl %eax, %eax
@@ -163,6 +166,7 @@ SYM_FUNC_START(efi32_stub_entry) popl %ecx popl %edx popl %esi + movl %esi, 8(%ebx) jmp efi32_entry SYM_FUNC_END(efi32_stub_entry) #endif
@@ -239,8 +243,6 @@ SYM_FUNC_END(efi_enter32) * * Arguments: %ecx image handle * %edx EFI system table pointer - * %esi struct bootparams pointer (or NULL when not using - * the EFI handover protocol) * * Since this is the point of no return for ordinary execution, no registers * are considered live except for the function parameters. [Note that the EFI
@@ -266,9 +268,18 @@ SYM_FUNC_START_LOCAL(efi32_entry) leal (efi32_boot_args - 1b)(%ebx), %ebx movl %ecx, 0(%ebx) movl %edx, 4(%ebx) - movl %esi, 8(%ebx) movb $0x0, 12(%ebx) // efi_is64 + /* + * Allocate some memory for a temporary struct boot_params, which only + * needs the minimal pieces that startup_32() relies on. + */ + subl $PARAM_SIZE, %esp + movl %esp, %esi + movl $PAGE_SIZE, BP_kernel_alignment(%esi) + movl $_end - 1b, BP_init_size(%esi) + subl $startup_32 - 1b, BP_init_size(%esi) + /* Disable paging */ movl %cr0, %eax btrl $X86_CR0_PG_BIT, %eax
@@ -294,8 +305,7 @@ SYM_FUNC_START(efi32_pe_entry) movl 8(%ebp), %ecx // image_handle movl 12(%ebp), %edx // sys_table - xorl %esi, %esi - jmp efi32_entry // pass %ecx, %edx, %esi + jmp efi32_entry // pass %ecx, %edx // no other registers remain live 2: popl %edi // restore callee-save registers
Greg Kroah-Hartman
maintainerPATCH 289/399 efi/libstub: Cast away type warning in use of max()
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ard Biesheuvel <[email protected]>
commit 61d130f261a3c15ae2c4b6f3ac3517d5d5b78855 upstream.
Avoid a type mismatch warning in max() by switching to max_t() and providing the type explicitly.
--- drivers/firmware/efi/libstub/randomalloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/firmware/efi/libstub/randomalloc.c +1 -1
@@ -120,7 +120,7 @@ efi_status_t efi_random_alloc(unsigned lcontinue ; } - target =round_up (max (md->phys_addr, alloc_min), align) + target_slot * align; + target =round_up (max_t (u64, md->phys_addr, alloc_min), align) + target_slot * align; pages = size /EFI_PAGE_SIZE ; status = efi_bs_call(allocate_pages, EFI_ALLOCATE_ADDRESS,
Greg Kroah-Hartman
maintainerPATCH 290/399 x86/efistub: Reinstate soft limit for initrd loading
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ard Biesheuvel <[email protected]>
commit decd347c2a75d32984beb8807d470b763a53b542 upstream.
Commit
8117961d98fb2 ("x86/efi: Disregard setup header of loaded image")
dropped the memcopy of the image's setup header into the boot_params struct provided to the core kernel, on the basis that EFI boot does not need it and should rely only on a single protocol to interface with the boot chain. It is also a prerequisite for being able to increase the section alignment to 4k, which is needed to enable memory protections when running in the boot services.
So only the setup_header fields that matter to the core kernel are populated explicitly, and everything else is ignored. One thing was overlooked, though: the initrd_addr_max field in the setup_header is not used by the core kernel, but it is used by the EFI stub itself when it loads the initrd, where its default value of INT_MAX is used as the soft limit for memory allocation.
This means that, in the old situation, the initrd was virtually always loaded in the lower 2G of memory, but now, due to initrd_addr_max being 0x0, the initrd may end up anywhere in memory. This should not be an issue principle, as most systems can deal with this fine. However, it does appear to tickle some problems in older UEFI implementations, where the memory ends up being corrupted, resulting in errors when unpacking the initramfs.
So set the initrd_addr_max field to INT_MAX like it was before.
--- drivers/firmware/efi/libstub/x86-stub.c | 1 + 1 file changed, 1 insertion(+)
drivers/firmware/efi/libstub/x86-stub.c +1 -0
@@ -487,6 +487,7 @@ efi_status_t __efiapi efi_pe_entry(efi_h hdr->vid_mode =0xffff ; hdr->type_of_loader =0x21 ; + hdr->initrd_addr_max =INT_MAX ;/* Convert unicode cmdline to ascii */ cmdline_ptr =efi_convert_cmdline (image, &options_size);
Greg Kroah-Hartman
maintainerPATCH 291/399 prctl: generalize PR_SET_MDWE support check to be per-arch
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zev Weiss <[email protected]>
commit d5aad4c2ca057e760a92a9a7d65bd38d72963f27 upstream.
Patch series "ARM: prctl: Reject PR_SET_MDWE where not supported".
I noticed after a recent kernel update that my ARM926 system started segfaulting on any execve() after calling prctl(PR_SET_MDWE). After some investigation it appears that ARMv5 is incapable of providing the appropriate protections for MDWE, since any readable memory is also implicitly executable.
The prctl_set_mdwe() function already had some special-case logic added disabling it on PARISC (commit 793838138c15, "prctl: Disable prctl(PR_SET_MDWE) on parisc"); this patch series (1) generalizes that check to use an arch_*() function, and (2) adds a corresponding override for ARM to disable MDWE on pre-ARMv6 CPUs.
With the series applied, prctl(PR_SET_MDWE) is rejected on ARMv5 and subsequent execve() calls (as well as mmap(PROT_READ|PROT_WRITE)) can succeed instead of unconditionally failing; on ARMv6 the prctl works as it did previously.
[0] https://lore.kernel.org/all/2023112456-linked-nape-bf19@gregkh/
This patch (of 2):
There exist systems other than PARISC where MDWE may not be feasible to support; rather than cluttering up the generic code with additional arch-specific logic let's add a generic function for checking MDWE support and allow each arch to override it as needed.
--- arch/parisc/include/asm/mman.h | 14 ++++++++++++++ include/linux/mman.h | 8 ++++++++ kernel/sys.c | 7 +++++-- 3 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 arch/parisc/include/asm/mman.h
arch/parisc/include/asm/mman.h new file +14 -0
@@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __ASM_MMAN_H__ +#define __ASM_MMAN_H__ + +#include <uapi/asm/mman.h> + +/* PARISC cannot allow mdwe as it needs writable stacks */ +static inline bool arch_memory_deny_write_exec_supported (void ) +{ +return false; +} +#define arch_memory_deny_write_exec_supported arch_memory_deny_write_exec_supported + +#endif /* __ASM_MMAN_H__ */
include/linux/mman.h +8 -0
@@ -162,6 +162,14 @@ calc_vm_flag_bits(unsigned long flags)unsigned long vm_commit_limit (void ); +#ifndef arch_memory_deny_write_exec_supported +static inline bool arch_memory_deny_write_exec_supported (void ) +{ +return true; +} +#define arch_memory_deny_write_exec_supported arch_memory_deny_write_exec_supported +#endif +/* * Denies creating a writable executable mapping or gaining executable permissions. *
kernel/sys.c +5 -2
@@ -2408,8 +2408,11 @@ static inline int prctl_set_mdwe(unsigneif (bits &PR_MDWE_NO_INHERIT && !(bits &PR_MDWE_REFUSE_EXEC_GAIN ))return -EINVAL ; -/* PARISC cannot allow mdwe as it needs writable stacks */ -if (IS_ENABLED (CONFIG_PARISC )) +/* +* EOPNOTSUPP might be more appropriate here in principle, but +* existing userspace depends on EINVAL specifically. +*/ +if (!arch_memory_deny_write_exec_supported ())return -EINVAL ; current_bits =get_current_mdwe ();
Greg Kroah-Hartman
maintainerPATCH 292/399 ARM: prctl: reject PR_SET_MDWE on pre-ARMv6
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zev Weiss <[email protected]>
commit 166ce846dc5974a266f6c2a2896dbef5425a6f21 upstream.
On v5 and lower CPUs we can't provide MDWE protection, so ensure we fail any attempt to enable it via prctl(PR_SET_MDWE).
Previously such an attempt would misleadingly succeed, leading to any subsequent mmap(PROT_READ|PROT_WRITE) or execve() failing unconditionally (the latter somewhat violently via force_fatal_sig(SIGSEGV) due to READ_IMPLIES_EXEC).
--- arch/arm/include/asm/mman.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 arch/arm/include/asm/mman.h
arch/arm/include/asm/mman.h new file +14 -0
@@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __ASM_MMAN_H__ +#define __ASM_MMAN_H__ + +#include <asm/system_info.h> +#include <uapi/asm/mman.h> + +static inline bool arch_memory_deny_write_exec_supported (void ) +{ +return cpu_architecture () >= CPU_ARCH_ARMv6; +} +#define arch_memory_deny_write_exec_supported arch_memory_deny_write_exec_supported + +#endif /* __ASM_MMAN_H__ */
Greg Kroah-Hartman
maintainerPATCH 293/399 tmpfs: fix race on handling dquot rbtree
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Carlos Maiolino <[email protected]>
commit 0a69b6b3a026543bc215ccc866d0aea5579e6ce2 upstream.
A syzkaller reproducer found a race while attempting to remove dquot information from the rb tree.
Fetching the rb_tree root node must also be protected by the dqopt->dqio_sem, otherwise, giving the right timing, shmem_release_dquot() will trigger a warning because it couldn't find a node in the tree, when the real reason was the root node changing before the search starts:
Thread 1 Thread 2
- shmem_release_dquot() - shmem_{acquire,release}_dquot()
- fetch ROOT - Fetch ROOT
- acquire dqio_sem
- wait dqio_sem
- do something, triger a tree rebalance
- release dqio_sem
- acquire dqio_sem
- start searching for the node, but
from the wrong location, missing
the node, and triggering a warning.
--- mm/shmem_quota.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
mm/shmem_quota.c +7 -3
@@ -116,7 +116,7 @@ static int shmem_free_file_info(struct sstatic int shmem_get_next_id (struct super_block *sb,struct kqid *qid) {struct mem_dqinfo *info =sb_dqinfo (sb, qid->type); -struct rb_node *node = ((struct rb_root *)info->dqi_priv)->rb_node; +struct rb_node *node;qid_t id =from_kqid (&init_user_ns, *qid);struct quota_info *dqopt =sb_dqopt (sb);struct quota_id *entry =NULL ;
@@ -126,6 +126,7 @@ static int shmem_get_next_id(struct supereturn -ESRCH ;down_read (&dqopt->dqio_sem); + node = ((struct rb_root *)info->dqi_priv)->rb_node;while (node) { entry = rb_entry(node, struct quota_id, node);
@@ -165,7 +166,7 @@ out_unlock:static int shmem_acquire_dquot (struct dquot *dquot) {struct mem_dqinfo *info =sb_dqinfo (dquot->dq_sb, dquot->dq_id.type); -struct rb_node **n = &((struct rb_root *)info->dqi_priv)->rb_node; +struct rb_node **n;struct shmem_sb_info *sbinfo = dquot->dq_sb->s_fs_info;struct rb_node *parent =NULL , *new_node =NULL ;struct quota_id *new_entry, *entry;
@@ -176,6 +177,8 @@ static int shmem_acquire_dquot(struct dqmutex_lock (&dquot->dq_lock);down_write (&dqopt->dqio_sem); + n = &((struct rb_root *)info->dqi_priv)->rb_node; +while (*n) { parent = *n; entry = rb_entry(parent, struct quota_id, node);
@@ -264,7 +267,7 @@ static bool shmem_is_empty_dquot(structstatic int shmem_release_dquot (struct dquot *dquot) {struct mem_dqinfo *info =sb_dqinfo (dquot->dq_sb, dquot->dq_id.type); -struct rb_node *node = ((struct rb_root *)info->dqi_priv)->rb_node; +struct rb_node *node;qid_t id =from_kqid (&init_user_ns, dquot->dq_id);struct quota_info *dqopt =sb_dqopt (dquot->dq_sb);struct quota_id *entry =NULL ;
@@ -275,6 +278,7 @@ static int shmem_release_dquot(struct dq goto out_dqlock;down_write (&dqopt->dqio_sem); + node = ((struct rb_root *)info->dqi_priv)->rb_node;while (node) { entry = rb_entry(node, struct quota_id, node);
Greg Kroah-Hartman
maintainerPATCH 294/399 btrfs: validate device maj:min during open
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Anand Jain <[email protected]>
commit 9f7eb8405dcbc79c5434821e9e3e92abe187ee8e upstream.
Boris managed to create a device capable of changing its maj:min without altering its device path.
Only multi-devices can be scanned. A device that gets scanned and remains in the btrfs kernel cache might end up with an incorrect maj:min.
Despite the temp-fsid feature patch did not introduce this bug, it could lead to issues if the above multi-device is converted to a single device with a stale maj:min. Subsequently, attempting to mount the same device with the correct maj:min might mistake it for another device with the same fsid, potentially resulting in wrongly auto-enabling the temp-fsid feature.
To address this, this patch validates the device's maj:min at the time of device open and updates it if it has changed since the last scan.
--- fs/btrfs/volumes.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
fs/btrfs/volumes.c +10 -0
@@ -694,6 +694,16 @@ static int btrfs_open_one_device(struct device->bdev = bdev_handle->bdev;clear_bit (BTRFS_DEV_STATE_IN_FS_METADATA , &device->dev_state); +if (device->devt != device->bdev->bd_dev) { +btrfs_warn (NULL , +"device %s maj:min changed from %d:%d to %d:%d" , + device->name->str,MAJOR (device->devt), +MINOR (device->devt),MAJOR (device->bdev->bd_dev), +MINOR (device->bdev->bd_dev)); + + device->devt = device->bdev->bd_dev; + } + fs_devices->open_devices++;if (test_bit (BTRFS_DEV_STATE_WRITEABLE , &device->dev_state) && device->devid !=BTRFS_DEV_REPLACE_DEVID ) {
Greg Kroah-Hartman
maintainerPATCH 295/399 btrfs: fix race in read_extent_buffer_pages()
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tavian Barnes <[email protected]>
commit ef1e68236b9153c27cb7cf29ead0c532870d4215 upstream.
There are reports from tree-checker that detects corrupted nodes, without any obvious pattern so possibly an overwrite in memory. After some debugging it turns out there's a race when reading an extent buffer the uptodate status can be missed.
To prevent concurrent reads for the same extent buffer, read_extent_buffer_pages() performs these checks:
/* (1) */
if (test_bit(EXTENT_BUFFER_UPTODATE, &eb->bflags))
return 0;
/* (2) */
if (test_and_set_bit(EXTENT_BUFFER_READING, &eb->bflags))
goto done;At this point, it seems safe to start the actual read operation. Once that completes, end_bbio_meta_read() does
/* (3) */
set_extent_buffer_uptodate(eb);
/* (4) */
clear_bit(EXTENT_BUFFER_READING, &eb->bflags);Normally, this is enough to ensure only one read happens, and all other callers wait for it to finish before returning. Unfortunately, there is a racey interleaving:
Thread A | Thread B | Thread C
---------+----------+---------
(1) | |
| (1) |
(2) | |
(3) | |
(4) | |
| (2) |
| | (1)When this happens, thread B kicks of an unnecessary read. Worse, thread C will see UPTODATE set and return immediately, while the read from thread B is still in progress. This race could result in tree-checker errors like this as the extent buffer is concurrently modified:
BTRFS critical (device dm-0): corrupted node, root=256
block=8550954455682405139 owner mismatch, have 11858205567642294356
expect [256, 18446744073709551360]Fix it by testing UPTODATE again after setting the READING bit, and if it's been set, skip the unnecessary read.
--- fs/btrfs/extent_io.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
fs/btrfs/extent_io.c +13 -0
@@ -4319,6 +4319,19 @@ int read_extent_buffer_pages(struct exteif (test_and_set_bit (EXTENT_BUFFER_READING , &eb->bflags)) goto done; +/* +* Between the initial test_bit(EXTENT_BUFFER_UPTODATE) and the above +* test_and_set_bit(EXTENT_BUFFER_READING), someone else could have +* started and finished reading the same eb. In this case, UPTODATE +* will now be set, and we shouldn't read it in again. +*/ +if (unlikely (test_bit (EXTENT_BUFFER_UPTODATE , &eb->bflags))) { +clear_bit (EXTENT_BUFFER_READING , &eb->bflags); +smp_mb__after_atomic (); +wake_up_bit (&eb->bflags,EXTENT_BUFFER_READING ); +return 0 ; + } +clear_bit (EXTENT_BUFFER_READ_ERR , &eb->bflags); eb->read_mirror =0 ;check_buffer_tree_ref (eb);
Greg Kroah-Hartman
maintainerPATCH 296/399 btrfs: zoned: dont skip block groups with 100% zone unusable
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Thumshirn <[email protected]>
commit a8b70c7f8600bc77d03c0b032c0662259b9e615e upstream.
Commit f4a9f219411f ("btrfs: do not delete unused block group if it may be used soon") changed the behaviour of deleting unused block-groups on zoned filesystems. Starting with this commit, we're using btrfs_space_info_used() to calculate the number of used bytes in a space_info. But btrfs_space_info_used() also accounts btrfs_space_info::bytes_zone_unusable as used bytes.
So if a block group is 100% zone_unusable it is skipped from the deletion step.
In order not to skip fully zone_unusable block-groups, also check if the block-group has bytes left that can be used on a zoned filesystem.
--- fs/btrfs/block-group.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/btrfs/block-group.c +2 -1
@@ -1550,7 +1550,8 @@ void btrfs_delete_unused_bgs(struct btrf* needing to allocate extents from the block group. */ used =btrfs_space_info_used (space_info, true); -if (space_info->total_bytes - block_group->length < used) { +if (space_info->total_bytes - block_group->length < used && + block_group->zone_unusable < block_group->length) {/* * Add a reference for the list, compensate for the ref * drop under the "next" label for the
Greg Kroah-Hartman
maintainerPATCH 297/399 btrfs: zoned: use zone aware sb location for scrub
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Thumshirn <[email protected]>
commit 74098a989b9c3370f768140b7783a7aaec2759b3 upstream.
At the moment scrub_supers() doesn't grab the super block's location via the zoned device aware btrfs_sb_log_location() but via btrfs_sb_offset().
This leads to checksum errors on 'scrub' as we're not accessing the correct location of the super block.
So use btrfs_sb_log_location() for getting the super blocks location on scrub.
--- fs/btrfs/scrub.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
fs/btrfs/scrub.c +11 -1
@@ -2805,7 +2805,17 @@ static noinline_for_stack int scrub_supe gen =btrfs_get_last_trans_committed (fs_info);for (i =0 ; i <BTRFS_SUPER_MIRROR_MAX ; i++) { - bytenr =btrfs_sb_offset (i); + ret =btrfs_sb_log_location (scrub_dev, i,0 , &bytenr); +if (ret == -ENOENT ) +break ; + +if (ret) { +spin_lock (&sctx->stat_lock); + sctx->stat.super_errors++; +spin_unlock (&sctx->stat_lock); +continue ; + } +if (bytenr +BTRFS_SUPER_INFO_SIZE > scrub_dev->commit_total_bytes)break ;
Greg Kroah-Hartman
maintainerPATCH 298/399 btrfs: zoned: fix use-after-free in do_zone_finish()
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Thumshirn <[email protected]>
commit 1ec17ef59168a1a6f1105f5dc517f783839a5302 upstream.
Shinichiro reported the following use-after-free triggered by the device replace operation in fstests btrfs/070.
BTRFS info (device nullb1): scrub: finished on devid 1 with status: 0
==================================================================
BUG: KASAN: slab-use-after-free in do_zone_finish+0x91a/0xb90 [btrfs]
Read of size 8 at addr ffff8881543c8060 by task btrfs-cleaner/3494007
CPU: 0 PID: 3494007 Comm: btrfs-cleaner Tainted: G W 6.8.0-rc5-kts #1
Hardware name: Supermicro Super Server/X11SPi-TF, BIOS 3.3 02/21/2020
Call Trace:
<TASK>
dump_stack_lvl+0x5b/0x90
print_report+0xcf/0x670
? __virt_addr_valid+0x200/0x3e0
kasan_report+0xd8/0x110
? do_zone_finish+0x91a/0xb90 [btrfs]
? do_zone_finish+0x91a/0xb90 [btrfs]
do_zone_finish+0x91a/0xb90 [btrfs]
btrfs_delete_unused_bgs+0x5e1/0x1750 [btrfs]
? __pfx_btrfs_delete_unused_bgs+0x10/0x10 [btrfs]
? btrfs_put_root+0x2d/0x220 [btrfs]
? btrfs_clean_one_deleted_snapshot+0x299/0x430 [btrfs]
cleaner_kthread+0x21e/0x380 [btrfs]
? __pfx_cleaner_kthread+0x10/0x10 [btrfs]
kthread+0x2e3/0x3c0
? __pfx_kthread+0x10/0x10
ret_from_fork+0x31/0x70
? __pfx_kthread+0x10/0x10
ret_from_fork_asm+0x1b/0x30
</TASK>
Allocated by task 3493983:
kasan_save_stack+0x33/0x60
kasan_save_track+0x14/0x30
__kasan_kmalloc+0xaa/0xb0
btrfs_alloc_device+0xb3/0x4e0 [btrfs]
device_list_add.constprop.0+0x993/0x1630 [btrfs]
btrfs_scan_one_device+0x219/0x3d0 [btrfs]
btrfs_control_ioctl+0x26e/0x310 [btrfs]
__x64_sys_ioctl+0x134/0x1b0
do_syscall_64+0x99/0x190
entry_SYSCALL_64_after_hwframe+0x6e/0x76
Freed by task 3494056:
kasan_save_stack+0x33/0x60
kasan_save_track+0x14/0x30
kasan_save_free_info+0x3f/0x60
poison_slab_object+0x102/0x170
__kasan_slab_free+0x32/0x70
kfree+0x11b/0x320
btrfs_rm_dev_replace_free_srcdev+0xca/0x280 [btrfs]
btrfs_dev_replace_finishing+0xd7e/0x14f0 [btrfs]
btrfs_dev_replace_by_ioctl+0x1286/0x25a0 [btrfs]
btrfs_ioctl+0xb27/0x57d0 [btrfs]
__x64_sys_ioctl+0x134/0x1b0
do_syscall_64+0x99/0x190
entry_SYSCALL_64_after_hwframe+0x6e/0x76
The buggy address belongs to the object at ffff8881543c8000
which belongs to the cache kmalloc-1k of size 1024
The buggy address is located 96 bytes inside of
freed 1024-byte region [ffff8881543c8000, ffff8881543c8400)
The buggy address belongs to the physical page:
page:00000000fe2c1285 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x1543c8
head:00000000fe2c1285 order:3 entire_mapcount:0 nr_pages_mapped:0 pincount:0
flags: 0x17ffffc0000840(slab|head|node=0|zone=2|lastcpupid=0x1fffff)
page_type: 0xffffffff()
raw: 0017ffffc0000840 ffff888100042dc0 ffffea0019e8f200 dead000000000002
raw: 0000000000000000 0000000000100010 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
Memory state around the buggy address:
ffff8881543c7f00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
ffff8881543c7f80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>ffff8881543c8000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff8881543c8080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff8881543c8100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fbThis UAF happens because we're accessing stale zone information of a already removed btrfs_device in do_zone_finish().
The sequence of events is as follows:
btrfs_dev_replace_start
btrfs_scrub_dev
btrfs_dev_replace_finishing
btrfs_dev_replace_update_device_in_mapping_tree <-- devices replaced btrfs_rm_dev_replace_free_srcdev
btrfs_free_device <-- device freed
cleaner_kthread
btrfs_delete_unused_bgs
btrfs_zone_finish
do_zone_finish <-- refers the freed device
The reason for this is that we're using a cached pointer to the chunk_map from the block group, but on device replace this cached pointer can contain stale device entries.
The staleness comes from the fact, that btrfs_block_group::physical_map is not a pointer to a btrfs_chunk_map but a memory copy of it.
Also take the fs_info::dev_replace::rwsem to prevent btrfs_dev_replace_update_device_in_mapping_tree() from changing the device underneath us again.
Note: btrfs_dev_replace_update_device_in_mapping_tree() is holding fs_info::mapping_tree_lock, but as this is a spinning read/write lock we cannot take it as the call to blkdev_zone_mgmt() requires a memory allocation which may not sleep.
But btrfs_dev_replace_update_device_in_mapping_tree() is always called with the fs_info::dev_replace::rwsem held in write mode.
Many thanks to Shinichiro for analyzing the bug.
--- fs/btrfs/zoned.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
fs/btrfs/zoned.c +7 -7
@@ -1563,11 +1563,7 @@ int btrfs_load_block_group_zone_info(strif (!map)return -EINVAL ; - cache->physical_map =btrfs_clone_chunk_map (map,GFP_NOFS ); -if (!cache->physical_map) { - ret = -ENOMEM ; - goto out; - } + cache->physical_map = map; zone_info =kcalloc (map->num_stripes,sizeof (*zone_info),GFP_NOFS );if (!zone_info) {
@@ -1679,7 +1675,6 @@ out: }bitmap_free (active);kfree (zone_info); -btrfs_free_chunk_map (map);return ret; }
@@ -2164,6 +2159,7 @@ static int do_zone_finish(struct btrfs_bstruct btrfs_chunk_map *map;const bool is_metadata = (block_group->flags & (BTRFS_BLOCK_GROUP_METADATA |BTRFS_BLOCK_GROUP_SYSTEM )); +struct btrfs_dev_replace *dev_replace = &fs_info->dev_replace;int ret =0 ;int i;
@@ -2239,6 +2235,7 @@ static int do_zone_finish(struct btrfs_bbtrfs_clear_data_reloc_bg (block_group);spin_unlock (&block_group->lock); +down_read (&dev_replace->rwsem); map = block_group->physical_map;for (i =0 ; i < map->num_stripes; i++) {struct btrfs_device *device = map->stripes[i].dev;
@@ -2253,13 +2250,16 @@ static int do_zone_finish(struct btrfs_b zinfo->zone_size >>SECTOR_SHIFT , GFP_NOFS); -if (ret) +if (ret) { +up_read (&dev_replace->rwsem);return ret; + }if (!(block_group->flags &BTRFS_BLOCK_GROUP_DATA )) zinfo->reserved_active_zones++;btrfs_dev_clear_active_zone (device, physical); } +up_read (&dev_replace->rwsem);if (!fully_written)btrfs_dec_block_group_ro (block_group);
Greg Kroah-Hartman
maintainerPATCH 299/399 wifi: mac80211: check/clear fast rx for non-4addr sta VLAN changes
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Felix Fietkau <[email protected]>
commit 4f2bdb3c5e3189297e156b3ff84b140423d64685 upstream.
When moving a station out of a VLAN and deleting the VLAN afterwards, the fast_rx entry still holds a pointer to the VLAN's netdev, which can cause use-after-free bugs. Fix this by immediately calling ieee80211_check_fast_rx after the VLAN change.
--- net/mac80211/cfg.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
net/mac80211/cfg.c +2 -3
@@ -2164,15 +2164,14 @@ static int ieee80211_change_station(stru }if (sta->sdata->vif.type ==NL80211_IFTYPE_AP_VLAN && - sta->sdata->u.vlan.sta) { -ieee80211_clear_fast_rx (sta); + sta->sdata->u.vlan.sta)RCU_INIT_POINTER (sta->sdata->u.vlan.sta,NULL ); - }if (test_sta_flag (sta,WLAN_STA_AUTHORIZED ))ieee80211_vif_dec_num_mcast (sta->sdata); sta->sdata = vlansdata; +ieee80211_check_fast_rx (sta);ieee80211_check_fast_xmit (sta);if (test_sta_flag (sta,WLAN_STA_AUTHORIZED )) {
Greg Kroah-Hartman
maintainerPATCH 300/399 wifi: cfg80211: add a flag to disable wireless extensions
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
commit be23b2d7c3b7c8bf57b1cf0bf890bd65df9d0186 upstream.
Wireless extensions are already disabled if MLO is enabled, given that we cannot support MLO there with all the hard- coded assumptions about BSSID etc.
However, the WiFi7 ecosystem is still stabilizing, and some devices may need MLO disabled while that happens. In that case, we might end up with a device that supports wext (but not MLO) in one kernel, and then breaks wext in the future (by enabling MLO), which is not desirable.
Add a flag to let such drivers/devices disable wext even if MLO isn't yet enabled.
--- include/net/cfg80211.h | 2 ++ net/wireless/wext-core.c | 7 +++++-- 2 files changed, 7 insertions(+), 2 deletions(-)
include/net/cfg80211.h +2 -0
@@ -4972,6 +4972,7 @@ struct cfg80211_ops {* set this flag to update channels on beacon hints. * @WIPHY_FLAG_SUPPORTS_NSTR_NONPRIMARY: support connection to non-primary link * of an NSTR mobile AP MLD. +* @WIPHY_FLAG_DISABLE_WEXT: disable wireless extensions for this device */ enum wiphy_flags {WIPHY_FLAG_SUPPORTS_EXT_KEK_KCK =BIT (0 ),
@@ -4983,6 +4984,7 @@ enum wiphy_flags {WIPHY_FLAG_4ADDR_STATION =BIT (6 ),WIPHY_FLAG_CONTROL_PORT_PROTOCOL =BIT (7 ),WIPHY_FLAG_IBSS_RSN =BIT (8 ), +WIPHY_FLAG_DISABLE_WEXT =BIT (9 ),WIPHY_FLAG_MESH_AUTH =BIT (10 ),WIPHY_FLAG_SUPPORTS_EXT_KCK_32 =BIT (11 ), WIPHY_FLAG_SUPPORTS_NSTR_NONPRIMARY = BIT(12),
net/wireless/wext-core.c +5 -2
@@ -4,6 +4,7 @@* Authors : Jean Tourrilhes - HPL - <[email protected]> * Copyright (c) 1997-2007 Jean Tourrilhes, All Rights Reserved. * Copyright 2009 Johannes Berg <[email protected]> +* Copyright (C) 2024 Intel Corporation * * (As all part of the Linux kernel, this file is GPL) */
@@ -662,7 +663,8 @@ struct iw_statistics *get_wireless_stats dev->ieee80211_ptr->wiphy->wext && dev->ieee80211_ptr->wiphy->wext->get_wireless_stats) {wireless_warn_cfg80211_wext (); -if (dev->ieee80211_ptr->wiphy->flags &WIPHY_FLAG_SUPPORTS_MLO ) +if (dev->ieee80211_ptr->wiphy->flags & (WIPHY_FLAG_SUPPORTS_MLO | +WIPHY_FLAG_DISABLE_WEXT ))return NULL ;return dev->ieee80211_ptr->wiphy->wext->get_wireless_stats (dev); }
@@ -704,7 +706,8 @@ static iw_handler get_handler(struct net#ifdef CONFIG_CFG80211_WEXT if (dev->ieee80211_ptr && dev->ieee80211_ptr->wiphy) {wireless_warn_cfg80211_wext (); -if (dev->ieee80211_ptr->wiphy->flags &WIPHY_FLAG_SUPPORTS_MLO ) +if (dev->ieee80211_ptr->wiphy->flags & (WIPHY_FLAG_SUPPORTS_MLO | +WIPHY_FLAG_DISABLE_WEXT ))return NULL ; handlers = dev->ieee80211_ptr->wiphy->wext; }
Greg Kroah-Hartman
maintainerPATCH 301/399 wifi: iwlwifi: mvm: disable MLO for the time being
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
commit 5f404005055304830bbbee0d66af2964fc48f29e upstream.
MLO ended up not really fully stable yet, we want to make sure it works well with the ecosystem before enabling it. Thus, remove the flag, but set WIPHY_FLAG_DISABLE_WEXT so we don't get wireless extensions back until we enable MLO for this hardware.
--- drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c +1 -1
@@ -354,7 +354,7 @@ int iwl_mvm_mac_setup_register(struct iwif (mvm->mld_api_is_used && mvm->nvm_data->sku_cap_11be_enable && !iwlwifi_mod_params.disable_11ax && !iwlwifi_mod_params.disable_11be) - hw->wiphy->flags |=WIPHY_FLAG_SUPPORTS_MLO ; + hw->wiphy->flags |=WIPHY_FLAG_DISABLE_WEXT ;/* With MLD FW API, it tracks timing by itself, * no need for any timing from the host
Greg Kroah-Hartman
maintainerPATCH 302/399 wifi: iwlwifi: fw: dont always use FW dump trig
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
commit 045a5b645dd59929b0e05375f493cde3a0318271 upstream.
Since the dump_data (struct iwl_fwrt_dump_data) is a union, it's not safe to unconditionally access and use the 'trig' member, it might be 'desc' instead. Access it only if it's known to be 'trig' rather than 'desc', i.e. if ini-debug is present.
--- drivers/net/wireless/intel/iwlwifi/fw/dbg.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
drivers/net/wireless/intel/iwlwifi/fw/dbg.c +9 -8
@@ -3074,8 +3074,6 @@ static void iwl_fw_dbg_collect_sync(strustruct iwl_fw_dbg_params params = {0 };struct iwl_fwrt_dump_data *dump_data = &fwrt->dump.wks[wk_idx].dump_data; -u32 policy; -u32 time_point;if (!test_bit (wk_idx, &fwrt->dump.active_wks))return ;
@@ -3106,13 +3104,16 @@ static void iwl_fw_dbg_collect_sync(struiwl_fw_dbg_stop_restart_recording (fwrt, ¶ms, false); - policy =le32_to_cpu (dump_data->trig->apply_policy); - time_point =le32_to_cpu (dump_data->trig->time_point); - -if (policy &IWL_FW_INI_APPLY_POLICY_DUMP_COMPLETE_CMD ) { -IWL_DEBUG_FW_INFO (fwrt,"WRT: sending dump complete\n" ); -iwl_send_dbg_dump_complete_cmd (fwrt, time_point,0 ); +if (iwl_trans_dbg_ini_valid (fwrt->trans)) { +u32 policy =le32_to_cpu (dump_data->trig->apply_policy); +u32 time_point =le32_to_cpu (dump_data->trig->time_point); + +if (policy &IWL_FW_INI_APPLY_POLICY_DUMP_COMPLETE_CMD ) { +IWL_DEBUG_FW_INFO (fwrt,"WRT: sending dump complete\n" ); +iwl_send_dbg_dump_complete_cmd (fwrt, time_point,0 ); + } } +if (fwrt->trans->dbg.last_tp_resetfw ==IWL_FW_INI_RESET_FW_MODE_STOP_FW_ONLY )iwl_force_nmi (fwrt->trans);
Greg Kroah-Hartman
maintainerPATCH 303/399 wifi: iwlwifi: mvm: handle debugfs names more carefully
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
commit 19d82bdedaf2db0bfb3762dda714ea803065eed5 upstream.
With debugfs=off, we can get here with the dbgfs_dir being an ERR_PTR(). Instead of checking for all this, which is often flagged as a mistake, simply handle the names here more carefully by printing them, then we don't need extra checks.
Also, while checking, I noticed theoretically 'buf' is too small, so fix that size as well.
--- drivers/net/wireless/intel/iwlwifi/mvm/debugfs-vif.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/net/wireless/intel/iwlwifi/mvm/debugfs-vif.c +7 -4
@@ -735,7 +735,9 @@ void iwl_mvm_vif_dbgfs_add_link(struct i {struct dentry *dbgfs_dir = vif->debugfs_dir;struct iwl_mvm_vif *mvmvif =iwl_mvm_vif_from_mac80211 (vif); -char buf[100 ]; +char buf[3 *3 +11 + (NL80211_WIPHY_NAME_MAXLEN +1 ) + + (7 +IFNAMSIZ +1 ) +6 +1 ]; +char name[7 +IFNAMSIZ +1 ];/* this will happen in monitor mode */ if (!dbgfs_dir)
@@ -748,10 +750,11 @@ void iwl_mvm_vif_dbgfs_add_link(struct i* find * netdev:wlan0 -> ../../../ieee80211/phy0/netdev:wlan0/iwlmvm/ */ -snprintf (buf,100 ,"../../../%pd3/iwlmvm" , dbgfs_dir); +snprintf (name,sizeof (name),"%pd" , dbgfs_dir); +snprintf (buf,sizeof (buf),"../../../%pd3/iwlmvm" , dbgfs_dir); - mvmvif->dbgfs_slink =debugfs_create_symlink (dbgfs_dir->d_name.name, - mvm->debugfs_dir, buf); + mvmvif->dbgfs_slink = +debugfs_create_symlink (name, mvm->debugfs_dir, buf); }void iwl_mvm_vif_dbgfs_rm_link (struct iwl_mvm *mvm,struct ieee80211_vif *vif)
Greg Kroah-Hartman
maintainerPATCH 304/399 Revert "drm/amd/display: Fix sending VSC (+ colorimetry) packets for DP/eDP displays without PSR"
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Harry Wentland <[email protected]>
commit 78aca9ee5e012e130dbfbd7191bc2302b0cf3b37 upstream.
This causes flicker on a bunch of eDP panels. The info_packet code also caused regressions on other OSes that we haven't' seen on Linux yet, but that is likely due to the fact that we haven't had a chance to test those environments on Linux.
We'll need to revisit this.
This reverts commit 202260f64519e591b5cd99626e441b6559f571a3.
--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 8 ++---- drivers/gpu/drm/amd/display/modules/info_packet/info_packet.c | 13 +++------- 2 files changed, 8 insertions(+), 13 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +3 -5
@@ -6256,9 +6256,8 @@ create_stream_for_sink(struct drm_connecif (stream->signal ==SIGNAL_TYPE_HDMI_TYPE_A )mod_build_hf_vsif_infopacket (stream, &stream->vsp_infopacket); -else if (stream->signal ==SIGNAL_TYPE_DISPLAY_PORT || - stream->signal ==SIGNAL_TYPE_DISPLAY_PORT_MST || - stream->signal ==SIGNAL_TYPE_EDP ) { + +if (stream->link->psr_settings.psr_feature_enabled || stream->link->replay_settings.replay_feature_enabled) {// // should decide stream support vsc sdp colorimetry capability // before building vsc info packet
@@ -6274,9 +6273,8 @@ create_stream_for_sink(struct drm_connecif (stream->out_transfer_func->tf ==TRANSFER_FUNCTION_GAMMA22 ) tf =TRANSFER_FUNC_GAMMA_22 ;mod_build_vsc_infopacket (stream, &stream->vsc_infopacket, stream->output_color_space, tf); + aconnector->psr_skip_count =AMDGPU_DM_PSR_ENTRY_DELAY ; -if (stream->link->psr_settings.psr_feature_enabled) - aconnector->psr_skip_count =AMDGPU_DM_PSR_ENTRY_DELAY ; } finish:dc_sink_release (sink);
drivers/gpu/drm/amd/display/modules/info_packet/info_packet.c +5 -8
@@ -147,15 +147,12 @@ void mod_build_vsc_infopacket(const stru }/* VSC packet set to 4 for PSR-SU, or 2 for PSR1 */ -if (stream->link->psr_settings.psr_feature_enabled) { -if (stream->link->psr_settings.psr_version ==DC_PSR_VERSION_SU_1 ) - vsc_packet_revision = vsc_packet_rev4; -else if (stream->link->psr_settings.psr_version ==DC_PSR_VERSION_1 ) - vsc_packet_revision = vsc_packet_rev2; - } - -if (stream->link->replay_settings.config.replay_supported) +if (stream->link->psr_settings.psr_version ==DC_PSR_VERSION_SU_1 ) + vsc_packet_revision = vsc_packet_rev4; +else if (stream->link->replay_settings.config.replay_supported) vsc_packet_revision = vsc_packet_rev4; +else if (stream->link->psr_settings.psr_version ==DC_PSR_VERSION_1 ) + vsc_packet_revision = vsc_packet_rev2;/* Update to revision 5 for extended colorimetry support */ if (stream->use_vsc_sdp_for_colorimetry)
Greg Kroah-Hartman
maintainerPATCH 305/399 gpio: cdev: sanitize the label before requesting the interrupt
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bartosz Golaszewski <[email protected]>
commit b34490879baa847d16fc529c8ea6e6d34f004b38 upstream.
When an interrupt is requested, a procfs directory is created under "/proc/irq/<irqnum>/<label>" where <label> is the string passed to one of the request_irq() variants.
What follows is that the string must not contain the "/" character or the procfs mkdir operation will fail. We don't have such constraints for GPIO consumer labels which are used verbatim as interrupt labels for GPIO irqs. We must therefore sanitize the consumer string before requesting the interrupt.
Let's replace all "/" with ":".
--- drivers/gpio/gpiolib-cdev.c | 38 ++++++++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 6 deletions(-)
drivers/gpio/gpiolib-cdev.c +32 -6
@@ -1089,10 +1089,20 @@ static u32 gpio_v2_line_config_debounce_return 0 ; } +static inline char *make_irq_label (const char *orig) +{ +return kstrdup_and_replace (orig,'/' ,':' ,GFP_KERNEL ); +} + +static inline void free_irq_label (const char *label) +{ +kfree (label); +} +static void edge_detector_stop (struct line *line) {if (line->irq) { -free_irq (line->irq, line); +free_irq_label (free_irq (line->irq, line)); line->irq =0 ; }
@@ -1116,6 +1126,7 @@ static int edge_detector_setup(struct liunsigned long irqflags =0 ;u64 eflags;int irq, ret; +char *label; eflags = edflags &GPIO_V2_LINE_EDGE_FLAGS ;if (eflags && !kfifo_initialized (&line->req->events)) {
@@ -1152,11 +1163,17 @@ static int edge_detector_setup(struct li IRQF_TRIGGER_RISING :IRQF_TRIGGER_FALLING ; irqflags |=IRQF_ONESHOT ; + label =make_irq_label (line->req->label); +if (!label) +return -ENOMEM ; +/* Request a thread to read the events */ ret =request_threaded_irq (irq, edge_irq_handler, edge_irq_thread, - irqflags, line->req->label, line); -if (ret) + irqflags, label, line); +if (ret) { +free_irq_label (label);return ret; + } line->irq = irq;return 0 ;
@@ -1979,7 +1996,7 @@ static void lineevent_free(struct lineevblocking_notifier_chain_unregister (&le->gdev->device_notifier, &le->device_unregistered_nb);if (le->irq) -free_irq (le->irq, le); +free_irq_label (free_irq (le->irq, le));if (le->desc)gpiod_free (le->desc);kfree (le->label);
@@ -2120,6 +2137,7 @@ static int lineevent_create(struct gpio_int fd;int ret;int irq, irqflags =0 ; +char *label;if (copy_from_user (&eventreq, ip,sizeof (eventreq)))return -EFAULT ;
@@ -2204,15 +2222,23 @@ static int lineevent_create(struct gpio_if (ret) goto out_free_le; + label =make_irq_label (le->label); +if (!label) { + ret = -ENOMEM ; + goto out_free_le; + } +/* Request a thread to read the events */ ret =request_threaded_irq (irq, lineevent_irq_handler, lineevent_irq_thread, irqflags, - le->label, + label, le); -if (ret) +if (ret) { +free_irq_label (label); goto out_free_le; + } le->irq = irq;
Greg Kroah-Hartman
maintainerPATCH 306/399 fbdev: Select I/O-memory framebuffer ops for SBus
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Zimmermann <[email protected]>
commit a8eb93b42d7e068306ca07f51055cbcde893fea3 upstream.
Framebuffer I/O on the Sparc Sbus requires read/write helpers for I/O memory. Select FB_IOMEM_FOPS accordingly.
--- drivers/video/fbdev/Kconfig | 3 +++ 1 file changed, 3 insertions(+)
drivers/video/fbdev/Kconfig +3 -0
@@ -501,6 +501,7 @@ config FB_SBUS_HELPERS select FB_CFB_COPYAREA select FB_CFB_FILLRECT select FB_CFB_IMAGEBLIT + select FB_IOMEM_FOPS config FB_BW2 bool "BWtwo support"
@@ -521,6 +522,7 @@ config FB_CG6 depends on (FB = y) && (SPARC && FB_SBUS) select FB_CFB_COPYAREA select FB_CFB_IMAGEBLIT + select FB_IOMEM_FOPS help This is the frame buffer device driver for the CGsix (GX, TurboGX) frame buffer.
@@ -530,6 +532,7 @@ config FB_FFB depends on FB_SBUS && SPARC64 select FB_CFB_COPYAREA select FB_CFB_IMAGEBLIT + select FB_IOMEM_FOPS help This is the frame buffer device driver for the Creator, Creator3D, and Elite3D graphics boards.
Greg Kroah-Hartman
maintainerPATCH 307/399 exec: Fix NOMMU linux_binprm::exec in transfer_args_to_stack()
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Max Filippov <[email protected]>
commit 2aea94ac14d1e0a8ae9e34febebe208213ba72f7 upstream.
In NOMMU kernel the value of linux_binprm::p is the offset inside the temporary program arguments array maintained in separate pages in the linux_binprm::page. linux_binprm::exec being a copy of linux_binprm::p thus must be adjusted when that array is copied to the user stack. Without that adjustment the value passed by the NOMMU kernel to the ELF program in the AT_EXECFN entry of the aux array doesn't make any sense and it may break programs that try to access memory pointed to by that entry.
Adjust linux_binprm::exec before the successful return from the transfer_args_to_stack().
--- fs/exec.c | 1 + 1 file changed, 1 insertion(+)
fs/exec.c +1 -0
@@ -895,6 +895,7 @@ int transfer_args_to_stack(struct linux_ goto out; } + bprm->exec += *sp_location -MAX_ARG_PAGES *PAGE_SIZE ; *sp_location = sp; out:
Greg Kroah-Hartman
maintainerPATCH 308/399 hexagon: vmlinux.lds.S: handle attributes section
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nathan Chancellor <[email protected]>
commit 549aa9678a0b3981d4821bf244579d9937650562 upstream.
After the linked LLVM change, the build fails with CONFIG_LD_ORPHAN_WARN_LEVEL="error", which happens with allmodconfig:
ld.lld: error: vmlinux.a(init/main.o):(.hexagon.attributes) is being placed in '.hexagon.attributes'
Handle the attributes section in a similar manner as arm and riscv by adding it after the primary ELF_DETAILS grouping in vmlinux.lds.S, which fixes the error.
--- arch/hexagon/kernel/vmlinux.lds.S | 1 + 1 file changed, 1 insertion(+)
arch/hexagon/kernel/vmlinux.lds.S +1 -0
@@ -63,6 +63,7 @@ SECTIONS STABS_DEBUG DWARF_DEBUG ELF_DETAILS + .hexagon.attributes 0 : { *(.hexagon.attributes) } DISCARDS }
Greg Kroah-Hartman
maintainerPATCH 309/399 mm: cachestat: fix two shmem bugs
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Weiner <[email protected]>
commit d5d39c707a4cf0bcc84680178677b97aa2cb2627 upstream.
When cachestat on shmem races with swapping and invalidation, there are two possible bugs:
1) A swapin error can have resulted in a poisoned swap entry in the shmem inode's xarray. Calling get_shadow_from_swap_cache() on it will result in an out-of-bounds access to swapper_spaces[].
Validate the entry with non_swap_entry() before going further.
2) When we find a valid swap entry in the shmem's inode, the shadow entry in the swapcache might not exist yet: swap IO is still in progress and we're before __remove_mapping; swapin, invalidation, or swapoff have removed the shadow from swapcache after we saw the shmem swap entry.
This will send a NULL to workingset_test_recent(). The latter purely operates on pointer bits, so it won't crash - node 0, memcg ID 0, eviction timestamp 0, etc. are all valid inputs - but it's a bogus test. In theory that could result in a false "recently evicted" count.
Such a false positive wouldn't be the end of the world. But for code clarity and (future) robustness, be explicit about this case.
Bail on get_shadow_from_swap_cache() returning NULL.
--- mm/filemap.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
mm/filemap.c +16 -0
@@ -4153,7 +4153,23 @@ static void filemap_cachestat(struct add/* shmem file - in swap cache */ swp_entry_t swp =radix_to_swp_entry (folio); +/* swapin error results in poisoned entry */ +if (non_swap_entry (swp)) + goto resched; + +/* +* Getting a swap entry from the shmem +* inode means we beat +* shmem_unuse(). rcu_read_lock() +* ensures swapoff waits for us before +* freeing the swapper space. However, +* we can race with swapping and +* invalidation, so there might not be +* a shadow in the swapcache (yet). +*/ shadow =get_shadow_from_swap_cache (swp); +if (!shadow) + goto resched; }#endif if (workingset_test_recent (shadow, true, &workingset))
Greg Kroah-Hartman
maintainerPATCH 310/399 selftests/mm: sigbus-wp test requires UFFD_FEATURE_WP_HUGETLBFS_SHMEM
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Edward Liaw <[email protected]>
commit 105840ebd76d8dbc1a7d734748ae320076f3201e upstream.
The sigbus-wp test requires the UFFD_FEATURE_WP_HUGETLBFS_SHMEM flag for shmem and hugetlb targets. Otherwise it is not backwards compatible with kernels <5.19 and fails with EINVAL.
--- tools/testing/selftests/mm/uffd-unit-tests.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tools/testing/selftests/mm/uffd-unit-tests.c +2 -1
@@ -1427,7 +1427,8 @@ uffd_test_case_t uffd_tests[] = { .uffd_fn = uffd_sigbus_wp_test, .mem_targets = MEM_ALL, .uffd_feature_required = UFFD_FEATURE_SIGBUS | - UFFD_FEATURE_EVENT_FORK | UFFD_FEATURE_PAGEFAULT_FLAG_WP, + UFFD_FEATURE_EVENT_FORK | UFFD_FEATURE_PAGEFAULT_FLAG_WP | + UFFD_FEATURE_WP_HUGETLBFS_SHMEM, }, { .name = "events",
Greg Kroah-Hartman
maintainerPATCH 311/399 selftests/mm: fix ARM related issue with fork after pthread_create
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Edward Liaw <[email protected]>
commit 8c864371b2a15a23ce35aa7e2bd241baaad6fbe8 upstream.
Following issue was observed while running the uffd-unit-tests selftest on ARM devices. On x86_64 no issues were detected:
pthread_create followed by fork caused deadlock in certain cases wherein fork required some work to be completed by the created thread. Used synchronization to ensure that created thread's start function has started before invoking fork.
--- tools/testing/selftests/mm/uffd-common.c | 3 +++ tools/testing/selftests/mm/uffd-common.h | 2 ++ tools/testing/selftests/mm/uffd-unit-tests.c | 10 ++++++++++ 3 files changed, 15 insertions(+)
tools/testing/selftests/mm/uffd-common.c +3 -0
@@ -18,6 +18,7 @@ bool test_uffdio_wp = true;unsigned long long *count_verify;uffd_test_ops_t *uffd_test_ops;uffd_test_case_ops_t *uffd_test_case_ops; +atomic_bool ready_for_fork;static int uffd_mem_fd_create (off_t mem_size,bool hugetlb) {
@@ -518,6 +519,8 @@ void *uffd_poll_thread(void *arg) pollfd[1 ].fd = pipefd[cpu*2 ]; pollfd[1 ].events =POLLIN ; + ready_for_fork = true; +for (;;) { ret =poll (pollfd,2 ,-1 );if (ret <=0 ) {
tools/testing/selftests/mm/uffd-common.h +2 -0
@@ -32,6 +32,7 @@#include <inttypes.h> #include <stdint.h> #include <sys/random.h> +#include <stdatomic.h> #include "../kselftest.h" #include "vm_util.h"
@@ -103,6 +104,7 @@ extern bool map_shared;extern bool test_uffdio_wp;extern unsigned long long *count_verify;extern volatile bool test_uffdio_copy_eexist; +extern atomic_bool ready_for_fork;extern uffd_test_ops_t anon_uffd_test_ops;extern uffd_test_ops_t shmem_uffd_test_ops;
tools/testing/selftests/mm/uffd-unit-tests.c +10 -0
@@ -775,6 +775,8 @@ static void uffd_sigbus_test_common(boolchar c;struct uffd_args args = {0 }; + ready_for_fork = false; +fcntl (uffd,F_SETFL , uffd_flags |O_NONBLOCK ); if (uffd_register(uffd, area_dst, nr_pages * page_size,
@@ -790,6 +792,9 @@ static void uffd_sigbus_test_common(boolif (pthread_create (&uffd_mon,NULL , uffd_poll_thread, &args))err ("uffd_poll_thread create" ); +while (!ready_for_fork) + ;/* Wait for the poll_thread to start executing before forking */ + pid =fork ();if (pid <0 )err ("fork" );
@@ -829,6 +834,8 @@ static void uffd_events_test_common(boolchar c;struct uffd_args args = {0 }; + ready_for_fork = false; +fcntl (uffd,F_SETFL , uffd_flags |O_NONBLOCK );if (uffd_register (uffd, area_dst, nr_pages * page_size, true, wp, false))
@@ -838,6 +845,9 @@ static void uffd_events_test_common(boolif (pthread_create (&uffd_mon,NULL , uffd_poll_thread, &args))err ("uffd_poll_thread create" ); +while (!ready_for_fork) + ;/* Wait for the poll_thread to start executing before forking */ + pid =fork ();if (pid <0 )err ("fork" );
Greg Kroah-Hartman
maintainerPATCH 312/399 mmc: sdhci-omap: re-tuning is needed after a pm transition to support emmc HS200 mode
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Romain Naour <[email protected]>
commit f9e2a5b00a35f2c064dc679808bc8db5cc779ed6 upstream.
"PM runtime functions" was been added in sdhci-omap driver in commit f433e8aac6b9 ("mmc: sdhci-omap: Implement PM runtime functions") along with "card power off and enable aggressive PM" in commit 3edf588e7fe0 ("mmc: sdhci-omap: Allow SDIO card power off and enable aggressive PM").
Since then, the sdhci-omap driver doesn't work using mmc-hs200 mode due to the tuning values being lost during a pm transition.
As for the sdhci_am654 driver, request a new tuning sequence before suspend (sdhci_omap_runtime_suspend()), otherwise the device will trigger cache flush error:
mmc1: cache flush error -110 (ETIMEDOUT)
mmc1: error -110 doing aggressive suspend
followed by I/O errors produced by fdisk -l /dev/mmcblk1boot1:
I/O error, dev mmcblk1boot0, sector 64384 op 0x0:(READ) flags 0x80700 phys_seg 1 prio class 2
I/O error, dev mmcblk1boot1, sector 64384 op 0x0:(READ) flags 0x80700 phys_seg 1 prio class 2
I/O error, dev mmcblk1boot1, sector 64384 op 0x0:(READ) flags 0x0 phys_seg 1 prio class 2
Buffer I/O error on dev mmcblk1boot1, logical block 8048, async page read I/O error, dev mmcblk1boot0, sector 64384 op 0x0:(READ) flags 0x0 phys_seg 1 prio class 2
Buffer I/O error on dev mmcblk1boot0, logical block 8048, async page read
Don't re-tune if auto retuning is supported in HW (when SDHCI_TUNING_MODE_3 is available).
--- drivers/mmc/host/sdhci-omap.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/mmc/host/sdhci-omap.c +3 -0
@@ -1439,6 +1439,9 @@ static int __maybe_unused sdhci_omap_runstruct sdhci_pltfm_host *pltfm_host =sdhci_priv (host);struct sdhci_omap_host *omap_host =sdhci_pltfm_priv (pltfm_host); +if (host->tuning_mode !=SDHCI_TUNING_MODE_3 ) +mmc_retune_needed (host->mmc); +if (omap_host->con != -EINVAL )sdhci_runtime_suspend_host (host);
Greg Kroah-Hartman
maintainerPATCH 313/399 mmc: core: Initialize mmc_blk_ioc_data
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikko Rapeli <[email protected]>
commit 0cdfe5b0bf295c0dee97436a8ed13336933a0211 upstream.
Commit 4d0c8d0aef63 ("mmc: core: Use mrq.sbc in close-ended ffu") adds flags uint to struct mmc_blk_ioc_data, but it does not get initialized for RPMB ioctls which now fails.
Let's fix this by always initializing the struct and flags to zero.
--- drivers/mmc/core/block.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/core/block.c +1 -1
@@ -413,7 +413,7 @@ static struct mmc_blk_ioc_data *mmc_blk_struct mmc_blk_ioc_data *idata;int err; - idata =kmalloc (sizeof (*idata),GFP_KERNEL ); + idata =kzalloc (sizeof (*idata),GFP_KERNEL );if (!idata) { err = -ENOMEM ; goto out;
Greg Kroah-Hartman
maintainerPATCH 314/399 mmc: core: Avoid negative index with array access
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikko Rapeli <[email protected]>
commit cf55a7acd1ed38afe43bba1c8a0935b51d1dc014 upstream.
Commit 4d0c8d0aef63 ("mmc: core: Use mrq.sbc in close-ended ffu") assigns prev_idata = idatas[i - 1], but doesn't check that the iterator i is greater than zero. Let's fix this by adding a check.
--- drivers/mmc/core/block.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/core/block.c +1 -1
@@ -488,7 +488,7 @@ static int __mmc_blk_ioctl_cmd(struct mmif (idata->flags &MMC_BLK_IOC_DROP )return 0 ; -if (idata->flags &MMC_BLK_IOC_SBC ) +if (idata->flags &MMC_BLK_IOC_SBC && i >0 ) prev_idata = idatas[i -1 ];/*
Greg Kroah-Hartman
maintainerPATCH 315/399 sdhci-of-dwcmshc: disable PM runtime in dwcmshc_remove()
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Liming Sun <[email protected]>
commit 03749309909935070253accab314288d332a204d upstream.
This commit disables PM runtime in dwcmshc_remove() to avoid the error message below when reloading the sdhci-of-dwcmshc.ko
sdhci-dwcmshc MLNXBF30:00: Unbalanced pm_runtime_enable!
--- drivers/mmc/host/sdhci-of-dwcmshc.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-)
drivers/mmc/host/sdhci-of-dwcmshc.c +17 -11
@@ -933,6 +933,17 @@ free_pltfm:return err; } +static void dwcmshc_disable_card_clk (struct sdhci_host *host) +{ +u16 ctrl; + + ctrl =sdhci_readw (host,SDHCI_CLOCK_CONTROL ); +if (ctrl &SDHCI_CLOCK_CARD_EN ) { + ctrl &= ~SDHCI_CLOCK_CARD_EN ; +sdhci_writew (host, ctrl,SDHCI_CLOCK_CONTROL ); + } +} +static void dwcmshc_remove (struct platform_device *pdev) {struct sdhci_host *host =platform_get_drvdata (pdev);
@@ -940,8 +951,14 @@ static void dwcmshc_remove(struct platfostruct dwcmshc_priv *priv =sdhci_pltfm_priv (pltfm_host);struct rk35xx_priv *rk_priv = priv->priv; +pm_runtime_get_sync (&pdev->dev); +pm_runtime_disable (&pdev->dev); +pm_runtime_put_noidle (&pdev->dev); +sdhci_remove_host (host,0 ); +dwcmshc_disable_card_clk (host); +clk_disable_unprepare (pltfm_host->clk);clk_disable_unprepare (priv->bus_clk);if (rk_priv)
@@ -1032,17 +1049,6 @@ static void dwcmshc_enable_card_clk(strusdhci_writew (host, ctrl,SDHCI_CLOCK_CONTROL ); } } - -static void dwcmshc_disable_card_clk (struct sdhci_host *host) -{ -u16 ctrl; - - ctrl =sdhci_readw (host,SDHCI_CLOCK_CONTROL ); -if (ctrl &SDHCI_CLOCK_CARD_EN ) { - ctrl &= ~SDHCI_CLOCK_CARD_EN ; -sdhci_writew (host, ctrl,SDHCI_CLOCK_CONTROL ); - } -}static int dwcmshc_runtime_suspend (struct device *dev) {
Greg Kroah-Hartman
maintainerPATCH 316/399 block: Do not force full zone append completion in req_bio_endio()
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Damien Le Moal <[email protected]>
commit 55251fbdf0146c252ceff146a1bb145546f3e034 upstream.
This reverts commit 748dc0b65ec2b4b7b3dbd7befcc4a54fdcac7988.
Partial zone append completions cannot be supported as there is no guarantees that the fragmented data will be written sequentially in the same manner as with a full command. Commit 748dc0b65ec2 ("block: fix partial zone append completion handling in req_bio_endio()") changed req_bio_endio() to always advance a partially failed BIO by its full length, but this can lead to incorrect accounting. So revert this change and let low level device drivers handle this case by always failing completely zone append operations. With this revert, users will still see an IO error for a partially completed zone append BIO.
--- block/blk-mq.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)
block/blk-mq.c +2 -7
@@ -771,16 +771,11 @@ static void req_bio_endio(struct request/* * Partial zone append completions cannot be supported as the * BIO fragments may end up not being written sequentially. -* For such case, force the completed nbytes to be equal to -* the BIO size so that bio_advance() sets the BIO remaining -* size to 0 and we end up calling bio_endio() before returning. */ -if (bio->bi_iter.bi_size != nbytes) { +if (bio->bi_iter.bi_size != nbytes) bio->bi_status =BLK_STS_IOERR ; - nbytes = bio->bi_iter.bi_size; - }else { +else bio->bi_iter.bi_sector = rq->__sector; - } }bio_advance (bio, nbytes);
Greg Kroah-Hartman
maintainerPATCH 317/399 thermal: devfreq_cooling: Fix perf state when calculate dfc res_util
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ye Zhang <[email protected]>
commit a26de34b3c77ae3a969654d94be49e433c947e3b upstream.
The issue occurs when the devfreq cooling device uses the EM power model and the get_real_power() callback is provided by the driver.
The EM power table is sorted ascending,can't index the table by cooling device state,so convert cooling state to performance state by dfc->max_state - dfc->capped_state.
--- drivers/thermal/devfreq_cooling.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/thermal/devfreq_cooling.c +1 -1
@@ -201,7 +201,7 @@ static int devfreq_cooling_get_requested res = dfc->power_ops->get_real_power (df, power, freq, voltage);if (!res) { - state = dfc->capped_state; + state = dfc->max_state - dfc->capped_state;/* Convert EM power into milli-Watts first */ dfc->res_util = dfc->em_pd->table[state].power;
Greg Kroah-Hartman
maintainerPATCH 318/399 Revert "thermal: core: Dont update trip points inside the hysteresis range"
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Lezcano <[email protected]>
commit f67cf45deedb118af302534643627ce59074e8eb upstream.
It has been reported the commit cf3986f8c01d3 introduced a regression when the temperature is wavering in the hysteresis region. The mitigation stops leading to an uncontrolled temperature increase until reaching the critical trip point.
Here what happens:
* 'throttle' is when the current temperature is greater than the trip point temperature
* 'target' is the mitigation level
* 'passive' is positive when there is a mitigation, zero otherwise
* these values are computed in the step_wise governor
Configuration:
trip point 1: temp=95°C, hyst=5°C (passive)
trip point 2: temp=115°C, hyst=0°C (critical)
governor: step_wise
1. The temperature crosses the way up the trip point 1 at 95°C
- trend=raising
- throttle=1, target=1
- passive=1
- set_trips: low=90°C, high=115°C
2. The temperature decreases but stays in the hysteresis region at
93°C
- trend=dropping
- throttle=0, target=0
- passive=1
Before cf3986f8c01d3
- set_trips: low=90°C, high=95°C
After cf3986f8c01d3
- set_trips: low=90°C, high=115°C
3. The temperature increases a bit but stays in the hysteresis region at 94°C (so below the trip point 1 temp 95°C)
- trend=raising
- throttle=0, target=0
- passive=1
Before cf3986f8c01d3
- set_trips: low=90°C, high=95°C
After cf3986f8c01d3
- set_trips: low=90°C, high=115°C
4. The temperature decreases but stays in the hysteresis region at
93°C
- trend=dropping
- throttle=0, target=THERMAL_NO_TARGET
- passive=0
Before cf3986f8c01d3
- set_trips: low=90°C, high=95°C
After cf3986f8c01d3
- set_trips: low=90°C, high=115°C
At this point, the 'passive' value is zero, there is no mitigation, the temperature is in the hysteresis region, the next trip point is 115°C. As 'passive' is zero, the timer to monitor the thermal zone is disabled. Consequently if the temperature continues to increase, no mitigation will happen and it will reach the 115°C trip point and reboot.
Before the optimization, the high boundary would have been 95°C, thus triggering the mitigation again and rearming the polling timer.
The optimization make sense but given the current implementation of the step_wise governor collaborating via this 'passive' flag with the core framework it can not work.
Quoted 1 line
From a higher perspective it seems like there is a problem between the
governor which sets a variable to be used by the core framework. That sounds akward and it would make much more sense if the core framework controls the governor and not the opposite. But as the devil hides in the details, there are some subtilities to be addressed before.
Elaborating those would be out of the scope this changelog. So let's stay simple and revert the change first to fixup all broken mobile platforms.
This reverts commit cf3986f8c01d3 ("thermal: core: Don't update trip points inside the hysteresis range") and takes a conflict with commit 0c0c4740c9d26 ("0c0c4740c9d2 thermal: trip: Use for_each_trip() in __thermal_zone_set_trips()") in drivers/thermal/thermal_trip.c into account.
--- drivers/thermal/thermal_trip.c | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-)
drivers/thermal/thermal_trip.c +2 -17
@@ -65,7 +65,6 @@ void __thermal_zone_set_trips(struct the {const struct thermal_trip *trip;int low = -INT_MAX , high =INT_MAX ; -bool same_trip = false;int ret;lockdep_assert_held (&tz->lock);
@@ -74,36 +73,22 @@ void __thermal_zone_set_trips(struct thereturn ;for_each_trip (tz, trip) { -bool low_set = false;int trip_low; trip_low = trip->temperature - trip->hysteresis; -if (trip_low < tz->temperature && trip_low > low) { +if (trip_low < tz->temperature && trip_low > low) low = trip_low; - low_set = true; - same_trip = false; - }if (trip->temperature > tz->temperature && - trip->temperature < high) { + trip->temperature < high) high = trip->temperature; - same_trip = low_set; - } }/* No need to change trip points */ if (tz->prev_low_trip == low && tz->prev_high_trip == high)return ; -/* -* If "high" and "low" are the same, skip the change unless this is the -* first time. -*/ -if (same_trip && (tz->prev_low_trip != -INT_MAX || - tz->prev_high_trip !=INT_MAX )) -return ; - tz->prev_low_trip = low; tz->prev_high_trip = high;
Greg Kroah-Hartman
maintainerPATCH 319/399 nouveau/dmem: handle kcalloc() allocation failure
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Duoming Zhou <[email protected]>
commit 16e87fe23d4af6df920406494ced5c0f4354567b upstream.
The kcalloc() in nouveau_dmem_evict_chunk() will return null if the physical memory has run out. As a result, if we dereference src_pfns, dst_pfns or dma_addrs, the null pointer dereference bugs will happen.
Moreover, the GPU is going away. If the kcalloc() fails, we could not evict all pages mapping a chunk. So this patch adds a __GFP_NOFAIL flag in kcalloc().
Finally, as there is no need to have physically contiguous memory, this patch switches kcalloc() to kvcalloc() in order to avoid failing allocations.
--- drivers/gpu/drm/nouveau/nouveau_dmem.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/gpu/drm/nouveau/nouveau_dmem.c +6 -6
@@ -378,9 +378,9 @@ nouveau_dmem_evict_chunk(struct nouveau_dma_addr_t *dma_addrs;struct nouveau_fence *fence; - src_pfns =kcalloc (npages,sizeof (*src_pfns),GFP_KERNEL ); - dst_pfns =kcalloc (npages,sizeof (*dst_pfns),GFP_KERNEL ); - dma_addrs =kcalloc (npages,sizeof (*dma_addrs),GFP_KERNEL ); + src_pfns =kvcalloc (npages,sizeof (*src_pfns),GFP_KERNEL | __GFP_NOFAIL); + dst_pfns =kvcalloc (npages,sizeof (*dst_pfns),GFP_KERNEL | __GFP_NOFAIL); + dma_addrs =kvcalloc (npages,sizeof (*dma_addrs),GFP_KERNEL | __GFP_NOFAIL);migrate_device_range (src_pfns, chunk->pagemap.range.start >>PAGE_SHIFT , npages);
@@ -406,11 +406,11 @@ nouveau_dmem_evict_chunk(struct nouveau_migrate_device_pages (src_pfns, dst_pfns, npages);nouveau_dmem_fence_done (&fence);migrate_device_finalize (src_pfns, dst_pfns, npages); -kfree (src_pfns); -kfree (dst_pfns); +kvfree (src_pfns); +kvfree (dst_pfns);for (i =0 ; i < npages; i++)dma_unmap_page (chunk->drm->dev->dev, dma_addrs[i],PAGE_SIZE ,DMA_BIDIRECTIONAL ); -kfree (dma_addrs); +kvfree (dma_addrs); }void
Greg Kroah-Hartman
maintainerPATCH 320/399 net: ll_temac: platform_get_resource replaced by wrong function
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Claus Hansen Ries <[email protected]>
commit 3a38a829c8bc27d78552c28e582eb1d885d07d11 upstream.
The function platform_get_resource was replaced with devm_platform_ioremap_resource_byname and is called using 0 as name.
This eventually ends up in platform_get_resource_byname in the call stack, where it causes a null pointer in strcmp.
if (type == resource_type(r) && !strcmp(r->name, name))
It should have been replaced with devm_platform_ioremap_resource.
--- drivers/net/ethernet/xilinx/ll_temac_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/xilinx/ll_temac_main.c +1 -1
@@ -1443,7 +1443,7 @@ static int temac_probe(struct platform_d }/* map device registers */ - lp->regs =devm_platform_ioremap_resource_byname (pdev,0 ); + lp->regs =devm_platform_ioremap_resource (pdev,0 );if (IS_ERR (lp->regs)) {dev_err (&pdev->dev,"could not map TEMAC registers\n" );return -ENOMEM ;
Greg Kroah-Hartman
maintainerPATCH 321/399 net: wan: framer: Add missing static inline qualifiers
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Herve Codina <[email protected]>
commit ea2c09283b44d1a3732a195a9b257d56779c8863 upstream.
Compilation with CONFIG_GENERIC_FRAMER disabled lead to the following
warnings:
framer.h:184:16: warning: no previous prototype for function 'framer_get' [-Wmissing-prototypes] 184 | struct framer *framer_get(struct device *dev, const char *con_id)
framer.h:184:1: note: declare 'static' if the function is not intended to be used outside of this translation unit 184 | struct framer *framer_get(struct device *dev, const char *con_id)
framer.h:189:6: warning: no previous prototype for function 'framer_put' [-Wmissing-prototypes] 189 | void framer_put(struct device *dev, struct framer *framer)
framer.h:189:1: note: declare 'static' if the function is not intended to be used outside of this translation unit 189 | void framer_put(struct device *dev, struct framer *framer)
Add missing 'static inline' qualifiers for these functions.
--- include/linux/framer/framer.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
include/linux/framer/framer.h +2 -2
@@ -181,12 +181,12 @@ static inline int framer_notifier_unregireturn -ENOSYS ; } -struct framer *framer_get (struct device *dev,const char *con_id) +static inline struct framer *framer_get (struct device *dev,const char *con_id) {return ERR_PTR (-ENOSYS ); } -void framer_put (struct device *dev,struct framer *framer) +static inline void framer_put (struct device *dev,struct framer *framer) { }
Greg Kroah-Hartman
maintainerPATCH 322/399 net: phy: qcom: at803x: fix kernel panic with at8031_probe
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian Marangi <[email protected]>
commit 6a4aee277740d04ac0fd54cfa17cc28261932ddc upstream.
On reworking and splitting the at803x driver, in splitting function of at803x PHYs it was added a NULL dereference bug where priv is referenced before it's actually allocated and then is tried to write to for the is_1000basex and is_fiber variables in the case of at8031, writing on the wrong address.
Fix this by correctly setting priv local variable only after at803x_probe is called and actually allocates priv in the phydev struct.
--- drivers/net/phy/at803x.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/phy/at803x.c +3 -1
@@ -1503,7 +1503,7 @@ static int at8031_parse_dt(struct phy_destatic int at8031_probe (struct phy_device *phydev) { -struct at803x_priv *priv = phydev->priv; +struct at803x_priv *priv;int mode_cfg;int ccr;int ret;
@@ -1512,6 +1512,8 @@ static int at8031_probe(struct phy_devicif (ret)return ret; + priv = phydev->priv; +/* Only supported on AR8031/AR8033, the AR8030/AR8035 use strapping * options. */
Greg Kroah-Hartman
maintainerPATCH 323/399 drm/xe/query: fix gt_id bounds check
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matthew Auld <[email protected]>
commit 45c30b2923e5c53e0ef057a8a525b0456adde18e upstream.
The user provided gt_id should always be less than the XE_MAX_GT_PER_TILE.
--- drivers/gpu/drm/xe/xe_query.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/xe/xe_query.c +1 -1
@@ -132,7 +132,7 @@ query_engine_cycles(struct xe_device *xe,return -EINVAL ; eci = &resp.eci; -if (eci->gt_id >XE_MAX_GT_PER_TILE ) +if (eci->gt_id >=XE_MAX_GT_PER_TILE )return -EINVAL ; gt =xe_device_get_gt (xe, eci->gt_id);
Signature · 1 line
2.44.0
Greg Kroah-Hartman
maintainerPATCH 324/399 drm/dp: Fix divide-by-zero regression on DP MST unplug with nouveau
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chris Bainbridge <[email protected]>
commit 9cbd1dae842737bfafa4b10a87909fa209dde250 upstream.
Fix a regression when using nouveau and unplugging a StarTech MSTDP122DP DisplayPort 1.2 MST hub (the same regression does not appear when using a Cable Matters DisplayPort 1.4 MST hub). Trace:
divide error: 0000 [#1] PREEMPT SMP PTI
CPU: 7 PID: 2962 Comm: Xorg Not tainted 6.8.0-rc3+ #744 Hardware name: Razer Blade/DANA_MB, BIOS 01.01 08/31/2018 RIP: 0010:drm_dp_bw_overhead+0xb4/0x110 [drm_display_helper] Code: c6 b8 01 00 00 00 75 61 01 c6 41 0f af f3 41 0f af f1 c1 e1 04 48 63 c7 31 d2 89 ff 48 8b 5d f8 c9 48 0f af f1 48 8d 44 06 ff <48> f7 f7 31 d2 31 c9 31 f6 31 ff 45 31 c0 45 31 c9 45 31 d2 45 31 RSP: 0018:ffffb2c5c211fa30 EFLAGS: 00010206 RAX: ffffffffffffffff RBX: 0000000000000000 RCX: 0000000000f59b00 RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000000 RBP: ffffb2c5c211fa48 R08: 0000000000000001 R09: 0000000000000020 R10: 0000000000000004 R11: 0000000000000000 R12: 0000000000023b4a R13: ffff91d37d165800 R14: ffff91d36fac6d80 R15: ffff91d34a764010 FS: 00007f4a1ca3fa80(0000) GS:ffff91d6edbc0000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000559491d49000 CR3: 000000011d180002 CR4: 00000000003706f0 Call Trace: <TASK> ? show_regs+0x6d/0x80 ? die+0x37/0xa0 ? do_trap+0xd4/0xf0 ? do_error_trap+0x71/0xb0 ? drm_dp_bw_overhead+0xb4/0x110 [drm_display_helper] ? exc_divide_error+0x3a/0x70 ? drm_dp_bw_overhead+0xb4/0x110 [drm_display_helper] ? asm_exc_divide_error+0x1b/0x20 ? drm_dp_bw_overhead+0xb4/0x110 [drm_display_helper] ? drm_dp_calc_pbn_mode+0x2e/0x70 [drm_display_helper] nv50_msto_atomic_check+0xda/0x120 [nouveau] drm_atomic_helper_check_modeset+0xa87/0xdf0 [drm_kms_helper] drm_atomic_helper_check+0x19/0xa0 [drm_kms_helper] nv50_disp_atomic_check+0x13f/0x2f0 [nouveau] drm_atomic_check_only+0x668/0xb20 [drm] ? drm_connector_list_iter_next+0x86/0xc0 [drm] drm_atomic_commit+0x58/0xd0 [drm] ? __pfx___drm_printfn_info+0x10/0x10 [drm] drm_atomic_connector_commit_dpms+0xd7/0x100 [drm] drm_mode_obj_set_property_ioctl+0x1c5/0x450 [drm] ? __pfx_drm_connector_property_set_ioctl+0x10/0x10 [drm] drm_connector_property_set_ioctl+0x3b/0x60 [drm] drm_ioctl_kernel+0xb9/0x120 [drm] drm_ioctl+0x2d0/0x550 [drm] ? __pfx_drm_connector_property_set_ioctl+0x10/0x10 [drm] nouveau_drm_ioctl+0x61/0xc0 [nouveau] __x64_sys_ioctl+0xa0/0xf0 do_syscall_64+0x76/0x140 ? do_syscall_64+0x85/0x140 ? do_syscall_64+0x85/0x140 entry_SYSCALL_64_after_hwframe+0x6e/0x76 RIP: 0033:0x7f4a1cd1a94f Code: 00 48 89 44 24 18 31 c0 48 8d 44 24 60 c7 04 24 10 00 00 00 48 89 44 24 08 48 8d 44 24 20 48 89 44 24 10 b8 10 00 00 00 0f 05 <41> 89 c0 3d 00 f0 ff ff 77 1f 48 8b 44 24 18 64 48 2b 04 25 28 00 RSP: 002b:00007ffd2f1df520 EFLAGS: 00000246 ORIG_RAX: 0000000000000010 RAX: ffffffffffffffda RBX: 00007ffd2f1df5b0 RCX: 00007f4a1cd1a94f RDX: 00007ffd2f1df5b0 RSI: 00000000c01064ab RDI: 000000000000000f RBP: 00000000c01064ab R08: 000056347932deb8 R09: 000056347a7d99c0 R10: 0000000000000000 R11: 0000000000000246 R12: 000056347938a220 R13: 000000000000000f R14: 0000563479d9f3f0 R15: 0000000000000000 </TASK> Modules linked in: rfcomm xt_conntrack nft_chain_nat xt_MASQUERADE nf_nat nf_conntrack_netlink nf_conntrack nf_defrag_ipv6 nf_defrag_ipv4 xfrm_user xfrm_algo xt_addrtype nft_compat nf_tables nfnetlink br_netfilter bridge stp llc ccm cmac algif_hash overlay algif_skcipher af_alg bnep binfmt_misc snd_sof_pci_intel_cnl snd_sof_intel_hda_common snd_soc_hdac_hda snd_sof_pci snd_sof_xtensa_dsp snd_sof_intel_hda snd_sof snd_sof_utils snd_soc_acpi_intel_match snd_soc_acpi snd_soc_core snd_compress snd_sof_intel_hda_mlink snd_hda_ext_core iwlmvm intel_rapl_msr intel_rapl_common intel_tcc_cooling x86_pkg_temp_thermal intel_powerclamp mac80211 coretemp kvm_intel snd_hda_codec_hdmi kvm snd_hda_codec_realtek snd_hda_codec_generic uvcvideo libarc4 snd_hda_intel snd_intel_dspcfg snd_hda_codec iwlwifi videobuf2_vmalloc videobuf2_memops uvc irqbypass btusb videobuf2_v4l2 snd_seq_midi crct10dif_pclmul hid_multitouch crc32_pclmul snd_seq_midi_event btrtl snd_hwdep videodev polyval_clmulni polyval_generic snd_rawmidi ghash_clmulni_intel aesni_intel btintel crypto_simd snd_hda_core cryptd snd_seq btbcm ee1004 8250_dw videobuf2_common btmtk rapl nls_iso8859_1 mei_hdcp thunderbolt bluetooth intel_cstate wmi_bmof intel_wmi_thunderbolt cfg80211 snd_pcm mc snd_seq_device i2c_i801 r8169 ecdh_generic snd_timer i2c_smbus ecc snd mei_me intel_lpss_pci mei ahci intel_lpss soundcore realtek libahci idma64 intel_pch_thermal i2c_hid_acpi i2c_hid acpi_pad sch_fq_codel msr parport_pc ppdev lp parport efi_pstore ip_tables x_tables autofs4 dm_crypt raid10 raid456 libcrc32c async_raid6_recov async_memcpy async_pq async_xor xor async_tx raid6_pq raid1 raid0 joydev input_leds hid_generic usbhid hid nouveau i915 drm_ttm_helper gpu_sched drm_gpuvm drm_exec i2c_algo_bit drm_buddy ttm drm_display_helper drm_kms_helper cec rc_core drm nvme nvme_core mxm_wmi xhci_pci xhci_pci_renesas video wmi pinctrl_cannonlake mac_hid ---[ end trace 0000000000000000 ]---
Fix this by avoiding the divide if bpp is 0.
--- drivers/gpu/drm/display/drm_dp_helper.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/gpu/drm/display/drm_dp_helper.c +7 -0
@@ -3982,6 +3982,13 @@ int drm_dp_bw_overhead(int lane_count, int hactive,u32 overhead =1000000 ;int symbol_cycles; +if (lane_count ==0 || hactive ==0 || bpp_x16 ==0 ) { +DRM_DEBUG_KMS ("Invalid BW overhead params: lane_count %d, hactive %d, bpp_x16 %d.%04d\n" , + lane_count, hactive, + bpp_x16 >>4 , (bpp_x16 &0xf ) *625 ); +return 0 ; + } +/* * DP Standard v2.1 2.6.4.1 * SSC downspread and ref clock variation margin:
Signature · 1 line
2.44.0
Greg Kroah-Hartman
maintainerPATCH 325/399 drm/vmwgfx: Create debugfs ttm_resource_manager entry only if needed
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jocelyn Falempe <[email protected]>
commit 4be9075fec0a639384ed19975634b662bfab938f upstream.
The driver creates /sys/kernel/debug/dri/0/mob_ttm even when the corresponding ttm_resource_manager is not allocated. This leads to a crash when trying to read from this file.
Add a check to create mob_ttm, system_mob_ttm, and gmr_ttm debug file only when the corresponding ttm_resource_manager is allocated.
crash> bt
PID: 3133409 TASK: ffff8fe4834a5000 CPU: 3 COMMAND: "grep"
#0 [ffffb954506b3b20] machine_kexec at ffffffffb2a6bec3 #1 [ffffb954506b3b78] __crash_kexec at ffffffffb2bb598a #2 [ffffb954506b3c38] crash_kexec at ffffffffb2bb68c1 #3 [ffffb954506b3c50] oops_end at ffffffffb2a2a9b1
#4 [ffffb954506b3c70] no_context at ffffffffb2a7e913 #5 [ffffb954506b3cc8] __bad_area_nosemaphore at ffffffffb2a7ec8c #6 [ffffb954506b3d10] do_page_fault at ffffffffb2a7f887 #7 [ffffb954506b3d40] page_fault at ffffffffb360116e
[exception RIP: ttm_resource_manager_debug+0x11]
RIP: ffffffffc04afd11 RSP: ffffb954506b3df0 RFLAGS: 00010246
RAX: ffff8fe41a6d1200 RBX: 0000000000000000 RCX: 0000000000000940
RDX: 0000000000000000 RSI: ffffffffc04b4338 RDI: 0000000000000000
RBP: ffffb954506b3e08 R8: ffff8fee3ffad000 R9: 0000000000000000
R10: ffff8fe41a76a000 R11: 0000000000000001 R12: 00000000ffffffff
R13: 0000000000000001 R14: ffff8fe5bb6f3900 R15: ffff8fe41a6d1200
ORIG_RAX: ffffffffffffffff CS: 0010 SS: 0018
#8 [ffffb954506b3e00] ttm_resource_manager_show at ffffffffc04afde7 [ttm]
#9 [ffffb954506b3e30] seq_read at ffffffffb2d8f9f3
RIP: 00007f4c4eda8985 RSP: 00007ffdbba9e9f8 RFLAGS: 00000246
RAX: ffffffffffffffda RBX: 000000000037e000 RCX: 00007f4c4eda8985
RDX: 000000000037e000 RSI: 00007f4c41573000 RDI: 0000000000000003
RBP: 000000000037e000 R8: 0000000000000000 R9: 000000000037fe30
R10: 0000000000000000 R11: 0000000000000246 R12: 00007f4c41573000
R13: 0000000000000003 R14: 00007f4c41572010 R15: 0000000000000003
ORIG_RAX: 0000000000000000 CS: 0033 SS: 002b--- drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +9 -6
@@ -1444,12 +1444,15 @@ static void vmw_debugfs_resource_manager root, "system_ttm");ttm_resource_manager_create_debugfs (ttm_manager_type (&vmw->bdev,TTM_PL_VRAM ), root,"vram_ttm" ); -ttm_resource_manager_create_debugfs (ttm_manager_type (&vmw->bdev,VMW_PL_GMR ), - root,"gmr_ttm" ); -ttm_resource_manager_create_debugfs (ttm_manager_type (&vmw->bdev,VMW_PL_MOB ), - root,"mob_ttm" ); -ttm_resource_manager_create_debugfs (ttm_manager_type (&vmw->bdev,VMW_PL_SYSTEM ), - root,"system_mob_ttm" ); +if (vmw->has_gmr) +ttm_resource_manager_create_debugfs (ttm_manager_type (&vmw->bdev,VMW_PL_GMR ), + root,"gmr_ttm" ); +if (vmw->has_mob) { +ttm_resource_manager_create_debugfs (ttm_manager_type (&vmw->bdev,VMW_PL_MOB ), + root,"mob_ttm" ); +ttm_resource_manager_create_debugfs (ttm_manager_type (&vmw->bdev,VMW_PL_SYSTEM ), + root,"system_mob_ttm" ); + } } static int vmwgfx_pm_notifier(struct notifier_block *nb, unsigned long val,
Greg Kroah-Hartman
maintainerPATCH 326/399 drm/amdkfd: fix TLB flush after unmap for GFX9.4.2
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Huang <[email protected]>
commit 1210e2f1033dc56b666c9f6dfb761a2d3f9f5d6c upstream.
TLB flush after unmap accidentially was removed on gfx9.4.2. It is to add it back.
--- drivers/gpu/drm/amd/amdkfd/kfd_priv.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdkfd/kfd_priv.h +1 -1
@@ -1473,7 +1473,7 @@ static inline void kfd_flush_tlb(structstatic inline bool kfd_flush_tlb_after_unmap (struct kfd_dev *dev) { -return KFD_GC_VERSION (dev) >IP_VERSION (9 ,4 ,2 ) || +return KFD_GC_VERSION (dev) >=IP_VERSION (9 ,4 ,2 ) || (KFD_GC_VERSION (dev) ==IP_VERSION (9 ,4 ,1 ) && dev->sdma_fw_version >=18 ) ||KFD_GC_VERSION (dev) ==IP_VERSION (9 ,4 ,0 ); }
Greg Kroah-Hartman
maintainerPATCH 327/399 drm/amdgpu: fix deadlock while reading mqd from debugfs
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Weiner <[email protected]>
commit 8678b1060ae2b75feb60b87e5b75e17374e3c1c5 upstream.
An errant disk backup on my desktop got into debugfs and triggered the following deadlock scenario in the amdgpu debugfs files. The machine also hard-resets immediately after those lines are printed (although I wasn't able to reproduce that part when reading by hand):
[ 1318.016074][ T1082] ======================================================
[ 1318.016607][ T1082] WARNING: possible circular locking dependency detected
[ 1318.017107][ T1082] 6.8.0-rc7-00015-ge0c8221b72c0 #17 Not tainted
[ 1318.017598][ T1082] ------------------------------------------------------
[ 1318.018096][ T1082] tar/1082 is trying to acquire lock:
[ 1318.018585][ T1082] ffff98c44175d6a0 (&mm->mmap_lock){++++}-{3:3}, at: __might_fault+0x40/0x80
[ 1318.019084][ T1082]
[ 1318.019084][ T1082] but task is already holding lock:
[ 1318.020052][ T1082] ffff98c4c13f55f8 (reservation_ww_class_mutex){+.+.}-{3:3}, at: amdgpu_debugfs_mqd_read+0x6a/0x250 [amdgpu]
[ 1318.020607][ T1082]
[ 1318.020607][ T1082] which lock already depends on the new lock.
[ 1318.020607][ T1082]
[ 1318.022081][ T1082]
[ 1318.022081][ T1082] the existing dependency chain (in reverse order) is:
[ 1318.023083][ T1082]
[ 1318.023083][ T1082] -> #2 (reservation_ww_class_mutex){+.+.}-{3:3}:
[ 1318.024114][ T1082] __ww_mutex_lock.constprop.0+0xe0/0x12f0
[ 1318.024639][ T1082] ww_mutex_lock+0x32/0x90
[ 1318.025161][ T1082] dma_resv_lockdep+0x18a/0x330
[ 1318.025683][ T1082] do_one_initcall+0x6a/0x350
[ 1318.026210][ T1082] kernel_init_freeable+0x1a3/0x310
[ 1318.026728][ T1082] kernel_init+0x15/0x1a0
[ 1318.027242][ T1082] ret_from_fork+0x2c/0x40
[ 1318.027759][ T1082] ret_from_fork_asm+0x11/0x20
[ 1318.028281][ T1082]
[ 1318.028281][ T1082] -> #1 (reservation_ww_class_acquire){+.+.}-{0:0}:
[ 1318.029297][ T1082] dma_resv_lockdep+0x16c/0x330
[ 1318.029790][ T1082] do_one_initcall+0x6a/0x350
[ 1318.030263][ T1082] kernel_init_freeable+0x1a3/0x310
[ 1318.030722][ T1082] kernel_init+0x15/0x1a0
[ 1318.031168][ T1082] ret_from_fork+0x2c/0x40
[ 1318.031598][ T1082] ret_from_fork_asm+0x11/0x20
[ 1318.032011][ T1082]
[ 1318.032011][ T1082] -> #0 (&mm->mmap_lock){++++}-{3:3}:
[ 1318.032778][ T1082] __lock_acquire+0x14bf/0x2680
[ 1318.033141][ T1082] lock_acquire+0xcd/0x2c0
[ 1318.033487][ T1082] __might_fault+0x58/0x80
[ 1318.033814][ T1082] amdgpu_debugfs_mqd_read+0x103/0x250 [amdgpu]
[ 1318.034181][ T1082] full_proxy_read+0x55/0x80
[ 1318.034487][ T1082] vfs_read+0xa7/0x360
[ 1318.034788][ T1082] ksys_read+0x70/0xf0
[ 1318.035085][ T1082] do_syscall_64+0x94/0x180
[ 1318.035375][ T1082] entry_SYSCALL_64_after_hwframe+0x46/0x4e
[ 1318.035664][ T1082]
[ 1318.035664][ T1082] other info that might help us debug this:
[ 1318.035664][ T1082]
[ 1318.036487][ T1082] Chain exists of:
[ 1318.036487][ T1082] &mm->mmap_lock --> reservation_ww_class_acquire --> reservation_ww_class_mutex
[ 1318.036487][ T1082]
[ 1318.037310][ T1082] Possible unsafe locking scenario:
[ 1318.037310][ T1082]
[ 1318.037838][ T1082] CPU0 CPU1
[ 1318.038101][ T1082] ---- ----
[ 1318.038350][ T1082] lock(reservation_ww_class_mutex);
[ 1318.038590][ T1082] lock(reservation_ww_class_acquire);
[ 1318.038839][ T1082] lock(reservation_ww_class_mutex);
[ 1318.039083][ T1082] rlock(&mm->mmap_lock);
[ 1318.039328][ T1082]
[ 1318.039328][ T1082] *** DEADLOCK ***
[ 1318.039328][ T1082]
[ 1318.040029][ T1082] 1 lock held by tar/1082:
[ 1318.040259][ T1082] #0: ffff98c4c13f55f8 (reservation_ww_class_mutex){+.+.}-{3:3}, at: amdgpu_debugfs_mqd_read+0x6a/0x250 [amdgpu]
[ 1318.040560][ T1082]
[ 1318.040560][ T1082] stack backtrace:
[ 1318.041053][ T1082] CPU: 22 PID: 1082 Comm: tar Not tainted 6.8.0-rc7-00015-ge0c8221b72c0 #17 3316c85d50e282c5643b075d1f01a4f6365e39c2
[ 1318.041329][ T1082] Hardware name: Gigabyte Technology Co., Ltd. B650 AORUS PRO AX/B650 AORUS PRO AX, BIOS F20 12/14/2023
[ 1318.041614][ T1082] Call Trace:
[ 1318.041895][ T1082] <TASK>
[ 1318.042175][ T1082] dump_stack_lvl+0x4a/0x80
[ 1318.042460][ T1082] check_noncircular+0x145/0x160
[ 1318.042743][ T1082] __lock_acquire+0x14bf/0x2680
[ 1318.043022][ T1082] lock_acquire+0xcd/0x2c0
[ 1318.043301][ T1082] ? __might_fault+0x40/0x80
[ 1318.043580][ T1082] ? __might_fault+0x40/0x80
[ 1318.043856][ T1082] __might_fault+0x58/0x80
[ 1318.044131][ T1082] ? __might_fault+0x40/0x80
[ 1318.044408][ T1082] amdgpu_debugfs_mqd_read+0x103/0x250 [amdgpu 8fe2afaa910cbd7654c8cab23563a94d6caebaab]
[ 1318.044749][ T1082] full_proxy_read+0x55/0x80
[ 1318.045042][ T1082] vfs_read+0xa7/0x360
[ 1318.045333][ T1082] ksys_read+0x70/0xf0
[ 1318.045623][ T1082] do_syscall_64+0x94/0x180
[ 1318.045913][ T1082] ? do_syscall_64+0xa0/0x180
[ 1318.046201][ T1082] ? lockdep_hardirqs_on+0x7d/0x100
[ 1318.046487][ T1082] ? do_syscall_64+0xa0/0x180
[ 1318.046773][ T1082] ? do_syscall_64+0xa0/0x180
[ 1318.047057][ T1082] ? do_syscall_64+0xa0/0x180
[ 1318.047337][ T1082] ? do_syscall_64+0xa0/0x180
[ 1318.047611][ T1082] entry_SYSCALL_64_after_hwframe+0x46/0x4e
[ 1318.047887][ T1082] RIP: 0033:0x7f480b70a39d
[ 1318.048162][ T1082] Code: 91 ba 0d 00 f7 d8 64 89 02 b8 ff ff ff ff eb b2 e8 18 a3 01 00 0f 1f 84 00 00 00 00 00 80 3d a9 3c 0e 00 00 74 17 31 c0 0f 05 <48> 3d 00 f0 ff ff 77 5b c3 66 2e 0f 1f 84 00 00 00 00 00 53 48 83
[ 1318.048769][ T1082] RSP: 002b:00007ffde77f5c68 EFLAGS: 00000246 ORIG_RAX: 0000000000000000
[ 1318.049083][ T1082] RAX: ffffffffffffffda RBX: 0000000000000800 RCX: 00007f480b70a39d
[ 1318.049392][ T1082] RDX: 0000000000000800 RSI: 000055c9f2120c00 RDI: 0000000000000008
[ 1318.049703][ T1082] RBP: 0000000000000800 R08: 000055c9f2120a94 R09: 0000000000000007
[ 1318.050011][ T1082] R10: 0000000000000000 R11: 0000000000000246 R12: 000055c9f2120c00
[ 1318.050324][ T1082] R13: 0000000000000008 R14: 0000000000000008 R15: 0000000000000800
[ 1318.050638][ T1082] </TASK>amdgpu_debugfs_mqd_read() holds a reservation when it calls put_user(), which may fault and acquire the mmap_sem. This violates the established locking order.
Bounce the mqd data through a kernel buffer to get put_user() out of the illegal section.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | 46 +++++++++++++++++++------------ 1 file changed, 29 insertions(+), 17 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +29 -17
@@ -524,46 +524,58 @@ static ssize_t amdgpu_debugfs_mqd_read(s {struct amdgpu_ring *ring =file_inode (f)->i_private;volatile u32 *mqd; -int r; +u32 *kbuf; +int r, i;uint32_t value, result;if (*pos &3 || size &3 )return -EINVAL ; - result =0 ; + kbuf =kmalloc (ring->mqd_size,GFP_KERNEL ); +if (!kbuf) +return -ENOMEM ; r =amdgpu_bo_reserve (ring->mqd_obj, false);if (unlikely (r !=0 )) -return r; + goto err_free; r =amdgpu_bo_kmap (ring->mqd_obj, (void **)&mqd); -if (r) { -amdgpu_bo_unreserve (ring->mqd_obj); -return r; - } +if (r) + goto err_unreserve; + +/* +* Copy to local buffer to avoid put_user(), which might fault +* and acquire mmap_sem, under reservation_ww_class_mutex. +*/ +for (i =0 ; i < ring->mqd_size/sizeof (u32); i++) + kbuf[i] = mqd[i]; + +amdgpu_bo_kunmap (ring->mqd_obj); +amdgpu_bo_unreserve (ring->mqd_obj); + result =0 ;while (size) {if (*pos >= ring->mqd_size) - goto done; +break ; - value = mqd[*pos/4 ]; + value = kbuf[*pos/4 ]; r =put_user (value, (uint32_t *)buf);if (r) - goto done; + goto err_free; buf +=4 ; result +=4 ; size -=4 ; *pos +=4 ; } -done: -amdgpu_bo_kunmap (ring->mqd_obj); - mqd =NULL ; -amdgpu_bo_unreserve (ring->mqd_obj); -if (r) -return r; - +kfree (kbuf);return result; + +err_unreserve: +amdgpu_bo_unreserve (ring->mqd_obj); +err_free: +kfree (kbuf); +return r; }static const struct file_operations amdgpu_debugfs_mqd_fops = {
Greg Kroah-Hartman
maintainerPATCH 328/399 drm/amd/display: Remove MPC rate control logic from DCN30 and above
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: George Shen <[email protected]>
commit edfa93d87fc46913868481fe8ed3fb62c891ffb5 upstream.
[Why]
MPC flow rate control is not needed for DCN30 and above. Current logic that uses it can result in underflow for certain edge cases (such as DSC N422 + ODM combine + 422 left edge pixel).
[How]
Remove MPC flow rate control logic and programming for DCN30 and above.
--- drivers/gpu/drm/amd/display/dc/dcn30/dcn30_mpc.c | 54 ++++++++------ drivers/gpu/drm/amd/display/dc/dcn30/dcn30_mpc.h | 14 +-- drivers/gpu/drm/amd/display/dc/dcn32/dcn32_mpc.c | 5 - drivers/gpu/drm/amd/display/dc/hwss/dcn314/dcn314_hwseq.c | 41 ---------- drivers/gpu/drm/amd/display/dc/hwss/dcn32/dcn32_hwseq.c | 41 ---------- drivers/gpu/drm/amd/display/dc/hwss/dcn35/dcn35_hwseq.c | 41 ---------- 6 files changed, 41 insertions(+), 155 deletions(-)
drivers/gpu/drm/amd/display/dc/dcn30/dcn30_mpc.c +32 -22
@@ -44,6 +44,36 @@#define NUM_ELEMENTS (a) (sizeof(a) / sizeof((a)[0])) +void mpc3_mpc_init (struct mpc *mpc) +{ +struct dcn30_mpc *mpc30 =TO_DCN30_MPC (mpc); +int opp_id; + +mpc1_mpc_init (mpc); + +for (opp_id =0 ; opp_id <MAX_OPP ; opp_id++) { +if (REG (MUX [opp_id])) +/* disable mpc out rate and flow control */ +REG_UPDATE_2 (MUX [opp_id],MPC_OUT_RATE_CONTROL_DISABLE , +1 ,MPC_OUT_FLOW_CONTROL_COUNT ,0 ); + } +} + +void mpc3_mpc_init_single_inst (struct mpc *mpc,unsigned int mpcc_id) +{ +struct dcn30_mpc *mpc30 =TO_DCN30_MPC (mpc); + +mpc1_mpc_init_single_inst (mpc, mpcc_id); + +/* assuming mpc out mux is connected to opp with the same index at this +* point in time (e.g. transitioning from vbios to driver) +*/ +if (mpcc_id <MAX_OPP &® (MUX [mpcc_id])) +/* disable mpc out rate and flow control */ +REG_UPDATE_2 (MUX [mpcc_id],MPC_OUT_RATE_CONTROL_DISABLE , +1 ,MPC_OUT_FLOW_CONTROL_COUNT ,0 ); +} +bool mpc3_is_dwb_idle (struct mpc *mpc,int dwb_id)
@@ -80,25 +110,6 @@ void mpc3_disable_dwb_mux( MPC_DWB0_MUX, 0xf); } -void mpc3_set_out_rate_control ( -struct mpc *mpc, -int opp_id, -bool enable, -bool rate_2x_mode, -struct mpc_dwb_flow_control *flow_control) -{ -struct dcn30_mpc *mpc30 =TO_DCN30_MPC (mpc); - -REG_UPDATE_2 (MUX [opp_id], -MPC_OUT_RATE_CONTROL_DISABLE , !enable, -MPC_OUT_RATE_CONTROL , rate_2x_mode); - -if (flow_control) -REG_UPDATE_2 (MUX [opp_id], -MPC_OUT_FLOW_CONTROL_MODE , flow_control->flow_ctrl_mode, -MPC_OUT_FLOW_CONTROL_COUNT , flow_control->flow_ctrl_cnt1); -} -enum dc_lut_mode mpc3_get_ogam_current (struct mpc *mpc,int mpcc_id) {/*Contrary to DCN2 and DCN1 wherein a single status register field holds this info;
@@ -1386,8 +1397,8 @@ static const struct mpc_funcs dcn30_mpc_ .read_mpcc_state = mpc1_read_mpcc_state, .insert_plane = mpc1_insert_plane, .remove_mpcc = mpc1_remove_mpcc, - .mpc_init = mpc1_mpc_init, - .mpc_init_single_inst = mpc1_mpc_init_single_inst, + .mpc_init = mpc3_mpc_init, + .mpc_init_single_inst = mpc3_mpc_init_single_inst, .update_blending = mpc2_update_blending, .cursor_lock = mpc1_cursor_lock, .get_mpcc_for_dpp = mpc1_get_mpcc_for_dpp,
@@ -1404,7 +1415,6 @@ static const struct mpc_funcs dcn30_mpc_ .set_dwb_mux = mpc3_set_dwb_mux, .disable_dwb_mux = mpc3_disable_dwb_mux, .is_dwb_idle = mpc3_is_dwb_idle, - .set_out_rate_control = mpc3_set_out_rate_control, .set_gamut_remap = mpc3_set_gamut_remap, .program_shaper = mpc3_program_shaper, .acquire_rmu = mpcc3_acquire_rmu,
drivers/gpu/drm/amd/display/dc/dcn30/dcn30_mpc.h +7 -7
@@ -1007,6 +1007,13 @@ void dcn30_mpc_construct(struct dcn30_mpint num_mpcc, int num_rmu); +void mpc3_mpc_init ( +struct mpc *mpc); + +void mpc3_mpc_init_single_inst ( +struct mpc *mpc, +unsigned int mpcc_id); + bool mpc3_program_shaper( struct mpc *mpc, const struct pwl_params *params,
@@ -1074,13 +1081,6 @@ bool mpc3_is_dwb_idle(struct mpc *mpc, int dwb_id); -void mpc3_set_out_rate_control ( -struct mpc *mpc, -int opp_id, -bool enable, -bool rate_2x_mode, -struct mpc_dwb_flow_control *flow_control); -void mpc3_power_on_ogam_lut (struct mpc *mpc,int mpcc_id,bool power_on);
drivers/gpu/drm/amd/display/dc/dcn32/dcn32_mpc.c +2 -3
@@ -47,7 +47,7 @@ void mpc32_mpc_init(struct mpc *mpc)struct dcn30_mpc *mpc30 =TO_DCN30_MPC (mpc);int mpcc_id; -mpc1_mpc_init (mpc); +mpc3_mpc_init (mpc);if (mpc->ctx->dc->debug.enable_mem_low_power.bits.mpc) {if (mpc30->mpc_mask->MPCC_MCM_SHAPER_MEM_LOW_PWR_MODE && mpc30->mpc_mask->MPCC_MCM_3DLUT_MEM_LOW_PWR_MODE) {
@@ -991,7 +991,7 @@ static const struct mpc_funcs dcn32_mpc_ .insert_plane = mpc1_insert_plane, .remove_mpcc = mpc1_remove_mpcc, .mpc_init = mpc32_mpc_init, - .mpc_init_single_inst = mpc1_mpc_init_single_inst, + .mpc_init_single_inst = mpc3_mpc_init_single_inst, .update_blending = mpc2_update_blending, .cursor_lock = mpc1_cursor_lock, .get_mpcc_for_dpp = mpc1_get_mpcc_for_dpp,
@@ -1008,7 +1008,6 @@ static const struct mpc_funcs dcn32_mpc_ .set_dwb_mux = mpc3_set_dwb_mux, .disable_dwb_mux = mpc3_disable_dwb_mux, .is_dwb_idle = mpc3_is_dwb_idle, - .set_out_rate_control = mpc3_set_out_rate_control, .set_gamut_remap = mpc3_set_gamut_remap, .program_shaper = mpc32_program_shaper, .program_3dlut = mpc32_program_3dlut,
drivers/gpu/drm/amd/display/dc/hwss/dcn314/dcn314_hwseq.c +0 -41
59 lines not on this page · raw message
drivers/gpu/drm/amd/display/dc/hwss/dcn32/dcn32_hwseq.c +0 -41
59 lines not on this page · raw message
drivers/gpu/drm/amd/display/dc/hwss/dcn35/dcn35_hwseq.c +0 -41
59 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 329/399 drm/amd/display: Set DCN351 BB and IP the same as DCN35
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xi Liu <[email protected]>
commit 0ccc2b30f4feadc0b1a282dbcc06e396382e5d74 upstream.
[WHY & HOW]
DCN351 and DCN35 should use the same bounding box and IP settings.
--- drivers/gpu/drm/amd/display/dc/dml2/dml2_translation_helper.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/gpu/drm/amd/display/dc/dml2/dml2_translation_helper.c +1 -5
@@ -228,17 +228,13 @@ void dml2_init_socbb_params(struct dml2_break ;case dml_project_dcn35: +case dml_project_dcn351: out->num_chans =4 ; out->round_trip_ping_latency_dcfclk_cycles =106 ; out->smn_latency_us =2 ; out->dispclk_dppclk_vco_speed_mhz =3600 ;break ; -case dml_project_dcn351: - out->num_chans =16 ; - out->round_trip_ping_latency_dcfclk_cycles =1100 ; - out->smn_latency_us =2 ; -break ; }/* ---Overrides if available--- */ if (dml2->config.bbox_overrides.dram_num_chan)
Greg Kroah-Hartman
maintainerPATCH 330/399 drm/i915/hwmon: Fix locking inversion in sysfs getter
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Janusz Krzysztofik <[email protected]>
commit b212b79768ccde74429f872c37618c543fa11333 upstream.
In i915 hwmon sysfs getter path we now take a hwmon_lock, then acquire an rpm wakeref. That results in lock inversion:
<4> [197.079335] ======================================================
<4> [197.085473] WARNING: possible circular locking dependency detected
<4> [197.091611] 6.8.0-rc7-Patchwork_129026v7-gc4dc92fb1152+ #1 Not tainted
<4> [197.098096] ------------------------------------------------------
<4> [197.104231] prometheus-node/839 is trying to acquire lock:
<4> [197.109680] ffffffff82764d80 (fs_reclaim){+.+.}-{0:0}, at: __kmalloc+0x9a/0x350 <4> [197.116939]
but task is already holding lock:
<4> [197.122730] ffff88811b772a40 (&hwmon->hwmon_lock){+.+.}-{3:3}, at: hwm_energy+0x4b/0x100 [i915] <4> [197.131543]
which lock already depends on the new lock.
...
<4> [197.507922] Chain exists of:
fs_reclaim --> >->reset.mutex --> &hwmon->hwmon_lock
<4> [197.518528] Possible unsafe locking scenario:
<4> [197.524411] CPU0 CPU1 <4> [197.528916] ---- ----
<4> [197.533418] lock(&hwmon->hwmon_lock);
<4> [197.537237] lock(>->reset.mutex);
<4> [197.543376] lock(&hwmon->hwmon_lock);
<4> [197.549682] lock(fs_reclaim);
...
<4> [197.632548] Call Trace:
<4> [197.634990] <TASK> <4> [197.637088] dump_stack_lvl+0x64/0xb0 <4> [197.640738] check_noncircular+0x15e/0x180 <4> [197.652968] check_prev_add+0xe9/0xce0 <4> [197.656705] __lock_acquire+0x179f/0x2300 <4> [197.660694] lock_acquire+0xd8/0x2d0 <4> [197.673009] fs_reclaim_acquire+0xa1/0xd0 <4> [197.680478] __kmalloc+0x9a/0x350 <4> [197.689063] acpi_ns_internalize_name.part.0+0x4a/0xb0 <4> [197.694170] acpi_ns_get_node_unlocked+0x60/0xf0 <4> [197.720608] acpi_ns_get_node+0x3b/0x60 <4> [197.724428] acpi_get_handle+0x57/0xb0 <4> [197.728164] acpi_has_method+0x20/0x50 <4> [197.731896] acpi_pci_set_power_state+0x43/0x120 <4> [197.736485] pci_power_up+0x24/0x1c0 <4> [197.740047] pci_pm_default_resume_early+0x9/0x30 <4> [197.744725] pci_pm_runtime_resume+0x2d/0x90 <4> [197.753911] __rpm_callback+0x3c/0x110 <4> [197.762586] rpm_callback+0x58/0x70 <4> [197.766064] rpm_resume+0x51e/0x730 <4> [197.769542] rpm_resume+0x267/0x730 <4> [197.773020] rpm_resume+0x267/0x730 <4> [197.776498] rpm_resume+0x267/0x730 <4> [197.779974] __pm_runtime_resume+0x49/0x90 <4> [197.784055] __intel_runtime_pm_get+0x19/0xa0 [i915] <4> [197.789070] hwm_energy+0x55/0x100 [i915] <4> [197.793183] hwm_read+0x9a/0x310 [i915] <4> [197.797124] hwmon_attr_show+0x36/0x120 <4> [197.800946] dev_attr_show+0x15/0x60 <4> [197.804509] sysfs_kf_seq_show+0xb5/0x100
Acquire the wakeref before the lock and hold it as long as the lock is also held. Follow that pattern across the whole source file where similar lock inversion can happen.
v2: Keep hardware read under the lock so the whole operation of updating
energy from hardware is still atomic (Guenter),
- instead, acquire the rpm wakeref before the lock and hold it as long as the lock is held,
- use the same aproach for other similar places across the i915_hwmon.c source file (Rodrigo).
--- drivers/gpu/drm/i915/i915_hwmon.c | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-)
drivers/gpu/drm/i915/i915_hwmon.c +19 -18
@@ -72,12 +72,13 @@ hwm_locked_with_pm_intel_uncore_rmw(strustruct intel_uncore *uncore = ddat->uncore;intel_wakeref_t wakeref; -mutex_lock (&hwmon->hwmon_lock); + with_intel_runtime_pm(uncore->rpm, wakeref) { +mutex_lock (&hwmon->hwmon_lock); - with_intel_runtime_pm(uncore->rpm, wakeref)intel_uncore_rmw (uncore, reg, clear, set); -mutex_unlock (&hwmon->hwmon_lock); +mutex_unlock (&hwmon->hwmon_lock); + } }/*
@@ -136,20 +137,21 @@ hwm_energy(struct hwm_drvdata *ddat, lonelse rgaddr = hwmon->rg.energy_status_all; -mutex_lock (&hwmon->hwmon_lock); + with_intel_runtime_pm(uncore->rpm, wakeref) { +mutex_lock (&hwmon->hwmon_lock); -with_intel_runtime_pm (uncore->rpm, wakeref) reg_val =intel_uncore_read (uncore, rgaddr); -if (reg_val >= ei->reg_val_prev) - ei->accum_energy += reg_val - ei->reg_val_prev; -else - ei->accum_energy +=UINT_MAX - ei->reg_val_prev + reg_val; - ei->reg_val_prev = reg_val; +if (reg_val >= ei->reg_val_prev) + ei->accum_energy += reg_val - ei->reg_val_prev; +else + ei->accum_energy +=UINT_MAX - ei->reg_val_prev + reg_val; + ei->reg_val_prev = reg_val; - *energy =mul_u64_u32_shr (ei->accum_energy,SF_ENERGY , - hwmon->scl_shift_energy); -mutex_unlock (&hwmon->hwmon_lock); + *energy =mul_u64_u32_shr (ei->accum_energy,SF_ENERGY , + hwmon->scl_shift_energy); +mutex_unlock (&hwmon->hwmon_lock); + } } static ssize_t
@@ -404,6 +406,7 @@ hwm_power_max_write(struct hwm_drvdata */* Block waiting for GuC reset to complete when needed */ for (;;) { + wakeref =intel_runtime_pm_get (ddat->uncore->rpm);mutex_lock (&hwmon->hwmon_lock);prepare_to_wait (&ddat->waitq, &wait,TASK_INTERRUPTIBLE );
@@ -417,14 +420,13 @@ hwm_power_max_write(struct hwm_drvdata * }mutex_unlock (&hwmon->hwmon_lock); +intel_runtime_pm_put (ddat->uncore->rpm, wakeref);schedule (); }finish_wait (&ddat->waitq, &wait);if (ret) - goto unlock; - - wakeref =intel_runtime_pm_get (ddat->uncore->rpm); + goto exit;/* Disable PL1 limit and verify, because the limit cannot be disabled on all platforms */ if (val ==PL1_DISABLE ) {
@@ -444,9 +446,8 @@ hwm_power_max_write(struct hwm_drvdata *intel_uncore_rmw (ddat->uncore, hwmon->rg.pkg_rapl_limit,PKG_PWR_LIM_1_EN |PKG_PWR_LIM_1 , nval); exit: -intel_runtime_pm_put (ddat->uncore->rpm, wakeref); -unlock:mutex_unlock (&hwmon->hwmon_lock); +intel_runtime_pm_put (ddat->uncore->rpm, wakeref);return ret; }
Greg Kroah-Hartman
maintainerPATCH 331/399 drm/i915/vma: Fix UAF on destroy against retire race
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Janusz Krzysztofik <[email protected]>
commit 0e45882ca829b26b915162e8e86dbb1095768e9e upstream.
Object debugging tools were sporadically reporting illegal attempts to free a still active i915 VMA object when parking a GT believed to be idle.
[161.359441] ODEBUG: free active (active state 0) object: ffff88811643b958 object type: i915_active hint: __i915_vma_active+0x0/0x50 [i915] [161.360082] WARNING: CPU: 5 PID: 276 at lib/debugobjects.c:514 debug_print_object+0x80/0xb0 ... [161.360304] CPU: 5 PID: 276 Comm: kworker/5:2 Not tainted 6.5.0-rc1-CI_DRM_13375-g003f860e5577+ #1 [161.360314] Hardware name: Intel Corporation Rocket Lake Client Platform/RocketLake S UDIMM 6L RVP, BIOS RKLSFWI1.R00.3173.A03.2204210138 04/21/2022 [161.360322] Workqueue: i915-unordered __intel_wakeref_put_work [i915] [161.360592] RIP: 0010:debug_print_object+0x80/0xb0 ... [161.361347] debug_object_free+0xeb/0x110 [161.361362] i915_active_fini+0x14/0x130 [i915] [161.361866] release_references+0xfe/0x1f0 [i915] [161.362543] i915_vma_parked+0x1db/0x380 [i915] [161.363129] __gt_park+0x121/0x230 [i915] [161.363515] ____intel_wakeref_put_last+0x1f/0x70 [i915]
That has been tracked down to be happening when another thread is deactivating the VMA inside __active_retire() helper, after the VMA's active counter has been already decremented to 0, but before deactivation of the VMA's object is reported to the object debugging tool.
We could prevent from that race by serializing i915_active_fini() with __active_retire() via ref->tree_lock, but that wouldn't stop the VMA from being used, e.g. from __i915_vma_retire() called at the end of __active_retire(), after that VMA has been already freed by a concurrent i915_vma_destroy() on return from the i915_active_fini(). Then, we should rather fix the issue at the VMA level, not in i915_active.
Since __i915_vma_parked() is called from __gt_park() on last put of the GT's wakeref, the issue could be addressed by holding the GT wakeref long enough for __active_retire() to complete before that wakeref is released and the GT parked.
I believe the issue was introduced by commit d93939730347 ("drm/i915:
Remove the vma refcount") which moved a call to i915_active_fini() from a dropped i915_vma_release(), called on last put of the removed VMA kref, to i915_vma_parked() processing path called on last put of a GT wakeref. However, its visibility to the object debugging tool was suppressed by a bug in i915_active that was fixed two weeks later with commit e92eb246feb9 ("drm/i915/active: Fix missing debug object activation").
A VMA associated with a request doesn't acquire a GT wakeref by itself. Instead, it depends on a wakeref held directly by the request's active intel_context for a GT associated with its VM, and indirectly on that intel_context's engine wakeref if the engine belongs to the same GT as the VMA's VM. Those wakerefs are released asynchronously to VMA deactivation.
Fix the issue by getting a wakeref for the VMA's GT when activating it, and putting that wakeref only after the VMA is deactivated. However, exclude global GTT from that processing path, otherwise the GPU never goes idle. Since __i915_vma_retire() may be called from atomic contexts, use async variant of wakeref put. Also, to avoid circular locking dependency, take care of acquiring the wakeref before VM mutex when both are needed.
v7: Add inline comments with justifications for:
- using untracked variants of intel_gt_pm_get/put() (Nirmoy),
- using async variant of _put(),
- not getting the wakeref in case of a global GTT,
- always getting the first wakeref outside vm->mutex.
v6: Since __i915_vma_active/retire() callbacks are not serialized, storing
a wakeref tracking handle inside struct i915_vma is not safe, and there is no other good place for that. Use untracked variants of intel_gt_pm_get/put_async().
v5: Replace "tile" with "GT" across commit description (Rodrigo),
- avoid mentioning multi-GT case in commit description (Rodrigo),
- explain why we need to take a temporary wakeref unconditionally inside
i915_vma_pin_ww() (Rodrigo).
v4: Refresh on top of commit 5e4e06e4087e ("drm/i915: Track gt pm
wakerefs") (Andi), - for more easy backporting, split out removal of former insufficient workarounds and move them to separate patches (Nirmoy).
- clean up commit message and description a bit.
v3: Identify root cause more precisely, and a commit to blame,
- identify and drop former workarounds,
- update commit message and description.
v2: Get the wakeref before VM mutex to avoid circular locking dependency,
- drop questionable Fixes: tag.
--- drivers/gpu/drm/i915/i915_vma.c | 50 ++++++++++++++++++++++++++++++++++------ 1 file changed, 43 insertions(+), 7 deletions(-)
drivers/gpu/drm/i915/i915_vma.c +43 -7
@@ -34,6 +34,7 @@#include "gt/intel_engine.h" #include "gt/intel_engine_heartbeat.h" #include "gt/intel_gt.h" +#include "gt/intel_gt_pm.h" #include "gt/intel_gt_requests.h" #include "gt/intel_tlb.h"
@@ -103,12 +104,42 @@ static inline struct i915_vma *active_tostatic int __i915_vma_active (struct i915_active *ref) { -return i915_vma_tryget (active_to_vma (ref)) ?0 : -ENOENT ; +struct i915_vma *vma =active_to_vma (ref); + +if (!i915_vma_tryget (vma)) +return -ENOENT ; + +/* +* Exclude global GTT VMA from holding a GT wakeref +* while active, otherwise GPU never goes idle. +*/ +if (!i915_vma_is_ggtt (vma)) { +/* +* Since we and our _retire() counterpart can be +* called asynchronously, storing a wakeref tracking +* handle inside struct i915_vma is not safe, and +* there is no other good place for that. Hence, +* use untracked variants of intel_gt_pm_get/put(). +*/ +intel_gt_pm_get_untracked (vma->vm->gt); + } + +return 0 ; }static void __i915_vma_retire (struct i915_active *ref) { -i915_vma_put (active_to_vma (ref)); +struct i915_vma *vma =active_to_vma (ref); + +if (!i915_vma_is_ggtt (vma)) { +/* +* Since we can be called from atomic contexts, +* use an async variant of intel_gt_pm_put(). +*/ +intel_gt_pm_put_async_untracked (vma->vm->gt); + } + +i915_vma_put (vma); } static struct i915_vma *
@@ -1404,7 +1435,7 @@ int i915_vma_pin_ww(struct i915_vma *vmastruct i915_vma_work *work =NULL ;struct dma_fence *moving =NULL ;struct i915_vma_resource *vma_res =NULL ; -intel_wakeref_t wakeref =0 ; +intel_wakeref_t wakeref;unsigned int bound;int err;
@@ -1424,8 +1455,14 @@ int i915_vma_pin_ww(struct i915_vma *vmaif (err)return err; -if (flags &PIN_GLOBAL ) - wakeref =intel_runtime_pm_get (&vma->vm->i915->runtime_pm); +/* +* In case of a global GTT, we must hold a runtime-pm wakeref +* while global PTEs are updated. In other cases, we hold +* the rpm reference while the VMA is active. Since runtime +* resume may require allocations, which are forbidden inside +* vm->mutex, get the first rpm wakeref outside of the mutex. +*/ + wakeref =intel_runtime_pm_get (&vma->vm->i915->runtime_pm);if (flags & vma->vm->bind_async_flags) {/* lock VM */
@@ -1561,8 +1598,7 @@ err_fence:if (work)dma_fence_work_commit_imm (&work->base); err_rpm: -if (wakeref) -intel_runtime_pm_put (&vma->vm->i915->runtime_pm, wakeref); +intel_runtime_pm_put (&vma->vm->i915->runtime_pm, wakeref);if (moving)dma_fence_put (moving);
Greg Kroah-Hartman
maintainerPATCH 332/399 drm/i915/bios: Tolerate devdata==NULL in intel_bios_encoder_supports_dp_dual_mode()
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ville Syrjälä <[email protected]>
commit 32e39bab59934bfd3f37097d4dd85ac5eb0fd549 upstream.
If we have no VBT, or the VBT didn't declare the encoder in question, we won't have the 'devdata' for the encoder. Instead of oopsing just bail early.
We won't be able to tell whether the port is DP++ or not, but so be it.
--- drivers/gpu/drm/i915/display/intel_bios.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/i915/display/intel_bios.c +3 -0
@@ -3344,6 +3344,9 @@ bool intel_bios_encoder_supports_dp_dual {const struct child_device_config *child = &devdata->child; +if (!devdata) +return false; +if (!intel_bios_encoder_supports_dp (devdata) || !intel_bios_encoder_supports_hdmi (devdata))return false;
Greg Kroah-Hartman
maintainerPATCH 333/399 drm/i915/vrr: Generate VRR "safe window" for DSB
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ville Syrjälä <[email protected]>
commit f7d3b9277ff7eb8e84e6f8554d1c2dd78278a572 upstream.
Looks like TRANS_CHICKEN bit 31 means something totally different depending on the platform:
TGL: generate VRR "safe window" for DSB
ADL/DG2: make TRANS_SET_CONTEXT_LATENCY effective with VRR
So far we've only set this on ADL/DG2, but when using DSB+VRR we also need to set it on TGL.
And a quick test on MTL says it doesn't need this bit for either of those purposes, even though it's still documented as valid in bspec.
--- drivers/gpu/drm/i915/display/intel_vrr.c | 7 ++++--- drivers/gpu/drm/i915/i915_reg.h | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-)
drivers/gpu/drm/i915/display/intel_vrr.c +4 -3
@@ -187,10 +187,11 @@ void intel_vrr_set_transcoder_timings(coenum transcoder cpu_transcoder = crtc_state->cpu_transcoder;/* -* TRANS_SET_CONTEXT_LATENCY with VRR enabled -* requires this chicken bit on ADL/DG2. +* This bit seems to have two meanings depending on the platform: +* TGL: generate VRR "safe window" for DSB vblank waits +* ADL/DG2: make TRANS_SET_CONTEXT_LATENCY effective with VRR */ -if (DISPLAY_VER (dev_priv) ==13 ) +if (IS_DISPLAY_VER (dev_priv,12 ,13 ))intel_de_rmw (dev_priv,CHICKEN_TRANS (cpu_transcoder),0 ,PIPE_VBLANK_WITH_DELAY );
drivers/gpu/drm/i915/i915_reg.h +1 -1
@@ -4597,7 +4597,7 @@#define MTL_CHICKEN_TRANS (trans) _MMIO_TRANS((trans), \ _MTL_CHICKEN_TRANS_A, \ _MTL_CHICKEN_TRANS_B) -#define PIPE_VBLANK_WITH_DELAY REG_BIT(31)/* ADL/DG2 */ +#define PIPE_VBLANK_WITH_DELAY REG_BIT(31)/* tgl+ */ #define SKL_UNMASK_VBL_TO_PIPE_IN_SRD REG_BIT(30)/* skl+ */ #define HSW_FRAME_START_DELAY_MASK REG_GENMASK(28, 27)#define HSW_FRAME_START_DELAY (x) REG_FIELD_PREP(HSW_FRAME_START_DELAY_MASK, x)
Greg Kroah-Hartman
maintainerPATCH 334/399 drm/i915/dsi: Go back to the previous INIT_OTP/DISPLAY_ON order, mostly
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ville Syrjälä <[email protected]>
commit 18846627ef1210dcd55d65342b055ea97a46ffff upstream.
Reinstate commit 88b065943cb5 ("drm/i915/dsi: Do display on sequence later on icl+"), for the most part. Turns out some machines (eg. Chuwi Minibook X) really do need that updated order. It is also the order the Windows driver uses.
However we can't just undo the revert since that would again break Lenovo 82TQ. After staring at the VBT sequences for both machines I've concluded that the Lenovo 82TQ sequences look somewhat broken:
- INIT_OTP is not present at all
- what should be in INIT_OTP is found in DISPLAY_ON
- what should be in DISPLAY_ON is found in BACKLIGHT_ON (along with the actual backlight stuff)
The Chuwi Minibook X on the other hand has a full complement of sequences in its VBT.
So let's try to deal with the broken sequences in the Lenovo 82TQ VBT by simply swapping the (non-existent) INIT_OTP sequence with the DISPLAY_ON sequence. Thus we execute DISPLAY_ON when intending to execute INIT_OTP, and execute nothing at all when intending to execute DISPLAY_ON. That should be 100% equivalent to the revert, for such broken VBTs.
References: https://gitlab.freedesktop.org/drm/intel/-/issues/10071
--- drivers/gpu/drm/i915/display/icl_dsi.c | 3 +- drivers/gpu/drm/i915/display/intel_bios.c | 43 +++++++++++++++++++++++++----- 2 files changed, 39 insertions(+), 7 deletions(-)
drivers/gpu/drm/i915/display/icl_dsi.c +2 -1
@@ -1155,7 +1155,6 @@ static void gen11_dsi_powerup_panel(stru }intel_dsi_vbt_exec_sequence (intel_dsi,MIPI_SEQ_INIT_OTP ); -intel_dsi_vbt_exec_sequence (intel_dsi,MIPI_SEQ_DISPLAY_ON );/* ensure all panel commands dispatched before enabling transcoder */ wait_for_cmds_dispatched_to_panel (encoder);
@@ -1256,6 +1255,8 @@ static void gen11_dsi_enable(struct inte/* step6d: enable dsi transcoder */ gen11_dsi_enable_transcoder (encoder); +intel_dsi_vbt_exec_sequence (intel_dsi,MIPI_SEQ_DISPLAY_ON ); +/* step7: enable backlight */ intel_backlight_enable (crtc_state, conn_state);intel_dsi_vbt_exec_sequence (intel_dsi,MIPI_SEQ_BACKLIGHT_ON );
drivers/gpu/drm/i915/display/intel_bios.c +37 -6
59 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 335/399 drm/i915/dsb: Fix DSB vblank waits when using VRR
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ville Syrjälä <[email protected]>
commit f12751168f1a49ebb84b8056cf038973c53b284f upstream.
Looks like the undelayed vblank gets signalled exactly when the active period ends. That is a problem for DSB+VRR when we are already in vblank and expect DSB to start executing as soon as we send the push. Instead of starting, the DSB just keeps on waiting for the undelayed vblank which won't signal until the end of the next frame's active period, which is far too late.
The end result is that DSB won't have even started
executing by the time the flips/etc. have completed.
We then wait for an extra 1ms, after which we terminate
the DSB and report a timeout:
[drm] *ERROR* [CRTC:80:pipe A] DSB 0 timed out waiting for idle (current head=0xfedf4000, head=0x0, tail=0x1080)
To fix this let's configure DSB to use the so called VRR "safe window" instead of the undelayed vblank to trigger the DSB vblank logic, when VRR is enabled.
--- drivers/gpu/drm/i915/display/intel_dsb.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
drivers/gpu/drm/i915/display/intel_dsb.c +14 -0
@@ -340,6 +340,17 @@ static int intel_dsb_dewake_scanline(conreturn max (0 , vblank_start -intel_usecs_to_scanlines (adjusted_mode, latency)); } +static u32 dsb_chicken (struct intel_crtc *crtc) +{ +if (crtc->mode_flags &I915_MODE_FLAG_VRR ) +return DSB_CTRL_WAIT_SAFE_WINDOW | +DSB_CTRL_NO_WAIT_VBLANK | +DSB_INST_WAIT_SAFE_WINDOW | +DSB_INST_NO_WAIT_VBLANK ; +else +return 0 ; +} +static void _intel_dsb_commit (struct intel_dsb *dsb,u32 ctrl,int dewake_scanline) {
@@ -361,6 +372,9 @@ static void _intel_dsb_commit(struct intintel_de_write_fw (dev_priv,DSB_CTRL (pipe, dsb->id), ctrl |DSB_ENABLE ); +intel_de_write_fw (dev_priv,DSB_CHICKEN (pipe, dsb->id), +dsb_chicken (crtc)); +intel_de_write_fw (dev_priv,DSB_HEAD (pipe, dsb->id),intel_dsb_buffer_ggtt_offset (&dsb->dsb_buf));
Greg Kroah-Hartman
maintainerPATCH 336/399 drm/i915: Do not match JSL in ehl_combo_pll_div_frac_wa_needed()
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jonathon Hall <[email protected]>
commit e41d769f1a7a1dc533c35ef7b366be3dbf432a1c upstream.
Since commit 0c65dc062611 ("drm/i915/jsl: s/JSL/JASPERLAKE for platform/subplatform defines"), boot freezes on a Jasper Lake tablet (Librem 11), usually with graphical corruption on the eDP display, but sometimes just a black screen. This commit was included in 6.6 and later.
That commit was intended to refactor EHL and JSL macros, but the change to ehl_combo_pll_div_frac_wa_needed() started matching JSL incorrectly when it was only intended to match EHL.
It replaced:
return ((IS_PLATFORM(i915, INTEL_ELKHARTLAKE) && IS_JSL_EHL_DISPLAY_STEP(i915, STEP_B0, STEP_FOREVER)) || with: return (((IS_ELKHARTLAKE(i915) || IS_JASPERLAKE(i915)) && IS_DISPLAY_STEP(i915, STEP_B0, STEP_FOREVER)) ||
Remove IS_JASPERLAKE() to fix the regression.
--- drivers/gpu/drm/i915/display/intel_dpll_mgr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/i915/display/intel_dpll_mgr.c +1 -1
@@ -2509,7 +2509,7 @@ static void icl_wrpll_params_populate(ststatic bool ehl_combo_pll_div_frac_wa_needed (struct drm_i915_private *i915) { -return (((IS_ELKHARTLAKE (i915) ||IS_JASPERLAKE (i915)) && +return ((IS_ELKHARTLAKE (i915) &&IS_DISPLAY_STEP (i915,STEP_B0 ,STEP_FOREVER )) ||IS_TIGERLAKE (i915) ||IS_ALDERLAKE_S (i915) ||IS_ALDERLAKE_P (i915)) && i915->display.dpll.ref_clks.nssc ==38400 ;
Greg Kroah-Hartman
maintainerPATCH 337/399 drm/i915: Pre-populate the cursor physical dma address
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ville Syrjälä <[email protected]>
commit 582dc04b0658ef3b90aeb49cbdd9747c2f1eccc3 upstream.
Calling i915_gem_object_get_dma_address() from the vblank evade critical section triggers might_sleep().
While we know that we've already pinned the framebuffer and thus i915_gem_object_get_dma_address() will in fact not sleep in this case, it seems reasonable to keep the unconditional might_sleep() for maximum coverage.
So let's instead pre-populate the dma address during fb pinning, which all happens before we enter the vblank evade critical section.
We can use u32 for the dma address as this class of hardware doesn't support >32bit addresses.
--- drivers/gpu/drm/i915/display/intel_cursor.c | 4 +--- drivers/gpu/drm/i915/display/intel_display_types.h | 1 + drivers/gpu/drm/i915/display/intel_fb_pin.c | 10 ++++++++++ 3 files changed, 12 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/display/intel_cursor.c +1 -3
@@ -35,12 +35,10 @@ static u32 intel_cursor_base(const struc {struct drm_i915_private *dev_priv =to_i915 (plane_state->uapi.plane->dev); -const struct drm_framebuffer *fb = plane_state->hw.fb; -struct drm_i915_gem_object *obj =intel_fb_obj (fb);u32 base;if (DISPLAY_INFO (dev_priv)->cursor_needs_physical) - base =i915_gem_object_get_dma_address (obj,0 ); + base = plane_state->phys_dma_addr;else base =intel_plane_ggtt_offset (plane_state);
drivers/gpu/drm/i915/display/intel_display_types.h +1 -0
@@ -719,6 +719,7 @@ struct intel_plane_state {#define PLANE_HAS_FENCE BIT(0)struct intel_fb_view view; +u32 phys_dma_addr;/* for cursor_needs_physical */ /* Plane pxp decryption state */ bool decrypt;
drivers/gpu/drm/i915/display/intel_fb_pin.c +10 -0
@@ -255,6 +255,16 @@ int intel_plane_pin_fb(struct intel_planreturn PTR_ERR (vma); plane_state->ggtt_vma = vma; + +/* +* Pre-populate the dma address before we enter the vblank +* evade critical section as i915_gem_object_get_dma_address() +* will trigger might_sleep() even if it won't actually sleep, +* which is the case when the fb has already been pinned. +*/ +if (phys_cursor) + plane_state->phys_dma_addr = +i915_gem_object_get_dma_address (intel_fb_obj (fb),0 ); }else {struct intel_framebuffer *intel_fb =to_intel_framebuffer (fb);
Greg Kroah-Hartman
maintainerPATCH 338/399 drm/i915/gt: Reset queue_priority_hint on parking
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chris Wilson <[email protected]>
commit 4a3859ea5240365d21f6053ee219bb240d520895 upstream.
Originally, with strict in order execution, we could complete execution only when the queue was empty. Preempt-to-busy allows replacement of an active request that may complete before the preemption is processed by HW. If that happens, the request is retired from the queue, but the queue_priority_hint remains set, preventing direct submission until after the next CS interrupt is processed.
This preempt-to-busy race can be triggered by the heartbeat, which will also act as the power-management barrier and upon completion allow us to idle the HW. We may process the completion of the heartbeat, and begin parking the engine before the CS event that restores the queue_priority_hint, causing us to fail the assertion that it is MIN.
<3>[ 166.210729] __engine_park:283 GEM_BUG_ON(engine->sched_engine->queue_priority_hint != (-((int)(~0U >> 1)) - 1))
<0>[ 166.210781] Dumping ftrace buffer:
<0>[ 166.210795] ---------------------------------
...
<0>[ 167.302811] drm_fdin-1097 2..s1. 165741070us : trace_ports: 0000:00:02.0 rcs0: promote { ccid:20 1217:2 prio 0 }
<0>[ 167.302861] drm_fdin-1097 2d.s2. 165741072us : execlists_submission_tasklet: 0000:00:02.0 rcs0: preempting last=1217:2, prio=0, hint=2147483646
<0>[ 167.302928] drm_fdin-1097 2d.s2. 165741072us : __i915_request_unsubmit: 0000:00:02.0 rcs0: fence 1217:2, current 0
<0>[ 167.302992] drm_fdin-1097 2d.s2. 165741073us : __i915_request_submit: 0000:00:02.0 rcs0: fence 3:4660, current 4659
<0>[ 167.303044] drm_fdin-1097 2d.s1. 165741076us : execlists_submission_tasklet: 0000:00:02.0 rcs0: context:3 schedule-in, ccid:40
<0>[ 167.303095] drm_fdin-1097 2d.s1. 165741077us : trace_ports: 0000:00:02.0 rcs0: submit { ccid:40 3:4660* prio 2147483646 }
<0>[ 167.303159] kworker/-89 11..... 165741139us : i915_request_retire.part.0: 0000:00:02.0 rcs0: fence c90:2, current 2
<0>[ 167.303208] kworker/-89 11..... 165741148us : __intel_context_do_unpin: 0000:00:02.0 rcs0: context:c90 unpin
<0>[ 167.303272] kworker/-89 11..... 165741159us : i915_request_retire.part.0: 0000:00:02.0 rcs0: fence 1217:2, current 2
<0>[ 167.303321] kworker/-89 11..... 165741166us : __intel_context_do_unpin: 0000:00:02.0 rcs0: context:1217 unpin
<0>[ 167.303384] kworker/-89 11..... 165741170us : i915_request_retire.part.0: 0000:00:02.0 rcs0: fence 3:4660, current 4660
<0>[ 167.303434] kworker/-89 11d..1. 165741172us : __intel_context_retire: 0000:00:02.0 rcs0: context:1216 retire runtime: { total:56028ns, avg:56028ns }
<0>[ 167.303484] kworker/-89 11..... 165741198us : __engine_park: 0000:00:02.0 rcs0: parked
<0>[ 167.303534] <idle>-0 5d.H3. 165741207us : execlists_irq_handler: 0000:00:02.0 rcs0: semaphore yield: 00000040
<0>[ 167.303583] kworker/-89 11..... 165741397us : __intel_context_retire: 0000:00:02.0 rcs0: context:1217 retire runtime: { total:325575ns, avg:0ns }
<0>[ 167.303756] kworker/-89 11..... 165741777us : __intel_context_retire: 0000:00:02.0 rcs0: context:c90 retire runtime: { total:0ns, avg:0ns }
<0>[ 167.303806] kworker/-89 11..... 165742017us : __engine_park: __engine_park:283 GEM_BUG_ON(engine->sched_engine->queue_priority_hint != (-((int)(~0U >> 1)) - 1))
<0>[ 167.303811] ---------------------------------
<4>[ 167.304722] ------------[ cut here ]------------
<2>[ 167.304725] kernel BUG at drivers/gpu/drm/i915/gt/intel_engine_pm.c:283!
<4>[ 167.304731] invalid opcode: 0000 [#1] PREEMPT SMP NOPTI
<4>[ 167.304734] CPU: 11 PID: 89 Comm: kworker/11:1 Tainted: G W 6.8.0-rc2-CI_DRM_14193-gc655e0fd2804+ #1
<4>[ 167.304736] Hardware name: Intel Corporation Rocket Lake Client Platform/RocketLake S UDIMM 6L RVP, BIOS RKLSFWI1.R00.3173.A03.2204210138 04/21/2022
<4>[ 167.304738] Workqueue: i915-unordered retire_work_handler [i915]
<4>[ 167.304839] RIP: 0010:__engine_park+0x3fd/0x680 [i915]
<4>[ 167.304937] Code: 00 48 c7 c2 b0 e5 86 a0 48 8d 3d 00 00 00 00 e8 79 48 d4 e0 bf 01 00 00 00 e8 ef 0a d4 e0 31 f6 bf 09 00 00 00 e8 03 49 c0 e0 <0f> 0b 0f 0b be 01 00 00 00 e8 f5 61 fd ff 31 c0 e9 34 fd ff ff 48
<4>[ 167.304940] RSP: 0018:ffffc9000059fce0 EFLAGS: 00010246
<4>[ 167.304942] RAX: 0000000000000200 RBX: 0000000000000000 RCX: 0000000000000006
<4>[ 167.304944] RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000009
<4>[ 167.304946] RBP: ffff8881330ca1b0 R08: 0000000000000001 R09: 0000000000000001
<4>[ 167.304947] R10: 0000000000000001 R11: 0000000000000001 R12: ffff8881330ca000
<4>[ 167.304948] R13: ffff888110f02aa0 R14: ffff88812d1d0205 R15: ffff88811277d4f0
<4>[ 167.304950] FS: 0000000000000000(0000) GS:ffff88844f780000(0000) knlGS:0000000000000000
<4>[ 167.304952] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
<4>[ 167.304953] CR2: 00007fc362200c40 CR3: 000000013306e003 CR4: 0000000000770ef0
<4>[ 167.304955] PKRU: 55555554
<4>[ 167.304957] Call Trace:
<4>[ 167.304958] <TASK>
<4>[ 167.305573] ____intel_wakeref_put_last+0x1d/0x80 [i915]
<4>[ 167.305685] i915_request_retire.part.0+0x34f/0x600 [i915]
<4>[ 167.305800] retire_requests+0x51/0x80 [i915]
<4>[ 167.305892] intel_gt_retire_requests_timeout+0x27f/0x700 [i915]
<4>[ 167.305985] process_scheduled_works+0x2db/0x530
<4>[ 167.305990] worker_thread+0x18c/0x350
<4>[ 167.305993] kthread+0xfe/0x130
<4>[ 167.305997] ret_from_fork+0x2c/0x50
<4>[ 167.306001] ret_from_fork_asm+0x1b/0x30
<4>[ 167.306004] </TASK>It is necessary for the queue_priority_hint to be lower than the next request submission upon waking up, as we rely on the hint to decide when to kick the tasklet to submit that first request.
--- drivers/gpu/drm/i915/gt/intel_engine_pm.c | 3 --- drivers/gpu/drm/i915/gt/intel_execlists_submission.c | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/gt/intel_engine_pm.c +0 -3
@@ -279,9 +279,6 @@ static int __engine_park(struct intel_waintel_engine_park_heartbeat (engine);intel_breadcrumbs_park (engine->breadcrumbs); -/* Must be reset upon idling, or we may miss the busy wakeup. */ -GEM_BUG_ON (engine->sched_engine->queue_priority_hint !=INT_MIN ); -if (engine->park) engine->park (engine);
drivers/gpu/drm/i915/gt/intel_execlists_submission.c +3 -0
@@ -3272,6 +3272,9 @@ static void execlists_park(struct intel_ {cancel_timer (&engine->execlists.timer);cancel_timer (&engine->execlists.preempt); + +/* Reset upon idling, or we may delay the busy wakeup. */ +WRITE_ONCE (engine->sched_engine->queue_priority_hint,INT_MIN ); }static void add_to_engine (struct i915_request *rq)
Greg Kroah-Hartman
maintainerPATCH 339/399 drm/amd/display: Fix bounds check for dcn35 DcfClocks
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Roman Li <[email protected]>
commit 2f10d4a51bbcd938f1f02f16c304ad1d54717b96 upstream.
[Why]
NumFclkLevelsEnabled is used for DcfClocks bounds check instead of designated NumDcfClkLevelsEnabled. That can cause array index out-of-bounds access.
[How]
Use designated variable for dcn35 DcfClocks bounds check.
--- drivers/gpu/drm/amd/display/dc/clk_mgr/dcn35/dcn35_clk_mgr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/clk_mgr/dcn35/dcn35_clk_mgr.c +1 -1
@@ -706,7 +706,7 @@ static void dcn35_clk_mgr_helper_populat clock_table->NumFclkLevelsEnabled; max_fclk =find_max_clk_value (clock_table->FclkClocks_Freq, num_fclk); - num_dcfclk = (clock_table->NumFclkLevelsEnabled >NUM_DCFCLK_DPM_LEVELS ) ?NUM_DCFCLK_DPM_LEVELS : + num_dcfclk = (clock_table->NumDcfClkLevelsEnabled >NUM_DCFCLK_DPM_LEVELS ) ?NUM_DCFCLK_DPM_LEVELS : clock_table->NumDcfClkLevelsEnabled;for (i =0 ; i < num_dcfclk; i++) {int j;
Greg Kroah-Hartman
maintainerPATCH 340/399 Bluetooth: hci_sync: Fix not checking error on hci_cmd_sync_cancel_sync
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luiz Augusto von Dentz <[email protected]>
commit 1c3366abdbe884be62e5a7502b4db758aa3974c6 upstream.
hci_cmd_sync_cancel_sync shall check the error passed to it since it will be propagated using req_result which is __u32 it needs to be properly set to a positive value if it was passed as negative othertise IS_ERR will not trigger as -(errno) would be converted to a positive value.
--- net/bluetooth/hci_core.c | 6 +++--- net/bluetooth/hci_sync.c | 5 ++++- 2 files changed, 7 insertions(+), 4 deletions(-)
net/bluetooth/hci_core.c +3 -3
@@ -2842,7 +2842,7 @@ static void hci_cancel_cmd_sync(struct hcancel_delayed_work_sync (&hdev->ncmd_timer);atomic_set (&hdev->cmd_cnt,1 ); -hci_cmd_sync_cancel_sync (hdev, -err); +hci_cmd_sync_cancel_sync (hdev, err); }/* Suspend HCI device */
@@ -2862,7 +2862,7 @@ int hci_suspend_dev(struct hci_dev *hdevreturn 0 ;/* Cancel potentially blocking sync operation before suspend */ -hci_cancel_cmd_sync (hdev, -EHOSTDOWN ); +hci_cancel_cmd_sync (hdev,EHOSTDOWN );hci_req_sync_lock (hdev); ret =hci_suspend_sync (hdev);
@@ -4178,7 +4178,7 @@ static void hci_send_cmd_sync(struct hci err =hci_send_frame (hdev, skb);if (err <0 ) { -hci_cmd_sync_cancel_sync (hdev, err); +hci_cmd_sync_cancel_sync (hdev, -err);return ; }
net/bluetooth/hci_sync.c +4 -1
@@ -611,7 +611,10 @@ void hci_cmd_sync_cancel_sync(struct hcibt_dev_dbg (hdev,"err 0x%2.2x" , err);if (hdev->req_status ==HCI_REQ_PEND ) { - hdev->req_result = err; +/* req_result is __u32 so error must be positive to be properly +* propagated. +*/ + hdev->req_result = err <0 ? -err : err; hdev->req_status =HCI_REQ_CANCELED ;wake_up_interruptible (&hdev->req_wait_q);
Greg Kroah-Hartman
maintainerPATCH 341/399 mtd: spinand: Add support for 5-byte IDs
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ezra Buehler <[email protected]>
commit 34a956739d295de6010cdaafeed698ccbba87ea4 upstream.
E.g. ESMT chips will return an identification code with a length of 5 bytes. In order to prevent ambiguity, flash chips would actually need to return IDs that are up to 17 or more bytes long due to JEDEC's continuation scheme. I understand that if a manufacturer ID is located in bank N of JEDEC's database (there are currently 16 banks), N - 1 continuation codes (7Fh) need to be added to the identification code (comprising of manufacturer ID and device ID). However, most flash chip manufacturers don't seem to implement this (correctly).
--- include/linux/mtd/spinand.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/mtd/spinand.h +1 -1
@@ -169,7 +169,7 @@struct spinand_op ;struct spinand_device ; -#define SPINAND_MAX_ID_LEN 4 +#define SPINAND_MAX_ID_LEN 5/* * For erase, write and read operation, we got the following timings : * tBERS (erase) 1ms to 4ms
Greg Kroah-Hartman
maintainerPATCH 342/399 Revert "usb: phy: generic: Get the vbus supply"
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexander Stein <[email protected]>
commit fdada0db0b2ae2addef4ccafe50937874dbeeebe upstream.
This reverts commit 75fd6485cccef269ac9eb3b71cf56753341195ef. This patch was applied twice by accident, causing probe failures. Revert the accident.
--- drivers/usb/phy/phy-generic.c | 7 ------- 1 file changed, 7 deletions(-)
drivers/usb/phy/phy-generic.c +0 -7
@@ -274,13 +274,6 @@ int usb_phy_gen_create_phy(struct devicereturn dev_err_probe (dev,PTR_ERR (nop->vbus_draw),"could not get vbus regulator\n" ); - nop->vbus_draw =devm_regulator_get_exclusive (dev,"vbus" ); -if (PTR_ERR (nop->vbus_draw) == -ENODEV ) - nop->vbus_draw =NULL ; -if (IS_ERR (nop->vbus_draw)) -return dev_err_probe (dev,PTR_ERR (nop->vbus_draw), -"could not get vbus regulator\n" ); - nop->dev = dev; nop->phy.dev = nop->dev; nop->phy.label ="nop-xceiv" ;
Greg Kroah-Hartman
maintainerPATCH 343/399 usb: cdc-wdm: close race between read and workqueue
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Oliver Neukum <[email protected]>
commit 339f83612f3a569b194680768b22bf113c26a29d upstream.
wdm_read() cannot race with itself. However, in service_outstanding_interrupt() it can race with the workqueue, which can be triggered by error handling.
Hence we need to make sure that the WDM_RESPONDING flag is not just only set but tested.
--- drivers/usb/class/cdc-wdm.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/usb/class/cdc-wdm.c +5 -1
@@ -485,6 +485,7 @@ out_free_mem:static int service_outstanding_interrupt (struct wdm_device *desc) {int rv =0 ; +int used;/* submit read urb only if the device is waiting for it */ if (!desc->resp_count || !--desc->resp_count)
@@ -499,7 +500,10 @@ static int service_outstanding_interrupt goto out; } -set_bit (WDM_RESPONDING , &desc->flags); + used =test_and_set_bit (WDM_RESPONDING , &desc->flags); +if (used) + goto out; +spin_unlock_irq (&desc->iuspin); rv =usb_submit_urb (desc->response,GFP_KERNEL );spin_lock_irq (&desc->iuspin);
Greg Kroah-Hartman
maintainerPATCH 344/399 usb: misc: ljca: Fix double free in error handling path
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yongzhi Liu <[email protected]>
commit 7c9631969287a5366bc8e39cd5abff154b35fb80 upstream.
When auxiliary_device_add() returns error and then calls auxiliary_device_uninit(), callback function ljca_auxdev_release calls kfree(auxdev->dev.platform_data) to free the parameter data of the function ljca_new_client_device. The callers of ljca_new_client_device shouldn't call kfree() again
in the error handling path to free the platform data.
Fix this by cleaning up the redundant kfree() in all callers and adding kfree() the passed in platform_data on errors which happen before auxiliary_device_init() succeeds .
--- drivers/usb/misc/usb-ljca.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-)
drivers/usb/misc/usb-ljca.c +9 -13
@@ -518,8 +518,10 @@ static int ljca_new_client_device(structint ret; client =kzalloc (sizeof *client,GFP_KERNEL ); -if (!client) +if (!client) { +kfree (data);return -ENOMEM ; + } client->type = type; client->id = id;
@@ -535,8 +537,10 @@ static int ljca_new_client_device(struct auxdev->dev.release = ljca_auxdev_release; ret =auxiliary_device_init (auxdev); -if (ret) +if (ret) { +kfree (data); goto err_free; + }ljca_auxdev_acpi_bind (adap, auxdev, adr, id);
@@ -590,12 +594,8 @@ static int ljca_enumerate_gpio(struct lj valid_pin[i] =get_unaligned_le32 (&desc->bank_desc[i].valid_pins);bitmap_from_arr32 (gpio_info->valid_pin_map, valid_pin, gpio_num); - ret =ljca_new_client_device (adap,LJCA_CLIENT_GPIO ,0 ,"ljca-gpio" , +return ljca_new_client_device (adap,LJCA_CLIENT_GPIO ,0 ,"ljca-gpio" , gpio_info,LJCA_GPIO_ACPI_ADR ); -if (ret) -kfree (gpio_info); - -return ret; }static int ljca_enumerate_i2c (struct ljca_adapter *adap)
@@ -629,10 +629,8 @@ static int ljca_enumerate_i2c(struct ljc ret =ljca_new_client_device (adap,LJCA_CLIENT_I2C , i,"ljca-i2c" , i2c_info,LJCA_I2C1_ACPI_ADR + i); -if (ret) { -kfree (i2c_info); +if (ret)return ret; - } }return 0 ;
@@ -669,10 +667,8 @@ static int ljca_enumerate_spi(struct ljc ret =ljca_new_client_device (adap,LJCA_CLIENT_SPI , i,"ljca-spi" , spi_info,LJCA_SPI1_ACPI_ADR + i); -if (ret) { -kfree (spi_info); +if (ret)return ret; - } }return 0 ;
Greg Kroah-Hartman
maintainerPATCH 345/399 USB: UAS: return ENODEV when submit urbs fail with device not attached
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Weitao Wang <[email protected]>
commit cd5432c712351a3d5f82512908f5febfca946ca6 upstream.
In the scenario of entering hibernation with udisk in the system, if the udisk was gone or resume fail in the thaw phase of hibernation. Its state will be set to NOTATTACHED. At this point, usb_hub_wq was already freezed and can't not handle disconnect event. Next, in the poweroff phase of hibernation, SYNCHRONIZE_CACHE SCSI command will be sent to this udisk when poweroff this scsi device, which will cause uas_submit_urbs to be called to submit URB for sense/data/cmd pipe. However, these URBs will submit fail as device was set to NOTATTACHED state. Then, uas_submit_urbs will return a value SCSI_MLQUEUE_DEVICE_BUSY to the caller. That will lead the SCSI layer go into an ugly loop and system fail to go into hibernation.
On the other hand, when we specially check for -ENODEV in function uas_queuecommand_lck, returning DID_ERROR to SCSI layer will cause device poweroff fail and system shutdown instead of entering hibernation.
To fix this issue, let uas_submit_urbs to return original generic error when submitting URB failed. At the same time, we need to translate -ENODEV to DID_NOT_CONNECT for the SCSI layer.
--- drivers/usb/storage/uas.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-)
drivers/usb/storage/uas.c +13 -15
@@ -533,7 +533,7 @@ static struct urb *uas_alloc_cmd_urb(str* daft to me. */ -static struct urb *uas_submit_sense_urb (struct scsi_cmnd *cmnd,gfp_t gfp) +static int uas_submit_sense_urb (struct scsi_cmnd *cmnd,gfp_t gfp) {struct uas_dev_info *devinfo = cmnd->device->hostdata;struct urb *urb;
@@ -541,30 +541,28 @@ static struct urb *uas_submit_sense_urb( urb =uas_alloc_sense_urb (devinfo, gfp, cmnd);if (!urb) -return NULL ; +return -ENOMEM ;usb_anchor_urb (urb, &devinfo->sense_urbs); err =usb_submit_urb (urb, gfp);if (err) {usb_unanchor_urb (urb);uas_log_cmd_state (cmnd,"sense submit err" , err);usb_free_urb (urb); -return NULL ; } -return urb; +return err; }static int uas_submit_urbs (struct scsi_cmnd *cmnd,struct uas_dev_info *devinfo) {struct uas_cmd_info *cmdinfo =scsi_cmd_priv (cmnd); -struct urb *urb;int err;lockdep_assert_held (&devinfo->lock);if (cmdinfo->state &SUBMIT_STATUS_URB ) { - urb =uas_submit_sense_urb (cmnd,GFP_ATOMIC ); -if (!urb) -return SCSI_MLQUEUE_DEVICE_BUSY ; + err =uas_submit_sense_urb (cmnd,GFP_ATOMIC ); +if (err) +return err; cmdinfo->state &= ~SUBMIT_STATUS_URB ; }
@@ -572,7 +570,7 @@ static int uas_submit_urbs(struct scsi_c cmdinfo->data_in_urb =uas_alloc_data_urb (devinfo,GFP_ATOMIC , cmnd,DMA_FROM_DEVICE );if (!cmdinfo->data_in_urb) -return SCSI_MLQUEUE_DEVICE_BUSY ; +return -ENOMEM ; cmdinfo->state &= ~ALLOC_DATA_IN_URB ; }
@@ -582,7 +580,7 @@ static int uas_submit_urbs(struct scsi_cif (err) {usb_unanchor_urb (cmdinfo->data_in_urb);uas_log_cmd_state (cmnd,"data in submit err" , err); -return SCSI_MLQUEUE_DEVICE_BUSY ; +return err; } cmdinfo->state &= ~SUBMIT_DATA_IN_URB ; cmdinfo->state |=DATA_IN_URB_INFLIGHT ;
@@ -592,7 +590,7 @@ static int uas_submit_urbs(struct scsi_c cmdinfo->data_out_urb =uas_alloc_data_urb (devinfo,GFP_ATOMIC , cmnd,DMA_TO_DEVICE );if (!cmdinfo->data_out_urb) -return SCSI_MLQUEUE_DEVICE_BUSY ; +return -ENOMEM ; cmdinfo->state &= ~ALLOC_DATA_OUT_URB ; }
@@ -602,7 +600,7 @@ static int uas_submit_urbs(struct scsi_cif (err) {usb_unanchor_urb (cmdinfo->data_out_urb);uas_log_cmd_state (cmnd,"data out submit err" , err); -return SCSI_MLQUEUE_DEVICE_BUSY ; +return err; } cmdinfo->state &= ~SUBMIT_DATA_OUT_URB ; cmdinfo->state |=DATA_OUT_URB_INFLIGHT ;
@@ -611,7 +609,7 @@ static int uas_submit_urbs(struct scsi_cif (cmdinfo->state &ALLOC_CMD_URB ) { cmdinfo->cmd_urb =uas_alloc_cmd_urb (devinfo,GFP_ATOMIC , cmnd);if (!cmdinfo->cmd_urb) -return SCSI_MLQUEUE_DEVICE_BUSY ; +return -ENOMEM ; cmdinfo->state &= ~ALLOC_CMD_URB ; }
@@ -621,7 +619,7 @@ static int uas_submit_urbs(struct scsi_cif (err) {usb_unanchor_urb (cmdinfo->cmd_urb);uas_log_cmd_state (cmnd,"cmd submit err" , err); -return SCSI_MLQUEUE_DEVICE_BUSY ; +return err; } cmdinfo->cmd_urb =NULL ; cmdinfo->state &= ~SUBMIT_CMD_URB ;
@@ -698,7 +696,7 @@ static int uas_queuecommand_lck(struct s* of queueing, no matter how fatal the error */ if (err == -ENODEV ) { -set_host_byte (cmnd,DID_ERROR ); +set_host_byte (cmnd,DID_NO_CONNECT );scsi_done (cmnd); goto zombie; }
Greg Kroah-Hartman
maintainerPATCH 346/399 vfio/pds: Make sure migration file isnt accessed after reset
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Brett Creeley <[email protected]>
[ Upstream commit 457f7308254756b6e4b8fc3876cb770dcf0e7cc7 ]
It's possible the migration file is accessed after reset when it has been cleaned up, especially when it's initiated by the device. This is because the driver doesn't rip out the filep when cleaning up it only frees the related page structures and sets its local struct pds_vfio_lm_file pointer to NULL. This can cause a NULL pointer dereference, which is shown in the example below during a restore after a device initiated reset:
BUG: kernel NULL pointer dereference, address: 000000000000000c PF: supervisor read access in kernel mode PF: error_code(0x0000) - not-present page PGD 0 P4D 0 Oops: 0000 [#1] PREEMPT SMP NOPTI RIP: 0010:pds_vfio_get_file_page+0x5d/0xf0 [pds_vfio_pci] [...] Call Trace: <TASK> pds_vfio_restore_write+0xf6/0x160 [pds_vfio_pci] vfs_write+0xc9/0x3f0 ? __fget_light+0xc9/0x110 ksys_write+0xb5/0xf0 __x64_sys_write+0x1a/0x20 do_syscall_64+0x38/0x90 entry_SYSCALL_64_after_hwframe+0x63/0xcd
[...]
Add a disabled flag to the driver's struct pds_vfio_lm_file that gets set during cleanup. Then make sure to check the flag when the migration file is accessed via its file_operations. By default this flag will be false as the memory for struct pds_vfio_lm_file is kzalloc'd, which means the struct pds_vfio_lm_file is enabled and accessible. Also, since the file_operations and driver's migration file cleanup happen under the protection of the same pds_vfio_lm_file.lock, using this flag is thread safe.
--- drivers/vfio/pci/pds/lm.c | 13 +++++++++++++ drivers/vfio/pci/pds/lm.h | 1 + 2 files changed, 14 insertions(+)
drivers/vfio/pci/pds/lm.c +13 -0
@@ -92,8 +92,10 @@ static void pds_vfio_put_lm_file(struct pds_vfio_lm_file *lm_file) {mutex_lock (&lm_file->lock); + lm_file->disabled = true; lm_file->size =0 ; lm_file->alloc_size =0 ; + lm_file->filep->f_pos =0 ;/* Free scatter list of file pages */ sg_free_table (&lm_file->sg_table);
@@ -183,6 +185,12 @@ static ssize_t pds_vfio_save_read(struct file *filp, char __user *buf, pos = &filp->f_pos;mutex_lock (&lm_file->lock); + +if (lm_file->disabled) { + done = -ENODEV ; + goto out_unlock; + } +if (*pos > lm_file->size) { done = -EINVAL ; goto out_unlock;
@@ -283,6 +291,11 @@ static ssize_t pds_vfio_restore_write(struct file *filp, const char __user *buf,mutex_lock (&lm_file->lock); +if (lm_file->disabled) { + done = -ENODEV ; + goto out_unlock; + } +while (len) {size_t page_offset;struct page *page;
drivers/vfio/pci/pds/lm.h +1 -0
@@ -27,6 +27,7 @@ struct pds_vfio_lm_file {struct scatterlist *last_offset_sg;/* Iterator */ unsigned int sg_last_entry;unsigned long last_offset; +bool disabled; };struct pds_vfio_pci_device ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 347/399 ring-buffer: Make wake once of ring_buffer_wait() more robust
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Steven Rostedt (Google) <[email protected]>
[ Upstream commit b70f2938242a028f8e9473781ede175486a59dc8 ]
The default behavior of ring_buffer_wait() when passed a NULL "cond" parameter is to exit the function the first time it is woken up. The current implementation uses a counter that starts at zero and when it is greater than one it exits the wait_event_interruptible().
But this relies on the internal working of wait_event_interruptible() as that code basically has:
if (cond)
return;
prepare_to_wait();
if (!cond)
schedule();
finish_wait();That is, cond is called twice before it sleeps. The default cond of ring_buffer_wait() needs to account for that and wait for its counter to increment twice before exiting.
Instead, use the seq/atomic_inc logic that is used by the tracing code that calls this function. Add an atomic_t seq to rb_irq_work and when cond is NULL, have the default callback take a descriptor as its data that holds the rbwork and the value of the seq when it started.
The wakeups will now increment the rbwork->seq and the cond callback will simply check if that number is different, and no longer have to rely on the implementation of wait_event_interruptible().
--- kernel/trace/ring_buffer.c | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-)
kernel/trace/ring_buffer.c +21 -13
@@ -384,6 +384,7 @@ struct rb_irq_work {struct irq_work work;wait_queue_head_t waiters;wait_queue_head_t full_waiters; +atomic_t seq;bool waiters_pending;bool full_waiters_pending;bool wakeup_full;
@@ -753,6 +754,9 @@ static void rb_wake_up_waiters(struct irq_work *work) { struct rb_irq_work *rbwork = container_of(work, struct rb_irq_work, work); +/* For waiters waiting for the first wake up */ + (void )atomic_fetch_inc_release (&rbwork->seq); +wake_up_all (&rbwork->waiters);if (rbwork->full_waiters_pending || rbwork->wakeup_full) {/* Only cpu_buffer sets the above flags */
@@ -881,20 +885,21 @@ rb_wait_cond(struct rb_irq_work *rbwork, struct trace_buffer *buffer,return false; } +struct rb_wait_data { +struct rb_irq_work *irq_work; +int seq; +}; +/* * The default wait condition for ring_buffer_wait() is to just to exit the * wait loop the first time it is woken up. */ static bool rb_wait_once (void *data) { -long *once = data; +struct rb_wait_data *rdata = data; +struct rb_irq_work *rbwork = rdata->irq_work; -/* wait_event() actually calls this twice before scheduling*/ -if (*once >1 ) -return true; - - (*once)++; -return false; +return atomic_read_acquire (&rbwork->seq) != rdata->seq; }/**
@@ -915,14 +920,9 @@ int ring_buffer_wait(struct trace_buffer *buffer, int cpu, int full,struct ring_buffer_per_cpu *cpu_buffer;struct wait_queue_head *waitq;struct rb_irq_work *rbwork; -long once =0 ; +struct rb_wait_data rdata;int ret =0 ; -if (!cond) { - cond = rb_wait_once; - data = &once; - } -/* * Depending on what the caller is waiting for, either any * data in any cpu buffer, or a specific buffer, put the
@@ -944,6 +944,14 @@ int ring_buffer_wait(struct trace_buffer *buffer, int cpu, int full,else waitq = &rbwork->waiters; +/* Set up to exit loop as soon as it is woken */ +if (!cond) { + cond = rb_wait_once; + rdata.irq_work = rbwork; + rdata.seq =atomic_read_acquire (&rbwork->seq); + data = &rdata; + } + ret =wait_event_interruptible ((*waitq),rb_wait_cond (rbwork, buffer, cpu, full, cond, data));
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 348/399 btrfs: fix extent map leak in unexpected scenario at unpin_extent_cache()
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Filipe Manana <[email protected]>
[ Upstream commit 8a565ec04d6c43f330e7401e5af3458431b29bc6 ]
At unpin_extent_cache() if we happen to find an extent map with an unexpected start offset, we jump to the 'out' label and never release the reference we added to the extent map through the call to lookup_extent_mapping(), therefore resulting in a leak. So fix this by moving the free_extent_map() under the 'out' label.
--- fs/btrfs/extent_map.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/extent_map.c +1 -1
@@ -342,9 +342,9 @@ int unpin_extent_cache(struct btrfs_inode *inode, u64 start, u64 len, u64 gen) em->mod_len = em->len; } -free_extent_map (em); out:write_unlock (&tree->lock); +free_extent_map (em);return ret; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 349/399 ALSA: sh: aica: reorder cleanup operations to avoid UAF bugs
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Duoming Zhou <[email protected]>
commit 051e0840ffa8ab25554d6b14b62c9ab9e4901457 upstream.
The dreamcastcard->timer could schedule the spu_dma_work and the spu_dma_work could also arm the dreamcastcard->timer.
When the snd_pcm_substream is closing, the aica_channel will be deallocated. But it could still be dereferenced in the worker thread. The reason is that del_timer() will return directly regardless of whether the timer handler is running or not and the worker could be rescheduled in the timer handler. As a result, the UAF bug will happen. The racy situation is shown below:
(Thread 1) | (Thread 2)
snd_aicapcm_pcm_close() |
... | run_spu_dma() //worker
| mod_timer()
flush_work() |
del_timer() | aica_period_elapsed() //timer
kfree(dreamcastcard->channel) | schedule_work()
| run_spu_dma() //worker
... | dreamcastcard->channel-> //USEIn order to mitigate this bug and other possible corner cases, call mod_timer() conditionally in run_spu_dma(), then implement PCM sync_stop op to cancel both the timer and worker. The sync_stop op will be called from PCM core appropriately when needed.
Message-ID: <[email protected]>
--- sound/sh/aica.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)
sound/sh/aica.c +14 -3
@@ -278,7 +278,8 @@ static void run_spu_dma(struct work_stru dreamcastcard->clicks++;if (unlikely (dreamcastcard->clicks >=AICA_PERIOD_NUMBER )) dreamcastcard->clicks %=AICA_PERIOD_NUMBER ; -mod_timer (&dreamcastcard->timer, jiffies +1 ); +if (snd_pcm_running (dreamcastcard->substream)) +mod_timer (&dreamcastcard->timer, jiffies +1 ); } }
@@ -290,6 +291,8 @@ static void aica_period_elapsed(struct t/*timer function - so cannot sleep */ int play_period;struct snd_pcm_runtime *runtime; +if (!snd_pcm_running (substream)) +return ; runtime = substream->runtime; dreamcastcard = substream->pcm->private_data;/* Have we played out an additional period? */
@@ -350,12 +353,19 @@ static int snd_aicapcm_pcm_open(struct sreturn 0 ; } +static int snd_aicapcm_pcm_sync_stop (struct snd_pcm_substream *substream) +{ +struct snd_card_aica *dreamcastcard = substream->pcm->private_data; + +del_timer_sync (&dreamcastcard->timer); +cancel_work_sync (&dreamcastcard->spu_dma_work); +return 0 ; +} +static int snd_aicapcm_pcm_close (struct snd_pcm_substream *substream) {struct snd_card_aica *dreamcastcard = substream->pcm->private_data; -flush_work (&(dreamcastcard->spu_dma_work)); -del_timer (&dreamcastcard->timer); dreamcastcard->substream =NULL ;kfree (dreamcastcard->channel);spu_disable ();
@@ -401,6 +411,7 @@ static const struct snd_pcm_ops snd_aica .prepare = snd_aicapcm_pcm_prepare, .trigger = snd_aicapcm_pcm_trigger, .pointer = snd_aicapcm_pcm_pointer, + .sync_stop = snd_aicapcm_pcm_sync_stop, };/* TO DO: set up to handle more than one pcm instance */
Greg Kroah-Hartman
maintainerPATCH 350/399 scsi: ufs: qcom: Provide default cycles_in_1us value
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dmitry Baryshkov <[email protected]>
commit 81e2c1a0f8d3f62f4c9e80b20270aa3481c40524 upstream.
The MSM8996 DT doesn't provide frequency limits for the core_clk_unipro clock, which results in miscalculation of the cycles_in_1us value. Provide the backwards-compatible default to support existing MSM8996 DT files.
--- drivers/ufs/host/ufs-qcom.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/ufs/host/ufs-qcom.c +4 -2
@@ -1196,8 +1196,10 @@ static int ufs_qcom_set_core_clk_ctrl(stlist_for_each_entry (clki, head, list) {if (!IS_ERR_OR_NULL (clki->clk) && - !strcmp (clki->name,"core_clk_unipro" )) { -if (is_scale_up) + !strcmp (clki->name,"core_clk_unipro" )) { +if (!clki->max_freq) + cycles_in_1us =150 ;/* default for backwards compatibility */ +else if (is_scale_up) cycles_in_1us =ceil (clki->max_freq, (1000 *1000 ));else cycles_in_1us =ceil (clk_get_rate (clki->clk), (1000 *1000 ));
Greg Kroah-Hartman
maintainerPATCH 351/399 scsi: sd: Fix TCG OPAL unlock on system resume
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Damien Le Moal <[email protected]>
commit 0c76106cb97548810214def8ee22700bbbb90543 upstream.
Commit 3cc2ffe5c16d ("scsi: sd: Differentiate system and runtime start/stop management") introduced the manage_system_start_stop scsi_device flag to allow libata to indicate to the SCSI disk driver that nothing should be done when resuming a disk on system resume. This change turned the execution of sd_resume() into a no-op for ATA devices on system resume. While this solved deadlock issues during device resume, this change also wrongly removed the execution of opal_unlock_from_suspend(). As a result, devices with TCG OPAL locking enabled remain locked and inaccessible after a system resume from sleep.
To fix this issue, introduce the SCSI driver resume method and implement it with the sd_resume() function calling opal_unlock_from_suspend(). The former sd_resume() function is renamed to sd_resume_common() and modified to call the new sd_resume() function. For non-ATA devices, this result in no functional changes.
In order for libata to explicitly execute sd_resume() when a device is resumed during system restart, the function scsi_resume_device() is introduced. libata calls this function from the revalidation work executed on devie resume, a state that is indicated with the new device flag ATA_DFLAG_RESUMING. Doing so, locked TCG OPAL enabled devices are unlocked on resume, allowing normal operation.
--- drivers/ata/libata-eh.c | 5 ++++- drivers/ata/libata-scsi.c | 9 +++++++++ drivers/scsi/scsi_scan.c | 34 ++++++++++++++++++++++++++++++++++ drivers/scsi/sd.c | 23 +++++++++++++++++++---- include/linux/libata.h | 1 + include/scsi/scsi_driver.h | 1 + include/scsi/scsi_host.h | 1 + 7 files changed, 69 insertions(+), 5 deletions(-)
drivers/ata/libata-eh.c +4 -1
@@ -712,8 +712,10 @@ void ata_scsi_port_error_handler(struct ehc->saved_ncq_enabled |=1 << devno;/* If we are resuming, wake up the device */ -if (ap->pflags &ATA_PFLAG_RESUMING ) +if (ap->pflags &ATA_PFLAG_RESUMING ) { + dev->flags |=ATA_DFLAG_RESUMING ; ehc->i.dev_action[devno] |=ATA_EH_SET_ACTIVE ; + } } }
@@ -3169,6 +3171,7 @@ static int ata_eh_revalidate_and_attach(return 0 ; err: + dev->flags &= ~ATA_DFLAG_RESUMING ; *r_failed_dev = dev;return rc; }
drivers/ata/libata-scsi.c +9 -0
@@ -4730,6 +4730,7 @@ void ata_scsi_dev_rescan(struct work_strstruct ata_link *link;struct ata_device *dev;unsigned long flags; +bool do_resume;int ret =0 ;mutex_lock (&ap->scsi_scan_mutex);
@@ -4751,7 +4752,15 @@ void ata_scsi_dev_rescan(struct work_strif (scsi_device_get (sdev))continue ; + do_resume = dev->flags &ATA_DFLAG_RESUMING ; +spin_unlock_irqrestore (ap->lock, flags); +if (do_resume) { + ret =scsi_resume_device (sdev); +if (ret == -EWOULDBLOCK ) + goto unlock; + dev->flags &= ~ATA_DFLAG_RESUMING ; + } ret =scsi_rescan_device (sdev);scsi_device_put (sdev);spin_lock_irqsave (ap->lock, flags);
drivers/scsi/scsi_scan.c +34 -0
@@ -1619,6 +1619,40 @@ int scsi_add_device(struct Scsi_Host *ho }EXPORT_SYMBOL (scsi_add_device); +int scsi_resume_device (struct scsi_device *sdev) +{ +struct device *dev = &sdev->sdev_gendev; +int ret =0 ; + +device_lock (dev); + +/* +* Bail out if the device or its queue are not running. Otherwise, +* the rescan may block waiting for commands to be executed, with us +* holding the device lock. This can result in a potential deadlock +* in the power management core code when system resume is on-going. +*/ +if (sdev->sdev_state !=SDEV_RUNNING || +blk_queue_pm_only (sdev->request_queue)) { + ret = -EWOULDBLOCK ; + goto unlock; + } + +if (dev->driver &&try_module_get (dev->driver->owner)) { +struct scsi_driver *drv =to_scsi_driver (dev->driver); + +if (drv->resume) + ret = drv->resume (dev); +module_put (dev->driver->owner); + } + +unlock: +device_unlock (dev); + +return ret; +} +EXPORT_SYMBOL (scsi_resume_device); +int scsi_rescan_device (struct scsi_device *sdev) {struct device *dev = &sdev->sdev_gendev;
drivers/scsi/sd.c +19 -4
@@ -3945,7 +3945,21 @@ static int sd_suspend_runtime(struct devreturn sd_suspend_common (dev, true); } -static int sd_resume (struct device *dev,bool runtime) +static int sd_resume (struct device *dev) +{ +struct scsi_disk *sdkp =dev_get_drvdata (dev); + +sd_printk (KERN_NOTICE , sdkp,"Starting disk\n" ); + +if (opal_unlock_from_suspend (sdkp->opal_dev)) { +sd_printk (KERN_NOTICE , sdkp,"OPAL unlock failed\n" ); +return -EIO ; + } + +return 0 ; +} + +static int sd_resume_common (struct device *dev,bool runtime) {struct scsi_disk *sdkp =dev_get_drvdata (dev);int ret;
@@ -3961,7 +3975,7 @@ static int sd_resume(struct device *dev,sd_printk (KERN_NOTICE , sdkp,"Starting disk\n" ); ret =sd_start_stop_device (sdkp,1 );if (!ret) { -opal_unlock_from_suspend (sdkp->opal_dev); +sd_resume (dev); sdkp->suspended = false; }
@@ -3980,7 +3994,7 @@ static int sd_resume_system(struct devicreturn 0 ; } -return sd_resume (dev, false); +return sd_resume_common (dev, false); }static int sd_resume_runtime (struct device *dev)
@@ -4007,7 +4021,7 @@ static int sd_resume_runtime(struct devi "Failed to clear sense data\n"); } -return sd_resume (dev, true); +return sd_resume_common (dev, true); }static const struct dev_pm_ops sd_pm_ops = {
@@ -4030,6 +4044,7 @@ static struct scsi_driver sd_template = .pm = &sd_pm_ops, }, .rescan = sd_rescan, + .resume = sd_resume, .init_command = sd_init_command, .uninit_command = sd_uninit_command, .done = sd_done,
include/linux/libata.h +1 -0
@@ -107,6 +107,7 @@ enum {ATA_DFLAG_NCQ_PRIO_ENABLED = (1 <<20 ),/* Priority cmds sent to dev */ ATA_DFLAG_CDL_ENABLED = (1 <<21 ),/* cmd duration limits is enabled */ +ATA_DFLAG_RESUMING = (1 <<22 ),/* Device is resuming */ ATA_DFLAG_DETACH = (1 <<24 ),ATA_DFLAG_DETACHED = (1 <<25 ), ATA_DFLAG_DA = (1 << 26), /* device supports Device Attention */
include/scsi/scsi_driver.h +1 -0
@@ -12,6 +12,7 @@ struct request;struct scsi_driver {struct device_driver gendrv; +int (*resume)(struct device *);void (*rescan)(struct device *);blk_status_t (*init_command)(struct scsi_cmnd *);void (*uninit_command)(struct scsi_cmnd *);
include/scsi/scsi_host.h +1 -0
@@ -767,6 +767,7 @@ scsi_template_proc_dir(const struct scsi#define scsi_template_proc_dir (sht) NULL#endif extern void scsi_scan_host (struct Scsi_Host *); +extern int scsi_resume_device (struct scsi_device *sdev);extern int scsi_rescan_device (struct scsi_device *sdev);extern void scsi_remove_host (struct Scsi_Host *);extern struct Scsi_Host *scsi_host_get (struct Scsi_Host *);
Greg Kroah-Hartman
maintainerPATCH 352/399 scsi: sg: Avoid sg device teardown race
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexander Wetzel <[email protected]>
commit 27f58c04a8f438078583041468ec60597841284d upstream.
sg_remove_sfp_usercontext() must not use sg_device_destroy() after calling scsi_device_put().
sg_device_destroy() is accessing the parent scsi_device request_queue which will already be set to NULL when the preceding call to scsi_device_put() removed the last reference to the parent scsi_device.
The resulting NULL pointer exception will then crash the kernel.
--- drivers/scsi/sg.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/scsi/sg.c +3 -1
@@ -2207,6 +2207,7 @@ sg_remove_sfp_usercontext(struct work_st { struct sg_fd *sfp = container_of(work, struct sg_fd, ew.work);struct sg_device *sdp = sfp->parentdp; +struct scsi_device *device = sdp->device;Sg_request *srp;unsigned long iflags;
@@ -2232,8 +2233,9 @@ sg_remove_sfp_usercontext(struct work_st "sg_remove_sfp: sfp=0x%p\n", sfp));kfree (sfp); -scsi_device_put (sdp->device); +WARN_ON_ONCE (kref_read (&sdp->d_ref) !=1 );kref_put (&sdp->d_ref, sg_device_destroy); +scsi_device_put (device);module_put (THIS_MODULE ); }
Greg Kroah-Hartman
maintainerPATCH 353/399 scsi: core: Fix unremoved procfs host directory regression
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guilherme G. Piccoli <[email protected]>
commit f23a4d6e07570826fe95023ca1aa96a011fa9f84 upstream.
Commit fc663711b944 ("scsi: core: Remove the /proc/scsi/${proc_name} directory earlier") fixed a bug related to modules loading/unloading, by adding a call to scsi_proc_hostdir_rm() on scsi_remove_host(). But that led to a potential duplicate call to the hostdir_rm() routine, since it's also called from scsi_host_dev_release(). That triggered a regression report, which was then fixed by commit be03df3d4bfe ("scsi: core: Fix a procfs host directory removal regression"). The fix just dropped the hostdir_rm() call from dev_release().
But it happens that this proc directory is created on scsi_host_alloc(), and that function "pairs" with scsi_host_dev_release(), while scsi_remove_host() pairs with scsi_add_host(). In other words, it seems the reason for removing the proc directory on dev_release() was meant to cover cases in which a SCSI host structure was allocated, but the call to scsi_add_host() didn't happen. And that pattern happens to exist in some error paths, for example.
Syzkaller causes that by using USB raw gadget device, error'ing on usb-storage driver, at usb_stor_probe2(). By checking that path, we can see that the BadDevice label leads to a scsi_host_put() after a SCSI host allocation, but there's no call to scsi_add_host() in such path. That leads to messages like this in dmesg (and a leak of the SCSI host proc structure):
usb-storage 4-1:87.51: USB Mass Storage device detected proc_dir_entry 'scsi/usb-storage' already registered
WARNING: CPU: 1 PID: 3519 at fs/proc/generic.c:377 proc_register+0x347/0x4e0 fs/proc/generic.c:376
The proper fix seems to still call scsi_proc_hostdir_rm() on dev_release(), but guard that with the state check for SHOST_CREATED; there is even a comment in scsi_host_dev_release() detailing that: such conditional is meant for cases where the SCSI host was allocated but there was no calls to {add,remove}_host(), like the usb-storage case.
This is what we propose here and with that, the error path of usb-storage does not trigger the warning anymore.
--- drivers/scsi/hosts.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/scsi/hosts.c +4 -3
@@ -353,12 +353,13 @@ static void scsi_host_dev_release(structif (shost->shost_state ==SHOST_CREATED ) {/* -* Free the shost_dev device name here if scsi_host_alloc() -* and scsi_host_put() have been called but neither +* Free the shost_dev device name and remove the proc host dir +* here if scsi_host_{alloc,put}() have been called but neither * scsi_host_add() nor scsi_remove_host() has been called. * This avoids that the memory allocated for the shost_dev -* name is leaked. +* name as well as the proc dir structure are leaked. */ +scsi_proc_hostdir_rm (shost->hostt);kfree (dev_name (&shost->shost_dev)); }
Greg Kroah-Hartman
maintainerPATCH 354/399 staging: vc04_services: changen strncpy() to strscpy_pad()
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnd Bergmann <[email protected]>
commit ef25725b7f8aaffd7756974d3246ec44fae0a5cf upstream.
gcc-14 warns about this strncpy() that results in a non-terminated string for an overflow:
In file included from include/linux/string.h:369,
from drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c:20:
In function 'strncpy',
inlined from 'create_component' at drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c:940:2:include/linux/fortify-string.h:108:33: error: '__builtin_strncpy' specified bound 128 equals destination size [-Werror=stringop-truncation]
Change it to strscpy_pad(), which produces a properly terminated and zero-padded string.
--- drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c +2 -2
@@ -937,8 +937,8 @@ static int create_component(struct vchiq/* build component create message */ m.h.type =MMAL_MSG_TYPE_COMPONENT_CREATE ; m.u.component_create.client_component = component->client_component; -strncpy (m.u.component_create.name, name, -sizeof (m.u.component_create.name)); +strscpy_pad (m.u.component_create.name, name, +sizeof (m.u.component_create.name)); ret = send_synchronous_mmal_msg(instance, &m, sizeof(m.u.component_create),
Greg Kroah-Hartman
maintainerPATCH 355/399 staging: vc04_services: fix information leak in create_component()
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
commit f37e76abd614b68987abc8e5c22d986013349771 upstream.
The m.u.component_create.pid field is for debugging and in the mainline kernel it's not used anything. However, it still needs to be set to something to prevent disclosing uninitialized stack data. Set it to zero.
--- drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c | 1 + 1 file changed, 1 insertion(+)
drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c +1 -0
@@ -939,6 +939,7 @@ static int create_component(struct vchiq m.u.component_create.client_component = component->client_component;strscpy_pad (m.u.component_create.name, name,sizeof (m.u.component_create.name)); + m.u.component_create.pid =0 ; ret = send_synchronous_mmal_msg(instance, &m, sizeof(m.u.component_create),
Greg Kroah-Hartman
maintainerPATCH 356/399 genirq: Introduce IRQF_COND_ONESHOT and use it in pinctrl-amd
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rafael J. Wysocki <[email protected]>
commit c2ddeb29612f7ca84ed10c6d4f3ac99705135447 upstream.
There is a problem when a driver requests a shared interrupt line to run a threaded handler on it without IRQF_ONESHOT set if that flag has been set already for the IRQ in question by somebody else. Namely, the request fails which usually leads to a probe failure even though the driver might have worked just fine with IRQF_ONESHOT, but it does not want to use it by default. Currently, the only way to handle this is to try to request the IRQ without IRQF_ONESHOT, but with IRQF_PROBE_SHARED set and if this fails, try again with IRQF_ONESHOT set. However, this is a bit cumbersome and not very clean.
When commit 7a36b901a6eb ("ACPI: OSL: Use a threaded interrupt handler for SCI") switched the ACPI subsystem over to using a threaded interrupt handler for the SCI, it had to use IRQF_ONESHOT for it because that's required due to the way the SCI handler works (it needs to walk all of the enabled GPEs before the interrupt line can be unmasked). The SCI interrupt line is not shared with other users very often due to the SCI handling overhead, but on sone systems it is shared and when the other user of it attempts to install a threaded handler, a flags mismatch related to IRQF_ONESHOT may occur.
As it turned out, that happened to the pinctrl-amd driver and so commit 4451e8e8415e ("pinctrl: amd: Add IRQF_ONESHOT to the interrupt request") attempted to address the issue by adding IRQF_ONESHOT to the interrupt flags in that driver, but this is now causing an IRQF_ONESHOT-related mismatch to occur on another system which cannot boot as a result of it.
Clearly, pinctrl-amd can work with IRQF_ONESHOT if need be, but it should not set that flag by default, so it needs a way to indicate that to the interrupt subsystem.
To that end, introdcuce a new interrupt flag, IRQF_COND_ONESHOT, which will only have effect when the IRQ line is shared and IRQF_ONESHOT has been set for it already, in which case it will be promoted to the latter.
This is sufficient for drivers sharing the interrupt line with the SCI as it is requested by the ACPI subsystem before any drivers are probed, so they will always see IRQF_ONESHOT set for the interrupt in question.
--- drivers/pinctrl/pinctrl-amd.c | 2 +- include/linux/interrupt.h | 3 +++ kernel/irq/manage.c | 9 +++++++-- 3 files changed, 11 insertions(+), 3 deletions(-)
drivers/pinctrl/pinctrl-amd.c +1 -1
@@ -1159,7 +1159,7 @@ static int amd_gpio_probe(struct platfor } ret =devm_request_irq (&pdev->dev, gpio_dev->irq, amd_gpio_irq_handler, -IRQF_SHARED |IRQF_ONESHOT ,KBUILD_MODNAME , gpio_dev); +IRQF_SHARED |IRQF_COND_ONESHOT ,KBUILD_MODNAME , gpio_dev);if (ret) goto out2;
include/linux/interrupt.h +3 -0
@@ -67,6 +67,8 @@* later. * IRQF_NO_DEBUG - Exclude from runnaway detection for IPI and similar handlers, * depends on IRQF_PERCPU. +* IRQF_COND_ONESHOT - Agree to do IRQF_ONESHOT if already set for a shared +* interrupt. */ #define IRQF_SHARED 0x00000080#define IRQF_PROBE_SHARED 0x00000100
@@ -82,6 +84,7 @@#define IRQF_COND_SUSPEND 0x00040000#define IRQF_NO_AUTOEN 0x00080000#define IRQF_NO_DEBUG 0x00100000 +#define IRQF_COND_ONESHOT 0x00200000#define IRQF_TIMER (__IRQF_TIMER | IRQF_NO_SUSPEND | IRQF_NO_THREAD)
kernel/irq/manage.c +7 -2
@@ -1642,8 +1642,13 @@ __setup_irq(unsigned int irq, struct irq }if (!((old->flags & new->flags) &IRQF_SHARED ) || - (oldtype != (new->flags &IRQF_TRIGGER_MASK )) || - ((old->flags ^ new->flags) &IRQF_ONESHOT )) + (oldtype != (new->flags &IRQF_TRIGGER_MASK ))) + goto mismatch; + +if ((old->flags &IRQF_ONESHOT ) && + (new->flags &IRQF_COND_ONESHOT )) + new->flags |=IRQF_ONESHOT ; +else if ((old->flags ^ new->flags) &IRQF_ONESHOT ) goto mismatch;/* All handlers must agree on per-cpuness */
Greg Kroah-Hartman
maintainerPATCH 357/399 usb: dwc3: Properly set system wakeup
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thinh Nguyen <[email protected]>
commit f9aa41130ac69d13a53ce2a153ca79c70d43f39c upstream.
If the device is configured for system wakeup, then make sure that the xHCI driver knows about it and make sure to permit wakeup only at the appropriate time.
For host mode, if the controller goes through the dwc3 code path, then a child xHCI platform device is created. Make sure the platform device also inherits the wakeup setting for xHCI to enable remote wakeup.
For device mode, make sure to disable system wakeup if no gadget driver is bound. We may experience unwanted system wakeup due to the wakeup signal from the controller PMU detecting connection/disconnection when in low power (D3). E.g. In the case of Steam Deck, the PCI PME prevents the system staying in suspend.
--- drivers/usb/dwc3/core.c | 2 ++ drivers/usb/dwc3/core.h | 2 ++ drivers/usb/dwc3/gadget.c | 10 ++++++++++ drivers/usb/dwc3/host.c | 11 +++++++++++ 4 files changed, 25 insertions(+)
drivers/usb/dwc3/core.c +2 -0
@@ -1519,6 +1519,8 @@ static void dwc3_get_properties(struct delse dwc->sysdev = dwc->dev; + dwc->sys_wakeup =device_may_wakeup (dwc->sysdev); + ret =device_property_read_string (dev,"usb-psy-name" , &usb_psy_name);if (ret >=0 ) { dwc->usb_psy =power_supply_get_by_name (usb_psy_name);
drivers/usb/dwc3/core.h +2 -0
@@ -1132,6 +1132,7 @@ struct dwc3_scratchpad_array {* 3 - Reserved * @dis_metastability_quirk: set to disable metastability quirk. * @dis_split_quirk: set to disable split boundary. +* @sys_wakeup: set if the device may do system wakeup. * @wakeup_configured: set if the device is configured for remote wakeup. * @suspended: set to track suspend event due to U3/L2. * @imod_interval: set the interrupt moderation interval in 250ns
@@ -1355,6 +1356,7 @@ struct dwc3 { unsigned dis_split_quirk:1; unsigned async_callbacks:1; + unsigned sys_wakeup:1; unsigned wakeup_configured:1; unsigned suspended:1;
drivers/usb/dwc3/gadget.c +10 -0
@@ -2968,6 +2968,9 @@ static int dwc3_gadget_start(struct usb_ dwc->gadget_driver = driver;spin_unlock_irqrestore (&dwc->lock, flags); +if (dwc->sys_wakeup) +device_wakeup_enable (dwc->sysdev); +return 0 ; }
@@ -2983,6 +2986,9 @@ static int dwc3_gadget_stop(struct usb_gstruct dwc3 *dwc =gadget_to_dwc (g);unsigned long flags; +if (dwc->sys_wakeup) +device_wakeup_disable (dwc->sysdev); +spin_lock_irqsave (&dwc->lock, flags); dwc->gadget_driver =NULL ; dwc->max_cfg_eps =0 ;
@@ -4664,6 +4670,10 @@ int dwc3_gadget_init(struct dwc3 *dwc)else dwc3_gadget_set_speed (dwc->gadget, dwc->maximum_speed); +/* No system wakeup if no gadget driver bound */ +if (dwc->sys_wakeup) +device_wakeup_disable (dwc->sysdev); +return 0 ; err5:
drivers/usb/dwc3/host.c +11 -0
@@ -123,6 +123,14 @@ int dwc3_host_init(struct dwc3 *dwc) goto err; } +if (dwc->sys_wakeup) { +/* Restore wakeup setting if switched from device */ +device_wakeup_enable (dwc->sysdev); + +/* Pass on wakeup setting to the new xhci platform device */ +device_init_wakeup (&xhci->dev, true); + } +return 0 ; err:platform_device_put (xhci);
@@ -131,6 +139,9 @@ err:void dwc3_host_exit (struct dwc3 *dwc) { +if (dwc->sys_wakeup) +device_init_wakeup (&dwc->xhci->dev, false); +platform_device_unregister (dwc->xhci); dwc->xhci =NULL ; }
Greg Kroah-Hartman
maintainerPATCH 358/399 USB: core: Fix deadlock in usb_deauthorize_interface()
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alan Stern <[email protected]>
commit 80ba43e9f799cbdd83842fc27db667289b3150f5 upstream.
Among the attribute file callback routines in drivers/usb/core/sysfs.c, the interface_authorized_store() function is the only one which acquires a device lock on an ancestor device: It calls usb_deauthorize_interface(), which locks the interface's parent USB device.
The will lead to deadlock if another process already owns that lock and tries to remove the interface, whether through a configuration change or because the device has been disconnected. As part of the removal procedure, device_del() waits for all ongoing sysfs attribute callbacks to complete. But usb_deauthorize_interface() can't complete until the device lock has been released, and the lock won't be released until the removal has finished.
The mechanism provided by sysfs to prevent this kind of deadlock is to use the sysfs_break_active_protection() function, which tells sysfs not to wait for the attribute callback.
Reported-and-tested by: Yue Sun <[email protected]> Reported by: xingwei lee <[email protected]>
--- drivers/usb/core/sysfs.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)
drivers/usb/core/sysfs.c +13 -3
@@ -1168,14 +1168,24 @@ static ssize_t interface_authorized_stor {struct usb_interface *intf =to_usb_interface (dev);bool val; +struct kernfs_node *kn;if (kstrtobool (buf, &val) !=0 )return -EINVAL ; -if (val) +if (val) {usb_authorize_interface (intf); -else -usb_deauthorize_interface (intf); + }else { +/* +* Prevent deadlock if another process is concurrently +* trying to unregister intf. +*/ + kn =sysfs_break_active_protection (&dev->kobj, &attr->attr); +if (kn) { +usb_deauthorize_interface (intf); +sysfs_unbreak_active_protection (kn); + } + }return count; }
Greg Kroah-Hartman
maintainerPATCH 359/399 USB: core: Add hub_get() and hub_put() routines
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alan Stern <[email protected]>
commit ee113b860aa169e9a4d2c167c95d0f1961c6e1b8 upstream.
Create hub_get() and hub_put() routines to encapsulate the kref_get() and kref_put() calls in hub.c. The new routines will be used by the next patch in this series.
--- drivers/usb/core/hub.c | 23 ++++++++++++++++------- drivers/usb/core/hub.h | 2 ++ 2 files changed, 18 insertions(+), 7 deletions(-)
drivers/usb/core/hub.c +16 -7
@@ -129,7 +129,6 @@ EXPORT_SYMBOL_GPL(ehci_cf_port_reset_rws#define HUB_DEBOUNCE_STEP 25#define HUB_DEBOUNCE_STABLE 100 -static void hub_release (struct kref *kref);static int usb_reset_and_verify_device (struct usb_device *udev);static int hub_port_disable (struct usb_hub *hub,int port1,int set_state); static bool hub_port_warm_reset_required(struct usb_hub *hub, int port1,
@@ -691,14 +690,14 @@ static void kick_hub_wq(struct usb_hub **/ intf =to_usb_interface (hub->intfdev);usb_autopm_get_interface_no_resume (intf); -kref_get (&hub->kref); +hub_get (hub);if (queue_work (hub_wq, &hub->events))return ;/* the work has already been scheduled */ usb_autopm_put_interface_async (intf); -kref_put (&hub->kref, hub_release); +hub_put (hub); }void usb_kick_hub_wq (struct usb_device *hdev)
@@ -1066,7 +1065,7 @@ static void hub_activate(struct usb_hub goto init2; goto init3; } -kref_get (&hub->kref); +hub_get (hub);/* The superspeed hub except for root hub has to use Hub Depth * value as an offset into the route string to locate the bits
@@ -1314,7 +1313,7 @@ static void hub_activate(struct usb_hubdevice_unlock (&hdev->dev); } -kref_put (&hub->kref, hub_release); +hub_put (hub); }/* Implement the continuations for the delays above */
@@ -1730,6 +1729,16 @@ static void hub_release(struct kref *krekfree (hub); } +void hub_get (struct usb_hub *hub) +{ +kref_get (&hub->kref); +} + +void hub_put (struct usb_hub *hub) +{ +kref_put (&hub->kref, hub_release); +} +static unsigned highspeed_hubs;static void hub_disconnect (struct usb_interface *intf)
@@ -1778,7 +1787,7 @@ static void hub_disconnect(struct usb_inonboard_hub_destroy_pdevs (&hub->onboard_hub_devs); -kref_put (&hub->kref, hub_release); +hub_put (hub); }static bool hub_descriptor_is_sane (struct usb_host_interface *desc)
@@ -5905,7 +5914,7 @@ out_hdev_lock:/* Balance the stuff in kick_hub_wq() and allow autosuspend */ usb_autopm_put_interface (intf); -kref_put (&hub->kref, hub_release); +hub_put (hub);kcov_remote_stop (); }
drivers/usb/core/hub.h +2 -0
@@ -129,6 +129,8 @@ extern void usb_hub_remove_port_device(sextern int usb_hub_set_port_power (struct usb_device *hdev,struct usb_hub *hub,int port1,bool set);extern struct usb_hub *usb_hub_to_struct_hub (struct usb_device *hdev); +extern void hub_get (struct usb_hub *hub); +extern void hub_put (struct usb_hub *hub);extern int hub_port_debounce (struct usb_hub *hub,int port1,bool must_be_connected); extern int usb_clear_port_feature(struct usb_device *hdev,
Greg Kroah-Hartman
maintainerPATCH 360/399 USB: core: Fix deadlock in port "disable" sysfs attribute
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alan Stern <[email protected]>
commit f4d1960764d8a70318b02f15203a1be2b2554ca1 upstream.
The show and store callback routines for the "disable" sysfs attribute file in port.c acquire the device lock for the port's parent hub device. This can cause problems if another process has locked the hub to remove it or change its configuration:
Removing the hub or changing its configuration requires the hub interface to be removed, which requires the port device to be removed, and device_del() waits until all outstanding sysfs attribute callbacks for the ports have returned. The lock can't be released until then.
But the disable_show() or disable_store() routine can't return until after it has acquired the lock.
The resulting deadlock can be avoided by calling sysfs_break_active_protection(). This will cause the sysfs core not to wait for the attribute's callback routine to return, allowing the removal to proceed. The disadvantage is that after making this call, there is no guarantee that the hub structure won't be deallocated at any moment. To prevent this, we have to acquire a reference to it first by calling hub_get().
--- drivers/usb/core/port.c | 38 ++++++++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-)
drivers/usb/core/port.c +34 -4
@@ -55,11 +55,22 @@ static ssize_t disable_show(struct devicu16 portstatus, unused;bool disabled;int rc; +struct kernfs_node *kn; +hub_get (hub); rc =usb_autopm_get_interface (intf);if (rc <0 ) -return rc; + goto out_hub_get; +/* +* Prevent deadlock if another process is concurrently +* trying to unregister hdev. +*/ + kn =sysfs_break_active_protection (&dev->kobj, &attr->attr); +if (!kn) { + rc = -ENODEV ; + goto out_autopm; + }usb_lock_device (hdev);if (hub->disconnected) { rc = -ENODEV ;
@@ -69,9 +80,13 @@ static ssize_t disable_show(struct devicusb_hub_port_status (hub, port1, &portstatus, &unused); disabled = !usb_port_is_power_on (hub, portstatus); -out_hdev_lock: + out_hdev_lock:usb_unlock_device (hdev); +sysfs_unbreak_active_protection (kn); + out_autopm:usb_autopm_put_interface (intf); + out_hub_get: +hub_put (hub);if (rc)return rc;
@@ -89,15 +104,26 @@ static ssize_t disable_store(struct deviint port1 = port_dev->portnum;bool disabled;int rc; +struct kernfs_node *kn; rc =kstrtobool (buf, &disabled);if (rc)return rc; +hub_get (hub); rc =usb_autopm_get_interface (intf);if (rc <0 ) -return rc; + goto out_hub_get; +/* +* Prevent deadlock if another process is concurrently +* trying to unregister hdev. +*/ + kn =sysfs_break_active_protection (&dev->kobj, &attr->attr); +if (!kn) { + rc = -ENODEV ; + goto out_autopm; + }usb_lock_device (hdev);if (hub->disconnected) { rc = -ENODEV ;
@@ -118,9 +144,13 @@ static ssize_t disable_store(struct deviif (!rc) rc = count; -out_hdev_lock: + out_hdev_lock:usb_unlock_device (hdev); +sysfs_unbreak_active_protection (kn); + out_autopm:usb_autopm_put_interface (intf); + out_hub_get: +hub_put (hub);return rc; }
Greg Kroah-Hartman
maintainerPATCH 361/399 usb: dwc2: host: Fix remote wakeup from hibernation
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Minas Harutyunyan <[email protected]>
commit bae2bc73a59c200db53b6c15fb26bb758e2c6108 upstream.
Starting from core v4.30a changed order of programming GPWRDN_PMUACTV to 0 in case of exit from hibernation on remote wakeup signaling from device.
--- drivers/usb/dwc2/core.h | 1 + drivers/usb/dwc2/hcd.c | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-)
drivers/usb/dwc2/core.h +1 -0
@@ -1086,6 +1086,7 @@ struct dwc2_hsotg {bool needs_byte_swap;/* DWC OTG HW Release versions */ +#define DWC2_CORE_REV_4_30a 0x4f54430a#define DWC2_CORE_REV_2_71a 0x4f54271a#define DWC2_CORE_REV_2_72a 0x4f54272a#define DWC2_CORE_REV_2_80a 0x4f54280a
drivers/usb/dwc2/hcd.c +13 -4
@@ -5610,10 +5610,12 @@ int dwc2_host_exit_hibernation(struct dwdwc2_writel (hsotg, hr->hcfg,HCFG );/* De-assert Wakeup Logic */ - gpwrdn =dwc2_readl (hsotg,GPWRDN ); - gpwrdn &= ~GPWRDN_PMUACTV ; -dwc2_writel (hsotg, gpwrdn,GPWRDN ); -udelay (10 ); +if (!(rem_wakeup && hsotg->hw_params.snpsid >= DWC2_CORE_REV_4_30a)) { + gpwrdn =dwc2_readl (hsotg,GPWRDN ); + gpwrdn &= ~GPWRDN_PMUACTV ; +dwc2_writel (hsotg, gpwrdn,GPWRDN ); +udelay (10 ); + } hprt0 = hr->hprt0; hprt0 |=HPRT0_PWR ;
@@ -5638,6 +5640,13 @@ int dwc2_host_exit_hibernation(struct dw hprt0 |=HPRT0_RES ;dwc2_writel (hsotg, hprt0,HPRT0 ); +/* De-assert Wakeup Logic */ +if ((rem_wakeup && hsotg->hw_params.snpsid >= DWC2_CORE_REV_4_30a)) { + gpwrdn =dwc2_readl (hsotg,GPWRDN ); + gpwrdn &= ~GPWRDN_PMUACTV ; +dwc2_writel (hsotg, gpwrdn,GPWRDN ); +udelay (10 ); + }/* Wait for Resume time and then program HPRT again */ mdelay (100 ); hprt0 &= ~HPRT0_RES ;
Greg Kroah-Hartman
maintainerPATCH 362/399 usb: dwc2: host: Fix hibernation flow
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Minas Harutyunyan <[email protected]>
commit 3c7b9856a82227db01a20171d2e24c7ce305d59b upstream.
Added to backup/restore registers HFLBADDR, HCCHARi, HCSPLTi, HCTSIZi, HCDMAi and HCDMABi.
--- drivers/usb/dwc2/core.h | 12 ++++++++++++ drivers/usb/dwc2/hcd.c | 18 ++++++++++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-)
drivers/usb/dwc2/core.h +12 -0
@@ -729,8 +729,14 @@ struct dwc2_dregs_backup {* struct dwc2_hregs_backup - Holds host registers state before * entering partial power down * @hcfg: Backup of HCFG register +* @hflbaddr: Backup of HFLBADDR register * @haintmsk: Backup of HAINTMSK register +* @hcchar: Backup of HCCHAR register +* @hcsplt: Backup of HCSPLT register * @hcintmsk: Backup of HCINTMSK register +* @hctsiz: Backup of HCTSIZ register +* @hdma: Backup of HCDMA register +* @hcdmab: Backup of HCDMAB register * @hprt0: Backup of HPTR0 register * @hfir: Backup of HFIR register * @hptxfsiz: Backup of HPTXFSIZ register
@@ -738,8 +744,14 @@ struct dwc2_dregs_backup {*/ struct dwc2_hregs_backup {u32 hcfg; +u32 hflbaddr;u32 haintmsk; +u32 hcchar[MAX_EPS_CHANNELS ]; +u32 hcsplt[MAX_EPS_CHANNELS ];u32 hcintmsk[MAX_EPS_CHANNELS ]; +u32 hctsiz[MAX_EPS_CHANNELS ]; +u32 hcidma[MAX_EPS_CHANNELS ]; +u32 hcidmab[MAX_EPS_CHANNELS ];u32 hprt0;u32 hfir;u32 hptxfsiz;
drivers/usb/dwc2/hcd.c +16 -2
@@ -5406,9 +5406,16 @@ int dwc2_backup_host_registers(struct dw/* Backup Host regs */ hr = &hsotg->hr_backup; hr->hcfg =dwc2_readl (hsotg,HCFG ); + hr->hflbaddr =dwc2_readl (hsotg,HFLBADDR ); hr->haintmsk =dwc2_readl (hsotg,HAINTMSK ); -for (i =0 ; i < hsotg->params.host_channels; ++i) +for (i =0 ; i < hsotg->params.host_channels; ++i) { + hr->hcchar[i] =dwc2_readl (hsotg,HCCHAR (i)); + hr->hcsplt[i] =dwc2_readl (hsotg,HCSPLT (i)); hr->hcintmsk[i] =dwc2_readl (hsotg,HCINTMSK (i)); + hr->hctsiz[i] =dwc2_readl (hsotg,HCTSIZ (i)); + hr->hcidma[i] =dwc2_readl (hsotg,HCDMA (i)); + hr->hcidmab[i] =dwc2_readl (hsotg,HCDMAB (i)); + } hr->hprt0 =dwc2_read_hprt0 (hsotg); hr->hfir =dwc2_readl (hsotg,HFIR );
@@ -5442,10 +5449,17 @@ int dwc2_restore_host_registers(struct d hr->valid = false;dwc2_writel (hsotg, hr->hcfg,HCFG ); +dwc2_writel (hsotg, hr->hflbaddr,HFLBADDR );dwc2_writel (hsotg, hr->haintmsk,HAINTMSK ); -for (i =0 ; i < hsotg->params.host_channels; ++i) +for (i =0 ; i < hsotg->params.host_channels; ++i) { +dwc2_writel (hsotg, hr->hcchar[i],HCCHAR (i)); +dwc2_writel (hsotg, hr->hcsplt[i],HCSPLT (i));dwc2_writel (hsotg, hr->hcintmsk[i],HCINTMSK (i)); +dwc2_writel (hsotg, hr->hctsiz[i],HCTSIZ (i)); +dwc2_writel (hsotg, hr->hcidma[i],HCDMA (i)); +dwc2_writel (hsotg, hr->hcidmab[i],HCDMAB (i)); + }dwc2_writel (hsotg, hr->hprt0,HPRT0 );dwc2_writel (hsotg, hr->hfir,HFIR );
Greg Kroah-Hartman
maintainerPATCH 363/399 usb: dwc2: host: Fix ISOC flow in DDMA mode
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Minas Harutyunyan <[email protected]>
commit b258e42688501cadb1a6dd658d6f015df9f32d8f upstream.
Fixed ISOC completion flow in DDMA mode. Added isoc descriptor actual length value and update urb's start_frame value.
Fixed initialization of ISOC DMA descriptors flow.
--- drivers/usb/dwc2/hcd.c | 12 ++++++++++-- drivers/usb/dwc2/hcd_ddma.c | 17 +++++++++++------ drivers/usb/dwc2/hw.h | 2 +- 3 files changed, 22 insertions(+), 9 deletions(-)
drivers/usb/dwc2/hcd.c +10 -2
@@ -2701,8 +2701,11 @@ enum dwc2_transaction_type dwc2_hcd_sele hsotg->available_host_channels--; } qh = list_entry(qh_ptr, struct dwc2_qh, qh_list_entry); -if (dwc2_assign_and_init_hc (hsotg, qh)) +if (dwc2_assign_and_init_hc (hsotg, qh)) { +if (hsotg->params.uframe_sched) + hsotg->available_host_channels++;break ; + }/* * Move the QH from the periodic ready schedule to the
@@ -2735,8 +2738,11 @@ enum dwc2_transaction_type dwc2_hcd_sele hsotg->available_host_channels--; } -if (dwc2_assign_and_init_hc (hsotg, qh)) +if (dwc2_assign_and_init_hc (hsotg, qh)) { +if (hsotg->params.uframe_sched) + hsotg->available_host_channels++;break ; + }/* * Move the QH from the non-periodic inactive schedule to the
@@ -4143,6 +4149,8 @@ void dwc2_host_complete(struct dwc2_hsot urb->actual_length);if (usb_pipetype (urb->pipe) ==PIPE_ISOCHRONOUS ) { +if (!hsotg->params.dma_desc_enable) + urb->start_frame = qtd->qh->start_active_frame; urb->error_count =dwc2_hcd_urb_get_error_count (qtd->urb);for (i =0 ; i < urb->number_of_packets; ++i) { urb->iso_frame_desc[i].actual_length =
drivers/usb/dwc2/hcd_ddma.c +11 -6
@@ -559,7 +559,7 @@ static void dwc2_init_isoc_dma_desc(stru idx = qh->td_last; inc = qh->host_interval; hsotg->frame_number =dwc2_hcd_get_frame_number (hsotg); - cur_idx =dwc2_frame_list_idx (hsotg->frame_number); + cur_idx = idx; next_idx =dwc2_desclist_idx_inc (qh->td_last, inc, qh->dev_speed);/*
@@ -866,6 +866,8 @@ static int dwc2_cmpl_host_isoc_dma_desc( {struct dwc2_dma_desc *dma_desc;struct dwc2_hcd_iso_packet_desc *frame_desc; +u16 frame_desc_idx; +struct urb *usb_urb = qtd->urb->priv;u16 remain =0 ;int rc =0 ;
@@ -878,8 +880,11 @@ static int dwc2_cmpl_host_isoc_dma_desc( DMA_FROM_DEVICE); dma_desc = &qh->desc_list[idx]; + frame_desc_idx = (idx - qtd->isoc_td_first) & (usb_urb->number_of_packets -1 ); - frame_desc = &qtd->urb->iso_descs[qtd->isoc_frame_index_last]; + frame_desc = &qtd->urb->iso_descs[frame_desc_idx]; +if (idx == qtd->isoc_td_first) + usb_urb->start_frame =dwc2_hcd_get_frame_number (hsotg); dma_desc->buf = (u32)(qtd->urb->dma + frame_desc->offset);if (chan->ep_is_in) remain = (dma_desc->status & HOST_DMA_ISOC_NBYTES_MASK) >>
@@ -900,7 +905,7 @@ static int dwc2_cmpl_host_isoc_dma_desc( frame_desc->status =0 ; } -if (++qtd->isoc_frame_index == qtd->urb->packet_count) { +if (++qtd->isoc_frame_index == usb_urb->number_of_packets) {/* * urb->status is not used for isoc transfers here. The * individual frame_desc status are used instead.
@@ -1005,11 +1010,11 @@ static void dwc2_complete_isoc_xfer_ddmareturn ; idx =dwc2_desclist_idx_inc (idx, qh->host_interval, chan->speed); -if (!rc) +if (rc ==0 )continue ; -if (rc ==DWC2_CMPL_DONE ) -break ; +if (rc ==DWC2_CMPL_DONE || rc ==DWC2_CMPL_STOP ) + goto stop_scan;/* rc == DWC2_CMPL_STOP */
drivers/usb/dwc2/hw.h +1 -1
@@ -698,7 +698,7 @@#define TXSTS_QTOP_TOKEN_MASK (0x3 << 25)#define TXSTS_QTOP_TOKEN_SHIFT 25#define TXSTS_QTOP_TERMINATE BIT(24) -#define TXSTS_QSPCAVAIL_MASK (0xff << 16) +#define TXSTS_QSPCAVAIL_MASK (0x7f << 16)#define TXSTS_QSPCAVAIL_SHIFT 16#define TXSTS_FSPCAVAIL_MASK (0xffff << 0)#define TXSTS_FSPCAVAIL_SHIFT 0
Greg Kroah-Hartman
maintainerPATCH 364/399 usb: dwc2: gadget: Fix exiting from clock gating
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Minas Harutyunyan <[email protected]>
commit 31f42da31417bec88158f3cf62d19db836217f1e upstream.
Added exiting from the clock gating mode on USB Reset Detect interrupt if core in the clock gating mode.
Added new condition to check core in clock gating mode or no.
--- drivers/usb/dwc2/core_intr.c | 9 ++++++--- drivers/usb/dwc2/gadget.c | 6 ++++++ drivers/usb/dwc2/hcd.c | 2 +- drivers/usb/dwc2/platform.c | 2 +- 4 files changed, 14 insertions(+), 5 deletions(-)
drivers/usb/dwc2/core_intr.c +6 -3
@@ -297,7 +297,8 @@ static void dwc2_handle_session_req_intr/* Exit gadget mode clock gating. */ if (hsotg->params.power_down == -DWC2_POWER_DOWN_PARAM_NONE && hsotg->bus_suspended) +DWC2_POWER_DOWN_PARAM_NONE && hsotg->bus_suspended && + !hsotg->params.no_clock_gating)dwc2_gadget_exit_clock_gating (hsotg,0 ); }
@@ -408,7 +409,8 @@ static void dwc2_handle_wakeup_detected_/* Exit gadget mode clock gating. */ if (hsotg->params.power_down == -DWC2_POWER_DOWN_PARAM_NONE && hsotg->bus_suspended) +DWC2_POWER_DOWN_PARAM_NONE && hsotg->bus_suspended && + !hsotg->params.no_clock_gating)dwc2_gadget_exit_clock_gating (hsotg,0 ); }else {/* Change to L0 state */
@@ -425,7 +427,8 @@ static void dwc2_handle_wakeup_detected_ }if (hsotg->params.power_down == -DWC2_POWER_DOWN_PARAM_NONE && hsotg->bus_suspended) +DWC2_POWER_DOWN_PARAM_NONE && hsotg->bus_suspended && + !hsotg->params.no_clock_gating)dwc2_host_exit_clock_gating (hsotg,1 );/*
drivers/usb/dwc2/gadget.c +6 -0
@@ -3727,6 +3727,12 @@ irq_retry:if (hsotg->in_ppd && hsotg->lx_state ==DWC2_L2 )dwc2_exit_partial_power_down (hsotg,0 , true); +/* Exit gadget mode clock gating. */ +if (hsotg->params.power_down == +DWC2_POWER_DOWN_PARAM_NONE && hsotg->bus_suspended && + !hsotg->params.no_clock_gating) +dwc2_gadget_exit_clock_gating (hsotg,0 ); + hsotg->lx_state =DWC2_L0 ; }
drivers/usb/dwc2/hcd.c +1 -1
@@ -4657,7 +4657,7 @@ static int _dwc2_hcd_urb_enqueue(struct }if (hsotg->params.power_down ==DWC2_POWER_DOWN_PARAM_NONE && - hsotg->bus_suspended) { + hsotg->bus_suspended && !hsotg->params.no_clock_gating) {if (dwc2_is_device_mode (hsotg))dwc2_gadget_exit_clock_gating (hsotg,0 );else
drivers/usb/dwc2/platform.c +1 -1
@@ -331,7 +331,7 @@ static void dwc2_driver_remove(struct pl/* Exit clock gating when driver is removed. */ if (hsotg->params.power_down ==DWC2_POWER_DOWN_PARAM_NONE && - hsotg->bus_suspended) { + hsotg->bus_suspended && !hsotg->params.no_clock_gating) {if (dwc2_is_device_mode (hsotg))dwc2_gadget_exit_clock_gating (hsotg,0 );else
Greg Kroah-Hartman
maintainerPATCH 365/399 usb: dwc2: gadget: LPM flow fix
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Minas Harutyunyan <[email protected]>
commit 5d69a3b54e5a630c90d82a4c2bdce3d53dc78710 upstream.
Added functionality to exit from L1 state by device initiation using remote wakeup signaling, in case when function driver queuing request while core in L1 state.
--- drivers/usb/dwc2/core.h | 1 drivers/usb/dwc2/core_intr.c | 65 ++++++++++++++++++++++++++++--------------- drivers/usb/dwc2/gadget.c | 4 ++ 3 files changed, 48 insertions(+), 22 deletions(-)
drivers/usb/dwc2/core.h +1 -0
@@ -1336,6 +1336,7 @@ int dwc2_backup_global_registers(structint dwc2_restore_global_registers (struct dwc2_hsotg *hsotg);void dwc2_enable_acg (struct dwc2_hsotg *hsotg); +void dwc2_wakeup_from_lpm_l1 (struct dwc2_hsotg *hsotg,bool remotewakeup);/* This function should be called on every hardware interrupt. */ irqreturn_t dwc2_handle_common_intr (int irq,void *dev);
drivers/usb/dwc2/core_intr.c +43 -22
97 lines not on this page · raw message
drivers/usb/dwc2/gadget.c +4 -0
@@ -1415,6 +1415,10 @@ static int dwc2_hsotg_ep_queue(struct us ep->name, req, req->length, req->buf, req->no_interrupt, req->zero, req->short_not_ok); +if (hs->lx_state ==DWC2_L1 ) { +dwc2_wakeup_from_lpm_l1 (hs, true); + } +/* Prevent new request submission when controller is suspended */ if (hs->lx_state !=DWC2_L0 ) { dev_dbg(hs->dev, "%s: submit request only in active state\n",
Greg Kroah-Hartman
maintainerPATCH 366/399 usb: udc: remove warning when queue disabled ep
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: yuan linyu <[email protected]>
commit 2a587a035214fa1b5ef598aea0b81848c5b72e5e upstream.
It is possible trigger below warning message from mass storage function,
WARNING: CPU: 6 PID: 3839 at drivers/usb/gadget/udc/core.c:294 usb_ep_queue+0x7c/0x104 pc : usb_ep_queue+0x7c/0x104 lr : fsg_main_thread+0x494/0x1b3c
Root cause is mass storage function try to queue request from main thread, but other thread may already disable ep when function disable.
As there is no function failure in the driver, in order to avoid effort to fix warning, change WARN_ON_ONCE() in usb_ep_queue() to pr_debug().
--- drivers/usb/gadget/udc/core.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/usb/gadget/udc/core.c +3 -1
@@ -292,7 +292,9 @@ int usb_ep_queue(struct usb_ep *ep, {int ret =0 ; -if (WARN_ON_ONCE (!ep->enabled && ep->address)) { +if (!ep->enabled && ep->address) { +pr_debug ("USB gadget: queue request to disabled ep 0x%x (%s)\n" , + ep->address, ep->name); ret = -ESHUTDOWN ; goto out; }
Greg Kroah-Hartman
maintainerPATCH 367/399 usb: typec: ucsi: Fix race between typec_switch and role_switch
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Krishna Kurapati <[email protected]>
commit f5e9bda03aa50ffad36eccafe893d004ef213c43 upstream.
When orientation switch is enabled in ucsi glink, there is a xhci probe failure seen when booting up in host mode in reverse orientation.
During bootup the following things happen in multiple drivers:
a) DWC3 controller driver initializes the core in device mode when the dr_mode is set to DRD. It relies on role_switch call to change role to host.
b) QMP driver initializes the lanes to TYPEC_ORIENTATION_NORMAL as a normal routine. It relies on the typec_switch_set call to get notified of orientation changes.
c) UCSI core reads the UCSI_GET_CONNECTOR_STATUS via the glink and provides initial role switch to dwc3 controller.
When booting up in host mode with orientation TYPEC_ORIENTATION_REVERSE, then we see the following things happening in order:
a) UCSI gives initial role as host to dwc3 controller ucsi_register_port. Upon receiving this notification, the dwc3 core needs to program GCTL from PRTCAP_DEVICE to PRTCAP_HOST and as part of this change, it asserts GCTL Core soft reset and waits for it to be completed before shifting it to host. Only after the reset is done will the dwc3_host_init be invoked and xhci is probed. DWC3 controller expects that the usb phy's are stable during this process i.e., the phy init is already done.
b) During the 100ms wait for GCTL core soft reset, the actual notification from PPM is received by ucsi_glink via pmic glink for changing role to host. The pmic_glink_ucsi_notify routine first sends the orientation change to QMP and then sends role to dwc3 via ucsi framework. This is happening exactly at the time GCTL core soft reset is being processed.
c) When QMP driver receives typec switch to TYPEC_ORIENTATION_REVERSE, it then re-programs the phy at the instant GCTL core soft reset has been asserted by dwc3 controller due to which the QMP PLL lock fails in qmp_combo_usb_power_on.
d) After the 100ms of GCTL core soft reset is completed, the dwc3 core goes for initializing the host mode and invokes xhci probe. But at this point the QMP is non-responsive and as a result, the xhci plat probe fails during xhci_reset.
Fix this by passing orientation switch to available ucsi instances if their gpio configuration is available before ucsi_register is invoked so that by the time, the pmic_glink_ucsi_notify provides typec_switch to QMP, the lane is already configured and the call would be a NOP thus not racing with role switch.
--- drivers/usb/typec/ucsi/ucsi_glink.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
drivers/usb/typec/ucsi/ucsi_glink.c +14 -0
@@ -255,6 +255,20 @@ static void pmic_glink_ucsi_notify(strucstatic void pmic_glink_ucsi_register (struct work_struct *work) { struct pmic_glink_ucsi *ucsi = container_of(work, struct pmic_glink_ucsi, register_work); +int orientation; +int i; + +for (i =0 ; i <PMIC_GLINK_MAX_PORTS ; i++) { +if (!ucsi->port_orientation[i]) +continue ; + orientation =gpiod_get_value (ucsi->port_orientation[i]); + +if (orientation >=0 ) { +typec_switch_set (ucsi->port_switch[i], + orientation ?TYPEC_ORIENTATION_REVERSE + :TYPEC_ORIENTATION_NORMAL ); + } + }ucsi_register (ucsi->ucsi); }
Greg Kroah-Hartman
maintainerPATCH 368/399 usb: typec: tcpm: fix double-free issue in tcpm_port_unregister_pd()
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xu Yang <[email protected]>
commit b63f90487bdf93a4223ce7853d14717e9d452856 upstream.
When unregister pd capabilitie in tcpm, KASAN will capture below double -free issue. The root cause is the same capabilitiy will be kfreed twice, the first time is kfreed by pd_capabilities_release() and the second time is explicitly kfreed by tcpm_port_unregister_pd().
[ 3.988059] BUG: KASAN: double-free in tcpm_port_unregister_pd+0x1a4/0x3dc [ 3.995001] Free of addr ffff0008164d3000 by task kworker/u16:0/10 [ 4.001206] [ 4.002712] CPU: 2 PID: 10 Comm: kworker/u16:0 Not tainted 6.8.0-rc5-next-20240220-05616-g52728c567a55 #53 [ 4.012402] Hardware name: Freescale i.MX8QXP MEK (DT) [ 4.017569] Workqueue: events_unbound deferred_probe_work_func [ 4.023456] Call trace: [ 4.025920] dump_backtrace+0x94/0xec [ 4.029629] show_stack+0x18/0x24 [ 4.032974] dump_stack_lvl+0x78/0x90 [ 4.036675] print_report+0xfc/0x5c0 [ 4.040289] kasan_report_invalid_free+0xa0/0xc0 [ 4.044937] __kasan_slab_free+0x124/0x154 [ 4.049072] kfree+0xb4/0x1e8 [ 4.052069] tcpm_port_unregister_pd+0x1a4/0x3dc [ 4.056725] tcpm_register_port+0x1dd0/0x2558 [ 4.061121] tcpci_register_port+0x420/0x71c [ 4.065430] tcpci_probe+0x118/0x2e0
To fix the issue, this will remove kree() from tcpm_port_unregister_pd().
--- drivers/usb/typec/tcpm/tcpm.c | 2 -- 1 file changed, 2 deletions(-)
drivers/usb/typec/tcpm/tcpm.c +0 -2
@@ -6199,9 +6199,7 @@ static void tcpm_port_unregister_pd(stru port->port_source_caps =NULL ;for (i =0 ; i < port->pd_count; i++) {usb_power_delivery_unregister_capabilities (port->pd_list[i]->sink_cap); -kfree (port->pd_list[i]->sink_cap);usb_power_delivery_unregister_capabilities (port->pd_list[i]->source_cap); -kfree (port->pd_list[i]->source_cap);devm_kfree (port->dev, port->pd_list[i]); port->pd_list[i] =NULL ;usb_power_delivery_unregister (port->pds[i]);
Greg Kroah-Hartman
maintainerPATCH 369/399 usb: typec: tcpm: Correct port source pdo array in pd_set callback
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kyle Tso <[email protected]>
commit 893cd9469c68a89a34956121685617dbb37497b1 upstream.
In tcpm_pd_set, the array of port source capabilities is port->src_pdo, not port->snk_pdo.
--- drivers/usb/typec/tcpm/tcpm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/typec/tcpm/tcpm.c +1 -1
@@ -6117,7 +6117,7 @@ static int tcpm_pd_set(struct typec_portif (data->source_desc.pdo[0 ]) {for (i =0 ; i <PDO_MAX_OBJECTS && data->source_desc.pdo[i]; i++) - port->snk_pdo[i] = data->source_desc.pdo[i]; + port->src_pdo[i] = data->source_desc.pdo[i]; port->nr_src_pdo = i +1 ; }
Greg Kroah-Hartman
maintainerPATCH 370/399 usb: typec: tcpm: Update PD of Type-C port upon pd_set
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kyle Tso <[email protected]>
commit 17af5050dead6cbcca12c1fcd17e0bb8bb284eae upstream.
The PD of Type-C port needs to be updated in pd_set. Unlink the Type-C port device to the old PD before linking it to a new one.
--- drivers/usb/typec/tcpm/tcpm.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/usb/typec/tcpm/tcpm.c +2 -0
@@ -6166,7 +6166,9 @@ static int tcpm_pd_set(struct typec_port port->port_source_caps = data->source_cap; port->port_sink_caps = data->sink_cap; +typec_port_set_usb_power_delivery (p,NULL ); port->selected_pd = pd; +typec_port_set_usb_power_delivery (p, port->selected_pd); unlock:mutex_unlock (&port->lock);return ret;
Greg Kroah-Hartman
maintainerPATCH 371/399 usb: typec: Return size of buffer if pd_set operation succeeds
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kyle Tso <[email protected]>
commit 53f5094fdf5deacd99b8655df692e9278506724d upstream.
The attribute writing should return the number of bytes used from the buffer on success.
--- drivers/usb/typec/class.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/usb/typec/class.c +6 -1
@@ -1310,6 +1310,7 @@ static ssize_t select_usb_power_delivery {struct typec_port *port =to_typec_port (dev);struct usb_power_delivery *pd; +int ret;if (!port->ops || !port->ops->pd_set)return -EOPNOTSUPP ;
@@ -1318,7 +1319,11 @@ static ssize_t select_usb_power_deliveryif (!pd)return -EINVAL ; -return port->ops->pd_set (port, pd); + ret = port->ops->pd_set (port, pd); +if (ret) +return ret; + +return size; } static ssize_t select_usb_power_delivery_show(struct device *dev,
Greg Kroah-Hartman
maintainerPATCH 372/399 usb: typec: ucsi: Clear EVENT_PENDING under PPM lock
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian A. Ehrhardt <[email protected]>
commit 15b2e71b4653b3e13df34695a29ebeee237c5af2 upstream.
Suppose we sleep on the PPM lock after clearing the EVENT_PENDING bit because the thread for another connector is executing a command. In this case the command completion of the other command will still report the connector change for our connector.
Clear the EVENT_PENDING bit under the PPM lock to avoid another useless call to ucsi_handle_connector_change() in this case.
--- drivers/usb/typec/ucsi/ucsi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/typec/ucsi/ucsi.c +2 -2
@@ -936,11 +936,11 @@ static void ucsi_handle_connector_changeif (con->status.change &UCSI_CONSTAT_CAM_CHANGE )ucsi_partner_task (con, ucsi_check_altmodes,1 ,0 ); -clear_bit (EVENT_PENDING , &con->ucsi->flags); -mutex_lock (&ucsi->ppm_lock); +clear_bit (EVENT_PENDING , &con->ucsi->flags); ret =ucsi_acknowledge_connector_change (ucsi);mutex_unlock (&ucsi->ppm_lock); +if (ret)dev_err (ucsi->dev,"%s: ACK failed (%d)" , __func__, ret);
Greg Kroah-Hartman
maintainerPATCH 373/399 usb: typec: ucsi: Check for notifications after init
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian A. Ehrhardt <[email protected]>
commit 808a8b9e0b87bbc72bcc1f7ddfe5d04746e7ce56 upstream.
The completion notification for the final SET_NOTIFICATION_ENABLE command during initialization can include a connector change notification. However, at the time this completion notification is processed, the ucsi struct is not ready to handle this notification. As a result the notification is ignored and the controller never sends an interrupt again.
Re-check CCI for a pending connector state change after initialization is complete. Adjust the corresponding debug message accordingly.
--- drivers/usb/typec/ucsi/ucsi.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/usb/typec/ucsi/ucsi.c +9 -1
@@ -958,7 +958,7 @@ void ucsi_connector_change(struct ucsi *struct ucsi_connector *con = &ucsi->connector[num -1 ];if (!(ucsi->ntfy &UCSI_ENABLE_NTFY_CONNECTOR_CHANGE )) { -dev_dbg (ucsi->dev,"Bogus connector change event\n" ); +dev_dbg (ucsi->dev,"Early connector change event\n" );return ; }
@@ -1355,6 +1355,7 @@ static int ucsi_init(struct ucsi *ucsi) {struct ucsi_connector *con, *connector;u64 command, ntfy; +u32 cci;int ret;int i;
@@ -1407,6 +1408,13 @@ static int ucsi_init(struct ucsi *ucsi) ucsi->connector = connector; ucsi->ntfy = ntfy; + + ret = ucsi->ops->read (ucsi,UCSI_CCI , &cci,sizeof (cci)); +if (ret) +return ret; +if (UCSI_CCI_CONNECTOR (READ_ONCE (cci))) +ucsi_connector_change (ucsi, cci); +return 0 ; err_unregister:
Greg Kroah-Hartman
maintainerPATCH 374/399 usb: typec: ucsi: Ack unsupported commands
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian A. Ehrhardt <[email protected]>
commit 6b5c85ddeea77d18c4b69e3bda60e9374a20c304 upstream.
If a command completes the OPM must send an ack. This applies to unsupported commands, too.
Send the required ACK for unsupported commands.
--- drivers/usb/typec/ucsi/ucsi.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/usb/typec/ucsi/ucsi.c +5 -1
@@ -138,8 +138,12 @@ static int ucsi_exec_command(struct ucsiif (!(cci &UCSI_CCI_COMMAND_COMPLETE ))return -EIO ; -if (cci &UCSI_CCI_NOT_SUPPORTED ) +if (cci &UCSI_CCI_NOT_SUPPORTED ) { +if (ucsi_acknowledge_command (ucsi) <0 ) +dev_err (ucsi->dev, +"ACK of unsupported command failed\n" );return -EOPNOTSUPP ; + }if (cci &UCSI_CCI_ERROR ) {if (cmd ==UCSI_GET_ERROR_STATUS )
Greg Kroah-Hartman
maintainerPATCH 375/399 usb: typec: ucsi_acpi: Refactor and fix DELL quirk
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian A. Ehrhardt <[email protected]>
commit 6aaceb7d9cd00f3e065dc4b054ecfe52c5253b03 upstream.
Some DELL systems don't like UCSI_ACK_CC_CI commands with the UCSI_ACK_CONNECTOR_CHANGE but not the UCSI_ACK_COMMAND_COMPLETE bit set. The current quirk still leaves room for races because it requires two consecutive ACK commands to be sent.
Refactor and significantly simplify the quirk to fix this:
Send a dummy command and bundle the connector change ack with the command completion ack in a single UCSI_ACK_CC_CI command. This removes the need to probe for the quirk.
While there define flag bits for struct ucsi_acpi->flags in ucsi_acpi.c and don't re-use definitions from ucsi.h for struct ucsi->flags.
--- drivers/usb/typec/ucsi/ucsi_acpi.c | 71 ++++++++++++++++--------------------- 1 file changed, 31 insertions(+), 40 deletions(-)
drivers/usb/typec/ucsi/ucsi_acpi.c +31 -40
@@ -23,10 +23,11 @@ struct ucsi_acpi {void *base;struct completion complete;unsigned long flags; +#define UCSI_ACPI_SUPPRESS_EVENT 0 +#define UCSI_ACPI_COMMAND_PENDING 1 +#define UCSI_ACPI_ACK_PENDING 2guid_t guid;u64 cmd; -bool dell_quirk_probed; -bool dell_quirk_active; };static int ucsi_acpi_dsm (struct ucsi_acpi *ua,int func)
@@ -79,9 +80,9 @@ static int ucsi_acpi_sync_write(struct uint ret;if (ack) -set_bit (ACK_PENDING , &ua->flags); +set_bit (UCSI_ACPI_ACK_PENDING , &ua->flags);else -set_bit (COMMAND_PENDING , &ua->flags); +set_bit (UCSI_ACPI_COMMAND_PENDING , &ua->flags); ret =ucsi_acpi_async_write (ucsi, offset, val, val_len);if (ret)
@@ -92,9 +93,9 @@ static int ucsi_acpi_sync_write(struct u out_clear_bit:if (ack) -clear_bit (ACK_PENDING , &ua->flags); +clear_bit (UCSI_ACPI_ACK_PENDING , &ua->flags);else -clear_bit (COMMAND_PENDING , &ua->flags); +clear_bit (UCSI_ACPI_COMMAND_PENDING , &ua->flags);return ret; }
@@ -129,51 +130,40 @@ static const struct ucsi_operations ucsi };/* -* Some Dell laptops expect that an ACK command with the -* UCSI_ACK_CONNECTOR_CHANGE bit set is followed by a (separate) -* ACK command that only has the UCSI_ACK_COMMAND_COMPLETE bit set. -* If this is not done events are not delivered to OSPM and -* subsequent commands will timeout. +* Some Dell laptops don't like ACK commands with the +* UCSI_ACK_CONNECTOR_CHANGE but not the UCSI_ACK_COMMAND_COMPLETE +* bit set. To work around this send a dummy command and bundle the +* UCSI_ACK_CONNECTOR_CHANGE with the UCSI_ACK_COMMAND_COMPLETE +* for the dummy command. */ static int ucsi_dell_sync_write (struct ucsi *ucsi,unsigned int offset,const void *val,size_t val_len) {struct ucsi_acpi *ua =ucsi_get_drvdata (ucsi); -u64 cmd = *(u64 *)val, ack =0 ; +u64 cmd = *(u64 *)val; +u64 dummycmd =UCSI_GET_CAPABILITY ;int ret; -if (UCSI_COMMAND (cmd) ==UCSI_ACK_CC_CI && - cmd &UCSI_ACK_CONNECTOR_CHANGE ) - ack =UCSI_ACK_CC_CI |UCSI_ACK_COMMAND_COMPLETE ; +if (cmd == (UCSI_ACK_CC_CI |UCSI_ACK_CONNECTOR_CHANGE )) { + cmd |=UCSI_ACK_COMMAND_COMPLETE ; - ret =ucsi_acpi_sync_write (ucsi, offset, val, val_len); -if (ret !=0 ) -return ret; -if (ack ==0 ) -return ret; - -if (!ua->dell_quirk_probed) { - ua->dell_quirk_probed = true; +/* +* The UCSI core thinks it is sending a connector change ack +* and will accept new connector change events. We don't want +* this to happen for the dummy command as its response will +* still report the very event that the core is trying to clear. +*/ +set_bit (UCSI_ACPI_SUPPRESS_EVENT , &ua->flags); + ret =ucsi_acpi_sync_write (ucsi,UCSI_CONTROL , &dummycmd, +sizeof (dummycmd)); +clear_bit (UCSI_ACPI_SUPPRESS_EVENT , &ua->flags); - cmd =UCSI_GET_CAPABILITY ; - ret =ucsi_acpi_sync_write (ucsi,UCSI_CONTROL , &cmd, -sizeof (cmd)); -if (ret ==0 ) -return ucsi_acpi_sync_write (ucsi,UCSI_CONTROL , - &ack,sizeof (ack)); -if (ret != -ETIMEDOUT ) +if (ret <0 )return ret; - - ua->dell_quirk_active = true; -dev_err (ua->dev,"Firmware bug: Additional ACK required after ACKing a connector change.\n" ); -dev_err (ua->dev,"Firmware bug: Enabling workaround\n" ); } -if (!ua->dell_quirk_active) -return ret; - -return ucsi_acpi_sync_write (ucsi,UCSI_CONTROL , &ack,sizeof (ack)); +return ucsi_acpi_sync_write (ucsi,UCSI_CONTROL , &cmd,sizeof (cmd)); }static const struct ucsi_operations ucsi_dell_ops = {
@@ -209,13 +199,14 @@ static void ucsi_acpi_notify(acpi_handleif (ret)return ; -if (UCSI_CCI_CONNECTOR (cci)) +if (UCSI_CCI_CONNECTOR (cci) && + !test_bit (UCSI_ACPI_SUPPRESS_EVENT , &ua->flags))ucsi_connector_change (ua->ucsi,UCSI_CCI_CONNECTOR (cci));if (cci &UCSI_CCI_ACK_COMPLETE &&test_bit (ACK_PENDING , &ua->flags))complete (&ua->complete);if (cci &UCSI_CCI_COMMAND_COMPLETE && -test_bit (COMMAND_PENDING , &ua->flags)) +test_bit (UCSI_ACPI_COMMAND_PENDING , &ua->flags))complete (&ua->complete); }
Greg Kroah-Hartman
maintainerPATCH 376/399 usb: typec: ucsi: Clear UCSI_CCI_RESET_COMPLETE before reset
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian A. Ehrhardt <[email protected]>
commit 3de4f996a0b5412aa451729008130a488f71563e upstream.
Check the UCSI_CCI_RESET_COMPLETE complete flag before starting another reset. Use a UCSI_SET_NOTIFICATION_ENABLE command to clear the flag if it is set.
--- drivers/usb/typec/ucsi/ucsi.c | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-)
drivers/usb/typec/ucsi/ucsi.c +35 -1
@@ -985,13 +985,47 @@ static int ucsi_reset_connector(struct ustatic int ucsi_reset_ppm (struct ucsi *ucsi) { -u64 command =UCSI_PPM_RESET ; +u64 command;unsigned long tmo;u32 cci;int ret;mutex_lock (&ucsi->ppm_lock); + ret = ucsi->ops->read (ucsi,UCSI_CCI , &cci,sizeof (cci)); +if (ret <0 ) + goto out; + +/* +* If UCSI_CCI_RESET_COMPLETE is already set we must clear +* the flag before we start another reset. Send a +* UCSI_SET_NOTIFICATION_ENABLE command to achieve this. +* Ignore a timeout and try the reset anyway if this fails. +*/ +if (cci &UCSI_CCI_RESET_COMPLETE ) { + command =UCSI_SET_NOTIFICATION_ENABLE ; + ret = ucsi->ops->async_write (ucsi,UCSI_CONTROL , &command, +sizeof (command)); +if (ret <0 ) + goto out; + + tmo = jiffies +msecs_to_jiffies (UCSI_TIMEOUT_MS ); +do { + ret = ucsi->ops->read (ucsi,UCSI_CCI , + &cci,sizeof (cci)); +if (ret <0 ) + goto out; +if (cci &UCSI_CCI_COMMAND_COMPLETE ) +break ; +if (time_is_before_jiffies (tmo)) +break ; +msleep (20 ); + }while (1 ); + +WARN_ON (cci &UCSI_CCI_RESET_COMPLETE ); + } + + command =UCSI_PPM_RESET ; ret = ucsi->ops->async_write (ucsi,UCSI_CONTROL , &command,sizeof (command));if (ret <0 )
Greg Kroah-Hartman
maintainerPATCH 377/399 scsi: qla2xxx: Prevent command send on chip reset
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Quinn Tran <[email protected]>
commit 4895009c4bb72f71f2e682f1e7d2c2d96e482087 upstream.
Currently IOCBs are allowed to push through while chip reset could be in progress. During chip reset the outstanding_cmds array is cleared twice. Once when any command on this array is returned as failed and secondly when the array is initialize to zero. If a command is inserted on to the array between these intervals, then the command will be lost. Check for chip reset before sending IOCB.
--- drivers/scsi/qla2xxx/qla_init.c | 8 ++++++-- drivers/scsi/qla2xxx/qla_iocb.c | 33 +++++++++++++++++++++++++++++++-- 2 files changed, 37 insertions(+), 4 deletions(-)
drivers/scsi/qla2xxx/qla_init.c +6 -2
@@ -1193,8 +1193,12 @@ int qla24xx_async_gnl(struct scsi_qla_horeturn rval; done_free_sp: -/* ref: INIT */ -kref_put (&sp->cmd_kref, qla2x00_sp_release); +/* +* use qla24xx_async_gnl_sp_done to purge all pending gnl request. +* kref_put is call behind the scene. +*/ + sp->u.iocb_cmd.u.mbx.in_mb[0 ] =MBS_COMMAND_ERROR ; +qla24xx_async_gnl_sp_done (sp,QLA_COMMAND_ERROR ); fcport->flags &= ~(FCF_ASYNC_SENT ); done: fcport->flags &= ~(FCF_ASYNC_ACTIVE );
drivers/scsi/qla2xxx/qla_iocb.c +31 -2
@@ -2587,6 +2587,33 @@ void qla2x00_sp_release(struct kref *kref) { struct srb *sp = container_of(kref, struct srb, cmd_kref); +struct scsi_qla_host *vha = sp->vha; + +switch (sp->type) { +case SRB_CT_PTHRU_CMD : +/* GPSC & GFPNID use fcport->ct_desc.ct_sns for both req & rsp */ +if (sp->u.iocb_cmd.u.ctarg.req && + (!sp->fcport || + sp->u.iocb_cmd.u.ctarg.req != sp->fcport->ct_desc.ct_sns)) { +dma_free_coherent (&vha->hw->pdev->dev, + sp->u.iocb_cmd.u.ctarg.req_allocated_size, + sp->u.iocb_cmd.u.ctarg.req, + sp->u.iocb_cmd.u.ctarg.req_dma); + sp->u.iocb_cmd.u.ctarg.req =NULL ; + } +if (sp->u.iocb_cmd.u.ctarg.rsp && + (!sp->fcport || + sp->u.iocb_cmd.u.ctarg.rsp != sp->fcport->ct_desc.ct_sns)) { +dma_free_coherent (&vha->hw->pdev->dev, + sp->u.iocb_cmd.u.ctarg.rsp_allocated_size, + sp->u.iocb_cmd.u.ctarg.rsp, + sp->u.iocb_cmd.u.ctarg.rsp_dma); + sp->u.iocb_cmd.u.ctarg.rsp =NULL ; + } +break ; +default : +break ; + } sp->free (sp); }
@@ -2692,7 +2719,7 @@ qla24xx_els_dcmd_iocb(scsi_qla_host_t *v*/ sp =qla2x00_get_sp (vha, fcport,GFP_KERNEL );if (!sp) { -kfree (fcport); +qla2x00_free_fcport (fcport);ql_log (ql_log_info, vha,0x70e6 ,"SRB allocation failed\n" );return -ENOMEM ;
@@ -2747,6 +2774,7 @@ qla24xx_els_dcmd_iocb(scsi_qla_host_t *vif (rval !=QLA_SUCCESS ) {/* ref: INIT */ kref_put (&sp->cmd_kref, qla2x00_sp_release); +qla2x00_free_fcport (fcport);return QLA_FUNCTION_FAILED ; }
@@ -2756,6 +2784,7 @@ qla24xx_els_dcmd_iocb(scsi_qla_host_t *v fcport->d_id.b.area, fcport->d_id.b.al_pa);wait_for_completion (&elsio->u.els_logo.comp); +qla2x00_free_fcport (fcport);/* ref: INIT */ kref_put (&sp->cmd_kref, qla2x00_sp_release);
@@ -3918,7 +3947,7 @@ qla2x00_start_sp(srb_t *sp)return -EAGAIN ; } - pkt =__qla2x00_alloc_iocbs (sp->qpair, sp); + pkt =qla2x00_alloc_iocbs_ready (sp->qpair, sp);if (!pkt) { rval = -EAGAIN ; ql_log(ql_log_warn, vha, 0x700c,
Greg Kroah-Hartman
maintainerPATCH 378/399 scsi: qla2xxx: Fix N2N stuck connection
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Quinn Tran <[email protected]>
commit 881eb861ca3877300570db10abbf11494e48548d upstream.
Disk failed to rediscover after chip reset error injection. The chip reset happens at the time when a PLOGI is being sent. This causes a flag to be left on which blocks the retry. Clear the blocking flag.
--- drivers/scsi/qla2xxx/qla_gbl.h | 2 +- drivers/scsi/qla2xxx/qla_iocb.c | 32 +++++++++++--------------------- drivers/scsi/qla2xxx/qla_os.c | 2 +- 3 files changed, 13 insertions(+), 23 deletions(-)
drivers/scsi/qla2xxx/qla_gbl.h +1 -1
@@ -44,7 +44,7 @@ extern int qla2x00_fabric_login(scsi_qlaextern int qla2x00_local_device_login (scsi_qla_host_t *,fc_port_t *);extern int qla24xx_els_dcmd_iocb (scsi_qla_host_t *,int ,port_id_t ); -extern int qla24xx_els_dcmd2_iocb (scsi_qla_host_t *,int ,fc_port_t *,bool ); +extern int qla24xx_els_dcmd2_iocb (scsi_qla_host_t *,int ,fc_port_t *);extern void qla2x00_els_dcmd2_free (scsi_qla_host_t *vha,struct els_plogi *els_plogi);
drivers/scsi/qla2xxx/qla_iocb.c +11 -21
@@ -3041,7 +3041,7 @@ static void qla2x00_els_dcmd2_sp_done(srint qla24xx_els_dcmd2_iocb (scsi_qla_host_t *vha,int els_opcode, -fc_port_t *fcport,bool wait) +fc_port_t *fcport) {srb_t *sp;struct srb_iocb *elsio =NULL ;
@@ -3056,8 +3056,7 @@ qla24xx_els_dcmd2_iocb(scsi_qla_host_t *if (!sp) {ql_log (ql_log_info, vha,0x70e6 ,"SRB allocation failed\n" ); - fcport->flags &= ~FCF_ASYNC_ACTIVE ; -return -ENOMEM ; + goto done; } fcport->flags |=FCF_ASYNC_SENT ;
@@ -3066,9 +3065,6 @@ qla24xx_els_dcmd2_iocb(scsi_qla_host_t *ql_dbg (ql_dbg_io, vha,0x3073 ,"%s Enter: PLOGI portid=%06x\n" , __func__, fcport->d_id.b24); -if (wait) - sp->flags =SRB_WAKEUP_ON_COMP ; - sp->type =SRB_ELS_DCMD ; sp->name ="ELS_DCMD" ; sp->fcport = fcport;
@@ -3084,7 +3080,7 @@ qla24xx_els_dcmd2_iocb(scsi_qla_host_t *if (!elsio->u.els_plogi.els_plogi_pyld) { rval =QLA_FUNCTION_FAILED ; - goto out; + goto done_free_sp; } resp_ptr = elsio->u.els_plogi.els_resp_pyld =
@@ -3093,7 +3089,7 @@ qla24xx_els_dcmd2_iocb(scsi_qla_host_t *if (!elsio->u.els_plogi.els_resp_pyld) { rval =QLA_FUNCTION_FAILED ; - goto out; + goto done_free_sp; }ql_dbg (ql_dbg_io, vha,0x3073 ,"PLOGI %p %p\n" , ptr, resp_ptr);
@@ -3109,7 +3105,6 @@ qla24xx_els_dcmd2_iocb(scsi_qla_host_t *if (els_opcode ==ELS_DCMD_PLOGI &&DBELL_ACTIVE (vha)) {struct fc_els_flogi *p = ptr; - p->fl_csp.sp_features |=cpu_to_be16 (FC_SP_FT_SEC ); }
@@ -3118,10 +3113,11 @@ qla24xx_els_dcmd2_iocb(scsi_qla_host_t * (uint8_t *)elsio->u.els_plogi.els_plogi_pyld, sizeof(*elsio->u.els_plogi.els_plogi_pyld)); -init_completion (&elsio->u.els_plogi.comp); rval =qla2x00_start_sp (sp);if (rval !=QLA_SUCCESS ) { - rval =QLA_FUNCTION_FAILED ; + fcport->flags |=FCF_LOGIN_NEEDED ; +set_bit (RELOGIN_NEEDED , &vha->dpc_flags); + goto done_free_sp; }else { ql_dbg(ql_dbg_disc, vha, 0x3074, "%s PLOGI sent, hdl=%x, loopid=%x, to port_id %06x from port_id %06x\n",
@@ -3129,21 +3125,15 @@ qla24xx_els_dcmd2_iocb(scsi_qla_host_t * fcport->d_id.b24, vha->d_id.b24); } -if (wait) { -wait_for_completion (&elsio->u.els_plogi.comp); - -if (elsio->u.els_plogi.comp_status !=CS_COMPLETE ) - rval =QLA_FUNCTION_FAILED ; - }else { - goto done; - } +return rval; -out: - fcport->flags &= ~(FCF_ASYNC_SENT |FCF_ASYNC_ACTIVE ); +done_free_sp:qla2x00_els_dcmd2_free (vha, &elsio->u.els_plogi);/* ref: INIT */ kref_put (&sp->cmd_kref, qla2x00_sp_release); done: + fcport->flags &= ~(FCF_ASYNC_SENT |FCF_ASYNC_ACTIVE ); +qla2x00_set_fcport_disc_state (fcport,DSC_DELETED );return rval; }
drivers/scsi/qla2xxx/qla_os.c +1 -1
@@ -5583,7 +5583,7 @@ qla2x00_do_work(struct scsi_qla_host *vhbreak ;case QLA_EVT_ELS_PLOGI :qla24xx_els_dcmd2_iocb (vha,ELS_DCMD_PLOGI , - e->u.fcport.fcport, false); + e->u.fcport.fcport);break ;case QLA_EVT_SA_REPLACE : rc =qla24xx_issue_sa_replace_iocb (vha, e);
Greg Kroah-Hartman
maintainerPATCH 379/399 scsi: qla2xxx: Split FCE|EFT trace control
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Quinn Tran <[email protected]>
commit 76a192e1a566e15365704b9f8fb3b70825f85064 upstream.
Current code combines the allocation of FCE|EFT trace buffers and enables the features all in 1 step.
Split this step into separate steps in preparation for follow-on patch to allow user to have a choice to enable / disable FCE trace feature.
--- drivers/scsi/qla2xxx/qla_init.c | 102 ++++++++++++++++------------------------ 1 file changed, 41 insertions(+), 61 deletions(-)
drivers/scsi/qla2xxx/qla_init.c +41 -61
@@ -2669,6 +2669,40 @@ exit:return rval; } +static void qla_enable_fce_trace (scsi_qla_host_t *vha) +{ +int rval; +struct qla_hw_data *ha = vha->hw; + +if (ha->fce) { + ha->flags.fce_enabled =1 ; +memset (ha->fce,0 ,fce_calc_size (ha->fce_bufs)); + rval =qla2x00_enable_fce_trace (vha, + ha->fce_dma, ha->fce_bufs, ha->fce_mb, &ha->fce_bufs); + +if (rval) { +ql_log (ql_log_warn, vha,0x8033 , +"Unable to reinitialize FCE (%d).\n" , rval); + ha->flags.fce_enabled =0 ; + } + } +} + +static void qla_enable_eft_trace (scsi_qla_host_t *vha) +{ +int rval; +struct qla_hw_data *ha = vha->hw; + +if (ha->eft) { +memset (ha->eft,0 ,EFT_SIZE ); + rval =qla2x00_enable_eft_trace (vha, ha->eft_dma,EFT_NUM_BUFFERS ); + +if (rval) { +ql_log (ql_log_warn, vha,0x8034 , +"Unable to reinitialize EFT (%d).\n" , rval); + } + } +}/* * qla2x00_initialize_adapter * Initialize board.
@@ -3672,9 +3706,8 @@ qla24xx_chip_diag(scsi_qla_host_t *vha) }static void -qla2x00_init_fce_trace (scsi_qla_host_t *vha) +qla2x00_alloc_fce_trace (scsi_qla_host_t *vha) { -int rval;dma_addr_t tc_dma;void *tc;struct qla_hw_data *ha = vha->hw;
@@ -3703,27 +3736,17 @@ qla2x00_init_fce_trace(scsi_qla_host_t *return ; } - rval =qla2x00_enable_fce_trace (vha, tc_dma,FCE_NUM_BUFFERS , - ha->fce_mb, &ha->fce_bufs); -if (rval) { -ql_log (ql_log_warn, vha,0x00bf , -"Unable to initialize FCE (%d).\n" , rval); -dma_free_coherent (&ha->pdev->dev,FCE_SIZE , tc, tc_dma); -return ; - } -ql_dbg (ql_dbg_init, vha,0x00c0 ,"Allocated (%d KB) for FCE...\n" ,FCE_SIZE /1024 ); - ha->flags.fce_enabled =1 ; ha->fce_dma = tc_dma; ha->fce = tc; + ha->fce_bufs =FCE_NUM_BUFFERS ; }static void -qla2x00_init_eft_trace (scsi_qla_host_t *vha) +qla2x00_alloc_eft_trace (scsi_qla_host_t *vha) { -int rval;dma_addr_t tc_dma;void *tc;struct qla_hw_data *ha = vha->hw;
@@ -3748,14 +3771,6 @@ qla2x00_init_eft_trace(scsi_qla_host_t *return ; } - rval =qla2x00_enable_eft_trace (vha, tc_dma,EFT_NUM_BUFFERS ); -if (rval) { -ql_log (ql_log_warn, vha,0x00c2 , -"Unable to initialize EFT (%d).\n" , rval); -dma_free_coherent (&ha->pdev->dev,EFT_SIZE , tc, tc_dma); -return ; - } -ql_dbg (ql_dbg_init, vha,0x00c3 ,"Allocated (%d KB) EFT ...\n" ,EFT_SIZE /1024 );
@@ -3763,13 +3778,6 @@ qla2x00_init_eft_trace(scsi_qla_host_t * ha->eft = tc; } -static void -qla2x00_alloc_offload_mem (scsi_qla_host_t *vha) -{ -qla2x00_init_fce_trace (vha); -qla2x00_init_eft_trace (vha); -} -void qla2x00_alloc_fw_dump (scsi_qla_host_t *vha) {
@@ -3824,10 +3832,10 @@ qla2x00_alloc_fw_dump(scsi_qla_host_t *vif (ha->tgt.atio_ring) mq_size += ha->tgt.atio_q_length *sizeof (request_t); -qla2x00_init_fce_trace (vha); +qla2x00_alloc_fce_trace (vha);if (ha->fce) fce_size =sizeof (struct qla2xxx_fce_chain ) +FCE_SIZE ; -qla2x00_init_eft_trace (vha); +qla2x00_alloc_eft_trace (vha);if (ha->eft) eft_size =EFT_SIZE ; }
@@ -4257,7 +4265,6 @@ qla2x00_setup_chip(scsi_qla_host_t *vha)struct qla_hw_data *ha = vha->hw;struct device_reg_2xxx __iomem *reg = &ha->iobase->isp;unsigned long flags; -uint16_t fw_major_version;int done_once =0 ;if (IS_P3P_TYPE (ha)) {
@@ -4324,7 +4331,6 @@ execute_fw_with_lr: goto failed; enable_82xx_npiv: - fw_major_version = ha->fw_major_version;if (IS_P3P_TYPE (ha))qla82xx_check_md_needed (vha);else
@@ -4353,12 +4359,11 @@ enable_82xx_npiv:if (rval !=QLA_SUCCESS ) goto failed; -if (!fw_major_version && !(IS_P3P_TYPE (ha))) -qla2x00_alloc_offload_mem (vha); -if (ql2xallocfwdump && !(IS_P3P_TYPE (ha)))qla2x00_alloc_fw_dump (vha); +qla_enable_fce_trace (vha); +qla_enable_eft_trace (vha); }else { goto failed; }
@@ -7491,7 +7496,6 @@ qla2x00_abort_isp_cleanup(scsi_qla_host_int qla2x00_abort_isp (scsi_qla_host_t *vha) { -int rval;uint8_t status =0 ;struct qla_hw_data *ha = vha->hw;struct scsi_qla_host *vp, *tvp;
@@ -7585,31 +7589,7 @@ qla2x00_abort_isp(scsi_qla_host_t *vha)if (IS_QLA81XX (ha) ||IS_QLA8031 (ha))qla2x00_get_fw_version (vha); -if (ha->fce) { - ha->flags.fce_enabled =1 ; -memset (ha->fce,0 , -fce_calc_size (ha->fce_bufs)); - rval =qla2x00_enable_fce_trace (vha, - ha->fce_dma, ha->fce_bufs, ha->fce_mb, - &ha->fce_bufs); -if (rval) { -ql_log (ql_log_warn, vha,0x8033 , -"Unable to reinitialize FCE " -"(%d).\n" , rval); - ha->flags.fce_enabled =0 ; - } - } -if (ha->eft) { -memset (ha->eft,0 ,EFT_SIZE ); - rval =qla2x00_enable_eft_trace (vha, - ha->eft_dma,EFT_NUM_BUFFERS ); -if (rval) { -ql_log (ql_log_warn, vha,0x8034 , -"Unable to reinitialize EFT " -"(%d).\n" , rval); - } - } }else {/* failed the ISP abort */ vha->flags.online =1 ;if (test_bit (ISP_ABORT_RETRY , &vha->dpc_flags)) {
Greg Kroah-Hartman
maintainerPATCH 380/399 scsi: qla2xxx: Update manufacturer detail
In reply to Greg Kroah-Hartman6.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bikash Hazarika <[email protected]>
commit 688fa069fda6fce24d243cddfe0c7024428acb74 upstream.
Update manufacturer detail from "Marvell Semiconductor, Inc." to "Marvell".
--- drivers/scsi/qla2xxx/qla_def.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/qla2xxx/qla_def.h +1 -1
@@ -82,7 +82,7 @@ typedef union {#include "qla_nvme.h" #define QLA2XXX_DRIVER_NAME "qla2xxx"#define QLA2XXX_APIDEV "ql2xapidev" -#define QLA2XXX_MANUFACTURER "Marvell Semiconductor, Inc." +#define QLA2XXX_MANUFACTURER "Marvell"/* * We have MAILBOX_REGISTER_COUNT sized arrays in a few places,