Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net

Cross-merge networking fixes after downstream PR (net-7.0-rc7).

Conflicts:

net/vmw_vsock/af_vsock.c
b18c83388874 ("vsock: initialize child_ns_mode_locked in vsock_net_init()")
0de607dc4fd8 ("vsock: add G2H fallback for CIDs not owned by H2G transport")

Adjacent changes:

drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c
ceee35e5674a ("bnxt_en: Refactor some basic ring setup and adjustment logic")
57cdfe0dc70b ("bnxt_en: Resize RSS contexts on channel count change")

drivers/net/wireless/intel/iwlwifi/mld/mac80211.c
4d56037a02bd ("wifi: iwlwifi: mld: block EMLSR during TDLS connections")
687a95d204e7 ("wifi: iwlwifi: mld: correctly set wifi generation data")

drivers/net/wireless/intel/iwlwifi/mld/scan.h
b6045c899e37 ("wifi: iwlwifi: mld: Refactor scan command handling")
ec66ec6a5a8f ("wifi: iwlwifi: mld: Fix MLO scan timing")

drivers/net/wireless/intel/iwlwifi/mvm/fw.c
078df640ef05 ("wifi: iwlwifi: mld: add support for iwl_mcc_allowed_ap_type_cmd v
2")
323156c3541e ("wifi: iwlwifi: mvm: don't send a 6E related command when not supported")

Signed-off-by: Jakub Kicinski <kuba@kernel.org>

+5166 -1992
+1
.mailmap
··· 316 316 Hans Verkuil <hverkuil@kernel.org> <hansverk@cisco.com> 317 317 Hao Ge <hao.ge@linux.dev> <gehao@kylinos.cn> 318 318 Harry Yoo <harry.yoo@oracle.com> <42.hyeyoo@gmail.com> 319 + Harry Yoo <harry@kernel.org> <harry.yoo@oracle.com> 319 320 Heiko Carstens <hca@linux.ibm.com> <h.carstens@de.ibm.com> 320 321 Heiko Carstens <hca@linux.ibm.com> <heiko.carstens@de.ibm.com> 321 322 Heiko Stuebner <heiko@sntech.de> <heiko.stuebner@bqreaders.com>
+10
Documentation/PCI/pcieaer-howto.rst
··· 85 85 the error message to the Root Port. Please refer to PCIe specs for other 86 86 fields. 87 87 88 + The 'TLP Header' is the prefix/header of the TLP that caused the error 89 + in raw hex format. To decode the TLP Header into human-readable form 90 + one may use tlp-tool: 91 + 92 + https://github.com/mmpg-x86/tlp-tool 93 + 94 + Example usage:: 95 + 96 + curl -L https://git.kernel.org/linus/2ca1c94ce0b6 | rtlp-tool --aer 97 + 88 98 AER Ratelimits 89 99 -------------- 90 100
+1 -1
Documentation/devicetree/bindings/auxdisplay/holtek,ht16k33.yaml
··· 66 66 required: 67 67 - refresh-rate-hz 68 68 69 - additionalProperties: false 69 + unevaluatedProperties: false 70 70 71 71 examples: 72 72 - |
+1
Documentation/devicetree/bindings/sound/rockchip-spdif.yaml
··· 33 33 - const: rockchip,rk3066-spdif 34 34 - items: 35 35 - enum: 36 + - rockchip,rk3576-spdif 36 37 - rockchip,rk3588-spdif 37 38 - const: rockchip,rk3568-spdif 38 39
+1 -1
Documentation/devicetree/bindings/sound/st,stm32-sai.yaml
··· 164 164 properties: 165 165 compatible: 166 166 contains: 167 - const: st,stm32mph7-sai 167 + const: st,stm32h7-sai 168 168 then: 169 169 properties: 170 170 clocks:
+50
Documentation/filesystems/overlayfs.rst
··· 783 783 mounted with "uuid=on". 784 784 785 785 786 + Durability and copy up 787 + ---------------------- 788 + 789 + The fsync(2) system call ensures that the data and metadata of a file 790 + are safely written to the backing storage, which is expected to 791 + guarantee the existence of the information post system crash. 792 + 793 + Without an fsync(2) call, there is no guarantee that the observed 794 + data after a system crash will be either the old or the new data, but 795 + in practice, the observed data after crash is often the old or new data 796 + or a mix of both. 797 + 798 + When an overlayfs file is modified for the first time, copy up will 799 + create a copy of the lower file and its parent directories in the upper 800 + layer. Since the Linux filesystem API does not enforce any particular 801 + ordering on storing changes without explicit fsync(2) calls, in case 802 + of a system crash, the upper file could end up with no data at all 803 + (i.e. zeros), which would be an unusual outcome. To avoid this 804 + experience, overlayfs calls fsync(2) on the upper file before completing 805 + data copy up with rename(2) or link(2) to make the copy up "atomic". 806 + 807 + By default, overlayfs does not explicitly call fsync(2) on copied up 808 + directories or on metadata-only copy up, so it provides no guarantee to 809 + persist the user's modification unless the user calls fsync(2). 810 + The fsync during copy up only guarantees that if a copy up is observed 811 + after a crash, the observed data is not zeroes or intermediate values 812 + from the copy up staging area. 813 + 814 + On traditional local filesystems with a single journal (e.g. ext4, xfs), 815 + fsync on a file also persists the parent directory changes, because they 816 + are usually modified in the same transaction, so metadata durability during 817 + data copy up effectively comes for free. Overlayfs further limits risk by 818 + disallowing network filesystems as upper layer. 819 + 820 + Overlayfs can be tuned to prefer performance or durability when storing 821 + to the underlying upper layer. This is controlled by the "fsync" mount 822 + option, which supports these values: 823 + 824 + - "auto": (default) 825 + Call fsync(2) on upper file before completion of data copy up. 826 + No explicit fsync(2) on directory or metadata-only copy up. 827 + - "strict": 828 + Call fsync(2) on upper file and directories before completion of any 829 + copy up. 830 + - "volatile": [*] 831 + Prefer performance over durability (see `Volatile mount`_) 832 + 833 + [*] The mount option "volatile" is an alias to "fsync=volatile". 834 + 835 + 786 836 Volatile mount 787 837 -------------- 788 838
+4 -4
Documentation/hwmon/adm1177.rst
··· 27 27 Sysfs entries 28 28 ------------- 29 29 30 - The following attributes are supported. Current maxim attribute 30 + The following attributes are supported. Current maximum attribute 31 31 is read-write, all other attributes are read-only. 32 32 33 - in0_input Measured voltage in microvolts. 33 + in0_input Measured voltage in millivolts. 34 34 35 - curr1_input Measured current in microamperes. 36 - curr1_max_alarm Overcurrent alarm in microamperes. 35 + curr1_input Measured current in milliamperes. 36 + curr1_max Overcurrent shutdown threshold in milliamperes.
+6 -4
Documentation/hwmon/peci-cputemp.rst
··· 51 51 temp1_crit Provides shutdown temperature of the CPU package which 52 52 is also known as the maximum processor junction 53 53 temperature, Tjmax or Tprochot. 54 - temp1_crit_hyst Provides the hysteresis value from Tcontrol to Tjmax of 55 - the CPU package. 54 + temp1_crit_hyst Provides the hysteresis temperature of the CPU 55 + package. Returns Tcontrol, the temperature at which 56 + the critical condition clears. 56 57 57 58 temp2_label "DTS" 58 59 temp2_input Provides current temperature of the CPU package scaled ··· 63 62 temp2_crit Provides shutdown temperature of the CPU package which 64 63 is also known as the maximum processor junction 65 64 temperature, Tjmax or Tprochot. 66 - temp2_crit_hyst Provides the hysteresis value from Tcontrol to Tjmax of 67 - the CPU package. 65 + temp2_crit_hyst Provides the hysteresis temperature of the CPU 66 + package. Returns Tcontrol, the temperature at which 67 + the critical condition clears. 68 68 69 69 temp3_label "Tcontrol" 70 70 temp3_input Provides current Tcontrol temperature of the CPU
+19 -4
Documentation/userspace-api/landlock.rst
··· 8 8 ===================================== 9 9 10 10 :Author: Mickaël Salaün 11 - :Date: January 2026 11 + :Date: March 2026 12 12 13 13 The goal of Landlock is to enable restriction of ambient rights (e.g. global 14 14 filesystem or network access) for a set of processes. Because Landlock ··· 197 197 198 198 .. code-block:: c 199 199 200 - __u32 restrict_flags = LANDLOCK_RESTRICT_SELF_LOG_NEW_EXEC_ON; 201 - if (abi < 7) { 202 - /* Clear logging flags unsupported before ABI 7. */ 200 + __u32 restrict_flags = 201 + LANDLOCK_RESTRICT_SELF_LOG_NEW_EXEC_ON | 202 + LANDLOCK_RESTRICT_SELF_TSYNC; 203 + switch (abi) { 204 + case 1 ... 6: 205 + /* Removes logging flags for ABI < 7 */ 203 206 restrict_flags &= ~(LANDLOCK_RESTRICT_SELF_LOG_SAME_EXEC_OFF | 204 207 LANDLOCK_RESTRICT_SELF_LOG_NEW_EXEC_ON | 205 208 LANDLOCK_RESTRICT_SELF_LOG_SUBDOMAINS_OFF); 209 + __attribute__((fallthrough)); 210 + case 7: 211 + /* 212 + * Removes multithreaded enforcement flag for ABI < 8 213 + * 214 + * WARNING: Without this flag, calling landlock_restrict_self(2) is 215 + * only equivalent if the calling process is single-threaded. Below 216 + * ABI v8 (and as of ABI v8, when not using this flag), a Landlock 217 + * policy would only be enforced for the calling thread and its 218 + * children (and not for all threads, including parents and siblings). 219 + */ 220 + restrict_flags &= ~LANDLOCK_RESTRICT_SELF_TSYNC; 206 221 } 207 222 208 223 The next step is to restrict the current thread from gaining more privileges
+15 -6
MAINTAINERS
··· 8628 8628 F: include/uapi/drm/lima_drm.h 8629 8629 8630 8630 DRM DRIVERS FOR LOONGSON 8631 + M: Jianmin Lv <lvjianmin@loongson.cn> 8632 + M: Qianhai Wu <wuqianhai@loongson.cn> 8633 + R: Huacai Chen <chenhuacai@kernel.org> 8634 + R: Mingcong Bai <jeffbai@aosc.io> 8635 + R: Xi Ruoyao <xry111@xry111.site> 8636 + R: Icenowy Zheng <zhengxingda@iscas.ac.cn> 8631 8637 L: dri-devel@lists.freedesktop.org 8632 - S: Orphan 8638 + S: Maintained 8633 8639 T: git https://gitlab.freedesktop.org/drm/misc/kernel.git 8634 8640 F: drivers/gpu/drm/loongson/ 8635 8641 ··· 9618 9612 9619 9613 EXT4 FILE SYSTEM 9620 9614 M: "Theodore Ts'o" <tytso@mit.edu> 9621 - M: Andreas Dilger <adilger.kernel@dilger.ca> 9615 + R: Andreas Dilger <adilger.kernel@dilger.ca> 9616 + R: Baokun Li <libaokun@linux.alibaba.com> 9617 + R: Jan Kara <jack@suse.cz> 9618 + R: Ojaswin Mujoo <ojaswin@linux.ibm.com> 9619 + R: Ritesh Harjani (IBM) <ritesh.list@gmail.com> 9620 + R: Zhang Yi <yi.zhang@huawei.com> 9622 9621 L: linux-ext4@vger.kernel.org 9623 9622 S: Maintained 9624 9623 W: http://ext4.wiki.kernel.org ··· 12018 12007 M: Wolfram Sang <wsa+renesas@sang-engineering.com> 12019 12008 L: linux-i2c@vger.kernel.org 12020 12009 S: Maintained 12021 - W: https://i2c.wiki.kernel.org/ 12022 12010 Q: https://patchwork.ozlabs.org/project/linux-i2c/list/ 12023 12011 T: git git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git 12024 12012 F: Documentation/i2c/ ··· 12043 12033 M: Andi Shyti <andi.shyti@kernel.org> 12044 12034 L: linux-i2c@vger.kernel.org 12045 12035 S: Maintained 12046 - W: https://i2c.wiki.kernel.org/ 12047 12036 Q: https://patchwork.ozlabs.org/project/linux-i2c/list/ 12048 12037 T: git git://git.kernel.org/pub/scm/linux/kernel/git/andi.shyti/linux.git 12049 12038 F: Documentation/devicetree/bindings/i2c/ ··· 16884 16875 R: Rik van Riel <riel@surriel.com> 16885 16876 R: Liam R. Howlett <Liam.Howlett@oracle.com> 16886 16877 R: Vlastimil Babka <vbabka@kernel.org> 16887 - R: Harry Yoo <harry.yoo@oracle.com> 16878 + R: Harry Yoo <harry@kernel.org> 16888 16879 R: Jann Horn <jannh@google.com> 16889 16880 L: linux-mm@kvack.org 16890 16881 S: Maintained ··· 24350 24341 24351 24342 SLAB ALLOCATOR 24352 24343 M: Vlastimil Babka <vbabka@kernel.org> 24353 - M: Harry Yoo <harry.yoo@oracle.com> 24344 + M: Harry Yoo <harry@kernel.org> 24354 24345 M: Andrew Morton <akpm@linux-foundation.org> 24355 24346 R: Hao Li <hao.li@linux.dev> 24356 24347 R: Christoph Lameter <cl@gentwo.org>
+1 -1
Makefile
··· 2 2 VERSION = 7 3 3 PATCHLEVEL = 0 4 4 SUBLEVEL = 0 5 - EXTRAVERSION = -rc5 5 + EXTRAVERSION = -rc6 6 6 NAME = Baby Opossum Posse 7 7 8 8 # *DOCUMENTATION*
+36
arch/loongarch/include/asm/linkage.h
··· 41 41 .cfi_endproc; \ 42 42 SYM_END(name, SYM_T_NONE) 43 43 44 + /* 45 + * This is for the signal handler trampoline, which is used as the return 46 + * address of the signal handlers in userspace instead of called normally. 47 + * The long standing libgcc bug https://gcc.gnu.org/PR124050 requires a 48 + * nop between .cfi_startproc and the actual address of the trampoline, so 49 + * we cannot simply use SYM_FUNC_START. 50 + * 51 + * This wrapper also contains all the .cfi_* directives for recovering 52 + * the content of the GPRs and the "return address" (where the rt_sigreturn 53 + * syscall will jump to), assuming there is a struct rt_sigframe (where 54 + * a struct sigcontext containing those information we need to recover) at 55 + * $sp. The "DWARF for the LoongArch(TM) Architecture" manual states 56 + * column 0 is for $zero, but it does not make too much sense to 57 + * save/restore the hardware zero register. Repurpose this column here 58 + * for the return address (here it's not the content of $ra we cannot use 59 + * the default column 3). 60 + */ 61 + #define SYM_SIGFUNC_START(name) \ 62 + .cfi_startproc; \ 63 + .cfi_signal_frame; \ 64 + .cfi_def_cfa 3, RT_SIGFRAME_SC; \ 65 + .cfi_return_column 0; \ 66 + .cfi_offset 0, SC_PC; \ 67 + \ 68 + .irp num, 1, 2, 3, 4, 5, 6, 7, 8, \ 69 + 9, 10, 11, 12, 13, 14, 15, 16, \ 70 + 17, 18, 19, 20, 21, 22, 23, 24, \ 71 + 25, 26, 27, 28, 29, 30, 31; \ 72 + .cfi_offset \num, SC_REGS + \num * SZREG; \ 73 + .endr; \ 74 + \ 75 + nop; \ 76 + SYM_START(name, SYM_L_GLOBAL, SYM_A_ALIGN) 77 + 78 + #define SYM_SIGFUNC_END(name) SYM_FUNC_END(name) 79 + 44 80 #endif
+9
arch/loongarch/include/asm/sigframe.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0+ */ 2 + 3 + #include <asm/siginfo.h> 4 + #include <asm/ucontext.h> 5 + 6 + struct rt_sigframe { 7 + struct siginfo rs_info; 8 + struct ucontext rs_uctx; 9 + };
+2
arch/loongarch/kernel/asm-offsets.c
··· 16 16 #include <asm/ptrace.h> 17 17 #include <asm/processor.h> 18 18 #include <asm/ftrace.h> 19 + #include <asm/sigframe.h> 19 20 #include <vdso/datapage.h> 20 21 21 22 static void __used output_ptreg_defines(void) ··· 221 220 COMMENT("Linux sigcontext offsets."); 222 221 OFFSET(SC_REGS, sigcontext, sc_regs); 223 222 OFFSET(SC_PC, sigcontext, sc_pc); 223 + OFFSET(RT_SIGFRAME_SC, rt_sigframe, rs_uctx.uc_mcontext); 224 224 BLANK(); 225 225 } 226 226
+3 -4
arch/loongarch/kernel/env.c
··· 42 42 int cpu, ret; 43 43 char *cpuname; 44 44 const char *model; 45 - struct device_node *root; 46 45 47 46 /* Parsing cpuname from DTS model property */ 48 - root = of_find_node_by_path("/"); 49 - ret = of_property_read_string(root, "model", &model); 47 + ret = of_property_read_string(of_root, "model", &model); 50 48 if (ret == 0) { 51 49 cpuname = kstrdup(model, GFP_KERNEL); 50 + if (!cpuname) 51 + return -ENOMEM; 52 52 loongson_sysconf.cpuname = strsep(&cpuname, " "); 53 53 } 54 - of_node_put(root); 55 54 56 55 if (loongson_sysconf.cpuname && !strncmp(loongson_sysconf.cpuname, "Loongson", 8)) { 57 56 for (cpu = 0; cpu < NR_CPUS; cpu++)
+1 -5
arch/loongarch/kernel/signal.c
··· 35 35 #include <asm/cpu-features.h> 36 36 #include <asm/fpu.h> 37 37 #include <asm/lbt.h> 38 + #include <asm/sigframe.h> 38 39 #include <asm/ucontext.h> 39 40 #include <asm/vdso.h> 40 41 ··· 51 50 /* Make sure we will not lose LBT ownership */ 52 51 #define lock_lbt_owner() ({ preempt_disable(); pagefault_disable(); }) 53 52 #define unlock_lbt_owner() ({ pagefault_enable(); preempt_enable(); }) 54 - 55 - struct rt_sigframe { 56 - struct siginfo rs_info; 57 - struct ucontext rs_uctx; 58 - }; 59 53 60 54 struct _ctx_layout { 61 55 struct sctx_info *addr;
+8 -8
arch/loongarch/kvm/intc/eiointc.c
··· 83 83 84 84 if (!(s->status & BIT(EIOINTC_ENABLE_CPU_ENCODE))) { 85 85 cpuid = ffs(cpuid) - 1; 86 - cpuid = (cpuid >= 4) ? 0 : cpuid; 86 + cpuid = ((cpuid < 0) || (cpuid >= 4)) ? 0 : cpuid; 87 87 } 88 88 89 89 vcpu = kvm_get_vcpu_by_cpuid(s->kvm, cpuid); ··· 472 472 switch (addr) { 473 473 case EIOINTC_NODETYPE_START ... EIOINTC_NODETYPE_END: 474 474 offset = (addr - EIOINTC_NODETYPE_START) / 4; 475 - p = s->nodetype + offset * 4; 475 + p = (void *)s->nodetype + offset * 4; 476 476 break; 477 477 case EIOINTC_IPMAP_START ... EIOINTC_IPMAP_END: 478 478 offset = (addr - EIOINTC_IPMAP_START) / 4; 479 - p = &s->ipmap + offset * 4; 479 + p = (void *)&s->ipmap + offset * 4; 480 480 break; 481 481 case EIOINTC_ENABLE_START ... EIOINTC_ENABLE_END: 482 482 offset = (addr - EIOINTC_ENABLE_START) / 4; 483 - p = s->enable + offset * 4; 483 + p = (void *)s->enable + offset * 4; 484 484 break; 485 485 case EIOINTC_BOUNCE_START ... EIOINTC_BOUNCE_END: 486 486 offset = (addr - EIOINTC_BOUNCE_START) / 4; 487 - p = s->bounce + offset * 4; 487 + p = (void *)s->bounce + offset * 4; 488 488 break; 489 489 case EIOINTC_ISR_START ... EIOINTC_ISR_END: 490 490 offset = (addr - EIOINTC_ISR_START) / 4; 491 - p = s->isr + offset * 4; 491 + p = (void *)s->isr + offset * 4; 492 492 break; 493 493 case EIOINTC_COREISR_START ... EIOINTC_COREISR_END: 494 494 if (cpu >= s->num_cpu) 495 495 return -EINVAL; 496 496 497 497 offset = (addr - EIOINTC_COREISR_START) / 4; 498 - p = s->coreisr[cpu] + offset * 4; 498 + p = (void *)s->coreisr[cpu] + offset * 4; 499 499 break; 500 500 case EIOINTC_COREMAP_START ... EIOINTC_COREMAP_END: 501 501 offset = (addr - EIOINTC_COREMAP_START) / 4; 502 - p = s->coremap + offset * 4; 502 + p = (void *)s->coremap + offset * 4; 503 503 break; 504 504 default: 505 505 kvm_err("%s: unknown eiointc register, addr = %d\n", __func__, addr);
+3
arch/loongarch/kvm/vcpu.c
··· 588 588 { 589 589 struct kvm_phyid_map *map; 590 590 591 + if (cpuid < 0) 592 + return NULL; 593 + 591 594 if (cpuid >= KVM_MAX_PHYID) 592 595 return NULL; 593 596
+80
arch/loongarch/pci/pci.c
··· 5 5 #include <linux/kernel.h> 6 6 #include <linux/init.h> 7 7 #include <linux/acpi.h> 8 + #include <linux/delay.h> 8 9 #include <linux/types.h> 9 10 #include <linux/pci.h> 10 11 #include <linux/vgaarb.h> 12 + #include <linux/io-64-nonatomic-lo-hi.h> 11 13 #include <asm/cacheflush.h> 12 14 #include <asm/loongson.h> 13 15 ··· 17 15 #define PCI_DEVICE_ID_LOONGSON_DC1 0x7a06 18 16 #define PCI_DEVICE_ID_LOONGSON_DC2 0x7a36 19 17 #define PCI_DEVICE_ID_LOONGSON_DC3 0x7a46 18 + #define PCI_DEVICE_ID_LOONGSON_GPU1 0x7a15 19 + #define PCI_DEVICE_ID_LOONGSON_GPU2 0x7a25 20 + #define PCI_DEVICE_ID_LOONGSON_GPU3 0x7a35 20 21 21 22 int raw_pci_read(unsigned int domain, unsigned int bus, unsigned int devfn, 22 23 int reg, int len, u32 *val) ··· 104 99 DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_LOONGSON, PCI_DEVICE_ID_LOONGSON_DC1, pci_fixup_vgadev); 105 100 DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_LOONGSON, PCI_DEVICE_ID_LOONGSON_DC2, pci_fixup_vgadev); 106 101 DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_LOONGSON, PCI_DEVICE_ID_LOONGSON_DC3, pci_fixup_vgadev); 102 + 103 + #define CRTC_NUM_MAX 2 104 + #define CRTC_OUTPUT_ENABLE 0x100 105 + 106 + static void loongson_gpu_fixup_dma_hang(struct pci_dev *pdev, bool on) 107 + { 108 + u32 i, val, count, crtc_offset, device; 109 + void __iomem *crtc_reg, *base, *regbase; 110 + static u32 crtc_status[CRTC_NUM_MAX] = { 0 }; 111 + 112 + base = pdev->bus->ops->map_bus(pdev->bus, pdev->devfn + 1, 0); 113 + device = readw(base + PCI_DEVICE_ID); 114 + 115 + regbase = ioremap(readq(base + PCI_BASE_ADDRESS_0) & ~0xffull, SZ_64K); 116 + if (!regbase) { 117 + pci_err(pdev, "Failed to ioremap()\n"); 118 + return; 119 + } 120 + 121 + switch (device) { 122 + case PCI_DEVICE_ID_LOONGSON_DC2: 123 + crtc_reg = regbase + 0x1240; 124 + crtc_offset = 0x10; 125 + break; 126 + case PCI_DEVICE_ID_LOONGSON_DC3: 127 + crtc_reg = regbase; 128 + crtc_offset = 0x400; 129 + break; 130 + } 131 + 132 + for (i = 0; i < CRTC_NUM_MAX; i++, crtc_reg += crtc_offset) { 133 + val = readl(crtc_reg); 134 + 135 + if (!on) 136 + crtc_status[i] = val; 137 + 138 + /* No need to fixup if the status is off at startup. */ 139 + if (!(crtc_status[i] & CRTC_OUTPUT_ENABLE)) 140 + continue; 141 + 142 + if (on) 143 + val |= CRTC_OUTPUT_ENABLE; 144 + else 145 + val &= ~CRTC_OUTPUT_ENABLE; 146 + 147 + mb(); 148 + writel(val, crtc_reg); 149 + 150 + for (count = 0; count < 40; count++) { 151 + val = readl(crtc_reg) & CRTC_OUTPUT_ENABLE; 152 + if ((on && val) || (!on && !val)) 153 + break; 154 + udelay(1000); 155 + } 156 + 157 + pci_info(pdev, "DMA hang fixup at reg[0x%lx]: 0x%x\n", 158 + (unsigned long)crtc_reg & 0xffff, readl(crtc_reg)); 159 + } 160 + 161 + iounmap(regbase); 162 + } 163 + 164 + static void pci_fixup_dma_hang_early(struct pci_dev *pdev) 165 + { 166 + loongson_gpu_fixup_dma_hang(pdev, false); 167 + } 168 + DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_LOONGSON, PCI_DEVICE_ID_LOONGSON_GPU2, pci_fixup_dma_hang_early); 169 + DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_LOONGSON, PCI_DEVICE_ID_LOONGSON_GPU3, pci_fixup_dma_hang_early); 170 + 171 + static void pci_fixup_dma_hang_final(struct pci_dev *pdev) 172 + { 173 + loongson_gpu_fixup_dma_hang(pdev, true); 174 + } 175 + DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_LOONGSON, PCI_DEVICE_ID_LOONGSON_GPU2, pci_fixup_dma_hang_final); 176 + DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_LOONGSON, PCI_DEVICE_ID_LOONGSON_GPU3, pci_fixup_dma_hang_final);
+2 -2
arch/loongarch/vdso/Makefile
··· 26 26 $(filter -W%,$(filter-out -Wa$(comma)%,$(KBUILD_CFLAGS))) \ 27 27 -std=gnu11 -fms-extensions -O2 -g -fno-strict-aliasing -fno-common -fno-builtin \ 28 28 -fno-stack-protector -fno-jump-tables -DDISABLE_BRANCH_PROFILING \ 29 - $(call cc-option, -fno-asynchronous-unwind-tables) \ 29 + $(call cc-option, -fasynchronous-unwind-tables) \ 30 30 $(call cc-option, -fno-stack-protector) 31 31 aflags-vdso := $(ccflags-vdso) \ 32 32 -D__ASSEMBLY__ -Wa,-gdwarf-2 ··· 41 41 42 42 # VDSO linker flags. 43 43 ldflags-y := -Bsymbolic --no-undefined -soname=linux-vdso.so.1 \ 44 - $(filter -E%,$(KBUILD_CFLAGS)) -shared --build-id -T 44 + $(filter -E%,$(KBUILD_CFLAGS)) -shared --build-id --eh-frame-hdr -T 45 45 46 46 # 47 47 # Shared build commands.
+3 -3
arch/loongarch/vdso/sigreturn.S
··· 12 12 13 13 #include <asm/regdef.h> 14 14 #include <asm/asm.h> 15 + #include <asm/asm-offsets.h> 15 16 16 17 .section .text 17 - .cfi_sections .debug_frame 18 18 19 - SYM_FUNC_START(__vdso_rt_sigreturn) 19 + SYM_SIGFUNC_START(__vdso_rt_sigreturn) 20 20 21 21 li.w a7, __NR_rt_sigreturn 22 22 syscall 0 23 23 24 - SYM_FUNC_END(__vdso_rt_sigreturn) 24 + SYM_SIGFUNC_END(__vdso_rt_sigreturn)
+2 -2
arch/s390/include/asm/barrier.h
··· 62 62 * @size: number of elements in array 63 63 */ 64 64 #define array_index_mask_nospec array_index_mask_nospec 65 - static inline unsigned long array_index_mask_nospec(unsigned long index, 66 - unsigned long size) 65 + static __always_inline unsigned long array_index_mask_nospec(unsigned long index, 66 + unsigned long size) 67 67 { 68 68 unsigned long mask; 69 69
+3
arch/s390/kernel/entry.S
··· 271 271 xgr %r9,%r9 272 272 xgr %r10,%r10 273 273 xgr %r11,%r11 274 + xgr %r12,%r12 274 275 la %r2,STACK_FRAME_OVERHEAD(%r15) # pointer to pt_regs 275 276 mvc __PT_R8(64,%r2),__LC_SAVE_AREA(%r13) 276 277 MBEAR %r2,%r13 ··· 408 407 xgr %r6,%r6 409 408 xgr %r7,%r7 410 409 xgr %r10,%r10 410 + xgr %r12,%r12 411 411 xc __PT_FLAGS(8,%r11),__PT_FLAGS(%r11) 412 412 mvc __PT_R8(64,%r11),__LC_SAVE_AREA(%r13) 413 413 MBEAR %r11,%r13 ··· 498 496 xgr %r6,%r6 499 497 xgr %r7,%r7 500 498 xgr %r10,%r10 499 + xgr %r12,%r12 501 500 stmg %r8,%r9,__PT_PSW(%r11) 502 501 xc __PT_FLAGS(8,%r11),__PT_FLAGS(%r11) 503 502 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
+4 -1
arch/s390/kernel/syscall.c
··· 13 13 */ 14 14 15 15 #include <linux/cpufeature.h> 16 + #include <linux/nospec.h> 16 17 #include <linux/errno.h> 17 18 #include <linux/sched.h> 18 19 #include <linux/mm.h> ··· 132 131 if (unlikely(test_and_clear_pt_regs_flag(regs, PIF_SYSCALL_RET_SET))) 133 132 goto out; 134 133 regs->gprs[2] = -ENOSYS; 135 - if (likely(nr < NR_syscalls)) 134 + if (likely(nr < NR_syscalls)) { 135 + nr = array_index_nospec(nr, NR_syscalls); 136 136 regs->gprs[2] = sys_call_table[nr](regs); 137 + } 137 138 out: 138 139 syscall_exit_to_user_mode(regs); 139 140 }
+15 -85
arch/s390/kvm/dat.c
··· 135 135 } 136 136 137 137 /** 138 - * dat_crstep_xchg() - Exchange a gmap CRSTE with another. 139 - * @crstep: Pointer to the CRST entry 140 - * @new: Replacement entry. 141 - * @gfn: The affected guest address. 142 - * @asce: The ASCE of the address space. 143 - * 144 - * Context: This function is assumed to be called with kvm->mmu_lock held. 145 - */ 146 - void dat_crstep_xchg(union crste *crstep, union crste new, gfn_t gfn, union asce asce) 147 - { 148 - if (crstep->h.i) { 149 - WRITE_ONCE(*crstep, new); 150 - return; 151 - } else if (cpu_has_edat2()) { 152 - crdte_crste(crstep, *crstep, new, gfn, asce); 153 - return; 154 - } 155 - 156 - if (machine_has_tlb_guest()) 157 - idte_crste(crstep, gfn, IDTE_GUEST_ASCE, asce, IDTE_GLOBAL); 158 - else 159 - idte_crste(crstep, gfn, 0, NULL_ASCE, IDTE_GLOBAL); 160 - WRITE_ONCE(*crstep, new); 161 - } 162 - 163 - /** 164 138 * dat_crstep_xchg_atomic() - Atomically exchange a gmap CRSTE with another. 165 139 * @crstep: Pointer to the CRST entry. 166 140 * @old: Expected old value. ··· 149 175 * 150 176 * Return: %true if the exchange was successful. 151 177 */ 152 - bool dat_crstep_xchg_atomic(union crste *crstep, union crste old, union crste new, gfn_t gfn, 153 - union asce asce) 178 + bool __must_check dat_crstep_xchg_atomic(union crste *crstep, union crste old, union crste new, 179 + gfn_t gfn, union asce asce) 154 180 { 155 181 if (old.h.i) 156 182 return arch_try_cmpxchg((long *)crstep, &old.val, new.val); ··· 266 292 pt->ptes[i].val = init.val | i * PAGE_SIZE; 267 293 /* No need to take locks as the page table is not installed yet. */ 268 294 pgste_init.prefix_notif = old.s.fc1.prefix_notif; 295 + pgste_init.vsie_notif = old.s.fc1.vsie_notif; 269 296 pgste_init.pcl = uses_skeys && init.h.i; 270 297 dat_init_pgstes(pt, pgste_init.val); 271 298 } else { ··· 868 893 869 894 /* This table entry needs to be updated. */ 870 895 if (walk->start <= gfn && walk->end >= next) { 871 - dat_crstep_xchg_atomic(crstep, crste, new_crste, gfn, walk->asce); 896 + if (!dat_crstep_xchg_atomic(crstep, crste, new_crste, gfn, walk->asce)) 897 + return -EINVAL; 872 898 /* A lower level table was present, needs to be freed. */ 873 899 if (!crste.h.fc && !crste.h.i) { 874 900 if (is_pmd(crste)) ··· 997 1021 return _dat_walk_gfn_range(start, end, asce, &test_age_ops, 0, NULL) > 0; 998 1022 } 999 1023 1000 - int dat_link(struct kvm_s390_mmu_cache *mc, union asce asce, int level, 1001 - bool uses_skeys, struct guest_fault *f) 1002 - { 1003 - union crste oldval, newval; 1004 - union pte newpte, oldpte; 1005 - union pgste pgste; 1006 - int rc = 0; 1007 - 1008 - rc = dat_entry_walk(mc, f->gfn, asce, DAT_WALK_ALLOC_CONTINUE, level, &f->crstep, &f->ptep); 1009 - if (rc == -EINVAL || rc == -ENOMEM) 1010 - return rc; 1011 - if (rc) 1012 - return -EAGAIN; 1013 - 1014 - if (WARN_ON_ONCE(unlikely(get_level(f->crstep, f->ptep) > level))) 1015 - return -EINVAL; 1016 - 1017 - if (f->ptep) { 1018 - pgste = pgste_get_lock(f->ptep); 1019 - oldpte = *f->ptep; 1020 - newpte = _pte(f->pfn, f->writable, f->write_attempt | oldpte.s.d, !f->page); 1021 - newpte.s.sd = oldpte.s.sd; 1022 - oldpte.s.sd = 0; 1023 - if (oldpte.val == _PTE_EMPTY.val || oldpte.h.pfra == f->pfn) { 1024 - pgste = __dat_ptep_xchg(f->ptep, pgste, newpte, f->gfn, asce, uses_skeys); 1025 - if (f->callback) 1026 - f->callback(f); 1027 - } else { 1028 - rc = -EAGAIN; 1029 - } 1030 - pgste_set_unlock(f->ptep, pgste); 1031 - } else { 1032 - oldval = READ_ONCE(*f->crstep); 1033 - newval = _crste_fc1(f->pfn, oldval.h.tt, f->writable, 1034 - f->write_attempt | oldval.s.fc1.d); 1035 - newval.s.fc1.sd = oldval.s.fc1.sd; 1036 - if (oldval.val != _CRSTE_EMPTY(oldval.h.tt).val && 1037 - crste_origin_large(oldval) != crste_origin_large(newval)) 1038 - return -EAGAIN; 1039 - if (!dat_crstep_xchg_atomic(f->crstep, oldval, newval, f->gfn, asce)) 1040 - return -EAGAIN; 1041 - if (f->callback) 1042 - f->callback(f); 1043 - } 1044 - 1045 - return rc; 1046 - } 1047 - 1048 1024 static long dat_set_pn_crste(union crste *crstep, gfn_t gfn, gfn_t next, struct dat_walk *walk) 1049 1025 { 1050 - union crste crste = READ_ONCE(*crstep); 1026 + union crste newcrste, oldcrste; 1051 1027 int *n = walk->priv; 1052 1028 1053 - if (!crste.h.fc || crste.h.i || crste.h.p) 1054 - return 0; 1055 - 1029 + do { 1030 + oldcrste = READ_ONCE(*crstep); 1031 + if (!oldcrste.h.fc || oldcrste.h.i || oldcrste.h.p) 1032 + return 0; 1033 + if (oldcrste.s.fc1.prefix_notif) 1034 + break; 1035 + newcrste = oldcrste; 1036 + newcrste.s.fc1.prefix_notif = 1; 1037 + } while (!dat_crstep_xchg_atomic(crstep, oldcrste, newcrste, gfn, walk->asce)); 1056 1038 *n = 2; 1057 - if (crste.s.fc1.prefix_notif) 1058 - return 0; 1059 - crste.s.fc1.prefix_notif = 1; 1060 - dat_crstep_xchg(crstep, crste, gfn, walk->asce); 1061 1039 return 0; 1062 1040 } 1063 1041
+12 -11
arch/s390/kvm/dat.h
··· 160 160 unsigned long :44; /* HW */ 161 161 unsigned long : 3; /* Unused */ 162 162 unsigned long : 1; /* HW */ 163 + unsigned long s : 1; /* Special */ 163 164 unsigned long w : 1; /* Writable soft-bit */ 164 165 unsigned long r : 1; /* Readable soft-bit */ 165 166 unsigned long d : 1; /* Dirty */ 166 167 unsigned long y : 1; /* Young */ 167 - unsigned long prefix_notif : 1; /* Guest prefix invalidation notification */ 168 168 unsigned long : 3; /* HW */ 169 + unsigned long prefix_notif : 1; /* Guest prefix invalidation notification */ 169 170 unsigned long vsie_notif : 1; /* Referenced in a shadow table */ 170 - unsigned long : 1; /* Unused */ 171 171 unsigned long : 4; /* HW */ 172 172 unsigned long sd : 1; /* Soft-Dirty */ 173 173 unsigned long pr : 1; /* Present */ ··· 183 183 unsigned long :33; /* HW */ 184 184 unsigned long :14; /* Unused */ 185 185 unsigned long : 1; /* HW */ 186 + unsigned long s : 1; /* Special */ 186 187 unsigned long w : 1; /* Writable soft-bit */ 187 188 unsigned long r : 1; /* Readable soft-bit */ 188 189 unsigned long d : 1; /* Dirty */ 189 190 unsigned long y : 1; /* Young */ 190 - unsigned long prefix_notif : 1; /* Guest prefix invalidation notification */ 191 191 unsigned long : 3; /* HW */ 192 + unsigned long prefix_notif : 1; /* Guest prefix invalidation notification */ 192 193 unsigned long vsie_notif : 1; /* Referenced in a shadow table */ 193 - unsigned long : 1; /* Unused */ 194 194 unsigned long : 4; /* HW */ 195 195 unsigned long sd : 1; /* Soft-Dirty */ 196 196 unsigned long pr : 1; /* Present */ ··· 254 254 struct { 255 255 unsigned long :47; 256 256 unsigned long : 1; /* HW (should be 0) */ 257 + unsigned long s : 1; /* Special */ 257 258 unsigned long w : 1; /* Writable */ 258 259 unsigned long r : 1; /* Readable */ 259 260 unsigned long d : 1; /* Dirty */ 260 261 unsigned long y : 1; /* Young */ 261 - unsigned long prefix_notif : 1; /* Guest prefix invalidation notification */ 262 262 unsigned long : 3; /* HW */ 263 + unsigned long prefix_notif : 1; /* Guest prefix invalidation notification */ 263 264 unsigned long vsie_notif : 1; /* Referenced in a shadow table */ 264 - unsigned long : 1; 265 265 unsigned long : 4; /* HW */ 266 266 unsigned long sd : 1; /* Soft-Dirty */ 267 267 unsigned long pr : 1; /* Present */ ··· 540 540 u16 type, u16 param); 541 541 int dat_set_prefix_notif_bit(union asce asce, gfn_t gfn); 542 542 bool dat_test_age_gfn(union asce asce, gfn_t start, gfn_t end); 543 - int dat_link(struct kvm_s390_mmu_cache *mc, union asce asce, int level, 544 - bool uses_skeys, struct guest_fault *f); 545 543 546 544 int dat_perform_essa(union asce asce, gfn_t gfn, int orc, union essa_state *state, bool *dirty); 547 545 long dat_reset_cmma(union asce asce, gfn_t start_gfn); ··· 936 938 return dat_crstep_xchg_atomic(_CRSTEP(pudp), _CRSTE(old), _CRSTE(new), gfn, asce); 937 939 } 938 940 939 - static inline void dat_crstep_clear(union crste *crstep, gfn_t gfn, union asce asce) 941 + static inline union crste dat_crstep_clear_atomic(union crste *crstep, gfn_t gfn, union asce asce) 940 942 { 941 - union crste newcrste = _CRSTE_EMPTY(crstep->h.tt); 943 + union crste oldcrste, empty = _CRSTE_EMPTY(crstep->h.tt); 942 944 943 - dat_crstep_xchg(crstep, newcrste, gfn, asce); 945 + do { 946 + oldcrste = READ_ONCE(*crstep); 947 + } while (!dat_crstep_xchg_atomic(crstep, oldcrste, empty, gfn, asce)); 948 + return oldcrste; 944 949 } 945 950 946 951 static inline int get_level(union crste *crstep, union pte *ptep)
+51 -20
arch/s390/kvm/gaccess.c
··· 1436 1436 1437 1437 if (!pgste_get_trylock(ptep_h, &pgste)) 1438 1438 return -EAGAIN; 1439 - newpte = _pte(f->pfn, f->writable, !p, 0); 1440 - newpte.s.d |= ptep->s.d; 1441 - newpte.s.sd |= ptep->s.sd; 1442 - newpte.h.p &= ptep->h.p; 1443 - pgste = _gmap_ptep_xchg(sg->parent, ptep_h, newpte, pgste, f->gfn, false); 1444 - pgste.vsie_notif = 1; 1439 + newpte = _pte(f->pfn, f->writable, !p, ptep_h->s.s); 1440 + newpte.s.d |= ptep_h->s.d; 1441 + newpte.s.sd |= ptep_h->s.sd; 1442 + newpte.h.p &= ptep_h->h.p; 1443 + if (!newpte.h.p && !f->writable) { 1444 + rc = -EOPNOTSUPP; 1445 + } else { 1446 + pgste = _gmap_ptep_xchg(sg->parent, ptep_h, newpte, pgste, f->gfn, false); 1447 + pgste.vsie_notif = 1; 1448 + } 1445 1449 pgste_set_unlock(ptep_h, pgste); 1450 + if (rc) 1451 + return rc; 1452 + if (!sg->parent) 1453 + return -EAGAIN; 1446 1454 1447 1455 newpte = _pte(f->pfn, 0, !p, 0); 1448 1456 if (!pgste_get_trylock(ptep, &pgste)) ··· 1464 1456 static int _do_shadow_crste(struct gmap *sg, gpa_t raddr, union crste *host, union crste *table, 1465 1457 struct guest_fault *f, bool p) 1466 1458 { 1467 - union crste newcrste; 1459 + union crste newcrste, oldcrste; 1468 1460 gfn_t gfn; 1469 1461 int rc; 1470 1462 ··· 1477 1469 if (rc) 1478 1470 return rc; 1479 1471 1480 - newcrste = _crste_fc1(f->pfn, host->h.tt, f->writable, !p); 1481 - newcrste.s.fc1.d |= host->s.fc1.d; 1482 - newcrste.s.fc1.sd |= host->s.fc1.sd; 1483 - newcrste.h.p &= host->h.p; 1484 - newcrste.s.fc1.vsie_notif = 1; 1485 - newcrste.s.fc1.prefix_notif = host->s.fc1.prefix_notif; 1486 - _gmap_crstep_xchg(sg->parent, host, newcrste, f->gfn, false); 1472 + do { 1473 + /* _gmap_crstep_xchg_atomic() could have unshadowed this shadow gmap */ 1474 + if (!sg->parent) 1475 + return -EAGAIN; 1476 + oldcrste = READ_ONCE(*host); 1477 + newcrste = _crste_fc1(f->pfn, oldcrste.h.tt, f->writable, !p); 1478 + newcrste.s.fc1.d |= oldcrste.s.fc1.d; 1479 + newcrste.s.fc1.sd |= oldcrste.s.fc1.sd; 1480 + newcrste.h.p &= oldcrste.h.p; 1481 + newcrste.s.fc1.vsie_notif = 1; 1482 + newcrste.s.fc1.prefix_notif = oldcrste.s.fc1.prefix_notif; 1483 + newcrste.s.fc1.s = oldcrste.s.fc1.s; 1484 + if (!newcrste.h.p && !f->writable) 1485 + return -EOPNOTSUPP; 1486 + } while (!_gmap_crstep_xchg_atomic(sg->parent, host, oldcrste, newcrste, f->gfn, false)); 1487 + if (!sg->parent) 1488 + return -EAGAIN; 1487 1489 1488 - newcrste = _crste_fc1(f->pfn, host->h.tt, 0, !p); 1489 - dat_crstep_xchg(table, newcrste, gpa_to_gfn(raddr), sg->asce); 1490 + newcrste = _crste_fc1(f->pfn, oldcrste.h.tt, 0, !p); 1491 + gfn = gpa_to_gfn(raddr); 1492 + while (!dat_crstep_xchg_atomic(table, READ_ONCE(*table), newcrste, gfn, sg->asce)) 1493 + ; 1490 1494 return 0; 1491 1495 } 1492 1496 ··· 1522 1502 if (rc) 1523 1503 return rc; 1524 1504 1525 - /* A race occourred. The shadow mapping is already valid, nothing to do */ 1526 - if ((ptep && !ptep->h.i) || (!ptep && crste_leaf(*table))) 1505 + /* A race occurred. The shadow mapping is already valid, nothing to do */ 1506 + if ((ptep && !ptep->h.i && ptep->h.p == w->p) || 1507 + (!ptep && crste_leaf(*table) && !table->h.i && table->h.p == w->p)) 1527 1508 return 0; 1528 1509 1529 1510 gl = get_level(table, ptep); 1511 + 1512 + /* In case of a real address space */ 1513 + if (w->level <= LEVEL_MEM) { 1514 + l = TABLE_TYPE_PAGE_TABLE; 1515 + hl = TABLE_TYPE_REGION1; 1516 + goto real_address_space; 1517 + } 1530 1518 1531 1519 /* 1532 1520 * Skip levels that are already protected. For each level, protect 1533 1521 * only the page containing the entry, not the whole table. 1534 1522 */ 1535 1523 for (i = gl ; i >= w->level; i--) { 1536 - rc = gmap_protect_rmap(mc, sg, entries[i - 1].gfn, gpa_to_gfn(saddr), 1537 - entries[i - 1].pfn, i, entries[i - 1].writable); 1524 + rc = gmap_protect_rmap(mc, sg, entries[i].gfn, gpa_to_gfn(saddr), 1525 + entries[i].pfn, i + 1, entries[i].writable); 1538 1526 if (rc) 1539 1527 return rc; 1528 + if (!sg->parent) 1529 + return -EAGAIN; 1540 1530 } 1541 1531 1542 1532 rc = dat_entry_walk(NULL, entries[LEVEL_MEM].gfn, sg->parent->asce, DAT_WALK_LEAF, ··· 1558 1528 /* Get the smallest granularity */ 1559 1529 l = min3(gl, hl, w->level); 1560 1530 1531 + real_address_space: 1561 1532 flags = DAT_WALK_SPLIT_ALLOC | (uses_skeys(sg->parent) ? DAT_WALK_USES_SKEYS : 0); 1562 1533 /* If necessary, create the shadow mapping */ 1563 1534 if (l < gl) {
+114 -46
arch/s390/kvm/gmap.c
··· 313 313 struct clear_young_pte_priv *priv = walk->priv; 314 314 union crste crste, new; 315 315 316 - crste = READ_ONCE(*crstep); 316 + do { 317 + crste = READ_ONCE(*crstep); 317 318 318 - if (!crste.h.fc) 319 - return 0; 320 - if (!crste.s.fc1.y && crste.h.i) 321 - return 0; 322 - if (!crste_prefix(crste) || gmap_mkold_prefix(priv->gmap, gfn, end)) { 319 + if (!crste.h.fc) 320 + return 0; 321 + if (!crste.s.fc1.y && crste.h.i) 322 + return 0; 323 + if (crste_prefix(crste) && !gmap_mkold_prefix(priv->gmap, gfn, end)) 324 + break; 325 + 323 326 new = crste; 324 327 new.h.i = 1; 325 328 new.s.fc1.y = 0; ··· 331 328 folio_set_dirty(phys_to_folio(crste_origin_large(crste))); 332 329 new.s.fc1.d = 0; 333 330 new.h.p = 1; 334 - dat_crstep_xchg(crstep, new, gfn, walk->asce); 335 - } 331 + } while (!dat_crstep_xchg_atomic(crstep, crste, new, gfn, walk->asce)); 332 + 336 333 priv->young = 1; 337 334 return 0; 338 335 } ··· 394 391 { 395 392 struct gmap_unmap_priv *priv = walk->priv; 396 393 struct folio *folio = NULL; 394 + union crste old = *crstep; 397 395 398 - if (crstep->h.fc) { 399 - if (crstep->s.fc1.pr && test_bit(GMAP_FLAG_EXPORT_ON_UNMAP, &priv->gmap->flags)) 400 - folio = phys_to_folio(crste_origin_large(*crstep)); 401 - gmap_crstep_xchg(priv->gmap, crstep, _CRSTE_EMPTY(crstep->h.tt), gfn); 402 - if (folio) 403 - uv_convert_from_secure_folio(folio); 404 - } 396 + if (!old.h.fc) 397 + return 0; 398 + 399 + if (old.s.fc1.pr && test_bit(GMAP_FLAG_EXPORT_ON_UNMAP, &priv->gmap->flags)) 400 + folio = phys_to_folio(crste_origin_large(old)); 401 + /* No races should happen because kvm->mmu_lock is held in write mode */ 402 + KVM_BUG_ON(!gmap_crstep_xchg_atomic(priv->gmap, crstep, old, _CRSTE_EMPTY(old.h.tt), gfn), 403 + priv->gmap->kvm); 404 + if (folio) 405 + uv_convert_from_secure_folio(folio); 405 406 406 407 return 0; 407 408 } ··· 481 474 482 475 if (fatal_signal_pending(current)) 483 476 return 1; 484 - crste = READ_ONCE(*table); 485 - if (!crste.h.fc) 486 - return 0; 487 - if (crste.h.p && !crste.s.fc1.sd) 488 - return 0; 477 + do { 478 + crste = READ_ONCE(*table); 479 + if (!crste.h.fc) 480 + return 0; 481 + if (crste.h.p && !crste.s.fc1.sd) 482 + return 0; 489 483 490 - /* 491 - * If this large page contains one or more prefixes of vCPUs that are 492 - * currently running, do not reset the protection, leave it marked as 493 - * dirty. 494 - */ 495 - if (!crste.s.fc1.prefix_notif || gmap_mkold_prefix(gmap, gfn, end)) { 484 + /* 485 + * If this large page contains one or more prefixes of vCPUs that are 486 + * currently running, do not reset the protection, leave it marked as 487 + * dirty. 488 + */ 489 + if (crste.s.fc1.prefix_notif && !gmap_mkold_prefix(gmap, gfn, end)) 490 + break; 496 491 new = crste; 497 492 new.h.p = 1; 498 493 new.s.fc1.sd = 0; 499 - gmap_crstep_xchg(gmap, table, new, gfn); 500 - } 494 + } while (!gmap_crstep_xchg_atomic(gmap, table, crste, new, gfn)); 501 495 502 496 for ( ; gfn < end; gfn++) 503 497 mark_page_dirty(gmap->kvm, gfn); ··· 519 511 _dat_walk_gfn_range(start, end, gmap->asce, &walk_ops, 0, gmap); 520 512 } 521 513 522 - static int gmap_handle_minor_crste_fault(union asce asce, struct guest_fault *f) 514 + static int gmap_handle_minor_crste_fault(struct gmap *gmap, struct guest_fault *f) 523 515 { 524 516 union crste newcrste, oldcrste = READ_ONCE(*f->crstep); 525 517 ··· 544 536 newcrste.s.fc1.d = 1; 545 537 newcrste.s.fc1.sd = 1; 546 538 } 547 - if (!oldcrste.s.fc1.d && newcrste.s.fc1.d) 548 - SetPageDirty(phys_to_page(crste_origin_large(newcrste))); 549 539 /* In case of races, let the slow path deal with it. */ 550 - return !dat_crstep_xchg_atomic(f->crstep, oldcrste, newcrste, f->gfn, asce); 540 + return !gmap_crstep_xchg_atomic(gmap, f->crstep, oldcrste, newcrste, f->gfn); 551 541 } 552 542 /* Trying to write on a read-only page, let the slow path deal with it. */ 553 543 return 1; ··· 574 568 newpte.s.d = 1; 575 569 newpte.s.sd = 1; 576 570 } 577 - if (!oldpte.s.d && newpte.s.d) 578 - SetPageDirty(pfn_to_page(newpte.h.pfra)); 579 571 *pgste = gmap_ptep_xchg(gmap, f->ptep, newpte, *pgste, f->gfn); 580 572 581 573 return 0; ··· 610 606 fault->callback(fault); 611 607 pgste_set_unlock(fault->ptep, pgste); 612 608 } else { 613 - rc = gmap_handle_minor_crste_fault(gmap->asce, fault); 609 + rc = gmap_handle_minor_crste_fault(gmap, fault); 614 610 if (!rc && fault->callback) 615 611 fault->callback(fault); 616 612 } ··· 627 623 return test_bit(GMAP_FLAG_ALLOW_HPAGE_1M, &gmap->flags); 628 624 } 629 625 626 + static int _gmap_link(struct kvm_s390_mmu_cache *mc, struct gmap *gmap, int level, 627 + struct guest_fault *f) 628 + { 629 + union crste oldval, newval; 630 + union pte newpte, oldpte; 631 + union pgste pgste; 632 + int rc = 0; 633 + 634 + rc = dat_entry_walk(mc, f->gfn, gmap->asce, DAT_WALK_ALLOC_CONTINUE, level, 635 + &f->crstep, &f->ptep); 636 + if (rc == -ENOMEM) 637 + return rc; 638 + if (KVM_BUG_ON(rc == -EINVAL, gmap->kvm)) 639 + return rc; 640 + if (rc) 641 + return -EAGAIN; 642 + if (KVM_BUG_ON(get_level(f->crstep, f->ptep) > level, gmap->kvm)) 643 + return -EINVAL; 644 + 645 + if (f->ptep) { 646 + pgste = pgste_get_lock(f->ptep); 647 + oldpte = *f->ptep; 648 + newpte = _pte(f->pfn, f->writable, f->write_attempt | oldpte.s.d, !f->page); 649 + newpte.s.sd = oldpte.s.sd; 650 + oldpte.s.sd = 0; 651 + if (oldpte.val == _PTE_EMPTY.val || oldpte.h.pfra == f->pfn) { 652 + pgste = gmap_ptep_xchg(gmap, f->ptep, newpte, pgste, f->gfn); 653 + if (f->callback) 654 + f->callback(f); 655 + } else { 656 + rc = -EAGAIN; 657 + } 658 + pgste_set_unlock(f->ptep, pgste); 659 + } else { 660 + do { 661 + oldval = READ_ONCE(*f->crstep); 662 + newval = _crste_fc1(f->pfn, oldval.h.tt, f->writable, 663 + f->write_attempt | oldval.s.fc1.d); 664 + newval.s.fc1.s = !f->page; 665 + newval.s.fc1.sd = oldval.s.fc1.sd; 666 + if (oldval.val != _CRSTE_EMPTY(oldval.h.tt).val && 667 + crste_origin_large(oldval) != crste_origin_large(newval)) 668 + return -EAGAIN; 669 + } while (!gmap_crstep_xchg_atomic(gmap, f->crstep, oldval, newval, f->gfn)); 670 + if (f->callback) 671 + f->callback(f); 672 + } 673 + 674 + return rc; 675 + } 676 + 630 677 int gmap_link(struct kvm_s390_mmu_cache *mc, struct gmap *gmap, struct guest_fault *f) 631 678 { 632 679 unsigned int order; 633 - int rc, level; 680 + int level; 634 681 635 682 lockdep_assert_held(&gmap->kvm->mmu_lock); 636 683 ··· 693 638 else if (order >= get_order(_SEGMENT_SIZE) && gmap_1m_allowed(gmap, f->gfn)) 694 639 level = TABLE_TYPE_SEGMENT; 695 640 } 696 - rc = dat_link(mc, gmap->asce, level, uses_skeys(gmap), f); 697 - KVM_BUG_ON(rc == -EINVAL, gmap->kvm); 698 - return rc; 641 + return _gmap_link(mc, gmap, level, f); 699 642 } 700 643 701 644 static int gmap_ucas_map_one(struct kvm_s390_mmu_cache *mc, struct gmap *gmap, 702 645 gfn_t p_gfn, gfn_t c_gfn, bool force_alloc) 703 646 { 647 + union crste newcrste, oldcrste; 704 648 struct page_table *pt; 705 - union crste newcrste; 706 649 union crste *crstep; 707 650 union pte *ptep; 708 651 int rc; ··· 726 673 &crstep, &ptep); 727 674 if (rc) 728 675 return rc; 729 - dat_crstep_xchg(crstep, newcrste, c_gfn, gmap->asce); 676 + do { 677 + oldcrste = READ_ONCE(*crstep); 678 + if (oldcrste.val == newcrste.val) 679 + break; 680 + } while (!dat_crstep_xchg_atomic(crstep, oldcrste, newcrste, c_gfn, gmap->asce)); 730 681 return 0; 731 682 } 732 683 ··· 834 777 int rc; 835 778 836 779 rc = dat_entry_walk(NULL, c_gfn, gmap->asce, 0, TABLE_TYPE_SEGMENT, &crstep, &ptep); 837 - if (!rc) 838 - dat_crstep_xchg(crstep, _PMD_EMPTY, c_gfn, gmap->asce); 780 + if (rc) 781 + return; 782 + while (!dat_crstep_xchg_atomic(crstep, READ_ONCE(*crstep), _PMD_EMPTY, c_gfn, gmap->asce)) 783 + ; 839 784 } 840 785 841 786 void gmap_ucas_unmap(struct gmap *gmap, gfn_t c_gfn, unsigned long count) ··· 1076 1017 dat_ptep_xchg(ptep, _PTE_EMPTY, r_gfn, sg->asce, uses_skeys(sg)); 1077 1018 return; 1078 1019 } 1079 - crste = READ_ONCE(*crstep); 1080 - dat_crstep_clear(crstep, r_gfn, sg->asce); 1020 + 1021 + crste = dat_crstep_clear_atomic(crstep, r_gfn, sg->asce); 1081 1022 if (crste_leaf(crste) || crste.h.i) 1082 1023 return; 1083 1024 if (is_pmd(crste)) ··· 1160 1101 static inline int __gmap_protect_asce_top_level(struct kvm_s390_mmu_cache *mc, struct gmap *sg, 1161 1102 struct gmap_protect_asce_top_level *context) 1162 1103 { 1104 + struct gmap *parent; 1163 1105 int rc, i; 1164 1106 1165 1107 guard(write_lock)(&sg->kvm->mmu_lock); ··· 1168 1108 if (kvm_s390_array_needs_retry_safe(sg->kvm, context->seq, context->f)) 1169 1109 return -EAGAIN; 1170 1110 1171 - scoped_guard(spinlock, &sg->parent->children_lock) { 1111 + parent = READ_ONCE(sg->parent); 1112 + if (!parent) 1113 + return -EAGAIN; 1114 + scoped_guard(spinlock, &parent->children_lock) { 1115 + if (READ_ONCE(sg->parent) != parent) 1116 + return -EAGAIN; 1172 1117 for (i = 0; i < CRST_TABLE_PAGES; i++) { 1173 1118 if (!context->f[i].valid) 1174 1119 continue; ··· 1255 1190 { 1256 1191 struct gmap *sg, *new; 1257 1192 int rc; 1193 + 1194 + if (WARN_ON(!parent)) 1195 + return ERR_PTR(-EINVAL); 1258 1196 1259 1197 scoped_guard(spinlock, &parent->children_lock) { 1260 1198 sg = gmap_find_shadow(parent, asce, edat_level);
+21 -12
arch/s390/kvm/gmap.h
··· 185 185 else 186 186 _gmap_handle_vsie_unshadow_event(gmap, gfn); 187 187 } 188 + if (!ptep->s.d && newpte.s.d && !newpte.s.s) 189 + SetPageDirty(pfn_to_page(newpte.h.pfra)); 188 190 return __dat_ptep_xchg(ptep, pgste, newpte, gfn, gmap->asce, uses_skeys(gmap)); 189 191 } 190 192 ··· 196 194 return _gmap_ptep_xchg(gmap, ptep, newpte, pgste, gfn, true); 197 195 } 198 196 199 - static inline void _gmap_crstep_xchg(struct gmap *gmap, union crste *crstep, union crste ne, 200 - gfn_t gfn, bool needs_lock) 197 + static inline bool __must_check _gmap_crstep_xchg_atomic(struct gmap *gmap, union crste *crstep, 198 + union crste oldcrste, union crste newcrste, 199 + gfn_t gfn, bool needs_lock) 201 200 { 202 - unsigned long align = 8 + (is_pmd(*crstep) ? 0 : 11); 201 + unsigned long align = is_pmd(newcrste) ? _PAGE_ENTRIES : _PAGE_ENTRIES * _CRST_ENTRIES; 202 + 203 + if (KVM_BUG_ON(crstep->h.tt != oldcrste.h.tt || newcrste.h.tt != oldcrste.h.tt, gmap->kvm)) 204 + return true; 203 205 204 206 lockdep_assert_held(&gmap->kvm->mmu_lock); 205 207 if (!needs_lock) 206 208 lockdep_assert_held(&gmap->children_lock); 207 209 208 210 gfn = ALIGN_DOWN(gfn, align); 209 - if (crste_prefix(*crstep) && (ne.h.p || ne.h.i || !crste_prefix(ne))) { 210 - ne.s.fc1.prefix_notif = 0; 211 + if (crste_prefix(oldcrste) && (newcrste.h.p || newcrste.h.i || !crste_prefix(newcrste))) { 212 + newcrste.s.fc1.prefix_notif = 0; 211 213 gmap_unmap_prefix(gmap, gfn, gfn + align); 212 214 } 213 - if (crste_leaf(*crstep) && crstep->s.fc1.vsie_notif && 214 - (ne.h.p || ne.h.i || !ne.s.fc1.vsie_notif)) { 215 - ne.s.fc1.vsie_notif = 0; 215 + if (crste_leaf(oldcrste) && oldcrste.s.fc1.vsie_notif && 216 + (newcrste.h.p || newcrste.h.i || !newcrste.s.fc1.vsie_notif)) { 217 + newcrste.s.fc1.vsie_notif = 0; 216 218 if (needs_lock) 217 219 gmap_handle_vsie_unshadow_event(gmap, gfn); 218 220 else 219 221 _gmap_handle_vsie_unshadow_event(gmap, gfn); 220 222 } 221 - dat_crstep_xchg(crstep, ne, gfn, gmap->asce); 223 + if (!oldcrste.s.fc1.d && newcrste.s.fc1.d && !newcrste.s.fc1.s) 224 + SetPageDirty(phys_to_page(crste_origin_large(newcrste))); 225 + return dat_crstep_xchg_atomic(crstep, oldcrste, newcrste, gfn, gmap->asce); 222 226 } 223 227 224 - static inline void gmap_crstep_xchg(struct gmap *gmap, union crste *crstep, union crste ne, 225 - gfn_t gfn) 228 + static inline bool __must_check gmap_crstep_xchg_atomic(struct gmap *gmap, union crste *crstep, 229 + union crste oldcrste, union crste newcrste, 230 + gfn_t gfn) 226 231 { 227 - return _gmap_crstep_xchg(gmap, crstep, ne, gfn, true); 232 + return _gmap_crstep_xchg_atomic(gmap, crstep, oldcrste, newcrste, gfn, true); 228 233 } 229 234 230 235 /**
+15 -3
arch/s390/kvm/kvm-s390.c
··· 5520 5520 } 5521 5521 #endif 5522 5522 case KVM_S390_VCPU_FAULT: { 5523 - idx = srcu_read_lock(&vcpu->kvm->srcu); 5524 - r = vcpu_dat_fault_handler(vcpu, arg, 0); 5525 - srcu_read_unlock(&vcpu->kvm->srcu, idx); 5523 + gpa_t gaddr = arg; 5524 + 5525 + scoped_guard(srcu, &vcpu->kvm->srcu) { 5526 + r = vcpu_ucontrol_translate(vcpu, &gaddr); 5527 + if (r) 5528 + break; 5529 + 5530 + r = kvm_s390_faultin_gfn_simple(vcpu, NULL, gpa_to_gfn(gaddr), false); 5531 + if (r == PGM_ADDRESSING) 5532 + r = -EFAULT; 5533 + if (r <= 0) 5534 + break; 5535 + r = -EIO; 5536 + KVM_BUG_ON(r, vcpu->kvm); 5537 + } 5526 5538 break; 5527 5539 } 5528 5540 case KVM_ENABLE_CAP:
+3 -1
arch/s390/kvm/vsie.c
··· 1328 1328 static int vsie_run(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page) 1329 1329 { 1330 1330 struct kvm_s390_sie_block *scb_s = &vsie_page->scb_s; 1331 - struct gmap *sg; 1331 + struct gmap *sg = NULL; 1332 1332 int rc = 0; 1333 1333 1334 1334 while (1) { ··· 1368 1368 sg = gmap_put(sg); 1369 1369 cond_resched(); 1370 1370 } 1371 + if (sg) 1372 + sg = gmap_put(sg); 1371 1373 1372 1374 if (rc == -EFAULT) { 1373 1375 /*
+6
arch/x86/coco/sev/noinstr.c
··· 121 121 122 122 WARN_ON(!irqs_disabled()); 123 123 124 + if (!sev_cfg.ghcbs_initialized) 125 + return boot_ghcb; 126 + 124 127 data = this_cpu_read(runtime_data); 125 128 ghcb = &data->ghcb_page; 126 129 ··· 166 163 struct ghcb *ghcb; 167 164 168 165 WARN_ON(!irqs_disabled()); 166 + 167 + if (!sev_cfg.ghcbs_initialized) 168 + return; 169 169 170 170 data = this_cpu_read(runtime_data); 171 171 ghcb = &data->ghcb_page;
+14
arch/x86/entry/entry_fred.c
··· 177 177 } 178 178 } 179 179 180 + #ifdef CONFIG_AMD_MEM_ENCRYPT 181 + noinstr void exc_vmm_communication(struct pt_regs *regs, unsigned long error_code) 182 + { 183 + if (user_mode(regs)) 184 + return user_exc_vmm_communication(regs, error_code); 185 + else 186 + return kernel_exc_vmm_communication(regs, error_code); 187 + } 188 + #endif 189 + 180 190 static noinstr void fred_hwexc(struct pt_regs *regs, unsigned long error_code) 181 191 { 182 192 /* Optimize for #PF. That's the only exception which matters performance wise */ ··· 217 207 #ifdef CONFIG_X86_CET 218 208 case X86_TRAP_CP: return exc_control_protection(regs, error_code); 219 209 #endif 210 + #ifdef CONFIG_AMD_MEM_ENCRYPT 211 + case X86_TRAP_VC: return exc_vmm_communication(regs, error_code); 212 + #endif 213 + 220 214 default: return fred_bad_type(regs, error_code); 221 215 } 222 216
+26 -7
arch/x86/kernel/cpu/common.c
··· 433 433 434 434 /* These bits should not change their value after CPU init is finished. */ 435 435 static const unsigned long cr4_pinned_mask = X86_CR4_SMEP | X86_CR4_SMAP | X86_CR4_UMIP | 436 - X86_CR4_FSGSBASE | X86_CR4_CET | X86_CR4_FRED; 436 + X86_CR4_FSGSBASE | X86_CR4_CET; 437 + 438 + /* 439 + * The CR pinning protects against ROP on the 'mov %reg, %CRn' instruction(s). 440 + * Since you can ROP directly to these instructions (barring shadow stack), 441 + * any protection must follow immediately and unconditionally after that. 442 + * 443 + * Specifically, the CR[04] write functions below will have the value 444 + * validation controlled by the @cr_pinning static_branch which is 445 + * __ro_after_init, just like the cr4_pinned_bits value. 446 + * 447 + * Once set, an attacker will have to defeat page-tables to get around these 448 + * restrictions. Which is a much bigger ask than 'simple' ROP. 449 + */ 437 450 static DEFINE_STATIC_KEY_FALSE_RO(cr_pinning); 438 451 static unsigned long cr4_pinned_bits __ro_after_init; 439 452 ··· 2063 2050 setup_umip(c); 2064 2051 setup_lass(c); 2065 2052 2066 - /* Enable FSGSBASE instructions if available. */ 2067 - if (cpu_has(c, X86_FEATURE_FSGSBASE)) { 2068 - cr4_set_bits(X86_CR4_FSGSBASE); 2069 - elf_hwcap2 |= HWCAP2_FSGSBASE; 2070 - } 2071 - 2072 2053 /* 2073 2054 * The vendor-specific functions might have changed features. 2074 2055 * Now we do "generic changes." ··· 2422 2415 2423 2416 /* GHCB needs to be setup to handle #VC. */ 2424 2417 setup_ghcb(); 2418 + 2419 + /* 2420 + * On CPUs with FSGSBASE support, paranoid_entry() uses 2421 + * ALTERNATIVE-patched RDGSBASE/WRGSBASE instructions. Secondary CPUs 2422 + * boot after alternatives are patched globally, so early exceptions 2423 + * execute patched code that depends on FSGSBASE. Enable the feature 2424 + * before any exceptions occur. 2425 + */ 2426 + if (cpu_feature_enabled(X86_FEATURE_FSGSBASE)) { 2427 + cr4_set_bits(X86_CR4_FSGSBASE); 2428 + elf_hwcap2 |= HWCAP2_FSGSBASE; 2429 + } 2425 2430 2426 2431 if (cpu_feature_enabled(X86_FEATURE_FRED)) { 2427 2432 /* The boot CPU has enabled FRED during early boot */
+10 -7
arch/x86/kvm/mmu/mmu.c
··· 3044 3044 bool prefetch = !fault || fault->prefetch; 3045 3045 bool write_fault = fault && fault->write; 3046 3046 3047 - if (unlikely(is_noslot_pfn(pfn))) { 3048 - vcpu->stat.pf_mmio_spte_created++; 3049 - mark_mmio_spte(vcpu, sptep, gfn, pte_access); 3050 - return RET_PF_EMULATE; 3051 - } 3052 - 3053 3047 if (is_shadow_present_pte(*sptep)) { 3054 3048 if (prefetch && is_last_spte(*sptep, level) && 3055 3049 pfn == spte_to_pfn(*sptep)) ··· 3060 3066 child = spte_to_child_sp(pte); 3061 3067 drop_parent_pte(vcpu->kvm, child, sptep); 3062 3068 flush = true; 3063 - } else if (WARN_ON_ONCE(pfn != spte_to_pfn(*sptep))) { 3069 + } else if (pfn != spte_to_pfn(*sptep)) { 3070 + WARN_ON_ONCE(vcpu->arch.mmu->root_role.direct); 3064 3071 drop_spte(vcpu->kvm, sptep); 3065 3072 flush = true; 3066 3073 } else 3067 3074 was_rmapped = 1; 3075 + } 3076 + 3077 + if (unlikely(is_noslot_pfn(pfn))) { 3078 + vcpu->stat.pf_mmio_spte_created++; 3079 + mark_mmio_spte(vcpu, sptep, gfn, pte_access); 3080 + if (flush) 3081 + kvm_flush_remote_tlbs_gfn(vcpu->kvm, gfn, level); 3082 + return RET_PF_EMULATE; 3068 3083 } 3069 3084 3070 3085 wrprot = make_spte(vcpu, sp, slot, pte_access, gfn, pfn, *sptep, prefetch,
+1 -1
arch/x86/platform/efi/quirks.c
··· 424 424 if (efi_enabled(EFI_DBG)) 425 425 return; 426 426 427 - sz = sizeof(*ranges_to_free) * efi.memmap.nr_map + 1; 427 + sz = sizeof(*ranges_to_free) * (efi.memmap.nr_map + 1); 428 428 ranges_to_free = kzalloc(sz, GFP_KERNEL); 429 429 if (!ranges_to_free) { 430 430 pr_err("Failed to allocate storage for freeable EFI regions\n");
+1
drivers/accel/ivpu/ivpu_drv.h
··· 35 35 #define IVPU_HW_IP_60XX 60 36 36 37 37 #define IVPU_HW_IP_REV_LNL_B0 4 38 + #define IVPU_HW_IP_REV_NVL_A0 0 38 39 39 40 #define IVPU_HW_BTRS_MTL 1 40 41 #define IVPU_HW_BTRS_LNL 2
+4 -2
drivers/accel/ivpu/ivpu_hw.c
··· 70 70 if (ivpu_hw_btrs_gen(vdev) == IVPU_HW_BTRS_MTL) 71 71 vdev->wa.interrupt_clear_with_0 = ivpu_hw_btrs_irqs_clear_with_0_mtl(vdev); 72 72 73 - if (ivpu_device_id(vdev) == PCI_DEVICE_ID_LNL && 74 - ivpu_revision(vdev) < IVPU_HW_IP_REV_LNL_B0) 73 + if ((ivpu_device_id(vdev) == PCI_DEVICE_ID_LNL && 74 + ivpu_revision(vdev) < IVPU_HW_IP_REV_LNL_B0) || 75 + (ivpu_device_id(vdev) == PCI_DEVICE_ID_NVL && 76 + ivpu_revision(vdev) == IVPU_HW_IP_REV_NVL_A0)) 75 77 vdev->wa.disable_clock_relinquish = true; 76 78 77 79 if (ivpu_test_mode & IVPU_TEST_MODE_CLK_RELINQ_ENABLE)
+2
drivers/acpi/ec.c
··· 1656 1656 1657 1657 ret = ec_install_handlers(ec, device, call_reg); 1658 1658 if (ret) { 1659 + ec_remove_handlers(ec); 1660 + 1659 1661 if (ec == first_ec) 1660 1662 first_ec = NULL; 1661 1663
+12 -3
drivers/auxdisplay/lcd2s.c
··· 99 99 { 100 100 struct lcd2s_data *lcd2s = lcd->drvdata; 101 101 u8 buf[2] = { LCD2S_CMD_WRITE, c }; 102 + int ret; 102 103 103 - lcd2s_i2c_master_send(lcd2s->i2c, buf, sizeof(buf)); 104 + ret = lcd2s_i2c_master_send(lcd2s->i2c, buf, sizeof(buf)); 105 + if (ret < 0) 106 + return ret; 107 + if (ret != sizeof(buf)) 108 + return -EIO; 104 109 return 0; 105 110 } 106 111 ··· 113 108 { 114 109 struct lcd2s_data *lcd2s = lcd->drvdata; 115 110 u8 buf[3] = { LCD2S_CMD_CUR_POS, y + 1, x + 1 }; 111 + int ret; 116 112 117 - lcd2s_i2c_master_send(lcd2s->i2c, buf, sizeof(buf)); 118 - 113 + ret = lcd2s_i2c_master_send(lcd2s->i2c, buf, sizeof(buf)); 114 + if (ret < 0) 115 + return ret; 116 + if (ret != sizeof(buf)) 117 + return -EIO; 119 118 return 0; 120 119 } 121 120
+1 -1
drivers/auxdisplay/line-display.c
··· 365 365 366 366 static void linedisp_release(struct device *dev) 367 367 { 368 - struct linedisp *linedisp = to_linedisp(dev); 368 + struct linedisp *linedisp = container_of(dev, struct linedisp, dev); 369 369 370 370 kfree(linedisp->map); 371 371 kfree(linedisp->message);
+26 -4
drivers/base/regmap/regmap.c
··· 1545 1545 unsigned int val_num) 1546 1546 { 1547 1547 void *orig_work_buf; 1548 + unsigned int selector_reg; 1548 1549 unsigned int win_offset; 1549 1550 unsigned int win_page; 1550 1551 bool page_chg; ··· 1564 1563 return -EINVAL; 1565 1564 } 1566 1565 1567 - /* It is possible to have selector register inside data window. 1568 - In that case, selector register is located on every page and 1569 - it needs no page switching, when accessed alone. */ 1566 + /* 1567 + * Calculate the address of the selector register in the corresponding 1568 + * data window if it is located on every page. 1569 + */ 1570 + page_chg = in_range(range->selector_reg, range->window_start, range->window_len); 1571 + if (page_chg) 1572 + selector_reg = range->range_min + win_page * range->window_len + 1573 + range->selector_reg - range->window_start; 1574 + 1575 + /* 1576 + * It is possible to have selector register inside data window. 1577 + * In that case, selector register is located on every page and it 1578 + * needs no page switching, when accessed alone. 1579 + * 1580 + * Nevertheless we should synchronize the cache values for it. 1581 + * This can't be properly achieved if the selector register is 1582 + * the first and the only one to be read inside the data window. 1583 + * That's why we update it in that case as well. 1584 + * 1585 + * However, we specifically avoid updating it for the default page, 1586 + * when it's overlapped with the real data window, to prevent from 1587 + * infinite looping. 1588 + */ 1570 1589 if (val_num > 1 || 1590 + (page_chg && selector_reg != range->selector_reg) || 1571 1591 range->window_start + win_offset != range->selector_reg) { 1572 1592 /* Use separate work_buf during page switching */ 1573 1593 orig_work_buf = map->work_buf; ··· 1597 1575 ret = _regmap_update_bits(map, range->selector_reg, 1598 1576 range->selector_mask, 1599 1577 win_page << range->selector_shift, 1600 - &page_chg, false); 1578 + NULL, false); 1601 1579 1602 1580 map->work_buf = orig_work_buf; 1603 1581
-3
drivers/bluetooth/hci_h4.c
··· 109 109 { 110 110 struct h4_struct *h4 = hu->priv; 111 111 112 - if (!test_bit(HCI_UART_REGISTERED, &hu->flags)) 113 - return -EUNATCH; 114 - 115 112 h4->rx_skb = h4_recv_buf(hu, h4->rx_skb, data, count, 116 113 h4_recv_pkts, ARRAY_SIZE(h4_recv_pkts)); 117 114 if (IS_ERR(h4->rx_skb)) {
+3 -6
drivers/cpufreq/cpufreq.c
··· 1427 1427 * If there is a problem with its frequency table, take it 1428 1428 * offline and drop it. 1429 1429 */ 1430 - if (policy->freq_table_sorted != CPUFREQ_TABLE_SORTED_ASCENDING && 1431 - policy->freq_table_sorted != CPUFREQ_TABLE_SORTED_DESCENDING) { 1432 - ret = cpufreq_table_validate_and_sort(policy); 1433 - if (ret) 1434 - goto out_offline_policy; 1435 - } 1430 + ret = cpufreq_table_validate_and_sort(policy); 1431 + if (ret) 1432 + goto out_offline_policy; 1436 1433 1437 1434 /* related_cpus should at least include policy->cpus. */ 1438 1435 cpumask_copy(policy->related_cpus, policy->cpus);
+12
drivers/cpufreq/cpufreq_conservative.c
··· 313 313 dbs_info->requested_freq = policy->cur; 314 314 } 315 315 316 + static void cs_limits(struct cpufreq_policy *policy) 317 + { 318 + struct cs_policy_dbs_info *dbs_info = to_dbs_info(policy->governor_data); 319 + 320 + /* 321 + * The limits have changed, so may have the current frequency. Reset 322 + * requested_freq to avoid any unintended outcomes due to the mismatch. 323 + */ 324 + dbs_info->requested_freq = policy->cur; 325 + } 326 + 316 327 static struct dbs_governor cs_governor = { 317 328 .gov = CPUFREQ_DBS_GOVERNOR_INITIALIZER("conservative"), 318 329 .kobj_type = { .default_groups = cs_groups }, ··· 333 322 .init = cs_init, 334 323 .exit = cs_exit, 335 324 .start = cs_start, 325 + .limits = cs_limits, 336 326 }; 337 327 338 328 #define CPU_FREQ_GOV_CONSERVATIVE (cs_governor.gov)
+3
drivers/cpufreq/cpufreq_governor.c
··· 563 563 564 564 void cpufreq_dbs_governor_limits(struct cpufreq_policy *policy) 565 565 { 566 + struct dbs_governor *gov = dbs_governor_of(policy); 566 567 struct policy_dbs_info *policy_dbs; 567 568 568 569 /* Protect gov->gdbs_data against cpufreq_dbs_governor_exit() */ ··· 575 574 mutex_lock(&policy_dbs->update_mutex); 576 575 cpufreq_policy_apply_limits(policy); 577 576 gov_update_sample_delay(policy_dbs, 0); 577 + if (gov->limits) 578 + gov->limits(policy); 578 579 mutex_unlock(&policy_dbs->update_mutex); 579 580 580 581 out:
+1
drivers/cpufreq/cpufreq_governor.h
··· 138 138 int (*init)(struct dbs_data *dbs_data); 139 139 void (*exit)(struct dbs_data *dbs_data); 140 140 void (*start)(struct cpufreq_policy *policy); 141 + void (*limits)(struct cpufreq_policy *policy); 141 142 }; 142 143 143 144 static inline struct dbs_governor *dbs_governor_of(struct cpufreq_policy *policy)
+4
drivers/cpufreq/freq_table.c
··· 360 360 if (policy_has_boost_freq(policy)) 361 361 policy->boost_supported = true; 362 362 363 + if (policy->freq_table_sorted == CPUFREQ_TABLE_SORTED_ASCENDING || 364 + policy->freq_table_sorted == CPUFREQ_TABLE_SORTED_DESCENDING) 365 + return 0; 366 + 363 367 return set_freq_table_sorted(policy); 364 368 } 365 369
+6 -2
drivers/dma/dw-edma/dw-edma-core.c
··· 844 844 { 845 845 struct dw_edma_chip *chip = dw->chip; 846 846 struct device *dev = dw->chip->dev; 847 + struct msi_desc *msi_desc; 847 848 u32 wr_mask = 1; 848 849 u32 rd_mask = 1; 849 850 int i, err = 0; ··· 896 895 &dw->irq[i]); 897 896 if (err) 898 897 goto err_irq_free; 899 - 900 - if (irq_get_msi_desc(irq)) 898 + msi_desc = irq_get_msi_desc(irq); 899 + if (msi_desc) { 901 900 get_cached_msi_msg(irq, &dw->irq[i].msi); 901 + if (!msi_desc->pci.msi_attrib.is_msix) 902 + dw->irq[i].msi.data = dw->irq[0].msi.data + i; 903 + } 902 904 } 903 905 904 906 dw->nr_irqs = i;
+3 -3
drivers/dma/dw-edma/dw-hdma-v0-core.c
··· 252 252 lower_32_bits(chunk->ll_region.paddr)); 253 253 SET_CH_32(dw, chan->dir, chan->id, llp.msb, 254 254 upper_32_bits(chunk->ll_region.paddr)); 255 + /* Set consumer cycle */ 256 + SET_CH_32(dw, chan->dir, chan->id, cycle_sync, 257 + HDMA_V0_CONSUMER_CYCLE_STAT | HDMA_V0_CONSUMER_CYCLE_BIT); 255 258 } 256 - /* Set consumer cycle */ 257 - SET_CH_32(dw, chan->dir, chan->id, cycle_sync, 258 - HDMA_V0_CONSUMER_CYCLE_STAT | HDMA_V0_CONSUMER_CYCLE_BIT); 259 259 260 260 dw_hdma_v0_sync_ll_data(chunk); 261 261
+11 -15
drivers/dma/fsl-edma-main.c
··· 317 317 return NULL; 318 318 i = fsl_chan - fsl_edma->chans; 319 319 320 - fsl_chan->priority = dma_spec->args[1]; 321 - fsl_chan->is_rxchan = dma_spec->args[2] & FSL_EDMA_RX; 322 - fsl_chan->is_remote = dma_spec->args[2] & FSL_EDMA_REMOTE; 323 - fsl_chan->is_multi_fifo = dma_spec->args[2] & FSL_EDMA_MULTI_FIFO; 320 + if (!b_chmux && i != dma_spec->args[0]) 321 + continue; 324 322 325 323 if ((dma_spec->args[2] & FSL_EDMA_EVEN_CH) && (i & 0x1)) 326 324 continue; ··· 326 328 if ((dma_spec->args[2] & FSL_EDMA_ODD_CH) && !(i & 0x1)) 327 329 continue; 328 330 329 - if (!b_chmux && i == dma_spec->args[0]) { 330 - chan = dma_get_slave_channel(chan); 331 - chan->device->privatecnt++; 332 - return chan; 333 - } else if (b_chmux && !fsl_chan->srcid) { 334 - /* if controller support channel mux, choose a free channel */ 335 - chan = dma_get_slave_channel(chan); 336 - chan->device->privatecnt++; 337 - fsl_chan->srcid = dma_spec->args[0]; 338 - return chan; 339 - } 331 + fsl_chan->srcid = dma_spec->args[0]; 332 + fsl_chan->priority = dma_spec->args[1]; 333 + fsl_chan->is_rxchan = dma_spec->args[2] & FSL_EDMA_RX; 334 + fsl_chan->is_remote = dma_spec->args[2] & FSL_EDMA_REMOTE; 335 + fsl_chan->is_multi_fifo = dma_spec->args[2] & FSL_EDMA_MULTI_FIFO; 336 + 337 + chan = dma_get_slave_channel(chan); 338 + chan->device->privatecnt++; 339 + return chan; 340 340 } 341 341 return NULL; 342 342 }
+4 -4
drivers/dma/idxd/cdev.c
··· 158 158 static void idxd_cdev_dev_release(struct device *dev) 159 159 { 160 160 struct idxd_cdev *idxd_cdev = dev_to_cdev(dev); 161 - struct idxd_cdev_context *cdev_ctx; 162 - struct idxd_wq *wq = idxd_cdev->wq; 163 161 164 - cdev_ctx = &ictx[wq->idxd->data->type]; 165 - ida_free(&cdev_ctx->minor_ida, idxd_cdev->minor); 166 162 kfree(idxd_cdev); 167 163 } 168 164 ··· 578 582 579 583 void idxd_wq_del_cdev(struct idxd_wq *wq) 580 584 { 585 + struct idxd_cdev_context *cdev_ctx; 581 586 struct idxd_cdev *idxd_cdev; 582 587 583 588 idxd_cdev = wq->idxd_cdev; 584 589 wq->idxd_cdev = NULL; 585 590 cdev_device_del(&idxd_cdev->cdev, cdev_dev(idxd_cdev)); 591 + 592 + cdev_ctx = &ictx[wq->idxd->data->type]; 593 + ida_free(&cdev_ctx->minor_ida, idxd_cdev->minor); 586 594 put_device(cdev_dev(idxd_cdev)); 587 595 } 588 596
+31 -14
drivers/dma/idxd/device.c
··· 175 175 free_descs(wq); 176 176 dma_free_coherent(dev, wq->compls_size, wq->compls, wq->compls_addr); 177 177 sbitmap_queue_free(&wq->sbq); 178 + wq->type = IDXD_WQT_NONE; 178 179 } 179 180 EXPORT_SYMBOL_NS_GPL(idxd_wq_free_resources, "IDXD"); 180 181 ··· 383 382 lockdep_assert_held(&wq->wq_lock); 384 383 wq->state = IDXD_WQ_DISABLED; 385 384 memset(wq->wqcfg, 0, idxd->wqcfg_size); 386 - wq->type = IDXD_WQT_NONE; 387 385 wq->threshold = 0; 388 386 wq->priority = 0; 389 387 wq->enqcmds_retries = IDXD_ENQCMDS_RETRIES; ··· 831 831 struct device *dev = &idxd->pdev->dev; 832 832 struct idxd_evl *evl = idxd->evl; 833 833 834 - gencfg.bits = ioread32(idxd->reg_base + IDXD_GENCFG_OFFSET); 835 - if (!gencfg.evl_en) 834 + if (!evl) 836 835 return; 837 836 838 837 mutex_lock(&evl->lock); ··· 1124 1125 { 1125 1126 int rc; 1126 1127 1127 - lockdep_assert_held(&idxd->dev_lock); 1128 + guard(spinlock)(&idxd->dev_lock); 1129 + 1130 + if (!test_bit(IDXD_FLAG_CONFIGURABLE, &idxd->flags)) 1131 + return 0; 1132 + 1128 1133 rc = idxd_wqs_setup(idxd); 1129 1134 if (rc < 0) 1130 1135 return rc; ··· 1335 1332 1336 1333 free_irq(ie->vector, ie); 1337 1334 idxd_flush_pending_descs(ie); 1335 + 1336 + /* The interrupt might have been already released by FLR */ 1337 + if (ie->int_handle == INVALID_INT_HANDLE) 1338 + return; 1339 + 1338 1340 if (idxd->request_int_handles) 1339 1341 idxd_device_release_int_handle(idxd, ie->int_handle, IDXD_IRQ_MSIX); 1340 1342 idxd_device_clear_perm_entry(idxd, ie); 1341 1343 ie->vector = -1; 1342 1344 ie->int_handle = INVALID_INT_HANDLE; 1343 1345 ie->pasid = IOMMU_PASID_INVALID; 1346 + } 1347 + 1348 + void idxd_wq_flush_descs(struct idxd_wq *wq) 1349 + { 1350 + struct idxd_irq_entry *ie = &wq->ie; 1351 + struct idxd_device *idxd = wq->idxd; 1352 + 1353 + guard(mutex)(&wq->wq_lock); 1354 + 1355 + if (wq->state != IDXD_WQ_ENABLED || wq->type != IDXD_WQT_KERNEL) 1356 + return; 1357 + 1358 + idxd_flush_pending_descs(ie); 1359 + if (idxd->request_int_handles) 1360 + idxd_device_release_int_handle(idxd, ie->int_handle, IDXD_IRQ_MSIX); 1361 + idxd_device_clear_perm_entry(idxd, ie); 1362 + ie->int_handle = INVALID_INT_HANDLE; 1344 1363 } 1345 1364 1346 1365 int idxd_wq_request_irq(struct idxd_wq *wq) ··· 1479 1454 } 1480 1455 } 1481 1456 1482 - rc = 0; 1483 - spin_lock(&idxd->dev_lock); 1484 - if (test_bit(IDXD_FLAG_CONFIGURABLE, &idxd->flags)) 1485 - rc = idxd_device_config(idxd); 1486 - spin_unlock(&idxd->dev_lock); 1457 + rc = idxd_device_config(idxd); 1487 1458 if (rc < 0) { 1488 1459 dev_dbg(dev, "Writing wq %d config failed: %d\n", wq->id, rc); 1489 1460 goto err; ··· 1554 1533 idxd_wq_reset(wq); 1555 1534 idxd_wq_free_resources(wq); 1556 1535 percpu_ref_exit(&wq->wq_active); 1557 - wq->type = IDXD_WQT_NONE; 1558 1536 wq->client_count = 0; 1559 1537 } 1560 1538 EXPORT_SYMBOL_NS_GPL(idxd_drv_disable_wq, "IDXD"); ··· 1574 1554 } 1575 1555 1576 1556 /* Device configuration */ 1577 - spin_lock(&idxd->dev_lock); 1578 - if (test_bit(IDXD_FLAG_CONFIGURABLE, &idxd->flags)) 1579 - rc = idxd_device_config(idxd); 1580 - spin_unlock(&idxd->dev_lock); 1557 + rc = idxd_device_config(idxd); 1581 1558 if (rc < 0) 1582 1559 return -ENXIO; 1583 1560
+18
drivers/dma/idxd/dma.c
··· 194 194 kfree(idxd_dma); 195 195 } 196 196 197 + static int idxd_dma_terminate_all(struct dma_chan *c) 198 + { 199 + struct idxd_wq *wq = to_idxd_wq(c); 200 + 201 + idxd_wq_flush_descs(wq); 202 + 203 + return 0; 204 + } 205 + 206 + static void idxd_dma_synchronize(struct dma_chan *c) 207 + { 208 + struct idxd_wq *wq = to_idxd_wq(c); 209 + 210 + idxd_wq_drain(wq); 211 + } 212 + 197 213 int idxd_register_dma_device(struct idxd_device *idxd) 198 214 { 199 215 struct idxd_dma_dev *idxd_dma; ··· 240 224 dma->device_issue_pending = idxd_dma_issue_pending; 241 225 dma->device_alloc_chan_resources = idxd_dma_alloc_chan_resources; 242 226 dma->device_free_chan_resources = idxd_dma_free_chan_resources; 227 + dma->device_terminate_all = idxd_dma_terminate_all; 228 + dma->device_synchronize = idxd_dma_synchronize; 243 229 244 230 rc = dma_async_device_register(dma); 245 231 if (rc < 0) {
+1
drivers/dma/idxd/idxd.h
··· 803 803 int idxd_wq_init_percpu_ref(struct idxd_wq *wq); 804 804 void idxd_wq_free_irq(struct idxd_wq *wq); 805 805 int idxd_wq_request_irq(struct idxd_wq *wq); 806 + void idxd_wq_flush_descs(struct idxd_wq *wq); 806 807 807 808 /* submission */ 808 809 int idxd_submit_desc(struct idxd_wq *wq, struct idxd_desc *desc);
+7 -7
drivers/dma/idxd/init.c
··· 973 973 974 974 idxd->rdbuf_limit = idxd_saved->saved_idxd.rdbuf_limit; 975 975 976 - idxd->evl->size = saved_evl->size; 976 + if (idxd->evl) 977 + idxd->evl->size = saved_evl->size; 977 978 978 979 for (i = 0; i < idxd->max_groups; i++) { 979 980 struct idxd_group *saved_group, *group; ··· 1105 1104 idxd_device_config_restore(idxd, idxd->idxd_saved); 1106 1105 1107 1106 /* Re-configure IDXD device if allowed. */ 1108 - if (test_bit(IDXD_FLAG_CONFIGURABLE, &idxd->flags)) { 1109 - rc = idxd_device_config(idxd); 1110 - if (rc < 0) { 1111 - dev_err(dev, "HALT: %s config fails\n", idxd_name); 1112 - goto out; 1113 - } 1107 + rc = idxd_device_config(idxd); 1108 + if (rc < 0) { 1109 + dev_err(dev, "HALT: %s config fails\n", idxd_name); 1110 + goto out; 1114 1111 } 1115 1112 1116 1113 /* Bind IDXD device to driver. */ ··· 1146 1147 } 1147 1148 out: 1148 1149 kfree(idxd->idxd_saved); 1150 + idxd->idxd_saved = NULL; 1149 1151 } 1150 1152 1151 1153 static const struct pci_error_handlers idxd_error_handler = {
+16
drivers/dma/idxd/irq.c
··· 397 397 dev_err(&idxd->pdev->dev, "FLR failed\n"); 398 398 } 399 399 400 + static void idxd_wqs_flush_descs(struct idxd_device *idxd) 401 + { 402 + int i; 403 + 404 + for (i = 0; i < idxd->max_wqs; i++) { 405 + struct idxd_wq *wq = idxd->wqs[i]; 406 + 407 + idxd_wq_flush_descs(wq); 408 + } 409 + } 410 + 400 411 static irqreturn_t idxd_halt(struct idxd_device *idxd) 401 412 { 402 413 union gensts_reg gensts; ··· 426 415 } else if (gensts.reset_type == IDXD_DEVICE_RESET_FLR) { 427 416 idxd->state = IDXD_DEV_HALTED; 428 417 idxd_mask_error_interrupts(idxd); 418 + /* Flush all pending descriptors, and disable 419 + * interrupts, they will be re-enabled when FLR 420 + * concludes. 421 + */ 422 + idxd_wqs_flush_descs(idxd); 429 423 dev_dbg(&idxd->pdev->dev, 430 424 "idxd halted, doing FLR. After FLR, configs are restored\n"); 431 425 INIT_WORK(&idxd->work, idxd_device_flr);
+1 -1
drivers/dma/idxd/submit.c
··· 138 138 */ 139 139 list_for_each_entry_safe(d, t, &flist, list) { 140 140 list_del_init(&d->list); 141 - idxd_dma_complete_txd(found, IDXD_COMPLETE_ABORT, true, 141 + idxd_dma_complete_txd(d, IDXD_COMPLETE_ABORT, true, 142 142 NULL, NULL); 143 143 } 144 144 }
+1
drivers/dma/idxd/sysfs.c
··· 1836 1836 { 1837 1837 struct idxd_device *idxd = confdev_to_idxd(dev); 1838 1838 1839 + destroy_workqueue(idxd->wq); 1839 1840 kfree(idxd->groups); 1840 1841 bitmap_free(idxd->wq_enable_map); 1841 1842 kfree(idxd->wqs);
+37 -31
drivers/dma/sh/rz-dmac.c
··· 10 10 */ 11 11 12 12 #include <linux/bitfield.h> 13 + #include <linux/cleanup.h> 13 14 #include <linux/dma-mapping.h> 14 15 #include <linux/dmaengine.h> 15 16 #include <linux/interrupt.h> ··· 297 296 { 298 297 struct dma_chan *chan = &channel->vc.chan; 299 298 struct rz_dmac *dmac = to_rz_dmac(chan->device); 300 - unsigned long flags; 301 299 302 300 dev_dbg(dmac->dev, "%s channel %d\n", __func__, channel->index); 303 301 304 - local_irq_save(flags); 305 302 rz_dmac_ch_writel(channel, CHCTRL_DEFAULT, CHCTRL, 1); 306 - local_irq_restore(flags); 307 303 } 308 304 309 305 static void rz_dmac_set_dmars_register(struct rz_dmac *dmac, int nr, u32 dmars) ··· 445 447 if (!desc) 446 448 break; 447 449 450 + /* No need to lock. This is called only for the 1st client. */ 448 451 list_add_tail(&desc->node, &channel->ld_free); 449 452 channel->descs_allocated++; 450 453 } ··· 501 502 dev_dbg(dmac->dev, "%s channel: %d src=0x%pad dst=0x%pad len=%zu\n", 502 503 __func__, channel->index, &src, &dest, len); 503 504 504 - if (list_empty(&channel->ld_free)) 505 - return NULL; 505 + scoped_guard(spinlock_irqsave, &channel->vc.lock) { 506 + if (list_empty(&channel->ld_free)) 507 + return NULL; 506 508 507 - desc = list_first_entry(&channel->ld_free, struct rz_dmac_desc, node); 509 + desc = list_first_entry(&channel->ld_free, struct rz_dmac_desc, node); 508 510 509 - desc->type = RZ_DMAC_DESC_MEMCPY; 510 - desc->src = src; 511 - desc->dest = dest; 512 - desc->len = len; 513 - desc->direction = DMA_MEM_TO_MEM; 511 + desc->type = RZ_DMAC_DESC_MEMCPY; 512 + desc->src = src; 513 + desc->dest = dest; 514 + desc->len = len; 515 + desc->direction = DMA_MEM_TO_MEM; 514 516 515 - list_move_tail(channel->ld_free.next, &channel->ld_queue); 517 + list_move_tail(channel->ld_free.next, &channel->ld_queue); 518 + } 519 + 516 520 return vchan_tx_prep(&channel->vc, &desc->vd, flags); 517 521 } 518 522 ··· 531 529 int dma_length = 0; 532 530 int i = 0; 533 531 534 - if (list_empty(&channel->ld_free)) 535 - return NULL; 532 + scoped_guard(spinlock_irqsave, &channel->vc.lock) { 533 + if (list_empty(&channel->ld_free)) 534 + return NULL; 536 535 537 - desc = list_first_entry(&channel->ld_free, struct rz_dmac_desc, node); 536 + desc = list_first_entry(&channel->ld_free, struct rz_dmac_desc, node); 538 537 539 - for_each_sg(sgl, sg, sg_len, i) { 540 - dma_length += sg_dma_len(sg); 538 + for_each_sg(sgl, sg, sg_len, i) 539 + dma_length += sg_dma_len(sg); 540 + 541 + desc->type = RZ_DMAC_DESC_SLAVE_SG; 542 + desc->sg = sgl; 543 + desc->sgcount = sg_len; 544 + desc->len = dma_length; 545 + desc->direction = direction; 546 + 547 + if (direction == DMA_DEV_TO_MEM) 548 + desc->src = channel->src_per_address; 549 + else 550 + desc->dest = channel->dst_per_address; 551 + 552 + list_move_tail(channel->ld_free.next, &channel->ld_queue); 541 553 } 542 554 543 - desc->type = RZ_DMAC_DESC_SLAVE_SG; 544 - desc->sg = sgl; 545 - desc->sgcount = sg_len; 546 - desc->len = dma_length; 547 - desc->direction = direction; 548 - 549 - if (direction == DMA_DEV_TO_MEM) 550 - desc->src = channel->src_per_address; 551 - else 552 - desc->dest = channel->dst_per_address; 553 - 554 - list_move_tail(channel->ld_free.next, &channel->ld_queue); 555 555 return vchan_tx_prep(&channel->vc, &desc->vd, flags); 556 556 } 557 557 ··· 565 561 unsigned int i; 566 562 LIST_HEAD(head); 567 563 568 - rz_dmac_disable_hw(channel); 569 564 spin_lock_irqsave(&channel->vc.lock, flags); 565 + rz_dmac_disable_hw(channel); 570 566 for (i = 0; i < DMAC_NR_LMDESC; i++) 571 567 lmdesc[i].header = 0; 572 568 ··· 703 699 if (chstat & CHSTAT_ER) { 704 700 dev_err(dmac->dev, "DMAC err CHSTAT_%d = %08X\n", 705 701 channel->index, chstat); 706 - rz_dmac_ch_writel(channel, CHCTRL_DEFAULT, CHCTRL, 1); 702 + 703 + scoped_guard(spinlock_irqsave, &channel->vc.lock) 704 + rz_dmac_ch_writel(channel, CHCTRL_DEFAULT, CHCTRL, 1); 707 705 goto done; 708 706 } 709 707
+2 -2
drivers/dma/xilinx/xdma.c
··· 1234 1234 1235 1235 xdev->rmap = devm_regmap_init_mmio(&pdev->dev, reg_base, 1236 1236 &xdma_regmap_config); 1237 - if (!xdev->rmap) { 1238 - xdma_err(xdev, "config regmap failed: %d", ret); 1237 + if (IS_ERR(xdev->rmap)) { 1238 + xdma_err(xdev, "config regmap failed: %pe", xdev->rmap); 1239 1239 goto failed; 1240 1240 } 1241 1241 INIT_LIST_HEAD(&xdev->dma_dev.channels);
+30 -16
drivers/dma/xilinx/xilinx_dma.c
··· 997 997 struct xilinx_cdma_tx_segment, 998 998 node); 999 999 cdma_hw = &cdma_seg->hw; 1000 - residue += (cdma_hw->control - cdma_hw->status) & 1001 - chan->xdev->max_buffer_len; 1000 + residue += (cdma_hw->control & chan->xdev->max_buffer_len) - 1001 + (cdma_hw->status & chan->xdev->max_buffer_len); 1002 1002 } else if (chan->xdev->dma_config->dmatype == 1003 1003 XDMA_TYPE_AXIDMA) { 1004 1004 axidma_seg = list_entry(entry, 1005 1005 struct xilinx_axidma_tx_segment, 1006 1006 node); 1007 1007 axidma_hw = &axidma_seg->hw; 1008 - residue += (axidma_hw->control - axidma_hw->status) & 1009 - chan->xdev->max_buffer_len; 1008 + residue += (axidma_hw->control & chan->xdev->max_buffer_len) - 1009 + (axidma_hw->status & chan->xdev->max_buffer_len); 1010 1010 } else { 1011 1011 aximcdma_seg = 1012 1012 list_entry(entry, ··· 1014 1014 node); 1015 1015 aximcdma_hw = &aximcdma_seg->hw; 1016 1016 residue += 1017 - (aximcdma_hw->control - aximcdma_hw->status) & 1018 - chan->xdev->max_buffer_len; 1017 + (aximcdma_hw->control & chan->xdev->max_buffer_len) - 1018 + (aximcdma_hw->status & chan->xdev->max_buffer_len); 1019 1019 } 1020 1020 } 1021 1021 ··· 1234 1234 } 1235 1235 1236 1236 dma_cookie_init(dchan); 1237 - 1238 - if (chan->xdev->dma_config->dmatype == XDMA_TYPE_AXIDMA) { 1239 - /* For AXI DMA resetting once channel will reset the 1240 - * other channel as well so enable the interrupts here. 1241 - */ 1242 - dma_ctrl_set(chan, XILINX_DMA_REG_DMACR, 1243 - XILINX_DMA_DMAXR_ALL_IRQ_MASK); 1244 - } 1245 1237 1246 1238 if ((chan->xdev->dma_config->dmatype == XDMA_TYPE_CDMA) && chan->has_sg) 1247 1239 dma_ctrl_set(chan, XILINX_DMA_REG_DMACR, ··· 1556 1564 if (chan->err) 1557 1565 return; 1558 1566 1559 - if (list_empty(&chan->pending_list)) 1567 + if (list_empty(&chan->pending_list)) { 1568 + if (chan->cyclic) { 1569 + struct xilinx_dma_tx_descriptor *desc; 1570 + struct list_head *entry; 1571 + 1572 + desc = list_last_entry(&chan->done_list, 1573 + struct xilinx_dma_tx_descriptor, node); 1574 + list_for_each(entry, &desc->segments) { 1575 + struct xilinx_axidma_tx_segment *axidma_seg; 1576 + struct xilinx_axidma_desc_hw *axidma_hw; 1577 + axidma_seg = list_entry(entry, 1578 + struct xilinx_axidma_tx_segment, 1579 + node); 1580 + axidma_hw = &axidma_seg->hw; 1581 + axidma_hw->status = 0; 1582 + } 1583 + 1584 + list_splice_tail_init(&chan->done_list, &chan->active_list); 1585 + chan->desc_pendingcount = 0; 1586 + chan->idle = false; 1587 + } 1560 1588 return; 1589 + } 1561 1590 1562 1591 if (!chan->idle) 1563 1592 return; ··· 1604 1591 head_desc->async_tx.phys); 1605 1592 reg &= ~XILINX_DMA_CR_DELAY_MAX; 1606 1593 reg |= chan->irq_delay << XILINX_DMA_CR_DELAY_SHIFT; 1594 + reg |= XILINX_DMA_DMAXR_ALL_IRQ_MASK; 1607 1595 dma_ctrl_write(chan, XILINX_DMA_REG_DMACR, reg); 1608 1596 1609 1597 xilinx_dma_start(chan); ··· 3038 3024 return -EINVAL; 3039 3025 } 3040 3026 3041 - xdev->common.directions |= chan->direction; 3027 + xdev->common.directions |= BIT(chan->direction); 3042 3028 3043 3029 /* Request the interrupt */ 3044 3030 chan->irq = of_irq_get(node, chan->tdest);
+2 -2
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c
··· 692 692 goto err_ib_sched; 693 693 } 694 694 695 - /* Drop the initial kref_init count (see drm_sched_main as example) */ 696 - dma_fence_put(f); 697 695 ret = dma_fence_wait(f, false); 696 + /* Drop the returned fence reference after the wait completes */ 697 + dma_fence_put(f); 698 698 699 699 err_ib_sched: 700 700 amdgpu_job_free(job);
+11 -2
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
··· 4207 4207 4208 4208 static int amdgpu_device_get_job_timeout_settings(struct amdgpu_device *adev) 4209 4209 { 4210 - char *input = amdgpu_lockup_timeout; 4210 + char buf[AMDGPU_MAX_TIMEOUT_PARAM_LENGTH]; 4211 + char *input = buf; 4211 4212 char *timeout_setting = NULL; 4212 4213 int index = 0; 4213 4214 long timeout; ··· 4218 4217 adev->gfx_timeout = adev->compute_timeout = adev->sdma_timeout = 4219 4218 adev->video_timeout = msecs_to_jiffies(2000); 4220 4219 4221 - if (!strnlen(input, AMDGPU_MAX_TIMEOUT_PARAM_LENGTH)) 4220 + if (!strnlen(amdgpu_lockup_timeout, AMDGPU_MAX_TIMEOUT_PARAM_LENGTH)) 4222 4221 return 0; 4222 + 4223 + /* 4224 + * strsep() destructively modifies its input by replacing delimiters 4225 + * with '\0'. Use a stack copy so the global module parameter buffer 4226 + * remains intact for multi-GPU systems where this function is called 4227 + * once per device. 4228 + */ 4229 + strscpy(buf, amdgpu_lockup_timeout, sizeof(buf)); 4223 4230 4224 4231 while ((timeout_setting = strsep(&input, ",")) && 4225 4232 strnlen(timeout_setting, AMDGPU_MAX_TIMEOUT_PARAM_LENGTH)) {
+32 -13
drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c
··· 35 35 * PASIDs are global address space identifiers that can be shared 36 36 * between the GPU, an IOMMU and the driver. VMs on different devices 37 37 * may use the same PASID if they share the same address 38 - * space. Therefore PASIDs are allocated using a global IDA. VMs are 39 - * looked up from the PASID per amdgpu_device. 38 + * space. Therefore PASIDs are allocated using IDR cyclic allocator 39 + * (similar to kernel PID allocation) which naturally delays reuse. 40 + * VMs are looked up from the PASID per amdgpu_device. 40 41 */ 41 - static DEFINE_IDA(amdgpu_pasid_ida); 42 + 43 + static DEFINE_IDR(amdgpu_pasid_idr); 44 + static DEFINE_SPINLOCK(amdgpu_pasid_idr_lock); 42 45 43 46 /* Helper to free pasid from a fence callback */ 44 47 struct amdgpu_pasid_cb { ··· 53 50 * amdgpu_pasid_alloc - Allocate a PASID 54 51 * @bits: Maximum width of the PASID in bits, must be at least 1 55 52 * 56 - * Allocates a PASID of the given width while keeping smaller PASIDs 57 - * available if possible. 53 + * Uses kernel's IDR cyclic allocator (same as PID allocation). 54 + * Allocates sequentially with automatic wrap-around. 58 55 * 59 56 * Returns a positive integer on success. Returns %-EINVAL if bits==0. 60 57 * Returns %-ENOSPC if no PASID was available. Returns %-ENOMEM on ··· 62 59 */ 63 60 int amdgpu_pasid_alloc(unsigned int bits) 64 61 { 65 - int pasid = -EINVAL; 62 + int pasid; 66 63 67 - for (bits = min(bits, 31U); bits > 0; bits--) { 68 - pasid = ida_alloc_range(&amdgpu_pasid_ida, 1U << (bits - 1), 69 - (1U << bits) - 1, GFP_KERNEL); 70 - if (pasid != -ENOSPC) 71 - break; 72 - } 64 + if (bits == 0) 65 + return -EINVAL; 66 + 67 + spin_lock(&amdgpu_pasid_idr_lock); 68 + pasid = idr_alloc_cyclic(&amdgpu_pasid_idr, NULL, 1, 69 + 1U << bits, GFP_KERNEL); 70 + spin_unlock(&amdgpu_pasid_idr_lock); 73 71 74 72 if (pasid >= 0) 75 73 trace_amdgpu_pasid_allocated(pasid); ··· 85 81 void amdgpu_pasid_free(u32 pasid) 86 82 { 87 83 trace_amdgpu_pasid_freed(pasid); 88 - ida_free(&amdgpu_pasid_ida, pasid); 84 + 85 + spin_lock(&amdgpu_pasid_idr_lock); 86 + idr_remove(&amdgpu_pasid_idr, pasid); 87 + spin_unlock(&amdgpu_pasid_idr_lock); 89 88 } 90 89 91 90 static void amdgpu_pasid_free_cb(struct dma_fence *fence, ··· 622 615 dma_fence_put(id->pasid_mapping); 623 616 } 624 617 } 618 + } 619 + 620 + /** 621 + * amdgpu_pasid_mgr_cleanup - cleanup PASID manager 622 + * 623 + * Cleanup the IDR allocator. 624 + */ 625 + void amdgpu_pasid_mgr_cleanup(void) 626 + { 627 + spin_lock(&amdgpu_pasid_idr_lock); 628 + idr_destroy(&amdgpu_pasid_idr); 629 + spin_unlock(&amdgpu_pasid_idr_lock); 625 630 }
+1
drivers/gpu/drm/amd/amdgpu/amdgpu_ids.h
··· 74 74 void amdgpu_pasid_free(u32 pasid); 75 75 void amdgpu_pasid_free_delayed(struct dma_resv *resv, 76 76 u32 pasid); 77 + void amdgpu_pasid_mgr_cleanup(void); 77 78 78 79 bool amdgpu_vmid_had_gpu_reset(struct amdgpu_device *adev, 79 80 struct amdgpu_vmid *id);
+4 -3
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
··· 2898 2898 xa_destroy(&adev->vm_manager.pasids); 2899 2899 2900 2900 amdgpu_vmid_mgr_fini(adev); 2901 + amdgpu_pasid_mgr_cleanup(); 2901 2902 } 2902 2903 2903 2904 /** ··· 2974 2973 if (!root) 2975 2974 return false; 2976 2975 2977 - addr /= AMDGPU_GPU_PAGE_SIZE; 2978 - 2979 2976 if (is_compute_context && !svm_range_restore_pages(adev, pasid, vmid, 2980 - node_id, addr, ts, write_fault)) { 2977 + node_id, addr >> PAGE_SHIFT, ts, write_fault)) { 2981 2978 amdgpu_bo_unref(&root); 2982 2979 return true; 2983 2980 } 2981 + 2982 + addr /= AMDGPU_GPU_PAGE_SIZE; 2984 2983 2985 2984 r = amdgpu_bo_reserve(root, true); 2986 2985 if (r)
+3 -3
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
··· 3170 3170 struct kfd_process *process; 3171 3171 int ret; 3172 3172 3173 - /* Each FD owns only one kfd_process */ 3174 - if (p->context_id != KFD_CONTEXT_ID_PRIMARY) 3173 + if (!filep->private_data || !p) 3175 3174 return -EINVAL; 3176 3175 3177 - if (!filep->private_data || !p) 3176 + /* Each FD owns only one kfd_process */ 3177 + if (p->context_id != KFD_CONTEXT_ID_PRIMARY) 3178 3178 return -EINVAL; 3179 3179 3180 3180 mutex_lock(&kfd_processes_mutex);
+8 -2
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
··· 3909 3909 3910 3910 aconnector->dc_sink = sink; 3911 3911 dc_sink_retain(aconnector->dc_sink); 3912 + drm_edid_free(aconnector->drm_edid); 3913 + aconnector->drm_edid = NULL; 3912 3914 if (sink->dc_edid.length == 0) { 3913 - aconnector->drm_edid = NULL; 3914 3915 hdmi_cec_unset_edid(aconnector); 3915 3916 if (aconnector->dc_link->aux_mode) { 3916 3917 drm_dp_cec_unset_edid(&aconnector->dm_dp_aux.aux); ··· 5423 5422 caps = &dm->backlight_caps[aconnector->bl_idx]; 5424 5423 5425 5424 /* Only offer ABM property when non-OLED and user didn't turn off by module parameter */ 5426 - if (!caps->ext_caps->bits.oled && amdgpu_dm_abm_level < 0) 5425 + if (caps->ext_caps && !caps->ext_caps->bits.oled && amdgpu_dm_abm_level < 0) 5427 5426 drm_object_attach_property(&aconnector->base.base, 5428 5427 dm->adev->mode_info.abm_level_property, 5429 5428 ABM_SYSFS_CONTROL); ··· 12524 12523 } 12525 12524 12526 12525 if (dc_resource_is_dsc_encoding_supported(dc)) { 12526 + for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) { 12527 + dm_new_crtc_state = to_dm_crtc_state(new_crtc_state); 12528 + dm_new_crtc_state->mode_changed_independent_from_dsc = new_crtc_state->mode_changed; 12529 + } 12530 + 12527 12531 for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) { 12528 12532 if (drm_atomic_crtc_needs_modeset(new_crtc_state)) { 12529 12533 ret = add_affected_mst_dsc_crtcs(state, crtc);
+1
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h
··· 984 984 985 985 bool freesync_vrr_info_changed; 986 986 987 + bool mode_changed_independent_from_dsc; 987 988 bool dsc_force_changed; 988 989 bool vrr_supported; 989 990 struct mod_freesync_config freesync_config;
+3 -1
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c
··· 1744 1744 int ind = find_crtc_index_in_state_by_stream(state, stream); 1745 1745 1746 1746 if (ind >= 0) { 1747 + struct dm_crtc_state *dm_new_crtc_state = to_dm_crtc_state(state->crtcs[ind].new_state); 1748 + 1747 1749 DRM_INFO_ONCE("%s:%d MST_DSC no mode changed for stream 0x%p\n", 1748 1750 __func__, __LINE__, stream); 1749 - state->crtcs[ind].new_state->mode_changed = 0; 1751 + dm_new_crtc_state->base.mode_changed = dm_new_crtc_state->mode_changed_independent_from_dsc; 1750 1752 } 1751 1753 } 1752 1754 }
+2 -4
drivers/gpu/drm/amd/display/dc/resource/dce100/dce100_resource.c
··· 650 650 return &enc110->base; 651 651 } 652 652 653 - if (enc_init_data->hpd_source >= ARRAY_SIZE(link_enc_hpd_regs)) 654 - return NULL; 655 - 656 653 link_regs_id = 657 654 map_transmitter_id_to_phy_instance(enc_init_data->transmitter); 658 655 ··· 658 661 &link_enc_feature, 659 662 &link_enc_regs[link_regs_id], 660 663 &link_enc_aux_regs[enc_init_data->channel - 1], 661 - &link_enc_hpd_regs[enc_init_data->hpd_source]); 664 + enc_init_data->hpd_source >= ARRAY_SIZE(link_enc_hpd_regs) ? 665 + NULL : &link_enc_hpd_regs[enc_init_data->hpd_source]); 662 666 return &enc110->base; 663 667 } 664 668
+3 -2
drivers/gpu/drm/amd/display/dc/resource/dce110/dce110_resource.c
··· 671 671 kzalloc_obj(struct dce110_link_encoder); 672 672 int link_regs_id; 673 673 674 - if (!enc110 || enc_init_data->hpd_source >= ARRAY_SIZE(link_enc_hpd_regs)) 674 + if (!enc110) 675 675 return NULL; 676 676 677 677 link_regs_id = ··· 682 682 &link_enc_feature, 683 683 &link_enc_regs[link_regs_id], 684 684 &link_enc_aux_regs[enc_init_data->channel - 1], 685 - &link_enc_hpd_regs[enc_init_data->hpd_source]); 685 + enc_init_data->hpd_source >= ARRAY_SIZE(link_enc_hpd_regs) ? 686 + NULL : &link_enc_hpd_regs[enc_init_data->hpd_source]); 686 687 return &enc110->base; 687 688 } 688 689
+3 -2
drivers/gpu/drm/amd/display/dc/resource/dce112/dce112_resource.c
··· 632 632 kzalloc_obj(struct dce110_link_encoder); 633 633 int link_regs_id; 634 634 635 - if (!enc110 || enc_init_data->hpd_source >= ARRAY_SIZE(link_enc_hpd_regs)) 635 + if (!enc110) 636 636 return NULL; 637 637 638 638 link_regs_id = ··· 643 643 &link_enc_feature, 644 644 &link_enc_regs[link_regs_id], 645 645 &link_enc_aux_regs[enc_init_data->channel - 1], 646 - &link_enc_hpd_regs[enc_init_data->hpd_source]); 646 + enc_init_data->hpd_source >= ARRAY_SIZE(link_enc_hpd_regs) ? 647 + NULL : &link_enc_hpd_regs[enc_init_data->hpd_source]); 647 648 return &enc110->base; 648 649 } 649 650
+3 -2
drivers/gpu/drm/amd/display/dc/resource/dce120/dce120_resource.c
··· 716 716 kzalloc_obj(struct dce110_link_encoder); 717 717 int link_regs_id; 718 718 719 - if (!enc110 || enc_init_data->hpd_source >= ARRAY_SIZE(link_enc_hpd_regs)) 719 + if (!enc110) 720 720 return NULL; 721 721 722 722 link_regs_id = ··· 727 727 &link_enc_feature, 728 728 &link_enc_regs[link_regs_id], 729 729 &link_enc_aux_regs[enc_init_data->channel - 1], 730 - &link_enc_hpd_regs[enc_init_data->hpd_source]); 730 + enc_init_data->hpd_source >= ARRAY_SIZE(link_enc_hpd_regs) ? 731 + NULL : &link_enc_hpd_regs[enc_init_data->hpd_source]); 731 732 732 733 return &enc110->base; 733 734 }
+6 -8
drivers/gpu/drm/amd/display/dc/resource/dce60/dce60_resource.c
··· 746 746 return &enc110->base; 747 747 } 748 748 749 - if (enc_init_data->hpd_source >= ARRAY_SIZE(link_enc_hpd_regs)) 750 - return NULL; 751 - 752 749 link_regs_id = 753 750 map_transmitter_id_to_phy_instance(enc_init_data->transmitter); 754 751 755 752 dce60_link_encoder_construct(enc110, 756 - enc_init_data, 757 - &link_enc_feature, 758 - &link_enc_regs[link_regs_id], 759 - &link_enc_aux_regs[enc_init_data->channel - 1], 760 - &link_enc_hpd_regs[enc_init_data->hpd_source]); 753 + enc_init_data, 754 + &link_enc_feature, 755 + &link_enc_regs[link_regs_id], 756 + &link_enc_aux_regs[enc_init_data->channel - 1], 757 + enc_init_data->hpd_source >= ARRAY_SIZE(link_enc_hpd_regs) ? 758 + NULL : &link_enc_hpd_regs[enc_init_data->hpd_source]); 761 759 return &enc110->base; 762 760 } 763 761
+2 -4
drivers/gpu/drm/amd/display/dc/resource/dce80/dce80_resource.c
··· 752 752 return &enc110->base; 753 753 } 754 754 755 - if (enc_init_data->hpd_source >= ARRAY_SIZE(link_enc_hpd_regs)) 756 - return NULL; 757 - 758 755 link_regs_id = 759 756 map_transmitter_id_to_phy_instance(enc_init_data->transmitter); 760 757 ··· 760 763 &link_enc_feature, 761 764 &link_enc_regs[link_regs_id], 762 765 &link_enc_aux_regs[enc_init_data->channel - 1], 763 - &link_enc_hpd_regs[enc_init_data->hpd_source]); 766 + enc_init_data->hpd_source >= ARRAY_SIZE(link_enc_hpd_regs) ? 767 + NULL : &link_enc_hpd_regs[enc_init_data->hpd_source]); 764 768 return &enc110->base; 765 769 } 766 770
+32 -1
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c
··· 59 59 60 60 #define to_amdgpu_device(x) (container_of(x, struct amdgpu_device, pm.smu_i2c)) 61 61 62 + static void smu_v13_0_0_get_od_setting_limits(struct smu_context *smu, 63 + int od_feature_bit, 64 + int32_t *min, int32_t *max); 65 + 62 66 static const struct smu_feature_bits smu_v13_0_0_dpm_features = { 63 67 .bits = { 64 68 SMU_FEATURE_BIT_INIT(FEATURE_DPM_GFXCLK_BIT), ··· 1047 1043 PPTable_t *pptable = smu->smu_table.driver_pptable; 1048 1044 const OverDriveLimits_t * const overdrive_upperlimits = 1049 1045 &pptable->SkuTable.OverDriveLimitsBasicMax; 1046 + int32_t min_value, max_value; 1047 + bool feature_enabled; 1050 1048 1051 - return overdrive_upperlimits->FeatureCtrlMask & (1U << od_feature_bit); 1049 + switch (od_feature_bit) { 1050 + case PP_OD_FEATURE_FAN_CURVE_BIT: 1051 + feature_enabled = !!(overdrive_upperlimits->FeatureCtrlMask & (1U << od_feature_bit)); 1052 + if (feature_enabled) { 1053 + smu_v13_0_0_get_od_setting_limits(smu, PP_OD_FEATURE_FAN_CURVE_TEMP, 1054 + &min_value, &max_value); 1055 + if (!min_value && !max_value) { 1056 + feature_enabled = false; 1057 + goto out; 1058 + } 1059 + 1060 + smu_v13_0_0_get_od_setting_limits(smu, PP_OD_FEATURE_FAN_CURVE_PWM, 1061 + &min_value, &max_value); 1062 + if (!min_value && !max_value) { 1063 + feature_enabled = false; 1064 + goto out; 1065 + } 1066 + } 1067 + break; 1068 + default: 1069 + feature_enabled = !!(overdrive_upperlimits->FeatureCtrlMask & (1U << od_feature_bit)); 1070 + break; 1071 + } 1072 + 1073 + out: 1074 + return feature_enabled; 1052 1075 } 1053 1076 1054 1077 static void smu_v13_0_0_get_od_setting_limits(struct smu_context *smu,
+12 -9
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c
··· 1391 1391 break; 1392 1392 case SMU_OD_MCLK: 1393 1393 if (!smu_v13_0_6_cap_supported(smu, SMU_CAP(SET_UCLK_MAX))) 1394 - return 0; 1394 + return -EOPNOTSUPP; 1395 1395 1396 1396 size += sysfs_emit_at(buf, size, "%s:\n", "OD_MCLK"); 1397 1397 size += sysfs_emit_at(buf, size, "0: %uMhz\n1: %uMhz\n", ··· 2122 2122 { 2123 2123 struct smu_dpm_context *smu_dpm = &(smu->smu_dpm); 2124 2124 struct smu_13_0_dpm_context *dpm_context = smu_dpm->dpm_context; 2125 + struct smu_dpm_table *uclk_table = &dpm_context->dpm_tables.uclk_table; 2125 2126 struct smu_umd_pstate_table *pstate_table = &smu->pstate_table; 2126 2127 uint32_t min_clk; 2127 2128 uint32_t max_clk; ··· 2222 2221 if (ret) 2223 2222 return ret; 2224 2223 2225 - min_clk = SMU_DPM_TABLE_MIN( 2226 - &dpm_context->dpm_tables.uclk_table); 2227 - max_clk = SMU_DPM_TABLE_MAX( 2228 - &dpm_context->dpm_tables.uclk_table); 2229 - ret = smu_v13_0_6_set_soft_freq_limited_range( 2230 - smu, SMU_UCLK, min_clk, max_clk, false); 2231 - if (ret) 2232 - return ret; 2224 + if (SMU_DPM_TABLE_MAX(uclk_table) != 2225 + pstate_table->uclk_pstate.curr.max) { 2226 + min_clk = SMU_DPM_TABLE_MIN(&dpm_context->dpm_tables.uclk_table); 2227 + max_clk = SMU_DPM_TABLE_MAX(&dpm_context->dpm_tables.uclk_table); 2228 + ret = smu_v13_0_6_set_soft_freq_limited_range(smu, 2229 + SMU_UCLK, min_clk, 2230 + max_clk, false); 2231 + if (ret) 2232 + return ret; 2233 + } 2233 2234 smu_v13_0_reset_custom_level(smu); 2234 2235 } 2235 2236 break;
+32 -1
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c
··· 59 59 60 60 #define to_amdgpu_device(x) (container_of(x, struct amdgpu_device, pm.smu_i2c)) 61 61 62 + static void smu_v13_0_7_get_od_setting_limits(struct smu_context *smu, 63 + int od_feature_bit, 64 + int32_t *min, int32_t *max); 65 + 62 66 static const struct smu_feature_bits smu_v13_0_7_dpm_features = { 63 67 .bits = { 64 68 SMU_FEATURE_BIT_INIT(FEATURE_DPM_GFXCLK_BIT), ··· 1057 1053 PPTable_t *pptable = smu->smu_table.driver_pptable; 1058 1054 const OverDriveLimits_t * const overdrive_upperlimits = 1059 1055 &pptable->SkuTable.OverDriveLimitsBasicMax; 1056 + int32_t min_value, max_value; 1057 + bool feature_enabled; 1060 1058 1061 - return overdrive_upperlimits->FeatureCtrlMask & (1U << od_feature_bit); 1059 + switch (od_feature_bit) { 1060 + case PP_OD_FEATURE_FAN_CURVE_BIT: 1061 + feature_enabled = !!(overdrive_upperlimits->FeatureCtrlMask & (1U << od_feature_bit)); 1062 + if (feature_enabled) { 1063 + smu_v13_0_7_get_od_setting_limits(smu, PP_OD_FEATURE_FAN_CURVE_TEMP, 1064 + &min_value, &max_value); 1065 + if (!min_value && !max_value) { 1066 + feature_enabled = false; 1067 + goto out; 1068 + } 1069 + 1070 + smu_v13_0_7_get_od_setting_limits(smu, PP_OD_FEATURE_FAN_CURVE_PWM, 1071 + &min_value, &max_value); 1072 + if (!min_value && !max_value) { 1073 + feature_enabled = false; 1074 + goto out; 1075 + } 1076 + } 1077 + break; 1078 + default: 1079 + feature_enabled = !!(overdrive_upperlimits->FeatureCtrlMask & (1U << od_feature_bit)); 1080 + break; 1081 + } 1082 + 1083 + out: 1084 + return feature_enabled; 1062 1085 } 1063 1086 1064 1087 static void smu_v13_0_7_get_od_setting_limits(struct smu_context *smu,
+32 -1
drivers/gpu/drm/amd/pm/swsmu/smu14/smu_v14_0_2_ppt.c
··· 56 56 57 57 #define to_amdgpu_device(x) (container_of(x, struct amdgpu_device, pm.smu_i2c)) 58 58 59 + static void smu_v14_0_2_get_od_setting_limits(struct smu_context *smu, 60 + int od_feature_bit, 61 + int32_t *min, int32_t *max); 62 + 59 63 static const struct smu_feature_bits smu_v14_0_2_dpm_features = { 60 64 .bits = { SMU_FEATURE_BIT_INIT(FEATURE_DPM_GFXCLK_BIT), 61 65 SMU_FEATURE_BIT_INIT(FEATURE_DPM_UCLK_BIT), ··· 926 922 PPTable_t *pptable = smu->smu_table.driver_pptable; 927 923 const OverDriveLimits_t * const overdrive_upperlimits = 928 924 &pptable->SkuTable.OverDriveLimitsBasicMax; 925 + int32_t min_value, max_value; 926 + bool feature_enabled; 929 927 930 - return overdrive_upperlimits->FeatureCtrlMask & (1U << od_feature_bit); 928 + switch (od_feature_bit) { 929 + case PP_OD_FEATURE_FAN_CURVE_BIT: 930 + feature_enabled = !!(overdrive_upperlimits->FeatureCtrlMask & (1U << od_feature_bit)); 931 + if (feature_enabled) { 932 + smu_v14_0_2_get_od_setting_limits(smu, PP_OD_FEATURE_FAN_CURVE_TEMP, 933 + &min_value, &max_value); 934 + if (!min_value && !max_value) { 935 + feature_enabled = false; 936 + goto out; 937 + } 938 + 939 + smu_v14_0_2_get_od_setting_limits(smu, PP_OD_FEATURE_FAN_CURVE_PWM, 940 + &min_value, &max_value); 941 + if (!min_value && !max_value) { 942 + feature_enabled = false; 943 + goto out; 944 + } 945 + } 946 + break; 947 + default: 948 + feature_enabled = !!(overdrive_upperlimits->FeatureCtrlMask & (1U << od_feature_bit)); 949 + break; 950 + } 951 + 952 + out: 953 + return feature_enabled; 931 954 } 932 955 933 956 static void smu_v14_0_2_get_od_setting_limits(struct smu_context *smu,
+27 -21
drivers/gpu/drm/drm_gem_shmem_helper.c
··· 550 550 } 551 551 EXPORT_SYMBOL_GPL(drm_gem_shmem_dumb_create); 552 552 553 - static bool drm_gem_shmem_try_map_pmd(struct vm_fault *vmf, unsigned long addr, 554 - struct page *page) 553 + static vm_fault_t try_insert_pfn(struct vm_fault *vmf, unsigned int order, 554 + unsigned long pfn) 555 555 { 556 + if (!order) { 557 + return vmf_insert_pfn(vmf->vma, vmf->address, pfn); 556 558 #ifdef CONFIG_ARCH_SUPPORTS_PMD_PFNMAP 557 - unsigned long pfn = page_to_pfn(page); 558 - unsigned long paddr = pfn << PAGE_SHIFT; 559 - bool aligned = (addr & ~PMD_MASK) == (paddr & ~PMD_MASK); 559 + } else if (order == PMD_ORDER) { 560 + unsigned long paddr = pfn << PAGE_SHIFT; 561 + bool aligned = (vmf->address & ~PMD_MASK) == (paddr & ~PMD_MASK); 560 562 561 - if (aligned && 562 - pmd_none(*vmf->pmd) && 563 - folio_test_pmd_mappable(page_folio(page))) { 564 - pfn &= PMD_MASK >> PAGE_SHIFT; 565 - if (vmf_insert_pfn_pmd(vmf, pfn, false) == VM_FAULT_NOPAGE) 566 - return true; 567 - } 563 + if (aligned && 564 + folio_test_pmd_mappable(page_folio(pfn_to_page(pfn)))) { 565 + pfn &= PMD_MASK >> PAGE_SHIFT; 566 + return vmf_insert_pfn_pmd(vmf, pfn, false); 567 + } 568 568 #endif 569 - 570 - return false; 569 + } 570 + return VM_FAULT_FALLBACK; 571 571 } 572 572 573 - static vm_fault_t drm_gem_shmem_fault(struct vm_fault *vmf) 573 + static vm_fault_t drm_gem_shmem_any_fault(struct vm_fault *vmf, unsigned int order) 574 574 { 575 575 struct vm_area_struct *vma = vmf->vma; 576 576 struct drm_gem_object *obj = vma->vm_private_data; ··· 580 580 struct page **pages = shmem->pages; 581 581 pgoff_t page_offset; 582 582 unsigned long pfn; 583 + 584 + if (order && order != PMD_ORDER) 585 + return VM_FAULT_FALLBACK; 583 586 584 587 /* Offset to faulty address in the VMA. */ 585 588 page_offset = vmf->pgoff - vma->vm_pgoff; ··· 596 593 goto out; 597 594 } 598 595 599 - if (drm_gem_shmem_try_map_pmd(vmf, vmf->address, pages[page_offset])) { 600 - ret = VM_FAULT_NOPAGE; 601 - goto out; 602 - } 603 - 604 596 pfn = page_to_pfn(pages[page_offset]); 605 - ret = vmf_insert_pfn(vma, vmf->address, pfn); 597 + ret = try_insert_pfn(vmf, order, pfn); 606 598 607 599 out: 608 600 dma_resv_unlock(shmem->base.resv); 609 601 610 602 return ret; 603 + } 604 + 605 + static vm_fault_t drm_gem_shmem_fault(struct vm_fault *vmf) 606 + { 607 + return drm_gem_shmem_any_fault(vmf, 0); 611 608 } 612 609 613 610 static void drm_gem_shmem_vm_open(struct vm_area_struct *vma) ··· 646 643 647 644 const struct vm_operations_struct drm_gem_shmem_vm_ops = { 648 645 .fault = drm_gem_shmem_fault, 646 + #ifdef CONFIG_ARCH_SUPPORTS_PMD_PFNMAP 647 + .huge_fault = drm_gem_shmem_any_fault, 648 + #endif 649 649 .open = drm_gem_shmem_vm_open, 650 650 .close = drm_gem_shmem_vm_close, 651 651 };
+2 -2
drivers/gpu/drm/drm_syncobj.c
··· 602 602 drm_syncobj_get(syncobj); 603 603 604 604 ret = xa_alloc(&file_private->syncobj_xa, handle, syncobj, xa_limit_32b, 605 - GFP_NOWAIT); 605 + GFP_KERNEL); 606 606 if (ret) 607 607 drm_syncobj_put(syncobj); 608 608 ··· 716 716 drm_syncobj_get(syncobj); 717 717 718 718 ret = xa_alloc(&file_private->syncobj_xa, handle, syncobj, xa_limit_32b, 719 - GFP_NOWAIT); 719 + GFP_KERNEL); 720 720 if (ret) 721 721 drm_syncobj_put(syncobj); 722 722
+7 -1
drivers/gpu/drm/i915/display/intel_display.c
··· 4602 4602 struct intel_crtc_state *crtc_state = 4603 4603 intel_atomic_get_new_crtc_state(state, crtc); 4604 4604 struct intel_crtc_state *saved_state; 4605 + int err; 4605 4606 4606 4607 saved_state = intel_crtc_state_alloc(crtc); 4607 4608 if (!saved_state) ··· 4611 4610 /* free the old crtc_state->hw members */ 4612 4611 intel_crtc_free_hw_state(crtc_state); 4613 4612 4614 - intel_dp_tunnel_atomic_clear_stream_bw(state, crtc_state); 4613 + err = intel_dp_tunnel_atomic_clear_stream_bw(state, crtc_state); 4614 + if (err) { 4615 + kfree(saved_state); 4616 + 4617 + return err; 4618 + } 4615 4619 4616 4620 /* FIXME: before the switch to atomic started, a new pipe_config was 4617 4621 * kzalloc'd. Code that depends on any field being zero should be
+14 -6
drivers/gpu/drm/i915/display/intel_dp_tunnel.c
··· 621 621 * 622 622 * Clear any DP tunnel stream BW requirement set by 623 623 * intel_dp_tunnel_atomic_compute_stream_bw(). 624 + * 625 + * Returns 0 in case of success, a negative error code otherwise. 624 626 */ 625 - void intel_dp_tunnel_atomic_clear_stream_bw(struct intel_atomic_state *state, 626 - struct intel_crtc_state *crtc_state) 627 + int intel_dp_tunnel_atomic_clear_stream_bw(struct intel_atomic_state *state, 628 + struct intel_crtc_state *crtc_state) 627 629 { 628 630 struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc); 631 + int err; 629 632 630 633 if (!crtc_state->dp_tunnel_ref.tunnel) 631 - return; 634 + return 0; 632 635 633 - drm_dp_tunnel_atomic_set_stream_bw(&state->base, 634 - crtc_state->dp_tunnel_ref.tunnel, 635 - crtc->pipe, 0); 636 + err = drm_dp_tunnel_atomic_set_stream_bw(&state->base, 637 + crtc_state->dp_tunnel_ref.tunnel, 638 + crtc->pipe, 0); 639 + if (err) 640 + return err; 641 + 636 642 drm_dp_tunnel_ref_put(&crtc_state->dp_tunnel_ref); 643 + 644 + return 0; 637 645 } 638 646 639 647 /**
+7 -4
drivers/gpu/drm/i915/display/intel_dp_tunnel.h
··· 40 40 struct intel_dp *intel_dp, 41 41 const struct intel_connector *connector, 42 42 struct intel_crtc_state *crtc_state); 43 - void intel_dp_tunnel_atomic_clear_stream_bw(struct intel_atomic_state *state, 44 - struct intel_crtc_state *crtc_state); 43 + int intel_dp_tunnel_atomic_clear_stream_bw(struct intel_atomic_state *state, 44 + struct intel_crtc_state *crtc_state); 45 45 46 46 int intel_dp_tunnel_atomic_add_state_for_crtc(struct intel_atomic_state *state, 47 47 struct intel_crtc *crtc); ··· 88 88 return 0; 89 89 } 90 90 91 - static inline void 91 + static inline int 92 92 intel_dp_tunnel_atomic_clear_stream_bw(struct intel_atomic_state *state, 93 - struct intel_crtc_state *crtc_state) {} 93 + struct intel_crtc_state *crtc_state) 94 + { 95 + return 0; 96 + } 94 97 95 98 static inline int 96 99 intel_dp_tunnel_atomic_add_state_for_crtc(struct intel_atomic_state *state,
+3 -1
drivers/gpu/drm/i915/display/intel_gmbus.c
··· 496 496 497 497 val = intel_de_read_fw(display, GMBUS3(display)); 498 498 do { 499 - if (extra_byte_added && len == 1) 499 + if (extra_byte_added && len == 1) { 500 + len--; 500 501 break; 502 + } 501 503 502 504 *buf++ = val & 0xff; 503 505 val >>= 8;
+9 -2
drivers/gpu/drm/i915/display/intel_plane.c
··· 436 436 drm_framebuffer_get(plane_state->hw.fb); 437 437 } 438 438 439 + static void unlink_nv12_plane(struct intel_crtc_state *crtc_state, 440 + struct intel_plane_state *plane_state); 441 + 439 442 void intel_plane_set_invisible(struct intel_crtc_state *crtc_state, 440 443 struct intel_plane_state *plane_state) 441 444 { 442 445 struct intel_plane *plane = to_intel_plane(plane_state->uapi.plane); 446 + 447 + unlink_nv12_plane(crtc_state, plane_state); 443 448 444 449 crtc_state->active_planes &= ~BIT(plane->id); 445 450 crtc_state->scaled_planes &= ~BIT(plane->id); ··· 1518 1513 struct intel_display *display = to_intel_display(plane_state); 1519 1514 struct intel_plane *plane = to_intel_plane(plane_state->uapi.plane); 1520 1515 1516 + if (!plane_state->planar_linked_plane) 1517 + return; 1518 + 1521 1519 plane_state->planar_linked_plane = NULL; 1522 1520 1523 1521 if (!plane_state->is_y_plane) ··· 1558 1550 if (plane->pipe != crtc->pipe) 1559 1551 continue; 1560 1552 1561 - if (plane_state->planar_linked_plane) 1562 - unlink_nv12_plane(crtc_state, plane_state); 1553 + unlink_nv12_plane(crtc_state, plane_state); 1563 1554 } 1564 1555 1565 1556 if (!crtc_state->nv12_planes)
+1 -1
drivers/gpu/drm/i915/i915_wait_util.h
··· 25 25 might_sleep(); \ 26 26 for (;;) { \ 27 27 const bool expired__ = ktime_after(ktime_get_raw(), end__); \ 28 - OP; \ 29 28 /* Guarantee COND check prior to timeout */ \ 30 29 barrier(); \ 30 + OP; \ 31 31 if (COND) { \ 32 32 ret__ = 0; \ 33 33 break; \
+5 -4
drivers/gpu/drm/mediatek/mtk_dsi.c
··· 1236 1236 1237 1237 dsi->host.ops = &mtk_dsi_ops; 1238 1238 dsi->host.dev = dev; 1239 + 1240 + init_waitqueue_head(&dsi->irq_wait_queue); 1241 + 1242 + platform_set_drvdata(pdev, dsi); 1243 + 1239 1244 ret = mipi_dsi_host_register(&dsi->host); 1240 1245 if (ret < 0) 1241 1246 return dev_err_probe(dev, ret, "Failed to register DSI host\n"); ··· 1251 1246 mipi_dsi_host_unregister(&dsi->host); 1252 1247 return dev_err_probe(&pdev->dev, ret, "Failed to request DSI irq\n"); 1253 1248 } 1254 - 1255 - init_waitqueue_head(&dsi->irq_wait_queue); 1256 - 1257 - platform_set_drvdata(pdev, dsi); 1258 1249 1259 1250 dsi->bridge.of_node = dev->of_node; 1260 1251 dsi->bridge.type = DRM_MODE_CONNECTOR_DSI;
+1
drivers/gpu/drm/xe/regs/xe_gt_regs.h
··· 553 553 #define ENABLE_SMP_LD_RENDER_SURFACE_CONTROL REG_BIT(44 - 32) 554 554 #define FORCE_SLM_FENCE_SCOPE_TO_TILE REG_BIT(42 - 32) 555 555 #define FORCE_UGM_FENCE_SCOPE_TO_TILE REG_BIT(41 - 32) 556 + #define L3_128B_256B_WRT_DIS REG_BIT(40 - 32) 556 557 #define MAXREQS_PER_BANK REG_GENMASK(39 - 32, 37 - 32) 557 558 #define DISABLE_128B_EVICTION_COMMAND_UDW REG_BIT(36 - 32) 558 559
+6 -6
drivers/gpu/drm/xe/xe_pt.c
··· 1442 1442 err = vma_check_userptr(vm, op->map.vma, pt_update); 1443 1443 break; 1444 1444 case DRM_GPUVA_OP_REMAP: 1445 - if (op->remap.prev) 1445 + if (op->remap.prev && !op->remap.skip_prev) 1446 1446 err = vma_check_userptr(vm, op->remap.prev, pt_update); 1447 - if (!err && op->remap.next) 1447 + if (!err && op->remap.next && !op->remap.skip_next) 1448 1448 err = vma_check_userptr(vm, op->remap.next, pt_update); 1449 1449 break; 1450 1450 case DRM_GPUVA_OP_UNMAP: ··· 2198 2198 2199 2199 err = unbind_op_prepare(tile, pt_update_ops, old); 2200 2200 2201 - if (!err && op->remap.prev) { 2201 + if (!err && op->remap.prev && !op->remap.skip_prev) { 2202 2202 err = bind_op_prepare(vm, tile, pt_update_ops, 2203 2203 op->remap.prev, false); 2204 2204 pt_update_ops->wait_vm_bookkeep = true; 2205 2205 } 2206 - if (!err && op->remap.next) { 2206 + if (!err && op->remap.next && !op->remap.skip_next) { 2207 2207 err = bind_op_prepare(vm, tile, pt_update_ops, 2208 2208 op->remap.next, false); 2209 2209 pt_update_ops->wait_vm_bookkeep = true; ··· 2428 2428 2429 2429 unbind_op_commit(vm, tile, pt_update_ops, old, fence, fence2); 2430 2430 2431 - if (op->remap.prev) 2431 + if (op->remap.prev && !op->remap.skip_prev) 2432 2432 bind_op_commit(vm, tile, pt_update_ops, op->remap.prev, 2433 2433 fence, fence2, false); 2434 - if (op->remap.next) 2434 + if (op->remap.next && !op->remap.skip_next) 2435 2435 bind_op_commit(vm, tile, pt_update_ops, op->remap.next, 2436 2436 fence, fence2, false); 2437 2437 break;
+2
drivers/gpu/drm/xe/xe_sriov_packet.c
··· 341 341 ret = xe_sriov_pf_migration_restore_produce(xe, vfid, *data); 342 342 if (ret) { 343 343 xe_sriov_packet_free(*data); 344 + *data = NULL; 345 + 344 346 return ret; 345 347 } 346 348
+18 -4
drivers/gpu/drm/xe/xe_vm.c
··· 2554 2554 if (!err && op->remap.skip_prev) { 2555 2555 op->remap.prev->tile_present = 2556 2556 tile_present; 2557 - op->remap.prev = NULL; 2558 2557 } 2559 2558 } 2560 2559 if (op->remap.next) { ··· 2563 2564 if (!err && op->remap.skip_next) { 2564 2565 op->remap.next->tile_present = 2565 2566 tile_present; 2566 - op->remap.next = NULL; 2567 2567 } 2568 2568 } 2569 2569 2570 - /* Adjust for partial unbind after removing VMA from VM */ 2570 + /* 2571 + * Adjust for partial unbind after removing VMA from VM. In case 2572 + * of unwind we might need to undo this later. 2573 + */ 2571 2574 if (!err) { 2572 2575 op->base.remap.unmap->va->va.addr = op->remap.start; 2573 2576 op->base.remap.unmap->va->va.range = op->remap.range; ··· 2688 2687 2689 2688 op->remap.start = xe_vma_start(old); 2690 2689 op->remap.range = xe_vma_size(old); 2690 + op->remap.old_start = op->remap.start; 2691 + op->remap.old_range = op->remap.range; 2691 2692 2692 2693 flags |= op->base.remap.unmap->va->flags & XE_VMA_CREATE_MASK; 2693 2694 if (op->base.remap.prev) { ··· 2838 2835 xe_svm_notifier_lock(vm); 2839 2836 vma->gpuva.flags &= ~XE_VMA_DESTROYED; 2840 2837 xe_svm_notifier_unlock(vm); 2841 - if (post_commit) 2838 + if (post_commit) { 2839 + /* 2840 + * Restore the old va range, in case of the 2841 + * prev/next skip optimisation. Otherwise what 2842 + * we re-insert here could be smaller than the 2843 + * original range. 2844 + */ 2845 + op->base.remap.unmap->va->va.addr = 2846 + op->remap.old_start; 2847 + op->base.remap.unmap->va->va.range = 2848 + op->remap.old_range; 2842 2849 xe_vm_insert_vma(vm, vma); 2850 + } 2843 2851 } 2844 2852 break; 2845 2853 }
+4
drivers/gpu/drm/xe/xe_vm_types.h
··· 373 373 u64 start; 374 374 /** @range: range of the VMA unmap */ 375 375 u64 range; 376 + /** @old_start: Original start of the VMA we unmap */ 377 + u64 old_start; 378 + /** @old_range: Original range of the VMA we unmap */ 379 + u64 old_range; 376 380 /** @skip_prev: skip prev rebind */ 377 381 bool skip_prev; 378 382 /** @skip_next: skip next rebind */
+2 -1
drivers/gpu/drm/xe/xe_wa.c
··· 247 247 LSN_DIM_Z_WGT_MASK, 248 248 LSN_LNI_WGT(1) | LSN_LNE_WGT(1) | 249 249 LSN_DIM_X_WGT(1) | LSN_DIM_Y_WGT(1) | 250 - LSN_DIM_Z_WGT(1))) 250 + LSN_DIM_Z_WGT(1)), 251 + SET(LSC_CHICKEN_BIT_0_UDW, L3_128B_256B_WRT_DIS)) 251 252 }, 252 253 253 254 /* Xe2_HPM */
+31 -23
drivers/hwmon/adm1177.c
··· 10 10 #include <linux/hwmon.h> 11 11 #include <linux/i2c.h> 12 12 #include <linux/init.h> 13 + #include <linux/math64.h> 14 + #include <linux/minmax.h> 13 15 #include <linux/module.h> 14 16 #include <linux/regulator/consumer.h> 15 17 ··· 35 33 struct adm1177_state { 36 34 struct i2c_client *client; 37 35 u32 r_sense_uohm; 38 - u32 alert_threshold_ua; 36 + u64 alert_threshold_ua; 39 37 bool vrange_high; 40 38 }; 41 39 ··· 50 48 } 51 49 52 50 static int adm1177_write_alert_thr(struct adm1177_state *st, 53 - u32 alert_threshold_ua) 51 + u64 alert_threshold_ua) 54 52 { 55 53 u64 val; 56 54 int ret; ··· 93 91 *val = div_u64((105840000ull * dummy), 94 92 4096 * st->r_sense_uohm); 95 93 return 0; 96 - case hwmon_curr_max_alarm: 97 - *val = st->alert_threshold_ua; 94 + case hwmon_curr_max: 95 + *val = div_u64(st->alert_threshold_ua, 1000); 98 96 return 0; 99 97 default: 100 98 return -EOPNOTSUPP; ··· 128 126 switch (type) { 129 127 case hwmon_curr: 130 128 switch (attr) { 131 - case hwmon_curr_max_alarm: 132 - adm1177_write_alert_thr(st, val); 133 - return 0; 129 + case hwmon_curr_max: 130 + val = clamp_val(val, 0, 131 + div_u64(105840000ULL, st->r_sense_uohm)); 132 + return adm1177_write_alert_thr(st, (u64)val * 1000); 134 133 default: 135 134 return -EOPNOTSUPP; 136 135 } ··· 159 156 if (st->r_sense_uohm) 160 157 return 0444; 161 158 return 0; 162 - case hwmon_curr_max_alarm: 159 + case hwmon_curr_max: 163 160 if (st->r_sense_uohm) 164 161 return 0644; 165 162 return 0; ··· 173 170 174 171 static const struct hwmon_channel_info * const adm1177_info[] = { 175 172 HWMON_CHANNEL_INFO(curr, 176 - HWMON_C_INPUT | HWMON_C_MAX_ALARM), 173 + HWMON_C_INPUT | HWMON_C_MAX), 177 174 HWMON_CHANNEL_INFO(in, 178 175 HWMON_I_INPUT), 179 176 NULL ··· 195 192 struct device *dev = &client->dev; 196 193 struct device *hwmon_dev; 197 194 struct adm1177_state *st; 198 - u32 alert_threshold_ua; 195 + u64 alert_threshold_ua; 196 + u32 prop; 199 197 int ret; 200 198 201 199 st = devm_kzalloc(dev, sizeof(*st), GFP_KERNEL); ··· 212 208 if (device_property_read_u32(dev, "shunt-resistor-micro-ohms", 213 209 &st->r_sense_uohm)) 214 210 st->r_sense_uohm = 0; 215 - if (device_property_read_u32(dev, "adi,shutdown-threshold-microamp", 216 - &alert_threshold_ua)) { 217 - if (st->r_sense_uohm) 218 - /* 219 - * set maximum default value from datasheet based on 220 - * shunt-resistor 221 - */ 222 - alert_threshold_ua = div_u64(105840000000, 223 - st->r_sense_uohm); 224 - else 225 - alert_threshold_ua = 0; 211 + if (!device_property_read_u32(dev, "adi,shutdown-threshold-microamp", 212 + &prop)) { 213 + alert_threshold_ua = prop; 214 + } else if (st->r_sense_uohm) { 215 + /* 216 + * set maximum default value from datasheet based on 217 + * shunt-resistor 218 + */ 219 + alert_threshold_ua = div_u64(105840000000ULL, 220 + st->r_sense_uohm); 221 + } else { 222 + alert_threshold_ua = 0; 226 223 } 227 224 st->vrange_high = device_property_read_bool(dev, 228 225 "adi,vrange-high-enable"); 229 - if (alert_threshold_ua && st->r_sense_uohm) 230 - adm1177_write_alert_thr(st, alert_threshold_ua); 226 + if (alert_threshold_ua && st->r_sense_uohm) { 227 + ret = adm1177_write_alert_thr(st, alert_threshold_ua); 228 + if (ret) 229 + return ret; 230 + } 231 231 232 232 ret = adm1177_write_cmd(st, ADM1177_CMD_V_CONT | 233 233 ADM1177_CMD_I_CONT |
+2 -2
drivers/hwmon/peci/cputemp.c
··· 131 131 *val = priv->temp.target.tjmax; 132 132 break; 133 133 case crit_hyst_type: 134 - *val = priv->temp.target.tjmax - priv->temp.target.tcontrol; 134 + *val = priv->temp.target.tcontrol; 135 135 break; 136 136 default: 137 137 ret = -EOPNOTSUPP; ··· 319 319 { 320 320 const struct peci_cputemp *priv = data; 321 321 322 - if (channel > CPUTEMP_CHANNEL_NUMS) 322 + if (channel >= CPUTEMP_CHANNEL_NUMS) 323 323 return 0; 324 324 325 325 if (channel < channel_core)
+2 -1
drivers/hwmon/pmbus/ina233.c
··· 72 72 73 73 /* Adjust returned value to match VIN coefficients */ 74 74 /* VIN: 1.25 mV VSHUNT: 2.5 uV LSB */ 75 - ret = DIV_ROUND_CLOSEST(ret * 25, 12500); 75 + ret = clamp_val(DIV_ROUND_CLOSEST((s16)ret * 25, 12500), 76 + S16_MIN, S16_MAX) & 0xffff; 76 77 break; 77 78 default: 78 79 ret = -ENODATA;
+18 -3
drivers/hwmon/pmbus/isl68137.c
··· 96 96 int page, 97 97 char *buf) 98 98 { 99 - int val = pmbus_read_byte_data(client, page, PMBUS_OPERATION); 99 + int val; 100 + 101 + val = pmbus_lock_interruptible(client); 102 + if (val) 103 + return val; 104 + 105 + val = pmbus_read_byte_data(client, page, PMBUS_OPERATION); 106 + 107 + pmbus_unlock(client); 100 108 101 109 if (val < 0) 102 110 return val; ··· 126 118 127 119 op_val = result ? ISL68137_VOUT_AVS : 0; 128 120 121 + rc = pmbus_lock_interruptible(client); 122 + if (rc) 123 + return rc; 124 + 129 125 /* 130 126 * Writes to VOUT setpoint over AVSBus will persist after the VRM is 131 127 * switched to PMBus control. Switching back to AVSBus control ··· 141 129 rc = pmbus_read_word_data(client, page, 0xff, 142 130 PMBUS_VOUT_COMMAND); 143 131 if (rc < 0) 144 - return rc; 132 + goto unlock; 145 133 146 134 rc = pmbus_write_word_data(client, page, PMBUS_VOUT_COMMAND, 147 135 rc); 148 136 if (rc < 0) 149 - return rc; 137 + goto unlock; 150 138 } 151 139 152 140 rc = pmbus_update_byte_data(client, page, PMBUS_OPERATION, 153 141 ISL68137_VOUT_AVS, op_val); 142 + 143 + unlock: 144 + pmbus_unlock(client); 154 145 155 146 return (rc < 0) ? rc : count; 156 147 }
+154 -38
drivers/hwmon/pmbus/pmbus_core.c
··· 6 6 * Copyright (c) 2012 Guenter Roeck 7 7 */ 8 8 9 + #include <linux/atomic.h> 9 10 #include <linux/debugfs.h> 10 11 #include <linux/delay.h> 11 12 #include <linux/dcache.h> ··· 22 21 #include <linux/pmbus.h> 23 22 #include <linux/regulator/driver.h> 24 23 #include <linux/regulator/machine.h> 25 - #include <linux/of.h> 26 24 #include <linux/thermal.h> 25 + #include <linux/workqueue.h> 27 26 #include "pmbus.h" 28 27 29 28 /* ··· 112 111 struct pmbus_sensor *sensors; 113 112 114 113 struct mutex update_lock; 114 + 115 + #if IS_ENABLED(CONFIG_REGULATOR) 116 + atomic_t regulator_events[PMBUS_PAGES]; 117 + struct work_struct regulator_notify_work; 118 + #endif 115 119 116 120 bool has_status_word; /* device uses STATUS_WORD register */ 117 121 int (*read_status)(struct i2c_client *client, int page); ··· 1215 1209 return sysfs_emit(buf, "%d\n", val); 1216 1210 } 1217 1211 1212 + static ssize_t pmbus_show_zero(struct device *dev, 1213 + struct device_attribute *devattr, char *buf) 1214 + { 1215 + return sysfs_emit(buf, "0\n"); 1216 + } 1217 + 1218 1218 static ssize_t pmbus_show_sensor(struct device *dev, 1219 1219 struct device_attribute *devattr, char *buf) 1220 1220 { ··· 1419 1407 int reg, 1420 1408 enum pmbus_sensor_classes class, 1421 1409 bool update, bool readonly, 1422 - bool convert) 1410 + bool writeonly, bool convert) 1423 1411 { 1424 1412 struct pmbus_sensor *sensor; 1425 1413 struct device_attribute *a; ··· 1448 1436 sensor->data = -ENODATA; 1449 1437 pmbus_dev_attr_init(a, sensor->name, 1450 1438 readonly ? 0444 : 0644, 1451 - pmbus_show_sensor, pmbus_set_sensor); 1439 + writeonly ? pmbus_show_zero : pmbus_show_sensor, 1440 + pmbus_set_sensor); 1452 1441 1453 1442 if (pmbus_add_attribute(data, &a->attr)) 1454 1443 return NULL; ··· 1508 1495 struct pmbus_limit_attr { 1509 1496 u16 reg; /* Limit register */ 1510 1497 u16 sbit; /* Alarm attribute status bit */ 1511 - bool update; /* True if register needs updates */ 1512 - bool low; /* True if low limit; for limits with compare functions only */ 1498 + bool readonly:1; /* True if the attribute is read-only */ 1499 + bool writeonly:1; /* True if the attribute is write-only */ 1500 + bool update:1; /* True if register needs updates */ 1501 + bool low:1; /* True if low limit; for limits with compare functions only */ 1513 1502 const char *attr; /* Attribute name */ 1514 1503 const char *alarm; /* Alarm attribute name */ 1515 1504 }; ··· 1526 1511 u8 nlimit; /* # of limit registers */ 1527 1512 enum pmbus_sensor_classes class;/* sensor class */ 1528 1513 const char *label; /* sensor label */ 1529 - bool paged; /* true if paged sensor */ 1530 - bool update; /* true if update needed */ 1531 - bool compare; /* true if compare function needed */ 1514 + bool paged:1; /* true if paged sensor */ 1515 + bool update:1; /* true if update needed */ 1516 + bool compare:1; /* true if compare function needed */ 1532 1517 u32 func; /* sensor mask */ 1533 1518 u32 sfunc; /* sensor status mask */ 1534 1519 int sreg; /* status register */ ··· 1559 1544 curr = pmbus_add_sensor(data, name, l->attr, index, 1560 1545 page, 0xff, l->reg, attr->class, 1561 1546 attr->update || l->update, 1562 - false, true); 1547 + l->readonly, l->writeonly, true); 1563 1548 if (!curr) 1564 1549 return -ENOMEM; 1565 1550 if (l->sbit && (info->func[page] & attr->sfunc)) { ··· 1599 1584 return ret; 1600 1585 } 1601 1586 base = pmbus_add_sensor(data, name, "input", index, page, phase, 1602 - attr->reg, attr->class, true, true, true); 1587 + attr->reg, attr->class, true, true, false, true); 1603 1588 if (!base) 1604 1589 return -ENOMEM; 1605 1590 /* No limit and alarm attributes for phase specific sensors */ ··· 1722 1707 }, { 1723 1708 .reg = PMBUS_VIRT_READ_VIN_AVG, 1724 1709 .update = true, 1710 + .readonly = true, 1725 1711 .attr = "average", 1726 1712 }, { 1727 1713 .reg = PMBUS_VIRT_READ_VIN_MIN, 1728 1714 .update = true, 1715 + .readonly = true, 1729 1716 .attr = "lowest", 1730 1717 }, { 1731 1718 .reg = PMBUS_VIRT_READ_VIN_MAX, 1732 1719 .update = true, 1720 + .readonly = true, 1733 1721 .attr = "highest", 1734 1722 }, { 1735 1723 .reg = PMBUS_VIRT_RESET_VIN_HISTORY, 1724 + .writeonly = true, 1736 1725 .attr = "reset_history", 1737 1726 }, { 1738 1727 .reg = PMBUS_MFR_VIN_MIN, 1728 + .readonly = true, 1739 1729 .attr = "rated_min", 1740 1730 }, { 1741 1731 .reg = PMBUS_MFR_VIN_MAX, 1732 + .readonly = true, 1742 1733 .attr = "rated_max", 1743 1734 }, 1744 1735 }; ··· 1797 1776 }, { 1798 1777 .reg = PMBUS_VIRT_READ_VOUT_AVG, 1799 1778 .update = true, 1779 + .readonly = true, 1800 1780 .attr = "average", 1801 1781 }, { 1802 1782 .reg = PMBUS_VIRT_READ_VOUT_MIN, 1803 1783 .update = true, 1784 + .readonly = true, 1804 1785 .attr = "lowest", 1805 1786 }, { 1806 1787 .reg = PMBUS_VIRT_READ_VOUT_MAX, 1807 1788 .update = true, 1789 + .readonly = true, 1808 1790 .attr = "highest", 1809 1791 }, { 1810 1792 .reg = PMBUS_VIRT_RESET_VOUT_HISTORY, 1793 + .writeonly = true, 1811 1794 .attr = "reset_history", 1812 1795 }, { 1813 1796 .reg = PMBUS_MFR_VOUT_MIN, 1797 + .readonly = true, 1814 1798 .attr = "rated_min", 1815 1799 }, { 1816 1800 .reg = PMBUS_MFR_VOUT_MAX, 1801 + .readonly = true, 1817 1802 .attr = "rated_max", 1818 1803 }, 1819 1804 }; ··· 1879 1852 }, { 1880 1853 .reg = PMBUS_VIRT_READ_IIN_AVG, 1881 1854 .update = true, 1855 + .readonly = true, 1882 1856 .attr = "average", 1883 1857 }, { 1884 1858 .reg = PMBUS_VIRT_READ_IIN_MIN, 1885 1859 .update = true, 1860 + .readonly = true, 1886 1861 .attr = "lowest", 1887 1862 }, { 1888 1863 .reg = PMBUS_VIRT_READ_IIN_MAX, 1889 1864 .update = true, 1865 + .readonly = true, 1890 1866 .attr = "highest", 1891 1867 }, { 1892 1868 .reg = PMBUS_VIRT_RESET_IIN_HISTORY, 1869 + .writeonly = true, 1893 1870 .attr = "reset_history", 1894 1871 }, { 1895 1872 .reg = PMBUS_MFR_IIN_MAX, 1873 + .readonly = true, 1896 1874 .attr = "rated_max", 1897 1875 }, 1898 1876 }; ··· 1921 1889 }, { 1922 1890 .reg = PMBUS_VIRT_READ_IOUT_AVG, 1923 1891 .update = true, 1892 + .readonly = true, 1924 1893 .attr = "average", 1925 1894 }, { 1926 1895 .reg = PMBUS_VIRT_READ_IOUT_MIN, 1927 1896 .update = true, 1897 + .readonly = true, 1928 1898 .attr = "lowest", 1929 1899 }, { 1930 1900 .reg = PMBUS_VIRT_READ_IOUT_MAX, 1931 1901 .update = true, 1902 + .readonly = true, 1932 1903 .attr = "highest", 1933 1904 }, { 1934 1905 .reg = PMBUS_VIRT_RESET_IOUT_HISTORY, 1906 + .writeonly = true, 1935 1907 .attr = "reset_history", 1936 1908 }, { 1937 1909 .reg = PMBUS_MFR_IOUT_MAX, 1910 + .readonly = true, 1938 1911 .attr = "rated_max", 1939 1912 }, 1940 1913 }; ··· 1980 1943 }, { 1981 1944 .reg = PMBUS_VIRT_READ_PIN_AVG, 1982 1945 .update = true, 1946 + .readonly = true, 1983 1947 .attr = "average", 1984 1948 }, { 1985 1949 .reg = PMBUS_VIRT_READ_PIN_MIN, 1986 1950 .update = true, 1951 + .readonly = true, 1987 1952 .attr = "input_lowest", 1988 1953 }, { 1989 1954 .reg = PMBUS_VIRT_READ_PIN_MAX, 1990 1955 .update = true, 1956 + .readonly = true, 1991 1957 .attr = "input_highest", 1992 1958 }, { 1993 1959 .reg = PMBUS_VIRT_RESET_PIN_HISTORY, 1960 + .writeonly = true, 1994 1961 .attr = "reset_history", 1995 1962 }, { 1996 1963 .reg = PMBUS_MFR_PIN_MAX, 1964 + .readonly = true, 1997 1965 .attr = "rated_max", 1998 1966 }, 1999 1967 }; ··· 2022 1980 }, { 2023 1981 .reg = PMBUS_VIRT_READ_POUT_AVG, 2024 1982 .update = true, 1983 + .readonly = true, 2025 1984 .attr = "average", 2026 1985 }, { 2027 1986 .reg = PMBUS_VIRT_READ_POUT_MIN, 2028 1987 .update = true, 1988 + .readonly = true, 2029 1989 .attr = "input_lowest", 2030 1990 }, { 2031 1991 .reg = PMBUS_VIRT_READ_POUT_MAX, 2032 1992 .update = true, 1993 + .readonly = true, 2033 1994 .attr = "input_highest", 2034 1995 }, { 2035 1996 .reg = PMBUS_VIRT_RESET_POUT_HISTORY, 1997 + .writeonly = true, 2036 1998 .attr = "reset_history", 2037 1999 }, { 2038 2000 .reg = PMBUS_MFR_POUT_MAX, 2001 + .readonly = true, 2039 2002 .attr = "rated_max", 2040 2003 }, 2041 2004 }; ··· 2096 2049 .sbit = PB_TEMP_OT_FAULT, 2097 2050 }, { 2098 2051 .reg = PMBUS_VIRT_READ_TEMP_MIN, 2052 + .readonly = true, 2099 2053 .attr = "lowest", 2100 2054 }, { 2101 2055 .reg = PMBUS_VIRT_READ_TEMP_AVG, 2056 + .readonly = true, 2102 2057 .attr = "average", 2103 2058 }, { 2104 2059 .reg = PMBUS_VIRT_READ_TEMP_MAX, 2060 + .readonly = true, 2105 2061 .attr = "highest", 2106 2062 }, { 2107 2063 .reg = PMBUS_VIRT_RESET_TEMP_HISTORY, 2064 + .writeonly = true, 2108 2065 .attr = "reset_history", 2109 2066 }, { 2110 2067 .reg = PMBUS_MFR_MAX_TEMP_1, 2068 + .readonly = true, 2111 2069 .attr = "rated_max", 2112 2070 }, 2113 2071 }; ··· 2142 2090 .sbit = PB_TEMP_OT_FAULT, 2143 2091 }, { 2144 2092 .reg = PMBUS_VIRT_READ_TEMP2_MIN, 2093 + .readonly = true, 2145 2094 .attr = "lowest", 2146 2095 }, { 2147 2096 .reg = PMBUS_VIRT_READ_TEMP2_AVG, 2097 + .readonly = true, 2148 2098 .attr = "average", 2149 2099 }, { 2150 2100 .reg = PMBUS_VIRT_READ_TEMP2_MAX, 2101 + .readonly = true, 2151 2102 .attr = "highest", 2152 2103 }, { 2153 2104 .reg = PMBUS_VIRT_RESET_TEMP2_HISTORY, 2105 + .writeonly = true, 2154 2106 .attr = "reset_history", 2155 2107 }, { 2156 2108 .reg = PMBUS_MFR_MAX_TEMP_2, 2109 + .readonly = true, 2157 2110 .attr = "rated_max", 2158 2111 }, 2159 2112 }; ··· 2188 2131 .sbit = PB_TEMP_OT_FAULT, 2189 2132 }, { 2190 2133 .reg = PMBUS_MFR_MAX_TEMP_3, 2134 + .readonly = true, 2191 2135 .attr = "rated_max", 2192 2136 }, 2193 2137 }; ··· 2272 2214 2273 2215 sensor = pmbus_add_sensor(data, "fan", "target", index, page, 2274 2216 0xff, PMBUS_VIRT_FAN_TARGET_1 + id, PSC_FAN, 2275 - false, false, true); 2217 + false, false, false, true); 2276 2218 2277 2219 if (!sensor) 2278 2220 return -ENOMEM; ··· 2283 2225 2284 2226 sensor = pmbus_add_sensor(data, "pwm", NULL, index, page, 2285 2227 0xff, PMBUS_VIRT_PWM_1 + id, PSC_PWM, 2286 - false, false, true); 2228 + false, false, false, true); 2287 2229 2288 2230 if (!sensor) 2289 2231 return -ENOMEM; 2290 2232 2291 2233 sensor = pmbus_add_sensor(data, "pwm", "enable", index, page, 2292 2234 0xff, PMBUS_VIRT_PWM_ENABLE_1 + id, PSC_PWM, 2293 - true, false, false); 2235 + true, false, false, false); 2294 2236 2295 2237 if (!sensor) 2296 2238 return -ENOMEM; ··· 2332 2274 2333 2275 if (pmbus_add_sensor(data, "fan", "input", index, 2334 2276 page, 0xff, pmbus_fan_registers[f], 2335 - PSC_FAN, true, true, true) == NULL) 2277 + PSC_FAN, true, true, false, true) == NULL) 2336 2278 return -ENOMEM; 2337 2279 2338 2280 /* Fan control */ ··· 3234 3176 .class = PSC_VOLTAGE_OUT, 3235 3177 .convert = true, 3236 3178 }; 3179 + int ret; 3237 3180 3181 + mutex_lock(&data->update_lock); 3238 3182 s.data = _pmbus_read_word_data(client, s.page, 0xff, PMBUS_READ_VOUT); 3239 - if (s.data < 0) 3240 - return s.data; 3183 + if (s.data < 0) { 3184 + ret = s.data; 3185 + goto unlock; 3186 + } 3241 3187 3242 - return (int)pmbus_reg2data(data, &s) * 1000; /* unit is uV */ 3188 + ret = (int)pmbus_reg2data(data, &s) * 1000; /* unit is uV */ 3189 + unlock: 3190 + mutex_unlock(&data->update_lock); 3191 + return ret; 3243 3192 } 3244 3193 3245 3194 static int pmbus_regulator_set_voltage(struct regulator_dev *rdev, int min_uv, ··· 3263 3198 }; 3264 3199 int val = DIV_ROUND_CLOSEST(min_uv, 1000); /* convert to mV */ 3265 3200 int low, high; 3201 + int ret; 3266 3202 3267 3203 *selector = 0; 3268 3204 3205 + mutex_lock(&data->update_lock); 3269 3206 low = pmbus_regulator_get_low_margin(client, s.page); 3270 - if (low < 0) 3271 - return low; 3207 + if (low < 0) { 3208 + ret = low; 3209 + goto unlock; 3210 + } 3272 3211 3273 3212 high = pmbus_regulator_get_high_margin(client, s.page); 3274 - if (high < 0) 3275 - return high; 3213 + if (high < 0) { 3214 + ret = high; 3215 + goto unlock; 3216 + } 3276 3217 3277 3218 /* Make sure we are within margins */ 3278 3219 if (low > val) ··· 3288 3217 3289 3218 val = pmbus_data2reg(data, &s, val); 3290 3219 3291 - return _pmbus_write_word_data(client, s.page, PMBUS_VOUT_COMMAND, (u16)val); 3220 + ret = _pmbus_write_word_data(client, s.page, PMBUS_VOUT_COMMAND, (u16)val); 3221 + unlock: 3222 + mutex_unlock(&data->update_lock); 3223 + return ret; 3292 3224 } 3293 3225 3294 3226 static int pmbus_regulator_list_voltage(struct regulator_dev *rdev, ··· 3301 3227 struct i2c_client *client = to_i2c_client(dev->parent); 3302 3228 struct pmbus_data *data = i2c_get_clientdata(client); 3303 3229 int val, low, high; 3230 + int ret; 3304 3231 3305 3232 if (data->flags & PMBUS_VOUT_PROTECTED) 3306 3233 return 0; ··· 3314 3239 val = DIV_ROUND_CLOSEST(rdev->desc->min_uV + 3315 3240 (rdev->desc->uV_step * selector), 1000); /* convert to mV */ 3316 3241 3242 + mutex_lock(&data->update_lock); 3243 + 3317 3244 low = pmbus_regulator_get_low_margin(client, rdev_get_id(rdev)); 3318 - if (low < 0) 3319 - return low; 3245 + if (low < 0) { 3246 + ret = low; 3247 + goto unlock; 3248 + } 3320 3249 3321 3250 high = pmbus_regulator_get_high_margin(client, rdev_get_id(rdev)); 3322 - if (high < 0) 3323 - return high; 3251 + if (high < 0) { 3252 + ret = high; 3253 + goto unlock; 3254 + } 3324 3255 3325 - if (val >= low && val <= high) 3326 - return val * 1000; /* unit is uV */ 3256 + if (val >= low && val <= high) { 3257 + ret = val * 1000; /* unit is uV */ 3258 + goto unlock; 3259 + } 3327 3260 3328 - return 0; 3261 + ret = 0; 3262 + unlock: 3263 + mutex_unlock(&data->update_lock); 3264 + return ret; 3329 3265 } 3330 3266 3331 3267 const struct regulator_ops pmbus_regulator_ops = { ··· 3367 3281 } 3368 3282 EXPORT_SYMBOL_NS_GPL(pmbus_regulator_init_cb, "PMBUS"); 3369 3283 3284 + static void pmbus_regulator_notify_work_cancel(void *data) 3285 + { 3286 + struct pmbus_data *pdata = data; 3287 + 3288 + cancel_work_sync(&pdata->regulator_notify_work); 3289 + } 3290 + 3291 + static void pmbus_regulator_notify_worker(struct work_struct *work) 3292 + { 3293 + struct pmbus_data *data = 3294 + container_of(work, struct pmbus_data, regulator_notify_work); 3295 + int i, j; 3296 + 3297 + for (i = 0; i < data->info->pages; i++) { 3298 + int event; 3299 + 3300 + event = atomic_xchg(&data->regulator_events[i], 0); 3301 + if (!event) 3302 + continue; 3303 + 3304 + for (j = 0; j < data->info->num_regulators; j++) { 3305 + if (i == rdev_get_id(data->rdevs[j])) { 3306 + regulator_notifier_call_chain(data->rdevs[j], 3307 + event, NULL); 3308 + break; 3309 + } 3310 + } 3311 + } 3312 + } 3313 + 3370 3314 static int pmbus_regulator_register(struct pmbus_data *data) 3371 3315 { 3372 3316 struct device *dev = data->dev; 3373 3317 const struct pmbus_driver_info *info = data->info; 3374 3318 const struct pmbus_platform_data *pdata = dev_get_platdata(dev); 3375 - int i; 3319 + int i, ret; 3376 3320 3377 3321 data->rdevs = devm_kzalloc(dev, sizeof(struct regulator_dev *) * info->num_regulators, 3378 3322 GFP_KERNEL); ··· 3426 3310 info->reg_desc[i].name); 3427 3311 } 3428 3312 3313 + INIT_WORK(&data->regulator_notify_work, pmbus_regulator_notify_worker); 3314 + 3315 + ret = devm_add_action_or_reset(dev, pmbus_regulator_notify_work_cancel, data); 3316 + if (ret) 3317 + return ret; 3318 + 3429 3319 return 0; 3430 3320 } 3431 3321 3432 3322 static void pmbus_regulator_notify(struct pmbus_data *data, int page, int event) 3433 3323 { 3434 - int j; 3435 - 3436 - for (j = 0; j < data->info->num_regulators; j++) { 3437 - if (page == rdev_get_id(data->rdevs[j])) { 3438 - regulator_notifier_call_chain(data->rdevs[j], event, NULL); 3439 - break; 3440 - } 3441 - } 3324 + atomic_or(event, &data->regulator_events[page]); 3325 + schedule_work(&data->regulator_notify_work); 3442 3326 } 3443 3327 #else 3444 3328 static int pmbus_regulator_register(struct pmbus_data *data)
+5 -6
drivers/i2c/busses/i2c-designware-amdisp.c
··· 7 7 8 8 #include <linux/module.h> 9 9 #include <linux/platform_device.h> 10 + #include <linux/pm_domain.h> 10 11 #include <linux/pm_runtime.h> 11 12 #include <linux/soc/amd/isp4_misc.h> 12 13 ··· 77 76 78 77 device_enable_async_suspend(&pdev->dev); 79 78 80 - pm_runtime_enable(&pdev->dev); 81 - pm_runtime_get_sync(&pdev->dev); 82 - 79 + dev_pm_genpd_resume(&pdev->dev); 83 80 ret = i2c_dw_probe(isp_i2c_dev); 84 81 if (ret) { 85 82 dev_err_probe(&pdev->dev, ret, "i2c_dw_probe failed\n"); 86 83 goto error_release_rpm; 87 84 } 88 - 89 - pm_runtime_put_sync(&pdev->dev); 85 + dev_pm_genpd_suspend(&pdev->dev); 86 + pm_runtime_set_suspended(&pdev->dev); 87 + pm_runtime_enable(&pdev->dev); 90 88 91 89 return 0; 92 90 93 91 error_release_rpm: 94 92 amd_isp_dw_i2c_plat_pm_cleanup(isp_i2c_dev); 95 - pm_runtime_put_sync(&pdev->dev); 96 93 return ret; 97 94 } 98 95
+32 -19
drivers/i2c/busses/i2c-imx.c
··· 1018 1018 return 0; 1019 1019 } 1020 1020 1021 - static inline void i2c_imx_isr_read_continue(struct imx_i2c_struct *i2c_imx) 1021 + static inline enum imx_i2c_state i2c_imx_isr_read_continue(struct imx_i2c_struct *i2c_imx) 1022 1022 { 1023 + enum imx_i2c_state next_state = IMX_I2C_STATE_READ_CONTINUE; 1023 1024 unsigned int temp; 1024 1025 1025 1026 if ((i2c_imx->msg->len - 1) == i2c_imx->msg_buf_idx) { ··· 1034 1033 i2c_imx->stopped = 1; 1035 1034 temp &= ~(I2CR_MSTA | I2CR_MTX); 1036 1035 imx_i2c_write_reg(temp, i2c_imx, IMX_I2C_I2CR); 1037 - } else { 1038 - /* 1039 - * For i2c master receiver repeat restart operation like: 1040 - * read -> repeat MSTA -> read/write 1041 - * The controller must set MTX before read the last byte in 1042 - * the first read operation, otherwise the first read cost 1043 - * one extra clock cycle. 1044 - */ 1045 - temp = imx_i2c_read_reg(i2c_imx, IMX_I2C_I2CR); 1046 - temp |= I2CR_MTX; 1047 - imx_i2c_write_reg(temp, i2c_imx, IMX_I2C_I2CR); 1036 + 1037 + return IMX_I2C_STATE_DONE; 1048 1038 } 1039 + /* 1040 + * For i2c master receiver repeat restart operation like: 1041 + * read -> repeat MSTA -> read/write 1042 + * The controller must set MTX before read the last byte in 1043 + * the first read operation, otherwise the first read cost 1044 + * one extra clock cycle. 1045 + */ 1046 + temp = imx_i2c_read_reg(i2c_imx, IMX_I2C_I2CR); 1047 + temp |= I2CR_MTX; 1048 + imx_i2c_write_reg(temp, i2c_imx, IMX_I2C_I2CR); 1049 + next_state = IMX_I2C_STATE_DONE; 1049 1050 } else if (i2c_imx->msg_buf_idx == (i2c_imx->msg->len - 2)) { 1050 1051 temp = imx_i2c_read_reg(i2c_imx, IMX_I2C_I2CR); 1051 1052 temp |= I2CR_TXAK; ··· 1055 1052 } 1056 1053 1057 1054 i2c_imx->msg->buf[i2c_imx->msg_buf_idx++] = imx_i2c_read_reg(i2c_imx, IMX_I2C_I2DR); 1055 + return next_state; 1058 1056 } 1059 1057 1060 1058 static inline void i2c_imx_isr_read_block_data_len(struct imx_i2c_struct *i2c_imx) ··· 1092 1088 break; 1093 1089 1094 1090 case IMX_I2C_STATE_READ_CONTINUE: 1095 - i2c_imx_isr_read_continue(i2c_imx); 1096 - if (i2c_imx->msg_buf_idx == i2c_imx->msg->len) { 1097 - i2c_imx->state = IMX_I2C_STATE_DONE; 1091 + i2c_imx->state = i2c_imx_isr_read_continue(i2c_imx); 1092 + if (i2c_imx->state == IMX_I2C_STATE_DONE) 1098 1093 wake_up(&i2c_imx->queue); 1099 - } 1100 1094 break; 1101 1095 1102 1096 case IMX_I2C_STATE_READ_BLOCK_DATA: ··· 1492 1490 bool is_lastmsg) 1493 1491 { 1494 1492 int block_data = msgs->flags & I2C_M_RECV_LEN; 1493 + int ret = 0; 1495 1494 1496 1495 dev_dbg(&i2c_imx->adapter.dev, 1497 1496 "<%s> write slave address: addr=0x%x\n", ··· 1525 1522 dev_err(&i2c_imx->adapter.dev, "<%s> read timedout\n", __func__); 1526 1523 return -ETIMEDOUT; 1527 1524 } 1528 - if (!i2c_imx->stopped) 1529 - return i2c_imx_bus_busy(i2c_imx, 0, false); 1525 + if (i2c_imx->is_lastmsg) { 1526 + if (!i2c_imx->stopped) 1527 + ret = i2c_imx_bus_busy(i2c_imx, 0, false); 1528 + /* 1529 + * Only read the last byte of the last message after the bus is 1530 + * not busy. Else the controller generates another clock which 1531 + * might confuse devices. 1532 + */ 1533 + if (!ret) 1534 + i2c_imx->msg->buf[i2c_imx->msg_buf_idx++] = imx_i2c_read_reg(i2c_imx, 1535 + IMX_I2C_I2DR); 1536 + } 1530 1537 1531 - return 0; 1538 + return ret; 1532 1539 } 1533 1540 1534 1541 static int i2c_imx_xfer_common(struct i2c_adapter *adapter,
+30 -13
drivers/infiniband/core/rw.c
··· 608 608 if (rdma_rw_io_needs_mr(qp->device, port_num, dir, sg_cnt)) { 609 609 ret = rdma_rw_init_mr_wrs(ctx, qp, port_num, sg, sg_cnt, 610 610 sg_offset, remote_addr, rkey, dir); 611 - } else if (sg_cnt > 1) { 612 - ret = rdma_rw_init_map_wrs(ctx, qp, sg, sg_cnt, sg_offset, 613 - remote_addr, rkey, dir); 614 - } else { 615 - ret = rdma_rw_init_single_wr(ctx, qp, sg, sg_offset, 616 - remote_addr, rkey, dir); 611 + /* 612 + * If MR init succeeded or failed for a reason other 613 + * than pool exhaustion, that result is final. 614 + * 615 + * Pool exhaustion (-EAGAIN) from the max_sgl_rd 616 + * optimization is recoverable: fall back to 617 + * direct SGE posting. iWARP and force_mr require 618 + * MRs unconditionally, so -EAGAIN is terminal. 619 + */ 620 + if (ret != -EAGAIN || 621 + rdma_protocol_iwarp(qp->device, port_num) || 622 + unlikely(rdma_rw_force_mr)) 623 + goto out; 617 624 } 618 625 626 + if (sg_cnt > 1) 627 + ret = rdma_rw_init_map_wrs(ctx, qp, sg, sg_cnt, sg_offset, 628 + remote_addr, rkey, dir); 629 + else 630 + ret = rdma_rw_init_single_wr(ctx, qp, sg, sg_offset, 631 + remote_addr, rkey, dir); 632 + 633 + out: 619 634 if (ret < 0) 620 635 goto out_unmap_sg; 621 636 return ret; ··· 701 686 return ret; 702 687 703 688 /* 704 - * IOVA mapping not available. Check if MR registration provides 705 - * better performance than multiple SGE entries. 689 + * IOVA not available; fall back to the map_wrs path, which maps 690 + * each bvec as a direct SGE. This is always correct: the MR path 691 + * is a throughput optimization, not a correctness requirement. 692 + * (iWARP, which does require MRs, is handled by the check above.) 693 + * 694 + * The rdma_rw_io_needs_mr() gate is not used here because nr_bvec 695 + * is a raw page count that overstates DMA entry demand -- the bvec 696 + * caller has no post-DMA-coalescing segment count, and feeding the 697 + * inflated count into the MR path exhausts the pool on RDMA READs. 706 698 */ 707 - if (rdma_rw_io_needs_mr(dev, port_num, dir, nr_bvec)) 708 - return rdma_rw_init_mr_wrs_bvec(ctx, qp, port_num, bvecs, 709 - nr_bvec, &iter, remote_addr, 710 - rkey, dir); 711 - 712 699 return rdma_rw_init_map_wrs_bvec(ctx, qp, bvecs, nr_bvec, &iter, 713 700 remote_addr, rkey, dir); 714 701 }
+9 -5
drivers/infiniband/hw/bng_re/bng_dev.c
··· 210 210 return rc; 211 211 } 212 212 213 - static void bng_re_query_hwrm_version(struct bng_re_dev *rdev) 213 + static int bng_re_query_hwrm_version(struct bng_re_dev *rdev) 214 214 { 215 215 struct bnge_auxr_dev *aux_dev = rdev->aux_dev; 216 216 struct hwrm_ver_get_output ver_get_resp = {}; ··· 230 230 if (rc) { 231 231 ibdev_err(&rdev->ibdev, "Failed to query HW version, rc = 0x%x", 232 232 rc); 233 - return; 233 + return rc; 234 234 } 235 235 236 236 cctx = rdev->chip_ctx; ··· 244 244 245 245 if (!cctx->hwrm_cmd_max_timeout) 246 246 cctx->hwrm_cmd_max_timeout = BNG_ROCE_FW_MAX_TIMEOUT; 247 + 248 + return 0; 247 249 } 248 250 249 251 static void bng_re_dev_uninit(struct bng_re_dev *rdev) ··· 308 306 goto msix_ctx_fail; 309 307 } 310 308 311 - bng_re_query_hwrm_version(rdev); 309 + rc = bng_re_query_hwrm_version(rdev); 310 + if (rc) 311 + goto destroy_chip_ctx; 312 312 313 313 rc = bng_re_alloc_fw_channel(&rdev->bng_res, &rdev->rcfw); 314 314 if (rc) { 315 315 ibdev_err(&rdev->ibdev, 316 316 "Failed to allocate RCFW Channel: %#x\n", rc); 317 - goto alloc_fw_chl_fail; 317 + goto destroy_chip_ctx; 318 318 } 319 319 320 320 /* Allocate nq record memory */ ··· 395 391 kfree(rdev->nqr); 396 392 nq_alloc_fail: 397 393 bng_re_free_rcfw_channel(&rdev->rcfw); 398 - alloc_fw_chl_fail: 394 + destroy_chip_ctx: 399 395 bng_re_destroy_chip_ctx(rdev); 400 396 msix_ctx_fail: 401 397 bnge_unregister_dev(rdev->aux_dev);
+40 -48
drivers/infiniband/hw/efa/efa_com.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause 2 2 /* 3 - * Copyright 2018-2025 Amazon.com, Inc. or its affiliates. All rights reserved. 3 + * Copyright 2018-2026 Amazon.com, Inc. or its affiliates. All rights reserved. 4 4 */ 5 5 6 6 #include <linux/log2.h> ··· 310 310 return &aq->comp_ctx[ctx_id]; 311 311 } 312 312 313 - static struct efa_comp_ctx *__efa_com_submit_admin_cmd(struct efa_com_admin_queue *aq, 314 - struct efa_admin_aq_entry *cmd, 315 - size_t cmd_size_in_bytes, 316 - struct efa_admin_acq_entry *comp, 317 - size_t comp_size_in_bytes) 313 + static void __efa_com_submit_admin_cmd(struct efa_com_admin_queue *aq, 314 + struct efa_comp_ctx *comp_ctx, 315 + struct efa_admin_aq_entry *cmd, 316 + size_t cmd_size_in_bytes, 317 + struct efa_admin_acq_entry *comp, 318 + size_t comp_size_in_bytes) 318 319 { 319 320 struct efa_admin_aq_entry *aqe; 320 - struct efa_comp_ctx *comp_ctx; 321 321 u16 queue_size_mask; 322 322 u16 cmd_id; 323 323 u16 ctx_id; 324 324 u16 pi; 325 - 326 - comp_ctx = efa_com_alloc_comp_ctx(aq); 327 - if (!comp_ctx) 328 - return ERR_PTR(-EINVAL); 329 325 330 326 queue_size_mask = aq->depth - 1; 331 327 pi = aq->sq.pc & queue_size_mask; ··· 356 360 357 361 /* barrier not needed in case of writel */ 358 362 writel(aq->sq.pc, aq->sq.db_addr); 359 - 360 - return comp_ctx; 361 363 } 362 364 363 365 static inline int efa_com_init_comp_ctxt(struct efa_com_admin_queue *aq) ··· 388 394 return 0; 389 395 } 390 396 391 - static struct efa_comp_ctx *efa_com_submit_admin_cmd(struct efa_com_admin_queue *aq, 392 - struct efa_admin_aq_entry *cmd, 393 - size_t cmd_size_in_bytes, 394 - struct efa_admin_acq_entry *comp, 395 - size_t comp_size_in_bytes) 397 + static int efa_com_submit_admin_cmd(struct efa_com_admin_queue *aq, 398 + struct efa_comp_ctx *comp_ctx, 399 + struct efa_admin_aq_entry *cmd, 400 + size_t cmd_size_in_bytes, 401 + struct efa_admin_acq_entry *comp, 402 + size_t comp_size_in_bytes) 396 403 { 397 - struct efa_comp_ctx *comp_ctx; 398 - 399 404 spin_lock(&aq->sq.lock); 400 405 if (!test_bit(EFA_AQ_STATE_RUNNING_BIT, &aq->state)) { 401 406 ibdev_err_ratelimited(aq->efa_dev, "Admin queue is closed\n"); 402 407 spin_unlock(&aq->sq.lock); 403 - return ERR_PTR(-ENODEV); 408 + return -ENODEV; 404 409 } 405 410 406 - comp_ctx = __efa_com_submit_admin_cmd(aq, cmd, cmd_size_in_bytes, comp, 407 - comp_size_in_bytes); 411 + __efa_com_submit_admin_cmd(aq, comp_ctx, cmd, cmd_size_in_bytes, comp, 412 + comp_size_in_bytes); 408 413 spin_unlock(&aq->sq.lock); 409 - if (IS_ERR(comp_ctx)) 410 - clear_bit(EFA_AQ_STATE_RUNNING_BIT, &aq->state); 411 414 412 - return comp_ctx; 415 + return 0; 413 416 } 414 417 415 418 static int efa_com_handle_single_admin_completion(struct efa_com_admin_queue *aq, ··· 503 512 { 504 513 unsigned long timeout; 505 514 unsigned long flags; 506 - int err; 507 515 508 516 timeout = jiffies + usecs_to_jiffies(aq->completion_timeout); 509 517 ··· 522 532 atomic64_inc(&aq->stats.no_completion); 523 533 524 534 clear_bit(EFA_AQ_STATE_RUNNING_BIT, &aq->state); 525 - err = -ETIME; 526 - goto out; 535 + return -ETIME; 527 536 } 528 537 529 538 msleep(aq->poll_interval); 530 539 } 531 540 532 - err = efa_com_comp_status_to_errno(comp_ctx->user_cqe->acq_common_descriptor.status); 533 - out: 534 - efa_com_dealloc_comp_ctx(aq, comp_ctx); 535 - return err; 541 + return efa_com_comp_status_to_errno( 542 + comp_ctx->user_cqe->acq_common_descriptor.status); 536 543 } 537 544 538 545 static int efa_com_wait_and_process_admin_cq_interrupts(struct efa_comp_ctx *comp_ctx, 539 546 struct efa_com_admin_queue *aq) 540 547 { 541 548 unsigned long flags; 542 - int err; 543 549 544 550 wait_for_completion_timeout(&comp_ctx->wait_event, 545 551 usecs_to_jiffies(aq->completion_timeout)); ··· 571 585 aq->cq.cc); 572 586 573 587 clear_bit(EFA_AQ_STATE_RUNNING_BIT, &aq->state); 574 - err = -ETIME; 575 - goto out; 588 + return -ETIME; 576 589 } 577 590 578 - err = efa_com_comp_status_to_errno(comp_ctx->user_cqe->acq_common_descriptor.status); 579 - out: 580 - efa_com_dealloc_comp_ctx(aq, comp_ctx); 581 - return err; 591 + return efa_com_comp_status_to_errno( 592 + comp_ctx->user_cqe->acq_common_descriptor.status); 582 593 } 583 594 584 595 /* ··· 625 642 ibdev_dbg(aq->efa_dev, "%s (opcode %d)\n", 626 643 efa_com_cmd_str(cmd->aq_common_descriptor.opcode), 627 644 cmd->aq_common_descriptor.opcode); 628 - comp_ctx = efa_com_submit_admin_cmd(aq, cmd, cmd_size, comp, comp_size); 629 - if (IS_ERR(comp_ctx)) { 645 + 646 + comp_ctx = efa_com_alloc_comp_ctx(aq); 647 + if (!comp_ctx) { 648 + clear_bit(EFA_AQ_STATE_RUNNING_BIT, &aq->state); 649 + up(&aq->avail_cmds); 650 + return -EINVAL; 651 + } 652 + 653 + err = efa_com_submit_admin_cmd(aq, comp_ctx, cmd, cmd_size, comp, comp_size); 654 + if (err) { 630 655 ibdev_err_ratelimited( 631 656 aq->efa_dev, 632 - "Failed to submit command %s (opcode %u) err %pe\n", 657 + "Failed to submit command %s (opcode %u) err %d\n", 633 658 efa_com_cmd_str(cmd->aq_common_descriptor.opcode), 634 - cmd->aq_common_descriptor.opcode, comp_ctx); 659 + cmd->aq_common_descriptor.opcode, err); 635 660 661 + efa_com_dealloc_comp_ctx(aq, comp_ctx); 636 662 up(&aq->avail_cmds); 637 663 atomic64_inc(&aq->stats.cmd_err); 638 - return PTR_ERR(comp_ctx); 664 + return err; 639 665 } 640 666 641 667 err = efa_com_wait_and_process_admin_cq(comp_ctx, aq); 642 668 if (err) { 643 669 ibdev_err_ratelimited( 644 670 aq->efa_dev, 645 - "Failed to process command %s (opcode %u) comp_status %d err %d\n", 671 + "Failed to process command %s (opcode %u) err %d\n", 646 672 efa_com_cmd_str(cmd->aq_common_descriptor.opcode), 647 - cmd->aq_common_descriptor.opcode, 648 - comp_ctx->user_cqe->acq_common_descriptor.status, err); 673 + cmd->aq_common_descriptor.opcode, err); 649 674 atomic64_inc(&aq->stats.cmd_err); 650 675 } 651 676 677 + efa_com_dealloc_comp_ctx(aq, comp_ctx); 652 678 up(&aq->avail_cmds); 653 679 654 680 return err;
+3 -1
drivers/infiniband/hw/ionic/ionic_controlpath.c
··· 508 508 { 509 509 const struct ib_global_route *grh; 510 510 enum rdma_network_type net; 511 + u8 smac[ETH_ALEN]; 511 512 u16 vlan; 512 513 int rc; 513 514 ··· 519 518 520 519 grh = rdma_ah_read_grh(attr); 521 520 522 - rc = rdma_read_gid_l2_fields(grh->sgid_attr, &vlan, &hdr->eth.smac_h[0]); 521 + rc = rdma_read_gid_l2_fields(grh->sgid_attr, &vlan, smac); 523 522 if (rc) 524 523 return rc; 525 524 ··· 537 536 if (rc) 538 537 return rc; 539 538 539 + ether_addr_copy(hdr->eth.smac_h, smac); 540 540 ether_addr_copy(hdr->eth.dmac_h, attr->roce.dmac); 541 541 542 542 if (net == RDMA_NETWORK_IPV4) {
+16 -13
drivers/infiniband/hw/irdma/cm.c
··· 2241 2241 int oldarpindex; 2242 2242 int arpindex; 2243 2243 struct net_device *netdev = iwdev->netdev; 2244 + int ret; 2244 2245 2245 2246 /* create an hte and cm_node for this instance */ 2246 2247 cm_node = kzalloc_obj(*cm_node, GFP_ATOMIC); 2247 2248 if (!cm_node) 2248 - return NULL; 2249 + return ERR_PTR(-ENOMEM); 2249 2250 2250 2251 /* set our node specific transport info */ 2251 2252 cm_node->ipv4 = cm_info->ipv4; ··· 2349 2348 arpindex = -EINVAL; 2350 2349 } 2351 2350 2352 - if (arpindex < 0) 2351 + if (arpindex < 0) { 2352 + ret = -EINVAL; 2353 2353 goto err; 2354 + } 2354 2355 2355 2356 ether_addr_copy(cm_node->rem_mac, 2356 2357 iwdev->rf->arp_table[arpindex].mac_addr); ··· 2363 2360 err: 2364 2361 kfree(cm_node); 2365 2362 2366 - return NULL; 2363 + return ERR_PTR(ret); 2367 2364 } 2368 2365 2369 2366 static void irdma_destroy_connection(struct irdma_cm_node *cm_node) ··· 3024 3021 3025 3022 /* create a CM connection node */ 3026 3023 cm_node = irdma_make_cm_node(cm_core, iwdev, cm_info, NULL); 3027 - if (!cm_node) 3028 - return -ENOMEM; 3024 + if (IS_ERR(cm_node)) 3025 + return PTR_ERR(cm_node); 3029 3026 3030 3027 /* set our node side to client (active) side */ 3031 3028 cm_node->tcp_cntxt.client = 1; ··· 3222 3219 cm_info.cm_id = listener->cm_id; 3223 3220 cm_node = irdma_make_cm_node(cm_core, iwdev, &cm_info, 3224 3221 listener); 3225 - if (!cm_node) { 3222 + if (IS_ERR(cm_node)) { 3226 3223 ibdev_dbg(&cm_core->iwdev->ibdev, 3227 - "CM: allocate node failed\n"); 3224 + "CM: allocate node failed ret=%ld\n", PTR_ERR(cm_node)); 3228 3225 refcount_dec(&listener->refcnt); 3229 3226 return; 3230 3227 } ··· 4242 4239 irdma_cm_event_reset(event); 4243 4240 break; 4244 4241 case IRDMA_CM_EVENT_CONNECTED: 4245 - if (!event->cm_node->cm_id || 4246 - event->cm_node->state != IRDMA_CM_STATE_OFFLOADED) 4242 + if (!cm_node->cm_id || 4243 + cm_node->state != IRDMA_CM_STATE_OFFLOADED) 4247 4244 break; 4248 4245 irdma_cm_event_connected(event); 4249 4246 break; 4250 4247 case IRDMA_CM_EVENT_MPA_REJECT: 4251 - if (!event->cm_node->cm_id || 4248 + if (!cm_node->cm_id || 4252 4249 cm_node->state == IRDMA_CM_STATE_OFFLOADED) 4253 4250 break; 4254 4251 irdma_send_cm_event(cm_node, cm_node->cm_id, 4255 4252 IW_CM_EVENT_CONNECT_REPLY, -ECONNREFUSED); 4256 4253 break; 4257 4254 case IRDMA_CM_EVENT_ABORTED: 4258 - if (!event->cm_node->cm_id || 4259 - event->cm_node->state == IRDMA_CM_STATE_OFFLOADED) 4255 + if (!cm_node->cm_id || 4256 + cm_node->state == IRDMA_CM_STATE_OFFLOADED) 4260 4257 break; 4261 4258 irdma_event_connect_error(event); 4262 4259 break; ··· 4266 4263 break; 4267 4264 } 4268 4265 4269 - irdma_rem_ref_cm_node(event->cm_node); 4266 + irdma_rem_ref_cm_node(cm_node); 4270 4267 kfree(event); 4271 4268 } 4272 4269
+22 -17
drivers/infiniband/hw/irdma/uk.c
··· 1438 1438 * irdma_round_up_wq - return round up qp wq depth 1439 1439 * @wqdepth: wq depth in quanta to round up 1440 1440 */ 1441 - static int irdma_round_up_wq(u32 wqdepth) 1441 + static u64 irdma_round_up_wq(u64 wqdepth) 1442 1442 { 1443 1443 int scount = 1; 1444 1444 ··· 1491 1491 int irdma_get_sqdepth(struct irdma_uk_attrs *uk_attrs, u32 sq_size, u8 shift, 1492 1492 u32 *sqdepth) 1493 1493 { 1494 - u32 min_size = (u32)uk_attrs->min_hw_wq_size << shift; 1494 + u32 min_hw_quanta = (u32)uk_attrs->min_hw_wq_size << shift; 1495 + u64 hw_quanta = 1496 + irdma_round_up_wq(((u64)sq_size << shift) + IRDMA_SQ_RSVD); 1495 1497 1496 - *sqdepth = irdma_round_up_wq((sq_size << shift) + IRDMA_SQ_RSVD); 1497 - 1498 - if (*sqdepth < min_size) 1499 - *sqdepth = min_size; 1500 - else if (*sqdepth > uk_attrs->max_hw_wq_quanta) 1498 + if (hw_quanta < min_hw_quanta) 1499 + hw_quanta = min_hw_quanta; 1500 + else if (hw_quanta > uk_attrs->max_hw_wq_quanta) 1501 1501 return -EINVAL; 1502 1502 1503 + *sqdepth = hw_quanta; 1503 1504 return 0; 1504 1505 } 1505 1506 ··· 1514 1513 int irdma_get_rqdepth(struct irdma_uk_attrs *uk_attrs, u32 rq_size, u8 shift, 1515 1514 u32 *rqdepth) 1516 1515 { 1517 - u32 min_size = (u32)uk_attrs->min_hw_wq_size << shift; 1516 + u32 min_hw_quanta = (u32)uk_attrs->min_hw_wq_size << shift; 1517 + u64 hw_quanta = 1518 + irdma_round_up_wq(((u64)rq_size << shift) + IRDMA_RQ_RSVD); 1518 1519 1519 - *rqdepth = irdma_round_up_wq((rq_size << shift) + IRDMA_RQ_RSVD); 1520 - 1521 - if (*rqdepth < min_size) 1522 - *rqdepth = min_size; 1523 - else if (*rqdepth > uk_attrs->max_hw_rq_quanta) 1520 + if (hw_quanta < min_hw_quanta) 1521 + hw_quanta = min_hw_quanta; 1522 + else if (hw_quanta > uk_attrs->max_hw_rq_quanta) 1524 1523 return -EINVAL; 1525 1524 1525 + *rqdepth = hw_quanta; 1526 1526 return 0; 1527 1527 } 1528 1528 ··· 1537 1535 int irdma_get_srqdepth(struct irdma_uk_attrs *uk_attrs, u32 srq_size, u8 shift, 1538 1536 u32 *srqdepth) 1539 1537 { 1540 - *srqdepth = irdma_round_up_wq((srq_size << shift) + IRDMA_RQ_RSVD); 1538 + u32 min_hw_quanta = (u32)uk_attrs->min_hw_wq_size << shift; 1539 + u64 hw_quanta = 1540 + irdma_round_up_wq(((u64)srq_size << shift) + IRDMA_RQ_RSVD); 1541 1541 1542 - if (*srqdepth < ((u32)uk_attrs->min_hw_wq_size << shift)) 1543 - *srqdepth = uk_attrs->min_hw_wq_size << shift; 1544 - else if (*srqdepth > uk_attrs->max_hw_srq_quanta) 1542 + if (hw_quanta < min_hw_quanta) 1543 + hw_quanta = min_hw_quanta; 1544 + else if (hw_quanta > uk_attrs->max_hw_srq_quanta) 1545 1545 return -EINVAL; 1546 1546 1547 + *srqdepth = hw_quanta; 1547 1548 return 0; 1548 1549 } 1549 1550
-2
drivers/infiniband/hw/irdma/utils.c
··· 2322 2322 struct irdma_qp *qp = sc_qp->qp_uk.back_qp; 2323 2323 struct ib_qp_attr attr; 2324 2324 2325 - if (qp->iwdev->rf->reset) 2326 - return; 2327 2325 attr.qp_state = IB_QPS_ERR; 2328 2326 2329 2327 if (rdma_protocol_roce(qp->ibqp.device, 1))
+6 -4
drivers/infiniband/hw/irdma/verbs.c
··· 558 558 } 559 559 560 560 irdma_qp_rem_ref(&iwqp->ibqp); 561 - wait_for_completion(&iwqp->free_qp); 561 + if (!iwdev->rf->reset) 562 + wait_for_completion(&iwqp->free_qp); 562 563 irdma_free_lsmm_rsrc(iwqp); 563 564 irdma_cqp_qp_destroy_cmd(&iwdev->rf->sc_dev, &iwqp->sc_qp); 564 565 ··· 1106 1105 spin_lock_init(&iwqp->sc_qp.pfpdu.lock); 1107 1106 iwqp->sig_all = init_attr->sq_sig_type == IB_SIGNAL_ALL_WR; 1108 1107 rf->qp_table[qp_num] = iwqp; 1108 + init_completion(&iwqp->free_qp); 1109 1109 1110 1110 if (udata) { 1111 1111 /* GEN_1 legacy support with libi40iw does not have expanded uresp struct */ ··· 1131 1129 } 1132 1130 } 1133 1131 1134 - init_completion(&iwqp->free_qp); 1135 1132 return 0; 1136 1133 1137 1134 error: ··· 1463 1462 ctx_info->remote_atomics_en = true; 1464 1463 } 1465 1464 1466 - wait_event(iwqp->mod_qp_waitq, !atomic_read(&iwqp->hw_mod_qp_pend)); 1467 - 1468 1465 ibdev_dbg(&iwdev->ibdev, 1469 1466 "VERBS: caller: %pS qp_id=%d to_ibqpstate=%d ibqpstate=%d irdma_qpstate=%d attr_mask=0x%x\n", 1470 1467 __builtin_return_address(0), ibqp->qp_num, attr->qp_state, ··· 1539 1540 case IB_QPS_ERR: 1540 1541 case IB_QPS_RESET: 1541 1542 if (iwqp->iwarp_state == IRDMA_QP_STATE_ERROR) { 1543 + iwqp->ibqp_state = attr->qp_state; 1542 1544 spin_unlock_irqrestore(&iwqp->lock, flags); 1543 1545 if (udata && udata->inlen) { 1544 1546 if (ib_copy_from_udata(&ureq, udata, ··· 1745 1745 case IB_QPS_ERR: 1746 1746 case IB_QPS_RESET: 1747 1747 if (iwqp->iwarp_state == IRDMA_QP_STATE_ERROR) { 1748 + iwqp->ibqp_state = attr->qp_state; 1748 1749 spin_unlock_irqrestore(&iwqp->lock, flags); 1749 1750 if (udata && udata->inlen) { 1750 1751 if (ib_copy_from_udata(&ureq, udata, ··· 3724 3723 3725 3724 err: 3726 3725 ib_umem_release(region); 3726 + iwmr->region = NULL; 3727 3727 return err; 3728 3728 } 3729 3729
+1 -1
drivers/iommu/generic_pt/fmt/amdv1.h
··· 191 191 } 192 192 #define pt_load_entry_raw amdv1pt_load_entry_raw 193 193 194 - static inline void 194 + static __always_inline void 195 195 amdv1pt_install_leaf_entry(struct pt_state *pts, pt_oaddr_t oa, 196 196 unsigned int oasz_lg2, 197 197 const struct pt_write_attrs *attrs)
+1 -1
drivers/iommu/generic_pt/iommu_pt.h
··· 1057 1057 1058 1058 pt_walk_range(&range, __unmap_range, &unmap); 1059 1059 1060 - gather_range_pages(iotlb_gather, iommu_table, iova, len, 1060 + gather_range_pages(iotlb_gather, iommu_table, iova, unmap.unmapped, 1061 1061 &unmap.free_list); 1062 1062 1063 1063 return unmap.unmapped;
+3
drivers/irqchip/irq-qcom-mpm.c
··· 306 306 if (ret < 0) 307 307 return ret; 308 308 309 + mbox_client_txdone(priv->mbox_chan, 0); 310 + 309 311 return 0; 310 312 } 311 313 ··· 436 434 } 437 435 438 436 priv->mbox_client.dev = dev; 437 + priv->mbox_client.knows_txdone = true; 439 438 priv->mbox_chan = mbox_request_channel(&priv->mbox_client, 0); 440 439 if (IS_ERR(priv->mbox_chan)) { 441 440 ret = PTR_ERR(priv->mbox_chan);
+1 -1
drivers/irqchip/irq-renesas-rzv2h.c
··· 621 621 return 0; 622 622 623 623 pm_put: 624 - pm_runtime_put(&pdev->dev); 624 + pm_runtime_put_sync(&pdev->dev); 625 625 626 626 return ret; 627 627 }
-2
drivers/media/i2c/ccs/ccs-core.c
··· 3080 3080 struct v4l2_rect *crop = 3081 3081 v4l2_subdev_state_get_crop(sd_state, pad); 3082 3082 3083 - guard(mutex)(&sensor->mutex); 3084 - 3085 3083 ccs_get_native_size(ssd, crop); 3086 3084 3087 3085 fmt->width = crop->width;
+5 -4
drivers/media/usb/uvc/uvc_video.c
··· 1751 1751 /* 1752 1752 * Free transfer buffers. 1753 1753 */ 1754 - static void uvc_free_urb_buffers(struct uvc_streaming *stream) 1754 + static void uvc_free_urb_buffers(struct uvc_streaming *stream, 1755 + unsigned int size) 1755 1756 { 1756 1757 struct usb_device *udev = stream->dev->udev; 1757 1758 struct uvc_urb *uvc_urb; ··· 1761 1760 if (!uvc_urb->buffer) 1762 1761 continue; 1763 1762 1764 - usb_free_noncoherent(udev, stream->urb_size, uvc_urb->buffer, 1763 + usb_free_noncoherent(udev, size, uvc_urb->buffer, 1765 1764 uvc_stream_dir(stream), uvc_urb->sgt); 1766 1765 uvc_urb->buffer = NULL; 1767 1766 uvc_urb->sgt = NULL; ··· 1821 1820 1822 1821 if (!uvc_alloc_urb_buffer(stream, uvc_urb, urb_size, 1823 1822 gfp_flags)) { 1824 - uvc_free_urb_buffers(stream); 1823 + uvc_free_urb_buffers(stream, urb_size); 1825 1824 break; 1826 1825 } 1827 1826 ··· 1869 1868 } 1870 1869 1871 1870 if (free_buffers) 1872 - uvc_free_urb_buffers(stream); 1871 + uvc_free_urb_buffers(stream, stream->urb_size); 1873 1872 } 1874 1873 1875 1874 /*
+1 -1
drivers/net/bonding/bond_main.c
··· 5324 5324 if (!(bond_slave_is_up(slave) && slave->link == BOND_LINK_UP)) 5325 5325 continue; 5326 5326 5327 - if (bond_is_last_slave(bond, slave)) { 5327 + if (i + 1 == slaves_count) { 5328 5328 skb2 = skb; 5329 5329 skb_used = true; 5330 5330 } else {
+19 -1
drivers/net/ethernet/airoha/airoha_eth.c
··· 795 795 796 796 static void airoha_qdma_cleanup_rx_queue(struct airoha_queue *q) 797 797 { 798 - struct airoha_eth *eth = q->qdma->eth; 798 + struct airoha_qdma *qdma = q->qdma; 799 + struct airoha_eth *eth = qdma->eth; 800 + int qid = q - &qdma->q_rx[0]; 799 801 800 802 while (q->queued) { 801 803 struct airoha_queue_entry *e = &q->entry[q->tail]; 804 + struct airoha_qdma_desc *desc = &q->desc[q->tail]; 802 805 struct page *page = virt_to_head_page(e->buf); 803 806 804 807 dma_sync_single_for_cpu(eth->dev, e->dma_addr, e->dma_len, 805 808 page_pool_get_dma_dir(q->page_pool)); 806 809 page_pool_put_full_page(q->page_pool, page, false); 810 + /* Reset DMA descriptor */ 811 + WRITE_ONCE(desc->ctrl, 0); 812 + WRITE_ONCE(desc->addr, 0); 813 + WRITE_ONCE(desc->data, 0); 814 + WRITE_ONCE(desc->msg0, 0); 815 + WRITE_ONCE(desc->msg1, 0); 816 + WRITE_ONCE(desc->msg2, 0); 817 + WRITE_ONCE(desc->msg3, 0); 818 + 807 819 q->tail = (q->tail + 1) % q->ndesc; 808 820 q->queued--; 809 821 } 822 + 823 + q->head = q->tail; 824 + airoha_qdma_rmw(qdma, REG_RX_DMA_IDX(qid), RX_RING_DMA_IDX_MASK, 825 + FIELD_PREP(RX_RING_DMA_IDX_MASK, q->tail)); 810 826 } 811 827 812 828 static int airoha_qdma_init_rx(struct airoha_qdma *qdma) ··· 2973 2957 if (err) 2974 2958 return err; 2975 2959 } 2960 + 2961 + set_bit(DEV_STATE_REGISTERED, &eth->state); 2976 2962 2977 2963 return 0; 2978 2964 }
+1
drivers/net/ethernet/airoha/airoha_eth.h
··· 88 88 89 89 enum { 90 90 DEV_STATE_INITIALIZED, 91 + DEV_STATE_REGISTERED, 91 92 }; 92 93 93 94 enum {
+7
drivers/net/ethernet/airoha/airoha_ppe.c
··· 1389 1389 struct airoha_eth *eth = ppe->eth; 1390 1390 int err = 0; 1391 1391 1392 + /* Netfilter flowtable can try to offload flower rules while not all 1393 + * the net_devices are registered or initialized. Delay offloading 1394 + * until all net_devices are registered in the system. 1395 + */ 1396 + if (!test_bit(DEV_STATE_REGISTERED, &eth->state)) 1397 + return -EBUSY; 1398 + 1392 1399 mutex_lock(&flow_offload_mutex); 1393 1400 1394 1401 if (!eth->npu)
+52 -24
drivers/net/ethernet/broadcom/bnxt/bnxt.c
··· 8037 8037 ulp_msix = bnxt_get_avail_msix(bp, bp->ulp_num_msix_want); 8038 8038 if (!ulp_msix) 8039 8039 bnxt_set_ulp_stat_ctxs(bp, 0); 8040 + else 8041 + bnxt_set_dflt_ulp_stat_ctxs(bp); 8040 8042 8041 8043 if (ulp_msix > bp->ulp_num_msix_want) 8042 8044 ulp_msix = bp->ulp_num_msix_want; ··· 8664 8662 struct hwrm_func_backing_store_qcaps_v2_output *resp; 8665 8663 struct hwrm_func_backing_store_qcaps_v2_input *req; 8666 8664 struct bnxt_ctx_mem_info *ctx = bp->ctx; 8667 - u16 type; 8665 + u16 type, next_type = 0; 8668 8666 int rc; 8669 8667 8670 8668 rc = hwrm_req_init(bp, req, HWRM_FUNC_BACKING_STORE_QCAPS_V2); ··· 8680 8678 8681 8679 resp = hwrm_req_hold(bp, req); 8682 8680 8683 - for (type = 0; type < BNXT_CTX_V2_MAX; ) { 8681 + for (type = 0; type < BNXT_CTX_V2_MAX; type = next_type) { 8684 8682 struct bnxt_ctx_mem_type *ctxm = &ctx->ctx_arr[type]; 8685 8683 u8 init_val, init_off, i; 8686 8684 u32 max_entries; ··· 8693 8691 if (rc) 8694 8692 goto ctx_done; 8695 8693 flags = le32_to_cpu(resp->flags); 8696 - type = le16_to_cpu(resp->next_valid_type); 8694 + next_type = le16_to_cpu(resp->next_valid_type); 8697 8695 if (!(flags & BNXT_CTX_MEM_TYPE_VALID)) { 8698 8696 bnxt_free_one_ctx_mem(bp, ctxm, true); 8699 8697 continue; ··· 8708 8706 else 8709 8707 continue; 8710 8708 } 8711 - ctxm->type = le16_to_cpu(resp->type); 8709 + ctxm->type = type; 8712 8710 ctxm->entry_size = entry_size; 8713 8711 ctxm->flags = flags; 8714 8712 ctxm->instance_bmap = le32_to_cpu(resp->instance_bit_map); ··· 12985 12983 return bp->num_tc ? bp->tx_nr_rings / bp->num_tc : bp->tx_nr_rings; 12986 12984 } 12987 12985 12986 + static void bnxt_set_xdp_tx_rings(struct bnxt *bp) 12987 + { 12988 + bp->tx_nr_rings_xdp = bp->tx_nr_rings_per_tc; 12989 + bp->tx_nr_rings += bp->tx_nr_rings_xdp; 12990 + } 12991 + 12992 + static void bnxt_adj_tx_rings(struct bnxt *bp) 12993 + { 12994 + /* Make adjustments if reserved TX rings are less than requested */ 12995 + bp->tx_nr_rings -= bp->tx_nr_rings_xdp; 12996 + bp->tx_nr_rings_per_tc = bnxt_tx_nr_rings_per_tc(bp); 12997 + if (bp->tx_nr_rings_xdp) 12998 + bnxt_set_xdp_tx_rings(bp); 12999 + } 13000 + 12988 13001 static int __bnxt_open_nic(struct bnxt *bp, bool irq_re_init, bool link_re_init) 12989 13002 { 12990 13003 int rc = 0; ··· 13017 13000 if (rc) 13018 13001 return rc; 13019 13002 13020 - /* Make adjustments if reserved TX rings are less than requested */ 13021 - bp->tx_nr_rings -= bp->tx_nr_rings_xdp; 13022 - bp->tx_nr_rings_per_tc = bnxt_tx_nr_rings_per_tc(bp); 13023 - if (bp->tx_nr_rings_xdp) { 13024 - bp->tx_nr_rings_xdp = bp->tx_nr_rings_per_tc; 13025 - bp->tx_nr_rings += bp->tx_nr_rings_xdp; 13026 - } 13003 + bnxt_adj_tx_rings(bp); 13027 13004 rc = bnxt_alloc_mem(bp, irq_re_init); 13028 13005 if (rc) { 13029 13006 netdev_err(bp->dev, "bnxt_alloc_mem err: %x\n", rc); ··· 15438 15427 return 0; 15439 15428 } 15440 15429 15430 + void bnxt_set_cp_rings(struct bnxt *bp, bool sh) 15431 + { 15432 + int tx_cp = bnxt_num_tx_to_cp(bp, bp->tx_nr_rings); 15433 + 15434 + bp->cp_nr_rings = sh ? max_t(int, tx_cp, bp->rx_nr_rings) : 15435 + tx_cp + bp->rx_nr_rings; 15436 + } 15437 + 15441 15438 int bnxt_setup_mq_tc(struct net_device *dev, u8 tc) 15442 15439 { 15443 15440 struct bnxt *bp = netdev_priv(dev); 15444 15441 bool sh = false; 15445 - int rc, tx_cp; 15442 + int rc; 15446 15443 15447 15444 if (tc > bp->max_tc) { 15448 15445 netdev_err(dev, "Too many traffic classes requested: %d. Max supported is %d.\n", ··· 15483 15464 bp->num_tc = 0; 15484 15465 } 15485 15466 bp->tx_nr_rings += bp->tx_nr_rings_xdp; 15486 - tx_cp = bnxt_num_tx_to_cp(bp, bp->tx_nr_rings); 15487 - bp->cp_nr_rings = sh ? max_t(int, tx_cp, bp->rx_nr_rings) : 15488 - tx_cp + bp->rx_nr_rings; 15467 + bnxt_set_cp_rings(bp, sh); 15489 15468 15490 15469 if (netif_running(bp->dev)) 15491 15470 return bnxt_open_nic(bp, true, false); ··· 16537 16520 bp->tx_nr_rings = bnxt_tx_nr_rings(bp); 16538 16521 } 16539 16522 16523 + static void bnxt_adj_dflt_rings(struct bnxt *bp, bool sh) 16524 + { 16525 + if (sh) 16526 + bnxt_trim_dflt_sh_rings(bp); 16527 + else 16528 + bp->cp_nr_rings = bp->tx_nr_rings_per_tc + bp->rx_nr_rings; 16529 + bp->tx_nr_rings = bnxt_tx_nr_rings(bp); 16530 + if (sh && READ_ONCE(bp->xdp_prog)) { 16531 + bnxt_set_xdp_tx_rings(bp); 16532 + bnxt_set_cp_rings(bp, true); 16533 + } 16534 + } 16535 + 16540 16536 static int bnxt_set_dflt_rings(struct bnxt *bp, bool sh) 16541 16537 { 16542 16538 int dflt_rings, max_rx_rings, max_tx_rings, rc; ··· 16575 16545 return rc; 16576 16546 bp->rx_nr_rings = min_t(int, dflt_rings, max_rx_rings); 16577 16547 bp->tx_nr_rings_per_tc = min_t(int, dflt_rings, max_tx_rings); 16578 - if (sh) 16579 - bnxt_trim_dflt_sh_rings(bp); 16580 - else 16581 - bp->cp_nr_rings = bp->tx_nr_rings_per_tc + bp->rx_nr_rings; 16582 - bp->tx_nr_rings = bnxt_tx_nr_rings(bp); 16548 + 16549 + bnxt_adj_dflt_rings(bp, sh); 16583 16550 16584 16551 avail_msix = bnxt_get_max_func_irqs(bp) - bp->cp_nr_rings; 16585 16552 if (avail_msix >= BNXT_MIN_ROCE_CP_RINGS) { ··· 16589 16562 rc = __bnxt_reserve_rings(bp); 16590 16563 if (rc && rc != -ENODEV) 16591 16564 netdev_warn(bp->dev, "Unable to reserve tx rings\n"); 16592 - bp->tx_nr_rings_per_tc = bnxt_tx_nr_rings_per_tc(bp); 16565 + 16566 + bnxt_adj_tx_rings(bp); 16593 16567 if (sh) 16594 - bnxt_trim_dflt_sh_rings(bp); 16568 + bnxt_adj_dflt_rings(bp, true); 16595 16569 16596 16570 /* Rings may have been trimmed, re-reserve the trimmed rings. */ 16597 16571 if (bnxt_need_reserve_rings(bp)) { 16598 16572 rc = __bnxt_reserve_rings(bp); 16599 16573 if (rc && rc != -ENODEV) 16600 16574 netdev_warn(bp->dev, "2nd rings reservation failed.\n"); 16601 - bp->tx_nr_rings_per_tc = bnxt_tx_nr_rings_per_tc(bp); 16575 + bnxt_adj_tx_rings(bp); 16602 16576 } 16603 16577 if (BNXT_CHIP_TYPE_NITRO_A0(bp)) { 16604 16578 bp->rx_nr_rings++; ··· 16633 16605 if (rc) 16634 16606 goto init_dflt_ring_err; 16635 16607 16636 - bp->tx_nr_rings_per_tc = bnxt_tx_nr_rings_per_tc(bp); 16608 + bnxt_adj_tx_rings(bp); 16637 16609 16638 16610 bnxt_set_dflt_rfs(bp); 16639 16611
+1
drivers/net/ethernet/broadcom/bnxt/bnxt.h
··· 3004 3004 int tx_xdp); 3005 3005 int bnxt_fw_init_one(struct bnxt *bp); 3006 3006 bool bnxt_hwrm_reset_permitted(struct bnxt *bp); 3007 + void bnxt_set_cp_rings(struct bnxt *bp, bool sh); 3007 3008 int bnxt_setup_mq_tc(struct net_device *dev, u8 tc); 3008 3009 struct bnxt_ntuple_filter *bnxt_lookup_ntp_filter_from_idx(struct bnxt *bp, 3009 3010 struct bnxt_ntuple_filter *fltr, u32 idx);
+1 -4
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c
··· 946 946 bool sh = false; 947 947 int tx_xdp = 0; 948 948 int rc = 0; 949 - int tx_cp; 950 949 951 950 if (channel->other_count) 952 951 return -EINVAL; ··· 1033 1034 if (tcs > 1) 1034 1035 bp->tx_nr_rings = bp->tx_nr_rings_per_tc * tcs + tx_xdp; 1035 1036 1036 - tx_cp = bnxt_num_tx_to_cp(bp, bp->tx_nr_rings); 1037 - bp->cp_nr_rings = sh ? max_t(int, tx_cp, bp->rx_nr_rings) : 1038 - tx_cp + bp->rx_nr_rings; 1037 + bnxt_set_cp_rings(bp, sh); 1039 1038 1040 1039 /* After changing number of rx channels, update NTUPLE feature. */ 1041 1040 netdev_update_features(dev);
+2 -3
drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c
··· 384 384 static int bnxt_xdp_set(struct bnxt *bp, struct bpf_prog *prog) 385 385 { 386 386 struct net_device *dev = bp->dev; 387 - int tx_xdp = 0, tx_cp, rc, tc; 387 + int tx_xdp = 0, rc, tc; 388 388 struct bpf_prog *old; 389 389 390 390 netdev_assert_locked(dev); ··· 431 431 } 432 432 bp->tx_nr_rings_xdp = tx_xdp; 433 433 bp->tx_nr_rings = bp->tx_nr_rings_per_tc * tc + tx_xdp; 434 - tx_cp = bnxt_num_tx_to_cp(bp, bp->tx_nr_rings); 435 - bp->cp_nr_rings = max_t(int, tx_cp, bp->rx_nr_rings); 434 + bnxt_set_cp_rings(bp, true); 436 435 bnxt_set_tpa_flags(bp); 437 436 bnxt_set_ring_params(bp); 438 437
+1 -1
drivers/net/ethernet/broadcom/tg3.c
··· 12299 12299 ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.advertising, 12300 12300 advertising); 12301 12301 12302 - if (netif_running(dev) && tp->link_up) { 12302 + if (netif_running(dev) && netif_carrier_ok(dev)) { 12303 12303 cmd->base.speed = tp->link_config.active_speed; 12304 12304 cmd->base.duplex = tp->link_config.active_duplex; 12305 12305 ethtool_convert_legacy_u32_to_link_mode(
+6 -4
drivers/net/ethernet/cadence/macb_pci.c
··· 96 96 return 0; 97 97 98 98 err_plat_dev_register: 99 - clk_unregister(plat_data.hclk); 99 + clk_unregister_fixed_rate(plat_data.hclk); 100 100 101 101 err_hclk_register: 102 - clk_unregister(plat_data.pclk); 102 + clk_unregister_fixed_rate(plat_data.pclk); 103 103 104 104 err_pclk_register: 105 105 return err; ··· 109 109 { 110 110 struct platform_device *plat_dev = pci_get_drvdata(pdev); 111 111 struct macb_platform_data *plat_data = dev_get_platdata(&plat_dev->dev); 112 + struct clk *pclk = plat_data->pclk; 113 + struct clk *hclk = plat_data->hclk; 112 114 113 - clk_unregister(plat_data->pclk); 114 - clk_unregister(plat_data->hclk); 115 115 platform_device_unregister(plat_dev); 116 + clk_unregister_fixed_rate(pclk); 117 + clk_unregister_fixed_rate(hclk); 116 118 } 117 119 118 120 static const struct pci_device_id dev_id_table[] = {
+24 -4
drivers/net/ethernet/faraday/ftgmac100.c
··· 977 977 priv->tx_skbs = kcalloc(MAX_TX_QUEUE_ENTRIES, sizeof(void *), 978 978 GFP_KERNEL); 979 979 if (!priv->tx_skbs) 980 - return -ENOMEM; 980 + goto err_free_rx_skbs; 981 981 982 982 /* Allocate descriptors */ 983 983 priv->rxdes = dma_alloc_coherent(priv->dev, 984 984 MAX_RX_QUEUE_ENTRIES * sizeof(struct ftgmac100_rxdes), 985 985 &priv->rxdes_dma, GFP_KERNEL); 986 986 if (!priv->rxdes) 987 - return -ENOMEM; 987 + goto err_free_tx_skbs; 988 988 priv->txdes = dma_alloc_coherent(priv->dev, 989 989 MAX_TX_QUEUE_ENTRIES * sizeof(struct ftgmac100_txdes), 990 990 &priv->txdes_dma, GFP_KERNEL); 991 991 if (!priv->txdes) 992 - return -ENOMEM; 992 + goto err_free_rxdes; 993 993 994 994 /* Allocate scratch packet buffer */ 995 995 priv->rx_scratch = dma_alloc_coherent(priv->dev, ··· 997 997 &priv->rx_scratch_dma, 998 998 GFP_KERNEL); 999 999 if (!priv->rx_scratch) 1000 - return -ENOMEM; 1000 + goto err_free_txdes; 1001 1001 1002 1002 return 0; 1003 + 1004 + err_free_txdes: 1005 + dma_free_coherent(priv->dev, 1006 + MAX_TX_QUEUE_ENTRIES * 1007 + sizeof(struct ftgmac100_txdes), 1008 + priv->txdes, priv->txdes_dma); 1009 + priv->txdes = NULL; 1010 + err_free_rxdes: 1011 + dma_free_coherent(priv->dev, 1012 + MAX_RX_QUEUE_ENTRIES * 1013 + sizeof(struct ftgmac100_rxdes), 1014 + priv->rxdes, priv->rxdes_dma); 1015 + priv->rxdes = NULL; 1016 + err_free_tx_skbs: 1017 + kfree(priv->tx_skbs); 1018 + priv->tx_skbs = NULL; 1019 + err_free_rx_skbs: 1020 + kfree(priv->rx_skbs); 1021 + priv->rx_skbs = NULL; 1022 + return -ENOMEM; 1003 1023 } 1004 1024 1005 1025 static void ftgmac100_init_rings(struct ftgmac100 *priv)
+12 -1
drivers/net/ethernet/freescale/enetc/enetc.c
··· 2578 2578 2579 2579 static void enetc_setup_txbdr(struct enetc_hw *hw, struct enetc_bdr *tx_ring) 2580 2580 { 2581 + struct enetc_si *si = container_of(hw, struct enetc_si, hw); 2581 2582 int idx = tx_ring->index; 2582 2583 u32 tbmr; 2583 2584 ··· 2592 2591 enetc_txbdr_wr(hw, idx, ENETC_TBLENR, 2593 2592 ENETC_RTBLENR_LEN(tx_ring->bd_count)); 2594 2593 2595 - /* clearing PI/CI registers for Tx not supported, adjust sw indexes */ 2594 + /* For ENETC v1, clearing PI/CI registers for Tx not supported, 2595 + * adjust sw indexes 2596 + */ 2596 2597 tx_ring->next_to_use = enetc_txbdr_rd(hw, idx, ENETC_TBPIR); 2597 2598 tx_ring->next_to_clean = enetc_txbdr_rd(hw, idx, ENETC_TBCIR); 2599 + 2600 + if (tx_ring->next_to_use != tx_ring->next_to_clean && 2601 + !is_enetc_rev1(si)) { 2602 + tx_ring->next_to_use = 0; 2603 + tx_ring->next_to_clean = 0; 2604 + enetc_txbdr_wr(hw, idx, ENETC_TBPIR, 0); 2605 + enetc_txbdr_wr(hw, idx, ENETC_TBCIR, 0); 2606 + } 2598 2607 2599 2608 /* enable Tx ints by setting pkt thr to 1 */ 2600 2609 enetc_txbdr_wr(hw, idx, ENETC_TBICR0, ENETC_TBICR0_ICEN | 0x1);
+11
drivers/net/ethernet/freescale/enetc/enetc4_hw.h
··· 134 134 135 135 /* Port operational register */ 136 136 #define ENETC4_POR 0x4100 137 + #define POR_TXDIS BIT(0) 138 + #define POR_RXDIS BIT(1) 139 + 140 + /* Port status register */ 141 + #define ENETC4_PSR 0x4104 142 + #define PSR_RX_BUSY BIT(1) 137 143 138 144 /* Port traffic class a transmit maximum SDU register */ 139 145 #define ENETC4_PTCTMSDUR(a) ((a) * 0x20 + 0x4208) ··· 178 172 179 173 /* Port internal MDIO base address, use to access PCS */ 180 174 #define ENETC4_PM_IMDIO_BASE 0x5030 175 + 176 + /* Port MAC 0/1 Interrupt Event Register */ 177 + #define ENETC4_PM_IEVENT(mac) (0x5040 + (mac) * 0x400) 178 + #define PM_IEVENT_TX_EMPTY BIT(5) 179 + #define PM_IEVENT_RX_EMPTY BIT(6) 181 180 182 181 /* Port MAC 0/1 Pause Quanta Register */ 183 182 #define ENETC4_PM_PAUSE_QUANTA(mac) (0x5054 + (mac) * 0x400)
+104 -14
drivers/net/ethernet/freescale/enetc/enetc4_pf.c
··· 444 444 enetc4_pf_reset_tc_msdu(&si->hw); 445 445 } 446 446 447 - static void enetc4_enable_trx(struct enetc_pf *pf) 448 - { 449 - struct enetc_hw *hw = &pf->si->hw; 450 - 451 - /* Enable port transmit/receive */ 452 - enetc_port_wr(hw, ENETC4_POR, 0); 453 - } 454 - 455 447 static void enetc4_configure_port(struct enetc_pf *pf) 456 448 { 457 449 enetc4_configure_port_si(pf); 458 450 enetc4_set_trx_frame_size(pf); 459 451 enetc_set_default_rss_key(pf); 460 - enetc4_enable_trx(pf); 461 452 } 462 453 463 454 static int enetc4_init_ntmp_user(struct enetc_si *si) ··· 792 801 enetc_port_wr(hw, ENETC4_PPAUOFFTR, pause_off_thresh); 793 802 } 794 803 795 - static void enetc4_enable_mac(struct enetc_pf *pf, bool en) 804 + static void enetc4_mac_wait_tx_empty(struct enetc_si *si, int mac) 796 805 { 806 + u32 val; 807 + 808 + if (read_poll_timeout(enetc_port_rd, val, 809 + val & PM_IEVENT_TX_EMPTY, 810 + 100, 10000, false, &si->hw, 811 + ENETC4_PM_IEVENT(mac))) 812 + dev_warn(&si->pdev->dev, 813 + "MAC %d TX is not empty\n", mac); 814 + } 815 + 816 + static void enetc4_mac_tx_graceful_stop(struct enetc_pf *pf) 817 + { 818 + struct enetc_hw *hw = &pf->si->hw; 819 + struct enetc_si *si = pf->si; 820 + u32 val; 821 + 822 + val = enetc_port_rd(hw, ENETC4_POR); 823 + val |= POR_TXDIS; 824 + enetc_port_wr(hw, ENETC4_POR, val); 825 + 826 + if (enetc_is_pseudo_mac(si)) 827 + return; 828 + 829 + enetc4_mac_wait_tx_empty(si, 0); 830 + if (si->hw_features & ENETC_SI_F_QBU) 831 + enetc4_mac_wait_tx_empty(si, 1); 832 + 833 + val = enetc_port_mac_rd(si, ENETC4_PM_CMD_CFG(0)); 834 + val &= ~PM_CMD_CFG_TX_EN; 835 + enetc_port_mac_wr(si, ENETC4_PM_CMD_CFG(0), val); 836 + } 837 + 838 + static void enetc4_mac_tx_enable(struct enetc_pf *pf) 839 + { 840 + struct enetc_hw *hw = &pf->si->hw; 797 841 struct enetc_si *si = pf->si; 798 842 u32 val; 799 843 800 844 val = enetc_port_mac_rd(si, ENETC4_PM_CMD_CFG(0)); 801 - val &= ~(PM_CMD_CFG_TX_EN | PM_CMD_CFG_RX_EN); 802 - val |= en ? (PM_CMD_CFG_TX_EN | PM_CMD_CFG_RX_EN) : 0; 845 + val |= PM_CMD_CFG_TX_EN; 846 + enetc_port_mac_wr(si, ENETC4_PM_CMD_CFG(0), val); 803 847 848 + val = enetc_port_rd(hw, ENETC4_POR); 849 + val &= ~POR_TXDIS; 850 + enetc_port_wr(hw, ENETC4_POR, val); 851 + } 852 + 853 + static void enetc4_mac_wait_rx_empty(struct enetc_si *si, int mac) 854 + { 855 + u32 val; 856 + 857 + if (read_poll_timeout(enetc_port_rd, val, 858 + val & PM_IEVENT_RX_EMPTY, 859 + 100, 10000, false, &si->hw, 860 + ENETC4_PM_IEVENT(mac))) 861 + dev_warn(&si->pdev->dev, 862 + "MAC %d RX is not empty\n", mac); 863 + } 864 + 865 + static void enetc4_mac_rx_graceful_stop(struct enetc_pf *pf) 866 + { 867 + struct enetc_hw *hw = &pf->si->hw; 868 + struct enetc_si *si = pf->si; 869 + u32 val; 870 + 871 + if (enetc_is_pseudo_mac(si)) 872 + goto check_rx_busy; 873 + 874 + if (si->hw_features & ENETC_SI_F_QBU) { 875 + val = enetc_port_rd(hw, ENETC4_PM_CMD_CFG(1)); 876 + val &= ~PM_CMD_CFG_RX_EN; 877 + enetc_port_wr(hw, ENETC4_PM_CMD_CFG(1), val); 878 + enetc4_mac_wait_rx_empty(si, 1); 879 + } 880 + 881 + val = enetc_port_rd(hw, ENETC4_PM_CMD_CFG(0)); 882 + val &= ~PM_CMD_CFG_RX_EN; 883 + enetc_port_wr(hw, ENETC4_PM_CMD_CFG(0), val); 884 + enetc4_mac_wait_rx_empty(si, 0); 885 + 886 + check_rx_busy: 887 + if (read_poll_timeout(enetc_port_rd, val, 888 + !(val & PSR_RX_BUSY), 889 + 100, 10000, false, hw, 890 + ENETC4_PSR)) 891 + dev_warn(&si->pdev->dev, "Port RX busy\n"); 892 + 893 + val = enetc_port_rd(hw, ENETC4_POR); 894 + val |= POR_RXDIS; 895 + enetc_port_wr(hw, ENETC4_POR, val); 896 + } 897 + 898 + static void enetc4_mac_rx_enable(struct enetc_pf *pf) 899 + { 900 + struct enetc_hw *hw = &pf->si->hw; 901 + struct enetc_si *si = pf->si; 902 + u32 val; 903 + 904 + val = enetc_port_rd(hw, ENETC4_POR); 905 + val &= ~POR_RXDIS; 906 + enetc_port_wr(hw, ENETC4_POR, val); 907 + 908 + val = enetc_port_mac_rd(si, ENETC4_PM_CMD_CFG(0)); 909 + val |= PM_CMD_CFG_RX_EN; 804 910 enetc_port_mac_wr(si, ENETC4_PM_CMD_CFG(0), val); 805 911 } 806 912 ··· 941 853 enetc4_set_hd_flow_control(pf, hd_fc); 942 854 enetc4_set_tx_pause(pf, priv->num_rx_rings, tx_pause); 943 855 enetc4_set_rx_pause(pf, rx_pause); 944 - enetc4_enable_mac(pf, true); 856 + enetc4_mac_tx_enable(pf); 857 + enetc4_mac_rx_enable(pf); 945 858 } 946 859 947 860 static void enetc4_pl_mac_link_down(struct phylink_config *config, ··· 951 862 { 952 863 struct enetc_pf *pf = phylink_to_enetc_pf(config); 953 864 954 - enetc4_enable_mac(pf, false); 865 + enetc4_mac_rx_graceful_stop(pf); 866 + enetc4_mac_tx_graceful_stop(pf); 955 867 } 956 868 957 869 static const struct phylink_mac_ops enetc_pl_mac_ops = {
+9 -1
drivers/net/ethernet/freescale/enetc/enetc_ethtool.c
··· 795 795 struct enetc_si *si = priv->si; 796 796 int err = 0; 797 797 798 + if (rxfh->hfunc != ETH_RSS_HASH_NO_CHANGE && 799 + rxfh->hfunc != ETH_RSS_HASH_TOP) 800 + return -EOPNOTSUPP; 801 + 798 802 /* set hash key, if PF */ 799 - if (rxfh->key && enetc_si_is_pf(si)) 803 + if (rxfh->key) { 804 + if (!enetc_si_is_pf(si)) 805 + return -EOPNOTSUPP; 806 + 800 807 enetc_set_rss_key(si, rxfh->key); 808 + } 801 809 802 810 /* set RSS table */ 803 811 if (rxfh->indir)
-3
drivers/net/ethernet/freescale/fec_ptp.c
··· 545 545 if (rq->perout.flags) 546 546 return -EOPNOTSUPP; 547 547 548 - if (rq->perout.index != fep->pps_channel) 549 - return -EOPNOTSUPP; 550 - 551 548 period.tv_sec = rq->perout.period.sec; 552 549 period.tv_nsec = rq->perout.period.nsec; 553 550 period_ns = timespec64_to_ns(&period);
+20 -1
drivers/net/ethernet/mediatek/mtk_ppe_offload.c
··· 244 244 return 0; 245 245 } 246 246 247 + static bool 248 + mtk_flow_is_valid_idev(const struct mtk_eth *eth, const struct net_device *idev) 249 + { 250 + size_t i; 251 + 252 + if (!idev) 253 + return false; 254 + 255 + for (i = 0; i < ARRAY_SIZE(eth->netdev); i++) { 256 + if (!eth->netdev[i]) 257 + continue; 258 + 259 + if (idev->netdev_ops == eth->netdev[i]->netdev_ops) 260 + return true; 261 + } 262 + 263 + return false; 264 + } 265 + 247 266 static int 248 267 mtk_flow_offload_replace(struct mtk_eth *eth, struct flow_cls_offload *f, 249 268 int ppe_index) ··· 289 270 flow_rule_match_meta(rule, &match); 290 271 if (mtk_is_netsys_v2_or_greater(eth)) { 291 272 idev = __dev_get_by_index(&init_net, match.key->ingress_ifindex); 292 - if (idev && idev->netdev_ops == eth->netdev[0]->netdev_ops) { 273 + if (mtk_flow_is_valid_idev(eth, idev)) { 293 274 struct mtk_mac *mac = netdev_priv(idev); 294 275 295 276 if (WARN_ON(mac->ppe_idx >= eth->soc->ppe_num))
+1 -3
drivers/net/ethernet/mellanox/mlx5/core/devlink.c
··· 107 107 if (err) 108 108 return err; 109 109 110 - err = mlx5_fw_version_query(dev, &running_fw, &stored_fw); 111 - if (err) 112 - return err; 110 + mlx5_fw_version_query(dev, &running_fw, &stored_fw); 113 111 114 112 snprintf(version_str, sizeof(version_str), "%d.%d.%04d", 115 113 mlx5_fw_ver_major(running_fw), mlx5_fw_ver_minor(running_fw),
+2
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
··· 3838 3838 return 0; 3839 3839 3840 3840 err_vports: 3841 + /* rollback to legacy, indicates don't unregister the uplink netdev */ 3842 + esw->dev->priv.flags |= MLX5_PRIV_FLAGS_SWITCH_LEGACY; 3841 3843 mlx5_esw_offloads_rep_unload(esw, MLX5_VPORT_UPLINK); 3842 3844 err_uplink: 3843 3845 esw_offloads_steering_cleanup(esw);
+32 -17
drivers/net/ethernet/mellanox/mlx5/core/fw.c
··· 828 828 return 0; 829 829 } 830 830 831 - int mlx5_fw_version_query(struct mlx5_core_dev *dev, 832 - u32 *running_ver, u32 *pending_ver) 831 + void mlx5_fw_version_query(struct mlx5_core_dev *dev, 832 + u32 *running_ver, u32 *pending_ver) 833 833 { 834 834 u32 reg_mcqi_version[MLX5_ST_SZ_DW(mcqi_version)] = {}; 835 835 bool pending_version_exists; 836 836 int component_index; 837 837 int err; 838 838 839 + *running_ver = 0; 840 + *pending_ver = 0; 841 + 839 842 if (!MLX5_CAP_GEN(dev, mcam_reg) || !MLX5_CAP_MCAM_REG(dev, mcqi) || 840 843 !MLX5_CAP_MCAM_REG(dev, mcqs)) { 841 844 mlx5_core_warn(dev, "fw query isn't supported by the FW\n"); 842 - return -EOPNOTSUPP; 845 + return; 843 846 } 844 847 845 848 component_index = mlx5_get_boot_img_component_index(dev); 846 - if (component_index < 0) 847 - return component_index; 849 + if (component_index < 0) { 850 + mlx5_core_warn(dev, "fw query failed to find boot img component index, err %d\n", 851 + component_index); 852 + return; 853 + } 848 854 855 + *running_ver = U32_MAX; /* indicate failure */ 849 856 err = mlx5_reg_mcqi_version_query(dev, component_index, 850 857 MCQI_FW_RUNNING_VERSION, 851 858 reg_mcqi_version); 852 - if (err) 853 - return err; 859 + if (!err) 860 + *running_ver = MLX5_GET(mcqi_version, reg_mcqi_version, 861 + version); 862 + else 863 + mlx5_core_warn(dev, "failed to query running version, err %d\n", 864 + err); 854 865 855 - *running_ver = MLX5_GET(mcqi_version, reg_mcqi_version, version); 856 - 866 + *pending_ver = U32_MAX; /* indicate failure */ 857 867 err = mlx5_fw_image_pending(dev, component_index, &pending_version_exists); 858 - if (err) 859 - return err; 868 + if (err) { 869 + mlx5_core_warn(dev, "failed to query pending image, err %d\n", 870 + err); 871 + return; 872 + } 860 873 861 874 if (!pending_version_exists) { 862 875 *pending_ver = 0; 863 - return 0; 876 + return; 864 877 } 865 878 866 879 err = mlx5_reg_mcqi_version_query(dev, component_index, 867 880 MCQI_FW_STORED_VERSION, 868 881 reg_mcqi_version); 869 - if (err) 870 - return err; 882 + if (!err) 883 + *pending_ver = MLX5_GET(mcqi_version, reg_mcqi_version, 884 + version); 885 + else 886 + mlx5_core_warn(dev, "failed to query pending version, err %d\n", 887 + err); 871 888 872 - *pending_ver = MLX5_GET(mcqi_version, reg_mcqi_version, version); 873 - 874 - return 0; 889 + return; 875 890 }
+3
drivers/net/ethernet/mellanox/mlx5/core/lag/debugfs.c
··· 161 161 162 162 void mlx5_ldev_add_debugfs(struct mlx5_core_dev *dev) 163 163 { 164 + struct mlx5_lag *ldev = mlx5_lag_dev(dev); 164 165 struct dentry *dbg; 165 166 167 + if (!ldev) 168 + return; 166 169 dbg = debugfs_create_dir("lag", mlx5_debugfs_get_dev_root(dev)); 167 170 dev->priv.dbg.lag_debugfs = dbg; 168 171
+2 -2
drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h
··· 393 393 394 394 int mlx5_firmware_flash(struct mlx5_core_dev *dev, const struct firmware *fw, 395 395 struct netlink_ext_ack *extack); 396 - int mlx5_fw_version_query(struct mlx5_core_dev *dev, 397 - u32 *running_ver, u32 *stored_ver); 396 + void mlx5_fw_version_query(struct mlx5_core_dev *dev, u32 *running_ver, 397 + u32 *stored_ver); 398 398 399 399 #ifdef CONFIG_MLX5_CORE_EN 400 400 int mlx5e_init(void);
+1 -1
drivers/net/ethernet/meta/fbnic/fbnic_debugfs.c
··· 197 197 return 0; 198 198 } 199 199 200 - for (i = 0; i <= ring->size_mask; i++) { 200 + for (i = 0; i < (ring->size_mask + 1) * FBNIC_BD_FRAG_COUNT; i++) { 201 201 u64 bd = le64_to_cpu(ring->desc[i]); 202 202 203 203 seq_printf(s, "%04x %#04llx %#014llx\n", i,
+3 -3
drivers/net/ethernet/meta/fbnic/fbnic_txrx.c
··· 927 927 /* Force DMA writes to flush before writing to tail */ 928 928 dma_wmb(); 929 929 930 - writel(i, bdq->doorbell); 930 + writel(i * FBNIC_BD_FRAG_COUNT, bdq->doorbell); 931 931 } 932 932 } 933 933 ··· 2564 2564 hpq->tail = 0; 2565 2565 hpq->head = 0; 2566 2566 2567 - log_size = fls(hpq->size_mask); 2567 + log_size = fls(hpq->size_mask) + ilog2(FBNIC_BD_FRAG_COUNT); 2568 2568 2569 2569 /* Store descriptor ring address and size */ 2570 2570 fbnic_ring_wr32(hpq, FBNIC_QUEUE_BDQ_HPQ_BAL, lower_32_bits(hpq->dma)); ··· 2576 2576 if (!ppq->size_mask) 2577 2577 goto write_ctl; 2578 2578 2579 - log_size = fls(ppq->size_mask); 2579 + log_size = fls(ppq->size_mask) + ilog2(FBNIC_BD_FRAG_COUNT); 2580 2580 2581 2581 /* Add enabling of PPQ to BDQ control */ 2582 2582 bdq_ctl |= FBNIC_QUEUE_BDQ_CTL_PPQ_ENABLE;
+1 -1
drivers/net/ethernet/meta/fbnic/fbnic_txrx.h
··· 38 38 #define FBNIC_MAX_XDPQS 128u 39 39 40 40 /* These apply to TWQs, TCQ, RCQ */ 41 - #define FBNIC_QUEUE_SIZE_MIN 16u 41 + #define FBNIC_QUEUE_SIZE_MIN 64u 42 42 #define FBNIC_QUEUE_SIZE_MAX SZ_64K 43 43 44 44 #define FBNIC_TXQ_SIZE_DEFAULT 1024
+7
drivers/net/ethernet/microsoft/mana/mana_en.c
··· 766 766 } 767 767 768 768 *frag_count = 1; 769 + 770 + /* In the single-buffer path, napi_build_skb() must see the 771 + * actual backing allocation size so skb->truesize reflects 772 + * the full page (or higher-order page), not just the usable 773 + * packet area. 774 + */ 775 + *alloc_size = PAGE_SIZE << get_order(*alloc_size); 769 776 return; 770 777 } 771 778
+4 -10
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
··· 157 157 static void stmmac_flush_tx_descriptors(struct stmmac_priv *priv, int queue); 158 158 static void stmmac_set_dma_operation_mode(struct stmmac_priv *priv, u32 txmode, 159 159 u32 rxmode, u32 chan); 160 - static int stmmac_vlan_restore(struct stmmac_priv *priv); 160 + static void stmmac_vlan_restore(struct stmmac_priv *priv); 161 161 162 162 #ifdef CONFIG_DEBUG_FS 163 163 static const struct net_device_ops stmmac_netdev_ops; ··· 6828 6828 return ret; 6829 6829 } 6830 6830 6831 - static int stmmac_vlan_restore(struct stmmac_priv *priv) 6831 + static void stmmac_vlan_restore(struct stmmac_priv *priv) 6832 6832 { 6833 - int ret; 6834 - 6835 6833 if (!(priv->dev->features & NETIF_F_VLAN_FEATURES)) 6836 - return 0; 6834 + return; 6837 6835 6838 6836 if (priv->hw->num_vlan) 6839 6837 stmmac_restore_hw_vlan_rx_fltr(priv, priv->dev, priv->hw); 6840 6838 6841 - ret = stmmac_vlan_update(priv, priv->num_double_vlans); 6842 - if (ret) 6843 - netdev_err(priv->dev, "Failed to restore VLANs\n"); 6844 - 6845 - return ret; 6839 + stmmac_vlan_update(priv, priv->num_double_vlans); 6846 6840 } 6847 6841 6848 6842 static int stmmac_bpf(struct net_device *dev, struct netdev_bpf *bpf)
+1 -1
drivers/net/ethernet/ti/icssg/icssg_common.c
··· 902 902 903 903 skb_reserve(skb, headroom); 904 904 skb_put(skb, pkt_len); 905 + skb_copy_to_linear_data(skb, xdp->data, pkt_len); 905 906 skb->dev = ndev; 906 907 907 908 /* RX HW timestamp */ ··· 913 912 skb->offload_fwd_mark = emac->offload_fwd_mark; 914 913 skb->protocol = eth_type_trans(skb, ndev); 915 914 916 - skb_mark_for_recycle(skb); 917 915 napi_gro_receive(&emac->napi_rx, skb); 918 916 ndev->stats.rx_bytes += pkt_len; 919 917 ndev->stats.rx_packets++;
+2 -2
drivers/net/ethernet/xilinx/xilinx_axienet.h
··· 105 105 #define XAXIDMA_BD_HAS_DRE_MASK 0xF00 /* Whether has DRE mask */ 106 106 #define XAXIDMA_BD_WORDLEN_MASK 0xFF /* Whether has DRE mask */ 107 107 108 - #define XAXIDMA_BD_CTRL_LENGTH_MASK 0x007FFFFF /* Requested len */ 108 + #define XAXIDMA_BD_CTRL_LENGTH_MASK GENMASK(25, 0) /* Requested len */ 109 109 #define XAXIDMA_BD_CTRL_TXSOF_MASK 0x08000000 /* First tx packet */ 110 110 #define XAXIDMA_BD_CTRL_TXEOF_MASK 0x04000000 /* Last tx packet */ 111 111 #define XAXIDMA_BD_CTRL_ALL_MASK 0x0C000000 /* All control bits */ ··· 130 130 #define XAXIDMA_BD_CTRL_TXEOF_MASK 0x04000000 /* Last tx packet */ 131 131 #define XAXIDMA_BD_CTRL_ALL_MASK 0x0C000000 /* All control bits */ 132 132 133 - #define XAXIDMA_BD_STS_ACTUAL_LEN_MASK 0x007FFFFF /* Actual len */ 133 + #define XAXIDMA_BD_STS_ACTUAL_LEN_MASK GENMASK(25, 0) /* Actual len */ 134 134 #define XAXIDMA_BD_STS_COMPLETE_MASK 0x80000000 /* Completed */ 135 135 #define XAXIDMA_BD_STS_DEC_ERR_MASK 0x40000000 /* Decode error */ 136 136 #define XAXIDMA_BD_STS_SLV_ERR_MASK 0x20000000 /* Slave error */
+4 -5
drivers/net/ethernet/xilinx/xilinx_axienet_main.c
··· 770 770 * @first_bd: Index of first descriptor to clean up 771 771 * @nr_bds: Max number of descriptors to clean up 772 772 * @force: Whether to clean descriptors even if not complete 773 - * @sizep: Pointer to a u32 filled with the total sum of all bytes 774 - * in all cleaned-up descriptors. Ignored if NULL. 773 + * @sizep: Pointer to a u32 accumulating the total byte count of 774 + * completed packets (using skb->len). Ignored if NULL. 775 775 * @budget: NAPI budget (use 0 when not called from NAPI poll) 776 776 * 777 777 * Would either be called after a successful transmit operation, or after ··· 805 805 DMA_TO_DEVICE); 806 806 807 807 if (cur_p->skb && (status & XAXIDMA_BD_STS_COMPLETE_MASK)) { 808 + if (sizep) 809 + *sizep += cur_p->skb->len; 808 810 napi_consume_skb(cur_p->skb, budget); 809 811 packets++; 810 812 } ··· 820 818 wmb(); 821 819 cur_p->cntrl = 0; 822 820 cur_p->status = 0; 823 - 824 - if (sizep) 825 - *sizep += status & XAXIDMA_BD_STS_ACTUAL_LEN_MASK; 826 821 } 827 822 828 823 if (!force) {
+6 -1
drivers/net/phy/sfp.c
··· 480 480 { 481 481 /* Ubiquiti U-Fiber Instant module claims that support all transceiver 482 482 * types including 10G Ethernet which is not truth. So clear all claimed 483 - * modes and set only one mode which module supports: 1000baseX_Full. 483 + * modes and set only one mode which module supports: 1000baseX_Full, 484 + * along with the Autoneg and pause bits. 484 485 */ 485 486 linkmode_zero(caps->link_modes); 486 487 linkmode_set_bit(ETHTOOL_LINK_MODE_1000baseX_Full_BIT, 487 488 caps->link_modes); 489 + linkmode_set_bit(ETHTOOL_LINK_MODE_Autoneg_BIT, caps->link_modes); 490 + linkmode_set_bit(ETHTOOL_LINK_MODE_Pause_BIT, caps->link_modes); 491 + linkmode_set_bit(ETHTOOL_LINK_MODE_Asym_Pause_BIT, caps->link_modes); 492 + 488 493 phy_interface_zero(caps->interfaces); 489 494 __set_bit(PHY_INTERFACE_MODE_1000BASEX, caps->interfaces); 490 495 }
+9 -11
drivers/net/virtio_net.c
··· 373 373 struct xdp_buff **xsk_buffs; 374 374 }; 375 375 376 - #define VIRTIO_NET_RSS_MAX_KEY_SIZE 40 377 - 378 376 /* Control VQ buffers: protected by the rtnl lock */ 379 377 struct control_buf { 380 378 struct virtio_net_ctrl_hdr hdr; ··· 476 478 477 479 /* Must be last as it ends in a flexible-array member. */ 478 480 TRAILING_OVERLAP(struct virtio_net_rss_config_trailer, rss_trailer, hash_key_data, 479 - u8 rss_hash_key_data[VIRTIO_NET_RSS_MAX_KEY_SIZE]; 481 + u8 rss_hash_key_data[NETDEV_RSS_KEY_LEN]; 480 482 ); 481 483 }; 482 484 static_assert(offsetof(struct virtnet_info, rss_trailer.hash_key_data) == ··· 6720 6722 struct virtnet_info *vi; 6721 6723 u16 max_queue_pairs; 6722 6724 int mtu = 0; 6725 + u16 key_sz; 6723 6726 6724 6727 /* Find if host supports multiqueue/rss virtio_net device */ 6725 6728 max_queue_pairs = 1; ··· 6853 6854 } 6854 6855 6855 6856 if (vi->has_rss || vi->has_rss_hash_report) { 6856 - vi->rss_key_size = 6857 - virtio_cread8(vdev, offsetof(struct virtio_net_config, rss_max_key_size)); 6858 - if (vi->rss_key_size > VIRTIO_NET_RSS_MAX_KEY_SIZE) { 6859 - dev_err(&vdev->dev, "rss_max_key_size=%u exceeds the limit %u.\n", 6860 - vi->rss_key_size, VIRTIO_NET_RSS_MAX_KEY_SIZE); 6861 - err = -EINVAL; 6862 - goto free; 6863 - } 6857 + key_sz = virtio_cread8(vdev, offsetof(struct virtio_net_config, rss_max_key_size)); 6858 + 6859 + vi->rss_key_size = min_t(u16, key_sz, NETDEV_RSS_KEY_LEN); 6860 + if (key_sz > vi->rss_key_size) 6861 + dev_warn(&vdev->dev, 6862 + "rss_max_key_size=%u exceeds driver limit %u, clamping\n", 6863 + key_sz, vi->rss_key_size); 6864 6864 6865 6865 vi->rss_hash_types_supported = 6866 6866 virtio_cread32(vdev, offsetof(struct virtio_net_config, supported_hash_types));
+4 -2
drivers/net/vxlan/vxlan_core.c
··· 1964 1964 ns_olen = request->len - skb_network_offset(request) - 1965 1965 sizeof(struct ipv6hdr) - sizeof(*ns); 1966 1966 for (i = 0; i < ns_olen-1; i += (ns->opt[i+1]<<3)) { 1967 - if (!ns->opt[i + 1]) { 1967 + if (!ns->opt[i + 1] || i + (ns->opt[i + 1] << 3) > ns_olen) { 1968 1968 kfree_skb(reply); 1969 1969 return NULL; 1970 1970 } 1971 1971 if (ns->opt[i] == ND_OPT_SOURCE_LL_ADDR) { 1972 - daddr = ns->opt + i + sizeof(struct nd_opt_hdr); 1972 + if ((ns->opt[i + 1] << 3) >= 1973 + sizeof(struct nd_opt_hdr) + ETH_ALEN) 1974 + daddr = ns->opt + i + sizeof(struct nd_opt_hdr); 1973 1975 break; 1974 1976 } 1975 1977 }
+7 -8
drivers/net/wireless/ath/ath11k/dp_rx.c
··· 1 1 // SPDX-License-Identifier: BSD-3-Clause-Clear 2 2 /* 3 3 * Copyright (c) 2018-2019 The Linux Foundation. All rights reserved. 4 - * Copyright (c) 2021-2025 Qualcomm Innovation Center, Inc. All rights reserved. 4 + * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. 5 5 */ 6 6 7 7 #include <linux/ieee80211.h> ··· 1110 1110 struct ath11k_base *ab = ar->ab; 1111 1111 struct ath11k_peer *peer; 1112 1112 struct ath11k_sta *arsta = ath11k_sta_to_arsta(params->sta); 1113 + struct dp_rx_tid *rx_tid; 1113 1114 int vdev_id = arsta->arvif->vdev_id; 1114 - dma_addr_t paddr; 1115 - bool active; 1116 1115 int ret; 1117 1116 1118 1117 spin_lock_bh(&ab->base_lock); ··· 1123 1124 return -ENOENT; 1124 1125 } 1125 1126 1126 - paddr = peer->rx_tid[params->tid].paddr; 1127 - active = peer->rx_tid[params->tid].active; 1127 + rx_tid = &peer->rx_tid[params->tid]; 1128 1128 1129 - if (!active) { 1129 + if (!rx_tid->active) { 1130 1130 spin_unlock_bh(&ab->base_lock); 1131 1131 return 0; 1132 1132 } 1133 1133 1134 - ret = ath11k_peer_rx_tid_reo_update(ar, peer, peer->rx_tid, 1, 0, false); 1134 + ret = ath11k_peer_rx_tid_reo_update(ar, peer, rx_tid, 1, 0, false); 1135 1135 spin_unlock_bh(&ab->base_lock); 1136 1136 if (ret) { 1137 1137 ath11k_warn(ab, "failed to update reo for rx tid %d: %d\n", ··· 1139 1141 } 1140 1142 1141 1143 ret = ath11k_wmi_peer_rx_reorder_queue_setup(ar, vdev_id, 1142 - params->sta->addr, paddr, 1144 + params->sta->addr, 1145 + rx_tid->paddr, 1143 1146 params->tid, 1, 1); 1144 1147 if (ret) 1145 1148 ath11k_warn(ab, "failed to send wmi to delete rx tid %d\n",
+3 -1
drivers/net/wireless/ath/ath12k/dp_rx.c
··· 735 735 struct ath12k_dp *dp = ath12k_ab_to_dp(ab); 736 736 struct ath12k_dp_link_peer *peer; 737 737 struct ath12k_sta *ahsta = ath12k_sta_to_ahsta(params->sta); 738 + struct ath12k_dp_rx_tid *rx_tid; 738 739 struct ath12k_link_sta *arsta; 739 740 int vdev_id; 740 741 bool active; ··· 771 770 return 0; 772 771 } 773 772 774 - ret = ath12k_dp_arch_peer_rx_tid_reo_update(dp, peer, peer->dp_peer->rx_tid, 773 + rx_tid = &peer->dp_peer->rx_tid[params->tid]; 774 + ret = ath12k_dp_arch_peer_rx_tid_reo_update(dp, peer, rx_tid, 775 775 1, 0, false); 776 776 spin_unlock_bh(&dp->dp_lock); 777 777 if (ret) {
+5
drivers/net/wireless/intel/iwlwifi/fw/api/commands.h
··· 297 297 SCAN_OFFLOAD_UPDATE_PROFILES_CMD = 0x6E, 298 298 299 299 /** 300 + * @SCAN_START_NOTIFICATION_UMAC: uses &struct iwl_umac_scan_start 301 + */ 302 + SCAN_START_NOTIFICATION_UMAC = 0xb2, 303 + 304 + /** 300 305 * @MATCH_FOUND_NOTIFICATION: scan match found 301 306 */ 302 307 MATCH_FOUND_NOTIFICATION = 0xd9,
+10
drivers/net/wireless/intel/iwlwifi/fw/api/scan.h
··· 1202 1202 }; 1203 1203 1204 1204 /** 1205 + * struct iwl_umac_scan_start - scan start notification 1206 + * @uid: scan id, &enum iwl_umac_scan_uid_offsets 1207 + * @reserved: for future use 1208 + */ 1209 + struct iwl_umac_scan_start { 1210 + __le32 uid; 1211 + __le32 reserved; 1212 + } __packed; /* SCAN_START_UMAC_API_S_VER_1 */ 1213 + 1214 + /** 1205 1215 * struct iwl_umac_scan_complete - scan complete notification 1206 1216 * @uid: scan id, &enum iwl_umac_scan_uid_offsets 1207 1217 * @last_schedule: last scheduling line
+69 -32
drivers/net/wireless/intel/iwlwifi/mld/iface.c
··· 118 118 IEEE80211_HE_MAC_CAP2_ACK_EN); 119 119 } 120 120 121 - static void iwl_mld_set_he_support(struct iwl_mld *mld, 122 - struct ieee80211_vif *vif, 123 - struct iwl_mac_config_cmd *cmd) 121 + struct iwl_mld_mac_wifi_gen_sta_iter_data { 122 + struct ieee80211_vif *vif; 123 + struct iwl_mac_wifi_gen_support *support; 124 + }; 125 + 126 + static void iwl_mld_mac_wifi_gen_sta_iter(void *_data, 127 + struct ieee80211_sta *sta) 124 128 { 125 - if (vif->type == NL80211_IFTYPE_AP) 126 - cmd->wifi_gen.he_ap_support = 1; 127 - else 128 - cmd->wifi_gen.he_support = 1; 129 + struct iwl_mld_sta *mld_sta = iwl_mld_sta_from_mac80211(sta); 130 + struct iwl_mld_mac_wifi_gen_sta_iter_data *data = _data; 131 + struct ieee80211_link_sta *link_sta; 132 + unsigned int link_id; 133 + 134 + if (mld_sta->vif != data->vif) 135 + return; 136 + 137 + for_each_sta_active_link(data->vif, sta, link_sta, link_id) { 138 + if (link_sta->he_cap.has_he) 139 + data->support->he_support = 1; 140 + if (link_sta->eht_cap.has_eht) 141 + data->support->eht_support = 1; 142 + } 143 + } 144 + 145 + static void iwl_mld_set_wifi_gen(struct iwl_mld *mld, 146 + struct ieee80211_vif *vif, 147 + struct iwl_mac_wifi_gen_support *support) 148 + { 149 + struct iwl_mld_mac_wifi_gen_sta_iter_data sta_iter_data = { 150 + .vif = vif, 151 + .support = support, 152 + }; 153 + struct ieee80211_bss_conf *link_conf; 154 + unsigned int link_id; 155 + 156 + switch (vif->type) { 157 + case NL80211_IFTYPE_MONITOR: 158 + /* for sniffer, set to HW capabilities */ 159 + support->he_support = 1; 160 + support->eht_support = mld->trans->cfg->eht_supported; 161 + break; 162 + case NL80211_IFTYPE_AP: 163 + /* for AP set according to the link configs */ 164 + for_each_vif_active_link(vif, link_conf, link_id) { 165 + support->he_ap_support |= link_conf->he_support; 166 + support->eht_support |= link_conf->eht_support; 167 + } 168 + break; 169 + default: 170 + /* 171 + * If we have MLO enabled, then the firmware needs to enable 172 + * address translation for the station(s) we add. That depends 173 + * on having EHT enabled in firmware, which in turn depends on 174 + * mac80211 in the iteration below. 175 + * However, mac80211 doesn't enable capabilities on the AP STA 176 + * until it has parsed the association response successfully, 177 + * so set EHT (and HE as a pre-requisite for EHT) when the vif 178 + * is an MLD. 179 + */ 180 + if (ieee80211_vif_is_mld(vif)) { 181 + support->he_support = 1; 182 + support->eht_support = 1; 183 + } 184 + 185 + ieee80211_iterate_stations_mtx(mld->hw, 186 + iwl_mld_mac_wifi_gen_sta_iter, 187 + &sta_iter_data); 188 + break; 189 + } 129 190 } 130 191 131 192 /* fill the common part for all interface types */ ··· 196 135 u32 action) 197 136 { 198 137 struct iwl_mld_vif *mld_vif = iwl_mld_vif_from_mac80211(vif); 199 - struct ieee80211_bss_conf *link_conf; 200 - unsigned int link_id; 201 138 202 139 lockdep_assert_wiphy(mld->wiphy); 203 140 ··· 213 154 cmd->nic_not_ack_enabled = 214 155 cpu_to_le32(!iwl_mld_is_nic_ack_enabled(mld, vif)); 215 156 216 - /* If we have MLO enabled, then the firmware needs to enable 217 - * address translation for the station(s) we add. That depends 218 - * on having EHT enabled in firmware, which in turn depends on 219 - * mac80211 in the code below. 220 - * However, mac80211 doesn't enable HE/EHT until it has parsed 221 - * the association response successfully, so just skip all that 222 - * and enable both when we have MLO. 223 - */ 224 - if (ieee80211_vif_is_mld(vif)) { 225 - iwl_mld_set_he_support(mld, vif, cmd); 226 - cmd->wifi_gen.eht_support = 1; 227 - return; 228 - } 229 - 230 - for_each_vif_active_link(vif, link_conf, link_id) { 231 - if (!link_conf->he_support) 232 - continue; 233 - 234 - iwl_mld_set_he_support(mld, vif, cmd); 235 - 236 - /* EHT, if supported, was already set above */ 237 - break; 238 - } 157 + iwl_mld_set_wifi_gen(mld, vif, &cmd->wifi_gen); 239 158 } 240 159 241 160 static void iwl_mld_fill_mac_cmd_sta(struct iwl_mld *mld,
+19
drivers/net/wireless/intel/iwlwifi/mld/mac80211.c
··· 1798 1798 1799 1799 if (vif->type == NL80211_IFTYPE_STATION) 1800 1800 iwl_mld_link_set_2mhz_block(mld, vif, sta); 1801 + 1802 + if (sta->tdls) { 1803 + /* 1804 + * update MAC since wifi generation flags may change, 1805 + * we also update MAC on association to the AP via the 1806 + * vif assoc change 1807 + */ 1808 + iwl_mld_mac_fw_action(mld, vif, FW_CTXT_ACTION_MODIFY); 1809 + } 1810 + 1801 1811 /* Now the link_sta's capabilities are set, update the FW */ 1802 1812 iwl_mld_config_tlc(mld, vif, sta); 1803 1813 ··· 1925 1915 /* Unblock EMLSR when TDLS connection is torn down */ 1926 1916 iwl_mld_unblock_emlsr(mld, vif, 1927 1917 IWL_MLD_EMLSR_BLOCKED_TDLS); 1918 + } 1919 + 1920 + if (sta->tdls) { 1921 + /* 1922 + * update MAC since wifi generation flags may change, 1923 + * we also update MAC on disassociation to the AP via 1924 + * the vif assoc change 1925 + */ 1926 + iwl_mld_mac_fw_action(mld, vif, FW_CTXT_ACTION_MODIFY); 1928 1927 } 1929 1928 } else { 1930 1929 return -EINVAL;
+1
drivers/net/wireless/intel/iwlwifi/mld/mld.c
··· 171 171 HCMD_NAME(MISSED_BEACONS_NOTIFICATION), 172 172 HCMD_NAME(MAC_PM_POWER_TABLE), 173 173 HCMD_NAME(MFUART_LOAD_NOTIFICATION), 174 + HCMD_NAME(SCAN_START_NOTIFICATION_UMAC), 174 175 HCMD_NAME(RSS_CONFIG_CMD), 175 176 HCMD_NAME(SCAN_ITERATION_COMPLETE_UMAC), 176 177 HCMD_NAME(REPLY_RX_MPDU_CMD),
+2 -2
drivers/net/wireless/intel/iwlwifi/mld/mlo.c
··· 739 739 740 740 /* Ignore any BSS that was not seen in the last MLO scan */ 741 741 if (ktime_before(link_conf->bss->ts_boottime, 742 - mld->scan.last_mlo_scan_time)) 742 + mld->scan.last_mlo_scan_start_time)) 743 743 continue; 744 744 745 745 data[n_data].link_id = link_id; ··· 945 945 if (!mld_vif->authorized || hweight16(usable_links) <= 1) 946 946 return; 947 947 948 - if (WARN(ktime_before(mld->scan.last_mlo_scan_time, 948 + if (WARN(ktime_before(mld->scan.last_mlo_scan_start_time, 949 949 ktime_sub_ns(ktime_get_boottime_ns(), 950 950 5ULL * NSEC_PER_SEC)), 951 951 "Last MLO scan was too long ago, can't select links\n"))
+5
drivers/net/wireless/intel/iwlwifi/mld/notif.c
··· 287 287 * at least enough bytes to cover the structure listed in the CMD_VER_ENTRY. 288 288 */ 289 289 290 + CMD_VERSIONS(scan_start_notif, 291 + CMD_VER_ENTRY(1, iwl_umac_scan_start)) 290 292 CMD_VERSIONS(scan_complete_notif, 291 293 CMD_VER_ENTRY(1, iwl_umac_scan_complete)) 292 294 CMD_VERSIONS(scan_iter_complete_notif, ··· 362 360 link_id) 363 361 DEFINE_SIMPLE_CANCELLATION(roc, iwl_roc_notif, activity) 364 362 DEFINE_SIMPLE_CANCELLATION(scan_complete, iwl_umac_scan_complete, uid) 363 + DEFINE_SIMPLE_CANCELLATION(scan_start, iwl_umac_scan_start, uid) 365 364 DEFINE_SIMPLE_CANCELLATION(probe_resp_data, iwl_probe_resp_data_notif, 366 365 mac_id) 367 366 DEFINE_SIMPLE_CANCELLATION(uapsd_misbehaving_ap, iwl_uapsd_misbehaving_ap_notif, ··· 405 402 RX_HANDLER_SYNC) 406 403 RX_HANDLER_NO_OBJECT(LEGACY_GROUP, BA_NOTIF, compressed_ba_notif, 407 404 RX_HANDLER_SYNC) 405 + RX_HANDLER_OF_SCAN(LEGACY_GROUP, SCAN_START_NOTIFICATION_UMAC, 406 + scan_start_notif) 408 407 RX_HANDLER_OF_SCAN(LEGACY_GROUP, SCAN_COMPLETE_UMAC, 409 408 scan_complete_notif) 410 409 RX_HANDLER_NO_OBJECT(LEGACY_GROUP, SCAN_ITERATION_COMPLETE_UMAC,
+27 -3
drivers/net/wireless/intel/iwlwifi/mld/scan.c
··· 478 478 params->flags & NL80211_SCAN_FLAG_COLOCATED_6GHZ) 479 479 flags |= IWL_UMAC_SCAN_GEN_FLAGS_V2_TRIGGER_UHB_SCAN; 480 480 481 + if (scan_status == IWL_MLD_SCAN_INT_MLO) 482 + flags |= IWL_UMAC_SCAN_GEN_FLAGS_V2_NTF_START; 483 + 481 484 if (params->enable_6ghz_passive) 482 485 flags |= IWL_UMAC_SCAN_GEN_FLAGS_V2_6GHZ_PASSIVE_SCAN; 483 486 ··· 1933 1930 ret = _iwl_mld_single_scan_start(mld, vif, req, &ies, 1934 1931 IWL_MLD_SCAN_INT_MLO); 1935 1932 1936 - if (!ret) 1937 - mld->scan.last_mlo_scan_time = ktime_get_boottime_ns(); 1938 - 1939 1933 IWL_DEBUG_SCAN(mld, "Internal MLO scan: ret=%d\n", ret); 1940 1934 } 1941 1935 ··· 2015 2015 { 2016 2016 IWL_DEBUG_SCAN(mld, "Scheduled scan results\n"); 2017 2017 ieee80211_sched_scan_results(mld->hw); 2018 + } 2019 + 2020 + void iwl_mld_handle_scan_start_notif(struct iwl_mld *mld, 2021 + struct iwl_rx_packet *pkt) 2022 + { 2023 + struct iwl_umac_scan_complete *notif = (void *)pkt->data; 2024 + u32 uid = le32_to_cpu(notif->uid); 2025 + 2026 + if (IWL_FW_CHECK(mld, uid >= ARRAY_SIZE(mld->scan.uid_status), 2027 + "FW reports out-of-range scan UID %d\n", uid)) 2028 + return; 2029 + 2030 + if (IWL_FW_CHECK(mld, !(mld->scan.uid_status[uid] & mld->scan.status), 2031 + "FW reports scan UID %d we didn't trigger\n", uid)) 2032 + return; 2033 + 2034 + IWL_DEBUG_SCAN(mld, "Scan started: uid=%u type=%u\n", uid, 2035 + mld->scan.uid_status[uid]); 2036 + if (IWL_FW_CHECK(mld, mld->scan.uid_status[uid] != IWL_MLD_SCAN_INT_MLO, 2037 + "FW reports scan start notification %d we didn't trigger\n", 2038 + mld->scan.uid_status[uid])) 2039 + return; 2040 + 2041 + mld->scan.last_mlo_scan_start_time = ktime_get_boottime_ns(); 2018 2042 } 2019 2043 2020 2044 void iwl_mld_handle_scan_complete_notif(struct iwl_mld *mld,
+6 -3
drivers/net/wireless/intel/iwlwifi/mld/scan.h
··· 27 27 void iwl_mld_handle_match_found_notif(struct iwl_mld *mld, 28 28 struct iwl_rx_packet *pkt); 29 29 30 + void iwl_mld_handle_scan_start_notif(struct iwl_mld *mld, 31 + struct iwl_rx_packet *pkt); 32 + 30 33 void iwl_mld_handle_scan_complete_notif(struct iwl_mld *mld, 31 34 struct iwl_rx_packet *pkt); 32 35 ··· 118 115 * in jiffies. 119 116 * @last_start_time_jiffies: stores the last start time in jiffies 120 117 * (interface up/reset/resume). 121 - * @last_mlo_scan_time: start time of the last MLO scan in nanoseconds since 122 - * boot. 118 + * @last_mlo_scan_start_time: start time of the last MLO scan in nanoseconds 119 + * since boot. 123 120 */ 124 121 struct iwl_mld_scan { 125 122 /* Add here fields that need clean up on restart */ ··· 141 138 u8 cmd_ver; 142 139 unsigned long last_6ghz_passive_jiffies; 143 140 unsigned long last_start_time_jiffies; 144 - u64 last_mlo_scan_time; 141 + u64 last_mlo_scan_start_time; 145 142 }; 146 143 147 144 /**
+1 -1
drivers/net/wireless/intel/iwlwifi/mvm/d3.c
··· 2807 2807 if (IS_ERR_OR_NULL(vif)) 2808 2808 return; 2809 2809 2810 - if (len < sizeof(struct iwl_scan_offload_match_info)) { 2810 + if (len < sizeof(struct iwl_scan_offload_match_info) + matches_len) { 2811 2811 IWL_ERR(mvm, "Invalid scan match info notification\n"); 2812 2812 return; 2813 2813 }
+2 -1
drivers/net/wireless/intel/iwlwifi/mvm/fw.c
··· 465 465 u8 cmd_ver; 466 466 int ret; 467 467 468 - if (mvm->trans->mac_cfg->device_family < IWL_DEVICE_FAMILY_AX210) { 468 + if (mvm->trans->mac_cfg->device_family < IWL_DEVICE_FAMILY_AX210 || 469 + !mvm->trans->cfg->uhb_supported) { 469 470 IWL_DEBUG_RADIO(mvm, "UATS feature is not supported\n"); 470 471 return; 471 472 }
+1 -1
drivers/net/wireless/microchip/wilc1000/hif.c
··· 163 163 u32 index = 0; 164 164 u32 i, scan_timeout; 165 165 u8 *buffer; 166 - u8 valuesize = 0; 166 + u32 valuesize = 0; 167 167 u8 *search_ssid_vals = NULL; 168 168 const u8 ch_list_len = request->n_channels; 169 169 struct host_if_drv *hif_drv = vif->hif_drv;
+5 -3
drivers/net/wireless/ti/wl1251/tx.c
··· 402 402 int hdrlen; 403 403 u8 *frame; 404 404 405 - skb = wl->tx_frames[result->id]; 406 - if (skb == NULL) { 407 - wl1251_error("SKB for packet %d is NULL", result->id); 405 + if (unlikely(result->id >= ARRAY_SIZE(wl->tx_frames) || 406 + wl->tx_frames[result->id] == NULL)) { 407 + wl1251_error("invalid packet id %u", result->id); 408 408 return; 409 409 } 410 + 411 + skb = wl->tx_frames[result->id]; 410 412 411 413 info = IEEE80211_SKB_CB(skb); 412 414
-1
drivers/net/wireless/virtual/virt_wifi.c
··· 559 559 eth_hw_addr_inherit(dev, priv->lowerdev); 560 560 netif_stacked_transfer_operstate(priv->lowerdev, dev); 561 561 562 - SET_NETDEV_DEV(dev, &priv->lowerdev->dev); 563 562 dev->ieee80211_ptr = kzalloc_obj(*dev->ieee80211_ptr); 564 563 565 564 if (!dev->ieee80211_ptr) {
+3
drivers/nfc/pn533/uart.c
··· 211 211 212 212 timer_delete(&dev->cmd_timeout); 213 213 for (i = 0; i < count; i++) { 214 + if (unlikely(!skb_tailroom(dev->recv_skb))) 215 + skb_trim(dev->recv_skb, 0); 216 + 214 217 skb_put_u8(dev->recv_skb, *data++); 215 218 if (!pn532_uart_rx_is_frame(dev->recv_skb)) 216 219 continue;
+3 -1
drivers/pci/pwrctrl/core.c
··· 299 299 struct device_node *remote __free(device_node) = 300 300 of_graph_get_remote_port_parent(endpoint); 301 301 if (remote) { 302 - if (of_pci_supply_present(remote)) 302 + if (of_pci_supply_present(remote)) { 303 + of_node_put(endpoint); 303 304 return true; 305 + } 304 306 } 305 307 } 306 308 }
-12
drivers/pci/pwrctrl/pci-pwrctrl-pwrseq.c
··· 68 68 return pwrseq_power_off(pwrseq->pwrseq); 69 69 } 70 70 71 - static void devm_pwrseq_pwrctrl_power_off(void *data) 72 - { 73 - struct pwrseq_pwrctrl *pwrseq = data; 74 - 75 - pwrseq_pwrctrl_power_off(&pwrseq->pwrctrl); 76 - } 77 - 78 71 static int pwrseq_pwrctrl_probe(struct platform_device *pdev) 79 72 { 80 73 const struct pwrseq_pwrctrl_pdata *pdata; ··· 93 100 if (IS_ERR(pwrseq->pwrseq)) 94 101 return dev_err_probe(dev, PTR_ERR(pwrseq->pwrseq), 95 102 "Failed to get the power sequencer\n"); 96 - 97 - ret = devm_add_action_or_reset(dev, devm_pwrseq_pwrctrl_power_off, 98 - pwrseq); 99 - if (ret) 100 - return ret; 101 103 102 104 pwrseq->pwrctrl.power_on = pwrseq_pwrctrl_power_on; 103 105 pwrseq->pwrctrl.power_off = pwrseq_pwrctrl_power_off;
-1
drivers/pci/pwrctrl/slot.c
··· 63 63 { 64 64 struct slot_pwrctrl *slot = data; 65 65 66 - slot_pwrctrl_power_off(&slot->pwrctrl); 67 66 regulator_bulk_free(slot->num_supplies, slot->supplies); 68 67 } 69 68
+2 -3
drivers/phy/Kconfig
··· 6 6 menu "PHY Subsystem" 7 7 8 8 config PHY_COMMON_PROPS 9 - bool 9 + bool "PHY common properties" if KUNIT_ALL_TESTS 10 10 help 11 11 This parses properties common between generic PHYs and Ethernet PHYs. 12 12 ··· 16 16 17 17 config PHY_COMMON_PROPS_TEST 18 18 tristate "KUnit tests for PHY common props" if !KUNIT_ALL_TESTS 19 - select PHY_COMMON_PROPS 20 - depends on KUNIT 19 + depends on KUNIT && PHY_COMMON_PROPS 21 20 default KUNIT_ALL_TESTS 22 21 help 23 22 This builds KUnit tests for the PHY common property API.
+2
drivers/phy/freescale/phy-fsl-lynx-28g.c
··· 1069 1069 1070 1070 for (i = 0; i < LYNX_28G_NUM_LANE; i++) { 1071 1071 lane = &priv->lane[i]; 1072 + if (!lane->phy) 1073 + continue; 1072 1074 1073 1075 mutex_lock(&lane->phy->mutex); 1074 1076
+1 -2
drivers/phy/qualcomm/phy-qcom-qmp-ufs.c
··· 990 990 QMP_PHY_INIT_CFG(QPHY_V6_PCS_UFS_MULTI_LANE_CTRL1, 0x02), 991 991 QMP_PHY_INIT_CFG(QPHY_V6_PCS_UFS_TX_MID_TERM_CTRL1, 0x43), 992 992 QMP_PHY_INIT_CFG(QPHY_V6_PCS_UFS_PCS_CTRL1, 0xc1), 993 + QMP_PHY_INIT_CFG(QPHY_V6_PCS_UFS_PLL_CNTL, 0x33), 993 994 QMP_PHY_INIT_CFG(QPHY_V6_PCS_UFS_TX_LARGE_AMP_DRV_LVL, 0x0f), 994 995 QMP_PHY_INIT_CFG(QPHY_V6_PCS_UFS_RX_SIGDET_CTRL2, 0x68), 995 996 QMP_PHY_INIT_CFG(QPHY_V6_PCS_UFS_TX_POST_EMP_LVL_S4, 0x0e), ··· 1000 999 }; 1001 1000 1002 1001 static const struct qmp_phy_init_tbl sm8650_ufsphy_g4_pcs[] = { 1003 - QMP_PHY_INIT_CFG(QPHY_V6_PCS_UFS_PLL_CNTL, 0x13), 1004 1002 QMP_PHY_INIT_CFG(QPHY_V6_PCS_UFS_TX_HSGEAR_CAPABILITY, 0x04), 1005 1003 QMP_PHY_INIT_CFG(QPHY_V6_PCS_UFS_RX_HSGEAR_CAPABILITY, 0x04), 1006 1004 }; 1007 1005 1008 1006 static const struct qmp_phy_init_tbl sm8650_ufsphy_g5_pcs[] = { 1009 - QMP_PHY_INIT_CFG(QPHY_V6_PCS_UFS_PLL_CNTL, 0x33), 1010 1007 QMP_PHY_INIT_CFG(QPHY_V6_PCS_UFS_TX_HSGEAR_CAPABILITY, 0x05), 1011 1008 QMP_PHY_INIT_CFG(QPHY_V6_PCS_UFS_RX_HSGEAR_CAPABILITY, 0x05), 1012 1009 QMP_PHY_INIT_CFG(QPHY_V6_PCS_UFS_RX_HS_G5_SYNC_LENGTH_CAPABILITY, 0x4d),
+14
drivers/phy/spacemit/phy-k1-usb2.c
··· 48 48 #define PHY_CLK_HSTXP_EN BIT(3) /* clock hstxp enable */ 49 49 #define PHY_HSTXP_MODE BIT(4) /* 0: force en_txp to be 1; 1: no force */ 50 50 51 + #define PHY_K1_HS_HOST_DISC 0x40 52 + #define PHY_K1_HS_HOST_DISC_CLR BIT(0) 53 + 51 54 #define PHY_PLL_DIV_CFG 0x98 52 55 #define PHY_FDIV_FRACT_8_15 GENMASK(7, 0) 53 56 #define PHY_FDIV_FRACT_16_19 GENMASK(11, 8) ··· 145 142 return 0; 146 143 } 147 144 145 + static int spacemit_usb2phy_disconnect(struct phy *phy, int port) 146 + { 147 + struct spacemit_usb2phy *sphy = phy_get_drvdata(phy); 148 + 149 + regmap_update_bits(sphy->regmap_base, PHY_K1_HS_HOST_DISC, 150 + PHY_K1_HS_HOST_DISC_CLR, PHY_K1_HS_HOST_DISC_CLR); 151 + 152 + return 0; 153 + } 154 + 148 155 static const struct phy_ops spacemit_usb2phy_ops = { 149 156 .init = spacemit_usb2phy_init, 150 157 .exit = spacemit_usb2phy_exit, 158 + .disconnect = spacemit_usb2phy_disconnect, 151 159 .owner = THIS_MODULE, 152 160 }; 153 161
+2
drivers/phy/ti/phy-j721e-wiz.c
··· 1425 1425 dev_err(dev, 1426 1426 "%s: Reading \"reg\" from \"%s\" failed: %d\n", 1427 1427 __func__, subnode->name, ret); 1428 + of_node_put(serdes); 1428 1429 return ret; 1429 1430 } 1430 1431 of_property_read_u32(subnode, "cdns,num-lanes", &num_lanes); ··· 1440 1439 } 1441 1440 } 1442 1441 1442 + of_node_put(serdes); 1443 1443 return 0; 1444 1444 } 1445 1445
+2 -1
drivers/scsi/ibmvscsi/ibmvfc.c
··· 4966 4966 switch (mad_status) { 4967 4967 case IBMVFC_MAD_SUCCESS: 4968 4968 ibmvfc_dbg(vhost, "Discover Targets succeeded\n"); 4969 - vhost->num_targets = be32_to_cpu(rsp->num_written); 4969 + vhost->num_targets = min_t(u32, be32_to_cpu(rsp->num_written), 4970 + max_targets); 4970 4971 ibmvfc_set_host_action(vhost, IBMVFC_HOST_ACTION_ALLOC_TGTS); 4971 4972 break; 4972 4973 case IBMVFC_MAD_FAILED:
+1 -1
drivers/scsi/scsi_transport_sas.c
··· 1734 1734 break; 1735 1735 1736 1736 default: 1737 - if (channel < shost->max_channel) { 1737 + if (channel <= shost->max_channel) { 1738 1738 res = scsi_scan_host_selected(shost, channel, id, lun, 1739 1739 SCSI_SCAN_MANUAL); 1740 1740 } else {
+1 -1
drivers/scsi/ses.c
··· 215 215 unsigned char *type_ptr = ses_dev->page1_types; 216 216 unsigned char *desc_ptr = ses_dev->page2 + 8; 217 217 218 - if (ses_recv_diag(sdev, 2, ses_dev->page2, ses_dev->page2_len) < 0) 218 + if (ses_recv_diag(sdev, 2, ses_dev->page2, ses_dev->page2_len)) 219 219 return NULL; 220 220 221 221 for (i = 0; i < ses_dev->page1_num_types; i++, type_ptr += 4) {
+2 -1
drivers/spi/spi-fsl-lpspi.c
··· 1009 1009 enable_irq(irq); 1010 1010 } 1011 1011 1012 - ret = devm_spi_register_controller(&pdev->dev, controller); 1012 + ret = spi_register_controller(controller); 1013 1013 if (ret < 0) { 1014 1014 dev_err_probe(&pdev->dev, ret, "spi_register_controller error\n"); 1015 1015 goto free_dma; ··· 1035 1035 struct fsl_lpspi_data *fsl_lpspi = 1036 1036 spi_controller_get_devdata(controller); 1037 1037 1038 + spi_unregister_controller(controller); 1038 1039 fsl_lpspi_dma_exit(controller); 1039 1040 1040 1041 pm_runtime_dont_use_autosuspend(fsl_lpspi->dev);
-2
drivers/spi/spi-meson-spicc.c
··· 1101 1101 1102 1102 /* Disable SPI */ 1103 1103 writel(0, spicc->base + SPICC_CONREG); 1104 - 1105 - spi_controller_put(spicc->host); 1106 1104 } 1107 1105 1108 1106 static const struct meson_spicc_data meson_spicc_gx_data = {
+10 -32
drivers/spi/spi-sn-f-ospi.c
··· 612 612 u32 num_cs = OSPI_NUM_CS; 613 613 int ret; 614 614 615 - ctlr = spi_alloc_host(dev, sizeof(*ospi)); 615 + ctlr = devm_spi_alloc_host(dev, sizeof(*ospi)); 616 616 if (!ctlr) 617 617 return -ENOMEM; 618 618 ··· 635 635 platform_set_drvdata(pdev, ospi); 636 636 637 637 ospi->base = devm_platform_ioremap_resource(pdev, 0); 638 - if (IS_ERR(ospi->base)) { 639 - ret = PTR_ERR(ospi->base); 640 - goto err_put_ctlr; 641 - } 638 + if (IS_ERR(ospi->base)) 639 + return PTR_ERR(ospi->base); 642 640 643 641 ospi->clk = devm_clk_get_enabled(dev, NULL); 644 - if (IS_ERR(ospi->clk)) { 645 - ret = PTR_ERR(ospi->clk); 646 - goto err_put_ctlr; 647 - } 642 + if (IS_ERR(ospi->clk)) 643 + return PTR_ERR(ospi->clk); 648 644 649 - mutex_init(&ospi->mlock); 645 + ret = devm_mutex_init(dev, &ospi->mlock); 646 + if (ret) 647 + return ret; 650 648 651 649 ret = f_ospi_init(ospi); 652 650 if (ret) 653 - goto err_destroy_mutex; 651 + return ret; 654 652 655 - ret = devm_spi_register_controller(dev, ctlr); 656 - if (ret) 657 - goto err_destroy_mutex; 658 - 659 - return 0; 660 - 661 - err_destroy_mutex: 662 - mutex_destroy(&ospi->mlock); 663 - 664 - err_put_ctlr: 665 - spi_controller_put(ctlr); 666 - 667 - return ret; 668 - } 669 - 670 - static void f_ospi_remove(struct platform_device *pdev) 671 - { 672 - struct f_ospi *ospi = platform_get_drvdata(pdev); 673 - 674 - mutex_destroy(&ospi->mlock); 653 + return devm_spi_register_controller(dev, ctlr); 675 654 } 676 655 677 656 static const struct of_device_id f_ospi_dt_ids[] = { ··· 665 686 .of_match_table = f_ospi_dt_ids, 666 687 }, 667 688 .probe = f_ospi_probe, 668 - .remove = f_ospi_remove, 669 689 }; 670 690 module_platform_driver(f_ospi_driver); 671 691
+19 -13
drivers/spi/spi.c
··· 50 50 struct spi_device *spi = to_spi_device(dev); 51 51 52 52 spi_controller_put(spi->controller); 53 - kfree(spi->driver_override); 54 53 free_percpu(spi->pcpu_statistics); 55 54 kfree(spi); 56 55 } ··· 72 73 struct device_attribute *a, 73 74 const char *buf, size_t count) 74 75 { 75 - struct spi_device *spi = to_spi_device(dev); 76 76 int ret; 77 77 78 - ret = driver_set_override(dev, &spi->driver_override, buf, count); 78 + ret = __device_set_driver_override(dev, buf, count); 79 79 if (ret) 80 80 return ret; 81 81 ··· 84 86 static ssize_t driver_override_show(struct device *dev, 85 87 struct device_attribute *a, char *buf) 86 88 { 87 - const struct spi_device *spi = to_spi_device(dev); 88 - ssize_t len; 89 - 90 - device_lock(dev); 91 - len = sysfs_emit(buf, "%s\n", spi->driver_override ? : ""); 92 - device_unlock(dev); 93 - return len; 89 + guard(spinlock)(&dev->driver_override.lock); 90 + return sysfs_emit(buf, "%s\n", dev->driver_override.name ?: ""); 94 91 } 95 92 static DEVICE_ATTR_RW(driver_override); 96 93 ··· 369 376 { 370 377 const struct spi_device *spi = to_spi_device(dev); 371 378 const struct spi_driver *sdrv = to_spi_driver(drv); 379 + int ret; 372 380 373 381 /* Check override first, and if set, only use the named driver */ 374 - if (spi->driver_override) 375 - return strcmp(spi->driver_override, drv->name) == 0; 382 + ret = device_match_driver_override(dev, drv); 383 + if (ret >= 0) 384 + return ret; 376 385 377 386 /* Attempt an OF style match */ 378 387 if (of_driver_match_device(dev, drv)) ··· 3534 3539 if (ret) 3535 3540 return ret; 3536 3541 3537 - return devm_add_action_or_reset(dev, devm_spi_unregister_controller, ctlr); 3542 + /* 3543 + * Prevent controller from being freed by spi_unregister_controller() 3544 + * if devm_add_action_or_reset() fails for a non-devres allocated 3545 + * controller. 3546 + */ 3547 + spi_controller_get(ctlr); 3538 3548 3549 + ret = devm_add_action_or_reset(dev, devm_spi_unregister_controller, ctlr); 3550 + 3551 + if (ret == 0 || ctlr->devm_allocated) 3552 + spi_controller_put(ctlr); 3553 + 3554 + return ret; 3539 3555 } 3540 3556 EXPORT_SYMBOL_GPL(devm_spi_register_controller); 3541 3557
+46 -6
drivers/target/loopback/tcm_loop.c
··· 26 26 #include <linux/slab.h> 27 27 #include <linux/types.h> 28 28 #include <linux/configfs.h> 29 + #include <linux/blk-mq.h> 29 30 #include <scsi/scsi.h> 30 31 #include <scsi/scsi_tcq.h> 31 32 #include <scsi/scsi_host.h> ··· 270 269 return (ret == TMR_FUNCTION_COMPLETE) ? SUCCESS : FAILED; 271 270 } 272 271 272 + static bool tcm_loop_flush_work_iter(struct request *rq, void *data) 273 + { 274 + struct scsi_cmnd *sc = blk_mq_rq_to_pdu(rq); 275 + struct tcm_loop_cmd *tl_cmd = scsi_cmd_priv(sc); 276 + struct se_cmd *se_cmd = &tl_cmd->tl_se_cmd; 277 + 278 + flush_work(&se_cmd->work); 279 + return true; 280 + } 281 + 273 282 static int tcm_loop_target_reset(struct scsi_cmnd *sc) 274 283 { 275 284 struct tcm_loop_hba *tl_hba; 276 285 struct tcm_loop_tpg *tl_tpg; 286 + struct Scsi_Host *sh = sc->device->host; 287 + int ret; 277 288 278 289 /* 279 290 * Locate the tcm_loop_hba_t pointer 280 291 */ 281 - tl_hba = *(struct tcm_loop_hba **)shost_priv(sc->device->host); 292 + tl_hba = *(struct tcm_loop_hba **)shost_priv(sh); 282 293 if (!tl_hba) { 283 294 pr_err("Unable to perform device reset without active I_T Nexus\n"); 284 295 return FAILED; ··· 299 286 * Locate the tl_tpg pointer from TargetID in sc->device->id 300 287 */ 301 288 tl_tpg = &tl_hba->tl_hba_tpgs[sc->device->id]; 302 - if (tl_tpg) { 303 - tl_tpg->tl_transport_status = TCM_TRANSPORT_ONLINE; 304 - return SUCCESS; 305 - } 306 - return FAILED; 289 + if (!tl_tpg) 290 + return FAILED; 291 + 292 + /* 293 + * Issue a LUN_RESET to drain all commands that the target core 294 + * knows about. This handles commands not yet marked CMD_T_COMPLETE. 295 + */ 296 + ret = tcm_loop_issue_tmr(tl_tpg, sc->device->lun, 0, TMR_LUN_RESET); 297 + if (ret != TMR_FUNCTION_COMPLETE) 298 + return FAILED; 299 + 300 + /* 301 + * Flush any deferred target core completion work that may still be 302 + * queued. Commands that already had CMD_T_COMPLETE set before the TMR 303 + * are skipped by the TMR drain, but their async completion work 304 + * (transport_lun_remove_cmd → percpu_ref_put, release_cmd → scsi_done) 305 + * may still be pending in target_completion_wq. 306 + * 307 + * The SCSI EH will reuse in-flight scsi_cmnd structures for recovery 308 + * commands (e.g. TUR) immediately after this handler returns SUCCESS — 309 + * if deferred work is still pending, the memset in queuecommand would 310 + * zero the se_cmd while the work accesses it, leaking the LUN 311 + * percpu_ref and hanging configfs unlink forever. 312 + * 313 + * Use blk_mq_tagset_busy_iter() to find all started requests and 314 + * flush_work() on each — the same pattern used by mpi3mr, scsi_debug, 315 + * and other SCSI drivers to drain outstanding commands during reset. 316 + */ 317 + blk_mq_tagset_busy_iter(&sh->tag_set, tcm_loop_flush_work_iter, NULL); 318 + 319 + tl_tpg->tl_transport_status = TCM_TRANSPORT_ONLINE; 320 + return SUCCESS; 307 321 } 308 322 309 323 static const struct scsi_host_template tcm_loop_driver_template = {
+1 -1
drivers/target/target_core_file.c
··· 276 276 ssize_t len = 0; 277 277 int ret = 0, i; 278 278 279 - aio_cmd = kmalloc_flex(*aio_cmd, bvecs, sgl_nents); 279 + aio_cmd = kzalloc_flex(*aio_cmd, bvecs, sgl_nents); 280 280 if (!aio_cmd) 281 281 return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; 282 282
+7 -1
drivers/thermal/intel/int340x_thermal/processor_thermal_soc_slider.c
··· 176 176 177 177 static void set_soc_power_profile(struct proc_thermal_device *proc_priv, int slider) 178 178 { 179 + u8 offset; 179 180 u64 val; 180 181 181 182 val = read_soc_slider(proc_priv); 182 183 val &= ~SLIDER_MASK; 183 184 val |= FIELD_PREP(SLIDER_MASK, slider) | BIT(SLIDER_ENABLE_BIT); 184 185 186 + if (slider == SOC_SLIDER_VALUE_MINIMUM || slider == SOC_SLIDER_VALUE_MAXIMUM) 187 + offset = 0; 188 + else 189 + offset = slider_offset; 190 + 185 191 /* Set the slider offset from module params */ 186 192 val &= ~SLIDER_OFFSET_MASK; 187 - val |= FIELD_PREP(SLIDER_OFFSET_MASK, slider_offset); 193 + val |= FIELD_PREP(SLIDER_OFFSET_MASK, offset); 188 194 189 195 write_soc_slider(proc_priv, val); 190 196 }
+2 -3
drivers/vfio/pci/vfio_pci_dmabuf.c
··· 301 301 */ 302 302 ret = dma_buf_fd(priv->dmabuf, get_dma_buf.open_flags); 303 303 if (ret < 0) 304 - goto err_dma_buf; 304 + dma_buf_put(priv->dmabuf); 305 + 305 306 return ret; 306 307 307 - err_dma_buf: 308 - dma_buf_put(priv->dmabuf); 309 308 err_dev_put: 310 309 vfio_device_put_registration(&vdev->vdev); 311 310 err_free_phys:
+10 -2
drivers/virt/coco/tdx-guest/tdx-guest.c
··· 171 171 #define GET_QUOTE_SUCCESS 0 172 172 #define GET_QUOTE_IN_FLIGHT 0xffffffffffffffff 173 173 174 + #define TDX_QUOTE_MAX_LEN (GET_QUOTE_BUF_SIZE - sizeof(struct tdx_quote_buf)) 175 + 174 176 /* struct tdx_quote_buf: Format of Quote request buffer. 175 177 * @version: Quote format version, filled by TD. 176 178 * @status: Status code of Quote request, filled by VMM. ··· 271 269 u8 *buf; 272 270 struct tdx_quote_buf *quote_buf = quote_data; 273 271 struct tsm_report_desc *desc = &report->desc; 272 + u32 out_len; 274 273 int ret; 275 274 u64 err; 276 275 ··· 309 306 return ret; 310 307 } 311 308 312 - buf = kvmemdup(quote_buf->data, quote_buf->out_len, GFP_KERNEL); 309 + out_len = READ_ONCE(quote_buf->out_len); 310 + 311 + if (out_len > TDX_QUOTE_MAX_LEN) 312 + return -EFBIG; 313 + 314 + buf = kvmemdup(quote_buf->data, out_len, GFP_KERNEL); 313 315 if (!buf) 314 316 return -ENOMEM; 315 317 316 318 report->outblob = buf; 317 - report->outblob_len = quote_buf->out_len; 319 + report->outblob_len = out_len; 318 320 319 321 /* 320 322 * TODO: parse the PEM-formatted cert chain out of the quote buffer when
+3
drivers/xen/privcmd.c
··· 1765 1765 1766 1766 static void __exit privcmd_exit(void) 1767 1767 { 1768 + if (!xen_initial_domain()) 1769 + unregister_xenstore_notifier(&xenstore_notifier); 1770 + 1768 1771 privcmd_ioeventfd_exit(); 1769 1772 privcmd_irqfd_exit(); 1770 1773 misc_deregister(&privcmd_dev);
+1 -1
fs/btrfs/block-group.c
··· 4583 4583 for (int i = 0; i < BTRFS_SPACE_INFO_SUB_GROUP_MAX; i++) { 4584 4584 if (space_info->sub_group[i]) { 4585 4585 check_removing_space_info(space_info->sub_group[i]); 4586 - kfree(space_info->sub_group[i]); 4586 + btrfs_sysfs_remove_space_info(space_info->sub_group[i]); 4587 4587 space_info->sub_group[i] = NULL; 4588 4588 } 4589 4589 }
+2 -2
fs/btrfs/disk-io.c
··· 2531 2531 2532 2532 if (mirror_num >= 0 && 2533 2533 btrfs_super_bytenr(sb) != btrfs_sb_offset(mirror_num)) { 2534 - btrfs_err(fs_info, "super offset mismatch %llu != %u", 2535 - btrfs_super_bytenr(sb), BTRFS_SUPER_INFO_OFFSET); 2534 + btrfs_err(fs_info, "super offset mismatch %llu != %llu", 2535 + btrfs_super_bytenr(sb), btrfs_sb_offset(mirror_num)); 2536 2536 ret = -EINVAL; 2537 2537 } 2538 2538
+65 -33
fs/btrfs/tree-log.c
··· 4616 4616 struct inode *inode, bool log_inode_only, 4617 4617 u64 logged_isize) 4618 4618 { 4619 + u64 gen = BTRFS_I(inode)->generation; 4619 4620 u64 flags; 4620 4621 4621 4622 if (log_inode_only) { 4622 - /* set the generation to zero so the recover code 4623 - * can tell the difference between an logging 4624 - * just to say 'this inode exists' and a logging 4625 - * to say 'update this inode with these values' 4623 + /* 4624 + * Set the generation to zero so the recover code can tell the 4625 + * difference between a logging just to say 'this inode exists' 4626 + * and a logging to say 'update this inode with these values'. 4627 + * But only if the inode was not already logged before. 4628 + * We access ->logged_trans directly since it was already set 4629 + * up in the call chain by btrfs_log_inode(), and data_race() 4630 + * to avoid false alerts from KCSAN and since it was set already 4631 + * and one can set it to 0 since that only happens on eviction 4632 + * and we are holding a ref on the inode. 4626 4633 */ 4627 - btrfs_set_inode_generation(leaf, item, 0); 4634 + ASSERT(data_race(BTRFS_I(inode)->logged_trans) > 0); 4635 + if (data_race(BTRFS_I(inode)->logged_trans) < trans->transid) 4636 + gen = 0; 4637 + 4628 4638 btrfs_set_inode_size(leaf, item, logged_isize); 4629 4639 } else { 4630 - btrfs_set_inode_generation(leaf, item, BTRFS_I(inode)->generation); 4631 4640 btrfs_set_inode_size(leaf, item, inode->i_size); 4632 4641 } 4642 + 4643 + btrfs_set_inode_generation(leaf, item, gen); 4633 4644 4634 4645 btrfs_set_inode_uid(leaf, item, i_uid_read(inode)); 4635 4646 btrfs_set_inode_gid(leaf, item, i_gid_read(inode)); ··· 5459 5448 return 0; 5460 5449 } 5461 5450 5462 - static int logged_inode_size(struct btrfs_root *log, struct btrfs_inode *inode, 5463 - struct btrfs_path *path, u64 *size_ret) 5451 + static int get_inode_size_to_log(struct btrfs_trans_handle *trans, 5452 + struct btrfs_inode *inode, 5453 + struct btrfs_path *path, u64 *size_ret) 5464 5454 { 5465 5455 struct btrfs_key key; 5456 + struct btrfs_inode_item *item; 5466 5457 int ret; 5467 5458 5468 5459 key.objectid = btrfs_ino(inode); 5469 5460 key.type = BTRFS_INODE_ITEM_KEY; 5470 5461 key.offset = 0; 5471 5462 5472 - ret = btrfs_search_slot(NULL, log, &key, path, 0, 0); 5473 - if (ret < 0) { 5474 - return ret; 5475 - } else if (ret > 0) { 5476 - *size_ret = 0; 5477 - } else { 5478 - struct btrfs_inode_item *item; 5463 + /* 5464 + * Our caller called inode_logged(), so logged_trans is up to date. 5465 + * Use data_race() to silence any warning from KCSAN. Once logged_trans 5466 + * is set, it can only be reset to 0 after inode eviction. 5467 + */ 5468 + if (data_race(inode->logged_trans) == trans->transid) { 5469 + ret = btrfs_search_slot(NULL, inode->root->log_root, &key, path, 0, 0); 5470 + } else if (inode->generation < trans->transid) { 5471 + path->search_commit_root = true; 5472 + path->skip_locking = true; 5473 + ret = btrfs_search_slot(NULL, inode->root, &key, path, 0, 0); 5474 + path->search_commit_root = false; 5475 + path->skip_locking = false; 5479 5476 5480 - item = btrfs_item_ptr(path->nodes[0], path->slots[0], 5481 - struct btrfs_inode_item); 5482 - *size_ret = btrfs_inode_size(path->nodes[0], item); 5483 - /* 5484 - * If the in-memory inode's i_size is smaller then the inode 5485 - * size stored in the btree, return the inode's i_size, so 5486 - * that we get a correct inode size after replaying the log 5487 - * when before a power failure we had a shrinking truncate 5488 - * followed by addition of a new name (rename / new hard link). 5489 - * Otherwise return the inode size from the btree, to avoid 5490 - * data loss when replaying a log due to previously doing a 5491 - * write that expands the inode's size and logging a new name 5492 - * immediately after. 5493 - */ 5494 - if (*size_ret > inode->vfs_inode.i_size) 5495 - *size_ret = inode->vfs_inode.i_size; 5477 + } else { 5478 + *size_ret = 0; 5479 + return 0; 5496 5480 } 5481 + 5482 + /* 5483 + * If the inode was logged before or is from a past transaction, then 5484 + * its inode item must exist in the log root or in the commit root. 5485 + */ 5486 + ASSERT(ret <= 0); 5487 + if (WARN_ON_ONCE(ret > 0)) 5488 + ret = -ENOENT; 5489 + 5490 + if (ret < 0) 5491 + return ret; 5492 + 5493 + item = btrfs_item_ptr(path->nodes[0], path->slots[0], 5494 + struct btrfs_inode_item); 5495 + *size_ret = btrfs_inode_size(path->nodes[0], item); 5496 + /* 5497 + * If the in-memory inode's i_size is smaller then the inode size stored 5498 + * in the btree, return the inode's i_size, so that we get a correct 5499 + * inode size after replaying the log when before a power failure we had 5500 + * a shrinking truncate followed by addition of a new name (rename / new 5501 + * hard link). Otherwise return the inode size from the btree, to avoid 5502 + * data loss when replaying a log due to previously doing a write that 5503 + * expands the inode's size and logging a new name immediately after. 5504 + */ 5505 + if (*size_ret > inode->vfs_inode.i_size) 5506 + *size_ret = inode->vfs_inode.i_size; 5497 5507 5498 5508 btrfs_release_path(path); 5499 5509 return 0; ··· 7028 6996 ret = drop_inode_items(trans, log, path, inode, 7029 6997 BTRFS_XATTR_ITEM_KEY); 7030 6998 } else { 7031 - if (inode_only == LOG_INODE_EXISTS && ctx->logged_before) { 6999 + if (inode_only == LOG_INODE_EXISTS) { 7032 7000 /* 7033 7001 * Make sure the new inode item we write to the log has 7034 7002 * the same isize as the current one (if it exists). ··· 7042 7010 * (zeroes), as if an expanding truncate happened, 7043 7011 * instead of getting a file of 4Kb only. 7044 7012 */ 7045 - ret = logged_inode_size(log, inode, path, &logged_isize); 7013 + ret = get_inode_size_to_log(trans, inode, path, &logged_isize); 7046 7014 if (ret) 7047 7015 goto out_unlock; 7048 7016 }
+3 -2
fs/btrfs/volumes.c
··· 8099 8099 smp_rmb(); 8100 8100 8101 8101 ret = update_dev_stat_item(trans, device); 8102 - if (!ret) 8103 - atomic_sub(stats_cnt, &device->dev_stats_ccnt); 8102 + if (ret) 8103 + break; 8104 + atomic_sub(stats_cnt, &device->dev_stats_ccnt); 8104 8105 } 8105 8106 mutex_unlock(&fs_devices->device_list_mutex); 8106 8107
+3 -1
fs/btrfs/zlib.c
··· 308 308 } 309 309 /* Queue the remaining part of the folio. */ 310 310 if (workspace->strm.total_out > bio->bi_iter.bi_size) { 311 - u32 cur_len = offset_in_folio(out_folio, workspace->strm.total_out); 311 + const u32 cur_len = workspace->strm.total_out - bio->bi_iter.bi_size; 312 + 313 + ASSERT(cur_len <= folio_size(out_folio)); 312 314 313 315 if (!bio_add_folio(bio, out_folio, cur_len, 0)) { 314 316 ret = -E2BIG;
+3 -2
fs/ext4/Makefile
··· 14 14 15 15 ext4-$(CONFIG_EXT4_FS_POSIX_ACL) += acl.o 16 16 ext4-$(CONFIG_EXT4_FS_SECURITY) += xattr_security.o 17 - ext4-inode-test-objs += inode-test.o 18 - obj-$(CONFIG_EXT4_KUNIT_TESTS) += ext4-inode-test.o 17 + ext4-test-objs += inode-test.o mballoc-test.o \ 18 + extents-test.o 19 + obj-$(CONFIG_EXT4_KUNIT_TESTS) += ext4-test.o 19 20 ext4-$(CONFIG_FS_VERITY) += verity.o 20 21 ext4-$(CONFIG_FS_ENCRYPTION) += crypto.o
+8 -1
fs/ext4/crypto.c
··· 163 163 */ 164 164 165 165 if (handle) { 166 + /* 167 + * Since the inode is new it is ok to pass the 168 + * XATTR_CREATE flag. This is necessary to match the 169 + * remaining journal credits check in the set_handle 170 + * function with the credits allocated for the new 171 + * inode. 172 + */ 166 173 res = ext4_xattr_set_handle(handle, inode, 167 174 EXT4_XATTR_INDEX_ENCRYPTION, 168 175 EXT4_XATTR_NAME_ENCRYPTION_CONTEXT, 169 - ctx, len, 0); 176 + ctx, len, XATTR_CREATE); 170 177 if (!res) { 171 178 ext4_set_inode_flag(inode, EXT4_INODE_ENCRYPT); 172 179 ext4_clear_inode_state(inode,
+6
fs/ext4/ext4.h
··· 1570 1570 struct proc_dir_entry *s_proc; 1571 1571 struct kobject s_kobj; 1572 1572 struct completion s_kobj_unregister; 1573 + struct mutex s_error_notify_mutex; /* protects sysfs_notify vs kobject_del */ 1573 1574 struct super_block *s_sb; 1574 1575 struct buffer_head *s_mmp_bh; 1575 1576 ··· 3945 3944 extern int ext4_block_write_begin(handle_t *handle, struct folio *folio, 3946 3945 loff_t pos, unsigned len, 3947 3946 get_block_t *get_block); 3947 + 3948 + #if IS_ENABLED(CONFIG_EXT4_KUNIT_TESTS) 3949 + #define EXPORT_SYMBOL_FOR_EXT4_TEST(sym) \ 3950 + EXPORT_SYMBOL_FOR_MODULES(sym, "ext4-test") 3951 + #endif 3948 3952 #endif /* __KERNEL__ */ 3949 3953 3950 3954 #endif /* _EXT4_H */
+12
fs/ext4/ext4_extents.h
··· 264 264 0xffff); 265 265 } 266 266 267 + extern int __ext4_ext_dirty(const char *where, unsigned int line, 268 + handle_t *handle, struct inode *inode, 269 + struct ext4_ext_path *path); 270 + extern int ext4_ext_zeroout(struct inode *inode, struct ext4_extent *ex); 271 + #if IS_ENABLED(CONFIG_EXT4_KUNIT_TESTS) 272 + extern int ext4_ext_space_root_idx_test(struct inode *inode, int check); 273 + extern struct ext4_ext_path *ext4_split_convert_extents_test( 274 + handle_t *handle, struct inode *inode, 275 + struct ext4_map_blocks *map, 276 + struct ext4_ext_path *path, 277 + int flags, unsigned int *allocated); 278 + #endif 267 279 #endif /* _EXT4_EXTENTS */ 268 280
+7 -5
fs/ext4/extents-test.c
··· 142 142 143 143 static void extents_kunit_exit(struct kunit *test) 144 144 { 145 - struct ext4_sb_info *sbi = k_ctx.k_ei->vfs_inode.i_sb->s_fs_info; 145 + struct super_block *sb = k_ctx.k_ei->vfs_inode.i_sb; 146 + struct ext4_sb_info *sbi = sb->s_fs_info; 146 147 148 + ext4_es_unregister_shrinker(sbi); 147 149 kfree(sbi); 148 150 kfree(k_ctx.k_ei); 149 151 kfree(k_ctx.k_data); ··· 282 280 eh->eh_depth = 0; 283 281 eh->eh_entries = cpu_to_le16(1); 284 282 eh->eh_magic = EXT4_EXT_MAGIC; 285 - eh->eh_max = 286 - cpu_to_le16(ext4_ext_space_root_idx(&k_ctx.k_ei->vfs_inode, 0)); 283 + eh->eh_max = cpu_to_le16(ext4_ext_space_root_idx_test( 284 + &k_ctx.k_ei->vfs_inode, 0)); 287 285 eh->eh_generation = 0; 288 286 289 287 /* ··· 386 384 387 385 switch (param->type) { 388 386 case TEST_SPLIT_CONVERT: 389 - path = ext4_split_convert_extents(NULL, inode, &map, path, 390 - param->split_flags, NULL); 387 + path = ext4_split_convert_extents_test(NULL, inode, &map, 388 + path, param->split_flags, NULL); 391 389 break; 392 390 case TEST_CREATE_BLOCKS: 393 391 ext4_map_create_blocks_helper(test, inode, &map, param->split_flags);
+68 -12
fs/ext4/extents.c
··· 184 184 * - ENOMEM 185 185 * - EIO 186 186 */ 187 - static int __ext4_ext_dirty(const char *where, unsigned int line, 188 - handle_t *handle, struct inode *inode, 189 - struct ext4_ext_path *path) 187 + int __ext4_ext_dirty(const char *where, unsigned int line, 188 + handle_t *handle, struct inode *inode, 189 + struct ext4_ext_path *path) 190 190 { 191 191 int err; 192 192 ··· 1736 1736 err = ext4_ext_get_access(handle, inode, path + k); 1737 1737 if (err) 1738 1738 return err; 1739 + if (unlikely(path[k].p_idx > EXT_LAST_INDEX(path[k].p_hdr))) { 1740 + EXT4_ERROR_INODE(inode, 1741 + "path[%d].p_idx %p > EXT_LAST_INDEX %p", 1742 + k, path[k].p_idx, 1743 + EXT_LAST_INDEX(path[k].p_hdr)); 1744 + return -EFSCORRUPTED; 1745 + } 1739 1746 path[k].p_idx->ei_block = border; 1740 1747 err = ext4_ext_dirty(handle, inode, path + k); 1741 1748 if (err) ··· 1755 1748 err = ext4_ext_get_access(handle, inode, path + k); 1756 1749 if (err) 1757 1750 goto clean; 1751 + if (unlikely(path[k].p_idx > EXT_LAST_INDEX(path[k].p_hdr))) { 1752 + EXT4_ERROR_INODE(inode, 1753 + "path[%d].p_idx %p > EXT_LAST_INDEX %p", 1754 + k, path[k].p_idx, 1755 + EXT_LAST_INDEX(path[k].p_hdr)); 1756 + err = -EFSCORRUPTED; 1757 + goto clean; 1758 + } 1758 1759 path[k].p_idx->ei_block = border; 1759 1760 err = ext4_ext_dirty(handle, inode, path + k); 1760 1761 if (err) ··· 3159 3144 } 3160 3145 3161 3146 /* FIXME!! we need to try to merge to left or right after zero-out */ 3162 - static int ext4_ext_zeroout(struct inode *inode, struct ext4_extent *ex) 3147 + int ext4_ext_zeroout(struct inode *inode, struct ext4_extent *ex) 3163 3148 { 3164 3149 ext4_fsblk_t ee_pblock; 3165 3150 unsigned int ee_len; ··· 3254 3239 3255 3240 insert_err = PTR_ERR(path); 3256 3241 err = 0; 3242 + if (insert_err != -ENOSPC && insert_err != -EDQUOT && 3243 + insert_err != -ENOMEM) 3244 + goto out_path; 3257 3245 3258 3246 /* 3259 3247 * Get a new path to try to zeroout or fix the extent length. ··· 3273 3255 goto out_path; 3274 3256 } 3275 3257 3258 + depth = ext_depth(inode); 3259 + ex = path[depth].p_ext; 3260 + if (!ex) { 3261 + EXT4_ERROR_INODE(inode, 3262 + "bad extent address lblock: %lu, depth: %d pblock %llu", 3263 + (unsigned long)ee_block, depth, path[depth].p_block); 3264 + err = -EFSCORRUPTED; 3265 + goto out; 3266 + } 3267 + 3276 3268 err = ext4_ext_get_access(handle, inode, path + depth); 3277 3269 if (err) 3278 3270 goto out; 3279 - 3280 - depth = ext_depth(inode); 3281 - ex = path[depth].p_ext; 3282 3271 3283 3272 fix_extent_len: 3284 3273 ex->ee_len = orig_ex.ee_len; ··· 3388 3363 3389 3364 ext4_ext_mark_initialized(ex); 3390 3365 3391 - ext4_ext_dirty(handle, inode, path + depth); 3366 + err = ext4_ext_dirty(handle, inode, path + depth); 3392 3367 if (err) 3393 3368 return err; 3394 3369 ··· 4482 4457 path = ext4_ext_insert_extent(handle, inode, path, &newex, flags); 4483 4458 if (IS_ERR(path)) { 4484 4459 err = PTR_ERR(path); 4485 - if (allocated_clusters) { 4460 + /* 4461 + * Gracefully handle out of space conditions. If the filesystem 4462 + * is inconsistent, we'll just leak allocated blocks to avoid 4463 + * causing even more damage. 4464 + */ 4465 + if (allocated_clusters && (err == -EDQUOT || err == -ENOSPC)) { 4486 4466 int fb_flags = 0; 4487 - 4488 4467 /* 4489 4468 * free data blocks we just allocated. 4490 4469 * not a good idea to call discard here directly, ··· 6267 6238 return 0; 6268 6239 } 6269 6240 6270 - #ifdef CONFIG_EXT4_KUNIT_TESTS 6271 - #include "extents-test.c" 6241 + #if IS_ENABLED(CONFIG_EXT4_KUNIT_TESTS) 6242 + int ext4_ext_space_root_idx_test(struct inode *inode, int check) 6243 + { 6244 + return ext4_ext_space_root_idx(inode, check); 6245 + } 6246 + EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_ext_space_root_idx_test); 6247 + 6248 + struct ext4_ext_path *ext4_split_convert_extents_test(handle_t *handle, 6249 + struct inode *inode, struct ext4_map_blocks *map, 6250 + struct ext4_ext_path *path, int flags, 6251 + unsigned int *allocated) 6252 + { 6253 + return ext4_split_convert_extents(handle, inode, map, path, 6254 + flags, allocated); 6255 + } 6256 + EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_split_convert_extents_test); 6257 + 6258 + EXPORT_SYMBOL_FOR_EXT4_TEST(__ext4_ext_dirty); 6259 + EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_ext_zeroout); 6260 + EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_es_register_shrinker); 6261 + EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_es_unregister_shrinker); 6262 + EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_map_create_blocks); 6263 + EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_es_init_tree); 6264 + EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_es_lookup_extent); 6265 + EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_es_insert_extent); 6266 + EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_ext_insert_extent); 6267 + EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_find_extent); 6268 + EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_issue_zeroout); 6269 + EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_map_query_blocks); 6272 6270 #endif
+10 -7
fs/ext4/fast_commit.c
··· 975 975 int ret = 0; 976 976 977 977 list_for_each_entry(ei, &sbi->s_fc_q[FC_Q_MAIN], i_fc_list) { 978 - ret = jbd2_submit_inode_data(journal, ei->jinode); 978 + ret = jbd2_submit_inode_data(journal, READ_ONCE(ei->jinode)); 979 979 if (ret) 980 980 return ret; 981 981 } 982 982 983 983 list_for_each_entry(ei, &sbi->s_fc_q[FC_Q_MAIN], i_fc_list) { 984 - ret = jbd2_wait_inode_data(journal, ei->jinode); 984 + ret = jbd2_wait_inode_data(journal, READ_ONCE(ei->jinode)); 985 985 if (ret) 986 986 return ret; 987 987 } ··· 1613 1613 /* Immediately update the inode on disk. */ 1614 1614 ret = ext4_handle_dirty_metadata(NULL, NULL, iloc.bh); 1615 1615 if (ret) 1616 - goto out; 1616 + goto out_brelse; 1617 1617 ret = sync_dirty_buffer(iloc.bh); 1618 1618 if (ret) 1619 - goto out; 1619 + goto out_brelse; 1620 1620 ret = ext4_mark_inode_used(sb, ino); 1621 1621 if (ret) 1622 - goto out; 1622 + goto out_brelse; 1623 1623 1624 1624 /* Given that we just wrote the inode on disk, this SHOULD succeed. */ 1625 1625 inode = ext4_iget(sb, ino, EXT4_IGET_NORMAL); 1626 1626 if (IS_ERR(inode)) { 1627 1627 ext4_debug("Inode not found."); 1628 - return -EFSCORRUPTED; 1628 + inode = NULL; 1629 + ret = -EFSCORRUPTED; 1630 + goto out_brelse; 1629 1631 } 1630 1632 1631 1633 /* ··· 1644 1642 ext4_inode_csum_set(inode, ext4_raw_inode(&iloc), EXT4_I(inode)); 1645 1643 ret = ext4_handle_dirty_metadata(NULL, NULL, iloc.bh); 1646 1644 sync_dirty_buffer(iloc.bh); 1645 + out_brelse: 1647 1646 brelse(iloc.bh); 1648 1647 out: 1649 1648 iput(inode); 1650 1649 if (!ret) 1651 1650 blkdev_issue_flush(sb->s_bdev); 1652 1651 1653 - return 0; 1652 + return ret; 1654 1653 } 1655 1654 1656 1655 /*
+14 -2
fs/ext4/fsync.c
··· 83 83 int datasync, bool *needs_barrier) 84 84 { 85 85 struct inode *inode = file->f_inode; 86 + struct writeback_control wbc = { 87 + .sync_mode = WB_SYNC_ALL, 88 + .nr_to_write = 0, 89 + }; 86 90 int ret; 87 91 88 92 ret = generic_buffers_fsync_noflush(file, start, end, datasync); 89 - if (!ret) 90 - ret = ext4_sync_parent(inode); 93 + if (ret) 94 + return ret; 95 + 96 + /* Force writeout of inode table buffer to disk */ 97 + ret = ext4_write_inode(inode, &wbc); 98 + if (ret) 99 + return ret; 100 + 101 + ret = ext4_sync_parent(inode); 102 + 91 103 if (test_opt(inode->i_sb, BARRIER)) 92 104 *needs_barrier = true; 93 105
+6
fs/ext4/ialloc.c
··· 686 686 if (unlikely(!gdp)) 687 687 return 0; 688 688 689 + /* Inode was never used in this filesystem? */ 690 + if (ext4_has_group_desc_csum(sb) && 691 + (gdp->bg_flags & cpu_to_le16(EXT4_BG_INODE_UNINIT) || 692 + ino >= EXT4_INODES_PER_GROUP(sb) - ext4_itable_unused_count(sb, gdp))) 693 + return 0; 694 + 689 695 bh = sb_find_get_block(sb, ext4_inode_table(sb, gdp) + 690 696 (ino / inodes_per_block)); 691 697 if (!bh || !buffer_uptodate(bh))
+9 -1
fs/ext4/inline.c
··· 522 522 goto out; 523 523 524 524 len = min_t(size_t, ext4_get_inline_size(inode), i_size_read(inode)); 525 - BUG_ON(len > PAGE_SIZE); 525 + 526 + if (len > PAGE_SIZE) { 527 + ext4_error_inode(inode, __func__, __LINE__, 0, 528 + "inline size %zu exceeds PAGE_SIZE", len); 529 + ret = -EFSCORRUPTED; 530 + brelse(iloc.bh); 531 + goto out; 532 + } 533 + 526 534 kaddr = kmap_local_folio(folio, 0); 527 535 ret = ext4_read_inline_data(inode, kaddr, len, &iloc); 528 536 kaddr = folio_zero_tail(folio, len, kaddr + len);
+60 -15
fs/ext4/inode.c
··· 128 128 static inline int ext4_begin_ordered_truncate(struct inode *inode, 129 129 loff_t new_size) 130 130 { 131 + struct jbd2_inode *jinode = READ_ONCE(EXT4_I(inode)->jinode); 132 + 131 133 trace_ext4_begin_ordered_truncate(inode, new_size); 132 134 /* 133 135 * If jinode is zero, then we never opened the file for ··· 137 135 * jbd2_journal_begin_ordered_truncate() since there's no 138 136 * outstanding writes we need to flush. 139 137 */ 140 - if (!EXT4_I(inode)->jinode) 138 + if (!jinode) 141 139 return 0; 142 140 return jbd2_journal_begin_ordered_truncate(EXT4_JOURNAL(inode), 143 - EXT4_I(inode)->jinode, 141 + jinode, 144 142 new_size); 145 143 } 146 144 ··· 186 184 if (EXT4_I(inode)->i_flags & EXT4_EA_INODE_FL) 187 185 ext4_evict_ea_inode(inode); 188 186 if (inode->i_nlink) { 187 + /* 188 + * If there's dirty page will lead to data loss, user 189 + * could see stale data. 190 + */ 191 + if (unlikely(!ext4_emergency_state(inode->i_sb) && 192 + mapping_tagged(&inode->i_data, PAGECACHE_TAG_DIRTY))) 193 + ext4_warning_inode(inode, "data will be lost"); 194 + 189 195 truncate_inode_pages_final(&inode->i_data); 190 196 191 197 goto no_delete; ··· 4461 4451 spin_unlock(&inode->i_lock); 4462 4452 return -ENOMEM; 4463 4453 } 4464 - ei->jinode = jinode; 4465 - jbd2_journal_init_jbd_inode(ei->jinode, inode); 4454 + jbd2_journal_init_jbd_inode(jinode, inode); 4455 + /* 4456 + * Publish ->jinode only after it is fully initialized so that 4457 + * readers never observe a partially initialized jbd2_inode. 4458 + */ 4459 + smp_wmb(); 4460 + WRITE_ONCE(ei->jinode, jinode); 4466 4461 jinode = NULL; 4467 4462 } 4468 4463 spin_unlock(&inode->i_lock); ··· 5416 5401 inode->i_op = &ext4_encrypted_symlink_inode_operations; 5417 5402 } else if (ext4_inode_is_fast_symlink(inode)) { 5418 5403 inode->i_op = &ext4_fast_symlink_inode_operations; 5419 - if (inode->i_size == 0 || 5420 - inode->i_size >= sizeof(ei->i_data) || 5421 - strnlen((char *)ei->i_data, inode->i_size + 1) != 5422 - inode->i_size) { 5423 - ext4_error_inode(inode, function, line, 0, 5424 - "invalid fast symlink length %llu", 5425 - (unsigned long long)inode->i_size); 5426 - ret = -EFSCORRUPTED; 5427 - goto bad_inode; 5404 + 5405 + /* 5406 + * Orphan cleanup can see inodes with i_size == 0 5407 + * and i_data uninitialized. Skip size checks in 5408 + * that case. This is safe because the first thing 5409 + * ext4_evict_inode() does for fast symlinks is 5410 + * clearing of i_data and i_size. 5411 + */ 5412 + if ((EXT4_SB(sb)->s_mount_state & EXT4_ORPHAN_FS)) { 5413 + if (inode->i_nlink != 0) { 5414 + ext4_error_inode(inode, function, line, 0, 5415 + "invalid orphan symlink nlink %d", 5416 + inode->i_nlink); 5417 + ret = -EFSCORRUPTED; 5418 + goto bad_inode; 5419 + } 5420 + } else { 5421 + if (inode->i_size == 0 || 5422 + inode->i_size >= sizeof(ei->i_data) || 5423 + strnlen((char *)ei->i_data, inode->i_size + 1) != 5424 + inode->i_size) { 5425 + ext4_error_inode(inode, function, line, 0, 5426 + "invalid fast symlink length %llu", 5427 + (unsigned long long)inode->i_size); 5428 + ret = -EFSCORRUPTED; 5429 + goto bad_inode; 5430 + } 5431 + inode_set_cached_link(inode, (char *)ei->i_data, 5432 + inode->i_size); 5428 5433 } 5429 - inode_set_cached_link(inode, (char *)ei->i_data, 5430 - inode->i_size); 5431 5434 } else { 5432 5435 inode->i_op = &ext4_symlink_inode_operations; 5433 5436 } ··· 5881 5848 5882 5849 if (attr->ia_size == inode->i_size) 5883 5850 inc_ivers = false; 5851 + 5852 + /* 5853 + * If file has inline data but new size exceeds inline capacity, 5854 + * convert to extent-based storage first to prevent inconsistent 5855 + * state (inline flag set but size exceeds inline capacity). 5856 + */ 5857 + if (ext4_has_inline_data(inode) && 5858 + attr->ia_size > EXT4_I(inode)->i_inline_size) { 5859 + error = ext4_convert_inline_data(inode); 5860 + if (error) 5861 + goto err_out; 5862 + } 5884 5863 5885 5864 if (shrink) { 5886 5865 if (ext4_should_order_data(inode)) {
+41 -40
fs/ext4/mballoc-test.c
··· 8 8 #include <linux/random.h> 9 9 10 10 #include "ext4.h" 11 + #include "mballoc.h" 11 12 12 13 struct mbt_grp_ctx { 13 14 struct buffer_head bitmap_bh; ··· 337 336 if (state) 338 337 mb_set_bits(bitmap_bh->b_data, blkoff, len); 339 338 else 340 - mb_clear_bits(bitmap_bh->b_data, blkoff, len); 339 + mb_clear_bits_test(bitmap_bh->b_data, blkoff, len); 341 340 342 341 return 0; 343 342 } ··· 414 413 415 414 /* get block at goal */ 416 415 ar.goal = ext4_group_first_block_no(sb, goal_group); 417 - found = ext4_mb_new_blocks_simple(&ar, &err); 416 + found = ext4_mb_new_blocks_simple_test(&ar, &err); 418 417 KUNIT_ASSERT_EQ_MSG(test, ar.goal, found, 419 418 "failed to alloc block at goal, expected %llu found %llu", 420 419 ar.goal, found); 421 420 422 421 /* get block after goal in goal group */ 423 422 ar.goal = ext4_group_first_block_no(sb, goal_group); 424 - found = ext4_mb_new_blocks_simple(&ar, &err); 423 + found = ext4_mb_new_blocks_simple_test(&ar, &err); 425 424 KUNIT_ASSERT_EQ_MSG(test, ar.goal + EXT4_C2B(sbi, 1), found, 426 425 "failed to alloc block after goal in goal group, expected %llu found %llu", 427 426 ar.goal + 1, found); ··· 429 428 /* get block after goal group */ 430 429 mbt_ctx_mark_used(sb, goal_group, 0, EXT4_CLUSTERS_PER_GROUP(sb)); 431 430 ar.goal = ext4_group_first_block_no(sb, goal_group); 432 - found = ext4_mb_new_blocks_simple(&ar, &err); 431 + found = ext4_mb_new_blocks_simple_test(&ar, &err); 433 432 KUNIT_ASSERT_EQ_MSG(test, 434 433 ext4_group_first_block_no(sb, goal_group + 1), found, 435 434 "failed to alloc block after goal group, expected %llu found %llu", ··· 439 438 for (i = goal_group; i < ext4_get_groups_count(sb); i++) 440 439 mbt_ctx_mark_used(sb, i, 0, EXT4_CLUSTERS_PER_GROUP(sb)); 441 440 ar.goal = ext4_group_first_block_no(sb, goal_group); 442 - found = ext4_mb_new_blocks_simple(&ar, &err); 441 + found = ext4_mb_new_blocks_simple_test(&ar, &err); 443 442 KUNIT_ASSERT_EQ_MSG(test, 444 443 ext4_group_first_block_no(sb, 0) + EXT4_C2B(sbi, 1), found, 445 444 "failed to alloc block before goal group, expected %llu found %llu", ··· 449 448 for (i = 0; i < ext4_get_groups_count(sb); i++) 450 449 mbt_ctx_mark_used(sb, i, 0, EXT4_CLUSTERS_PER_GROUP(sb)); 451 450 ar.goal = ext4_group_first_block_no(sb, goal_group); 452 - found = ext4_mb_new_blocks_simple(&ar, &err); 451 + found = ext4_mb_new_blocks_simple_test(&ar, &err); 453 452 KUNIT_ASSERT_NE_MSG(test, err, 0, 454 453 "unexpectedly get block when no block is available"); 455 454 } ··· 493 492 continue; 494 493 495 494 bitmap = mbt_ctx_bitmap(sb, i); 496 - bit = mb_find_next_zero_bit(bitmap, max, 0); 495 + bit = mb_find_next_zero_bit_test(bitmap, max, 0); 497 496 KUNIT_ASSERT_EQ_MSG(test, bit, max, 498 497 "free block on unexpected group %d", i); 499 498 } 500 499 501 500 bitmap = mbt_ctx_bitmap(sb, goal_group); 502 - bit = mb_find_next_zero_bit(bitmap, max, 0); 501 + bit = mb_find_next_zero_bit_test(bitmap, max, 0); 503 502 KUNIT_ASSERT_EQ(test, bit, start); 504 503 505 - bit = mb_find_next_bit(bitmap, max, bit + 1); 504 + bit = mb_find_next_bit_test(bitmap, max, bit + 1); 506 505 KUNIT_ASSERT_EQ(test, bit, start + len); 507 506 } 508 507 ··· 525 524 526 525 block = ext4_group_first_block_no(sb, goal_group) + 527 526 EXT4_C2B(sbi, start); 528 - ext4_free_blocks_simple(inode, block, len); 527 + ext4_free_blocks_simple_test(inode, block, len); 529 528 validate_free_blocks_simple(test, sb, goal_group, start, len); 530 529 mbt_ctx_mark_used(sb, goal_group, 0, EXT4_CLUSTERS_PER_GROUP(sb)); 531 530 } ··· 567 566 568 567 bitmap = mbt_ctx_bitmap(sb, TEST_GOAL_GROUP); 569 568 memset(bitmap, 0, sb->s_blocksize); 570 - ret = ext4_mb_mark_diskspace_used(ac, NULL); 569 + ret = ext4_mb_mark_diskspace_used_test(ac, NULL); 571 570 KUNIT_ASSERT_EQ(test, ret, 0); 572 571 573 572 max = EXT4_CLUSTERS_PER_GROUP(sb); 574 - i = mb_find_next_bit(bitmap, max, 0); 573 + i = mb_find_next_bit_test(bitmap, max, 0); 575 574 KUNIT_ASSERT_EQ(test, i, start); 576 - i = mb_find_next_zero_bit(bitmap, max, i + 1); 575 + i = mb_find_next_zero_bit_test(bitmap, max, i + 1); 577 576 KUNIT_ASSERT_EQ(test, i, start + len); 578 - i = mb_find_next_bit(bitmap, max, i + 1); 577 + i = mb_find_next_bit_test(bitmap, max, i + 1); 579 578 KUNIT_ASSERT_EQ(test, max, i); 580 579 } 581 580 ··· 618 617 max = EXT4_CLUSTERS_PER_GROUP(sb); 619 618 bb_h = buddy + sbi->s_mb_offsets[1]; 620 619 621 - off = mb_find_next_zero_bit(bb, max, 0); 620 + off = mb_find_next_zero_bit_test(bb, max, 0); 622 621 grp->bb_first_free = off; 623 622 while (off < max) { 624 623 grp->bb_counters[0]++; 625 624 grp->bb_free++; 626 625 627 - if (!(off & 1) && !mb_test_bit(off + 1, bb)) { 626 + if (!(off & 1) && !mb_test_bit_test(off + 1, bb)) { 628 627 grp->bb_free++; 629 628 grp->bb_counters[0]--; 630 - mb_clear_bit(off >> 1, bb_h); 629 + mb_clear_bit_test(off >> 1, bb_h); 631 630 grp->bb_counters[1]++; 632 631 grp->bb_largest_free_order = 1; 633 632 off++; 634 633 } 635 634 636 - off = mb_find_next_zero_bit(bb, max, off + 1); 635 + off = mb_find_next_zero_bit_test(bb, max, off + 1); 637 636 } 638 637 639 638 for (order = 1; order < MB_NUM_ORDERS(sb) - 1; order++) { 640 639 bb = buddy + sbi->s_mb_offsets[order]; 641 640 bb_h = buddy + sbi->s_mb_offsets[order + 1]; 642 641 max = max >> 1; 643 - off = mb_find_next_zero_bit(bb, max, 0); 642 + off = mb_find_next_zero_bit_test(bb, max, 0); 644 643 645 644 while (off < max) { 646 - if (!(off & 1) && !mb_test_bit(off + 1, bb)) { 645 + if (!(off & 1) && !mb_test_bit_test(off + 1, bb)) { 647 646 mb_set_bits(bb, off, 2); 648 647 grp->bb_counters[order] -= 2; 649 - mb_clear_bit(off >> 1, bb_h); 648 + mb_clear_bit_test(off >> 1, bb_h); 650 649 grp->bb_counters[order + 1]++; 651 650 grp->bb_largest_free_order = order + 1; 652 651 off++; 653 652 } 654 653 655 - off = mb_find_next_zero_bit(bb, max, off + 1); 654 + off = mb_find_next_zero_bit_test(bb, max, off + 1); 656 655 } 657 656 } 658 657 659 658 max = EXT4_CLUSTERS_PER_GROUP(sb); 660 - off = mb_find_next_zero_bit(bitmap, max, 0); 659 + off = mb_find_next_zero_bit_test(bitmap, max, 0); 661 660 while (off < max) { 662 661 grp->bb_fragments++; 663 662 664 - off = mb_find_next_bit(bitmap, max, off + 1); 663 + off = mb_find_next_bit_test(bitmap, max, off + 1); 665 664 if (off + 1 >= max) 666 665 break; 667 666 668 - off = mb_find_next_zero_bit(bitmap, max, off + 1); 667 + off = mb_find_next_zero_bit_test(bitmap, max, off + 1); 669 668 } 670 669 } 671 670 ··· 707 706 /* needed by validation in ext4_mb_generate_buddy */ 708 707 ext4_grp->bb_free = mbt_grp->bb_free; 709 708 memset(ext4_buddy, 0xff, sb->s_blocksize); 710 - ext4_mb_generate_buddy(sb, ext4_buddy, bitmap, TEST_GOAL_GROUP, 709 + ext4_mb_generate_buddy_test(sb, ext4_buddy, bitmap, TEST_GOAL_GROUP, 711 710 ext4_grp); 712 711 713 712 KUNIT_ASSERT_EQ(test, memcmp(mbt_buddy, ext4_buddy, sb->s_blocksize), ··· 761 760 ex.fe_group = TEST_GOAL_GROUP; 762 761 763 762 ext4_lock_group(sb, TEST_GOAL_GROUP); 764 - mb_mark_used(e4b, &ex); 763 + mb_mark_used_test(e4b, &ex); 765 764 ext4_unlock_group(sb, TEST_GOAL_GROUP); 766 765 767 766 mb_set_bits(bitmap, start, len); ··· 770 769 memset(buddy, 0xff, sb->s_blocksize); 771 770 for (i = 0; i < MB_NUM_ORDERS(sb); i++) 772 771 grp->bb_counters[i] = 0; 773 - ext4_mb_generate_buddy(sb, buddy, bitmap, 0, grp); 772 + ext4_mb_generate_buddy_test(sb, buddy, bitmap, 0, grp); 774 773 775 774 KUNIT_ASSERT_EQ(test, memcmp(buddy, e4b->bd_buddy, sb->s_blocksize), 776 775 0); ··· 799 798 bb_counters[MB_NUM_ORDERS(sb)]), GFP_KERNEL); 800 799 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, grp); 801 800 802 - ret = ext4_mb_load_buddy(sb, TEST_GOAL_GROUP, &e4b); 801 + ret = ext4_mb_load_buddy_test(sb, TEST_GOAL_GROUP, &e4b); 803 802 KUNIT_ASSERT_EQ(test, ret, 0); 804 803 805 804 grp->bb_free = EXT4_CLUSTERS_PER_GROUP(sb); ··· 810 809 test_mb_mark_used_range(test, &e4b, ranges[i].start, 811 810 ranges[i].len, bitmap, buddy, grp); 812 811 813 - ext4_mb_unload_buddy(&e4b); 812 + ext4_mb_unload_buddy_test(&e4b); 814 813 } 815 814 816 815 static void ··· 826 825 return; 827 826 828 827 ext4_lock_group(sb, e4b->bd_group); 829 - mb_free_blocks(NULL, e4b, start, len); 828 + mb_free_blocks_test(NULL, e4b, start, len); 830 829 ext4_unlock_group(sb, e4b->bd_group); 831 830 832 - mb_clear_bits(bitmap, start, len); 831 + mb_clear_bits_test(bitmap, start, len); 833 832 /* bypass bb_free validatoin in ext4_mb_generate_buddy */ 834 833 grp->bb_free += len; 835 834 memset(buddy, 0xff, sb->s_blocksize); 836 835 for (i = 0; i < MB_NUM_ORDERS(sb); i++) 837 836 grp->bb_counters[i] = 0; 838 - ext4_mb_generate_buddy(sb, buddy, bitmap, 0, grp); 837 + ext4_mb_generate_buddy_test(sb, buddy, bitmap, 0, grp); 839 838 840 839 KUNIT_ASSERT_EQ(test, memcmp(buddy, e4b->bd_buddy, sb->s_blocksize), 841 840 0); ··· 866 865 bb_counters[MB_NUM_ORDERS(sb)]), GFP_KERNEL); 867 866 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, grp); 868 867 869 - ret = ext4_mb_load_buddy(sb, TEST_GOAL_GROUP, &e4b); 868 + ret = ext4_mb_load_buddy_test(sb, TEST_GOAL_GROUP, &e4b); 870 869 KUNIT_ASSERT_EQ(test, ret, 0); 871 870 872 871 ex.fe_start = 0; ··· 874 873 ex.fe_group = TEST_GOAL_GROUP; 875 874 876 875 ext4_lock_group(sb, TEST_GOAL_GROUP); 877 - mb_mark_used(&e4b, &ex); 876 + mb_mark_used_test(&e4b, &ex); 878 877 ext4_unlock_group(sb, TEST_GOAL_GROUP); 879 878 880 879 grp->bb_free = 0; ··· 887 886 test_mb_free_blocks_range(test, &e4b, ranges[i].start, 888 887 ranges[i].len, bitmap, buddy, grp); 889 888 890 - ext4_mb_unload_buddy(&e4b); 889 + ext4_mb_unload_buddy_test(&e4b); 891 890 } 892 891 893 892 #define COUNT_FOR_ESTIMATE 100000 ··· 905 904 if (sb->s_blocksize > PAGE_SIZE) 906 905 kunit_skip(test, "blocksize exceeds pagesize"); 907 906 908 - ret = ext4_mb_load_buddy(sb, TEST_GOAL_GROUP, &e4b); 907 + ret = ext4_mb_load_buddy_test(sb, TEST_GOAL_GROUP, &e4b); 909 908 KUNIT_ASSERT_EQ(test, ret, 0); 910 909 911 910 ex.fe_group = TEST_GOAL_GROUP; ··· 919 918 ex.fe_start = ranges[i].start; 920 919 ex.fe_len = ranges[i].len; 921 920 ext4_lock_group(sb, TEST_GOAL_GROUP); 922 - mb_mark_used(&e4b, &ex); 921 + mb_mark_used_test(&e4b, &ex); 923 922 ext4_unlock_group(sb, TEST_GOAL_GROUP); 924 923 } 925 924 end = jiffies; ··· 930 929 continue; 931 930 932 931 ext4_lock_group(sb, TEST_GOAL_GROUP); 933 - mb_free_blocks(NULL, &e4b, ranges[i].start, 932 + mb_free_blocks_test(NULL, &e4b, ranges[i].start, 934 933 ranges[i].len); 935 934 ext4_unlock_group(sb, TEST_GOAL_GROUP); 936 935 } 937 936 } 938 937 939 938 kunit_info(test, "costed jiffies %lu\n", all); 940 - ext4_mb_unload_buddy(&e4b); 939 + ext4_mb_unload_buddy_test(&e4b); 941 940 } 942 941 943 942 static const struct mbt_ext4_block_layout mbt_test_layouts[] = {
+114 -18
fs/ext4/mballoc.c
··· 1199 1199 1200 1200 /* searching for the right group start from the goal value specified */ 1201 1201 start = ac->ac_g_ex.fe_group; 1202 + if (start >= ngroups) 1203 + start = 0; 1202 1204 ac->ac_prefetch_grp = start; 1203 1205 ac->ac_prefetch_nr = 0; 1204 1206 ··· 2445 2443 return 0; 2446 2444 2447 2445 err = ext4_mb_load_buddy(ac->ac_sb, group, e4b); 2448 - if (err) 2446 + if (err) { 2447 + if (EXT4_MB_GRP_BBITMAP_CORRUPT(e4b->bd_info) && 2448 + !(ac->ac_flags & EXT4_MB_HINT_GOAL_ONLY)) 2449 + return 0; 2449 2450 return err; 2451 + } 2450 2452 2451 2453 ext4_lock_group(ac->ac_sb, group); 2452 2454 if (unlikely(EXT4_MB_GRP_BBITMAP_CORRUPT(e4b->bd_info))) ··· 3586 3580 rcu_read_unlock(); 3587 3581 iput(sbi->s_buddy_cache); 3588 3582 err_freesgi: 3589 - rcu_read_lock(); 3590 - kvfree(rcu_dereference(sbi->s_group_info)); 3591 - rcu_read_unlock(); 3583 + kvfree(rcu_access_pointer(sbi->s_group_info)); 3592 3584 return -ENOMEM; 3593 3585 } 3594 3586 ··· 3893 3889 struct kmem_cache *cachep = get_groupinfo_cache(sb->s_blocksize_bits); 3894 3890 int count; 3895 3891 3896 - if (test_opt(sb, DISCARD)) { 3897 - /* 3898 - * wait the discard work to drain all of ext4_free_data 3899 - */ 3900 - flush_work(&sbi->s_discard_work); 3901 - WARN_ON_ONCE(!list_empty(&sbi->s_discard_list)); 3902 - } 3892 + /* 3893 + * wait the discard work to drain all of ext4_free_data 3894 + */ 3895 + flush_work(&sbi->s_discard_work); 3896 + WARN_ON_ONCE(!list_empty(&sbi->s_discard_list)); 3903 3897 3904 - if (sbi->s_group_info) { 3898 + group_info = rcu_access_pointer(sbi->s_group_info); 3899 + if (group_info) { 3905 3900 for (i = 0; i < ngroups; i++) { 3906 3901 cond_resched(); 3907 3902 grinfo = ext4_get_group_info(sb, i); ··· 3918 3915 num_meta_group_infos = (ngroups + 3919 3916 EXT4_DESC_PER_BLOCK(sb) - 1) >> 3920 3917 EXT4_DESC_PER_BLOCK_BITS(sb); 3921 - rcu_read_lock(); 3922 - group_info = rcu_dereference(sbi->s_group_info); 3923 3918 for (i = 0; i < num_meta_group_infos; i++) 3924 3919 kfree(group_info[i]); 3925 3920 kvfree(group_info); 3926 - rcu_read_unlock(); 3927 3921 } 3928 3922 ext4_mb_avg_fragment_size_destroy(sbi); 3929 3923 ext4_mb_largest_free_orders_destroy(sbi); ··· 4084 4084 4085 4085 #define EXT4_MB_BITMAP_MARKED_CHECK 0x0001 4086 4086 #define EXT4_MB_SYNC_UPDATE 0x0002 4087 - static int 4087 + int 4088 4088 ext4_mb_mark_context(handle_t *handle, struct super_block *sb, bool state, 4089 4089 ext4_group_t group, ext4_grpblk_t blkoff, 4090 4090 ext4_grpblk_t len, int flags, ext4_grpblk_t *ret_changed) ··· 7188 7188 return error; 7189 7189 } 7190 7190 7191 - #ifdef CONFIG_EXT4_KUNIT_TESTS 7192 - #include "mballoc-test.c" 7191 + #if IS_ENABLED(CONFIG_EXT4_KUNIT_TESTS) 7192 + void mb_clear_bits_test(void *bm, int cur, int len) 7193 + { 7194 + mb_clear_bits(bm, cur, len); 7195 + } 7196 + EXPORT_SYMBOL_FOR_EXT4_TEST(mb_clear_bits_test); 7197 + 7198 + ext4_fsblk_t 7199 + ext4_mb_new_blocks_simple_test(struct ext4_allocation_request *ar, 7200 + int *errp) 7201 + { 7202 + return ext4_mb_new_blocks_simple(ar, errp); 7203 + } 7204 + EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_mb_new_blocks_simple_test); 7205 + 7206 + int mb_find_next_zero_bit_test(void *addr, int max, int start) 7207 + { 7208 + return mb_find_next_zero_bit(addr, max, start); 7209 + } 7210 + EXPORT_SYMBOL_FOR_EXT4_TEST(mb_find_next_zero_bit_test); 7211 + 7212 + int mb_find_next_bit_test(void *addr, int max, int start) 7213 + { 7214 + return mb_find_next_bit(addr, max, start); 7215 + } 7216 + EXPORT_SYMBOL_FOR_EXT4_TEST(mb_find_next_bit_test); 7217 + 7218 + void mb_clear_bit_test(int bit, void *addr) 7219 + { 7220 + mb_clear_bit(bit, addr); 7221 + } 7222 + EXPORT_SYMBOL_FOR_EXT4_TEST(mb_clear_bit_test); 7223 + 7224 + int mb_test_bit_test(int bit, void *addr) 7225 + { 7226 + return mb_test_bit(bit, addr); 7227 + } 7228 + EXPORT_SYMBOL_FOR_EXT4_TEST(mb_test_bit_test); 7229 + 7230 + int ext4_mb_mark_diskspace_used_test(struct ext4_allocation_context *ac, 7231 + handle_t *handle) 7232 + { 7233 + return ext4_mb_mark_diskspace_used(ac, handle); 7234 + } 7235 + EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_mb_mark_diskspace_used_test); 7236 + 7237 + int mb_mark_used_test(struct ext4_buddy *e4b, struct ext4_free_extent *ex) 7238 + { 7239 + return mb_mark_used(e4b, ex); 7240 + } 7241 + EXPORT_SYMBOL_FOR_EXT4_TEST(mb_mark_used_test); 7242 + 7243 + void ext4_mb_generate_buddy_test(struct super_block *sb, void *buddy, 7244 + void *bitmap, ext4_group_t group, 7245 + struct ext4_group_info *grp) 7246 + { 7247 + ext4_mb_generate_buddy(sb, buddy, bitmap, group, grp); 7248 + } 7249 + EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_mb_generate_buddy_test); 7250 + 7251 + int ext4_mb_load_buddy_test(struct super_block *sb, ext4_group_t group, 7252 + struct ext4_buddy *e4b) 7253 + { 7254 + return ext4_mb_load_buddy(sb, group, e4b); 7255 + } 7256 + EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_mb_load_buddy_test); 7257 + 7258 + void ext4_mb_unload_buddy_test(struct ext4_buddy *e4b) 7259 + { 7260 + ext4_mb_unload_buddy(e4b); 7261 + } 7262 + EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_mb_unload_buddy_test); 7263 + 7264 + void mb_free_blocks_test(struct inode *inode, struct ext4_buddy *e4b, 7265 + int first, int count) 7266 + { 7267 + mb_free_blocks(inode, e4b, first, count); 7268 + } 7269 + EXPORT_SYMBOL_FOR_EXT4_TEST(mb_free_blocks_test); 7270 + 7271 + void ext4_free_blocks_simple_test(struct inode *inode, ext4_fsblk_t block, 7272 + unsigned long count) 7273 + { 7274 + return ext4_free_blocks_simple(inode, block, count); 7275 + } 7276 + EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_free_blocks_simple_test); 7277 + 7278 + EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_wait_block_bitmap); 7279 + EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_mb_init); 7280 + EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_get_group_desc); 7281 + EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_count_free_clusters); 7282 + EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_get_group_info); 7283 + EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_free_group_clusters_set); 7284 + EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_mb_release); 7285 + EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_read_block_bitmap_nowait); 7286 + EXPORT_SYMBOL_FOR_EXT4_TEST(mb_set_bits); 7287 + EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_fc_init_inode); 7288 + EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_mb_mark_context); 7193 7289 #endif
+30
fs/ext4/mballoc.h
··· 270 270 ext4_mballoc_query_range_fn formatter, 271 271 void *priv); 272 272 273 + extern int ext4_mb_mark_context(handle_t *handle, 274 + struct super_block *sb, bool state, 275 + ext4_group_t group, ext4_grpblk_t blkoff, 276 + ext4_grpblk_t len, int flags, 277 + ext4_grpblk_t *ret_changed); 278 + #if IS_ENABLED(CONFIG_EXT4_KUNIT_TESTS) 279 + extern void mb_clear_bits_test(void *bm, int cur, int len); 280 + extern ext4_fsblk_t 281 + ext4_mb_new_blocks_simple_test(struct ext4_allocation_request *ar, 282 + int *errp); 283 + extern int mb_find_next_zero_bit_test(void *addr, int max, int start); 284 + extern int mb_find_next_bit_test(void *addr, int max, int start); 285 + extern void mb_clear_bit_test(int bit, void *addr); 286 + extern int mb_test_bit_test(int bit, void *addr); 287 + extern int 288 + ext4_mb_mark_diskspace_used_test(struct ext4_allocation_context *ac, 289 + handle_t *handle); 290 + extern int mb_mark_used_test(struct ext4_buddy *e4b, 291 + struct ext4_free_extent *ex); 292 + extern void ext4_mb_generate_buddy_test(struct super_block *sb, 293 + void *buddy, void *bitmap, ext4_group_t group, 294 + struct ext4_group_info *grp); 295 + extern int ext4_mb_load_buddy_test(struct super_block *sb, 296 + ext4_group_t group, struct ext4_buddy *e4b); 297 + extern void ext4_mb_unload_buddy_test(struct ext4_buddy *e4b); 298 + extern void mb_free_blocks_test(struct inode *inode, 299 + struct ext4_buddy *e4b, int first, int count); 300 + extern void ext4_free_blocks_simple_test(struct inode *inode, 301 + ext4_fsblk_t block, unsigned long count); 302 + #endif 273 303 #endif
+8 -2
fs/ext4/page-io.c
··· 524 524 nr_to_submit++; 525 525 } while ((bh = bh->b_this_page) != head); 526 526 527 - /* Nothing to submit? Just unlock the folio... */ 528 - if (!nr_to_submit) 527 + if (!nr_to_submit) { 528 + /* 529 + * We have nothing to submit. Just cycle the folio through 530 + * writeback state to properly update xarray tags. 531 + */ 532 + __folio_start_writeback(folio, keep_towrite); 533 + folio_end_writeback(folio); 529 534 return 0; 535 + } 530 536 531 537 bh = head = folio_buffers(folio); 532 538
+31 -6
fs/ext4/super.c
··· 1254 1254 struct buffer_head **group_desc; 1255 1255 int i; 1256 1256 1257 - rcu_read_lock(); 1258 - group_desc = rcu_dereference(sbi->s_group_desc); 1257 + group_desc = rcu_access_pointer(sbi->s_group_desc); 1259 1258 for (i = 0; i < sbi->s_gdb_count; i++) 1260 1259 brelse(group_desc[i]); 1261 1260 kvfree(group_desc); 1262 - rcu_read_unlock(); 1263 1261 } 1264 1262 1265 1263 static void ext4_flex_groups_free(struct ext4_sb_info *sbi) ··· 1265 1267 struct flex_groups **flex_groups; 1266 1268 int i; 1267 1269 1268 - rcu_read_lock(); 1269 - flex_groups = rcu_dereference(sbi->s_flex_groups); 1270 + flex_groups = rcu_access_pointer(sbi->s_flex_groups); 1270 1271 if (flex_groups) { 1271 1272 for (i = 0; i < sbi->s_flex_groups_allocated; i++) 1272 1273 kvfree(flex_groups[i]); 1273 1274 kvfree(flex_groups); 1274 1275 } 1275 - rcu_read_unlock(); 1276 1276 } 1277 1277 1278 1278 static void ext4_put_super(struct super_block *sb) ··· 1523 1527 invalidate_inode_buffers(inode); 1524 1528 clear_inode(inode); 1525 1529 ext4_discard_preallocations(inode); 1530 + /* 1531 + * We must remove the inode from the hash before ext4_free_inode() 1532 + * clears the bit in inode bitmap as otherwise another process reusing 1533 + * the inode will block in insert_inode_hash() waiting for inode 1534 + * eviction to complete while holding transaction handle open, but 1535 + * ext4_evict_inode() still running for that inode could block waiting 1536 + * for transaction commit if the inode is marked as IS_SYNC => deadlock. 1537 + * 1538 + * Removing the inode from the hash here is safe. There are two cases 1539 + * to consider: 1540 + * 1) The inode still has references to it (i_nlink > 0). In that case 1541 + * we are keeping the inode and once we remove the inode from the hash, 1542 + * iget() can create the new inode structure for the same inode number 1543 + * and we are fine with that as all IO on behalf of the inode is 1544 + * finished. 1545 + * 2) We are deleting the inode (i_nlink == 0). In that case inode 1546 + * number cannot be reused until ext4_free_inode() clears the bit in 1547 + * the inode bitmap, at which point all IO is done and reuse is fine 1548 + * again. 1549 + */ 1550 + remove_inode_hash(inode); 1526 1551 ext4_es_remove_extent(inode, 0, EXT_MAX_BLOCKS); 1527 1552 dquot_drop(inode); 1528 1553 if (EXT4_I(inode)->jinode) { ··· 3650 3633 "extents feature\n"); 3651 3634 return 0; 3652 3635 } 3636 + if (ext4_has_feature_bigalloc(sb) && 3637 + le32_to_cpu(EXT4_SB(sb)->s_es->s_first_data_block)) { 3638 + ext4_msg(sb, KERN_WARNING, 3639 + "bad geometry: bigalloc file system with non-zero " 3640 + "first_data_block\n"); 3641 + return 0; 3642 + } 3653 3643 3654 3644 #if !IS_ENABLED(CONFIG_QUOTA) || !IS_ENABLED(CONFIG_QFMT_V2) 3655 3645 if (!readonly && (ext4_has_feature_quota(sb) || ··· 5427 5403 5428 5404 timer_setup(&sbi->s_err_report, print_daily_error_info, 0); 5429 5405 spin_lock_init(&sbi->s_error_lock); 5406 + mutex_init(&sbi->s_error_notify_mutex); 5430 5407 INIT_WORK(&sbi->s_sb_upd_work, update_super_work); 5431 5408 5432 5409 err = ext4_group_desc_init(sb, es, logical_sb_block, &first_not_zeroed);
+9 -1
fs/ext4/sysfs.c
··· 597 597 598 598 void ext4_notify_error_sysfs(struct ext4_sb_info *sbi) 599 599 { 600 - sysfs_notify(&sbi->s_kobj, NULL, "errors_count"); 600 + mutex_lock(&sbi->s_error_notify_mutex); 601 + if (sbi->s_kobj.state_in_sysfs) 602 + sysfs_notify(&sbi->s_kobj, NULL, "errors_count"); 603 + mutex_unlock(&sbi->s_error_notify_mutex); 601 604 } 602 605 603 606 static struct kobject *ext4_root; ··· 613 610 int err; 614 611 615 612 init_completion(&sbi->s_kobj_unregister); 613 + mutex_lock(&sbi->s_error_notify_mutex); 616 614 err = kobject_init_and_add(&sbi->s_kobj, &ext4_sb_ktype, ext4_root, 617 615 "%s", sb->s_id); 616 + mutex_unlock(&sbi->s_error_notify_mutex); 618 617 if (err) { 619 618 kobject_put(&sbi->s_kobj); 620 619 wait_for_completion(&sbi->s_kobj_unregister); ··· 649 644 650 645 if (sbi->s_proc) 651 646 remove_proc_subtree(sb->s_id, ext4_proc_root); 647 + 648 + mutex_lock(&sbi->s_error_notify_mutex); 652 649 kobject_del(&sbi->s_kobj); 650 + mutex_unlock(&sbi->s_error_notify_mutex); 653 651 } 654 652 655 653 int __init ext4_init_sysfs(void)
+27 -9
fs/fs-writeback.c
··· 1711 1711 } 1712 1712 } 1713 1713 1714 + static bool __sync_lazytime(struct inode *inode) 1715 + { 1716 + spin_lock(&inode->i_lock); 1717 + if (!(inode_state_read(inode) & I_DIRTY_TIME)) { 1718 + spin_unlock(&inode->i_lock); 1719 + return false; 1720 + } 1721 + inode_state_clear(inode, I_DIRTY_TIME); 1722 + spin_unlock(&inode->i_lock); 1723 + inode->i_op->sync_lazytime(inode); 1724 + return true; 1725 + } 1726 + 1714 1727 bool sync_lazytime(struct inode *inode) 1715 1728 { 1716 1729 if (!(inode_state_read_once(inode) & I_DIRTY_TIME)) ··· 1731 1718 1732 1719 trace_writeback_lazytime(inode); 1733 1720 if (inode->i_op->sync_lazytime) 1734 - inode->i_op->sync_lazytime(inode); 1735 - else 1736 - mark_inode_dirty_sync(inode); 1721 + return __sync_lazytime(inode); 1722 + mark_inode_dirty_sync(inode); 1737 1723 return true; 1738 1724 } 1739 1725 ··· 2787 2775 * The mapping can appear untagged while still on-list since we 2788 2776 * do not have the mapping lock. Skip it here, wb completion 2789 2777 * will remove it. 2790 - * 2791 - * If the mapping does not have data integrity semantics, 2792 - * there's no need to wait for the writeout to complete, as the 2793 - * mapping cannot guarantee that data is persistently stored. 2794 2778 */ 2795 - if (!mapping_tagged(mapping, PAGECACHE_TAG_WRITEBACK) || 2796 - mapping_no_data_integrity(mapping)) 2779 + if (!mapping_tagged(mapping, PAGECACHE_TAG_WRITEBACK)) 2797 2780 continue; 2798 2781 2799 2782 spin_unlock_irq(&sb->s_inode_wblist_lock); ··· 2923 2916 */ 2924 2917 if (bdi == &noop_backing_dev_info) 2925 2918 return; 2919 + 2920 + /* 2921 + * If the superblock has SB_I_NO_DATA_INTEGRITY set, there's no need to 2922 + * wait for the writeout to complete, as the filesystem cannot guarantee 2923 + * data persistence on sync. Just kick off writeback and return. 2924 + */ 2925 + if (sb->s_iflags & SB_I_NO_DATA_INTEGRITY) { 2926 + wakeup_flusher_threads_bdi(bdi, WB_REASON_SYNC); 2927 + return; 2928 + } 2929 + 2926 2930 WARN_ON(!rwsem_is_locked(&sb->s_umount)); 2927 2931 2928 2932 /* protect against inode wb switch, see inode_switch_wbs_work_fn() */
+1 -3
fs/fuse/file.c
··· 3201 3201 3202 3202 inode->i_fop = &fuse_file_operations; 3203 3203 inode->i_data.a_ops = &fuse_file_aops; 3204 - if (fc->writeback_cache) { 3204 + if (fc->writeback_cache) 3205 3205 mapping_set_writeback_may_deadlock_on_reclaim(&inode->i_data); 3206 - mapping_set_no_data_integrity(&inode->i_data); 3207 - } 3208 3206 3209 3207 INIT_LIST_HEAD(&fi->write_files); 3210 3208 INIT_LIST_HEAD(&fi->queued_writes);
+1
fs/fuse/inode.c
··· 1709 1709 sb->s_export_op = &fuse_export_operations; 1710 1710 sb->s_iflags |= SB_I_IMA_UNVERIFIABLE_SIGNATURE; 1711 1711 sb->s_iflags |= SB_I_NOIDMAP; 1712 + sb->s_iflags |= SB_I_NO_DATA_INTEGRITY; 1712 1713 if (sb->s_user_ns != &init_user_ns) 1713 1714 sb->s_iflags |= SB_I_UNTRUSTED_MOUNTER; 1714 1715 sb->s_flags &= ~(SB_NOSEC | SB_I_VERSION);
+50 -1
fs/iomap/bio.c
··· 8 8 #include "internal.h" 9 9 #include "trace.h" 10 10 11 - static void iomap_read_end_io(struct bio *bio) 11 + static DEFINE_SPINLOCK(failed_read_lock); 12 + static struct bio_list failed_read_list = BIO_EMPTY_LIST; 13 + 14 + static void __iomap_read_end_io(struct bio *bio) 12 15 { 13 16 int error = blk_status_to_errno(bio->bi_status); 14 17 struct folio_iter fi; ··· 19 16 bio_for_each_folio_all(fi, bio) 20 17 iomap_finish_folio_read(fi.folio, fi.offset, fi.length, error); 21 18 bio_put(bio); 19 + } 20 + 21 + static void 22 + iomap_fail_reads( 23 + struct work_struct *work) 24 + { 25 + struct bio *bio; 26 + struct bio_list tmp = BIO_EMPTY_LIST; 27 + unsigned long flags; 28 + 29 + spin_lock_irqsave(&failed_read_lock, flags); 30 + bio_list_merge_init(&tmp, &failed_read_list); 31 + spin_unlock_irqrestore(&failed_read_lock, flags); 32 + 33 + while ((bio = bio_list_pop(&tmp)) != NULL) { 34 + __iomap_read_end_io(bio); 35 + cond_resched(); 36 + } 37 + } 38 + 39 + static DECLARE_WORK(failed_read_work, iomap_fail_reads); 40 + 41 + static void iomap_fail_buffered_read(struct bio *bio) 42 + { 43 + unsigned long flags; 44 + 45 + /* 46 + * Bounce I/O errors to a workqueue to avoid nested i_lock acquisitions 47 + * in the fserror code. The caller no longer owns the bio reference 48 + * after the spinlock drops. 49 + */ 50 + spin_lock_irqsave(&failed_read_lock, flags); 51 + if (bio_list_empty(&failed_read_list)) 52 + WARN_ON_ONCE(!schedule_work(&failed_read_work)); 53 + bio_list_add(&failed_read_list, bio); 54 + spin_unlock_irqrestore(&failed_read_lock, flags); 55 + } 56 + 57 + static void iomap_read_end_io(struct bio *bio) 58 + { 59 + if (bio->bi_status) { 60 + iomap_fail_buffered_read(bio); 61 + return; 62 + } 63 + 64 + __iomap_read_end_io(bio); 22 65 } 23 66 24 67 static void iomap_bio_submit_read(struct iomap_read_folio_ctx *ctx)
+10 -5
fs/iomap/buffered-io.c
··· 514 514 loff_t length = iomap_length(iter); 515 515 struct folio *folio = ctx->cur_folio; 516 516 size_t folio_len = folio_size(folio); 517 + struct iomap_folio_state *ifs; 517 518 size_t poff, plen; 518 519 loff_t pos_diff; 519 520 int ret; ··· 526 525 return iomap_iter_advance(iter, length); 527 526 } 528 527 529 - ifs_alloc(iter->inode, folio, iter->flags); 528 + ifs = ifs_alloc(iter->inode, folio, iter->flags); 530 529 531 530 length = min_t(loff_t, length, folio_len - offset_in_folio(folio, pos)); 532 531 while (length) { ··· 561 560 562 561 *bytes_submitted += plen; 563 562 /* 564 - * If the entire folio has been read in by the IO 565 - * helper, then the helper owns the folio and will end 566 - * the read on it. 563 + * Hand off folio ownership to the IO helper when: 564 + * 1) The entire folio has been submitted for IO, or 565 + * 2) There is no ifs attached to the folio 566 + * 567 + * Case (2) occurs when 1 << i_blkbits matches the folio 568 + * size but the underlying filesystem or block device 569 + * uses a smaller granularity for IO. 567 570 */ 568 - if (*bytes_submitted == folio_len) 571 + if (*bytes_submitted == folio_len || !ifs) 569 572 ctx->cur_folio = NULL; 570 573 } 571 574
+13 -2
fs/jbd2/checkpoint.c
··· 267 267 */ 268 268 BUFFER_TRACE(bh, "queue"); 269 269 get_bh(bh); 270 - J_ASSERT_BH(bh, !buffer_jwrite(bh)); 270 + if (WARN_ON_ONCE(buffer_jwrite(bh))) { 271 + put_bh(bh); /* drop the ref we just took */ 272 + spin_unlock(&journal->j_list_lock); 273 + /* Clean up any previously batched buffers */ 274 + if (batch_count) 275 + __flush_batch(journal, &batch_count); 276 + jbd2_journal_abort(journal, -EFSCORRUPTED); 277 + return -EFSCORRUPTED; 278 + } 271 279 journal->j_chkpt_bhs[batch_count++] = bh; 272 280 transaction->t_chp_stats.cs_written++; 273 281 transaction->t_checkpoint_list = jh->b_cpnext; ··· 333 325 334 326 if (!jbd2_journal_get_log_tail(journal, &first_tid, &blocknr)) 335 327 return 1; 336 - J_ASSERT(blocknr != 0); 328 + if (WARN_ON_ONCE(blocknr == 0)) { 329 + jbd2_journal_abort(journal, -EFSCORRUPTED); 330 + return -EFSCORRUPTED; 331 + } 337 332 338 333 /* 339 334 * We need to make sure that any blocks that were recently written out
+24 -6
fs/mpage.c
··· 646 646 } 647 647 648 648 /** 649 - * mpage_writepages - walk the list of dirty pages of the given address space & writepage() all of them 649 + * __mpage_writepages - walk the list of dirty pages of the given address space 650 + * & writepage() all of them 650 651 * @mapping: address space structure to write 651 652 * @wbc: subtract the number of written pages from *@wbc->nr_to_write 652 653 * @get_block: the filesystem's block mapper function. 654 + * @write_folio: handler to call for each folio before calling 655 + * mpage_write_folio() 653 656 * 654 657 * This is a library function, which implements the writepages() 655 - * address_space_operation. 658 + * address_space_operation. It calls @write_folio handler for each folio. If 659 + * the handler returns value > 0, it calls mpage_write_folio() to do the 660 + * folio writeback. 656 661 */ 657 662 int 658 - mpage_writepages(struct address_space *mapping, 659 - struct writeback_control *wbc, get_block_t get_block) 663 + __mpage_writepages(struct address_space *mapping, 664 + struct writeback_control *wbc, get_block_t get_block, 665 + int (*write_folio)(struct folio *folio, 666 + struct writeback_control *wbc)) 660 667 { 661 668 struct mpage_data mpd = { 662 669 .get_block = get_block, ··· 673 666 int error; 674 667 675 668 blk_start_plug(&plug); 676 - while ((folio = writeback_iter(mapping, wbc, folio, &error))) 669 + while ((folio = writeback_iter(mapping, wbc, folio, &error))) { 670 + if (write_folio) { 671 + error = write_folio(folio, wbc); 672 + /* 673 + * == 0 means folio is handled, < 0 means error. In 674 + * both cases hand back control to writeback_iter() 675 + */ 676 + if (error <= 0) 677 + continue; 678 + /* Let mpage_write_folio() handle the folio. */ 679 + } 677 680 error = mpage_write_folio(wbc, folio, &mpd); 681 + } 678 682 if (mpd.bio) 679 683 mpage_bio_submit_write(mpd.bio); 680 684 blk_finish_plug(&plug); 681 685 return error; 682 686 } 683 - EXPORT_SYMBOL(mpage_writepages); 687 + EXPORT_SYMBOL(__mpage_writepages);
+8 -2
fs/namei.c
··· 2437 2437 EXPORT_SYMBOL(hashlen_string); 2438 2438 2439 2439 /* 2440 - * Calculate the length and hash of the path component, and 2441 - * return the length as the result. 2440 + * hash_name - Calculate the length and hash of the path component 2441 + * @nd: the path resolution state 2442 + * @name: the pathname to read the component from 2443 + * @lastword: if the component fits in a single word, LAST_WORD_IS_DOT, 2444 + * LAST_WORD_IS_DOTDOT, or some other value depending on whether the 2445 + * component is '.', '..', or something else. Otherwise, @lastword is 0. 2446 + * 2447 + * Returns: a pointer to the terminating '/' or NUL character in @name. 2442 2448 */ 2443 2449 static inline const char *hash_name(struct nameidata *nd, 2444 2450 const char *name,
+1 -2
fs/netfs/buffered_read.c
··· 171 171 spin_lock(&rreq->lock); 172 172 list_add_tail(&subreq->rreq_link, &stream->subrequests); 173 173 if (list_is_first(&subreq->rreq_link, &stream->subrequests)) { 174 - stream->front = subreq; 175 174 if (!stream->active) { 176 - stream->collected_to = stream->front->start; 175 + stream->collected_to = subreq->start; 177 176 /* Store list pointers before active flag */ 178 177 smp_store_release(&stream->active, true); 179 178 }
+1 -2
fs/netfs/direct_read.c
··· 71 71 spin_lock(&rreq->lock); 72 72 list_add_tail(&subreq->rreq_link, &stream->subrequests); 73 73 if (list_is_first(&subreq->rreq_link, &stream->subrequests)) { 74 - stream->front = subreq; 75 74 if (!stream->active) { 76 - stream->collected_to = stream->front->start; 75 + stream->collected_to = subreq->start; 77 76 /* Store list pointers before active flag */ 78 77 smp_store_release(&stream->active, true); 79 78 }
+11 -4
fs/netfs/direct_write.c
··· 111 111 netfs_prepare_write(wreq, stream, wreq->start + wreq->transferred); 112 112 subreq = stream->construct; 113 113 stream->construct = NULL; 114 - stream->front = NULL; 115 114 } 116 115 117 116 /* Check if (re-)preparation failed. */ ··· 185 186 stream->sreq_max_segs = INT_MAX; 186 187 187 188 netfs_get_subrequest(subreq, netfs_sreq_trace_get_resubmit); 188 - stream->prepare_write(subreq); 189 189 190 - __set_bit(NETFS_SREQ_IN_PROGRESS, &subreq->flags); 191 - netfs_stat(&netfs_n_wh_retry_write_subreq); 190 + if (stream->prepare_write) { 191 + stream->prepare_write(subreq); 192 + __set_bit(NETFS_SREQ_IN_PROGRESS, &subreq->flags); 193 + netfs_stat(&netfs_n_wh_retry_write_subreq); 194 + } else { 195 + struct iov_iter source; 196 + 197 + netfs_reset_iter(subreq); 198 + source = subreq->io_iter; 199 + netfs_reissue_write(stream, subreq, &source); 200 + } 192 201 } 193 202 194 203 netfs_unbuffered_write_done(wreq);
+43
fs/netfs/iterator.c
··· 143 143 } 144 144 145 145 /* 146 + * Select the span of a kvec iterator we're going to use. Limit it by both 147 + * maximum size and maximum number of segments. Returns the size of the span 148 + * in bytes. 149 + */ 150 + static size_t netfs_limit_kvec(const struct iov_iter *iter, size_t start_offset, 151 + size_t max_size, size_t max_segs) 152 + { 153 + const struct kvec *kvecs = iter->kvec; 154 + unsigned int nkv = iter->nr_segs, ix = 0, nsegs = 0; 155 + size_t len, span = 0, n = iter->count; 156 + size_t skip = iter->iov_offset + start_offset; 157 + 158 + if (WARN_ON(!iov_iter_is_kvec(iter)) || 159 + WARN_ON(start_offset > n) || 160 + n == 0) 161 + return 0; 162 + 163 + while (n && ix < nkv && skip) { 164 + len = kvecs[ix].iov_len; 165 + if (skip < len) 166 + break; 167 + skip -= len; 168 + n -= len; 169 + ix++; 170 + } 171 + 172 + while (n && ix < nkv) { 173 + len = min3(n, kvecs[ix].iov_len - skip, max_size); 174 + span += len; 175 + nsegs++; 176 + ix++; 177 + if (span >= max_size || nsegs >= max_segs) 178 + break; 179 + skip = 0; 180 + n -= len; 181 + } 182 + 183 + return min(span, max_size); 184 + } 185 + 186 + /* 146 187 * Select the span of an xarray iterator we're going to use. Limit it by both 147 188 * maximum size and maximum number of segments. It is assumed that segments 148 189 * can be larger than a page in size, provided they're physically contiguous. ··· 286 245 return netfs_limit_bvec(iter, start_offset, max_size, max_segs); 287 246 if (iov_iter_is_xarray(iter)) 288 247 return netfs_limit_xarray(iter, start_offset, max_size, max_segs); 248 + if (iov_iter_is_kvec(iter)) 249 + return netfs_limit_kvec(iter, start_offset, max_size, max_segs); 289 250 BUG(); 290 251 } 291 252 EXPORT_SYMBOL(netfs_limit_iter);
+2 -2
fs/netfs/read_collect.c
··· 205 205 * in progress. The issuer thread may be adding stuff to the tail 206 206 * whilst we're doing this. 207 207 */ 208 - front = READ_ONCE(stream->front); 208 + front = list_first_entry_or_null(&stream->subrequests, 209 + struct netfs_io_subrequest, rreq_link); 209 210 while (front) { 210 211 size_t transferred; 211 212 ··· 302 301 list_del_init(&front->rreq_link); 303 302 front = list_first_entry_or_null(&stream->subrequests, 304 303 struct netfs_io_subrequest, rreq_link); 305 - stream->front = front; 306 304 spin_unlock(&rreq->lock); 307 305 netfs_put_subrequest(remove, 308 306 notes & ABANDON_SREQ ?
+4 -1
fs/netfs/read_retry.c
··· 93 93 from->start, from->transferred, from->len); 94 94 95 95 if (test_bit(NETFS_SREQ_FAILED, &from->flags) || 96 - !test_bit(NETFS_SREQ_NEED_RETRY, &from->flags)) 96 + !test_bit(NETFS_SREQ_NEED_RETRY, &from->flags)) { 97 + subreq = from; 97 98 goto abandon; 99 + } 98 100 99 101 list_for_each_continue(next, &stream->subrequests) { 100 102 subreq = list_entry(next, struct netfs_io_subrequest, rreq_link); ··· 180 178 if (subreq == to) 181 179 break; 182 180 } 181 + subreq = NULL; 183 182 continue; 184 183 } 185 184
-1
fs/netfs/read_single.c
··· 107 107 spin_lock(&rreq->lock); 108 108 list_add_tail(&subreq->rreq_link, &stream->subrequests); 109 109 trace_netfs_sreq(subreq, netfs_sreq_trace_added); 110 - stream->front = subreq; 111 110 /* Store list pointers before active flag */ 112 111 smp_store_release(&stream->active, true); 113 112 spin_unlock(&rreq->lock);
+2 -2
fs/netfs/write_collect.c
··· 228 228 if (!smp_load_acquire(&stream->active)) 229 229 continue; 230 230 231 - front = stream->front; 231 + front = list_first_entry_or_null(&stream->subrequests, 232 + struct netfs_io_subrequest, rreq_link); 232 233 while (front) { 233 234 trace_netfs_collect_sreq(wreq, front); 234 235 //_debug("sreq [%x] %llx %zx/%zx", ··· 280 279 list_del_init(&front->rreq_link); 281 280 front = list_first_entry_or_null(&stream->subrequests, 282 281 struct netfs_io_subrequest, rreq_link); 283 - stream->front = front; 284 282 spin_unlock(&wreq->lock); 285 283 netfs_put_subrequest(remove, 286 284 notes & SAW_FAILURE ?
+1 -2
fs/netfs/write_issue.c
··· 206 206 spin_lock(&wreq->lock); 207 207 list_add_tail(&subreq->rreq_link, &stream->subrequests); 208 208 if (list_is_first(&subreq->rreq_link, &stream->subrequests)) { 209 - stream->front = subreq; 210 209 if (!stream->active) { 211 - stream->collected_to = stream->front->start; 210 + stream->collected_to = subreq->start; 212 211 /* Write list pointers before active flag */ 213 212 smp_store_release(&stream->active, true); 214 213 }
+3 -3
fs/overlayfs/copy_up.c
··· 1146 1146 return -EOVERFLOW; 1147 1147 1148 1148 /* 1149 - * With metacopy disabled, we fsync after final metadata copyup, for 1149 + * With "fsync=strict", we fsync after final metadata copyup, for 1150 1150 * both regular files and directories to get atomic copyup semantics 1151 1151 * on filesystems that do not use strict metadata ordering (e.g. ubifs). 1152 1152 * 1153 - * With metacopy enabled we want to avoid fsync on all meta copyup 1153 + * By default, we want to avoid fsync on all meta copyup, because 1154 1154 * that will hurt performance of workloads such as chown -R, so we 1155 1155 * only fsync on data copyup as legacy behavior. 1156 1156 */ 1157 - ctx.metadata_fsync = !OVL_FS(dentry->d_sb)->config.metacopy && 1157 + ctx.metadata_fsync = ovl_should_sync_metadata(OVL_FS(dentry->d_sb)) && 1158 1158 (S_ISREG(ctx.stat.mode) || S_ISDIR(ctx.stat.mode)); 1159 1159 ctx.metacopy = ovl_need_meta_copy_up(dentry, ctx.stat.mode, flags); 1160 1160
+21
fs/overlayfs/overlayfs.h
··· 99 99 OVL_VERITY_REQUIRE, 100 100 }; 101 101 102 + enum { 103 + OVL_FSYNC_VOLATILE, 104 + OVL_FSYNC_AUTO, 105 + OVL_FSYNC_STRICT, 106 + }; 107 + 102 108 /* 103 109 * The tuple (fh,uuid) is a universal unique identifier for a copy up origin, 104 110 * where: ··· 660 654 static inline bool ovl_xino_warn(struct ovl_fs *ofs) 661 655 { 662 656 return ofs->config.xino == OVL_XINO_ON; 657 + } 658 + 659 + static inline bool ovl_should_sync(struct ovl_fs *ofs) 660 + { 661 + return ofs->config.fsync_mode != OVL_FSYNC_VOLATILE; 662 + } 663 + 664 + static inline bool ovl_should_sync_metadata(struct ovl_fs *ofs) 665 + { 666 + return ofs->config.fsync_mode == OVL_FSYNC_STRICT; 667 + } 668 + 669 + static inline bool ovl_is_volatile(struct ovl_config *config) 670 + { 671 + return config->fsync_mode == OVL_FSYNC_VOLATILE; 663 672 } 664 673 665 674 /*
+1 -6
fs/overlayfs/ovl_entry.h
··· 18 18 int xino; 19 19 bool metacopy; 20 20 bool userxattr; 21 - bool ovl_volatile; 21 + int fsync_mode; 22 22 }; 23 23 24 24 struct ovl_sb { ··· 118 118 WARN_ON_ONCE(sb->s_type != &ovl_fs_type); 119 119 120 120 return (struct ovl_fs *)sb->s_fs_info; 121 - } 122 - 123 - static inline bool ovl_should_sync(struct ovl_fs *ofs) 124 - { 125 - return !ofs->config.ovl_volatile; 126 121 } 127 122 128 123 static inline unsigned int ovl_numlower(struct ovl_entry *oe)
+28 -5
fs/overlayfs/params.c
··· 58 58 Opt_xino, 59 59 Opt_metacopy, 60 60 Opt_verity, 61 + Opt_fsync, 61 62 Opt_volatile, 62 63 Opt_override_creds, 63 64 }; ··· 141 140 return OVL_VERITY_OFF; 142 141 } 143 142 143 + static const struct constant_table ovl_parameter_fsync[] = { 144 + { "volatile", OVL_FSYNC_VOLATILE }, 145 + { "auto", OVL_FSYNC_AUTO }, 146 + { "strict", OVL_FSYNC_STRICT }, 147 + {} 148 + }; 149 + 150 + static const char *ovl_fsync_mode(struct ovl_config *config) 151 + { 152 + return ovl_parameter_fsync[config->fsync_mode].name; 153 + } 154 + 155 + static int ovl_fsync_mode_def(void) 156 + { 157 + return OVL_FSYNC_AUTO; 158 + } 159 + 144 160 const struct fs_parameter_spec ovl_parameter_spec[] = { 145 161 fsparam_string_empty("lowerdir", Opt_lowerdir), 146 162 fsparam_file_or_string("lowerdir+", Opt_lowerdir_add), ··· 173 155 fsparam_enum("xino", Opt_xino, ovl_parameter_xino), 174 156 fsparam_enum("metacopy", Opt_metacopy, ovl_parameter_bool), 175 157 fsparam_enum("verity", Opt_verity, ovl_parameter_verity), 158 + fsparam_enum("fsync", Opt_fsync, ovl_parameter_fsync), 176 159 fsparam_flag("volatile", Opt_volatile), 177 160 fsparam_flag_no("override_creds", Opt_override_creds), 178 161 {} ··· 684 665 case Opt_verity: 685 666 config->verity_mode = result.uint_32; 686 667 break; 668 + case Opt_fsync: 669 + config->fsync_mode = result.uint_32; 670 + break; 687 671 case Opt_volatile: 688 - config->ovl_volatile = true; 672 + config->fsync_mode = OVL_FSYNC_VOLATILE; 689 673 break; 690 674 case Opt_userxattr: 691 675 config->userxattr = true; ··· 822 800 ofs->config.nfs_export = ovl_nfs_export_def; 823 801 ofs->config.xino = ovl_xino_def(); 824 802 ofs->config.metacopy = ovl_metacopy_def; 803 + ofs->config.fsync_mode = ovl_fsync_mode_def(); 825 804 826 805 fc->s_fs_info = ofs; 827 806 fc->fs_private = ctx; ··· 893 870 config->index = false; 894 871 } 895 872 896 - if (!config->upperdir && config->ovl_volatile) { 873 + if (!config->upperdir && ovl_is_volatile(config)) { 897 874 pr_info("option \"volatile\" is meaningless in a non-upper mount, ignoring it.\n"); 898 - config->ovl_volatile = false; 875 + config->fsync_mode = ovl_fsync_mode_def(); 899 876 } 900 877 901 878 if (!config->upperdir && config->uuid == OVL_UUID_ON) { ··· 1093 1070 seq_printf(m, ",xino=%s", ovl_xino_mode(&ofs->config)); 1094 1071 if (ofs->config.metacopy != ovl_metacopy_def) 1095 1072 seq_printf(m, ",metacopy=%s", str_on_off(ofs->config.metacopy)); 1096 - if (ofs->config.ovl_volatile) 1097 - seq_puts(m, ",volatile"); 1073 + if (ofs->config.fsync_mode != ovl_fsync_mode_def()) 1074 + seq_printf(m, ",fsync=%s", ovl_fsync_mode(&ofs->config)); 1098 1075 if (ofs->config.userxattr) 1099 1076 seq_puts(m, ",userxattr"); 1100 1077 if (ofs->config.verity_mode != ovl_verity_mode_def())
+1 -1
fs/overlayfs/super.c
··· 776 776 * For volatile mount, create a incompat/volatile/dirty file to keep 777 777 * track of it. 778 778 */ 779 - if (ofs->config.ovl_volatile) { 779 + if (ovl_is_volatile(&ofs->config)) { 780 780 err = ovl_create_volatile_dirty(ofs); 781 781 if (err < 0) { 782 782 pr_err("Failed to create volatile/dirty file.\n");
+4 -1
fs/overlayfs/util.c
··· 85 85 if (!exportfs_can_decode_fh(sb->s_export_op)) 86 86 return 0; 87 87 88 - return sb->s_export_op->encode_fh ? -1 : FILEID_INO32_GEN; 88 + if (sb->s_export_op->encode_fh == generic_encode_ino32_fh) 89 + return FILEID_INO32_GEN; 90 + 91 + return -1; 89 92 } 90 93 91 94 struct dentry *ovl_indexdir(struct super_block *sb)
+4 -3
fs/smb/client/Makefile
··· 48 48 # Build the SMB2 error mapping table from smb2status.h 49 49 # 50 50 $(obj)/smb2_mapping_table.c: $(src)/../common/smb2status.h \ 51 - $(src)/gen_smb2_mapping 52 - $(call cmd,gen_smb2_mapping) 51 + $(src)/gen_smb2_mapping FORCE 52 + $(call if_changed,gen_smb2_mapping) 53 53 54 54 $(obj)/smb2maperror.o: $(obj)/smb2_mapping_table.c 55 55 ··· 58 58 59 59 obj-$(CONFIG_SMB_KUNIT_TESTS) += smb2maperror_test.o 60 60 61 - clean-files += smb2_mapping_table.c 61 + # Let Kbuild handle tracking and cleaning 62 + targets += smb2_mapping_table.c
+45 -27
fs/smb/server/oplock.c
··· 82 82 spin_unlock(&lb->lb_lock); 83 83 } 84 84 85 - static void lb_add(struct lease_table *lb) 85 + static struct lease_table *alloc_lease_table(struct oplock_info *opinfo) 86 86 { 87 - write_lock(&lease_list_lock); 88 - list_add(&lb->l_entry, &lease_table_list); 89 - write_unlock(&lease_list_lock); 87 + struct lease_table *lb; 88 + 89 + lb = kmalloc_obj(struct lease_table, KSMBD_DEFAULT_GFP); 90 + if (!lb) 91 + return NULL; 92 + 93 + memcpy(lb->client_guid, opinfo->conn->ClientGUID, 94 + SMB2_CLIENT_GUID_SIZE); 95 + INIT_LIST_HEAD(&lb->lease_list); 96 + spin_lock_init(&lb->lb_lock); 97 + return lb; 90 98 } 91 99 92 100 static int alloc_lease(struct oplock_info *opinfo, struct lease_ctx_info *lctx) ··· 1050 1042 lease2->version = lease1->version; 1051 1043 } 1052 1044 1053 - static int add_lease_global_list(struct oplock_info *opinfo) 1045 + static void add_lease_global_list(struct oplock_info *opinfo, 1046 + struct lease_table *new_lb) 1054 1047 { 1055 1048 struct lease_table *lb; 1056 1049 1057 - read_lock(&lease_list_lock); 1050 + write_lock(&lease_list_lock); 1058 1051 list_for_each_entry(lb, &lease_table_list, l_entry) { 1059 1052 if (!memcmp(lb->client_guid, opinfo->conn->ClientGUID, 1060 1053 SMB2_CLIENT_GUID_SIZE)) { 1061 1054 opinfo->o_lease->l_lb = lb; 1062 1055 lease_add_list(opinfo); 1063 - read_unlock(&lease_list_lock); 1064 - return 0; 1056 + write_unlock(&lease_list_lock); 1057 + kfree(new_lb); 1058 + return; 1065 1059 } 1066 1060 } 1067 - read_unlock(&lease_list_lock); 1068 1061 1069 - lb = kmalloc_obj(struct lease_table, KSMBD_DEFAULT_GFP); 1070 - if (!lb) 1071 - return -ENOMEM; 1072 - 1073 - memcpy(lb->client_guid, opinfo->conn->ClientGUID, 1074 - SMB2_CLIENT_GUID_SIZE); 1075 - INIT_LIST_HEAD(&lb->lease_list); 1076 - spin_lock_init(&lb->lb_lock); 1077 - opinfo->o_lease->l_lb = lb; 1062 + opinfo->o_lease->l_lb = new_lb; 1078 1063 lease_add_list(opinfo); 1079 - lb_add(lb); 1080 - return 0; 1064 + list_add(&new_lb->l_entry, &lease_table_list); 1065 + write_unlock(&lease_list_lock); 1081 1066 } 1082 1067 1083 1068 static void set_oplock_level(struct oplock_info *opinfo, int level, ··· 1190 1189 int err = 0; 1191 1190 struct oplock_info *opinfo = NULL, *prev_opinfo = NULL; 1192 1191 struct ksmbd_inode *ci = fp->f_ci; 1192 + struct lease_table *new_lb = NULL; 1193 1193 bool prev_op_has_lease; 1194 1194 __le32 prev_op_state = 0; 1195 1195 ··· 1293 1291 set_oplock_level(opinfo, req_op_level, lctx); 1294 1292 1295 1293 out: 1294 + /* 1295 + * Set o_fp before any publication so that concurrent readers 1296 + * (e.g. find_same_lease_key() on the lease list) that 1297 + * dereference opinfo->o_fp don't hit a NULL pointer. 1298 + * 1299 + * Keep the original publication order so concurrent opens can 1300 + * still observe the in-flight grant via ci->m_op_list, but make 1301 + * everything after opinfo_add() no-fail by preallocating any new 1302 + * lease_table first. 1303 + */ 1304 + opinfo->o_fp = fp; 1305 + if (opinfo->is_lease) { 1306 + new_lb = alloc_lease_table(opinfo); 1307 + if (!new_lb) { 1308 + err = -ENOMEM; 1309 + goto err_out; 1310 + } 1311 + } 1312 + 1296 1313 opinfo_count_inc(fp); 1297 1314 opinfo_add(opinfo, fp); 1298 1315 1299 - if (opinfo->is_lease) { 1300 - err = add_lease_global_list(opinfo); 1301 - if (err) 1302 - goto err_out; 1303 - } 1316 + if (opinfo->is_lease) 1317 + add_lease_global_list(opinfo, new_lb); 1304 1318 1305 1319 rcu_assign_pointer(fp->f_opinfo, opinfo); 1306 - opinfo->o_fp = fp; 1307 1320 1308 1321 return 0; 1309 1322 err_out: 1310 - __free_opinfo(opinfo); 1323 + kfree(new_lb); 1324 + opinfo_put(opinfo); 1311 1325 return err; 1312 1326 } 1313 1327
+52 -21
fs/smb/server/smb2pdu.c
··· 1939 1939 if (sess->user && sess->user->flags & KSMBD_USER_FLAG_DELAY_SESSION) 1940 1940 try_delay = true; 1941 1941 1942 - sess->last_active = jiffies; 1943 - sess->state = SMB2_SESSION_EXPIRED; 1942 + /* 1943 + * For binding requests, session belongs to another 1944 + * connection. Do not expire it. 1945 + */ 1946 + if (!(req->Flags & SMB2_SESSION_REQ_FLAG_BINDING)) { 1947 + sess->last_active = jiffies; 1948 + sess->state = SMB2_SESSION_EXPIRED; 1949 + } 1944 1950 ksmbd_user_session_put(sess); 1945 1951 work->sess = NULL; 1946 1952 if (try_delay) { ··· 4452 4446 d_info.wptr = (char *)rsp->Buffer; 4453 4447 d_info.rptr = (char *)rsp->Buffer; 4454 4448 d_info.out_buf_len = 4455 - smb2_calc_max_out_buf_len(work, 8, 4456 - le32_to_cpu(req->OutputBufferLength)); 4449 + smb2_calc_max_out_buf_len(work, 4450 + offsetof(struct smb2_query_directory_rsp, Buffer), 4451 + le32_to_cpu(req->OutputBufferLength)); 4457 4452 if (d_info.out_buf_len < 0) { 4458 4453 rc = -EINVAL; 4459 4454 goto err_out; ··· 4721 4714 } 4722 4715 4723 4716 buf_free_len = 4724 - smb2_calc_max_out_buf_len(work, 8, 4725 - le32_to_cpu(req->OutputBufferLength)); 4717 + smb2_calc_max_out_buf_len(work, 4718 + offsetof(struct smb2_query_info_rsp, Buffer), 4719 + le32_to_cpu(req->OutputBufferLength)); 4726 4720 if (buf_free_len < 0) 4727 4721 return -EINVAL; 4728 4722 ··· 4940 4932 int conv_len; 4941 4933 char *filename; 4942 4934 u64 time; 4943 - int ret; 4935 + int ret, buf_free_len, filename_len; 4936 + struct smb2_query_info_req *req = ksmbd_req_buf_next(work); 4944 4937 4945 4938 if (!(fp->daccess & FILE_READ_ATTRIBUTES_LE)) { 4946 4939 ksmbd_debug(SMB, "no right to read the attributes : 0x%x\n", ··· 4952 4943 filename = convert_to_nt_pathname(work->tcon->share_conf, &fp->filp->f_path); 4953 4944 if (IS_ERR(filename)) 4954 4945 return PTR_ERR(filename); 4946 + 4947 + filename_len = strlen(filename); 4948 + buf_free_len = smb2_calc_max_out_buf_len(work, 4949 + offsetof(struct smb2_query_info_rsp, Buffer) + 4950 + offsetof(struct smb2_file_all_info, FileName), 4951 + le32_to_cpu(req->OutputBufferLength)); 4952 + if (buf_free_len < (filename_len + 1) * 2) { 4953 + kfree(filename); 4954 + return -EINVAL; 4955 + } 4955 4956 4956 4957 ret = vfs_getattr(&fp->filp->f_path, &stat, STATX_BASIC_STATS, 4957 4958 AT_STATX_SYNC_AS_STAT); ··· 5006 4987 file_info->Mode = fp->coption; 5007 4988 file_info->AlignmentRequirement = 0; 5008 4989 conv_len = smbConvertToUTF16((__le16 *)file_info->FileName, filename, 5009 - PATH_MAX, conn->local_nls, 0); 4990 + min(filename_len, PATH_MAX), 4991 + conn->local_nls, 0); 5010 4992 conv_len *= 2; 5011 4993 file_info->FileNameLength = cpu_to_le32(conv_len); 5012 4994 rsp->OutputBufferLength = ··· 5061 5041 file_info = (struct smb2_file_stream_info *)rsp->Buffer; 5062 5042 5063 5043 buf_free_len = 5064 - smb2_calc_max_out_buf_len(work, 8, 5065 - le32_to_cpu(req->OutputBufferLength)); 5044 + smb2_calc_max_out_buf_len(work, 5045 + offsetof(struct smb2_query_info_rsp, Buffer), 5046 + le32_to_cpu(req->OutputBufferLength)); 5066 5047 if (buf_free_len < 0) 5067 5048 goto out; 5068 5049 ··· 7607 7586 rc = vfs_lock_file(filp, smb_lock->cmd, flock, NULL); 7608 7587 skip: 7609 7588 if (smb_lock->flags & SMB2_LOCKFLAG_UNLOCK) { 7589 + locks_free_lock(flock); 7590 + kfree(smb_lock); 7610 7591 if (!rc) { 7611 7592 ksmbd_debug(SMB, "File unlocked\n"); 7612 7593 } else if (rc == -ENOENT) { 7613 7594 rsp->hdr.Status = STATUS_NOT_LOCKED; 7595 + err = rc; 7614 7596 goto out; 7615 7597 } 7616 - locks_free_lock(flock); 7617 - kfree(smb_lock); 7618 7598 } else { 7619 7599 if (rc == FILE_LOCK_DEFERRED) { 7620 7600 void **argv; ··· 7684 7662 spin_unlock(&work->conn->llist_lock); 7685 7663 ksmbd_debug(SMB, "successful in taking lock\n"); 7686 7664 } else { 7665 + locks_free_lock(flock); 7666 + kfree(smb_lock); 7667 + err = rc; 7687 7668 goto out; 7688 7669 } 7689 7670 } ··· 7717 7692 struct file_lock *rlock = NULL; 7718 7693 7719 7694 rlock = smb_flock_init(filp); 7720 - rlock->c.flc_type = F_UNLCK; 7721 - rlock->fl_start = smb_lock->start; 7722 - rlock->fl_end = smb_lock->end; 7695 + if (rlock) { 7696 + rlock->c.flc_type = F_UNLCK; 7697 + rlock->fl_start = smb_lock->start; 7698 + rlock->fl_end = smb_lock->end; 7723 7699 7724 - rc = vfs_lock_file(filp, F_SETLK, rlock, NULL); 7725 - if (rc) 7726 - pr_err("rollback unlock fail : %d\n", rc); 7700 + rc = vfs_lock_file(filp, F_SETLK, rlock, NULL); 7701 + if (rc) 7702 + pr_err("rollback unlock fail : %d\n", rc); 7703 + } else { 7704 + pr_err("rollback unlock alloc failed\n"); 7705 + } 7727 7706 7728 7707 list_del(&smb_lock->llist); 7729 7708 spin_lock(&work->conn->llist_lock); ··· 7737 7708 spin_unlock(&work->conn->llist_lock); 7738 7709 7739 7710 locks_free_lock(smb_lock->fl); 7740 - locks_free_lock(rlock); 7711 + if (rlock) 7712 + locks_free_lock(rlock); 7741 7713 kfree(smb_lock); 7742 7714 } 7743 7715 out2: ··· 8221 8191 buffer = (char *)req + le32_to_cpu(req->InputOffset); 8222 8192 8223 8193 cnt_code = le32_to_cpu(req->CtlCode); 8224 - ret = smb2_calc_max_out_buf_len(work, 48, 8225 - le32_to_cpu(req->MaxOutputResponse)); 8194 + ret = smb2_calc_max_out_buf_len(work, 8195 + offsetof(struct smb2_ioctl_rsp, Buffer), 8196 + le32_to_cpu(req->MaxOutputResponse)); 8226 8197 if (ret < 0) { 8227 8198 rsp->hdr.Status = STATUS_INVALID_PARAMETER; 8228 8199 goto out;
+15 -18
fs/udf/inode.c
··· 181 181 } 182 182 } 183 183 184 - static int udf_adinicb_writepages(struct address_space *mapping, 185 - struct writeback_control *wbc) 184 + static int udf_handle_page_wb(struct folio *folio, 185 + struct writeback_control *wbc) 186 186 { 187 - struct inode *inode = mapping->host; 187 + struct inode *inode = folio->mapping->host; 188 188 struct udf_inode_info *iinfo = UDF_I(inode); 189 - struct folio *folio = NULL; 190 - int error = 0; 191 189 192 - while ((folio = writeback_iter(mapping, wbc, folio, &error))) { 193 - BUG_ON(!folio_test_locked(folio)); 194 - BUG_ON(folio->index != 0); 195 - memcpy_from_file_folio(iinfo->i_data + iinfo->i_lenEAttr, folio, 190 + /* 191 + * Inodes in the normal format are handled by the generic code. This 192 + * check is race-free as the folio lock protects us from inode type 193 + * conversion. 194 + */ 195 + if (iinfo->i_alloc_type != ICBTAG_FLAG_AD_IN_ICB) 196 + return 1; 197 + 198 + memcpy_from_file_folio(iinfo->i_data + iinfo->i_lenEAttr, folio, 196 199 0, i_size_read(inode)); 197 - folio_unlock(folio); 198 - } 199 - 200 + folio_unlock(folio); 200 201 mark_inode_dirty(inode); 201 202 return 0; 202 203 } ··· 205 204 static int udf_writepages(struct address_space *mapping, 206 205 struct writeback_control *wbc) 207 206 { 208 - struct inode *inode = mapping->host; 209 - struct udf_inode_info *iinfo = UDF_I(inode); 210 - 211 - if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) 212 - return udf_adinicb_writepages(mapping, wbc); 213 - return mpage_writepages(mapping, wbc, udf_get_block_wb); 207 + return __mpage_writepages(mapping, wbc, udf_get_block_wb, 208 + udf_handle_page_wb); 214 209 } 215 210 216 211 static void udf_adinicb_read_folio(struct folio *folio)
+2 -1
fs/xfs/libxfs/xfs_attr.h
··· 55 55 struct xfs_trans *tp; 56 56 struct xfs_inode *dp; /* inode */ 57 57 struct xfs_attrlist_cursor_kern cursor; /* position in list */ 58 - void *buffer; /* output buffer */ 58 + /* output buffer */ 59 + void *buffer __counted_by_ptr(bufsize); 59 60 60 61 /* 61 62 * Abort attribute list iteration if non-zero. Can be used to pass
+22
fs/xfs/libxfs/xfs_attr_leaf.c
··· 1416 1416 } 1417 1417 1418 1418 /* 1419 + * Reinitialize an existing attr fork block as an empty leaf, and attach 1420 + * the buffer to tp. 1421 + */ 1422 + int 1423 + xfs_attr3_leaf_init( 1424 + struct xfs_trans *tp, 1425 + struct xfs_inode *dp, 1426 + xfs_dablk_t blkno) 1427 + { 1428 + struct xfs_buf *bp = NULL; 1429 + struct xfs_da_args args = { 1430 + .trans = tp, 1431 + .dp = dp, 1432 + .owner = dp->i_ino, 1433 + .geo = dp->i_mount->m_attr_geo, 1434 + }; 1435 + 1436 + ASSERT(tp != NULL); 1437 + 1438 + return xfs_attr3_leaf_create(&args, blkno, &bp); 1439 + } 1440 + /* 1419 1441 * Split the leaf node, rebalance, then add the new entry. 1420 1442 * 1421 1443 * Returns 0 if the entry was added, 1 if a further split is needed or a
+3
fs/xfs/libxfs/xfs_attr_leaf.h
··· 87 87 /* 88 88 * Routines used for shrinking the Btree. 89 89 */ 90 + 91 + int xfs_attr3_leaf_init(struct xfs_trans *tp, struct xfs_inode *dp, 92 + xfs_dablk_t blkno); 90 93 int xfs_attr3_leaf_toosmall(struct xfs_da_state *state, int *retval); 91 94 void xfs_attr3_leaf_unbalance(struct xfs_da_state *state, 92 95 struct xfs_da_state_blk *drop_blk,
+42 -11
fs/xfs/libxfs/xfs_da_btree.c
··· 1506 1506 } 1507 1507 1508 1508 /* 1509 - * Remove an entry from an intermediate node. 1509 + * Internal implementation to remove an entry from an intermediate node. 1510 1510 */ 1511 1511 STATIC void 1512 - xfs_da3_node_remove( 1513 - struct xfs_da_state *state, 1514 - struct xfs_da_state_blk *drop_blk) 1512 + __xfs_da3_node_remove( 1513 + struct xfs_trans *tp, 1514 + struct xfs_inode *dp, 1515 + struct xfs_da_geometry *geo, 1516 + struct xfs_da_state_blk *drop_blk) 1515 1517 { 1516 1518 struct xfs_da_intnode *node; 1517 1519 struct xfs_da3_icnode_hdr nodehdr; 1518 1520 struct xfs_da_node_entry *btree; 1519 1521 int index; 1520 1522 int tmp; 1521 - struct xfs_inode *dp = state->args->dp; 1522 - 1523 - trace_xfs_da_node_remove(state->args); 1524 1523 1525 1524 node = drop_blk->bp->b_addr; 1526 1525 xfs_da3_node_hdr_from_disk(dp->i_mount, &nodehdr, node); ··· 1535 1536 tmp = nodehdr.count - index - 1; 1536 1537 tmp *= (uint)sizeof(xfs_da_node_entry_t); 1537 1538 memmove(&btree[index], &btree[index + 1], tmp); 1538 - xfs_trans_log_buf(state->args->trans, drop_blk->bp, 1539 + xfs_trans_log_buf(tp, drop_blk->bp, 1539 1540 XFS_DA_LOGRANGE(node, &btree[index], tmp)); 1540 1541 index = nodehdr.count - 1; 1541 1542 } 1542 1543 memset(&btree[index], 0, sizeof(xfs_da_node_entry_t)); 1543 - xfs_trans_log_buf(state->args->trans, drop_blk->bp, 1544 + xfs_trans_log_buf(tp, drop_blk->bp, 1544 1545 XFS_DA_LOGRANGE(node, &btree[index], sizeof(btree[index]))); 1545 1546 nodehdr.count -= 1; 1546 1547 xfs_da3_node_hdr_to_disk(dp->i_mount, node, &nodehdr); 1547 - xfs_trans_log_buf(state->args->trans, drop_blk->bp, 1548 - XFS_DA_LOGRANGE(node, &node->hdr, state->args->geo->node_hdr_size)); 1548 + xfs_trans_log_buf(tp, drop_blk->bp, 1549 + XFS_DA_LOGRANGE(node, &node->hdr, geo->node_hdr_size)); 1549 1550 1550 1551 /* 1551 1552 * Copy the last hash value from the block to propagate upwards. 1552 1553 */ 1553 1554 drop_blk->hashval = be32_to_cpu(btree[index - 1].hashval); 1555 + } 1556 + 1557 + /* 1558 + * Remove an entry from an intermediate node. 1559 + */ 1560 + STATIC void 1561 + xfs_da3_node_remove( 1562 + struct xfs_da_state *state, 1563 + struct xfs_da_state_blk *drop_blk) 1564 + { 1565 + trace_xfs_da_node_remove(state->args); 1566 + 1567 + __xfs_da3_node_remove(state->args->trans, state->args->dp, 1568 + state->args->geo, drop_blk); 1569 + } 1570 + 1571 + /* 1572 + * Remove an entry from an intermediate attr node at the specified index. 1573 + */ 1574 + void 1575 + xfs_attr3_node_entry_remove( 1576 + struct xfs_trans *tp, 1577 + struct xfs_inode *dp, 1578 + struct xfs_buf *bp, 1579 + int index) 1580 + { 1581 + struct xfs_da_state_blk blk = { 1582 + .index = index, 1583 + .bp = bp, 1584 + }; 1585 + 1586 + __xfs_da3_node_remove(tp, dp, dp->i_mount->m_attr_geo, &blk); 1554 1587 } 1555 1588 1556 1589 /*
+2
fs/xfs/libxfs/xfs_da_btree.h
··· 184 184 int xfs_da3_join(xfs_da_state_t *state); 185 185 void xfs_da3_fixhashpath(struct xfs_da_state *state, 186 186 struct xfs_da_state_path *path_to_to_fix); 187 + void xfs_attr3_node_entry_remove(struct xfs_trans *tp, struct xfs_inode *dp, 188 + struct xfs_buf *bp, int index); 187 189 188 190 /* 189 191 * Routines used for finding things in the Btree.
+3 -1
fs/xfs/scrub/quota.c
··· 171 171 172 172 error = xchk_quota_item_bmap(sc, dq, offset); 173 173 xchk_iunlock(sc, XFS_ILOCK_SHARED); 174 - if (!xchk_fblock_process_error(sc, XFS_DATA_FORK, offset, &error)) 174 + if (!xchk_fblock_process_error(sc, XFS_DATA_FORK, offset, &error)) { 175 + mutex_unlock(&dq->q_qlock); 175 176 return error; 177 + } 176 178 177 179 /* 178 180 * Warn if the hard limits are larger than the fs.
+2 -10
fs/xfs/scrub/trace.h
··· 972 972 TP_STRUCT__entry( 973 973 __field(dev_t, dev) 974 974 __field(unsigned long, ino) 975 - __array(char, pathname, MAXNAMELEN) 976 975 ), 977 976 TP_fast_assign( 978 - char *path; 979 - 980 977 __entry->ino = file_inode(xf->file)->i_ino; 981 - path = file_path(xf->file, __entry->pathname, MAXNAMELEN); 982 - if (IS_ERR(path)) 983 - strncpy(__entry->pathname, "(unknown)", 984 - sizeof(__entry->pathname)); 985 978 ), 986 - TP_printk("xfino 0x%lx path '%s'", 987 - __entry->ino, 988 - __entry->pathname) 979 + TP_printk("xfino 0x%lx", 980 + __entry->ino) 989 981 ); 990 982 991 983 TRACE_EVENT(xfile_destroy,
+59 -40
fs/xfs/xfs_attr_inactive.c
··· 140 140 xfs_daddr_t parent_blkno, child_blkno; 141 141 struct xfs_buf *child_bp; 142 142 struct xfs_da3_icnode_hdr ichdr; 143 - int error, i; 143 + int error; 144 144 145 145 /* 146 146 * Since this code is recursive (gasp!) we must protect ourselves. ··· 152 152 return -EFSCORRUPTED; 153 153 } 154 154 155 - xfs_da3_node_hdr_from_disk(dp->i_mount, &ichdr, bp->b_addr); 155 + xfs_da3_node_hdr_from_disk(mp, &ichdr, bp->b_addr); 156 156 parent_blkno = xfs_buf_daddr(bp); 157 157 if (!ichdr.count) { 158 158 xfs_trans_brelse(*trans, bp); ··· 167 167 * over the leaves removing all of them. If this is higher up 168 168 * in the tree, recurse downward. 169 169 */ 170 - for (i = 0; i < ichdr.count; i++) { 170 + while (ichdr.count > 0) { 171 171 /* 172 172 * Read the subsidiary block to see what we have to work with. 173 173 * Don't do this in a transaction. This is a depth-first ··· 218 218 xfs_trans_binval(*trans, child_bp); 219 219 child_bp = NULL; 220 220 221 - /* 222 - * If we're not done, re-read the parent to get the next 223 - * child block number. 224 - */ 225 - if (i + 1 < ichdr.count) { 226 - struct xfs_da3_icnode_hdr phdr; 221 + error = xfs_da3_node_read_mapped(*trans, dp, 222 + parent_blkno, &bp, XFS_ATTR_FORK); 223 + if (error) 224 + return error; 227 225 228 - error = xfs_da3_node_read_mapped(*trans, dp, 229 - parent_blkno, &bp, XFS_ATTR_FORK); 226 + /* 227 + * Remove entry from parent node, prevents being indexed to. 228 + */ 229 + xfs_attr3_node_entry_remove(*trans, dp, bp, 0); 230 + 231 + xfs_da3_node_hdr_from_disk(mp, &ichdr, bp->b_addr); 232 + bp = NULL; 233 + 234 + if (ichdr.count > 0) { 235 + /* 236 + * If we're not done, get the next child block number. 237 + */ 238 + child_fsb = be32_to_cpu(ichdr.btree[0].before); 239 + 240 + /* 241 + * Atomically commit the whole invalidate stuff. 242 + */ 243 + error = xfs_trans_roll_inode(trans, dp); 230 244 if (error) 231 245 return error; 232 - xfs_da3_node_hdr_from_disk(dp->i_mount, &phdr, 233 - bp->b_addr); 234 - child_fsb = be32_to_cpu(phdr.btree[i + 1].before); 235 - xfs_trans_brelse(*trans, bp); 236 - bp = NULL; 237 246 } 238 - /* 239 - * Atomically commit the whole invalidate stuff. 240 - */ 241 - error = xfs_trans_roll_inode(trans, dp); 242 - if (error) 243 - return error; 244 247 } 245 248 246 249 return 0; ··· 260 257 struct xfs_trans **trans, 261 258 struct xfs_inode *dp) 262 259 { 263 - struct xfs_mount *mp = dp->i_mount; 264 260 struct xfs_da_blkinfo *info; 265 261 struct xfs_buf *bp; 266 - xfs_daddr_t blkno; 267 262 int error; 268 263 269 264 /* ··· 273 272 error = xfs_da3_node_read(*trans, dp, 0, &bp, XFS_ATTR_FORK); 274 273 if (error) 275 274 return error; 276 - blkno = xfs_buf_daddr(bp); 277 275 278 276 /* 279 277 * Invalidate the tree, even if the "tree" is only a single leaf block. ··· 283 283 case cpu_to_be16(XFS_DA_NODE_MAGIC): 284 284 case cpu_to_be16(XFS_DA3_NODE_MAGIC): 285 285 error = xfs_attr3_node_inactive(trans, dp, bp, 1); 286 + /* 287 + * Empty root node block are not allowed, convert it to leaf. 288 + */ 289 + if (!error) 290 + error = xfs_attr3_leaf_init(*trans, dp, 0); 291 + if (!error) 292 + error = xfs_trans_roll_inode(trans, dp); 286 293 break; 287 294 case cpu_to_be16(XFS_ATTR_LEAF_MAGIC): 288 295 case cpu_to_be16(XFS_ATTR3_LEAF_MAGIC): 289 296 error = xfs_attr3_leaf_inactive(trans, dp, bp); 297 + /* 298 + * Reinit the leaf before truncating extents so that a crash 299 + * mid-truncation leaves an empty leaf rather than one with 300 + * entries that may reference freed remote value blocks. 301 + */ 302 + if (!error) 303 + error = xfs_attr3_leaf_init(*trans, dp, 0); 304 + if (!error) 305 + error = xfs_trans_roll_inode(trans, dp); 290 306 break; 291 307 default: 292 308 xfs_dirattr_mark_sick(dp, XFS_ATTR_FORK); ··· 311 295 xfs_trans_brelse(*trans, bp); 312 296 break; 313 297 } 314 - if (error) 315 - return error; 316 - 317 - /* 318 - * Invalidate the incore copy of the root block. 319 - */ 320 - error = xfs_trans_get_buf(*trans, mp->m_ddev_targp, blkno, 321 - XFS_FSB_TO_BB(mp, mp->m_attr_geo->fsbcount), 0, &bp); 322 - if (error) 323 - return error; 324 - xfs_trans_binval(*trans, bp); /* remove from cache */ 325 - /* 326 - * Commit the invalidate and start the next transaction. 327 - */ 328 - error = xfs_trans_roll_inode(trans, dp); 329 298 330 299 return error; 331 300 } ··· 329 328 { 330 329 struct xfs_trans *trans; 331 330 struct xfs_mount *mp; 331 + struct xfs_buf *bp; 332 332 int lock_mode = XFS_ILOCK_SHARED; 333 333 int error = 0; 334 334 ··· 365 363 * removal below. 366 364 */ 367 365 if (dp->i_af.if_nextents > 0) { 366 + /* 367 + * Invalidate and truncate all blocks but leave the root block. 368 + */ 368 369 error = xfs_attr3_root_inactive(&trans, dp); 369 370 if (error) 370 371 goto out_cancel; 371 372 373 + error = xfs_itruncate_extents(&trans, dp, XFS_ATTR_FORK, 374 + XFS_FSB_TO_B(mp, mp->m_attr_geo->fsbcount)); 375 + if (error) 376 + goto out_cancel; 377 + 378 + /* 379 + * Invalidate and truncate the root block and ensure that the 380 + * operation is completed within a single transaction. 381 + */ 382 + error = xfs_da_get_buf(trans, dp, 0, &bp, XFS_ATTR_FORK); 383 + if (error) 384 + goto out_cancel; 385 + 386 + xfs_trans_binval(trans, bp); 372 387 error = xfs_itruncate_extents(&trans, dp, XFS_ATTR_FORK, 0); 373 388 if (error) 374 389 goto out_cancel;
+2 -49
fs/xfs/xfs_attr_item.c
··· 653 653 break; 654 654 } 655 655 if (error) { 656 - xfs_irele(ip); 657 656 XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, attrp, 658 657 sizeof(*attrp)); 659 658 return ERR_PTR(-EFSCORRUPTED); ··· 1046 1047 break; 1047 1048 case XFS_ATTRI_OP_FLAGS_SET: 1048 1049 case XFS_ATTRI_OP_FLAGS_REPLACE: 1049 - /* Log item, attr name, attr value */ 1050 - if (item->ri_total != 3) { 1050 + /* Log item, attr name, optional attr value */ 1051 + if (item->ri_total != 2 + !!attri_formatp->alfi_value_len) { 1051 1052 XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, 1052 1053 attri_formatp, len); 1053 1054 return -EFSCORRUPTED; ··· 1129 1130 XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, 1130 1131 attri_formatp, len); 1131 1132 return -EFSCORRUPTED; 1132 - } 1133 - 1134 - switch (op) { 1135 - case XFS_ATTRI_OP_FLAGS_REMOVE: 1136 - /* Regular remove operations operate only on names. */ 1137 - if (attr_value != NULL || value_len != 0) { 1138 - XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, 1139 - attri_formatp, len); 1140 - return -EFSCORRUPTED; 1141 - } 1142 - fallthrough; 1143 - case XFS_ATTRI_OP_FLAGS_PPTR_REMOVE: 1144 - case XFS_ATTRI_OP_FLAGS_PPTR_SET: 1145 - case XFS_ATTRI_OP_FLAGS_SET: 1146 - case XFS_ATTRI_OP_FLAGS_REPLACE: 1147 - /* 1148 - * Regular xattr set/remove/replace operations require a name 1149 - * and do not take a newname. Values are optional for set and 1150 - * replace. 1151 - * 1152 - * Name-value set/remove operations must have a name, do not 1153 - * take a newname, and can take a value. 1154 - */ 1155 - if (attr_name == NULL || name_len == 0) { 1156 - XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, 1157 - attri_formatp, len); 1158 - return -EFSCORRUPTED; 1159 - } 1160 - break; 1161 - case XFS_ATTRI_OP_FLAGS_PPTR_REPLACE: 1162 - /* 1163 - * Name-value replace operations require the caller to 1164 - * specify the old and new names and values explicitly. 1165 - * Values are optional. 1166 - */ 1167 - if (attr_name == NULL || name_len == 0) { 1168 - XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, 1169 - attri_formatp, len); 1170 - return -EFSCORRUPTED; 1171 - } 1172 - if (attr_new_name == NULL || new_name_len == 0) { 1173 - XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, 1174 - attri_formatp, len); 1175 - return -EFSCORRUPTED; 1176 - } 1177 - break; 1178 1133 } 1179 1134 1180 1135 /*
+7 -2
fs/xfs/xfs_dquot_item.c
··· 125 125 struct xfs_dq_logitem *qlip = DQUOT_ITEM(lip); 126 126 struct xfs_dquot *dqp = qlip->qli_dquot; 127 127 struct xfs_buf *bp; 128 + struct xfs_ail *ailp = lip->li_ailp; 128 129 uint rval = XFS_ITEM_SUCCESS; 129 130 int error; 130 131 ··· 154 153 goto out_unlock; 155 154 } 156 155 157 - spin_unlock(&lip->li_ailp->ail_lock); 156 + spin_unlock(&ailp->ail_lock); 158 157 159 158 error = xfs_dquot_use_attached_buf(dqp, &bp); 160 159 if (error == -EAGAIN) { ··· 173 172 rval = XFS_ITEM_FLUSHING; 174 173 } 175 174 xfs_buf_relse(bp); 175 + /* 176 + * The buffer no longer protects the log item from reclaim, so 177 + * do not reference lip after this point. 178 + */ 176 179 177 180 out_relock_ail: 178 - spin_lock(&lip->li_ailp->ail_lock); 181 + spin_lock(&ailp->ail_lock); 179 182 out_unlock: 180 183 mutex_unlock(&dqp->q_qlock); 181 184 return rval;
+1 -1
fs/xfs/xfs_handle.c
··· 443 443 context.dp = dp; 444 444 context.resynch = 1; 445 445 context.attr_filter = xfs_attr_filter(flags); 446 - context.buffer = buffer; 447 446 context.bufsize = round_down(bufsize, sizeof(uint32_t)); 447 + context.buffer = buffer; 448 448 context.firstu = context.bufsize; 449 449 context.put_listent = xfs_ioc_attr_put_listent; 450 450
+2 -1
fs/xfs/xfs_inode.c
··· 1048 1048 xfs_assert_ilocked(ip, XFS_ILOCK_EXCL); 1049 1049 if (icount_read(VFS_I(ip))) 1050 1050 xfs_assert_ilocked(ip, XFS_IOLOCK_EXCL); 1051 - ASSERT(new_size <= XFS_ISIZE(ip)); 1051 + if (whichfork == XFS_DATA_FORK) 1052 + ASSERT(new_size <= XFS_ISIZE(ip)); 1052 1053 ASSERT(tp->t_flags & XFS_TRANS_PERM_LOG_RES); 1053 1054 ASSERT(ip->i_itemp != NULL); 1054 1055 ASSERT(ip->i_itemp->ili_lock_flags == 0);
+7 -2
fs/xfs/xfs_inode_item.c
··· 746 746 struct xfs_inode_log_item *iip = INODE_ITEM(lip); 747 747 struct xfs_inode *ip = iip->ili_inode; 748 748 struct xfs_buf *bp = lip->li_buf; 749 + struct xfs_ail *ailp = lip->li_ailp; 749 750 uint rval = XFS_ITEM_SUCCESS; 750 751 int error; 751 752 ··· 772 771 if (!xfs_buf_trylock(bp)) 773 772 return XFS_ITEM_LOCKED; 774 773 775 - spin_unlock(&lip->li_ailp->ail_lock); 774 + spin_unlock(&ailp->ail_lock); 776 775 777 776 /* 778 777 * We need to hold a reference for flushing the cluster buffer as it may ··· 796 795 rval = XFS_ITEM_LOCKED; 797 796 } 798 797 799 - spin_lock(&lip->li_ailp->ail_lock); 798 + /* 799 + * The buffer no longer protects the log item from reclaim, so 800 + * do not reference lip after this point. 801 + */ 802 + spin_lock(&ailp->ail_lock); 800 803 return rval; 801 804 } 802 805
+4 -3
fs/xfs/xfs_mount.c
··· 608 608 * have been retrying in the background. This will prevent never-ending 609 609 * retries in AIL pushing from hanging the unmount. 610 610 * 611 - * Finally, we can push the AIL to clean all the remaining dirty objects, then 612 - * reclaim the remaining inodes that are still in memory at this point in time. 611 + * Stop inodegc and background reclaim before pushing the AIL so that they 612 + * are not running while the AIL is being flushed. Then push the AIL to 613 + * clean all the remaining dirty objects and reclaim the remaining inodes. 613 614 */ 614 615 static void 615 616 xfs_unmount_flush_inodes( ··· 622 621 623 622 xfs_set_unmounting(mp); 624 623 625 - xfs_ail_push_all_sync(mp->m_ail); 626 624 xfs_inodegc_stop(mp); 627 625 cancel_delayed_work_sync(&mp->m_reclaim_work); 626 + xfs_ail_push_all_sync(mp->m_ail); 628 627 xfs_reclaim_inodes(mp); 629 628 xfs_health_unmount(mp); 630 629 xfs_healthmon_unmount(mp);
+34 -13
fs/xfs/xfs_trace.h
··· 56 56 #include <linux/tracepoint.h> 57 57 58 58 struct xfs_agf; 59 + struct xfs_ail; 59 60 struct xfs_alloc_arg; 60 61 struct xfs_attr_list_context; 61 62 struct xfs_buf_log_item; ··· 1651 1650 DEFINE_EVENT(xfs_log_item_class, name, \ 1652 1651 TP_PROTO(struct xfs_log_item *lip), \ 1653 1652 TP_ARGS(lip)) 1654 - DEFINE_LOG_ITEM_EVENT(xfs_ail_push); 1655 - DEFINE_LOG_ITEM_EVENT(xfs_ail_pinned); 1656 - DEFINE_LOG_ITEM_EVENT(xfs_ail_locked); 1657 - DEFINE_LOG_ITEM_EVENT(xfs_ail_flushing); 1658 1653 DEFINE_LOG_ITEM_EVENT(xfs_cil_whiteout_mark); 1659 1654 DEFINE_LOG_ITEM_EVENT(xfs_cil_whiteout_skip); 1660 1655 DEFINE_LOG_ITEM_EVENT(xfs_cil_whiteout_unpin); 1661 1656 DEFINE_LOG_ITEM_EVENT(xlog_ail_insert_abort); 1662 1657 DEFINE_LOG_ITEM_EVENT(xfs_trans_free_abort); 1658 + 1659 + DECLARE_EVENT_CLASS(xfs_ail_push_class, 1660 + TP_PROTO(struct xfs_ail *ailp, uint type, unsigned long flags, xfs_lsn_t lsn), 1661 + TP_ARGS(ailp, type, flags, lsn), 1662 + TP_STRUCT__entry( 1663 + __field(dev_t, dev) 1664 + __field(uint, type) 1665 + __field(unsigned long, flags) 1666 + __field(xfs_lsn_t, lsn) 1667 + ), 1668 + TP_fast_assign( 1669 + __entry->dev = ailp->ail_log->l_mp->m_super->s_dev; 1670 + __entry->type = type; 1671 + __entry->flags = flags; 1672 + __entry->lsn = lsn; 1673 + ), 1674 + TP_printk("dev %d:%d lsn %d/%d type %s flags %s", 1675 + MAJOR(__entry->dev), MINOR(__entry->dev), 1676 + CYCLE_LSN(__entry->lsn), BLOCK_LSN(__entry->lsn), 1677 + __print_symbolic(__entry->type, XFS_LI_TYPE_DESC), 1678 + __print_flags(__entry->flags, "|", XFS_LI_FLAGS)) 1679 + ) 1680 + 1681 + #define DEFINE_AIL_PUSH_EVENT(name) \ 1682 + DEFINE_EVENT(xfs_ail_push_class, name, \ 1683 + TP_PROTO(struct xfs_ail *ailp, uint type, unsigned long flags, xfs_lsn_t lsn), \ 1684 + TP_ARGS(ailp, type, flags, lsn)) 1685 + DEFINE_AIL_PUSH_EVENT(xfs_ail_push); 1686 + DEFINE_AIL_PUSH_EVENT(xfs_ail_pinned); 1687 + DEFINE_AIL_PUSH_EVENT(xfs_ail_locked); 1688 + DEFINE_AIL_PUSH_EVENT(xfs_ail_flushing); 1663 1689 1664 1690 DECLARE_EVENT_CLASS(xfs_ail_class, 1665 1691 TP_PROTO(struct xfs_log_item *lip, xfs_lsn_t old_lsn, xfs_lsn_t new_lsn), ··· 5119 5091 TP_STRUCT__entry( 5120 5092 __field(dev_t, dev) 5121 5093 __field(unsigned long, ino) 5122 - __array(char, pathname, MAXNAMELEN) 5123 5094 ), 5124 5095 TP_fast_assign( 5125 - char *path; 5126 5096 struct file *file = btp->bt_file; 5127 5097 5128 5098 __entry->dev = btp->bt_mount->m_super->s_dev; 5129 5099 __entry->ino = file_inode(file)->i_ino; 5130 - path = file_path(file, __entry->pathname, MAXNAMELEN); 5131 - if (IS_ERR(path)) 5132 - strncpy(__entry->pathname, "(unknown)", 5133 - sizeof(__entry->pathname)); 5134 5100 ), 5135 - TP_printk("dev %d:%d xmino 0x%lx path '%s'", 5101 + TP_printk("dev %d:%d xmino 0x%lx", 5136 5102 MAJOR(__entry->dev), MINOR(__entry->dev), 5137 - __entry->ino, 5138 - __entry->pathname) 5103 + __entry->ino) 5139 5104 ); 5140 5105 5141 5106 TRACE_EVENT(xmbuf_free,
+75 -52
fs/xfs/xfs_trans_ail.c
··· 365 365 return XFS_ITEM_SUCCESS; 366 366 } 367 367 368 + /* 369 + * Push a single log item from the AIL. 370 + * 371 + * @lip may have been released and freed by the time this function returns, 372 + * so callers must not dereference the log item afterwards. 373 + */ 368 374 static inline uint 369 375 xfsaild_push_item( 370 376 struct xfs_ail *ailp, ··· 464 458 return target_lsn; 465 459 } 466 460 461 + static void 462 + xfsaild_process_logitem( 463 + struct xfs_ail *ailp, 464 + struct xfs_log_item *lip, 465 + int *stuck, 466 + int *flushing) 467 + { 468 + struct xfs_mount *mp = ailp->ail_log->l_mp; 469 + uint type = lip->li_type; 470 + unsigned long flags = lip->li_flags; 471 + xfs_lsn_t item_lsn = lip->li_lsn; 472 + int lock_result; 473 + 474 + /* 475 + * Note that iop_push may unlock and reacquire the AIL lock. We 476 + * rely on the AIL cursor implementation to be able to deal with 477 + * the dropped lock. 478 + * 479 + * The log item may have been freed by the push, so it must not 480 + * be accessed or dereferenced below this line. 481 + */ 482 + lock_result = xfsaild_push_item(ailp, lip); 483 + switch (lock_result) { 484 + case XFS_ITEM_SUCCESS: 485 + XFS_STATS_INC(mp, xs_push_ail_success); 486 + trace_xfs_ail_push(ailp, type, flags, item_lsn); 487 + 488 + ailp->ail_last_pushed_lsn = item_lsn; 489 + break; 490 + 491 + case XFS_ITEM_FLUSHING: 492 + /* 493 + * The item or its backing buffer is already being 494 + * flushed. The typical reason for that is that an 495 + * inode buffer is locked because we already pushed the 496 + * updates to it as part of inode clustering. 497 + * 498 + * We do not want to stop flushing just because lots 499 + * of items are already being flushed, but we need to 500 + * re-try the flushing relatively soon if most of the 501 + * AIL is being flushed. 502 + */ 503 + XFS_STATS_INC(mp, xs_push_ail_flushing); 504 + trace_xfs_ail_flushing(ailp, type, flags, item_lsn); 505 + 506 + (*flushing)++; 507 + ailp->ail_last_pushed_lsn = item_lsn; 508 + break; 509 + 510 + case XFS_ITEM_PINNED: 511 + XFS_STATS_INC(mp, xs_push_ail_pinned); 512 + trace_xfs_ail_pinned(ailp, type, flags, item_lsn); 513 + 514 + (*stuck)++; 515 + ailp->ail_log_flush++; 516 + break; 517 + case XFS_ITEM_LOCKED: 518 + XFS_STATS_INC(mp, xs_push_ail_locked); 519 + trace_xfs_ail_locked(ailp, type, flags, item_lsn); 520 + 521 + (*stuck)++; 522 + break; 523 + default: 524 + ASSERT(0); 525 + break; 526 + } 527 + } 528 + 467 529 static long 468 530 xfsaild_push( 469 531 struct xfs_ail *ailp) ··· 579 505 580 506 lsn = lip->li_lsn; 581 507 while ((XFS_LSN_CMP(lip->li_lsn, ailp->ail_target) <= 0)) { 582 - int lock_result; 583 508 584 509 if (test_bit(XFS_LI_FLUSHING, &lip->li_flags)) 585 510 goto next_item; 586 511 587 - /* 588 - * Note that iop_push may unlock and reacquire the AIL lock. We 589 - * rely on the AIL cursor implementation to be able to deal with 590 - * the dropped lock. 591 - */ 592 - lock_result = xfsaild_push_item(ailp, lip); 593 - switch (lock_result) { 594 - case XFS_ITEM_SUCCESS: 595 - XFS_STATS_INC(mp, xs_push_ail_success); 596 - trace_xfs_ail_push(lip); 597 - 598 - ailp->ail_last_pushed_lsn = lsn; 599 - break; 600 - 601 - case XFS_ITEM_FLUSHING: 602 - /* 603 - * The item or its backing buffer is already being 604 - * flushed. The typical reason for that is that an 605 - * inode buffer is locked because we already pushed the 606 - * updates to it as part of inode clustering. 607 - * 608 - * We do not want to stop flushing just because lots 609 - * of items are already being flushed, but we need to 610 - * re-try the flushing relatively soon if most of the 611 - * AIL is being flushed. 612 - */ 613 - XFS_STATS_INC(mp, xs_push_ail_flushing); 614 - trace_xfs_ail_flushing(lip); 615 - 616 - flushing++; 617 - ailp->ail_last_pushed_lsn = lsn; 618 - break; 619 - 620 - case XFS_ITEM_PINNED: 621 - XFS_STATS_INC(mp, xs_push_ail_pinned); 622 - trace_xfs_ail_pinned(lip); 623 - 624 - stuck++; 625 - ailp->ail_log_flush++; 626 - break; 627 - case XFS_ITEM_LOCKED: 628 - XFS_STATS_INC(mp, xs_push_ail_locked); 629 - trace_xfs_ail_locked(lip); 630 - 631 - stuck++; 632 - break; 633 - default: 634 - ASSERT(0); 635 - break; 636 - } 637 - 512 + xfsaild_process_logitem(ailp, lip, &stuck, &flushing); 638 513 count++; 639 514 640 515 /*
+8 -10
fs/xfs/xfs_verify_media.c
··· 183 183 min_not_zero(SZ_1M, me->me_max_io_size); 184 184 185 185 BUILD_BUG_ON(BBSHIFT != SECTOR_SHIFT); 186 - ASSERT(BBTOB(bbcount) >= bdev_logical_block_size(btp->bt_bdev)); 186 + ASSERT(BBTOB(bbcount) >= btp->bt_logical_sectorsize); 187 187 188 - return clamp(iosize, bdev_logical_block_size(btp->bt_bdev), 189 - BBTOB(bbcount)); 188 + return clamp(iosize, btp->bt_logical_sectorsize, BBTOB(bbcount)); 190 189 } 191 190 192 191 /* Allocate as much memory as we can get for verification buffer. */ ··· 217 218 unsigned int bio_bbcount, 218 219 blk_status_t bio_status) 219 220 { 220 - trace_xfs_verify_media_error(mp, me, btp->bt_bdev->bd_dev, daddr, 221 - bio_bbcount, bio_status); 221 + trace_xfs_verify_media_error(mp, me, btp->bt_dev, daddr, bio_bbcount, 222 + bio_status); 222 223 223 224 /* 224 225 * Pass any error, I/O or otherwise, up to the caller if we didn't ··· 279 280 btp = mp->m_ddev_targp; 280 281 break; 281 282 case XFS_DEV_LOG: 282 - if (mp->m_logdev_targp->bt_bdev != mp->m_ddev_targp->bt_bdev) 283 + if (mp->m_logdev_targp != mp->m_ddev_targp) 283 284 btp = mp->m_logdev_targp; 284 285 break; 285 286 case XFS_DEV_RT: ··· 298 299 299 300 /* start and end have to be aligned to the lba size */ 300 301 if (!IS_ALIGNED(BBTOB(me->me_start_daddr | me->me_end_daddr), 301 - bdev_logical_block_size(btp->bt_bdev))) 302 + btp->bt_logical_sectorsize)) 302 303 return -EINVAL; 303 304 304 305 /* ··· 330 331 if (!folio) 331 332 return -ENOMEM; 332 333 333 - trace_xfs_verify_media(mp, me, btp->bt_bdev->bd_dev, daddr, bbcount, 334 - folio); 334 + trace_xfs_verify_media(mp, me, btp->bt_dev, daddr, bbcount, folio); 335 335 336 336 bio = bio_alloc(btp->bt_bdev, 1, REQ_OP_READ, GFP_KERNEL); 337 337 if (!bio) { ··· 398 400 * an operational error. 399 401 */ 400 402 me->me_start_daddr = daddr; 401 - trace_xfs_verify_media_end(mp, me, btp->bt_bdev->bd_dev); 403 + trace_xfs_verify_media_end(mp, me, btp->bt_dev); 402 404 return 0; 403 405 } 404 406
+1 -1
fs/xfs/xfs_xattr.c
··· 332 332 memset(&context, 0, sizeof(context)); 333 333 context.dp = XFS_I(inode); 334 334 context.resynch = 1; 335 - context.buffer = size ? data : NULL; 336 335 context.bufsize = size; 336 + context.buffer = size ? data : NULL; 337 337 context.firstu = context.bufsize; 338 338 context.put_listent = xfs_xattr_put_listent; 339 339
+3
include/linux/cgroup-defs.h
··· 609 609 /* used to wait for offlining of csses */ 610 610 wait_queue_head_t offline_waitq; 611 611 612 + /* used by cgroup_rmdir() to wait for dying tasks to leave */ 613 + wait_queue_head_t dying_populated_waitq; 614 + 612 615 /* used to schedule release agent */ 613 616 struct work_struct release_agent_work; 614 617
+1
include/linux/fs/super_types.h
··· 338 338 #define SB_I_NOUMASK 0x00001000 /* VFS does not apply umask */ 339 339 #define SB_I_NOIDMAP 0x00002000 /* No idmapped mounts on this superblock */ 340 340 #define SB_I_ALLOW_HSM 0x00004000 /* Allow HSM events on this superblock */ 341 + #define SB_I_NO_DATA_INTEGRITY 0x00008000 /* fs cannot guarantee data persistence on sync */ 341 342 342 343 #endif /* _LINUX_FS_SUPER_TYPES_H */
+2 -1
include/linux/iommu.h
··· 980 980 static inline void iommu_iotlb_sync(struct iommu_domain *domain, 981 981 struct iommu_iotlb_gather *iotlb_gather) 982 982 { 983 - if (domain->ops->iotlb_sync) 983 + if (domain->ops->iotlb_sync && 984 + likely(iotlb_gather->start < iotlb_gather->end)) 984 985 domain->ops->iotlb_sync(domain, iotlb_gather); 985 986 986 987 iommu_iotlb_gather_init(iotlb_gather);
+21 -11
include/linux/leafops.h
··· 363 363 return swp_offset(entry) & SWP_PFN_MASK; 364 364 } 365 365 366 + static inline void softleaf_migration_sync(softleaf_t entry, 367 + struct folio *folio) 368 + { 369 + /* 370 + * Ensure we do not race with split, which might alter tail pages into new 371 + * folios and thus result in observing an unlocked folio. 372 + * This matches the write barrier in __split_folio_to_order(). 373 + */ 374 + smp_rmb(); 375 + 376 + /* 377 + * Any use of migration entries may only occur while the 378 + * corresponding page is locked 379 + */ 380 + VM_WARN_ON_ONCE(!folio_test_locked(folio)); 381 + } 382 + 366 383 /** 367 384 * softleaf_to_page() - Obtains struct page for PFN encoded within leaf entry. 368 385 * @entry: Leaf entry, softleaf_has_pfn(@entry) must return true. ··· 391 374 struct page *page = pfn_to_page(softleaf_to_pfn(entry)); 392 375 393 376 VM_WARN_ON_ONCE(!softleaf_has_pfn(entry)); 394 - /* 395 - * Any use of migration entries may only occur while the 396 - * corresponding page is locked 397 - */ 398 - VM_WARN_ON_ONCE(softleaf_is_migration(entry) && !PageLocked(page)); 377 + if (softleaf_is_migration(entry)) 378 + softleaf_migration_sync(entry, page_folio(page)); 399 379 400 380 return page; 401 381 } ··· 408 394 struct folio *folio = pfn_folio(softleaf_to_pfn(entry)); 409 395 410 396 VM_WARN_ON_ONCE(!softleaf_has_pfn(entry)); 411 - /* 412 - * Any use of migration entries may only occur while the 413 - * corresponding folio is locked. 414 - */ 415 - VM_WARN_ON_ONCE(softleaf_is_migration(entry) && 416 - !folio_test_locked(folio)); 397 + if (softleaf_is_migration(entry)) 398 + softleaf_migration_sync(entry, folio); 417 399 418 400 return folio; 419 401 }
+1
include/linux/mempolicy.h
··· 55 55 nodemask_t cpuset_mems_allowed; /* relative to these nodes */ 56 56 nodemask_t user_nodemask; /* nodemask passed by user */ 57 57 } w; 58 + struct rcu_head rcu; 58 59 }; 59 60 60 61 /*
+9 -2
include/linux/mpage.h
··· 17 17 18 18 void mpage_readahead(struct readahead_control *, get_block_t get_block); 19 19 int mpage_read_folio(struct folio *folio, get_block_t get_block); 20 - int mpage_writepages(struct address_space *mapping, 21 - struct writeback_control *wbc, get_block_t get_block); 20 + int __mpage_writepages(struct address_space *mapping, 21 + struct writeback_control *wbc, get_block_t get_block, 22 + int (*write_folio)(struct folio *folio, 23 + struct writeback_control *wbc)); 24 + static inline int mpage_writepages(struct address_space *mapping, 25 + struct writeback_control *wbc, get_block_t get_block) 26 + { 27 + return __mpage_writepages(mapping, wbc, get_block, NULL); 28 + } 22 29 23 30 #endif
+1 -1
include/linux/netfilter/ipset/ip_set.h
··· 309 309 310 310 /* register and unregister set references */ 311 311 extern ip_set_id_t ip_set_get_byname(struct net *net, 312 - const char *name, struct ip_set **set); 312 + const struct nlattr *name, struct ip_set **set); 313 313 extern void ip_set_put_byindex(struct net *net, ip_set_id_t index); 314 314 extern void ip_set_name_byindex(struct net *net, ip_set_id_t index, char *name); 315 315 extern ip_set_id_t ip_set_nfnl_get_byindex(struct net *net, ip_set_id_t index);
-1
include/linux/netfs.h
··· 140 140 void (*issue_write)(struct netfs_io_subrequest *subreq); 141 141 /* Collection tracking */ 142 142 struct list_head subrequests; /* Contributory I/O operations */ 143 - struct netfs_io_subrequest *front; /* Op being collected */ 144 143 unsigned long long collected_to; /* Position we've collected results to */ 145 144 size_t transferred; /* The amount transferred from this stream */ 146 145 unsigned short error; /* Aggregate error for the stream */
-11
include/linux/pagemap.h
··· 210 210 AS_WRITEBACK_MAY_DEADLOCK_ON_RECLAIM = 9, 211 211 AS_KERNEL_FILE = 10, /* mapping for a fake kernel file that shouldn't 212 212 account usage to user cgroups */ 213 - AS_NO_DATA_INTEGRITY = 11, /* no data integrity guarantees */ 214 213 /* Bits 16-25 are used for FOLIO_ORDER */ 215 214 AS_FOLIO_ORDER_BITS = 5, 216 215 AS_FOLIO_ORDER_MIN = 16, ··· 343 344 static inline bool mapping_writeback_may_deadlock_on_reclaim(const struct address_space *mapping) 344 345 { 345 346 return test_bit(AS_WRITEBACK_MAY_DEADLOCK_ON_RECLAIM, &mapping->flags); 346 - } 347 - 348 - static inline void mapping_set_no_data_integrity(struct address_space *mapping) 349 - { 350 - set_bit(AS_NO_DATA_INTEGRITY, &mapping->flags); 351 - } 352 - 353 - static inline bool mapping_no_data_integrity(const struct address_space *mapping) 354 - { 355 - return test_bit(AS_NO_DATA_INTEGRITY, &mapping->flags); 356 347 } 357 348 358 349 static inline gfp_t mapping_gfp_mask(const struct address_space *mapping)
+1
include/linux/skbuff.h
··· 5106 5106 return unlikely(skb->active_extensions); 5107 5107 } 5108 5108 #else 5109 + static inline void __skb_ext_put(struct skb_ext *ext) {} 5109 5110 static inline void skb_ext_put(struct sk_buff *skb) {} 5110 5111 static inline void skb_ext_reset(struct sk_buff *skb) {} 5111 5112 static inline void skb_ext_del(struct sk_buff *skb, int unused) {}
-5
include/linux/spi/spi.h
··· 159 159 * @modalias: Name of the driver to use with this device, or an alias 160 160 * for that name. This appears in the sysfs "modalias" attribute 161 161 * for driver coldplugging, and in uevents used for hotplugging 162 - * @driver_override: If the name of a driver is written to this attribute, then 163 - * the device will bind to the named driver and only the named driver. 164 - * Do not set directly, because core frees it; use driver_set_override() to 165 - * set or clear it. 166 162 * @pcpu_statistics: statistics for the spi_device 167 163 * @word_delay: delay to be inserted between consecutive 168 164 * words of a transfer ··· 220 224 void *controller_state; 221 225 void *controller_data; 222 226 char modalias[SPI_NAME_SIZE]; 223 - const char *driver_override; 224 227 225 228 /* The statistics */ 226 229 struct spi_statistics __percpu *pcpu_statistics;
+1
include/net/netns/mpls.h
··· 17 17 size_t platform_labels; 18 18 struct mpls_route __rcu * __rcu *platform_label; 19 19 struct mutex platform_mutex; 20 + seqcount_mutex_t platform_label_seq; 20 21 21 22 struct ctl_table_header *ctl; 22 23 };
-5
include/sound/sdca_function.h
··· 27 27 #define SDCA_MAX_ENTITY_COUNT 128 28 28 29 29 /* 30 - * Sanity check on number of initialization writes, can be expanded if needed. 31 - */ 32 - #define SDCA_MAX_INIT_COUNT 2048 33 - 34 - /* 35 30 * The Cluster IDs are 16-bit, so a maximum of 65535 Clusters per 36 31 * function can be represented, however limit this to a slightly 37 32 * more reasonable value. Can be expanded if needed.
+7 -4
include/trace/events/btrfs.h
··· 769 769 ), 770 770 771 771 TP_fast_assign( 772 - const struct dentry *dentry = file->f_path.dentry; 773 - const struct inode *inode = d_inode(dentry); 772 + struct dentry *dentry = file_dentry(file); 773 + struct inode *inode = file_inode(file); 774 + struct dentry *parent = dget_parent(dentry); 775 + struct inode *parent_inode = d_inode(parent); 774 776 775 - TP_fast_assign_fsid(btrfs_sb(file->f_path.dentry->d_sb)); 777 + dput(parent); 778 + TP_fast_assign_fsid(btrfs_sb(inode->i_sb)); 776 779 __entry->ino = btrfs_ino(BTRFS_I(inode)); 777 - __entry->parent = btrfs_ino(BTRFS_I(d_inode(dentry->d_parent))); 780 + __entry->parent = btrfs_ino(BTRFS_I(parent_inode)); 778 781 __entry->datasync = datasync; 779 782 __entry->root_objectid = btrfs_root_id(BTRFS_I(inode)->root); 780 783 ),
+4 -4
include/trace/events/netfs.h
··· 740 740 __field(unsigned int, wreq) 741 741 __field(unsigned char, stream) 742 742 __field(unsigned long long, collected_to) 743 - __field(unsigned long long, front) 743 + __field(unsigned long long, issued_to) 744 744 ), 745 745 746 746 TP_fast_assign( 747 747 __entry->wreq = wreq->debug_id; 748 748 __entry->stream = stream->stream_nr; 749 749 __entry->collected_to = stream->collected_to; 750 - __entry->front = stream->front ? stream->front->start : UINT_MAX; 750 + __entry->issued_to = atomic64_read(&wreq->issued_to); 751 751 ), 752 752 753 - TP_printk("R=%08x[%x:] cto=%llx frn=%llx", 753 + TP_printk("R=%08x[%x:] cto=%llx ito=%llx", 754 754 __entry->wreq, __entry->stream, 755 - __entry->collected_to, __entry->front) 755 + __entry->collected_to, __entry->issued_to) 756 756 ); 757 757 758 758 TRACE_EVENT(netfs_folioq,
+3 -1
io_uring/fdinfo.c
··· 119 119 sq_idx); 120 120 break; 121 121 } 122 - if ((++sq_head & sq_mask) == 0) { 122 + if (sq_idx == sq_mask) { 123 123 seq_printf(m, 124 124 "%5u: corrupted sqe, wrapping 128B entry\n", 125 125 sq_idx); 126 126 break; 127 127 } 128 + sq_head++; 129 + i++; 128 130 sqe128 = true; 129 131 } 130 132 seq_printf(m, "%5u: opcode:%s, fd:%d, flags:%x, off:%llu, "
+85 -3
kernel/cgroup/cgroup.c
··· 2126 2126 #endif 2127 2127 2128 2128 init_waitqueue_head(&cgrp->offline_waitq); 2129 + init_waitqueue_head(&cgrp->dying_populated_waitq); 2129 2130 INIT_WORK(&cgrp->release_agent_work, cgroup1_release_agent); 2130 2131 } 2131 2132 ··· 6225 6224 return 0; 6226 6225 }; 6227 6226 6227 + /** 6228 + * cgroup_drain_dying - wait for dying tasks to leave before rmdir 6229 + * @cgrp: the cgroup being removed 6230 + * 6231 + * cgroup.procs and cgroup.threads use css_task_iter which filters out 6232 + * PF_EXITING tasks so that userspace doesn't see tasks that have already been 6233 + * reaped via waitpid(). However, cgroup_has_tasks() - which tests whether the 6234 + * cgroup has non-empty css_sets - is only updated when dying tasks pass through 6235 + * cgroup_task_dead() in finish_task_switch(). This creates a window where 6236 + * cgroup.procs reads empty but cgroup_has_tasks() is still true, making rmdir 6237 + * fail with -EBUSY from cgroup_destroy_locked() even though userspace sees no 6238 + * tasks. 6239 + * 6240 + * This function aligns cgroup_has_tasks() with what userspace can observe. If 6241 + * cgroup_has_tasks() but the task iterator sees nothing (all remaining tasks are 6242 + * PF_EXITING), we wait for cgroup_task_dead() to finish processing them. As the 6243 + * window between PF_EXITING and cgroup_task_dead() is short, the wait is brief. 6244 + * 6245 + * This function only concerns itself with this cgroup's own dying tasks. 6246 + * Whether the cgroup has children is cgroup_destroy_locked()'s problem. 6247 + * 6248 + * Each cgroup_task_dead() kicks the waitqueue via cset->cgrp_links, and we 6249 + * retry the full check from scratch. 6250 + * 6251 + * Must be called with cgroup_mutex held. 6252 + */ 6253 + static int cgroup_drain_dying(struct cgroup *cgrp) 6254 + __releases(&cgroup_mutex) __acquires(&cgroup_mutex) 6255 + { 6256 + struct css_task_iter it; 6257 + struct task_struct *task; 6258 + DEFINE_WAIT(wait); 6259 + 6260 + lockdep_assert_held(&cgroup_mutex); 6261 + retry: 6262 + if (!cgroup_has_tasks(cgrp)) 6263 + return 0; 6264 + 6265 + /* Same iterator as cgroup.threads - if any task is visible, it's busy */ 6266 + css_task_iter_start(&cgrp->self, 0, &it); 6267 + task = css_task_iter_next(&it); 6268 + css_task_iter_end(&it); 6269 + 6270 + if (task) 6271 + return -EBUSY; 6272 + 6273 + /* 6274 + * All remaining tasks are PF_EXITING and will pass through 6275 + * cgroup_task_dead() shortly. Wait for a kick and retry. 6276 + * 6277 + * cgroup_has_tasks() can't transition from false to true while we're 6278 + * holding cgroup_mutex, but the true to false transition happens 6279 + * under css_set_lock (via cgroup_task_dead()). We must retest and 6280 + * prepare_to_wait() under css_set_lock. Otherwise, the transition 6281 + * can happen between our first test and prepare_to_wait(), and we 6282 + * sleep with no one to wake us. 6283 + */ 6284 + spin_lock_irq(&css_set_lock); 6285 + if (!cgroup_has_tasks(cgrp)) { 6286 + spin_unlock_irq(&css_set_lock); 6287 + return 0; 6288 + } 6289 + prepare_to_wait(&cgrp->dying_populated_waitq, &wait, 6290 + TASK_UNINTERRUPTIBLE); 6291 + spin_unlock_irq(&css_set_lock); 6292 + mutex_unlock(&cgroup_mutex); 6293 + schedule(); 6294 + finish_wait(&cgrp->dying_populated_waitq, &wait); 6295 + mutex_lock(&cgroup_mutex); 6296 + goto retry; 6297 + } 6298 + 6228 6299 int cgroup_rmdir(struct kernfs_node *kn) 6229 6300 { 6230 6301 struct cgroup *cgrp; ··· 6306 6233 if (!cgrp) 6307 6234 return 0; 6308 6235 6309 - ret = cgroup_destroy_locked(cgrp); 6310 - if (!ret) 6311 - TRACE_CGROUP_PATH(rmdir, cgrp); 6236 + ret = cgroup_drain_dying(cgrp); 6237 + if (!ret) { 6238 + ret = cgroup_destroy_locked(cgrp); 6239 + if (!ret) 6240 + TRACE_CGROUP_PATH(rmdir, cgrp); 6241 + } 6312 6242 6313 6243 cgroup_kn_unlock(kn); 6314 6244 return ret; ··· 7071 6995 7072 6996 static void do_cgroup_task_dead(struct task_struct *tsk) 7073 6997 { 6998 + struct cgrp_cset_link *link; 7074 6999 struct css_set *cset; 7075 7000 unsigned long flags; 7076 7001 ··· 7084 7007 /* matches the signal->live check in css_task_iter_advance() */ 7085 7008 if (thread_group_leader(tsk) && atomic_read(&tsk->signal->live)) 7086 7009 list_add_tail(&tsk->cg_list, &cset->dying_tasks); 7010 + 7011 + /* kick cgroup_drain_dying() waiters, see cgroup_rmdir() */ 7012 + list_for_each_entry(link, &cset->cgrp_links, cgrp_link) 7013 + if (waitqueue_active(&link->cgrp->dying_populated_waitq)) 7014 + wake_up(&link->cgrp->dying_populated_waitq); 7087 7015 7088 7016 if (dl_task(tsk)) 7089 7017 dec_dl_tasks_cs(tsk);
+20 -9
kernel/cgroup/cpuset.c
··· 2988 2988 struct cgroup_subsys_state *css; 2989 2989 struct cpuset *cs, *oldcs; 2990 2990 struct task_struct *task; 2991 - bool cpus_updated, mems_updated; 2991 + bool setsched_check; 2992 2992 int ret; 2993 2993 2994 2994 /* used later by cpuset_attach() */ ··· 3003 3003 if (ret) 3004 3004 goto out_unlock; 3005 3005 3006 - cpus_updated = !cpumask_equal(cs->effective_cpus, oldcs->effective_cpus); 3007 - mems_updated = !nodes_equal(cs->effective_mems, oldcs->effective_mems); 3006 + /* 3007 + * Skip rights over task setsched check in v2 when nothing changes, 3008 + * migration permission derives from hierarchy ownership in 3009 + * cgroup_procs_write_permission()). 3010 + */ 3011 + setsched_check = !cpuset_v2() || 3012 + !cpumask_equal(cs->effective_cpus, oldcs->effective_cpus) || 3013 + !nodes_equal(cs->effective_mems, oldcs->effective_mems); 3014 + 3015 + /* 3016 + * A v1 cpuset with tasks will have no CPU left only when CPU hotplug 3017 + * brings the last online CPU offline as users are not allowed to empty 3018 + * cpuset.cpus when there are active tasks inside. When that happens, 3019 + * we should allow tasks to migrate out without security check to make 3020 + * sure they will be able to run after migration. 3021 + */ 3022 + if (!is_in_v2_mode() && cpumask_empty(oldcs->effective_cpus)) 3023 + setsched_check = false; 3008 3024 3009 3025 cgroup_taskset_for_each(task, css, tset) { 3010 3026 ret = task_can_attach(task); 3011 3027 if (ret) 3012 3028 goto out_unlock; 3013 3029 3014 - /* 3015 - * Skip rights over task check in v2 when nothing changes, 3016 - * migration permission derives from hierarchy ownership in 3017 - * cgroup_procs_write_permission()). 3018 - */ 3019 - if (!cpuset_v2() || (cpus_updated || mems_updated)) { 3030 + if (setsched_check) { 3020 3031 ret = security_task_setscheduler(task); 3021 3032 if (ret) 3022 3033 goto out_unlock;
+1 -1
kernel/futex/core.c
··· 342 342 if (!vma) 343 343 return FUTEX_NO_NODE; 344 344 345 - mpol = vma_policy(vma); 345 + mpol = READ_ONCE(vma->vm_policy); 346 346 if (!mpol) 347 347 return FUTEX_NO_NODE; 348 348
+2 -1
kernel/futex/pi.c
··· 918 918 int futex_lock_pi(u32 __user *uaddr, unsigned int flags, ktime_t *time, int trylock) 919 919 { 920 920 struct hrtimer_sleeper timeout, *to; 921 - struct task_struct *exiting = NULL; 921 + struct task_struct *exiting; 922 922 struct rt_mutex_waiter rt_waiter; 923 923 struct futex_q q = futex_q_init; 924 924 DEFINE_WAKE_Q(wake_q); ··· 933 933 to = futex_setup_timer(time, &timeout, flags, 0); 934 934 935 935 retry: 936 + exiting = NULL; 936 937 ret = get_futex_key(uaddr, flags, &q.key, FUTEX_WRITE); 937 938 if (unlikely(ret != 0)) 938 939 goto out;
+8
kernel/futex/syscalls.c
··· 459 459 if (ret) 460 460 return ret; 461 461 462 + /* 463 + * For now mandate both flags are identical, like the sys_futex() 464 + * interface has. If/when we merge the variable sized futex support, 465 + * that patch can modify this test to allow a difference in size. 466 + */ 467 + if (futexes[0].w.flags != futexes[1].w.flags) 468 + return -EINVAL; 469 + 462 470 cmpval = futexes[0].w.val; 463 471 464 472 return futex_requeue(u64_to_user_ptr(futexes[0].w.uaddr), futexes[0].w.flags,
+1 -1
kernel/power/main.c
··· 40 40 { 41 41 WARN_ON(!mutex_is_locked(&system_transition_mutex)); 42 42 43 - if (WARN_ON(!saved_gfp_count) || --saved_gfp_count) 43 + if (!saved_gfp_count || --saved_gfp_count) 44 44 return; 45 45 46 46 gfp_allowed_mask = saved_gfp_mask;
+11
kernel/power/snapshot.c
··· 2855 2855 { 2856 2856 int error; 2857 2857 2858 + /* 2859 + * Call snapshot_write_next() to drain any trailing zero pages, 2860 + * but make sure we're in the data page region first. 2861 + * This function can return PAGE_SIZE if the kernel was expecting 2862 + * another copy page. Return -ENODATA in that situation. 2863 + */ 2864 + if (handle->cur > nr_meta_pages + 1) { 2865 + error = snapshot_write_next(handle); 2866 + if (error) 2867 + return error > 0 ? -ENODATA : error; 2868 + } 2858 2869 copy_last_highmem_page(); 2859 2870 error = hibernate_restore_protect_page(handle->buffer); 2860 2871 /* Do that only if we have loaded the image entirely */
+70 -25
kernel/sched/ext.c
··· 2404 2404 { 2405 2405 struct scx_sched *sch = scx_root; 2406 2406 2407 - /* see kick_cpus_irq_workfn() */ 2407 + /* see kick_sync_wait_bal_cb() */ 2408 2408 smp_store_release(&rq->scx.kick_sync, rq->scx.kick_sync + 1); 2409 2409 2410 2410 update_curr_scx(rq); ··· 2447 2447 switch_class(rq, next); 2448 2448 } 2449 2449 2450 + static void kick_sync_wait_bal_cb(struct rq *rq) 2451 + { 2452 + struct scx_kick_syncs __rcu *ks = __this_cpu_read(scx_kick_syncs); 2453 + unsigned long *ksyncs = rcu_dereference_sched(ks)->syncs; 2454 + bool waited; 2455 + s32 cpu; 2456 + 2457 + /* 2458 + * Drop rq lock and enable IRQs while waiting. IRQs must be enabled 2459 + * — a target CPU may be waiting for us to process an IPI (e.g. TLB 2460 + * flush) while we wait for its kick_sync to advance. 2461 + * 2462 + * Also, keep advancing our own kick_sync so that new kick_sync waits 2463 + * targeting us, which can start after we drop the lock, cannot form 2464 + * cyclic dependencies. 2465 + */ 2466 + retry: 2467 + waited = false; 2468 + for_each_cpu(cpu, rq->scx.cpus_to_sync) { 2469 + /* 2470 + * smp_load_acquire() pairs with smp_store_release() on 2471 + * kick_sync updates on the target CPUs. 2472 + */ 2473 + if (cpu == cpu_of(rq) || 2474 + smp_load_acquire(&cpu_rq(cpu)->scx.kick_sync) != ksyncs[cpu]) { 2475 + cpumask_clear_cpu(cpu, rq->scx.cpus_to_sync); 2476 + continue; 2477 + } 2478 + 2479 + raw_spin_rq_unlock_irq(rq); 2480 + while (READ_ONCE(cpu_rq(cpu)->scx.kick_sync) == ksyncs[cpu]) { 2481 + smp_store_release(&rq->scx.kick_sync, rq->scx.kick_sync + 1); 2482 + cpu_relax(); 2483 + } 2484 + raw_spin_rq_lock_irq(rq); 2485 + waited = true; 2486 + } 2487 + 2488 + if (waited) 2489 + goto retry; 2490 + } 2491 + 2450 2492 static struct task_struct *first_local_task(struct rq *rq) 2451 2493 { 2452 2494 return list_first_entry_or_null(&rq->scx.local_dsq.list, ··· 2502 2460 bool keep_prev; 2503 2461 struct task_struct *p; 2504 2462 2505 - /* see kick_cpus_irq_workfn() */ 2463 + /* see kick_sync_wait_bal_cb() */ 2506 2464 smp_store_release(&rq->scx.kick_sync, rq->scx.kick_sync + 1); 2507 2465 2508 2466 rq_modified_begin(rq, &ext_sched_class); ··· 2511 2469 balance_one(rq, prev); 2512 2470 rq_repin_lock(rq, rf); 2513 2471 maybe_queue_balance_callback(rq); 2472 + 2473 + /* 2474 + * Defer to a balance callback which can drop rq lock and enable 2475 + * IRQs. Waiting directly in the pick path would deadlock against 2476 + * CPUs sending us IPIs (e.g. TLB flushes) while we wait for them. 2477 + */ 2478 + if (unlikely(rq->scx.kick_sync_pending)) { 2479 + rq->scx.kick_sync_pending = false; 2480 + queue_balance_callback(rq, &rq->scx.kick_sync_bal_cb, 2481 + kick_sync_wait_bal_cb); 2482 + } 2514 2483 2515 2484 /* 2516 2485 * If any higher-priority sched class enqueued a runnable task on ··· 4766 4713 if (!cpumask_empty(rq->scx.cpus_to_wait)) 4767 4714 dump_line(&ns, " cpus_to_wait : %*pb", 4768 4715 cpumask_pr_args(rq->scx.cpus_to_wait)); 4716 + if (!cpumask_empty(rq->scx.cpus_to_sync)) 4717 + dump_line(&ns, " cpus_to_sync : %*pb", 4718 + cpumask_pr_args(rq->scx.cpus_to_sync)); 4769 4719 4770 4720 used = seq_buf_used(&ns); 4771 4721 if (SCX_HAS_OP(sch, dump_cpu)) { ··· 5666 5610 5667 5611 if (cpumask_test_cpu(cpu, this_scx->cpus_to_wait)) { 5668 5612 if (cur_class == &ext_sched_class) { 5613 + cpumask_set_cpu(cpu, this_scx->cpus_to_sync); 5669 5614 ksyncs[cpu] = rq->scx.kick_sync; 5670 5615 should_wait = true; 5671 - } else { 5672 - cpumask_clear_cpu(cpu, this_scx->cpus_to_wait); 5673 5616 } 5617 + cpumask_clear_cpu(cpu, this_scx->cpus_to_wait); 5674 5618 } 5675 5619 5676 5620 resched_curr(rq); ··· 5725 5669 cpumask_clear_cpu(cpu, this_scx->cpus_to_kick_if_idle); 5726 5670 } 5727 5671 5728 - if (!should_wait) 5729 - return; 5730 - 5731 - for_each_cpu(cpu, this_scx->cpus_to_wait) { 5732 - unsigned long *wait_kick_sync = &cpu_rq(cpu)->scx.kick_sync; 5733 - 5734 - /* 5735 - * Busy-wait until the task running at the time of kicking is no 5736 - * longer running. This can be used to implement e.g. core 5737 - * scheduling. 5738 - * 5739 - * smp_cond_load_acquire() pairs with store_releases in 5740 - * pick_task_scx() and put_prev_task_scx(). The former breaks 5741 - * the wait if SCX's scheduling path is entered even if the same 5742 - * task is picked subsequently. The latter is necessary to break 5743 - * the wait when $cpu is taken by a higher sched class. 5744 - */ 5745 - if (cpu != cpu_of(this_rq)) 5746 - smp_cond_load_acquire(wait_kick_sync, VAL != ksyncs[cpu]); 5747 - 5748 - cpumask_clear_cpu(cpu, this_scx->cpus_to_wait); 5672 + /* 5673 + * Can't wait in hardirq — kick_sync can't advance, deadlocking if 5674 + * CPUs wait for each other. Defer to kick_sync_wait_bal_cb(). 5675 + */ 5676 + if (should_wait) { 5677 + raw_spin_rq_lock(this_rq); 5678 + this_scx->kick_sync_pending = true; 5679 + resched_curr(this_rq); 5680 + raw_spin_rq_unlock(this_rq); 5749 5681 } 5750 5682 } 5751 5683 ··· 5838 5794 BUG_ON(!zalloc_cpumask_var_node(&rq->scx.cpus_to_kick_if_idle, GFP_KERNEL, n)); 5839 5795 BUG_ON(!zalloc_cpumask_var_node(&rq->scx.cpus_to_preempt, GFP_KERNEL, n)); 5840 5796 BUG_ON(!zalloc_cpumask_var_node(&rq->scx.cpus_to_wait, GFP_KERNEL, n)); 5797 + BUG_ON(!zalloc_cpumask_var_node(&rq->scx.cpus_to_sync, GFP_KERNEL, n)); 5841 5798 rq->scx.deferred_irq_work = IRQ_WORK_INIT_HARD(deferred_irq_workfn); 5842 5799 rq->scx.kick_cpus_irq_work = IRQ_WORK_INIT_HARD(kick_cpus_irq_workfn); 5843 5800
+1 -1
kernel/sched/ext_idle.c
··· 543 543 * piled up on it even if there is an idle core elsewhere on 544 544 * the system. 545 545 */ 546 - waker_node = cpu_to_node(cpu); 546 + waker_node = scx_cpu_node_if_enabled(cpu); 547 547 if (!(current->flags & PF_EXITING) && 548 548 cpu_rq(cpu)->scx.local_dsq.nr == 0 && 549 549 (!(flags & SCX_PICK_IDLE_IN_NODE) || (waker_node == node)) &&
+3
kernel/sched/sched.h
··· 805 805 cpumask_var_t cpus_to_kick_if_idle; 806 806 cpumask_var_t cpus_to_preempt; 807 807 cpumask_var_t cpus_to_wait; 808 + cpumask_var_t cpus_to_sync; 809 + bool kick_sync_pending; 808 810 unsigned long kick_sync; 809 811 local_t reenq_local_deferred; 810 812 struct balance_callback deferred_bal_cb; 813 + struct balance_callback kick_sync_bal_cb; 811 814 struct irq_work deferred_irq_work; 812 815 struct irq_work kick_cpus_irq_work; 813 816 struct scx_dispatch_q bypass_dsq;
+1 -1
kernel/sysctl.c
··· 1118 1118 unsigned long bitmap_len = table->maxlen; 1119 1119 unsigned long *bitmap = *(unsigned long **) table->data; 1120 1120 unsigned long *tmp_bitmap = NULL; 1121 - char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c; 1121 + char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c = 0; 1122 1122 1123 1123 if (!bitmap || !bitmap_len || !left || (*ppos && SYSCTL_KERN_TO_USER(dir))) { 1124 1124 *lenp = 0;
+1 -1
kernel/time/alarmtimer.c
··· 540 540 { 541 541 struct alarm *alarm = &timr->it.alarm.alarmtimer; 542 542 543 - return alarm_forward(alarm, timr->it_interval, now); 543 + return alarm_forward(alarm, now, timr->it_interval); 544 544 } 545 545 546 546 /**
+69 -16
kernel/trace/trace_events_trigger.c
··· 22 22 static struct llist_head trigger_data_free_list; 23 23 static DEFINE_MUTEX(trigger_data_kthread_mutex); 24 24 25 + static int trigger_kthread_fn(void *ignore); 26 + 27 + static void trigger_create_kthread_locked(void) 28 + { 29 + lockdep_assert_held(&trigger_data_kthread_mutex); 30 + 31 + if (!trigger_kthread) { 32 + struct task_struct *kthread; 33 + 34 + kthread = kthread_create(trigger_kthread_fn, NULL, 35 + "trigger_data_free"); 36 + if (!IS_ERR(kthread)) 37 + WRITE_ONCE(trigger_kthread, kthread); 38 + } 39 + } 40 + 41 + static void trigger_data_free_queued_locked(void) 42 + { 43 + struct event_trigger_data *data, *tmp; 44 + struct llist_node *llnodes; 45 + 46 + lockdep_assert_held(&trigger_data_kthread_mutex); 47 + 48 + llnodes = llist_del_all(&trigger_data_free_list); 49 + if (!llnodes) 50 + return; 51 + 52 + tracepoint_synchronize_unregister(); 53 + 54 + llist_for_each_entry_safe(data, tmp, llnodes, llist) 55 + kfree(data); 56 + } 57 + 25 58 /* Bulk garbage collection of event_trigger_data elements */ 26 59 static int trigger_kthread_fn(void *ignore) 27 60 { ··· 89 56 if (data->cmd_ops->set_filter) 90 57 data->cmd_ops->set_filter(NULL, data, NULL); 91 58 92 - if (unlikely(!trigger_kthread)) { 93 - guard(mutex)(&trigger_data_kthread_mutex); 94 - /* Check again after taking mutex */ 95 - if (!trigger_kthread) { 96 - struct task_struct *kthread; 97 - 98 - kthread = kthread_create(trigger_kthread_fn, NULL, 99 - "trigger_data_free"); 100 - if (!IS_ERR(kthread)) 101 - WRITE_ONCE(trigger_kthread, kthread); 102 - } 59 + /* 60 + * Boot-time trigger registration can fail before kthread creation 61 + * works. Keep the deferred-free semantics during boot and let late 62 + * init start the kthread to drain the list. 63 + */ 64 + if (system_state == SYSTEM_BOOTING && !trigger_kthread) { 65 + llist_add(&data->llist, &trigger_data_free_list); 66 + return; 103 67 } 104 68 105 - if (!trigger_kthread) { 106 - /* Do it the slow way */ 107 - tracepoint_synchronize_unregister(); 108 - kfree(data); 109 - return; 69 + if (unlikely(!trigger_kthread)) { 70 + guard(mutex)(&trigger_data_kthread_mutex); 71 + 72 + trigger_create_kthread_locked(); 73 + /* Check again after taking mutex */ 74 + if (!trigger_kthread) { 75 + llist_add(&data->llist, &trigger_data_free_list); 76 + /* Drain the queued frees synchronously if creation failed. */ 77 + trigger_data_free_queued_locked(); 78 + return; 79 + } 110 80 } 111 81 112 82 llist_add(&data->llist, &trigger_data_free_list); 113 83 wake_up_process(trigger_kthread); 114 84 } 85 + 86 + static int __init trigger_data_free_init(void) 87 + { 88 + guard(mutex)(&trigger_data_kthread_mutex); 89 + 90 + if (llist_empty(&trigger_data_free_list)) 91 + return 0; 92 + 93 + trigger_create_kthread_locked(); 94 + if (trigger_kthread) 95 + wake_up_process(trigger_kthread); 96 + else 97 + trigger_data_free_queued_locked(); 98 + 99 + return 0; 100 + } 101 + late_initcall(trigger_data_free_init); 115 102 116 103 static inline void data_ops_trigger(struct event_trigger_data *data, 117 104 struct trace_buffer *buffer, void *rec,
+5 -5
kernel/trace/trace_osnoise.c
··· 2073 2073 if (!osnoise_has_registered_instances()) 2074 2074 return; 2075 2075 2076 - guard(mutex)(&interface_lock); 2077 2076 guard(cpus_read_lock)(); 2077 + guard(mutex)(&interface_lock); 2078 2078 2079 2079 if (!cpu_online(cpu)) 2080 2080 return; ··· 2237 2237 if (running) 2238 2238 stop_per_cpu_kthreads(); 2239 2239 2240 - mutex_lock(&interface_lock); 2241 2240 /* 2242 2241 * avoid CPU hotplug operations that might read options. 2243 2242 */ 2244 2243 cpus_read_lock(); 2244 + mutex_lock(&interface_lock); 2245 2245 2246 2246 retval = cnt; 2247 2247 ··· 2257 2257 clear_bit(option, &osnoise_options); 2258 2258 } 2259 2259 2260 - cpus_read_unlock(); 2261 2260 mutex_unlock(&interface_lock); 2261 + cpus_read_unlock(); 2262 2262 2263 2263 if (running) 2264 2264 start_per_cpu_kthreads(); ··· 2345 2345 if (running) 2346 2346 stop_per_cpu_kthreads(); 2347 2347 2348 - mutex_lock(&interface_lock); 2349 2348 /* 2350 2349 * osnoise_cpumask is read by CPU hotplug operations. 2351 2350 */ 2352 2351 cpus_read_lock(); 2352 + mutex_lock(&interface_lock); 2353 2353 2354 2354 cpumask_copy(&osnoise_cpumask, osnoise_cpumask_new); 2355 2355 2356 - cpus_read_unlock(); 2357 2356 mutex_unlock(&interface_lock); 2357 + cpus_read_unlock(); 2358 2358 2359 2359 if (running) 2360 2360 start_per_cpu_kthreads();
+22 -3
kernel/workqueue.c
··· 7699 7699 else 7700 7700 ts = touched; 7701 7701 7702 - /* did we stall? */ 7702 + /* 7703 + * Did we stall? 7704 + * 7705 + * Do a lockless check first to do not disturb the system. 7706 + * 7707 + * Prevent false positives by double checking the timestamp 7708 + * under pool->lock. The lock makes sure that the check reads 7709 + * an updated pool->last_progress_ts when this CPU saw 7710 + * an already updated pool->worklist above. It seems better 7711 + * than adding another barrier into __queue_work() which 7712 + * is a hotter path. 7713 + */ 7703 7714 if (time_after(now, ts + thresh)) { 7715 + scoped_guard(raw_spinlock_irqsave, &pool->lock) { 7716 + pool_ts = pool->last_progress_ts; 7717 + if (time_after(pool_ts, touched)) 7718 + ts = pool_ts; 7719 + else 7720 + ts = touched; 7721 + } 7722 + if (!time_after(now, ts + thresh)) 7723 + continue; 7724 + 7704 7725 lockup_detected = true; 7705 7726 stall_time = jiffies_to_msecs(now - pool_ts) / 1000; 7706 7727 max_stall_time = max(max_stall_time, stall_time); ··· 7733 7712 pr_cont_pool_info(pool); 7734 7713 pr_cont(" stuck for %us!\n", stall_time); 7735 7714 } 7736 - 7737 - 7738 7715 } 7739 7716 7740 7717 if (lockup_detected)
+2 -5
lib/bug.c
··· 173 173 return module_find_bug(bugaddr); 174 174 } 175 175 176 - __diag_push(); 177 - __diag_ignore(GCC, all, "-Wsuggest-attribute=format", 178 - "Not a valid __printf() conversion candidate."); 179 - static void __warn_printf(const char *fmt, struct pt_regs *regs) 176 + static __printf(1, 0) 177 + void __warn_printf(const char *fmt, struct pt_regs *regs) 180 178 { 181 179 if (!fmt) 182 180 return; ··· 193 195 194 196 printk("%s", fmt); 195 197 } 196 - __diag_pop(); 197 198 198 199 static enum bug_trap_type __report_bug(struct bug_entry *bug, unsigned long bugaddr, struct pt_regs *regs) 199 200 {
+4
lib/crypto/chacha-block-generic.c
··· 87 87 &out[i * sizeof(u32)]); 88 88 89 89 state->x[12]++; 90 + 91 + chacha_zeroize_state(&permuted_state); 90 92 } 91 93 EXPORT_SYMBOL(chacha_block_generic); 92 94 ··· 112 110 113 111 memcpy(&out[0], &permuted_state.x[0], 16); 114 112 memcpy(&out[4], &permuted_state.x[12], 16); 113 + 114 + chacha_zeroize_state(&permuted_state); 115 115 } 116 116 EXPORT_SYMBOL(hchacha_block_generic);
+9 -1
mm/damon/sysfs.c
··· 1524 1524 if (IS_ERR(param_ctx)) 1525 1525 return PTR_ERR(param_ctx); 1526 1526 test_ctx = damon_sysfs_new_test_ctx(kdamond->damon_ctx); 1527 - if (!test_ctx) 1527 + if (!test_ctx) { 1528 + damon_destroy_ctx(param_ctx); 1528 1529 return -ENOMEM; 1530 + } 1529 1531 err = damon_commit_ctx(test_ctx, param_ctx); 1530 1532 if (err) 1531 1533 goto out; ··· 1620 1618 1621 1619 if (!mutex_trylock(&damon_sysfs_lock)) 1622 1620 return 0; 1621 + if (sysfs_kdamond->contexts->nr != 1) 1622 + goto out; 1623 1623 damon_sysfs_upd_tuned_intervals(sysfs_kdamond); 1624 1624 damon_sysfs_upd_schemes_stats(sysfs_kdamond); 1625 1625 damon_sysfs_upd_schemes_effective_quotas(sysfs_kdamond); 1626 + out: 1626 1627 mutex_unlock(&damon_sysfs_lock); 1627 1628 return 0; 1628 1629 } ··· 1752 1747 static int damon_sysfs_handle_cmd(enum damon_sysfs_cmd cmd, 1753 1748 struct damon_sysfs_kdamond *kdamond) 1754 1749 { 1750 + if (cmd != DAMON_SYSFS_CMD_OFF && kdamond->contexts->nr != 1) 1751 + return -EINVAL; 1752 + 1755 1753 switch (cmd) { 1756 1754 case DAMON_SYSFS_CMD_ON: 1757 1755 return damon_sysfs_turn_damon_on(kdamond);
+15 -3
mm/memory.c
··· 6815 6815 6816 6816 pudp = pud_offset(p4dp, address); 6817 6817 pud = pudp_get(pudp); 6818 - if (pud_none(pud)) 6818 + if (!pud_present(pud)) 6819 6819 goto out; 6820 6820 if (pud_leaf(pud)) { 6821 6821 lock = pud_lock(mm, pudp); 6822 - if (!unlikely(pud_leaf(pud))) { 6822 + pud = pudp_get(pudp); 6823 + 6824 + if (unlikely(!pud_present(pud))) { 6825 + spin_unlock(lock); 6826 + goto out; 6827 + } else if (unlikely(!pud_leaf(pud))) { 6823 6828 spin_unlock(lock); 6824 6829 goto retry; 6825 6830 } ··· 6836 6831 6837 6832 pmdp = pmd_offset(pudp, address); 6838 6833 pmd = pmdp_get_lockless(pmdp); 6834 + if (!pmd_present(pmd)) 6835 + goto out; 6839 6836 if (pmd_leaf(pmd)) { 6840 6837 lock = pmd_lock(mm, pmdp); 6841 - if (!unlikely(pmd_leaf(pmd))) { 6838 + pmd = pmdp_get(pmdp); 6839 + 6840 + if (unlikely(!pmd_present(pmd))) { 6841 + spin_unlock(lock); 6842 + goto out; 6843 + } else if (unlikely(!pmd_leaf(pmd))) { 6842 6844 spin_unlock(lock); 6843 6845 goto retry; 6844 6846 }
+8 -2
mm/mempolicy.c
··· 487 487 { 488 488 if (!atomic_dec_and_test(&pol->refcnt)) 489 489 return; 490 - kmem_cache_free(policy_cache, pol); 490 + /* 491 + * Required to allow mmap_lock_speculative*() access, see for example 492 + * futex_key_to_node_opt(). All accesses are serialized by mmap_lock, 493 + * however the speculative lock section unbound by the normal lock 494 + * boundaries, requiring RCU freeing. 495 + */ 496 + kfree_rcu(pol, rcu); 491 497 } 492 498 EXPORT_SYMBOL_FOR_MODULES(__mpol_put, "kvm"); 493 499 ··· 1026 1020 } 1027 1021 1028 1022 old = vma->vm_policy; 1029 - vma->vm_policy = new; /* protected by mmap_lock */ 1023 + WRITE_ONCE(vma->vm_policy, new); /* protected by mmap_lock */ 1030 1024 mpol_put(old); 1031 1025 1032 1026 return 0;
+1 -2
mm/mseal.c
··· 56 56 unsigned long start, unsigned long end) 57 57 { 58 58 struct vm_area_struct *vma, *prev; 59 - unsigned long curr_start = start; 60 59 VMA_ITERATOR(vmi, mm, start); 61 60 62 61 /* We know there are no gaps so this will be non-NULL. */ ··· 65 66 prev = vma; 66 67 67 68 for_each_vma_range(vmi, vma, end) { 69 + const unsigned long curr_start = MAX(vma->vm_start, start); 68 70 const unsigned long curr_end = MIN(vma->vm_end, end); 69 71 70 72 if (!(vma->vm_flags & VM_SEALED)) { ··· 79 79 } 80 80 81 81 prev = vma; 82 - curr_start = curr_end; 83 82 } 84 83 85 84 return 0;
+22 -3
mm/pagewalk.c
··· 97 97 static int walk_pmd_range(pud_t *pud, unsigned long addr, unsigned long end, 98 98 struct mm_walk *walk) 99 99 { 100 + pud_t pudval = pudp_get(pud); 100 101 pmd_t *pmd; 101 102 unsigned long next; 102 103 const struct mm_walk_ops *ops = walk->ops; ··· 105 104 bool has_install = ops->install_pte; 106 105 int err = 0; 107 106 int depth = real_depth(3); 107 + 108 + /* 109 + * For PTE handling, pte_offset_map_lock() takes care of checking 110 + * whether there actually is a page table. But it also has to be 111 + * very careful about concurrent page table reclaim. 112 + * 113 + * Similarly, we have to be careful here - a PUD entry that points 114 + * to a PMD table cannot go away, so we can just walk it. But if 115 + * it's something else, we need to ensure we didn't race something, 116 + * so need to retry. 117 + * 118 + * A pertinent example of this is a PUD refault after PUD split - 119 + * we will need to split again or risk accessing invalid memory. 120 + */ 121 + if (!pud_present(pudval) || pud_leaf(pudval)) { 122 + walk->action = ACTION_AGAIN; 123 + return 0; 124 + } 108 125 109 126 pmd = pmd_offset(pud, addr); 110 127 do { ··· 237 218 else if (pud_leaf(*pud) || !pud_present(*pud)) 238 219 continue; /* Nothing to do. */ 239 220 240 - if (pud_none(*pud)) 241 - goto again; 242 - 243 221 err = walk_pmd_range(pud, addr, next, walk); 244 222 if (err) 245 223 break; 224 + 225 + if (walk->action == ACTION_AGAIN) 226 + goto again; 246 227 } while (pud++, addr = next, addr != end); 247 228 248 229 return err;
+4 -5
mm/swap_state.c
··· 494 494 495 495 __folio_set_locked(folio); 496 496 __folio_set_swapbacked(folio); 497 + 498 + if (!charged && mem_cgroup_swapin_charge_folio(folio, NULL, gfp, entry)) 499 + goto failed; 500 + 497 501 for (;;) { 498 502 ret = swap_cache_add_folio(folio, entry, &shadow); 499 503 if (!ret) ··· 516 512 swapcache = swap_cache_get_folio(entry); 517 513 if (swapcache) 518 514 goto failed; 519 - } 520 - 521 - if (!charged && mem_cgroup_swapin_charge_folio(folio, NULL, gfp, entry)) { 522 - swap_cache_del_folio(folio); 523 - goto failed; 524 515 } 525 516 526 517 memcg1_swapin(entry, folio_nr_pages(folio));
+7 -1
net/bluetooth/hci_conn.c
··· 1843 1843 u8 aux_num_cis = 0; 1844 1844 u8 cis_id; 1845 1845 1846 + hci_dev_lock(hdev); 1847 + 1846 1848 conn = hci_conn_hash_lookup_cig(hdev, cig_id); 1847 - if (!conn) 1849 + if (!conn) { 1850 + hci_dev_unlock(hdev); 1848 1851 return 0; 1852 + } 1849 1853 1850 1854 qos = &conn->iso_qos; 1851 1855 pdu->cig_id = cig_id; ··· 1887 1883 cis->p_rtn = qos->ucast.in.rtn; 1888 1884 } 1889 1885 pdu->num_cis = aux_num_cis; 1886 + 1887 + hci_dev_unlock(hdev); 1890 1888 1891 1889 if (!pdu->num_cis) 1892 1890 return 0;
+55 -72
net/bluetooth/hci_event.c
··· 80 80 return data; 81 81 } 82 82 83 + static void hci_store_wake_reason(struct hci_dev *hdev, 84 + const bdaddr_t *bdaddr, u8 addr_type) 85 + __must_hold(&hdev->lock); 86 + 83 87 static u8 hci_cc_inquiry_cancel(struct hci_dev *hdev, void *data, 84 88 struct sk_buff *skb) 85 89 { ··· 3115 3111 bt_dev_dbg(hdev, "status 0x%2.2x", status); 3116 3112 3117 3113 hci_dev_lock(hdev); 3114 + hci_store_wake_reason(hdev, &ev->bdaddr, BDADDR_BREDR); 3118 3115 3119 3116 /* Check for existing connection: 3120 3117 * ··· 3278 3273 __u8 flags = 0; 3279 3274 3280 3275 bt_dev_dbg(hdev, "bdaddr %pMR type 0x%x", &ev->bdaddr, ev->link_type); 3276 + 3277 + hci_dev_lock(hdev); 3278 + hci_store_wake_reason(hdev, &ev->bdaddr, BDADDR_BREDR); 3279 + hci_dev_unlock(hdev); 3281 3280 3282 3281 /* Reject incoming connection from device with same BD ADDR against 3283 3282 * CVE-2020-26555 ··· 5030 5021 bt_dev_dbg(hdev, "status 0x%2.2x", status); 5031 5022 5032 5023 hci_dev_lock(hdev); 5024 + hci_store_wake_reason(hdev, &ev->bdaddr, BDADDR_BREDR); 5033 5025 5034 5026 conn = hci_conn_hash_lookup_ba(hdev, ev->link_type, &ev->bdaddr); 5035 5027 if (!conn) { ··· 5723 5713 int err; 5724 5714 5725 5715 hci_dev_lock(hdev); 5716 + hci_store_wake_reason(hdev, bdaddr, bdaddr_type); 5726 5717 5727 5718 /* All controllers implicitly stop advertising in the event of a 5728 5719 * connection, so ensure that the state bit is cleared. ··· 6016 6005 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); 6017 6006 6018 6007 hci_dev_lock(hdev); 6008 + hci_store_wake_reason(hdev, &ev->bdaddr, ev->bdaddr_type); 6019 6009 6020 6010 hci_dev_clear_flag(hdev, HCI_PA_SYNC); 6021 6011 ··· 6415 6403 info->length + 1)) 6416 6404 break; 6417 6405 6406 + hci_store_wake_reason(hdev, &info->bdaddr, info->bdaddr_type); 6407 + 6418 6408 if (info->length <= max_adv_len(hdev)) { 6419 6409 rssi = info->data[info->length]; 6420 6410 process_adv_report(hdev, info->type, &info->bdaddr, ··· 6505 6491 info->length)) 6506 6492 break; 6507 6493 6494 + hci_store_wake_reason(hdev, &info->bdaddr, info->bdaddr_type); 6495 + 6508 6496 evt_type = __le16_to_cpu(info->type) & LE_EXT_ADV_EVT_TYPE_MASK; 6509 6497 legacy_evt_type = ext_evt_type_to_legacy(hdev, evt_type); 6510 6498 ··· 6552 6536 bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); 6553 6537 6554 6538 hci_dev_lock(hdev); 6539 + hci_store_wake_reason(hdev, &ev->bdaddr, ev->bdaddr_type); 6555 6540 6556 6541 hci_dev_clear_flag(hdev, HCI_PA_SYNC); 6557 6542 ··· 6784 6767 latency = le16_to_cpu(ev->latency); 6785 6768 timeout = le16_to_cpu(ev->timeout); 6786 6769 6770 + hci_dev_lock(hdev); 6771 + 6787 6772 hcon = hci_conn_hash_lookup_handle(hdev, handle); 6788 - if (!hcon || hcon->state != BT_CONNECTED) 6789 - return send_conn_param_neg_reply(hdev, handle, 6790 - HCI_ERROR_UNKNOWN_CONN_ID); 6773 + if (!hcon || hcon->state != BT_CONNECTED) { 6774 + send_conn_param_neg_reply(hdev, handle, 6775 + HCI_ERROR_UNKNOWN_CONN_ID); 6776 + goto unlock; 6777 + } 6791 6778 6792 - if (max > hcon->le_conn_max_interval) 6793 - return send_conn_param_neg_reply(hdev, handle, 6794 - HCI_ERROR_INVALID_LL_PARAMS); 6779 + if (max > hcon->le_conn_max_interval) { 6780 + send_conn_param_neg_reply(hdev, handle, 6781 + HCI_ERROR_INVALID_LL_PARAMS); 6782 + goto unlock; 6783 + } 6795 6784 6796 - if (hci_check_conn_params(min, max, latency, timeout)) 6797 - return send_conn_param_neg_reply(hdev, handle, 6798 - HCI_ERROR_INVALID_LL_PARAMS); 6785 + if (hci_check_conn_params(min, max, latency, timeout)) { 6786 + send_conn_param_neg_reply(hdev, handle, 6787 + HCI_ERROR_INVALID_LL_PARAMS); 6788 + goto unlock; 6789 + } 6799 6790 6800 6791 if (hcon->role == HCI_ROLE_MASTER) { 6801 6792 struct hci_conn_params *params; 6802 6793 u8 store_hint; 6803 - 6804 - hci_dev_lock(hdev); 6805 6794 6806 6795 params = hci_conn_params_lookup(hdev, &hcon->dst, 6807 6796 hcon->dst_type); ··· 6820 6797 } else { 6821 6798 store_hint = 0x00; 6822 6799 } 6823 - 6824 - hci_dev_unlock(hdev); 6825 6800 6826 6801 mgmt_new_conn_param(hdev, &hcon->dst, hcon->dst_type, 6827 6802 store_hint, min, max, latency, timeout); ··· 6834 6813 cp.max_ce_len = 0; 6835 6814 6836 6815 hci_send_cmd(hdev, HCI_OP_LE_CONN_PARAM_REQ_REPLY, sizeof(cp), &cp); 6816 + 6817 + unlock: 6818 + hci_dev_unlock(hdev); 6837 6819 } 6838 6820 6839 6821 static void hci_le_direct_adv_report_evt(struct hci_dev *hdev, void *data, ··· 6857 6833 6858 6834 for (i = 0; i < ev->num; i++) { 6859 6835 struct hci_ev_le_direct_adv_info *info = &ev->info[i]; 6836 + 6837 + hci_store_wake_reason(hdev, &info->bdaddr, info->bdaddr_type); 6860 6838 6861 6839 process_adv_report(hdev, info->type, &info->bdaddr, 6862 6840 info->bdaddr_type, &info->direct_addr, ··· 7543 7517 return true; 7544 7518 } 7545 7519 7546 - static void hci_store_wake_reason(struct hci_dev *hdev, u8 event, 7547 - struct sk_buff *skb) 7520 + static void hci_store_wake_reason(struct hci_dev *hdev, 7521 + const bdaddr_t *bdaddr, u8 addr_type) 7522 + __must_hold(&hdev->lock) 7548 7523 { 7549 - struct hci_ev_le_advertising_info *adv; 7550 - struct hci_ev_le_direct_adv_info *direct_adv; 7551 - struct hci_ev_le_ext_adv_info *ext_adv; 7552 - const struct hci_ev_conn_complete *conn_complete = (void *)skb->data; 7553 - const struct hci_ev_conn_request *conn_request = (void *)skb->data; 7554 - 7555 - hci_dev_lock(hdev); 7524 + lockdep_assert_held(&hdev->lock); 7556 7525 7557 7526 /* If we are currently suspended and this is the first BT event seen, 7558 7527 * save the wake reason associated with the event. 7559 7528 */ 7560 7529 if (!hdev->suspended || hdev->wake_reason) 7561 - goto unlock; 7530 + return; 7531 + 7532 + if (!bdaddr) { 7533 + hdev->wake_reason = MGMT_WAKE_REASON_UNEXPECTED; 7534 + return; 7535 + } 7562 7536 7563 7537 /* Default to remote wake. Values for wake_reason are documented in the 7564 7538 * Bluez mgmt api docs. 7565 7539 */ 7566 7540 hdev->wake_reason = MGMT_WAKE_REASON_REMOTE_WAKE; 7567 - 7568 - /* Once configured for remote wakeup, we should only wake up for 7569 - * reconnections. It's useful to see which device is waking us up so 7570 - * keep track of the bdaddr of the connection event that woke us up. 7571 - */ 7572 - if (event == HCI_EV_CONN_REQUEST) { 7573 - bacpy(&hdev->wake_addr, &conn_request->bdaddr); 7574 - hdev->wake_addr_type = BDADDR_BREDR; 7575 - } else if (event == HCI_EV_CONN_COMPLETE) { 7576 - bacpy(&hdev->wake_addr, &conn_complete->bdaddr); 7577 - hdev->wake_addr_type = BDADDR_BREDR; 7578 - } else if (event == HCI_EV_LE_META) { 7579 - struct hci_ev_le_meta *le_ev = (void *)skb->data; 7580 - u8 subevent = le_ev->subevent; 7581 - u8 *ptr = &skb->data[sizeof(*le_ev)]; 7582 - u8 num_reports = *ptr; 7583 - 7584 - if ((subevent == HCI_EV_LE_ADVERTISING_REPORT || 7585 - subevent == HCI_EV_LE_DIRECT_ADV_REPORT || 7586 - subevent == HCI_EV_LE_EXT_ADV_REPORT) && 7587 - num_reports) { 7588 - adv = (void *)(ptr + 1); 7589 - direct_adv = (void *)(ptr + 1); 7590 - ext_adv = (void *)(ptr + 1); 7591 - 7592 - switch (subevent) { 7593 - case HCI_EV_LE_ADVERTISING_REPORT: 7594 - bacpy(&hdev->wake_addr, &adv->bdaddr); 7595 - hdev->wake_addr_type = adv->bdaddr_type; 7596 - break; 7597 - case HCI_EV_LE_DIRECT_ADV_REPORT: 7598 - bacpy(&hdev->wake_addr, &direct_adv->bdaddr); 7599 - hdev->wake_addr_type = direct_adv->bdaddr_type; 7600 - break; 7601 - case HCI_EV_LE_EXT_ADV_REPORT: 7602 - bacpy(&hdev->wake_addr, &ext_adv->bdaddr); 7603 - hdev->wake_addr_type = ext_adv->bdaddr_type; 7604 - break; 7605 - } 7606 - } 7607 - } else { 7608 - hdev->wake_reason = MGMT_WAKE_REASON_UNEXPECTED; 7609 - } 7610 - 7611 - unlock: 7612 - hci_dev_unlock(hdev); 7541 + bacpy(&hdev->wake_addr, bdaddr); 7542 + hdev->wake_addr_type = addr_type; 7613 7543 } 7614 7544 7615 7545 #define HCI_EV_VL(_op, _func, _min_len, _max_len) \ ··· 7812 7830 7813 7831 skb_pull(skb, HCI_EVENT_HDR_SIZE); 7814 7832 7815 - /* Store wake reason if we're suspended */ 7816 - hci_store_wake_reason(hdev, event, skb); 7817 - 7818 7833 bt_dev_dbg(hdev, "event 0x%2.2x", event); 7819 7834 7820 7835 hci_event_func(hdev, event, skb, &opcode, &status, &req_complete, 7821 7836 &req_complete_skb); 7837 + 7838 + hci_dev_lock(hdev); 7839 + hci_store_wake_reason(hdev, NULL, 0); 7840 + hci_dev_unlock(hdev); 7822 7841 7823 7842 if (req_complete) { 7824 7843 req_complete(hdev, status, opcode);
+62 -26
net/bluetooth/hci_sync.c
··· 780 780 void *data, hci_cmd_sync_work_destroy_t destroy) 781 781 { 782 782 if (hci_cmd_sync_lookup_entry(hdev, func, data, destroy)) 783 - return 0; 783 + return -EEXIST; 784 784 785 785 return hci_cmd_sync_queue(hdev, func, data, destroy); 786 786 } ··· 801 801 return -ENETDOWN; 802 802 803 803 /* If on cmd_sync_work then run immediately otherwise queue */ 804 - if (current_work() == &hdev->cmd_sync_work) 805 - return func(hdev, data); 804 + if (current_work() == &hdev->cmd_sync_work) { 805 + int err; 806 + 807 + err = func(hdev, data); 808 + if (destroy) 809 + destroy(hdev, data, err); 810 + 811 + return 0; 812 + } 806 813 807 814 return hci_cmd_sync_submit(hdev, func, data, destroy); 808 815 } ··· 3262 3255 3263 3256 int hci_update_passive_scan(struct hci_dev *hdev) 3264 3257 { 3258 + int err; 3259 + 3265 3260 /* Only queue if it would have any effect */ 3266 3261 if (!test_bit(HCI_UP, &hdev->flags) || 3267 3262 test_bit(HCI_INIT, &hdev->flags) || ··· 3273 3264 hci_dev_test_flag(hdev, HCI_UNREGISTER)) 3274 3265 return 0; 3275 3266 3276 - return hci_cmd_sync_queue_once(hdev, update_passive_scan_sync, NULL, 3277 - NULL); 3267 + err = hci_cmd_sync_queue_once(hdev, update_passive_scan_sync, NULL, 3268 + NULL); 3269 + return (err == -EEXIST) ? 0 : err; 3278 3270 } 3279 3271 3280 3272 int hci_write_sc_support_sync(struct hci_dev *hdev, u8 val) ··· 6968 6958 6969 6959 int hci_connect_acl_sync(struct hci_dev *hdev, struct hci_conn *conn) 6970 6960 { 6971 - return hci_cmd_sync_queue_once(hdev, hci_acl_create_conn_sync, conn, 6972 - NULL); 6961 + int err; 6962 + 6963 + err = hci_cmd_sync_queue_once(hdev, hci_acl_create_conn_sync, conn, 6964 + NULL); 6965 + return (err == -EEXIST) ? 0 : err; 6973 6966 } 6974 6967 6975 6968 static void create_le_conn_complete(struct hci_dev *hdev, void *data, int err) ··· 7008 6995 7009 6996 int hci_connect_le_sync(struct hci_dev *hdev, struct hci_conn *conn) 7010 6997 { 7011 - return hci_cmd_sync_queue_once(hdev, hci_le_create_conn_sync, conn, 7012 - create_le_conn_complete); 6998 + int err; 6999 + 7000 + err = hci_cmd_sync_queue_once(hdev, hci_le_create_conn_sync, conn, 7001 + create_le_conn_complete); 7002 + return (err == -EEXIST) ? 0 : err; 7013 7003 } 7014 7004 7015 7005 int hci_cancel_connect_sync(struct hci_dev *hdev, struct hci_conn *conn) ··· 7219 7203 7220 7204 int hci_connect_pa_sync(struct hci_dev *hdev, struct hci_conn *conn) 7221 7205 { 7222 - return hci_cmd_sync_queue_once(hdev, hci_le_pa_create_sync, conn, 7223 - create_pa_complete); 7206 + int err; 7207 + 7208 + err = hci_cmd_sync_queue_once(hdev, hci_le_pa_create_sync, conn, 7209 + create_pa_complete); 7210 + return (err == -EEXIST) ? 0 : err; 7224 7211 } 7225 7212 7226 7213 static void create_big_complete(struct hci_dev *hdev, void *data, int err) ··· 7241 7222 7242 7223 static int hci_le_big_create_sync(struct hci_dev *hdev, void *data) 7243 7224 { 7244 - DEFINE_FLEX(struct hci_cp_le_big_create_sync, cp, bis, num_bis, 0x11); 7225 + DEFINE_FLEX(struct hci_cp_le_big_create_sync, cp, bis, num_bis, 7226 + HCI_MAX_ISO_BIS); 7245 7227 struct hci_conn *conn = data; 7246 7228 struct bt_iso_qos *qos = &conn->iso_qos; 7247 7229 int err; ··· 7286 7266 7287 7267 int hci_connect_big_sync(struct hci_dev *hdev, struct hci_conn *conn) 7288 7268 { 7289 - return hci_cmd_sync_queue_once(hdev, hci_le_big_create_sync, conn, 7290 - create_big_complete); 7269 + int err; 7270 + 7271 + err = hci_cmd_sync_queue_once(hdev, hci_le_big_create_sync, conn, 7272 + create_big_complete); 7273 + return (err == -EEXIST) ? 0 : err; 7291 7274 } 7292 7275 7293 7276 struct past_data { ··· 7382 7359 if (err) 7383 7360 kfree(data); 7384 7361 7385 - return err; 7362 + return (err == -EEXIST) ? 0 : err; 7386 7363 } 7387 7364 7388 7365 static void le_read_features_complete(struct hci_dev *hdev, void *data, int err) ··· 7391 7368 7392 7369 bt_dev_dbg(hdev, "err %d", err); 7393 7370 7394 - if (err == -ECANCELED) 7395 - return; 7396 - 7397 7371 hci_conn_drop(conn); 7372 + hci_conn_put(conn); 7398 7373 } 7399 7374 7400 7375 static int hci_le_read_all_remote_features_sync(struct hci_dev *hdev, ··· 7459 7438 * role is possible. Otherwise just transition into the 7460 7439 * connected state without requesting the remote features. 7461 7440 */ 7462 - if (conn->out || (hdev->le_features[0] & HCI_LE_PERIPHERAL_FEATURES)) 7441 + if (conn->out || (hdev->le_features[0] & HCI_LE_PERIPHERAL_FEATURES)) { 7463 7442 err = hci_cmd_sync_queue_once(hdev, 7464 7443 hci_le_read_remote_features_sync, 7465 - hci_conn_hold(conn), 7444 + hci_conn_hold(hci_conn_get(conn)), 7466 7445 le_read_features_complete); 7467 - else 7446 + if (err) { 7447 + hci_conn_drop(conn); 7448 + hci_conn_put(conn); 7449 + } 7450 + } else { 7468 7451 err = -EOPNOTSUPP; 7452 + } 7469 7453 7470 - return err; 7454 + return (err == -EEXIST) ? 0 : err; 7471 7455 } 7472 7456 7473 7457 static void pkt_type_changed(struct hci_dev *hdev, void *data, int err) ··· 7498 7472 { 7499 7473 struct hci_dev *hdev = conn->hdev; 7500 7474 struct hci_cp_change_conn_ptype *cp; 7475 + int err; 7501 7476 7502 7477 cp = kmalloc_obj(*cp); 7503 7478 if (!cp) ··· 7507 7480 cp->handle = cpu_to_le16(conn->handle); 7508 7481 cp->pkt_type = cpu_to_le16(pkt_type); 7509 7482 7510 - return hci_cmd_sync_queue_once(hdev, hci_change_conn_ptype_sync, cp, 7511 - pkt_type_changed); 7483 + err = hci_cmd_sync_queue_once(hdev, hci_change_conn_ptype_sync, cp, 7484 + pkt_type_changed); 7485 + if (err) 7486 + kfree(cp); 7487 + 7488 + return (err == -EEXIST) ? 0 : err; 7512 7489 } 7513 7490 7514 7491 static void le_phy_update_complete(struct hci_dev *hdev, void *data, int err) ··· 7538 7507 { 7539 7508 struct hci_dev *hdev = conn->hdev; 7540 7509 struct hci_cp_le_set_phy *cp; 7510 + int err; 7541 7511 7542 7512 cp = kmalloc_obj(*cp); 7543 7513 if (!cp) ··· 7549 7517 cp->tx_phys = tx_phys; 7550 7518 cp->rx_phys = rx_phys; 7551 7519 7552 - return hci_cmd_sync_queue_once(hdev, hci_le_set_phy_sync, cp, 7553 - le_phy_update_complete); 7520 + err = hci_cmd_sync_queue_once(hdev, hci_le_set_phy_sync, cp, 7521 + le_phy_update_complete); 7522 + if (err) 7523 + kfree(cp); 7524 + 7525 + return (err == -EEXIST) ? 0 : err; 7554 7526 }
+14 -3
net/bluetooth/mgmt.c
··· 2478 2478 struct mgmt_mesh_tx *mesh_tx; 2479 2479 struct mgmt_cp_mesh_send *send = data; 2480 2480 struct mgmt_rp_mesh_read_features rp; 2481 + u16 expected_len; 2481 2482 bool sending; 2482 2483 int err = 0; 2483 2484 ··· 2486 2485 !hci_dev_test_flag(hdev, HCI_MESH_EXPERIMENTAL)) 2487 2486 return mgmt_cmd_status(sk, hdev->id, MGMT_OP_MESH_SEND, 2488 2487 MGMT_STATUS_NOT_SUPPORTED); 2489 - if (!hci_dev_test_flag(hdev, HCI_LE_ENABLED) || 2490 - len <= MGMT_MESH_SEND_SIZE || 2491 - len > (MGMT_MESH_SEND_SIZE + 31)) 2488 + if (!hci_dev_test_flag(hdev, HCI_LE_ENABLED)) 2492 2489 return mgmt_cmd_status(sk, hdev->id, MGMT_OP_MESH_SEND, 2493 2490 MGMT_STATUS_REJECTED); 2491 + 2492 + if (!send->adv_data_len || send->adv_data_len > 31) 2493 + return mgmt_cmd_status(sk, hdev->id, MGMT_OP_MESH_SEND, 2494 + MGMT_STATUS_REJECTED); 2495 + 2496 + expected_len = struct_size(send, adv_data, send->adv_data_len); 2497 + if (expected_len != len) 2498 + return mgmt_cmd_status(sk, hdev->id, MGMT_OP_MESH_SEND, 2499 + MGMT_STATUS_INVALID_PARAMS); 2494 2500 2495 2501 hci_dev_lock(hdev); 2496 2502 ··· 7254 7246 static bool ltk_is_valid(struct mgmt_ltk_info *key) 7255 7247 { 7256 7248 if (key->initiator != 0x00 && key->initiator != 0x01) 7249 + return false; 7250 + 7251 + if (key->enc_size > sizeof(key->val)) 7257 7252 return false; 7258 7253 7259 7254 switch (key->addr.type) {
+23 -7
net/bluetooth/sco.c
··· 298 298 int err = 0; 299 299 300 300 sco_conn_lock(conn); 301 - if (conn->sk) 301 + if (conn->sk || sco_pi(sk)->conn) 302 302 err = -EBUSY; 303 303 else 304 304 __sco_chan_add(conn, sk, parent); ··· 353 353 354 354 lock_sock(sk); 355 355 356 + /* Recheck state after reacquiring the socket lock, as another 357 + * thread may have changed it (e.g., closed the socket). 358 + */ 359 + if (sk->sk_state != BT_OPEN && sk->sk_state != BT_BOUND) { 360 + release_sock(sk); 361 + hci_conn_drop(hcon); 362 + err = -EBADFD; 363 + goto unlock; 364 + } 365 + 356 366 err = sco_chan_add(conn, sk, NULL); 357 367 if (err) { 358 368 release_sock(sk); 369 + hci_conn_drop(hcon); 359 370 goto unlock; 360 371 } 361 372 ··· 667 656 addr->sa_family != AF_BLUETOOTH) 668 657 return -EINVAL; 669 658 670 - if (sk->sk_state != BT_OPEN && sk->sk_state != BT_BOUND) 671 - return -EBADFD; 672 - 673 - if (sk->sk_type != SOCK_SEQPACKET) 674 - err = -EINVAL; 675 - 676 659 lock_sock(sk); 660 + 661 + if (sk->sk_state != BT_OPEN && sk->sk_state != BT_BOUND) { 662 + release_sock(sk); 663 + return -EBADFD; 664 + } 665 + 666 + if (sk->sk_type != SOCK_SEQPACKET) { 667 + release_sock(sk); 668 + return -EINVAL; 669 + } 670 + 677 671 /* Set destination address and psm */ 678 672 bacpy(&sco_pi(sk)->dst, &sa->sco_bdaddr); 679 673 release_sock(sk);
+6 -5
net/bluetooth/smp.c
··· 1018 1018 1019 1019 smp_s1(smp->tk, smp->prnd, smp->rrnd, stk); 1020 1020 1021 - if (hcon->pending_sec_level == BT_SECURITY_HIGH) 1022 - auth = 1; 1023 - else 1024 - auth = 0; 1021 + auth = test_bit(SMP_FLAG_MITM_AUTH, &smp->flags) ? 1 : 0; 1025 1022 1026 1023 /* Even though there's no _RESPONDER suffix this is the 1027 1024 * responder STK we're adding for later lookup (the initiator ··· 1823 1826 if (sec_level > conn->hcon->pending_sec_level) 1824 1827 conn->hcon->pending_sec_level = sec_level; 1825 1828 1826 - /* If we need MITM check that it can be achieved */ 1829 + /* If we need MITM check that it can be achieved. */ 1827 1830 if (conn->hcon->pending_sec_level >= BT_SECURITY_HIGH) { 1828 1831 u8 method; 1829 1832 ··· 1831 1834 req->io_capability); 1832 1835 if (method == JUST_WORKS || method == JUST_CFM) 1833 1836 return SMP_AUTH_REQUIREMENTS; 1837 + 1838 + /* Force MITM bit if it isn't set by the initiator. */ 1839 + auth |= SMP_AUTH_MITM; 1840 + rsp.auth_req |= SMP_AUTH_MITM; 1834 1841 } 1835 1842 1836 1843 key_size = min(req->max_key_size, rsp.max_key_size);
+11 -7
net/bridge/br_arp_nd_proxy.c
··· 250 250 251 251 static void br_nd_send(struct net_bridge *br, struct net_bridge_port *p, 252 252 struct sk_buff *request, struct neighbour *n, 253 - __be16 vlan_proto, u16 vlan_tci, struct nd_msg *ns) 253 + __be16 vlan_proto, u16 vlan_tci) 254 254 { 255 255 struct net_device *dev = request->dev; 256 256 struct net_bridge_vlan_group *vg; 257 + struct nd_msg *na, *ns; 257 258 struct sk_buff *reply; 258 - struct nd_msg *na; 259 259 struct ipv6hdr *pip6; 260 260 int na_olen = 8; /* opt hdr + ETH_ALEN for target */ 261 261 int ns_olen; ··· 263 263 u8 *daddr; 264 264 u16 pvid; 265 265 266 - if (!dev) 266 + if (!dev || skb_linearize(request)) 267 267 return; 268 268 269 269 len = LL_RESERVED_SPACE(dev) + sizeof(struct ipv6hdr) + ··· 280 280 skb_set_mac_header(reply, 0); 281 281 282 282 daddr = eth_hdr(request)->h_source; 283 + ns = (struct nd_msg *)(skb_network_header(request) + 284 + sizeof(struct ipv6hdr)); 283 285 284 286 /* Do we need option processing ? */ 285 287 ns_olen = request->len - (skb_network_offset(request) + 286 288 sizeof(struct ipv6hdr)) - sizeof(*ns); 287 289 for (i = 0; i < ns_olen - 1; i += (ns->opt[i + 1] << 3)) { 288 - if (!ns->opt[i + 1]) { 290 + if (!ns->opt[i + 1] || i + (ns->opt[i + 1] << 3) > ns_olen) { 289 291 kfree_skb(reply); 290 292 return; 291 293 } 292 294 if (ns->opt[i] == ND_OPT_SOURCE_LL_ADDR) { 293 - daddr = ns->opt + i + sizeof(struct nd_opt_hdr); 295 + if ((ns->opt[i + 1] << 3) >= 296 + sizeof(struct nd_opt_hdr) + ETH_ALEN) 297 + daddr = ns->opt + i + sizeof(struct nd_opt_hdr); 294 298 break; 295 299 } 296 300 } ··· 475 471 if (vid != 0) 476 472 br_nd_send(br, p, skb, n, 477 473 skb->vlan_proto, 478 - skb_vlan_tag_get(skb), msg); 474 + skb_vlan_tag_get(skb)); 479 475 else 480 - br_nd_send(br, p, skb, n, 0, 0, msg); 476 + br_nd_send(br, p, skb, n, 0, 0); 481 477 replied = true; 482 478 } 483 479
+2 -2
net/bridge/br_mrp_netlink.c
··· 196 196 br_mrp_start_test_policy[IFLA_BRIDGE_MRP_START_TEST_MAX + 1] = { 197 197 [IFLA_BRIDGE_MRP_START_TEST_UNSPEC] = { .type = NLA_REJECT }, 198 198 [IFLA_BRIDGE_MRP_START_TEST_RING_ID] = { .type = NLA_U32 }, 199 - [IFLA_BRIDGE_MRP_START_TEST_INTERVAL] = { .type = NLA_U32 }, 199 + [IFLA_BRIDGE_MRP_START_TEST_INTERVAL] = NLA_POLICY_MIN(NLA_U32, 1), 200 200 [IFLA_BRIDGE_MRP_START_TEST_MAX_MISS] = { .type = NLA_U32 }, 201 201 [IFLA_BRIDGE_MRP_START_TEST_PERIOD] = { .type = NLA_U32 }, 202 202 [IFLA_BRIDGE_MRP_START_TEST_MONITOR] = { .type = NLA_U32 }, ··· 316 316 br_mrp_start_in_test_policy[IFLA_BRIDGE_MRP_START_IN_TEST_MAX + 1] = { 317 317 [IFLA_BRIDGE_MRP_START_IN_TEST_UNSPEC] = { .type = NLA_REJECT }, 318 318 [IFLA_BRIDGE_MRP_START_IN_TEST_IN_ID] = { .type = NLA_U32 }, 319 - [IFLA_BRIDGE_MRP_START_IN_TEST_INTERVAL] = { .type = NLA_U32 }, 319 + [IFLA_BRIDGE_MRP_START_IN_TEST_INTERVAL] = NLA_POLICY_MIN(NLA_U32, 1), 320 320 [IFLA_BRIDGE_MRP_START_IN_TEST_MAX_MISS] = { .type = NLA_U32 }, 321 321 [IFLA_BRIDGE_MRP_START_IN_TEST_PERIOD] = { .type = NLA_U32 }, 322 322 };
+8 -3
net/core/dev.c
··· 3819 3819 * segmentation-offloads.rst). 3820 3820 */ 3821 3821 if (skb_shinfo(skb)->gso_type & SKB_GSO_TCPV4) { 3822 - struct iphdr *iph = skb->encapsulation ? 3823 - inner_ip_hdr(skb) : ip_hdr(skb); 3822 + const struct iphdr *iph; 3823 + struct iphdr _iph; 3824 + int nhoff = skb->encapsulation ? 3825 + skb_inner_network_offset(skb) : 3826 + skb_network_offset(skb); 3824 3827 3825 - if (!(iph->frag_off & htons(IP_DF))) 3828 + iph = skb_header_pointer(skb, nhoff, sizeof(_iph), &_iph); 3829 + 3830 + if (!iph || !(iph->frag_off & htons(IP_DF))) 3826 3831 features &= ~dev->mangleid_features; 3827 3832 } 3828 3833
+17 -15
net/hsr/hsr_device.c
··· 532 532 static int hsr_ndo_vlan_rx_add_vid(struct net_device *dev, 533 533 __be16 proto, u16 vid) 534 534 { 535 - bool is_slave_a_added = false; 536 - bool is_slave_b_added = false; 535 + struct net_device *slave_a_dev = NULL; 536 + struct net_device *slave_b_dev = NULL; 537 537 struct hsr_port *port; 538 538 struct hsr_priv *hsr; 539 539 int ret = 0; ··· 549 549 switch (port->type) { 550 550 case HSR_PT_SLAVE_A: 551 551 if (ret) { 552 - /* clean up Slave-B */ 553 552 netdev_err(dev, "add vid failed for Slave-A\n"); 554 - if (is_slave_b_added) 555 - vlan_vid_del(port->dev, proto, vid); 556 - return ret; 553 + goto unwind; 557 554 } 558 - 559 - is_slave_a_added = true; 555 + slave_a_dev = port->dev; 560 556 break; 561 - 562 557 case HSR_PT_SLAVE_B: 563 558 if (ret) { 564 - /* clean up Slave-A */ 565 559 netdev_err(dev, "add vid failed for Slave-B\n"); 566 - if (is_slave_a_added) 567 - vlan_vid_del(port->dev, proto, vid); 568 - return ret; 560 + goto unwind; 569 561 } 570 - 571 - is_slave_b_added = true; 562 + slave_b_dev = port->dev; 572 563 break; 573 564 default: 565 + if (ret) 566 + goto unwind; 574 567 break; 575 568 } 576 569 } 577 570 578 571 return 0; 572 + 573 + unwind: 574 + if (slave_a_dev) 575 + vlan_vid_del(slave_a_dev, proto, vid); 576 + 577 + if (slave_b_dev) 578 + vlan_vid_del(slave_b_dev, proto, vid); 579 + 580 + return ret; 579 581 } 580 582 581 583 static int hsr_ndo_vlan_rx_kill_vid(struct net_device *dev,
+36 -2
net/hsr/hsr_framereg.c
··· 123 123 hsr_free_node(node); 124 124 } 125 125 126 + static void hsr_lock_seq_out_pair(struct hsr_node *node_a, 127 + struct hsr_node *node_b) 128 + { 129 + if (node_a == node_b) { 130 + spin_lock_bh(&node_a->seq_out_lock); 131 + return; 132 + } 133 + 134 + if (node_a < node_b) { 135 + spin_lock_bh(&node_a->seq_out_lock); 136 + spin_lock_nested(&node_b->seq_out_lock, SINGLE_DEPTH_NESTING); 137 + } else { 138 + spin_lock_bh(&node_b->seq_out_lock); 139 + spin_lock_nested(&node_a->seq_out_lock, SINGLE_DEPTH_NESTING); 140 + } 141 + } 142 + 143 + static void hsr_unlock_seq_out_pair(struct hsr_node *node_a, 144 + struct hsr_node *node_b) 145 + { 146 + if (node_a == node_b) { 147 + spin_unlock_bh(&node_a->seq_out_lock); 148 + return; 149 + } 150 + 151 + if (node_a < node_b) { 152 + spin_unlock(&node_b->seq_out_lock); 153 + spin_unlock_bh(&node_a->seq_out_lock); 154 + } else { 155 + spin_unlock(&node_a->seq_out_lock); 156 + spin_unlock_bh(&node_b->seq_out_lock); 157 + } 158 + } 159 + 126 160 void hsr_del_nodes(struct list_head *node_db) 127 161 { 128 162 struct hsr_node *node; ··· 466 432 } 467 433 468 434 ether_addr_copy(node_real->macaddress_B, ethhdr->h_source); 469 - spin_lock_bh(&node_real->seq_out_lock); 435 + hsr_lock_seq_out_pair(node_real, node_curr); 470 436 for (i = 0; i < HSR_PT_PORTS; i++) { 471 437 if (!node_curr->time_in_stale[i] && 472 438 time_after(node_curr->time_in[i], node_real->time_in[i])) { ··· 489 455 src_blk->seq_nrs[i], HSR_SEQ_BLOCK_SIZE); 490 456 } 491 457 } 492 - spin_unlock_bh(&node_real->seq_out_lock); 458 + hsr_unlock_seq_out_pair(node_real, node_curr); 493 459 node_real->addr_B_port = port_rcv->type; 494 460 495 461 spin_lock_bh(&hsr->list_lock);
+3 -3
net/ipv6/addrconf.c
··· 3625 3625 if ((ifp->flags & IFA_F_PERMANENT) && 3626 3626 fixup_permanent_addr(net, idev, ifp) < 0) { 3627 3627 write_unlock_bh(&idev->lock); 3628 - in6_ifa_hold(ifp); 3629 - ipv6_del_addr(ifp); 3630 - write_lock_bh(&idev->lock); 3631 3628 3632 3629 net_info_ratelimited("%s: Failed to add prefix route for address %pI6c; dropping\n", 3633 3630 idev->dev->name, &ifp->addr); 3631 + in6_ifa_hold(ifp); 3632 + ipv6_del_addr(ifp); 3633 + write_lock_bh(&idev->lock); 3634 3634 } 3635 3635 } 3636 3636
+10
net/ipv6/datagram.c
··· 762 762 { 763 763 struct in6_pktinfo *src_info; 764 764 struct cmsghdr *cmsg; 765 + struct ipv6_rt_hdr *orthdr; 765 766 struct ipv6_rt_hdr *rthdr; 766 767 struct ipv6_opt_hdr *hdr; 767 768 struct ipv6_txoptions *opt = ipc6->opt; ··· 924 923 goto exit_f; 925 924 } 926 925 if (cmsg->cmsg_type == IPV6_DSTOPTS) { 926 + if (opt->dst1opt) 927 + opt->opt_flen -= ipv6_optlen(opt->dst1opt); 927 928 opt->opt_flen += len; 928 929 opt->dst1opt = hdr; 929 930 } else { 931 + if (opt->dst0opt) 932 + opt->opt_nflen -= ipv6_optlen(opt->dst0opt); 930 933 opt->opt_nflen += len; 931 934 opt->dst0opt = hdr; 932 935 } ··· 973 968 goto exit_f; 974 969 } 975 970 971 + orthdr = opt->srcrt; 972 + if (orthdr) 973 + opt->opt_nflen -= ((orthdr->hdrlen + 1) << 3); 976 974 opt->opt_nflen += len; 977 975 opt->srcrt = rthdr; 978 976 979 977 if (cmsg->cmsg_type == IPV6_2292RTHDR && opt->dst1opt) { 980 978 int dsthdrlen = ((opt->dst1opt->hdrlen+1)<<3); 981 979 980 + if (opt->dst0opt) 981 + opt->opt_nflen -= ipv6_optlen(opt->dst0opt); 982 982 opt->opt_nflen += dsthdrlen; 983 983 opt->dst0opt = opt->dst1opt; 984 984 opt->dst1opt = NULL;
+3
net/ipv6/icmp.c
··· 875 875 if (!skb2) 876 876 return 1; 877 877 878 + /* Remove debris left by IPv4 stack. */ 879 + memset(IP6CB(skb2), 0, sizeof(*IP6CB(skb2))); 880 + 878 881 skb_dst_drop(skb2); 879 882 skb_pull(skb2, nhs); 880 883 skb_reset_network_header(skb2);
+2 -2
net/ipv6/ioam6.c
··· 708 708 struct ioam6_namespace *ns, 709 709 struct ioam6_trace_hdr *trace, 710 710 struct ioam6_schema *sc, 711 - u8 sclen, bool is_input) 711 + unsigned int sclen, bool is_input) 712 712 { 713 713 struct net_device *dev = skb_dst_dev(skb); 714 714 struct timespec64 ts; ··· 939 939 bool is_input) 940 940 { 941 941 struct ioam6_schema *sc; 942 - u8 sclen = 0; 942 + unsigned int sclen = 0; 943 943 944 944 /* Skip if Overflow flag is set 945 945 */
+11 -3
net/ipv6/ip6_fib.c
··· 730 730 731 731 void fib6_metric_set(struct fib6_info *f6i, int metric, u32 val) 732 732 { 733 + struct dst_metrics *m; 734 + 733 735 if (!f6i) 734 736 return; 735 737 736 - if (f6i->fib6_metrics == &dst_default_metrics) { 738 + if (READ_ONCE(f6i->fib6_metrics) == &dst_default_metrics) { 739 + struct dst_metrics *dflt = (struct dst_metrics *)&dst_default_metrics; 737 740 struct dst_metrics *p = kzalloc_obj(*p, GFP_ATOMIC); 738 741 739 742 if (!p) 740 743 return; 741 744 745 + p->metrics[metric - 1] = val; 742 746 refcount_set(&p->refcnt, 1); 743 - f6i->fib6_metrics = p; 747 + if (cmpxchg(&f6i->fib6_metrics, dflt, p) != dflt) 748 + kfree(p); 749 + else 750 + return; 744 751 } 745 752 746 - f6i->fib6_metrics->metrics[metric - 1] = val; 753 + m = READ_ONCE(f6i->fib6_metrics); 754 + WRITE_ONCE(m->metrics[metric - 1], val); 747 755 } 748 756 749 757 /*
-5
net/ipv6/ip6_flowlabel.c
··· 133 133 if (time_after(ttd, fl->expires)) 134 134 fl->expires = ttd; 135 135 ttd = fl->expires; 136 - if (fl->opt && fl->share == IPV6_FL_S_EXCL) { 137 - struct ipv6_txoptions *opt = fl->opt; 138 - fl->opt = NULL; 139 - kfree(opt); 140 - } 141 136 if (!timer_pending(&ip6_fl_gc_timer) || 142 137 time_after(ip6_fl_gc_timer.expires, ttd)) 143 138 mod_timer(&ip6_fl_gc_timer, ttd);
+5
net/ipv6/ip6_tunnel.c
··· 601 601 if (!skb2) 602 602 return 0; 603 603 604 + /* Remove debris left by IPv6 stack. */ 605 + memset(IPCB(skb2), 0, sizeof(*IPCB(skb2))); 606 + 604 607 skb_dst_drop(skb2); 605 608 606 609 skb_pull(skb2, offset); 607 610 skb_reset_network_header(skb2); 608 611 eiph = ip_hdr(skb2); 612 + if (eiph->version != 4 || eiph->ihl < 5) 613 + goto out; 609 614 610 615 /* Try to guess incoming interface */ 611 616 rt = ip_route_output_ports(dev_net(skb->dev), &fl4, NULL, eiph->saddr,
+3
net/ipv6/ndisc.c
··· 1210 1210 ndmsg->nduseropt_icmp_type = icmp6h->icmp6_type; 1211 1211 ndmsg->nduseropt_icmp_code = icmp6h->icmp6_code; 1212 1212 ndmsg->nduseropt_opts_len = opt->nd_opt_len << 3; 1213 + ndmsg->nduseropt_pad1 = 0; 1214 + ndmsg->nduseropt_pad2 = 0; 1215 + ndmsg->nduseropt_pad3 = 0; 1213 1216 1214 1217 memcpy(ndmsg + 1, opt, opt->nd_opt_len << 3); 1215 1218
+25 -4
net/mpls/af_mpls.c
··· 82 82 return mpls_dereference(net, platform_label[index]); 83 83 } 84 84 85 + static struct mpls_route __rcu **mpls_platform_label_rcu(struct net *net, size_t *platform_labels) 86 + { 87 + struct mpls_route __rcu **platform_label; 88 + unsigned int sequence; 89 + 90 + do { 91 + sequence = read_seqcount_begin(&net->mpls.platform_label_seq); 92 + platform_label = rcu_dereference(net->mpls.platform_label); 93 + *platform_labels = net->mpls.platform_labels; 94 + } while (read_seqcount_retry(&net->mpls.platform_label_seq, sequence)); 95 + 96 + return platform_label; 97 + } 98 + 85 99 static struct mpls_route *mpls_route_input_rcu(struct net *net, unsigned int index) 86 100 { 87 101 struct mpls_route __rcu **platform_label; 102 + size_t platform_labels; 88 103 89 - if (index >= net->mpls.platform_labels) 104 + platform_label = mpls_platform_label_rcu(net, &platform_labels); 105 + 106 + if (index >= platform_labels) 90 107 return NULL; 91 108 92 - platform_label = rcu_dereference(net->mpls.platform_label); 93 109 return rcu_dereference(platform_label[index]); 94 110 } 95 111 ··· 2252 2236 if (index < MPLS_LABEL_FIRST_UNRESERVED) 2253 2237 index = MPLS_LABEL_FIRST_UNRESERVED; 2254 2238 2255 - platform_label = rcu_dereference(net->mpls.platform_label); 2256 - platform_labels = net->mpls.platform_labels; 2239 + platform_label = mpls_platform_label_rcu(net, &platform_labels); 2257 2240 2258 2241 if (filter.filter_set) 2259 2242 flags |= NLM_F_DUMP_FILTERED; ··· 2656 2641 } 2657 2642 2658 2643 /* Update the global pointers */ 2644 + local_bh_disable(); 2645 + write_seqcount_begin(&net->mpls.platform_label_seq); 2659 2646 net->mpls.platform_labels = limit; 2660 2647 rcu_assign_pointer(net->mpls.platform_label, labels); 2648 + write_seqcount_end(&net->mpls.platform_label_seq); 2649 + local_bh_enable(); 2661 2650 2662 2651 mutex_unlock(&net->mpls.platform_mutex); 2663 2652 ··· 2743 2724 int i; 2744 2725 2745 2726 mutex_init(&net->mpls.platform_mutex); 2727 + seqcount_mutex_init(&net->mpls.platform_label_seq, &net->mpls.platform_mutex); 2728 + 2746 2729 net->mpls.platform_labels = 0; 2747 2730 net->mpls.platform_label = NULL; 2748 2731 net->mpls.ip_ttl_propagate = 1;
+8 -3
net/mptcp/protocol.c
··· 2006 2006 static int __mptcp_recvmsg_mskq(struct sock *sk, struct msghdr *msg, 2007 2007 size_t len, int flags, int copied_total, 2008 2008 struct scm_timestamping_internal *tss, 2009 - int *cmsg_flags) 2009 + int *cmsg_flags, struct sk_buff **last) 2010 2010 { 2011 2011 struct mptcp_sock *msk = mptcp_sk(sk); 2012 2012 struct sk_buff *skb, *tmp; ··· 2023 2023 /* skip already peeked skbs */ 2024 2024 if (total_data_len + data_len <= copied_total) { 2025 2025 total_data_len += data_len; 2026 + *last = skb; 2026 2027 continue; 2027 2028 } 2028 2029 ··· 2059 2058 } 2060 2059 2061 2060 mptcp_eat_recv_skb(sk, skb); 2061 + } else { 2062 + *last = skb; 2062 2063 } 2063 2064 2064 2065 if (copied >= len) ··· 2291 2288 cmsg_flags = MPTCP_CMSG_INQ; 2292 2289 2293 2290 while (copied < len) { 2291 + struct sk_buff *last = NULL; 2294 2292 int err, bytes_read; 2295 2293 2296 2294 bytes_read = __mptcp_recvmsg_mskq(sk, msg, len - copied, flags, 2297 - copied, &tss, &cmsg_flags); 2295 + copied, &tss, &cmsg_flags, 2296 + &last); 2298 2297 if (unlikely(bytes_read < 0)) { 2299 2298 if (!copied) 2300 2299 copied = bytes_read; ··· 2348 2343 2349 2344 pr_debug("block timeout %ld\n", timeo); 2350 2345 mptcp_cleanup_rbuf(msk, copied); 2351 - err = sk_wait_data(sk, &timeo, NULL); 2346 + err = sk_wait_data(sk, &timeo, last); 2352 2347 if (err < 0) { 2353 2348 err = copied ? : err; 2354 2349 goto out_err;
+2 -2
net/netfilter/ipset/ip_set_core.c
··· 821 821 * 822 822 */ 823 823 ip_set_id_t 824 - ip_set_get_byname(struct net *net, const char *name, struct ip_set **set) 824 + ip_set_get_byname(struct net *net, const struct nlattr *name, struct ip_set **set) 825 825 { 826 826 ip_set_id_t i, index = IPSET_INVALID_ID; 827 827 struct ip_set *s; ··· 830 830 rcu_read_lock(); 831 831 for (i = 0; i < inst->ip_set_max; i++) { 832 832 s = rcu_dereference(inst->ip_set_list)[i]; 833 - if (s && STRNCMP(s->name, name)) { 833 + if (s && nla_strcmp(name, s->name) == 0) { 834 834 __ip_set_get(s); 835 835 index = i; 836 836 *set = s;
+1 -1
net/netfilter/ipset/ip_set_hash_gen.h
··· 1098 1098 if (!test_bit(i, n->used)) 1099 1099 k++; 1100 1100 } 1101 - if (n->pos == 0 && k == 0) { 1101 + if (k == n->pos) { 1102 1102 t->hregion[r].ext_size -= ext_size(n->size, dsize); 1103 1103 rcu_assign_pointer(hbucket(t, key), NULL); 1104 1104 kfree_rcu(n, rcu);
+2 -2
net/netfilter/ipset/ip_set_list_set.c
··· 367 367 ret = ip_set_get_extensions(set, tb, &ext); 368 368 if (ret) 369 369 return ret; 370 - e.id = ip_set_get_byname(map->net, nla_data(tb[IPSET_ATTR_NAME]), &s); 370 + e.id = ip_set_get_byname(map->net, tb[IPSET_ATTR_NAME], &s); 371 371 if (e.id == IPSET_INVALID_ID) 372 372 return -IPSET_ERR_NAME; 373 373 /* "Loop detection" */ ··· 389 389 390 390 if (tb[IPSET_ATTR_NAMEREF]) { 391 391 e.refid = ip_set_get_byname(map->net, 392 - nla_data(tb[IPSET_ATTR_NAMEREF]), 392 + tb[IPSET_ATTR_NAMEREF], 393 393 &s); 394 394 if (e.refid == IPSET_INVALID_ID) { 395 395 ret = -IPSET_ERR_NAMEREF;
+1 -1
net/netfilter/nf_conntrack_helper.c
··· 415 415 */ 416 416 synchronize_rcu(); 417 417 418 - nf_ct_expect_iterate_destroy(expect_iter_me, NULL); 418 + nf_ct_expect_iterate_destroy(expect_iter_me, me); 419 419 nf_ct_iterate_destroy(unhelp, me); 420 420 421 421 /* nf_ct_iterate_destroy() does an unconditional synchronize_rcu() as
+15 -45
net/netfilter/nf_conntrack_netlink.c
··· 2634 2634 2635 2635 static struct nf_conntrack_expect * 2636 2636 ctnetlink_alloc_expect(const struct nlattr *const cda[], struct nf_conn *ct, 2637 - struct nf_conntrack_helper *helper, 2638 2637 struct nf_conntrack_tuple *tuple, 2639 2638 struct nf_conntrack_tuple *mask); 2640 2639 ··· 2862 2863 { 2863 2864 struct nlattr *cda[CTA_EXPECT_MAX+1]; 2864 2865 struct nf_conntrack_tuple tuple, mask; 2865 - struct nf_conntrack_helper *helper = NULL; 2866 2866 struct nf_conntrack_expect *exp; 2867 2867 int err; 2868 2868 ··· 2875 2877 if (err < 0) 2876 2878 return err; 2877 2879 2878 - if (cda[CTA_EXPECT_HELP_NAME]) { 2879 - const char *helpname = nla_data(cda[CTA_EXPECT_HELP_NAME]); 2880 - 2881 - helper = __nf_conntrack_helper_find(helpname, nf_ct_l3num(ct), 2882 - nf_ct_protonum(ct)); 2883 - if (helper == NULL) 2884 - return -EOPNOTSUPP; 2885 - } 2886 - 2887 2880 exp = ctnetlink_alloc_expect((const struct nlattr * const *)cda, ct, 2888 - helper, &tuple, &mask); 2881 + &tuple, &mask); 2889 2882 if (IS_ERR(exp)) 2890 2883 return PTR_ERR(exp); 2891 2884 ··· 3515 3526 3516 3527 static struct nf_conntrack_expect * 3517 3528 ctnetlink_alloc_expect(const struct nlattr * const cda[], struct nf_conn *ct, 3518 - struct nf_conntrack_helper *helper, 3519 3529 struct nf_conntrack_tuple *tuple, 3520 3530 struct nf_conntrack_tuple *mask) 3521 3531 { 3522 3532 struct net *net = read_pnet(&ct->ct_net); 3533 + struct nf_conntrack_helper *helper; 3523 3534 struct nf_conntrack_expect *exp; 3524 3535 struct nf_conn_help *help; 3525 3536 u32 class = 0; ··· 3529 3540 if (!help) 3530 3541 return ERR_PTR(-EOPNOTSUPP); 3531 3542 3532 - if (cda[CTA_EXPECT_CLASS] && helper) { 3543 + helper = rcu_dereference(help->helper); 3544 + if (!helper) 3545 + return ERR_PTR(-EOPNOTSUPP); 3546 + 3547 + if (cda[CTA_EXPECT_CLASS]) { 3533 3548 class = ntohl(nla_get_be32(cda[CTA_EXPECT_CLASS])); 3534 3549 if (class > helper->expect_class_max) 3535 3550 return ERR_PTR(-EINVAL); ··· 3567 3574 #ifdef CONFIG_NF_CONNTRACK_ZONES 3568 3575 exp->zone = ct->zone; 3569 3576 #endif 3570 - if (!helper) 3571 - helper = rcu_dereference(help->helper); 3572 3577 rcu_assign_pointer(exp->helper, helper); 3573 3578 exp->tuple = *tuple; 3574 3579 exp->mask.src.u3 = mask->src.u3; ··· 3577 3586 exp, nf_ct_l3num(ct)); 3578 3587 if (err < 0) 3579 3588 goto err_out; 3589 + #if IS_ENABLED(CONFIG_NF_NAT) 3590 + } else { 3591 + memset(&exp->saved_addr, 0, sizeof(exp->saved_addr)); 3592 + memset(&exp->saved_proto, 0, sizeof(exp->saved_proto)); 3593 + exp->dir = 0; 3594 + #endif 3580 3595 } 3581 3596 return exp; 3582 3597 err_out: ··· 3598 3601 { 3599 3602 struct nf_conntrack_tuple tuple, mask, master_tuple; 3600 3603 struct nf_conntrack_tuple_hash *h = NULL; 3601 - struct nf_conntrack_helper *helper = NULL; 3602 3604 struct nf_conntrack_expect *exp; 3603 3605 struct nf_conn *ct; 3604 3606 int err; ··· 3623 3627 ct = nf_ct_tuplehash_to_ctrack(h); 3624 3628 3625 3629 rcu_read_lock(); 3626 - if (cda[CTA_EXPECT_HELP_NAME]) { 3627 - const char *helpname = nla_data(cda[CTA_EXPECT_HELP_NAME]); 3628 - 3629 - helper = __nf_conntrack_helper_find(helpname, u3, 3630 - nf_ct_protonum(ct)); 3631 - if (helper == NULL) { 3632 - rcu_read_unlock(); 3633 - #ifdef CONFIG_MODULES 3634 - if (request_module("nfct-helper-%s", helpname) < 0) { 3635 - err = -EOPNOTSUPP; 3636 - goto err_ct; 3637 - } 3638 - rcu_read_lock(); 3639 - helper = __nf_conntrack_helper_find(helpname, u3, 3640 - nf_ct_protonum(ct)); 3641 - if (helper) { 3642 - err = -EAGAIN; 3643 - goto err_rcu; 3644 - } 3645 - rcu_read_unlock(); 3646 - #endif 3647 - err = -EOPNOTSUPP; 3648 - goto err_ct; 3649 - } 3650 - } 3651 - 3652 - exp = ctnetlink_alloc_expect(cda, ct, helper, &tuple, &mask); 3630 + exp = ctnetlink_alloc_expect(cda, ct, &tuple, &mask); 3653 3631 if (IS_ERR(exp)) { 3654 3632 err = PTR_ERR(exp); 3655 3633 goto err_rcu; ··· 3633 3663 nf_ct_expect_put(exp); 3634 3664 err_rcu: 3635 3665 rcu_read_unlock(); 3636 - err_ct: 3637 3666 nf_ct_put(ct); 3667 + 3638 3668 return err; 3639 3669 } 3640 3670
+130 -66
net/netfilter/nf_flow_table_offload.c
··· 15 15 #include <net/netfilter/nf_conntrack_core.h> 16 16 #include <net/netfilter/nf_conntrack_tuple.h> 17 17 18 + #define NF_FLOW_RULE_ACTION_MAX 24 19 + 18 20 static struct workqueue_struct *nf_flow_offload_add_wq; 19 21 static struct workqueue_struct *nf_flow_offload_del_wq; 20 22 static struct workqueue_struct *nf_flow_offload_stats_wq; ··· 219 217 static inline struct flow_action_entry * 220 218 flow_action_entry_next(struct nf_flow_rule *flow_rule) 221 219 { 222 - int i = flow_rule->rule->action.num_entries++; 220 + int i; 221 + 222 + if (unlikely(flow_rule->rule->action.num_entries >= NF_FLOW_RULE_ACTION_MAX)) 223 + return NULL; 224 + 225 + i = flow_rule->rule->action.num_entries++; 223 226 224 227 return &flow_rule->rule->action.entries[i]; 225 228 } ··· 241 234 const unsigned char *addr; 242 235 u32 mask, val; 243 236 u16 val16; 237 + 238 + if (!entry0 || !entry1) 239 + return -E2BIG; 244 240 245 241 this_tuple = &flow->tuplehash[dir].tuple; 246 242 ··· 295 285 u8 nud_state; 296 286 u16 val16; 297 287 288 + if (!entry0 || !entry1) 289 + return -E2BIG; 290 + 298 291 this_tuple = &flow->tuplehash[dir].tuple; 299 292 300 293 switch (this_tuple->xmit_type) { ··· 339 326 return 0; 340 327 } 341 328 342 - static void flow_offload_ipv4_snat(struct net *net, 343 - const struct flow_offload *flow, 344 - enum flow_offload_tuple_dir dir, 345 - struct nf_flow_rule *flow_rule) 329 + static int flow_offload_ipv4_snat(struct net *net, 330 + const struct flow_offload *flow, 331 + enum flow_offload_tuple_dir dir, 332 + struct nf_flow_rule *flow_rule) 346 333 { 347 334 struct flow_action_entry *entry = flow_action_entry_next(flow_rule); 348 335 u32 mask = ~htonl(0xffffffff); 349 336 __be32 addr; 350 337 u32 offset; 338 + 339 + if (!entry) 340 + return -E2BIG; 351 341 352 342 switch (dir) { 353 343 case FLOW_OFFLOAD_DIR_ORIGINAL: ··· 362 346 offset = offsetof(struct iphdr, daddr); 363 347 break; 364 348 default: 365 - return; 349 + return -EOPNOTSUPP; 366 350 } 367 351 368 352 flow_offload_mangle(entry, FLOW_ACT_MANGLE_HDR_TYPE_IP4, offset, 369 353 &addr, &mask); 354 + return 0; 370 355 } 371 356 372 - static void flow_offload_ipv4_dnat(struct net *net, 373 - const struct flow_offload *flow, 374 - enum flow_offload_tuple_dir dir, 375 - struct nf_flow_rule *flow_rule) 357 + static int flow_offload_ipv4_dnat(struct net *net, 358 + const struct flow_offload *flow, 359 + enum flow_offload_tuple_dir dir, 360 + struct nf_flow_rule *flow_rule) 376 361 { 377 362 struct flow_action_entry *entry = flow_action_entry_next(flow_rule); 378 363 u32 mask = ~htonl(0xffffffff); 379 364 __be32 addr; 380 365 u32 offset; 366 + 367 + if (!entry) 368 + return -E2BIG; 381 369 382 370 switch (dir) { 383 371 case FLOW_OFFLOAD_DIR_ORIGINAL: ··· 393 373 offset = offsetof(struct iphdr, saddr); 394 374 break; 395 375 default: 396 - return; 376 + return -EOPNOTSUPP; 397 377 } 398 378 399 379 flow_offload_mangle(entry, FLOW_ACT_MANGLE_HDR_TYPE_IP4, offset, 400 380 &addr, &mask); 381 + return 0; 401 382 } 402 383 403 - static void flow_offload_ipv6_mangle(struct nf_flow_rule *flow_rule, 384 + static int flow_offload_ipv6_mangle(struct nf_flow_rule *flow_rule, 404 385 unsigned int offset, 405 386 const __be32 *addr, const __be32 *mask) 406 387 { ··· 410 389 411 390 for (i = 0; i < sizeof(struct in6_addr) / sizeof(u32); i++) { 412 391 entry = flow_action_entry_next(flow_rule); 392 + if (!entry) 393 + return -E2BIG; 394 + 413 395 flow_offload_mangle(entry, FLOW_ACT_MANGLE_HDR_TYPE_IP6, 414 396 offset + i * sizeof(u32), &addr[i], mask); 415 397 } 398 + 399 + return 0; 416 400 } 417 401 418 - static void flow_offload_ipv6_snat(struct net *net, 419 - const struct flow_offload *flow, 420 - enum flow_offload_tuple_dir dir, 421 - struct nf_flow_rule *flow_rule) 402 + static int flow_offload_ipv6_snat(struct net *net, 403 + const struct flow_offload *flow, 404 + enum flow_offload_tuple_dir dir, 405 + struct nf_flow_rule *flow_rule) 422 406 { 423 407 u32 mask = ~htonl(0xffffffff); 424 408 const __be32 *addr; ··· 439 413 offset = offsetof(struct ipv6hdr, daddr); 440 414 break; 441 415 default: 442 - return; 416 + return -EOPNOTSUPP; 443 417 } 444 418 445 - flow_offload_ipv6_mangle(flow_rule, offset, addr, &mask); 419 + return flow_offload_ipv6_mangle(flow_rule, offset, addr, &mask); 446 420 } 447 421 448 - static void flow_offload_ipv6_dnat(struct net *net, 449 - const struct flow_offload *flow, 450 - enum flow_offload_tuple_dir dir, 451 - struct nf_flow_rule *flow_rule) 422 + static int flow_offload_ipv6_dnat(struct net *net, 423 + const struct flow_offload *flow, 424 + enum flow_offload_tuple_dir dir, 425 + struct nf_flow_rule *flow_rule) 452 426 { 453 427 u32 mask = ~htonl(0xffffffff); 454 428 const __be32 *addr; ··· 464 438 offset = offsetof(struct ipv6hdr, saddr); 465 439 break; 466 440 default: 467 - return; 441 + return -EOPNOTSUPP; 468 442 } 469 443 470 - flow_offload_ipv6_mangle(flow_rule, offset, addr, &mask); 444 + return flow_offload_ipv6_mangle(flow_rule, offset, addr, &mask); 471 445 } 472 446 473 447 static int flow_offload_l4proto(const struct flow_offload *flow) ··· 489 463 return type; 490 464 } 491 465 492 - static void flow_offload_port_snat(struct net *net, 493 - const struct flow_offload *flow, 494 - enum flow_offload_tuple_dir dir, 495 - struct nf_flow_rule *flow_rule) 466 + static int flow_offload_port_snat(struct net *net, 467 + const struct flow_offload *flow, 468 + enum flow_offload_tuple_dir dir, 469 + struct nf_flow_rule *flow_rule) 496 470 { 497 471 struct flow_action_entry *entry = flow_action_entry_next(flow_rule); 498 472 u32 mask, port; 499 473 u32 offset; 474 + 475 + if (!entry) 476 + return -E2BIG; 500 477 501 478 switch (dir) { 502 479 case FLOW_OFFLOAD_DIR_ORIGINAL: ··· 515 486 mask = ~htonl(0xffff); 516 487 break; 517 488 default: 518 - return; 489 + return -EOPNOTSUPP; 519 490 } 520 491 521 492 flow_offload_mangle(entry, flow_offload_l4proto(flow), offset, 522 493 &port, &mask); 494 + return 0; 523 495 } 524 496 525 - static void flow_offload_port_dnat(struct net *net, 526 - const struct flow_offload *flow, 527 - enum flow_offload_tuple_dir dir, 528 - struct nf_flow_rule *flow_rule) 497 + static int flow_offload_port_dnat(struct net *net, 498 + const struct flow_offload *flow, 499 + enum flow_offload_tuple_dir dir, 500 + struct nf_flow_rule *flow_rule) 529 501 { 530 502 struct flow_action_entry *entry = flow_action_entry_next(flow_rule); 531 503 u32 mask, port; 532 504 u32 offset; 505 + 506 + if (!entry) 507 + return -E2BIG; 533 508 534 509 switch (dir) { 535 510 case FLOW_OFFLOAD_DIR_ORIGINAL: ··· 549 516 mask = ~htonl(0xffff0000); 550 517 break; 551 518 default: 552 - return; 519 + return -EOPNOTSUPP; 553 520 } 554 521 555 522 flow_offload_mangle(entry, flow_offload_l4proto(flow), offset, 556 523 &port, &mask); 524 + return 0; 557 525 } 558 526 559 - static void flow_offload_ipv4_checksum(struct net *net, 560 - const struct flow_offload *flow, 561 - struct nf_flow_rule *flow_rule) 527 + static int flow_offload_ipv4_checksum(struct net *net, 528 + const struct flow_offload *flow, 529 + struct nf_flow_rule *flow_rule) 562 530 { 563 531 u8 protonum = flow->tuplehash[FLOW_OFFLOAD_DIR_ORIGINAL].tuple.l4proto; 564 532 struct flow_action_entry *entry = flow_action_entry_next(flow_rule); 533 + 534 + if (!entry) 535 + return -E2BIG; 565 536 566 537 entry->id = FLOW_ACTION_CSUM; 567 538 entry->csum_flags = TCA_CSUM_UPDATE_FLAG_IPV4HDR; ··· 578 541 entry->csum_flags |= TCA_CSUM_UPDATE_FLAG_UDP; 579 542 break; 580 543 } 544 + 545 + return 0; 581 546 } 582 547 583 - static void flow_offload_redirect(struct net *net, 584 - const struct flow_offload *flow, 585 - enum flow_offload_tuple_dir dir, 586 - struct nf_flow_rule *flow_rule) 548 + static int flow_offload_redirect(struct net *net, 549 + const struct flow_offload *flow, 550 + enum flow_offload_tuple_dir dir, 551 + struct nf_flow_rule *flow_rule) 587 552 { 588 553 const struct flow_offload_tuple *this_tuple, *other_tuple; 589 554 struct flow_action_entry *entry; ··· 603 564 ifindex = other_tuple->iifidx; 604 565 break; 605 566 default: 606 - return; 567 + return -EOPNOTSUPP; 607 568 } 608 569 609 570 dev = dev_get_by_index(net, ifindex); 610 571 if (!dev) 611 - return; 572 + return -ENODEV; 612 573 613 574 entry = flow_action_entry_next(flow_rule); 575 + if (!entry) { 576 + dev_put(dev); 577 + return -E2BIG; 578 + } 579 + 614 580 entry->id = FLOW_ACTION_REDIRECT; 615 581 entry->dev = dev; 582 + 583 + return 0; 616 584 } 617 585 618 - static void flow_offload_encap_tunnel(const struct flow_offload *flow, 619 - enum flow_offload_tuple_dir dir, 620 - struct nf_flow_rule *flow_rule) 586 + static int flow_offload_encap_tunnel(const struct flow_offload *flow, 587 + enum flow_offload_tuple_dir dir, 588 + struct nf_flow_rule *flow_rule) 621 589 { 622 590 const struct flow_offload_tuple *this_tuple; 623 591 struct flow_action_entry *entry; ··· 632 586 633 587 this_tuple = &flow->tuplehash[dir].tuple; 634 588 if (this_tuple->xmit_type == FLOW_OFFLOAD_XMIT_DIRECT) 635 - return; 589 + return 0; 636 590 637 591 dst = this_tuple->dst_cache; 638 592 if (dst && dst->lwtstate) { ··· 641 595 tun_info = lwt_tun_info(dst->lwtstate); 642 596 if (tun_info && (tun_info->mode & IP_TUNNEL_INFO_TX)) { 643 597 entry = flow_action_entry_next(flow_rule); 598 + if (!entry) 599 + return -E2BIG; 644 600 entry->id = FLOW_ACTION_TUNNEL_ENCAP; 645 601 entry->tunnel = tun_info; 646 602 } 647 603 } 604 + 605 + return 0; 648 606 } 649 607 650 - static void flow_offload_decap_tunnel(const struct flow_offload *flow, 651 - enum flow_offload_tuple_dir dir, 652 - struct nf_flow_rule *flow_rule) 608 + static int flow_offload_decap_tunnel(const struct flow_offload *flow, 609 + enum flow_offload_tuple_dir dir, 610 + struct nf_flow_rule *flow_rule) 653 611 { 654 612 const struct flow_offload_tuple *other_tuple; 655 613 struct flow_action_entry *entry; ··· 661 611 662 612 other_tuple = &flow->tuplehash[!dir].tuple; 663 613 if (other_tuple->xmit_type == FLOW_OFFLOAD_XMIT_DIRECT) 664 - return; 614 + return 0; 665 615 666 616 dst = other_tuple->dst_cache; 667 617 if (dst && dst->lwtstate) { ··· 670 620 tun_info = lwt_tun_info(dst->lwtstate); 671 621 if (tun_info && (tun_info->mode & IP_TUNNEL_INFO_TX)) { 672 622 entry = flow_action_entry_next(flow_rule); 623 + if (!entry) 624 + return -E2BIG; 673 625 entry->id = FLOW_ACTION_TUNNEL_DECAP; 674 626 } 675 627 } 628 + 629 + return 0; 676 630 } 677 631 678 632 static int ··· 688 634 const struct flow_offload_tuple *tuple; 689 635 int i; 690 636 691 - flow_offload_decap_tunnel(flow, dir, flow_rule); 692 - flow_offload_encap_tunnel(flow, dir, flow_rule); 637 + if (flow_offload_decap_tunnel(flow, dir, flow_rule) < 0 || 638 + flow_offload_encap_tunnel(flow, dir, flow_rule) < 0) 639 + return -1; 693 640 694 641 if (flow_offload_eth_src(net, flow, dir, flow_rule) < 0 || 695 642 flow_offload_eth_dst(net, flow, dir, flow_rule) < 0) ··· 706 651 707 652 if (tuple->encap[i].proto == htons(ETH_P_8021Q)) { 708 653 entry = flow_action_entry_next(flow_rule); 654 + if (!entry) 655 + return -1; 709 656 entry->id = FLOW_ACTION_VLAN_POP; 710 657 } 711 658 } ··· 721 664 continue; 722 665 723 666 entry = flow_action_entry_next(flow_rule); 667 + if (!entry) 668 + return -1; 724 669 725 670 switch (other_tuple->encap[i].proto) { 726 671 case htons(ETH_P_PPP_SES): ··· 748 689 return -1; 749 690 750 691 if (test_bit(NF_FLOW_SNAT, &flow->flags)) { 751 - flow_offload_ipv4_snat(net, flow, dir, flow_rule); 752 - flow_offload_port_snat(net, flow, dir, flow_rule); 692 + if (flow_offload_ipv4_snat(net, flow, dir, flow_rule) < 0 || 693 + flow_offload_port_snat(net, flow, dir, flow_rule) < 0) 694 + return -1; 753 695 } 754 696 if (test_bit(NF_FLOW_DNAT, &flow->flags)) { 755 - flow_offload_ipv4_dnat(net, flow, dir, flow_rule); 756 - flow_offload_port_dnat(net, flow, dir, flow_rule); 697 + if (flow_offload_ipv4_dnat(net, flow, dir, flow_rule) < 0 || 698 + flow_offload_port_dnat(net, flow, dir, flow_rule) < 0) 699 + return -1; 757 700 } 758 701 if (test_bit(NF_FLOW_SNAT, &flow->flags) || 759 702 test_bit(NF_FLOW_DNAT, &flow->flags)) 760 - flow_offload_ipv4_checksum(net, flow, flow_rule); 703 + if (flow_offload_ipv4_checksum(net, flow, flow_rule) < 0) 704 + return -1; 761 705 762 - flow_offload_redirect(net, flow, dir, flow_rule); 706 + if (flow_offload_redirect(net, flow, dir, flow_rule) < 0) 707 + return -1; 763 708 764 709 return 0; 765 710 } ··· 777 714 return -1; 778 715 779 716 if (test_bit(NF_FLOW_SNAT, &flow->flags)) { 780 - flow_offload_ipv6_snat(net, flow, dir, flow_rule); 781 - flow_offload_port_snat(net, flow, dir, flow_rule); 717 + if (flow_offload_ipv6_snat(net, flow, dir, flow_rule) < 0 || 718 + flow_offload_port_snat(net, flow, dir, flow_rule) < 0) 719 + return -1; 782 720 } 783 721 if (test_bit(NF_FLOW_DNAT, &flow->flags)) { 784 - flow_offload_ipv6_dnat(net, flow, dir, flow_rule); 785 - flow_offload_port_dnat(net, flow, dir, flow_rule); 722 + if (flow_offload_ipv6_dnat(net, flow, dir, flow_rule) < 0 || 723 + flow_offload_port_dnat(net, flow, dir, flow_rule) < 0) 724 + return -1; 786 725 } 787 726 788 - flow_offload_redirect(net, flow, dir, flow_rule); 727 + if (flow_offload_redirect(net, flow, dir, flow_rule) < 0) 728 + return -1; 789 729 790 730 return 0; 791 731 } 792 732 EXPORT_SYMBOL_GPL(nf_flow_rule_route_ipv6); 793 - 794 - #define NF_FLOW_RULE_ACTION_MAX 16 795 733 796 734 static struct nf_flow_rule * 797 735 nf_flow_offload_rule_alloc(struct net *net,
+5 -2
net/netfilter/nf_tables_api.c
··· 11591 11591 switch (data->verdict.code) { 11592 11592 case NF_ACCEPT: 11593 11593 case NF_DROP: 11594 - case NF_QUEUE: 11595 - break; 11596 11594 case NFT_CONTINUE: 11597 11595 case NFT_BREAK: 11598 11596 case NFT_RETURN: ··· 11625 11627 11626 11628 data->verdict.chain = chain; 11627 11629 break; 11630 + case NF_QUEUE: 11631 + /* The nft_queue expression is used for this purpose, an 11632 + * immediate NF_QUEUE verdict should not ever be seen here. 11633 + */ 11634 + fallthrough; 11628 11635 default: 11629 11636 return -EINVAL; 11630 11637 }
+23
net/netfilter/x_tables.c
··· 501 501 par->match->table, par->table); 502 502 return -EINVAL; 503 503 } 504 + 505 + /* NFPROTO_UNSPEC implies NF_INET_* hooks which do not overlap with 506 + * NF_ARP_IN,OUT,FORWARD, allow explicit extensions with NFPROTO_ARP 507 + * support. 508 + */ 509 + if (par->family == NFPROTO_ARP && 510 + par->match->family != NFPROTO_ARP) { 511 + pr_info_ratelimited("%s_tables: %s match: not valid for this family\n", 512 + xt_prefix[par->family], par->match->name); 513 + return -EINVAL; 514 + } 504 515 if (par->match->hooks && (par->hook_mask & ~par->match->hooks) != 0) { 505 516 char used[64], allow[64]; 506 517 ··· 1027 1016 par->target->table, par->table); 1028 1017 return -EINVAL; 1029 1018 } 1019 + 1020 + /* NFPROTO_UNSPEC implies NF_INET_* hooks which do not overlap with 1021 + * NF_ARP_IN,OUT,FORWARD, allow explicit extensions with NFPROTO_ARP 1022 + * support. 1023 + */ 1024 + if (par->family == NFPROTO_ARP && 1025 + par->target->family != NFPROTO_ARP) { 1026 + pr_info_ratelimited("%s_tables: %s target: not valid for this family\n", 1027 + xt_prefix[par->family], par->target->name); 1028 + return -EINVAL; 1029 + } 1030 + 1030 1031 if (par->target->hooks && (par->hook_mask & ~par->target->hooks) != 0) { 1031 1032 char used[64], allow[64]; 1032 1033
+6
net/netfilter/xt_cgroup.c
··· 65 65 66 66 info->priv = NULL; 67 67 if (info->has_path) { 68 + if (strnlen(info->path, sizeof(info->path)) >= sizeof(info->path)) 69 + return -ENAMETOOLONG; 70 + 68 71 cgrp = cgroup_get_from_path(info->path); 69 72 if (IS_ERR(cgrp)) { 70 73 pr_info_ratelimited("invalid path, errno=%ld\n", ··· 105 102 106 103 info->priv = NULL; 107 104 if (info->has_path) { 105 + if (strnlen(info->path, sizeof(info->path)) >= sizeof(info->path)) 106 + return -ENAMETOOLONG; 107 + 108 108 cgrp = cgroup_get_from_path(info->path); 109 109 if (IS_ERR(cgrp)) { 110 110 pr_info_ratelimited("invalid path, errno=%ld\n",
+5
net/netfilter/xt_rateest.c
··· 91 91 goto err1; 92 92 } 93 93 94 + if (strnlen(info->name1, sizeof(info->name1)) >= sizeof(info->name1)) 95 + return -ENAMETOOLONG; 96 + if (strnlen(info->name2, sizeof(info->name2)) >= sizeof(info->name2)) 97 + return -ENAMETOOLONG; 98 + 94 99 ret = -ENOENT; 95 100 est1 = xt_rateest_lookup(par->net, info->name1); 96 101 if (!est1)
+13 -18
net/qrtr/af_qrtr.c
··· 118 118 * @ep: endpoint 119 119 * @ref: reference count for node 120 120 * @nid: node id 121 - * @qrtr_tx_flow: tree of qrtr_tx_flow, keyed by node << 32 | port 121 + * @qrtr_tx_flow: xarray of qrtr_tx_flow, keyed by node << 32 | port 122 122 * @qrtr_tx_lock: lock for qrtr_tx_flow inserts 123 123 * @rx_queue: receive queue 124 124 * @item: list item for broadcast list ··· 129 129 struct kref ref; 130 130 unsigned int nid; 131 131 132 - struct radix_tree_root qrtr_tx_flow; 132 + struct xarray qrtr_tx_flow; 133 133 struct mutex qrtr_tx_lock; /* for qrtr_tx_flow */ 134 134 135 135 struct sk_buff_head rx_queue; ··· 172 172 struct qrtr_tx_flow *flow; 173 173 unsigned long flags; 174 174 void __rcu **slot; 175 + unsigned long index; 175 176 176 177 spin_lock_irqsave(&qrtr_nodes_lock, flags); 177 178 /* If the node is a bridge for other nodes, there are possibly ··· 190 189 skb_queue_purge(&node->rx_queue); 191 190 192 191 /* Free tx flow counters */ 193 - radix_tree_for_each_slot(slot, &node->qrtr_tx_flow, &iter, 0) { 194 - flow = *slot; 195 - radix_tree_iter_delete(&node->qrtr_tx_flow, &iter, slot); 192 + xa_for_each(&node->qrtr_tx_flow, index, flow) 196 193 kfree(flow); 197 - } 194 + xa_destroy(&node->qrtr_tx_flow); 198 195 kfree(node); 199 196 } 200 197 ··· 227 228 228 229 key = remote_node << 32 | remote_port; 229 230 230 - rcu_read_lock(); 231 - flow = radix_tree_lookup(&node->qrtr_tx_flow, key); 232 - rcu_read_unlock(); 231 + flow = xa_load(&node->qrtr_tx_flow, key); 233 232 if (flow) { 234 233 spin_lock(&flow->resume_tx.lock); 235 234 flow->pending = 0; ··· 266 269 return 0; 267 270 268 271 mutex_lock(&node->qrtr_tx_lock); 269 - flow = radix_tree_lookup(&node->qrtr_tx_flow, key); 272 + flow = xa_load(&node->qrtr_tx_flow, key); 270 273 if (!flow) { 271 274 flow = kzalloc_obj(*flow); 272 275 if (flow) { 273 276 init_waitqueue_head(&flow->resume_tx); 274 - if (radix_tree_insert(&node->qrtr_tx_flow, key, flow)) { 277 + if (xa_err(xa_store(&node->qrtr_tx_flow, key, flow, 278 + GFP_KERNEL))) { 275 279 kfree(flow); 276 280 flow = NULL; 277 281 } ··· 324 326 unsigned long key = (u64)dest_node << 32 | dest_port; 325 327 struct qrtr_tx_flow *flow; 326 328 327 - rcu_read_lock(); 328 - flow = radix_tree_lookup(&node->qrtr_tx_flow, key); 329 - rcu_read_unlock(); 329 + flow = xa_load(&node->qrtr_tx_flow, key); 330 330 if (flow) { 331 331 spin_lock_irq(&flow->resume_tx.lock); 332 332 flow->tx_failed = 1; ··· 595 599 node->nid = QRTR_EP_NID_AUTO; 596 600 node->ep = ep; 597 601 598 - INIT_RADIX_TREE(&node->qrtr_tx_flow, GFP_KERNEL); 602 + xa_init(&node->qrtr_tx_flow); 599 603 mutex_init(&node->qrtr_tx_lock); 600 604 601 605 qrtr_node_assign(node, nid); ··· 623 627 struct qrtr_tx_flow *flow; 624 628 struct sk_buff *skb; 625 629 unsigned long flags; 630 + unsigned long index; 626 631 void __rcu **slot; 627 632 628 633 mutex_lock(&node->ep_lock); ··· 646 649 647 650 /* Wake up any transmitters waiting for resume-tx from the node */ 648 651 mutex_lock(&node->qrtr_tx_lock); 649 - radix_tree_for_each_slot(slot, &node->qrtr_tx_flow, &iter, 0) { 650 - flow = *slot; 652 + xa_for_each(&node->qrtr_tx_flow, index, flow) 651 653 wake_up_interruptible_all(&flow->resume_tx); 652 - } 653 654 mutex_unlock(&node->qrtr_tx_lock); 654 655 655 656 qrtr_node_release(node);
+6 -1
net/rds/ib_rdma.c
··· 604 604 return ibmr; 605 605 } 606 606 607 - if (conn) 607 + if (conn) { 608 608 ic = conn->c_transport_data; 609 + if (!ic || !ic->i_cm_id || !ic->i_cm_id->qp) { 610 + ret = -ENODEV; 611 + goto out; 612 + } 613 + } 609 614 610 615 if (!rds_ibdev->mr_8k_pool || !rds_ibdev->mr_1m_pool) { 611 616 ret = -ENODEV;
+1
net/sched/cls_api.c
··· 2969 2969 tcm->tcm__pad1 = 0; 2970 2970 tcm->tcm__pad2 = 0; 2971 2971 tcm->tcm_handle = 0; 2972 + tcm->tcm_info = 0; 2972 2973 if (block->q) { 2973 2974 tcm->tcm_ifindex = qdisc_dev(block->q)->ifindex; 2974 2975 tcm->tcm_parent = block->q->handle;
+9 -1
net/sched/cls_flow.c
··· 503 503 } 504 504 505 505 if (TC_H_MAJ(baseclass) == 0) { 506 - struct Qdisc *q = tcf_block_q(tp->chain->block); 506 + struct tcf_block *block = tp->chain->block; 507 + struct Qdisc *q; 507 508 509 + if (tcf_block_shared(block)) { 510 + NL_SET_ERR_MSG(extack, 511 + "Must specify baseclass when attaching flow filter to block"); 512 + goto err2; 513 + } 514 + 515 + q = tcf_block_q(block); 508 516 baseclass = TC_H_MAKE(q->handle, baseclass); 509 517 } 510 518 if (TC_H_MIN(baseclass) == 0)
+12 -2
net/sched/cls_fw.c
··· 247 247 struct nlattr *tb[TCA_FW_MAX + 1]; 248 248 int err; 249 249 250 - if (!opt) 251 - return handle ? -EINVAL : 0; /* Succeed if it is old method. */ 250 + if (!opt) { 251 + if (handle) 252 + return -EINVAL; 253 + 254 + if (tcf_block_shared(tp->chain->block)) { 255 + NL_SET_ERR_MSG(extack, 256 + "Must specify mark when attaching fw filter to block"); 257 + return -EINVAL; 258 + } 259 + 260 + return 0; /* Succeed if it is old method. */ 261 + } 252 262 253 263 err = nla_parse_nested_deprecated(tb, TCA_FW_MAX, opt, fw_policy, 254 264 NULL);
+2 -2
net/sched/sch_hfsc.c
··· 555 555 rtsc_min(struct runtime_sc *rtsc, struct internal_sc *isc, u64 x, u64 y) 556 556 { 557 557 u64 y1, y2, dx, dy; 558 - u32 dsm; 558 + u64 dsm; 559 559 560 560 if (isc->sm1 <= isc->sm2) { 561 561 /* service curve is convex */ ··· 598 598 */ 599 599 dx = (y1 - y) << SM_SHIFT; 600 600 dsm = isc->sm1 - isc->sm2; 601 - do_div(dx, dsm); 601 + dx = div64_u64(dx, dsm); 602 602 /* 603 603 * check if (x, y1) belongs to the 1st segment of rtsc. 604 604 * if so, add the offset.
+3 -2
net/sched/sch_netem.c
··· 519 519 goto finish_segs; 520 520 } 521 521 522 - skb->data[get_random_u32_below(skb_headlen(skb))] ^= 523 - 1<<get_random_u32_below(8); 522 + if (skb_headlen(skb)) 523 + skb->data[get_random_u32_below(skb_headlen(skb))] ^= 524 + 1 << get_random_u32_below(8); 524 525 } 525 526 526 527 if (unlikely(q->t_len >= sch->limit)) {
+1
net/vmw_vsock/af_vsock.c
··· 2952 2952 net->vsock.mode = vsock_net_child_mode(current->nsproxy->net_ns); 2953 2953 2954 2954 net->vsock.child_ns_mode = net->vsock.mode; 2955 + net->vsock.child_ns_mode_locked = 0; 2955 2956 net->vsock.g2h_fallback = 1; 2956 2957 } 2957 2958
+6 -3
net/x25/x25_in.c
··· 34 34 struct sk_buff *skbo, *skbn = skb; 35 35 struct x25_sock *x25 = x25_sk(sk); 36 36 37 + /* make sure we don't overflow */ 38 + if (x25->fraglen + skb->len > USHRT_MAX) 39 + return 1; 40 + 37 41 if (more) { 38 42 x25->fraglen += skb->len; 39 43 skb_queue_tail(&x25->fragment_queue, skb); ··· 48 44 if (x25->fraglen > 0) { /* End of fragment */ 49 45 int len = x25->fraglen + skb->len; 50 46 51 - if ((skbn = alloc_skb(len, GFP_ATOMIC)) == NULL){ 52 - kfree_skb(skb); 47 + skbn = alloc_skb(len, GFP_ATOMIC); 48 + if (!skbn) 53 49 return 1; 54 - } 55 50 56 51 skb_queue_tail(&x25->fragment_queue, skb); 57 52
+1
net/x25/x25_subr.c
··· 40 40 skb_queue_purge(&x25->interrupt_in_queue); 41 41 skb_queue_purge(&x25->interrupt_out_queue); 42 42 skb_queue_purge(&x25->fragment_queue); 43 + x25->fraglen = 0; 43 44 } 44 45 45 46
+18 -15
rust/kernel/regulator.rs
··· 23 23 prelude::*, 24 24 }; 25 25 26 - use core::{marker::PhantomData, mem::ManuallyDrop, ptr::NonNull}; 26 + use core::{ 27 + marker::PhantomData, 28 + mem::ManuallyDrop, // 29 + }; 27 30 28 31 mod private { 29 32 pub trait Sealed {} ··· 232 229 /// 233 230 /// # Invariants 234 231 /// 235 - /// - `inner` is a non-null wrapper over a pointer to a `struct 236 - /// regulator` obtained from [`regulator_get()`]. 232 + /// - `inner` is a pointer obtained from a successful call to 233 + /// [`regulator_get()`]. It is treated as an opaque token that may only be 234 + /// accessed using C API methods (e.g., it may be `NULL` if the C API returns 235 + /// `NULL`). 237 236 /// 238 237 /// [`regulator_get()`]: https://docs.kernel.org/driver-api/regulator.html#c.regulator_get 239 238 pub struct Regulator<State> 240 239 where 241 240 State: RegulatorState, 242 241 { 243 - inner: NonNull<bindings::regulator>, 242 + inner: *mut bindings::regulator, 244 243 _phantom: PhantomData<State>, 245 244 } 246 245 ··· 254 249 // SAFETY: Safe as per the type invariants of `Regulator`. 255 250 to_result(unsafe { 256 251 bindings::regulator_set_voltage( 257 - self.inner.as_ptr(), 252 + self.inner, 258 253 min_voltage.as_microvolts(), 259 254 max_voltage.as_microvolts(), 260 255 ) ··· 264 259 /// Gets the current voltage of the regulator. 265 260 pub fn get_voltage(&self) -> Result<Voltage> { 266 261 // SAFETY: Safe as per the type invariants of `Regulator`. 267 - let voltage = unsafe { bindings::regulator_get_voltage(self.inner.as_ptr()) }; 262 + let voltage = unsafe { bindings::regulator_get_voltage(self.inner) }; 268 263 269 264 to_result(voltage).map(|()| Voltage::from_microvolts(voltage)) 270 265 } ··· 275 270 // received from the C code. 276 271 from_err_ptr(unsafe { bindings::regulator_get(dev.as_raw(), name.as_char_ptr()) })?; 277 272 278 - // SAFETY: We can safely trust `inner` to be a pointer to a valid 279 - // regulator if `ERR_PTR` was not returned. 280 - let inner = unsafe { NonNull::new_unchecked(inner) }; 281 - 273 + // INVARIANT: `inner` is a pointer obtained from `regulator_get()`, and 274 + // the call was successful. 282 275 Ok(Self { 283 276 inner, 284 277 _phantom: PhantomData, ··· 285 282 286 283 fn enable_internal(&self) -> Result { 287 284 // SAFETY: Safe as per the type invariants of `Regulator`. 288 - to_result(unsafe { bindings::regulator_enable(self.inner.as_ptr()) }) 285 + to_result(unsafe { bindings::regulator_enable(self.inner) }) 289 286 } 290 287 291 288 fn disable_internal(&self) -> Result { 292 289 // SAFETY: Safe as per the type invariants of `Regulator`. 293 - to_result(unsafe { bindings::regulator_disable(self.inner.as_ptr()) }) 290 + to_result(unsafe { bindings::regulator_disable(self.inner) }) 294 291 } 295 292 } 296 293 ··· 352 349 /// Checks if the regulator is enabled. 353 350 pub fn is_enabled(&self) -> bool { 354 351 // SAFETY: Safe as per the type invariants of `Regulator`. 355 - unsafe { bindings::regulator_is_enabled(self.inner.as_ptr()) != 0 } 352 + unsafe { bindings::regulator_is_enabled(self.inner) != 0 } 356 353 } 357 354 } 358 355 ··· 362 359 // SAFETY: By the type invariants, we know that `self` owns a 363 360 // reference on the enabled refcount, so it is safe to relinquish it 364 361 // now. 365 - unsafe { bindings::regulator_disable(self.inner.as_ptr()) }; 362 + unsafe { bindings::regulator_disable(self.inner) }; 366 363 } 367 364 // SAFETY: By the type invariants, we know that `self` owns a reference, 368 365 // so it is safe to relinquish it now. 369 - unsafe { bindings::regulator_put(self.inner.as_ptr()) }; 366 + unsafe { bindings::regulator_put(self.inner) }; 370 367 } 371 368 } 372 369
+3 -2
samples/landlock/sandboxer.c
··· 299 299 300 300 /* clang-format on */ 301 301 302 - #define LANDLOCK_ABI_LAST 7 302 + #define LANDLOCK_ABI_LAST 8 303 303 304 304 #define XSTR(s) #s 305 305 #define STR(s) XSTR(s) ··· 436 436 /* Removes LANDLOCK_RESTRICT_SELF_LOG_NEW_EXEC_ON for ABI < 7 */ 437 437 supported_restrict_flags &= 438 438 ~LANDLOCK_RESTRICT_SELF_LOG_NEW_EXEC_ON; 439 - 439 + __attribute__((fallthrough)); 440 + case 7: 440 441 /* Must be printed for any ABI < LANDLOCK_ABI_LAST. */ 441 442 fprintf(stderr, 442 443 "Hint: You should update the running kernel "
+1 -2
security/landlock/domain.c
··· 94 94 * allocate with GFP_KERNEL_ACCOUNT because it is independent from the 95 95 * caller. 96 96 */ 97 - details = 98 - kzalloc_flex(*details, exe_path, path_size); 97 + details = kzalloc_flex(*details, exe_path, path_size); 99 98 if (!details) 100 99 return ERR_PTR(-ENOMEM); 101 100
+4 -5
security/landlock/ruleset.c
··· 32 32 { 33 33 struct landlock_ruleset *new_ruleset; 34 34 35 - new_ruleset = 36 - kzalloc_flex(*new_ruleset, access_masks, num_layers, 37 - GFP_KERNEL_ACCOUNT); 35 + new_ruleset = kzalloc_flex(*new_ruleset, access_masks, num_layers, 36 + GFP_KERNEL_ACCOUNT); 38 37 if (!new_ruleset) 39 38 return ERR_PTR(-ENOMEM); 40 39 refcount_set(&new_ruleset->usage, 1); ··· 558 559 if (IS_ERR(new_dom)) 559 560 return new_dom; 560 561 561 - new_dom->hierarchy = kzalloc_obj(*new_dom->hierarchy, 562 - GFP_KERNEL_ACCOUNT); 562 + new_dom->hierarchy = 563 + kzalloc_obj(*new_dom->hierarchy, GFP_KERNEL_ACCOUNT); 563 564 if (!new_dom->hierarchy) 564 565 return ERR_PTR(-ENOMEM); 565 566
+73 -19
security/landlock/tsync.c
··· 203 203 return ctx; 204 204 } 205 205 206 + /** 207 + * tsync_works_trim - Put the last tsync_work element 208 + * 209 + * @s: TSYNC works to trim. 210 + * 211 + * Put the last task and decrement the size of @s. 212 + * 213 + * This helper does not cancel a running task, but just reset the last element 214 + * to zero. 215 + */ 216 + static void tsync_works_trim(struct tsync_works *s) 217 + { 218 + struct tsync_work *ctx; 219 + 220 + if (WARN_ON_ONCE(s->size <= 0)) 221 + return; 222 + 223 + ctx = s->works[s->size - 1]; 224 + 225 + /* 226 + * For consistency, remove the task from ctx so that it does not look like 227 + * we handed it a task_work. 228 + */ 229 + put_task_struct(ctx->task); 230 + *ctx = (typeof(*ctx)){}; 231 + 232 + /* 233 + * Cancel the tsync_works_provide() change to recycle the reserved memory 234 + * for the next thread, if any. This also ensures that cancel_tsync_works() 235 + * and tsync_works_release() do not see any NULL task pointers. 236 + */ 237 + s->size--; 238 + } 239 + 206 240 /* 207 241 * tsync_works_grow_by - preallocates space for n more contexts in s 208 242 * ··· 290 256 * tsync_works_contains - checks for presence of task in s 291 257 */ 292 258 static bool tsync_works_contains_task(const struct tsync_works *s, 293 - struct task_struct *task) 259 + const struct task_struct *task) 294 260 { 295 261 size_t i; 296 262 297 263 for (i = 0; i < s->size; i++) 298 264 if (s->works[i]->task == task) 299 265 return true; 266 + 300 267 return false; 301 268 } 302 269 ··· 311 276 size_t i; 312 277 313 278 for (i = 0; i < s->size; i++) { 314 - if (!s->works[i]->task) 279 + if (WARN_ON_ONCE(!s->works[i]->task)) 315 280 continue; 316 281 317 282 put_task_struct(s->works[i]->task); ··· 319 284 320 285 for (i = 0; i < s->capacity; i++) 321 286 kfree(s->works[i]); 287 + 322 288 kfree(s->works); 323 289 s->works = NULL; 324 290 s->size = 0; ··· 331 295 */ 332 296 static size_t count_additional_threads(const struct tsync_works *works) 333 297 { 334 - struct task_struct *thread, *caller; 298 + const struct task_struct *caller, *thread; 335 299 size_t n = 0; 336 300 337 301 caller = current; ··· 370 334 struct tsync_shared_context *shared_ctx) 371 335 { 372 336 int err; 373 - struct task_struct *thread, *caller; 337 + const struct task_struct *caller; 338 + struct task_struct *thread; 374 339 struct tsync_work *ctx; 375 340 bool found_more_threads = false; 376 341 ··· 416 379 417 380 init_task_work(&ctx->work, restrict_one_thread_callback); 418 381 err = task_work_add(thread, &ctx->work, TWA_SIGNAL); 419 - if (err) { 382 + if (unlikely(err)) { 420 383 /* 421 384 * task_work_add() only fails if the task is about to exit. We 422 385 * checked that earlier, but it can happen as a race. Resume 423 386 * without setting an error, as the task is probably gone in the 424 - * next loop iteration. For consistency, remove the task from ctx 425 - * so that it does not look like we handed it a task_work. 387 + * next loop iteration. 426 388 */ 427 - put_task_struct(ctx->task); 428 - ctx->task = NULL; 389 + tsync_works_trim(works); 429 390 430 391 atomic_dec(&shared_ctx->num_preparing); 431 392 atomic_dec(&shared_ctx->num_unfinished); ··· 441 406 * shared_ctx->num_preparing and shared_ctx->num_unfished and mark the two 442 407 * completions if needed, as if the task was never scheduled. 443 408 */ 444 - static void cancel_tsync_works(struct tsync_works *works, 409 + static void cancel_tsync_works(const struct tsync_works *works, 445 410 struct tsync_shared_context *shared_ctx) 446 411 { 447 - int i; 412 + size_t i; 448 413 449 414 for (i = 0; i < works->size; i++) { 415 + if (WARN_ON_ONCE(!works->works[i]->task)) 416 + continue; 417 + 450 418 if (!task_work_cancel(works->works[i]->task, 451 419 &works->works[i]->work)) 452 420 continue; ··· 484 446 shared_ctx.old_cred = old_cred; 485 447 shared_ctx.new_cred = new_cred; 486 448 shared_ctx.set_no_new_privs = task_no_new_privs(current); 449 + 450 + /* 451 + * Serialize concurrent TSYNC operations to prevent deadlocks when 452 + * multiple threads call landlock_restrict_self() simultaneously. 453 + * If the lock is already held, we gracefully yield by restarting the 454 + * syscall. This allows the current thread to process pending 455 + * task_works before retrying. 456 + */ 457 + if (!down_write_trylock(&current->signal->exec_update_lock)) 458 + return restart_syscall(); 487 459 488 460 /* 489 461 * We schedule a pseudo-signal task_work for each of the calling task's ··· 575 527 -ERESTARTNOINTR); 576 528 577 529 /* 578 - * Cancel task works for tasks that did not start running yet, 579 - * and decrement all_prepared and num_unfinished accordingly. 530 + * Opportunistic improvement: try to cancel task 531 + * works for tasks that did not start running 532 + * yet. We do not have a guarantee that it 533 + * cancels any of the enqueued task works 534 + * because task_work_run() might already have 535 + * dequeued them. 580 536 */ 581 537 cancel_tsync_works(&works, &shared_ctx); 582 538 583 539 /* 584 - * The remaining task works have started running, so waiting for 585 - * their completion will finish. 540 + * Break the loop with error. The cleanup code 541 + * after the loop unblocks the remaining 542 + * task_works. 586 543 */ 587 - wait_for_completion(&shared_ctx.all_prepared); 544 + break; 588 545 } 589 546 } 590 547 } while (found_more_threads && 591 548 !atomic_read(&shared_ctx.preparation_error)); 592 549 593 550 /* 594 - * We now have all sibling threads blocking and in "prepared" state in the 595 - * task work. Ask all threads to commit. 551 + * We now have either (a) all sibling threads blocking and in "prepared" 552 + * state in the task work, or (b) the preparation error is set. Ask all 553 + * threads to commit (or abort). 596 554 */ 597 555 complete_all(&shared_ctx.ready_to_commit); 598 556 ··· 610 556 wait_for_completion(&shared_ctx.all_finished); 611 557 612 558 tsync_works_release(&works); 613 - 559 + up_write(&current->signal->exec_update_lock); 614 560 return atomic_read(&shared_ctx.preparation_error); 615 561 }
+1 -1
sound/firewire/amdtp-stream.c
··· 1164 1164 struct pkt_desc *desc = s->packet_descs_cursor; 1165 1165 unsigned int pkt_header_length; 1166 1166 unsigned int packets; 1167 - u32 curr_cycle_time; 1167 + u32 curr_cycle_time = 0; 1168 1168 bool need_hw_irq; 1169 1169 int i; 1170 1170
+86 -8
sound/hda/codecs/realtek/alc269.c
··· 1017 1017 return 0; 1018 1018 } 1019 1019 1020 - #define STARLABS_STARFIGHTER_SHUTUP_DELAY_MS 30 1020 + #define ALC233_STARFIGHTER_SPK_PIN 0x1b 1021 + #define ALC233_STARFIGHTER_GPIO2 0x04 1021 1022 1022 - static void starlabs_starfighter_shutup(struct hda_codec *codec) 1023 + static void alc233_starfighter_update_amp(struct hda_codec *codec, bool on) 1023 1024 { 1024 - if (snd_hda_gen_shutup_speakers(codec)) 1025 - msleep(STARLABS_STARFIGHTER_SHUTUP_DELAY_MS); 1025 + snd_hda_codec_write(codec, ALC233_STARFIGHTER_SPK_PIN, 0, 1026 + AC_VERB_SET_EAPD_BTLENABLE, 1027 + on ? AC_EAPDBTL_EAPD : 0); 1028 + alc_update_gpio_data(codec, ALC233_STARFIGHTER_GPIO2, on); 1029 + } 1030 + 1031 + static void alc233_starfighter_pcm_hook(struct hda_pcm_stream *hinfo, 1032 + struct hda_codec *codec, 1033 + struct snd_pcm_substream *substream, 1034 + int action) 1035 + { 1036 + switch (action) { 1037 + case HDA_GEN_PCM_ACT_PREPARE: 1038 + alc233_starfighter_update_amp(codec, true); 1039 + break; 1040 + case HDA_GEN_PCM_ACT_CLEANUP: 1041 + alc233_starfighter_update_amp(codec, false); 1042 + break; 1043 + } 1026 1044 } 1027 1045 1028 1046 static void alc233_fixup_starlabs_starfighter(struct hda_codec *codec, ··· 1049 1031 { 1050 1032 struct alc_spec *spec = codec->spec; 1051 1033 1052 - if (action == HDA_FIXUP_ACT_PRE_PROBE) 1053 - spec->shutup = starlabs_starfighter_shutup; 1034 + switch (action) { 1035 + case HDA_FIXUP_ACT_PRE_PROBE: 1036 + spec->gpio_mask |= ALC233_STARFIGHTER_GPIO2; 1037 + spec->gpio_dir |= ALC233_STARFIGHTER_GPIO2; 1038 + spec->gpio_data &= ~ALC233_STARFIGHTER_GPIO2; 1039 + break; 1040 + case HDA_FIXUP_ACT_PROBE: 1041 + spec->gen.pcm_playback_hook = alc233_starfighter_pcm_hook; 1042 + break; 1043 + } 1054 1044 } 1055 1045 1056 1046 static void alc269_fixup_pincfg_no_hp_to_lineout(struct hda_codec *codec, ··· 3725 3699 alc_fixup_hp_gpio_led(codec, action, 0x04, 0x0); 3726 3700 alc285_fixup_hp_coef_micmute_led(codec, fix, action); 3727 3701 } 3702 + 3703 + static void alc245_hp_spk_mute_led_update(void *private_data, int enabled) 3704 + { 3705 + struct hda_codec *codec = private_data; 3706 + unsigned int val; 3707 + 3708 + val = enabled ? 0x08 : 0x04; /* 0x08 led on, 0x04 led off */ 3709 + alc_update_coef_idx(codec, 0x0b, 0x0c, val); 3710 + } 3711 + 3728 3712 /* JD2: mute led GPIO3: micmute led */ 3729 3713 static void alc245_tas2781_i2c_hp_fixup_muteled(struct hda_codec *codec, 3730 3714 const struct hda_fixup *fix, int action) 3731 3715 { 3732 3716 struct alc_spec *spec = codec->spec; 3717 + hda_nid_t hp_pin = alc_get_hp_pin(spec); 3733 3718 static const hda_nid_t conn[] = { 0x02 }; 3734 3719 3735 3720 switch (action) { 3736 3721 case HDA_FIXUP_ACT_PRE_PROBE: 3722 + if (!hp_pin) { 3723 + spec->gen.vmaster_mute.hook = alc245_hp_spk_mute_led_update; 3724 + spec->gen.vmaster_mute_led = 1; 3725 + } 3737 3726 spec->gen.auto_mute_via_amp = 1; 3738 3727 snd_hda_override_conn_list(codec, 0x17, ARRAY_SIZE(conn), conn); 3728 + break; 3729 + case HDA_FIXUP_ACT_INIT: 3730 + if (!hp_pin) 3731 + alc245_hp_spk_mute_led_update(codec, !spec->gen.master_mute); 3739 3732 break; 3740 3733 } 3741 3734 3742 3735 tas2781_fixup_txnw_i2c(codec, fix, action); 3743 - alc245_fixup_hp_mute_led_coefbit(codec, fix, action); 3736 + if (hp_pin) 3737 + alc245_fixup_hp_mute_led_coefbit(codec, fix, action); 3744 3738 alc285_fixup_hp_coef_micmute_led(codec, fix, action); 3745 3739 } 3746 3740 /* ··· 4122 4076 ALC233_FIXUP_LENOVO_GPIO2_MIC_HOTKEY, 4123 4077 ALC245_FIXUP_BASS_HP_DAC, 4124 4078 ALC245_FIXUP_ACER_MICMUTE_LED, 4079 + ALC245_FIXUP_CS35L41_I2C_2_MUTE_LED, 4080 + ALC236_FIXUP_HP_DMIC, 4125 4081 }; 4126 4082 4127 4083 /* A special fixup for Lenovo C940 and Yoga Duet 7; ··· 6653 6605 .v.func = alc285_fixup_hp_coef_micmute_led, 6654 6606 .chained = true, 6655 6607 .chain_id = ALC2XX_FIXUP_HEADSET_MIC, 6608 + }, 6609 + [ALC245_FIXUP_CS35L41_I2C_2_MUTE_LED] = { 6610 + .type = HDA_FIXUP_FUNC, 6611 + .v.func = alc245_fixup_hp_mute_led_coefbit, 6612 + .chained = true, 6613 + .chain_id = ALC287_FIXUP_CS35L41_I2C_2, 6614 + }, 6615 + [ALC236_FIXUP_HP_DMIC] = { 6616 + .type = HDA_FIXUP_PINS, 6617 + .v.pins = (const struct hda_pintbl[]) { 6618 + { 0x12, 0x90a60160 }, /* use as internal mic */ 6619 + { } 6620 + }, 6656 6621 } 6657 6622 }; 6658 6623 ··· 6720 6659 SND_PCI_QUIRK(0x1025, 0x1597, "Acer Nitro 5 AN517-55", ALC2XX_FIXUP_HEADSET_MIC), 6721 6660 SND_PCI_QUIRK(0x1025, 0x169a, "Acer Swift SFG16", ALC256_FIXUP_ACER_SFG16_MICMUTE_LED), 6722 6661 SND_PCI_QUIRK(0x1025, 0x171e, "Acer Nitro ANV15-51", ALC245_FIXUP_ACER_MICMUTE_LED), 6662 + SND_PCI_QUIRK(0x1025, 0x173a, "Acer Swift SFG14-73", ALC245_FIXUP_ACER_MICMUTE_LED), 6723 6663 SND_PCI_QUIRK(0x1025, 0x1826, "Acer Helios ZPC", ALC287_FIXUP_PREDATOR_SPK_CS35L41_I2C_2), 6724 6664 SND_PCI_QUIRK(0x1025, 0x182c, "Acer Helios ZPD", ALC287_FIXUP_PREDATOR_SPK_CS35L41_I2C_2), 6725 6665 SND_PCI_QUIRK(0x1025, 0x1844, "Acer Helios ZPS", ALC287_FIXUP_PREDATOR_SPK_CS35L41_I2C_2), ··· 6916 6854 SND_PCI_QUIRK(0x103c, 0x8730, "HP ProBook 445 G7", ALC236_FIXUP_HP_MUTE_LED_MICMUTE_VREF), 6917 6855 SND_PCI_QUIRK(0x103c, 0x8735, "HP ProBook 435 G7", ALC236_FIXUP_HP_MUTE_LED_MICMUTE_VREF), 6918 6856 SND_PCI_QUIRK(0x103c, 0x8736, "HP", ALC285_FIXUP_HP_GPIO_AMP_INIT), 6857 + SND_PCI_QUIRK(0x103c, 0x8756, "HP ENVY Laptop 13-ba0xxx", ALC245_FIXUP_HP_X360_MUTE_LEDS), 6919 6858 SND_PCI_QUIRK(0x103c, 0x8760, "HP EliteBook 8{4,5}5 G7", ALC285_FIXUP_HP_BEEP_MICMUTE_LED), 6920 6859 SND_PCI_QUIRK(0x103c, 0x876e, "HP ENVY x360 Convertible 13-ay0xxx", ALC245_FIXUP_HP_X360_MUTE_LEDS), 6921 6860 SND_PCI_QUIRK(0x103c, 0x877a, "HP", ALC285_FIXUP_HP_MUTE_LED), ··· 6930 6867 SND_PCI_QUIRK(0x103c, 0x8788, "HP OMEN 15", ALC285_FIXUP_HP_MUTE_LED), 6931 6868 SND_PCI_QUIRK(0x103c, 0x87b7, "HP Laptop 14-fq0xxx", ALC236_FIXUP_HP_MUTE_LED_COEFBIT2), 6932 6869 SND_PCI_QUIRK(0x103c, 0x87c8, "HP", ALC287_FIXUP_HP_GPIO_LED), 6870 + SND_PCI_QUIRK(0x103c, 0x87cb, "HP Pavilion 15-eg0xxx", ALC287_FIXUP_HP_GPIO_LED), 6933 6871 SND_PCI_QUIRK(0x103c, 0x87cc, "HP Pavilion 15-eg0xxx", ALC287_FIXUP_HP_GPIO_LED), 6934 6872 SND_PCI_QUIRK(0x103c, 0x87d3, "HP Laptop 15-gw0xxx", ALC236_FIXUP_HP_MUTE_LED_COEFBIT2), 6935 6873 SND_PCI_QUIRK(0x103c, 0x87df, "HP ProBook 430 G8 Notebook PC", ALC236_FIXUP_HP_GPIO_LED), ··· 7018 6954 SND_PCI_QUIRK(0x103c, 0x8a30, "HP Envy 17", ALC287_FIXUP_CS35L41_I2C_2), 7019 6955 SND_PCI_QUIRK(0x103c, 0x8a31, "HP Envy 15", ALC287_FIXUP_CS35L41_I2C_2), 7020 6956 SND_PCI_QUIRK(0x103c, 0x8a34, "HP Pavilion x360 2-in-1 Laptop 14-ek0xxx", ALC245_FIXUP_HP_MUTE_LED_COEFBIT), 6957 + SND_PCI_QUIRK(0x103c, 0x8a3d, "HP Victus 15-fb0xxx (MB 8A3D)", ALC245_FIXUP_HP_MUTE_LED_V2_COEFBIT), 7021 6958 SND_PCI_QUIRK(0x103c, 0x8a4f, "HP Victus 15-fa0xxx (MB 8A4F)", ALC245_FIXUP_HP_MUTE_LED_COEFBIT), 7022 6959 SND_PCI_QUIRK(0x103c, 0x8a6e, "HP EDNA 360", ALC287_FIXUP_CS35L41_I2C_4), 7023 6960 SND_PCI_QUIRK(0x103c, 0x8a74, "HP ProBook 440 G8 Notebook PC", ALC236_FIXUP_HP_GPIO_LED), ··· 7162 7097 SND_PCI_QUIRK(0x103c, 0x8da1, "HP 16 Clipper OmniBook X", ALC287_FIXUP_CS35L41_I2C_2), 7163 7098 SND_PCI_QUIRK(0x103c, 0x8da7, "HP 14 Enstrom OmniBook X", ALC287_FIXUP_CS35L41_I2C_2), 7164 7099 SND_PCI_QUIRK(0x103c, 0x8da8, "HP 16 Piston OmniBook X", ALC287_FIXUP_CS35L41_I2C_2), 7100 + SND_PCI_QUIRK(0x103c, 0x8dc9, "HP Laptop 15-fc0xxx", ALC236_FIXUP_HP_DMIC), 7165 7101 SND_PCI_QUIRK(0x103c, 0x8dd4, "HP EliteStudio 8 AIO", ALC274_FIXUP_HP_AIO_BIND_DACS), 7102 + SND_PCI_QUIRK(0x103c, 0x8dd7, "HP Laptop 15-fd0xxx", ALC236_FIXUP_HP_MUTE_LED_COEFBIT2), 7166 7103 SND_PCI_QUIRK(0x103c, 0x8de8, "HP Gemtree", ALC245_FIXUP_TAS2781_SPI_2), 7167 7104 SND_PCI_QUIRK(0x103c, 0x8de9, "HP Gemtree", ALC245_FIXUP_TAS2781_SPI_2), 7168 7105 SND_PCI_QUIRK(0x103c, 0x8dec, "HP EliteBook 640 G12", ALC236_FIXUP_HP_GPIO_LED), ··· 7195 7128 SND_PCI_QUIRK(0x103c, 0x8e37, "HP 16 Piston OmniBook X", ALC287_FIXUP_CS35L41_I2C_2), 7196 7129 SND_PCI_QUIRK(0x103c, 0x8e3a, "HP Agusta", ALC287_FIXUP_CS35L41_I2C_2), 7197 7130 SND_PCI_QUIRK(0x103c, 0x8e3b, "HP Agusta", ALC287_FIXUP_CS35L41_I2C_2), 7198 - SND_PCI_QUIRK(0x103c, 0x8e60, "HP Trekker ", ALC287_FIXUP_CS35L41_I2C_2), 7131 + SND_PCI_QUIRK(0x103c, 0x8e60, "HP OmniBook 7 Laptop 16-bh0xxx", ALC245_FIXUP_CS35L41_I2C_2_MUTE_LED), 7199 7132 SND_PCI_QUIRK(0x103c, 0x8e61, "HP Trekker ", ALC287_FIXUP_CS35L41_I2C_2), 7200 7133 SND_PCI_QUIRK(0x103c, 0x8e62, "HP Trekker ", ALC287_FIXUP_CS35L41_I2C_2), 7201 7134 SND_PCI_QUIRK(0x103c, 0x8e8a, "HP NexusX", ALC245_FIXUP_HP_TAS2781_I2C_MUTE_LED), ··· 7244 7177 SND_PCI_QUIRK(0x1043, 0x115d, "Asus 1015E", ALC269_FIXUP_LIMIT_INT_MIC_BOOST), 7245 7178 SND_PCI_QUIRK(0x1043, 0x1194, "ASUS UM3406KA", ALC287_FIXUP_CS35L41_I2C_2), 7246 7179 SND_PCI_QUIRK(0x1043, 0x11c0, "ASUS X556UR", ALC255_FIXUP_ASUS_MIC_NO_PRESENCE), 7180 + HDA_CODEC_QUIRK(0x1043, 0x1204, "ASUS Strix G16 G615JMR", ALC287_FIXUP_TXNW2781_I2C_ASUS), 7247 7181 SND_PCI_QUIRK(0x1043, 0x1204, "ASUS Strix G615JHR_JMR_JPR", ALC287_FIXUP_TAS2781_I2C), 7248 7182 SND_PCI_QUIRK(0x1043, 0x1214, "ASUS Strix G615LH_LM_LP", ALC287_FIXUP_TAS2781_I2C), 7249 7183 SND_PCI_QUIRK(0x1043, 0x125e, "ASUS Q524UQK", ALC255_FIXUP_ASUS_MIC_NO_PRESENCE), ··· 7274 7206 SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS G513PI/PU/PV", ALC287_FIXUP_CS35L41_I2C_2), 7275 7207 SND_PCI_QUIRK(0x1043, 0x14f2, "ASUS VivoBook X515JA", ALC256_FIXUP_ASUS_MIC_NO_PRESENCE), 7276 7208 SND_PCI_QUIRK(0x1043, 0x1503, "ASUS G733PY/PZ/PZV/PYV", ALC287_FIXUP_CS35L41_I2C_2), 7209 + SND_PCI_QUIRK(0x1043, 0x1514, "ASUS ROG Flow Z13 GZ302EAC", ALC287_FIXUP_CS35L41_I2C_2), 7277 7210 SND_PCI_QUIRK(0x1043, 0x1517, "Asus Zenbook UX31A", ALC269VB_FIXUP_ASUS_ZENBOOK_UX31A), 7278 7211 SND_PCI_QUIRK(0x1043, 0x1533, "ASUS GV302XA/XJ/XQ/XU/XV/XI", ALC287_FIXUP_CS35L41_I2C_2), 7279 7212 SND_PCI_QUIRK(0x1043, 0x1573, "ASUS GZ301VV/VQ/VU/VJ/VA/VC/VE/VVC/VQC/VUC/VJC/VEC/VCC", ALC285_FIXUP_ASUS_HEADSET_MIC), 7280 7213 SND_PCI_QUIRK(0x1043, 0x1584, "ASUS UM3406GA ", ALC287_FIXUP_CS35L41_I2C_2), 7214 + SND_PCI_QUIRK(0x1043, 0x1602, "ASUS ROG Strix SCAR 15", ALC285_FIXUP_ASUS_G533Z_PINS), 7281 7215 SND_PCI_QUIRK(0x1043, 0x1652, "ASUS ROG Zephyrus Do 15 SE", ALC289_FIXUP_ASUS_ZEPHYRUS_DUAL_SPK), 7282 7216 SND_PCI_QUIRK(0x1043, 0x1662, "ASUS GV301QH", ALC294_FIXUP_ASUS_DUAL_SPK), 7283 7217 SND_PCI_QUIRK(0x1043, 0x1663, "ASUS GU603ZI/ZJ/ZQ/ZU/ZV", ALC285_FIXUP_ASUS_HEADSET_MIC), ··· 7419 7349 SND_PCI_QUIRK(0x144d, 0xc188, "Samsung Galaxy Book Flex (NT950QCT-A38A)", ALC298_FIXUP_SAMSUNG_AMP), 7420 7350 SND_PCI_QUIRK(0x144d, 0xc189, "Samsung Galaxy Book Flex (NT950QCG-X716)", ALC298_FIXUP_SAMSUNG_AMP), 7421 7351 SND_PCI_QUIRK(0x144d, 0xc18a, "Samsung Galaxy Book Ion (NP930XCJ-K01US)", ALC298_FIXUP_SAMSUNG_AMP), 7352 + SND_PCI_QUIRK(0x144d, 0xc1ac, "Samsung Galaxy Book2 Pro 360 (NP950QED)", ALC298_FIXUP_SAMSUNG_AMP_V2_2_AMPS), 7422 7353 SND_PCI_QUIRK(0x144d, 0xc1a3, "Samsung Galaxy Book Pro (NP935XDB-KC1SE)", ALC298_FIXUP_SAMSUNG_AMP), 7423 7354 SND_PCI_QUIRK(0x144d, 0xc1a4, "Samsung Galaxy Book Pro 360 (NT935QBD)", ALC298_FIXUP_SAMSUNG_AMP), 7424 7355 SND_PCI_QUIRK(0x144d, 0xc1a6, "Samsung Galaxy Book Pro 360 (NP930QBD)", ALC298_FIXUP_SAMSUNG_AMP), ··· 7615 7544 SND_PCI_QUIRK(0x17aa, 0x3834, "Lenovo IdeaPad Slim 9i 14ITL5", ALC287_FIXUP_YOGA7_14ITL_SPEAKERS), 7616 7545 SND_PCI_QUIRK(0x17aa, 0x383d, "Legion Y9000X 2019", ALC285_FIXUP_LEGION_Y9000X_SPEAKERS), 7617 7546 SND_PCI_QUIRK(0x17aa, 0x3843, "Lenovo Yoga 9i / Yoga Book 9i", ALC287_FIXUP_LENOVO_YOGA_BOOK_9I), 7547 + /* Yoga Pro 7 14IMH9 shares PCI SSID 17aa:3847 with Legion 7 16ACHG6; 7548 + * use codec SSID to distinguish them 7549 + */ 7550 + HDA_CODEC_QUIRK(0x17aa, 0x38cf, "Lenovo Yoga Pro 7 14IMH9", ALC287_FIXUP_YOGA9_14IMH9_BASS_SPK_PIN), 7618 7551 SND_PCI_QUIRK(0x17aa, 0x3847, "Legion 7 16ACHG6", ALC287_FIXUP_LEGION_16ACHG6), 7619 7552 SND_PCI_QUIRK(0x17aa, 0x384a, "Lenovo Yoga 7 15ITL5", ALC287_FIXUP_YOGA7_14ITL_SPEAKERS), 7620 7553 SND_PCI_QUIRK(0x17aa, 0x3852, "Lenovo Yoga 7 14ITL5", ALC287_FIXUP_YOGA7_14ITL_SPEAKERS), ··· 7650 7575 SND_PCI_QUIRK(0x17aa, 0x38ab, "Thinkbook 16P", ALC287_FIXUP_MG_RTKC_CSAMP_CS35L41_I2C_THINKPAD), 7651 7576 SND_PCI_QUIRK(0x17aa, 0x38b4, "Legion Slim 7 16IRH8", ALC287_FIXUP_CS35L41_I2C_2), 7652 7577 HDA_CODEC_QUIRK(0x17aa, 0x391c, "Lenovo Yoga 7 2-in-1 14AKP10", ALC287_FIXUP_YOGA9_14IAP7_BASS_SPK_PIN), 7578 + HDA_CODEC_QUIRK(0x17aa, 0x391d, "Lenovo Yoga 7 2-in-1 16AKP10", ALC287_FIXUP_YOGA9_14IAP7_BASS_SPK_PIN), 7653 7579 SND_PCI_QUIRK(0x17aa, 0x38b5, "Legion Slim 7 16IRH8", ALC287_FIXUP_CS35L41_I2C_2), 7654 7580 SND_PCI_QUIRK(0x17aa, 0x38b6, "Legion Slim 7 16APH8", ALC287_FIXUP_CS35L41_I2C_2), 7655 7581 SND_PCI_QUIRK(0x17aa, 0x38b7, "Legion Slim 7 16APH8", ALC287_FIXUP_CS35L41_I2C_2), ··· 7681 7605 SND_PCI_QUIRK(0x17aa, 0x3902, "Lenovo E50-80", ALC269_FIXUP_DMIC_THINKPAD_ACPI), 7682 7606 SND_PCI_QUIRK(0x17aa, 0x390d, "Lenovo Yoga Pro 7 14ASP10", ALC287_FIXUP_YOGA9_14IAP7_BASS_SPK_PIN), 7683 7607 SND_PCI_QUIRK(0x17aa, 0x3913, "Lenovo 145", ALC236_FIXUP_LENOVO_INV_DMIC), 7608 + SND_PCI_QUIRK(0x17aa, 0x391a, "Lenovo Yoga Slim 7 14AKP10", ALC287_FIXUP_YOGA9_14IAP7_BASS_SPK_PIN), 7684 7609 SND_PCI_QUIRK(0x17aa, 0x391f, "Yoga S990-16 pro Quad YC Quad", ALC287_FIXUP_TXNW2781_I2C), 7685 7610 SND_PCI_QUIRK(0x17aa, 0x3920, "Yoga S990-16 pro Quad VECO Quad", ALC287_FIXUP_TXNW2781_I2C), 7686 7611 SND_PCI_QUIRK(0x17aa, 0x3929, "Thinkbook 13x Gen 5", ALC287_FIXUP_MG_RTKC_CSAMP_CS35L41_I2C_THINKPAD), ··· 7775 7698 SND_PCI_QUIRK(0xf111, 0x0009, "Framework Laptop", ALC295_FIXUP_FRAMEWORK_LAPTOP_MIC_NO_PRESENCE), 7776 7699 SND_PCI_QUIRK(0xf111, 0x000b, "Framework Laptop", ALC295_FIXUP_FRAMEWORK_LAPTOP_MIC_NO_PRESENCE), 7777 7700 SND_PCI_QUIRK(0xf111, 0x000c, "Framework Laptop", ALC295_FIXUP_FRAMEWORK_LAPTOP_MIC_NO_PRESENCE), 7701 + SND_PCI_QUIRK(0xf111, 0x000f, "Framework Laptop", ALC295_FIXUP_FRAMEWORK_LAPTOP_MIC_NO_PRESENCE), 7778 7702 7779 7703 #if 0 7780 7704 /* Below is a quirk table taken from the old code.
+13 -1
sound/hda/controllers/intel.c
··· 2077 2077 { PCI_DEVICE_SUB(0x1022, 0x1487, 0x1043, 0x874f) }, /* ASUS ROG Zenith II / Strix */ 2078 2078 { PCI_DEVICE_SUB(0x1022, 0x1487, 0x1462, 0xcb59) }, /* MSI TRX40 Creator */ 2079 2079 { PCI_DEVICE_SUB(0x1022, 0x1487, 0x1462, 0xcb60) }, /* MSI TRX40 */ 2080 - { PCI_DEVICE_SUB(0x1022, 0x15e3, 0x1462, 0xee59) }, /* MSI X870E Tomahawk WiFi */ 2081 2080 {} 2082 2081 }; 2083 2082 2084 2083 static struct pci_device_id driver_denylist_ideapad_z570[] = { 2085 2084 { PCI_DEVICE_SUB(0x10de, 0x0bea, 0x0000, 0x0000) }, /* NVIDIA GF108 HDA */ 2085 + {} 2086 + }; 2087 + 2088 + static struct pci_device_id driver_denylist_msi_x870e[] = { 2089 + { PCI_DEVICE_SUB(0x1022, 0x15e3, 0x1462, 0xee59) }, /* MSI X870E Tomahawk WiFi */ 2086 2090 {} 2087 2091 }; 2088 2092 ··· 2102 2098 DMI_MATCH(DMI_PRODUCT_VERSION, "Ideapad Z570"), 2103 2099 }, 2104 2100 .driver_data = &driver_denylist_ideapad_z570, 2101 + }, 2102 + { 2103 + /* PCI device matching alone incorrectly matches some laptops */ 2104 + .matches = { 2105 + DMI_MATCH(DMI_BOARD_VENDOR, "Micro-Star International Co., Ltd."), 2106 + DMI_MATCH(DMI_BOARD_NAME, "MAG X870E TOMAHAWK WIFI (MS-7E59)"), 2107 + }, 2108 + .driver_data = &driver_denylist_msi_x870e, 2105 2109 }, 2106 2110 {} 2107 2111 };
+4 -2
sound/pci/asihpi/hpimsgx.c
··· 581 581 HPI_ADAPTER_OPEN); 582 582 hm.adapter_index = adapter; 583 583 hw_entry_point(&hm, &hr); 584 - memcpy(&rESP_HPI_ADAPTER_OPEN[adapter], &hr, 585 - sizeof(rESP_HPI_ADAPTER_OPEN[0])); 584 + memcpy(&rESP_HPI_ADAPTER_OPEN[adapter].h, &hr, 585 + sizeof(rESP_HPI_ADAPTER_OPEN[adapter].h)); 586 + memcpy(&rESP_HPI_ADAPTER_OPEN[adapter].a, &hr.u.ax.info, 587 + sizeof(rESP_HPI_ADAPTER_OPEN[adapter].a)); 586 588 if (hr.error) 587 589 return hr.error; 588 590
+7 -3
sound/pci/ctxfi/ctatc.c
··· 1427 1427 daio_mgr = (struct daio_mgr *)atc->rsc_mgrs[DAIO]; 1428 1428 da_desc.msr = atc->msr; 1429 1429 for (i = 0; i < NUM_DAIOTYP; i++) { 1430 - if (((i == MIC) && !cap.dedicated_mic) || ((i == RCA) && !cap.dedicated_rca)) 1430 + if (((i == MIC) && !cap.dedicated_mic) || 1431 + ((i == RCA) && !cap.dedicated_rca) || 1432 + i == SPDIFI1) 1431 1433 continue; 1432 - da_desc.type = (atc->model != CTSB073X) ? i : 1433 - ((i == SPDIFIO) ? SPDIFI1 : i); 1434 + if (atc->model == CTSB073X && i == SPDIFIO) 1435 + da_desc.type = SPDIFI1; 1436 + else 1437 + da_desc.type = i; 1434 1438 da_desc.output = (i < LINEIM) || (i == RCA); 1435 1439 err = daio_mgr->get_daio(daio_mgr, &da_desc, 1436 1440 (struct daio **)&atc->daios[i]);
+51 -31
sound/pci/ctxfi/ctdaio.c
··· 99 99 .output_slot = daio_index, 100 100 }; 101 101 102 - static unsigned int daio_device_index(enum DAIOTYP type, struct hw *hw) 102 + static int daio_device_index(enum DAIOTYP type, struct hw *hw) 103 103 { 104 104 switch (hw->chip_type) { 105 105 case ATC20K1: ··· 112 112 case LINEO3: return 5; 113 113 case LINEO4: return 6; 114 114 case LINEIM: return 7; 115 - default: return -EINVAL; 115 + default: 116 + pr_err("ctxfi: Invalid type %d for hw20k1\n", type); 117 + return -EINVAL; 116 118 } 117 119 case ATC20K2: 118 120 switch (type) { 119 121 case SPDIFOO: return 0; 120 122 case SPDIFIO: return 0; 123 + case SPDIFI1: return 1; 121 124 case LINEO1: return 4; 122 125 case LINEO2: return 7; 123 126 case LINEO3: return 5; ··· 128 125 case LINEIM: return 4; 129 126 case MIC: return 5; 130 127 case RCA: return 3; 131 - default: return -EINVAL; 128 + default: 129 + pr_err("ctxfi: Invalid type %d for hw20k2\n", type); 130 + return -EINVAL; 132 131 } 133 132 default: 133 + pr_err("ctxfi: Invalid chip type %d\n", hw->chip_type); 134 134 return -EINVAL; 135 135 } 136 136 } ··· 154 148 155 149 static int dao_commit_write(struct dao *dao) 156 150 { 157 - dao->hw->dao_commit_write(dao->hw, 158 - daio_device_index(dao->daio.type, dao->hw), dao->ctrl_blk); 151 + int idx = daio_device_index(dao->daio.type, dao->hw); 152 + 153 + if (idx < 0) 154 + return idx; 155 + dao->hw->dao_commit_write(dao->hw, idx, dao->ctrl_blk); 159 156 return 0; 160 157 } 161 158 ··· 296 287 297 288 static int dai_commit_write(struct dai *dai) 298 289 { 299 - dai->hw->dai_commit_write(dai->hw, 300 - daio_device_index(dai->daio.type, dai->hw), dai->ctrl_blk); 290 + int idx = daio_device_index(dai->daio.type, dai->hw); 291 + 292 + if (idx < 0) 293 + return idx; 294 + dai->hw->dai_commit_write(dai->hw, idx, dai->ctrl_blk); 301 295 return 0; 302 296 } 303 297 ··· 379 367 { 380 368 struct hw *hw = mgr->mgr.hw; 381 369 unsigned int conf; 382 - int err; 370 + int idx, err; 383 371 384 372 err = daio_rsc_init(&dao->daio, desc, mgr->mgr.hw); 385 373 if (err) ··· 398 386 if (err) 399 387 goto error2; 400 388 401 - hw->daio_mgr_dsb_dao(mgr->mgr.ctrl_blk, 402 - daio_device_index(dao->daio.type, hw)); 389 + idx = daio_device_index(dao->daio.type, hw); 390 + if (idx < 0) { 391 + err = idx; 392 + goto error2; 393 + } 394 + 395 + hw->daio_mgr_dsb_dao(mgr->mgr.ctrl_blk, idx); 403 396 hw->daio_mgr_commit_write(hw, mgr->mgr.ctrl_blk); 404 397 405 398 conf = (desc->msr & 0x7) | (desc->passthru << 3); 406 - hw->daio_mgr_dao_init(hw, mgr->mgr.ctrl_blk, 407 - daio_device_index(dao->daio.type, hw), conf); 408 - hw->daio_mgr_enb_dao(mgr->mgr.ctrl_blk, 409 - daio_device_index(dao->daio.type, hw)); 399 + hw->daio_mgr_dao_init(hw, mgr->mgr.ctrl_blk, idx, conf); 400 + hw->daio_mgr_enb_dao(mgr->mgr.ctrl_blk, idx); 410 401 hw->daio_mgr_commit_write(hw, mgr->mgr.ctrl_blk); 411 402 412 403 return 0; ··· 458 443 const struct daio_desc *desc, 459 444 struct daio_mgr *mgr) 460 445 { 461 - int err; 446 + int idx, err; 462 447 struct hw *hw = mgr->mgr.hw; 463 448 unsigned int rsr, msr; 464 449 ··· 472 457 if (err) 473 458 goto error1; 474 459 460 + idx = daio_device_index(dai->daio.type, dai->hw); 461 + if (idx < 0) { 462 + err = idx; 463 + goto error1; 464 + } 465 + 475 466 for (rsr = 0, msr = desc->msr; msr > 1; msr >>= 1) 476 467 rsr++; 477 468 ··· 486 465 /* default to disabling control of a SRC */ 487 466 hw->dai_srt_set_ec(dai->ctrl_blk, 0); 488 467 hw->dai_srt_set_et(dai->ctrl_blk, 0); /* default to disabling SRT */ 489 - hw->dai_commit_write(hw, 490 - daio_device_index(dai->daio.type, dai->hw), dai->ctrl_blk); 468 + hw->dai_commit_write(hw, idx, dai->ctrl_blk); 491 469 492 470 return 0; 493 471 ··· 601 581 static int daio_mgr_enb_daio(struct daio_mgr *mgr, struct daio *daio) 602 582 { 603 583 struct hw *hw = mgr->mgr.hw; 584 + int idx = daio_device_index(daio->type, hw); 604 585 605 - if (daio->output) { 606 - hw->daio_mgr_enb_dao(mgr->mgr.ctrl_blk, 607 - daio_device_index(daio->type, hw)); 608 - } else { 609 - hw->daio_mgr_enb_dai(mgr->mgr.ctrl_blk, 610 - daio_device_index(daio->type, hw)); 611 - } 586 + if (idx < 0) 587 + return idx; 588 + if (daio->output) 589 + hw->daio_mgr_enb_dao(mgr->mgr.ctrl_blk, idx); 590 + else 591 + hw->daio_mgr_enb_dai(mgr->mgr.ctrl_blk, idx); 612 592 return 0; 613 593 } 614 594 615 595 static int daio_mgr_dsb_daio(struct daio_mgr *mgr, struct daio *daio) 616 596 { 617 597 struct hw *hw = mgr->mgr.hw; 598 + int idx = daio_device_index(daio->type, hw); 618 599 619 - if (daio->output) { 620 - hw->daio_mgr_dsb_dao(mgr->mgr.ctrl_blk, 621 - daio_device_index(daio->type, hw)); 622 - } else { 623 - hw->daio_mgr_dsb_dai(mgr->mgr.ctrl_blk, 624 - daio_device_index(daio->type, hw)); 625 - } 600 + if (idx < 0) 601 + return idx; 602 + if (daio->output) 603 + hw->daio_mgr_dsb_dao(mgr->mgr.ctrl_blk, idx); 604 + else 605 + hw->daio_mgr_dsb_dai(mgr->mgr.ctrl_blk, idx); 626 606 return 0; 627 607 } 628 608
+14 -1
sound/soc/amd/acp-config.c
··· 23 23 24 24 static int acp_quirk_data; 25 25 26 + static const struct dmi_system_id acp70_acpi_flag_override_table[] = { 27 + { 28 + .matches = { 29 + DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK COMPUTER INC."), 30 + DMI_MATCH(DMI_PRODUCT_NAME, "HN7306EA"), 31 + }, 32 + }, 33 + {} 34 + }; 35 + 26 36 static const struct config_entry config_table[] = { 27 37 { 28 38 .flags = FLAG_AMD_SOF, ··· 196 186 */ 197 187 if (!pci->revision) 198 188 return 0; 199 - else if (pci->revision >= ACP_7_0_REV) 189 + else if (pci->revision >= ACP_7_0_REV) { 190 + if (dmi_check_system(acp70_acpi_flag_override_table)) 191 + return 0; 200 192 return snd_amd_acp_acpi_find_config(pci); 193 + } 201 194 202 195 for (i = 0; i < ARRAY_SIZE(config_table); i++, table++) { 203 196 if (table->device != device)
+8
sound/soc/amd/acp/acp-sdw-legacy-mach.c
··· 111 111 }, 112 112 .driver_data = (void *)(ASOC_SDW_CODEC_SPKR), 113 113 }, 114 + { 115 + .callback = soc_sdw_quirk_cb, 116 + .matches = { 117 + DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK COMPUTER INC."), 118 + DMI_MATCH(DMI_PRODUCT_NAME, "HN7306EA"), 119 + }, 120 + .driver_data = (void *)(ASOC_SDW_ACP_DMIC), 121 + }, 114 122 {} 115 123 }; 116 124
+61
sound/soc/amd/acp/amd-acp70-acpi-match.c
··· 69 69 }, 70 70 }; 71 71 72 + static const struct snd_soc_acpi_endpoint jack_dmic_endpoints[] = { 73 + /* Jack Endpoint */ 74 + { 75 + .num = 0, 76 + .aggregated = 0, 77 + .group_position = 0, 78 + .group_id = 0, 79 + }, 80 + /* DMIC Endpoint */ 81 + { 82 + /* 83 + * rt721 endpoint #2 maps to AIF3 (internal DMIC capture). 84 + * Endpoint #1 is AIF2 amp path and is handled by external amps 85 + * on this platform. 86 + */ 87 + .num = 2, 88 + .aggregated = 0, 89 + .group_position = 0, 90 + .group_id = 0, 91 + }, 92 + }; 93 + 72 94 static const struct snd_soc_acpi_adr_device rt712_vb_1_group1_adr[] = { 73 95 { 74 96 .adr = 0x000130025D071201ull, ··· 585 563 {} 586 564 }; 587 565 566 + static const struct snd_soc_acpi_adr_device rt721_l1u0_tas2783x2_l1u8b_adr[] = { 567 + { 568 + .adr = 0x000130025D072101ull, 569 + /* 570 + * On this platform speakers are provided by two TAS2783 amps. 571 + * Keep rt721 as UAJ + DMIC only. 572 + */ 573 + .num_endpoints = ARRAY_SIZE(jack_dmic_endpoints), 574 + .endpoints = jack_dmic_endpoints, 575 + .name_prefix = "rt721", 576 + }, 577 + { 578 + .adr = 0x0001380102000001ull, 579 + .num_endpoints = 1, 580 + .endpoints = &spk_l_endpoint, 581 + .name_prefix = "tas2783-1", 582 + }, 583 + { 584 + .adr = 0x00013B0102000001ull, 585 + .num_endpoints = 1, 586 + .endpoints = &spk_r_endpoint, 587 + .name_prefix = "tas2783-2", 588 + }, 589 + }; 590 + 591 + static const struct snd_soc_acpi_link_adr acp70_rt721_l1u0_tas2783x2_l1u8b[] = { 592 + { 593 + .mask = BIT(1), 594 + .num_adr = ARRAY_SIZE(rt721_l1u0_tas2783x2_l1u8b_adr), 595 + .adr_d = rt721_l1u0_tas2783x2_l1u8b_adr, 596 + }, 597 + {} 598 + }; 599 + 588 600 struct snd_soc_acpi_mach snd_soc_acpi_amd_acp70_sdw_machines[] = { 589 601 { 590 602 .link_mask = BIT(0) | BIT(1), ··· 704 648 .link_mask = BIT(1), 705 649 .links = acp70_alc712_vb_l1, 706 650 .machine_check = snd_soc_acpi_amd_sdca_is_device_rt712_vb, 651 + .drv_name = "amd_sdw", 652 + }, 653 + { 654 + .link_mask = BIT(1), 655 + .links = acp70_rt721_l1u0_tas2783x2_l1u8b, 707 656 .drv_name = "amd_sdw", 708 657 }, 709 658 {},
+1 -1
sound/soc/amd/ps/pci-ps.c
··· 339 339 mach->mach_params.subsystem_device = acp_data->subsystem_device; 340 340 mach->mach_params.subsystem_id_set = true; 341 341 342 - dev_dbg(dev, "SSID %x%x\n", mach->mach_params.subsystem_vendor, 342 + dev_dbg(dev, "SSID %x%04x\n", mach->mach_params.subsystem_vendor, 343 343 mach->mach_params.subsystem_device); 344 344 return mach; 345 345 }
+28
sound/soc/amd/yc/acp6x-mach.c
··· 48 48 { 49 49 .driver_data = &acp6x_card, 50 50 .matches = { 51 + DMI_MATCH(DMI_BOARD_VENDOR, "HP"), 52 + DMI_MATCH(DMI_PRODUCT_NAME, "HP Laptop 15-fc0xxx"), 53 + } 54 + }, 55 + { 56 + .driver_data = &acp6x_card, 57 + .matches = { 51 58 DMI_MATCH(DMI_BOARD_VENDOR, "Dell Inc."), 52 59 DMI_MATCH(DMI_PRODUCT_NAME, "Dell G15 5525"), 53 60 } ··· 722 715 .matches = { 723 716 DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK COMPUTER INC."), 724 717 DMI_MATCH(DMI_BOARD_NAME, "PM1503CDA"), 718 + } 719 + }, 720 + { 721 + .driver_data = &acp6x_card, 722 + .matches = { 723 + DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK COMPUTER INC."), 724 + DMI_MATCH(DMI_BOARD_NAME, "BM1403CDA"), 725 + } 726 + }, 727 + { 728 + .driver_data = &acp6x_card, 729 + .matches = { 730 + DMI_MATCH(DMI_BOARD_VENDOR, "Micro-Star International Co., Ltd."), 731 + DMI_MATCH(DMI_PRODUCT_NAME, "Thin A15 B7VE"), 732 + } 733 + }, 734 + { 735 + .driver_data = &acp6x_card, 736 + .matches = { 737 + DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK COMPUTER INC."), 738 + DMI_MATCH(DMI_PRODUCT_NAME, "M7601RM"), 725 739 } 726 740 }, 727 741 {}
+24 -10
sound/soc/cirrus/ep93xx-i2s.c
··· 91 91 return __raw_readl(info->regs + reg); 92 92 } 93 93 94 - static void ep93xx_i2s_enable(struct ep93xx_i2s_info *info, int stream) 94 + static int ep93xx_i2s_enable(struct ep93xx_i2s_info *info, int stream) 95 95 { 96 96 unsigned base_reg; 97 + int err; 97 98 98 99 if ((ep93xx_i2s_read_reg(info, EP93XX_I2S_TX0EN) & 0x1) == 0 && 99 100 (ep93xx_i2s_read_reg(info, EP93XX_I2S_RX0EN) & 0x1) == 0) { 100 101 /* Enable clocks */ 101 - clk_prepare_enable(info->mclk); 102 - clk_prepare_enable(info->sclk); 103 - clk_prepare_enable(info->lrclk); 102 + err = clk_prepare_enable(info->mclk); 103 + if (err) 104 + return err; 105 + err = clk_prepare_enable(info->sclk); 106 + if (err) { 107 + clk_disable_unprepare(info->mclk); 108 + return err; 109 + } 110 + err = clk_prepare_enable(info->lrclk); 111 + if (err) { 112 + clk_disable_unprepare(info->sclk); 113 + clk_disable_unprepare(info->mclk); 114 + return err; 115 + } 104 116 105 117 /* Enable i2s */ 106 118 ep93xx_i2s_write_reg(info, EP93XX_I2S_GLCTRL, 1); ··· 131 119 ep93xx_i2s_write_reg(info, EP93XX_I2S_TXCTRL, 132 120 EP93XX_I2S_TXCTRL_TXEMPTY_LVL | 133 121 EP93XX_I2S_TXCTRL_TXUFIE); 122 + 123 + return 0; 134 124 } 135 125 136 126 static void ep93xx_i2s_disable(struct ep93xx_i2s_info *info, int stream) ··· 209 195 { 210 196 struct ep93xx_i2s_info *info = snd_soc_dai_get_drvdata(dai); 211 197 212 - ep93xx_i2s_enable(info, substream->stream); 213 - 214 - return 0; 198 + return ep93xx_i2s_enable(info, substream->stream); 215 199 } 216 200 217 201 static void ep93xx_i2s_shutdown(struct snd_pcm_substream *substream, ··· 385 373 static int ep93xx_i2s_resume(struct snd_soc_component *component) 386 374 { 387 375 struct ep93xx_i2s_info *info = snd_soc_component_get_drvdata(component); 376 + int err; 388 377 389 378 if (!snd_soc_component_active(component)) 390 379 return 0; 391 380 392 - ep93xx_i2s_enable(info, SNDRV_PCM_STREAM_PLAYBACK); 393 - ep93xx_i2s_enable(info, SNDRV_PCM_STREAM_CAPTURE); 381 + err = ep93xx_i2s_enable(info, SNDRV_PCM_STREAM_PLAYBACK); 382 + if (err) 383 + return err; 394 384 395 - return 0; 385 + return ep93xx_i2s_enable(info, SNDRV_PCM_STREAM_CAPTURE); 396 386 } 397 387 #else 398 388 #define ep93xx_i2s_suspend NULL
+24 -10
sound/soc/codecs/adau1372.c
··· 762 762 return 0; 763 763 } 764 764 765 - static void adau1372_enable_pll(struct adau1372 *adau1372) 765 + static int adau1372_enable_pll(struct adau1372 *adau1372) 766 766 { 767 767 unsigned int val, timeout = 0; 768 768 int ret; ··· 778 778 timeout++; 779 779 } while (!(val & 1) && timeout < 3); 780 780 781 - if (ret < 0 || !(val & 1)) 781 + if (ret < 0 || !(val & 1)) { 782 782 dev_err(adau1372->dev, "Failed to lock PLL\n"); 783 + return ret < 0 ? ret : -ETIMEDOUT; 784 + } 785 + 786 + return 0; 783 787 } 784 788 785 - static void adau1372_set_power(struct adau1372 *adau1372, bool enable) 789 + static int adau1372_set_power(struct adau1372 *adau1372, bool enable) 786 790 { 787 791 if (adau1372->enabled == enable) 788 - return; 792 + return 0; 789 793 790 794 if (enable) { 791 795 unsigned int clk_ctrl = ADAU1372_CLK_CTRL_MCLK_EN; 796 + int ret; 792 797 793 - clk_prepare_enable(adau1372->mclk); 798 + ret = clk_prepare_enable(adau1372->mclk); 799 + if (ret) 800 + return ret; 794 801 if (adau1372->pd_gpio) 795 802 gpiod_set_value(adau1372->pd_gpio, 0); 796 803 ··· 811 804 * accessed. 812 805 */ 813 806 if (adau1372->use_pll) { 814 - adau1372_enable_pll(adau1372); 807 + ret = adau1372_enable_pll(adau1372); 808 + if (ret) { 809 + regcache_cache_only(adau1372->regmap, true); 810 + if (adau1372->pd_gpio) 811 + gpiod_set_value(adau1372->pd_gpio, 1); 812 + clk_disable_unprepare(adau1372->mclk); 813 + return ret; 814 + } 815 815 clk_ctrl |= ADAU1372_CLK_CTRL_CLKSRC; 816 816 } 817 817 ··· 843 829 } 844 830 845 831 adau1372->enabled = enable; 832 + 833 + return 0; 846 834 } 847 835 848 836 static int adau1372_set_bias_level(struct snd_soc_component *component, ··· 858 842 case SND_SOC_BIAS_PREPARE: 859 843 break; 860 844 case SND_SOC_BIAS_STANDBY: 861 - adau1372_set_power(adau1372, true); 862 - break; 845 + return adau1372_set_power(adau1372, true); 863 846 case SND_SOC_BIAS_OFF: 864 - adau1372_set_power(adau1372, false); 865 - break; 847 + return adau1372_set_power(adau1372, false); 866 848 } 867 849 868 850 return 0;
+4 -2
sound/soc/codecs/sma1307.c
··· 1759 1759 sma1307->set.mode_size * 2 * sizeof(int), 1760 1760 GFP_KERNEL); 1761 1761 if (!sma1307->set.mode_set[i]) { 1762 - for (int j = 0; j < i; j++) 1763 - kfree(sma1307->set.mode_set[j]); 1762 + for (int j = 0; j < i; j++) { 1763 + devm_kfree(sma1307->dev, sma1307->set.mode_set[j]); 1764 + sma1307->set.mode_set[j] = NULL; 1765 + } 1764 1766 sma1307->set.status = false; 1765 1767 return; 1766 1768 }
+3
sound/soc/codecs/tas2781-fmwlib.c
··· 2550 2550 int k = i * (cali_data->cali_dat_sz_per_dev + 1); 2551 2551 int rc; 2552 2552 2553 + if (!data || !cali_data->total_sz) 2554 + return; 2555 + 2553 2556 if (data[k] != i) { 2554 2557 dev_err(priv->dev, "%s: no cal-data for dev %d from usr-spc\n", 2555 2558 __func__, i);
+1 -1
sound/soc/codecs/wcd934x.c
··· 2172 2172 u32 def_dmic_rate, dmic_clk_drv; 2173 2173 int ret; 2174 2174 2175 - ret = wcd_dt_parse_mbhc_data(comp->dev, &wcd->mbhc_cfg); 2175 + ret = wcd_dt_parse_micbias_info(&wcd->common); 2176 2176 if (ret) 2177 2177 return ret; 2178 2178
+2
sound/soc/fsl/imx-card.c
··· 710 710 link->ops = &imx_aif_ops; 711 711 } 712 712 713 + playback_only = false; 714 + capture_only = false; 713 715 graph_util_parse_link_direction(np, &playback_only, &capture_only); 714 716 link->playback_only = playback_only; 715 717 link->capture_only = capture_only;
+2 -2
sound/soc/generic/simple-card-utils.c
··· 1183 1183 bool is_playback_only = of_property_read_bool(np, "playback-only"); 1184 1184 bool is_capture_only = of_property_read_bool(np, "capture-only"); 1185 1185 1186 - if (np && playback_only) 1186 + if (playback_only && is_playback_only) 1187 1187 *playback_only = is_playback_only; 1188 - if (np && capture_only) 1188 + if (capture_only && is_capture_only) 1189 1189 *capture_only = is_capture_only; 1190 1190 } 1191 1191 EXPORT_SYMBOL_GPL(graph_util_parse_link_direction);
-2
sound/soc/intel/boards/Kconfig
··· 530 530 select SND_SOC_CS42L43_SDW 531 531 select MFD_CS42L43 532 532 select MFD_CS42L43_SDW 533 - select PINCTRL_CS42L43 534 - select SPI_CS42L43 535 533 select SND_SOC_CS35L56_SPI 536 534 select SND_SOC_CS35L56_SDW 537 535 select SND_SOC_DMIC
+1 -1
sound/soc/intel/boards/ehl_rt5660.c
··· 127 127 params_rate(params) * 50, 128 128 params_rate(params) * 512); 129 129 if (ret < 0) 130 - dev_err(codec_dai->dev, "can't set codec pll: %d\n", ret); 130 + dev_err(rtd->dev, "can't set codec pll: %d\n", ret); 131 131 132 132 return ret; 133 133 }
+9 -1
sound/soc/intel/catpt/device.c
··· 281 281 if (IS_ERR(cdev->pci_ba)) 282 282 return PTR_ERR(cdev->pci_ba); 283 283 284 - /* alloc buffer for storing DRAM context during dx transitions */ 284 + /* 285 + * As per design HOST is responsible for preserving firmware's runtime 286 + * context during D0 -> D3 -> D0 transitions. Addresses used for DMA 287 + * to/from HOST memory shall be outside the reserved range of 0xFFFxxxxx. 288 + */ 289 + ret = dma_coerce_mask_and_coherent(cdev->dev, DMA_BIT_MASK(31)); 290 + if (ret) 291 + return ret; 292 + 285 293 cdev->dxbuf_vaddr = dmam_alloc_coherent(dev, catpt_dram_size(cdev), 286 294 &cdev->dxbuf_paddr, GFP_KERNEL); 287 295 if (!cdev->dxbuf_vaddr)
-3
sound/soc/intel/catpt/dsp.c
··· 125 125 dmac->dev = cdev->dev; 126 126 dmac->irq = cdev->irq; 127 127 128 - ret = dma_coerce_mask_and_coherent(cdev->dev, DMA_BIT_MASK(31)); 129 - if (ret) 130 - return ret; 131 128 /* 132 129 * Caller is responsible for putting device in D0 to allow 133 130 * for I/O and memory access before probing DW.
+10 -4
sound/soc/sdca/sdca_functions.c
··· 216 216 } else if (num_init_writes % sizeof(*raw) != 0) { 217 217 dev_err(dev, "%pfwP: init table size invalid\n", function_node); 218 218 return -EINVAL; 219 - } else if ((num_init_writes / sizeof(*raw)) > SDCA_MAX_INIT_COUNT) { 220 - dev_err(dev, "%pfwP: maximum init table size exceeded\n", function_node); 221 - return -EINVAL; 222 219 } 223 220 224 221 raw = kzalloc(num_init_writes, GFP_KERNEL); ··· 1601 1604 static struct sdca_entity *find_sdca_entity_by_label(struct sdca_function_data *function, 1602 1605 const char *entity_label) 1603 1606 { 1607 + struct sdca_entity *entity = NULL; 1604 1608 int i; 1605 1609 1606 1610 for (i = 0; i < function->num_entities; i++) { 1607 - struct sdca_entity *entity = &function->entities[i]; 1611 + entity = &function->entities[i]; 1612 + 1613 + /* check whole string first*/ 1614 + if (!strcmp(entity->label, entity_label)) 1615 + return entity; 1616 + } 1617 + 1618 + for (i = 0; i < function->num_entities; i++) { 1619 + entity = &function->entities[i]; 1608 1620 1609 1621 if (!strncmp(entity->label, entity_label, strlen(entity_label))) 1610 1622 return entity;
+1
sound/soc/soc-core.c
··· 2859 2859 INIT_LIST_HEAD(&component->dobj_list); 2860 2860 INIT_LIST_HEAD(&component->card_list); 2861 2861 INIT_LIST_HEAD(&component->list); 2862 + INIT_LIST_HEAD(&component->card_aux_list); 2862 2863 mutex_init(&component->io_mutex); 2863 2864 2864 2865 if (!component->name) {
+1 -1
sound/soc/sof/ipc4-topology.c
··· 2950 2950 return -EINVAL; 2951 2951 } 2952 2952 2953 - if (scontrol->priv_size < sizeof(struct sof_abi_hdr)) { 2953 + if (scontrol->priv_size && scontrol->priv_size < sizeof(struct sof_abi_hdr)) { 2954 2954 dev_err(sdev->dev, 2955 2955 "bytes control %s initial data size %zu is insufficient.\n", 2956 2956 scontrol->name, scontrol->priv_size);
+1 -1
sound/soc/sof/topology.c
··· 736 736 asize = le32_to_cpu(array->size); 737 737 738 738 /* validate asize */ 739 - if (asize < 0) { /* FIXME: A zero-size array makes no sense */ 739 + if (asize < sizeof(*array)) { 740 740 dev_err(scomp->dev, "error: invalid array size 0x%x\n", 741 741 asize); 742 742 return -EINVAL;
+1
sound/usb/Kconfig
··· 192 192 tristate "Qualcomm Audio Offload driver" 193 193 depends on QCOM_QMI_HELPERS && SND_USB_AUDIO && SND_SOC_USB 194 194 depends on USB_XHCI_HCD && USB_XHCI_SIDEBAND 195 + select AUXILIARY_BUS 195 196 help 196 197 Say Y here to enable the Qualcomm USB audio offloading feature. 197 198
+1 -1
sound/usb/caiaq/device.c
··· 488 488 memset(id, 0, sizeof(id)); 489 489 490 490 for (c = card->shortname, len = 0; 491 - *c && len < sizeof(card->id); c++) 491 + *c && len < sizeof(card->id) - 1; c++) 492 492 if (*c != ' ') 493 493 id[len++] = *c; 494 494
+1 -1
sound/usb/qcom/qc_audio_offload.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 2 2 /* 3 - * Copyright (c) 2022-2025 Qualcomm Innovation Center, Inc. All rights reserved. 3 + * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. 4 4 */ 5 5 6 6 #include <linux/auxiliary_bus.h>
+8
sound/usb/quirks.c
··· 2148 2148 /* Device matches */ 2149 2149 DEVICE_FLG(0x001f, 0x0b21, /* AB13X USB Audio */ 2150 2150 QUIRK_FLAG_FORCE_IFACE_RESET | QUIRK_FLAG_IFACE_DELAY), 2151 + DEVICE_FLG(0x001f, 0x0b23, /* AB17X USB Audio */ 2152 + QUIRK_FLAG_FORCE_IFACE_RESET | QUIRK_FLAG_IFACE_DELAY), 2151 2153 DEVICE_FLG(0x0020, 0x0b21, /* GHW-123P */ 2152 2154 QUIRK_FLAG_FORCE_IFACE_RESET | QUIRK_FLAG_IFACE_DELAY), 2153 2155 DEVICE_FLG(0x03f0, 0x654a, /* HP 320 FHD Webcam */ ··· 2305 2303 QUIRK_FLAG_PLAYBACK_FIRST | QUIRK_FLAG_GENERIC_IMPLICIT_FB), 2306 2304 DEVICE_FLG(0x13e5, 0x0001, /* Serato Phono */ 2307 2305 QUIRK_FLAG_IGNORE_CTL_ERROR), 2306 + DEVICE_FLG(0x152a, 0x880a, /* NeuralDSP Quad Cortex */ 2307 + 0), /* Doesn't have the vendor quirk which would otherwise apply */ 2308 2308 DEVICE_FLG(0x154e, 0x1002, /* Denon DCD-1500RE */ 2309 2309 QUIRK_FLAG_ITF_USB_DSD_DAC | QUIRK_FLAG_CTL_MSG_DELAY), 2310 2310 DEVICE_FLG(0x154e, 0x1003, /* Denon DA-300USB */ ··· 2433 2429 QUIRK_FLAG_CTL_MSG_DELAY | QUIRK_FLAG_IFACE_DELAY), 2434 2430 VENDOR_FLG(0x07fd, /* MOTU */ 2435 2431 QUIRK_FLAG_VALIDATE_RATES), 2432 + DEVICE_FLG(0x1235, 0x8006, 0), /* Focusrite Scarlett 2i2 1st Gen */ 2433 + DEVICE_FLG(0x1235, 0x800a, 0), /* Focusrite Scarlett 2i4 1st Gen */ 2434 + DEVICE_FLG(0x1235, 0x8016, 0), /* Focusrite Scarlett 2i2 1st Gen */ 2435 + DEVICE_FLG(0x1235, 0x801c, 0), /* Focusrite Scarlett Solo 1st Gen */ 2436 2436 VENDOR_FLG(0x1235, /* Focusrite Novation */ 2437 2437 QUIRK_FLAG_SKIP_CLOCK_SELECTOR | 2438 2438 QUIRK_FLAG_SKIP_IFACE_SETUP),
+15
tools/testing/selftests/cgroup/lib/cgroup_util.c
··· 123 123 return ret; 124 124 } 125 125 126 + int cg_read_strcmp_wait(const char *cgroup, const char *control, 127 + const char *expected) 128 + { 129 + int i, ret; 130 + 131 + for (i = 0; i < 100; i++) { 132 + ret = cg_read_strcmp(cgroup, control, expected); 133 + if (!ret) 134 + return ret; 135 + usleep(10000); 136 + } 137 + 138 + return ret; 139 + } 140 + 126 141 int cg_read_strstr(const char *cgroup, const char *control, const char *needle) 127 142 { 128 143 char buf[PAGE_SIZE];
+2
tools/testing/selftests/cgroup/lib/include/cgroup_util.h
··· 61 61 char *buf, size_t len); 62 62 extern int cg_read_strcmp(const char *cgroup, const char *control, 63 63 const char *expected); 64 + extern int cg_read_strcmp_wait(const char *cgroup, const char *control, 65 + const char *expected); 64 66 extern int cg_read_strstr(const char *cgroup, const char *control, 65 67 const char *needle); 66 68 extern long cg_read_long(const char *cgroup, const char *control);
+2 -1
tools/testing/selftests/cgroup/test_core.c
··· 233 233 if (err) 234 234 goto cleanup; 235 235 236 - if (cg_read_strcmp(cg_test_d, "cgroup.events", "populated 0\n")) 236 + if (cg_read_strcmp_wait(cg_test_d, "cgroup.events", 237 + "populated 0\n")) 237 238 goto cleanup; 238 239 239 240 /* Remove cgroup. */
+4 -3
tools/testing/selftests/cgroup/test_kill.c
··· 86 86 wait_for_pid(pids[i]); 87 87 88 88 if (ret == KSFT_PASS && 89 - cg_read_strcmp(cgroup, "cgroup.events", "populated 0\n")) 89 + cg_read_strcmp_wait(cgroup, "cgroup.events", "populated 0\n")) 90 90 ret = KSFT_FAIL; 91 91 92 92 if (cgroup) ··· 190 190 wait_for_pid(pids[i]); 191 191 192 192 if (ret == KSFT_PASS && 193 - cg_read_strcmp(cgroup[0], "cgroup.events", "populated 0\n")) 193 + cg_read_strcmp_wait(cgroup[0], "cgroup.events", 194 + "populated 0\n")) 194 195 ret = KSFT_FAIL; 195 196 196 197 for (i = 9; i >= 0 && cgroup[i]; i--) { ··· 252 251 wait_for_pid(pid); 253 252 254 253 if (ret == KSFT_PASS && 255 - cg_read_strcmp(cgroup, "cgroup.events", "populated 0\n")) 254 + cg_read_strcmp_wait(cgroup, "cgroup.events", "populated 0\n")) 256 255 ret = KSFT_FAIL; 257 256 258 257 if (cgroup)
+91 -2
tools/testing/selftests/landlock/tsync_test.c
··· 6 6 */ 7 7 8 8 #define _GNU_SOURCE 9 - #include <pthread.h> 10 - #include <sys/prctl.h> 11 9 #include <linux/landlock.h> 10 + #include <pthread.h> 11 + #include <signal.h> 12 + #include <sys/prctl.h> 12 13 13 14 #include "common.h" 14 15 ··· 155 154 /* Expect that both succeeded. */ 156 155 EXPECT_EQ(0, d[0].result); 157 156 EXPECT_EQ(0, d[1].result); 157 + 158 + EXPECT_EQ(0, close(ruleset_fd)); 159 + } 160 + 161 + static void signal_nop_handler(int sig) 162 + { 163 + } 164 + 165 + struct signaler_data { 166 + pthread_t target; 167 + volatile bool stop; 168 + }; 169 + 170 + static void *signaler_thread(void *data) 171 + { 172 + struct signaler_data *sd = data; 173 + 174 + while (!sd->stop) 175 + pthread_kill(sd->target, SIGUSR1); 176 + 177 + return NULL; 178 + } 179 + 180 + /* 181 + * Number of idle sibling threads. This must be large enough that even on 182 + * machines with many cores, the sibling threads cannot all complete their 183 + * credential preparation in a single parallel wave, otherwise the signaler 184 + * thread has no window to interrupt wait_for_completion_interruptible(). 185 + * 200 threads on a 64-core machine yields ~3 serialized waves, giving the 186 + * tight signal loop enough time to land an interruption. 187 + */ 188 + #define NUM_IDLE_THREADS 200 189 + 190 + /* 191 + * Exercises the tsync interruption and cancellation paths in tsync.c. 192 + * 193 + * When a signal interrupts the calling thread while it waits for sibling 194 + * threads to finish their credential preparation 195 + * (wait_for_completion_interruptible in landlock_restrict_sibling_threads), 196 + * the kernel sets ERESTARTNOINTR, cancels queued task works that have not 197 + * started yet (cancel_tsync_works), then waits for the remaining works to 198 + * finish. On the error return, syscalls.c aborts the prepared credentials. 199 + * The kernel automatically restarts the syscall, so userspace sees success. 200 + */ 201 + TEST(tsync_interrupt) 202 + { 203 + size_t i; 204 + pthread_t threads[NUM_IDLE_THREADS]; 205 + pthread_t signaler; 206 + struct signaler_data sd; 207 + struct sigaction sa = {}; 208 + const int ruleset_fd = create_ruleset(_metadata); 209 + 210 + disable_caps(_metadata); 211 + 212 + /* Install a no-op SIGUSR1 handler so the signal does not kill us. */ 213 + sa.sa_handler = signal_nop_handler; 214 + sigemptyset(&sa.sa_mask); 215 + ASSERT_EQ(0, sigaction(SIGUSR1, &sa, NULL)); 216 + 217 + ASSERT_EQ(0, prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0)); 218 + 219 + for (i = 0; i < NUM_IDLE_THREADS; i++) 220 + ASSERT_EQ(0, pthread_create(&threads[i], NULL, idle, NULL)); 221 + 222 + /* 223 + * Start a signaler thread that continuously sends SIGUSR1 to the 224 + * calling thread. This maximizes the chance of interrupting 225 + * wait_for_completion_interruptible() in the kernel's tsync path. 226 + */ 227 + sd.target = pthread_self(); 228 + sd.stop = false; 229 + ASSERT_EQ(0, pthread_create(&signaler, NULL, signaler_thread, &sd)); 230 + 231 + /* 232 + * The syscall may be interrupted and transparently restarted by the 233 + * kernel (ERESTARTNOINTR). From userspace, it should always succeed. 234 + */ 235 + EXPECT_EQ(0, landlock_restrict_self(ruleset_fd, 236 + LANDLOCK_RESTRICT_SELF_TSYNC)); 237 + 238 + sd.stop = true; 239 + ASSERT_EQ(0, pthread_join(signaler, NULL)); 240 + 241 + for (i = 0; i < NUM_IDLE_THREADS; i++) { 242 + ASSERT_EQ(0, pthread_cancel(threads[i])); 243 + ASSERT_EQ(0, pthread_join(threads[i], NULL)); 244 + } 158 245 159 246 EXPECT_EQ(0, close(ruleset_fd)); 160 247 }
+1 -1
tools/testing/selftests/mount_setattr/mount_setattr_test.c
··· 1020 1020 "size=100000,mode=700"), 0); 1021 1021 1022 1022 ASSERT_EQ(mount("testing", "/mnt", "tmpfs", MS_NOATIME | MS_NODEV, 1023 - "size=2m,mode=700"), 0); 1023 + "size=256m,mode=700"), 0); 1024 1024 1025 1025 ASSERT_EQ(mkdir("/mnt/A", 0777), 0); 1026 1026
+1
tools/testing/selftests/sched_ext/Makefile
··· 188 188 rt_stall \ 189 189 test_example \ 190 190 total_bw \ 191 + cyclic_kick_wait \ 191 192 192 193 testcase-targets := $(addsuffix .o,$(addprefix $(SCXOBJ_DIR)/,$(auto-test-targets))) 193 194
+68
tools/testing/selftests/sched_ext/cyclic_kick_wait.bpf.c
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + /* 3 + * Stress concurrent SCX_KICK_WAIT calls to reproduce wait-cycle deadlock. 4 + * 5 + * Three CPUs are designated from userspace. Every enqueue from one of the 6 + * three CPUs kicks the next CPU in the ring with SCX_KICK_WAIT, creating a 7 + * persistent A -> B -> C -> A wait cycle pressure. 8 + */ 9 + #include <scx/common.bpf.h> 10 + 11 + char _license[] SEC("license") = "GPL"; 12 + 13 + const volatile s32 test_cpu_a; 14 + const volatile s32 test_cpu_b; 15 + const volatile s32 test_cpu_c; 16 + 17 + u64 nr_enqueues; 18 + u64 nr_wait_kicks; 19 + 20 + UEI_DEFINE(uei); 21 + 22 + static s32 target_cpu(s32 cpu) 23 + { 24 + if (cpu == test_cpu_a) 25 + return test_cpu_b; 26 + if (cpu == test_cpu_b) 27 + return test_cpu_c; 28 + if (cpu == test_cpu_c) 29 + return test_cpu_a; 30 + return -1; 31 + } 32 + 33 + void BPF_STRUCT_OPS(cyclic_kick_wait_enqueue, struct task_struct *p, 34 + u64 enq_flags) 35 + { 36 + s32 this_cpu = bpf_get_smp_processor_id(); 37 + s32 tgt; 38 + 39 + __sync_fetch_and_add(&nr_enqueues, 1); 40 + 41 + if (p->flags & PF_KTHREAD) { 42 + scx_bpf_dsq_insert(p, SCX_DSQ_LOCAL, SCX_SLICE_INF, 43 + enq_flags | SCX_ENQ_PREEMPT); 44 + return; 45 + } 46 + 47 + scx_bpf_dsq_insert(p, SCX_DSQ_GLOBAL, SCX_SLICE_DFL, enq_flags); 48 + 49 + tgt = target_cpu(this_cpu); 50 + if (tgt < 0 || tgt == this_cpu) 51 + return; 52 + 53 + __sync_fetch_and_add(&nr_wait_kicks, 1); 54 + scx_bpf_kick_cpu(tgt, SCX_KICK_WAIT); 55 + } 56 + 57 + void BPF_STRUCT_OPS(cyclic_kick_wait_exit, struct scx_exit_info *ei) 58 + { 59 + UEI_RECORD(uei, ei); 60 + } 61 + 62 + SEC(".struct_ops.link") 63 + struct sched_ext_ops cyclic_kick_wait_ops = { 64 + .enqueue = cyclic_kick_wait_enqueue, 65 + .exit = cyclic_kick_wait_exit, 66 + .name = "cyclic_kick_wait", 67 + .timeout_ms = 1000U, 68 + };
+194
tools/testing/selftests/sched_ext/cyclic_kick_wait.c
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + /* 3 + * Test SCX_KICK_WAIT forward progress under cyclic wait pressure. 4 + * 5 + * SCX_KICK_WAIT busy-waits until the target CPU enters the scheduling path. 6 + * If multiple CPUs form a wait cycle (A waits for B, B waits for C, C waits 7 + * for A), all CPUs deadlock unless the implementation breaks the cycle. 8 + * 9 + * This test creates that scenario: three CPUs are arranged in a ring. The BPF 10 + * scheduler's ops.enqueue() kicks the next CPU in the ring with SCX_KICK_WAIT 11 + * on every enqueue. Userspace pins 4 worker threads per CPU that loop calling 12 + * sched_yield(), generating a steady stream of enqueues and thus sustained 13 + * A->B->C->A kick_wait cycle pressure. The test passes if the system remains 14 + * responsive for 5 seconds without the scheduler being killed by the watchdog. 15 + */ 16 + #define _GNU_SOURCE 17 + 18 + #include <bpf/bpf.h> 19 + #include <errno.h> 20 + #include <pthread.h> 21 + #include <sched.h> 22 + #include <scx/common.h> 23 + #include <stdint.h> 24 + #include <string.h> 25 + #include <time.h> 26 + #include <unistd.h> 27 + 28 + #include "scx_test.h" 29 + #include "cyclic_kick_wait.bpf.skel.h" 30 + 31 + #define WORKERS_PER_CPU 4 32 + #define NR_TEST_CPUS 3 33 + #define NR_WORKERS (NR_TEST_CPUS * WORKERS_PER_CPU) 34 + 35 + struct worker_ctx { 36 + pthread_t tid; 37 + int cpu; 38 + volatile bool stop; 39 + volatile __u64 iters; 40 + bool started; 41 + }; 42 + 43 + static void *worker_fn(void *arg) 44 + { 45 + struct worker_ctx *worker = arg; 46 + cpu_set_t mask; 47 + 48 + CPU_ZERO(&mask); 49 + CPU_SET(worker->cpu, &mask); 50 + 51 + if (sched_setaffinity(0, sizeof(mask), &mask)) 52 + return (void *)(uintptr_t)errno; 53 + 54 + while (!worker->stop) { 55 + sched_yield(); 56 + worker->iters++; 57 + } 58 + 59 + return NULL; 60 + } 61 + 62 + static int join_worker(struct worker_ctx *worker) 63 + { 64 + void *ret; 65 + struct timespec ts; 66 + int err; 67 + 68 + if (!worker->started) 69 + return 0; 70 + 71 + if (clock_gettime(CLOCK_REALTIME, &ts)) 72 + return -errno; 73 + 74 + ts.tv_sec += 2; 75 + err = pthread_timedjoin_np(worker->tid, &ret, &ts); 76 + if (err == ETIMEDOUT) 77 + pthread_detach(worker->tid); 78 + if (err) 79 + return -err; 80 + 81 + if ((uintptr_t)ret) 82 + return -(int)(uintptr_t)ret; 83 + 84 + return 0; 85 + } 86 + 87 + static enum scx_test_status setup(void **ctx) 88 + { 89 + struct cyclic_kick_wait *skel; 90 + 91 + skel = cyclic_kick_wait__open(); 92 + SCX_FAIL_IF(!skel, "Failed to open skel"); 93 + SCX_ENUM_INIT(skel); 94 + 95 + *ctx = skel; 96 + return SCX_TEST_PASS; 97 + } 98 + 99 + static enum scx_test_status run(void *ctx) 100 + { 101 + struct cyclic_kick_wait *skel = ctx; 102 + struct worker_ctx workers[NR_WORKERS] = {}; 103 + struct bpf_link *link = NULL; 104 + enum scx_test_status status = SCX_TEST_PASS; 105 + int test_cpus[NR_TEST_CPUS]; 106 + int nr_cpus = 0; 107 + cpu_set_t mask; 108 + int ret, i; 109 + 110 + if (sched_getaffinity(0, sizeof(mask), &mask)) { 111 + SCX_ERR("Failed to get affinity (%d)", errno); 112 + return SCX_TEST_FAIL; 113 + } 114 + 115 + for (i = 0; i < CPU_SETSIZE; i++) { 116 + if (CPU_ISSET(i, &mask)) 117 + test_cpus[nr_cpus++] = i; 118 + if (nr_cpus == NR_TEST_CPUS) 119 + break; 120 + } 121 + 122 + if (nr_cpus < NR_TEST_CPUS) 123 + return SCX_TEST_SKIP; 124 + 125 + skel->rodata->test_cpu_a = test_cpus[0]; 126 + skel->rodata->test_cpu_b = test_cpus[1]; 127 + skel->rodata->test_cpu_c = test_cpus[2]; 128 + 129 + if (cyclic_kick_wait__load(skel)) { 130 + SCX_ERR("Failed to load skel"); 131 + return SCX_TEST_FAIL; 132 + } 133 + 134 + link = bpf_map__attach_struct_ops(skel->maps.cyclic_kick_wait_ops); 135 + if (!link) { 136 + SCX_ERR("Failed to attach scheduler"); 137 + return SCX_TEST_FAIL; 138 + } 139 + 140 + for (i = 0; i < NR_WORKERS; i++) 141 + workers[i].cpu = test_cpus[i / WORKERS_PER_CPU]; 142 + 143 + for (i = 0; i < NR_WORKERS; i++) { 144 + ret = pthread_create(&workers[i].tid, NULL, worker_fn, &workers[i]); 145 + if (ret) { 146 + SCX_ERR("Failed to create worker thread %d (%d)", i, ret); 147 + status = SCX_TEST_FAIL; 148 + goto out; 149 + } 150 + workers[i].started = true; 151 + } 152 + 153 + sleep(5); 154 + 155 + if (skel->data->uei.kind != EXIT_KIND(SCX_EXIT_NONE)) { 156 + SCX_ERR("Scheduler exited unexpectedly (kind=%llu code=%lld)", 157 + (unsigned long long)skel->data->uei.kind, 158 + (long long)skel->data->uei.exit_code); 159 + status = SCX_TEST_FAIL; 160 + } 161 + 162 + out: 163 + for (i = 0; i < NR_WORKERS; i++) 164 + workers[i].stop = true; 165 + 166 + for (i = 0; i < NR_WORKERS; i++) { 167 + ret = join_worker(&workers[i]); 168 + if (ret && status == SCX_TEST_PASS) { 169 + SCX_ERR("Failed to join worker thread %d (%d)", i, ret); 170 + status = SCX_TEST_FAIL; 171 + } 172 + } 173 + 174 + if (link) 175 + bpf_link__destroy(link); 176 + 177 + return status; 178 + } 179 + 180 + static void cleanup(void *ctx) 181 + { 182 + struct cyclic_kick_wait *skel = ctx; 183 + 184 + cyclic_kick_wait__destroy(skel); 185 + } 186 + 187 + struct scx_test cyclic_kick_wait = { 188 + .name = "cyclic_kick_wait", 189 + .description = "Verify SCX_KICK_WAIT forward progress under a 3-CPU wait cycle", 190 + .setup = setup, 191 + .run = run, 192 + .cleanup = cleanup, 193 + }; 194 + REGISTER_SCX_TEST(&cyclic_kick_wait)
+44
tools/testing/selftests/tc-testing/tc-tests/infra/filter.json
··· 22 22 "teardown": [ 23 23 "$TC qdisc del dev $DUMMY root handle 1: htb default 1" 24 24 ] 25 + }, 26 + { 27 + "id": "b7e3", 28 + "name": "Empty fw filter on shared block - rejected at config time", 29 + "category": [ 30 + "filter", 31 + "fw" 32 + ], 33 + "plugins": { 34 + "requires": "nsPlugin" 35 + }, 36 + "setup": [ 37 + "$TC qdisc add dev $DEV1 egress_block 1 clsact" 38 + ], 39 + "cmdUnderTest": "$TC filter add block 1 protocol ip prio 1 fw", 40 + "expExitCode": "2", 41 + "verifyCmd": "$TC filter show block 1", 42 + "matchPattern": "fw", 43 + "matchCount": "0", 44 + "teardown": [ 45 + "$TC qdisc del dev $DEV1 clsact" 46 + ] 47 + }, 48 + { 49 + "id": "c8f4", 50 + "name": "Flow filter on shared block without baseclass - rejected at config time", 51 + "category": [ 52 + "filter", 53 + "flow" 54 + ], 55 + "plugins": { 56 + "requires": "nsPlugin" 57 + }, 58 + "setup": [ 59 + "$TC qdisc add dev $DEV1 ingress_block 1 clsact" 60 + ], 61 + "cmdUnderTest": "$TC filter add block 1 protocol ip prio 1 handle 1 flow map key dst", 62 + "expExitCode": "2", 63 + "verifyCmd": "$TC filter show block 1", 64 + "matchPattern": "flow", 65 + "matchCount": "0", 66 + "teardown": [ 67 + "$TC qdisc del dev $DEV1 clsact" 68 + ] 25 69 } 26 70 ]
+25
tools/testing/selftests/tc-testing/tc-tests/infra/qdiscs.json
··· 1111 1111 "teardown": [ 1112 1112 "$TC qdisc del dev $DUMMY root handle 1:" 1113 1113 ] 1114 + }, 1115 + { 1116 + "id": "a3d7", 1117 + "name": "HFSC with large m1 - no divide-by-zero on class reactivation", 1118 + "category": [ 1119 + "qdisc", 1120 + "hfsc" 1121 + ], 1122 + "plugins": { 1123 + "requires": "nsPlugin" 1124 + }, 1125 + "setup": [ 1126 + "$TC qdisc replace dev $DUMMY root handle 1: hfsc default 1", 1127 + "$TC class replace dev $DUMMY parent 1: classid 1:1 hfsc rt m1 32gbit d 1ms m2 0bit ls m1 32gbit d 1ms m2 0bit", 1128 + "ping -I$DUMMY -f -c1 -s64 -W1 10.10.10.1 || true", 1129 + "sleep 1" 1130 + ], 1131 + "cmdUnderTest": "ping -I$DUMMY -f -c1 -s64 -W1 10.10.10.1 || true", 1132 + "expExitCode": "0", 1133 + "verifyCmd": "$TC qdisc show dev $DUMMY", 1134 + "matchPattern": "qdisc hfsc 1: root", 1135 + "matchCount": "1", 1136 + "teardown": [ 1137 + "$TC qdisc del dev $DUMMY handle 1: root" 1138 + ] 1114 1139 } 1115 1140 ]
-1
tools/tracing/rtla/src/timerlat_bpf.h
··· 12 12 }; 13 13 14 14 #ifndef __bpf__ 15 - #include <bpf/libbpf.h> 16 15 #ifdef HAVE_BPF_SKEL 17 16 int timerlat_bpf_init(struct timerlat_params *params); 18 17 int timerlat_bpf_attach(void);