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

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'for-linus' into for-next

Pull remaining 6.18-devel changes.

Signed-off-by: Takashi Iwai <tiwai@suse.de>

+6249 -2409
+4 -2
.mailmap
··· 206 206 David Brownell <david-b@pacbell.net> 207 207 David Collins <quic_collinsd@quicinc.com> <collinsd@codeaurora.org> 208 208 David Heidelberg <david@ixit.cz> <d.okias@gmail.com> 209 + David Hildenbrand <david@kernel.org> <david@redhat.com> 209 210 David Rheinsberg <david@readahead.eu> <dh.herrmann@gmail.com> 210 211 David Rheinsberg <david@readahead.eu> <dh.herrmann@googlemail.com> 211 212 David Rheinsberg <david@readahead.eu> <david.rheinsberg@gmail.com> ··· 427 426 Kenneth Westfield <quic_kwestfie@quicinc.com> <kwestfie@codeaurora.org> 428 427 Kiran Gunda <quic_kgunda@quicinc.com> <kgunda@codeaurora.org> 429 428 Kirill Tkhai <tkhai@ya.ru> <ktkhai@virtuozzo.com> 430 - Kirill A. Shutemov <kas@kernel.org> <kirill.shutemov@linux.intel.com> 429 + Kiryl Shutsemau <kas@kernel.org> <kirill.shutemov@linux.intel.com> 431 430 Kishon Vijay Abraham I <kishon@kernel.org> <kishon@ti.com> 432 431 Konrad Dybcio <konradybcio@kernel.org> <konrad.dybcio@linaro.org> 433 432 Konrad Dybcio <konradybcio@kernel.org> <konrad.dybcio@somainline.org> ··· 606 605 Oleksij Rempel <o.rempel@pengutronix.de> <ore@pengutronix.de> 607 606 Oliver Hartkopp <socketcan@hartkopp.net> <oliver.hartkopp@volkswagen.de> 608 607 Oliver Hartkopp <socketcan@hartkopp.net> <oliver@hartkopp.net> 609 - Oliver Upton <oliver.upton@linux.dev> <oupton@google.com> 608 + Oliver Upton <oupton@kernel.org> <oupton@google.com> 609 + Oliver Upton <oupton@kernel.org> <oliver.upton@linux.dev> 610 610 Ondřej Jirman <megi@xff.cz> <megous@megous.com> 611 611 Oza Pawandeep <quic_poza@quicinc.com> <poza@codeaurora.org> 612 612 Pali Rohár <pali@kernel.org> <pali.rohar@gmail.com>
+1 -1
Documentation/devicetree/bindings/gpio/ti,twl4030-gpio.yaml
··· 1 1 # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) 2 2 %YAML 1.2 3 3 --- 4 - $id: http://devicetree.org/schemas/ti,twl4030-gpio.yaml# 4 + $id: http://devicetree.org/schemas/gpio/ti,twl4030-gpio.yaml# 5 5 $schema: http://devicetree.org/meta-schemas/core.yaml# 6 6 7 7 title: TI TWL4030 GPIO controller
+4 -4
Documentation/firmware-guide/acpi/i2c-muxes.rst
··· 37 37 Name (_HID, ...) 38 38 Name (_CRS, ResourceTemplate () { 39 39 I2cSerialBus (0x50, ControllerInitiated, I2C_SPEED, 40 - AddressingMode7Bit, "\\_SB.SMB1.CH00", 0x00, 41 - ResourceConsumer,,) 40 + AddressingMode7Bit, "\\_SB.SMB1.MUX0.CH00", 41 + 0x00, ResourceConsumer,,) 42 42 } 43 43 } 44 44 } ··· 52 52 Name (_HID, ...) 53 53 Name (_CRS, ResourceTemplate () { 54 54 I2cSerialBus (0x50, ControllerInitiated, I2C_SPEED, 55 - AddressingMode7Bit, "\\_SB.SMB1.CH01", 0x00, 56 - ResourceConsumer,,) 55 + AddressingMode7Bit, "\\_SB.SMB1.MUX0.CH01", 56 + 0x00, ResourceConsumer,,) 57 57 } 58 58 } 59 59 }
+2 -2
Documentation/userspace-api/netlink/intro-specs.rst
··· 13 13 Kernel comes with a simple CLI tool which should be useful when 14 14 developing Netlink related code. The tool is implemented in Python 15 15 and can use a YAML specification to issue Netlink requests 16 - to the kernel. Only Generic Netlink is supported. 16 + to the kernel. 17 17 18 18 The tool is located at ``tools/net/ynl/pyynl/cli.py``. It accepts 19 - a handul of arguments, the most important ones are: 19 + a handful of arguments, the most important ones are: 20 20 21 21 - ``--spec`` - point to the spec file 22 22 - ``--do $name`` / ``--dump $name`` - issue request ``$name``
+26 -20
MAINTAINERS
··· 915 915 ALPHA PORT 916 916 M: Richard Henderson <richard.henderson@linaro.org> 917 917 M: Matt Turner <mattst88@gmail.com> 918 + M: Magnus Lindholm <linmag7@gmail.com> 918 919 L: linux-alpha@vger.kernel.org 919 920 S: Odd Fixes 920 921 F: arch/alpha/ ··· 4399 4398 M: Jens Axboe <axboe@kernel.dk> 4400 4399 L: linux-block@vger.kernel.org 4401 4400 S: Maintained 4402 - T: git git://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux-block.git 4401 + T: git git://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux.git 4403 4402 F: Documentation/ABI/stable/sysfs-block 4404 4403 F: Documentation/block/ 4405 4404 F: block/ ··· 4819 4818 F: drivers/net/dsa/bcm_sf2* 4820 4819 F: include/linux/dsa/brcm.h 4821 4820 F: include/linux/platform_data/b53.h 4821 + F: net/dsa/tag_brcm.c 4822 4822 4823 4823 BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE 4824 4824 M: Florian Fainelli <florian.fainelli@broadcom.com> ··· 9209 9207 R: Jeffle Xu <jefflexu@linux.alibaba.com> 9210 9208 R: Sandeep Dhavale <dhavale@google.com> 9211 9209 R: Hongbo Li <lihongbo22@huawei.com> 9210 + R: Chunhai Guo <guochunhai@vivo.com> 9212 9211 L: linux-erofs@lists.ozlabs.org 9213 9212 S: Maintained 9214 9213 W: https://erofs.docs.kernel.org ··· 11528 11525 HUGETLB SUBSYSTEM 11529 11526 M: Muchun Song <muchun.song@linux.dev> 11530 11527 M: Oscar Salvador <osalvador@suse.de> 11531 - R: David Hildenbrand <david@redhat.com> 11528 + R: David Hildenbrand <david@kernel.org> 11532 11529 L: linux-mm@kvack.org 11533 11530 S: Maintained 11534 11531 F: Documentation/ABI/testing/sysfs-kernel-mm-hugepages ··· 12524 12521 F: include/linux/net/intel/*/ 12525 12522 12526 12523 INTEL ETHERNET PROTOCOL DRIVER FOR RDMA 12524 + M: Krzysztof Czurylo <krzysztof.czurylo@intel.com> 12527 12525 M: Tatyana Nikolova <tatyana.e.nikolova@intel.com> 12528 12526 L: linux-rdma@vger.kernel.org 12529 12527 S: Supported ··· 12865 12861 K: \bSGX_ 12866 12862 12867 12863 INTEL SKYLAKE INT3472 ACPI DEVICE DRIVER 12868 - M: Daniel Scally <djrscally@gmail.com> 12864 + M: Daniel Scally <dan.scally@ideasonboard.com> 12865 + M: Sakari Ailus <sakari.ailus@linux.intel.com> 12869 12866 S: Maintained 12870 12867 F: drivers/platform/x86/intel/int3472/ 12871 12868 F: include/linux/platform_data/x86/int3472.h ··· 13661 13656 13662 13657 KERNEL VIRTUAL MACHINE FOR ARM64 (KVM/arm64) 13663 13658 M: Marc Zyngier <maz@kernel.org> 13664 - M: Oliver Upton <oliver.upton@linux.dev> 13659 + M: Oliver Upton <oupton@kernel.org> 13665 13660 R: Joey Gouly <joey.gouly@arm.com> 13666 13661 R: Suzuki K Poulose <suzuki.poulose@arm.com> 13667 13662 R: Zenghui Yu <yuzenghui@huawei.com> ··· 13735 13730 M: Christian Borntraeger <borntraeger@linux.ibm.com> 13736 13731 M: Janosch Frank <frankja@linux.ibm.com> 13737 13732 M: Claudio Imbrenda <imbrenda@linux.ibm.com> 13738 - R: David Hildenbrand <david@redhat.com> 13733 + R: David Hildenbrand <david@kernel.org> 13739 13734 L: kvm@vger.kernel.org 13740 13735 S: Supported 13741 13736 T: git git://git.kernel.org/pub/scm/linux/kernel/git/kvms390/linux.git ··· 16222 16217 F: drivers/devfreq/tegra30-devfreq.c 16223 16218 16224 16219 MEMORY HOT(UN)PLUG 16225 - M: David Hildenbrand <david@redhat.com> 16220 + M: David Hildenbrand <david@kernel.org> 16226 16221 M: Oscar Salvador <osalvador@suse.de> 16227 16222 L: linux-mm@kvack.org 16228 16223 S: Maintained ··· 16247 16242 16248 16243 MEMORY MANAGEMENT - CORE 16249 16244 M: Andrew Morton <akpm@linux-foundation.org> 16250 - M: David Hildenbrand <david@redhat.com> 16245 + M: David Hildenbrand <david@kernel.org> 16251 16246 R: Lorenzo Stoakes <lorenzo.stoakes@oracle.com> 16252 16247 R: Liam R. Howlett <Liam.Howlett@oracle.com> 16253 16248 R: Vlastimil Babka <vbabka@suse.cz> ··· 16303 16298 16304 16299 MEMORY MANAGEMENT - GUP (GET USER PAGES) 16305 16300 M: Andrew Morton <akpm@linux-foundation.org> 16306 - M: David Hildenbrand <david@redhat.com> 16301 + M: David Hildenbrand <david@kernel.org> 16307 16302 R: Jason Gunthorpe <jgg@nvidia.com> 16308 16303 R: John Hubbard <jhubbard@nvidia.com> 16309 16304 R: Peter Xu <peterx@redhat.com> ··· 16319 16314 16320 16315 MEMORY MANAGEMENT - KSM (Kernel Samepage Merging) 16321 16316 M: Andrew Morton <akpm@linux-foundation.org> 16322 - M: David Hildenbrand <david@redhat.com> 16317 + M: David Hildenbrand <david@kernel.org> 16323 16318 R: Xu Xin <xu.xin16@zte.com.cn> 16324 16319 R: Chengming Zhou <chengming.zhou@linux.dev> 16325 16320 L: linux-mm@kvack.org ··· 16335 16330 16336 16331 MEMORY MANAGEMENT - MEMORY POLICY AND MIGRATION 16337 16332 M: Andrew Morton <akpm@linux-foundation.org> 16338 - M: David Hildenbrand <david@redhat.com> 16333 + M: David Hildenbrand <david@kernel.org> 16339 16334 R: Zi Yan <ziy@nvidia.com> 16340 16335 R: Matthew Brost <matthew.brost@intel.com> 16341 16336 R: Joshua Hahn <joshua.hahnjy@gmail.com> ··· 16375 16370 16376 16371 MEMORY MANAGEMENT - MISC 16377 16372 M: Andrew Morton <akpm@linux-foundation.org> 16378 - M: David Hildenbrand <david@redhat.com> 16373 + M: David Hildenbrand <david@kernel.org> 16379 16374 R: Lorenzo Stoakes <lorenzo.stoakes@oracle.com> 16380 16375 R: Liam R. Howlett <Liam.Howlett@oracle.com> 16381 16376 R: Vlastimil Babka <vbabka@suse.cz> ··· 16463 16458 MEMORY MANAGEMENT - RECLAIM 16464 16459 M: Andrew Morton <akpm@linux-foundation.org> 16465 16460 M: Johannes Weiner <hannes@cmpxchg.org> 16466 - R: David Hildenbrand <david@redhat.com> 16461 + R: David Hildenbrand <david@kernel.org> 16467 16462 R: Michal Hocko <mhocko@kernel.org> 16468 16463 R: Qi Zheng <zhengqi.arch@bytedance.com> 16469 16464 R: Shakeel Butt <shakeel.butt@linux.dev> ··· 16476 16471 16477 16472 MEMORY MANAGEMENT - RMAP (REVERSE MAPPING) 16478 16473 M: Andrew Morton <akpm@linux-foundation.org> 16479 - M: David Hildenbrand <david@redhat.com> 16474 + M: David Hildenbrand <david@kernel.org> 16480 16475 M: Lorenzo Stoakes <lorenzo.stoakes@oracle.com> 16481 16476 R: Rik van Riel <riel@surriel.com> 16482 16477 R: Liam R. Howlett <Liam.Howlett@oracle.com> ··· 16500 16495 16501 16496 MEMORY MANAGEMENT - SWAP 16502 16497 M: Andrew Morton <akpm@linux-foundation.org> 16498 + M: Chris Li <chrisl@kernel.org> 16499 + M: Kairui Song <kasong@tencent.com> 16503 16500 R: Kemeng Shi <shikemeng@huaweicloud.com> 16504 - R: Kairui Song <kasong@tencent.com> 16505 16501 R: Nhat Pham <nphamcs@gmail.com> 16506 16502 R: Baoquan He <bhe@redhat.com> 16507 16503 R: Barry Song <baohua@kernel.org> 16508 - R: Chris Li <chrisl@kernel.org> 16509 16504 L: linux-mm@kvack.org 16510 16505 S: Maintained 16511 16506 F: Documentation/mm/swap-table.rst ··· 16521 16516 16522 16517 MEMORY MANAGEMENT - THP (TRANSPARENT HUGE PAGE) 16523 16518 M: Andrew Morton <akpm@linux-foundation.org> 16524 - M: David Hildenbrand <david@redhat.com> 16519 + M: David Hildenbrand <david@kernel.org> 16525 16520 M: Lorenzo Stoakes <lorenzo.stoakes@oracle.com> 16526 16521 R: Zi Yan <ziy@nvidia.com> 16527 16522 R: Baolin Wang <baolin.wang@linux.alibaba.com> ··· 16623 16618 M: Andrew Morton <akpm@linux-foundation.org> 16624 16619 M: Liam R. Howlett <Liam.Howlett@oracle.com> 16625 16620 M: Lorenzo Stoakes <lorenzo.stoakes@oracle.com> 16626 - M: David Hildenbrand <david@redhat.com> 16621 + M: David Hildenbrand <david@kernel.org> 16627 16622 R: Vlastimil Babka <vbabka@suse.cz> 16628 16623 R: Jann Horn <jannh@google.com> 16629 16624 L: linux-mm@kvack.org ··· 20165 20160 R: Jiri Olsa <jolsa@kernel.org> 20166 20161 R: Ian Rogers <irogers@google.com> 20167 20162 R: Adrian Hunter <adrian.hunter@intel.com> 20163 + R: James Clark <james.clark@linaro.org> 20168 20164 L: linux-perf-users@vger.kernel.org 20169 20165 L: linux-kernel@vger.kernel.org 20170 20166 S: Supported ··· 27090 27084 27091 27085 VIRTIO BALLOON 27092 27086 M: "Michael S. Tsirkin" <mst@redhat.com> 27093 - M: David Hildenbrand <david@redhat.com> 27087 + M: David Hildenbrand <david@kernel.org> 27094 27088 L: virtualization@lists.linux.dev 27095 27089 S: Maintained 27096 27090 F: drivers/virtio/virtio_balloon.c ··· 27245 27239 F: include/uapi/linux/virtio_iommu.h 27246 27240 27247 27241 VIRTIO MEM DRIVER 27248 - M: David Hildenbrand <david@redhat.com> 27242 + M: David Hildenbrand <david@kernel.org> 27249 27243 L: virtualization@lists.linux.dev 27250 27244 S: Maintained 27251 27245 W: https://virtio-mem.gitlab.io/ ··· 27851 27845 F: arch/x86/kernel/unwind_*.c 27852 27846 27853 27847 X86 TRUST DOMAIN EXTENSIONS (TDX) 27854 - M: Kirill A. Shutemov <kas@kernel.org> 27848 + M: Kiryl Shutsemau <kas@kernel.org> 27855 27849 R: Dave Hansen <dave.hansen@linux.intel.com> 27856 27850 R: Rick Edgecombe <rick.p.edgecombe@intel.com> 27857 27851 L: x86@kernel.org
+1 -1
Makefile
··· 2 2 VERSION = 6 3 3 PATCHLEVEL = 18 4 4 SUBLEVEL = 0 5 - EXTRAVERSION = -rc4 5 + EXTRAVERSION = -rc6 6 6 NAME = Baby Opossum Posse 7 7 8 8 # *DOCUMENTATION*
+7
arch/Kconfig
··· 917 917 An architecture should select this option if it requires the 918 918 .kcfi_traps section for KCFI trap handling. 919 919 920 + config ARCH_USES_CFI_GENERIC_LLVM_PASS 921 + bool 922 + help 923 + An architecture should select this option if it uses the generic 924 + KCFIPass in LLVM to expand kCFI bundles instead of architecture-specific 925 + lowering. 926 + 920 927 config CFI 921 928 bool "Use Kernel Control Flow Integrity (kCFI)" 922 929 default CFI_CLANG
+2
arch/arm/Kconfig
··· 44 44 select ARCH_USE_BUILTIN_BSWAP 45 45 select ARCH_USE_CMPXCHG_LOCKREF 46 46 select ARCH_USE_MEMTEST 47 + # https://github.com/llvm/llvm-project/commit/d130f402642fba3d065aacb506cb061c899558de 48 + select ARCH_USES_CFI_GENERIC_LLVM_PASS if CLANG_VERSION < 220000 47 49 select ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT if MMU 48 50 select ARCH_WANT_GENERAL_HUGETLB 49 51 select ARCH_WANT_IPC_PARSE_VERSION
+5 -2
arch/arm64/include/asm/alternative.h
··· 26 26 bool alternative_is_applied(u16 cpucap); 27 27 28 28 #ifdef CONFIG_MODULES 29 - void apply_alternatives_module(void *start, size_t length); 29 + int apply_alternatives_module(void *start, size_t length); 30 30 #else 31 - static inline void apply_alternatives_module(void *start, size_t length) { } 31 + static inline int apply_alternatives_module(void *start, size_t length) 32 + { 33 + return 0; 34 + } 32 35 #endif 33 36 34 37 void alt_cb_patch_nops(struct alt_instr *alt, __le32 *origptr,
+1 -2
arch/arm64/include/asm/kfence.h
··· 10 10 11 11 #include <asm/set_memory.h> 12 12 13 - static inline bool arch_kfence_init_pool(void) { return true; } 14 - 15 13 static inline bool kfence_protect_page(unsigned long addr, bool protect) 16 14 { 17 15 set_memory_valid(addr, 1, !protect); ··· 23 25 { 24 26 return !kfence_early_init; 25 27 } 28 + bool arch_kfence_init_pool(void); 26 29 #else /* CONFIG_KFENCE */ 27 30 static inline bool arm64_kfence_can_set_direct_map(void) { return false; } 28 31 #endif /* CONFIG_KFENCE */
+11 -4
arch/arm64/include/asm/percpu.h
··· 77 77 " stxr" #sfx "\t%w[loop], %" #w "[tmp], %[ptr]\n" \ 78 78 " cbnz %w[loop], 1b", \ 79 79 /* LSE atomics */ \ 80 - #op_lse "\t%" #w "[val], %[ptr]\n" \ 80 + #op_lse "\t%" #w "[val], %" #w "[tmp], %[ptr]\n" \ 81 81 __nops(3)) \ 82 82 : [loop] "=&r" (loop), [tmp] "=&r" (tmp), \ 83 83 [ptr] "+Q"(*(u##sz *)ptr) \ ··· 124 124 PERCPU_RW_OPS(16) 125 125 PERCPU_RW_OPS(32) 126 126 PERCPU_RW_OPS(64) 127 - PERCPU_OP(add, add, stadd) 128 - PERCPU_OP(andnot, bic, stclr) 129 - PERCPU_OP(or, orr, stset) 127 + 128 + /* 129 + * Use value-returning atomics for CPU-local ops as they are more likely 130 + * to execute "near" to the CPU (e.g. in L1$). 131 + * 132 + * https://lore.kernel.org/r/e7d539ed-ced0-4b96-8ecd-048a5b803b85@paulmck-laptop 133 + */ 134 + PERCPU_OP(add, add, ldadd) 135 + PERCPU_OP(andnot, bic, ldclr) 136 + PERCPU_OP(or, orr, ldset) 130 137 PERCPU_RET_OP(add, add, ldadd) 131 138 132 139 #undef PERCPU_RW_OPS
+1 -1
arch/arm64/include/asm/scs.h
··· 53 53 EDYNSCS_INVALID_CFA_OPCODE = 4, 54 54 }; 55 55 56 - int __pi_scs_patch(const u8 eh_frame[], int size); 56 + int __pi_scs_patch(const u8 eh_frame[], int size, bool skip_dry_run); 57 57 58 58 #endif /* __ASSEMBLY __ */ 59 59
+1
arch/arm64/include/asm/spectre.h
··· 117 117 __le32 *origptr, __le32 *updptr, int nr_inst); 118 118 void spectre_bhb_patch_clearbhb(struct alt_instr *alt, 119 119 __le32 *origptr, __le32 *updptr, int nr_inst); 120 + void spectre_print_disabled_mitigations(void); 120 121 121 122 #endif /* __ASSEMBLY__ */ 122 123 #endif /* __ASM_SPECTRE_H */
+1 -7
arch/arm64/kernel/acpi.c
··· 197 197 */ 198 198 void __init acpi_boot_table_init(void) 199 199 { 200 - int ret; 201 - 202 200 /* 203 201 * Enable ACPI instead of device tree unless 204 202 * - ACPI has been disabled explicitly (acpi=off), or ··· 250 252 * behaviour, use acpi=nospcr to disable console in ACPI SPCR 251 253 * table as default serial console. 252 254 */ 253 - ret = acpi_parse_spcr(earlycon_acpi_spcr_enable, 255 + acpi_parse_spcr(earlycon_acpi_spcr_enable, 254 256 !param_acpi_nospcr); 255 - if (!ret || param_acpi_nospcr || !IS_ENABLED(CONFIG_ACPI_SPCR_TABLE)) 256 - pr_info("Use ACPI SPCR as default console: No\n"); 257 - else 258 - pr_info("Use ACPI SPCR as default console: Yes\n"); 259 257 260 258 if (IS_ENABLED(CONFIG_ACPI_BGRT)) 261 259 acpi_table_parse(ACPI_SIG_BGRT, acpi_parse_bgrt);
+12 -7
arch/arm64/kernel/alternative.c
··· 139 139 } while (cur += d_size, cur < end); 140 140 } 141 141 142 - static void __apply_alternatives(const struct alt_region *region, 143 - bool is_module, 144 - unsigned long *cpucap_mask) 142 + static int __apply_alternatives(const struct alt_region *region, 143 + bool is_module, 144 + unsigned long *cpucap_mask) 145 145 { 146 146 struct alt_instr *alt; 147 147 __le32 *origptr, *updptr; ··· 166 166 updptr = is_module ? origptr : lm_alias(origptr); 167 167 nr_inst = alt->orig_len / AARCH64_INSN_SIZE; 168 168 169 - if (ALT_HAS_CB(alt)) 169 + if (ALT_HAS_CB(alt)) { 170 170 alt_cb = ALT_REPL_PTR(alt); 171 - else 171 + if (is_module && !core_kernel_text((unsigned long)alt_cb)) 172 + return -ENOEXEC; 173 + } else { 172 174 alt_cb = patch_alternative; 175 + } 173 176 174 177 alt_cb(alt, origptr, updptr, nr_inst); 175 178 ··· 196 193 bitmap_and(applied_alternatives, applied_alternatives, 197 194 system_cpucaps, ARM64_NCAPS); 198 195 } 196 + 197 + return 0; 199 198 } 200 199 201 200 static void __init apply_alternatives_vdso(void) ··· 282 277 } 283 278 284 279 #ifdef CONFIG_MODULES 285 - void apply_alternatives_module(void *start, size_t length) 280 + int apply_alternatives_module(void *start, size_t length) 286 281 { 287 282 struct alt_region region = { 288 283 .begin = start, ··· 292 287 293 288 bitmap_fill(all_capabilities, ARM64_NCAPS); 294 289 295 - __apply_alternatives(&region, true, &all_capabilities[0]); 290 + return __apply_alternatives(&region, true, &all_capabilities[0]); 296 291 } 297 292 #endif 298 293
+6
arch/arm64/kernel/cpufeature.c
··· 95 95 #include <asm/vectors.h> 96 96 #include <asm/virt.h> 97 97 98 + #include <asm/spectre.h> 98 99 /* Kernel representation of AT_HWCAP and AT_HWCAP2 */ 99 100 static DECLARE_BITMAP(elf_hwcap, MAX_CPU_FEATURES) __read_mostly; 100 101 ··· 3876 3875 */ 3877 3876 if (system_uses_ttbr0_pan()) 3878 3877 pr_info("emulated: Privileged Access Never (PAN) using TTBR0_EL1 switching\n"); 3878 + 3879 + /* 3880 + * Report Spectre mitigations status. 3881 + */ 3882 + spectre_print_disabled_mitigations(); 3879 3883 } 3880 3884 3881 3885 void __init setup_system_features(void)
+17 -4
arch/arm64/kernel/module.c
··· 489 489 int ret; 490 490 491 491 s = find_section(hdr, sechdrs, ".altinstructions"); 492 - if (s) 493 - apply_alternatives_module((void *)s->sh_addr, s->sh_size); 492 + if (s) { 493 + ret = apply_alternatives_module((void *)s->sh_addr, s->sh_size); 494 + if (ret < 0) { 495 + pr_err("module %s: error occurred when applying alternatives\n", me->name); 496 + return ret; 497 + } 498 + } 494 499 495 500 if (scs_is_dynamic()) { 496 501 s = find_section(hdr, sechdrs, ".init.eh_frame"); 497 502 if (s) { 498 - ret = __pi_scs_patch((void *)s->sh_addr, s->sh_size); 499 - if (ret) 503 + /* 504 + * Because we can reject modules that are malformed 505 + * so SCS patching fails, skip dry run and try to patch 506 + * it in place. If patching fails, the module would not 507 + * be loaded anyway. 508 + */ 509 + ret = __pi_scs_patch((void *)s->sh_addr, s->sh_size, true); 510 + if (ret) { 500 511 pr_err("module %s: error occurred during dynamic SCS patching (%d)\n", 501 512 me->name, ret); 513 + return -ENOEXEC; 514 + } 502 515 } 503 516 } 504 517
+2 -1
arch/arm64/kernel/mte.c
··· 476 476 477 477 folio = page_folio(page); 478 478 if (folio_test_hugetlb(folio)) 479 - WARN_ON_ONCE(!folio_test_hugetlb_mte_tagged(folio)); 479 + WARN_ON_ONCE(!folio_test_hugetlb_mte_tagged(folio) && 480 + !is_huge_zero_folio(folio)); 480 481 else 481 482 WARN_ON_ONCE(!page_mte_tagged(page) && !is_zero_page(page)); 482 483
+1 -1
arch/arm64/kernel/pi/map_kernel.c
··· 104 104 105 105 if (enable_scs) { 106 106 scs_patch(__eh_frame_start + va_offset, 107 - __eh_frame_end - __eh_frame_start); 107 + __eh_frame_end - __eh_frame_start, false); 108 108 asm("ic ialluis"); 109 109 110 110 dynamic_scs_is_enabled = true;
+6 -4
arch/arm64/kernel/pi/patch-scs.c
··· 225 225 return 0; 226 226 } 227 227 228 - int scs_patch(const u8 eh_frame[], int size) 228 + int scs_patch(const u8 eh_frame[], int size, bool skip_dry_run) 229 229 { 230 230 int code_alignment_factor = 1; 231 231 bool fde_use_sdata8 = false; ··· 277 277 } 278 278 } else { 279 279 ret = scs_handle_fde_frame(frame, code_alignment_factor, 280 - fde_use_sdata8, true); 280 + fde_use_sdata8, !skip_dry_run); 281 281 if (ret) 282 282 return ret; 283 - scs_handle_fde_frame(frame, code_alignment_factor, 284 - fde_use_sdata8, false); 283 + 284 + if (!skip_dry_run) 285 + scs_handle_fde_frame(frame, code_alignment_factor, 286 + fde_use_sdata8, false); 285 287 } 286 288 287 289 p += sizeof(frame->size) + frame->size;
+1 -1
arch/arm64/kernel/pi/pi.h
··· 27 27 void init_feature_override(u64 boot_status, const void *fdt, int chosen); 28 28 u64 kaslr_early_init(void *fdt, int chosen); 29 29 void relocate_kernel(u64 offset); 30 - int scs_patch(const u8 eh_frame[], int size); 30 + int scs_patch(const u8 eh_frame[], int size, bool skip_dry_run); 31 31 32 32 void map_range(phys_addr_t *pte, u64 start, u64 end, phys_addr_t pa, 33 33 pgprot_t prot, int level, pte_t *tbl, bool may_use_cont,
+4 -1
arch/arm64/kernel/probes/kprobes.c
··· 49 49 addr = execmem_alloc(EXECMEM_KPROBES, PAGE_SIZE); 50 50 if (!addr) 51 51 return NULL; 52 - set_memory_rox((unsigned long)addr, 1); 52 + if (set_memory_rox((unsigned long)addr, 1)) { 53 + execmem_free(addr); 54 + return NULL; 55 + } 53 56 return addr; 54 57 } 55 58
+18 -17
arch/arm64/kernel/proton-pack.c
··· 91 91 92 92 static bool spectre_v2_mitigations_off(void) 93 93 { 94 - bool ret = __nospectre_v2 || cpu_mitigations_off(); 95 - 96 - if (ret) 97 - pr_info_once("spectre-v2 mitigation disabled by command line option\n"); 98 - 99 - return ret; 94 + return __nospectre_v2 || cpu_mitigations_off(); 100 95 } 101 96 102 97 static const char *get_bhb_affected_string(enum mitigation_state bhb_state) ··· 416 421 */ 417 422 static bool spectre_v4_mitigations_off(void) 418 423 { 419 - bool ret = cpu_mitigations_off() || 420 - __spectre_v4_policy == SPECTRE_V4_POLICY_MITIGATION_DISABLED; 421 - 422 - if (ret) 423 - pr_info_once("spectre-v4 mitigation disabled by command-line option\n"); 424 - 425 - return ret; 424 + return cpu_mitigations_off() || 425 + __spectre_v4_policy == SPECTRE_V4_POLICY_MITIGATION_DISABLED; 426 426 } 427 427 428 428 /* Do we need to toggle the mitigation state on entry to/exit from the kernel? */ ··· 1032 1042 1033 1043 if (arm64_get_spectre_v2_state() == SPECTRE_VULNERABLE) { 1034 1044 /* No point mitigating Spectre-BHB alone. */ 1035 - } else if (!IS_ENABLED(CONFIG_MITIGATE_SPECTRE_BRANCH_HISTORY)) { 1036 - pr_info_once("spectre-bhb mitigation disabled by compile time option\n"); 1037 - } else if (cpu_mitigations_off() || __nospectre_bhb) { 1038 - pr_info_once("spectre-bhb mitigation disabled by command line option\n"); 1039 1045 } else if (supports_ecbhb(SCOPE_LOCAL_CPU)) { 1040 1046 state = SPECTRE_MITIGATED; 1041 1047 set_bit(BHB_HW, &system_bhb_mitigations); ··· 1185 1199 pr_err("WARNING: %s", EBPF_WARN); 1186 1200 } 1187 1201 #endif 1202 + 1203 + void spectre_print_disabled_mitigations(void) 1204 + { 1205 + /* Keep a single copy of the common message suffix to avoid duplication. */ 1206 + const char *spectre_disabled_suffix = "mitigation disabled by command-line option\n"; 1207 + 1208 + if (spectre_v2_mitigations_off()) 1209 + pr_info("spectre-v2 %s", spectre_disabled_suffix); 1210 + 1211 + if (spectre_v4_mitigations_off()) 1212 + pr_info("spectre-v4 %s", spectre_disabled_suffix); 1213 + 1214 + if (__nospectre_bhb || cpu_mitigations_off()) 1215 + pr_info("spectre-bhb %s", spectre_disabled_suffix); 1216 + }
+7 -2
arch/arm64/kvm/hyp/nvhe/ffa.c
··· 479 479 struct ffa_mem_region_attributes *ep_mem_access; 480 480 struct ffa_composite_mem_region *reg; 481 481 struct ffa_mem_region *buf; 482 - u32 offset, nr_ranges; 482 + u32 offset, nr_ranges, checked_offset; 483 483 int ret = 0; 484 484 485 485 if (addr_mbz || npages_mbz || fraglen > len || ··· 516 516 goto out_unlock; 517 517 } 518 518 519 - if (fraglen < offset + sizeof(struct ffa_composite_mem_region)) { 519 + if (check_add_overflow(offset, sizeof(struct ffa_composite_mem_region), &checked_offset)) { 520 + ret = FFA_RET_INVALID_PARAMETERS; 521 + goto out_unlock; 522 + } 523 + 524 + if (fraglen < checked_offset) { 520 525 ret = FFA_RET_INVALID_PARAMETERS; 521 526 goto out_unlock; 522 527 }
+28
arch/arm64/kvm/hyp/nvhe/mem_protect.c
··· 367 367 return kvm_pgtable_stage2_unmap(pgt, addr, BIT(pgt->ia_bits) - addr); 368 368 } 369 369 370 + /* 371 + * Ensure the PFN range is contained within PA-range. 372 + * 373 + * This check is also robust to overflows and is therefore a requirement before 374 + * using a pfn/nr_pages pair from an untrusted source. 375 + */ 376 + static bool pfn_range_is_valid(u64 pfn, u64 nr_pages) 377 + { 378 + u64 limit = BIT(kvm_phys_shift(&host_mmu.arch.mmu) - PAGE_SHIFT); 379 + 380 + return pfn < limit && ((limit - pfn) >= nr_pages); 381 + } 382 + 370 383 struct kvm_mem_range { 371 384 u64 start; 372 385 u64 end; ··· 789 776 void *virt = __hyp_va(phys); 790 777 int ret; 791 778 779 + if (!pfn_range_is_valid(pfn, nr_pages)) 780 + return -EINVAL; 781 + 792 782 host_lock_component(); 793 783 hyp_lock_component(); 794 784 ··· 819 803 u64 size = PAGE_SIZE * nr_pages; 820 804 u64 virt = (u64)__hyp_va(phys); 821 805 int ret; 806 + 807 + if (!pfn_range_is_valid(pfn, nr_pages)) 808 + return -EINVAL; 822 809 823 810 host_lock_component(); 824 811 hyp_lock_component(); ··· 906 887 u64 size = PAGE_SIZE * nr_pages; 907 888 int ret; 908 889 890 + if (!pfn_range_is_valid(pfn, nr_pages)) 891 + return -EINVAL; 892 + 909 893 host_lock_component(); 910 894 ret = __host_check_page_state_range(phys, size, PKVM_PAGE_OWNED); 911 895 if (!ret) ··· 923 901 u64 phys = hyp_pfn_to_phys(pfn); 924 902 u64 size = PAGE_SIZE * nr_pages; 925 903 int ret; 904 + 905 + if (!pfn_range_is_valid(pfn, nr_pages)) 906 + return -EINVAL; 926 907 927 908 host_lock_component(); 928 909 ret = __host_check_page_state_range(phys, size, PKVM_PAGE_SHARED_OWNED); ··· 968 943 int ret; 969 944 970 945 if (prot & ~KVM_PGTABLE_PROT_RWX) 946 + return -EINVAL; 947 + 948 + if (!pfn_range_is_valid(pfn, nr_pages)) 971 949 return -EINVAL; 972 950 973 951 ret = __guest_check_transition_size(phys, ipa, nr_pages, &size);
+38 -33
arch/arm64/kvm/sys_regs.c
··· 2595 2595 .val = 0, \ 2596 2596 } 2597 2597 2598 - /* sys_reg_desc initialiser for known cpufeature ID registers */ 2599 - #define AA32_ID_SANITISED(name) { \ 2600 - ID_DESC(name), \ 2601 - .visibility = aa32_id_visibility, \ 2602 - .val = 0, \ 2603 - } 2604 - 2605 2598 /* sys_reg_desc initialiser for writable ID registers */ 2606 2599 #define ID_WRITABLE(name, mask) { \ 2607 2600 ID_DESC(name), \ 2608 2601 .val = mask, \ 2602 + } 2603 + 2604 + /* 2605 + * 32bit ID regs are fully writable when the guest is 32bit 2606 + * capable. Nothing in the KVM code should rely on 32bit features 2607 + * anyway, only 64bit, so let the VMM do its worse. 2608 + */ 2609 + #define AA32_ID_WRITABLE(name) { \ 2610 + ID_DESC(name), \ 2611 + .visibility = aa32_id_visibility, \ 2612 + .val = GENMASK(31, 0), \ 2609 2613 } 2610 2614 2611 2615 /* sys_reg_desc initialiser for cpufeature ID registers that need filtering */ ··· 3132 3128 3133 3129 /* AArch64 mappings of the AArch32 ID registers */ 3134 3130 /* CRm=1 */ 3135 - AA32_ID_SANITISED(ID_PFR0_EL1), 3136 - AA32_ID_SANITISED(ID_PFR1_EL1), 3131 + AA32_ID_WRITABLE(ID_PFR0_EL1), 3132 + AA32_ID_WRITABLE(ID_PFR1_EL1), 3137 3133 { SYS_DESC(SYS_ID_DFR0_EL1), 3138 3134 .access = access_id_reg, 3139 3135 .get_user = get_id_reg, 3140 3136 .set_user = set_id_dfr0_el1, 3141 3137 .visibility = aa32_id_visibility, 3142 3138 .reset = read_sanitised_id_dfr0_el1, 3143 - .val = ID_DFR0_EL1_PerfMon_MASK | 3144 - ID_DFR0_EL1_CopDbg_MASK, }, 3139 + .val = GENMASK(31, 0) }, 3145 3140 ID_HIDDEN(ID_AFR0_EL1), 3146 - AA32_ID_SANITISED(ID_MMFR0_EL1), 3147 - AA32_ID_SANITISED(ID_MMFR1_EL1), 3148 - AA32_ID_SANITISED(ID_MMFR2_EL1), 3149 - AA32_ID_SANITISED(ID_MMFR3_EL1), 3141 + AA32_ID_WRITABLE(ID_MMFR0_EL1), 3142 + AA32_ID_WRITABLE(ID_MMFR1_EL1), 3143 + AA32_ID_WRITABLE(ID_MMFR2_EL1), 3144 + AA32_ID_WRITABLE(ID_MMFR3_EL1), 3150 3145 3151 3146 /* CRm=2 */ 3152 - AA32_ID_SANITISED(ID_ISAR0_EL1), 3153 - AA32_ID_SANITISED(ID_ISAR1_EL1), 3154 - AA32_ID_SANITISED(ID_ISAR2_EL1), 3155 - AA32_ID_SANITISED(ID_ISAR3_EL1), 3156 - AA32_ID_SANITISED(ID_ISAR4_EL1), 3157 - AA32_ID_SANITISED(ID_ISAR5_EL1), 3158 - AA32_ID_SANITISED(ID_MMFR4_EL1), 3159 - AA32_ID_SANITISED(ID_ISAR6_EL1), 3147 + AA32_ID_WRITABLE(ID_ISAR0_EL1), 3148 + AA32_ID_WRITABLE(ID_ISAR1_EL1), 3149 + AA32_ID_WRITABLE(ID_ISAR2_EL1), 3150 + AA32_ID_WRITABLE(ID_ISAR3_EL1), 3151 + AA32_ID_WRITABLE(ID_ISAR4_EL1), 3152 + AA32_ID_WRITABLE(ID_ISAR5_EL1), 3153 + AA32_ID_WRITABLE(ID_MMFR4_EL1), 3154 + AA32_ID_WRITABLE(ID_ISAR6_EL1), 3160 3155 3161 3156 /* CRm=3 */ 3162 - AA32_ID_SANITISED(MVFR0_EL1), 3163 - AA32_ID_SANITISED(MVFR1_EL1), 3164 - AA32_ID_SANITISED(MVFR2_EL1), 3157 + AA32_ID_WRITABLE(MVFR0_EL1), 3158 + AA32_ID_WRITABLE(MVFR1_EL1), 3159 + AA32_ID_WRITABLE(MVFR2_EL1), 3165 3160 ID_UNALLOCATED(3,3), 3166 - AA32_ID_SANITISED(ID_PFR2_EL1), 3161 + AA32_ID_WRITABLE(ID_PFR2_EL1), 3167 3162 ID_HIDDEN(ID_DFR1_EL1), 3168 - AA32_ID_SANITISED(ID_MMFR5_EL1), 3163 + AA32_ID_WRITABLE(ID_MMFR5_EL1), 3169 3164 ID_UNALLOCATED(3,7), 3170 3165 3171 3166 /* AArch64 ID registers */ ··· 5609 5606 5610 5607 guard(mutex)(&kvm->arch.config_lock); 5611 5608 5612 - if (!(static_branch_unlikely(&kvm_vgic_global_state.gicv3_cpuif) && 5613 - irqchip_in_kernel(kvm) && 5614 - kvm->arch.vgic.vgic_model == KVM_DEV_TYPE_ARM_VGIC_V3)) { 5615 - kvm->arch.id_regs[IDREG_IDX(SYS_ID_AA64PFR0_EL1)] &= ~ID_AA64PFR0_EL1_GIC_MASK; 5616 - kvm->arch.id_regs[IDREG_IDX(SYS_ID_PFR1_EL1)] &= ~ID_PFR1_EL1_GIC_MASK; 5609 + if (!irqchip_in_kernel(kvm)) { 5610 + u64 val; 5611 + 5612 + val = kvm_read_vm_id_reg(kvm, SYS_ID_AA64PFR0_EL1) & ~ID_AA64PFR0_EL1_GIC; 5613 + kvm_set_vm_id_reg(kvm, SYS_ID_AA64PFR0_EL1, val); 5614 + val = kvm_read_vm_id_reg(kvm, SYS_ID_PFR1_EL1) & ~ID_PFR1_EL1_GIC; 5615 + kvm_set_vm_id_reg(kvm, SYS_ID_PFR1_EL1, val); 5617 5616 } 5618 5617 5619 5618 if (vcpu_has_nv(vcpu)) {
+12 -4
arch/arm64/kvm/vgic/vgic-debug.c
··· 64 64 static int iter_mark_lpis(struct kvm *kvm) 65 65 { 66 66 struct vgic_dist *dist = &kvm->arch.vgic; 67 + unsigned long intid, flags; 67 68 struct vgic_irq *irq; 68 - unsigned long intid; 69 69 int nr_lpis = 0; 70 + 71 + xa_lock_irqsave(&dist->lpi_xa, flags); 70 72 71 73 xa_for_each(&dist->lpi_xa, intid, irq) { 72 74 if (!vgic_try_get_irq_ref(irq)) 73 75 continue; 74 76 75 - xa_set_mark(&dist->lpi_xa, intid, LPI_XA_MARK_DEBUG_ITER); 77 + __xa_set_mark(&dist->lpi_xa, intid, LPI_XA_MARK_DEBUG_ITER); 76 78 nr_lpis++; 77 79 } 80 + 81 + xa_unlock_irqrestore(&dist->lpi_xa, flags); 78 82 79 83 return nr_lpis; 80 84 } ··· 86 82 static void iter_unmark_lpis(struct kvm *kvm) 87 83 { 88 84 struct vgic_dist *dist = &kvm->arch.vgic; 85 + unsigned long intid, flags; 89 86 struct vgic_irq *irq; 90 - unsigned long intid; 91 87 92 88 xa_for_each_marked(&dist->lpi_xa, intid, irq, LPI_XA_MARK_DEBUG_ITER) { 93 - xa_clear_mark(&dist->lpi_xa, intid, LPI_XA_MARK_DEBUG_ITER); 89 + xa_lock_irqsave(&dist->lpi_xa, flags); 90 + __xa_clear_mark(&dist->lpi_xa, intid, LPI_XA_MARK_DEBUG_ITER); 91 + xa_unlock_irqrestore(&dist->lpi_xa, flags); 92 + 93 + /* vgic_put_irq() expects to be called outside of the xa_lock */ 94 94 vgic_put_irq(kvm, irq); 95 95 } 96 96 }
+13 -3
arch/arm64/kvm/vgic/vgic-init.c
··· 53 53 { 54 54 struct vgic_dist *dist = &kvm->arch.vgic; 55 55 56 - xa_init(&dist->lpi_xa); 56 + xa_init_flags(&dist->lpi_xa, XA_FLAGS_LOCK_IRQ); 57 57 } 58 58 59 59 /* CREATION */ ··· 71 71 int kvm_vgic_create(struct kvm *kvm, u32 type) 72 72 { 73 73 struct kvm_vcpu *vcpu; 74 + u64 aa64pfr0, pfr1; 74 75 unsigned long i; 75 76 int ret; 76 77 ··· 162 161 163 162 kvm->arch.vgic.vgic_dist_base = VGIC_ADDR_UNDEF; 164 163 165 - if (type == KVM_DEV_TYPE_ARM_VGIC_V2) 164 + aa64pfr0 = kvm_read_vm_id_reg(kvm, SYS_ID_AA64PFR0_EL1) & ~ID_AA64PFR0_EL1_GIC; 165 + pfr1 = kvm_read_vm_id_reg(kvm, SYS_ID_PFR1_EL1) & ~ID_PFR1_EL1_GIC; 166 + 167 + if (type == KVM_DEV_TYPE_ARM_VGIC_V2) { 166 168 kvm->arch.vgic.vgic_cpu_base = VGIC_ADDR_UNDEF; 167 - else 169 + } else { 168 170 INIT_LIST_HEAD(&kvm->arch.vgic.rd_regions); 171 + aa64pfr0 |= SYS_FIELD_PREP_ENUM(ID_AA64PFR0_EL1, GIC, IMP); 172 + pfr1 |= SYS_FIELD_PREP_ENUM(ID_PFR1_EL1, GIC, GICv3); 173 + } 174 + 175 + kvm_set_vm_id_reg(kvm, SYS_ID_AA64PFR0_EL1, aa64pfr0); 176 + kvm_set_vm_id_reg(kvm, SYS_ID_PFR1_EL1, pfr1); 169 177 170 178 if (type == KVM_DEV_TYPE_ARM_VGIC_V3) 171 179 kvm->arch.vgic.nassgicap = system_supports_direct_sgis();
+8 -10
arch/arm64/kvm/vgic/vgic-its.c
··· 78 78 { 79 79 struct vgic_dist *dist = &kvm->arch.vgic; 80 80 struct vgic_irq *irq = vgic_get_irq(kvm, intid), *oldirq; 81 + unsigned long flags; 81 82 int ret; 82 83 83 84 /* In this case there is no put, since we keep the reference. */ ··· 89 88 if (!irq) 90 89 return ERR_PTR(-ENOMEM); 91 90 92 - ret = xa_reserve(&dist->lpi_xa, intid, GFP_KERNEL_ACCOUNT); 91 + ret = xa_reserve_irq(&dist->lpi_xa, intid, GFP_KERNEL_ACCOUNT); 93 92 if (ret) { 94 93 kfree(irq); 95 94 return ERR_PTR(ret); ··· 104 103 irq->target_vcpu = vcpu; 105 104 irq->group = 1; 106 105 107 - xa_lock(&dist->lpi_xa); 106 + xa_lock_irqsave(&dist->lpi_xa, flags); 108 107 109 108 /* 110 109 * There could be a race with another vgic_add_lpi(), so we need to ··· 115 114 /* Someone was faster with adding this LPI, lets use that. */ 116 115 kfree(irq); 117 116 irq = oldirq; 118 - 119 - goto out_unlock; 117 + } else { 118 + ret = xa_err(__xa_store(&dist->lpi_xa, intid, irq, 0)); 120 119 } 121 120 122 - ret = xa_err(__xa_store(&dist->lpi_xa, intid, irq, 0)); 121 + xa_unlock_irqrestore(&dist->lpi_xa, flags); 122 + 123 123 if (ret) { 124 124 xa_release(&dist->lpi_xa, intid); 125 125 kfree(irq); 126 - } 127 126 128 - out_unlock: 129 - xa_unlock(&dist->lpi_xa); 130 - 131 - if (ret) 132 127 return ERR_PTR(ret); 128 + } 133 129 134 130 /* 135 131 * We "cache" the configuration table entries in our struct vgic_irq's.
+2 -1
arch/arm64/kvm/vgic/vgic-v3.c
··· 301 301 return; 302 302 303 303 /* Hide GICv3 sysreg if necessary */ 304 - if (vcpu->kvm->arch.vgic.vgic_model == KVM_DEV_TYPE_ARM_VGIC_V2) { 304 + if (vcpu->kvm->arch.vgic.vgic_model == KVM_DEV_TYPE_ARM_VGIC_V2 || 305 + !irqchip_in_kernel(vcpu->kvm)) { 305 306 vgic_v3->vgic_hcr |= (ICH_HCR_EL2_TALL0 | ICH_HCR_EL2_TALL1 | 306 307 ICH_HCR_EL2_TC); 307 308 return;
+15 -8
arch/arm64/kvm/vgic/vgic.c
··· 28 28 * kvm->arch.config_lock (mutex) 29 29 * its->cmd_lock (mutex) 30 30 * its->its_lock (mutex) 31 - * vgic_dist->lpi_xa.xa_lock 31 + * vgic_dist->lpi_xa.xa_lock must be taken with IRQs disabled 32 32 * vgic_cpu->ap_list_lock must be taken with IRQs disabled 33 33 * vgic_irq->irq_lock must be taken with IRQs disabled 34 34 * ··· 141 141 void vgic_put_irq(struct kvm *kvm, struct vgic_irq *irq) 142 142 { 143 143 struct vgic_dist *dist = &kvm->arch.vgic; 144 + unsigned long flags; 144 145 145 - if (irq->intid >= VGIC_MIN_LPI) 146 - might_lock(&dist->lpi_xa.xa_lock); 146 + /* 147 + * Normally the lock is only taken when the refcount drops to 0. 148 + * Acquire/release it early on lockdep kernels to make locking issues 149 + * in rare release paths a bit more obvious. 150 + */ 151 + if (IS_ENABLED(CONFIG_LOCKDEP) && irq->intid >= VGIC_MIN_LPI) { 152 + guard(spinlock_irqsave)(&dist->lpi_xa.xa_lock); 153 + } 147 154 148 155 if (!__vgic_put_irq(kvm, irq)) 149 156 return; 150 157 151 - xa_lock(&dist->lpi_xa); 158 + xa_lock_irqsave(&dist->lpi_xa, flags); 152 159 vgic_release_lpi_locked(dist, irq); 153 - xa_unlock(&dist->lpi_xa); 160 + xa_unlock_irqrestore(&dist->lpi_xa, flags); 154 161 } 155 162 156 163 static void vgic_release_deleted_lpis(struct kvm *kvm) 157 164 { 158 165 struct vgic_dist *dist = &kvm->arch.vgic; 159 - unsigned long intid; 166 + unsigned long flags, intid; 160 167 struct vgic_irq *irq; 161 168 162 - xa_lock(&dist->lpi_xa); 169 + xa_lock_irqsave(&dist->lpi_xa, flags); 163 170 164 171 xa_for_each(&dist->lpi_xa, intid, irq) { 165 172 if (irq->pending_release) 166 173 vgic_release_lpi_locked(dist, irq); 167 174 } 168 175 169 - xa_unlock(&dist->lpi_xa); 176 + xa_unlock_irqrestore(&dist->lpi_xa, flags); 170 177 } 171 178 172 179 void vgic_flush_pending_lpis(struct kvm_vcpu *vcpu)
+10
arch/arm64/mm/fault.c
··· 969 969 970 970 void tag_clear_highpage(struct page *page) 971 971 { 972 + /* 973 + * Check if MTE is supported and fall back to clear_highpage(). 974 + * get_huge_zero_folio() unconditionally passes __GFP_ZEROTAGS and 975 + * post_alloc_hook() will invoke tag_clear_highpage(). 976 + */ 977 + if (!system_supports_mte()) { 978 + clear_highpage(page); 979 + return; 980 + } 981 + 972 982 /* Newly allocated page, shouldn't have been tagged yet */ 973 983 WARN_ON_ONCE(!try_page_mte_tagging(page)); 974 984 mte_zero_clear_page_tags(page_address(page));
+80 -31
arch/arm64/mm/mmu.c
··· 708 708 return ret; 709 709 } 710 710 711 + static inline bool force_pte_mapping(void) 712 + { 713 + const bool bbml2 = system_capabilities_finalized() ? 714 + system_supports_bbml2_noabort() : cpu_supports_bbml2_noabort(); 715 + 716 + if (debug_pagealloc_enabled()) 717 + return true; 718 + if (bbml2) 719 + return false; 720 + return rodata_full || arm64_kfence_can_set_direct_map() || is_realm_world(); 721 + } 722 + 723 + static inline bool split_leaf_mapping_possible(void) 724 + { 725 + /* 726 + * !BBML2_NOABORT systems should never run into scenarios where we would 727 + * have to split. So exit early and let calling code detect it and raise 728 + * a warning. 729 + */ 730 + if (!system_supports_bbml2_noabort()) 731 + return false; 732 + return !force_pte_mapping(); 733 + } 734 + 711 735 static DEFINE_MUTEX(pgtable_split_lock); 712 736 713 737 int split_kernel_leaf_mapping(unsigned long start, unsigned long end) ··· 739 715 int ret; 740 716 741 717 /* 742 - * !BBML2_NOABORT systems should not be trying to change permissions on 743 - * anything that is not pte-mapped in the first place. Just return early 744 - * and let the permission change code raise a warning if not already 745 - * pte-mapped. 718 + * Exit early if the region is within a pte-mapped area or if we can't 719 + * split. For the latter case, the permission change code will raise a 720 + * warning if not already pte-mapped. 746 721 */ 747 - if (!system_supports_bbml2_noabort()) 722 + if (!split_leaf_mapping_possible() || is_kfence_address((void *)start)) 748 723 return 0; 749 724 750 725 /* ··· 781 758 return ret; 782 759 } 783 760 784 - static int __init split_to_ptes_pud_entry(pud_t *pudp, unsigned long addr, 785 - unsigned long next, 786 - struct mm_walk *walk) 761 + static int split_to_ptes_pud_entry(pud_t *pudp, unsigned long addr, 762 + unsigned long next, struct mm_walk *walk) 787 763 { 764 + gfp_t gfp = *(gfp_t *)walk->private; 788 765 pud_t pud = pudp_get(pudp); 789 766 int ret = 0; 790 767 791 768 if (pud_leaf(pud)) 792 - ret = split_pud(pudp, pud, GFP_ATOMIC, false); 769 + ret = split_pud(pudp, pud, gfp, false); 793 770 794 771 return ret; 795 772 } 796 773 797 - static int __init split_to_ptes_pmd_entry(pmd_t *pmdp, unsigned long addr, 798 - unsigned long next, 799 - struct mm_walk *walk) 774 + static int split_to_ptes_pmd_entry(pmd_t *pmdp, unsigned long addr, 775 + unsigned long next, struct mm_walk *walk) 800 776 { 777 + gfp_t gfp = *(gfp_t *)walk->private; 801 778 pmd_t pmd = pmdp_get(pmdp); 802 779 int ret = 0; 803 780 804 781 if (pmd_leaf(pmd)) { 805 782 if (pmd_cont(pmd)) 806 783 split_contpmd(pmdp); 807 - ret = split_pmd(pmdp, pmd, GFP_ATOMIC, false); 784 + ret = split_pmd(pmdp, pmd, gfp, false); 808 785 809 786 /* 810 787 * We have split the pmd directly to ptes so there is no need to ··· 816 793 return ret; 817 794 } 818 795 819 - static int __init split_to_ptes_pte_entry(pte_t *ptep, unsigned long addr, 820 - unsigned long next, 821 - struct mm_walk *walk) 796 + static int split_to_ptes_pte_entry(pte_t *ptep, unsigned long addr, 797 + unsigned long next, struct mm_walk *walk) 822 798 { 823 799 pte_t pte = __ptep_get(ptep); 824 800 ··· 827 805 return 0; 828 806 } 829 807 830 - static const struct mm_walk_ops split_to_ptes_ops __initconst = { 808 + static const struct mm_walk_ops split_to_ptes_ops = { 831 809 .pud_entry = split_to_ptes_pud_entry, 832 810 .pmd_entry = split_to_ptes_pmd_entry, 833 811 .pte_entry = split_to_ptes_pte_entry, 834 812 }; 813 + 814 + static int range_split_to_ptes(unsigned long start, unsigned long end, gfp_t gfp) 815 + { 816 + int ret; 817 + 818 + arch_enter_lazy_mmu_mode(); 819 + ret = walk_kernel_page_table_range_lockless(start, end, 820 + &split_to_ptes_ops, NULL, &gfp); 821 + arch_leave_lazy_mmu_mode(); 822 + 823 + return ret; 824 + } 835 825 836 826 static bool linear_map_requires_bbml2 __initdata; 837 827 ··· 881 847 * PTE. The kernel alias remains static throughout runtime so 882 848 * can continue to be safely mapped with large mappings. 883 849 */ 884 - ret = walk_kernel_page_table_range_lockless(lstart, kstart, 885 - &split_to_ptes_ops, NULL, NULL); 850 + ret = range_split_to_ptes(lstart, kstart, GFP_ATOMIC); 886 851 if (!ret) 887 - ret = walk_kernel_page_table_range_lockless(kend, lend, 888 - &split_to_ptes_ops, NULL, NULL); 852 + ret = range_split_to_ptes(kend, lend, GFP_ATOMIC); 889 853 if (ret) 890 854 panic("Failed to split linear map\n"); 891 855 flush_tlb_kernel_range(lstart, lend); ··· 1034 1002 memblock_clear_nomap(kfence_pool, KFENCE_POOL_SIZE); 1035 1003 __kfence_pool = phys_to_virt(kfence_pool); 1036 1004 } 1005 + 1006 + bool arch_kfence_init_pool(void) 1007 + { 1008 + unsigned long start = (unsigned long)__kfence_pool; 1009 + unsigned long end = start + KFENCE_POOL_SIZE; 1010 + int ret; 1011 + 1012 + /* Exit early if we know the linear map is already pte-mapped. */ 1013 + if (!split_leaf_mapping_possible()) 1014 + return true; 1015 + 1016 + /* Kfence pool is already pte-mapped for the early init case. */ 1017 + if (kfence_early_init) 1018 + return true; 1019 + 1020 + mutex_lock(&pgtable_split_lock); 1021 + ret = range_split_to_ptes(start, end, GFP_PGTABLE_KERNEL); 1022 + mutex_unlock(&pgtable_split_lock); 1023 + 1024 + /* 1025 + * Since the system supports bbml2_noabort, tlb invalidation is not 1026 + * required here; the pgtable mappings have been split to pte but larger 1027 + * entries may safely linger in the TLB. 1028 + */ 1029 + 1030 + return !ret; 1031 + } 1037 1032 #else /* CONFIG_KFENCE */ 1038 1033 1039 1034 static inline phys_addr_t arm64_kfence_alloc_pool(void) { return 0; } 1040 1035 static inline void arm64_kfence_map_pool(phys_addr_t kfence_pool, pgd_t *pgdp) { } 1041 1036 1042 1037 #endif /* CONFIG_KFENCE */ 1043 - 1044 - static inline bool force_pte_mapping(void) 1045 - { 1046 - bool bbml2 = system_capabilities_finalized() ? 1047 - system_supports_bbml2_noabort() : cpu_supports_bbml2_noabort(); 1048 - 1049 - return (!bbml2 && (rodata_full || arm64_kfence_can_set_direct_map() || 1050 - is_realm_world())) || 1051 - debug_pagealloc_enabled(); 1052 - } 1053 1038 1054 1039 static void __init map_mem(pgd_t *pgdp) 1055 1040 {
+1 -1
arch/loongarch/Makefile
··· 109 109 ifdef CONFIG_RUSTC_HAS_ANNOTATE_TABLEJUMP 110 110 KBUILD_RUSTFLAGS += -Cllvm-args=--loongarch-annotate-tablejump 111 111 else 112 - KBUILD_RUSTFLAGS += -Zno-jump-tables # keep compatibility with older compilers 112 + KBUILD_RUSTFLAGS += $(if $(call rustc-min-version,109300),-Cjump-tables=n,-Zno-jump-tables) # keep compatibility with older compilers 113 113 endif 114 114 ifdef CONFIG_LTO_CLANG 115 115 # The annotate-tablejump option can not be passed to LLVM backend when LTO is enabled.
+2
arch/loongarch/include/asm/cpu-features.h
··· 67 67 #define cpu_has_hypervisor cpu_opt(LOONGARCH_CPU_HYPERVISOR) 68 68 #define cpu_has_ptw cpu_opt(LOONGARCH_CPU_PTW) 69 69 #define cpu_has_lspw cpu_opt(LOONGARCH_CPU_LSPW) 70 + #define cpu_has_msgint cpu_opt(LOONGARCH_CPU_MSGINT) 70 71 #define cpu_has_avecint cpu_opt(LOONGARCH_CPU_AVECINT) 72 + #define cpu_has_redirectint cpu_opt(LOONGARCH_CPU_REDIRECTINT) 71 73 72 74 #endif /* __ASM_CPU_FEATURES_H */
+5 -1
arch/loongarch/include/asm/cpu.h
··· 101 101 #define CPU_FEATURE_HYPERVISOR 26 /* CPU has hypervisor (running in VM) */ 102 102 #define CPU_FEATURE_PTW 27 /* CPU has hardware page table walker */ 103 103 #define CPU_FEATURE_LSPW 28 /* CPU has LSPW (lddir/ldpte instructions) */ 104 - #define CPU_FEATURE_AVECINT 29 /* CPU has AVEC interrupt */ 104 + #define CPU_FEATURE_MSGINT 29 /* CPU has MSG interrupt */ 105 + #define CPU_FEATURE_AVECINT 30 /* CPU has AVEC interrupt */ 106 + #define CPU_FEATURE_REDIRECTINT 31 /* CPU has interrupt remapping */ 105 107 106 108 #define LOONGARCH_CPU_CPUCFG BIT_ULL(CPU_FEATURE_CPUCFG) 107 109 #define LOONGARCH_CPU_LAM BIT_ULL(CPU_FEATURE_LAM) ··· 134 132 #define LOONGARCH_CPU_HYPERVISOR BIT_ULL(CPU_FEATURE_HYPERVISOR) 135 133 #define LOONGARCH_CPU_PTW BIT_ULL(CPU_FEATURE_PTW) 136 134 #define LOONGARCH_CPU_LSPW BIT_ULL(CPU_FEATURE_LSPW) 135 + #define LOONGARCH_CPU_MSGINT BIT_ULL(CPU_FEATURE_MSGINT) 137 136 #define LOONGARCH_CPU_AVECINT BIT_ULL(CPU_FEATURE_AVECINT) 137 + #define LOONGARCH_CPU_REDIRECTINT BIT_ULL(CPU_FEATURE_REDIRECTINT) 138 138 139 139 #endif /* _ASM_CPU_H */
+2 -2
arch/loongarch/include/asm/hw_breakpoint.h
··· 134 134 /* Determine number of BRP registers available. */ 135 135 static inline int get_num_brps(void) 136 136 { 137 - return csr_read64(LOONGARCH_CSR_FWPC) & CSR_FWPC_NUM; 137 + return csr_read32(LOONGARCH_CSR_FWPC) & CSR_FWPC_NUM; 138 138 } 139 139 140 140 /* Determine number of WRP registers available. */ 141 141 static inline int get_num_wrps(void) 142 142 { 143 - return csr_read64(LOONGARCH_CSR_MWPC) & CSR_MWPC_NUM; 143 + return csr_read32(LOONGARCH_CSR_MWPC) & CSR_MWPC_NUM; 144 144 } 145 145 146 146 #endif /* __KERNEL__ */
+4 -1
arch/loongarch/include/asm/io.h
··· 14 14 #include <asm/pgtable-bits.h> 15 15 #include <asm/string.h> 16 16 17 - extern void __init __iomem *early_ioremap(u64 phys_addr, unsigned long size); 17 + extern void __init __iomem *early_ioremap(phys_addr_t phys_addr, unsigned long size); 18 18 extern void __init early_iounmap(void __iomem *addr, unsigned long size); 19 19 20 20 #define early_memremap early_ioremap ··· 25 25 static inline void __iomem *ioremap_prot(phys_addr_t offset, unsigned long size, 26 26 pgprot_t prot) 27 27 { 28 + if (offset > TO_PHYS_MASK) 29 + return NULL; 30 + 28 31 switch (pgprot_val(prot) & _CACHE_MASK) { 29 32 case _CACHE_CC: 30 33 return (void __iomem *)(unsigned long)(CACHE_BASE + offset);
+2
arch/loongarch/include/asm/loongarch.h
··· 128 128 #define CPUCFG6_PMNUM GENMASK(7, 4) 129 129 #define CPUCFG6_PMNUM_SHIFT 4 130 130 #define CPUCFG6_PMBITS GENMASK(13, 8) 131 + #define CPUCFG6_PMBITS_SHIFT 8 131 132 #define CPUCFG6_UPM BIT(14) 132 133 133 134 #define LOONGARCH_CPUCFG16 0x10 ··· 1138 1137 #define IOCSRF_FLATMODE BIT_ULL(10) 1139 1138 #define IOCSRF_VM BIT_ULL(11) 1140 1139 #define IOCSRF_AVEC BIT_ULL(15) 1140 + #define IOCSRF_REDIRECT BIT_ULL(16) 1141 1141 1142 1142 #define LOONGARCH_IOCSR_VENDOR 0x10 1143 1143
+1 -1
arch/loongarch/include/asm/pgalloc.h
··· 88 88 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long address) 89 89 { 90 90 pud_t *pud; 91 - struct ptdesc *ptdesc = pagetable_alloc(GFP_KERNEL & ~__GFP_HIGHMEM, 0); 91 + struct ptdesc *ptdesc = pagetable_alloc(GFP_KERNEL, 0); 92 92 93 93 if (!ptdesc) 94 94 return NULL;
+8 -3
arch/loongarch/include/asm/pgtable.h
··· 424 424 425 425 static inline pte_t pte_modify(pte_t pte, pgprot_t newprot) 426 426 { 427 + if (pte_val(pte) & _PAGE_DIRTY) 428 + pte_val(pte) |= _PAGE_MODIFIED; 429 + 427 430 return __pte((pte_val(pte) & _PAGE_CHG_MASK) | 428 431 (pgprot_val(newprot) & ~_PAGE_CHG_MASK)); 429 432 } ··· 550 547 551 548 static inline pmd_t pmd_modify(pmd_t pmd, pgprot_t newprot) 552 549 { 553 - pmd_val(pmd) = (pmd_val(pmd) & _HPAGE_CHG_MASK) | 554 - (pgprot_val(newprot) & ~_HPAGE_CHG_MASK); 555 - return pmd; 550 + if (pmd_val(pmd) & _PAGE_DIRTY) 551 + pmd_val(pmd) |= _PAGE_MODIFIED; 552 + 553 + return __pmd((pmd_val(pmd) & _HPAGE_CHG_MASK) | 554 + (pgprot_val(newprot) & ~_HPAGE_CHG_MASK)); 556 555 } 557 556 558 557 static inline pmd_t pmd_mkinvalid(pmd_t pmd)
+4
arch/loongarch/kernel/cpu-probe.c
··· 157 157 c->options |= LOONGARCH_CPU_TLB; 158 158 if (config & CPUCFG1_IOCSR) 159 159 c->options |= LOONGARCH_CPU_IOCSR; 160 + if (config & CPUCFG1_MSGINT) 161 + c->options |= LOONGARCH_CPU_MSGINT; 160 162 if (config & CPUCFG1_UAL) { 161 163 c->options |= LOONGARCH_CPU_UAL; 162 164 elf_hwcap |= HWCAP_LOONGARCH_UAL; ··· 333 331 c->options |= LOONGARCH_CPU_EIODECODE; 334 332 if (config & IOCSRF_AVEC) 335 333 c->options |= LOONGARCH_CPU_AVECINT; 334 + if (config & IOCSRF_REDIRECT) 335 + c->options |= LOONGARCH_CPU_REDIRECTINT; 336 336 if (config & IOCSRF_VM) 337 337 c->options |= LOONGARCH_CPU_HYPERVISOR; 338 338 }
+1 -1
arch/loongarch/kernel/kexec_efi.c
··· 42 42 { 43 43 int ret; 44 44 unsigned long text_offset, kernel_segment_number; 45 - struct kexec_buf kbuf; 45 + struct kexec_buf kbuf = {}; 46 46 struct kexec_segment *kernel_segment; 47 47 struct loongarch_image_header *h; 48 48
+1 -1
arch/loongarch/kernel/kexec_elf.c
··· 59 59 int ret; 60 60 unsigned long text_offset, kernel_segment_number; 61 61 struct elfhdr ehdr; 62 - struct kexec_buf kbuf; 62 + struct kexec_buf kbuf = {}; 63 63 struct kexec_elf_info elf_info; 64 64 struct kexec_segment *kernel_segment; 65 65
-22
arch/loongarch/kernel/machine_kexec.c
··· 39 39 static unsigned long start_addr; 40 40 static unsigned long first_ind_entry; 41 41 42 - static void kexec_image_info(const struct kimage *kimage) 43 - { 44 - unsigned long i; 45 - 46 - pr_debug("kexec kimage info:\n"); 47 - pr_debug("\ttype: %d\n", kimage->type); 48 - pr_debug("\tstart: %lx\n", kimage->start); 49 - pr_debug("\thead: %lx\n", kimage->head); 50 - pr_debug("\tnr_segments: %lu\n", kimage->nr_segments); 51 - 52 - for (i = 0; i < kimage->nr_segments; i++) { 53 - pr_debug("\t segment[%lu]: %016lx - %016lx", i, 54 - kimage->segment[i].mem, 55 - kimage->segment[i].mem + kimage->segment[i].memsz); 56 - pr_debug("\t\t0x%lx bytes, %lu pages\n", 57 - (unsigned long)kimage->segment[i].memsz, 58 - (unsigned long)kimage->segment[i].memsz / PAGE_SIZE); 59 - } 60 - } 61 - 62 42 int machine_kexec_prepare(struct kimage *kimage) 63 43 { 64 44 int i; 65 45 char *bootloader = "kexec"; 66 46 void *cmdline_ptr = (void *)KEXEC_CMDLINE_ADDR; 67 - 68 - kexec_image_info(kimage); 69 47 70 48 kimage->arch.efi_boot = fw_arg0; 71 49 kimage->arch.systable_ptr = fw_arg2;
+1 -1
arch/loongarch/kernel/machine_kexec_file.c
··· 143 143 unsigned long initrd_load_addr = 0; 144 144 unsigned long orig_segments = image->nr_segments; 145 145 char *modified_cmdline = NULL; 146 - struct kexec_buf kbuf; 146 + struct kexec_buf kbuf = {}; 147 147 148 148 kbuf.image = image; 149 149 /* Don't allocate anything below the kernel */
+3 -4
arch/loongarch/kernel/mem.c
··· 13 13 void __init memblock_init(void) 14 14 { 15 15 u32 mem_type; 16 - u64 mem_start, mem_end, mem_size; 16 + u64 mem_start, mem_size; 17 17 efi_memory_desc_t *md; 18 18 19 19 /* Parse memory information */ ··· 21 21 mem_type = md->type; 22 22 mem_start = md->phys_addr; 23 23 mem_size = md->num_pages << EFI_PAGE_SHIFT; 24 - mem_end = mem_start + mem_size; 25 24 26 25 switch (mem_type) { 27 26 case EFI_LOADER_CODE: ··· 30 31 case EFI_PERSISTENT_MEMORY: 31 32 case EFI_CONVENTIONAL_MEMORY: 32 33 memblock_add(mem_start, mem_size); 33 - if (max_low_pfn < (mem_end >> PAGE_SHIFT)) 34 - max_low_pfn = mem_end >> PAGE_SHIFT; 35 34 break; 36 35 case EFI_PAL_CODE: 37 36 case EFI_UNUSABLE_MEMORY: ··· 46 49 } 47 50 } 48 51 52 + max_pfn = PFN_DOWN(memblock_end_of_DRAM()); 53 + max_low_pfn = min(PFN_DOWN(HIGHMEM_START), max_pfn); 49 54 memblock_set_current_limit(PFN_PHYS(max_low_pfn)); 50 55 51 56 /* Reserve the first 2MB */
+2 -21
arch/loongarch/kernel/numa.c
··· 272 272 node_mem_init(node); 273 273 node_set_online(node); 274 274 } 275 - max_low_pfn = PHYS_PFN(memblock_end_of_DRAM()); 275 + max_pfn = PFN_DOWN(memblock_end_of_DRAM()); 276 + max_low_pfn = min(PFN_DOWN(HIGHMEM_START), max_pfn); 276 277 277 278 setup_nr_node_ids(); 278 279 loongson_sysconf.nr_nodes = nr_node_ids; ··· 283 282 } 284 283 285 284 #endif 286 - 287 - void __init paging_init(void) 288 - { 289 - unsigned int node; 290 - unsigned long zones_size[MAX_NR_ZONES] = {0, }; 291 - 292 - for_each_online_node(node) { 293 - unsigned long start_pfn, end_pfn; 294 - 295 - get_pfn_range_for_nid(node, &start_pfn, &end_pfn); 296 - 297 - if (end_pfn > max_low_pfn) 298 - max_low_pfn = end_pfn; 299 - } 300 - #ifdef CONFIG_ZONE_DMA32 301 - zones_size[ZONE_DMA32] = MAX_DMA32_PFN; 302 - #endif 303 - zones_size[ZONE_NORMAL] = max_low_pfn; 304 - free_area_init(zones_size); 305 - } 306 285 307 286 int pcibus_to_node(struct pci_bus *bus) 308 287 {
+4 -3
arch/loongarch/kernel/perf_event.c
··· 845 845 846 846 static int __init init_hw_perf_events(void) 847 847 { 848 - int counters; 848 + int bits, counters; 849 849 850 850 if (!cpu_has_pmp) 851 851 return -ENODEV; 852 852 853 853 pr_info("Performance counters: "); 854 - counters = ((read_cpucfg(LOONGARCH_CPUCFG6) & CPUCFG6_PMNUM) >> 4) + 1; 854 + bits = ((read_cpucfg(LOONGARCH_CPUCFG6) & CPUCFG6_PMBITS) >> CPUCFG6_PMBITS_SHIFT) + 1; 855 + counters = ((read_cpucfg(LOONGARCH_CPUCFG6) & CPUCFG6_PMNUM) >> CPUCFG6_PMNUM_SHIFT) + 1; 855 856 856 857 loongarch_pmu.num_counters = counters; 857 858 loongarch_pmu.max_period = (1ULL << 63) - 1; ··· 868 867 on_each_cpu(reset_counters, NULL, 1); 869 868 870 869 pr_cont("%s PMU enabled, %d %d-bit counters available to each CPU.\n", 871 - loongarch_pmu.name, counters, 64); 870 + loongarch_pmu.name, counters, bits); 872 871 873 872 perf_pmu_register(&pmu, "cpu", PERF_TYPE_RAW); 874 873
+2 -3
arch/loongarch/kernel/setup.c
··· 294 294 295 295 early_init_dt_scan(fdt_pointer, __pa(fdt_pointer)); 296 296 early_init_fdt_reserve_self(); 297 - 298 - max_low_pfn = PFN_PHYS(memblock_end_of_DRAM()); 299 297 #endif 300 298 } 301 299 ··· 388 390 static void __init arch_mem_init(char **cmdline_p) 389 391 { 390 392 /* Recalculate max_low_pfn for "mem=xxx" */ 391 - max_pfn = max_low_pfn = PHYS_PFN(memblock_end_of_DRAM()); 393 + max_pfn = PFN_DOWN(memblock_end_of_DRAM()); 394 + max_low_pfn = min(PFN_DOWN(HIGHMEM_START), max_pfn); 392 395 393 396 if (usermem) 394 397 pr_info("User-defined physical RAM map overwrite\n");
+2 -2
arch/loongarch/kernel/traps.c
··· 1131 1131 tlbrentry = (unsigned long)exception_handlers + 80*VECSIZE; 1132 1132 1133 1133 csr_write64(eentry, LOONGARCH_CSR_EENTRY); 1134 - csr_write64(eentry, LOONGARCH_CSR_MERRENTRY); 1135 - csr_write64(tlbrentry, LOONGARCH_CSR_TLBRENTRY); 1134 + csr_write64(__pa(eentry), LOONGARCH_CSR_MERRENTRY); 1135 + csr_write64(__pa(tlbrentry), LOONGARCH_CSR_TLBRENTRY); 1136 1136 } 1137 1137 1138 1138 void per_cpu_trap_init(int cpu)
+1 -1
arch/loongarch/kvm/intc/eiointc.c
··· 439 439 spin_lock_irqsave(&s->lock, flags); 440 440 switch (type) { 441 441 case KVM_DEV_LOONGARCH_EXTIOI_CTRL_INIT_NUM_CPU: 442 - if (val >= EIOINTC_ROUTE_MAX_VCPUS) 442 + if (val > EIOINTC_ROUTE_MAX_VCPUS) 443 443 ret = -EINVAL; 444 444 else 445 445 s->num_cpu = val;
+1 -1
arch/loongarch/kvm/mmu.c
··· 857 857 858 858 if (writeable) { 859 859 prot_bits = kvm_pte_mkwriteable(prot_bits); 860 - if (write) 860 + if (write || !kvm_slot_dirty_track_enabled(memslot)) 861 861 prot_bits = kvm_pte_mkdirty(prot_bits); 862 862 } 863 863
+2
arch/loongarch/kvm/timer.c
··· 4 4 */ 5 5 6 6 #include <linux/kvm_host.h> 7 + #include <asm/delay.h> 7 8 #include <asm/kvm_csr.h> 8 9 #include <asm/kvm_vcpu.h> 9 10 ··· 96 95 * and set CSR TVAL with -1 97 96 */ 98 97 write_gcsr_timertick(0); 98 + __delay(2); /* Wait cycles until timer interrupt injected */ 99 99 100 100 /* 101 101 * Writing CSR_TINTCLR_TI to LOONGARCH_CSR_TINTCLR will clear
+9 -10
arch/loongarch/kvm/vcpu.c
··· 132 132 * Clear KVM_LARCH_PMU if the guest is not using PMU CSRs when 133 133 * exiting the guest, so that the next time trap into the guest. 134 134 * We don't need to deal with PMU CSRs contexts. 135 + * 136 + * Otherwise set the request bit KVM_REQ_PMU to restore guest PMU 137 + * before entering guest VM 135 138 */ 136 139 val = kvm_read_sw_gcsr(csr, LOONGARCH_CSR_PERFCTRL0); 137 140 val |= kvm_read_sw_gcsr(csr, LOONGARCH_CSR_PERFCTRL1); ··· 142 139 val |= kvm_read_sw_gcsr(csr, LOONGARCH_CSR_PERFCTRL3); 143 140 if (!(val & KVM_PMU_EVENT_ENABLED)) 144 141 vcpu->arch.aux_inuse &= ~KVM_LARCH_PMU; 142 + else 143 + kvm_make_request(KVM_REQ_PMU, vcpu); 145 144 146 145 kvm_restore_host_pmu(vcpu); 147 - } 148 - 149 - static void kvm_restore_pmu(struct kvm_vcpu *vcpu) 150 - { 151 - if ((vcpu->arch.aux_inuse & KVM_LARCH_PMU)) 152 - kvm_make_request(KVM_REQ_PMU, vcpu); 153 146 } 154 147 155 148 static void kvm_check_pmu(struct kvm_vcpu *vcpu) ··· 298 299 vcpu->arch.aux_inuse &= ~KVM_LARCH_SWCSR_LATEST; 299 300 300 301 if (kvm_request_pending(vcpu) || xfer_to_guest_mode_work_pending()) { 301 - kvm_lose_pmu(vcpu); 302 + if (vcpu->arch.aux_inuse & KVM_LARCH_PMU) { 303 + kvm_lose_pmu(vcpu); 304 + kvm_make_request(KVM_REQ_PMU, vcpu); 305 + } 302 306 /* make sure the vcpu mode has been written */ 303 307 smp_store_mb(vcpu->mode, OUTSIDE_GUEST_MODE); 304 308 local_irq_enable(); ··· 1605 1603 /* Restore timer state regardless */ 1606 1604 kvm_restore_timer(vcpu); 1607 1605 kvm_make_request(KVM_REQ_STEAL_UPDATE, vcpu); 1608 - 1609 - /* Restore hardware PMU CSRs */ 1610 - kvm_restore_pmu(vcpu); 1611 1606 1612 1607 /* Don't bother restoring registers multiple times unless necessary */ 1613 1608 if (vcpu->arch.aux_inuse & KVM_LARCH_HWCSR_USABLE)
-2
arch/loongarch/mm/init.c
··· 60 60 return memblock_is_memory(addr) && !memblock_is_reserved(addr); 61 61 } 62 62 63 - #ifndef CONFIG_NUMA 64 63 void __init paging_init(void) 65 64 { 66 65 unsigned long max_zone_pfns[MAX_NR_ZONES]; ··· 71 72 72 73 free_area_init(max_zone_pfns); 73 74 } 74 - #endif /* !CONFIG_NUMA */ 75 75 76 76 void __ref free_initmem(void) 77 77 {
+1 -1
arch/loongarch/mm/ioremap.c
··· 6 6 #include <asm/io.h> 7 7 #include <asm-generic/early_ioremap.h> 8 8 9 - void __init __iomem *early_ioremap(u64 phys_addr, unsigned long size) 9 + void __init __iomem *early_ioremap(phys_addr_t phys_addr, unsigned long size) 10 10 { 11 11 return ((void __iomem *)TO_CACHE(phys_addr)); 12 12 }
+10 -3
arch/parisc/kernel/unwind.c
··· 35 35 36 36 #define KERNEL_START (KERNEL_BINARY_TEXT_START) 37 37 38 + #define ALIGNMENT_OK(ptr, type) (((ptr) & (sizeof(type) - 1)) == 0) 39 + 38 40 extern struct unwind_table_entry __start___unwind[]; 39 41 extern struct unwind_table_entry __stop___unwind[]; 40 42 ··· 259 257 if (pc_is_kernel_fn(pc, _switch_to) || 260 258 pc == (unsigned long)&_switch_to_ret) { 261 259 info->prev_sp = info->sp - CALLEE_SAVE_FRAME_SIZE; 262 - info->prev_ip = *(unsigned long *)(info->prev_sp - RP_OFFSET); 260 + if (ALIGNMENT_OK(info->prev_sp, long)) 261 + info->prev_ip = *(unsigned long *)(info->prev_sp - RP_OFFSET); 262 + else 263 + info->prev_ip = info->prev_sp = 0; 263 264 return 1; 264 265 } 265 266 266 267 #ifdef CONFIG_IRQSTACKS 267 - if (pc == (unsigned long)&_call_on_stack) { 268 + if (pc == (unsigned long)&_call_on_stack && ALIGNMENT_OK(info->sp, long)) { 268 269 info->prev_sp = *(unsigned long *)(info->sp - FRAME_SIZE - REG_SZ); 269 270 info->prev_ip = *(unsigned long *)(info->sp - FRAME_SIZE - RP_OFFSET); 270 271 return 1; ··· 375 370 info->prev_sp = info->sp - frame_size; 376 371 if (e->Millicode) 377 372 info->rp = info->r31; 378 - else if (rpoffset) 373 + else if (rpoffset && ALIGNMENT_OK(info->prev_sp, long)) 379 374 info->rp = *(unsigned long *)(info->prev_sp - rpoffset); 375 + else 376 + info->rp = 0; 380 377 info->prev_ip = info->rp; 381 378 info->rp = 0; 382 379 }
+1
arch/powerpc/Kconfig
··· 137 137 select ARCH_HAS_DMA_OPS if PPC64 138 138 select ARCH_HAS_FORTIFY_SOURCE 139 139 select ARCH_HAS_GCOV_PROFILE_ALL 140 + select ARCH_HAS_GIGANTIC_PAGE if ARCH_SUPPORTS_HUGETLBFS 140 141 select ARCH_HAS_KCOV 141 142 select ARCH_HAS_KERNEL_FPU_SUPPORT if PPC64 && PPC_FPU 142 143 select ARCH_HAS_MEMBARRIER_CALLBACKS
-1
arch/powerpc/platforms/Kconfig.cputype
··· 423 423 config PPC_RADIX_MMU 424 424 bool "Radix MMU Support" 425 425 depends on PPC_BOOK3S_64 426 - select ARCH_HAS_GIGANTIC_PAGE 427 426 default y 428 427 help 429 428 Enable support for the Power ISA 3.0 Radix style MMU. Currently this
+1 -1
arch/riscv/Kconfig
··· 367 367 systems to handle cache management. 368 368 369 369 config AS_HAS_INSN 370 - def_bool $(as-instr,.insn r 51$(comma) 0$(comma) 0$(comma) t0$(comma) t0$(comma) zero) 370 + def_bool $(as-instr,.insn 0x100000f) 371 371 372 372 config AS_HAS_OPTION_ARCH 373 373 # https://github.com/llvm/llvm-project/commit/9e8ed3403c191ab9c4903e8eeb8f732ff8a43cb4
+1 -16
arch/riscv/Makefile
··· 134 134 CHECKFLAGS += -D__riscv -D__riscv_xlen=$(BITS) 135 135 136 136 # Default target when executing plain make 137 - boot := arch/riscv/boot 138 - ifeq ($(CONFIG_XIP_KERNEL),y) 139 - KBUILD_IMAGE := $(boot)/xipImage 140 - else 141 - ifeq ($(CONFIG_RISCV_M_MODE)$(CONFIG_SOC_CANAAN_K210),yy) 142 - KBUILD_IMAGE := $(boot)/loader.bin 143 - else 144 - ifeq ($(CONFIG_EFI_ZBOOT),) 145 - KBUILD_IMAGE := $(boot)/Image.gz 146 - else 147 - KBUILD_IMAGE := $(boot)/vmlinuz.efi 148 - endif 149 - endif 150 - endif 151 - 152 137 boot := arch/riscv/boot 153 138 boot-image-y := Image 154 139 boot-image-$(CONFIG_KERNEL_BZIP2) := Image.bz2 ··· 144 159 boot-image-$(CONFIG_KERNEL_ZSTD) := Image.zst 145 160 boot-image-$(CONFIG_KERNEL_XZ) := Image.xz 146 161 ifdef CONFIG_RISCV_M_MODE 147 - boot-image-$(CONFIG_ARCH_CANAAN) := loader.bin 162 + boot-image-$(CONFIG_SOC_CANAAN_K210) := loader.bin 148 163 endif 149 164 boot-image-$(CONFIG_EFI_ZBOOT) := vmlinuz.efi 150 165 boot-image-$(CONFIG_XIP_KERNEL) := xipImage
+6
arch/riscv/include/asm/asm.h
··· 12 12 #define __ASM_STR(x) #x 13 13 #endif 14 14 15 + #ifdef CONFIG_AS_HAS_INSN 16 + #define ASM_INSN_I(__x) ".insn " __x 17 + #else 18 + #define ASM_INSN_I(__x) ".4byte " __x 19 + #endif 20 + 15 21 #if __riscv_xlen == 64 16 22 #define __REG_SEL(a, b) __ASM_STR(a) 17 23 #elif __riscv_xlen == 32
+4 -4
arch/riscv/include/asm/insn-def.h
··· 256 256 INSN_S(OPCODE_OP_IMM, FUNC3(6), __RS2(3), \ 257 257 SIMM12((offset) & 0xfe0), RS1(base)) 258 258 259 - #define RISCV_PAUSE ".4byte 0x100000f" 260 - #define ZAWRS_WRS_NTO ".4byte 0x00d00073" 261 - #define ZAWRS_WRS_STO ".4byte 0x01d00073" 262 - #define RISCV_NOP4 ".4byte 0x00000013" 259 + #define RISCV_PAUSE ASM_INSN_I("0x100000f") 260 + #define ZAWRS_WRS_NTO ASM_INSN_I("0x00d00073") 261 + #define ZAWRS_WRS_STO ASM_INSN_I("0x01d00073") 262 + #define RISCV_NOP4 ASM_INSN_I("0x00000013") 263 263 264 264 #define RISCV_INSN_NOP4 _AC(0x00000013, U) 265 265
+3 -3
arch/riscv/include/asm/vendor_extensions/mips.h
··· 30 30 * allowing any subsequent instructions to fetch. 31 31 */ 32 32 33 - #define MIPS_PAUSE ".4byte 0x00501013\n\t" 34 - #define MIPS_EHB ".4byte 0x00301013\n\t" 35 - #define MIPS_IHB ".4byte 0x00101013\n\t" 33 + #define MIPS_PAUSE ASM_INSN_I("0x00501013\n\t") 34 + #define MIPS_EHB ASM_INSN_I("0x00301013\n\t") 35 + #define MIPS_IHB ASM_INSN_I("0x00101013\n\t") 36 36 37 37 #endif // _ASM_RISCV_VENDOR_EXTENSIONS_MIPS_H
+2 -2
arch/riscv/kernel/kgdb.c
··· 265 265 { 266 266 if (!strncmp(remcom_in_buffer, gdb_xfer_read_target, 267 267 sizeof(gdb_xfer_read_target))) 268 - strcpy(remcom_out_buffer, riscv_gdb_stub_target_desc); 268 + strscpy(remcom_out_buffer, riscv_gdb_stub_target_desc, BUFMAX); 269 269 else if (!strncmp(remcom_in_buffer, gdb_xfer_read_cpuxml, 270 270 sizeof(gdb_xfer_read_cpuxml))) 271 - strcpy(remcom_out_buffer, riscv_gdb_stub_cpuxml); 271 + strscpy(remcom_out_buffer, riscv_gdb_stub_cpuxml, BUFMAX); 272 272 } 273 273 274 274 static inline void kgdb_arch_update_addr(struct pt_regs *regs,
+6 -2
arch/riscv/kernel/module-sections.c
··· 119 119 unsigned int num_plts = 0; 120 120 unsigned int num_gots = 0; 121 121 Elf_Rela *scratch = NULL; 122 + Elf_Rela *new_scratch; 122 123 size_t scratch_size = 0; 123 124 int i; 124 125 ··· 169 168 scratch_size_needed = (num_scratch_relas + num_relas) * sizeof(*scratch); 170 169 if (scratch_size_needed > scratch_size) { 171 170 scratch_size = scratch_size_needed; 172 - scratch = kvrealloc(scratch, scratch_size, GFP_KERNEL); 173 - if (!scratch) 171 + new_scratch = kvrealloc(scratch, scratch_size, GFP_KERNEL); 172 + if (!new_scratch) { 173 + kvfree(scratch); 174 174 return -ENOMEM; 175 + } 176 + scratch = new_scratch; 175 177 } 176 178 177 179 for (size_t j = 0; j < num_relas; j++)
+19 -2
arch/riscv/kernel/stacktrace.c
··· 16 16 17 17 #ifdef CONFIG_FRAME_POINTER 18 18 19 + /* 20 + * This disables KASAN checking when reading a value from another task's stack, 21 + * since the other task could be running on another CPU and could have poisoned 22 + * the stack in the meantime. 23 + */ 24 + #define READ_ONCE_TASK_STACK(task, x) \ 25 + ({ \ 26 + unsigned long val; \ 27 + unsigned long addr = x; \ 28 + if ((task) == current) \ 29 + val = READ_ONCE(addr); \ 30 + else \ 31 + val = READ_ONCE_NOCHECK(addr); \ 32 + val; \ 33 + }) 34 + 19 35 extern asmlinkage void handle_exception(void); 20 36 extern unsigned long ret_from_exception_end; 21 37 ··· 85 69 fp = frame->ra; 86 70 pc = regs->ra; 87 71 } else { 88 - fp = frame->fp; 89 - pc = ftrace_graph_ret_addr(current, &graph_idx, frame->ra, 72 + fp = READ_ONCE_TASK_STACK(task, frame->fp); 73 + pc = READ_ONCE_TASK_STACK(task, frame->ra); 74 + pc = ftrace_graph_ret_addr(current, &graph_idx, pc, 90 75 &frame->ra); 91 76 if (pc >= (unsigned long)handle_exception && 92 77 pc < (unsigned long)&ret_from_exception_end) {
+1 -1
arch/riscv/kernel/tests/Kconfig.debug
··· 31 31 If unsure, say N. 32 32 33 33 config RISCV_KPROBES_KUNIT 34 - bool "KUnit test for riscv kprobes" if !KUNIT_ALL_TESTS 34 + tristate "KUnit test for riscv kprobes" if !KUNIT_ALL_TESTS 35 35 depends on KUNIT 36 36 depends on KPROBES 37 37 default KUNIT_ALL_TESTS
+3 -1
arch/riscv/kernel/tests/kprobes/Makefile
··· 1 - obj-y += test-kprobes.o test-kprobes-asm.o 1 + obj-$(CONFIG_RISCV_KPROBES_KUNIT) += kprobes_riscv_kunit.o 2 + 3 + kprobes_riscv_kunit-objs := test-kprobes.o test-kprobes-asm.o
+4 -1
arch/riscv/kernel/tests/kprobes/test-kprobes.c
··· 49 49 }; 50 50 51 51 static struct kunit_suite kprobes_test_suite = { 52 - .name = "kprobes_test_riscv", 52 + .name = "kprobes_riscv", 53 53 .test_cases = kprobes_testcases, 54 54 }; 55 55 56 56 kunit_test_suites(&kprobes_test_suite); 57 + 58 + MODULE_LICENSE("GPL"); 59 + MODULE_DESCRIPTION("KUnit test for riscv kprobes");
+14 -2
arch/riscv/kvm/aia_imsic.c
··· 689 689 */ 690 690 691 691 read_lock_irqsave(&imsic->vsfile_lock, flags); 692 - if (imsic->vsfile_cpu > -1) 693 - ret = !!(csr_read(CSR_HGEIP) & BIT(imsic->vsfile_hgei)); 692 + if (imsic->vsfile_cpu > -1) { 693 + /* 694 + * This function is typically called from kvm_vcpu_block() via 695 + * kvm_arch_vcpu_runnable() upon WFI trap. The kvm_vcpu_block() 696 + * can be preempted and the blocking VCPU might resume on a 697 + * different CPU. This means it is possible that current CPU 698 + * does not match the imsic->vsfile_cpu hence this function 699 + * must check imsic->vsfile_cpu before accessing HGEIP CSR. 700 + */ 701 + if (imsic->vsfile_cpu != vcpu->cpu) 702 + ret = true; 703 + else 704 + ret = !!(csr_read(CSR_HGEIP) & BIT(imsic->vsfile_hgei)); 705 + } 694 706 read_unlock_irqrestore(&imsic->vsfile_lock, flags); 695 707 696 708 return ret;
+2 -23
arch/riscv/kvm/mmu.c
··· 171 171 enum kvm_mr_change change) 172 172 { 173 173 hva_t hva, reg_end, size; 174 - gpa_t base_gpa; 175 174 bool writable; 176 175 int ret = 0; 177 176 ··· 189 190 hva = new->userspace_addr; 190 191 size = new->npages << PAGE_SHIFT; 191 192 reg_end = hva + size; 192 - base_gpa = new->base_gfn << PAGE_SHIFT; 193 193 writable = !(new->flags & KVM_MEM_READONLY); 194 194 195 195 mmap_read_lock(current->mm); 196 196 197 197 /* 198 198 * A memory region could potentially cover multiple VMAs, and 199 - * any holes between them, so iterate over all of them to find 200 - * out if we can map any of them right now. 199 + * any holes between them, so iterate over all of them. 201 200 * 202 201 * +--------------------------------------------+ 203 202 * +---------------+----------------+ +----------------+ ··· 206 209 */ 207 210 do { 208 211 struct vm_area_struct *vma; 209 - hva_t vm_start, vm_end; 212 + hva_t vm_end; 210 213 211 214 vma = find_vma_intersection(current->mm, hva, reg_end); 212 215 if (!vma) ··· 222 225 } 223 226 224 227 /* Take the intersection of this VMA with the memory region */ 225 - vm_start = max(hva, vma->vm_start); 226 228 vm_end = min(reg_end, vma->vm_end); 227 229 228 230 if (vma->vm_flags & VM_PFNMAP) { 229 - gpa_t gpa = base_gpa + (vm_start - hva); 230 - phys_addr_t pa; 231 - 232 - pa = (phys_addr_t)vma->vm_pgoff << PAGE_SHIFT; 233 - pa += vm_start - vma->vm_start; 234 - 235 231 /* IO region dirty page logging not allowed */ 236 232 if (new->flags & KVM_MEM_LOG_DIRTY_PAGES) { 237 233 ret = -EINVAL; 238 234 goto out; 239 235 } 240 - 241 - ret = kvm_riscv_mmu_ioremap(kvm, gpa, pa, vm_end - vm_start, 242 - writable, false); 243 - if (ret) 244 - break; 245 236 } 246 237 hva = vm_end; 247 238 } while (hva < reg_end); 248 - 249 - if (change == KVM_MR_FLAGS_ONLY) 250 - goto out; 251 - 252 - if (ret) 253 - kvm_riscv_mmu_iounmap(kvm, base_gpa, size); 254 239 255 240 out: 256 241 mmap_read_unlock(current->mm);
+1 -1
arch/riscv/kvm/vcpu.c
··· 212 212 213 213 int kvm_arch_vcpu_runnable(struct kvm_vcpu *vcpu) 214 214 { 215 - return (kvm_riscv_vcpu_has_interrupts(vcpu, -1UL) && 215 + return (kvm_riscv_vcpu_has_interrupts(vcpu, -1ULL) && 216 216 !kvm_riscv_vcpu_stopped(vcpu) && !vcpu->arch.pause); 217 217 } 218 218
+1 -1
arch/riscv/mm/ptdump.c
··· 21 21 #define pt_dump_seq_puts(m, fmt) \ 22 22 ({ \ 23 23 if (m) \ 24 - seq_printf(m, fmt); \ 24 + seq_puts(m, fmt); \ 25 25 }) 26 26 27 27 /*
+5 -7
arch/s390/include/asm/pgtable.h
··· 1154 1154 #define IPTE_NODAT 0x400 1155 1155 #define IPTE_GUEST_ASCE 0x800 1156 1156 1157 - static __always_inline void __ptep_rdp(unsigned long addr, pte_t *ptep, 1158 - unsigned long opt, unsigned long asce, 1159 - int local) 1157 + static __always_inline void __ptep_rdp(unsigned long addr, pte_t *ptep, int local) 1160 1158 { 1161 1159 unsigned long pto; 1162 1160 1163 1161 pto = __pa(ptep) & ~(PTRS_PER_PTE * sizeof(pte_t) - 1); 1164 - asm volatile(".insn rrf,0xb98b0000,%[r1],%[r2],%[asce],%[m4]" 1162 + asm volatile(".insn rrf,0xb98b0000,%[r1],%[r2],%%r0,%[m4]" 1165 1163 : "+m" (*ptep) 1166 - : [r1] "a" (pto), [r2] "a" ((addr & PAGE_MASK) | opt), 1167 - [asce] "a" (asce), [m4] "i" (local)); 1164 + : [r1] "a" (pto), [r2] "a" (addr & PAGE_MASK), 1165 + [m4] "i" (local)); 1168 1166 } 1169 1167 1170 1168 static __always_inline void __ptep_ipte(unsigned long address, pte_t *ptep, ··· 1346 1348 * A local RDP can be used to do the flush. 1347 1349 */ 1348 1350 if (cpu_has_rdp() && !(pte_val(*ptep) & _PAGE_PROTECT)) 1349 - __ptep_rdp(address, ptep, 0, 0, 1); 1351 + __ptep_rdp(address, ptep, 1); 1350 1352 } 1351 1353 #define flush_tlb_fix_spurious_fault flush_tlb_fix_spurious_fault 1352 1354
+2 -2
arch/s390/mm/pgtable.c
··· 274 274 preempt_disable(); 275 275 atomic_inc(&mm->context.flush_count); 276 276 if (cpumask_equal(mm_cpumask(mm), cpumask_of(smp_processor_id()))) 277 - __ptep_rdp(addr, ptep, 0, 0, 1); 277 + __ptep_rdp(addr, ptep, 1); 278 278 else 279 - __ptep_rdp(addr, ptep, 0, 0, 0); 279 + __ptep_rdp(addr, ptep, 0); 280 280 /* 281 281 * PTE is not invalidated by RDP, only _PAGE_PROTECT is cleared. That 282 282 * means it is still valid and active, and must not be changed according
+1 -1
arch/x86/Makefile
··· 98 98 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104816 99 99 # 100 100 KBUILD_CFLAGS += $(call cc-option,-fcf-protection=branch -fno-jump-tables) 101 - KBUILD_RUSTFLAGS += -Zcf-protection=branch -Zno-jump-tables 101 + KBUILD_RUSTFLAGS += -Zcf-protection=branch $(if $(call rustc-min-version,109300),-Cjump-tables=n,-Zno-jump-tables) 102 102 else 103 103 KBUILD_CFLAGS += $(call cc-option,-fcf-protection=none) 104 104 endif
+5 -5
arch/x86/events/core.c
··· 2789 2789 return; 2790 2790 } 2791 2791 2792 - if (perf_callchain_store(entry, regs->ip)) 2793 - return; 2794 - 2795 - if (perf_hw_regs(regs)) 2792 + if (perf_hw_regs(regs)) { 2793 + if (perf_callchain_store(entry, regs->ip)) 2794 + return; 2796 2795 unwind_start(&state, current, regs, NULL); 2797 - else 2796 + } else { 2798 2797 unwind_start(&state, current, NULL, (void *)regs->sp); 2798 + } 2799 2799 2800 2800 for (; !unwind_done(&state); unwind_next_frame(&state)) { 2801 2801 addr = unwind_get_return_address(&state);
-1
arch/x86/include/asm/amd/node.h
··· 23 23 #define AMD_NODE0_PCI_SLOT 0x18 24 24 25 25 struct pci_dev *amd_node_get_func(u16 node, u8 func); 26 - struct pci_dev *amd_node_get_root(u16 node); 27 26 28 27 static inline u16 amd_num_nodes(void) 29 28 {
+5
arch/x86/include/asm/ftrace.h
··· 56 56 return &arch_ftrace_regs(fregs)->regs; 57 57 } 58 58 59 + #define arch_ftrace_partial_regs(regs) do { \ 60 + regs->flags &= ~X86_EFLAGS_FIXED; \ 61 + regs->cs = __KERNEL_CS; \ 62 + } while (0) 63 + 59 64 #define arch_ftrace_fill_perf_regs(fregs, _regs) do { \ 60 65 (_regs)->ip = arch_ftrace_regs(fregs)->regs.ip; \ 61 66 (_regs)->sp = arch_ftrace_regs(fregs)->regs.sp; \
+4
arch/x86/include/asm/runtime-const.h
··· 2 2 #ifndef _ASM_RUNTIME_CONST_H 3 3 #define _ASM_RUNTIME_CONST_H 4 4 5 + #ifdef MODULE 6 + #error "Cannot use runtime-const infrastructure from modules" 7 + #endif 8 + 5 9 #ifdef __ASSEMBLY__ 6 10 7 11 .macro RUNTIME_CONST_PTR sym reg
+5 -5
arch/x86/include/asm/uaccess_64.h
··· 12 12 #include <asm/cpufeatures.h> 13 13 #include <asm/page.h> 14 14 #include <asm/percpu.h> 15 - #include <asm/runtime-const.h> 16 15 17 - /* 18 - * Virtual variable: there's no actual backing store for this, 19 - * it can purely be used as 'runtime_const_ptr(USER_PTR_MAX)' 20 - */ 16 + #ifdef MODULE 17 + #define runtime_const_ptr(sym) (sym) 18 + #else 19 + #include <asm/runtime-const.h> 20 + #endif 21 21 extern unsigned long USER_PTR_MAX; 22 22 23 23 #ifdef CONFIG_ADDRESS_MASKING
+1
arch/x86/include/uapi/asm/vmx.h
··· 93 93 #define EXIT_REASON_TPAUSE 68 94 94 #define EXIT_REASON_BUS_LOCK 74 95 95 #define EXIT_REASON_NOTIFY 75 96 + #define EXIT_REASON_SEAMCALL 76 96 97 #define EXIT_REASON_TDCALL 77 97 98 #define EXIT_REASON_MSR_READ_IMM 84 98 99 #define EXIT_REASON_MSR_WRITE_IMM 85
+1 -1
arch/x86/kernel/acpi/cppc.c
··· 196 196 break; 197 197 } 198 198 199 - for_each_present_cpu(cpu) { 199 + for_each_online_cpu(cpu) { 200 200 u32 tmp; 201 201 int ret; 202 202
+51 -99
arch/x86/kernel/amd_node.c
··· 34 34 return pci_get_domain_bus_and_slot(0, 0, PCI_DEVFN(AMD_NODE0_PCI_SLOT + node, func)); 35 35 } 36 36 37 - #define DF_BLK_INST_CNT 0x040 38 - #define DF_CFG_ADDR_CNTL_LEGACY 0x084 39 - #define DF_CFG_ADDR_CNTL_DF4 0xC04 40 - 41 - #define DF_MAJOR_REVISION GENMASK(27, 24) 42 - 43 - static u16 get_cfg_addr_cntl_offset(struct pci_dev *df_f0) 44 - { 45 - u32 reg; 46 - 47 - /* 48 - * Revision fields added for DF4 and later. 49 - * 50 - * Major revision of '0' is found pre-DF4. Field is Read-as-Zero. 51 - */ 52 - if (pci_read_config_dword(df_f0, DF_BLK_INST_CNT, &reg)) 53 - return 0; 54 - 55 - if (reg & DF_MAJOR_REVISION) 56 - return DF_CFG_ADDR_CNTL_DF4; 57 - 58 - return DF_CFG_ADDR_CNTL_LEGACY; 59 - } 60 - 61 - struct pci_dev *amd_node_get_root(u16 node) 62 - { 63 - struct pci_dev *root; 64 - u16 cntl_off; 65 - u8 bus; 66 - 67 - if (!cpu_feature_enabled(X86_FEATURE_ZEN)) 68 - return NULL; 69 - 70 - /* 71 - * D18F0xXXX [Config Address Control] (DF::CfgAddressCntl) 72 - * Bits [7:0] (SecBusNum) holds the bus number of the root device for 73 - * this Data Fabric instance. The segment, device, and function will be 0. 74 - */ 75 - struct pci_dev *df_f0 __free(pci_dev_put) = amd_node_get_func(node, 0); 76 - if (!df_f0) 77 - return NULL; 78 - 79 - cntl_off = get_cfg_addr_cntl_offset(df_f0); 80 - if (!cntl_off) 81 - return NULL; 82 - 83 - if (pci_read_config_byte(df_f0, cntl_off, &bus)) 84 - return NULL; 85 - 86 - /* Grab the pointer for the actual root device instance. */ 87 - root = pci_get_domain_bus_and_slot(0, bus, 0); 88 - 89 - pci_dbg(root, "is root for AMD node %u\n", node); 90 - return root; 91 - } 92 - 93 37 static struct pci_dev **amd_roots; 94 38 95 39 /* Protect the PCI config register pairs used for SMN. */ ··· 218 274 DEFINE_SHOW_STORE_ATTRIBUTE(smn_address); 219 275 DEFINE_SHOW_STORE_ATTRIBUTE(smn_value); 220 276 221 - static int amd_cache_roots(void) 277 + static struct pci_dev *get_next_root(struct pci_dev *root) 222 278 { 223 - u16 node, num_nodes = amd_num_nodes(); 224 - 225 - amd_roots = kcalloc(num_nodes, sizeof(*amd_roots), GFP_KERNEL); 226 - if (!amd_roots) 227 - return -ENOMEM; 228 - 229 - for (node = 0; node < num_nodes; node++) 230 - amd_roots[node] = amd_node_get_root(node); 231 - 232 - return 0; 233 - } 234 - 235 - static int reserve_root_config_spaces(void) 236 - { 237 - struct pci_dev *root = NULL; 238 - struct pci_bus *bus = NULL; 239 - 240 - while ((bus = pci_find_next_bus(bus))) { 241 - /* Root device is Device 0 Function 0 on each Primary Bus. */ 242 - root = pci_get_slot(bus, 0); 243 - if (!root) 279 + while ((root = pci_get_class(PCI_CLASS_BRIDGE_HOST << 8, root))) { 280 + /* Root device is Device 0 Function 0. */ 281 + if (root->devfn) 244 282 continue; 245 283 246 284 if (root->vendor != PCI_VENDOR_ID_AMD && 247 285 root->vendor != PCI_VENDOR_ID_HYGON) 248 286 continue; 249 287 250 - pci_dbg(root, "Reserving PCI config space\n"); 251 - 252 - /* 253 - * There are a few SMN index/data pairs and other registers 254 - * that shouldn't be accessed by user space. 255 - * So reserve the entire PCI config space for simplicity rather 256 - * than covering specific registers piecemeal. 257 - */ 258 - if (!pci_request_config_region_exclusive(root, 0, PCI_CFG_SPACE_SIZE, NULL)) { 259 - pci_err(root, "Failed to reserve config space\n"); 260 - return -EEXIST; 261 - } 288 + break; 262 289 } 263 290 264 - smn_exclusive = true; 265 - return 0; 291 + return root; 266 292 } 267 293 268 294 static bool enable_dfs; ··· 246 332 247 333 static int __init amd_smn_init(void) 248 334 { 249 - int err; 335 + u16 count, num_roots, roots_per_node, node, num_nodes; 336 + struct pci_dev *root; 250 337 251 338 if (!cpu_feature_enabled(X86_FEATURE_ZEN)) 252 339 return 0; ··· 257 342 if (amd_roots) 258 343 return 0; 259 344 260 - err = amd_cache_roots(); 261 - if (err) 262 - return err; 345 + num_roots = 0; 346 + root = NULL; 347 + while ((root = get_next_root(root))) { 348 + pci_dbg(root, "Reserving PCI config space\n"); 263 349 264 - err = reserve_root_config_spaces(); 265 - if (err) 266 - return err; 350 + /* 351 + * There are a few SMN index/data pairs and other registers 352 + * that shouldn't be accessed by user space. So reserve the 353 + * entire PCI config space for simplicity rather than covering 354 + * specific registers piecemeal. 355 + */ 356 + if (!pci_request_config_region_exclusive(root, 0, PCI_CFG_SPACE_SIZE, NULL)) { 357 + pci_err(root, "Failed to reserve config space\n"); 358 + return -EEXIST; 359 + } 360 + 361 + num_roots++; 362 + } 363 + 364 + pr_debug("Found %d AMD root devices\n", num_roots); 365 + 366 + if (!num_roots) 367 + return -ENODEV; 368 + 369 + num_nodes = amd_num_nodes(); 370 + amd_roots = kcalloc(num_nodes, sizeof(*amd_roots), GFP_KERNEL); 371 + if (!amd_roots) 372 + return -ENOMEM; 373 + 374 + roots_per_node = num_roots / num_nodes; 375 + 376 + count = 0; 377 + node = 0; 378 + root = NULL; 379 + while (node < num_nodes && (root = get_next_root(root))) { 380 + /* Use one root for each node and skip the rest. */ 381 + if (count++ % roots_per_node) 382 + continue; 383 + 384 + pci_dbg(root, "is root for AMD node %u\n", node); 385 + amd_roots[node++] = root; 386 + } 267 387 268 388 if (enable_dfs) { 269 389 debugfs_dir = debugfs_create_dir("amd_smn", arch_debugfs_dir); ··· 307 357 debugfs_create_file("address", 0600, debugfs_dir, NULL, &smn_address_fops); 308 358 debugfs_create_file("value", 0600, debugfs_dir, NULL, &smn_value_fops); 309 359 } 360 + 361 + smn_exclusive = true; 310 362 311 363 return 0; 312 364 }
+8
arch/x86/kernel/cpu/amd.c
··· 1037 1037 1038 1038 static const struct x86_cpu_id zen5_rdseed_microcode[] = { 1039 1039 ZEN_MODEL_STEP_UCODE(0x1a, 0x02, 0x1, 0x0b00215a), 1040 + ZEN_MODEL_STEP_UCODE(0x1a, 0x08, 0x1, 0x0b008121), 1040 1041 ZEN_MODEL_STEP_UCODE(0x1a, 0x11, 0x0, 0x0b101054), 1042 + ZEN_MODEL_STEP_UCODE(0x1a, 0x24, 0x0, 0x0b204037), 1043 + ZEN_MODEL_STEP_UCODE(0x1a, 0x44, 0x0, 0x0b404035), 1044 + ZEN_MODEL_STEP_UCODE(0x1a, 0x44, 0x1, 0x0b404108), 1045 + ZEN_MODEL_STEP_UCODE(0x1a, 0x60, 0x0, 0x0b600037), 1046 + ZEN_MODEL_STEP_UCODE(0x1a, 0x68, 0x0, 0x0b608038), 1047 + ZEN_MODEL_STEP_UCODE(0x1a, 0x70, 0x0, 0x0b700037), 1048 + {}, 1041 1049 }; 1042 1050 1043 1051 static void init_amd_zen5(struct cpuinfo_x86 *c)
+5 -1
arch/x86/kernel/cpu/common.c
··· 78 78 DEFINE_PER_CPU_READ_MOSTLY(struct cpuinfo_x86, cpu_info); 79 79 EXPORT_PER_CPU_SYMBOL(cpu_info); 80 80 81 + /* Used for modules: built-in code uses runtime constants */ 82 + unsigned long USER_PTR_MAX; 83 + EXPORT_SYMBOL(USER_PTR_MAX); 84 + 81 85 u32 elf_hwcap2 __read_mostly; 82 86 83 87 /* Number of siblings per CPU package */ ··· 2583 2579 alternative_instructions(); 2584 2580 2585 2581 if (IS_ENABLED(CONFIG_X86_64)) { 2586 - unsigned long USER_PTR_MAX = TASK_SIZE_MAX; 2582 + USER_PTR_MAX = TASK_SIZE_MAX; 2587 2583 2588 2584 /* 2589 2585 * Enable this when LAM is gated on LASS support
+3
arch/x86/kernel/cpu/microcode/amd.c
··· 220 220 case 0xaa001: return cur_rev <= 0xaa00116; break; 221 221 case 0xaa002: return cur_rev <= 0xaa00218; break; 222 222 case 0xb0021: return cur_rev <= 0xb002146; break; 223 + case 0xb0081: return cur_rev <= 0xb008111; break; 223 224 case 0xb1010: return cur_rev <= 0xb101046; break; 224 225 case 0xb2040: return cur_rev <= 0xb204031; break; 225 226 case 0xb4040: return cur_rev <= 0xb404031; break; 227 + case 0xb4041: return cur_rev <= 0xb404101; break; 226 228 case 0xb6000: return cur_rev <= 0xb600031; break; 229 + case 0xb6080: return cur_rev <= 0xb608031; break; 227 230 case 0xb7000: return cur_rev <= 0xb700031; break; 228 231 default: break; 229 232 }
+7 -1
arch/x86/kernel/ftrace_64.S
··· 354 354 UNWIND_HINT_UNDEFINED 355 355 ANNOTATE_NOENDBR 356 356 357 + /* Restore return_to_handler value that got eaten by previous ret instruction. */ 358 + subq $8, %rsp 359 + UNWIND_HINT_FUNC 360 + 357 361 /* Save ftrace_regs for function exit context */ 358 362 subq $(FRAME_SIZE), %rsp 359 363 360 364 movq %rax, RAX(%rsp) 361 365 movq %rdx, RDX(%rsp) 362 366 movq %rbp, RBP(%rsp) 367 + movq %rsp, RSP(%rsp) 363 368 movq %rsp, %rdi 364 369 365 370 call ftrace_return_to_handler ··· 373 368 movq RDX(%rsp), %rdx 374 369 movq RAX(%rsp), %rax 375 370 376 - addq $(FRAME_SIZE), %rsp 371 + addq $(FRAME_SIZE) + 8, %rsp 372 + 377 373 /* 378 374 * Jump back to the old return address. This cannot be JMP_NOSPEC rdi 379 375 * since IBT would demand that contain ENDBR, which simply isn't so for
+15 -9
arch/x86/kvm/svm/avic.c
··· 216 216 * This function is called from IOMMU driver to notify 217 217 * SVM to schedule in a particular vCPU of a particular VM. 218 218 */ 219 - int avic_ga_log_notifier(u32 ga_tag) 219 + static int avic_ga_log_notifier(u32 ga_tag) 220 220 { 221 221 unsigned long flags; 222 222 struct kvm_svm *kvm_svm; ··· 788 788 struct kvm_vcpu *vcpu = &svm->vcpu; 789 789 790 790 INIT_LIST_HEAD(&svm->ir_list); 791 - spin_lock_init(&svm->ir_list_lock); 791 + raw_spin_lock_init(&svm->ir_list_lock); 792 792 793 793 if (!enable_apicv || !irqchip_in_kernel(vcpu->kvm)) 794 794 return 0; ··· 816 816 if (!vcpu) 817 817 return; 818 818 819 - spin_lock_irqsave(&to_svm(vcpu)->ir_list_lock, flags); 819 + raw_spin_lock_irqsave(&to_svm(vcpu)->ir_list_lock, flags); 820 820 list_del(&irqfd->vcpu_list); 821 - spin_unlock_irqrestore(&to_svm(vcpu)->ir_list_lock, flags); 821 + raw_spin_unlock_irqrestore(&to_svm(vcpu)->ir_list_lock, flags); 822 822 } 823 823 824 824 int avic_pi_update_irte(struct kvm_kernel_irqfd *irqfd, struct kvm *kvm, ··· 855 855 * list of IRQs being posted to the vCPU, to ensure the IRTE 856 856 * isn't programmed with stale pCPU/IsRunning information. 857 857 */ 858 - guard(spinlock_irqsave)(&svm->ir_list_lock); 858 + guard(raw_spinlock_irqsave)(&svm->ir_list_lock); 859 859 860 860 /* 861 861 * Update the target pCPU for IOMMU doorbells if the vCPU is ··· 972 972 * up-to-date entry information, or that this task will wait until 973 973 * svm_ir_list_add() completes to set the new target pCPU. 974 974 */ 975 - spin_lock_irqsave(&svm->ir_list_lock, flags); 975 + raw_spin_lock_irqsave(&svm->ir_list_lock, flags); 976 976 977 977 entry = svm->avic_physical_id_entry; 978 978 WARN_ON_ONCE(entry & AVIC_PHYSICAL_ID_ENTRY_IS_RUNNING_MASK); ··· 997 997 998 998 avic_update_iommu_vcpu_affinity(vcpu, h_physical_id, action); 999 999 1000 - spin_unlock_irqrestore(&svm->ir_list_lock, flags); 1000 + raw_spin_unlock_irqrestore(&svm->ir_list_lock, flags); 1001 1001 } 1002 1002 1003 1003 void avic_vcpu_load(struct kvm_vcpu *vcpu, int cpu) ··· 1035 1035 * or that this task will wait until svm_ir_list_add() completes to 1036 1036 * mark the vCPU as not running. 1037 1037 */ 1038 - spin_lock_irqsave(&svm->ir_list_lock, flags); 1038 + raw_spin_lock_irqsave(&svm->ir_list_lock, flags); 1039 1039 1040 1040 avic_update_iommu_vcpu_affinity(vcpu, -1, action); 1041 1041 ··· 1059 1059 1060 1060 svm->avic_physical_id_entry = entry; 1061 1061 1062 - spin_unlock_irqrestore(&svm->ir_list_lock, flags); 1062 + raw_spin_unlock_irqrestore(&svm->ir_list_lock, flags); 1063 1063 } 1064 1064 1065 1065 void avic_vcpu_put(struct kvm_vcpu *vcpu) ··· 1242 1242 amd_iommu_register_ga_log_notifier(&avic_ga_log_notifier); 1243 1243 1244 1244 return true; 1245 + } 1246 + 1247 + void avic_hardware_unsetup(void) 1248 + { 1249 + if (avic) 1250 + amd_iommu_register_ga_log_notifier(NULL); 1245 1251 }
+7 -13
arch/x86/kvm/svm/nested.c
··· 677 677 */ 678 678 svm_copy_lbrs(vmcb02, vmcb12); 679 679 vmcb02->save.dbgctl &= ~DEBUGCTL_RESERVED_BITS; 680 - svm_update_lbrv(&svm->vcpu); 681 - 682 - } else if (unlikely(vmcb01->control.virt_ext & LBR_CTL_ENABLE_MASK)) { 680 + } else { 683 681 svm_copy_lbrs(vmcb02, vmcb01); 684 682 } 683 + svm_update_lbrv(&svm->vcpu); 685 684 } 686 685 687 686 static inline bool is_evtinj_soft(u32 evtinj) ··· 832 833 svm->soft_int_next_rip = vmcb12_rip; 833 834 } 834 835 835 - vmcb02->control.virt_ext = vmcb01->control.virt_ext & 836 - LBR_CTL_ENABLE_MASK; 837 - if (guest_cpu_cap_has(vcpu, X86_FEATURE_LBRV)) 838 - vmcb02->control.virt_ext |= 839 - (svm->nested.ctl.virt_ext & LBR_CTL_ENABLE_MASK); 836 + /* LBR_CTL_ENABLE_MASK is controlled by svm_update_lbrv() */ 840 837 841 838 if (!nested_vmcb_needs_vls_intercept(svm)) 842 839 vmcb02->control.virt_ext |= VIRTUAL_VMLOAD_VMSAVE_ENABLE_MASK; ··· 1184 1189 kvm_make_request(KVM_REQ_EVENT, &svm->vcpu); 1185 1190 1186 1191 if (unlikely(guest_cpu_cap_has(vcpu, X86_FEATURE_LBRV) && 1187 - (svm->nested.ctl.virt_ext & LBR_CTL_ENABLE_MASK))) { 1192 + (svm->nested.ctl.virt_ext & LBR_CTL_ENABLE_MASK))) 1188 1193 svm_copy_lbrs(vmcb12, vmcb02); 1189 - svm_update_lbrv(vcpu); 1190 - } else if (unlikely(vmcb01->control.virt_ext & LBR_CTL_ENABLE_MASK)) { 1194 + else 1191 1195 svm_copy_lbrs(vmcb01, vmcb02); 1192 - svm_update_lbrv(vcpu); 1193 - } 1196 + 1197 + svm_update_lbrv(vcpu); 1194 1198 1195 1199 if (vnmi) { 1196 1200 if (vmcb02->control.int_ctl & V_NMI_BLOCKING_MASK)
+39 -49
arch/x86/kvm/svm/svm.c
··· 806 806 vmcb_mark_dirty(to_vmcb, VMCB_LBR); 807 807 } 808 808 809 + static void __svm_enable_lbrv(struct kvm_vcpu *vcpu) 810 + { 811 + to_svm(vcpu)->vmcb->control.virt_ext |= LBR_CTL_ENABLE_MASK; 812 + } 813 + 809 814 void svm_enable_lbrv(struct kvm_vcpu *vcpu) 810 815 { 811 - struct vcpu_svm *svm = to_svm(vcpu); 812 - 813 - svm->vmcb->control.virt_ext |= LBR_CTL_ENABLE_MASK; 816 + __svm_enable_lbrv(vcpu); 814 817 svm_recalc_lbr_msr_intercepts(vcpu); 815 - 816 - /* Move the LBR msrs to the vmcb02 so that the guest can see them. */ 817 - if (is_guest_mode(vcpu)) 818 - svm_copy_lbrs(svm->vmcb, svm->vmcb01.ptr); 819 818 } 820 819 821 - static void svm_disable_lbrv(struct kvm_vcpu *vcpu) 820 + static void __svm_disable_lbrv(struct kvm_vcpu *vcpu) 822 821 { 823 - struct vcpu_svm *svm = to_svm(vcpu); 824 - 825 822 KVM_BUG_ON(sev_es_guest(vcpu->kvm), vcpu->kvm); 826 - svm->vmcb->control.virt_ext &= ~LBR_CTL_ENABLE_MASK; 827 - svm_recalc_lbr_msr_intercepts(vcpu); 828 - 829 - /* 830 - * Move the LBR msrs back to the vmcb01 to avoid copying them 831 - * on nested guest entries. 832 - */ 833 - if (is_guest_mode(vcpu)) 834 - svm_copy_lbrs(svm->vmcb01.ptr, svm->vmcb); 835 - } 836 - 837 - static struct vmcb *svm_get_lbr_vmcb(struct vcpu_svm *svm) 838 - { 839 - /* 840 - * If LBR virtualization is disabled, the LBR MSRs are always kept in 841 - * vmcb01. If LBR virtualization is enabled and L1 is running VMs of 842 - * its own, the MSRs are moved between vmcb01 and vmcb02 as needed. 843 - */ 844 - return svm->vmcb->control.virt_ext & LBR_CTL_ENABLE_MASK ? svm->vmcb : 845 - svm->vmcb01.ptr; 823 + to_svm(vcpu)->vmcb->control.virt_ext &= ~LBR_CTL_ENABLE_MASK; 846 824 } 847 825 848 826 void svm_update_lbrv(struct kvm_vcpu *vcpu) 849 827 { 850 828 struct vcpu_svm *svm = to_svm(vcpu); 851 829 bool current_enable_lbrv = svm->vmcb->control.virt_ext & LBR_CTL_ENABLE_MASK; 852 - bool enable_lbrv = (svm_get_lbr_vmcb(svm)->save.dbgctl & DEBUGCTLMSR_LBR) || 830 + bool enable_lbrv = (svm->vmcb->save.dbgctl & DEBUGCTLMSR_LBR) || 853 831 (is_guest_mode(vcpu) && guest_cpu_cap_has(vcpu, X86_FEATURE_LBRV) && 854 832 (svm->nested.ctl.virt_ext & LBR_CTL_ENABLE_MASK)); 855 833 856 - if (enable_lbrv == current_enable_lbrv) 857 - return; 834 + if (enable_lbrv && !current_enable_lbrv) 835 + __svm_enable_lbrv(vcpu); 836 + else if (!enable_lbrv && current_enable_lbrv) 837 + __svm_disable_lbrv(vcpu); 858 838 859 - if (enable_lbrv) 860 - svm_enable_lbrv(vcpu); 861 - else 862 - svm_disable_lbrv(vcpu); 839 + /* 840 + * During nested transitions, it is possible that the current VMCB has 841 + * LBR_CTL set, but the previous LBR_CTL had it cleared (or vice versa). 842 + * In this case, even though LBR_CTL does not need an update, intercepts 843 + * do, so always recalculate the intercepts here. 844 + */ 845 + svm_recalc_lbr_msr_intercepts(vcpu); 863 846 } 864 847 865 848 void disable_nmi_singlestep(struct vcpu_svm *svm) ··· 903 920 static void svm_hardware_unsetup(void) 904 921 { 905 922 int cpu; 923 + 924 + avic_hardware_unsetup(); 906 925 907 926 sev_hardware_unsetup(); 908 927 ··· 2707 2722 msr_info->data = svm->tsc_aux; 2708 2723 break; 2709 2724 case MSR_IA32_DEBUGCTLMSR: 2710 - msr_info->data = svm_get_lbr_vmcb(svm)->save.dbgctl; 2725 + msr_info->data = svm->vmcb->save.dbgctl; 2711 2726 break; 2712 2727 case MSR_IA32_LASTBRANCHFROMIP: 2713 - msr_info->data = svm_get_lbr_vmcb(svm)->save.br_from; 2728 + msr_info->data = svm->vmcb->save.br_from; 2714 2729 break; 2715 2730 case MSR_IA32_LASTBRANCHTOIP: 2716 - msr_info->data = svm_get_lbr_vmcb(svm)->save.br_to; 2731 + msr_info->data = svm->vmcb->save.br_to; 2717 2732 break; 2718 2733 case MSR_IA32_LASTINTFROMIP: 2719 - msr_info->data = svm_get_lbr_vmcb(svm)->save.last_excp_from; 2734 + msr_info->data = svm->vmcb->save.last_excp_from; 2720 2735 break; 2721 2736 case MSR_IA32_LASTINTTOIP: 2722 - msr_info->data = svm_get_lbr_vmcb(svm)->save.last_excp_to; 2737 + msr_info->data = svm->vmcb->save.last_excp_to; 2723 2738 break; 2724 2739 case MSR_VM_HSAVE_PA: 2725 2740 msr_info->data = svm->nested.hsave_msr; ··· 2987 3002 if (data & DEBUGCTL_RESERVED_BITS) 2988 3003 return 1; 2989 3004 2990 - svm_get_lbr_vmcb(svm)->save.dbgctl = data; 3005 + if (svm->vmcb->save.dbgctl == data) 3006 + break; 3007 + 3008 + svm->vmcb->save.dbgctl = data; 3009 + vmcb_mark_dirty(svm->vmcb, VMCB_LBR); 2991 3010 svm_update_lbrv(vcpu); 2992 3011 break; 2993 3012 case MSR_VM_HSAVE_PA: ··· 5375 5386 5376 5387 svm_hv_hardware_setup(); 5377 5388 5378 - for_each_possible_cpu(cpu) { 5379 - r = svm_cpu_init(cpu); 5380 - if (r) 5381 - goto err; 5382 - } 5383 - 5384 5389 enable_apicv = avic_hardware_setup(); 5385 5390 if (!enable_apicv) { 5386 5391 enable_ipiv = false; ··· 5418 5435 svm_set_cpu_caps(); 5419 5436 5420 5437 kvm_caps.inapplicable_quirks &= ~KVM_X86_QUIRK_CD_NW_CLEARED; 5438 + 5439 + for_each_possible_cpu(cpu) { 5440 + r = svm_cpu_init(cpu); 5441 + if (r) 5442 + goto err; 5443 + } 5444 + 5421 5445 return 0; 5422 5446 5423 5447 err:
+2 -2
arch/x86/kvm/svm/svm.h
··· 329 329 * back into remapped mode). 330 330 */ 331 331 struct list_head ir_list; 332 - spinlock_t ir_list_lock; 332 + raw_spinlock_t ir_list_lock; 333 333 334 334 struct vcpu_sev_es_state sev_es; 335 335 ··· 805 805 ) 806 806 807 807 bool __init avic_hardware_setup(void); 808 - int avic_ga_log_notifier(u32 ga_tag); 808 + void avic_hardware_unsetup(void); 809 809 void avic_vm_destroy(struct kvm *kvm); 810 810 int avic_vm_init(struct kvm *kvm); 811 811 void avic_init_vmcb(struct vcpu_svm *svm, struct vmcb *vmcb);
+1 -1
arch/x86/kvm/vmx/common.h
··· 98 98 error_code |= (exit_qualification & EPT_VIOLATION_PROT_MASK) 99 99 ? PFERR_PRESENT_MASK : 0; 100 100 101 - if (error_code & EPT_VIOLATION_GVA_IS_VALID) 101 + if (exit_qualification & EPT_VIOLATION_GVA_IS_VALID) 102 102 error_code |= (exit_qualification & EPT_VIOLATION_GVA_TRANSLATED) ? 103 103 PFERR_GUEST_FINAL_MASK : PFERR_GUEST_PAGE_MASK; 104 104
+8
arch/x86/kvm/vmx/nested.c
··· 6728 6728 case EXIT_REASON_NOTIFY: 6729 6729 /* Notify VM exit is not exposed to L1 */ 6730 6730 return false; 6731 + case EXIT_REASON_SEAMCALL: 6732 + case EXIT_REASON_TDCALL: 6733 + /* 6734 + * SEAMCALL and TDCALL unconditionally VM-Exit, but aren't 6735 + * virtualized by KVM for L1 hypervisors, i.e. L1 should 6736 + * never want or expect such an exit. 6737 + */ 6738 + return false; 6731 6739 default: 6732 6740 return true; 6733 6741 }
+8
arch/x86/kvm/vmx/vmx.c
··· 6032 6032 return 1; 6033 6033 } 6034 6034 6035 + static int handle_tdx_instruction(struct kvm_vcpu *vcpu) 6036 + { 6037 + kvm_queue_exception(vcpu, UD_VECTOR); 6038 + return 1; 6039 + } 6040 + 6035 6041 #ifndef CONFIG_X86_SGX_KVM 6036 6042 static int handle_encls(struct kvm_vcpu *vcpu) 6037 6043 { ··· 6163 6157 [EXIT_REASON_ENCLS] = handle_encls, 6164 6158 [EXIT_REASON_BUS_LOCK] = handle_bus_lock_vmexit, 6165 6159 [EXIT_REASON_NOTIFY] = handle_notify, 6160 + [EXIT_REASON_SEAMCALL] = handle_tdx_instruction, 6161 + [EXIT_REASON_TDCALL] = handle_tdx_instruction, 6166 6162 [EXIT_REASON_MSR_READ_IMM] = handle_rdmsr_imm, 6167 6163 [EXIT_REASON_MSR_WRITE_IMM] = handle_wrmsr_imm, 6168 6164 };
+29 -19
arch/x86/kvm/x86.c
··· 3874 3874 3875 3875 /* 3876 3876 * Returns true if the MSR in question is managed via XSTATE, i.e. is context 3877 - * switched with the rest of guest FPU state. Note! S_CET is _not_ context 3878 - * switched via XSTATE even though it _is_ saved/restored via XSAVES/XRSTORS. 3879 - * Because S_CET is loaded on VM-Enter and VM-Exit via dedicated VMCS fields, 3880 - * the value saved/restored via XSTATE is always the host's value. That detail 3881 - * is _extremely_ important, as the guest's S_CET must _never_ be resident in 3882 - * hardware while executing in the host. Loading guest values for U_CET and 3883 - * PL[0-3]_SSP while executing in the kernel is safe, as U_CET is specific to 3884 - * userspace, and PL[0-3]_SSP are only consumed when transitioning to lower 3885 - * privilege levels, i.e. are effectively only consumed by userspace as well. 3877 + * switched with the rest of guest FPU state. 3878 + * 3879 + * Note, S_CET is _not_ saved/restored via XSAVES/XRSTORS. 3886 3880 */ 3887 3881 static bool is_xstate_managed_msr(struct kvm_vcpu *vcpu, u32 msr) 3888 3882 { ··· 3899 3905 * MSR that is managed via XSTATE. Note, the caller is responsible for doing 3900 3906 * the initial FPU load, this helper only ensures that guest state is resident 3901 3907 * in hardware (the kernel can load its FPU state in IRQ context). 3908 + * 3909 + * Note, loading guest values for U_CET and PL[0-3]_SSP while executing in the 3910 + * kernel is safe, as U_CET is specific to userspace, and PL[0-3]_SSP are only 3911 + * consumed when transitioning to lower privilege levels, i.e. are effectively 3912 + * only consumed by userspace as well. 3902 3913 */ 3903 3914 static __always_inline void kvm_access_xstate_msr(struct kvm_vcpu *vcpu, 3904 3915 struct msr_data *msr_info, ··· 11806 11807 /* Swap (qemu) user FPU context for the guest FPU context. */ 11807 11808 static void kvm_load_guest_fpu(struct kvm_vcpu *vcpu) 11808 11809 { 11810 + if (KVM_BUG_ON(vcpu->arch.guest_fpu.fpstate->in_use, vcpu->kvm)) 11811 + return; 11812 + 11809 11813 /* Exclude PKRU, it's restored separately immediately after VM-Exit. */ 11810 11814 fpu_swap_kvm_fpstate(&vcpu->arch.guest_fpu, true); 11811 11815 trace_kvm_fpu(1); ··· 11817 11815 /* When vcpu_run ends, restore user space FPU context. */ 11818 11816 static void kvm_put_guest_fpu(struct kvm_vcpu *vcpu) 11819 11817 { 11818 + if (KVM_BUG_ON(!vcpu->arch.guest_fpu.fpstate->in_use, vcpu->kvm)) 11819 + return; 11820 + 11820 11821 fpu_swap_kvm_fpstate(&vcpu->arch.guest_fpu, false); 11821 11822 ++vcpu->stat.fpu_reload; 11822 11823 trace_kvm_fpu(0); ··· 12142 12137 int r; 12143 12138 12144 12139 vcpu_load(vcpu); 12145 - if (kvm_mpx_supported()) 12146 - kvm_load_guest_fpu(vcpu); 12147 - 12148 12140 kvm_vcpu_srcu_read_lock(vcpu); 12149 12141 12150 12142 r = kvm_apic_accept_events(vcpu); ··· 12158 12156 12159 12157 out: 12160 12158 kvm_vcpu_srcu_read_unlock(vcpu); 12161 - 12162 - if (kvm_mpx_supported()) 12163 - kvm_put_guest_fpu(vcpu); 12164 12159 vcpu_put(vcpu); 12165 12160 return r; 12166 12161 } ··· 12787 12788 { 12788 12789 struct fpstate *fpstate = vcpu->arch.guest_fpu.fpstate; 12789 12790 u64 xfeatures_mask; 12791 + bool fpu_in_use; 12790 12792 int i; 12791 12793 12792 12794 /* ··· 12811 12811 BUILD_BUG_ON(sizeof(xfeatures_mask) * BITS_PER_BYTE <= XFEATURE_MAX); 12812 12812 12813 12813 /* 12814 - * All paths that lead to INIT are required to load the guest's FPU 12815 - * state (because most paths are buried in KVM_RUN). 12814 + * Unload guest FPU state (if necessary) before zeroing XSTATE fields 12815 + * as the kernel can only modify the state when its resident in memory, 12816 + * i.e. when it's not loaded into hardware. 12817 + * 12818 + * WARN if the vCPU's desire to run, i.e. whether or not its in KVM_RUN, 12819 + * doesn't match the loaded/in-use state of the FPU, as KVM_RUN is the 12820 + * only path that can trigger INIT emulation _and_ loads FPU state, and 12821 + * KVM_RUN should _always_ load FPU state. 12816 12822 */ 12817 - kvm_put_guest_fpu(vcpu); 12823 + WARN_ON_ONCE(vcpu->wants_to_run != fpstate->in_use); 12824 + fpu_in_use = fpstate->in_use; 12825 + if (fpu_in_use) 12826 + kvm_put_guest_fpu(vcpu); 12818 12827 for_each_set_bit(i, (unsigned long *)&xfeatures_mask, XFEATURE_MAX) 12819 12828 fpstate_clear_xstate_component(fpstate, i); 12820 - kvm_load_guest_fpu(vcpu); 12829 + if (fpu_in_use) 12830 + kvm_load_guest_fpu(vcpu); 12821 12831 } 12822 12832 12823 12833 void kvm_vcpu_reset(struct kvm_vcpu *vcpu, bool init_event)
+37 -14
drivers/acpi/acpi_mrrm.c
··· 152 152 153 153 static __init int add_boot_memory_ranges(void) 154 154 { 155 - struct kobject *pkobj, *kobj; 155 + struct kobject *pkobj, *kobj, **kobjs; 156 156 int ret = -EINVAL; 157 - char *name; 157 + char name[16]; 158 + int i; 158 159 159 160 pkobj = kobject_create_and_add("memory_ranges", acpi_kobj); 161 + if (!pkobj) 162 + return -ENOMEM; 160 163 161 - for (int i = 0; i < mrrm_mem_entry_num; i++) { 162 - name = kasprintf(GFP_KERNEL, "range%d", i); 163 - if (!name) { 164 - ret = -ENOMEM; 165 - break; 166 - } 167 - 168 - kobj = kobject_create_and_add(name, pkobj); 169 - 170 - ret = sysfs_create_groups(kobj, memory_range_groups); 171 - if (ret) 172 - return ret; 164 + kobjs = kcalloc(mrrm_mem_entry_num, sizeof(*kobjs), GFP_KERNEL); 165 + if (!kobjs) { 166 + kobject_put(pkobj); 167 + return -ENOMEM; 173 168 } 174 169 170 + for (i = 0; i < mrrm_mem_entry_num; i++) { 171 + scnprintf(name, sizeof(name), "range%d", i); 172 + kobj = kobject_create_and_add(name, pkobj); 173 + if (!kobj) { 174 + ret = -ENOMEM; 175 + goto cleanup; 176 + } 177 + 178 + ret = sysfs_create_groups(kobj, memory_range_groups); 179 + if (ret) { 180 + kobject_put(kobj); 181 + goto cleanup; 182 + } 183 + kobjs[i] = kobj; 184 + } 185 + 186 + kfree(kobjs); 187 + return 0; 188 + 189 + cleanup: 190 + for (int j = 0; j < i; j++) { 191 + if (kobjs[j]) { 192 + sysfs_remove_groups(kobjs[j], memory_range_groups); 193 + kobject_put(kobjs[j]); 194 + } 195 + } 196 + kfree(kobjs); 197 + kobject_put(pkobj); 175 198 return ret; 176 199 } 177 200
+4 -4
drivers/acpi/cppc_acpi.c
··· 460 460 if (acpi_disabled) 461 461 return false; 462 462 463 - for_each_present_cpu(cpu) { 463 + for_each_online_cpu(cpu) { 464 464 cpc_ptr = per_cpu(cpc_desc_ptr, cpu); 465 465 if (!cpc_ptr) 466 466 return false; ··· 476 476 struct cpc_desc *cpc_ptr; 477 477 int cpu; 478 478 479 - for_each_present_cpu(cpu) { 479 + for_each_online_cpu(cpu) { 480 480 cpc_ptr = per_cpu(cpc_desc_ptr, cpu); 481 481 desired_reg = &cpc_ptr->cpc_regs[DESIRED_PERF]; 482 482 if (!CPC_IN_SYSTEM_MEMORY(desired_reg) && ··· 750 750 } 751 751 752 752 /* 753 - * Disregard _CPC if the number of entries in the return pachage is not 753 + * Disregard _CPC if the number of entries in the return package is not 754 754 * as expected, but support future revisions being proper supersets of 755 755 * the v3 and only causing more entries to be returned by _CPC. 756 756 */ ··· 1435 1435 { 1436 1436 int cpu; 1437 1437 1438 - for_each_present_cpu(cpu) { 1438 + for_each_online_cpu(cpu) { 1439 1439 struct cpc_register_resource *ref_perf_reg; 1440 1440 struct cpc_desc *cpc_desc; 1441 1441
+25 -21
drivers/acpi/numa/hmat.c
··· 874 874 } 875 875 } 876 876 877 - static void hmat_register_target(struct memory_target *target) 877 + static void hmat_hotplug_target(struct memory_target *target) 878 878 { 879 879 int nid = pxm_to_node(target->memory_pxm); 880 880 881 + /* 882 + * Skip offline nodes. This can happen when memory marked EFI_MEMORY_SP, 883 + * "specific purpose", is applied to all the memory in a proximity 884 + * domain leading to * the node being marked offline / unplugged, or if 885 + * memory-only "hotplug" node is offline. 886 + */ 887 + if (nid == NUMA_NO_NODE || !node_online(nid)) 888 + return; 889 + 890 + guard(mutex)(&target_lock); 891 + if (target->registered) 892 + return; 893 + 894 + hmat_register_target_initiators(target); 895 + hmat_register_target_cache(target); 896 + hmat_register_target_perf(target, ACCESS_COORDINATE_LOCAL); 897 + hmat_register_target_perf(target, ACCESS_COORDINATE_CPU); 898 + target->registered = true; 899 + } 900 + 901 + static void hmat_register_target(struct memory_target *target) 902 + { 881 903 /* 882 904 * Devices may belong to either an offline or online 883 905 * node, so unconditionally add them. ··· 917 895 } 918 896 mutex_unlock(&target_lock); 919 897 920 - /* 921 - * Skip offline nodes. This can happen when memory 922 - * marked EFI_MEMORY_SP, "specific purpose", is applied 923 - * to all the memory in a proximity domain leading to 924 - * the node being marked offline / unplugged, or if 925 - * memory-only "hotplug" node is offline. 926 - */ 927 - if (nid == NUMA_NO_NODE || !node_online(nid)) 928 - return; 929 - 930 - mutex_lock(&target_lock); 931 - if (!target->registered) { 932 - hmat_register_target_initiators(target); 933 - hmat_register_target_cache(target); 934 - hmat_register_target_perf(target, ACCESS_COORDINATE_LOCAL); 935 - hmat_register_target_perf(target, ACCESS_COORDINATE_CPU); 936 - target->registered = true; 937 - } 938 - mutex_unlock(&target_lock); 898 + hmat_hotplug_target(target); 939 899 } 940 900 941 901 static void hmat_register_targets(void) ··· 943 939 if (!target) 944 940 return NOTIFY_OK; 945 941 946 - hmat_register_target(target); 942 + hmat_hotplug_target(target); 947 943 return NOTIFY_OK; 948 944 } 949 945
+1 -1
drivers/acpi/numa/srat.c
··· 237 237 struct acpi_srat_generic_affinity *p = 238 238 (struct acpi_srat_generic_affinity *)header; 239 239 240 - if (p->device_handle_type == 0) { 240 + if (p->device_handle_type == 1) { 241 241 /* 242 242 * For pci devices this may be the only place they 243 243 * are assigned a proximity domain
+1 -1
drivers/acpi/sbs.c
··· 487 487 if (result) 488 488 return result; 489 489 490 - battery->present = state & (1 << battery->id); 490 + battery->present = !!(state & (1 << battery->id)); 491 491 if (!battery->present) 492 492 return 0; 493 493
+16 -12
drivers/bluetooth/btrtl.c
··· 50 50 51 51 #define RTL_CHIP_SUBVER (&(struct rtl_vendor_cmd) {{0x10, 0x38, 0x04, 0x28, 0x80}}) 52 52 #define RTL_CHIP_REV (&(struct rtl_vendor_cmd) {{0x10, 0x3A, 0x04, 0x28, 0x80}}) 53 - #define RTL_SEC_PROJ (&(struct rtl_vendor_cmd) {{0x10, 0xA4, 0x0D, 0x00, 0xb0}}) 53 + #define RTL_SEC_PROJ (&(struct rtl_vendor_cmd) {{0x10, 0xA4, 0xAD, 0x00, 0xb0}}) 54 54 55 55 #define RTL_PATCH_SNIPPETS 0x01 56 56 #define RTL_PATCH_DUMMY_HEADER 0x02 ··· 534 534 { 535 535 struct rtl_epatch_header_v2 *hdr; 536 536 int rc; 537 - u8 reg_val[2]; 538 537 u8 key_id; 539 538 u32 num_sections; 540 539 struct rtl_section *section; ··· 548 549 .len = btrtl_dev->fw_len - 7, /* Cut the tail */ 549 550 }; 550 551 551 - rc = btrtl_vendor_read_reg16(hdev, RTL_SEC_PROJ, reg_val); 552 - if (rc < 0) 553 - return -EIO; 554 - key_id = reg_val[0]; 555 - 556 - rtl_dev_dbg(hdev, "%s: key id %u", __func__, key_id); 557 - 558 - btrtl_dev->key_id = key_id; 552 + key_id = btrtl_dev->key_id; 559 553 560 554 hdr = rtl_iov_pull_data(&iov, sizeof(*hdr)); 561 555 if (!hdr) ··· 617 625 len += entry->len; 618 626 } 619 627 620 - if (!len) 628 + if (!len) { 629 + kvfree(ptr); 621 630 return -EPERM; 631 + } 622 632 623 633 *_buf = ptr; 624 634 return len; ··· 1062 1068 u16 hci_rev, lmp_subver; 1063 1069 u8 hci_ver, lmp_ver, chip_type = 0; 1064 1070 int ret; 1071 + int rc; 1072 + u8 key_id; 1065 1073 u8 reg_val[2]; 1066 1074 1067 1075 btrtl_dev = kzalloc(sizeof(*btrtl_dev), GFP_KERNEL); ··· 1174 1178 goto err_free; 1175 1179 } 1176 1180 1181 + rc = btrtl_vendor_read_reg16(hdev, RTL_SEC_PROJ, reg_val); 1182 + if (rc < 0) 1183 + goto err_free; 1184 + 1185 + key_id = reg_val[0]; 1186 + btrtl_dev->key_id = key_id; 1187 + rtl_dev_info(hdev, "%s: key id %u", __func__, key_id); 1188 + 1177 1189 btrtl_dev->fw_len = -EIO; 1178 1190 if (lmp_subver == RTL_ROM_LMP_8852A && hci_rev == 0x000c) { 1179 1191 snprintf(fw_name, sizeof(fw_name), "%s_v2.bin", ··· 1204 1200 goto err_free; 1205 1201 } 1206 1202 1207 - if (btrtl_dev->ic_info->cfg_name) { 1203 + if (btrtl_dev->ic_info->cfg_name && !btrtl_dev->key_id) { 1208 1204 if (postfix) { 1209 1205 snprintf(cfg_name, sizeof(cfg_name), "%s-%s.bin", 1210 1206 btrtl_dev->ic_info->cfg_name, postfix);
+6 -7
drivers/bluetooth/btusb.c
··· 4361 4361 4362 4362 hci_unregister_dev(hdev); 4363 4363 4364 + if (data->oob_wake_irq) 4365 + device_init_wakeup(&data->udev->dev, false); 4366 + if (data->reset_gpio) 4367 + gpiod_put(data->reset_gpio); 4368 + 4364 4369 if (intf == data->intf) { 4365 4370 if (data->isoc) 4366 4371 usb_driver_release_interface(&btusb_driver, data->isoc); ··· 4376 4371 usb_driver_release_interface(&btusb_driver, data->diag); 4377 4372 usb_driver_release_interface(&btusb_driver, data->intf); 4378 4373 } else if (intf == data->diag) { 4379 - usb_driver_release_interface(&btusb_driver, data->intf); 4380 4374 if (data->isoc) 4381 4375 usb_driver_release_interface(&btusb_driver, data->isoc); 4376 + usb_driver_release_interface(&btusb_driver, data->intf); 4382 4377 } 4383 - 4384 - if (data->oob_wake_irq) 4385 - device_init_wakeup(&data->udev->dev, false); 4386 - 4387 - if (data->reset_gpio) 4388 - gpiod_put(data->reset_gpio); 4389 4378 4390 4379 hci_free_dev(hdev); 4391 4380 }
+4 -5
drivers/cpufreq/intel_pstate.c
··· 603 603 { 604 604 u64 misc_en; 605 605 606 - if (!cpu_feature_enabled(X86_FEATURE_IDA)) 607 - return true; 608 - 609 606 rdmsrq(MSR_IA32_MISC_ENABLE, misc_en); 610 607 611 608 return !!(misc_en & MSR_IA32_MISC_ENABLE_TURBO_DISABLE); ··· 2103 2106 u32 vid; 2104 2107 2105 2108 val = (u64)pstate << 8; 2106 - if (READ_ONCE(global.no_turbo) && !READ_ONCE(global.turbo_disabled)) 2109 + if (READ_ONCE(global.no_turbo) && !READ_ONCE(global.turbo_disabled) && 2110 + cpu_feature_enabled(X86_FEATURE_IDA)) 2107 2111 val |= (u64)1 << 32; 2108 2112 2109 2113 vid_fp = cpudata->vid.min + mul_fp( ··· 2269 2271 u64 val; 2270 2272 2271 2273 val = (u64)pstate << 8; 2272 - if (READ_ONCE(global.no_turbo) && !READ_ONCE(global.turbo_disabled)) 2274 + if (READ_ONCE(global.no_turbo) && !READ_ONCE(global.turbo_disabled) && 2275 + cpu_feature_enabled(X86_FEATURE_IDA)) 2273 2276 val |= (u64)1 << 32; 2274 2277 2275 2278 return val;
+3 -2
drivers/cpuidle/cpuidle-riscv-sbi.c
··· 18 18 #include <linux/module.h> 19 19 #include <linux/of.h> 20 20 #include <linux/slab.h> 21 + #include <linux/string.h> 21 22 #include <linux/platform_device.h> 22 23 #include <linux/pm_domain.h> 23 24 #include <linux/pm_runtime.h> ··· 304 303 drv->states[0].exit_latency = 1; 305 304 drv->states[0].target_residency = 1; 306 305 drv->states[0].power_usage = UINT_MAX; 307 - strcpy(drv->states[0].name, "WFI"); 308 - strcpy(drv->states[0].desc, "RISC-V WFI"); 306 + strscpy(drv->states[0].name, "WFI"); 307 + strscpy(drv->states[0].desc, "RISC-V WFI"); 309 308 310 309 /* 311 310 * If no DT idle states are detected (ret == 0) let the driver
+2
drivers/crypto/hisilicon/qm.c
··· 3871 3871 pdev = container_of(dev, struct pci_dev, dev); 3872 3872 if (pci_physfn(pdev) != qm->pdev) { 3873 3873 pci_err(qm->pdev, "the pdev input does not match the pf!\n"); 3874 + put_device(dev); 3874 3875 return -EINVAL; 3875 3876 } 3876 3877 3877 3878 *fun_index = pdev->devfn; 3879 + put_device(dev); 3878 3880 3879 3881 return 0; 3880 3882 }
+2
drivers/cxl/core/region.c
··· 3702 3702 if (validate_region_offset(cxlr, offset)) 3703 3703 return -EINVAL; 3704 3704 3705 + offset -= cxlr->params.cache_size; 3705 3706 rc = region_offset_to_dpa_result(cxlr, offset, &result); 3706 3707 if (rc || !result.cxlmd || result.dpa == ULLONG_MAX) { 3707 3708 dev_dbg(&cxlr->dev, ··· 3735 3734 if (validate_region_offset(cxlr, offset)) 3736 3735 return -EINVAL; 3737 3736 3737 + offset -= cxlr->params.cache_size; 3738 3738 rc = region_offset_to_dpa_result(cxlr, offset, &result); 3739 3739 if (rc || !result.cxlmd || result.dpa == ULLONG_MAX) { 3740 3740 dev_dbg(&cxlr->dev,
+17 -5
drivers/edac/altera_edac.c
··· 1184 1184 if (ret) 1185 1185 return ret; 1186 1186 1187 - /* Verify OCRAM has been initialized */ 1187 + /* 1188 + * Verify that OCRAM has been initialized. 1189 + * During a warm reset, OCRAM contents are retained, but the control 1190 + * and status registers are reset to their default values. Therefore, 1191 + * ECC must be explicitly re-enabled in the control register. 1192 + * Error condition: if INITCOMPLETEA is clear and ECC_EN is already set. 1193 + */ 1188 1194 if (!ecc_test_bits(ALTR_A10_ECC_INITCOMPLETEA, 1189 - (base + ALTR_A10_ECC_INITSTAT_OFST))) 1190 - return -ENODEV; 1195 + (base + ALTR_A10_ECC_INITSTAT_OFST))) { 1196 + if (!ecc_test_bits(ALTR_A10_ECC_EN, 1197 + (base + ALTR_A10_ECC_CTRL_OFST))) 1198 + ecc_set_bits(ALTR_A10_ECC_EN, 1199 + (base + ALTR_A10_ECC_CTRL_OFST)); 1200 + else 1201 + return -ENODEV; 1202 + } 1191 1203 1192 1204 /* Enable IRQ on Single Bit Error */ 1193 1205 writel(ALTR_A10_ECC_SERRINTEN, (base + ALTR_A10_ECC_ERRINTENS_OFST)); ··· 1369 1357 .ue_set_mask = ALTR_A10_ECC_TDERRA, 1370 1358 .set_err_ofst = ALTR_A10_ECC_INTTEST_OFST, 1371 1359 .ecc_irq_handler = altr_edac_a10_ecc_irq, 1372 - .inject_fops = &altr_edac_a10_device_inject2_fops, 1360 + .inject_fops = &altr_edac_a10_device_inject_fops, 1373 1361 }; 1374 1362 1375 1363 #endif /* CONFIG_EDAC_ALTERA_ETHERNET */ ··· 1459 1447 .ue_set_mask = ALTR_A10_ECC_TDERRA, 1460 1448 .set_err_ofst = ALTR_A10_ECC_INTTEST_OFST, 1461 1449 .ecc_irq_handler = altr_edac_a10_ecc_irq, 1462 - .inject_fops = &altr_edac_a10_device_inject2_fops, 1450 + .inject_fops = &altr_edac_a10_device_inject_fops, 1463 1451 }; 1464 1452 1465 1453 #endif /* CONFIG_EDAC_ALTERA_USB */
+14 -12
drivers/edac/versalnet_edac.c
··· 433 433 phys_addr_t pfn; 434 434 int err; 435 435 436 - if (WARN_ON_ONCE(ctl_num > NUM_CONTROLLERS)) 436 + if (WARN_ON_ONCE(ctl_num >= NUM_CONTROLLERS)) 437 437 return; 438 438 439 439 mci = priv->mci[ctl_num]; ··· 605 605 length = result[MSG_ERR_LENGTH]; 606 606 offset = result[MSG_ERR_OFFSET]; 607 607 608 + /* 609 + * The data can come in two stretches. Construct the regs from two 610 + * messages. The offset indicates the offset from which the data is to 611 + * be taken. 612 + */ 613 + for (i = 0 ; i < length; i++) { 614 + k = offset + i; 615 + j = ERROR_DATA + i; 616 + mc_priv->regs[k] = result[j]; 617 + } 618 + 608 619 if (result[TOTAL_ERR_LENGTH] > length) { 609 620 if (!mc_priv->part_len) 610 621 mc_priv->part_len = length; 611 622 else 612 623 mc_priv->part_len += length; 613 - /* 614 - * The data can come in 2 stretches. Construct the regs from 2 615 - * messages the offset indicates the offset from which the data is to 616 - * be taken 617 - */ 618 - for (i = 0 ; i < length; i++) { 619 - k = offset + i; 620 - j = ERROR_DATA + i; 621 - mc_priv->regs[k] = result[j]; 622 - } 624 + 623 625 if (mc_priv->part_len < result[TOTAL_ERR_LENGTH]) 624 626 return 0; 625 627 mc_priv->part_len = 0; ··· 707 705 /* Convert to bytes */ 708 706 length = result[TOTAL_ERR_LENGTH] * 4; 709 707 log_non_standard_event(sec_type, &amd_versalnet_guid, mc_priv->message, 710 - sec_sev, (void *)&result[ERROR_DATA], length); 708 + sec_sev, (void *)&mc_priv->regs, length); 711 709 712 710 return 0; 713 711 }
+2
drivers/firewire/core-card.c
··· 577 577 INIT_LIST_HEAD(&card->transactions.list); 578 578 spin_lock_init(&card->transactions.lock); 579 579 580 + spin_lock_init(&card->topology_map.lock); 581 + 580 582 card->split_timeout.hi = DEFAULT_SPLIT_TIMEOUT / 8000; 581 583 card->split_timeout.lo = (DEFAULT_SPLIT_TIMEOUT % 8000) << 19; 582 584 card->split_timeout.cycles = DEFAULT_SPLIT_TIMEOUT;
+2 -1
drivers/firewire/core-topology.c
··· 441 441 const u32 *self_ids, int self_id_count) 442 442 { 443 443 __be32 *map = buffer; 444 + u32 next_generation = be32_to_cpu(buffer[1]) + 1; 444 445 int node_count = (root_node_id & 0x3f) + 1; 445 446 446 447 memset(map, 0, buffer_size); 447 448 448 449 *map++ = cpu_to_be32((self_id_count + 2) << 16); 449 - *map++ = cpu_to_be32(be32_to_cpu(buffer[1]) + 1); 450 + *map++ = cpu_to_be32(next_generation); 450 451 *map++ = cpu_to_be32((node_count << 16) | self_id_count); 451 452 452 453 while (self_id_count--)
+1
drivers/gpio/gpio-aggregator.c
··· 723 723 chip->get_multiple = gpio_fwd_get_multiple_locked; 724 724 chip->set = gpio_fwd_set; 725 725 chip->set_multiple = gpio_fwd_set_multiple_locked; 726 + chip->set_config = gpio_fwd_set_config; 726 727 chip->to_irq = gpio_fwd_to_irq; 727 728 chip->base = -1; 728 729 chip->ngpio = ngpios;
-19
drivers/gpio/gpio-tb10x.c
··· 50 50 return ioread32(gpio->base + offs); 51 51 } 52 52 53 - static inline void tb10x_reg_write(struct tb10x_gpio *gpio, unsigned int offs, 54 - u32 val) 55 - { 56 - iowrite32(val, gpio->base + offs); 57 - } 58 - 59 - static inline void tb10x_set_bits(struct tb10x_gpio *gpio, unsigned int offs, 60 - u32 mask, u32 val) 61 - { 62 - u32 r; 63 - 64 - guard(gpio_generic_lock_irqsave)(&gpio->chip); 65 - 66 - r = tb10x_reg_read(gpio, offs); 67 - r = (r & ~mask) | (val & mask); 68 - 69 - tb10x_reg_write(gpio, offs, r); 70 - } 71 - 72 53 static int tb10x_gpio_to_irq(struct gpio_chip *chip, unsigned offset) 73 54 { 74 55 struct tb10x_gpio *tb10x_gpio = gpiochip_get_data(chip);
+1 -1
drivers/gpio/gpiolib-swnode.c
··· 41 41 !strcmp(gdev_node->name, GPIOLIB_SWNODE_UNDEFINED_NAME)) 42 42 return ERR_PTR(-ENOENT); 43 43 44 - gdev = gpio_device_find_by_label(gdev_node->name); 44 + gdev = gpio_device_find_by_fwnode(fwnode); 45 45 return gdev ?: ERR_PTR(-EPROBE_DEFER); 46 46 } 47 47
+7 -1
drivers/gpio/gpiolib.c
··· 5296 5296 struct gpio_device *gdev; 5297 5297 loff_t index = *pos; 5298 5298 5299 + s->private = NULL; 5300 + 5299 5301 priv = kzalloc(sizeof(*priv), GFP_KERNEL); 5300 5302 if (!priv) 5301 5303 return NULL; ··· 5331 5329 5332 5330 static void gpiolib_seq_stop(struct seq_file *s, void *v) 5333 5331 { 5334 - struct gpiolib_seq_priv *priv = s->private; 5332 + struct gpiolib_seq_priv *priv; 5333 + 5334 + priv = s->private; 5335 + if (!priv) 5336 + return; 5335 5337 5336 5338 srcu_read_unlock(&gpio_devices_srcu, priv->idx); 5337 5339 kfree(priv);
+1 -1
drivers/gpu/drm/Makefile
··· 245 245 quiet_cmd_hdrtest = HDRTEST $(patsubst %.hdrtest,%.h,$@) 246 246 cmd_hdrtest = \ 247 247 $(CC) $(c_flags) -fsyntax-only -x c /dev/null -include $< -include $<; \ 248 - PYTHONDONTWRITEBYTECODE=1 $(KERNELDOC) -none $(if $(CONFIG_WERROR)$(CONFIG_DRM_WERROR),-Werror) $<; \ 248 + PYTHONDONTWRITEBYTECODE=1 $(PYTHON3) $(KERNELDOC) -none $(if $(CONFIG_WERROR)$(CONFIG_DRM_WERROR),-Werror) $<; \ 249 249 touch $@ 250 250 251 251 $(obj)/%.hdrtest: $(src)/%.h FORCE
+4
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
··· 1267 1267 1268 1268 (void)amdgpu_vm_bo_unmap(adev, bo_va, entry->va); 1269 1269 1270 + /* VM entity stopped if process killed, don't clear freed pt bo */ 1271 + if (!amdgpu_vm_ready(vm)) 1272 + return 0; 1273 + 1270 1274 (void)amdgpu_vm_clear_freed(adev, vm, &bo_va->last_pt_update); 1271 1275 1272 1276 (void)amdgpu_sync_fence(sync, bo_va->last_pt_update, GFP_KERNEL);
+1 -1
drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
··· 236 236 r = amdgpu_xcp_select_scheds(adev, hw_ip, hw_prio, fpriv, 237 237 &num_scheds, &scheds); 238 238 if (r) 239 - goto cleanup_entity; 239 + goto error_free_entity; 240 240 } 241 241 242 242 /* disable load balance if the hw engine retains context among dependent jobs */
-4
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
··· 5243 5243 if (amdgpu_sriov_vf(adev)) 5244 5244 amdgpu_virt_release_full_gpu(adev, false); 5245 5245 5246 - r = amdgpu_dpm_notify_rlc_state(adev, false); 5247 - if (r) 5248 - return r; 5249 - 5250 5246 return 0; 5251 5247 } 5252 5248
+12
drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c
··· 82 82 struct amdgpu_bo *bo = gem_to_amdgpu_bo(obj); 83 83 struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev); 84 84 85 + /* 86 + * Disable peer-to-peer access for DCC-enabled VRAM surfaces on GFX12+. 87 + * Such buffers cannot be safely accessed over P2P due to device-local 88 + * compression metadata. Fallback to system-memory path instead. 89 + * Device supports GFX12 (GC 12.x or newer) 90 + * BO was created with the AMDGPU_GEM_CREATE_GFX12_DCC flag 91 + * 92 + */ 93 + if (amdgpu_ip_version(adev, GC_HWIP, 0) >= IP_VERSION(12, 0, 0) && 94 + bo->flags & AMDGPU_GEM_CREATE_GFX12_DCC) 95 + attach->peer2peer = false; 96 + 85 97 if (!amdgpu_dmabuf_is_xgmi_accessible(attach_adev, bo) && 86 98 pci_p2pdma_distance(adev->pdev, attach->dev, false) < 0) 87 99 attach->peer2peer = false;
+7 -2
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
··· 2632 2632 { 2633 2633 struct drm_device *drm_dev = dev_get_drvdata(dev); 2634 2634 struct amdgpu_device *adev = drm_to_adev(drm_dev); 2635 + int r; 2635 2636 2636 - if (amdgpu_acpi_should_gpu_reset(adev)) 2637 - return amdgpu_asic_reset(adev); 2637 + if (amdgpu_acpi_should_gpu_reset(adev)) { 2638 + amdgpu_device_lock_reset_domain(adev->reset_domain); 2639 + r = amdgpu_asic_reset(adev); 2640 + amdgpu_device_unlock_reset_domain(adev->reset_domain); 2641 + return r; 2642 + } 2638 2643 2639 2644 return 0; 2640 2645 }
+2
drivers/gpu/drm/amd/amdgpu/amdgpu_isp.c
··· 280 280 if (ret) 281 281 return ret; 282 282 283 + /* Ensure *bo is NULL so a new BO will be created */ 284 + *bo = NULL; 283 285 ret = amdgpu_bo_create_kernel(adev, 284 286 size, 285 287 ISP_MC_ADDR_ALIGN,
+4 -1
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
··· 2355 2355 if (!ret && !psp->securedisplay_context.context.resp_status) { 2356 2356 psp->securedisplay_context.context.initialized = true; 2357 2357 mutex_init(&psp->securedisplay_context.mutex); 2358 - } else 2358 + } else { 2359 + /* don't try again */ 2360 + psp->securedisplay_context.context.bin_desc.size_bytes = 0; 2359 2361 return ret; 2362 + } 2360 2363 2361 2364 mutex_lock(&psp->securedisplay_context.mutex); 2362 2365
+3 -2
drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c
··· 151 151 { 152 152 struct amdgpu_userq_fence *userq_fence, *tmp; 153 153 struct dma_fence *fence; 154 + unsigned long flags; 154 155 u64 rptr; 155 156 int i; 156 157 157 158 if (!fence_drv) 158 159 return; 159 160 161 + spin_lock_irqsave(&fence_drv->fence_list_lock, flags); 160 162 rptr = amdgpu_userq_fence_read(fence_drv); 161 163 162 - spin_lock(&fence_drv->fence_list_lock); 163 164 list_for_each_entry_safe(userq_fence, tmp, &fence_drv->fences, link) { 164 165 fence = &userq_fence->base; 165 166 ··· 175 174 list_del(&userq_fence->link); 176 175 dma_fence_put(fence); 177 176 } 178 - spin_unlock(&fence_drv->fence_list_lock); 177 + spin_unlock_irqrestore(&fence_drv->fence_list_lock, flags); 179 178 } 180 179 181 180 void amdgpu_userq_fence_driver_destroy(struct kref *ref)
+2 -1
drivers/gpu/drm/amd/amdgpu/aqua_vanjaram.c
··· 407 407 return -EINVAL; 408 408 } 409 409 410 - if (adev->kfd.init_complete && !amdgpu_in_reset(adev)) 410 + if (adev->kfd.init_complete && !amdgpu_in_reset(adev) && 411 + !adev->in_suspend) 411 412 flags |= AMDGPU_XCP_OPS_KFD; 412 413 413 414 if (flags & AMDGPU_XCP_OPS_KFD) {
+5
drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c
··· 3102 3102 return r; 3103 3103 } 3104 3104 3105 + adev->gfx.gfx_supported_reset = 3106 + amdgpu_get_soft_full_reset_mask(&adev->gfx.gfx_ring[0]); 3107 + adev->gfx.compute_supported_reset = 3108 + amdgpu_get_soft_full_reset_mask(&adev->gfx.compute_ring[0]); 3109 + 3105 3110 return r; 3106 3111 } 3107 3112
+5
drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c
··· 4399 4399 4400 4400 gfx_v7_0_gpu_early_init(adev); 4401 4401 4402 + adev->gfx.gfx_supported_reset = 4403 + amdgpu_get_soft_full_reset_mask(&adev->gfx.gfx_ring[0]); 4404 + adev->gfx.compute_supported_reset = 4405 + amdgpu_get_soft_full_reset_mask(&adev->gfx.compute_ring[0]); 4406 + 4402 4407 return r; 4403 4408 } 4404 4409
+5
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
··· 2023 2023 if (r) 2024 2024 return r; 2025 2025 2026 + adev->gfx.gfx_supported_reset = 2027 + amdgpu_get_soft_full_reset_mask(&adev->gfx.gfx_ring[0]); 2028 + adev->gfx.compute_supported_reset = 2029 + amdgpu_get_soft_full_reset_mask(&adev->gfx.compute_ring[0]); 2030 + 2026 2031 return 0; 2027 2032 } 2028 2033
+3 -1
drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c
··· 2292 2292 r = amdgpu_xcp_init(adev->xcp_mgr, num_xcp, mode); 2293 2293 2294 2294 } else { 2295 - if (amdgpu_xcp_query_partition_mode(adev->xcp_mgr, 2295 + if (adev->in_suspend) 2296 + amdgpu_xcp_restore_partition_mode(adev->xcp_mgr); 2297 + else if (amdgpu_xcp_query_partition_mode(adev->xcp_mgr, 2296 2298 AMDGPU_XCP_FL_NONE) == 2297 2299 AMDGPU_UNKNOWN_COMPUTE_PARTITION_MODE) 2298 2300 r = amdgpu_xcp_switch_partition_mode(
+1
drivers/gpu/drm/amd/amdgpu/jpeg_v5_0_1.c
··· 878 878 .get_rptr = jpeg_v5_0_1_dec_ring_get_rptr, 879 879 .get_wptr = jpeg_v5_0_1_dec_ring_get_wptr, 880 880 .set_wptr = jpeg_v5_0_1_dec_ring_set_wptr, 881 + .parse_cs = amdgpu_jpeg_dec_parse_cs, 881 882 .emit_frame_size = 882 883 SOC15_FLUSH_GPU_TLB_NUM_WREG * 6 + 883 884 SOC15_FLUSH_GPU_TLB_NUM_REG_WAIT * 8 +
+25 -1
drivers/gpu/drm/amd/amdgpu/psp_v11_0.c
··· 142 142 return err; 143 143 } 144 144 145 + static int psp_v11_wait_for_tos_unload(struct psp_context *psp) 146 + { 147 + struct amdgpu_device *adev = psp->adev; 148 + uint32_t sol_reg1, sol_reg2; 149 + int retry_loop; 150 + 151 + /* Wait for the TOS to be unloaded */ 152 + for (retry_loop = 0; retry_loop < 20; retry_loop++) { 153 + sol_reg1 = RREG32_SOC15(MP0, 0, mmMP0_SMN_C2PMSG_81); 154 + usleep_range(1000, 2000); 155 + sol_reg2 = RREG32_SOC15(MP0, 0, mmMP0_SMN_C2PMSG_81); 156 + if (sol_reg1 == sol_reg2) 157 + return 0; 158 + } 159 + dev_err(adev->dev, "TOS unload failed, C2PMSG_33: %x C2PMSG_81: %x", 160 + RREG32_SOC15(MP0, 0, mmMP0_SMN_C2PMSG_33), 161 + RREG32_SOC15(MP0, 0, mmMP0_SMN_C2PMSG_81)); 162 + 163 + return -ETIME; 164 + } 165 + 145 166 static int psp_v11_0_wait_for_bootloader(struct psp_context *psp) 146 167 { 147 168 struct amdgpu_device *adev = psp->adev; 148 - 149 169 int ret; 150 170 int retry_loop; 171 + 172 + /* For a reset done at the end of S3, only wait for TOS to be unloaded */ 173 + if (adev->in_s3 && !(adev->flags & AMD_IS_APU) && amdgpu_in_reset(adev)) 174 + return psp_v11_wait_for_tos_unload(psp); 151 175 152 176 for (retry_loop = 0; retry_loop < 20; retry_loop++) { 153 177 /* Wait for bootloader to signify that is
+6 -6
drivers/gpu/drm/amd/amdkfd/kfd_queue.c
··· 297 297 goto out_err_unreserve; 298 298 } 299 299 300 - if (properties->ctx_save_restore_area_size != topo_dev->node_props.cwsr_size) { 301 - pr_debug("queue cwsr size 0x%x not equal to node cwsr size 0x%x\n", 300 + if (properties->ctx_save_restore_area_size < topo_dev->node_props.cwsr_size) { 301 + pr_debug("queue cwsr size 0x%x not sufficient for node cwsr size 0x%x\n", 302 302 properties->ctx_save_restore_area_size, 303 303 topo_dev->node_props.cwsr_size); 304 304 err = -EINVAL; 305 305 goto out_err_unreserve; 306 306 } 307 307 308 - total_cwsr_size = (topo_dev->node_props.cwsr_size + topo_dev->node_props.debug_memory_size) 309 - * NUM_XCC(pdd->dev->xcc_mask); 308 + total_cwsr_size = (properties->ctx_save_restore_area_size + 309 + topo_dev->node_props.debug_memory_size) * NUM_XCC(pdd->dev->xcc_mask); 310 310 total_cwsr_size = ALIGN(total_cwsr_size, PAGE_SIZE); 311 311 312 312 err = kfd_queue_buffer_get(vm, (void *)properties->ctx_save_restore_area_address, ··· 352 352 topo_dev = kfd_topology_device_by_id(pdd->dev->id); 353 353 if (!topo_dev) 354 354 return -EINVAL; 355 - total_cwsr_size = (topo_dev->node_props.cwsr_size + topo_dev->node_props.debug_memory_size) 356 - * NUM_XCC(pdd->dev->xcc_mask); 355 + total_cwsr_size = (properties->ctx_save_restore_area_size + 356 + topo_dev->node_props.debug_memory_size) * NUM_XCC(pdd->dev->xcc_mask); 357 357 total_cwsr_size = ALIGN(total_cwsr_size, PAGE_SIZE); 358 358 359 359 kfd_queue_buffer_svm_put(pdd, properties->ctx_save_restore_area_address, total_cwsr_size);
+2
drivers/gpu/drm/amd/amdkfd/kfd_svm.c
··· 3687 3687 svm_range_apply_attrs(p, prange, nattr, attrs, &update_mapping); 3688 3688 /* TODO: unmap ranges from GPU that lost access */ 3689 3689 } 3690 + update_mapping |= !p->xnack_enabled && !list_empty(&remap_list); 3691 + 3690 3692 list_for_each_entry_safe(prange, next, &remove_list, update_list) { 3691 3693 pr_debug("unlink old 0x%p prange 0x%p [0x%lx 0x%lx]\n", 3692 3694 prange->svms, prange, prange->start,
+10 -2
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
··· 3563 3563 /* Do mst topology probing after resuming cached state*/ 3564 3564 drm_connector_list_iter_begin(ddev, &iter); 3565 3565 drm_for_each_connector_iter(connector, &iter) { 3566 + bool init = false; 3566 3567 3567 3568 if (connector->connector_type == DRM_MODE_CONNECTOR_WRITEBACK) 3568 3569 continue; ··· 3573 3572 aconnector->mst_root) 3574 3573 continue; 3575 3574 3576 - drm_dp_mst_topology_queue_probe(&aconnector->mst_mgr); 3575 + scoped_guard(mutex, &aconnector->mst_mgr.lock) { 3576 + init = !aconnector->mst_mgr.mst_primary; 3577 + } 3578 + if (init) 3579 + dm_helpers_dp_mst_start_top_mgr(aconnector->dc_link->ctx, 3580 + aconnector->dc_link, false); 3581 + else 3582 + drm_dp_mst_topology_queue_probe(&aconnector->mst_mgr); 3577 3583 } 3578 3584 drm_connector_list_iter_end(&iter); 3579 3585 ··· 8038 8030 "mode %dx%d@%dHz is not native, enabling scaling\n", 8039 8031 adjusted_mode->hdisplay, adjusted_mode->vdisplay, 8040 8032 drm_mode_vrefresh(adjusted_mode)); 8041 - dm_new_connector_state->scaling = RMX_FULL; 8033 + dm_new_connector_state->scaling = RMX_ASPECT; 8042 8034 } 8043 8035 return 0; 8044 8036 }
+2 -1
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c
··· 1302 1302 if (connector->status != connector_status_connected) 1303 1303 return -ENODEV; 1304 1304 1305 - if (pipe_ctx != NULL && pipe_ctx->stream_res.tg->funcs->get_odm_combine_segments) 1305 + if (pipe_ctx && pipe_ctx->stream_res.tg && 1306 + pipe_ctx->stream_res.tg->funcs->get_odm_combine_segments) 1306 1307 pipe_ctx->stream_res.tg->funcs->get_odm_combine_segments(pipe_ctx->stream_res.tg, &segments); 1307 1308 1308 1309 seq_printf(m, "%d\n", segments);
+11
drivers/gpu/drm/amd/display/modules/freesync/freesync.c
··· 1260 1260 update_v_total_for_static_ramp( 1261 1261 core_freesync, stream, in_out_vrr); 1262 1262 } 1263 + 1264 + /* 1265 + * If VRR is inactive, set vtotal min and max to nominal vtotal 1266 + */ 1267 + if (in_out_vrr->state == VRR_STATE_INACTIVE) { 1268 + in_out_vrr->adjust.v_total_min = 1269 + mod_freesync_calc_v_total_from_refresh(stream, 1270 + in_out_vrr->max_refresh_in_uhz); 1271 + in_out_vrr->adjust.v_total_max = in_out_vrr->adjust.v_total_min; 1272 + return; 1273 + } 1263 1274 } 1264 1275 1265 1276 unsigned long long mod_freesync_calc_nominal_field_rate(
-18
drivers/gpu/drm/amd/pm/amdgpu_dpm.c
··· 195 195 return ret; 196 196 } 197 197 198 - int amdgpu_dpm_notify_rlc_state(struct amdgpu_device *adev, bool en) 199 - { 200 - int ret = 0; 201 - const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs; 202 - 203 - if (pp_funcs && pp_funcs->notify_rlc_state) { 204 - mutex_lock(&adev->pm.mutex); 205 - 206 - ret = pp_funcs->notify_rlc_state( 207 - adev->powerplay.pp_handle, 208 - en); 209 - 210 - mutex_unlock(&adev->pm.mutex); 211 - } 212 - 213 - return ret; 214 - } 215 - 216 198 int amdgpu_dpm_is_baco_supported(struct amdgpu_device *adev) 217 199 { 218 200 const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs;
+2 -2
drivers/gpu/drm/amd/pm/amdgpu_pm.c
··· 4724 4724 ret = devm_device_add_group(adev->dev, 4725 4725 &amdgpu_pm_policy_attr_group); 4726 4726 if (ret) 4727 - goto err_out0; 4727 + goto err_out1; 4728 4728 } 4729 4729 4730 4730 if (amdgpu_dpm_is_temp_metrics_supported(adev, SMU_TEMP_METRIC_GPUBOARD)) { 4731 4731 ret = devm_device_add_group(adev->dev, 4732 4732 &amdgpu_board_attr_group); 4733 4733 if (ret) 4734 - goto err_out0; 4734 + goto err_out1; 4735 4735 if (amdgpu_pm_get_sensor_generic(adev, AMDGPU_PP_SENSOR_MAXNODEPOWERLIMIT, 4736 4736 (void *)&tmp) != -EOPNOTSUPP) { 4737 4737 sysfs_add_file_to_group(&adev->dev->kobj,
-2
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h
··· 424 424 int amdgpu_dpm_set_mp1_state(struct amdgpu_device *adev, 425 425 enum pp_mp1_state mp1_state); 426 426 427 - int amdgpu_dpm_notify_rlc_state(struct amdgpu_device *adev, bool en); 428 - 429 427 int amdgpu_dpm_set_gfx_power_up_by_imu(struct amdgpu_device *adev); 430 428 431 429 int amdgpu_dpm_baco_exit(struct amdgpu_device *adev);
+6
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
··· 2040 2040 smu->is_apu && (amdgpu_in_reset(adev) || adev->in_s0ix)) 2041 2041 return 0; 2042 2042 2043 + /* vangogh s0ix */ 2044 + if ((amdgpu_ip_version(adev, MP1_HWIP, 0) == IP_VERSION(11, 5, 0) || 2045 + amdgpu_ip_version(adev, MP1_HWIP, 0) == IP_VERSION(11, 5, 2)) && 2046 + adev->in_s0ix) 2047 + return 0; 2048 + 2043 2049 /* 2044 2050 * For gpu reset, runpm and hibernation through BACO, 2045 2051 * BACO feature has to be kept enabled.
+3
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c
··· 2217 2217 uint32_t total_cu = adev->gfx.config.max_cu_per_sh * 2218 2218 adev->gfx.config.max_sh_per_se * adev->gfx.config.max_shader_engines; 2219 2219 2220 + if (adev->in_s0ix) 2221 + return 0; 2222 + 2220 2223 /* allow message will be sent after enable message on Vangogh*/ 2221 2224 if (smu_cmn_feature_is_enabled(smu, SMU_FEATURE_DPM_GFXCLK_BIT) && 2222 2225 (adev->pg_flags & AMD_PG_SUPPORT_GFX_PG)) {
+2 -2
drivers/gpu/drm/clients/drm_client_setup.c
··· 13 13 static char drm_client_default[16] = CONFIG_DRM_CLIENT_DEFAULT; 14 14 module_param_string(active, drm_client_default, sizeof(drm_client_default), 0444); 15 15 MODULE_PARM_DESC(active, 16 - "Choose which drm client to start, default is" 17 - CONFIG_DRM_CLIENT_DEFAULT "]"); 16 + "Choose which drm client to start, default is " 17 + CONFIG_DRM_CLIENT_DEFAULT); 18 18 19 19 /** 20 20 * drm_client_setup() - Setup in-kernel DRM clients
+1 -1
drivers/gpu/drm/i915/Makefile
··· 413 413 # 414 414 # Enable locally for CONFIG_DRM_I915_WERROR=y. See also scripts/Makefile.build 415 415 ifdef CONFIG_DRM_I915_WERROR 416 - cmd_checkdoc = PYTHONDONTWRITEBYTECODE=1 $(KERNELDOC) -none -Werror $< 416 + cmd_checkdoc = PYTHONDONTWRITEBYTECODE=1 $(PYTHON3) $(KERNELDOC) -none -Werror $< 417 417 endif 418 418 419 419 # header test
+6 -1
drivers/gpu/drm/i915/display/intel_psr.c
··· 585 585 struct intel_display *display = to_intel_display(intel_dp); 586 586 int ret; 587 587 588 + /* TODO: Enable Panel Replay on MST once it's properly implemented. */ 589 + if (intel_dp->mst_detect == DRM_DP_MST) 590 + return; 591 + 588 592 ret = drm_dp_dpcd_read_data(&intel_dp->aux, DP_PANEL_REPLAY_CAP_SUPPORT, 589 593 &intel_dp->pr_dpcd, sizeof(intel_dp->pr_dpcd)); 590 594 if (ret < 0) ··· 892 888 { 893 889 struct intel_display *display = to_intel_display(intel_dp); 894 890 u32 current_dc_state = intel_display_power_get_current_dc_state(display); 895 - struct drm_vblank_crtc *vblank = &display->drm->vblank[intel_dp->psr.pipe]; 891 + struct intel_crtc *crtc = intel_crtc_for_pipe(display, intel_dp->psr.pipe); 892 + struct drm_vblank_crtc *vblank = drm_crtc_vblank_crtc(&crtc->base); 896 893 897 894 return (current_dc_state != DC_STATE_EN_UPTO_DC5 && 898 895 current_dc_state != DC_STATE_EN_UPTO_DC6) ||
+2 -2
drivers/gpu/drm/i915/gt/intel_gt_clock_utils.c
··· 205 205 206 206 u64 intel_gt_clock_interval_to_ns(const struct intel_gt *gt, u64 count) 207 207 { 208 - return div_u64_roundup(count * NSEC_PER_SEC, gt->clock_frequency); 208 + return mul_u64_u32_div(count, NSEC_PER_SEC, gt->clock_frequency); 209 209 } 210 210 211 211 u64 intel_gt_pm_interval_to_ns(const struct intel_gt *gt, u64 count) ··· 215 215 216 216 u64 intel_gt_ns_to_clock_interval(const struct intel_gt *gt, u64 ns) 217 217 { 218 - return div_u64_roundup(gt->clock_frequency * ns, NSEC_PER_SEC); 218 + return mul_u64_u32_div(ns, gt->clock_frequency, NSEC_PER_SEC); 219 219 } 220 220 221 221 u64 intel_gt_ns_to_pm_interval(const struct intel_gt *gt, u64 ns)
+14 -2
drivers/gpu/drm/i915/i915_vma.c
··· 1595 1595 err_vma_res: 1596 1596 i915_vma_resource_free(vma_res); 1597 1597 err_fence: 1598 - if (work) 1599 - dma_fence_work_commit_imm(&work->base); 1598 + if (work) { 1599 + /* 1600 + * When pinning VMA to GGTT on CHV or BXT with VTD enabled, 1601 + * commit VMA binding asynchronously to avoid risk of lock 1602 + * inversion among reservation_ww locks held here and 1603 + * cpu_hotplug_lock acquired from stop_machine(), which we 1604 + * wrap around GGTT updates when running in those environments. 1605 + */ 1606 + if (i915_vma_is_ggtt(vma) && 1607 + intel_vm_no_concurrent_access_wa(vma->vm->i915)) 1608 + dma_fence_work_commit(&work->base); 1609 + else 1610 + dma_fence_work_commit_imm(&work->base); 1611 + } 1600 1612 err_rpm: 1601 1613 intel_runtime_pm_put(&vma->vm->i915->runtime_pm, wakeref); 1602 1614
+1
drivers/gpu/drm/imagination/Kconfig
··· 7 7 depends on DRM 8 8 depends on MMU 9 9 depends on PM 10 + depends on POWER_SEQUENCING || !POWER_SEQUENCING 10 11 select DRM_EXEC 11 12 select DRM_GEM_SHMEM_HELPER 12 13 select DRM_SCHED
+7
drivers/gpu/drm/mediatek/mtk_crtc.c
··· 283 283 unsigned int i; 284 284 unsigned long flags; 285 285 286 + /* release GCE HW usage and start autosuspend */ 287 + pm_runtime_mark_last_busy(cmdq_cl->chan->mbox->dev); 288 + pm_runtime_put_autosuspend(cmdq_cl->chan->mbox->dev); 289 + 286 290 if (data->sta < 0) 287 291 return; 288 292 ··· 621 617 spin_lock_irqsave(&mtk_crtc->config_lock, flags); 622 618 mtk_crtc->config_updating = false; 623 619 spin_unlock_irqrestore(&mtk_crtc->config_lock, flags); 620 + 621 + if (pm_runtime_resume_and_get(mtk_crtc->cmdq_client.chan->mbox->dev) < 0) 622 + goto update_config_out; 624 623 625 624 mbox_send_message(mtk_crtc->cmdq_client.chan, cmdq_handle); 626 625 mbox_client_txdone(mtk_crtc->cmdq_client.chan, 0);
+1 -23
drivers/gpu/drm/mediatek/mtk_plane.c
··· 21 21 22 22 static const u64 modifiers[] = { 23 23 DRM_FORMAT_MOD_LINEAR, 24 - DRM_FORMAT_MOD_ARM_AFBC(AFBC_FORMAT_MOD_BLOCK_SIZE_32x8 | 25 - AFBC_FORMAT_MOD_SPLIT | 26 - AFBC_FORMAT_MOD_SPARSE), 27 24 DRM_FORMAT_MOD_INVALID, 28 25 }; 29 26 ··· 68 71 uint32_t format, 69 72 uint64_t modifier) 70 73 { 71 - if (modifier == DRM_FORMAT_MOD_LINEAR) 72 - return true; 73 - 74 - if (modifier != DRM_FORMAT_MOD_ARM_AFBC( 75 - AFBC_FORMAT_MOD_BLOCK_SIZE_32x8 | 76 - AFBC_FORMAT_MOD_SPLIT | 77 - AFBC_FORMAT_MOD_SPARSE)) 78 - return false; 79 - 80 - if (format != DRM_FORMAT_XRGB8888 && 81 - format != DRM_FORMAT_ARGB8888 && 82 - format != DRM_FORMAT_BGRX8888 && 83 - format != DRM_FORMAT_BGRA8888 && 84 - format != DRM_FORMAT_ABGR8888 && 85 - format != DRM_FORMAT_XBGR8888 && 86 - format != DRM_FORMAT_RGB888 && 87 - format != DRM_FORMAT_BGR888) 88 - return false; 89 - 90 - return true; 74 + return modifier == DRM_FORMAT_MOD_LINEAR; 91 75 } 92 76 93 77 static void mtk_plane_destroy_state(struct drm_plane *plane,
+3 -1
drivers/gpu/drm/nouveau/dispnv50/disp.c
··· 2867 2867 } 2868 2868 2869 2869 /* Assign the correct format modifiers */ 2870 - if (disp->disp->object.oclass >= TU102_DISP) 2870 + if (disp->disp->object.oclass >= GB202_DISP) 2871 + nouveau_display(dev)->format_modifiers = wndwca7e_modifiers; 2872 + else if (disp->disp->object.oclass >= TU102_DISP) 2871 2873 nouveau_display(dev)->format_modifiers = wndwc57e_modifiers; 2872 2874 else 2873 2875 if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_FERMI)
+1
drivers/gpu/drm/nouveau/dispnv50/disp.h
··· 104 104 extern const u64 disp50xx_modifiers[]; 105 105 extern const u64 disp90xx_modifiers[]; 106 106 extern const u64 wndwc57e_modifiers[]; 107 + extern const u64 wndwca7e_modifiers[]; 107 108 #endif
+22 -2
drivers/gpu/drm/nouveau/dispnv50/wndw.c
··· 786 786 } 787 787 788 788 /* This function assumes the format has already been validated against the plane 789 - * and the modifier was validated against the device-wides modifier list at FB 789 + * and the modifier was validated against the device-wide modifier list at FB 790 790 * creation time. 791 791 */ 792 792 static bool nv50_plane_format_mod_supported(struct drm_plane *plane, 793 793 u32 format, u64 modifier) 794 794 { 795 795 struct nouveau_drm *drm = nouveau_drm(plane->dev); 796 + const struct drm_format_info *info = drm_format_info(format); 796 797 uint8_t i; 797 798 798 799 /* All chipsets can display all formats in linear layout */ ··· 801 800 return true; 802 801 803 802 if (drm->client.device.info.chipset < 0xc0) { 804 - const struct drm_format_info *info = drm_format_info(format); 805 803 const uint8_t kind = (modifier >> 12) & 0xff; 806 804 807 805 if (!format) return false; 808 806 809 807 for (i = 0; i < info->num_planes; i++) 810 808 if ((info->cpp[i] != 4) && kind != 0x70) return false; 809 + } else if (drm->client.device.info.chipset >= 0x1b2) { 810 + const uint8_t slayout = ((modifier >> 22) & 0x1) | 811 + ((modifier >> 25) & 0x6); 812 + 813 + if (!format) 814 + return false; 815 + 816 + /* 817 + * Note in practice this implies only formats where cpp is equal 818 + * for each plane, or >= 4 for all planes, are supported. 819 + */ 820 + for (i = 0; i < info->num_planes; i++) { 821 + if (((info->cpp[i] == 2) && slayout != 3) || 822 + ((info->cpp[i] == 1) && slayout != 2) || 823 + ((info->cpp[i] >= 4) && slayout != 1)) 824 + return false; 825 + 826 + /* 24-bit not supported. It has yet another layout */ 827 + WARN_ON(info->cpp[i] == 3); 828 + } 811 829 } 812 830 813 831 return true;
+33
drivers/gpu/drm/nouveau/dispnv50/wndwca7e.c
··· 179 179 return 0; 180 180 } 181 181 182 + /**************************************************************** 183 + * Log2(block height) ----------------------------+ * 184 + * Page Kind ----------------------------------+ | * 185 + * Gob Height/Page Kind Generation ------+ | | * 186 + * Sector layout -------+ | | | * 187 + * Compression ------+ | | | | */ 188 + const u64 wndwca7e_modifiers[] = { /* | | | | | */ 189 + /* 4cpp+ modifiers */ 190 + DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 1, 2, 0x06, 0), 191 + DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 1, 2, 0x06, 1), 192 + DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 1, 2, 0x06, 2), 193 + DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 1, 2, 0x06, 3), 194 + DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 1, 2, 0x06, 4), 195 + DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 1, 2, 0x06, 5), 196 + /* 1cpp/8bpp modifiers */ 197 + DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 2, 2, 0x06, 0), 198 + DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 2, 2, 0x06, 1), 199 + DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 2, 2, 0x06, 2), 200 + DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 2, 2, 0x06, 3), 201 + DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 2, 2, 0x06, 4), 202 + DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 2, 2, 0x06, 5), 203 + /* 2cpp/16bpp modifiers */ 204 + DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 3, 2, 0x06, 0), 205 + DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 3, 2, 0x06, 1), 206 + DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 3, 2, 0x06, 2), 207 + DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 3, 2, 0x06, 3), 208 + DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 3, 2, 0x06, 4), 209 + DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 3, 2, 0x06, 5), 210 + /* All formats support linear */ 211 + DRM_FORMAT_MOD_LINEAR, 212 + DRM_FORMAT_MOD_INVALID 213 + }; 214 + 182 215 static const struct nv50_wndw_func 183 216 wndwca7e = { 184 217 .acquire = wndwc37e_acquire,
+18
drivers/gpu/drm/panthor/panthor_gem.c
··· 288 288 289 289 panthor_gem_debugfs_set_usage_flags(bo, 0); 290 290 291 + /* If this is a write-combine mapping, we query the sgt to force a CPU 292 + * cache flush (dma_map_sgtable() is called when the sgt is created). 293 + * This ensures the zero-ing is visible to any uncached mapping created 294 + * by vmap/mmap. 295 + * FIXME: Ideally this should be done when pages are allocated, not at 296 + * BO creation time. 297 + */ 298 + if (shmem->map_wc) { 299 + struct sg_table *sgt; 300 + 301 + sgt = drm_gem_shmem_get_pages_sgt(shmem); 302 + if (IS_ERR(sgt)) { 303 + ret = PTR_ERR(sgt); 304 + goto out_put_gem; 305 + } 306 + } 307 + 291 308 /* 292 309 * Allocate an id of idr table where the obj is registered 293 310 * and handle has the id what user can see. ··· 313 296 if (!ret) 314 297 *size = bo->base.base.size; 315 298 299 + out_put_gem: 316 300 /* drop reference from allocate - handle holds it now. */ 317 301 drm_gem_object_put(&shmem->base); 318 302
+19 -15
drivers/gpu/drm/scheduler/sched_entity.c
··· 173 173 } 174 174 EXPORT_SYMBOL(drm_sched_entity_error); 175 175 176 + static void drm_sched_entity_kill_jobs_cb(struct dma_fence *f, 177 + struct dma_fence_cb *cb); 178 + 176 179 static void drm_sched_entity_kill_jobs_work(struct work_struct *wrk) 177 180 { 178 181 struct drm_sched_job *job = container_of(wrk, typeof(*job), work); 179 - 180 - drm_sched_fence_scheduled(job->s_fence, NULL); 181 - drm_sched_fence_finished(job->s_fence, -ESRCH); 182 - WARN_ON(job->s_fence->parent); 183 - job->sched->ops->free_job(job); 184 - } 185 - 186 - /* Signal the scheduler finished fence when the entity in question is killed. */ 187 - static void drm_sched_entity_kill_jobs_cb(struct dma_fence *f, 188 - struct dma_fence_cb *cb) 189 - { 190 - struct drm_sched_job *job = container_of(cb, struct drm_sched_job, 191 - finish_cb); 182 + struct dma_fence *f; 192 183 unsigned long index; 193 - 194 - dma_fence_put(f); 195 184 196 185 /* Wait for all dependencies to avoid data corruptions */ 197 186 xa_for_each(&job->dependencies, index, f) { ··· 208 219 209 220 dma_fence_put(f); 210 221 } 222 + 223 + drm_sched_fence_scheduled(job->s_fence, NULL); 224 + drm_sched_fence_finished(job->s_fence, -ESRCH); 225 + WARN_ON(job->s_fence->parent); 226 + job->sched->ops->free_job(job); 227 + } 228 + 229 + /* Signal the scheduler finished fence when the entity in question is killed. */ 230 + static void drm_sched_entity_kill_jobs_cb(struct dma_fence *f, 231 + struct dma_fence_cb *cb) 232 + { 233 + struct drm_sched_job *job = container_of(cb, struct drm_sched_job, 234 + finish_cb); 235 + 236 + dma_fence_put(f); 211 237 212 238 INIT_WORK(&job->work, drm_sched_entity_kill_jobs_work); 213 239 schedule_work(&job->work);
+1
drivers/gpu/drm/tiny/Kconfig
··· 85 85 config DRM_PIXPAPER 86 86 tristate "DRM support for PIXPAPER display panels" 87 87 depends on DRM && SPI 88 + depends on MMU 88 89 select DRM_CLIENT_SELECTION 89 90 select DRM_GEM_SHMEM_HELPER 90 91 select DRM_KMS_HELPER
+15 -1
drivers/gpu/drm/vmwgfx/vmwgfx_cursor_plane.c
··· 100 100 if (vmw->has_mob) { 101 101 if ((vmw->capabilities2 & SVGA_CAP2_CURSOR_MOB) != 0) 102 102 return VMW_CURSOR_UPDATE_MOB; 103 + else 104 + return VMW_CURSOR_UPDATE_GB_ONLY; 103 105 } 104 - 106 + drm_warn_once(&vmw->drm, "Unknown Cursor Type!\n"); 105 107 return VMW_CURSOR_UPDATE_NONE; 106 108 } 107 109 ··· 141 139 { 142 140 switch (update_type) { 143 141 case VMW_CURSOR_UPDATE_LEGACY: 142 + case VMW_CURSOR_UPDATE_GB_ONLY: 144 143 case VMW_CURSOR_UPDATE_NONE: 145 144 return 0; 146 145 case VMW_CURSOR_UPDATE_MOB: ··· 626 623 if (!surface || vps->cursor.legacy.id == surface->snooper.id) 627 624 vps->cursor.update_type = VMW_CURSOR_UPDATE_NONE; 628 625 break; 626 + case VMW_CURSOR_UPDATE_GB_ONLY: 629 627 case VMW_CURSOR_UPDATE_MOB: { 630 628 bo = vmw_user_object_buffer(&vps->uo); 631 629 if (bo) { ··· 741 737 vmw_cursor_plane_atomic_update(struct drm_plane *plane, 742 738 struct drm_atomic_state *state) 743 739 { 740 + struct vmw_bo *bo; 744 741 struct drm_plane_state *new_state = 745 742 drm_atomic_get_new_plane_state(state, plane); 746 743 struct drm_plane_state *old_state = ··· 766 761 break; 767 762 case VMW_CURSOR_UPDATE_MOB: 768 763 vmw_cursor_update_mob(dev_priv, vps); 764 + break; 765 + case VMW_CURSOR_UPDATE_GB_ONLY: 766 + bo = vmw_user_object_buffer(&vps->uo); 767 + if (bo) 768 + vmw_send_define_cursor_cmd(dev_priv, bo->map.virtual, 769 + vps->base.crtc_w, 770 + vps->base.crtc_h, 771 + vps->base.hotspot_x, 772 + vps->base.hotspot_y); 769 773 break; 770 774 case VMW_CURSOR_UPDATE_NONE: 771 775 /* do nothing */
+1
drivers/gpu/drm/vmwgfx/vmwgfx_cursor_plane.h
··· 33 33 enum vmw_cursor_update_type { 34 34 VMW_CURSOR_UPDATE_NONE = 0, 35 35 VMW_CURSOR_UPDATE_LEGACY, 36 + VMW_CURSOR_UPDATE_GB_ONLY, 36 37 VMW_CURSOR_UPDATE_MOB, 37 38 }; 38 39
+5
drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
··· 3668 3668 3669 3669 3670 3670 cmd_id = header->id; 3671 + if (header->size > SVGA_CMD_MAX_DATASIZE) { 3672 + VMW_DEBUG_USER("SVGA3D command: %d is too big.\n", 3673 + cmd_id + SVGA_3D_CMD_BASE); 3674 + return -E2BIG; 3675 + } 3671 3676 *size = header->size + sizeof(SVGA3dCmdHeader); 3672 3677 3673 3678 cmd_id -= SVGA_3D_CMD_BASE;
+5 -7
drivers/gpu/drm/vmwgfx/vmwgfx_page_dirty.c
··· 32 32 33 33 /** 34 34 * struct vmw_bo_dirty - Dirty information for buffer objects 35 + * @ref_count: Reference count for this structure. Must be first member! 35 36 * @start: First currently dirty bit 36 37 * @end: Last currently dirty bit + 1 37 38 * @method: The currently used dirty method 38 39 * @change_count: Number of consecutive method change triggers 39 - * @ref_count: Reference count for this structure 40 40 * @bitmap_size: The size of the bitmap in bits. Typically equal to the 41 41 * nuber of pages in the bo. 42 42 * @bitmap: A bitmap where each bit represents a page. A set bit means a 43 43 * dirty page. 44 44 */ 45 45 struct vmw_bo_dirty { 46 + struct kref ref_count; 46 47 unsigned long start; 47 48 unsigned long end; 48 49 enum vmw_bo_dirty_method method; 49 50 unsigned int change_count; 50 - unsigned int ref_count; 51 51 unsigned long bitmap_size; 52 52 unsigned long bitmap[]; 53 53 }; ··· 221 221 int ret; 222 222 223 223 if (dirty) { 224 - dirty->ref_count++; 224 + kref_get(&dirty->ref_count); 225 225 return 0; 226 226 } 227 227 ··· 235 235 dirty->bitmap_size = num_pages; 236 236 dirty->start = dirty->bitmap_size; 237 237 dirty->end = 0; 238 - dirty->ref_count = 1; 238 + kref_init(&dirty->ref_count); 239 239 if (num_pages < PAGE_SIZE / sizeof(pte_t)) { 240 240 dirty->method = VMW_BO_DIRTY_PAGETABLE; 241 241 } else { ··· 274 274 { 275 275 struct vmw_bo_dirty *dirty = vbo->dirty; 276 276 277 - if (dirty && --dirty->ref_count == 0) { 278 - kvfree(dirty); 277 + if (dirty && kref_put(&dirty->ref_count, (void *)kvfree)) 279 278 vbo->dirty = NULL; 280 - } 281 279 } 282 280 283 281 /**
+1
drivers/gpu/drm/xe/regs/xe_gt_regs.h
··· 168 168 169 169 #define XEHP_SLICE_COMMON_ECO_CHICKEN1 XE_REG_MCR(0x731c, XE_REG_OPTION_MASKED) 170 170 #define MSC_MSAA_REODER_BUF_BYPASS_DISABLE REG_BIT(14) 171 + #define FAST_CLEAR_VALIGN_FIX REG_BIT(13) 171 172 172 173 #define XE2LPM_CCCHKNREG1 XE_REG(0x82a8) 173 174
+7 -7
drivers/gpu/drm/xe/xe_device.c
··· 988 988 989 989 drm_dbg(&xe->drm, "Shutting down device\n"); 990 990 991 - if (xe_driver_flr_disabled(xe)) { 992 - xe_display_pm_shutdown(xe); 991 + xe_display_pm_shutdown(xe); 993 992 994 - xe_irq_suspend(xe); 993 + xe_irq_suspend(xe); 995 994 996 - for_each_gt(gt, xe, id) 997 - xe_gt_shutdown(gt); 995 + for_each_gt(gt, xe, id) 996 + xe_gt_shutdown(gt); 998 997 999 - xe_display_pm_shutdown_late(xe); 1000 - } else { 998 + xe_display_pm_shutdown_late(xe); 999 + 1000 + if (!xe_driver_flr_disabled(xe)) { 1001 1001 /* BOOM! */ 1002 1002 __xe_driver_flr(xe); 1003 1003 }
+2 -1
drivers/gpu/drm/xe/xe_exec.c
··· 165 165 166 166 for (num_syncs = 0; num_syncs < args->num_syncs; num_syncs++) { 167 167 err = xe_sync_entry_parse(xe, xef, &syncs[num_syncs], 168 - &syncs_user[num_syncs], SYNC_PARSE_FLAG_EXEC | 168 + &syncs_user[num_syncs], NULL, 0, 169 + SYNC_PARSE_FLAG_EXEC | 169 170 (xe_vm_in_lr_mode(vm) ? 170 171 SYNC_PARSE_FLAG_LR_MODE : 0)); 171 172 if (err)
+14
drivers/gpu/drm/xe/xe_exec_queue.c
··· 10 10 #include <drm/drm_device.h> 11 11 #include <drm/drm_drv.h> 12 12 #include <drm/drm_file.h> 13 + #include <drm/drm_syncobj.h> 13 14 #include <uapi/drm/xe_drm.h> 14 15 15 16 #include "xe_dep_scheduler.h" ··· 325 324 } 326 325 xe_vm_put(migrate_vm); 327 326 327 + if (!IS_ERR(q)) { 328 + int err = drm_syncobj_create(&q->ufence_syncobj, 329 + DRM_SYNCOBJ_CREATE_SIGNALED, 330 + NULL); 331 + if (err) { 332 + xe_exec_queue_put(q); 333 + return ERR_PTR(err); 334 + } 335 + } 336 + 328 337 return q; 329 338 } 330 339 ALLOW_ERROR_INJECTION(xe_exec_queue_create_bind, ERRNO); ··· 343 332 { 344 333 struct xe_exec_queue *q = container_of(ref, struct xe_exec_queue, refcount); 345 334 struct xe_exec_queue *eq, *next; 335 + 336 + if (q->ufence_syncobj) 337 + drm_syncobj_put(q->ufence_syncobj); 346 338 347 339 if (xe_exec_queue_uses_pxp(q)) 348 340 xe_pxp_exec_queue_remove(gt_to_xe(q->gt)->pxp, q);
+7
drivers/gpu/drm/xe/xe_exec_queue_types.h
··· 15 15 #include "xe_hw_fence_types.h" 16 16 #include "xe_lrc_types.h" 17 17 18 + struct drm_syncobj; 18 19 struct xe_execlist_exec_queue; 19 20 struct xe_gt; 20 21 struct xe_guc_exec_queue; ··· 155 154 /** @pxp.link: link into the list of PXP exec queues */ 156 155 struct list_head link; 157 156 } pxp; 157 + 158 + /** @ufence_syncobj: User fence syncobj */ 159 + struct drm_syncobj *ufence_syncobj; 160 + 161 + /** @ufence_timeline_value: User fence timeline value */ 162 + u64 ufence_timeline_value; 158 163 159 164 /** @ops: submission backend exec queue operations */ 160 165 const struct xe_exec_queue_ops *ops;
+3
drivers/gpu/drm/xe/xe_guc_ct.c
··· 200 200 { 201 201 struct xe_guc_ct *ct = arg; 202 202 203 + #if IS_ENABLED(CONFIG_DRM_XE_DEBUG) 204 + cancel_work_sync(&ct->dead.worker); 205 + #endif 203 206 ct_exit_safe_mode(ct); 204 207 destroy_workqueue(ct->g2h_wq); 205 208 xa_destroy(&ct->fence_lookup);
+30 -15
drivers/gpu/drm/xe/xe_oa.c
··· 10 10 11 11 #include <drm/drm_drv.h> 12 12 #include <drm/drm_managed.h> 13 + #include <drm/drm_syncobj.h> 13 14 #include <uapi/drm/xe_drm.h> 14 15 15 16 #include <generated/xe_wa_oob.h> ··· 1390 1389 return 0; 1391 1390 } 1392 1391 1393 - static int xe_oa_parse_syncs(struct xe_oa *oa, struct xe_oa_open_param *param) 1392 + static int xe_oa_parse_syncs(struct xe_oa *oa, 1393 + struct xe_oa_stream *stream, 1394 + struct xe_oa_open_param *param) 1394 1395 { 1395 1396 int ret, num_syncs, num_ufence = 0; 1396 1397 ··· 1412 1409 1413 1410 for (num_syncs = 0; num_syncs < param->num_syncs; num_syncs++) { 1414 1411 ret = xe_sync_entry_parse(oa->xe, param->xef, &param->syncs[num_syncs], 1415 - &param->syncs_user[num_syncs], 0); 1412 + &param->syncs_user[num_syncs], 1413 + stream->ufence_syncobj, 1414 + ++stream->ufence_timeline_value, 0); 1416 1415 if (ret) 1417 1416 goto err_syncs; 1418 1417 ··· 1544 1539 return -ENODEV; 1545 1540 1546 1541 param.xef = stream->xef; 1547 - err = xe_oa_parse_syncs(stream->oa, &param); 1542 + err = xe_oa_parse_syncs(stream->oa, stream, &param); 1548 1543 if (err) 1549 1544 goto err_config_put; 1550 1545 ··· 1640 1635 if (stream->exec_q) 1641 1636 xe_exec_queue_put(stream->exec_q); 1642 1637 1638 + drm_syncobj_put(stream->ufence_syncobj); 1643 1639 kfree(stream); 1644 1640 } 1645 1641 ··· 1832 1826 struct xe_oa_open_param *param) 1833 1827 { 1834 1828 struct xe_oa_stream *stream; 1829 + struct drm_syncobj *ufence_syncobj; 1835 1830 int stream_fd; 1836 1831 int ret; 1837 1832 ··· 1843 1836 goto exit; 1844 1837 } 1845 1838 1839 + ret = drm_syncobj_create(&ufence_syncobj, DRM_SYNCOBJ_CREATE_SIGNALED, 1840 + NULL); 1841 + if (ret) 1842 + goto exit; 1843 + 1846 1844 stream = kzalloc(sizeof(*stream), GFP_KERNEL); 1847 1845 if (!stream) { 1848 1846 ret = -ENOMEM; 1849 - goto exit; 1847 + goto err_syncobj; 1850 1848 } 1851 - 1849 + stream->ufence_syncobj = ufence_syncobj; 1852 1850 stream->oa = oa; 1853 - ret = xe_oa_stream_init(stream, param); 1851 + 1852 + ret = xe_oa_parse_syncs(oa, stream, param); 1854 1853 if (ret) 1855 1854 goto err_free; 1855 + 1856 + ret = xe_oa_stream_init(stream, param); 1857 + if (ret) { 1858 + while (param->num_syncs--) 1859 + xe_sync_entry_cleanup(&param->syncs[param->num_syncs]); 1860 + kfree(param->syncs); 1861 + goto err_free; 1862 + } 1856 1863 1857 1864 if (!param->disabled) { 1858 1865 ret = xe_oa_enable_locked(stream); ··· 1891 1870 xe_oa_stream_destroy(stream); 1892 1871 err_free: 1893 1872 kfree(stream); 1873 + err_syncobj: 1874 + drm_syncobj_put(ufence_syncobj); 1894 1875 exit: 1895 1876 return ret; 1896 1877 } ··· 2106 2083 goto err_exec_q; 2107 2084 } 2108 2085 2109 - ret = xe_oa_parse_syncs(oa, &param); 2110 - if (ret) 2111 - goto err_exec_q; 2112 - 2113 2086 mutex_lock(&param.hwe->gt->oa.gt_lock); 2114 2087 ret = xe_oa_stream_open_ioctl_locked(oa, &param); 2115 2088 mutex_unlock(&param.hwe->gt->oa.gt_lock); 2116 2089 if (ret < 0) 2117 - goto err_sync_cleanup; 2090 + goto err_exec_q; 2118 2091 2119 2092 return ret; 2120 2093 2121 - err_sync_cleanup: 2122 - while (param.num_syncs--) 2123 - xe_sync_entry_cleanup(&param.syncs[param.num_syncs]); 2124 - kfree(param.syncs); 2125 2094 err_exec_q: 2126 2095 if (param.exec_q) 2127 2096 xe_exec_queue_put(param.exec_q);
+8
drivers/gpu/drm/xe/xe_oa_types.h
··· 15 15 #include "regs/xe_reg_defs.h" 16 16 #include "xe_hw_engine_types.h" 17 17 18 + struct drm_syncobj; 19 + 18 20 #define DEFAULT_XE_OA_BUFFER_SIZE SZ_16M 19 21 20 22 enum xe_oa_report_header { ··· 249 247 250 248 /** @xef: xe_file with which the stream was opened */ 251 249 struct xe_file *xef; 250 + 251 + /** @ufence_syncobj: User fence syncobj */ 252 + struct drm_syncobj *ufence_syncobj; 253 + 254 + /** @ufence_timeline_value: User fence timeline value */ 255 + u64 ufence_timeline_value; 252 256 253 257 /** @last_fence: fence to use in stream destroy when needed */ 254 258 struct dma_fence *last_fence;
+15 -2
drivers/gpu/drm/xe/xe_sync.c
··· 113 113 int xe_sync_entry_parse(struct xe_device *xe, struct xe_file *xef, 114 114 struct xe_sync_entry *sync, 115 115 struct drm_xe_sync __user *sync_user, 116 + struct drm_syncobj *ufence_syncobj, 117 + u64 ufence_timeline_value, 116 118 unsigned int flags) 117 119 { 118 120 struct drm_xe_sync sync_in; ··· 194 192 if (exec) { 195 193 sync->addr = sync_in.addr; 196 194 } else { 195 + sync->ufence_timeline_value = ufence_timeline_value; 197 196 sync->ufence = user_fence_create(xe, sync_in.addr, 198 197 sync_in.timeline_value); 199 198 if (XE_IOCTL_DBG(xe, IS_ERR(sync->ufence))) 200 199 return PTR_ERR(sync->ufence); 200 + sync->ufence_chain_fence = dma_fence_chain_alloc(); 201 + if (!sync->ufence_chain_fence) 202 + return -ENOMEM; 203 + sync->ufence_syncobj = ufence_syncobj; 201 204 } 202 205 203 206 break; ··· 246 239 } else if (sync->ufence) { 247 240 int err; 248 241 249 - dma_fence_get(fence); 242 + drm_syncobj_add_point(sync->ufence_syncobj, 243 + sync->ufence_chain_fence, 244 + fence, sync->ufence_timeline_value); 245 + sync->ufence_chain_fence = NULL; 246 + 247 + fence = drm_syncobj_fence_get(sync->ufence_syncobj); 250 248 user_fence_get(sync->ufence); 251 249 err = dma_fence_add_callback(fence, &sync->ufence->cb, 252 250 user_fence_cb); ··· 271 259 drm_syncobj_put(sync->syncobj); 272 260 dma_fence_put(sync->fence); 273 261 dma_fence_chain_free(sync->chain_fence); 274 - if (sync->ufence) 262 + dma_fence_chain_free(sync->ufence_chain_fence); 263 + if (!IS_ERR_OR_NULL(sync->ufence)) 275 264 user_fence_put(sync->ufence); 276 265 } 277 266
+3
drivers/gpu/drm/xe/xe_sync.h
··· 8 8 9 9 #include "xe_sync_types.h" 10 10 11 + struct drm_syncobj; 11 12 struct xe_device; 12 13 struct xe_exec_queue; 13 14 struct xe_file; ··· 22 21 int xe_sync_entry_parse(struct xe_device *xe, struct xe_file *xef, 23 22 struct xe_sync_entry *sync, 24 23 struct drm_xe_sync __user *sync_user, 24 + struct drm_syncobj *ufence_syncobj, 25 + u64 ufence_timeline_value, 25 26 unsigned int flags); 26 27 int xe_sync_entry_add_deps(struct xe_sync_entry *sync, 27 28 struct xe_sched_job *job);
+3
drivers/gpu/drm/xe/xe_sync_types.h
··· 18 18 struct drm_syncobj *syncobj; 19 19 struct dma_fence *fence; 20 20 struct dma_fence_chain *chain_fence; 21 + struct dma_fence_chain *ufence_chain_fence; 22 + struct drm_syncobj *ufence_syncobj; 21 23 struct xe_user_fence *ufence; 22 24 u64 addr; 23 25 u64 timeline_value; 26 + u64 ufence_timeline_value; 24 27 u32 type; 25 28 u32 flags; 26 29 };
+4
drivers/gpu/drm/xe/xe_vm.c
··· 3606 3606 3607 3607 syncs_user = u64_to_user_ptr(args->syncs); 3608 3608 for (num_syncs = 0; num_syncs < args->num_syncs; num_syncs++) { 3609 + struct xe_exec_queue *__q = q ?: vm->q[0]; 3610 + 3609 3611 err = xe_sync_entry_parse(xe, xef, &syncs[num_syncs], 3610 3612 &syncs_user[num_syncs], 3613 + __q->ufence_syncobj, 3614 + ++__q->ufence_timeline_value, 3611 3615 (xe_vm_in_lr_mode(vm) ? 3612 3616 SYNC_PARSE_FLAG_LR_MODE : 0) | 3613 3617 (!args->num_binds ?
+11
drivers/gpu/drm/xe/xe_wa.c
··· 679 679 }, 680 680 { XE_RTP_NAME("14023061436"), 681 681 XE_RTP_RULES(GRAPHICS_VERSION_RANGE(3000, 3001), 682 + FUNC(xe_rtp_match_first_render_or_compute), OR, 683 + GRAPHICS_VERSION_RANGE(3003, 3005), 682 684 FUNC(xe_rtp_match_first_render_or_compute)), 683 685 XE_RTP_ACTIONS(SET(TDL_CHICKEN, QID_WAIT_FOR_THREAD_NOT_RUN_DISABLE)) 684 686 }, ··· 917 915 { XE_RTP_NAME("22021007897"), 918 916 XE_RTP_RULES(GRAPHICS_VERSION_RANGE(3000, 3003), ENGINE_CLASS(RENDER)), 919 917 XE_RTP_ACTIONS(SET(COMMON_SLICE_CHICKEN4, SBE_PUSH_CONSTANT_BEHIND_FIX_ENABLE)) 918 + }, 919 + { XE_RTP_NAME("14024681466"), 920 + XE_RTP_RULES(GRAPHICS_VERSION_RANGE(3000, 3005), ENGINE_CLASS(RENDER)), 921 + XE_RTP_ACTIONS(SET(XEHP_SLICE_COMMON_ECO_CHICKEN1, FAST_CLEAR_VALIGN_FIX)) 922 + }, 923 + { XE_RTP_NAME("15016589081"), 924 + XE_RTP_RULES(GRAPHICS_VERSION(3000), GRAPHICS_STEP(A0, B0), 925 + ENGINE_CLASS(RENDER)), 926 + XE_RTP_ACTIONS(SET(CHICKEN_RASTER_1, DIS_CLIP_NEGATIVE_BOUNDING_BOX)) 920 927 }, 921 928 }; 922 929
+26 -28
drivers/hwmon/gpd-fan.c
··· 12 12 * Copyright (c) 2024 Cryolitia PukNgae 13 13 */ 14 14 15 - #include <linux/acpi.h> 16 15 #include <linux/dmi.h> 17 16 #include <linux/hwmon.h> 17 + #include <linux/io.h> 18 18 #include <linux/ioport.h> 19 19 #include <linux/kernel.h> 20 20 #include <linux/module.h> ··· 276 276 return (u16)high << 8 | low; 277 277 } 278 278 279 - static void gpd_win4_init_ec(void) 280 - { 281 - u8 chip_id, chip_ver; 282 - 283 - gpd_ecram_read(0x2000, &chip_id); 284 - 285 - if (chip_id == 0x55) { 286 - gpd_ecram_read(0x1060, &chip_ver); 287 - gpd_ecram_write(0x1060, chip_ver | 0x80); 288 - } 289 - } 290 - 291 - static int gpd_win4_read_rpm(void) 292 - { 293 - int ret; 294 - 295 - ret = gpd_generic_read_rpm(); 296 - 297 - if (ret == 0) 298 - // Re-init EC when speed is 0 299 - gpd_win4_init_ec(); 300 - 301 - return ret; 302 - } 303 - 304 279 static int gpd_wm2_read_rpm(void) 305 280 { 306 281 for (u16 pwm_ctr_offset = GPD_PWM_CTR_OFFSET; ··· 295 320 static int gpd_read_rpm(void) 296 321 { 297 322 switch (gpd_driver_priv.drvdata->board) { 323 + case win4_6800u: 298 324 case win_mini: 299 325 case duo: 300 326 return gpd_generic_read_rpm(); 301 - case win4_6800u: 302 - return gpd_win4_read_rpm(); 303 327 case win_max_2: 304 328 return gpd_wm2_read_rpm(); 305 329 } ··· 581 607 .info = gpd_fan_hwmon_channel_info 582 608 }; 583 609 610 + static void gpd_win4_init_ec(void) 611 + { 612 + u8 chip_id, chip_ver; 613 + 614 + gpd_ecram_read(0x2000, &chip_id); 615 + 616 + if (chip_id == 0x55) { 617 + gpd_ecram_read(0x1060, &chip_ver); 618 + gpd_ecram_write(0x1060, chip_ver | 0x80); 619 + } 620 + } 621 + 622 + static void gpd_init_ec(void) 623 + { 624 + // The buggy firmware won't initialize EC properly on boot. 625 + // Before its initialization, reading RPM will always return 0, 626 + // and writing PWM will have no effect. 627 + // Initialize it manually on driver load. 628 + if (gpd_driver_priv.drvdata->board == win4_6800u) 629 + gpd_win4_init_ec(); 630 + } 631 + 584 632 static int gpd_fan_probe(struct platform_device *pdev) 585 633 { 586 634 struct device *dev = &pdev->dev; ··· 629 633 if (IS_ERR(hwdev)) 630 634 return dev_err_probe(dev, PTR_ERR(hwdev), 631 635 "Failed to register hwmon device\n"); 636 + 637 + gpd_init_ec(); 632 638 633 639 return 0; 634 640 }
+23 -27
drivers/i2c/muxes/i2c-mux-pca954x.c
··· 118 118 raw_spinlock_t lock; 119 119 struct regulator *supply; 120 120 121 + struct gpio_desc *reset_gpio; 121 122 struct reset_control *reset_cont; 122 123 }; 123 124 ··· 316 315 return 1 << chan; 317 316 } 318 317 319 - static void pca954x_reset_assert(struct pca954x *data) 320 - { 321 - if (data->reset_cont) 322 - reset_control_assert(data->reset_cont); 323 - } 324 - 325 - static void pca954x_reset_deassert(struct pca954x *data) 326 - { 327 - if (data->reset_cont) 328 - reset_control_deassert(data->reset_cont); 329 - } 330 - 331 - static void pca954x_reset_mux(struct pca954x *data) 332 - { 333 - pca954x_reset_assert(data); 334 - udelay(1); 335 - pca954x_reset_deassert(data); 336 - } 337 - 338 318 static int pca954x_select_chan(struct i2c_mux_core *muxc, u32 chan) 339 319 { 340 320 struct pca954x *data = i2c_mux_priv(muxc); ··· 329 347 ret = pca954x_reg_write(muxc->parent, client, regval); 330 348 data->last_chan = ret < 0 ? 0 : regval; 331 349 } 332 - if (ret == -ETIMEDOUT && data->reset_cont) 333 - pca954x_reset_mux(data); 334 350 335 351 return ret; 336 352 } ··· 338 358 struct pca954x *data = i2c_mux_priv(muxc); 339 359 struct i2c_client *client = data->client; 340 360 s32 idle_state; 341 - int ret = 0; 342 361 343 362 idle_state = READ_ONCE(data->idle_state); 344 363 if (idle_state >= 0) ··· 347 368 if (idle_state == MUX_IDLE_DISCONNECT) { 348 369 /* Deselect active channel */ 349 370 data->last_chan = 0; 350 - ret = pca954x_reg_write(muxc->parent, client, 351 - data->last_chan); 352 - if (ret == -ETIMEDOUT && data->reset_cont) 353 - pca954x_reset_mux(data); 371 + return pca954x_reg_write(muxc->parent, client, 372 + data->last_chan); 354 373 } 355 374 356 375 /* otherwise leave as-is */ ··· 527 550 if (IS_ERR(data->reset_cont)) 528 551 return dev_err_probe(dev, PTR_ERR(data->reset_cont), 529 552 "Failed to get reset\n"); 553 + else if (data->reset_cont) 554 + return 0; 555 + 556 + /* 557 + * fallback to legacy reset-gpios 558 + */ 559 + data->reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH); 560 + if (IS_ERR(data->reset_gpio)) { 561 + return dev_err_probe(dev, PTR_ERR(data->reset_gpio), 562 + "Failed to get reset gpio"); 563 + } 530 564 531 565 return 0; 566 + } 567 + 568 + static void pca954x_reset_deassert(struct pca954x *data) 569 + { 570 + if (data->reset_cont) 571 + reset_control_deassert(data->reset_cont); 572 + else 573 + gpiod_set_value_cansleep(data->reset_gpio, 0); 532 574 } 533 575 534 576 /* ··· 589 593 if (ret) 590 594 goto fail_cleanup; 591 595 592 - if (data->reset_cont) { 596 + if (data->reset_cont || data->reset_gpio) { 593 597 udelay(1); 594 598 pca954x_reset_deassert(data); 595 599 /* Give the chip some time to recover. */
+1
drivers/infiniband/core/uverbs_std_types_cq.c
··· 206 206 return ret; 207 207 208 208 err_free: 209 + ib_umem_release(umem); 209 210 rdma_restrack_put(&cq->res); 210 211 kfree(cq); 211 212 err_event_file:
+3 -8
drivers/infiniband/hw/bnxt_re/ib_verbs.c
··· 913 913 spin_unlock_irqrestore(&qp->scq->cq_lock, flags); 914 914 } 915 915 916 - static int bnxt_re_destroy_gsi_sqp(struct bnxt_re_qp *qp) 916 + static void bnxt_re_destroy_gsi_sqp(struct bnxt_re_qp *qp) 917 917 { 918 918 struct bnxt_re_qp *gsi_sqp; 919 919 struct bnxt_re_ah *gsi_sah; ··· 933 933 934 934 ibdev_dbg(&rdev->ibdev, "Destroy the shadow QP\n"); 935 935 rc = bnxt_qplib_destroy_qp(&rdev->qplib_res, &gsi_sqp->qplib_qp); 936 - if (rc) { 936 + if (rc) 937 937 ibdev_err(&rdev->ibdev, "Destroy Shadow QP failed"); 938 - goto fail; 939 - } 938 + 940 939 bnxt_qplib_free_qp_res(&rdev->qplib_res, &gsi_sqp->qplib_qp); 941 940 942 941 /* remove from active qp list */ ··· 950 951 rdev->gsi_ctx.gsi_sqp = NULL; 951 952 rdev->gsi_ctx.gsi_sah = NULL; 952 953 rdev->gsi_ctx.sqp_tbl = NULL; 953 - 954 - return 0; 955 - fail: 956 - return rc; 957 954 } 958 955 959 956 static void bnxt_re_del_unique_gid(struct bnxt_re_dev *rdev)
+7 -9
drivers/infiniband/hw/efa/efa_verbs.c
··· 1216 1216 if (umem->length < cq->size) { 1217 1217 ibdev_dbg(&dev->ibdev, "External memory too small\n"); 1218 1218 err = -EINVAL; 1219 - goto err_free_mem; 1219 + goto err_out; 1220 1220 } 1221 1221 1222 1222 if (!ib_umem_is_contiguous(umem)) { 1223 1223 ibdev_dbg(&dev->ibdev, "Non contiguous CQ unsupported\n"); 1224 1224 err = -EINVAL; 1225 - goto err_free_mem; 1225 + goto err_out; 1226 1226 } 1227 1227 1228 1228 cq->cpu_addr = NULL; ··· 1251 1251 1252 1252 err = efa_com_create_cq(&dev->edev, &params, &result); 1253 1253 if (err) 1254 - goto err_free_mem; 1254 + goto err_free_mapped; 1255 1255 1256 1256 resp.db_off = result.db_off; 1257 1257 resp.cq_idx = result.cq_idx; ··· 1299 1299 efa_cq_user_mmap_entries_remove(cq); 1300 1300 err_destroy_cq: 1301 1301 efa_destroy_cq_idx(dev, cq->cq_idx); 1302 - err_free_mem: 1303 - if (umem) 1304 - ib_umem_release(umem); 1305 - else 1306 - efa_free_mapped(dev, cq->cpu_addr, cq->dma_addr, cq->size, DMA_FROM_DEVICE); 1307 - 1302 + err_free_mapped: 1303 + if (!umem) 1304 + efa_free_mapped(dev, cq->cpu_addr, cq->dma_addr, cq->size, 1305 + DMA_FROM_DEVICE); 1308 1306 err_out: 1309 1307 atomic64_inc(&dev->stats.create_cq_err); 1310 1308 return err;
+55 -3
drivers/infiniband/hw/hns/hns_roce_cq.c
··· 30 30 * SOFTWARE. 31 31 */ 32 32 33 + #include <linux/pci.h> 33 34 #include <rdma/ib_umem.h> 34 35 #include <rdma/uverbs_ioctl.h> 35 36 #include "hns_roce_device.h" 36 37 #include "hns_roce_cmd.h" 37 38 #include "hns_roce_hem.h" 38 39 #include "hns_roce_common.h" 40 + 41 + void hns_roce_put_cq_bankid_for_uctx(struct hns_roce_ucontext *uctx) 42 + { 43 + struct hns_roce_dev *hr_dev = to_hr_dev(uctx->ibucontext.device); 44 + struct hns_roce_cq_table *cq_table = &hr_dev->cq_table; 45 + 46 + if (hr_dev->pci_dev->revision < PCI_REVISION_ID_HIP09) 47 + return; 48 + 49 + mutex_lock(&cq_table->bank_mutex); 50 + cq_table->ctx_num[uctx->cq_bank_id]--; 51 + mutex_unlock(&cq_table->bank_mutex); 52 + } 53 + 54 + void hns_roce_get_cq_bankid_for_uctx(struct hns_roce_ucontext *uctx) 55 + { 56 + struct hns_roce_dev *hr_dev = to_hr_dev(uctx->ibucontext.device); 57 + struct hns_roce_cq_table *cq_table = &hr_dev->cq_table; 58 + u32 least_load = cq_table->ctx_num[0]; 59 + u8 bankid = 0; 60 + u8 i; 61 + 62 + if (hr_dev->pci_dev->revision < PCI_REVISION_ID_HIP09) 63 + return; 64 + 65 + mutex_lock(&cq_table->bank_mutex); 66 + for (i = 1; i < HNS_ROCE_CQ_BANK_NUM; i++) { 67 + if (cq_table->ctx_num[i] < least_load) { 68 + least_load = cq_table->ctx_num[i]; 69 + bankid = i; 70 + } 71 + } 72 + cq_table->ctx_num[bankid]++; 73 + mutex_unlock(&cq_table->bank_mutex); 74 + 75 + uctx->cq_bank_id = bankid; 76 + } 39 77 40 78 static u8 get_least_load_bankid_for_cq(struct hns_roce_bank *bank) 41 79 { ··· 93 55 return bankid; 94 56 } 95 57 96 - static int alloc_cqn(struct hns_roce_dev *hr_dev, struct hns_roce_cq *hr_cq) 58 + static u8 select_cq_bankid(struct hns_roce_dev *hr_dev, 59 + struct hns_roce_bank *bank, struct ib_udata *udata) 60 + { 61 + struct hns_roce_ucontext *uctx = udata ? 62 + rdma_udata_to_drv_context(udata, struct hns_roce_ucontext, 63 + ibucontext) : NULL; 64 + 65 + if (hr_dev->pci_dev->revision >= PCI_REVISION_ID_HIP09) 66 + return uctx ? uctx->cq_bank_id : 0; 67 + 68 + return get_least_load_bankid_for_cq(bank); 69 + } 70 + 71 + static int alloc_cqn(struct hns_roce_dev *hr_dev, struct hns_roce_cq *hr_cq, 72 + struct ib_udata *udata) 97 73 { 98 74 struct hns_roce_cq_table *cq_table = &hr_dev->cq_table; 99 75 struct hns_roce_bank *bank; ··· 115 63 int id; 116 64 117 65 mutex_lock(&cq_table->bank_mutex); 118 - bankid = get_least_load_bankid_for_cq(cq_table->bank); 66 + bankid = select_cq_bankid(hr_dev, cq_table->bank, udata); 119 67 bank = &cq_table->bank[bankid]; 120 68 121 69 id = ida_alloc_range(&bank->ida, bank->min, bank->max, GFP_KERNEL); ··· 448 396 goto err_cq_buf; 449 397 } 450 398 451 - ret = alloc_cqn(hr_dev, hr_cq); 399 + ret = alloc_cqn(hr_dev, hr_cq, udata); 452 400 if (ret) { 453 401 ibdev_err(ibdev, "failed to alloc CQN, ret = %d.\n", ret); 454 402 goto err_cq_db;
+4
drivers/infiniband/hw/hns/hns_roce_device.h
··· 217 217 struct mutex page_mutex; 218 218 struct hns_user_mmap_entry *db_mmap_entry; 219 219 u32 config; 220 + u8 cq_bank_id; 220 221 }; 221 222 222 223 struct hns_roce_pd { ··· 496 495 struct hns_roce_hem_table table; 497 496 struct hns_roce_bank bank[HNS_ROCE_CQ_BANK_NUM]; 498 497 struct mutex bank_mutex; 498 + u32 ctx_num[HNS_ROCE_CQ_BANK_NUM]; 499 499 }; 500 500 501 501 struct hns_roce_srq_table { ··· 1307 1305 size_t length, 1308 1306 enum hns_roce_mmap_type mmap_type); 1309 1307 bool check_sl_valid(struct hns_roce_dev *hr_dev, u8 sl); 1308 + void hns_roce_put_cq_bankid_for_uctx(struct hns_roce_ucontext *uctx); 1309 + void hns_roce_get_cq_bankid_for_uctx(struct hns_roce_ucontext *uctx); 1310 1310 1311 1311 #endif /* _HNS_ROCE_DEVICE_H */
+8 -4
drivers/infiniband/hw/hns/hns_roce_hw_v2.c
··· 165 165 hr_reg_write(fseg, FRMR_PBL_BUF_PG_SZ, 166 166 to_hr_hw_page_shift(mr->pbl_mtr.hem_cfg.buf_pg_shift)); 167 167 hr_reg_clear(fseg, FRMR_BLK_MODE); 168 + hr_reg_clear(fseg, FRMR_BLOCK_SIZE); 169 + hr_reg_clear(fseg, FRMR_ZBVA); 168 170 } 169 171 170 172 static void set_atomic_seg(const struct ib_send_wr *wr, ··· 340 338 struct hns_roce_qp *qp = to_hr_qp(ibqp); 341 339 int j = 0; 342 340 int i; 343 - 344 - hr_reg_write(rc_sq_wqe, RC_SEND_WQE_MSG_START_SGE_IDX, 345 - (*sge_ind) & (qp->sge.sge_cnt - 1)); 346 341 347 342 hr_reg_write(rc_sq_wqe, RC_SEND_WQE_INLINE, 348 343 !!(wr->send_flags & IB_SEND_INLINE)); ··· 585 586 hr_reg_write(rc_sq_wqe, RC_SEND_WQE_CQE, 586 587 (wr->send_flags & IB_SEND_SIGNALED) ? 1 : 0); 587 588 589 + hr_reg_write(rc_sq_wqe, RC_SEND_WQE_MSG_START_SGE_IDX, 590 + curr_idx & (qp->sge.sge_cnt - 1)); 591 + 588 592 if (wr->opcode == IB_WR_ATOMIC_CMP_AND_SWP || 589 593 wr->opcode == IB_WR_ATOMIC_FETCH_AND_ADD) { 590 594 if (msg_len != ATOMIC_WR_LEN) ··· 735 733 qp->sq.wrid[wqe_idx] = wr->wr_id; 736 734 owner_bit = 737 735 ~(((qp->sq.head + nreq) >> ilog2(qp->sq.wqe_cnt)) & 0x1); 736 + 737 + /* RC and UD share the same DirectWQE field layout */ 738 + ((struct hns_roce_v2_rc_send_wqe *)wqe)->byte_4 = 0; 738 739 739 740 /* Corresponding to the QP type, wqe process separately */ 740 741 if (ibqp->qp_type == IB_QPT_RC) ··· 7052 7047 dev_err(hr_dev->dev, "RoCE Engine init failed!\n"); 7053 7048 goto error_failed_roce_init; 7054 7049 } 7055 - 7056 7050 7057 7051 handle->priv = hr_dev; 7058 7052
+4
drivers/infiniband/hw/hns/hns_roce_main.c
··· 425 425 if (ret) 426 426 goto error_fail_copy_to_udata; 427 427 428 + hns_roce_get_cq_bankid_for_uctx(context); 429 + 428 430 return 0; 429 431 430 432 error_fail_copy_to_udata: ··· 448 446 { 449 447 struct hns_roce_ucontext *context = to_hr_ucontext(ibcontext); 450 448 struct hns_roce_dev *hr_dev = to_hr_dev(ibcontext->device); 449 + 450 + hns_roce_put_cq_bankid_for_uctx(context); 451 451 452 452 if (hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_CQ_RECORD_DB || 453 453 hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_QP_RECORD_DB)
-2
drivers/infiniband/hw/hns/hns_roce_qp.c
··· 662 662 663 663 hr_qp->sq.wqe_shift = ucmd->log_sq_stride; 664 664 hr_qp->sq.wqe_cnt = cnt; 665 - cap->max_send_sge = hr_qp->sq.max_gs; 666 665 667 666 return 0; 668 667 } ··· 743 744 744 745 /* sync the parameters of kernel QP to user's configuration */ 745 746 cap->max_send_wr = cnt; 746 - cap->max_send_sge = hr_qp->sq.max_gs; 747 747 748 748 return 0; 749 749 }
+1 -1
drivers/infiniband/hw/irdma/pble.c
··· 71 71 static void get_sd_pd_idx(struct irdma_hmc_pble_rsrc *pble_rsrc, 72 72 struct sd_pd_idx *idx) 73 73 { 74 - idx->sd_idx = (u32)pble_rsrc->next_fpm_addr / IRDMA_HMC_DIRECT_BP_SIZE; 74 + idx->sd_idx = pble_rsrc->next_fpm_addr / IRDMA_HMC_DIRECT_BP_SIZE; 75 75 idx->pd_idx = (u32)(pble_rsrc->next_fpm_addr / IRDMA_HMC_PAGED_BP_SIZE); 76 76 idx->rel_pd_idx = (idx->pd_idx % IRDMA_HMC_PD_CNT_IN_SD); 77 77 }
+1 -1
drivers/infiniband/hw/irdma/type.h
··· 706 706 u32 vchnl_ver; 707 707 u16 num_vfs; 708 708 u16 hmc_fn_id; 709 - u8 vf_id; 709 + u16 vf_id; 710 710 bool privileged:1; 711 711 bool vchnl_up:1; 712 712 bool ceq_valid:1;
+1
drivers/infiniband/hw/irdma/verbs.c
··· 2503 2503 spin_lock_init(&iwcq->lock); 2504 2504 INIT_LIST_HEAD(&iwcq->resize_list); 2505 2505 INIT_LIST_HEAD(&iwcq->cmpl_generated); 2506 + iwcq->cq_num = cq_num; 2506 2507 info.dev = dev; 2507 2508 ukinfo->cq_size = max(entries, 4); 2508 2509 ukinfo->cq_id = cq_num;
+1 -1
drivers/infiniband/hw/irdma/verbs.h
··· 140 140 struct irdma_cq { 141 141 struct ib_cq ibcq; 142 142 struct irdma_sc_cq sc_cq; 143 - u16 cq_num; 143 + u32 cq_num; 144 144 bool user_mode; 145 145 atomic_t armed; 146 146 enum irdma_cmpl_notify last_notify;
+7 -4
drivers/infiniband/hw/mlx5/cq.c
··· 1020 1020 if (cq->create_flags & IB_UVERBS_CQ_FLAGS_IGNORE_OVERRUN) 1021 1021 MLX5_SET(cqc, cqc, oi, 1); 1022 1022 1023 + if (udata) { 1024 + cq->mcq.comp = mlx5_add_cq_to_tasklet; 1025 + cq->mcq.tasklet_ctx.comp = mlx5_ib_cq_comp; 1026 + } else { 1027 + cq->mcq.comp = mlx5_ib_cq_comp; 1028 + } 1029 + 1023 1030 err = mlx5_core_create_cq(dev->mdev, &cq->mcq, cqb, inlen, out, sizeof(out)); 1024 1031 if (err) 1025 1032 goto err_cqb; 1026 1033 1027 1034 mlx5_ib_dbg(dev, "cqn 0x%x\n", cq->mcq.cqn); 1028 - if (udata) 1029 - cq->mcq.tasklet_ctx.comp = mlx5_ib_cq_comp; 1030 - else 1031 - cq->mcq.comp = mlx5_ib_cq_comp; 1032 1035 cq->mcq.event = mlx5_ib_cq_event; 1033 1036 1034 1037 INIT_LIST_HEAD(&cq->wc_list);
+3 -9
drivers/iommu/iommufd/io_pagetable.c
··· 707 707 struct iopt_area *area; 708 708 unsigned long unmapped_bytes = 0; 709 709 unsigned int tries = 0; 710 - int rc = -ENOENT; 710 + /* If there are no mapped entries then success */ 711 + int rc = 0; 711 712 712 713 /* 713 714 * The domains_rwsem must be held in read mode any time any area->pages ··· 778 777 779 778 down_write(&iopt->iova_rwsem); 780 779 } 781 - if (unmapped_bytes) 782 - rc = 0; 783 780 784 781 out_unlock_iova: 785 782 up_write(&iopt->iova_rwsem); ··· 814 815 815 816 int iopt_unmap_all(struct io_pagetable *iopt, unsigned long *unmapped) 816 817 { 817 - int rc; 818 - 819 - rc = iopt_unmap_iova_range(iopt, 0, ULONG_MAX, unmapped); 820 818 /* If the IOVAs are empty then unmap all succeeds */ 821 - if (rc == -ENOENT) 822 - return 0; 823 - return rc; 819 + return iopt_unmap_iova_range(iopt, 0, ULONG_MAX, unmapped); 824 820 } 825 821 826 822 /* The caller must always free all the nodes in the allowed_iova rb_root. */
+4
drivers/iommu/iommufd/ioas.c
··· 367 367 &unmapped); 368 368 if (rc) 369 369 goto out_put; 370 + if (!unmapped) { 371 + rc = -ENOENT; 372 + goto out_put; 373 + } 370 374 } 371 375 372 376 cmd->length = unmapped;
+2 -3
drivers/iommu/iommufd/iova_bitmap.c
··· 130 130 static unsigned long iova_bitmap_offset_to_index(struct iova_bitmap *bitmap, 131 131 unsigned long iova) 132 132 { 133 - unsigned long pgsize = 1UL << bitmap->mapped.pgshift; 134 - 135 - return iova / (BITS_PER_TYPE(*bitmap->bitmap) * pgsize); 133 + return (iova >> bitmap->mapped.pgshift) / 134 + BITS_PER_TYPE(*bitmap->bitmap); 136 135 } 137 136 138 137 /*
+2 -1
drivers/irqchip/irq-riscv-intc.c
··· 166 166 static const struct irq_domain_ops riscv_intc_domain_ops = { 167 167 .map = riscv_intc_domain_map, 168 168 .xlate = irq_domain_xlate_onecell, 169 - .alloc = riscv_intc_domain_alloc 169 + .alloc = riscv_intc_domain_alloc, 170 + .free = irq_domain_free_irqs_top, 170 171 }; 171 172 172 173 static struct fwnode_handle *riscv_intc_hwnode(void)
+13 -5
drivers/isdn/hardware/mISDN/hfcsusb.c
··· 1904 1904 mISDN_freebchannel(&hw->bch[1]); 1905 1905 mISDN_freebchannel(&hw->bch[0]); 1906 1906 mISDN_freedchannel(&hw->dch); 1907 - kfree(hw); 1908 1907 return err; 1909 1908 } 1910 1909 1911 1910 static int 1912 1911 hfcsusb_probe(struct usb_interface *intf, const struct usb_device_id *id) 1913 1912 { 1913 + int err; 1914 1914 struct hfcsusb *hw; 1915 1915 struct usb_device *dev = interface_to_usbdev(intf); 1916 1916 struct usb_host_interface *iface = intf->cur_altsetting; ··· 2101 2101 if (!hw->ctrl_urb) { 2102 2102 pr_warn("%s: No memory for control urb\n", 2103 2103 driver_info->vend_name); 2104 - kfree(hw); 2105 - return -ENOMEM; 2104 + err = -ENOMEM; 2105 + goto err_free_hw; 2106 2106 } 2107 2107 2108 2108 pr_info("%s: %s: detected \"%s\" (%s, if=%d alt=%d)\n", 2109 2109 hw->name, __func__, driver_info->vend_name, 2110 2110 conf_str[small_match], ifnum, alt_used); 2111 2111 2112 - if (setup_instance(hw, dev->dev.parent)) 2113 - return -EIO; 2112 + if (setup_instance(hw, dev->dev.parent)) { 2113 + err = -EIO; 2114 + goto err_free_urb; 2115 + } 2114 2116 2115 2117 hw->intf = intf; 2116 2118 usb_set_intfdata(hw->intf, hw); 2117 2119 return 0; 2120 + 2121 + err_free_urb: 2122 + usb_free_urb(hw->ctrl_urb); 2123 + err_free_hw: 2124 + kfree(hw); 2125 + return err; 2118 2126 } 2119 2127 2120 2128 /* function called when an active device is removed */
+5
drivers/media/common/videobuf2/videobuf2-v4l2.c
··· 1010 1010 if (vb2_queue_is_busy(vdev->queue, file)) 1011 1011 return -EBUSY; 1012 1012 1013 + if (vb2_fileio_is_active(vdev->queue)) { 1014 + dprintk(vdev->queue, 1, "file io in progress\n"); 1015 + return -EBUSY; 1016 + } 1017 + 1013 1018 return vb2_core_remove_bufs(vdev->queue, d->index, d->count); 1014 1019 } 1015 1020 EXPORT_SYMBOL_GPL(vb2_ioctl_remove_bufs);
+3 -6
drivers/media/pci/cx18/cx18-driver.c
··· 1136 1136 int video_input; 1137 1137 int fw_retry_count = 3; 1138 1138 struct v4l2_frequency vf; 1139 - struct cx18_open_id fh; 1140 1139 v4l2_std_id std; 1141 - 1142 - fh.cx = cx; 1143 1140 1144 1141 if (test_bit(CX18_F_I_FAILED, &cx->i_flags)) 1145 1142 return -ENXIO; ··· 1217 1220 1218 1221 video_input = cx->active_input; 1219 1222 cx->active_input++; /* Force update of input */ 1220 - cx18_s_input(NULL, &fh, video_input); 1223 + cx18_do_s_input(cx, video_input); 1221 1224 1222 1225 /* Let the VIDIOC_S_STD ioctl do all the work, keeps the code 1223 1226 in one place. */ 1224 1227 cx->std++; /* Force full standard initialization */ 1225 1228 std = (cx->tuner_std == V4L2_STD_ALL) ? V4L2_STD_NTSC_M : cx->tuner_std; 1226 - cx18_s_std(NULL, &fh, std); 1227 - cx18_s_frequency(NULL, &fh, &vf); 1229 + cx18_do_s_std(cx, std); 1230 + cx18_do_s_frequency(cx, &vf); 1228 1231 return 0; 1229 1232 } 1230 1233
+19 -11
drivers/media/pci/cx18/cx18-ioctl.c
··· 521 521 return 0; 522 522 } 523 523 524 - int cx18_s_input(struct file *file, void *fh, unsigned int inp) 524 + int cx18_do_s_input(struct cx18 *cx, unsigned int inp) 525 525 { 526 - struct cx18_open_id *id = file2id(file); 527 - struct cx18 *cx = id->cx; 528 526 v4l2_std_id std = V4L2_STD_ALL; 529 527 const struct cx18_card_video_input *card_input = 530 528 cx->card->video_inputs + inp; ··· 556 558 return 0; 557 559 } 558 560 561 + static int cx18_s_input(struct file *file, void *fh, unsigned int inp) 562 + { 563 + return cx18_do_s_input(file2id(file)->cx, inp); 564 + } 565 + 559 566 static int cx18_g_frequency(struct file *file, void *fh, 560 567 struct v4l2_frequency *vf) 561 568 { ··· 573 570 return 0; 574 571 } 575 572 576 - int cx18_s_frequency(struct file *file, void *fh, const struct v4l2_frequency *vf) 573 + int cx18_do_s_frequency(struct cx18 *cx, const struct v4l2_frequency *vf) 577 574 { 578 - struct cx18_open_id *id = file2id(file); 579 - struct cx18 *cx = id->cx; 580 - 581 575 if (vf->tuner != 0) 582 576 return -EINVAL; 583 577 ··· 585 585 return 0; 586 586 } 587 587 588 + static int cx18_s_frequency(struct file *file, void *fh, 589 + const struct v4l2_frequency *vf) 590 + { 591 + return cx18_do_s_frequency(file2id(file)->cx, vf); 592 + } 593 + 588 594 static int cx18_g_std(struct file *file, void *fh, v4l2_std_id *std) 589 595 { 590 596 struct cx18 *cx = file2id(file)->cx; ··· 599 593 return 0; 600 594 } 601 595 602 - int cx18_s_std(struct file *file, void *fh, v4l2_std_id std) 596 + int cx18_do_s_std(struct cx18 *cx, v4l2_std_id std) 603 597 { 604 - struct cx18_open_id *id = file2id(file); 605 - struct cx18 *cx = id->cx; 606 - 607 598 if ((std & V4L2_STD_ALL) == 0) 608 599 return -EINVAL; 609 600 ··· 643 640 /* Tuner */ 644 641 cx18_call_all(cx, video, s_std, cx->std); 645 642 return 0; 643 + } 644 + 645 + static int cx18_s_std(struct file *file, void *fh, v4l2_std_id std) 646 + { 647 + return cx18_do_s_std(file2id(file)->cx, std); 646 648 } 647 649 648 650 static int cx18_s_tuner(struct file *file, void *fh, const struct v4l2_tuner *vt)
+5 -3
drivers/media/pci/cx18/cx18-ioctl.h
··· 12 12 void cx18_expand_service_set(struct v4l2_sliced_vbi_format *fmt, int is_pal); 13 13 u16 cx18_get_service_set(struct v4l2_sliced_vbi_format *fmt); 14 14 void cx18_set_funcs(struct video_device *vdev); 15 - int cx18_s_std(struct file *file, void *fh, v4l2_std_id std); 16 - int cx18_s_frequency(struct file *file, void *fh, const struct v4l2_frequency *vf); 17 - int cx18_s_input(struct file *file, void *fh, unsigned int inp); 15 + 16 + struct cx18; 17 + int cx18_do_s_std(struct cx18 *cx, v4l2_std_id std); 18 + int cx18_do_s_frequency(struct cx18 *cx, const struct v4l2_frequency *vf); 19 + int cx18_do_s_input(struct cx18 *cx, unsigned int inp);
+4 -7
drivers/media/pci/ivtv/ivtv-driver.c
··· 1247 1247 1248 1248 int ivtv_init_on_first_open(struct ivtv *itv) 1249 1249 { 1250 - struct v4l2_frequency vf; 1251 1250 /* Needed to call ioctls later */ 1252 - struct ivtv_open_id fh; 1251 + struct ivtv_stream *s = &itv->streams[IVTV_ENC_STREAM_TYPE_MPG]; 1252 + struct v4l2_frequency vf; 1253 1253 int fw_retry_count = 3; 1254 1254 int video_input; 1255 - 1256 - fh.itv = itv; 1257 - fh.type = IVTV_ENC_STREAM_TYPE_MPG; 1258 1255 1259 1256 if (test_bit(IVTV_F_I_FAILED, &itv->i_flags)) 1260 1257 return -ENXIO; ··· 1294 1297 1295 1298 video_input = itv->active_input; 1296 1299 itv->active_input++; /* Force update of input */ 1297 - ivtv_s_input(NULL, &fh, video_input); 1300 + ivtv_do_s_input(itv, video_input); 1298 1301 1299 1302 /* Let the VIDIOC_S_STD ioctl do all the work, keeps the code 1300 1303 in one place. */ 1301 1304 itv->std++; /* Force full standard initialization */ 1302 1305 itv->std_out = itv->std; 1303 - ivtv_s_frequency(NULL, &fh, &vf); 1306 + ivtv_do_s_frequency(s, &vf); 1304 1307 1305 1308 if (itv->card->v4l2_capabilities & V4L2_CAP_VIDEO_OUTPUT) { 1306 1309 /* Turn on the TV-out: ivtv_init_mpeg_decoder() initializes
+17 -5
drivers/media/pci/ivtv/ivtv-ioctl.c
··· 974 974 return 0; 975 975 } 976 976 977 - int ivtv_s_input(struct file *file, void *fh, unsigned int inp) 977 + int ivtv_do_s_input(struct ivtv *itv, unsigned int inp) 978 978 { 979 - struct ivtv *itv = file2id(file)->itv; 980 979 v4l2_std_id std; 981 980 int i; 982 981 ··· 1014 1015 ivtv_unmute(itv); 1015 1016 1016 1017 return 0; 1018 + } 1019 + 1020 + static int ivtv_s_input(struct file *file, void *fh, unsigned int inp) 1021 + { 1022 + return ivtv_do_s_input(file2id(file)->itv, inp); 1017 1023 } 1018 1024 1019 1025 static int ivtv_g_output(struct file *file, void *fh, unsigned int *i) ··· 1069 1065 return 0; 1070 1066 } 1071 1067 1072 - int ivtv_s_frequency(struct file *file, void *fh, const struct v4l2_frequency *vf) 1068 + int ivtv_do_s_frequency(struct ivtv_stream *s, const struct v4l2_frequency *vf) 1073 1069 { 1074 - struct ivtv *itv = file2id(file)->itv; 1075 - struct ivtv_stream *s = &itv->streams[file2id(file)->type]; 1070 + struct ivtv *itv = s->itv; 1076 1071 1077 1072 if (s->vdev.vfl_dir) 1078 1073 return -ENOTTY; ··· 1083 1080 ivtv_call_all(itv, tuner, s_frequency, vf); 1084 1081 ivtv_unmute(itv); 1085 1082 return 0; 1083 + } 1084 + 1085 + static int ivtv_s_frequency(struct file *file, void *fh, 1086 + const struct v4l2_frequency *vf) 1087 + { 1088 + struct ivtv_open_id *id = file2id(file); 1089 + struct ivtv *itv = id->itv; 1090 + 1091 + return ivtv_do_s_frequency(&itv->streams[id->type], vf); 1086 1092 } 1087 1093 1088 1094 static int ivtv_g_std(struct file *file, void *fh, v4l2_std_id *std)
+4 -2
drivers/media/pci/ivtv/ivtv-ioctl.h
··· 9 9 #ifndef IVTV_IOCTL_H 10 10 #define IVTV_IOCTL_H 11 11 12 + struct ivtv; 13 + 12 14 u16 ivtv_service2vbi(int type); 13 15 void ivtv_expand_service_set(struct v4l2_sliced_vbi_format *fmt, int is_pal); 14 16 u16 ivtv_get_service_set(struct v4l2_sliced_vbi_format *fmt); ··· 19 17 void ivtv_set_funcs(struct video_device *vdev); 20 18 void ivtv_s_std_enc(struct ivtv *itv, v4l2_std_id std); 21 19 void ivtv_s_std_dec(struct ivtv *itv, v4l2_std_id std); 22 - int ivtv_s_frequency(struct file *file, void *fh, const struct v4l2_frequency *vf); 23 - int ivtv_s_input(struct file *file, void *fh, unsigned int inp); 20 + int ivtv_do_s_frequency(struct ivtv_stream *s, const struct v4l2_frequency *vf); 21 + int ivtv_do_s_input(struct ivtv *itv, unsigned int inp); 24 22 25 23 #endif
+14 -1
drivers/media/usb/uvc/uvc_driver.c
··· 167 167 168 168 static struct uvc_streaming *uvc_stream_by_id(struct uvc_device *dev, int id) 169 169 { 170 - struct uvc_streaming *stream; 170 + struct uvc_streaming *stream, *last_stream; 171 + unsigned int count = 0; 171 172 172 173 list_for_each_entry(stream, &dev->streams, list) { 174 + count += 1; 175 + last_stream = stream; 173 176 if (stream->header.bTerminalLink == id) 174 177 return stream; 178 + } 179 + 180 + /* 181 + * If the streaming entity is referenced by an invalid ID, notify the 182 + * user and use heuristics to guess the correct entity. 183 + */ 184 + if (count == 1 && id == UVC_INVALID_ENTITY_ID) { 185 + dev_warn(&dev->intf->dev, 186 + "UVC non compliance: Invalid USB header. The streaming entity has an invalid ID, guessing the correct one."); 187 + return last_stream; 175 188 } 176 189 177 190 return NULL;
+1 -1
drivers/media/v4l2-core/v4l2-subdev.c
··· 2608 2608 int v4l2_subdev_get_privacy_led(struct v4l2_subdev *sd) 2609 2609 { 2610 2610 #if IS_REACHABLE(CONFIG_LEDS_CLASS) 2611 - sd->privacy_led = led_get(sd->dev, "privacy-led"); 2611 + sd->privacy_led = led_get(sd->dev, "privacy"); 2612 2612 if (IS_ERR(sd->privacy_led) && PTR_ERR(sd->privacy_led) != -ENOENT) 2613 2613 return dev_err_probe(sd->dev, PTR_ERR(sd->privacy_led), 2614 2614 "getting privacy LED\n");
+1 -1
drivers/mmc/host/Kconfig
··· 950 950 config MMC_WMT 951 951 tristate "Wondermedia SD/MMC Host Controller support" 952 952 depends on ARCH_VT8500 || COMPILE_TEST 953 - default y 953 + default ARCH_VT8500 954 954 help 955 955 This selects support for the SD/MMC Host Controller on 956 956 Wondermedia WM8505/WM8650 based SoCs.
+2 -2
drivers/mmc/host/dw_mmc-rockchip.c
··· 42 42 */ 43 43 static int rockchip_mmc_get_internal_phase(struct dw_mci *host, bool sample) 44 44 { 45 - unsigned long rate = clk_get_rate(host->ciu_clk); 45 + unsigned long rate = clk_get_rate(host->ciu_clk) / RK3288_CLKGEN_DIV; 46 46 u32 raw_value; 47 47 u16 degrees; 48 48 u32 delay_num = 0; ··· 85 85 86 86 static int rockchip_mmc_set_internal_phase(struct dw_mci *host, bool sample, int degrees) 87 87 { 88 - unsigned long rate = clk_get_rate(host->ciu_clk); 88 + unsigned long rate = clk_get_rate(host->ciu_clk) / RK3288_CLKGEN_DIV; 89 89 u8 nineties, remainder; 90 90 u8 delay_num; 91 91 u32 raw_value;
+18 -38
drivers/mmc/host/pxamci.c
··· 652 652 host->clkrt = CLKRT_OFF; 653 653 654 654 host->clk = devm_clk_get(dev, NULL); 655 - if (IS_ERR(host->clk)) { 656 - host->clk = NULL; 657 - return PTR_ERR(host->clk); 658 - } 655 + if (IS_ERR(host->clk)) 656 + return dev_err_probe(dev, PTR_ERR(host->clk), 657 + "Failed to acquire clock\n"); 659 658 660 659 host->clkrate = clk_get_rate(host->clk); 661 660 ··· 702 703 703 704 platform_set_drvdata(pdev, mmc); 704 705 705 - host->dma_chan_rx = dma_request_chan(dev, "rx"); 706 - if (IS_ERR(host->dma_chan_rx)) { 707 - host->dma_chan_rx = NULL; 706 + host->dma_chan_rx = devm_dma_request_chan(dev, "rx"); 707 + if (IS_ERR(host->dma_chan_rx)) 708 708 return dev_err_probe(dev, PTR_ERR(host->dma_chan_rx), 709 709 "unable to request rx dma channel\n"); 710 - } 711 710 712 - host->dma_chan_tx = dma_request_chan(dev, "tx"); 713 - if (IS_ERR(host->dma_chan_tx)) { 714 - dev_err(dev, "unable to request tx dma channel\n"); 715 - ret = PTR_ERR(host->dma_chan_tx); 716 - host->dma_chan_tx = NULL; 717 - goto out; 718 - } 711 + 712 + host->dma_chan_tx = devm_dma_request_chan(dev, "tx"); 713 + if (IS_ERR(host->dma_chan_tx)) 714 + return dev_err_probe(dev, PTR_ERR(host->dma_chan_tx), 715 + "unable to request tx dma channel\n"); 719 716 720 717 if (host->pdata) { 721 718 host->detect_delay_ms = host->pdata->detect_delay_ms; 722 719 723 720 host->power = devm_gpiod_get_optional(dev, "power", GPIOD_OUT_LOW); 724 - if (IS_ERR(host->power)) { 725 - ret = PTR_ERR(host->power); 726 - dev_err(dev, "Failed requesting gpio_power\n"); 727 - goto out; 728 - } 721 + if (IS_ERR(host->power)) 722 + return dev_err_probe(dev, PTR_ERR(host->power), 723 + "Failed requesting gpio_power\n"); 729 724 730 725 /* FIXME: should we pass detection delay to debounce? */ 731 726 ret = mmc_gpiod_request_cd(mmc, "cd", 0, false, 0); 732 - if (ret && ret != -ENOENT) { 733 - dev_err(dev, "Failed requesting gpio_cd\n"); 734 - goto out; 735 - } 727 + if (ret && ret != -ENOENT) 728 + return dev_err_probe(dev, ret, "Failed requesting gpio_cd\n"); 736 729 737 730 if (!host->pdata->gpio_card_ro_invert) 738 731 mmc->caps2 |= MMC_CAP2_RO_ACTIVE_HIGH; 739 732 740 733 ret = mmc_gpiod_request_ro(mmc, "wp", 0, 0); 741 - if (ret && ret != -ENOENT) { 742 - dev_err(dev, "Failed requesting gpio_ro\n"); 743 - goto out; 744 - } 734 + if (ret && ret != -ENOENT) 735 + return dev_err_probe(dev, ret, "Failed requesting gpio_ro\n"); 736 + 745 737 if (!ret) 746 738 host->use_ro_gpio = true; 747 739 ··· 749 759 if (ret) { 750 760 if (host->pdata && host->pdata->exit) 751 761 host->pdata->exit(dev, mmc); 752 - goto out; 753 762 } 754 763 755 - return 0; 756 - 757 - out: 758 - if (host->dma_chan_rx) 759 - dma_release_channel(host->dma_chan_rx); 760 - if (host->dma_chan_tx) 761 - dma_release_channel(host->dma_chan_tx); 762 764 return ret; 763 765 } 764 766 ··· 773 791 774 792 dmaengine_terminate_all(host->dma_chan_rx); 775 793 dmaengine_terminate_all(host->dma_chan_tx); 776 - dma_release_channel(host->dma_chan_rx); 777 - dma_release_channel(host->dma_chan_tx); 778 794 } 779 795 } 780 796
+1 -1
drivers/mmc/host/sdhci-of-dwcmshc.c
··· 94 94 #define DLL_TXCLK_TAPNUM_DEFAULT 0x10 95 95 #define DLL_TXCLK_TAPNUM_90_DEGREES 0xA 96 96 #define DLL_TXCLK_TAPNUM_FROM_SW BIT(24) 97 - #define DLL_STRBIN_TAPNUM_DEFAULT 0x8 97 + #define DLL_STRBIN_TAPNUM_DEFAULT 0x4 98 98 #define DLL_STRBIN_TAPNUM_FROM_SW BIT(24) 99 99 #define DLL_STRBIN_DELAY_NUM_SEL BIT(26) 100 100 #define DLL_STRBIN_DELAY_NUM_OFFSET 16
+3 -2
drivers/net/bonding/bond_main.c
··· 2120 2120 /* check for initial state */ 2121 2121 new_slave->link = BOND_LINK_NOCHANGE; 2122 2122 if (bond->params.miimon) { 2123 - if (netif_carrier_ok(slave_dev)) { 2123 + if (netif_running(slave_dev) && netif_carrier_ok(slave_dev)) { 2124 2124 if (bond->params.updelay) { 2125 2125 bond_set_slave_link_state(new_slave, 2126 2126 BOND_LINK_BACK, ··· 2665 2665 bond_for_each_slave_rcu(bond, slave, iter) { 2666 2666 bond_propose_link_state(slave, BOND_LINK_NOCHANGE); 2667 2667 2668 - link_state = netif_carrier_ok(slave->dev); 2668 + link_state = netif_running(slave->dev) && 2669 + netif_carrier_ok(slave->dev); 2669 2670 2670 2671 switch (slave->link) { 2671 2672 case BOND_LINK_UP:
+1 -8
drivers/net/bonding/bond_options.c
··· 225 225 { NULL, -1, 0}, 226 226 }; 227 227 228 - static const struct bond_opt_value bond_actor_port_prio_tbl[] = { 229 - { "minval", 0, BOND_VALFLAG_MIN}, 230 - { "maxval", 65535, BOND_VALFLAG_MAX}, 231 - { "default", 255, BOND_VALFLAG_DEFAULT}, 232 - { NULL, -1, 0}, 233 - }; 234 - 235 228 static const struct bond_opt_value bond_ad_user_port_key_tbl[] = { 236 229 { "minval", 0, BOND_VALFLAG_MIN | BOND_VALFLAG_DEFAULT}, 237 230 { "maxval", 1023, BOND_VALFLAG_MAX}, ··· 490 497 .id = BOND_OPT_ACTOR_PORT_PRIO, 491 498 .name = "actor_port_prio", 492 499 .unsuppmodes = BOND_MODE_ALL_EX(BIT(BOND_MODE_8023AD)), 493 - .values = bond_actor_port_prio_tbl, 500 + .flags = BOND_OPTFLAG_RAWVAL, 494 501 .set = bond_option_actor_port_prio_set, 495 502 }, 496 503 [BOND_OPT_AD_ACTOR_SYSTEM] = {
+29 -7
drivers/net/dsa/b53/b53_common.c
··· 371 371 * frames should be flooded or not. 372 372 */ 373 373 b53_read8(dev, B53_CTRL_PAGE, B53_IP_MULTICAST_CTRL, &mgmt); 374 - mgmt |= B53_UC_FWD_EN | B53_MC_FWD_EN | B53_IPMC_FWD_EN; 374 + mgmt |= B53_UC_FWD_EN | B53_MC_FWD_EN | B53_IP_MC; 375 375 b53_write8(dev, B53_CTRL_PAGE, B53_IP_MULTICAST_CTRL, mgmt); 376 376 } else { 377 377 b53_read8(dev, B53_CTRL_PAGE, B53_IP_MULTICAST_CTRL, &mgmt); 378 - mgmt |= B53_IP_MCAST_25; 378 + mgmt |= B53_IP_MC; 379 379 b53_write8(dev, B53_CTRL_PAGE, B53_IP_MULTICAST_CTRL, mgmt); 380 380 } 381 381 } ··· 1372 1372 else 1373 1373 reg &= ~PORT_OVERRIDE_FULL_DUPLEX; 1374 1374 1375 + reg &= ~(0x3 << GMII_PO_SPEED_S); 1376 + if (is5301x(dev) || is58xx(dev)) 1377 + reg &= ~PORT_OVERRIDE_SPEED_2000M; 1378 + 1375 1379 switch (speed) { 1376 1380 case 2000: 1377 1381 reg |= PORT_OVERRIDE_SPEED_2000M; ··· 1393 1389 dev_err(dev->dev, "unknown speed: %d\n", speed); 1394 1390 return; 1395 1391 } 1392 + 1393 + if (is5325(dev)) 1394 + reg &= ~PORT_OVERRIDE_LP_FLOW_25; 1395 + else 1396 + reg &= ~(PORT_OVERRIDE_RX_FLOW | PORT_OVERRIDE_TX_FLOW); 1396 1397 1397 1398 if (rx_pause) { 1398 1399 if (is5325(dev)) ··· 1602 1593 struct b53_device *dev = dp->ds->priv; 1603 1594 int port = dp->index; 1604 1595 1605 - if (mode == MLO_AN_PHY) 1596 + if (mode == MLO_AN_PHY) { 1597 + if (is63xx(dev) && in_range(port, B53_63XX_RGMII0, 4)) 1598 + b53_force_link(dev, port, false); 1606 1599 return; 1600 + } 1607 1601 1608 1602 if (mode == MLO_AN_FIXED) { 1609 1603 b53_force_link(dev, port, false); ··· 1634 1622 if (mode == MLO_AN_PHY) { 1635 1623 /* Re-negotiate EEE if it was enabled already */ 1636 1624 p->eee_enabled = b53_eee_init(ds, port, phydev); 1625 + 1626 + if (is63xx(dev) && in_range(port, B53_63XX_RGMII0, 4)) { 1627 + b53_force_port_config(dev, port, speed, duplex, 1628 + tx_pause, rx_pause); 1629 + b53_force_link(dev, port, true); 1630 + } 1631 + 1637 1632 return; 1638 1633 } 1639 1634 ··· 2037 2018 do { 2038 2019 b53_read8(dev, B53_ARLIO_PAGE, offset, &reg); 2039 2020 if (!(reg & ARL_SRCH_STDN)) 2040 - return 0; 2021 + return -ENOENT; 2041 2022 2042 2023 if (reg & ARL_SRCH_VLID) 2043 2024 return 0; ··· 2087 2068 int b53_fdb_dump(struct dsa_switch *ds, int port, 2088 2069 dsa_fdb_dump_cb_t *cb, void *data) 2089 2070 { 2071 + unsigned int count = 0, results_per_hit = 1; 2090 2072 struct b53_device *priv = ds->priv; 2091 2073 struct b53_arl_entry results[2]; 2092 - unsigned int count = 0; 2093 2074 u8 offset; 2094 2075 int ret; 2095 2076 u8 reg; 2077 + 2078 + if (priv->num_arl_bins > 2) 2079 + results_per_hit = 2; 2096 2080 2097 2081 mutex_lock(&priv->arl_mutex); 2098 2082 ··· 2118 2096 if (ret) 2119 2097 break; 2120 2098 2121 - if (priv->num_arl_bins > 2) { 2099 + if (results_per_hit == 2) { 2122 2100 b53_arl_search_rd(priv, 1, &results[1]); 2123 2101 ret = b53_fdb_copy(port, &results[1], cb, data); 2124 2102 if (ret) ··· 2128 2106 break; 2129 2107 } 2130 2108 2131 - } while (count++ < b53_max_arl_entries(priv) / 2); 2109 + } while (count++ < b53_max_arl_entries(priv) / results_per_hit); 2132 2110 2133 2111 mutex_unlock(&priv->arl_mutex); 2134 2112
+1 -2
drivers/net/dsa/b53/b53_regs.h
··· 111 111 112 112 /* IP Multicast control (8 bit) */ 113 113 #define B53_IP_MULTICAST_CTRL 0x21 114 - #define B53_IP_MCAST_25 BIT(0) 115 - #define B53_IPMC_FWD_EN BIT(1) 114 + #define B53_IP_MC BIT(0) 116 115 #define B53_UC_FWD_EN BIT(6) 117 116 #define B53_MC_FWD_EN BIT(7) 118 117
+84 -14
drivers/net/dsa/microchip/ksz9477.c
··· 1355 1355 } 1356 1356 } 1357 1357 1358 + #define RESV_MCAST_CNT 8 1359 + 1360 + static u8 reserved_mcast_map[RESV_MCAST_CNT] = { 0, 1, 3, 16, 32, 33, 2, 17 }; 1361 + 1358 1362 int ksz9477_enable_stp_addr(struct ksz_device *dev) 1359 1363 { 1364 + u8 i, ports, update; 1360 1365 const u32 *masks; 1366 + bool override; 1361 1367 u32 data; 1362 1368 int ret; 1363 1369 ··· 1372 1366 /* Enable Reserved multicast table */ 1373 1367 ksz_cfg(dev, REG_SW_LUE_CTRL_0, SW_RESV_MCAST_ENABLE, true); 1374 1368 1375 - /* Set the Override bit for forwarding BPDU packet to CPU */ 1376 - ret = ksz_write32(dev, REG_SW_ALU_VAL_B, 1377 - ALU_V_OVERRIDE | BIT(dev->cpu_port)); 1378 - if (ret < 0) 1379 - return ret; 1369 + /* The reserved multicast address table has 8 entries. Each entry has 1370 + * a default value of which port to forward. It is assumed the host 1371 + * port is the last port in most of the switches, but that is not the 1372 + * case for KSZ9477 or maybe KSZ9897. For LAN937X family the default 1373 + * port is port 5, the first RGMII port. It is okay for LAN9370, a 1374 + * 5-port switch, but may not be correct for the other 8-port 1375 + * versions. It is necessary to update the whole table to forward to 1376 + * the right ports. 1377 + * Furthermore PTP messages can use a reserved multicast address and 1378 + * the host will not receive them if this table is not correct. 1379 + */ 1380 + for (i = 0; i < RESV_MCAST_CNT; i++) { 1381 + data = reserved_mcast_map[i] << 1382 + dev->info->shifts[ALU_STAT_INDEX]; 1383 + data |= ALU_STAT_START | 1384 + masks[ALU_STAT_DIRECT] | 1385 + masks[ALU_RESV_MCAST_ADDR] | 1386 + masks[ALU_STAT_READ]; 1387 + ret = ksz_write32(dev, REG_SW_ALU_STAT_CTRL__4, data); 1388 + if (ret < 0) 1389 + return ret; 1380 1390 1381 - data = ALU_STAT_START | ALU_RESV_MCAST_ADDR | masks[ALU_STAT_WRITE]; 1391 + /* wait to be finished */ 1392 + ret = ksz9477_wait_alu_sta_ready(dev); 1393 + if (ret < 0) 1394 + return ret; 1382 1395 1383 - ret = ksz_write32(dev, REG_SW_ALU_STAT_CTRL__4, data); 1384 - if (ret < 0) 1385 - return ret; 1396 + ret = ksz_read32(dev, REG_SW_ALU_VAL_B, &data); 1397 + if (ret < 0) 1398 + return ret; 1386 1399 1387 - /* wait to be finished */ 1388 - ret = ksz9477_wait_alu_sta_ready(dev); 1389 - if (ret < 0) { 1390 - dev_err(dev->dev, "Failed to update Reserved Multicast table\n"); 1391 - return ret; 1400 + override = false; 1401 + ports = data & dev->port_mask; 1402 + switch (i) { 1403 + case 0: 1404 + case 6: 1405 + /* Change the host port. */ 1406 + update = BIT(dev->cpu_port); 1407 + override = true; 1408 + break; 1409 + case 2: 1410 + /* Change the host port. */ 1411 + update = BIT(dev->cpu_port); 1412 + break; 1413 + case 4: 1414 + case 5: 1415 + case 7: 1416 + /* Skip the host port. */ 1417 + update = dev->port_mask & ~BIT(dev->cpu_port); 1418 + break; 1419 + default: 1420 + update = ports; 1421 + break; 1422 + } 1423 + if (update != ports || override) { 1424 + data &= ~dev->port_mask; 1425 + data |= update; 1426 + /* Set Override bit to receive frame even when port is 1427 + * closed. 1428 + */ 1429 + if (override) 1430 + data |= ALU_V_OVERRIDE; 1431 + ret = ksz_write32(dev, REG_SW_ALU_VAL_B, data); 1432 + if (ret < 0) 1433 + return ret; 1434 + 1435 + data = reserved_mcast_map[i] << 1436 + dev->info->shifts[ALU_STAT_INDEX]; 1437 + data |= ALU_STAT_START | 1438 + masks[ALU_STAT_DIRECT] | 1439 + masks[ALU_RESV_MCAST_ADDR] | 1440 + masks[ALU_STAT_WRITE]; 1441 + ret = ksz_write32(dev, REG_SW_ALU_STAT_CTRL__4, data); 1442 + if (ret < 0) 1443 + return ret; 1444 + 1445 + /* wait to be finished */ 1446 + ret = ksz9477_wait_alu_sta_ready(dev); 1447 + if (ret < 0) 1448 + return ret; 1449 + } 1392 1450 } 1393 1451 1394 1452 return 0;
+1 -2
drivers/net/dsa/microchip/ksz9477_reg.h
··· 2 2 /* 3 3 * Microchip KSZ9477 register definitions 4 4 * 5 - * Copyright (C) 2017-2024 Microchip Technology Inc. 5 + * Copyright (C) 2017-2025 Microchip Technology Inc. 6 6 */ 7 7 8 8 #ifndef __KSZ9477_REGS_H ··· 397 397 398 398 #define ALU_RESV_MCAST_INDEX_M (BIT(6) - 1) 399 399 #define ALU_STAT_START BIT(7) 400 - #define ALU_RESV_MCAST_ADDR BIT(1) 401 400 402 401 #define REG_SW_ALU_VAL_A 0x0420 403 402
+4
drivers/net/dsa/microchip/ksz_common.c
··· 808 808 static const u32 ksz9477_masks[] = { 809 809 [ALU_STAT_WRITE] = 0, 810 810 [ALU_STAT_READ] = 1, 811 + [ALU_STAT_DIRECT] = 0, 812 + [ALU_RESV_MCAST_ADDR] = BIT(1), 811 813 [P_MII_TX_FLOW_CTRL] = BIT(5), 812 814 [P_MII_RX_FLOW_CTRL] = BIT(3), 813 815 }; ··· 837 835 static const u32 lan937x_masks[] = { 838 836 [ALU_STAT_WRITE] = 1, 839 837 [ALU_STAT_READ] = 2, 838 + [ALU_STAT_DIRECT] = BIT(3), 839 + [ALU_RESV_MCAST_ADDR] = BIT(2), 840 840 [P_MII_TX_FLOW_CTRL] = BIT(5), 841 841 [P_MII_RX_FLOW_CTRL] = BIT(3), 842 842 };
+2
drivers/net/dsa/microchip/ksz_common.h
··· 294 294 DYNAMIC_MAC_TABLE_TIMESTAMP, 295 295 ALU_STAT_WRITE, 296 296 ALU_STAT_READ, 297 + ALU_STAT_DIRECT, 298 + ALU_RESV_MCAST_ADDR, 297 299 P_MII_TX_FLOW_CTRL, 298 300 P_MII_RX_FLOW_CTRL, 299 301 };
+5 -1
drivers/net/ethernet/broadcom/bnxt/bnxt.c
··· 12439 12439 return -ENODEV; 12440 12440 } 12441 12441 12442 - static void bnxt_clear_reservations(struct bnxt *bp, bool fw_reset) 12442 + void bnxt_clear_reservations(struct bnxt *bp, bool fw_reset) 12443 12443 { 12444 12444 struct bnxt_hw_resc *hw_resc = &bp->hw_resc; 12445 12445 ··· 16892 16892 if (netif_running(dev)) 16893 16893 netif_close(dev); 16894 16894 16895 + if (bnxt_hwrm_func_drv_unrgtr(bp)) { 16896 + pcie_flr(pdev); 16897 + goto shutdown_exit; 16898 + } 16895 16899 bnxt_ptp_clear(bp); 16896 16900 bnxt_clear_int_mode(bp); 16897 16901 pci_disable_device(pdev);
+2 -1
drivers/net/ethernet/broadcom/bnxt/bnxt.h
··· 2149 2149 static inline void bnxt_bs_trace_check_wrap(struct bnxt_bs_trace_info *bs_trace, 2150 2150 u32 offset) 2151 2151 { 2152 - if (!bs_trace->wrapped && 2152 + if (!bs_trace->wrapped && bs_trace->magic_byte && 2153 2153 *bs_trace->magic_byte != BNXT_TRACE_BUF_MAGIC_BYTE) 2154 2154 bs_trace->wrapped = 1; 2155 2155 bs_trace->last_offset = offset; ··· 2941 2941 int bnxt_update_link(struct bnxt *bp, bool chng_link_state); 2942 2942 int bnxt_hwrm_set_pause(struct bnxt *); 2943 2943 int bnxt_hwrm_set_link_setting(struct bnxt *, bool, bool); 2944 + void bnxt_clear_reservations(struct bnxt *bp, bool fw_reset); 2944 2945 int bnxt_cancel_reservations(struct bnxt *bp, bool fw_reset); 2945 2946 int bnxt_hwrm_alloc_wol_fltr(struct bnxt *bp); 2946 2947 int bnxt_hwrm_free_wol_fltr(struct bnxt *bp);
+3 -2
drivers/net/ethernet/broadcom/bnxt/bnxt_coredump.c
··· 333 333 u32 offset = 0; 334 334 int rc = 0; 335 335 336 + record->max_entries = cpu_to_le32(ctxm->max_entries); 337 + record->entry_size = cpu_to_le32(ctxm->entry_size); 338 + 336 339 rc = bnxt_dbg_hwrm_log_buffer_flush(bp, type, 0, &offset); 337 340 if (rc) 338 341 return; 339 342 340 343 bnxt_bs_trace_check_wrap(bs_trace, offset); 341 - record->max_entries = cpu_to_le32(ctxm->max_entries); 342 - record->entry_size = cpu_to_le32(ctxm->entry_size); 343 344 record->offset = cpu_to_le32(bs_trace->last_offset); 344 345 record->wrapped = bs_trace->wrapped; 345 346 }
+1 -1
drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c
··· 461 461 rtnl_unlock(); 462 462 break; 463 463 } 464 - bnxt_cancel_reservations(bp, false); 464 + bnxt_clear_reservations(bp, false); 465 465 bnxt_free_ctx_mem(bp, false); 466 466 break; 467 467 }
+2 -2
drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c
··· 1051 1051 if (ptp->ptp_clock) { 1052 1052 ptp_clock_unregister(ptp->ptp_clock); 1053 1053 ptp->ptp_clock = NULL; 1054 - kfree(ptp->ptp_info.pin_config); 1055 - ptp->ptp_info.pin_config = NULL; 1056 1054 } 1055 + kfree(ptp->ptp_info.pin_config); 1056 + ptp->ptp_info.pin_config = NULL; 1057 1057 } 1058 1058 1059 1059 int bnxt_ptp_init(struct bnxt *bp)
+2
drivers/net/ethernet/freescale/fec_main.c
··· 1835 1835 ndev->stats.rx_packets++; 1836 1836 pkt_len = fec16_to_cpu(bdp->cbd_datlen); 1837 1837 ndev->stats.rx_bytes += pkt_len; 1838 + if (fep->quirks & FEC_QUIRK_HAS_RACC) 1839 + ndev->stats.rx_bytes -= 2; 1838 1840 1839 1841 index = fec_enet_get_bd_index(bdp, &rxq->bd); 1840 1842 page = rxq->rx_skb_info[index].page;
+15
drivers/net/ethernet/google/gve/gve_ptp.c
··· 26 26 return 0; 27 27 } 28 28 29 + static int gve_ptp_gettimex64(struct ptp_clock_info *info, 30 + struct timespec64 *ts, 31 + struct ptp_system_timestamp *sts) 32 + { 33 + return -EOPNOTSUPP; 34 + } 35 + 36 + static int gve_ptp_settime64(struct ptp_clock_info *info, 37 + const struct timespec64 *ts) 38 + { 39 + return -EOPNOTSUPP; 40 + } 41 + 29 42 static long gve_ptp_do_aux_work(struct ptp_clock_info *info) 30 43 { 31 44 const struct gve_ptp *ptp = container_of(info, struct gve_ptp, info); ··· 60 47 static const struct ptp_clock_info gve_ptp_caps = { 61 48 .owner = THIS_MODULE, 62 49 .name = "gve clock", 50 + .gettimex64 = gve_ptp_gettimex64, 51 + .settime64 = gve_ptp_settime64, 63 52 .do_aux_work = gve_ptp_do_aux_work, 64 53 }; 65 54
+2 -2
drivers/net/ethernet/intel/Kconfig
··· 146 146 tristate "Intel(R) 10GbE PCI Express adapters support" 147 147 depends on PCI 148 148 depends on PTP_1588_CLOCK_OPTIONAL 149 - select LIBIE_FWLOG 149 + select LIBIE_FWLOG if DEBUG_FS 150 150 select MDIO 151 151 select NET_DEVLINK 152 152 select PLDMFW ··· 298 298 select DIMLIB 299 299 select LIBIE 300 300 select LIBIE_ADMINQ 301 - select LIBIE_FWLOG 301 + select LIBIE_FWLOG if DEBUG_FS 302 302 select NET_DEVLINK 303 303 select PACKING 304 304 select PLDMFW
-2
drivers/net/ethernet/intel/ixgbe/ixgbe.h
··· 821 821 #ifdef CONFIG_IXGBE_HWMON 822 822 struct hwmon_buff *ixgbe_hwmon_buff; 823 823 #endif /* CONFIG_IXGBE_HWMON */ 824 - #ifdef CONFIG_DEBUG_FS 825 824 struct dentry *ixgbe_dbg_adapter; 826 - #endif /*CONFIG_DEBUG_FS*/ 827 825 828 826 u8 default_up; 829 827 /* Bitmask indicating in use pools */
+2 -4
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c
··· 1516 1516 pool->xdp_cnt = numptrs; 1517 1517 pool->xdp = devm_kcalloc(pfvf->dev, 1518 1518 numptrs, sizeof(struct xdp_buff *), GFP_KERNEL); 1519 - if (IS_ERR(pool->xdp)) { 1520 - netdev_err(pfvf->netdev, "Creation of xsk pool failed\n"); 1521 - return PTR_ERR(pool->xdp); 1522 - } 1519 + if (!pool->xdp) 1520 + return -ENOMEM; 1523 1521 } 1524 1522 1525 1523 return 0;
+20 -3
drivers/net/ethernet/mellanox/mlx5/core/cq.c
··· 66 66 tasklet_schedule(&ctx->task); 67 67 } 68 68 69 - static void mlx5_add_cq_to_tasklet(struct mlx5_core_cq *cq, 70 - struct mlx5_eqe *eqe) 69 + void mlx5_add_cq_to_tasklet(struct mlx5_core_cq *cq, 70 + struct mlx5_eqe *eqe) 71 71 { 72 72 unsigned long flags; 73 73 struct mlx5_eq_tasklet *tasklet_ctx = cq->tasklet_ctx.priv; ··· 95 95 if (schedule_tasklet) 96 96 tasklet_schedule(&tasklet_ctx->task); 97 97 } 98 + EXPORT_SYMBOL(mlx5_add_cq_to_tasklet); 98 99 100 + static void mlx5_core_cq_dummy_cb(struct mlx5_core_cq *cq, struct mlx5_eqe *eqe) 101 + { 102 + mlx5_core_err(cq->eq->core.dev, 103 + "CQ default completion callback, CQ #%u\n", cq->cqn); 104 + } 105 + 106 + #define MLX5_CQ_INIT_CMD_SN cpu_to_be32(2 << 28) 99 107 /* Callers must verify outbox status in case of err */ 100 108 int mlx5_create_cq(struct mlx5_core_dev *dev, struct mlx5_core_cq *cq, 101 109 u32 *in, int inlen, u32 *out, int outlen) ··· 129 121 cq->arm_sn = 0; 130 122 cq->eq = eq; 131 123 cq->uid = MLX5_GET(create_cq_in, in, uid); 124 + 125 + /* Kernel CQs must set the arm_db address prior to calling 126 + * this function, allowing for the proper value to be 127 + * initialized. User CQs are responsible for their own 128 + * initialization since they do not use the arm_db field. 129 + */ 130 + if (cq->arm_db) 131 + *cq->arm_db = MLX5_CQ_INIT_CMD_SN; 132 + 132 133 refcount_set(&cq->refcount, 1); 133 134 init_completion(&cq->free); 134 135 if (!cq->comp) 135 - cq->comp = mlx5_add_cq_to_tasklet; 136 + cq->comp = mlx5_core_cq_dummy_cb; 136 137 /* assuming CQ will be deleted before the EQ */ 137 138 cq->tasklet_ctx.priv = &eq->tasklet_ctx; 138 139 INIT_LIST_HEAD(&cq->tasklet_ctx.list);
+1 -1
drivers/net/ethernet/mellanox/mlx5/core/devlink.c
··· 541 541 max_num_channels = mlx5e_get_max_num_channels(mdev); 542 542 if (val32 > max_num_channels) { 543 543 NL_SET_ERR_MSG_FMT_MOD(extack, 544 - "Requested num_doorbells (%u) exceeds maximum number of channels (%u)", 544 + "Requested num_doorbells (%u) exceeds max number of channels (%u)", 545 545 val32, max_num_channels); 546 546 return -EINVAL; 547 547 }
+3
drivers/net/ethernet/mellanox/mlx5/core/en.h
··· 634 634 struct mlx5e_shampo_hd { 635 635 struct mlx5e_frag_page *pages; 636 636 u32 hd_per_wq; 637 + u32 hd_per_page; 637 638 u16 hd_per_wqe; 639 + u8 log_hd_per_page; 640 + u8 log_hd_entry_size; 638 641 unsigned long *bitmap; 639 642 u16 pi; 640 643 u16 ci;
+2 -1
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c
··· 804 804 goto err_xfrm; 805 805 } 806 806 807 - if (mlx5_eswitch_block_mode(priv->mdev)) 807 + err = mlx5_eswitch_block_mode(priv->mdev); 808 + if (err) 808 809 goto unblock_ipsec; 809 810 810 811 if (x->props.mode == XFRM_MODE_TUNNEL &&
+28 -5
drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c
··· 595 595 struct mlx5_core_dev *mdev = priv->mdev; 596 596 u8 max_bw_value[IEEE_8021QAZ_MAX_TCS]; 597 597 u8 max_bw_unit[IEEE_8021QAZ_MAX_TCS]; 598 - __u64 upper_limit_mbps = roundup(255 * MLX5E_100MB, MLX5E_1GB); 598 + __u64 upper_limit_mbps; 599 + __u64 upper_limit_gbps; 599 600 int i; 601 + struct { 602 + int scale; 603 + const char *units_str; 604 + } units[] = { 605 + [MLX5_100_MBPS_UNIT] = { 606 + .scale = 100, 607 + .units_str = "Mbps", 608 + }, 609 + [MLX5_GBPS_UNIT] = { 610 + .scale = 1, 611 + .units_str = "Gbps", 612 + }, 613 + }; 600 614 601 615 memset(max_bw_value, 0, sizeof(max_bw_value)); 602 616 memset(max_bw_unit, 0, sizeof(max_bw_unit)); 617 + upper_limit_mbps = 255 * MLX5E_100MB; 618 + upper_limit_gbps = 255 * MLX5E_1GB; 603 619 604 620 for (i = 0; i <= mlx5_max_tc(mdev); i++) { 605 621 if (!maxrate->tc_maxrate[i]) { 606 622 max_bw_unit[i] = MLX5_BW_NO_LIMIT; 607 623 continue; 608 624 } 609 - if (maxrate->tc_maxrate[i] < upper_limit_mbps) { 625 + if (maxrate->tc_maxrate[i] <= upper_limit_mbps) { 610 626 max_bw_value[i] = div_u64(maxrate->tc_maxrate[i], 611 627 MLX5E_100MB); 612 628 max_bw_value[i] = max_bw_value[i] ? max_bw_value[i] : 1; 613 629 max_bw_unit[i] = MLX5_100_MBPS_UNIT; 614 - } else { 630 + } else if (max_bw_value[i] <= upper_limit_gbps) { 615 631 max_bw_value[i] = div_u64(maxrate->tc_maxrate[i], 616 632 MLX5E_1GB); 617 633 max_bw_unit[i] = MLX5_GBPS_UNIT; 634 + } else { 635 + netdev_err(netdev, 636 + "tc_%d maxrate %llu Kbps exceeds limit %llu\n", 637 + i, maxrate->tc_maxrate[i], 638 + upper_limit_gbps); 639 + return -EINVAL; 618 640 } 619 641 } 620 642 621 643 for (i = 0; i < IEEE_8021QAZ_MAX_TCS; i++) { 622 - netdev_dbg(netdev, "%s: tc_%d <=> max_bw %d Gbps\n", 623 - __func__, i, max_bw_value[i]); 644 + netdev_dbg(netdev, "%s: tc_%d <=> max_bw %u %s\n", __func__, i, 645 + max_bw_value[i] * units[max_bw_unit[i]].scale, 646 + units[max_bw_unit[i]].units_str); 624 647 } 625 648 626 649 return mlx5_modify_port_ets_rate_limit(mdev, max_bw_value, max_bw_unit);
+1 -3
drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
··· 2125 2125 if (!size_read) 2126 2126 return i; 2127 2127 2128 - if (size_read == -EINVAL) 2129 - return -EINVAL; 2130 2128 if (size_read < 0) { 2131 2129 NL_SET_ERR_MSG_FMT_MOD( 2132 2130 extack, 2133 2131 "Query module eeprom by page failed, read %u bytes, err %d", 2134 2132 i, size_read); 2135 - return i; 2133 + return size_read; 2136 2134 } 2137 2135 2138 2136 i += size_read;
+19 -6
drivers/net/ethernet/mellanox/mlx5/core/en_main.c
··· 791 791 int node) 792 792 { 793 793 void *wqc = MLX5_ADDR_OF(rqc, rqp->rqc, wq); 794 + u8 log_hd_per_page, log_hd_entry_size; 795 + u16 hd_per_wq, hd_per_wqe; 794 796 u32 hd_pool_size; 795 - u16 hd_per_wq; 796 797 int wq_size; 797 798 int err; 798 799 ··· 816 815 if (err) 817 816 goto err_umr_mkey; 818 817 819 - rq->mpwqe.shampo->hd_per_wqe = 820 - mlx5e_shampo_hd_per_wqe(mdev, params, rqp); 818 + hd_per_wqe = mlx5e_shampo_hd_per_wqe(mdev, params, rqp); 821 819 wq_size = BIT(MLX5_GET(wq, wqc, log_wq_sz)); 822 - hd_pool_size = (rq->mpwqe.shampo->hd_per_wqe * wq_size) / 823 - MLX5E_SHAMPO_WQ_HEADER_PER_PAGE; 820 + 821 + BUILD_BUG_ON(MLX5E_SHAMPO_LOG_MAX_HEADER_ENTRY_SIZE > PAGE_SHIFT); 822 + if (hd_per_wqe >= MLX5E_SHAMPO_WQ_HEADER_PER_PAGE) { 823 + log_hd_per_page = MLX5E_SHAMPO_LOG_WQ_HEADER_PER_PAGE; 824 + log_hd_entry_size = MLX5E_SHAMPO_LOG_MAX_HEADER_ENTRY_SIZE; 825 + } else { 826 + log_hd_per_page = order_base_2(hd_per_wqe); 827 + log_hd_entry_size = order_base_2(PAGE_SIZE / hd_per_wqe); 828 + } 829 + 830 + rq->mpwqe.shampo->hd_per_wqe = hd_per_wqe; 831 + rq->mpwqe.shampo->hd_per_page = BIT(log_hd_per_page); 832 + rq->mpwqe.shampo->log_hd_per_page = log_hd_per_page; 833 + rq->mpwqe.shampo->log_hd_entry_size = log_hd_entry_size; 834 + 835 + hd_pool_size = (hd_per_wqe * wq_size) >> log_hd_per_page; 824 836 825 837 if (netif_rxq_has_unreadable_mp(rq->netdev, rq->ix)) { 826 838 /* Separate page pool for shampo headers */ ··· 2219 2205 mcq->set_ci_db = cq->wq_ctrl.db.db; 2220 2206 mcq->arm_db = cq->wq_ctrl.db.db + 1; 2221 2207 *mcq->set_ci_db = 0; 2222 - *mcq->arm_db = 0; 2223 2208 mcq->vector = param->eq_ix; 2224 2209 mcq->comp = mlx5e_completion_event; 2225 2210 mcq->event = mlx5e_cq_error_event;
+39 -33
drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
··· 648 648 umr_wqe->hdr.uctrl.mkey_mask = cpu_to_be64(MLX5_MKEY_MASK_FREE); 649 649 } 650 650 651 - static struct mlx5e_frag_page *mlx5e_shampo_hd_to_frag_page(struct mlx5e_rq *rq, int header_index) 651 + static struct mlx5e_frag_page *mlx5e_shampo_hd_to_frag_page(struct mlx5e_rq *rq, 652 + int header_index) 652 653 { 653 - BUILD_BUG_ON(MLX5E_SHAMPO_LOG_MAX_HEADER_ENTRY_SIZE > PAGE_SHIFT); 654 + struct mlx5e_shampo_hd *shampo = rq->mpwqe.shampo; 654 655 655 - return &rq->mpwqe.shampo->pages[header_index >> MLX5E_SHAMPO_LOG_WQ_HEADER_PER_PAGE]; 656 + return &shampo->pages[header_index >> shampo->log_hd_per_page]; 656 657 } 657 658 658 - static u64 mlx5e_shampo_hd_offset(int header_index) 659 + static u64 mlx5e_shampo_hd_offset(struct mlx5e_rq *rq, int header_index) 659 660 { 660 - return (header_index & (MLX5E_SHAMPO_WQ_HEADER_PER_PAGE - 1)) << 661 - MLX5E_SHAMPO_LOG_MAX_HEADER_ENTRY_SIZE; 661 + struct mlx5e_shampo_hd *shampo = rq->mpwqe.shampo; 662 + u32 hd_per_page = shampo->hd_per_page; 663 + 664 + return (header_index & (hd_per_page - 1)) << shampo->log_hd_entry_size; 662 665 } 663 666 664 667 static void mlx5e_free_rx_shampo_hd_entry(struct mlx5e_rq *rq, u16 header_index); ··· 674 671 u16 pi, header_offset, err, wqe_bbs; 675 672 u32 lkey = rq->mdev->mlx5e_res.hw_objs.mkey; 676 673 struct mlx5e_umr_wqe *umr_wqe; 677 - int headroom, i = 0; 674 + int headroom, i; 678 675 679 676 headroom = rq->buff.headroom; 680 677 wqe_bbs = MLX5E_KSM_UMR_WQEBBS(ksm_entries); ··· 682 679 umr_wqe = mlx5_wq_cyc_get_wqe(&sq->wq, pi); 683 680 build_ksm_umr(sq, umr_wqe, shampo->mkey_be, index, ksm_entries); 684 681 685 - WARN_ON_ONCE(ksm_entries & (MLX5E_SHAMPO_WQ_HEADER_PER_PAGE - 1)); 686 - while (i < ksm_entries) { 687 - struct mlx5e_frag_page *frag_page = mlx5e_shampo_hd_to_frag_page(rq, index); 682 + for (i = 0; i < ksm_entries; i++, index++) { 683 + struct mlx5e_frag_page *frag_page; 688 684 u64 addr; 689 685 690 - err = mlx5e_page_alloc_fragmented(rq->hd_page_pool, frag_page); 691 - if (unlikely(err)) 692 - goto err_unmap; 686 + frag_page = mlx5e_shampo_hd_to_frag_page(rq, index); 687 + header_offset = mlx5e_shampo_hd_offset(rq, index); 688 + if (!header_offset) { 689 + err = mlx5e_page_alloc_fragmented(rq->hd_page_pool, 690 + frag_page); 691 + if (err) 692 + goto err_unmap; 693 + } 693 694 694 695 addr = page_pool_get_dma_addr_netmem(frag_page->netmem); 695 - 696 - for (int j = 0; j < MLX5E_SHAMPO_WQ_HEADER_PER_PAGE; j++) { 697 - header_offset = mlx5e_shampo_hd_offset(index++); 698 - 699 - umr_wqe->inline_ksms[i++] = (struct mlx5_ksm) { 700 - .key = cpu_to_be32(lkey), 701 - .va = cpu_to_be64(addr + header_offset + headroom), 702 - }; 703 - } 696 + umr_wqe->inline_ksms[i] = (struct mlx5_ksm) { 697 + .key = cpu_to_be32(lkey), 698 + .va = cpu_to_be64(addr + header_offset + headroom), 699 + }; 704 700 } 705 701 706 702 sq->db.wqe_info[pi] = (struct mlx5e_icosq_wqe_info) { ··· 715 713 return 0; 716 714 717 715 err_unmap: 718 - while (--i) { 716 + while (--i >= 0) { 719 717 --index; 720 - header_offset = mlx5e_shampo_hd_offset(index); 718 + header_offset = mlx5e_shampo_hd_offset(rq, index); 721 719 if (!header_offset) { 722 720 struct mlx5e_frag_page *frag_page = mlx5e_shampo_hd_to_frag_page(rq, index); 723 721 ··· 737 735 struct mlx5e_icosq *sq = rq->icosq; 738 736 int i, err, max_ksm_entries, len; 739 737 740 - max_ksm_entries = ALIGN_DOWN(MLX5E_MAX_KSM_PER_WQE(rq->mdev), 741 - MLX5E_SHAMPO_WQ_HEADER_PER_PAGE); 738 + max_ksm_entries = MLX5E_MAX_KSM_PER_WQE(rq->mdev); 742 739 ksm_entries = bitmap_find_window(shampo->bitmap, 743 740 shampo->hd_per_wqe, 744 741 shampo->hd_per_wq, shampo->pi); 745 - ksm_entries = ALIGN_DOWN(ksm_entries, MLX5E_SHAMPO_WQ_HEADER_PER_PAGE); 742 + ksm_entries = ALIGN_DOWN(ksm_entries, shampo->hd_per_page); 746 743 if (!ksm_entries) 747 744 return 0; 748 745 ··· 859 858 { 860 859 struct mlx5e_shampo_hd *shampo = rq->mpwqe.shampo; 861 860 862 - if (((header_index + 1) & (MLX5E_SHAMPO_WQ_HEADER_PER_PAGE - 1)) == 0) { 861 + if (((header_index + 1) & (shampo->hd_per_page - 1)) == 0) { 863 862 struct mlx5e_frag_page *frag_page = mlx5e_shampo_hd_to_frag_page(rq, header_index); 864 863 865 864 mlx5e_page_release_fragmented(rq->hd_page_pool, frag_page); ··· 1226 1225 static void *mlx5e_shampo_get_packet_hd(struct mlx5e_rq *rq, u16 header_index) 1227 1226 { 1228 1227 struct mlx5e_frag_page *frag_page = mlx5e_shampo_hd_to_frag_page(rq, header_index); 1229 - u16 head_offset = mlx5e_shampo_hd_offset(header_index) + rq->buff.headroom; 1228 + u16 head_offset = mlx5e_shampo_hd_offset(rq, header_index); 1229 + void *addr = netmem_address(frag_page->netmem); 1230 1230 1231 - return netmem_address(frag_page->netmem) + head_offset; 1231 + return addr + head_offset + rq->buff.headroom; 1232 1232 } 1233 1233 1234 1234 static void mlx5e_shampo_update_ipv4_udp_hdr(struct mlx5e_rq *rq, struct iphdr *ipv4) ··· 2269 2267 struct mlx5_cqe64 *cqe, u16 header_index) 2270 2268 { 2271 2269 struct mlx5e_frag_page *frag_page = mlx5e_shampo_hd_to_frag_page(rq, header_index); 2272 - u16 head_offset = mlx5e_shampo_hd_offset(header_index); 2270 + u16 head_offset = mlx5e_shampo_hd_offset(rq, header_index); 2271 + struct mlx5e_shampo_hd *shampo = rq->mpwqe.shampo; 2273 2272 u16 head_size = cqe->shampo.header_size; 2274 2273 u16 rx_headroom = rq->buff.headroom; 2275 2274 struct sk_buff *skb = NULL; ··· 2286 2283 data = hdr + rx_headroom; 2287 2284 frag_size = MLX5_SKB_FRAG_SZ(rx_headroom + head_size); 2288 2285 2289 - if (likely(frag_size <= BIT(MLX5E_SHAMPO_LOG_MAX_HEADER_ENTRY_SIZE))) { 2286 + if (likely(frag_size <= BIT(shampo->log_hd_entry_size))) { 2290 2287 /* build SKB around header */ 2291 2288 dma_sync_single_range_for_cpu(rq->pdev, dma_addr, 0, frag_size, rq->buff.map_dir); 2292 2289 net_prefetchw(hdr); ··· 2359 2356 { 2360 2357 int nr_frags = skb_shinfo(skb)->nr_frags; 2361 2358 2362 - return PAGE_SIZE * nr_frags + data_bcnt <= GRO_LEGACY_MAX_SIZE; 2359 + if (PAGE_SIZE >= GRO_LEGACY_MAX_SIZE) 2360 + return skb->len + data_bcnt <= GRO_LEGACY_MAX_SIZE; 2361 + else 2362 + return PAGE_SIZE * nr_frags + data_bcnt <= GRO_LEGACY_MAX_SIZE; 2363 2363 } 2364 2364 2365 2365 static void mlx5e_handle_rx_cqe_mpwrq_shampo(struct mlx5e_rq *rq, struct mlx5_cqe64 *cqe)
+7 -8
drivers/net/ethernet/mellanox/mlx5/core/fpga/conn.c
··· 421 421 __be64 *pas; 422 422 u32 i; 423 423 424 + conn->cq.mcq.cqe_sz = 64; 425 + conn->cq.mcq.set_ci_db = conn->cq.wq_ctrl.db.db; 426 + conn->cq.mcq.arm_db = conn->cq.wq_ctrl.db.db + 1; 427 + *conn->cq.mcq.set_ci_db = 0; 428 + conn->cq.mcq.vector = 0; 429 + conn->cq.mcq.comp = mlx5_fpga_conn_cq_complete; 430 + 424 431 cq_size = roundup_pow_of_two(cq_size); 425 432 MLX5_SET(cqc, temp_cqc, log_cq_size, ilog2(cq_size)); 426 433 ··· 475 468 if (err) 476 469 goto err_cqwq; 477 470 478 - conn->cq.mcq.cqe_sz = 64; 479 - conn->cq.mcq.set_ci_db = conn->cq.wq_ctrl.db.db; 480 - conn->cq.mcq.arm_db = conn->cq.wq_ctrl.db.db + 1; 481 - *conn->cq.mcq.set_ci_db = 0; 482 - *conn->cq.mcq.arm_db = 0; 483 - conn->cq.mcq.vector = 0; 484 - conn->cq.mcq.comp = mlx5_fpga_conn_cq_complete; 485 471 tasklet_setup(&conn->cq.tasklet, mlx5_fpga_conn_cq_tasklet); 486 - 487 472 mlx5_fpga_dbg(fdev, "Created CQ #0x%x\n", conn->cq.mcq.cqn); 488 473 489 474 goto out;
-7
drivers/net/ethernet/mellanox/mlx5/core/steering/hws/send.c
··· 873 873 return err; 874 874 } 875 875 876 - static void hws_cq_complete(struct mlx5_core_cq *mcq, 877 - struct mlx5_eqe *eqe) 878 - { 879 - pr_err("CQ completion CQ: #%u\n", mcq->cqn); 880 - } 881 - 882 876 static int hws_send_ring_alloc_cq(struct mlx5_core_dev *mdev, 883 877 int numa_node, 884 878 struct mlx5hws_send_engine *queue, ··· 895 901 mcq->cqe_sz = 64; 896 902 mcq->set_ci_db = cq->wq_ctrl.db.db; 897 903 mcq->arm_db = cq->wq_ctrl.db.db + 1; 898 - mcq->comp = hws_cq_complete; 899 904 900 905 for (i = 0; i < mlx5_cqwq_get_size(&cq->wq); i++) { 901 906 cqe = mlx5_cqwq_get_wqe(&cq->wq, i);
+7 -21
drivers/net/ethernet/mellanox/mlx5/core/steering/sws/dr_send.c
··· 1049 1049 return 0; 1050 1050 } 1051 1051 1052 - static void dr_cq_complete(struct mlx5_core_cq *mcq, 1053 - struct mlx5_eqe *eqe) 1054 - { 1055 - pr_err("CQ completion CQ: #%u\n", mcq->cqn); 1056 - } 1057 - 1058 1052 static struct mlx5dr_cq *dr_create_cq(struct mlx5_core_dev *mdev, 1059 1053 struct mlx5_uars_page *uar, 1060 1054 size_t ncqe) ··· 1083 1089 cqe->op_own = MLX5_CQE_INVALID << 4 | MLX5_CQE_OWNER_MASK; 1084 1090 } 1085 1091 1092 + cq->mcq.cqe_sz = 64; 1093 + cq->mcq.set_ci_db = cq->wq_ctrl.db.db; 1094 + cq->mcq.arm_db = cq->wq_ctrl.db.db + 1; 1095 + *cq->mcq.set_ci_db = 0; 1096 + cq->mcq.vector = 0; 1097 + cq->mdev = mdev; 1098 + 1086 1099 inlen = MLX5_ST_SZ_BYTES(create_cq_in) + 1087 1100 sizeof(u64) * cq->wq_ctrl.buf.npages; 1088 1101 in = kvzalloc(inlen, GFP_KERNEL); ··· 1113 1112 pas = (__be64 *)MLX5_ADDR_OF(create_cq_in, in, pas); 1114 1113 mlx5_fill_page_frag_array(&cq->wq_ctrl.buf, pas); 1115 1114 1116 - cq->mcq.comp = dr_cq_complete; 1117 - 1118 1115 err = mlx5_core_create_cq(mdev, &cq->mcq, in, inlen, out, sizeof(out)); 1119 1116 kvfree(in); 1120 1117 1121 1118 if (err) 1122 1119 goto err_cqwq; 1123 - 1124 - cq->mcq.cqe_sz = 64; 1125 - cq->mcq.set_ci_db = cq->wq_ctrl.db.db; 1126 - cq->mcq.arm_db = cq->wq_ctrl.db.db + 1; 1127 - *cq->mcq.set_ci_db = 0; 1128 - 1129 - /* set no-zero value, in order to avoid the HW to run db-recovery on 1130 - * CQ that used in polling mode. 1131 - */ 1132 - *cq->mcq.arm_db = cpu_to_be32(2 << 28); 1133 - 1134 - cq->mcq.vector = 0; 1135 - cq->mdev = mdev; 1136 1120 1137 1121 return cq; 1138 1122
+9 -9
drivers/net/ethernet/microchip/lan966x/lan966x_ethtool.c
··· 294 294 { 295 295 int i, j; 296 296 297 - mutex_lock(&lan966x->stats_lock); 297 + spin_lock(&lan966x->stats_lock); 298 298 299 299 for (i = 0; i < lan966x->num_phys_ports; i++) { 300 300 uint idx = i * lan966x->num_stats; ··· 310 310 } 311 311 } 312 312 313 - mutex_unlock(&lan966x->stats_lock); 313 + spin_unlock(&lan966x->stats_lock); 314 314 } 315 315 316 316 static int lan966x_get_sset_count(struct net_device *dev, int sset) ··· 365 365 366 366 idx = port->chip_port * lan966x->num_stats; 367 367 368 - mutex_lock(&lan966x->stats_lock); 368 + spin_lock(&lan966x->stats_lock); 369 369 370 370 mac_stats->FramesTransmittedOK = 371 371 lan966x->stats[idx + SYS_COUNT_TX_UC] + ··· 416 416 lan966x->stats[idx + SYS_COUNT_RX_LONG] + 417 417 lan966x->stats[idx + SYS_COUNT_RX_PMAC_LONG]; 418 418 419 - mutex_unlock(&lan966x->stats_lock); 419 + spin_unlock(&lan966x->stats_lock); 420 420 } 421 421 422 422 static const struct ethtool_rmon_hist_range lan966x_rmon_ranges[] = { ··· 442 442 443 443 idx = port->chip_port * lan966x->num_stats; 444 444 445 - mutex_lock(&lan966x->stats_lock); 445 + spin_lock(&lan966x->stats_lock); 446 446 447 447 rmon_stats->undersize_pkts = 448 448 lan966x->stats[idx + SYS_COUNT_RX_SHORT] + ··· 500 500 lan966x->stats[idx + SYS_COUNT_TX_SZ_1024_1526] + 501 501 lan966x->stats[idx + SYS_COUNT_TX_PMAC_SZ_1024_1526]; 502 502 503 - mutex_unlock(&lan966x->stats_lock); 503 + spin_unlock(&lan966x->stats_lock); 504 504 505 505 *ranges = lan966x_rmon_ranges; 506 506 } ··· 603 603 604 604 idx = port->chip_port * lan966x->num_stats; 605 605 606 - mutex_lock(&lan966x->stats_lock); 606 + spin_lock(&lan966x->stats_lock); 607 607 608 608 stats->rx_bytes = lan966x->stats[idx + SYS_COUNT_RX_OCT] + 609 609 lan966x->stats[idx + SYS_COUNT_RX_PMAC_OCT]; ··· 685 685 686 686 stats->collisions = lan966x->stats[idx + SYS_COUNT_TX_COL]; 687 687 688 - mutex_unlock(&lan966x->stats_lock); 688 + spin_unlock(&lan966x->stats_lock); 689 689 } 690 690 691 691 int lan966x_stats_init(struct lan966x *lan966x) ··· 701 701 return -ENOMEM; 702 702 703 703 /* Init stats worker */ 704 - mutex_init(&lan966x->stats_lock); 704 + spin_lock_init(&lan966x->stats_lock); 705 705 snprintf(queue_name, sizeof(queue_name), "%s-stats", 706 706 dev_name(lan966x->dev)); 707 707 lan966x->stats_queue = create_singlethread_workqueue(queue_name);
-2
drivers/net/ethernet/microchip/lan966x/lan966x_main.c
··· 1261 1261 1262 1262 cancel_delayed_work_sync(&lan966x->stats_work); 1263 1263 destroy_workqueue(lan966x->stats_queue); 1264 - mutex_destroy(&lan966x->stats_lock); 1265 1264 1266 1265 debugfs_remove_recursive(lan966x->debugfs_root); 1267 1266 ··· 1278 1279 1279 1280 cancel_delayed_work_sync(&lan966x->stats_work); 1280 1281 destroy_workqueue(lan966x->stats_queue); 1281 - mutex_destroy(&lan966x->stats_lock); 1282 1282 1283 1283 lan966x_mac_purge_entries(lan966x); 1284 1284 lan966x_mdb_deinit(lan966x);
+2 -2
drivers/net/ethernet/microchip/lan966x/lan966x_main.h
··· 295 295 const struct lan966x_stat_layout *stats_layout; 296 296 u32 num_stats; 297 297 298 - /* workqueue for reading stats */ 299 - struct mutex stats_lock; 298 + /* lock for reading stats */ 299 + spinlock_t stats_lock; 300 300 u64 *stats; 301 301 struct delayed_work stats_work; 302 302 struct workqueue_struct *stats_queue;
+4 -4
drivers/net/ethernet/microchip/lan966x/lan966x_vcap_impl.c
··· 403 403 u32 counter; 404 404 405 405 id = id & 0xff; /* counter limit */ 406 - mutex_lock(&lan966x->stats_lock); 406 + spin_lock(&lan966x->stats_lock); 407 407 lan_wr(SYS_STAT_CFG_STAT_VIEW_SET(id), lan966x, SYS_STAT_CFG); 408 408 counter = lan_rd(lan966x, SYS_CNT(LAN966X_STAT_ESDX_GRN_PKTS)) + 409 409 lan_rd(lan966x, SYS_CNT(LAN966X_STAT_ESDX_YEL_PKTS)); 410 - mutex_unlock(&lan966x->stats_lock); 410 + spin_unlock(&lan966x->stats_lock); 411 411 if (counter) 412 412 admin->cache.counter = counter; 413 413 } ··· 417 417 { 418 418 id = id & 0xff; /* counter limit */ 419 419 420 - mutex_lock(&lan966x->stats_lock); 420 + spin_lock(&lan966x->stats_lock); 421 421 lan_wr(SYS_STAT_CFG_STAT_VIEW_SET(id), lan966x, SYS_STAT_CFG); 422 422 lan_wr(0, lan966x, SYS_CNT(LAN966X_STAT_ESDX_GRN_BYTES)); 423 423 lan_wr(admin->cache.counter, lan966x, 424 424 SYS_CNT(LAN966X_STAT_ESDX_GRN_PKTS)); 425 425 lan_wr(0, lan966x, SYS_CNT(LAN966X_STAT_ESDX_YEL_BYTES)); 426 426 lan_wr(0, lan966x, SYS_CNT(LAN966X_STAT_ESDX_YEL_PKTS)); 427 - mutex_unlock(&lan966x->stats_lock); 427 + spin_unlock(&lan966x->stats_lock); 428 428 } 429 429 430 430 static void lan966x_vcap_cache_write(struct net_device *dev,
+17 -17
drivers/net/ethernet/pensando/ionic/ionic_txrx.c
··· 29 29 30 30 static inline void ionic_txq_post(struct ionic_queue *q, bool ring_dbell) 31 31 { 32 + /* Ensure TX descriptor writes reach memory before NIC reads them. 33 + * Prevents device from fetching stale descriptors. 34 + */ 35 + dma_wmb(); 32 36 ionic_q_post(q, ring_dbell); 33 37 } 34 38 ··· 1448 1444 bool encap; 1449 1445 int err; 1450 1446 1451 - desc_info = &q->tx_info[q->head_idx]; 1452 - 1453 - if (unlikely(ionic_tx_map_skb(q, skb, desc_info))) 1454 - return -EIO; 1455 - 1456 - len = skb->len; 1457 - mss = skb_shinfo(skb)->gso_size; 1458 - outer_csum = (skb_shinfo(skb)->gso_type & (SKB_GSO_GRE | 1459 - SKB_GSO_GRE_CSUM | 1460 - SKB_GSO_IPXIP4 | 1461 - SKB_GSO_IPXIP6 | 1462 - SKB_GSO_UDP_TUNNEL | 1463 - SKB_GSO_UDP_TUNNEL_CSUM)); 1464 1447 has_vlan = !!skb_vlan_tag_present(skb); 1465 1448 vlan_tci = skb_vlan_tag_get(skb); 1466 1449 encap = skb->encapsulation; ··· 1461 1470 err = ionic_tx_tcp_inner_pseudo_csum(skb); 1462 1471 else 1463 1472 err = ionic_tx_tcp_pseudo_csum(skb); 1464 - if (unlikely(err)) { 1465 - /* clean up mapping from ionic_tx_map_skb */ 1466 - ionic_tx_desc_unmap_bufs(q, desc_info); 1473 + if (unlikely(err)) 1467 1474 return err; 1468 - } 1469 1475 1476 + desc_info = &q->tx_info[q->head_idx]; 1477 + if (unlikely(ionic_tx_map_skb(q, skb, desc_info))) 1478 + return -EIO; 1479 + 1480 + len = skb->len; 1481 + mss = skb_shinfo(skb)->gso_size; 1482 + outer_csum = (skb_shinfo(skb)->gso_type & (SKB_GSO_GRE | 1483 + SKB_GSO_GRE_CSUM | 1484 + SKB_GSO_IPXIP4 | 1485 + SKB_GSO_IPXIP6 | 1486 + SKB_GSO_UDP_TUNNEL | 1487 + SKB_GSO_UDP_TUNNEL_CSUM)); 1470 1488 if (encap) 1471 1489 hdrlen = skb_inner_tcp_all_headers(skb); 1472 1490 else
+3
drivers/net/ethernet/spacemit/k1_emac.c
··· 1441 1441 struct emac_priv *priv = netdev_priv(dev); 1442 1442 u8 fc = 0; 1443 1443 1444 + if (!netif_running(dev)) 1445 + return -ENETDOWN; 1446 + 1444 1447 priv->flow_control_autoneg = pause->autoneg; 1445 1448 1446 1449 if (pause->autoneg) {
+38 -15
drivers/net/ethernet/ti/am65-cpsw-qos.c
··· 276 276 /* The number of wireside clocks contained in the verify 277 277 * timeout counter. The default is 0x1312d0 278 278 * (10ms at 125Mhz in 1G mode). 279 + * The frequency of the clock depends on the link speed 280 + * and the PHY interface. 279 281 */ 280 - val = 125 * HZ_PER_MHZ; /* assuming 125MHz wireside clock */ 282 + switch (port->slave.phy_if) { 283 + case PHY_INTERFACE_MODE_RGMII: 284 + case PHY_INTERFACE_MODE_RGMII_ID: 285 + case PHY_INTERFACE_MODE_RGMII_RXID: 286 + case PHY_INTERFACE_MODE_RGMII_TXID: 287 + if (port->qos.link_speed == SPEED_1000) 288 + val = 125 * HZ_PER_MHZ; /* 125 MHz at 1000Mbps*/ 289 + else if (port->qos.link_speed == SPEED_100) 290 + val = 25 * HZ_PER_MHZ; /* 25 MHz at 100Mbps*/ 291 + else 292 + val = (25 * HZ_PER_MHZ) / 10; /* 2.5 MHz at 10Mbps*/ 293 + break; 281 294 295 + case PHY_INTERFACE_MODE_QSGMII: 296 + case PHY_INTERFACE_MODE_SGMII: 297 + val = 125 * HZ_PER_MHZ; /* 125 MHz */ 298 + break; 299 + 300 + default: 301 + netdev_err(port->ndev, "selected mode does not supported IET\n"); 302 + return -EOPNOTSUPP; 303 + } 282 304 val /= MILLIHZ_PER_HZ; /* count per ms timeout */ 283 305 val *= verify_time_ms; /* count for timeout ms */ 284 306 ··· 317 295 u32 ctrl, status; 318 296 int try; 319 297 320 - try = 20; 298 + try = 3; 299 + 300 + /* Reset the verify state machine by writing 1 301 + * to LINKFAIL 302 + */ 303 + ctrl = readl(port->port_base + AM65_CPSW_PN_REG_IET_CTRL); 304 + ctrl |= AM65_CPSW_PN_IET_MAC_LINKFAIL; 305 + writel(ctrl, port->port_base + AM65_CPSW_PN_REG_IET_CTRL); 306 + 307 + /* Clear MAC_LINKFAIL bit to start Verify. */ 308 + ctrl = readl(port->port_base + AM65_CPSW_PN_REG_IET_CTRL); 309 + ctrl &= ~AM65_CPSW_PN_IET_MAC_LINKFAIL; 310 + writel(ctrl, port->port_base + AM65_CPSW_PN_REG_IET_CTRL); 311 + 321 312 do { 322 - /* Reset the verify state machine by writing 1 323 - * to LINKFAIL 324 - */ 325 - ctrl = readl(port->port_base + AM65_CPSW_PN_REG_IET_CTRL); 326 - ctrl |= AM65_CPSW_PN_IET_MAC_LINKFAIL; 327 - writel(ctrl, port->port_base + AM65_CPSW_PN_REG_IET_CTRL); 328 - 329 - /* Clear MAC_LINKFAIL bit to start Verify. */ 330 - ctrl = readl(port->port_base + AM65_CPSW_PN_REG_IET_CTRL); 331 - ctrl &= ~AM65_CPSW_PN_IET_MAC_LINKFAIL; 332 - writel(ctrl, port->port_base + AM65_CPSW_PN_REG_IET_CTRL); 333 - 334 313 msleep(port->qos.iet.verify_time_ms); 335 314 336 315 status = readl(port->port_base + AM65_CPSW_PN_REG_IET_STATUS); ··· 353 330 netdev_dbg(port->ndev, "MAC Merge verify error\n"); 354 331 return -ENODEV; 355 332 } 356 - } while (try-- > 0); 333 + } while (--try > 0); 357 334 358 335 netdev_dbg(port->ndev, "MAC Merge verify timeout\n"); 359 336 return -ETIMEDOUT;
+7
drivers/net/ethernet/ti/icssg/icssg_config.c
··· 66 66 #define FDB_GEN_CFG1 0x60 67 67 #define SMEM_VLAN_OFFSET 8 68 68 #define SMEM_VLAN_OFFSET_MASK GENMASK(25, 8) 69 + #define FDB_HASH_SIZE_MASK GENMASK(6, 3) 70 + #define FDB_HASH_SIZE_SHIFT 3 71 + #define FDB_HASH_SIZE 3 69 72 70 73 #define FDB_GEN_CFG2 0x64 71 74 #define FDB_VLAN_EN BIT(6) ··· 466 463 /* Set VLAN TABLE address base */ 467 464 regmap_update_bits(prueth->miig_rt, FDB_GEN_CFG1, SMEM_VLAN_OFFSET_MASK, 468 465 addr << SMEM_VLAN_OFFSET); 466 + regmap_update_bits(prueth->miig_rt, FDB_GEN_CFG1, FDB_HASH_SIZE_MASK, 467 + FDB_HASH_SIZE << FDB_HASH_SIZE_SHIFT); 469 468 /* Set enable VLAN aware mode, and FDBs for all PRUs */ 470 469 regmap_write(prueth->miig_rt, FDB_GEN_CFG2, (FDB_PRU0_EN | FDB_PRU1_EN | FDB_HOST_EN)); 471 470 prueth->vlan_tbl = (struct prueth_vlan_tbl __force *)(prueth->shram.va + ··· 489 484 /* Set VLAN TABLE address base */ 490 485 regmap_update_bits(prueth->miig_rt, FDB_GEN_CFG1, SMEM_VLAN_OFFSET_MASK, 491 486 addr << SMEM_VLAN_OFFSET); 487 + regmap_update_bits(prueth->miig_rt, FDB_GEN_CFG1, FDB_HASH_SIZE_MASK, 488 + FDB_HASH_SIZE << FDB_HASH_SIZE_SHIFT); 492 489 /* Set enable VLAN aware mode, and FDBs for all PRUs */ 493 490 regmap_write(prueth->miig_rt, FDB_GEN_CFG2, FDB_EN_ALL); 494 491 prueth->vlan_tbl = (struct prueth_vlan_tbl __force *)(prueth->shram.va +
+5 -5
drivers/net/ethernet/ti/netcp_core.c
··· 1338 1338 1339 1339 tx_pipe->dma_channel = knav_dma_open_channel(dev, 1340 1340 tx_pipe->dma_chan_name, &config); 1341 - if (IS_ERR(tx_pipe->dma_channel)) { 1341 + if (!tx_pipe->dma_channel) { 1342 1342 dev_err(dev, "failed opening tx chan(%s)\n", 1343 1343 tx_pipe->dma_chan_name); 1344 - ret = PTR_ERR(tx_pipe->dma_channel); 1344 + ret = -EINVAL; 1345 1345 goto err; 1346 1346 } 1347 1347 ··· 1359 1359 return 0; 1360 1360 1361 1361 err: 1362 - if (!IS_ERR_OR_NULL(tx_pipe->dma_channel)) 1362 + if (tx_pipe->dma_channel) 1363 1363 knav_dma_close_channel(tx_pipe->dma_channel); 1364 1364 tx_pipe->dma_channel = NULL; 1365 1365 return ret; ··· 1678 1678 1679 1679 netcp->rx_channel = knav_dma_open_channel(netcp->netcp_device->device, 1680 1680 netcp->dma_chan_name, &config); 1681 - if (IS_ERR(netcp->rx_channel)) { 1681 + if (!netcp->rx_channel) { 1682 1682 dev_err(netcp->ndev_dev, "failed opening rx chan(%s\n", 1683 1683 netcp->dma_chan_name); 1684 - ret = PTR_ERR(netcp->rx_channel); 1684 + ret = -EINVAL; 1685 1685 goto fail; 1686 1686 } 1687 1687
+2 -1
drivers/net/ethernet/wangxun/libwx/wx_hw.c
··· 2427 2427 wx->oem_svid = pdev->subsystem_vendor; 2428 2428 wx->oem_ssid = pdev->subsystem_device; 2429 2429 wx->bus.device = PCI_SLOT(pdev->devfn); 2430 - wx->bus.func = PCI_FUNC(pdev->devfn); 2430 + wx->bus.func = FIELD_GET(WX_CFG_PORT_ST_LANID, 2431 + rd32(wx, WX_CFG_PORT_ST)); 2431 2432 2432 2433 if (wx->oem_svid == PCI_VENDOR_ID_WANGXUN || 2433 2434 pdev->is_virtfn) {
+2 -2
drivers/net/ethernet/wangxun/libwx/wx_type.h
··· 97 97 #define WX_CFG_PORT_CTL_DRV_LOAD BIT(3) 98 98 #define WX_CFG_PORT_CTL_QINQ BIT(2) 99 99 #define WX_CFG_PORT_CTL_D_VLAN BIT(0) /* double vlan*/ 100 + #define WX_CFG_PORT_ST 0x14404 101 + #define WX_CFG_PORT_ST_LANID GENMASK(9, 8) 100 102 #define WX_CFG_TAG_TPID(_i) (0x14430 + ((_i) * 4)) 101 103 #define WX_CFG_PORT_CTL_NUM_VT_MASK GENMASK(13, 12) /* number of TVs */ 102 104 ··· 558 556 /* Tx Descriptors needed, worst case */ 559 557 #define TXD_USE_COUNT(S) DIV_ROUND_UP((S), WX_MAX_DATA_PER_TXD) 560 558 #define DESC_NEEDED (MAX_SKB_FRAGS + 4) 561 - 562 - #define WX_CFG_PORT_ST 0x14404 563 559 564 560 /******************* Receive Descriptor bit definitions **********************/ 565 561 #define WX_RXD_STAT_DD BIT(0) /* Done */
+2
drivers/net/mdio/mdio-airoha.c
··· 219 219 priv = bus->priv; 220 220 priv->base_addr = addr; 221 221 priv->regmap = device_node_to_regmap(dev->parent->of_node); 222 + if (IS_ERR(priv->regmap)) 223 + return PTR_ERR(priv->regmap); 222 224 223 225 priv->clk = devm_clk_get_enabled(dev, NULL); 224 226 if (IS_ERR(priv->clk))
+10
drivers/net/netconsole.c
··· 936 936 if (count > MAX_EXTRADATA_VALUE_LEN) 937 937 return -EMSGSIZE; 938 938 939 + mutex_lock(&netconsole_subsys.su_mutex); 939 940 mutex_lock(&dynamic_netconsole_mutex); 940 941 941 942 ret = strscpy(udm->value, buf, sizeof(udm->value)); ··· 950 949 ret = count; 951 950 out_unlock: 952 951 mutex_unlock(&dynamic_netconsole_mutex); 952 + mutex_unlock(&netconsole_subsys.su_mutex); 953 953 return ret; 954 954 } 955 955 ··· 976 974 if (ret) 977 975 return ret; 978 976 977 + mutex_lock(&netconsole_subsys.su_mutex); 979 978 mutex_lock(&dynamic_netconsole_mutex); 980 979 curr = !!(nt->sysdata_fields & SYSDATA_MSGID); 981 980 if (msgid_enabled == curr) ··· 997 994 ret = strnlen(buf, count); 998 995 unlock: 999 996 mutex_unlock(&dynamic_netconsole_mutex); 997 + mutex_unlock(&netconsole_subsys.su_mutex); 1000 998 return ret; 1001 999 } 1002 1000 ··· 1012 1008 if (ret) 1013 1009 return ret; 1014 1010 1011 + mutex_lock(&netconsole_subsys.su_mutex); 1015 1012 mutex_lock(&dynamic_netconsole_mutex); 1016 1013 curr = !!(nt->sysdata_fields & SYSDATA_RELEASE); 1017 1014 if (release_enabled == curr) ··· 1033 1028 ret = strnlen(buf, count); 1034 1029 unlock: 1035 1030 mutex_unlock(&dynamic_netconsole_mutex); 1031 + mutex_unlock(&netconsole_subsys.su_mutex); 1036 1032 return ret; 1037 1033 } 1038 1034 ··· 1048 1042 if (ret) 1049 1043 return ret; 1050 1044 1045 + mutex_lock(&netconsole_subsys.su_mutex); 1051 1046 mutex_lock(&dynamic_netconsole_mutex); 1052 1047 curr = !!(nt->sysdata_fields & SYSDATA_TASKNAME); 1053 1048 if (taskname_enabled == curr) ··· 1069 1062 ret = strnlen(buf, count); 1070 1063 unlock: 1071 1064 mutex_unlock(&dynamic_netconsole_mutex); 1065 + mutex_unlock(&netconsole_subsys.su_mutex); 1072 1066 return ret; 1073 1067 } 1074 1068 ··· 1085 1077 if (ret) 1086 1078 return ret; 1087 1079 1080 + mutex_lock(&netconsole_subsys.su_mutex); 1088 1081 mutex_lock(&dynamic_netconsole_mutex); 1089 1082 curr = !!(nt->sysdata_fields & SYSDATA_CPU_NR); 1090 1083 if (cpu_nr_enabled == curr) ··· 1114 1105 ret = strnlen(buf, count); 1115 1106 unlock: 1116 1107 mutex_unlock(&dynamic_netconsole_mutex); 1108 + mutex_unlock(&netconsole_subsys.su_mutex); 1117 1109 return ret; 1118 1110 } 1119 1111
+4 -1
drivers/net/phy/mdio_bus.c
··· 73 73 return err; 74 74 75 75 err = mdiobus_register_reset(mdiodev); 76 - if (err) 76 + if (err) { 77 + gpiod_put(mdiodev->reset_gpio); 78 + mdiodev->reset_gpio = NULL; 77 79 return err; 80 + } 78 81 79 82 /* Assert the reset signal */ 80 83 mdio_device_reset(mdiodev, 1);
+169 -6
drivers/net/phy/micrel.c
··· 466 466 u16 rev; 467 467 }; 468 468 469 + struct lanphy_reg_data { 470 + int page; 471 + u16 addr; 472 + u16 val; 473 + }; 474 + 469 475 static const struct kszphy_type lan8814_type = { 470 476 .led_mode_reg = ~LAN8814_LED_CTRL_1, 471 477 .cable_diag_reg = LAN8814_CABLE_DIAG, ··· 2842 2836 #define LAN8814_PAGE_PCS_DIGITAL 2 2843 2837 2844 2838 /** 2839 + * LAN8814_PAGE_EEE - Selects Extended Page 3. 2840 + * 2841 + * This page contains EEE registers 2842 + */ 2843 + #define LAN8814_PAGE_EEE 3 2844 + 2845 + /** 2845 2846 * LAN8814_PAGE_COMMON_REGS - Selects Extended Page 4. 2846 2847 * 2847 2848 * This page contains device-common registers that affect the entire chip. ··· 2865 2852 * rate adaptation FIFOs, and the per-port 1588 TSU block. 2866 2853 */ 2867 2854 #define LAN8814_PAGE_PORT_REGS 5 2855 + 2856 + /** 2857 + * LAN8814_PAGE_POWER_REGS - Selects Extended Page 28. 2858 + * 2859 + * This page contains analog control registers and power mode registers. 2860 + */ 2861 + #define LAN8814_PAGE_POWER_REGS 28 2868 2862 2869 2863 /** 2870 2864 * LAN8814_PAGE_SYSTEM_CTRL - Selects Extended Page 31. ··· 4380 4360 { 4381 4361 struct kszphy_priv *lan8814 = phydev->priv; 4382 4362 4383 - /* Reset the PHY */ 4384 - lanphy_modify_page_reg(phydev, LAN8814_PAGE_COMMON_REGS, 4385 - LAN8814_QSGMII_SOFT_RESET, 4386 - LAN8814_QSGMII_SOFT_RESET_BIT, 4387 - LAN8814_QSGMII_SOFT_RESET_BIT); 4388 - 4389 4363 /* Disable ANEG with QSGMII PCS Host side */ 4390 4364 lanphy_modify_page_reg(phydev, LAN8814_PAGE_PORT_REGS, 4391 4365 LAN8814_QSGMII_PCS1G_ANEG_CONFIG, ··· 4465 4451 addr, sizeof(struct lan8814_shared_priv)); 4466 4452 4467 4453 if (phy_package_init_once(phydev)) { 4454 + /* Reset the PHY */ 4455 + lanphy_modify_page_reg(phydev, LAN8814_PAGE_COMMON_REGS, 4456 + LAN8814_QSGMII_SOFT_RESET, 4457 + LAN8814_QSGMII_SOFT_RESET_BIT, 4458 + LAN8814_QSGMII_SOFT_RESET_BIT); 4459 + 4468 4460 err = lan8814_release_coma_mode(phydev); 4469 4461 if (err) 4470 4462 return err; ··· 5904 5884 return 0; 5905 5885 } 5906 5886 5887 + #define LAN8814_POWER_MGMT_MODE_3_ANEG_MDI 0x13 5888 + #define LAN8814_POWER_MGMT_MODE_4_ANEG_MDIX 0x14 5889 + #define LAN8814_POWER_MGMT_MODE_5_10BT_MDI 0x15 5890 + #define LAN8814_POWER_MGMT_MODE_6_10BT_MDIX 0x16 5891 + #define LAN8814_POWER_MGMT_MODE_7_100BT_TRAIN 0x17 5892 + #define LAN8814_POWER_MGMT_MODE_8_100BT_MDI 0x18 5893 + #define LAN8814_POWER_MGMT_MODE_9_100BT_EEE_MDI_TX 0x19 5894 + #define LAN8814_POWER_MGMT_MODE_10_100BT_EEE_MDI_RX 0x1a 5895 + #define LAN8814_POWER_MGMT_MODE_11_100BT_MDIX 0x1b 5896 + #define LAN8814_POWER_MGMT_MODE_12_100BT_EEE_MDIX_TX 0x1c 5897 + #define LAN8814_POWER_MGMT_MODE_13_100BT_EEE_MDIX_RX 0x1d 5898 + #define LAN8814_POWER_MGMT_MODE_14_100BTX_EEE_TX_RX 0x1e 5899 + 5900 + #define LAN8814_POWER_MGMT_DLLPD_D BIT(0) 5901 + #define LAN8814_POWER_MGMT_ADCPD_D BIT(1) 5902 + #define LAN8814_POWER_MGMT_PGAPD_D BIT(2) 5903 + #define LAN8814_POWER_MGMT_TXPD_D BIT(3) 5904 + #define LAN8814_POWER_MGMT_DLLPD_C BIT(4) 5905 + #define LAN8814_POWER_MGMT_ADCPD_C BIT(5) 5906 + #define LAN8814_POWER_MGMT_PGAPD_C BIT(6) 5907 + #define LAN8814_POWER_MGMT_TXPD_C BIT(7) 5908 + #define LAN8814_POWER_MGMT_DLLPD_B BIT(8) 5909 + #define LAN8814_POWER_MGMT_ADCPD_B BIT(9) 5910 + #define LAN8814_POWER_MGMT_PGAPD_B BIT(10) 5911 + #define LAN8814_POWER_MGMT_TXPD_B BIT(11) 5912 + #define LAN8814_POWER_MGMT_DLLPD_A BIT(12) 5913 + #define LAN8814_POWER_MGMT_ADCPD_A BIT(13) 5914 + #define LAN8814_POWER_MGMT_PGAPD_A BIT(14) 5915 + #define LAN8814_POWER_MGMT_TXPD_A BIT(15) 5916 + 5917 + #define LAN8814_POWER_MGMT_C_D (LAN8814_POWER_MGMT_DLLPD_D | \ 5918 + LAN8814_POWER_MGMT_ADCPD_D | \ 5919 + LAN8814_POWER_MGMT_PGAPD_D | \ 5920 + LAN8814_POWER_MGMT_DLLPD_C | \ 5921 + LAN8814_POWER_MGMT_ADCPD_C | \ 5922 + LAN8814_POWER_MGMT_PGAPD_C) 5923 + 5924 + #define LAN8814_POWER_MGMT_B_C_D (LAN8814_POWER_MGMT_C_D | \ 5925 + LAN8814_POWER_MGMT_DLLPD_B | \ 5926 + LAN8814_POWER_MGMT_ADCPD_B | \ 5927 + LAN8814_POWER_MGMT_PGAPD_B) 5928 + 5929 + #define LAN8814_POWER_MGMT_VAL1 (LAN8814_POWER_MGMT_C_D | \ 5930 + LAN8814_POWER_MGMT_ADCPD_B | \ 5931 + LAN8814_POWER_MGMT_PGAPD_B | \ 5932 + LAN8814_POWER_MGMT_ADCPD_A | \ 5933 + LAN8814_POWER_MGMT_PGAPD_A) 5934 + 5935 + #define LAN8814_POWER_MGMT_VAL2 LAN8814_POWER_MGMT_C_D 5936 + 5937 + #define LAN8814_POWER_MGMT_VAL3 (LAN8814_POWER_MGMT_C_D | \ 5938 + LAN8814_POWER_MGMT_DLLPD_B | \ 5939 + LAN8814_POWER_MGMT_ADCPD_B | \ 5940 + LAN8814_POWER_MGMT_PGAPD_A) 5941 + 5942 + #define LAN8814_POWER_MGMT_VAL4 (LAN8814_POWER_MGMT_B_C_D | \ 5943 + LAN8814_POWER_MGMT_ADCPD_A | \ 5944 + LAN8814_POWER_MGMT_PGAPD_A) 5945 + 5946 + #define LAN8814_POWER_MGMT_VAL5 LAN8814_POWER_MGMT_B_C_D 5947 + 5948 + #define LAN8814_EEE_WAKE_TX_TIMER 0x0e 5949 + #define LAN8814_EEE_WAKE_TX_TIMER_MAX_VAL 0x1f 5950 + 5951 + static const struct lanphy_reg_data short_center_tap_errata[] = { 5952 + { LAN8814_PAGE_POWER_REGS, 5953 + LAN8814_POWER_MGMT_MODE_3_ANEG_MDI, 5954 + LAN8814_POWER_MGMT_VAL1 }, 5955 + { LAN8814_PAGE_POWER_REGS, 5956 + LAN8814_POWER_MGMT_MODE_4_ANEG_MDIX, 5957 + LAN8814_POWER_MGMT_VAL1 }, 5958 + { LAN8814_PAGE_POWER_REGS, 5959 + LAN8814_POWER_MGMT_MODE_5_10BT_MDI, 5960 + LAN8814_POWER_MGMT_VAL1 }, 5961 + { LAN8814_PAGE_POWER_REGS, 5962 + LAN8814_POWER_MGMT_MODE_6_10BT_MDIX, 5963 + LAN8814_POWER_MGMT_VAL1 }, 5964 + { LAN8814_PAGE_POWER_REGS, 5965 + LAN8814_POWER_MGMT_MODE_7_100BT_TRAIN, 5966 + LAN8814_POWER_MGMT_VAL2 }, 5967 + { LAN8814_PAGE_POWER_REGS, 5968 + LAN8814_POWER_MGMT_MODE_8_100BT_MDI, 5969 + LAN8814_POWER_MGMT_VAL3 }, 5970 + { LAN8814_PAGE_POWER_REGS, 5971 + LAN8814_POWER_MGMT_MODE_9_100BT_EEE_MDI_TX, 5972 + LAN8814_POWER_MGMT_VAL3 }, 5973 + { LAN8814_PAGE_POWER_REGS, 5974 + LAN8814_POWER_MGMT_MODE_10_100BT_EEE_MDI_RX, 5975 + LAN8814_POWER_MGMT_VAL4 }, 5976 + { LAN8814_PAGE_POWER_REGS, 5977 + LAN8814_POWER_MGMT_MODE_11_100BT_MDIX, 5978 + LAN8814_POWER_MGMT_VAL5 }, 5979 + { LAN8814_PAGE_POWER_REGS, 5980 + LAN8814_POWER_MGMT_MODE_12_100BT_EEE_MDIX_TX, 5981 + LAN8814_POWER_MGMT_VAL5 }, 5982 + { LAN8814_PAGE_POWER_REGS, 5983 + LAN8814_POWER_MGMT_MODE_13_100BT_EEE_MDIX_RX, 5984 + LAN8814_POWER_MGMT_VAL4 }, 5985 + { LAN8814_PAGE_POWER_REGS, 5986 + LAN8814_POWER_MGMT_MODE_14_100BTX_EEE_TX_RX, 5987 + LAN8814_POWER_MGMT_VAL4 }, 5988 + }; 5989 + 5990 + static const struct lanphy_reg_data waketx_timer_errata[] = { 5991 + { LAN8814_PAGE_EEE, 5992 + LAN8814_EEE_WAKE_TX_TIMER, 5993 + LAN8814_EEE_WAKE_TX_TIMER_MAX_VAL }, 5994 + }; 5995 + 5996 + static int lanphy_write_reg_data(struct phy_device *phydev, 5997 + const struct lanphy_reg_data *data, 5998 + size_t num) 5999 + { 6000 + int ret = 0; 6001 + 6002 + while (num--) { 6003 + ret = lanphy_write_page_reg(phydev, data->page, data->addr, 6004 + data->val); 6005 + if (ret) 6006 + break; 6007 + } 6008 + 6009 + return ret; 6010 + } 6011 + 6012 + static int lan8842_erratas(struct phy_device *phydev) 6013 + { 6014 + int ret; 6015 + 6016 + ret = lanphy_write_reg_data(phydev, short_center_tap_errata, 6017 + ARRAY_SIZE(short_center_tap_errata)); 6018 + if (ret) 6019 + return ret; 6020 + 6021 + return lanphy_write_reg_data(phydev, waketx_timer_errata, 6022 + ARRAY_SIZE(waketx_timer_errata)); 6023 + } 6024 + 5907 6025 static int lan8842_config_init(struct phy_device *phydev) 5908 6026 { 5909 6027 int ret; ··· 6051 5893 LAN8814_QSGMII_SOFT_RESET, 6052 5894 LAN8814_QSGMII_SOFT_RESET_BIT, 6053 5895 LAN8814_QSGMII_SOFT_RESET_BIT); 5896 + if (ret < 0) 5897 + return ret; 5898 + 5899 + /* Apply the erratas for this device */ 5900 + ret = lan8842_erratas(phydev); 6054 5901 if (ret < 0) 6055 5902 return ret; 6056 5903
+6
drivers/net/usb/qmi_wwan.c
··· 192 192 if (!skbn) 193 193 return 0; 194 194 195 + /* Raw IP packets don't have a MAC header, but other subsystems 196 + * (like xfrm) may still access MAC header offsets, so they must 197 + * be initialized. 198 + */ 199 + skb_reset_mac_header(skbn); 200 + 195 201 switch (skb->data[offset + qmimux_hdr_sz] & 0xf0) { 196 202 case 0x40: 197 203 skbn->protocol = htons(ETH_P_IP);
+36 -20
drivers/net/virtio_net.c
··· 910 910 goto ok; 911 911 } 912 912 913 - /* 914 - * Verify that we can indeed put this data into a skb. 915 - * This is here to handle cases when the device erroneously 916 - * tries to receive more than is possible. This is usually 917 - * the case of a broken device. 918 - */ 919 - if (unlikely(len > MAX_SKB_FRAGS * PAGE_SIZE)) { 920 - net_dbg_ratelimited("%s: too much data\n", skb->dev->name); 921 - dev_kfree_skb(skb); 922 - return NULL; 923 - } 924 913 BUG_ON(offset >= PAGE_SIZE); 925 914 while (len) { 926 915 unsigned int frag_size = min((unsigned)PAGE_SIZE - offset, len); ··· 2101 2112 struct virtnet_rq_stats *stats) 2102 2113 { 2103 2114 struct page *page = buf; 2104 - struct sk_buff *skb = 2105 - page_to_skb(vi, rq, page, 0, len, PAGE_SIZE, 0); 2115 + struct sk_buff *skb; 2106 2116 2117 + /* Make sure that len does not exceed the size allocated in 2118 + * add_recvbuf_big. 2119 + */ 2120 + if (unlikely(len > (vi->big_packets_num_skbfrags + 1) * PAGE_SIZE)) { 2121 + pr_debug("%s: rx error: len %u exceeds allocated size %lu\n", 2122 + dev->name, len, 2123 + (vi->big_packets_num_skbfrags + 1) * PAGE_SIZE); 2124 + goto err; 2125 + } 2126 + 2127 + skb = page_to_skb(vi, rq, page, 0, len, PAGE_SIZE, 0); 2107 2128 u64_stats_add(&stats->bytes, len - vi->hdr_len); 2108 2129 if (unlikely(!skb)) 2109 2130 goto err; ··· 2538 2539 return NULL; 2539 2540 } 2540 2541 2542 + static inline u32 2543 + virtio_net_hash_value(const struct virtio_net_hdr_v1_hash *hdr_hash) 2544 + { 2545 + return __le16_to_cpu(hdr_hash->hash_value_lo) | 2546 + (__le16_to_cpu(hdr_hash->hash_value_hi) << 16); 2547 + } 2548 + 2541 2549 static void virtio_skb_set_hash(const struct virtio_net_hdr_v1_hash *hdr_hash, 2542 2550 struct sk_buff *skb) 2543 2551 { ··· 2571 2565 default: 2572 2566 rss_hash_type = PKT_HASH_TYPE_NONE; 2573 2567 } 2574 - skb_set_hash(skb, __le32_to_cpu(hdr_hash->hash_value), rss_hash_type); 2568 + skb_set_hash(skb, virtio_net_hash_value(hdr_hash), rss_hash_type); 2575 2569 } 2576 2570 2577 2571 static void virtnet_receive_done(struct virtnet_info *vi, struct receive_queue *rq, ··· 2631 2625 return; 2632 2626 } 2633 2627 2634 - /* 1. Save the flags early, as the XDP program might overwrite them. 2628 + /* About the flags below: 2629 + * 1. Save the flags early, as the XDP program might overwrite them. 2635 2630 * These flags ensure packets marked as VIRTIO_NET_HDR_F_DATA_VALID 2636 2631 * stay valid after XDP processing. 2637 2632 * 2. XDP doesn't work with partially checksummed packets (refer to 2638 2633 * virtnet_xdp_set()), so packets marked as 2639 2634 * VIRTIO_NET_HDR_F_NEEDS_CSUM get dropped during XDP processing. 2640 2635 */ 2641 - flags = ((struct virtio_net_common_hdr *)buf)->hdr.flags; 2642 2636 2643 - if (vi->mergeable_rx_bufs) 2637 + if (vi->mergeable_rx_bufs) { 2638 + flags = ((struct virtio_net_common_hdr *)buf)->hdr.flags; 2644 2639 skb = receive_mergeable(dev, vi, rq, buf, ctx, len, xdp_xmit, 2645 2640 stats); 2646 - else if (vi->big_packets) 2641 + } else if (vi->big_packets) { 2642 + void *p = page_address((struct page *)buf); 2643 + 2644 + flags = ((struct virtio_net_common_hdr *)p)->hdr.flags; 2647 2645 skb = receive_big(dev, vi, rq, buf, len, stats); 2648 - else 2646 + } else { 2647 + flags = ((struct virtio_net_common_hdr *)buf)->hdr.flags; 2649 2648 skb = receive_small(dev, vi, rq, buf, ctx, len, xdp_xmit, stats); 2649 + } 2650 2650 2651 2651 if (unlikely(!skb)) 2652 2652 return; ··· 3322 3310 bool can_push; 3323 3311 3324 3312 pr_debug("%s: xmit %p %pM\n", vi->dev->name, skb, dest); 3313 + 3314 + /* Make sure it's safe to cast between formats */ 3315 + BUILD_BUG_ON(__alignof__(*hdr) != __alignof__(hdr->hash_hdr)); 3316 + BUILD_BUG_ON(__alignof__(*hdr) != __alignof__(hdr->hash_hdr.hdr)); 3325 3317 3326 3318 can_push = vi->any_header_sg && 3327 3319 !((unsigned long)skb->data & (__alignof__(*hdr) - 1)) && ··· 6766 6750 hash_report = VIRTIO_NET_HASH_REPORT_NONE; 6767 6751 6768 6752 *rss_type = virtnet_xdp_rss_type[hash_report]; 6769 - *hash = __le32_to_cpu(hdr_hash->hash_value); 6753 + *hash = virtio_net_hash_value(hdr_hash); 6770 6754 return 0; 6771 6755 } 6772 6756
+4 -3
drivers/net/wan/framer/pef2256/pef2256.c
··· 648 648 audio_devs[i].id = i; 649 649 } 650 650 651 - ret = mfd_add_devices(pef2256->dev, 0, audio_devs, count, NULL, 0, NULL); 651 + ret = devm_mfd_add_devices(pef2256->dev, 0, audio_devs, count, 652 + NULL, 0, NULL); 652 653 kfree(audio_devs); 653 654 return ret; 654 655 } ··· 823 822 824 823 platform_set_drvdata(pdev, pef2256); 825 824 826 - ret = mfd_add_devices(pef2256->dev, 0, pef2256_devs, 827 - ARRAY_SIZE(pef2256_devs), NULL, 0, NULL); 825 + ret = devm_mfd_add_devices(pef2256->dev, 0, pef2256_devs, 826 + ARRAY_SIZE(pef2256_devs), NULL, 0, NULL); 828 827 if (ret) { 829 828 dev_err(pef2256->dev, "add devices failed (%d)\n", ret); 830 829 return ret;
+20 -19
drivers/net/wireless/ath/ath10k/wmi.c
··· 1764 1764 1765 1765 int ath10k_wmi_wait_for_service_ready(struct ath10k *ar) 1766 1766 { 1767 - unsigned long timeout = jiffies + WMI_SERVICE_READY_TIMEOUT_HZ; 1768 1767 unsigned long time_left, i; 1769 1768 1770 - /* Sometimes the PCI HIF doesn't receive interrupt 1771 - * for the service ready message even if the buffer 1772 - * was completed. PCIe sniffer shows that it's 1773 - * because the corresponding CE ring doesn't fires 1774 - * it. Workaround here by polling CE rings. Since 1775 - * the message could arrive at any time, continue 1776 - * polling until timeout. 1777 - */ 1778 - do { 1769 + time_left = wait_for_completion_timeout(&ar->wmi.service_ready, 1770 + WMI_SERVICE_READY_TIMEOUT_HZ); 1771 + if (!time_left) { 1772 + /* Sometimes the PCI HIF doesn't receive interrupt 1773 + * for the service ready message even if the buffer 1774 + * was completed. PCIe sniffer shows that it's 1775 + * because the corresponding CE ring doesn't fires 1776 + * it. Workaround here by polling CE rings once. 1777 + */ 1778 + ath10k_warn(ar, "failed to receive service ready completion, polling..\n"); 1779 + 1779 1780 for (i = 0; i < CE_COUNT; i++) 1780 1781 ath10k_hif_send_complete_check(ar, i, 1); 1781 1782 1782 - /* The 100 ms granularity is a tradeoff considering scheduler 1783 - * overhead and response latency 1784 - */ 1785 1783 time_left = wait_for_completion_timeout(&ar->wmi.service_ready, 1786 - msecs_to_jiffies(100)); 1787 - if (time_left) 1788 - return 0; 1789 - } while (time_before(jiffies, timeout)); 1784 + WMI_SERVICE_READY_TIMEOUT_HZ); 1785 + if (!time_left) { 1786 + ath10k_warn(ar, "polling timed out\n"); 1787 + return -ETIMEDOUT; 1788 + } 1790 1789 1791 - ath10k_warn(ar, "failed to receive service ready completion\n"); 1792 - return -ETIMEDOUT; 1790 + ath10k_warn(ar, "service ready completion received, continuing normally\n"); 1791 + } 1792 + 1793 + return 0; 1793 1794 } 1794 1795 1795 1796 int ath10k_wmi_wait_for_unified_ready(struct ath10k *ar)
+3
drivers/net/wireless/ath/ath11k/wmi.c
··· 5961 5961 dma_unmap_single(ar->ab->dev, skb_cb->paddr, msdu->len, DMA_TO_DEVICE); 5962 5962 5963 5963 info = IEEE80211_SKB_CB(msdu); 5964 + memset(&info->status, 0, sizeof(info->status)); 5965 + info->status.rates[0].idx = -1; 5966 + 5964 5967 if ((!(info->flags & IEEE80211_TX_CTL_NO_ACK)) && 5965 5968 !tx_compl_param->status) { 5966 5969 info->flags |= IEEE80211_TX_STAT_ACK;
+55 -67
drivers/net/wireless/ath/ath12k/mac.c
··· 4064 4064 return ret; 4065 4065 } 4066 4066 4067 - static void ath12k_mac_vif_setup_ps(struct ath12k_link_vif *arvif) 4068 - { 4069 - struct ath12k *ar = arvif->ar; 4070 - struct ieee80211_vif *vif = arvif->ahvif->vif; 4071 - struct ieee80211_conf *conf = &ath12k_ar_to_hw(ar)->conf; 4072 - enum wmi_sta_powersave_param param; 4073 - struct ieee80211_bss_conf *info; 4074 - enum wmi_sta_ps_mode psmode; 4075 - int ret; 4076 - int timeout; 4077 - bool enable_ps; 4078 - 4079 - lockdep_assert_wiphy(ath12k_ar_to_hw(ar)->wiphy); 4080 - 4081 - if (vif->type != NL80211_IFTYPE_STATION) 4082 - return; 4083 - 4084 - enable_ps = arvif->ahvif->ps; 4085 - if (enable_ps) { 4086 - psmode = WMI_STA_PS_MODE_ENABLED; 4087 - param = WMI_STA_PS_PARAM_INACTIVITY_TIME; 4088 - 4089 - timeout = conf->dynamic_ps_timeout; 4090 - if (timeout == 0) { 4091 - info = ath12k_mac_get_link_bss_conf(arvif); 4092 - if (!info) { 4093 - ath12k_warn(ar->ab, "unable to access bss link conf in setup ps for vif %pM link %u\n", 4094 - vif->addr, arvif->link_id); 4095 - return; 4096 - } 4097 - 4098 - /* firmware doesn't like 0 */ 4099 - timeout = ieee80211_tu_to_usec(info->beacon_int) / 1000; 4100 - } 4101 - 4102 - ret = ath12k_wmi_set_sta_ps_param(ar, arvif->vdev_id, param, 4103 - timeout); 4104 - if (ret) { 4105 - ath12k_warn(ar->ab, "failed to set inactivity time for vdev %d: %i\n", 4106 - arvif->vdev_id, ret); 4107 - return; 4108 - } 4109 - } else { 4110 - psmode = WMI_STA_PS_MODE_DISABLED; 4111 - } 4112 - 4113 - ath12k_dbg(ar->ab, ATH12K_DBG_MAC, "mac vdev %d psmode %s\n", 4114 - arvif->vdev_id, psmode ? "enable" : "disable"); 4115 - 4116 - ret = ath12k_wmi_pdev_set_ps_mode(ar, arvif->vdev_id, psmode); 4117 - if (ret) 4118 - ath12k_warn(ar->ab, "failed to set sta power save mode %d for vdev %d: %d\n", 4119 - psmode, arvif->vdev_id, ret); 4120 - } 4121 - 4122 4067 static void ath12k_mac_op_vif_cfg_changed(struct ieee80211_hw *hw, 4123 4068 struct ieee80211_vif *vif, 4124 4069 u64 changed) 4125 4070 { 4126 4071 struct ath12k_vif *ahvif = ath12k_vif_to_ahvif(vif); 4127 4072 unsigned long links = ahvif->links_map; 4128 - struct ieee80211_vif_cfg *vif_cfg; 4129 4073 struct ieee80211_bss_conf *info; 4130 4074 struct ath12k_link_vif *arvif; 4131 4075 struct ieee80211_sta *sta; ··· 4133 4189 } 4134 4190 } 4135 4191 } 4192 + } 4136 4193 4137 - if (changed & BSS_CHANGED_PS) { 4138 - links = ahvif->links_map; 4139 - vif_cfg = &vif->cfg; 4194 + static void ath12k_mac_vif_setup_ps(struct ath12k_link_vif *arvif) 4195 + { 4196 + struct ath12k *ar = arvif->ar; 4197 + struct ieee80211_vif *vif = arvif->ahvif->vif; 4198 + struct ieee80211_conf *conf = &ath12k_ar_to_hw(ar)->conf; 4199 + enum wmi_sta_powersave_param param; 4200 + struct ieee80211_bss_conf *info; 4201 + enum wmi_sta_ps_mode psmode; 4202 + int ret; 4203 + int timeout; 4204 + bool enable_ps; 4140 4205 4141 - for_each_set_bit(link_id, &links, IEEE80211_MLD_MAX_NUM_LINKS) { 4142 - arvif = wiphy_dereference(hw->wiphy, ahvif->link[link_id]); 4143 - if (!arvif || !arvif->ar) 4144 - continue; 4206 + lockdep_assert_wiphy(ath12k_ar_to_hw(ar)->wiphy); 4145 4207 4146 - ar = arvif->ar; 4208 + if (vif->type != NL80211_IFTYPE_STATION) 4209 + return; 4147 4210 4148 - if (ar->ab->hw_params->supports_sta_ps) { 4149 - ahvif->ps = vif_cfg->ps; 4150 - ath12k_mac_vif_setup_ps(arvif); 4211 + enable_ps = arvif->ahvif->ps; 4212 + if (enable_ps) { 4213 + psmode = WMI_STA_PS_MODE_ENABLED; 4214 + param = WMI_STA_PS_PARAM_INACTIVITY_TIME; 4215 + 4216 + timeout = conf->dynamic_ps_timeout; 4217 + if (timeout == 0) { 4218 + info = ath12k_mac_get_link_bss_conf(arvif); 4219 + if (!info) { 4220 + ath12k_warn(ar->ab, "unable to access bss link conf in setup ps for vif %pM link %u\n", 4221 + vif->addr, arvif->link_id); 4222 + return; 4151 4223 } 4224 + 4225 + /* firmware doesn't like 0 */ 4226 + timeout = ieee80211_tu_to_usec(info->beacon_int) / 1000; 4152 4227 } 4228 + 4229 + ret = ath12k_wmi_set_sta_ps_param(ar, arvif->vdev_id, param, 4230 + timeout); 4231 + if (ret) { 4232 + ath12k_warn(ar->ab, "failed to set inactivity time for vdev %d: %i\n", 4233 + arvif->vdev_id, ret); 4234 + return; 4235 + } 4236 + } else { 4237 + psmode = WMI_STA_PS_MODE_DISABLED; 4153 4238 } 4239 + 4240 + ath12k_dbg(ar->ab, ATH12K_DBG_MAC, "mac vdev %d psmode %s\n", 4241 + arvif->vdev_id, psmode ? "enable" : "disable"); 4242 + 4243 + ret = ath12k_wmi_pdev_set_ps_mode(ar, arvif->vdev_id, psmode); 4244 + if (ret) 4245 + ath12k_warn(ar->ab, "failed to set sta power save mode %d for vdev %d: %d\n", 4246 + psmode, arvif->vdev_id, ret); 4154 4247 } 4155 4248 4156 4249 static bool ath12k_mac_supports_tpc(struct ath12k *ar, struct ath12k_vif *ahvif, ··· 4209 4228 { 4210 4229 struct ath12k_vif *ahvif = arvif->ahvif; 4211 4230 struct ieee80211_vif *vif = ath12k_ahvif_to_vif(ahvif); 4231 + struct ieee80211_vif_cfg *vif_cfg = &vif->cfg; 4212 4232 struct cfg80211_chan_def def; 4213 4233 u32 param_id, param_value; 4214 4234 enum nl80211_band band; ··· 4496 4514 } 4497 4515 4498 4516 ath12k_mac_fils_discovery(arvif, info); 4517 + 4518 + if (changed & BSS_CHANGED_PS && 4519 + ar->ab->hw_params->supports_sta_ps) { 4520 + ahvif->ps = vif_cfg->ps; 4521 + ath12k_mac_vif_setup_ps(arvif); 4522 + } 4499 4523 } 4500 4524 4501 4525 static struct ath12k_vif_cache *ath12k_ahvif_get_link_cache(struct ath12k_vif *ahvif,
+1 -6
drivers/net/wireless/intel/iwlwifi/mld/link.c
··· 708 708 iwl_mld_get_chan_load_from_element(struct iwl_mld *mld, 709 709 struct ieee80211_bss_conf *link_conf) 710 710 { 711 - struct ieee80211_vif *vif = link_conf->vif; 712 711 const struct cfg80211_bss_ies *ies; 713 712 const struct element *bss_load_elem = NULL; 714 713 const struct ieee80211_bss_load_elem *bss_load; 715 714 716 715 guard(rcu)(); 717 716 718 - if (ieee80211_vif_link_active(vif, link_conf->link_id)) 719 - ies = rcu_dereference(link_conf->bss->beacon_ies); 720 - else 721 - ies = rcu_dereference(link_conf->bss->ies); 722 - 717 + ies = rcu_dereference(link_conf->bss->beacon_ies); 723 718 if (ies) 724 719 bss_load_elem = cfg80211_find_elem(WLAN_EID_QBSS_LOAD, 725 720 ies->data, ies->len);
+3 -10
drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c
··· 938 938 939 939 u16 iwl_mvm_mac_ctxt_get_beacon_flags(const struct iwl_fw *fw, u8 rate_idx) 940 940 { 941 + u16 flags = iwl_mvm_mac80211_idx_to_hwrate(fw, rate_idx); 941 942 bool is_new_rate = iwl_fw_lookup_cmd_ver(fw, BEACON_TEMPLATE_CMD, 0) > 10; 942 - u16 flags, cck_flag; 943 - 944 - if (is_new_rate) { 945 - flags = iwl_mvm_mac80211_idx_to_hwrate(fw, rate_idx); 946 - cck_flag = IWL_MAC_BEACON_CCK; 947 - } else { 948 - cck_flag = IWL_MAC_BEACON_CCK_V1; 949 - flags = iwl_fw_rate_idx_to_plcp(rate_idx); 950 - } 951 943 952 944 if (rate_idx <= IWL_LAST_CCK_RATE) 953 - flags |= cck_flag; 945 + flags |= is_new_rate ? IWL_MAC_BEACON_CCK 946 + : IWL_MAC_BEACON_CCK_V1; 954 947 955 948 return flags; 956 949 }
+7 -7
drivers/net/wireless/intel/iwlwifi/mvm/time-event.c
··· 463 463 if (!aux_roc_te) /* Not a Aux ROC time event */ 464 464 return -EINVAL; 465 465 466 - iwl_mvm_te_check_trigger(mvm, notif, te_data); 466 + iwl_mvm_te_check_trigger(mvm, notif, aux_roc_te); 467 467 468 468 IWL_DEBUG_TE(mvm, 469 469 "Aux ROC time event notification - UID = 0x%x action %d (error = %d)\n", ··· 475 475 /* End TE, notify mac80211 */ 476 476 ieee80211_remain_on_channel_expired(mvm->hw); 477 477 iwl_mvm_roc_finished(mvm); /* flush aux queue */ 478 - list_del(&te_data->list); /* remove from list */ 479 - te_data->running = false; 480 - te_data->vif = NULL; 481 - te_data->uid = 0; 482 - te_data->id = TE_MAX; 478 + list_del(&aux_roc_te->list); /* remove from list */ 479 + aux_roc_te->running = false; 480 + aux_roc_te->vif = NULL; 481 + aux_roc_te->uid = 0; 482 + aux_roc_te->id = TE_MAX; 483 483 } else if (le32_to_cpu(notif->action) == TE_V2_NOTIF_HOST_EVENT_START) { 484 484 set_bit(IWL_MVM_STATUS_ROC_AUX_RUNNING, &mvm->status); 485 - te_data->running = true; 485 + aux_roc_te->running = true; 486 486 ieee80211_ready_on_channel(mvm->hw); /* Start TE */ 487 487 } else { 488 488 IWL_DEBUG_TE(mvm,
+9 -3
drivers/net/wireless/intel/iwlwifi/mvm/utils.c
··· 159 159 160 160 u8 iwl_mvm_mac80211_idx_to_hwrate(const struct iwl_fw *fw, int rate_idx) 161 161 { 162 - return (rate_idx >= IWL_FIRST_OFDM_RATE ? 163 - rate_idx - IWL_FIRST_OFDM_RATE : 164 - rate_idx); 162 + if (iwl_fw_lookup_cmd_ver(fw, TX_CMD, 0) > 8) 163 + /* In the new rate legacy rates are indexed: 164 + * 0 - 3 for CCK and 0 - 7 for OFDM. 165 + */ 166 + return (rate_idx >= IWL_FIRST_OFDM_RATE ? 167 + rate_idx - IWL_FIRST_OFDM_RATE : 168 + rate_idx); 169 + 170 + return iwl_fw_rate_idx_to_plcp(rate_idx); 165 171 } 166 172 167 173 u8 iwl_mvm_mac80211_ac_to_ucode_ac(enum ieee80211_ac_numbers ac)
+66 -5
drivers/net/wireless/marvell/mwl8k.c
··· 2966 2966 /* 2967 2967 * CMD_SET_BEACON. 2968 2968 */ 2969 + 2970 + static bool mwl8k_beacon_has_ds_params(const u8 *buf, int len) 2971 + { 2972 + const struct ieee80211_mgmt *mgmt = (const void *)buf; 2973 + int ies_len; 2974 + 2975 + if (len <= offsetof(struct ieee80211_mgmt, u.beacon.variable)) 2976 + return false; 2977 + 2978 + ies_len = len - offsetof(struct ieee80211_mgmt, u.beacon.variable); 2979 + 2980 + return cfg80211_find_ie(WLAN_EID_DS_PARAMS, mgmt->u.beacon.variable, 2981 + ies_len) != NULL; 2982 + } 2983 + 2984 + static void mwl8k_beacon_copy_inject_ds_params(struct ieee80211_hw *hw, 2985 + u8 *buf_dst, const u8 *buf_src, 2986 + int src_len) 2987 + { 2988 + const struct ieee80211_mgmt *mgmt = (const void *)buf_src; 2989 + static const u8 before_ds_params[] = { 2990 + WLAN_EID_SSID, 2991 + WLAN_EID_SUPP_RATES, 2992 + }; 2993 + const u8 *ies; 2994 + int hdr_len, left, offs, pos; 2995 + 2996 + ies = mgmt->u.beacon.variable; 2997 + hdr_len = offsetof(struct ieee80211_mgmt, u.beacon.variable); 2998 + 2999 + offs = ieee80211_ie_split(ies, src_len - hdr_len, before_ds_params, 3000 + ARRAY_SIZE(before_ds_params), 0); 3001 + 3002 + pos = hdr_len + offs; 3003 + left = src_len - pos; 3004 + 3005 + memcpy(buf_dst, buf_src, pos); 3006 + 3007 + /* Inject a DSSS Parameter Set after SSID + Supp Rates */ 3008 + buf_dst[pos + 0] = WLAN_EID_DS_PARAMS; 3009 + buf_dst[pos + 1] = 1; 3010 + buf_dst[pos + 2] = hw->conf.chandef.chan->hw_value; 3011 + 3012 + memcpy(buf_dst + pos + 3, buf_src + pos, left); 3013 + } 2969 3014 struct mwl8k_cmd_set_beacon { 2970 3015 struct mwl8k_cmd_pkt_hdr header; 2971 3016 __le16 beacon_len; ··· 3020 2975 static int mwl8k_cmd_set_beacon(struct ieee80211_hw *hw, 3021 2976 struct ieee80211_vif *vif, u8 *beacon, int len) 3022 2977 { 2978 + bool ds_params_present = mwl8k_beacon_has_ds_params(beacon, len); 3023 2979 struct mwl8k_cmd_set_beacon *cmd; 3024 - int rc; 2980 + int rc, final_len = len; 3025 2981 3026 - cmd = kzalloc(sizeof(*cmd) + len, GFP_KERNEL); 2982 + if (!ds_params_present) { 2983 + /* 2984 + * mwl8k firmware requires a DS Params IE with the current 2985 + * channel in AP beacons. If mac80211/hostapd does not 2986 + * include it, inject one here. IE ID + length + channel 2987 + * number = 3 bytes. 2988 + */ 2989 + final_len += 3; 2990 + } 2991 + 2992 + cmd = kzalloc(sizeof(*cmd) + final_len, GFP_KERNEL); 3027 2993 if (cmd == NULL) 3028 2994 return -ENOMEM; 3029 2995 3030 2996 cmd->header.code = cpu_to_le16(MWL8K_CMD_SET_BEACON); 3031 - cmd->header.length = cpu_to_le16(sizeof(*cmd) + len); 3032 - cmd->beacon_len = cpu_to_le16(len); 3033 - memcpy(cmd->beacon, beacon, len); 2997 + cmd->header.length = cpu_to_le16(sizeof(*cmd) + final_len); 2998 + cmd->beacon_len = cpu_to_le16(final_len); 2999 + 3000 + if (ds_params_present) 3001 + memcpy(cmd->beacon, beacon, len); 3002 + else 3003 + mwl8k_beacon_copy_inject_ds_params(hw, cmd->beacon, beacon, 3004 + len); 3034 3005 3035 3006 rc = mwl8k_post_pervif_cmd(hw, vif, &cmd->header); 3036 3007 kfree(cmd);
+14 -7
drivers/net/wireless/virtual/mac80211_hwsim.c
··· 2003 2003 struct ieee80211_sta *sta = control->sta; 2004 2004 struct ieee80211_bss_conf *bss_conf; 2005 2005 2006 + /* This can happen in case of monitor injection */ 2007 + if (!vif) { 2008 + ieee80211_free_txskb(hw, skb); 2009 + return; 2010 + } 2011 + 2006 2012 if (link != IEEE80211_LINK_UNSPECIFIED) { 2007 - bss_conf = rcu_dereference(txi->control.vif->link_conf[link]); 2013 + bss_conf = rcu_dereference(vif->link_conf[link]); 2008 2014 if (sta) 2009 2015 link_sta = rcu_dereference(sta->link[link]); 2010 2016 } else { ··· 2071 2065 return; 2072 2066 } 2073 2067 2074 - if (txi->control.vif) 2075 - hwsim_check_magic(txi->control.vif); 2068 + if (vif) 2069 + hwsim_check_magic(vif); 2076 2070 if (control->sta) 2077 2071 hwsim_check_sta_magic(control->sta); 2078 2072 2079 2073 if (ieee80211_hw_check(hw, SUPPORTS_RC_TABLE)) 2080 - ieee80211_get_tx_rates(txi->control.vif, control->sta, skb, 2074 + ieee80211_get_tx_rates(vif, control->sta, skb, 2081 2075 txi->control.rates, 2082 2076 ARRAY_SIZE(txi->control.rates)); 2083 2077 ··· 6704 6698 .n_mcgrps = ARRAY_SIZE(hwsim_mcgrps), 6705 6699 }; 6706 6700 6707 - static void remove_user_radios(u32 portid) 6701 + static void remove_user_radios(u32 portid, int netgroup) 6708 6702 { 6709 6703 struct mac80211_hwsim_data *entry, *tmp; 6710 6704 LIST_HEAD(list); 6711 6705 6712 6706 spin_lock_bh(&hwsim_radio_lock); 6713 6707 list_for_each_entry_safe(entry, tmp, &hwsim_radios, list) { 6714 - if (entry->destroy_on_close && entry->portid == portid) { 6708 + if (entry->destroy_on_close && entry->portid == portid && 6709 + entry->netgroup == netgroup) { 6715 6710 list_move(&entry->list, &list); 6716 6711 rhashtable_remove_fast(&hwsim_radios_rht, &entry->rht, 6717 6712 hwsim_rht_params); ··· 6737 6730 if (state != NETLINK_URELEASE) 6738 6731 return NOTIFY_DONE; 6739 6732 6740 - remove_user_radios(notify->portid); 6733 + remove_user_radios(notify->portid, hwsim_net_get_netgroup(notify->net)); 6741 6734 6742 6735 if (notify->portid == hwsim_net_get_wmediumd(notify->net)) { 6743 6736 printk(KERN_INFO "mac80211_hwsim: wmediumd released netlink"
+1
drivers/net/wireless/zydas/zd1211rw/zd_usb.c
··· 791 791 if (urbs) { 792 792 for (i = 0; i < RX_URBS_COUNT; i++) 793 793 free_rx_urb(urbs[i]); 794 + kfree(urbs); 794 795 } 795 796 return r; 796 797 }
+2
drivers/pci/pci.h
··· 958 958 void pci_restore_aspm_l1ss_state(struct pci_dev *dev); 959 959 960 960 #ifdef CONFIG_PCIEASPM 961 + void pcie_aspm_remove_cap(struct pci_dev *pdev, u32 lnkcap); 961 962 void pcie_aspm_init_link_state(struct pci_dev *pdev); 962 963 void pcie_aspm_exit_link_state(struct pci_dev *pdev); 963 964 void pcie_aspm_pm_state_change(struct pci_dev *pdev, bool locked); ··· 966 965 void pci_configure_ltr(struct pci_dev *pdev); 967 966 void pci_bridge_reconfigure_ltr(struct pci_dev *pdev); 968 967 #else 968 + static inline void pcie_aspm_remove_cap(struct pci_dev *pdev, u32 lnkcap) { } 969 969 static inline void pcie_aspm_init_link_state(struct pci_dev *pdev) { } 970 970 static inline void pcie_aspm_exit_link_state(struct pci_dev *pdev) { } 971 971 static inline void pcie_aspm_pm_state_change(struct pci_dev *pdev, bool locked) { }
+17 -8
drivers/pci/pcie/aspm.c
··· 814 814 static void pcie_aspm_cap_init(struct pcie_link_state *link, int blacklist) 815 815 { 816 816 struct pci_dev *child = link->downstream, *parent = link->pdev; 817 - u32 parent_lnkcap, child_lnkcap; 818 817 u16 parent_lnkctl, child_lnkctl; 819 818 struct pci_bus *linkbus = parent->subordinate; 820 819 ··· 828 829 * If ASPM not supported, don't mess with the clocks and link, 829 830 * bail out now. 830 831 */ 831 - pcie_capability_read_dword(parent, PCI_EXP_LNKCAP, &parent_lnkcap); 832 - pcie_capability_read_dword(child, PCI_EXP_LNKCAP, &child_lnkcap); 833 - if (!(parent_lnkcap & child_lnkcap & PCI_EXP_LNKCAP_ASPMS)) 832 + if (!(parent->aspm_l0s_support && child->aspm_l0s_support) && 833 + !(parent->aspm_l1_support && child->aspm_l1_support)) 834 834 return; 835 835 836 836 /* Configure common clock before checking latencies */ ··· 841 843 * read-only Link Capabilities may change depending on common clock 842 844 * configuration (PCIe r5.0, sec 7.5.3.6). 843 845 */ 844 - pcie_capability_read_dword(parent, PCI_EXP_LNKCAP, &parent_lnkcap); 845 - pcie_capability_read_dword(child, PCI_EXP_LNKCAP, &child_lnkcap); 846 846 pcie_capability_read_word(parent, PCI_EXP_LNKCTL, &parent_lnkctl); 847 847 pcie_capability_read_word(child, PCI_EXP_LNKCTL, &child_lnkctl); 848 848 ··· 860 864 * given link unless components on both sides of the link each 861 865 * support L0s. 862 866 */ 863 - if (parent_lnkcap & child_lnkcap & PCI_EXP_LNKCAP_ASPM_L0S) 867 + if (parent->aspm_l0s_support && child->aspm_l0s_support) 864 868 link->aspm_support |= PCIE_LINK_STATE_L0S; 865 869 866 870 if (child_lnkctl & PCI_EXP_LNKCTL_ASPM_L0S) ··· 869 873 link->aspm_enabled |= PCIE_LINK_STATE_L0S_DW; 870 874 871 875 /* Setup L1 state */ 872 - if (parent_lnkcap & child_lnkcap & PCI_EXP_LNKCAP_ASPM_L1) 876 + if (parent->aspm_l1_support && child->aspm_l1_support) 873 877 link->aspm_support |= PCIE_LINK_STATE_L1; 874 878 875 879 if (parent_lnkctl & child_lnkctl & PCI_EXP_LNKCTL_ASPM_L1) ··· 1525 1529 return __pci_enable_link_state(pdev, state, true); 1526 1530 } 1527 1531 EXPORT_SYMBOL(pci_enable_link_state_locked); 1532 + 1533 + void pcie_aspm_remove_cap(struct pci_dev *pdev, u32 lnkcap) 1534 + { 1535 + if (lnkcap & PCI_EXP_LNKCAP_ASPM_L0S) 1536 + pdev->aspm_l0s_support = 0; 1537 + if (lnkcap & PCI_EXP_LNKCAP_ASPM_L1) 1538 + pdev->aspm_l1_support = 0; 1539 + 1540 + pci_info(pdev, "ASPM: Link Capabilities%s%s treated as unsupported to avoid device defect\n", 1541 + lnkcap & PCI_EXP_LNKCAP_ASPM_L0S ? " L0s" : "", 1542 + lnkcap & PCI_EXP_LNKCAP_ASPM_L1 ? " L1" : ""); 1543 + 1544 + } 1528 1545 1529 1546 static int pcie_aspm_set_policy(const char *val, 1530 1547 const struct kernel_param *kp)
+7
drivers/pci/probe.c
··· 1656 1656 if (reg32 & PCI_EXP_LNKCAP_DLLLARC) 1657 1657 pdev->link_active_reporting = 1; 1658 1658 1659 + #ifdef CONFIG_PCIEASPM 1660 + if (reg32 & PCI_EXP_LNKCAP_ASPM_L0S) 1661 + pdev->aspm_l0s_support = 1; 1662 + if (reg32 & PCI_EXP_LNKCAP_ASPM_L1) 1663 + pdev->aspm_l1_support = 1; 1664 + #endif 1665 + 1659 1666 parent = pci_upstream_bridge(pdev); 1660 1667 if (!parent) 1661 1668 return;
+21 -19
drivers/pci/quirks.c
··· 2494 2494 */ 2495 2495 static void quirk_disable_aspm_l0s(struct pci_dev *dev) 2496 2496 { 2497 - pci_info(dev, "Disabling L0s\n"); 2498 - pci_disable_link_state(dev, PCIE_LINK_STATE_L0S); 2497 + pcie_aspm_remove_cap(dev, PCI_EXP_LNKCAP_ASPM_L0S); 2499 2498 } 2500 - DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x10a7, quirk_disable_aspm_l0s); 2501 - DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x10a9, quirk_disable_aspm_l0s); 2502 - DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x10b6, quirk_disable_aspm_l0s); 2503 - DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x10c6, quirk_disable_aspm_l0s); 2504 - DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x10c7, quirk_disable_aspm_l0s); 2505 - DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x10c8, quirk_disable_aspm_l0s); 2506 - DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x10d6, quirk_disable_aspm_l0s); 2507 - DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x10db, quirk_disable_aspm_l0s); 2508 - DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x10dd, quirk_disable_aspm_l0s); 2509 - DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x10e1, quirk_disable_aspm_l0s); 2510 - DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x10ec, quirk_disable_aspm_l0s); 2511 - DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x10f1, quirk_disable_aspm_l0s); 2512 - DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x10f4, quirk_disable_aspm_l0s); 2513 - DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x1508, quirk_disable_aspm_l0s); 2499 + DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x10a7, quirk_disable_aspm_l0s); 2500 + DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x10a9, quirk_disable_aspm_l0s); 2501 + DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x10b6, quirk_disable_aspm_l0s); 2502 + DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x10c6, quirk_disable_aspm_l0s); 2503 + DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x10c7, quirk_disable_aspm_l0s); 2504 + DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x10c8, quirk_disable_aspm_l0s); 2505 + DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x10d6, quirk_disable_aspm_l0s); 2506 + DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x10db, quirk_disable_aspm_l0s); 2507 + DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x10dd, quirk_disable_aspm_l0s); 2508 + DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x10e1, quirk_disable_aspm_l0s); 2509 + DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x10ec, quirk_disable_aspm_l0s); 2510 + DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x10f1, quirk_disable_aspm_l0s); 2511 + DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x10f4, quirk_disable_aspm_l0s); 2512 + DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x1508, quirk_disable_aspm_l0s); 2514 2513 2515 2514 static void quirk_disable_aspm_l0s_l1(struct pci_dev *dev) 2516 2515 { 2517 - pci_info(dev, "Disabling ASPM L0s/L1\n"); 2518 - pci_disable_link_state(dev, PCIE_LINK_STATE_L0S | PCIE_LINK_STATE_L1); 2516 + pcie_aspm_remove_cap(dev, 2517 + PCI_EXP_LNKCAP_ASPM_L0S | PCI_EXP_LNKCAP_ASPM_L1); 2519 2518 } 2520 2519 2521 2520 /* ··· 2522 2523 * upstream PCIe root port when ASPM is enabled. At least L0s mode is affected; 2523 2524 * disable both L0s and L1 for now to be safe. 2524 2525 */ 2525 - DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ASMEDIA, 0x1080, quirk_disable_aspm_l0s_l1); 2526 + DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ASMEDIA, 0x1080, quirk_disable_aspm_l0s_l1); 2527 + DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_FREESCALE, 0x0451, quirk_disable_aspm_l0s_l1); 2528 + DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_PASEMI, 0xa002, quirk_disable_aspm_l0s_l1); 2529 + DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_HUAWEI, 0x1105, quirk_disable_aspm_l0s_l1); 2526 2530 2527 2531 /* 2528 2532 * Some Pericom PCIe-to-PCI bridges in reverse mode need the PCIe Retrain
+1 -1
drivers/platform/x86/Kconfig
··· 432 432 depends on INPUT 433 433 help 434 434 This driver provides supports for the wireless buttons found on some AMD, 435 - HP, & Xioami laptops. 435 + HP, & Xiaomi laptops. 436 436 On such systems the driver should load automatically (via ACPI alias). 437 437 438 438 To compile this driver as a module, choose M here: the module will
+12
drivers/platform/x86/dell/dell-wmi-base.c
··· 365 365 /* Backlight brightness change event */ 366 366 { KE_IGNORE, 0x0003, { KEY_RESERVED } }, 367 367 368 + /* 369 + * Electronic privacy screen toggled, extended data gives state, 370 + * separate entries for on/off see handling in dell_wmi_process_key(). 371 + */ 372 + { KE_KEY, 0x000c, { KEY_EPRIVACY_SCREEN_OFF } }, 373 + { KE_KEY, 0x000c, { KEY_EPRIVACY_SCREEN_ON } }, 374 + 368 375 /* Ultra-performance mode switch request */ 369 376 { KE_IGNORE, 0x000d, { KEY_RESERVED } }, 370 377 ··· 442 435 "Dell tablet mode switch", 443 436 SW_TABLET_MODE, !buffer[0]); 444 437 return 1; 438 + } else if (type == 0x0012 && code == 0x000c && remaining > 0) { 439 + /* Eprivacy toggle, switch to "on" key entry for on events */ 440 + if (buffer[0] == 2) 441 + key++; 442 + used = 1; 445 443 } else if (type == 0x0012 && code == 0x000d && remaining > 0) { 446 444 value = (buffer[2] == 2); 447 445 used = 1;
+1 -4
drivers/platform/x86/intel/int3472/clk_and_regulator.c
··· 245 245 if (IS_ERR(regulator->rdev)) 246 246 return PTR_ERR(regulator->rdev); 247 247 248 - int3472->regulators[int3472->n_regulator_gpios].ena_gpio = gpio; 249 248 int3472->n_regulator_gpios++; 250 249 return 0; 251 250 } 252 251 253 252 void skl_int3472_unregister_regulator(struct int3472_discrete_device *int3472) 254 253 { 255 - for (int i = 0; i < int3472->n_regulator_gpios; i++) { 254 + for (int i = 0; i < int3472->n_regulator_gpios; i++) 256 255 regulator_unregister(int3472->regulators[i].rdev); 257 - gpiod_put(int3472->regulators[i].ena_gpio); 258 - } 259 256 }
+1 -1
drivers/platform/x86/intel/int3472/led.c
··· 43 43 44 44 int3472->pled.lookup.provider = int3472->pled.name; 45 45 int3472->pled.lookup.dev_id = int3472->sensor_name; 46 - int3472->pled.lookup.con_id = "privacy-led"; 46 + int3472->pled.lookup.con_id = "privacy"; 47 47 led_add_lookup(&int3472->pled.lookup); 48 48 49 49 return 0;
+11 -2
drivers/pmdomain/arm/scmi_pm_domain.c
··· 41 41 42 42 static int scmi_pm_domain_probe(struct scmi_device *sdev) 43 43 { 44 - int num_domains, i; 44 + int num_domains, i, ret; 45 45 struct device *dev = &sdev->dev; 46 46 struct device_node *np = dev->of_node; 47 47 struct scmi_pm_domain *scmi_pd; ··· 108 108 scmi_pd_data->domains = domains; 109 109 scmi_pd_data->num_domains = num_domains; 110 110 111 + ret = of_genpd_add_provider_onecell(np, scmi_pd_data); 112 + if (ret) 113 + goto err_rm_genpds; 114 + 111 115 dev_set_drvdata(dev, scmi_pd_data); 112 116 113 - return of_genpd_add_provider_onecell(np, scmi_pd_data); 117 + return 0; 118 + err_rm_genpds: 119 + for (i = num_domains - 1; i >= 0; i--) 120 + pm_genpd_remove(domains[i]); 121 + 122 + return ret; 114 123 } 115 124 116 125 static void scmi_pm_domain_remove(struct scmi_device *sdev)
+2
drivers/pmdomain/imx/gpc.c
··· 536 536 return; 537 537 } 538 538 } 539 + 540 + of_node_put(pgc_node); 539 541 } 540 542 541 543 static struct platform_driver imx_gpc_driver = {
+14 -15
drivers/pmdomain/samsung/exynos-pm-domains.c
··· 92 92 { }, 93 93 }; 94 94 95 - static const char *exynos_get_domain_name(struct device_node *node) 95 + static const char *exynos_get_domain_name(struct device *dev, 96 + struct device_node *node) 96 97 { 97 98 const char *name; 98 99 99 100 if (of_property_read_string(node, "label", &name) < 0) 100 101 name = kbasename(node->full_name); 101 - return kstrdup_const(name, GFP_KERNEL); 102 + return devm_kstrdup_const(dev, name, GFP_KERNEL); 102 103 } 103 104 104 105 static int exynos_pd_probe(struct platform_device *pdev) ··· 116 115 if (!pd) 117 116 return -ENOMEM; 118 117 119 - pd->pd.name = exynos_get_domain_name(np); 118 + pd->pd.name = exynos_get_domain_name(dev, np); 120 119 if (!pd->pd.name) 121 120 return -ENOMEM; 122 121 123 122 pd->base = of_iomap(np, 0); 124 - if (!pd->base) { 125 - kfree_const(pd->pd.name); 123 + if (!pd->base) 126 124 return -ENODEV; 127 - } 128 125 129 126 pd->pd.power_off = exynos_pd_power_off; 130 127 pd->pd.power_on = exynos_pd_power_on; 131 128 pd->local_pwr_cfg = pm_domain_cfg->local_pwr_cfg; 129 + 130 + /* 131 + * Some Samsung platforms with bootloaders turning on the splash-screen 132 + * and handing it over to the kernel, requires the power-domains to be 133 + * reset during boot. 134 + */ 135 + if (IS_ENABLED(CONFIG_ARM) && 136 + of_device_is_compatible(np, "samsung,exynos4210-pd")) 137 + exynos_pd_power_off(&pd->pd); 132 138 133 139 on = readl_relaxed(pd->base + 0x4) & pd->local_pwr_cfg; 134 140 ··· 154 146 pr_info("%pOF has as child subdomain: %pOF.\n", 155 147 parent.np, child.np); 156 148 } 157 - 158 - /* 159 - * Some Samsung platforms with bootloaders turning on the splash-screen 160 - * and handing it over to the kernel, requires the power-domains to be 161 - * reset during boot. As a temporary hack to manage this, let's enforce 162 - * a sync_state. 163 - */ 164 - if (!ret) 165 - of_genpd_sync_state(np); 166 149 167 150 pm_runtime_enable(dev); 168 151 return ret;
+4
drivers/ptp/ptp_chardev.c
··· 561 561 return ptp_mask_en_single(pccontext->private_clkdata, argptr); 562 562 563 563 case PTP_SYS_OFFSET_PRECISE_CYCLES: 564 + if (!ptp->has_cycles) 565 + return -EOPNOTSUPP; 564 566 return ptp_sys_offset_precise(ptp, argptr, 565 567 ptp->info->getcrosscycles); 566 568 567 569 case PTP_SYS_OFFSET_EXTENDED_CYCLES: 570 + if (!ptp->has_cycles) 571 + return -EOPNOTSUPP; 568 572 return ptp_sys_offset_extended(ptp, argptr, 569 573 ptp->info->getcyclesx64); 570 574 default:
+1
drivers/regulator/fixed.c
··· 334 334 ret = dev_err_probe(&pdev->dev, PTR_ERR(drvdata->dev), 335 335 "Failed to register regulator: %ld\n", 336 336 PTR_ERR(drvdata->dev)); 337 + gpiod_put(cfg.ena_gpiod); 337 338 return ret; 338 339 } 339 340
-1
drivers/rtc/rtc-cpcap.c
··· 268 268 return err; 269 269 270 270 rtc->alarm_irq = platform_get_irq(pdev, 0); 271 - rtc->alarm_enabled = true; 272 271 err = devm_request_threaded_irq(dev, rtc->alarm_irq, NULL, 273 272 cpcap_rtc_alarm_irq, 274 273 IRQF_TRIGGER_NONE | IRQF_ONESHOT,
+1 -1
drivers/rtc/rtc-rx8025.c
··· 316 316 return hour_reg; 317 317 rx8025->is_24 = (hour_reg & RX8035_BIT_HOUR_1224); 318 318 } else { 319 - rx8025->is_24 = (ctrl[1] & RX8025_BIT_CTRL1_1224); 319 + rx8025->is_24 = (ctrl[0] & RX8025_BIT_CTRL1_1224); 320 320 } 321 321 out: 322 322 return err;
-1
drivers/rtc/rtc-tps6586x.c
··· 258 258 259 259 irq_set_status_flags(rtc->irq, IRQ_NOAUTOEN); 260 260 261 - rtc->irq_en = true; 262 261 ret = devm_request_threaded_irq(&pdev->dev, rtc->irq, NULL, 263 262 tps6586x_rtc_irq, 264 263 IRQF_ONESHOT,
+7 -7
drivers/soc/ti/knav_dma.c
··· 402 402 * @name: slave channel name 403 403 * @config: dma configuration parameters 404 404 * 405 - * Returns pointer to appropriate DMA channel on success or error. 405 + * Return: Pointer to appropriate DMA channel on success or NULL on error. 406 406 */ 407 407 void *knav_dma_open_channel(struct device *dev, const char *name, 408 408 struct knav_dma_cfg *config) ··· 414 414 415 415 if (!kdev) { 416 416 pr_err("keystone-navigator-dma driver not registered\n"); 417 - return (void *)-EINVAL; 417 + return NULL; 418 418 } 419 419 420 420 chan_num = of_channel_match_helper(dev->of_node, name, &instance); 421 421 if (chan_num < 0) { 422 422 dev_err(kdev->dev, "No DMA instance with name %s\n", name); 423 - return (void *)-EINVAL; 423 + return NULL; 424 424 } 425 425 426 426 dev_dbg(kdev->dev, "initializing %s channel %d from DMA %s\n", ··· 431 431 if (config->direction != DMA_MEM_TO_DEV && 432 432 config->direction != DMA_DEV_TO_MEM) { 433 433 dev_err(kdev->dev, "bad direction\n"); 434 - return (void *)-EINVAL; 434 + return NULL; 435 435 } 436 436 437 437 /* Look for correct dma instance */ ··· 443 443 } 444 444 if (!dma) { 445 445 dev_err(kdev->dev, "No DMA instance with name %s\n", instance); 446 - return (void *)-EINVAL; 446 + return NULL; 447 447 } 448 448 449 449 /* Look for correct dma channel from dma instance */ ··· 463 463 if (!chan) { 464 464 dev_err(kdev->dev, "channel %d is not in DMA %s\n", 465 465 chan_num, instance); 466 - return (void *)-EINVAL; 466 + return NULL; 467 467 } 468 468 469 469 if (atomic_read(&chan->ref_count) >= 1) { 470 470 if (!check_config(chan, config)) { 471 471 dev_err(kdev->dev, "channel %d config miss-match\n", 472 472 chan_num); 473 - return (void *)-EINVAL; 473 + return NULL; 474 474 } 475 475 } 476 476
+11 -4
drivers/spi/spi-imx.c
··· 519 519 { 520 520 u32 reg; 521 521 522 - reg = readl(spi_imx->base + MX51_ECSPI_CTRL); 523 - reg |= MX51_ECSPI_CTRL_XCH; 524 - writel(reg, spi_imx->base + MX51_ECSPI_CTRL); 522 + if (spi_imx->usedma) { 523 + reg = readl(spi_imx->base + MX51_ECSPI_DMA); 524 + reg |= MX51_ECSPI_DMA_TEDEN | MX51_ECSPI_DMA_RXDEN; 525 + writel(reg, spi_imx->base + MX51_ECSPI_DMA); 526 + } else { 527 + reg = readl(spi_imx->base + MX51_ECSPI_CTRL); 528 + reg |= MX51_ECSPI_CTRL_XCH; 529 + writel(reg, spi_imx->base + MX51_ECSPI_CTRL); 530 + } 525 531 } 526 532 527 533 static void mx51_ecspi_disable(struct spi_imx_data *spi_imx) ··· 765 759 writel(MX51_ECSPI_DMA_RX_WML(spi_imx->wml - 1) | 766 760 MX51_ECSPI_DMA_TX_WML(tx_wml) | 767 761 MX51_ECSPI_DMA_RXT_WML(spi_imx->wml) | 768 - MX51_ECSPI_DMA_TEDEN | MX51_ECSPI_DMA_RXDEN | 769 762 MX51_ECSPI_DMA_RXTDEN, spi_imx->base + MX51_ECSPI_DMA); 770 763 } 771 764 ··· 1524 1519 dmaengine_submit(desc_tx); 1525 1520 reinit_completion(&spi_imx->dma_tx_completion); 1526 1521 dma_async_issue_pending(controller->dma_tx); 1522 + 1523 + spi_imx->devtype_data->trigger(spi_imx); 1527 1524 1528 1525 transfer_timeout = spi_imx_calculate_timeout(spi_imx, transfer->len); 1529 1526
+1 -1
drivers/spi/spi-xilinx.c
··· 300 300 301 301 /* Read out all the data from the Rx FIFO */ 302 302 rx_words = n_words; 303 - stalled = 10; 303 + stalled = 32; 304 304 while (rx_words) { 305 305 if (rx_words == n_words && !(stalled--) && 306 306 !(sr & XSPI_SR_TX_EMPTY_MASK) &&
+12
drivers/spi/spi.c
··· 2851 2851 acpi_set_modalias(adev, acpi_device_hid(adev), spi->modalias, 2852 2852 sizeof(spi->modalias)); 2853 2853 2854 + /* 2855 + * This gets re-tried in spi_probe() for -EPROBE_DEFER handling in case 2856 + * the GPIO controller does not have a driver yet. This needs to be done 2857 + * here too, because this call sets the GPIO direction and/or bias. 2858 + * Setting these needs to be done even if there is no driver, in which 2859 + * case spi_probe() will never get called. 2860 + * TODO: ideally the setup of the GPIO should be handled in a generic 2861 + * manner in the ACPI/gpiolib core code. 2862 + */ 2863 + if (spi->irq < 0) 2864 + spi->irq = acpi_dev_gpio_irq_get(adev, 0); 2865 + 2854 2866 acpi_device_set_enumerated(adev); 2855 2867 2856 2868 adev->power.flags.ignore_parent = true;
+1 -1
drivers/ufs/core/ufs-sysfs.c
··· 1949 1949 return hba->dev_info.hid_sup ? attr->mode : 0; 1950 1950 } 1951 1951 1952 - const struct attribute_group ufs_sysfs_hid_group = { 1952 + static const struct attribute_group ufs_sysfs_hid_group = { 1953 1953 .name = "hid", 1954 1954 .attrs = ufs_sysfs_hid, 1955 1955 .is_visible = ufs_sysfs_hid_is_visible,
-1
drivers/ufs/core/ufs-sysfs.h
··· 14 14 15 15 extern const struct attribute_group ufs_sysfs_unit_descriptor_group; 16 16 extern const struct attribute_group ufs_sysfs_lun_attributes_group; 17 - extern const struct attribute_group ufs_sysfs_hid_group; 18 17 19 18 #endif
+6 -11
drivers/ufs/core/ufshcd.c
··· 5066 5066 * If UFS device isn't active then we will have to issue link startup 5067 5067 * 2 times to make sure the device state move to active. 5068 5068 */ 5069 - if (!ufshcd_is_ufs_dev_active(hba)) 5069 + if (!(hba->quirks & UFSHCD_QUIRK_PERFORM_LINK_STARTUP_ONCE) && 5070 + !ufshcd_is_ufs_dev_active(hba)) 5070 5071 link_startup_again = true; 5071 5072 5072 5073 link_startup: ··· 5132 5131 ufshcd_readl(hba, REG_UIC_ERROR_CODE_PHY_ADAPTER_LAYER); 5133 5132 ret = ufshcd_make_hba_operational(hba); 5134 5133 out: 5135 - if (ret) { 5134 + if (ret) 5136 5135 dev_err(hba->dev, "link startup failed %d\n", ret); 5137 - ufshcd_print_host_state(hba); 5138 - ufshcd_print_pwr_info(hba); 5139 - ufshcd_print_evt_hist(hba); 5140 - } 5141 5136 return ret; 5142 5137 } 5143 5138 ··· 8500 8503 DEVICE_DESC_PARAM_EXT_UFS_FEATURE_SUP) & 8501 8504 UFS_DEV_HID_SUPPORT; 8502 8505 8503 - sysfs_update_group(&hba->dev->kobj, &ufs_sysfs_hid_group); 8504 - 8505 8506 model_index = desc_buf[DEVICE_DESC_PARAM_PRDCT_NAME]; 8506 8507 8507 8508 err = ufshcd_read_string_desc(hba, model_index, ··· 10656 10661 * @mmio_base: base register address 10657 10662 * @irq: Interrupt line of device 10658 10663 * 10659 - * Return: 0 on success, non-zero value on failure. 10664 + * Return: 0 on success; < 0 on failure. 10660 10665 */ 10661 10666 int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq) 10662 10667 { ··· 10886 10891 if (err) 10887 10892 goto out_disable; 10888 10893 10889 - async_schedule(ufshcd_async_scan, hba); 10890 10894 ufs_sysfs_add_nodes(hba->dev); 10895 + async_schedule(ufshcd_async_scan, hba); 10891 10896 10892 10897 device_enable_async_suspend(dev); 10893 10898 ufshcd_pm_qos_init(hba); ··· 10897 10902 hba->is_irq_enabled = false; 10898 10903 ufshcd_hba_exit(hba); 10899 10904 out_error: 10900 - return err; 10905 + return err > 0 ? -EIO : err; 10901 10906 } 10902 10907 EXPORT_SYMBOL_GPL(ufshcd_init); 10903 10908
+14 -1
drivers/ufs/host/ufs-qcom.c
··· 740 740 741 741 742 742 /* reset the connected UFS device during power down */ 743 - if (ufs_qcom_is_link_off(hba) && host->device_reset) 743 + if (ufs_qcom_is_link_off(hba) && host->device_reset) { 744 744 ufs_qcom_device_reset_ctrl(hba, true); 745 + /* 746 + * After sending the SSU command, asserting the rst_n 747 + * line causes the device firmware to wake up and 748 + * execute its reset routine. 749 + * 750 + * During this process, the device may draw current 751 + * beyond the permissible limit for low-power mode (LPM). 752 + * A 10ms delay, based on experimental observations, 753 + * allows the UFS device to complete its hardware reset 754 + * before transitioning the power rail to LPM. 755 + */ 756 + usleep_range(10000, 11000); 757 + } 745 758 746 759 return ufs_qcom_ice_suspend(host); 747 760 }
+67 -3
drivers/ufs/host/ufshcd-pci.c
··· 15 15 #include <linux/pci.h> 16 16 #include <linux/pm_runtime.h> 17 17 #include <linux/pm_qos.h> 18 + #include <linux/suspend.h> 18 19 #include <linux/debugfs.h> 19 20 #include <linux/uuid.h> 20 21 #include <linux/acpi.h> ··· 32 31 u32 dsm_fns; 33 32 u32 active_ltr; 34 33 u32 idle_ltr; 34 + int saved_spm_lvl; 35 35 struct dentry *debugfs_root; 36 36 struct gpio_desc *reset_gpio; 37 37 }; ··· 349 347 host = devm_kzalloc(hba->dev, sizeof(*host), GFP_KERNEL); 350 348 if (!host) 351 349 return -ENOMEM; 350 + host->saved_spm_lvl = -1; 352 351 ufshcd_set_variant(hba, host); 353 352 intel_dsm_init(host, hba->dev); 354 353 if (INTEL_DSM_SUPPORTED(host, RESET)) { ··· 428 425 static int ufs_intel_adl_init(struct ufs_hba *hba) 429 426 { 430 427 hba->nop_out_timeout = 200; 431 - hba->quirks |= UFSHCD_QUIRK_BROKEN_AUTO_HIBERN8; 428 + hba->quirks |= UFSHCD_QUIRK_BROKEN_AUTO_HIBERN8 | 429 + UFSHCD_QUIRK_PERFORM_LINK_STARTUP_ONCE; 432 430 hba->caps |= UFSHCD_CAP_WB_EN; 433 431 return ufs_intel_common_init(hba); 434 432 } ··· 542 538 543 539 return ufshcd_system_resume(dev); 544 540 } 541 + 542 + static int ufs_intel_suspend_prepare(struct device *dev) 543 + { 544 + struct ufs_hba *hba = dev_get_drvdata(dev); 545 + struct intel_host *host = ufshcd_get_variant(hba); 546 + int err; 547 + 548 + /* 549 + * Only s2idle (S0ix) retains link state. Force power-off 550 + * (UFS_PM_LVL_5) for any other case. 551 + */ 552 + if (pm_suspend_target_state != PM_SUSPEND_TO_IDLE && hba->spm_lvl < UFS_PM_LVL_5) { 553 + host->saved_spm_lvl = hba->spm_lvl; 554 + hba->spm_lvl = UFS_PM_LVL_5; 555 + } 556 + 557 + err = ufshcd_suspend_prepare(dev); 558 + 559 + if (err < 0 && host->saved_spm_lvl != -1) { 560 + hba->spm_lvl = host->saved_spm_lvl; 561 + host->saved_spm_lvl = -1; 562 + } 563 + 564 + return err; 565 + } 566 + 567 + static void ufs_intel_resume_complete(struct device *dev) 568 + { 569 + struct ufs_hba *hba = dev_get_drvdata(dev); 570 + struct intel_host *host = ufshcd_get_variant(hba); 571 + 572 + ufshcd_resume_complete(dev); 573 + 574 + if (host->saved_spm_lvl != -1) { 575 + hba->spm_lvl = host->saved_spm_lvl; 576 + host->saved_spm_lvl = -1; 577 + } 578 + } 579 + 580 + static int ufshcd_pci_suspend_prepare(struct device *dev) 581 + { 582 + struct ufs_hba *hba = dev_get_drvdata(dev); 583 + 584 + if (!strcmp(hba->vops->name, "intel-pci")) 585 + return ufs_intel_suspend_prepare(dev); 586 + 587 + return ufshcd_suspend_prepare(dev); 588 + } 589 + 590 + static void ufshcd_pci_resume_complete(struct device *dev) 591 + { 592 + struct ufs_hba *hba = dev_get_drvdata(dev); 593 + 594 + if (!strcmp(hba->vops->name, "intel-pci")) { 595 + ufs_intel_resume_complete(dev); 596 + return; 597 + } 598 + 599 + ufshcd_resume_complete(dev); 600 + } 545 601 #endif 546 602 547 603 /** ··· 675 611 .thaw = ufshcd_system_resume, 676 612 .poweroff = ufshcd_system_suspend, 677 613 .restore = ufshcd_pci_restore, 678 - .prepare = ufshcd_suspend_prepare, 679 - .complete = ufshcd_resume_complete, 614 + .prepare = ufshcd_pci_suspend_prepare, 615 + .complete = ufshcd_pci_resume_complete, 680 616 #endif 681 617 }; 682 618
+2 -4
drivers/vdpa/mlx5/net/mlx5_vnet.c
··· 573 573 vcq->mcq.set_ci_db = vcq->db.db; 574 574 vcq->mcq.arm_db = vcq->db.db + 1; 575 575 vcq->mcq.cqe_sz = 64; 576 + vcq->mcq.comp = mlx5_vdpa_cq_comp; 577 + vcq->cqe = num_ent; 576 578 577 579 err = cq_frag_buf_alloc(ndev, &vcq->buf, num_ent); 578 580 if (err) ··· 614 612 if (err) 615 613 goto err_vec; 616 614 617 - vcq->mcq.comp = mlx5_vdpa_cq_comp; 618 - vcq->cqe = num_ent; 619 - vcq->mcq.set_ci_db = vcq->db.db; 620 - vcq->mcq.arm_db = vcq->db.db + 1; 621 615 mlx5_cq_arm(&mvq->cq.mcq, MLX5_CQ_DB_REQ_NOT, uar_page, mvq->cq.mcq.cons_index); 622 616 kfree(in); 623 617 return 0;
+8
fs/btrfs/extent_io.c
··· 2228 2228 wbc_account_cgroup_owner(wbc, folio, range_len); 2229 2229 folio_unlock(folio); 2230 2230 } 2231 + /* 2232 + * If the fs is already in error status, do not submit any writeback 2233 + * but immediately finish it. 2234 + */ 2235 + if (unlikely(BTRFS_FS_ERROR(fs_info))) { 2236 + btrfs_bio_end_io(bbio, errno_to_blk_status(BTRFS_FS_ERROR(fs_info))); 2237 + return; 2238 + } 2231 2239 btrfs_submit_bbio(bbio, 0); 2232 2240 } 2233 2241
+10
fs/btrfs/file.c
··· 2854 2854 { 2855 2855 struct btrfs_trans_handle *trans; 2856 2856 struct btrfs_root *root = BTRFS_I(inode)->root; 2857 + u64 range_start; 2858 + u64 range_end; 2857 2859 int ret; 2858 2860 int ret2; 2859 2861 2860 2862 if (mode & FALLOC_FL_KEEP_SIZE || end <= i_size_read(inode)) 2861 2863 return 0; 2864 + 2865 + range_start = round_down(i_size_read(inode), root->fs_info->sectorsize); 2866 + range_end = round_up(end, root->fs_info->sectorsize); 2867 + 2868 + ret = btrfs_inode_set_file_extent_range(BTRFS_I(inode), range_start, 2869 + range_end - range_start); 2870 + if (ret) 2871 + return ret; 2862 2872 2863 2873 trans = btrfs_start_transaction(root, 1); 2864 2874 if (IS_ERR(trans))
+3 -2
fs/btrfs/inode.c
··· 177 177 return ret; 178 178 } 179 179 ret = paths_from_inode(inum, ipath); 180 - if (ret < 0) 180 + if (ret < 0) { 181 + btrfs_put_root(local_root); 181 182 goto err; 183 + } 182 184 183 185 /* 184 186 * We deliberately ignore the bit ipath might have been too small to ··· 6875 6873 BTRFS_I(inode)->dir_index = 0ULL; 6876 6874 inode_inc_iversion(inode); 6877 6875 inode_set_ctime_current(inode); 6878 - set_bit(BTRFS_INODE_COPY_EVERYTHING, &BTRFS_I(inode)->runtime_flags); 6879 6876 6880 6877 ret = btrfs_add_link(trans, BTRFS_I(dir), BTRFS_I(inode), 6881 6878 &fname.disk_name, 1, index);
+3 -1
fs/btrfs/qgroup.c
··· 1539 1539 ASSERT(prealloc); 1540 1540 1541 1541 /* Check the level of src and dst first */ 1542 - if (btrfs_qgroup_level(src) >= btrfs_qgroup_level(dst)) 1542 + if (btrfs_qgroup_level(src) >= btrfs_qgroup_level(dst)) { 1543 + kfree(prealloc); 1543 1544 return -EINVAL; 1545 + } 1544 1546 1545 1547 mutex_lock(&fs_info->qgroup_ioctl_lock); 1546 1548 if (!fs_info->quota_root) {
+2
fs/btrfs/scrub.c
··· 2203 2203 ret = btrfs_map_block(fs_info, BTRFS_MAP_WRITE, full_stripe_start, 2204 2204 &length, &bioc, NULL, NULL); 2205 2205 if (ret < 0) { 2206 + bio_put(bio); 2206 2207 btrfs_put_bioc(bioc); 2207 2208 btrfs_bio_counter_dec(fs_info); 2208 2209 goto out; ··· 2213 2212 btrfs_put_bioc(bioc); 2214 2213 if (!rbio) { 2215 2214 ret = -ENOMEM; 2215 + bio_put(bio); 2216 2216 btrfs_bio_counter_dec(fs_info); 2217 2217 goto out; 2218 2218 }
+4 -1
fs/btrfs/tree-log.c
··· 7122 7122 * a power failure unless the log was synced as part of an fsync 7123 7123 * against any other unrelated inode. 7124 7124 */ 7125 - if (inode_only != LOG_INODE_EXISTS) 7125 + if (!ctx->logging_new_name && inode_only != LOG_INODE_EXISTS) 7126 7126 inode->last_log_commit = inode->last_sub_trans; 7127 7127 spin_unlock(&inode->lock); 7128 7128 ··· 7909 7909 struct btrfs_log_ctx ctx; 7910 7910 bool log_pinned = false; 7911 7911 int ret; 7912 + 7913 + /* The inode has a new name (ref/extref), so make sure we log it. */ 7914 + set_bit(BTRFS_INODE_COPY_EVERYTHING, &inode->runtime_flags); 7912 7915 7913 7916 btrfs_init_log_ctx(&ctx, inode); 7914 7917 ctx.logging_new_name = true;
+28 -32
fs/btrfs/zoned.c
··· 1317 1317 if (!btrfs_dev_is_sequential(device, info->physical)) { 1318 1318 up_read(&dev_replace->rwsem); 1319 1319 info->alloc_offset = WP_CONVENTIONAL; 1320 + info->capacity = device->zone_info->zone_size; 1320 1321 return 0; 1321 1322 } 1322 1323 ··· 1523 1522 u64 last_alloc) 1524 1523 { 1525 1524 struct btrfs_fs_info *fs_info = bg->fs_info; 1525 + u64 stripe_nr = 0, stripe_offset = 0; 1526 + u32 stripe_index = 0; 1526 1527 1527 1528 if ((map->type & BTRFS_BLOCK_GROUP_DATA) && !fs_info->stripe_root) { 1528 1529 btrfs_err(fs_info, "zoned: data %s needs raid-stripe-tree", ··· 1532 1529 return -EINVAL; 1533 1530 } 1534 1531 1532 + if (last_alloc) { 1533 + u32 factor = map->num_stripes; 1534 + 1535 + stripe_nr = last_alloc >> BTRFS_STRIPE_LEN_SHIFT; 1536 + stripe_offset = last_alloc & BTRFS_STRIPE_LEN_MASK; 1537 + stripe_nr = div_u64_rem(stripe_nr, factor, &stripe_index); 1538 + } 1539 + 1535 1540 for (int i = 0; i < map->num_stripes; i++) { 1536 1541 if (zone_info[i].alloc_offset == WP_MISSING_DEV) 1537 1542 continue; 1538 1543 1539 1544 if (zone_info[i].alloc_offset == WP_CONVENTIONAL) { 1540 - u64 stripe_nr, full_stripe_nr; 1541 - u64 stripe_offset; 1542 - int stripe_index; 1543 1545 1544 - stripe_nr = div64_u64(last_alloc, map->stripe_size); 1545 - stripe_offset = stripe_nr * map->stripe_size; 1546 - full_stripe_nr = div_u64(stripe_nr, map->num_stripes); 1547 - div_u64_rem(stripe_nr, map->num_stripes, &stripe_index); 1548 - 1549 - zone_info[i].alloc_offset = 1550 - full_stripe_nr * map->stripe_size; 1546 + zone_info[i].alloc_offset = btrfs_stripe_nr_to_offset(stripe_nr); 1551 1547 1552 1548 if (stripe_index > i) 1553 - zone_info[i].alloc_offset += map->stripe_size; 1549 + zone_info[i].alloc_offset += BTRFS_STRIPE_LEN; 1554 1550 else if (stripe_index == i) 1555 - zone_info[i].alloc_offset += 1556 - (last_alloc - stripe_offset); 1551 + zone_info[i].alloc_offset += stripe_offset; 1557 1552 } 1558 1553 1559 1554 if (test_bit(0, active) != test_bit(i, active)) { ··· 1575 1574 u64 last_alloc) 1576 1575 { 1577 1576 struct btrfs_fs_info *fs_info = bg->fs_info; 1577 + u64 stripe_nr = 0, stripe_offset = 0; 1578 + u32 stripe_index = 0; 1578 1579 1579 1580 if ((map->type & BTRFS_BLOCK_GROUP_DATA) && !fs_info->stripe_root) { 1580 1581 btrfs_err(fs_info, "zoned: data %s needs raid-stripe-tree", 1581 1582 btrfs_bg_type_to_raid_name(map->type)); 1582 1583 return -EINVAL; 1584 + } 1585 + 1586 + if (last_alloc) { 1587 + u32 factor = map->num_stripes / map->sub_stripes; 1588 + 1589 + stripe_nr = last_alloc >> BTRFS_STRIPE_LEN_SHIFT; 1590 + stripe_offset = last_alloc & BTRFS_STRIPE_LEN_MASK; 1591 + stripe_nr = div_u64_rem(stripe_nr, factor, &stripe_index); 1583 1592 } 1584 1593 1585 1594 for (int i = 0; i < map->num_stripes; i++) { ··· 1605 1594 } 1606 1595 1607 1596 if (zone_info[i].alloc_offset == WP_CONVENTIONAL) { 1608 - u64 stripe_nr, full_stripe_nr; 1609 - u64 stripe_offset; 1610 - int stripe_index; 1611 - 1612 - stripe_nr = div64_u64(last_alloc, map->stripe_size); 1613 - stripe_offset = stripe_nr * map->stripe_size; 1614 - full_stripe_nr = div_u64(stripe_nr, 1615 - map->num_stripes / map->sub_stripes); 1616 - div_u64_rem(stripe_nr, 1617 - (map->num_stripes / map->sub_stripes), 1618 - &stripe_index); 1619 - 1620 - zone_info[i].alloc_offset = 1621 - full_stripe_nr * map->stripe_size; 1597 + zone_info[i].alloc_offset = btrfs_stripe_nr_to_offset(stripe_nr); 1622 1598 1623 1599 if (stripe_index > (i / map->sub_stripes)) 1624 - zone_info[i].alloc_offset += map->stripe_size; 1600 + zone_info[i].alloc_offset += BTRFS_STRIPE_LEN; 1625 1601 else if (stripe_index == (i / map->sub_stripes)) 1626 - zone_info[i].alloc_offset += 1627 - (last_alloc - stripe_offset); 1602 + zone_info[i].alloc_offset += stripe_offset; 1628 1603 } 1629 1604 1630 1605 if ((i % map->sub_stripes) == 0) { ··· 1680 1683 set_bit(BLOCK_GROUP_FLAG_SEQUENTIAL_ZONE, &cache->runtime_flags); 1681 1684 1682 1685 if (num_conventional > 0) { 1683 - /* Zone capacity is always zone size in emulation */ 1684 - cache->zone_capacity = cache->length; 1685 1686 ret = calculate_alloc_pointer(cache, &last_alloc, new); 1686 1687 if (ret) { 1687 1688 btrfs_err(fs_info, ··· 1688 1693 goto out; 1689 1694 } else if (map->num_stripes == num_conventional) { 1690 1695 cache->alloc_offset = last_alloc; 1696 + cache->zone_capacity = cache->length; 1691 1697 set_bit(BLOCK_GROUP_FLAG_ZONE_IS_ACTIVE, &cache->runtime_flags); 1692 1698 goto out; 1693 1699 }
+1 -2
fs/crypto/inline_crypt.c
··· 333 333 inode = mapping->host; 334 334 335 335 *inode_ret = inode; 336 - *lblk_num_ret = ((u64)folio->index << (PAGE_SHIFT - inode->i_blkbits)) + 337 - (bh_offset(bh) >> inode->i_blkbits); 336 + *lblk_num_ret = (folio_pos(folio) + bh_offset(bh)) >> inode->i_blkbits; 338 337 return true; 339 338 } 340 339
+7 -4
fs/erofs/decompressor_zstd.c
··· 172 172 dctx.bounce = strm->bounce; 173 173 174 174 do { 175 - dctx.avail_out = out_buf.size - out_buf.pos; 176 175 dctx.inbuf_sz = in_buf.size; 177 176 dctx.inbuf_pos = in_buf.pos; 178 177 err = z_erofs_stream_switch_bufs(&dctx, &out_buf.dst, ··· 187 188 in_buf.pos = dctx.inbuf_pos; 188 189 189 190 zerr = zstd_decompress_stream(stream, &out_buf, &in_buf); 190 - if (zstd_is_error(zerr) || (!zerr && rq->outputsize)) { 191 + dctx.avail_out = out_buf.size - out_buf.pos; 192 + if (zstd_is_error(zerr) || 193 + ((rq->outputsize + dctx.avail_out) && (!zerr || (zerr > 0 && 194 + !(rq->inputsize + in_buf.size - in_buf.pos))))) { 191 195 erofs_err(sb, "failed to decompress in[%u] out[%u]: %s", 192 196 rq->inputsize, rq->outputsize, 193 - zerr ? zstd_get_error_name(zerr) : "unexpected end of stream"); 197 + zstd_is_error(zerr) ? zstd_get_error_name(zerr) : 198 + "unexpected end of stream"); 194 199 err = -EFSCORRUPTED; 195 200 break; 196 201 } 197 - } while (rq->outputsize || out_buf.pos < out_buf.size); 202 + } while (rq->outputsize + dctx.avail_out); 198 203 199 204 if (dctx.kout) 200 205 kunmap_local(dctx.kout);
+8
fs/nfs/client.c
··· 338 338 /* Match the xprt security policy */ 339 339 if (clp->cl_xprtsec.policy != data->xprtsec.policy) 340 340 continue; 341 + if (clp->cl_xprtsec.policy == RPC_XPRTSEC_TLS_X509) { 342 + if (clp->cl_xprtsec.cert_serial != 343 + data->xprtsec.cert_serial) 344 + continue; 345 + if (clp->cl_xprtsec.privkey_serial != 346 + data->xprtsec.privkey_serial) 347 + continue; 348 + } 341 349 342 350 refcount_inc(&clp->cl_count); 343 351 return clp;
+4 -3
fs/nfs/dir.c
··· 2268 2268 return -ENAMETOOLONG; 2269 2269 2270 2270 if (open_flags & O_CREAT) { 2271 - file->f_mode |= FMODE_CREATED; 2272 2271 error = nfs_do_create(dir, dentry, mode, open_flags); 2273 - if (error) 2272 + if (!error) { 2273 + file->f_mode |= FMODE_CREATED; 2274 + return finish_open(file, dentry, NULL); 2275 + } else if (error != -EEXIST || open_flags & O_EXCL) 2274 2276 return error; 2275 - return finish_open(file, dentry, NULL); 2276 2277 } 2277 2278 if (d_in_lookup(dentry)) { 2278 2279 /* The only flags nfs_lookup considers are
+12 -6
fs/nfs/inode.c
··· 718 718 struct nfs_fattr *fattr; 719 719 loff_t oldsize = i_size_read(inode); 720 720 int error = 0; 721 + kuid_t task_uid = current_fsuid(); 722 + kuid_t owner_uid = inode->i_uid; 721 723 722 724 nfs_inc_stats(inode, NFSIOS_VFSSETATTR); 723 725 ··· 741 739 if (nfs_have_delegated_mtime(inode) && attr->ia_valid & ATTR_MTIME) { 742 740 spin_lock(&inode->i_lock); 743 741 if (attr->ia_valid & ATTR_MTIME_SET) { 744 - nfs_set_timestamps_to_ts(inode, attr); 745 - attr->ia_valid &= ~(ATTR_MTIME|ATTR_MTIME_SET| 742 + if (uid_eq(task_uid, owner_uid)) { 743 + nfs_set_timestamps_to_ts(inode, attr); 744 + attr->ia_valid &= ~(ATTR_MTIME|ATTR_MTIME_SET| 746 745 ATTR_ATIME|ATTR_ATIME_SET); 746 + } 747 747 } else { 748 748 nfs_update_timestamps(inode, attr->ia_valid); 749 749 attr->ia_valid &= ~(ATTR_MTIME|ATTR_ATIME); ··· 755 751 attr->ia_valid & ATTR_ATIME && 756 752 !(attr->ia_valid & ATTR_MTIME)) { 757 753 if (attr->ia_valid & ATTR_ATIME_SET) { 758 - spin_lock(&inode->i_lock); 759 - nfs_set_timestamps_to_ts(inode, attr); 760 - spin_unlock(&inode->i_lock); 761 - attr->ia_valid &= ~(ATTR_ATIME|ATTR_ATIME_SET); 754 + if (uid_eq(task_uid, owner_uid)) { 755 + spin_lock(&inode->i_lock); 756 + nfs_set_timestamps_to_ts(inode, attr); 757 + spin_unlock(&inode->i_lock); 758 + attr->ia_valid &= ~(ATTR_ATIME|ATTR_ATIME_SET); 759 + } 762 760 } else { 763 761 nfs_update_delegated_atime(inode); 764 762 attr->ia_valid &= ~ATTR_ATIME;
+121 -108
fs/nfs/localio.c
··· 42 42 /* Begin mostly DIO-specific members */ 43 43 size_t end_len; 44 44 short int end_iter_index; 45 - short int n_iters; 45 + atomic_t n_iters; 46 46 bool iter_is_dio_aligned[NFSLOCAL_MAX_IOS]; 47 - loff_t offset[NFSLOCAL_MAX_IOS] ____cacheline_aligned; 48 - struct iov_iter iters[NFSLOCAL_MAX_IOS]; 47 + struct iov_iter iters[NFSLOCAL_MAX_IOS] ____cacheline_aligned; 49 48 /* End mostly DIO-specific members */ 50 49 }; 51 50 ··· 313 314 init_sync_kiocb(&iocb->kiocb, file); 314 315 315 316 iocb->hdr = hdr; 317 + iocb->kiocb.ki_pos = hdr->args.offset; 316 318 iocb->kiocb.ki_flags &= ~IOCB_APPEND; 319 + iocb->kiocb.ki_complete = NULL; 317 320 iocb->aio_complete_work = NULL; 318 321 319 322 iocb->end_iter_index = -1; ··· 389 388 return true; 390 389 } 391 390 391 + static void 392 + nfs_local_iter_setup(struct iov_iter *iter, int rw, struct bio_vec *bvec, 393 + unsigned int nvecs, unsigned long total, 394 + size_t start, size_t len) 395 + { 396 + iov_iter_bvec(iter, rw, bvec, nvecs, total); 397 + if (start) 398 + iov_iter_advance(iter, start); 399 + iov_iter_truncate(iter, len); 400 + } 401 + 392 402 /* 393 403 * Setup as many as 3 iov_iter based on extents described by @local_dio. 394 404 * Returns the number of iov_iter that were setup. 395 405 */ 396 406 static int 397 407 nfs_local_iters_setup_dio(struct nfs_local_kiocb *iocb, int rw, 398 - unsigned int nvecs, size_t len, 408 + unsigned int nvecs, unsigned long total, 399 409 struct nfs_local_dio *local_dio) 400 410 { 401 411 int n_iters = 0; ··· 414 402 415 403 /* Setup misaligned start? */ 416 404 if (local_dio->start_len) { 417 - iov_iter_bvec(&iters[n_iters], rw, iocb->bvec, nvecs, len); 418 - iters[n_iters].count = local_dio->start_len; 419 - iocb->offset[n_iters] = iocb->hdr->args.offset; 420 - iocb->iter_is_dio_aligned[n_iters] = false; 405 + nfs_local_iter_setup(&iters[n_iters], rw, iocb->bvec, 406 + nvecs, total, 0, local_dio->start_len); 421 407 ++n_iters; 422 408 } 423 409 424 - /* Setup misaligned end? 425 - * If so, the end is purposely setup to be issued using buffered IO 426 - * before the middle (which will use DIO, if DIO-aligned, with AIO). 427 - * This creates problems if/when the end results in a partial write. 428 - * So must save index and length of end to handle this corner case. 410 + /* 411 + * Setup DIO-aligned middle, if there is no misaligned end (below) 412 + * then AIO completion is used, see nfs_local_call_{read,write} 429 413 */ 430 - if (local_dio->end_len) { 431 - iov_iter_bvec(&iters[n_iters], rw, iocb->bvec, nvecs, len); 432 - iocb->offset[n_iters] = local_dio->end_offset; 433 - iov_iter_advance(&iters[n_iters], 434 - local_dio->start_len + local_dio->middle_len); 435 - iocb->iter_is_dio_aligned[n_iters] = false; 436 - /* Save index and length of end */ 437 - iocb->end_iter_index = n_iters; 438 - iocb->end_len = local_dio->end_len; 439 - ++n_iters; 440 - } 441 - 442 - /* Setup DIO-aligned middle to be issued last, to allow for 443 - * DIO with AIO completion (see nfs_local_call_{read,write}). 444 - */ 445 - iov_iter_bvec(&iters[n_iters], rw, iocb->bvec, nvecs, len); 446 - if (local_dio->start_len) 447 - iov_iter_advance(&iters[n_iters], local_dio->start_len); 448 - iters[n_iters].count -= local_dio->end_len; 449 - iocb->offset[n_iters] = local_dio->middle_offset; 414 + nfs_local_iter_setup(&iters[n_iters], rw, iocb->bvec, nvecs, 415 + total, local_dio->start_len, local_dio->middle_len); 450 416 451 417 iocb->iter_is_dio_aligned[n_iters] = 452 418 nfs_iov_iter_aligned_bvec(&iters[n_iters], ··· 432 442 433 443 if (unlikely(!iocb->iter_is_dio_aligned[n_iters])) { 434 444 trace_nfs_local_dio_misaligned(iocb->hdr->inode, 435 - iocb->hdr->args.offset, len, local_dio); 445 + local_dio->start_len, local_dio->middle_len, local_dio); 436 446 return 0; /* no DIO-aligned IO possible */ 437 447 } 448 + iocb->end_iter_index = n_iters; 438 449 ++n_iters; 439 450 440 - iocb->n_iters = n_iters; 451 + /* Setup misaligned end? */ 452 + if (local_dio->end_len) { 453 + nfs_local_iter_setup(&iters[n_iters], rw, iocb->bvec, 454 + nvecs, total, local_dio->start_len + 455 + local_dio->middle_len, local_dio->end_len); 456 + iocb->end_iter_index = n_iters; 457 + ++n_iters; 458 + } 459 + 460 + atomic_set(&iocb->n_iters, n_iters); 441 461 return n_iters; 442 462 } 443 463 ··· 473 473 } 474 474 len = hdr->args.count - total; 475 475 476 + /* 477 + * For each iocb, iocb->n_iters is always at least 1 and we always 478 + * end io after first nfs_local_pgio_done call unless misaligned DIO. 479 + */ 480 + atomic_set(&iocb->n_iters, 1); 481 + 476 482 if (test_bit(NFS_IOHDR_ODIRECT, &hdr->flags)) { 477 483 struct nfs_local_dio local_dio; 478 484 479 485 if (nfs_is_local_dio_possible(iocb, rw, len, &local_dio) && 480 - nfs_local_iters_setup_dio(iocb, rw, v, len, &local_dio) != 0) 486 + nfs_local_iters_setup_dio(iocb, rw, v, len, &local_dio) != 0) { 487 + /* Ensure DIO WRITE's IO on stable storage upon completion */ 488 + if (rw == ITER_SOURCE) 489 + iocb->kiocb.ki_flags |= IOCB_DSYNC|IOCB_SYNC; 481 490 return; /* is DIO-aligned */ 491 + } 482 492 } 483 493 484 494 /* Use buffered IO */ 485 - iocb->offset[0] = hdr->args.offset; 486 495 iov_iter_bvec(&iocb->iters[0], rw, iocb->bvec, v, len); 487 - iocb->n_iters = 1; 488 496 } 489 497 490 498 static void ··· 512 504 hdr->task.tk_start = ktime_get(); 513 505 } 514 506 515 - static void 516 - nfs_local_pgio_done(struct nfs_pgio_header *hdr, long status) 507 + static bool 508 + nfs_local_pgio_done(struct nfs_local_kiocb *iocb, long status, bool force) 517 509 { 510 + struct nfs_pgio_header *hdr = iocb->hdr; 511 + 518 512 /* Must handle partial completions */ 519 513 if (status >= 0) { 520 514 hdr->res.count += status; ··· 527 517 hdr->res.op_status = nfs_localio_errno_to_nfs4_stat(status); 528 518 hdr->task.tk_status = status; 529 519 } 520 + 521 + if (force) 522 + return true; 523 + 524 + BUG_ON(atomic_read(&iocb->n_iters) <= 0); 525 + return atomic_dec_and_test(&iocb->n_iters); 530 526 } 531 527 532 528 static void ··· 563 547 queue_work(nfsiod_workqueue, &iocb->work); 564 548 } 565 549 566 - static void 567 - nfs_local_read_done(struct nfs_local_kiocb *iocb, long status) 550 + static void nfs_local_read_done(struct nfs_local_kiocb *iocb) 568 551 { 569 552 struct nfs_pgio_header *hdr = iocb->hdr; 570 553 struct file *filp = iocb->kiocb.ki_filp; 554 + long status = hdr->task.tk_status; 571 555 572 556 if ((iocb->kiocb.ki_flags & IOCB_DIRECT) && status == -EINVAL) { 573 557 /* Underlying FS will return -EINVAL if misaligned DIO is attempted. */ ··· 580 564 */ 581 565 hdr->res.replen = 0; 582 566 583 - if (hdr->res.count != hdr->args.count || 584 - hdr->args.offset + hdr->res.count >= i_size_read(file_inode(filp))) 567 + /* nfs_readpage_result() handles short read */ 568 + 569 + if (hdr->args.offset + hdr->res.count >= i_size_read(file_inode(filp))) 585 570 hdr->res.eof = true; 586 571 587 572 dprintk("%s: read %ld bytes eof %d.\n", __func__, 588 573 status > 0 ? status : 0, hdr->res.eof); 574 + } 575 + 576 + static inline void nfs_local_read_iocb_done(struct nfs_local_kiocb *iocb) 577 + { 578 + nfs_local_read_done(iocb); 579 + nfs_local_pgio_release(iocb); 589 580 } 590 581 591 582 static void nfs_local_read_aio_complete_work(struct work_struct *work) ··· 600 577 struct nfs_local_kiocb *iocb = 601 578 container_of(work, struct nfs_local_kiocb, work); 602 579 603 - nfs_local_pgio_release(iocb); 580 + nfs_local_read_iocb_done(iocb); 604 581 } 605 582 606 583 static void nfs_local_read_aio_complete(struct kiocb *kiocb, long ret) ··· 608 585 struct nfs_local_kiocb *iocb = 609 586 container_of(kiocb, struct nfs_local_kiocb, kiocb); 610 587 611 - nfs_local_pgio_done(iocb->hdr, ret); 612 - nfs_local_read_done(iocb, ret); 588 + /* AIO completion of DIO read should always be last to complete */ 589 + if (unlikely(!nfs_local_pgio_done(iocb, ret, false))) 590 + return; 591 + 613 592 nfs_local_pgio_aio_complete(iocb); /* Calls nfs_local_read_aio_complete_work */ 614 593 } 615 594 ··· 621 596 container_of(work, struct nfs_local_kiocb, work); 622 597 struct file *filp = iocb->kiocb.ki_filp; 623 598 const struct cred *save_cred; 599 + bool force_done = false; 624 600 ssize_t status; 601 + int n_iters; 625 602 626 603 save_cred = override_creds(filp->f_cred); 627 604 628 - for (int i = 0; i < iocb->n_iters ; i++) { 605 + n_iters = atomic_read(&iocb->n_iters); 606 + for (int i = 0; i < n_iters ; i++) { 629 607 if (iocb->iter_is_dio_aligned[i]) { 630 608 iocb->kiocb.ki_flags |= IOCB_DIRECT; 631 - iocb->kiocb.ki_complete = nfs_local_read_aio_complete; 632 - iocb->aio_complete_work = nfs_local_read_aio_complete_work; 633 - } 609 + /* Only use AIO completion if DIO-aligned segment is last */ 610 + if (i == iocb->end_iter_index) { 611 + iocb->kiocb.ki_complete = nfs_local_read_aio_complete; 612 + iocb->aio_complete_work = nfs_local_read_aio_complete_work; 613 + } 614 + } else 615 + iocb->kiocb.ki_flags &= ~IOCB_DIRECT; 634 616 635 - iocb->kiocb.ki_pos = iocb->offset[i]; 636 617 status = filp->f_op->read_iter(&iocb->kiocb, &iocb->iters[i]); 637 618 if (status != -EIOCBQUEUED) { 638 - nfs_local_pgio_done(iocb->hdr, status); 639 - if (iocb->hdr->task.tk_status) 619 + if (unlikely(status >= 0 && status < iocb->iters[i].count)) 620 + force_done = true; /* Partial read */ 621 + if (nfs_local_pgio_done(iocb, status, force_done)) { 622 + nfs_local_read_iocb_done(iocb); 640 623 break; 624 + } 641 625 } 642 626 } 643 627 644 628 revert_creds(save_cred); 645 - 646 - if (status != -EIOCBQUEUED) { 647 - nfs_local_read_done(iocb, status); 648 - nfs_local_pgio_release(iocb); 649 - } 650 629 } 651 630 652 631 static int ··· 765 736 fattr->du.nfs3.used = stat.blocks << 9; 766 737 } 767 738 768 - static void 769 - nfs_local_write_done(struct nfs_local_kiocb *iocb, long status) 739 + static void nfs_local_write_done(struct nfs_local_kiocb *iocb) 770 740 { 771 741 struct nfs_pgio_header *hdr = iocb->hdr; 772 - struct inode *inode = hdr->inode; 742 + long status = hdr->task.tk_status; 773 743 774 744 dprintk("%s: wrote %ld bytes.\n", __func__, status > 0 ? status : 0); 775 745 ··· 787 759 nfs_set_pgio_error(hdr, -ENOSPC, hdr->args.offset); 788 760 status = -ENOSPC; 789 761 /* record -ENOSPC in terms of nfs_local_pgio_done */ 790 - nfs_local_pgio_done(hdr, status); 762 + (void) nfs_local_pgio_done(iocb, status, true); 791 763 } 792 764 if (hdr->task.tk_status < 0) 793 - nfs_reset_boot_verifier(inode); 765 + nfs_reset_boot_verifier(hdr->inode); 766 + } 767 + 768 + static inline void nfs_local_write_iocb_done(struct nfs_local_kiocb *iocb) 769 + { 770 + nfs_local_write_done(iocb); 771 + nfs_local_vfs_getattr(iocb); 772 + nfs_local_pgio_release(iocb); 794 773 } 795 774 796 775 static void nfs_local_write_aio_complete_work(struct work_struct *work) ··· 805 770 struct nfs_local_kiocb *iocb = 806 771 container_of(work, struct nfs_local_kiocb, work); 807 772 808 - nfs_local_vfs_getattr(iocb); 809 - nfs_local_pgio_release(iocb); 773 + nfs_local_write_iocb_done(iocb); 810 774 } 811 775 812 776 static void nfs_local_write_aio_complete(struct kiocb *kiocb, long ret) ··· 813 779 struct nfs_local_kiocb *iocb = 814 780 container_of(kiocb, struct nfs_local_kiocb, kiocb); 815 781 816 - nfs_local_pgio_done(iocb->hdr, ret); 817 - nfs_local_write_done(iocb, ret); 782 + /* AIO completion of DIO write should always be last to complete */ 783 + if (unlikely(!nfs_local_pgio_done(iocb, ret, false))) 784 + return; 785 + 818 786 nfs_local_pgio_aio_complete(iocb); /* Calls nfs_local_write_aio_complete_work */ 819 787 } 820 788 ··· 827 791 struct file *filp = iocb->kiocb.ki_filp; 828 792 unsigned long old_flags = current->flags; 829 793 const struct cred *save_cred; 794 + bool force_done = false; 830 795 ssize_t status; 796 + int n_iters; 831 797 832 798 current->flags |= PF_LOCAL_THROTTLE | PF_MEMALLOC_NOIO; 833 799 save_cred = override_creds(filp->f_cred); 834 800 835 801 file_start_write(filp); 836 - for (int i = 0; i < iocb->n_iters ; i++) { 802 + n_iters = atomic_read(&iocb->n_iters); 803 + for (int i = 0; i < n_iters ; i++) { 837 804 if (iocb->iter_is_dio_aligned[i]) { 838 805 iocb->kiocb.ki_flags |= IOCB_DIRECT; 839 - iocb->kiocb.ki_complete = nfs_local_write_aio_complete; 840 - iocb->aio_complete_work = nfs_local_write_aio_complete_work; 841 - } 842 - retry: 843 - iocb->kiocb.ki_pos = iocb->offset[i]; 806 + /* Only use AIO completion if DIO-aligned segment is last */ 807 + if (i == iocb->end_iter_index) { 808 + iocb->kiocb.ki_complete = nfs_local_write_aio_complete; 809 + iocb->aio_complete_work = nfs_local_write_aio_complete_work; 810 + } 811 + } else 812 + iocb->kiocb.ki_flags &= ~IOCB_DIRECT; 813 + 844 814 status = filp->f_op->write_iter(&iocb->kiocb, &iocb->iters[i]); 845 815 if (status != -EIOCBQUEUED) { 846 - if (unlikely(status >= 0 && status < iocb->iters[i].count)) { 847 - /* partial write */ 848 - if (i == iocb->end_iter_index) { 849 - /* Must not account partial end, otherwise, due 850 - * to end being issued before middle: the partial 851 - * write accounting in nfs_local_write_done() 852 - * would incorrectly advance hdr->args.offset 853 - */ 854 - status = 0; 855 - } else { 856 - /* Partial write at start or buffered middle, 857 - * exit early. 858 - */ 859 - nfs_local_pgio_done(iocb->hdr, status); 860 - break; 861 - } 862 - } else if (unlikely(status == -ENOTBLK && 863 - (iocb->kiocb.ki_flags & IOCB_DIRECT))) { 864 - /* VFS will return -ENOTBLK if DIO WRITE fails to 865 - * invalidate the page cache. Retry using buffered IO. 866 - */ 867 - iocb->kiocb.ki_flags &= ~IOCB_DIRECT; 868 - iocb->kiocb.ki_complete = NULL; 869 - iocb->aio_complete_work = NULL; 870 - goto retry; 871 - } 872 - nfs_local_pgio_done(iocb->hdr, status); 873 - if (iocb->hdr->task.tk_status) 816 + if (unlikely(status >= 0 && status < iocb->iters[i].count)) 817 + force_done = true; /* Partial write */ 818 + if (nfs_local_pgio_done(iocb, status, force_done)) { 819 + nfs_local_write_iocb_done(iocb); 874 820 break; 821 + } 875 822 } 876 823 } 877 824 file_end_write(filp); 878 825 879 826 revert_creds(save_cred); 880 827 current->flags = old_flags; 881 - 882 - if (status != -EIOCBQUEUED) { 883 - nfs_local_write_done(iocb, status); 884 - nfs_local_vfs_getattr(iocb); 885 - nfs_local_pgio_release(iocb); 886 - } 887 828 } 888 829 889 830 static int
+12 -2
fs/nfs/nfs3client.c
··· 2 2 #include <linux/nfs_fs.h> 3 3 #include <linux/nfs_mount.h> 4 4 #include <linux/sunrpc/addr.h> 5 + #include <net/handshake.h> 5 6 #include "internal.h" 6 7 #include "nfs3_fs.h" 7 8 #include "netns.h" ··· 99 98 .net = mds_clp->cl_net, 100 99 .timeparms = &ds_timeout, 101 100 .cred = mds_srv->cred, 102 - .xprtsec = mds_clp->cl_xprtsec, 101 + .xprtsec = { 102 + .policy = RPC_XPRTSEC_NONE, 103 + .cert_serial = TLS_NO_CERT, 104 + .privkey_serial = TLS_NO_PRIVKEY, 105 + }, 103 106 .connect_timeout = connect_timeout, 104 107 .reconnect_timeout = connect_timeout, 105 108 }; ··· 116 111 cl_init.hostname = buf; 117 112 118 113 switch (ds_proto) { 114 + case XPRT_TRANSPORT_TCP_TLS: 115 + if (mds_clp->cl_xprtsec.policy != RPC_XPRTSEC_NONE) 116 + cl_init.xprtsec = mds_clp->cl_xprtsec; 117 + else 118 + ds_proto = XPRT_TRANSPORT_TCP; 119 + fallthrough; 119 120 case XPRT_TRANSPORT_RDMA: 120 121 case XPRT_TRANSPORT_TCP: 121 - case XPRT_TRANSPORT_TCP_TLS: 122 122 if (mds_clp->cl_nconnect > 1) 123 123 cl_init.nconnect = mds_clp->cl_nconnect; 124 124 }
+12 -2
fs/nfs/nfs4client.c
··· 11 11 #include <linux/sunrpc/xprt.h> 12 12 #include <linux/sunrpc/bc_xprt.h> 13 13 #include <linux/sunrpc/rpc_pipe_fs.h> 14 + #include <net/handshake.h> 14 15 #include "internal.h" 15 16 #include "callback.h" 16 17 #include "delegation.h" ··· 984 983 .net = mds_clp->cl_net, 985 984 .timeparms = &ds_timeout, 986 985 .cred = mds_srv->cred, 987 - .xprtsec = mds_srv->nfs_client->cl_xprtsec, 986 + .xprtsec = { 987 + .policy = RPC_XPRTSEC_NONE, 988 + .cert_serial = TLS_NO_CERT, 989 + .privkey_serial = TLS_NO_PRIVKEY, 990 + }, 988 991 }; 989 992 char buf[INET6_ADDRSTRLEN + 1]; 990 993 ··· 997 992 cl_init.hostname = buf; 998 993 999 994 switch (ds_proto) { 995 + case XPRT_TRANSPORT_TCP_TLS: 996 + if (mds_srv->nfs_client->cl_xprtsec.policy != RPC_XPRTSEC_NONE) 997 + cl_init.xprtsec = mds_srv->nfs_client->cl_xprtsec; 998 + else 999 + ds_proto = XPRT_TRANSPORT_TCP; 1000 + fallthrough; 1000 1001 case XPRT_TRANSPORT_RDMA: 1001 1002 case XPRT_TRANSPORT_TCP: 1002 - case XPRT_TRANSPORT_TCP_TLS: 1003 1003 if (mds_clp->cl_nconnect > 1) { 1004 1004 cl_init.nconnect = mds_clp->cl_nconnect; 1005 1005 cl_init.max_connect = NFS_MAX_TRANSPORTS;
+6 -3
fs/nfs/nfs4proc.c
··· 4715 4715 }; 4716 4716 unsigned short task_flags = 0; 4717 4717 4718 - if (NFS_SERVER(inode)->flags & NFS_MOUNT_SOFTREVAL) 4718 + if (server->flags & NFS_MOUNT_SOFTREVAL) 4719 4719 task_flags |= RPC_TASK_TIMEOUT; 4720 + if (server->caps & NFS_CAP_MOVEABLE) 4721 + task_flags |= RPC_TASK_MOVEABLE; 4720 4722 4721 4723 args.bitmask = nfs4_bitmask(server, fattr->label); 4722 4724 4723 4725 nfs_fattr_init(fattr); 4726 + nfs4_init_sequence(&args.seq_args, &res.seq_res, 0, 0); 4724 4727 4725 4728 dprintk("NFS call lookupp ino=0x%lx\n", inode->i_ino); 4726 - status = nfs4_call_sync(clnt, server, &msg, &args.seq_args, 4727 - &res.seq_res, task_flags); 4729 + status = nfs4_do_call_sync(clnt, server, &msg, &args.seq_args, 4730 + &res.seq_res, task_flags); 4728 4731 dprintk("NFS reply lookupp: %d\n", status); 4729 4732 return status; 4730 4733 }
+35 -31
fs/nfs/pnfs_nfs.c
··· 809 809 unsigned int retrans) 810 810 { 811 811 struct nfs_client *clp = ERR_PTR(-EIO); 812 + struct nfs_client *mds_clp = mds_srv->nfs_client; 813 + enum xprtsec_policies xprtsec_policy = mds_clp->cl_xprtsec.policy; 812 814 struct nfs4_pnfs_ds_addr *da; 813 815 unsigned long connect_timeout = timeo * (retrans + 1) * HZ / 10; 816 + int ds_proto; 814 817 int status = 0; 815 818 816 819 dprintk("--> %s DS %s\n", __func__, ds->ds_remotestr); ··· 837 834 .xprtsec = clp->cl_xprtsec, 838 835 }; 839 836 840 - if (da->da_transport != clp->cl_proto && 841 - clp->cl_proto != XPRT_TRANSPORT_TCP_TLS) 842 - continue; 843 - if (da->da_transport == XPRT_TRANSPORT_TCP && 844 - mds_srv->nfs_client->cl_proto == XPRT_TRANSPORT_TCP_TLS) 837 + if (xprt_args.ident == XPRT_TRANSPORT_TCP && 838 + clp->cl_proto == XPRT_TRANSPORT_TCP_TLS) 845 839 xprt_args.ident = XPRT_TRANSPORT_TCP_TLS; 846 840 847 - if (da->da_addr.ss_family != clp->cl_addr.ss_family) 841 + if (xprt_args.ident != clp->cl_proto) 842 + continue; 843 + if (xprt_args.dstaddr->sa_family != 844 + clp->cl_addr.ss_family) 848 845 continue; 849 846 /* Add this address as an alias */ 850 847 rpc_clnt_add_xprt(clp->cl_rpcclient, &xprt_args, 851 - rpc_clnt_test_and_add_xprt, NULL); 848 + rpc_clnt_test_and_add_xprt, NULL); 852 849 continue; 853 850 } 854 - if (da->da_transport == XPRT_TRANSPORT_TCP && 855 - mds_srv->nfs_client->cl_proto == XPRT_TRANSPORT_TCP_TLS) 856 - da->da_transport = XPRT_TRANSPORT_TCP_TLS; 857 - clp = get_v3_ds_connect(mds_srv, 858 - &da->da_addr, 859 - da->da_addrlen, da->da_transport, 860 - timeo, retrans); 851 + 852 + ds_proto = da->da_transport; 853 + if (ds_proto == XPRT_TRANSPORT_TCP && 854 + xprtsec_policy != RPC_XPRTSEC_NONE) 855 + ds_proto = XPRT_TRANSPORT_TCP_TLS; 856 + 857 + clp = get_v3_ds_connect(mds_srv, &da->da_addr, da->da_addrlen, 858 + ds_proto, timeo, retrans); 861 859 if (IS_ERR(clp)) 862 860 continue; 863 861 clp->cl_rpcclient->cl_softerr = 0; ··· 884 880 u32 minor_version) 885 881 { 886 882 struct nfs_client *clp = ERR_PTR(-EIO); 883 + struct nfs_client *mds_clp = mds_srv->nfs_client; 884 + enum xprtsec_policies xprtsec_policy = mds_clp->cl_xprtsec.policy; 887 885 struct nfs4_pnfs_ds_addr *da; 886 + int ds_proto; 888 887 int status = 0; 889 888 890 889 dprintk("--> %s DS %s\n", __func__, ds->ds_remotestr); ··· 915 908 .data = &xprtdata, 916 909 }; 917 910 918 - if (da->da_transport != clp->cl_proto && 919 - clp->cl_proto != XPRT_TRANSPORT_TCP_TLS) 920 - continue; 921 - if (da->da_transport == XPRT_TRANSPORT_TCP && 922 - mds_srv->nfs_client->cl_proto == 923 - XPRT_TRANSPORT_TCP_TLS) { 911 + if (xprt_args.ident == XPRT_TRANSPORT_TCP && 912 + clp->cl_proto == XPRT_TRANSPORT_TCP_TLS) { 924 913 struct sockaddr *addr = 925 914 (struct sockaddr *)&da->da_addr; 926 915 struct sockaddr_in *sin = ··· 947 944 xprt_args.ident = XPRT_TRANSPORT_TCP_TLS; 948 945 xprt_args.servername = servername; 949 946 } 950 - if (da->da_addr.ss_family != clp->cl_addr.ss_family) 947 + if (xprt_args.ident != clp->cl_proto) 948 + continue; 949 + if (xprt_args.dstaddr->sa_family != 950 + clp->cl_addr.ss_family) 951 951 continue; 952 952 953 953 /** ··· 964 958 if (xprtdata.cred) 965 959 put_cred(xprtdata.cred); 966 960 } else { 967 - if (da->da_transport == XPRT_TRANSPORT_TCP && 968 - mds_srv->nfs_client->cl_proto == 969 - XPRT_TRANSPORT_TCP_TLS) 970 - da->da_transport = XPRT_TRANSPORT_TCP_TLS; 971 - clp = nfs4_set_ds_client(mds_srv, 972 - &da->da_addr, 973 - da->da_addrlen, 974 - da->da_transport, timeo, 975 - retrans, minor_version); 961 + ds_proto = da->da_transport; 962 + if (ds_proto == XPRT_TRANSPORT_TCP && 963 + xprtsec_policy != RPC_XPRTSEC_NONE) 964 + ds_proto = XPRT_TRANSPORT_TCP_TLS; 965 + 966 + clp = nfs4_set_ds_client(mds_srv, &da->da_addr, 967 + da->da_addrlen, ds_proto, 968 + timeo, retrans, minor_version); 976 969 if (IS_ERR(clp)) 977 970 continue; 978 971 ··· 982 977 clp = ERR_PTR(-EIO); 983 978 continue; 984 979 } 985 - 986 980 } 987 981 } 988 982
+1
fs/nfs/sysfs.c
··· 189 189 return p; 190 190 191 191 kobject_put(&p->kobject); 192 + kobject_put(&p->nfs_net_kobj); 192 193 } 193 194 return NULL; 194 195 }
+49 -19
fs/nfsd/nfs4state.c
··· 1542 1542 release_all_access(stp); 1543 1543 if (stp->st_stateowner) 1544 1544 nfs4_put_stateowner(stp->st_stateowner); 1545 - WARN_ON(!list_empty(&stid->sc_cp_list)); 1545 + if (!list_empty(&stid->sc_cp_list)) 1546 + nfs4_free_cpntf_statelist(stid->sc_client->net, stid); 1546 1547 kmem_cache_free(stateid_slab, stid); 1547 1548 } 1548 1549 ··· 3487 3486 struct nfsd4_slot *slot = resp->cstate.slot; 3488 3487 unsigned int base; 3489 3488 3490 - dprintk("--> %s slot %p\n", __func__, slot); 3489 + /* 3490 + * RFC 5661 Section 2.10.6.1.2: 3491 + * 3492 + * Any time SEQUENCE ... returns an error ... [t]he replier MUST NOT 3493 + * modify the reply cache entry for the slot whenever an error is 3494 + * returned from SEQUENCE ... 3495 + * 3496 + * Because nfsd4_store_cache_entry is called only by 3497 + * nfsd4_sequence_done(), nfsd4_store_cache_entry() is called only 3498 + * when a SEQUENCE operation was part of the COMPOUND. 3499 + * nfs41_check_op_ordering() ensures SEQUENCE is the first op. 3500 + */ 3501 + if (resp->opcnt == 1 && resp->cstate.status != nfs_ok) 3502 + return; 3491 3503 3492 3504 slot->sl_flags |= NFSD4_SLOT_INITIALIZED; 3493 3505 slot->sl_opcnt = resp->opcnt; ··· 4363 4349 return true; 4364 4350 } 4365 4351 4352 + /* 4353 + * Note that the response is constructed here both for the case 4354 + * of a new SEQUENCE request and for a replayed SEQUENCE request. 4355 + * We do not cache SEQUENCE responses as SEQUENCE is idempotent. 4356 + */ 4357 + static void nfsd4_construct_sequence_response(struct nfsd4_session *session, 4358 + struct nfsd4_sequence *seq) 4359 + { 4360 + struct nfs4_client *clp = session->se_client; 4361 + 4362 + seq->maxslots_response = max(session->se_target_maxslots, 4363 + seq->maxslots); 4364 + seq->target_maxslots = session->se_target_maxslots; 4365 + 4366 + switch (clp->cl_cb_state) { 4367 + case NFSD4_CB_DOWN: 4368 + seq->status_flags = SEQ4_STATUS_CB_PATH_DOWN; 4369 + break; 4370 + case NFSD4_CB_FAULT: 4371 + seq->status_flags = SEQ4_STATUS_BACKCHANNEL_FAULT; 4372 + break; 4373 + default: 4374 + seq->status_flags = 0; 4375 + } 4376 + if (!list_empty(&clp->cl_revoked)) 4377 + seq->status_flags |= SEQ4_STATUS_RECALLABLE_STATE_REVOKED; 4378 + if (atomic_read(&clp->cl_admin_revoked)) 4379 + seq->status_flags |= SEQ4_STATUS_ADMIN_STATE_REVOKED; 4380 + } 4381 + 4366 4382 __be32 4367 4383 nfsd4_sequence(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, 4368 4384 union nfsd4_op_u *u) ··· 4442 4398 dprintk("%s: slotid %d\n", __func__, seq->slotid); 4443 4399 4444 4400 trace_nfsd_slot_seqid_sequence(clp, seq, slot); 4401 + 4402 + nfsd4_construct_sequence_response(session, seq); 4403 + 4445 4404 status = check_slot_seqid(seq->seqid, slot->sl_seqid, slot->sl_flags); 4446 4405 if (status == nfserr_replay_cache) { 4447 4406 status = nfserr_seq_misordered; ··· 4542 4495 } 4543 4496 4544 4497 out: 4545 - seq->maxslots = max(session->se_target_maxslots, seq->maxslots); 4546 - seq->target_maxslots = session->se_target_maxslots; 4547 - 4548 - switch (clp->cl_cb_state) { 4549 - case NFSD4_CB_DOWN: 4550 - seq->status_flags = SEQ4_STATUS_CB_PATH_DOWN; 4551 - break; 4552 - case NFSD4_CB_FAULT: 4553 - seq->status_flags = SEQ4_STATUS_BACKCHANNEL_FAULT; 4554 - break; 4555 - default: 4556 - seq->status_flags = 0; 4557 - } 4558 - if (!list_empty(&clp->cl_revoked)) 4559 - seq->status_flags |= SEQ4_STATUS_RECALLABLE_STATE_REVOKED; 4560 - if (atomic_read(&clp->cl_admin_revoked)) 4561 - seq->status_flags |= SEQ4_STATUS_ADMIN_STATE_REVOKED; 4562 4498 trace_nfsd_seq4_status(rqstp, seq); 4563 4499 out_no_session: 4564 4500 if (conn)
+2 -3
fs/nfsd/nfs4xdr.c
··· 5073 5073 return nfserr; 5074 5074 /* Note slotid's are numbered from zero: */ 5075 5075 /* sr_highest_slotid */ 5076 - nfserr = nfsd4_encode_slotid4(xdr, seq->maxslots - 1); 5076 + nfserr = nfsd4_encode_slotid4(xdr, seq->maxslots_response - 1); 5077 5077 if (nfserr != nfs_ok) 5078 5078 return nfserr; 5079 5079 /* sr_target_highest_slotid */ ··· 5925 5925 */ 5926 5926 warn_on_nonidempotent_op(op); 5927 5927 xdr_truncate_encode(xdr, op_status_offset + XDR_UNIT); 5928 - } 5929 - if (so) { 5928 + } else if (so) { 5930 5929 int len = xdr->buf->len - (op_status_offset + XDR_UNIT); 5931 5930 5932 5931 so->so_replay.rp_status = op->status;
+1
fs/nfsd/nfsd.h
··· 458 458 #define NFSD4_2_SUPPORTED_ATTRS_WORD2 \ 459 459 (NFSD4_1_SUPPORTED_ATTRS_WORD2 | \ 460 460 FATTR4_WORD2_MODE_UMASK | \ 461 + FATTR4_WORD2_CLONE_BLKSIZE | \ 461 462 NFSD4_2_SECURITY_ATTRS | \ 462 463 FATTR4_WORD2_XATTR_SUPPORT | \ 463 464 FATTR4_WORD2_TIME_DELEG_ACCESS | \
+3 -3
fs/nfsd/nfsfh.c
··· 269 269 dentry); 270 270 } 271 271 272 - fhp->fh_dentry = dentry; 273 - fhp->fh_export = exp; 274 - 275 272 switch (fhp->fh_maxsize) { 276 273 case NFS4_FHSIZE: 277 274 if (dentry->d_sb->s_export_op->flags & EXPORT_OP_NOATOMIC_ATTR) ··· 289 292 if (exp->ex_flags & NFSEXP_V4ROOT) 290 293 goto out; 291 294 } 295 + 296 + fhp->fh_dentry = dentry; 297 + fhp->fh_export = exp; 292 298 293 299 return 0; 294 300 out:
+2 -1
fs/nfsd/xdr4.h
··· 574 574 struct nfs4_sessionid sessionid; /* request/response */ 575 575 u32 seqid; /* request/response */ 576 576 u32 slotid; /* request/response */ 577 - u32 maxslots; /* request/response */ 577 + u32 maxslots; /* request */ 578 578 u32 cachethis; /* request */ 579 + u32 maxslots_response; /* response */ 579 580 u32 target_maxslots; /* response */ 580 581 u32 status_flags; /* response */ 581 582 };
+6 -1
fs/nilfs2/segment.c
··· 2768 2768 2769 2769 if (sci->sc_task) { 2770 2770 wake_up(&sci->sc_wait_daemon); 2771 - kthread_stop(sci->sc_task); 2771 + if (kthread_stop(sci->sc_task)) { 2772 + spin_lock(&sci->sc_state_lock); 2773 + sci->sc_task = NULL; 2774 + timer_shutdown_sync(&sci->sc_timer); 2775 + spin_unlock(&sci->sc_state_lock); 2776 + } 2772 2777 } 2773 2778 2774 2779 spin_lock(&sci->sc_state_lock);
+9 -3
fs/proc/generic.c
··· 698 698 } 699 699 } 700 700 701 + static void pde_erase(struct proc_dir_entry *pde, struct proc_dir_entry *parent) 702 + { 703 + rb_erase(&pde->subdir_node, &parent->subdir); 704 + RB_CLEAR_NODE(&pde->subdir_node); 705 + } 706 + 701 707 /* 702 708 * Remove a /proc entry and free it if it's not currently in use. 703 709 */ ··· 726 720 WARN(1, "removing permanent /proc entry '%s'", de->name); 727 721 de = NULL; 728 722 } else { 729 - rb_erase(&de->subdir_node, &parent->subdir); 723 + pde_erase(de, parent); 730 724 if (S_ISDIR(de->mode)) 731 725 parent->nlink--; 732 726 } ··· 770 764 root->parent->name, root->name); 771 765 return -EINVAL; 772 766 } 773 - rb_erase(&root->subdir_node, &parent->subdir); 767 + pde_erase(root, parent); 774 768 775 769 de = root; 776 770 while (1) { ··· 782 776 next->parent->name, next->name); 783 777 return -EINVAL; 784 778 } 785 - rb_erase(&next->subdir_node, &de->subdir); 779 + pde_erase(next, de); 786 780 de = next; 787 781 continue; 788 782 }
+9 -7
fs/smb/client/cached_dir.c
··· 388 388 * lease. Release one here, and the second below. 389 389 */ 390 390 cfid->has_lease = false; 391 - kref_put(&cfid->refcount, smb2_close_cached_fid); 391 + close_cached_dir(cfid); 392 392 } 393 393 spin_unlock(&cfids->cfid_list_lock); 394 394 395 - kref_put(&cfid->refcount, smb2_close_cached_fid); 395 + close_cached_dir(cfid); 396 396 } else { 397 397 *ret_cfid = cfid; 398 398 atomic_inc(&tcon->num_remote_opens); ··· 438 438 439 439 static void 440 440 smb2_close_cached_fid(struct kref *ref) 441 + __releases(&cfid->cfids->cfid_list_lock) 441 442 { 442 443 struct cached_fid *cfid = container_of(ref, struct cached_fid, 443 444 refcount); 444 445 int rc; 445 446 446 - spin_lock(&cfid->cfids->cfid_list_lock); 447 + lockdep_assert_held(&cfid->cfids->cfid_list_lock); 448 + 447 449 if (cfid->on_list) { 448 450 list_del(&cfid->entry); 449 451 cfid->on_list = false; ··· 480 478 spin_lock(&cfid->cfids->cfid_list_lock); 481 479 if (cfid->has_lease) { 482 480 cfid->has_lease = false; 483 - kref_put(&cfid->refcount, smb2_close_cached_fid); 481 + close_cached_dir(cfid); 484 482 } 485 483 spin_unlock(&cfid->cfids->cfid_list_lock); 486 484 close_cached_dir(cfid); ··· 489 487 490 488 void close_cached_dir(struct cached_fid *cfid) 491 489 { 492 - kref_put(&cfid->refcount, smb2_close_cached_fid); 490 + kref_put_lock(&cfid->refcount, smb2_close_cached_fid, &cfid->cfids->cfid_list_lock); 493 491 } 494 492 495 493 /* ··· 598 596 599 597 WARN_ON(cfid->on_list); 600 598 601 - kref_put(&cfid->refcount, smb2_close_cached_fid); 599 + close_cached_dir(cfid); 602 600 cifs_put_tcon(tcon, netfs_trace_tcon_ref_put_cached_close); 603 601 } 604 602 ··· 764 762 * Drop the ref-count from above, either the lease-ref (if there 765 763 * was one) or the extra one acquired. 766 764 */ 767 - kref_put(&cfid->refcount, smb2_close_cached_fid); 765 + close_cached_dir(cfid); 768 766 } 769 767 queue_delayed_work(cfid_put_wq, &cfids->laundromat_work, 770 768 dir_cache_timeout * HZ);
+3 -1
fs/smb/client/fs_context.c
··· 1435 1435 cifs_errorf(fc, "Unknown error parsing devname\n"); 1436 1436 goto cifs_parse_mount_err; 1437 1437 } 1438 + kfree(ctx->source); 1438 1439 ctx->source = smb3_fs_context_fullpath(ctx, '/'); 1439 1440 if (IS_ERR(ctx->source)) { 1440 1441 ctx->source = NULL; 1441 1442 cifs_errorf(fc, "OOM when copying UNC string\n"); 1442 1443 goto cifs_parse_mount_err; 1443 1444 } 1445 + kfree(fc->source); 1444 1446 fc->source = kstrdup(ctx->source, GFP_KERNEL); 1445 1447 if (fc->source == NULL) { 1446 1448 cifs_errorf(fc, "OOM when copying UNC string\n"); ··· 1470 1468 break; 1471 1469 } 1472 1470 1473 - if (strnlen(param->string, CIFS_MAX_USERNAME_LEN) > 1471 + if (strnlen(param->string, CIFS_MAX_USERNAME_LEN) == 1474 1472 CIFS_MAX_USERNAME_LEN) { 1475 1473 pr_warn("username too long\n"); 1476 1474 goto cifs_parse_mount_err;
+2
fs/smb/client/smb2inode.c
··· 1294 1294 smb2_to_name = cifs_convert_path_to_utf16(to_name, cifs_sb); 1295 1295 if (smb2_to_name == NULL) { 1296 1296 rc = -ENOMEM; 1297 + if (cfile) 1298 + cifsFileInfo_put(cfile); 1297 1299 goto smb2_rename_path; 1298 1300 } 1299 1301 in_iov.iov_base = smb2_to_name;
+5 -2
fs/smb/client/smb2pdu.c
··· 4054 4054 4055 4055 smb_rsp = (struct smb2_change_notify_rsp *)rsp_iov.iov_base; 4056 4056 4057 - smb2_validate_iov(le16_to_cpu(smb_rsp->OutputBufferOffset), 4058 - le32_to_cpu(smb_rsp->OutputBufferLength), &rsp_iov, 4057 + rc = smb2_validate_iov(le16_to_cpu(smb_rsp->OutputBufferOffset), 4058 + le32_to_cpu(smb_rsp->OutputBufferLength), 4059 + &rsp_iov, 4059 4060 sizeof(struct file_notify_information)); 4061 + if (rc) 4062 + goto cnotify_exit; 4060 4063 4061 4064 *out_data = kmemdup((char *)smb_rsp + le16_to_cpu(smb_rsp->OutputBufferOffset), 4062 4065 le32_to_cpu(smb_rsp->OutputBufferLength), GFP_KERNEL);
+3
fs/smb/client/smbdirect.c
··· 290 290 break; 291 291 292 292 case SMBDIRECT_SOCKET_CREATED: 293 + sc->status = SMBDIRECT_SOCKET_DISCONNECTED; 294 + break; 295 + 293 296 case SMBDIRECT_SOCKET_CONNECTED: 294 297 sc->status = SMBDIRECT_SOCKET_ERROR; 295 298 break;
+1 -1
fs/smb/client/transport.c
··· 830 830 if (!server || server->terminate) 831 831 continue; 832 832 833 - if (CIFS_CHAN_NEEDS_RECONNECT(ses, i)) 833 + if (CIFS_CHAN_NEEDS_RECONNECT(ses, cur)) 834 834 continue; 835 835 836 836 /*
+36 -2
fs/smb/server/transport_rdma.c
··· 334 334 break; 335 335 336 336 case SMBDIRECT_SOCKET_CREATED: 337 + sc->status = SMBDIRECT_SOCKET_DISCONNECTED; 338 + break; 339 + 337 340 case SMBDIRECT_SOCKET_CONNECTED: 338 341 sc->status = SMBDIRECT_SOCKET_ERROR; 339 342 break; ··· 1886 1883 static int smb_direct_prepare_negotiation(struct smbdirect_socket *sc) 1887 1884 { 1888 1885 struct smbdirect_recv_io *recvmsg; 1886 + bool recv_posted = false; 1889 1887 int ret; 1890 1888 1891 1889 WARN_ON_ONCE(sc->status != SMBDIRECT_SOCKET_CREATED); ··· 1903 1899 pr_err("Can't post recv: %d\n", ret); 1904 1900 goto out_err; 1905 1901 } 1902 + recv_posted = true; 1906 1903 1907 1904 ret = smb_direct_accept_client(sc); 1908 1905 if (ret) { ··· 1913 1908 1914 1909 return 0; 1915 1910 out_err: 1916 - put_recvmsg(sc, recvmsg); 1911 + /* 1912 + * If the recv was never posted, return it to the free list. 1913 + * If it was posted, leave it alone so disconnect teardown can 1914 + * drain the QP and complete it (flush) and the completion path 1915 + * will unmap it exactly once. 1916 + */ 1917 + if (!recv_posted) 1918 + put_recvmsg(sc, recvmsg); 1917 1919 return ret; 1918 1920 } 1919 1921 ··· 2618 2606 } 2619 2607 } 2620 2608 2621 - bool ksmbd_rdma_capable_netdev(struct net_device *netdev) 2609 + static bool ksmbd_find_rdma_capable_netdev(struct net_device *netdev) 2622 2610 { 2623 2611 struct smb_direct_device *smb_dev; 2624 2612 int i; ··· 2658 2646 netdev->name, str_true_false(rdma_capable)); 2659 2647 2660 2648 return rdma_capable; 2649 + } 2650 + 2651 + bool ksmbd_rdma_capable_netdev(struct net_device *netdev) 2652 + { 2653 + struct net_device *lower_dev; 2654 + struct list_head *iter; 2655 + 2656 + if (ksmbd_find_rdma_capable_netdev(netdev)) 2657 + return true; 2658 + 2659 + /* check if netdev is bridge or VLAN */ 2660 + if (netif_is_bridge_master(netdev) || 2661 + netdev->priv_flags & IFF_802_1Q_VLAN) 2662 + netdev_for_each_lower_dev(netdev, lower_dev, iter) 2663 + if (ksmbd_find_rdma_capable_netdev(lower_dev)) 2664 + return true; 2665 + 2666 + /* check if netdev is IPoIB safely without layer violation */ 2667 + if (netdev->type == ARPHRD_INFINIBAND) 2668 + return true; 2669 + 2670 + return false; 2661 2671 } 2662 2672 2663 2673 static const struct ksmbd_transport_ops ksmbd_smb_direct_transport_ops = {
+4 -1
fs/smb/server/transport_tcp.c
··· 290 290 } 291 291 } 292 292 up_read(&conn_list_lock); 293 - if (ret == -EAGAIN) 293 + if (ret == -EAGAIN) { 294 + /* Per-IP limit hit: release the just-accepted socket. */ 295 + sock_release(client_sk); 294 296 continue; 297 + } 295 298 296 299 skip_max_ip_conns_limit: 297 300 if (server_conf.max_connections &&
+3 -1
fs/xfs/xfs_discard.c
··· 726 726 break; 727 727 } 728 728 729 - if (!tr.queued) 729 + if (!tr.queued) { 730 + kfree(tr.extents); 730 731 break; 732 + } 731 733 732 734 /* 733 735 * We hand the extent list to the discard function here so the
+69 -13
fs/xfs/xfs_iomap.c
··· 1091 1091 }; 1092 1092 #endif /* CONFIG_XFS_RT */ 1093 1093 1094 + #ifdef DEBUG 1095 + static void 1096 + xfs_check_atomic_cow_conversion( 1097 + struct xfs_inode *ip, 1098 + xfs_fileoff_t offset_fsb, 1099 + xfs_filblks_t count_fsb, 1100 + const struct xfs_bmbt_irec *cmap) 1101 + { 1102 + struct xfs_iext_cursor icur; 1103 + struct xfs_bmbt_irec cmap2 = { }; 1104 + 1105 + if (xfs_iext_lookup_extent(ip, ip->i_cowfp, offset_fsb, &icur, &cmap2)) 1106 + xfs_trim_extent(&cmap2, offset_fsb, count_fsb); 1107 + 1108 + ASSERT(cmap2.br_startoff == cmap->br_startoff); 1109 + ASSERT(cmap2.br_blockcount == cmap->br_blockcount); 1110 + ASSERT(cmap2.br_startblock == cmap->br_startblock); 1111 + ASSERT(cmap2.br_state == cmap->br_state); 1112 + } 1113 + #else 1114 + # define xfs_check_atomic_cow_conversion(...) ((void)0) 1115 + #endif 1116 + 1094 1117 static int 1095 1118 xfs_atomic_write_cow_iomap_begin( 1096 1119 struct inode *inode, ··· 1125 1102 { 1126 1103 struct xfs_inode *ip = XFS_I(inode); 1127 1104 struct xfs_mount *mp = ip->i_mount; 1128 - const xfs_fileoff_t offset_fsb = XFS_B_TO_FSBT(mp, offset); 1129 - xfs_fileoff_t end_fsb = xfs_iomap_end_fsb(mp, offset, length); 1130 - xfs_filblks_t count_fsb = end_fsb - offset_fsb; 1105 + const xfs_fileoff_t offset_fsb = XFS_B_TO_FSBT(mp, offset); 1106 + const xfs_fileoff_t end_fsb = XFS_B_TO_FSB(mp, offset + length); 1107 + const xfs_filblks_t count_fsb = end_fsb - offset_fsb; 1108 + xfs_filblks_t hole_count_fsb; 1131 1109 int nmaps = 1; 1132 1110 xfs_filblks_t resaligned; 1133 1111 struct xfs_bmbt_irec cmap; ··· 1154 1130 return -EAGAIN; 1155 1131 1156 1132 trace_xfs_iomap_atomic_write_cow(ip, offset, length); 1157 - 1133 + retry: 1158 1134 xfs_ilock(ip, XFS_ILOCK_EXCL); 1159 1135 1160 1136 if (!ip->i_cowfp) { ··· 1165 1141 if (!xfs_iext_lookup_extent(ip, ip->i_cowfp, offset_fsb, &icur, &cmap)) 1166 1142 cmap.br_startoff = end_fsb; 1167 1143 if (cmap.br_startoff <= offset_fsb) { 1144 + if (isnullstartblock(cmap.br_startblock)) 1145 + goto convert_delay; 1146 + 1147 + /* 1148 + * cmap could extend outside the write range due to previous 1149 + * speculative preallocations. We must trim cmap to the write 1150 + * range because the cow fork treats written mappings to mean 1151 + * "write in progress". 1152 + */ 1168 1153 xfs_trim_extent(&cmap, offset_fsb, count_fsb); 1169 1154 goto found; 1170 1155 } 1171 1156 1172 - end_fsb = cmap.br_startoff; 1173 - count_fsb = end_fsb - offset_fsb; 1157 + hole_count_fsb = cmap.br_startoff - offset_fsb; 1174 1158 1175 - resaligned = xfs_aligned_fsb_count(offset_fsb, count_fsb, 1159 + resaligned = xfs_aligned_fsb_count(offset_fsb, hole_count_fsb, 1176 1160 xfs_get_cowextsz_hint(ip)); 1177 1161 xfs_iunlock(ip, XFS_ILOCK_EXCL); 1178 1162 ··· 1201 1169 if (!xfs_iext_lookup_extent(ip, ip->i_cowfp, offset_fsb, &icur, &cmap)) 1202 1170 cmap.br_startoff = end_fsb; 1203 1171 if (cmap.br_startoff <= offset_fsb) { 1204 - xfs_trim_extent(&cmap, offset_fsb, count_fsb); 1205 1172 xfs_trans_cancel(tp); 1173 + if (isnullstartblock(cmap.br_startblock)) 1174 + goto convert_delay; 1175 + xfs_trim_extent(&cmap, offset_fsb, count_fsb); 1206 1176 goto found; 1207 1177 } 1208 1178 ··· 1216 1182 * atomic writes to that same range will be aligned (and don't require 1217 1183 * this COW-based method). 1218 1184 */ 1219 - error = xfs_bmapi_write(tp, ip, offset_fsb, count_fsb, 1185 + error = xfs_bmapi_write(tp, ip, offset_fsb, hole_count_fsb, 1220 1186 XFS_BMAPI_COWFORK | XFS_BMAPI_PREALLOC | 1221 1187 XFS_BMAPI_EXTSZALIGN, 0, &cmap, &nmaps); 1222 1188 if (error) { ··· 1229 1195 if (error) 1230 1196 goto out_unlock; 1231 1197 1198 + /* 1199 + * cmap could map more blocks than the range we passed into bmapi_write 1200 + * because of EXTSZALIGN or adjacent pre-existing unwritten mappings 1201 + * that were merged. Trim cmap to the original write range so that we 1202 + * don't convert more than we were asked to do for this write. 1203 + */ 1204 + xfs_trim_extent(&cmap, offset_fsb, count_fsb); 1205 + 1232 1206 found: 1233 1207 if (cmap.br_state != XFS_EXT_NORM) { 1234 - error = xfs_reflink_convert_cow_locked(ip, offset_fsb, 1235 - count_fsb); 1208 + error = xfs_reflink_convert_cow_locked(ip, cmap.br_startoff, 1209 + cmap.br_blockcount); 1236 1210 if (error) 1237 1211 goto out_unlock; 1238 1212 cmap.br_state = XFS_EXT_NORM; 1213 + xfs_check_atomic_cow_conversion(ip, offset_fsb, count_fsb, 1214 + &cmap); 1239 1215 } 1240 1216 1241 - length = XFS_FSB_TO_B(mp, cmap.br_startoff + cmap.br_blockcount); 1242 - trace_xfs_iomap_found(ip, offset, length - offset, XFS_COW_FORK, &cmap); 1217 + trace_xfs_iomap_found(ip, offset, length, XFS_COW_FORK, &cmap); 1243 1218 seq = xfs_iomap_inode_sequence(ip, IOMAP_F_SHARED); 1244 1219 xfs_iunlock(ip, XFS_ILOCK_EXCL); 1245 1220 return xfs_bmbt_to_iomap(ip, iomap, &cmap, flags, IOMAP_F_SHARED, seq); 1246 1221 1222 + convert_delay: 1223 + xfs_iunlock(ip, XFS_ILOCK_EXCL); 1224 + error = xfs_bmapi_convert_delalloc(ip, XFS_COW_FORK, offset, iomap, 1225 + NULL); 1226 + if (error) 1227 + return error; 1228 + 1229 + /* 1230 + * Try the lookup again, because the delalloc conversion might have 1231 + * turned the COW mapping into unwritten, but we need it to be in 1232 + * written state. 1233 + */ 1234 + goto retry; 1247 1235 out_unlock: 1248 1236 xfs_iunlock(ip, XFS_ILOCK_EXCL); 1249 1237 return error;
+4 -2
fs/xfs/xfs_zone_alloc.c
··· 615 615 lockdep_assert_held(&zi->zi_open_zones_lock); 616 616 617 617 list_for_each_entry_reverse(oz, &zi->zi_open_zones, oz_entry) 618 - if (xfs_try_use_zone(zi, file_hint, oz, false)) 618 + if (xfs_try_use_zone(zi, file_hint, oz, XFS_ZONE_ALLOC_OK)) 619 619 return oz; 620 620 621 621 cond_resched_lock(&zi->zi_open_zones_lock); ··· 1249 1249 1250 1250 while ((rtg = xfs_rtgroup_next(mp, rtg))) { 1251 1251 error = xfs_init_zone(&iz, rtg, NULL); 1252 - if (error) 1252 + if (error) { 1253 + xfs_rtgroup_rele(rtg); 1253 1254 goto out_free_zone_info; 1255 + } 1254 1256 } 1255 1257 } 1256 1258
+1 -1
include/drm/Makefile
··· 11 11 quiet_cmd_hdrtest = HDRTEST $(patsubst %.hdrtest,%.h,$@) 12 12 cmd_hdrtest = \ 13 13 $(CC) $(c_flags) -fsyntax-only -x c /dev/null -include $< -include $<; \ 14 - PYTHONDONTWRITEBYTECODE=1 $(KERNELDOC) -none $(if $(CONFIG_WERROR)$(CONFIG_DRM_WERROR),-Werror) $<; \ 14 + PYTHONDONTWRITEBYTECODE=1 $(PYTHON3) $(KERNELDOC) -none $(if $(CONFIG_WERROR)$(CONFIG_DRM_WERROR),-Werror) $<; \ 15 15 touch $@ 16 16 17 17 $(obj)/%.hdrtest: $(src)/%.h FORCE
+8 -3
include/linux/compiler_types.h
··· 250 250 /* 251 251 * GCC does not warn about unused static inline functions for -Wunused-function. 252 252 * Suppress the warning in clang as well by using __maybe_unused, but enable it 253 - * for W=1 build. This will allow clang to find unused functions. Remove the 254 - * __inline_maybe_unused entirely after fixing most of -Wunused-function warnings. 253 + * for W=2 build. This will allow clang to find unused functions. 255 254 */ 256 - #ifdef KBUILD_EXTRA_WARN1 255 + #ifdef KBUILD_EXTRA_WARN2 257 256 #define __inline_maybe_unused 258 257 #else 259 258 #define __inline_maybe_unused __maybe_unused ··· 458 459 # define __nocfi __attribute__((__no_sanitize__("kcfi"))) 459 460 #else 460 461 # define __nocfi 462 + #endif 463 + 464 + #if defined(CONFIG_ARCH_USES_CFI_GENERIC_LLVM_PASS) 465 + # define __nocfi_generic __nocfi 466 + #else 467 + # define __nocfi_generic 461 468 #endif 462 469 463 470 /*
+1 -1
include/linux/dma-mapping.h
··· 90 90 */ 91 91 #define DMA_MAPPING_ERROR (~(dma_addr_t)0) 92 92 93 - #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1)) 93 + #define DMA_BIT_MASK(n) GENMASK_ULL(n - 1, 0) 94 94 95 95 struct dma_iova_state { 96 96 dma_addr_t addr;
+1 -1
include/linux/entry-virt.h
··· 32 32 */ 33 33 static inline int arch_xfer_to_guest_mode_handle_work(unsigned long ti_work); 34 34 35 - #ifndef arch_xfer_to_guest_mode_work 35 + #ifndef arch_xfer_to_guest_mode_handle_work 36 36 static inline int arch_xfer_to_guest_mode_handle_work(unsigned long ti_work) 37 37 { 38 38 return 0;
+1 -1
include/linux/ethtool.h
··· 492 492 }; 493 493 494 494 #define ETHTOOL_MAX_LANES 8 495 - /** 495 + /* 496 496 * IEEE 802.3ck/df defines 16 bins for FEC histogram plus one more for 497 497 * the end-of-list marker, total 17 items 498 498 */
+20
include/linux/filter.h
··· 901 901 cb->data_end = skb->data + skb_headlen(skb); 902 902 } 903 903 904 + static inline int bpf_prog_run_data_pointers( 905 + const struct bpf_prog *prog, 906 + struct sk_buff *skb) 907 + { 908 + struct bpf_skb_data_end *cb = (struct bpf_skb_data_end *)skb->cb; 909 + void *save_data_meta, *save_data_end; 910 + int res; 911 + 912 + save_data_meta = cb->data_meta; 913 + save_data_end = cb->data_end; 914 + 915 + bpf_compute_data_pointers(skb); 916 + res = bpf_prog_run(prog, skb); 917 + 918 + cb->data_meta = save_data_meta; 919 + cb->data_end = save_data_end; 920 + 921 + return res; 922 + } 923 + 904 924 /* Similar to bpf_compute_data_pointers(), except that save orginal 905 925 * data in cb->data and cb->meta_data for restore. 906 926 */
+9 -1
include/linux/ftrace.h
··· 193 193 #if !defined(CONFIG_HAVE_DYNAMIC_FTRACE_WITH_ARGS) || \ 194 194 defined(CONFIG_HAVE_FTRACE_REGS_HAVING_PT_REGS) 195 195 196 + #ifndef arch_ftrace_partial_regs 197 + #define arch_ftrace_partial_regs(regs) do {} while (0) 198 + #endif 199 + 196 200 static __always_inline struct pt_regs * 197 201 ftrace_partial_regs(struct ftrace_regs *fregs, struct pt_regs *regs) 198 202 { ··· 206 202 * Since arch_ftrace_get_regs() will check some members and may return 207 203 * NULL, we can not use it. 208 204 */ 209 - return &arch_ftrace_regs(fregs)->regs; 205 + regs = &arch_ftrace_regs(fregs)->regs; 206 + 207 + /* Allow arch specific updates to regs. */ 208 + arch_ftrace_partial_regs(regs); 209 + return regs; 210 210 } 211 211 212 212 #endif /* !CONFIG_HAVE_DYNAMIC_FTRACE_WITH_ARGS || CONFIG_HAVE_FTRACE_REGS_HAVING_PT_REGS */
+3
include/linux/gfp.h
··· 7 7 #include <linux/mmzone.h> 8 8 #include <linux/topology.h> 9 9 #include <linux/alloc_tag.h> 10 + #include <linux/cleanup.h> 10 11 #include <linux/sched.h> 11 12 12 13 struct vm_area_struct; ··· 463 462 #endif 464 463 /* This should be paired with folio_put() rather than free_contig_range(). */ 465 464 #define folio_alloc_gigantic(...) alloc_hooks(folio_alloc_gigantic_noprof(__VA_ARGS__)) 465 + 466 + DEFINE_FREE(free_page, void *, free_page((unsigned long)_T)) 466 467 467 468 #endif /* __LINUX_GFP_H */
+23 -32
include/linux/huge_mm.h
··· 376 376 int folio_split(struct folio *folio, unsigned int new_order, struct page *page, 377 377 struct list_head *list); 378 378 /* 379 - * try_folio_split - try to split a @folio at @page using non uniform split. 379 + * try_folio_split_to_order - try to split a @folio at @page to @new_order using 380 + * non uniform split. 380 381 * @folio: folio to be split 381 - * @page: split to order-0 at the given page 382 - * @list: store the after-split folios 382 + * @page: split to @new_order at the given page 383 + * @new_order: the target split order 383 384 * 384 - * Try to split a @folio at @page using non uniform split to order-0, if 385 - * non uniform split is not supported, fall back to uniform split. 385 + * Try to split a @folio at @page using non uniform split to @new_order, if 386 + * non uniform split is not supported, fall back to uniform split. After-split 387 + * folios are put back to LRU list. Use min_order_for_split() to get the lower 388 + * bound of @new_order. 386 389 * 387 390 * Return: 0: split is successful, otherwise split failed. 388 391 */ 389 - static inline int try_folio_split(struct folio *folio, struct page *page, 390 - struct list_head *list) 392 + static inline int try_folio_split_to_order(struct folio *folio, 393 + struct page *page, unsigned int new_order) 391 394 { 392 - int ret = min_order_for_split(folio); 393 - 394 - if (ret < 0) 395 - return ret; 396 - 397 - if (!non_uniform_split_supported(folio, 0, false)) 398 - return split_huge_page_to_list_to_order(&folio->page, list, 399 - ret); 400 - return folio_split(folio, ret, page, list); 395 + if (!non_uniform_split_supported(folio, new_order, /* warns= */ false)) 396 + return split_huge_page_to_list_to_order(&folio->page, NULL, 397 + new_order); 398 + return folio_split(folio, new_order, page, NULL); 401 399 } 402 400 static inline int split_huge_page(struct page *page) 403 401 { 404 - struct folio *folio = page_folio(page); 405 - int ret = min_order_for_split(folio); 406 - 407 - if (ret < 0) 408 - return ret; 409 - 410 - /* 411 - * split_huge_page() locks the page before splitting and 412 - * expects the same page that has been split to be locked when 413 - * returned. split_folio(page_folio(page)) cannot be used here 414 - * because it converts the page to folio and passes the head 415 - * page to be split. 416 - */ 417 - return split_huge_page_to_list_to_order(page, NULL, ret); 402 + return split_huge_page_to_list_to_order(page, NULL, 0); 418 403 } 419 404 void deferred_split_folio(struct folio *folio, bool partially_mapped); 420 405 ··· 582 597 return -EINVAL; 583 598 } 584 599 600 + static inline int min_order_for_split(struct folio *folio) 601 + { 602 + VM_WARN_ON_ONCE_FOLIO(1, folio); 603 + return -EINVAL; 604 + } 605 + 585 606 static inline int split_folio_to_list(struct folio *folio, struct list_head *list) 586 607 { 587 608 VM_WARN_ON_ONCE_FOLIO(1, folio); 588 609 return -EINVAL; 589 610 } 590 611 591 - static inline int try_folio_split(struct folio *folio, struct page *page, 592 - struct list_head *list) 612 + static inline int try_folio_split_to_order(struct folio *folio, 613 + struct page *page, unsigned int new_order) 593 614 { 594 615 VM_WARN_ON_ONCE_FOLIO(1, folio); 595 616 return -EINVAL;
+1
include/linux/map_benchmark.h
··· 27 27 __u32 dma_dir; /* DMA data direction */ 28 28 __u32 dma_trans_ns; /* time for DMA transmission in ns */ 29 29 __u32 granule; /* how many PAGE_SIZE will do map/unmap once a time */ 30 + __u8 expansion[76]; /* For future use */ 30 31 }; 31 32 #endif /* _KERNEL_DMA_BENCHMARK_H */
+1
include/linux/mlx5/cq.h
··· 183 183 complete(&cq->free); 184 184 } 185 185 186 + void mlx5_add_cq_to_tasklet(struct mlx5_core_cq *cq, struct mlx5_eqe *eqe); 186 187 int mlx5_create_cq(struct mlx5_core_dev *dev, struct mlx5_core_cq *cq, 187 188 u32 *in, int inlen, u32 *out, int outlen); 188 189 int mlx5_core_create_cq(struct mlx5_core_dev *dev, struct mlx5_core_cq *cq,
+10 -3
include/linux/mm.h
··· 2074 2074 return folio_large_nr_pages(folio); 2075 2075 } 2076 2076 2077 - #if !defined(CONFIG_ARCH_HAS_GIGANTIC_PAGE) 2077 + #if !defined(CONFIG_HAVE_GIGANTIC_FOLIOS) 2078 2078 /* 2079 2079 * We don't expect any folios that exceed buddy sizes (and consequently 2080 2080 * memory sections). ··· 2087 2087 * pages are guaranteed to be contiguous. 2088 2088 */ 2089 2089 #define MAX_FOLIO_ORDER PFN_SECTION_SHIFT 2090 - #else 2090 + #elif defined(CONFIG_HUGETLB_PAGE) 2091 2091 /* 2092 2092 * There is no real limit on the folio size. We limit them to the maximum we 2093 - * currently expect (e.g., hugetlb, dax). 2093 + * currently expect (see CONFIG_HAVE_GIGANTIC_FOLIOS): with hugetlb, we expect 2094 + * no folios larger than 16 GiB on 64bit and 1 GiB on 32bit. 2095 + */ 2096 + #define MAX_FOLIO_ORDER get_order(IS_ENABLED(CONFIG_64BIT) ? SZ_16G : SZ_1G) 2097 + #else 2098 + /* 2099 + * Without hugetlb, gigantic folios that are bigger than a single PUD are 2100 + * currently impossible. 2094 2101 */ 2095 2102 #define MAX_FOLIO_ORDER PUD_ORDER 2096 2103 #endif
+12
include/linux/net/intel/libie/fwlog.h
··· 78 78 ); 79 79 }; 80 80 81 + #if IS_ENABLED(CONFIG_LIBIE_FWLOG) 81 82 int libie_fwlog_init(struct libie_fwlog *fwlog, struct libie_fwlog_api *api); 82 83 void libie_fwlog_deinit(struct libie_fwlog *fwlog); 83 84 void libie_fwlog_reregister(struct libie_fwlog *fwlog); 84 85 void libie_get_fwlog_data(struct libie_fwlog *fwlog, u8 *buf, u16 len); 86 + #else 87 + static inline int libie_fwlog_init(struct libie_fwlog *fwlog, 88 + struct libie_fwlog_api *api) 89 + { 90 + return -EOPNOTSUPP; 91 + } 92 + static inline void libie_fwlog_deinit(struct libie_fwlog *fwlog) { } 93 + static inline void libie_fwlog_reregister(struct libie_fwlog *fwlog) { } 94 + static inline void libie_get_fwlog_data(struct libie_fwlog *fwlog, u8 *buf, 95 + u16 len) { } 96 + #endif /* CONFIG_LIBIE_FWLOG */ 85 97 #endif /* _LIBIE_FWLOG_H_ */
+2
include/linux/pci.h
··· 412 412 u16 l1ss; /* L1SS Capability pointer */ 413 413 #ifdef CONFIG_PCIEASPM 414 414 struct pcie_link_state *link_state; /* ASPM link state */ 415 + unsigned int aspm_l0s_support:1; /* ASPM L0s support */ 416 + unsigned int aspm_l1_support:1; /* ASPM L1 support */ 415 417 unsigned int ltr_path:1; /* Latency Tolerance Reporting 416 418 supported from root to here */ 417 419 #endif
-1
include/linux/platform_data/x86/int3472.h
··· 100 100 struct regulator_consumer_supply supply_map[GPIO_REGULATOR_SUPPLY_MAP_COUNT * 2]; 101 101 char supply_name_upper[GPIO_SUPPLY_NAME_LENGTH]; 102 102 char regulator_name[GPIO_REGULATOR_NAME_LENGTH]; 103 - struct gpio_desc *ena_gpio; 104 103 struct regulator_dev *rdev; 105 104 struct regulator_desc rdesc; 106 105 };
+2 -1
include/linux/virtio_net.h
··· 401 401 if (!tnl_hdr_negotiated) 402 402 return -EINVAL; 403 403 404 - vhdr->hash_hdr.hash_value = 0; 404 + vhdr->hash_hdr.hash_value_lo = 0; 405 + vhdr->hash_hdr.hash_value_hi = 0; 405 406 vhdr->hash_hdr.hash_report = 0; 406 407 vhdr->hash_hdr.padding = 0; 407 408
+5
include/net/bluetooth/hci.h
··· 2783 2783 __u8 data[]; 2784 2784 } __packed; 2785 2785 2786 + #define HCI_EV_LE_PA_SYNC_LOST 0x10 2787 + struct hci_ev_le_pa_sync_lost { 2788 + __le16 handle; 2789 + } __packed; 2790 + 2786 2791 #define LE_PA_DATA_COMPLETE 0x00 2787 2792 #define LE_PA_DATA_MORE_TO_COME 0x01 2788 2793 #define LE_PA_DATA_TRUNCATED 0x02
+1 -1
include/net/bluetooth/mgmt.h
··· 780 780 __u8 ad_type; 781 781 __u8 offset; 782 782 __u8 length; 783 - __u8 value[31]; 783 + __u8 value[HCI_MAX_AD_LENGTH]; 784 784 } __packed; 785 785 786 786 #define MGMT_OP_ADD_ADV_PATTERNS_MONITOR 0x0052
+78
include/net/cfg80211.h
··· 6435 6435 * after wiphy_lock() was called. Therefore, wiphy_cancel_work() can 6436 6436 * use just cancel_work() instead of cancel_work_sync(), it requires 6437 6437 * being in a section protected by wiphy_lock(). 6438 + * 6439 + * Note that these are scheduled with a timer where the accuracy 6440 + * becomes less the longer in the future the scheduled timer is. Use 6441 + * wiphy_hrtimer_work_queue() if the timer must be not be late by more 6442 + * than approximately 10 percent. 6438 6443 */ 6439 6444 void wiphy_delayed_work_queue(struct wiphy *wiphy, 6440 6445 struct wiphy_delayed_work *dwork, ··· 6510 6505 */ 6511 6506 bool wiphy_delayed_work_pending(struct wiphy *wiphy, 6512 6507 struct wiphy_delayed_work *dwork); 6508 + 6509 + struct wiphy_hrtimer_work { 6510 + struct wiphy_work work; 6511 + struct wiphy *wiphy; 6512 + struct hrtimer timer; 6513 + }; 6514 + 6515 + enum hrtimer_restart wiphy_hrtimer_work_timer(struct hrtimer *t); 6516 + 6517 + static inline void wiphy_hrtimer_work_init(struct wiphy_hrtimer_work *hrwork, 6518 + wiphy_work_func_t func) 6519 + { 6520 + hrtimer_setup(&hrwork->timer, wiphy_hrtimer_work_timer, 6521 + CLOCK_BOOTTIME, HRTIMER_MODE_REL); 6522 + wiphy_work_init(&hrwork->work, func); 6523 + } 6524 + 6525 + /** 6526 + * wiphy_hrtimer_work_queue - queue hrtimer work for the wiphy 6527 + * @wiphy: the wiphy to queue for 6528 + * @hrwork: the high resolution timer worker 6529 + * @delay: the delay given as a ktime_t 6530 + * 6531 + * Please refer to wiphy_delayed_work_queue(). The difference is that 6532 + * the hrtimer work uses a high resolution timer for scheduling. This 6533 + * may be needed if timeouts might be scheduled further in the future 6534 + * and the accuracy of the normal timer is not sufficient. 6535 + * 6536 + * Expect a delay of a few milliseconds as the timer is scheduled 6537 + * with some slack and some more time may pass between queueing the 6538 + * work and its start. 6539 + */ 6540 + void wiphy_hrtimer_work_queue(struct wiphy *wiphy, 6541 + struct wiphy_hrtimer_work *hrwork, 6542 + ktime_t delay); 6543 + 6544 + /** 6545 + * wiphy_hrtimer_work_cancel - cancel previously queued hrtimer work 6546 + * @wiphy: the wiphy, for debug purposes 6547 + * @hrtimer: the hrtimer work to cancel 6548 + * 6549 + * Cancel the work *without* waiting for it, this assumes being 6550 + * called under the wiphy mutex acquired by wiphy_lock(). 6551 + */ 6552 + void wiphy_hrtimer_work_cancel(struct wiphy *wiphy, 6553 + struct wiphy_hrtimer_work *hrtimer); 6554 + 6555 + /** 6556 + * wiphy_hrtimer_work_flush - flush previously queued hrtimer work 6557 + * @wiphy: the wiphy, for debug purposes 6558 + * @hrwork: the hrtimer work to flush 6559 + * 6560 + * Flush the work (i.e. run it if pending). This must be called 6561 + * under the wiphy mutex acquired by wiphy_lock(). 6562 + */ 6563 + void wiphy_hrtimer_work_flush(struct wiphy *wiphy, 6564 + struct wiphy_hrtimer_work *hrwork); 6565 + 6566 + /** 6567 + * wiphy_hrtimer_work_pending - Find out whether a wiphy hrtimer 6568 + * work item is currently pending. 6569 + * 6570 + * @wiphy: the wiphy, for debug purposes 6571 + * @hrwork: the hrtimer work in question 6572 + * 6573 + * Return: true if timer is pending, false otherwise 6574 + * 6575 + * Please refer to the wiphy_delayed_work_pending() documentation as 6576 + * this is the equivalent function for hrtimer based delayed work 6577 + * items. 6578 + */ 6579 + bool wiphy_hrtimer_work_pending(struct wiphy *wiphy, 6580 + struct wiphy_hrtimer_work *hrwork); 6513 6581 6514 6582 /** 6515 6583 * enum ieee80211_ap_reg_power - regulatory power for an Access Point
+1 -1
include/net/libeth/xdp.h
··· 513 513 * can't fail, but can send less frames if there's no enough free descriptors 514 514 * available. The actual free space is returned by @prep from the driver. 515 515 */ 516 - static __always_inline u32 516 + static __always_inline __nocfi_generic u32 517 517 libeth_xdp_tx_xmit_bulk(const struct libeth_xdp_tx_frame *bulk, void *xdpsq, 518 518 u32 n, bool unroll, u64 priv, 519 519 u32 (*prep)(void *xdpsq, struct libeth_xdpsq *sq),
+15 -8
include/uapi/drm/drm_fourcc.h
··· 979 979 * 2 = Gob Height 8, Turing+ Page Kind mapping 980 980 * 3 = Reserved for future use. 981 981 * 982 - * 22:22 s Sector layout. On Tegra GPUs prior to Xavier, there is a further 983 - * bit remapping step that occurs at an even lower level than the 984 - * page kind and block linear swizzles. This causes the layout of 985 - * surfaces mapped in those SOC's GPUs to be incompatible with the 986 - * equivalent mapping on other GPUs in the same system. 982 + * 22:22 s Sector layout. There is a further bit remapping step that occurs 983 + * 26:27 at an even lower level than the page kind and block linear 984 + * swizzles. This causes the bit arrangement of surfaces in memory 985 + * to differ subtly, and prevents direct sharing of surfaces between 986 + * GPUs with different layouts. 987 987 * 988 - * 0 = Tegra K1 - Tegra Parker/TX2 Layout. 989 - * 1 = Desktop GPU and Tegra Xavier+ Layout 988 + * 0 = Tegra K1 - Tegra Parker/TX2 Layout 989 + * 1 = Pre-GB20x, GB20x 32+ bpp, GB10, Tegra Xavier-Orin Layout 990 + * 2 = GB20x(Blackwell 2)+ 8 bpp surface layout 991 + * 3 = GB20x(Blackwell 2)+ 16 bpp surface layout 992 + * 4 = Reserved for future use. 993 + * 5 = Reserved for future use. 994 + * 6 = Reserved for future use. 995 + * 7 = Reserved for future use. 990 996 * 991 997 * 25:23 c Lossless Framebuffer Compression type. 992 998 * ··· 1007 1001 * 6 = Reserved for future use 1008 1002 * 7 = Reserved for future use 1009 1003 * 1010 - * 55:25 - Reserved for future use. Must be zero. 1004 + * 55:28 - Reserved for future use. Must be zero. 1011 1005 */ 1012 1006 #define DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(c, s, g, k, h) \ 1013 1007 fourcc_mod_code(NVIDIA, (0x10 | \ ··· 1015 1009 (((k) & 0xff) << 12) | \ 1016 1010 (((g) & 0x3) << 20) | \ 1017 1011 (((s) & 0x1) << 22) | \ 1012 + (((s) & 0x6) << 25) | \ 1018 1013 (((c) & 0x7) << 23))) 1019 1014 1020 1015 /* To grandfather in prior block linear format modifiers to the above layout,
+12
include/uapi/linux/input-event-codes.h
··· 631 631 #define KEY_BRIGHTNESS_MIN 0x250 /* Set Brightness to Minimum */ 632 632 #define KEY_BRIGHTNESS_MAX 0x251 /* Set Brightness to Maximum */ 633 633 634 + /* 635 + * Keycodes for hotkeys toggling the electronic privacy screen found on some 636 + * laptops on/off. Note when the embedded-controller turns on/off the eprivacy 637 + * screen itself then the state should be reported through drm connecter props: 638 + * https://www.kernel.org/doc/html/latest/gpu/drm-kms.html#standard-connector-properties 639 + * Except when implementing the drm connecter properties API is not possible 640 + * because e.g. the firmware does not allow querying the presence and/or status 641 + * of the eprivacy screen at boot. 642 + */ 643 + #define KEY_EPRIVACY_SCREEN_ON 0x252 644 + #define KEY_EPRIVACY_SCREEN_OFF 0x253 645 + 634 646 #define KEY_KBDINPUTASSIST_PREV 0x260 635 647 #define KEY_KBDINPUTASSIST_NEXT 0x261 636 648 #define KEY_KBDINPUTASSIST_PREVGROUP 0x262
-12
include/uapi/linux/io_uring.h
··· 689 689 /* query various aspects of io_uring, see linux/io_uring/query.h */ 690 690 IORING_REGISTER_QUERY = 35, 691 691 692 - /* return zcrx buffers back into circulation */ 693 - IORING_REGISTER_ZCRX_REFILL = 36, 694 - 695 692 /* this goes last */ 696 693 IORING_REGISTER_LAST, 697 694 ··· 1068 1071 __u32 zcrx_id; 1069 1072 __u32 __resv2; 1070 1073 __u64 __resv[3]; 1071 - }; 1072 - 1073 - struct io_uring_zcrx_sync_refill { 1074 - __u32 zcrx_id; 1075 - /* the number of entries to return */ 1076 - __u32 nr_entries; 1077 - /* pointer to an array of struct io_uring_zcrx_rqe */ 1078 - __u64 rqes; 1079 - __u64 __resv[2]; 1080 1074 }; 1081 1075 1082 1076 #ifdef __cplusplus
+3
include/uapi/linux/io_uring/query.h
··· 36 36 __u64 enter_flags; 37 37 /* Bitmask of all supported IOSQE_* flags */ 38 38 __u64 sqe_flags; 39 + /* The number of available query opcodes */ 40 + __u32 nr_query_opcodes; 41 + __u32 __pad; 39 42 }; 40 43 41 44 #endif
+2 -1
include/uapi/linux/virtio_net.h
··· 193 193 194 194 struct virtio_net_hdr_v1_hash { 195 195 struct virtio_net_hdr_v1 hdr; 196 - __le32 hash_value; 196 + __le16 hash_value_lo; 197 + __le16 hash_value_hi; 197 198 #define VIRTIO_NET_HASH_REPORT_NONE 0 198 199 #define VIRTIO_NET_HASH_REPORT_IPv4 1 199 200 #define VIRTIO_NET_HASH_REPORT_TCPv4 2
+7
include/ufs/ufshcd.h
··· 688 688 * single doorbell mode. 689 689 */ 690 690 UFSHCD_QUIRK_BROKEN_LSDBS_CAP = 1 << 25, 691 + 692 + /* 693 + * This quirk indicates that DME_LINKSTARTUP should not be issued a 2nd 694 + * time (refer link_startup_again) after the 1st time was successful, 695 + * because it causes link startup to become unreliable. 696 + */ 697 + UFSHCD_QUIRK_PERFORM_LINK_STARTUP_ONCE = 1 << 26, 691 698 }; 692 699 693 700 enum ufshcd_caps {
+1 -1
io_uring/memmap.c
··· 135 135 struct io_mapped_region *mr, 136 136 struct io_uring_region_desc *reg) 137 137 { 138 - unsigned long size = mr->nr_pages << PAGE_SHIFT; 138 + unsigned long size = (size_t) mr->nr_pages << PAGE_SHIFT; 139 139 struct page **pages; 140 140 int nr_pages; 141 141
+2
io_uring/query.c
··· 20 20 e->ring_setup_flags = IORING_SETUP_FLAGS; 21 21 e->enter_flags = IORING_ENTER_FLAGS; 22 22 e->sqe_flags = SQE_VALID_FLAGS; 23 + e->nr_query_opcodes = __IO_URING_QUERY_MAX; 24 + e->__pad = 0; 23 25 return sizeof(*e); 24 26 } 25 27
-3
io_uring/register.c
··· 827 827 case IORING_REGISTER_QUERY: 828 828 ret = io_query(ctx, arg, nr_args); 829 829 break; 830 - case IORING_REGISTER_ZCRX_REFILL: 831 - ret = io_zcrx_return_bufs(ctx, arg, nr_args); 832 - break; 833 830 default: 834 831 ret = -EINVAL; 835 832 break;
+18 -9
io_uring/rsrc.c
··· 943 943 struct req_iterator rq_iter; 944 944 struct io_mapped_ubuf *imu; 945 945 struct io_rsrc_node *node; 946 - struct bio_vec bv, *bvec; 947 - u16 nr_bvecs; 946 + struct bio_vec bv; 947 + unsigned int nr_bvecs = 0; 948 948 int ret = 0; 949 949 950 950 io_ring_submit_lock(ctx, issue_flags); ··· 965 965 goto unlock; 966 966 } 967 967 968 - nr_bvecs = blk_rq_nr_phys_segments(rq); 969 - imu = io_alloc_imu(ctx, nr_bvecs); 968 + /* 969 + * blk_rq_nr_phys_segments() may overestimate the number of bvecs 970 + * but avoids needing to iterate over the bvecs 971 + */ 972 + imu = io_alloc_imu(ctx, blk_rq_nr_phys_segments(rq)); 970 973 if (!imu) { 971 974 kfree(node); 972 975 ret = -ENOMEM; ··· 980 977 imu->len = blk_rq_bytes(rq); 981 978 imu->acct_pages = 0; 982 979 imu->folio_shift = PAGE_SHIFT; 983 - imu->nr_bvecs = nr_bvecs; 984 980 refcount_set(&imu->refs, 1); 985 981 imu->release = release; 986 982 imu->priv = rq; 987 983 imu->is_kbuf = true; 988 984 imu->dir = 1 << rq_data_dir(rq); 989 985 990 - bvec = imu->bvec; 991 986 rq_for_each_bvec(bv, rq, rq_iter) 992 - *bvec++ = bv; 987 + imu->bvec[nr_bvecs++] = bv; 988 + imu->nr_bvecs = nr_bvecs; 993 989 994 990 node->buf = imu; 995 991 data->nodes[index] = node; ··· 1405 1403 size_t max_segs = 0; 1406 1404 unsigned i; 1407 1405 1408 - for (i = 0; i < nr_iovs; i++) 1406 + for (i = 0; i < nr_iovs; i++) { 1409 1407 max_segs += (iov[i].iov_len >> shift) + 2; 1408 + if (max_segs > INT_MAX) 1409 + return -EOVERFLOW; 1410 + } 1410 1411 return max_segs; 1411 1412 } 1412 1413 ··· 1515 1510 if (unlikely(ret)) 1516 1511 return ret; 1517 1512 } else { 1518 - nr_segs = io_estimate_bvec_size(iov, nr_iovs, imu); 1513 + int ret = io_estimate_bvec_size(iov, nr_iovs, imu); 1514 + 1515 + if (ret < 0) 1516 + return ret; 1517 + nr_segs = ret; 1519 1518 } 1520 1519 1521 1520 if (sizeof(struct bio_vec) > sizeof(struct iovec)) {
+3
io_uring/rw.c
··· 463 463 464 464 void io_readv_writev_cleanup(struct io_kiocb *req) 465 465 { 466 + struct io_async_rw *rw = req->async_data; 467 + 466 468 lockdep_assert_held(&req->ctx->uring_lock); 469 + io_vec_free(&rw->vec); 467 470 io_rw_recycle(req, 0); 468 471 } 469 472
-68
io_uring/zcrx.c
··· 928 928 .uninstall = io_pp_uninstall, 929 929 }; 930 930 931 - #define IO_ZCRX_MAX_SYS_REFILL_BUFS (1 << 16) 932 - #define IO_ZCRX_SYS_REFILL_BATCH 32 933 - 934 - static void io_return_buffers(struct io_zcrx_ifq *ifq, 935 - struct io_uring_zcrx_rqe *rqes, unsigned nr) 936 - { 937 - int i; 938 - 939 - for (i = 0; i < nr; i++) { 940 - struct net_iov *niov; 941 - netmem_ref netmem; 942 - 943 - if (!io_parse_rqe(&rqes[i], ifq, &niov)) 944 - continue; 945 - 946 - scoped_guard(spinlock_bh, &ifq->rq_lock) { 947 - if (!io_zcrx_put_niov_uref(niov)) 948 - continue; 949 - } 950 - 951 - netmem = net_iov_to_netmem(niov); 952 - if (!page_pool_unref_and_test(netmem)) 953 - continue; 954 - io_zcrx_return_niov(niov); 955 - } 956 - } 957 - 958 - int io_zcrx_return_bufs(struct io_ring_ctx *ctx, 959 - void __user *arg, unsigned nr_arg) 960 - { 961 - struct io_uring_zcrx_rqe rqes[IO_ZCRX_SYS_REFILL_BATCH]; 962 - struct io_uring_zcrx_rqe __user *user_rqes; 963 - struct io_uring_zcrx_sync_refill zr; 964 - struct io_zcrx_ifq *ifq; 965 - unsigned nr, i; 966 - 967 - if (nr_arg) 968 - return -EINVAL; 969 - if (copy_from_user(&zr, arg, sizeof(zr))) 970 - return -EFAULT; 971 - if (!zr.nr_entries || zr.nr_entries > IO_ZCRX_MAX_SYS_REFILL_BUFS) 972 - return -EINVAL; 973 - if (!mem_is_zero(&zr.__resv, sizeof(zr.__resv))) 974 - return -EINVAL; 975 - 976 - ifq = xa_load(&ctx->zcrx_ctxs, zr.zcrx_id); 977 - if (!ifq) 978 - return -EINVAL; 979 - nr = zr.nr_entries; 980 - user_rqes = u64_to_user_ptr(zr.rqes); 981 - 982 - for (i = 0; i < nr;) { 983 - unsigned batch = min(nr - i, IO_ZCRX_SYS_REFILL_BATCH); 984 - size_t size = batch * sizeof(rqes[0]); 985 - 986 - if (copy_from_user(rqes, user_rqes + i, size)) 987 - return i ? i : -EFAULT; 988 - io_return_buffers(ifq, rqes, batch); 989 - 990 - i += batch; 991 - 992 - if (fatal_signal_pending(current)) 993 - return i; 994 - cond_resched(); 995 - } 996 - return nr; 997 - } 998 - 999 931 static bool io_zcrx_queue_cqe(struct io_kiocb *req, struct net_iov *niov, 1000 932 struct io_zcrx_ifq *ifq, int off, int len) 1001 933 {
-7
io_uring/zcrx.h
··· 63 63 }; 64 64 65 65 #if defined(CONFIG_IO_URING_ZCRX) 66 - int io_zcrx_return_bufs(struct io_ring_ctx *ctx, 67 - void __user *arg, unsigned nr_arg); 68 66 int io_register_zcrx_ifq(struct io_ring_ctx *ctx, 69 67 struct io_uring_zcrx_ifq_reg __user *arg); 70 68 void io_unregister_zcrx_ifqs(struct io_ring_ctx *ctx); ··· 94 96 unsigned int id) 95 97 { 96 98 return NULL; 97 - } 98 - static inline int io_zcrx_return_bufs(struct io_ring_ctx *ctx, 99 - void __user *arg, unsigned nr_arg) 100 - { 101 - return -EOPNOTSUPP; 102 99 } 103 100 #endif 104 101
+9
kernel/Kconfig.kexec
··· 109 109 to keep data or state alive across the kexec. For this to work, 110 110 both source and target kernels need to have this option enabled. 111 111 112 + config KEXEC_HANDOVER_DEBUG 113 + bool "Enable Kexec Handover debug checks" 114 + depends on KEXEC_HANDOVER 115 + help 116 + This option enables extra sanity checks for the Kexec Handover 117 + subsystem. Since, KHO performance is crucial in live update 118 + scenarios and the extra code might be adding overhead it is 119 + only optionally enabled. 120 + 112 121 config CRASH_DUMP 113 122 bool "kernel crash dumps" 114 123 default ARCH_DEFAULT_CRASH_DUMP
+1
kernel/Makefile
··· 83 83 obj-$(CONFIG_KEXEC_FILE) += kexec_file.o 84 84 obj-$(CONFIG_KEXEC_ELF) += kexec_elf.o 85 85 obj-$(CONFIG_KEXEC_HANDOVER) += kexec_handover.o 86 + obj-$(CONFIG_KEXEC_HANDOVER_DEBUG) += kexec_handover_debug.o 86 87 obj-$(CONFIG_BACKTRACE_SELF_TEST) += backtracetest.o 87 88 obj-$(CONFIG_COMPAT) += compat.o 88 89 obj-$(CONFIG_CGROUPS) += cgroup/
+15 -11
kernel/bpf/helpers.c
··· 4169 4169 } 4170 4170 4171 4171 /** 4172 - * bpf_task_work_schedule_signal - Schedule BPF callback using task_work_add with TWA_SIGNAL mode 4172 + * bpf_task_work_schedule_signal_impl - Schedule BPF callback using task_work_add with TWA_SIGNAL 4173 + * mode 4173 4174 * @task: Task struct for which callback should be scheduled 4174 4175 * @tw: Pointer to struct bpf_task_work in BPF map value for internal bookkeeping 4175 4176 * @map__map: bpf_map that embeds struct bpf_task_work in the values ··· 4179 4178 * 4180 4179 * Return: 0 if task work has been scheduled successfully, negative error code otherwise 4181 4180 */ 4182 - __bpf_kfunc int bpf_task_work_schedule_signal(struct task_struct *task, struct bpf_task_work *tw, 4183 - void *map__map, bpf_task_work_callback_t callback, 4184 - void *aux__prog) 4181 + __bpf_kfunc int bpf_task_work_schedule_signal_impl(struct task_struct *task, 4182 + struct bpf_task_work *tw, void *map__map, 4183 + bpf_task_work_callback_t callback, 4184 + void *aux__prog) 4185 4185 { 4186 4186 return bpf_task_work_schedule(task, tw, map__map, callback, aux__prog, TWA_SIGNAL); 4187 4187 } 4188 4188 4189 4189 /** 4190 - * bpf_task_work_schedule_resume - Schedule BPF callback using task_work_add with TWA_RESUME mode 4190 + * bpf_task_work_schedule_resume_impl - Schedule BPF callback using task_work_add with TWA_RESUME 4191 + * mode 4191 4192 * @task: Task struct for which callback should be scheduled 4192 4193 * @tw: Pointer to struct bpf_task_work in BPF map value for internal bookkeeping 4193 4194 * @map__map: bpf_map that embeds struct bpf_task_work in the values ··· 4198 4195 * 4199 4196 * Return: 0 if task work has been scheduled successfully, negative error code otherwise 4200 4197 */ 4201 - __bpf_kfunc int bpf_task_work_schedule_resume(struct task_struct *task, struct bpf_task_work *tw, 4202 - void *map__map, bpf_task_work_callback_t callback, 4203 - void *aux__prog) 4198 + __bpf_kfunc int bpf_task_work_schedule_resume_impl(struct task_struct *task, 4199 + struct bpf_task_work *tw, void *map__map, 4200 + bpf_task_work_callback_t callback, 4201 + void *aux__prog) 4204 4202 { 4205 4203 return bpf_task_work_schedule(task, tw, map__map, callback, aux__prog, TWA_RESUME); 4206 4204 } ··· 4380 4376 #if defined(CONFIG_BPF_LSM) && defined(CONFIG_CGROUPS) 4381 4377 BTF_ID_FLAGS(func, bpf_cgroup_read_xattr, KF_RCU) 4382 4378 #endif 4383 - BTF_ID_FLAGS(func, bpf_stream_vprintk, KF_TRUSTED_ARGS) 4384 - BTF_ID_FLAGS(func, bpf_task_work_schedule_signal, KF_TRUSTED_ARGS) 4385 - BTF_ID_FLAGS(func, bpf_task_work_schedule_resume, KF_TRUSTED_ARGS) 4379 + BTF_ID_FLAGS(func, bpf_stream_vprintk_impl, KF_TRUSTED_ARGS) 4380 + BTF_ID_FLAGS(func, bpf_task_work_schedule_signal_impl, KF_TRUSTED_ARGS) 4381 + BTF_ID_FLAGS(func, bpf_task_work_schedule_resume_impl, KF_TRUSTED_ARGS) 4386 4382 BTF_KFUNCS_END(common_btf_ids) 4387 4383 4388 4384 static const struct btf_kfunc_id_set common_kfunc_set = {
+2 -1
kernel/bpf/stream.c
··· 355 355 * Avoid using enum bpf_stream_id so that kfunc users don't have to pull in the 356 356 * enum in headers. 357 357 */ 358 - __bpf_kfunc int bpf_stream_vprintk(int stream_id, const char *fmt__str, const void *args, u32 len__sz, void *aux__prog) 358 + __bpf_kfunc int bpf_stream_vprintk_impl(int stream_id, const char *fmt__str, const void *args, 359 + u32 len__sz, void *aux__prog) 359 360 { 360 361 struct bpf_bprintf_data data = { 361 362 .get_bin_args = true,
-5
kernel/bpf/trampoline.c
··· 479 479 * BPF_TRAMP_F_SHARE_IPMODIFY is set, we can generate the 480 480 * trampoline again, and retry register. 481 481 */ 482 - /* reset fops->func and fops->trampoline for re-register */ 483 - tr->fops->func = NULL; 484 - tr->fops->trampoline = 0; 485 - 486 - /* free im memory and reallocate later */ 487 482 bpf_tramp_image_free(im); 488 483 goto again; 489 484 }
+10 -8
kernel/bpf/verifier.c
··· 8866 8866 struct bpf_verifier_state *cur) 8867 8867 { 8868 8868 struct bpf_func_state *fold, *fcur; 8869 - int i, fr; 8869 + int i, fr, num_slots; 8870 8870 8871 8871 reset_idmap_scratch(env); 8872 8872 for (fr = old->curframe; fr >= 0; fr--) { ··· 8879 8879 &fcur->regs[i], 8880 8880 &env->idmap_scratch); 8881 8881 8882 - for (i = 0; i < fold->allocated_stack / BPF_REG_SIZE; i++) { 8882 + num_slots = min(fold->allocated_stack / BPF_REG_SIZE, 8883 + fcur->allocated_stack / BPF_REG_SIZE); 8884 + for (i = 0; i < num_slots; i++) { 8883 8885 if (!is_spilled_reg(&fold->stack[i]) || 8884 8886 !is_spilled_reg(&fcur->stack[i])) 8885 8887 continue; ··· 12261 12259 KF_bpf_res_spin_lock_irqsave, 12262 12260 KF_bpf_res_spin_unlock_irqrestore, 12263 12261 KF___bpf_trap, 12264 - KF_bpf_task_work_schedule_signal, 12265 - KF_bpf_task_work_schedule_resume, 12262 + KF_bpf_task_work_schedule_signal_impl, 12263 + KF_bpf_task_work_schedule_resume_impl, 12266 12264 }; 12267 12265 12268 12266 BTF_ID_LIST(special_kfunc_list) ··· 12333 12331 BTF_ID(func, bpf_res_spin_lock_irqsave) 12334 12332 BTF_ID(func, bpf_res_spin_unlock_irqrestore) 12335 12333 BTF_ID(func, __bpf_trap) 12336 - BTF_ID(func, bpf_task_work_schedule_signal) 12337 - BTF_ID(func, bpf_task_work_schedule_resume) 12334 + BTF_ID(func, bpf_task_work_schedule_signal_impl) 12335 + BTF_ID(func, bpf_task_work_schedule_resume_impl) 12338 12336 12339 12337 static bool is_task_work_add_kfunc(u32 func_id) 12340 12338 { 12341 - return func_id == special_kfunc_list[KF_bpf_task_work_schedule_signal] || 12342 - func_id == special_kfunc_list[KF_bpf_task_work_schedule_resume]; 12339 + return func_id == special_kfunc_list[KF_bpf_task_work_schedule_signal_impl] || 12340 + func_id == special_kfunc_list[KF_bpf_task_work_schedule_resume_impl]; 12343 12341 } 12344 12342 12345 12343 static bool is_kfunc_ret_null(struct bpf_kfunc_call_arg_meta *meta)
+1 -1
kernel/crash_core.c
··· 373 373 old_res->start = 0; 374 374 old_res->end = 0; 375 375 } else { 376 - crashk_res.end = ram_res->start - 1; 376 + old_res->end = ram_res->start - 1; 377 377 } 378 378 379 379 crash_free_reserved_phys_range(ram_res->start, ram_res->end);
+15 -5
kernel/events/core.c
··· 11773 11773 11774 11774 event = container_of(hrtimer, struct perf_event, hw.hrtimer); 11775 11775 11776 - if (event->state != PERF_EVENT_STATE_ACTIVE) 11776 + if (event->state != PERF_EVENT_STATE_ACTIVE || 11777 + event->hw.state & PERF_HES_STOPPED) 11777 11778 return HRTIMER_NORESTART; 11778 11779 11779 11780 event->pmu->read(event); ··· 11820 11819 struct hw_perf_event *hwc = &event->hw; 11821 11820 11822 11821 /* 11823 - * The throttle can be triggered in the hrtimer handler. 11824 - * The HRTIMER_NORESTART should be used to stop the timer, 11825 - * rather than hrtimer_cancel(). See perf_swevent_hrtimer() 11822 + * Careful: this function can be triggered in the hrtimer handler, 11823 + * for cpu-clock events, so hrtimer_cancel() would cause a 11824 + * deadlock. 11825 + * 11826 + * So use hrtimer_try_to_cancel() to try to stop the hrtimer, 11827 + * and the cpu-clock handler also sets the PERF_HES_STOPPED flag, 11828 + * which guarantees that perf_swevent_hrtimer() will stop the 11829 + * hrtimer once it sees the PERF_HES_STOPPED flag. 11826 11830 */ 11827 11831 if (is_sampling_event(event) && (hwc->interrupts != MAX_INTERRUPTS)) { 11828 11832 ktime_t remaining = hrtimer_get_remaining(&hwc->hrtimer); 11829 11833 local64_set(&hwc->period_left, ktime_to_ns(remaining)); 11830 11834 11831 - hrtimer_cancel(&hwc->hrtimer); 11835 + hrtimer_try_to_cancel(&hwc->hrtimer); 11832 11836 } 11833 11837 } 11834 11838 ··· 11877 11871 11878 11872 static void cpu_clock_event_start(struct perf_event *event, int flags) 11879 11873 { 11874 + event->hw.state = 0; 11880 11875 local64_set(&event->hw.prev_count, local_clock()); 11881 11876 perf_swevent_start_hrtimer(event); 11882 11877 } 11883 11878 11884 11879 static void cpu_clock_event_stop(struct perf_event *event, int flags) 11885 11880 { 11881 + event->hw.state = PERF_HES_STOPPED; 11886 11882 perf_swevent_cancel_hrtimer(event); 11887 11883 if (flags & PERF_EF_UPDATE) 11888 11884 cpu_clock_event_update(event); ··· 11958 11950 11959 11951 static void task_clock_event_start(struct perf_event *event, int flags) 11960 11952 { 11953 + event->hw.state = 0; 11961 11954 local64_set(&event->hw.prev_count, event->ctx->time); 11962 11955 perf_swevent_start_hrtimer(event); 11963 11956 } 11964 11957 11965 11958 static void task_clock_event_stop(struct perf_event *event, int flags) 11966 11959 { 11960 + event->hw.state = PERF_HES_STOPPED; 11967 11961 perf_swevent_cancel_hrtimer(event); 11968 11962 if (flags & PERF_EF_UPDATE) 11969 11963 task_clock_event_update(event, event->ctx->time);
+6 -6
kernel/futex/core.c
··· 1680 1680 { 1681 1681 struct mm_struct *mm = fph->mm; 1682 1682 1683 - guard(rcu)(); 1683 + guard(preempt)(); 1684 1684 1685 - if (smp_load_acquire(&fph->state) == FR_PERCPU) { 1686 - this_cpu_inc(*mm->futex_ref); 1685 + if (READ_ONCE(fph->state) == FR_PERCPU) { 1686 + __this_cpu_inc(*mm->futex_ref); 1687 1687 return true; 1688 1688 } 1689 1689 ··· 1694 1694 { 1695 1695 struct mm_struct *mm = fph->mm; 1696 1696 1697 - guard(rcu)(); 1697 + guard(preempt)(); 1698 1698 1699 - if (smp_load_acquire(&fph->state) == FR_PERCPU) { 1700 - this_cpu_dec(*mm->futex_ref); 1699 + if (READ_ONCE(fph->state) == FR_PERCPU) { 1700 + __this_cpu_dec(*mm->futex_ref); 1701 1701 return false; 1702 1702 } 1703 1703
+3 -1
kernel/gcov/gcc_4_7.c
··· 18 18 #include <linux/mm.h> 19 19 #include "gcov.h" 20 20 21 - #if (__GNUC__ >= 14) 21 + #if (__GNUC__ >= 15) 22 + #define GCOV_COUNTERS 10 23 + #elif (__GNUC__ >= 14) 22 24 #define GCOV_COUNTERS 9 23 25 #elif (__GNUC__ >= 10) 24 26 #define GCOV_COUNTERS 8
+58 -37
kernel/kexec_handover.c
··· 8 8 9 9 #define pr_fmt(fmt) "KHO: " fmt 10 10 11 + #include <linux/cleanup.h> 11 12 #include <linux/cma.h> 12 13 #include <linux/count_zeros.h> 13 14 #include <linux/debugfs.h> ··· 23 22 24 23 #include <asm/early_ioremap.h> 25 24 25 + #include "kexec_handover_internal.h" 26 26 /* 27 27 * KHO is tightly coupled with mm init and needs access to some of mm 28 28 * internal APIs. ··· 69 67 * Keep track of memory that is to be preserved across KHO. 70 68 * 71 69 * The serializing side uses two levels of xarrays to manage chunks of per-order 72 - * 512 byte bitmaps. For instance if PAGE_SIZE = 4096, the entire 1G order of a 73 - * 1TB system would fit inside a single 512 byte bitmap. For order 0 allocations 74 - * each bitmap will cover 16M of address space. Thus, for 16G of memory at most 75 - * 512K of bitmap memory will be needed for order 0. 70 + * PAGE_SIZE byte bitmaps. For instance if PAGE_SIZE = 4096, the entire 1G order 71 + * of a 8TB system would fit inside a single 4096 byte bitmap. For order 0 72 + * allocations each bitmap will cover 128M of address space. Thus, for 16G of 73 + * memory at most 512K of bitmap memory will be needed for order 0. 76 74 * 77 75 * This approach is fully incremental, as the serialization progresses folios 78 76 * can continue be aggregated to the tracker. The final step, immediately prior ··· 80 78 * successor kernel to parse. 81 79 */ 82 80 83 - #define PRESERVE_BITS (512 * 8) 81 + #define PRESERVE_BITS (PAGE_SIZE * 8) 84 82 85 83 struct kho_mem_phys_bits { 86 84 DECLARE_BITMAP(preserve, PRESERVE_BITS); 87 85 }; 86 + 87 + static_assert(sizeof(struct kho_mem_phys_bits) == PAGE_SIZE); 88 88 89 89 struct kho_mem_phys { 90 90 /* ··· 135 131 .finalized = false, 136 132 }; 137 133 138 - static void *xa_load_or_alloc(struct xarray *xa, unsigned long index, size_t sz) 134 + static void *xa_load_or_alloc(struct xarray *xa, unsigned long index) 139 135 { 140 - void *elm, *res; 136 + void *res = xa_load(xa, index); 141 137 142 - elm = xa_load(xa, index); 143 - if (elm) 144 - return elm; 138 + if (res) 139 + return res; 145 140 146 - elm = kzalloc(sz, GFP_KERNEL); 141 + void *elm __free(free_page) = (void *)get_zeroed_page(GFP_KERNEL); 142 + 147 143 if (!elm) 148 144 return ERR_PTR(-ENOMEM); 149 145 146 + if (WARN_ON(kho_scratch_overlap(virt_to_phys(elm), PAGE_SIZE))) 147 + return ERR_PTR(-EINVAL); 148 + 150 149 res = xa_cmpxchg(xa, index, NULL, elm, GFP_KERNEL); 151 150 if (xa_is_err(res)) 152 - res = ERR_PTR(xa_err(res)); 153 - 154 - if (res) { 155 - kfree(elm); 151 + return ERR_PTR(xa_err(res)); 152 + else if (res) 156 153 return res; 157 - } 158 154 159 - return elm; 155 + return no_free_ptr(elm); 160 156 } 161 157 162 158 static void __kho_unpreserve(struct kho_mem_track *track, unsigned long pfn, ··· 171 167 const unsigned long pfn_high = pfn >> order; 172 168 173 169 physxa = xa_load(&track->orders, order); 174 - if (!physxa) 175 - continue; 170 + if (WARN_ON_ONCE(!physxa)) 171 + return; 176 172 177 173 bits = xa_load(&physxa->phys_bits, pfn_high / PRESERVE_BITS); 178 - if (!bits) 179 - continue; 174 + if (WARN_ON_ONCE(!bits)) 175 + return; 180 176 181 177 clear_bit(pfn_high % PRESERVE_BITS, bits->preserve); 182 178 ··· 220 216 } 221 217 } 222 218 223 - bits = xa_load_or_alloc(&physxa->phys_bits, pfn_high / PRESERVE_BITS, 224 - sizeof(*bits)); 219 + bits = xa_load_or_alloc(&physxa->phys_bits, pfn_high / PRESERVE_BITS); 225 220 if (IS_ERR(bits)) 226 221 return PTR_ERR(bits); 227 222 ··· 348 345 static struct khoser_mem_chunk *new_chunk(struct khoser_mem_chunk *cur_chunk, 349 346 unsigned long order) 350 347 { 351 - struct khoser_mem_chunk *chunk; 348 + struct khoser_mem_chunk *chunk __free(free_page) = NULL; 352 349 353 - chunk = kzalloc(PAGE_SIZE, GFP_KERNEL); 350 + chunk = (void *)get_zeroed_page(GFP_KERNEL); 354 351 if (!chunk) 355 - return NULL; 352 + return ERR_PTR(-ENOMEM); 353 + 354 + if (WARN_ON(kho_scratch_overlap(virt_to_phys(chunk), PAGE_SIZE))) 355 + return ERR_PTR(-EINVAL); 356 + 356 357 chunk->hdr.order = order; 357 358 if (cur_chunk) 358 359 KHOSER_STORE_PTR(cur_chunk->hdr.next, chunk); 359 - return chunk; 360 + return no_free_ptr(chunk); 360 361 } 361 362 362 363 static void kho_mem_ser_free(struct khoser_mem_chunk *first_chunk) ··· 381 374 struct khoser_mem_chunk *chunk = NULL; 382 375 struct kho_mem_phys *physxa; 383 376 unsigned long order; 377 + int err = -ENOMEM; 384 378 385 379 xa_for_each(&ser->track.orders, order, physxa) { 386 380 struct kho_mem_phys_bits *bits; 387 381 unsigned long phys; 388 382 389 383 chunk = new_chunk(chunk, order); 390 - if (!chunk) 384 + if (IS_ERR(chunk)) { 385 + err = PTR_ERR(chunk); 391 386 goto err_free; 387 + } 392 388 393 389 if (!first_chunk) 394 390 first_chunk = chunk; ··· 401 391 402 392 if (chunk->hdr.num_elms == ARRAY_SIZE(chunk->bitmaps)) { 403 393 chunk = new_chunk(chunk, order); 404 - if (!chunk) 394 + if (IS_ERR(chunk)) { 395 + err = PTR_ERR(chunk); 405 396 goto err_free; 397 + } 406 398 } 407 399 408 400 elm = &chunk->bitmaps[chunk->hdr.num_elms]; ··· 421 409 422 410 err_free: 423 411 kho_mem_ser_free(first_chunk); 424 - return -ENOMEM; 412 + return err; 425 413 } 426 414 427 415 static void __init deserialize_bitmap(unsigned int order, ··· 477 465 * area for early allocations that happen before page allocator is 478 466 * initialized. 479 467 */ 480 - static struct kho_scratch *kho_scratch; 481 - static unsigned int kho_scratch_cnt; 468 + struct kho_scratch *kho_scratch; 469 + unsigned int kho_scratch_cnt; 482 470 483 471 /* 484 472 * The scratch areas are scaled by default as percent of memory allocated from ··· 764 752 const unsigned int order = folio_order(folio); 765 753 struct kho_mem_track *track = &kho_out.ser.track; 766 754 755 + if (WARN_ON(kho_scratch_overlap(pfn << PAGE_SHIFT, PAGE_SIZE << order))) 756 + return -EINVAL; 757 + 767 758 return __kho_preserve_order(track, pfn, order); 768 759 } 769 760 EXPORT_SYMBOL_GPL(kho_preserve_folio); ··· 789 774 unsigned long pfn = start_pfn; 790 775 unsigned long failed_pfn = 0; 791 776 int err = 0; 777 + 778 + if (WARN_ON(kho_scratch_overlap(start_pfn << PAGE_SHIFT, 779 + nr_pages << PAGE_SHIFT))) { 780 + return -EINVAL; 781 + } 792 782 793 783 while (pfn < end_pfn) { 794 784 const unsigned int order = ··· 882 862 return NULL; 883 863 } 884 864 885 - static void kho_vmalloc_unpreserve_chunk(struct kho_vmalloc_chunk *chunk) 865 + static void kho_vmalloc_unpreserve_chunk(struct kho_vmalloc_chunk *chunk, 866 + unsigned short order) 886 867 { 887 868 struct kho_mem_track *track = &kho_out.ser.track; 888 869 unsigned long pfn = PHYS_PFN(virt_to_phys(chunk)); 889 870 890 871 __kho_unpreserve(track, pfn, pfn + 1); 891 872 892 - for (int i = 0; chunk->phys[i]; i++) { 873 + for (int i = 0; i < ARRAY_SIZE(chunk->phys) && chunk->phys[i]; i++) { 893 874 pfn = PHYS_PFN(chunk->phys[i]); 894 - __kho_unpreserve(track, pfn, pfn + 1); 875 + __kho_unpreserve(track, pfn, pfn + (1 << order)); 895 876 } 896 877 } 897 878 ··· 903 882 while (chunk) { 904 883 struct kho_vmalloc_chunk *tmp = chunk; 905 884 906 - kho_vmalloc_unpreserve_chunk(chunk); 885 + kho_vmalloc_unpreserve_chunk(chunk, kho_vmalloc->order); 907 886 908 887 chunk = KHOSER_LOAD_PTR(chunk->hdr.next); 909 888 free_page((unsigned long)tmp); ··· 1013 992 while (chunk) { 1014 993 struct page *page; 1015 994 1016 - for (int i = 0; chunk->phys[i]; i++) { 995 + for (int i = 0; i < ARRAY_SIZE(chunk->phys) && chunk->phys[i]; i++) { 1017 996 phys_addr_t phys = chunk->phys[i]; 1018 997 1019 998 if (idx + contig_pages > total_pages)
+25
kernel/kexec_handover_debug.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-only 2 + /* 3 + * kexec_handover_debug.c - kexec handover optional debug functionality 4 + * Copyright (C) 2025 Google LLC, Pasha Tatashin <pasha.tatashin@soleen.com> 5 + */ 6 + 7 + #define pr_fmt(fmt) "KHO: " fmt 8 + 9 + #include "kexec_handover_internal.h" 10 + 11 + bool kho_scratch_overlap(phys_addr_t phys, size_t size) 12 + { 13 + phys_addr_t scratch_start, scratch_end; 14 + unsigned int i; 15 + 16 + for (i = 0; i < kho_scratch_cnt; i++) { 17 + scratch_start = kho_scratch[i].addr; 18 + scratch_end = kho_scratch[i].addr + kho_scratch[i].size; 19 + 20 + if (phys < scratch_end && (phys + size) > scratch_start) 21 + return true; 22 + } 23 + 24 + return false; 25 + }
+20
kernel/kexec_handover_internal.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + #ifndef LINUX_KEXEC_HANDOVER_INTERNAL_H 3 + #define LINUX_KEXEC_HANDOVER_INTERNAL_H 4 + 5 + #include <linux/kexec_handover.h> 6 + #include <linux/types.h> 7 + 8 + extern struct kho_scratch *kho_scratch; 9 + extern unsigned int kho_scratch_cnt; 10 + 11 + #ifdef CONFIG_KEXEC_HANDOVER_DEBUG 12 + bool kho_scratch_overlap(phys_addr_t phys, size_t size); 13 + #else 14 + static inline bool kho_scratch_overlap(phys_addr_t phys, size_t size) 15 + { 16 + return false; 17 + } 18 + #endif /* CONFIG_KEXEC_HANDOVER_DEBUG */ 19 + 20 + #endif /* LINUX_KEXEC_HANDOVER_INTERNAL_H */
+13 -9
kernel/power/swap.c
··· 635 635 }; 636 636 637 637 /* Indicates the image size after compression */ 638 - static atomic_t compressed_size = ATOMIC_INIT(0); 638 + static atomic64_t compressed_size = ATOMIC_INIT(0); 639 639 640 640 /* 641 641 * Compression function that runs in its own thread. ··· 664 664 d->ret = crypto_acomp_compress(d->cr); 665 665 d->cmp_len = d->cr->dlen; 666 666 667 - atomic_set(&compressed_size, atomic_read(&compressed_size) + d->cmp_len); 667 + atomic64_add(d->cmp_len, &compressed_size); 668 668 atomic_set_release(&d->stop, 1); 669 669 wake_up(&d->done); 670 670 } ··· 689 689 ktime_t start; 690 690 ktime_t stop; 691 691 size_t off; 692 - unsigned thr, run_threads, nr_threads; 692 + unsigned int thr, run_threads, nr_threads; 693 693 unsigned char *page = NULL; 694 694 struct cmp_data *data = NULL; 695 695 struct crc_data *crc = NULL; 696 696 697 697 hib_init_batch(&hb); 698 698 699 - atomic_set(&compressed_size, 0); 699 + atomic64_set(&compressed_size, 0); 700 700 701 701 /* 702 702 * We'll limit the number of threads for compression to limit memory ··· 877 877 stop = ktime_get(); 878 878 if (!ret) 879 879 ret = err2; 880 - if (!ret) 880 + if (!ret) { 881 + swsusp_show_speed(start, stop, nr_to_write, "Wrote"); 882 + pr_info("Image size after compression: %lld kbytes\n", 883 + (atomic64_read(&compressed_size) / 1024)); 881 884 pr_info("Image saving done\n"); 882 - swsusp_show_speed(start, stop, nr_to_write, "Wrote"); 883 - pr_info("Image size after compression: %d kbytes\n", 884 - (atomic_read(&compressed_size) / 1024)); 885 + } else { 886 + pr_err("Image saving failed: %d\n", ret); 887 + } 885 888 886 889 out_clean: 887 890 hib_finish_batch(&hb); ··· 902 899 } 903 900 vfree(data); 904 901 } 905 - if (page) free_page((unsigned long)page); 902 + if (page) 903 + free_page((unsigned long)page); 906 904 907 905 return ret; 908 906 }
+1 -1
kernel/sched/core.c
··· 9606 9606 9607 9607 guard(rq_lock_irq)(rq); 9608 9608 cfs_rq->runtime_enabled = runtime_enabled; 9609 - cfs_rq->runtime_remaining = 0; 9609 + cfs_rq->runtime_remaining = 1; 9610 9610 9611 9611 if (cfs_rq->throttled) 9612 9612 unthrottle_cfs_rq(cfs_rq);
+6 -9
kernel/sched/fair.c
··· 6024 6024 struct sched_entity *se = cfs_rq->tg->se[cpu_of(rq)]; 6025 6025 6026 6026 /* 6027 - * It's possible we are called with !runtime_remaining due to things 6028 - * like user changed quota setting(see tg_set_cfs_bandwidth()) or async 6029 - * unthrottled us with a positive runtime_remaining but other still 6030 - * running entities consumed those runtime before we reached here. 6027 + * It's possible we are called with runtime_remaining < 0 due to things 6028 + * like async unthrottled us with a positive runtime_remaining but other 6029 + * still running entities consumed those runtime before we reached here. 6031 6030 * 6032 - * Anyway, we can't unthrottle this cfs_rq without any runtime remaining 6033 - * because any enqueue in tg_unthrottle_up() will immediately trigger a 6034 - * throttle, which is not supposed to happen on unthrottle path. 6031 + * We can't unthrottle this cfs_rq without any runtime remaining because 6032 + * any enqueue in tg_unthrottle_up() will immediately trigger a throttle, 6033 + * which is not supposed to happen on unthrottle path. 6035 6034 */ 6036 6035 if (cfs_rq->runtime_enabled && cfs_rq->runtime_remaining <= 0) 6037 6036 return; 6038 - 6039 - se = cfs_rq->tg->se[cpu_of(rq)]; 6040 6037 6041 6038 cfs_rq->throttled = 0; 6042 6039
+6 -6
kernel/time/posix-timers.c
··· 475 475 if (!kc->timer_create) 476 476 return -EOPNOTSUPP; 477 477 478 - new_timer = alloc_posix_timer(); 479 - if (unlikely(!new_timer)) 480 - return -EAGAIN; 481 - 482 - spin_lock_init(&new_timer->it_lock); 483 - 484 478 /* Special case for CRIU to restore timers with a given timer ID. */ 485 479 if (unlikely(current->signal->timer_create_restore_ids)) { 486 480 if (copy_from_user(&req_id, created_timer_id, sizeof(req_id))) ··· 483 489 if ((unsigned int)req_id > INT_MAX) 484 490 return -EINVAL; 485 491 } 492 + 493 + new_timer = alloc_posix_timer(); 494 + if (unlikely(!new_timer)) 495 + return -EAGAIN; 496 + 497 + spin_lock_init(&new_timer->it_lock); 486 498 487 499 /* 488 500 * Add the timer to the hash table. The timer is not yet valid
+45 -15
kernel/trace/ftrace.c
··· 1971 1971 */ 1972 1972 static int __ftrace_hash_update_ipmodify(struct ftrace_ops *ops, 1973 1973 struct ftrace_hash *old_hash, 1974 - struct ftrace_hash *new_hash) 1974 + struct ftrace_hash *new_hash, 1975 + bool update_target) 1975 1976 { 1976 1977 struct ftrace_page *pg; 1977 1978 struct dyn_ftrace *rec, *end = NULL; ··· 2007 2006 if (rec->flags & FTRACE_FL_DISABLED) 2008 2007 continue; 2009 2008 2010 - /* We need to update only differences of filter_hash */ 2009 + /* 2010 + * Unless we are updating the target of a direct function, 2011 + * we only need to update differences of filter_hash 2012 + */ 2011 2013 in_old = !!ftrace_lookup_ip(old_hash, rec->ip); 2012 2014 in_new = !!ftrace_lookup_ip(new_hash, rec->ip); 2013 - if (in_old == in_new) 2015 + if (!update_target && (in_old == in_new)) 2014 2016 continue; 2015 2017 2016 2018 if (in_new) { ··· 2024 2020 if (is_ipmodify) 2025 2021 goto rollback; 2026 2022 2027 - FTRACE_WARN_ON(rec->flags & FTRACE_FL_DIRECT); 2023 + /* 2024 + * If this is called by __modify_ftrace_direct() 2025 + * then it is only changing where the direct 2026 + * pointer is jumping to, and the record already 2027 + * points to a direct trampoline. If it isn't, 2028 + * then it is a bug to update ipmodify on a direct 2029 + * caller. 2030 + */ 2031 + FTRACE_WARN_ON(!update_target && 2032 + (rec->flags & FTRACE_FL_DIRECT)); 2028 2033 2029 2034 /* 2030 2035 * Another ops with IPMODIFY is already ··· 2089 2076 if (ftrace_hash_empty(hash)) 2090 2077 hash = NULL; 2091 2078 2092 - return __ftrace_hash_update_ipmodify(ops, EMPTY_HASH, hash); 2079 + return __ftrace_hash_update_ipmodify(ops, EMPTY_HASH, hash, false); 2093 2080 } 2094 2081 2095 2082 /* Disabling always succeeds */ ··· 2100 2087 if (ftrace_hash_empty(hash)) 2101 2088 hash = NULL; 2102 2089 2103 - __ftrace_hash_update_ipmodify(ops, hash, EMPTY_HASH); 2090 + __ftrace_hash_update_ipmodify(ops, hash, EMPTY_HASH, false); 2104 2091 } 2105 2092 2106 2093 static int ftrace_hash_ipmodify_update(struct ftrace_ops *ops, ··· 2114 2101 if (ftrace_hash_empty(new_hash)) 2115 2102 new_hash = NULL; 2116 2103 2117 - return __ftrace_hash_update_ipmodify(ops, old_hash, new_hash); 2104 + return __ftrace_hash_update_ipmodify(ops, old_hash, new_hash, false); 2118 2105 } 2119 2106 2120 2107 static void print_ip_ins(const char *fmt, const unsigned char *p) ··· 5966 5953 free_ftrace_hash(fhp); 5967 5954 } 5968 5955 5956 + static void reset_direct(struct ftrace_ops *ops, unsigned long addr) 5957 + { 5958 + struct ftrace_hash *hash = ops->func_hash->filter_hash; 5959 + 5960 + remove_direct_functions_hash(hash, addr); 5961 + 5962 + /* cleanup for possible another register call */ 5963 + ops->func = NULL; 5964 + ops->trampoline = 0; 5965 + } 5966 + 5969 5967 /** 5970 5968 * register_ftrace_direct - Call a custom trampoline directly 5971 5969 * for multiple functions registered in @ops ··· 6072 6048 ops->direct_call = addr; 6073 6049 6074 6050 err = register_ftrace_function_nolock(ops); 6051 + if (err) 6052 + reset_direct(ops, addr); 6075 6053 6076 6054 out_unlock: 6077 6055 mutex_unlock(&direct_mutex); ··· 6106 6080 int unregister_ftrace_direct(struct ftrace_ops *ops, unsigned long addr, 6107 6081 bool free_filters) 6108 6082 { 6109 - struct ftrace_hash *hash = ops->func_hash->filter_hash; 6110 6083 int err; 6111 6084 6112 6085 if (check_direct_multi(ops)) ··· 6115 6090 6116 6091 mutex_lock(&direct_mutex); 6117 6092 err = unregister_ftrace_function(ops); 6118 - remove_direct_functions_hash(hash, addr); 6093 + reset_direct(ops, addr); 6119 6094 mutex_unlock(&direct_mutex); 6120 - 6121 - /* cleanup for possible another register call */ 6122 - ops->func = NULL; 6123 - ops->trampoline = 0; 6124 6095 6125 6096 if (free_filters) 6126 6097 ftrace_free_filter(ops); ··· 6127 6106 static int 6128 6107 __modify_ftrace_direct(struct ftrace_ops *ops, unsigned long addr) 6129 6108 { 6130 - struct ftrace_hash *hash; 6109 + struct ftrace_hash *hash = ops->func_hash->filter_hash; 6131 6110 struct ftrace_func_entry *entry, *iter; 6132 6111 static struct ftrace_ops tmp_ops = { 6133 6112 .func = ftrace_stub, ··· 6148 6127 return err; 6149 6128 6150 6129 /* 6130 + * Call __ftrace_hash_update_ipmodify() here, so that we can call 6131 + * ops->ops_func for the ops. This is needed because the above 6132 + * register_ftrace_function_nolock() worked on tmp_ops. 6133 + */ 6134 + err = __ftrace_hash_update_ipmodify(ops, hash, hash, true); 6135 + if (err) 6136 + goto out; 6137 + 6138 + /* 6151 6139 * Now the ftrace_ops_list_func() is called to do the direct callers. 6152 6140 * We can safely change the direct functions attached to each entry. 6153 6141 */ 6154 6142 mutex_lock(&ftrace_lock); 6155 6143 6156 - hash = ops->func_hash->filter_hash; 6157 6144 size = 1 << hash->size_bits; 6158 6145 for (i = 0; i < size; i++) { 6159 6146 hlist_for_each_entry(iter, &hash->buckets[i], hlist) { ··· 6176 6147 6177 6148 mutex_unlock(&ftrace_lock); 6178 6149 6150 + out: 6179 6151 /* Removing the tmp_ops will add the updated direct callers to the functions */ 6180 6152 unregister_ftrace_function(&tmp_ops); 6181 6153
+4
kernel/trace/ring_buffer.c
··· 7344 7344 goto out; 7345 7345 } 7346 7346 7347 + /* Did the reader catch up with the writer? */ 7348 + if (cpu_buffer->reader_page == cpu_buffer->commit_page) 7349 + goto out; 7350 + 7347 7351 reader = rb_get_reader_page(cpu_buffer); 7348 7352 if (WARN_ON(!reader)) 7349 7353 goto out;
+4 -2
kernel/trace/trace_events_hist.c
··· 3272 3272 var = create_var(hist_data, file, field_name, val->size, val->type); 3273 3273 if (IS_ERR(var)) { 3274 3274 hist_err(tr, HIST_ERR_VAR_CREATE_FIND_FAIL, errpos(field_name)); 3275 - kfree(val); 3275 + destroy_hist_field(val, 0); 3276 3276 ret = PTR_ERR(var); 3277 3277 goto err; 3278 3278 } 3279 3279 3280 3280 field_var = kzalloc(sizeof(struct field_var), GFP_KERNEL); 3281 3281 if (!field_var) { 3282 - kfree(val); 3282 + destroy_hist_field(val, 0); 3283 + kfree_const(var->type); 3284 + kfree(var->var.name); 3283 3285 kfree(var); 3284 3286 ret = -ENOMEM; 3285 3287 goto err;
+6 -1
kernel/trace/trace_fprobe.c
··· 106 106 if (!tuser->name) 107 107 return NULL; 108 108 109 + /* Register tracepoint if it is loaded. */ 109 110 if (tpoint) { 111 + tuser->tpoint = tpoint; 110 112 ret = tracepoint_user_register(tuser); 111 113 if (ret) 112 114 return ERR_PTR(ret); 113 115 } 114 116 115 - tuser->tpoint = tpoint; 116 117 tuser->refcount = 1; 117 118 INIT_LIST_HEAD(&tuser->list); 118 119 list_add(&tuser->list, &tracepoint_user_list); ··· 1514 1513 if (!trace_probe_is_enabled(tp)) { 1515 1514 list_for_each_entry(tf, trace_probe_probe_list(tp), tp.list) { 1516 1515 unregister_fprobe(&tf->fp); 1516 + if (tf->tuser) { 1517 + tracepoint_user_put(tf->tuser); 1518 + tf->tuser = NULL; 1519 + } 1517 1520 } 1518 1521 } 1519 1522
+1 -1
lib/crypto/Kconfig
··· 64 64 config CRYPTO_LIB_CURVE25519_ARCH 65 65 bool 66 66 depends on CRYPTO_LIB_CURVE25519 && !UML && !KMSAN 67 - default y if ARM && KERNEL_MODE_NEON 67 + default y if ARM && KERNEL_MODE_NEON && !CPU_BIG_ENDIAN 68 68 default y if PPC64 && CPU_LITTLE_ENDIAN 69 69 default y if X86_64 70 70
+1 -1
lib/crypto/Makefile
··· 90 90 libcurve25519-$(CONFIG_CRYPTO_LIB_CURVE25519_GENERIC) += curve25519-fiat32.o 91 91 endif 92 92 # clang versions prior to 18 may blow out the stack with KASAN 93 - ifeq ($(call clang-min-version, 180000),) 93 + ifeq ($(CONFIG_CC_IS_CLANG)_$(call clang-min-version, 180000),y_) 94 94 KASAN_SANITIZE_curve25519-hacl64.o := n 95 95 endif 96 96
+16 -14
lib/maple_tree.c
··· 64 64 #define CREATE_TRACE_POINTS 65 65 #include <trace/events/maple_tree.h> 66 66 67 + #define TP_FCT tracepoint_string(__func__) 68 + 67 69 /* 68 70 * Kernel pointer hashing renders much of the maple tree dump useless as tagged 69 71 * pointers get hashed to arbitrary values. ··· 2758 2756 MA_STATE(l_mas, mas->tree, mas->index, mas->last); 2759 2757 MA_STATE(r_mas, mas->tree, mas->index, mas->last); 2760 2758 2761 - trace_ma_op(__func__, mas); 2759 + trace_ma_op(TP_FCT, mas); 2762 2760 2763 2761 /* 2764 2762 * Rebalancing occurs if a node is insufficient. Data is rebalanced ··· 2999 2997 MA_STATE(prev_l_mas, mas->tree, mas->index, mas->last); 3000 2998 MA_STATE(prev_r_mas, mas->tree, mas->index, mas->last); 3001 2999 3002 - trace_ma_op(__func__, mas); 3000 + trace_ma_op(TP_FCT, mas); 3003 3001 3004 3002 mast.l = &l_mas; 3005 3003 mast.r = &r_mas; ··· 3174 3172 return false; 3175 3173 } 3176 3174 3177 - trace_ma_write(__func__, wr_mas->mas, wr_mas->r_max, entry); 3175 + trace_ma_write(TP_FCT, wr_mas->mas, wr_mas->r_max, entry); 3178 3176 return true; 3179 3177 } 3180 3178 ··· 3418 3416 * of data may happen. 3419 3417 */ 3420 3418 mas = wr_mas->mas; 3421 - trace_ma_op(__func__, mas); 3419 + trace_ma_op(TP_FCT, mas); 3422 3420 3423 3421 if (unlikely(!mas->index && mas->last == ULONG_MAX)) 3424 3422 return mas_new_root(mas, wr_mas->entry); ··· 3554 3552 } else { 3555 3553 memcpy(wr_mas->node, newnode, sizeof(struct maple_node)); 3556 3554 } 3557 - trace_ma_write(__func__, mas, 0, wr_mas->entry); 3555 + trace_ma_write(TP_FCT, mas, 0, wr_mas->entry); 3558 3556 mas_update_gap(mas); 3559 3557 mas->end = new_end; 3560 3558 return; ··· 3598 3596 mas->offset++; /* Keep mas accurate. */ 3599 3597 } 3600 3598 3601 - trace_ma_write(__func__, mas, 0, wr_mas->entry); 3599 + trace_ma_write(TP_FCT, mas, 0, wr_mas->entry); 3602 3600 /* 3603 3601 * Only update gap when the new entry is empty or there is an empty 3604 3602 * entry in the original two ranges. ··· 3719 3717 mas_update_gap(mas); 3720 3718 3721 3719 mas->end = new_end; 3722 - trace_ma_write(__func__, mas, new_end, wr_mas->entry); 3720 + trace_ma_write(TP_FCT, mas, new_end, wr_mas->entry); 3723 3721 return; 3724 3722 } 3725 3723 ··· 3733 3731 { 3734 3732 struct maple_big_node b_node; 3735 3733 3736 - trace_ma_write(__func__, wr_mas->mas, 0, wr_mas->entry); 3734 + trace_ma_write(TP_FCT, wr_mas->mas, 0, wr_mas->entry); 3737 3735 memset(&b_node, 0, sizeof(struct maple_big_node)); 3738 3736 mas_store_b_node(wr_mas, &b_node, wr_mas->offset_end); 3739 3737 mas_commit_b_node(wr_mas, &b_node); ··· 5064 5062 { 5065 5063 MA_WR_STATE(wr_mas, mas, entry); 5066 5064 5067 - trace_ma_write(__func__, mas, 0, entry); 5065 + trace_ma_write(TP_FCT, mas, 0, entry); 5068 5066 #ifdef CONFIG_DEBUG_MAPLE_TREE 5069 5067 if (MAS_WARN_ON(mas, mas->index > mas->last)) 5070 5068 pr_err("Error %lX > %lX " PTR_FMT "\n", mas->index, mas->last, ··· 5165 5163 } 5166 5164 5167 5165 store: 5168 - trace_ma_write(__func__, mas, 0, entry); 5166 + trace_ma_write(TP_FCT, mas, 0, entry); 5169 5167 mas_wr_store_entry(&wr_mas); 5170 5168 MAS_WR_BUG_ON(&wr_mas, mas_is_err(mas)); 5171 5169 mas_destroy(mas); ··· 5884 5882 MA_STATE(mas, mt, index, index); 5885 5883 void *entry; 5886 5884 5887 - trace_ma_read(__func__, &mas); 5885 + trace_ma_read(TP_FCT, &mas); 5888 5886 rcu_read_lock(); 5889 5887 retry: 5890 5888 entry = mas_start(&mas); ··· 5927 5925 MA_STATE(mas, mt, index, last); 5928 5926 int ret = 0; 5929 5927 5930 - trace_ma_write(__func__, &mas, 0, entry); 5928 + trace_ma_write(TP_FCT, &mas, 0, entry); 5931 5929 if (WARN_ON_ONCE(xa_is_advanced(entry))) 5932 5930 return -EINVAL; 5933 5931 ··· 6150 6148 void *entry = NULL; 6151 6149 6152 6150 MA_STATE(mas, mt, index, index); 6153 - trace_ma_op(__func__, &mas); 6151 + trace_ma_op(TP_FCT, &mas); 6154 6152 6155 6153 mtree_lock(mt); 6156 6154 entry = mas_erase(&mas); ··· 6487 6485 unsigned long copy = *index; 6488 6486 #endif 6489 6487 6490 - trace_ma_read(__func__, &mas); 6488 + trace_ma_read(TP_FCT, &mas); 6491 6489 6492 6490 if ((*index) > max) 6493 6491 return NULL;
+3
lib/test_kho.c
··· 301 301 phys_addr_t fdt_phys; 302 302 int err; 303 303 304 + if (!kho_is_enabled()) 305 + return 0; 306 + 304 307 err = kho_retrieve_subtree(KHO_TEST_FDT, &fdt_phys); 305 308 if (!err) 306 309 return kho_test_restore(fdt_phys);
+7
mm/Kconfig
··· 908 908 config PGTABLE_HAS_HUGE_LEAVES 909 909 def_bool TRANSPARENT_HUGEPAGE || HUGETLB_PAGE 910 910 911 + # 912 + # We can end up creating gigantic folio. 913 + # 914 + config HAVE_GIGANTIC_FOLIOS 915 + def_bool (HUGETLB_PAGE && ARCH_HAS_GIGANTIC_PAGE) || \ 916 + (ZONE_DEVICE && HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD) 917 + 911 918 # TODO: Allow to be enabled without THP 912 919 config ARCH_SUPPORTS_HUGE_PFNMAP 913 920 def_bool n
+6 -3
mm/damon/stat.c
··· 46 46 47 47 static struct damon_ctx *damon_stat_context; 48 48 49 + static unsigned long damon_stat_last_refresh_jiffies; 50 + 49 51 static void damon_stat_set_estimated_memory_bandwidth(struct damon_ctx *c) 50 52 { 51 53 struct damon_target *t; ··· 132 130 static int damon_stat_damon_call_fn(void *data) 133 131 { 134 132 struct damon_ctx *c = data; 135 - static unsigned long last_refresh_jiffies; 136 133 137 134 /* avoid unnecessarily frequent stat update */ 138 - if (time_before_eq(jiffies, last_refresh_jiffies + 135 + if (time_before_eq(jiffies, damon_stat_last_refresh_jiffies + 139 136 msecs_to_jiffies(5 * MSEC_PER_SEC))) 140 137 return 0; 141 - last_refresh_jiffies = jiffies; 138 + damon_stat_last_refresh_jiffies = jiffies; 142 139 143 140 aggr_interval_us = c->attrs.aggr_interval; 144 141 damon_stat_set_estimated_memory_bandwidth(c); ··· 211 210 err = damon_start(&damon_stat_context, 1, true); 212 211 if (err) 213 212 return err; 213 + 214 + damon_stat_last_refresh_jiffies = jiffies; 214 215 call_control.data = damon_stat_context; 215 216 return damon_call(damon_stat_context, &call_control); 216 217 }
+7 -3
mm/damon/sysfs.c
··· 1552 1552 return ctx; 1553 1553 } 1554 1554 1555 + static unsigned long damon_sysfs_next_update_jiffies; 1556 + 1555 1557 static int damon_sysfs_repeat_call_fn(void *data) 1556 1558 { 1557 1559 struct damon_sysfs_kdamond *sysfs_kdamond = data; 1558 - static unsigned long next_update_jiffies; 1559 1560 1560 1561 if (!sysfs_kdamond->refresh_ms) 1561 1562 return 0; 1562 - if (time_before(jiffies, next_update_jiffies)) 1563 + if (time_before(jiffies, damon_sysfs_next_update_jiffies)) 1563 1564 return 0; 1564 - next_update_jiffies = jiffies + 1565 + damon_sysfs_next_update_jiffies = jiffies + 1565 1566 msecs_to_jiffies(sysfs_kdamond->refresh_ms); 1566 1567 1567 1568 if (!mutex_trylock(&damon_sysfs_lock)) ··· 1607 1606 return err; 1608 1607 } 1609 1608 kdamond->damon_ctx = ctx; 1609 + 1610 + damon_sysfs_next_update_jiffies = 1611 + jiffies + msecs_to_jiffies(kdamond->refresh_ms); 1610 1612 1611 1613 repeat_call_control->fn = damon_sysfs_repeat_call_fn; 1612 1614 repeat_call_control->data = kdamond;
+20 -8
mm/filemap.c
··· 3681 3681 static vm_fault_t filemap_map_folio_range(struct vm_fault *vmf, 3682 3682 struct folio *folio, unsigned long start, 3683 3683 unsigned long addr, unsigned int nr_pages, 3684 - unsigned long *rss, unsigned short *mmap_miss) 3684 + unsigned long *rss, unsigned short *mmap_miss, 3685 + bool can_map_large) 3685 3686 { 3686 3687 unsigned int ref_from_caller = 1; 3687 3688 vm_fault_t ret = 0; ··· 3697 3696 * The folio must not cross VMA or page table boundary. 3698 3697 */ 3699 3698 addr0 = addr - start * PAGE_SIZE; 3700 - if (folio_within_vma(folio, vmf->vma) && 3699 + if (can_map_large && folio_within_vma(folio, vmf->vma) && 3701 3700 (addr0 & PMD_MASK) == ((addr0 + folio_size(folio) - 1) & PMD_MASK)) { 3702 3701 vmf->pte -= start; 3703 3702 page -= start; ··· 3812 3811 unsigned long rss = 0; 3813 3812 unsigned int nr_pages = 0, folio_type; 3814 3813 unsigned short mmap_miss = 0, mmap_miss_saved; 3814 + bool can_map_large; 3815 3815 3816 3816 rcu_read_lock(); 3817 3817 folio = next_uptodate_folio(&xas, mapping, end_pgoff); 3818 3818 if (!folio) 3819 3819 goto out; 3820 3820 3821 - if (filemap_map_pmd(vmf, folio, start_pgoff)) { 3821 + file_end = DIV_ROUND_UP(i_size_read(mapping->host), PAGE_SIZE) - 1; 3822 + end_pgoff = min(end_pgoff, file_end); 3823 + 3824 + /* 3825 + * Do not allow to map with PTEs beyond i_size and with PMD 3826 + * across i_size to preserve SIGBUS semantics. 3827 + * 3828 + * Make an exception for shmem/tmpfs that for long time 3829 + * intentionally mapped with PMDs across i_size. 3830 + */ 3831 + can_map_large = shmem_mapping(mapping) || 3832 + file_end >= folio_next_index(folio); 3833 + 3834 + if (can_map_large && filemap_map_pmd(vmf, folio, start_pgoff)) { 3822 3835 ret = VM_FAULT_NOPAGE; 3823 3836 goto out; 3824 3837 } ··· 3844 3829 folio_put(folio); 3845 3830 goto out; 3846 3831 } 3847 - 3848 - file_end = DIV_ROUND_UP(i_size_read(mapping->host), PAGE_SIZE) - 1; 3849 - if (end_pgoff > file_end) 3850 - end_pgoff = file_end; 3851 3832 3852 3833 folio_type = mm_counter_file(folio); 3853 3834 do { ··· 3861 3850 else 3862 3851 ret |= filemap_map_folio_range(vmf, folio, 3863 3852 xas.xa_index - folio->index, addr, 3864 - nr_pages, &rss, &mmap_miss); 3853 + nr_pages, &rss, &mmap_miss, 3854 + can_map_large); 3865 3855 3866 3856 folio_unlock(folio); 3867 3857 } while ((folio = next_uptodate_folio(&xas, mapping, end_pgoff)) != NULL);
+27 -14
mm/huge_memory.c
··· 214 214 if (likely(atomic_inc_not_zero(&huge_zero_refcount))) 215 215 return true; 216 216 217 - zero_folio = folio_alloc((GFP_TRANSHUGE | __GFP_ZERO) & ~__GFP_MOVABLE, 217 + zero_folio = folio_alloc((GFP_TRANSHUGE | __GFP_ZERO | __GFP_ZEROTAGS) & 218 + ~__GFP_MOVABLE, 218 219 HPAGE_PMD_ORDER); 219 220 if (!zero_folio) { 220 221 count_vm_event(THP_ZERO_PAGE_ALLOC_FAILED); ··· 3264 3263 caller_pins; 3265 3264 } 3266 3265 3266 + static bool page_range_has_hwpoisoned(struct page *page, long nr_pages) 3267 + { 3268 + for (; nr_pages; page++, nr_pages--) 3269 + if (PageHWPoison(page)) 3270 + return true; 3271 + return false; 3272 + } 3273 + 3267 3274 /* 3268 3275 * It splits @folio into @new_order folios and copies the @folio metadata to 3269 3276 * all the resulting folios. ··· 3279 3270 static void __split_folio_to_order(struct folio *folio, int old_order, 3280 3271 int new_order) 3281 3272 { 3273 + /* Scan poisoned pages when split a poisoned folio to large folios */ 3274 + const bool handle_hwpoison = folio_test_has_hwpoisoned(folio) && new_order; 3282 3275 long new_nr_pages = 1 << new_order; 3283 3276 long nr_pages = 1 << old_order; 3284 3277 long i; 3285 3278 3279 + folio_clear_has_hwpoisoned(folio); 3280 + 3281 + /* Check first new_nr_pages since the loop below skips them */ 3282 + if (handle_hwpoison && 3283 + page_range_has_hwpoisoned(folio_page(folio, 0), new_nr_pages)) 3284 + folio_set_has_hwpoisoned(folio); 3286 3285 /* 3287 3286 * Skip the first new_nr_pages, since the new folio from them have all 3288 3287 * the flags from the original folio. 3289 3288 */ 3290 3289 for (i = new_nr_pages; i < nr_pages; i += new_nr_pages) { 3291 3290 struct page *new_head = &folio->page + i; 3292 - 3293 3291 /* 3294 3292 * Careful: new_folio is not a "real" folio before we cleared PageTail. 3295 3293 * Don't pass it around before clear_compound_head(). ··· 3337 3321 #endif 3338 3322 (1L << PG_dirty) | 3339 3323 LRU_GEN_MASK | LRU_REFS_MASK)); 3324 + 3325 + if (handle_hwpoison && 3326 + page_range_has_hwpoisoned(new_head, new_nr_pages)) 3327 + folio_set_has_hwpoisoned(new_folio); 3340 3328 3341 3329 new_folio->mapping = folio->mapping; 3342 3330 new_folio->index = folio->index + i; ··· 3442 3422 if (folio_test_anon(folio)) 3443 3423 mod_mthp_stat(order, MTHP_STAT_NR_ANON, -1); 3444 3424 3445 - folio_clear_has_hwpoisoned(folio); 3446 - 3447 3425 /* 3448 3426 * split to new_order one order at a time. For uniform split, 3449 3427 * folio is split to new_order directly. ··· 3522 3504 /* order-1 is not supported for anonymous THP. */ 3523 3505 VM_WARN_ONCE(warns && new_order == 1, 3524 3506 "Cannot split to order-1 folio"); 3525 - return new_order != 1; 3507 + if (new_order == 1) 3508 + return false; 3526 3509 } else if (IS_ENABLED(CONFIG_READ_ONLY_THP_FOR_FS) && 3527 3510 !mapping_large_folio_support(folio->mapping)) { 3528 3511 /* ··· 3554 3535 if (folio_test_anon(folio)) { 3555 3536 VM_WARN_ONCE(warns && new_order == 1, 3556 3537 "Cannot split to order-1 folio"); 3557 - return new_order != 1; 3538 + if (new_order == 1) 3539 + return false; 3558 3540 } else if (new_order) { 3559 3541 if (IS_ENABLED(CONFIG_READ_ONLY_THP_FOR_FS) && 3560 3542 !mapping_large_folio_support(folio->mapping)) { ··· 3673 3653 3674 3654 min_order = mapping_min_folio_order(folio->mapping); 3675 3655 if (new_order < min_order) { 3676 - VM_WARN_ONCE(1, "Cannot split mapped folio below min-order: %u", 3677 - min_order); 3678 3656 ret = -EINVAL; 3679 3657 goto out; 3680 3658 } ··· 4004 3986 4005 3987 int split_folio_to_list(struct folio *folio, struct list_head *list) 4006 3988 { 4007 - int ret = min_order_for_split(folio); 4008 - 4009 - if (ret < 0) 4010 - return ret; 4011 - 4012 - return split_huge_page_to_list_to_order(&folio->page, list, ret); 3989 + return split_huge_page_to_list_to_order(&folio->page, list, 0); 4013 3990 } 4014 3991 4015 3992 /*
-3
mm/kmsan/core.c
··· 72 72 73 73 nr_entries = stack_trace_save(entries, KMSAN_STACK_DEPTH, 0); 74 74 75 - /* Don't sleep. */ 76 - flags &= ~(__GFP_DIRECT_RECLAIM | __GFP_KSWAPD_RECLAIM); 77 - 78 75 handle = stack_depot_save(entries, nr_entries, flags); 79 76 return stack_depot_set_extra_bits(handle, extra); 80 77 }
+4 -2
mm/kmsan/hooks.c
··· 84 84 if (s->ctor) 85 85 return; 86 86 kmsan_enter_runtime(); 87 - kmsan_internal_poison_memory(object, s->object_size, GFP_KERNEL, 87 + kmsan_internal_poison_memory(object, s->object_size, 88 + GFP_KERNEL & ~(__GFP_RECLAIM), 88 89 KMSAN_POISON_CHECK | KMSAN_POISON_FREE); 89 90 kmsan_leave_runtime(); 90 91 } ··· 115 114 kmsan_enter_runtime(); 116 115 page = virt_to_head_page((void *)ptr); 117 116 KMSAN_WARN_ON(ptr != page_address(page)); 118 - kmsan_internal_poison_memory((void *)ptr, page_size(page), GFP_KERNEL, 117 + kmsan_internal_poison_memory((void *)ptr, page_size(page), 118 + GFP_KERNEL & ~(__GFP_RECLAIM), 119 119 KMSAN_POISON_CHECK | KMSAN_POISON_FREE); 120 120 kmsan_leave_runtime(); 121 121 }
+1 -1
mm/kmsan/shadow.c
··· 208 208 return; 209 209 kmsan_enter_runtime(); 210 210 kmsan_internal_poison_memory(page_address(page), page_size(page), 211 - GFP_KERNEL, 211 + GFP_KERNEL & ~(__GFP_RECLAIM), 212 212 KMSAN_POISON_CHECK | KMSAN_POISON_FREE); 213 213 kmsan_leave_runtime(); 214 214 }
+104 -9
mm/ksm.c
··· 2455 2455 return true; 2456 2456 } 2457 2457 2458 + struct ksm_next_page_arg { 2459 + struct folio *folio; 2460 + struct page *page; 2461 + unsigned long addr; 2462 + }; 2463 + 2464 + static int ksm_next_page_pmd_entry(pmd_t *pmdp, unsigned long addr, unsigned long end, 2465 + struct mm_walk *walk) 2466 + { 2467 + struct ksm_next_page_arg *private = walk->private; 2468 + struct vm_area_struct *vma = walk->vma; 2469 + pte_t *start_ptep = NULL, *ptep, pte; 2470 + struct mm_struct *mm = walk->mm; 2471 + struct folio *folio; 2472 + struct page *page; 2473 + spinlock_t *ptl; 2474 + pmd_t pmd; 2475 + 2476 + if (ksm_test_exit(mm)) 2477 + return 0; 2478 + 2479 + cond_resched(); 2480 + 2481 + pmd = pmdp_get_lockless(pmdp); 2482 + if (!pmd_present(pmd)) 2483 + return 0; 2484 + 2485 + if (IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE) && pmd_leaf(pmd)) { 2486 + ptl = pmd_lock(mm, pmdp); 2487 + pmd = pmdp_get(pmdp); 2488 + 2489 + if (!pmd_present(pmd)) { 2490 + goto not_found_unlock; 2491 + } else if (pmd_leaf(pmd)) { 2492 + page = vm_normal_page_pmd(vma, addr, pmd); 2493 + if (!page) 2494 + goto not_found_unlock; 2495 + folio = page_folio(page); 2496 + 2497 + if (folio_is_zone_device(folio) || !folio_test_anon(folio)) 2498 + goto not_found_unlock; 2499 + 2500 + page += ((addr & (PMD_SIZE - 1)) >> PAGE_SHIFT); 2501 + goto found_unlock; 2502 + } 2503 + spin_unlock(ptl); 2504 + } 2505 + 2506 + start_ptep = pte_offset_map_lock(mm, pmdp, addr, &ptl); 2507 + if (!start_ptep) 2508 + return 0; 2509 + 2510 + for (ptep = start_ptep; addr < end; ptep++, addr += PAGE_SIZE) { 2511 + pte = ptep_get(ptep); 2512 + 2513 + if (!pte_present(pte)) 2514 + continue; 2515 + 2516 + page = vm_normal_page(vma, addr, pte); 2517 + if (!page) 2518 + continue; 2519 + folio = page_folio(page); 2520 + 2521 + if (folio_is_zone_device(folio) || !folio_test_anon(folio)) 2522 + continue; 2523 + goto found_unlock; 2524 + } 2525 + 2526 + not_found_unlock: 2527 + spin_unlock(ptl); 2528 + if (start_ptep) 2529 + pte_unmap(start_ptep); 2530 + return 0; 2531 + found_unlock: 2532 + folio_get(folio); 2533 + spin_unlock(ptl); 2534 + if (start_ptep) 2535 + pte_unmap(start_ptep); 2536 + private->page = page; 2537 + private->folio = folio; 2538 + private->addr = addr; 2539 + return 1; 2540 + } 2541 + 2542 + static struct mm_walk_ops ksm_next_page_ops = { 2543 + .pmd_entry = ksm_next_page_pmd_entry, 2544 + .walk_lock = PGWALK_RDLOCK, 2545 + }; 2546 + 2458 2547 static struct ksm_rmap_item *scan_get_next_rmap_item(struct page **page) 2459 2548 { 2460 2549 struct mm_struct *mm; ··· 2631 2542 ksm_scan.address = vma->vm_end; 2632 2543 2633 2544 while (ksm_scan.address < vma->vm_end) { 2545 + struct ksm_next_page_arg ksm_next_page_arg; 2634 2546 struct page *tmp_page = NULL; 2635 - struct folio_walk fw; 2636 2547 struct folio *folio; 2637 2548 2638 2549 if (ksm_test_exit(mm)) 2639 2550 break; 2640 2551 2641 - folio = folio_walk_start(&fw, vma, ksm_scan.address, 0); 2642 - if (folio) { 2643 - if (!folio_is_zone_device(folio) && 2644 - folio_test_anon(folio)) { 2645 - folio_get(folio); 2646 - tmp_page = fw.page; 2647 - } 2648 - folio_walk_end(&fw, vma); 2552 + int found; 2553 + 2554 + found = walk_page_range_vma(vma, ksm_scan.address, 2555 + vma->vm_end, 2556 + &ksm_next_page_ops, 2557 + &ksm_next_page_arg); 2558 + 2559 + if (found > 0) { 2560 + folio = ksm_next_page_arg.folio; 2561 + tmp_page = ksm_next_page_arg.page; 2562 + ksm_scan.address = ksm_next_page_arg.addr; 2563 + } else { 2564 + VM_WARN_ON_ONCE(found < 0); 2565 + ksm_scan.address = vma->vm_end - PAGE_SIZE; 2649 2566 } 2650 2567 2651 2568 if (tmp_page) {
+19 -1
mm/memory.c
··· 65 65 #include <linux/gfp.h> 66 66 #include <linux/migrate.h> 67 67 #include <linux/string.h> 68 + #include <linux/shmem_fs.h> 68 69 #include <linux/memory-tiers.h> 69 70 #include <linux/debugfs.h> 70 71 #include <linux/userfaultfd_k.h> ··· 5502 5501 return ret; 5503 5502 } 5504 5503 5504 + if (!needs_fallback && vma->vm_file) { 5505 + struct address_space *mapping = vma->vm_file->f_mapping; 5506 + pgoff_t file_end; 5507 + 5508 + file_end = DIV_ROUND_UP(i_size_read(mapping->host), PAGE_SIZE); 5509 + 5510 + /* 5511 + * Do not allow to map with PTEs beyond i_size and with PMD 5512 + * across i_size to preserve SIGBUS semantics. 5513 + * 5514 + * Make an exception for shmem/tmpfs that for long time 5515 + * intentionally mapped with PMDs across i_size. 5516 + */ 5517 + needs_fallback = !shmem_mapping(mapping) && 5518 + file_end < folio_next_index(folio); 5519 + } 5520 + 5505 5521 if (pmd_none(*vmf->pmd)) { 5506 - if (folio_test_pmd_mappable(folio)) { 5522 + if (!needs_fallback && folio_test_pmd_mappable(folio)) { 5507 5523 ret = do_set_pmd(vmf, folio, page); 5508 5524 if (ret != VM_FAULT_FALLBACK) 5509 5525 return ret;
+1 -1
mm/mm_init.c
··· 2469 2469 panic("Failed to allocate %s hash table\n", tablename); 2470 2470 2471 2471 pr_info("%s hash table entries: %ld (order: %d, %lu bytes, %s)\n", 2472 - tablename, 1UL << log2qty, ilog2(size) - PAGE_SHIFT, size, 2472 + tablename, 1UL << log2qty, get_order(size), size, 2473 2473 virt ? (huge ? "vmalloc hugepage" : "vmalloc") : "linear"); 2474 2474 2475 2475 if (_hash_shift)
+1 -1
mm/mremap.c
··· 187 187 if (!folio || !folio_test_large(folio)) 188 188 return 1; 189 189 190 - return folio_pte_batch(folio, ptep, pte, max_nr); 190 + return folio_pte_batch_flags(folio, NULL, ptep, &pte, max_nr, FPB_RESPECT_WRITE); 191 191 } 192 192 193 193 static int move_ptes(struct pagetable_move_control *pmc,
+1 -1
mm/secretmem.c
··· 82 82 __folio_mark_uptodate(folio); 83 83 err = filemap_add_folio(mapping, folio, offset, gfp); 84 84 if (unlikely(err)) { 85 - folio_put(folio); 86 85 /* 87 86 * If a split of large page was required, it 88 87 * already happened when we marked the page invalid 89 88 * which guarantees that this call won't fail 90 89 */ 91 90 set_direct_map_default_noflush(folio_page(folio, 0)); 91 + folio_put(folio); 92 92 if (err == -EEXIST) 93 93 goto retry; 94 94
+6 -3
mm/shmem.c
··· 1882 1882 struct shmem_inode_info *info = SHMEM_I(inode); 1883 1883 unsigned long suitable_orders = 0; 1884 1884 struct folio *folio = NULL; 1885 + pgoff_t aligned_index; 1885 1886 long pages; 1886 1887 int error, order; 1887 1888 ··· 1896 1895 order = highest_order(suitable_orders); 1897 1896 while (suitable_orders) { 1898 1897 pages = 1UL << order; 1899 - index = round_down(index, pages); 1900 - folio = shmem_alloc_folio(gfp, order, info, index); 1901 - if (folio) 1898 + aligned_index = round_down(index, pages); 1899 + folio = shmem_alloc_folio(gfp, order, info, aligned_index); 1900 + if (folio) { 1901 + index = aligned_index; 1902 1902 goto allocated; 1903 + } 1903 1904 1904 1905 if (pages == HPAGE_PMD_NR) 1905 1906 count_vm_event(THP_FILE_FALLBACK);
+16 -4
mm/slub.c
··· 2046 2046 if (slab_exts) { 2047 2047 unsigned int offs = obj_to_index(obj_exts_slab->slab_cache, 2048 2048 obj_exts_slab, obj_exts); 2049 - /* codetag should be NULL */ 2049 + 2050 + if (unlikely(is_codetag_empty(&slab_exts[offs].ref))) 2051 + return; 2052 + 2053 + /* codetag should be NULL here */ 2050 2054 WARN_ON(slab_exts[offs].ref.ct); 2051 2055 set_codetag_empty(&slab_exts[offs].ref); 2052 2056 } ··· 4670 4666 if (kmem_cache_debug(s)) { 4671 4667 freelist = alloc_single_from_new_slab(s, slab, orig_size, gfpflags); 4672 4668 4673 - if (unlikely(!freelist)) 4669 + if (unlikely(!freelist)) { 4670 + /* This could cause an endless loop. Fail instead. */ 4671 + if (!allow_spin) 4672 + return NULL; 4674 4673 goto new_objects; 4674 + } 4675 4675 4676 4676 if (s->flags & SLAB_STORE_USER) 4677 4677 set_track(s, freelist, TRACK_ALLOC, addr, ··· 6336 6328 6337 6329 if (unlikely(!slab_free_hook(s, p[i], init, false))) { 6338 6330 p[i] = p[--size]; 6339 - if (!size) 6340 - goto flush_remote; 6341 6331 continue; 6342 6332 } 6343 6333 ··· 6349 6343 6350 6344 i++; 6351 6345 } 6346 + 6347 + if (!size) 6348 + goto flush_remote; 6352 6349 6353 6350 next_batch: 6354 6351 if (!local_trylock(&s->cpu_sheaves->lock)) ··· 6406 6397 size -= batch; 6407 6398 goto next_batch; 6408 6399 } 6400 + 6401 + if (remote_nr) 6402 + goto flush_remote; 6409 6403 6410 6404 return; 6411 6405
+13
mm/swap_state.c
··· 748 748 749 749 blk_start_plug(&plug); 750 750 for (addr = start; addr < end; ilx++, addr += PAGE_SIZE) { 751 + struct swap_info_struct *si = NULL; 752 + 751 753 if (!pte++) { 752 754 pte = pte_offset_map(vmf->pmd, addr); 753 755 if (!pte) ··· 763 761 continue; 764 762 pte_unmap(pte); 765 763 pte = NULL; 764 + /* 765 + * Readahead entry may come from a device that we are not 766 + * holding a reference to, try to grab a reference, or skip. 767 + */ 768 + if (swp_type(entry) != swp_type(targ_entry)) { 769 + si = get_swap_device(entry); 770 + if (!si) 771 + continue; 772 + } 766 773 folio = __read_swap_cache_async(entry, gfp_mask, mpol, ilx, 767 774 &page_allocated, false); 775 + if (si) 776 + put_swap_device(si); 768 777 if (!folio) 769 778 continue; 770 779 if (page_allocated) {
+31 -6
mm/truncate.c
··· 177 177 return 0; 178 178 } 179 179 180 + static int try_folio_split_or_unmap(struct folio *folio, struct page *split_at, 181 + unsigned long min_order) 182 + { 183 + enum ttu_flags ttu_flags = 184 + TTU_SYNC | 185 + TTU_SPLIT_HUGE_PMD | 186 + TTU_IGNORE_MLOCK; 187 + int ret; 188 + 189 + ret = try_folio_split_to_order(folio, split_at, min_order); 190 + 191 + /* 192 + * If the split fails, unmap the folio, so it will be refaulted 193 + * with PTEs to respect SIGBUS semantics. 194 + * 195 + * Make an exception for shmem/tmpfs that for long time 196 + * intentionally mapped with PMDs across i_size. 197 + */ 198 + if (ret && !shmem_mapping(folio->mapping)) { 199 + try_to_unmap(folio, ttu_flags); 200 + WARN_ON(folio_mapped(folio)); 201 + } 202 + 203 + return ret; 204 + } 205 + 180 206 /* 181 207 * Handle partial folios. The folio may be entirely within the 182 208 * range if a split has raced with us. If not, we zero the part of the ··· 220 194 size_t size = folio_size(folio); 221 195 unsigned int offset, length; 222 196 struct page *split_at, *split_at2; 197 + unsigned int min_order; 223 198 224 199 if (pos < start) 225 200 offset = start - pos; ··· 250 223 if (!folio_test_large(folio)) 251 224 return true; 252 225 226 + min_order = mapping_min_folio_order(folio->mapping); 253 227 split_at = folio_page(folio, PAGE_ALIGN_DOWN(offset) / PAGE_SIZE); 254 - if (!try_folio_split(folio, split_at, NULL)) { 228 + if (!try_folio_split_or_unmap(folio, split_at, min_order)) { 255 229 /* 256 230 * try to split at offset + length to make sure folios within 257 231 * the range can be dropped, especially to avoid memory waste ··· 276 248 if (!folio_trylock(folio2)) 277 249 goto out; 278 250 279 - /* 280 - * make sure folio2 is large and does not change its mapping. 281 - * Its split result does not matter here. 282 - */ 251 + /* make sure folio2 is large and does not change its mapping */ 283 252 if (folio_test_large(folio2) && 284 253 folio2->mapping == folio->mapping) 285 - try_folio_split(folio2, split_at2, NULL); 254 + try_folio_split_or_unmap(folio2, split_at2, min_order); 286 255 287 256 folio_unlock(folio2); 288 257 out:
+2
net/8021q/vlan.c
··· 193 193 vlan_group_set_device(grp, vlan->vlan_proto, vlan_id, dev); 194 194 grp->nr_vlan_devs++; 195 195 196 + netdev_update_features(dev); 197 + 196 198 return 0; 197 199 198 200 out_unregister_netdev:
+79 -32
net/bluetooth/6lowpan.c
··· 53 53 static struct l2cap_chan *listen_chan; 54 54 static DEFINE_MUTEX(set_lock); 55 55 56 + enum { 57 + LOWPAN_PEER_CLOSING, 58 + LOWPAN_PEER_MAXBITS 59 + }; 60 + 56 61 struct lowpan_peer { 57 62 struct list_head list; 58 63 struct rcu_head rcu; ··· 66 61 /* peer addresses in various formats */ 67 62 unsigned char lladdr[ETH_ALEN]; 68 63 struct in6_addr peer_addr; 64 + 65 + DECLARE_BITMAP(flags, LOWPAN_PEER_MAXBITS); 69 66 }; 70 67 71 68 struct lowpan_btle_dev { ··· 296 289 local_skb->pkt_type = PACKET_HOST; 297 290 local_skb->dev = dev; 298 291 292 + skb_reset_mac_header(local_skb); 299 293 skb_set_transport_header(local_skb, sizeof(struct ipv6hdr)); 300 294 301 295 if (give_skb_to_upper(local_skb, dev) != NET_RX_SUCCESS) { ··· 927 919 928 920 BT_DBG("peer %p chan %p", peer, peer->chan); 929 921 922 + l2cap_chan_lock(peer->chan); 930 923 l2cap_chan_close(peer->chan, ENOENT); 924 + l2cap_chan_unlock(peer->chan); 931 925 932 926 return 0; 933 927 } ··· 966 956 } 967 957 968 958 static int get_l2cap_conn(char *buf, bdaddr_t *addr, u8 *addr_type, 969 - struct l2cap_conn **conn) 959 + struct l2cap_conn **conn, bool disconnect) 970 960 { 971 961 struct hci_conn *hcon; 972 962 struct hci_dev *hdev; 963 + int le_addr_type; 973 964 int n; 974 965 975 966 n = sscanf(buf, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx %hhu", ··· 981 970 if (n < 7) 982 971 return -EINVAL; 983 972 973 + if (disconnect) { 974 + /* The "disconnect" debugfs command has used different address 975 + * type constants than "connect" since 2015. Let's retain that 976 + * for now even though it's obviously buggy... 977 + */ 978 + *addr_type += 1; 979 + } 980 + 981 + switch (*addr_type) { 982 + case BDADDR_LE_PUBLIC: 983 + le_addr_type = ADDR_LE_DEV_PUBLIC; 984 + break; 985 + case BDADDR_LE_RANDOM: 986 + le_addr_type = ADDR_LE_DEV_RANDOM; 987 + break; 988 + default: 989 + return -EINVAL; 990 + } 991 + 984 992 /* The LE_PUBLIC address type is ignored because of BDADDR_ANY */ 985 993 hdev = hci_get_route(addr, BDADDR_ANY, BDADDR_LE_PUBLIC); 986 994 if (!hdev) 987 995 return -ENOENT; 988 996 989 997 hci_dev_lock(hdev); 990 - hcon = hci_conn_hash_lookup_le(hdev, addr, *addr_type); 998 + hcon = hci_conn_hash_lookup_le(hdev, addr, le_addr_type); 991 999 hci_dev_unlock(hdev); 992 1000 hci_dev_put(hdev); 993 1001 ··· 1023 993 static void disconnect_all_peers(void) 1024 994 { 1025 995 struct lowpan_btle_dev *entry; 1026 - struct lowpan_peer *peer, *tmp_peer, *new_peer; 1027 - struct list_head peers; 996 + struct lowpan_peer *peer; 997 + int nchans; 1028 998 1029 - INIT_LIST_HEAD(&peers); 1030 - 1031 - /* We make a separate list of peers as the close_cb() will 1032 - * modify the device peers list so it is better not to mess 1033 - * with the same list at the same time. 999 + /* l2cap_chan_close() cannot be called from RCU, and lock ordering 1000 + * chan->lock > devices_lock prevents taking write side lock, so copy 1001 + * then close. 1034 1002 */ 1035 1003 1036 1004 rcu_read_lock(); 1037 - 1038 - list_for_each_entry_rcu(entry, &bt_6lowpan_devices, list) { 1039 - list_for_each_entry_rcu(peer, &entry->peers, list) { 1040 - new_peer = kmalloc(sizeof(*new_peer), GFP_ATOMIC); 1041 - if (!new_peer) 1042 - break; 1043 - 1044 - new_peer->chan = peer->chan; 1045 - INIT_LIST_HEAD(&new_peer->list); 1046 - 1047 - list_add(&new_peer->list, &peers); 1048 - } 1049 - } 1050 - 1005 + list_for_each_entry_rcu(entry, &bt_6lowpan_devices, list) 1006 + list_for_each_entry_rcu(peer, &entry->peers, list) 1007 + clear_bit(LOWPAN_PEER_CLOSING, peer->flags); 1051 1008 rcu_read_unlock(); 1052 1009 1053 - spin_lock(&devices_lock); 1054 - list_for_each_entry_safe(peer, tmp_peer, &peers, list) { 1055 - l2cap_chan_close(peer->chan, ENOENT); 1010 + do { 1011 + struct l2cap_chan *chans[32]; 1012 + int i; 1056 1013 1057 - list_del_rcu(&peer->list); 1058 - kfree_rcu(peer, rcu); 1059 - } 1060 - spin_unlock(&devices_lock); 1014 + nchans = 0; 1015 + 1016 + spin_lock(&devices_lock); 1017 + 1018 + list_for_each_entry_rcu(entry, &bt_6lowpan_devices, list) { 1019 + list_for_each_entry_rcu(peer, &entry->peers, list) { 1020 + if (test_and_set_bit(LOWPAN_PEER_CLOSING, 1021 + peer->flags)) 1022 + continue; 1023 + 1024 + l2cap_chan_hold(peer->chan); 1025 + chans[nchans++] = peer->chan; 1026 + 1027 + if (nchans >= ARRAY_SIZE(chans)) 1028 + goto done; 1029 + } 1030 + } 1031 + 1032 + done: 1033 + spin_unlock(&devices_lock); 1034 + 1035 + for (i = 0; i < nchans; ++i) { 1036 + l2cap_chan_lock(chans[i]); 1037 + l2cap_chan_close(chans[i], ENOENT); 1038 + l2cap_chan_unlock(chans[i]); 1039 + l2cap_chan_put(chans[i]); 1040 + } 1041 + } while (nchans); 1061 1042 } 1062 1043 1063 1044 struct set_enable { ··· 1091 1050 1092 1051 mutex_lock(&set_lock); 1093 1052 if (listen_chan) { 1053 + l2cap_chan_lock(listen_chan); 1094 1054 l2cap_chan_close(listen_chan, 0); 1055 + l2cap_chan_unlock(listen_chan); 1095 1056 l2cap_chan_put(listen_chan); 1096 1057 } 1097 1058 ··· 1146 1103 buf[buf_size] = '\0'; 1147 1104 1148 1105 if (memcmp(buf, "connect ", 8) == 0) { 1149 - ret = get_l2cap_conn(&buf[8], &addr, &addr_type, &conn); 1106 + ret = get_l2cap_conn(&buf[8], &addr, &addr_type, &conn, false); 1150 1107 if (ret == -EINVAL) 1151 1108 return ret; 1152 1109 1153 1110 mutex_lock(&set_lock); 1154 1111 if (listen_chan) { 1112 + l2cap_chan_lock(listen_chan); 1155 1113 l2cap_chan_close(listen_chan, 0); 1114 + l2cap_chan_unlock(listen_chan); 1156 1115 l2cap_chan_put(listen_chan); 1157 1116 listen_chan = NULL; 1158 1117 } ··· 1185 1140 } 1186 1141 1187 1142 if (memcmp(buf, "disconnect ", 11) == 0) { 1188 - ret = get_l2cap_conn(&buf[11], &addr, &addr_type, &conn); 1143 + ret = get_l2cap_conn(&buf[11], &addr, &addr_type, &conn, true); 1189 1144 if (ret < 0) 1190 1145 return ret; 1191 1146 ··· 1316 1271 debugfs_remove(lowpan_control_debugfs); 1317 1272 1318 1273 if (listen_chan) { 1274 + l2cap_chan_lock(listen_chan); 1319 1275 l2cap_chan_close(listen_chan, 0); 1276 + l2cap_chan_unlock(listen_chan); 1320 1277 l2cap_chan_put(listen_chan); 1321 1278 } 1322 1279
+19 -14
net/bluetooth/hci_conn.c
··· 769 769 d->count++; 770 770 } 771 771 772 - static int hci_le_big_terminate(struct hci_dev *hdev, u8 big, struct hci_conn *conn) 772 + static int hci_le_big_terminate(struct hci_dev *hdev, struct hci_conn *conn) 773 773 { 774 774 struct iso_list_data *d; 775 775 int ret; 776 776 777 - bt_dev_dbg(hdev, "big 0x%2.2x sync_handle 0x%4.4x", big, conn->sync_handle); 777 + bt_dev_dbg(hdev, "hcon %p big 0x%2.2x sync_handle 0x%4.4x", conn, 778 + conn->iso_qos.bcast.big, conn->sync_handle); 778 779 779 780 d = kzalloc(sizeof(*d), GFP_KERNEL); 780 781 if (!d) 781 782 return -ENOMEM; 782 783 783 - d->big = big; 784 + d->big = conn->iso_qos.bcast.big; 784 785 d->sync_handle = conn->sync_handle; 785 786 786 - if (test_and_clear_bit(HCI_CONN_PA_SYNC, &conn->flags)) { 787 + if (conn->type == PA_LINK && 788 + test_and_clear_bit(HCI_CONN_PA_SYNC, &conn->flags)) { 787 789 hci_conn_hash_list_flag(hdev, find_bis, PA_LINK, 788 790 HCI_CONN_PA_SYNC, d); 789 791 ··· 802 800 if (!d->count) 803 801 d->big_sync_term = true; 804 802 } 803 + 804 + if (!d->pa_sync_term && !d->big_sync_term) 805 + return 0; 805 806 806 807 ret = hci_cmd_sync_queue(hdev, big_terminate_sync, d, 807 808 terminate_big_destroy); ··· 857 852 858 853 hci_le_terminate_big(hdev, conn); 859 854 } else { 860 - hci_le_big_terminate(hdev, conn->iso_qos.bcast.big, 861 - conn); 855 + hci_le_big_terminate(hdev, conn); 862 856 } 863 857 } 864 858 ··· 998 994 conn->mtu = hdev->le_mtu ? hdev->le_mtu : hdev->acl_mtu; 999 995 break; 1000 996 case CIS_LINK: 1001 - case BIS_LINK: 1002 - case PA_LINK: 1003 997 /* conn->src should reflect the local identity address */ 1004 998 hci_copy_identity_address(hdev, &conn->src, &conn->src_type); 1005 999 1006 - /* set proper cleanup function */ 1007 - if (!bacmp(dst, BDADDR_ANY)) 1008 - conn->cleanup = bis_cleanup; 1009 - else if (conn->role == HCI_ROLE_MASTER) 1000 + if (conn->role == HCI_ROLE_MASTER) 1010 1001 conn->cleanup = cis_cleanup; 1011 1002 1012 - conn->mtu = hdev->iso_mtu ? hdev->iso_mtu : 1013 - hdev->le_mtu ? hdev->le_mtu : hdev->acl_mtu; 1003 + conn->mtu = hdev->iso_mtu; 1004 + break; 1005 + case PA_LINK: 1006 + case BIS_LINK: 1007 + /* conn->src should reflect the local identity address */ 1008 + hci_copy_identity_address(hdev, &conn->src, &conn->src_type); 1009 + conn->cleanup = bis_cleanup; 1010 + conn->mtu = hdev->iso_mtu; 1014 1011 break; 1015 1012 case SCO_LINK: 1016 1013 if (lmp_esco_capable(hdev))
+43 -20
net/bluetooth/hci_event.c
··· 4218 4218 } 4219 4219 4220 4220 if (i == ARRAY_SIZE(hci_cc_table)) { 4221 + if (!skb->len) { 4222 + bt_dev_err(hdev, "Unexpected cc 0x%4.4x with no status", 4223 + *opcode); 4224 + *status = HCI_ERROR_UNSPECIFIED; 4225 + return; 4226 + } 4227 + 4221 4228 /* Unknown opcode, assume byte 0 contains the status, so 4222 4229 * that e.g. __hci_cmd_sync() properly returns errors 4223 4230 * for vendor specific commands send by HCI drivers. ··· 5843 5836 le16_to_cpu(ev->supervision_timeout)); 5844 5837 } 5845 5838 5839 + static void hci_le_pa_sync_lost_evt(struct hci_dev *hdev, void *data, 5840 + struct sk_buff *skb) 5841 + { 5842 + struct hci_ev_le_pa_sync_lost *ev = data; 5843 + u16 handle = le16_to_cpu(ev->handle); 5844 + struct hci_conn *conn; 5845 + 5846 + bt_dev_dbg(hdev, "sync handle 0x%4.4x", handle); 5847 + 5848 + hci_dev_lock(hdev); 5849 + 5850 + /* Delete the pa sync connection */ 5851 + conn = hci_conn_hash_lookup_pa_sync_handle(hdev, handle); 5852 + if (conn) { 5853 + clear_bit(HCI_CONN_BIG_SYNC, &conn->flags); 5854 + clear_bit(HCI_CONN_PA_SYNC, &conn->flags); 5855 + hci_disconn_cfm(conn, HCI_ERROR_REMOTE_USER_TERM); 5856 + hci_conn_del(conn); 5857 + } 5858 + 5859 + hci_dev_unlock(hdev); 5860 + } 5861 + 5846 5862 static void hci_le_ext_adv_term_evt(struct hci_dev *hdev, void *data, 5847 5863 struct sk_buff *skb) 5848 5864 { ··· 7024 6994 continue; 7025 6995 } 7026 6996 7027 - if (ev->status != 0x42) { 6997 + if (ev->status != 0x42) 7028 6998 /* Mark PA sync as established */ 7029 6999 set_bit(HCI_CONN_PA_SYNC, &bis->flags); 7030 - /* Reset cleanup callback of PA Sync so it doesn't 7031 - * terminate the sync when deleting the connection. 7032 - */ 7033 - conn->cleanup = NULL; 7034 - } 7035 7000 7036 7001 bis->sync_handle = conn->sync_handle; 7037 7002 bis->iso_qos.bcast.big = ev->handle; ··· 7069 7044 struct sk_buff *skb) 7070 7045 { 7071 7046 struct hci_evt_le_big_sync_lost *ev = data; 7072 - struct hci_conn *bis, *conn; 7073 - bool mgmt_conn; 7047 + struct hci_conn *bis; 7048 + bool mgmt_conn = false; 7074 7049 7075 7050 bt_dev_dbg(hdev, "big handle 0x%2.2x", ev->handle); 7076 7051 7077 7052 hci_dev_lock(hdev); 7078 7053 7079 - /* Delete the pa sync connection */ 7080 - bis = hci_conn_hash_lookup_pa_sync_big_handle(hdev, ev->handle); 7081 - if (bis) { 7082 - conn = hci_conn_hash_lookup_pa_sync_handle(hdev, 7083 - bis->sync_handle); 7084 - if (conn) 7085 - hci_conn_del(conn); 7086 - } 7087 - 7088 7054 /* Delete each bis connection */ 7089 7055 while ((bis = hci_conn_hash_lookup_big_state(hdev, ev->handle, 7090 7056 BT_CONNECTED, 7091 7057 HCI_ROLE_SLAVE))) { 7092 - mgmt_conn = test_and_clear_bit(HCI_CONN_MGMT_CONNECTED, &bis->flags); 7093 - mgmt_device_disconnected(hdev, &bis->dst, bis->type, bis->dst_type, 7094 - ev->reason, mgmt_conn); 7058 + if (!mgmt_conn) { 7059 + mgmt_conn = test_and_clear_bit(HCI_CONN_MGMT_CONNECTED, 7060 + &bis->flags); 7061 + mgmt_device_disconnected(hdev, &bis->dst, bis->type, 7062 + bis->dst_type, ev->reason, 7063 + mgmt_conn); 7064 + } 7095 7065 7096 7066 clear_bit(HCI_CONN_BIG_SYNC, &bis->flags); 7097 7067 hci_disconn_cfm(bis, ev->reason); ··· 7200 7180 hci_le_per_adv_report_evt, 7201 7181 sizeof(struct hci_ev_le_per_adv_report), 7202 7182 HCI_MAX_EVENT_SIZE), 7183 + /* [0x10 = HCI_EV_LE_PA_SYNC_LOST] */ 7184 + HCI_LE_EV(HCI_EV_LE_PA_SYNC_LOST, hci_le_pa_sync_lost_evt, 7185 + sizeof(struct hci_ev_le_pa_sync_lost)), 7203 7186 /* [0x12 = HCI_EV_LE_EXT_ADV_SET_TERM] */ 7204 7187 HCI_LE_EV(HCI_EV_LE_EXT_ADV_SET_TERM, hci_le_ext_adv_term_evt, 7205 7188 sizeof(struct hci_evt_le_ext_adv_set_term)),
+1 -1
net/bluetooth/hci_sync.c
··· 6999 6999 7000 7000 hci_dev_lock(hdev); 7001 7001 7002 - if (!hci_conn_valid(hdev, conn)) 7002 + if (hci_conn_valid(hdev, conn)) 7003 7003 clear_bit(HCI_CONN_CREATE_PA_SYNC, &conn->flags); 7004 7004 7005 7005 if (!err)
+1
net/bluetooth/l2cap_core.c
··· 497 497 498 498 kref_get(&c->kref); 499 499 } 500 + EXPORT_SYMBOL_GPL(l2cap_chan_hold); 500 501 501 502 struct l2cap_chan *l2cap_chan_hold_unless_zero(struct l2cap_chan *c) 502 503 {
+4 -3
net/bluetooth/mgmt.c
··· 5395 5395 for (i = 0; i < pattern_count; i++) { 5396 5396 offset = patterns[i].offset; 5397 5397 length = patterns[i].length; 5398 - if (offset >= HCI_MAX_EXT_AD_LENGTH || 5399 - length > HCI_MAX_EXT_AD_LENGTH || 5400 - (offset + length) > HCI_MAX_EXT_AD_LENGTH) 5398 + if (offset >= HCI_MAX_AD_LENGTH || 5399 + length > HCI_MAX_AD_LENGTH || 5400 + (offset + length) > HCI_MAX_AD_LENGTH) 5401 5401 return MGMT_STATUS_INVALID_PARAMS; 5402 5402 5403 5403 p = kmalloc(sizeof(*p), GFP_KERNEL); ··· 9497 9497 cancel_delayed_work_sync(&hdev->discov_off); 9498 9498 cancel_delayed_work_sync(&hdev->service_cache); 9499 9499 cancel_delayed_work_sync(&hdev->rpa_expired); 9500 + cancel_delayed_work_sync(&hdev->mesh_send_done); 9500 9501 } 9501 9502 9502 9503 void mgmt_power_on(struct hci_dev *hdev, int err)
+1 -1
net/bridge/br_forward.c
··· 25 25 26 26 vg = nbp_vlan_group_rcu(p); 27 27 return ((p->flags & BR_HAIRPIN_MODE) || skb->dev != p->dev) && 28 - (br_mst_is_enabled(p->br) || p->state == BR_STATE_FORWARDING) && 28 + (br_mst_is_enabled(p) || p->state == BR_STATE_FORWARDING) && 29 29 br_allowed_egress(vg, skb) && nbp_switchdev_allowed_egress(p, skb) && 30 30 !br_skb_isolated(p, skb); 31 31 }
+1
net/bridge/br_if.c
··· 386 386 del_nbp(p); 387 387 } 388 388 389 + br_mst_uninit(br); 389 390 br_recalculate_neigh_suppress_enabled(br); 390 391 391 392 br_fdb_delete_by_port(br, NULL, 0, 1);
+2 -2
net/bridge/br_input.c
··· 94 94 95 95 br = p->br; 96 96 97 - if (br_mst_is_enabled(br)) { 97 + if (br_mst_is_enabled(p)) { 98 98 state = BR_STATE_FORWARDING; 99 99 } else { 100 100 if (p->state == BR_STATE_DISABLED) { ··· 429 429 return RX_HANDLER_PASS; 430 430 431 431 forward: 432 - if (br_mst_is_enabled(p->br)) 432 + if (br_mst_is_enabled(p)) 433 433 goto defer_stp_filtering; 434 434 435 435 switch (p->state) {
+8 -2
net/bridge/br_mst.c
··· 22 22 } 23 23 EXPORT_SYMBOL_GPL(br_mst_enabled); 24 24 25 + void br_mst_uninit(struct net_bridge *br) 26 + { 27 + if (br_opt_get(br, BROPT_MST_ENABLED)) 28 + static_branch_dec(&br_mst_used); 29 + } 30 + 25 31 int br_mst_get_info(const struct net_device *dev, u16 msti, unsigned long *vids) 26 32 { 27 33 const struct net_bridge_vlan_group *vg; ··· 231 225 return err; 232 226 233 227 if (on) 234 - static_branch_enable(&br_mst_used); 228 + static_branch_inc(&br_mst_used); 235 229 else 236 - static_branch_disable(&br_mst_used); 230 + static_branch_dec(&br_mst_used); 237 231 238 232 br_opt_toggle(br, BROPT_MST_ENABLED, on); 239 233 return 0;
+10 -3
net/bridge/br_private.h
··· 1935 1935 /* br_mst.c */ 1936 1936 #ifdef CONFIG_BRIDGE_VLAN_FILTERING 1937 1937 DECLARE_STATIC_KEY_FALSE(br_mst_used); 1938 - static inline bool br_mst_is_enabled(struct net_bridge *br) 1938 + static inline bool br_mst_is_enabled(const struct net_bridge_port *p) 1939 1939 { 1940 + /* check the port's vlan group to avoid racing with port deletion */ 1940 1941 return static_branch_unlikely(&br_mst_used) && 1941 - br_opt_get(br, BROPT_MST_ENABLED); 1942 + br_opt_get(p->br, BROPT_MST_ENABLED) && 1943 + rcu_access_pointer(p->vlgrp); 1942 1944 } 1943 1945 1944 1946 int br_mst_set_state(struct net_bridge_port *p, u16 msti, u8 state, ··· 1954 1952 const struct net_bridge_vlan_group *vg); 1955 1953 int br_mst_process(struct net_bridge_port *p, const struct nlattr *mst_attr, 1956 1954 struct netlink_ext_ack *extack); 1955 + void br_mst_uninit(struct net_bridge *br); 1957 1956 #else 1958 - static inline bool br_mst_is_enabled(struct net_bridge *br) 1957 + static inline bool br_mst_is_enabled(const struct net_bridge_port *p) 1959 1958 { 1960 1959 return false; 1961 1960 } ··· 1989 1986 struct netlink_ext_ack *extack) 1990 1987 { 1991 1988 return -EOPNOTSUPP; 1989 + } 1990 + 1991 + static inline void br_mst_uninit(struct net_bridge *br) 1992 + { 1992 1993 } 1993 1994 #endif 1994 1995
+2 -2
net/core/gro_cells.c
··· 60 60 struct sk_buff *skb; 61 61 int work_done = 0; 62 62 63 - __local_lock_nested_bh(&cell->bh_lock); 64 63 while (work_done < budget) { 64 + __local_lock_nested_bh(&cell->bh_lock); 65 65 skb = __skb_dequeue(&cell->napi_skbs); 66 + __local_unlock_nested_bh(&cell->bh_lock); 66 67 if (!skb) 67 68 break; 68 69 napi_gro_receive(napi, skb); ··· 72 71 73 72 if (work_done < budget) 74 73 napi_complete_done(napi, work_done); 75 - __local_unlock_nested_bh(&cell->bh_lock); 76 74 return work_done; 77 75 } 78 76
+7 -7
net/core/netpoll.c
··· 228 228 { 229 229 struct sk_buff_head *skb_pool; 230 230 struct sk_buff *skb; 231 - unsigned long flags; 232 231 233 232 skb_pool = &np->skb_pool; 234 233 235 - spin_lock_irqsave(&skb_pool->lock, flags); 236 - while (skb_pool->qlen < MAX_SKBS) { 234 + while (READ_ONCE(skb_pool->qlen) < MAX_SKBS) { 237 235 skb = alloc_skb(MAX_SKB_SIZE, GFP_ATOMIC); 238 236 if (!skb) 239 237 break; 240 238 241 - __skb_queue_tail(skb_pool, skb); 239 + skb_queue_tail(skb_pool, skb); 242 240 } 243 - spin_unlock_irqrestore(&skb_pool->lock, flags); 244 241 } 245 242 246 243 static void zap_completion_queue(void) ··· 811 814 if (!npinfo) 812 815 return; 813 816 817 + /* At this point, there is a single npinfo instance per netdevice, and 818 + * its refcnt tracks how many netpoll structures are linked to it. We 819 + * only perform npinfo cleanup when the refcnt decrements to zero. 820 + */ 814 821 if (refcount_dec_and_test(&npinfo->refcnt)) { 815 822 const struct net_device_ops *ops; 816 823 ··· 824 823 825 824 RCU_INIT_POINTER(np->dev->npinfo, NULL); 826 825 call_rcu(&npinfo->rcu, rcu_cleanup_netpoll_info); 827 - } else 828 - RCU_INIT_POINTER(np->dev->npinfo, NULL); 826 + } 829 827 830 828 skb_pool_flush(np); 831 829 }
+12 -4
net/dsa/tag_brcm.c
··· 176 176 /* Remove Broadcom tag and update checksum */ 177 177 skb_pull_rcsum(skb, BRCM_TAG_LEN); 178 178 179 - dsa_default_offload_fwd_mark(skb); 179 + if (likely(!is_link_local_ether_addr(eth_hdr(skb)->h_dest))) 180 + dsa_default_offload_fwd_mark(skb); 180 181 181 182 return skb; 182 183 } ··· 225 224 { 226 225 int len = BRCM_LEG_TAG_LEN; 227 226 int source_port; 227 + __be16 *proto; 228 228 u8 *brcm_tag; 229 229 230 230 if (unlikely(!pskb_may_pull(skb, BRCM_LEG_TAG_LEN + VLAN_HLEN))) 231 231 return NULL; 232 232 233 233 brcm_tag = dsa_etype_header_pos_rx(skb); 234 + proto = (__be16 *)(brcm_tag + BRCM_LEG_TAG_LEN); 234 235 235 236 source_port = brcm_tag[5] & BRCM_LEG_PORT_ID; 236 237 ··· 240 237 if (!skb->dev) 241 238 return NULL; 242 239 243 - /* VLAN tag is added by BCM63xx internal switch */ 244 - if (netdev_uses_dsa(skb->dev)) 240 + /* The internal switch in BCM63XX SoCs always tags on egress on the CPU 241 + * port. We use VID 0 internally for untagged traffic, so strip the tag 242 + * if the TCI field is all 0, and keep it otherwise to also retain 243 + * e.g. 802.1p tagged packets. 244 + */ 245 + if (proto[0] == htons(ETH_P_8021Q) && proto[1] == 0) 245 246 len += VLAN_HLEN; 246 247 247 248 /* Remove Broadcom tag and update checksum */ 248 249 skb_pull_rcsum(skb, len); 249 250 250 - dsa_default_offload_fwd_mark(skb); 251 + if (likely(!is_link_local_ether_addr(eth_hdr(skb)->h_dest))) 252 + dsa_default_offload_fwd_mark(skb); 251 253 252 254 dsa_strip_etype_header(skb, len); 253 255
+1
net/handshake/tlshd.c
··· 259 259 260 260 out_cancel: 261 261 genlmsg_cancel(msg, hdr); 262 + nlmsg_free(msg); 262 263 out: 263 264 return ret; 264 265 }
+4 -1
net/hsr/hsr_device.c
··· 320 320 } 321 321 322 322 hsr_stag = skb_put(skb, sizeof(struct hsr_sup_tag)); 323 + skb_set_network_header(skb, ETH_HLEN + HSR_HLEN); 324 + skb_reset_mac_len(skb); 325 + 323 326 set_hsr_stag_path(hsr_stag, (hsr->prot_version ? 0x0 : 0xf)); 324 327 set_hsr_stag_HSR_ver(hsr_stag, hsr->prot_version); 325 328 ··· 337 334 } 338 335 339 336 hsr_stag->tlv.HSR_TLV_type = type; 340 - /* TODO: Why 12 in HSRv0? */ 337 + /* HSRv0 has 6 unused bytes after the MAC */ 341 338 hsr_stag->tlv.HSR_TLV_length = hsr->prot_version ? 342 339 sizeof(struct hsr_sup_payload) : 12; 343 340
+15 -7
net/hsr/hsr_forward.c
··· 262 262 return skb; 263 263 } 264 264 265 - static void hsr_set_path_id(struct hsr_ethhdr *hsr_ethhdr, 265 + static void hsr_set_path_id(struct hsr_frame_info *frame, 266 + struct hsr_ethhdr *hsr_ethhdr, 266 267 struct hsr_port *port) 267 268 { 268 269 int path_id; 269 270 270 - if (port->type == HSR_PT_SLAVE_A) 271 - path_id = 0; 272 - else 273 - path_id = 1; 271 + if (port->hsr->prot_version) { 272 + if (port->type == HSR_PT_SLAVE_A) 273 + path_id = 0; 274 + else 275 + path_id = 1; 276 + } else { 277 + if (frame->is_supervision) 278 + path_id = 0xf; 279 + else 280 + path_id = 1; 281 + } 274 282 275 283 set_hsr_tag_path(&hsr_ethhdr->hsr_tag, path_id); 276 284 } ··· 312 304 else 313 305 hsr_ethhdr = (struct hsr_ethhdr *)pc; 314 306 315 - hsr_set_path_id(hsr_ethhdr, port); 307 + hsr_set_path_id(frame, hsr_ethhdr, port); 316 308 set_hsr_tag_LSDU_size(&hsr_ethhdr->hsr_tag, lsdu_size); 317 309 hsr_ethhdr->hsr_tag.sequence_nr = htons(frame->sequence_nr); 318 310 hsr_ethhdr->hsr_tag.encap_proto = hsr_ethhdr->ethhdr.h_proto; ··· 338 330 (struct hsr_ethhdr *)skb_mac_header(frame->skb_hsr); 339 331 340 332 /* set the lane id properly */ 341 - hsr_set_path_id(hsr_ethhdr, port); 333 + hsr_set_path_id(frame, hsr_ethhdr, port); 342 334 return skb_clone(frame->skb_hsr, GFP_ATOMIC); 343 335 } else if (port->dev->features & NETIF_F_HW_HSR_TAG_INS) { 344 336 return skb_clone(frame->skb_std, GFP_ATOMIC);
+5
net/ipv4/route.c
··· 607 607 oldest_p = fnhe_p; 608 608 } 609 609 } 610 + 611 + /* Clear oldest->fnhe_daddr to prevent this fnhe from being 612 + * rebound with new dsts in rt_bind_exception(). 613 + */ 614 + oldest->fnhe_daddr = 0; 610 615 fnhe_flush_routes(oldest); 611 616 *oldest_p = oldest->fnhe_next; 612 617 kfree_rcu(oldest, rcu);
+1 -1
net/mac80211/chan.c
··· 1290 1290 &link->csa.finalize_work); 1291 1291 break; 1292 1292 case NL80211_IFTYPE_STATION: 1293 - wiphy_delayed_work_queue(sdata->local->hw.wiphy, 1293 + wiphy_hrtimer_work_queue(sdata->local->hw.wiphy, 1294 1294 &link->u.mgd.csa.switch_work, 0); 1295 1295 break; 1296 1296 case NL80211_IFTYPE_UNSPECIFIED:
+4 -4
net/mac80211/ieee80211_i.h
··· 612 612 u8 *assoc_req_ies; 613 613 size_t assoc_req_ies_len; 614 614 615 - struct wiphy_delayed_work ml_reconf_work; 615 + struct wiphy_hrtimer_work ml_reconf_work; 616 616 u16 removed_links; 617 617 618 618 /* TID-to-link mapping support */ 619 - struct wiphy_delayed_work ttlm_work; 619 + struct wiphy_hrtimer_work ttlm_work; 620 620 struct ieee80211_adv_ttlm_info ttlm_info; 621 621 struct wiphy_work teardown_ttlm_work; 622 622 ··· 1017 1017 bool operating_11g_mode; 1018 1018 1019 1019 struct { 1020 - struct wiphy_delayed_work switch_work; 1020 + struct wiphy_hrtimer_work switch_work; 1021 1021 struct cfg80211_chan_def ap_chandef; 1022 1022 struct ieee80211_parsed_tpe tpe; 1023 - unsigned long time; 1023 + ktime_t time; 1024 1024 bool waiting_bcn; 1025 1025 bool ignored_same_chan; 1026 1026 bool blocked_tx;
+11 -3
net/mac80211/iface.c
··· 223 223 if (netif_carrier_ok(sdata->dev)) 224 224 return -EBUSY; 225 225 226 + /* if any stations are set known (so they know this vif too), reject */ 227 + if (sta_info_get_by_idx(sdata, 0)) 228 + return -EBUSY; 229 + 226 230 /* First check no ROC work is happening on this iface */ 227 231 list_for_each_entry(roc, &local->roc_list, list) { 228 232 if (roc->sdata != sdata) ··· 246 242 ret = -EBUSY; 247 243 } 248 244 245 + /* 246 + * More interface types could be added here but changing the 247 + * address while powered makes the most sense in client modes. 248 + */ 249 249 switch (sdata->vif.type) { 250 250 case NL80211_IFTYPE_STATION: 251 251 case NL80211_IFTYPE_P2P_CLIENT: 252 - /* More interface types could be added here but changing the 253 - * address while powered makes the most sense in client modes. 254 - */ 252 + /* refuse while connecting */ 253 + if (sdata->u.mgd.auth_data || sdata->u.mgd.assoc_data) 254 + return -EBUSY; 255 255 break; 256 256 default: 257 257 ret = -EOPNOTSUPP;
+2 -2
net/mac80211/link.c
··· 472 472 * from there. 473 473 */ 474 474 if (link->conf->csa_active) 475 - wiphy_delayed_work_queue(local->hw.wiphy, 475 + wiphy_hrtimer_work_queue(local->hw.wiphy, 476 476 &link->u.mgd.csa.switch_work, 477 477 link->u.mgd.csa.time - 478 - jiffies); 478 + ktime_get_boottime()); 479 479 } 480 480 481 481 for_each_set_bit(link_id, &add, IEEE80211_MLD_MAX_NUM_LINKS) {
+26 -26
net/mac80211/mlme.c
··· 45 45 #define IEEE80211_ASSOC_TIMEOUT_SHORT (HZ / 10) 46 46 #define IEEE80211_ASSOC_MAX_TRIES 3 47 47 48 - #define IEEE80211_ADV_TTLM_SAFETY_BUFFER_MS msecs_to_jiffies(100) 48 + #define IEEE80211_ADV_TTLM_SAFETY_BUFFER_MS (100 * USEC_PER_MSEC) 49 49 #define IEEE80211_ADV_TTLM_ST_UNDERFLOW 0xff00 50 50 51 51 #define IEEE80211_NEG_TTLM_REQ_TIMEOUT (HZ / 5) ··· 2594 2594 return; 2595 2595 } 2596 2596 2597 - wiphy_delayed_work_queue(sdata->local->hw.wiphy, 2597 + wiphy_hrtimer_work_queue(sdata->local->hw.wiphy, 2598 2598 &link->u.mgd.csa.switch_work, 0); 2599 2599 } 2600 2600 ··· 2753 2753 .timestamp = timestamp, 2754 2754 .device_timestamp = device_timestamp, 2755 2755 }; 2756 - unsigned long now; 2756 + u32 csa_time_tu; 2757 + ktime_t now; 2757 2758 int res; 2758 2759 2759 2760 lockdep_assert_wiphy(local->hw.wiphy); ··· 2984 2983 csa_ie.mode); 2985 2984 2986 2985 /* we may have to handle timeout for deactivated link in software */ 2987 - now = jiffies; 2988 - link->u.mgd.csa.time = now + 2989 - TU_TO_JIFFIES((max_t(int, csa_ie.count, 1) - 1) * 2990 - link->conf->beacon_int); 2986 + now = ktime_get_boottime(); 2987 + csa_time_tu = (max_t(int, csa_ie.count, 1) - 1) * link->conf->beacon_int; 2988 + link->u.mgd.csa.time = now + us_to_ktime(ieee80211_tu_to_usec(csa_time_tu)); 2991 2989 2992 2990 if (ieee80211_vif_link_active(&sdata->vif, link->link_id) && 2993 2991 local->ops->channel_switch) { ··· 3001 3001 } 3002 3002 3003 3003 /* channel switch handled in software */ 3004 - wiphy_delayed_work_queue(local->hw.wiphy, 3004 + wiphy_hrtimer_work_queue(local->hw.wiphy, 3005 3005 &link->u.mgd.csa.switch_work, 3006 3006 link->u.mgd.csa.time - now); 3007 3007 return; ··· 4242 4242 4243 4243 memset(&sdata->u.mgd.ttlm_info, 0, 4244 4244 sizeof(sdata->u.mgd.ttlm_info)); 4245 - wiphy_delayed_work_cancel(sdata->local->hw.wiphy, &ifmgd->ttlm_work); 4245 + wiphy_hrtimer_work_cancel(sdata->local->hw.wiphy, &ifmgd->ttlm_work); 4246 4246 4247 4247 memset(&sdata->vif.neg_ttlm, 0, sizeof(sdata->vif.neg_ttlm)); 4248 4248 wiphy_delayed_work_cancel(sdata->local->hw.wiphy, 4249 4249 &ifmgd->neg_ttlm_timeout_work); 4250 4250 4251 4251 sdata->u.mgd.removed_links = 0; 4252 - wiphy_delayed_work_cancel(sdata->local->hw.wiphy, 4252 + wiphy_hrtimer_work_cancel(sdata->local->hw.wiphy, 4253 4253 &sdata->u.mgd.ml_reconf_work); 4254 4254 4255 4255 wiphy_work_cancel(sdata->local->hw.wiphy, ··· 6876 6876 /* In case the removal was cancelled, abort it */ 6877 6877 if (sdata->u.mgd.removed_links) { 6878 6878 sdata->u.mgd.removed_links = 0; 6879 - wiphy_delayed_work_cancel(sdata->local->hw.wiphy, 6879 + wiphy_hrtimer_work_cancel(sdata->local->hw.wiphy, 6880 6880 &sdata->u.mgd.ml_reconf_work); 6881 6881 } 6882 6882 return; ··· 6906 6906 } 6907 6907 6908 6908 sdata->u.mgd.removed_links = removed_links; 6909 - wiphy_delayed_work_queue(sdata->local->hw.wiphy, 6909 + wiphy_hrtimer_work_queue(sdata->local->hw.wiphy, 6910 6910 &sdata->u.mgd.ml_reconf_work, 6911 - TU_TO_JIFFIES(delay)); 6911 + us_to_ktime(ieee80211_tu_to_usec(delay))); 6912 6912 } 6913 6913 6914 6914 static int ieee80211_ttlm_set_links(struct ieee80211_sub_if_data *sdata, ··· 7095 7095 /* if a planned TID-to-link mapping was cancelled - 7096 7096 * abort it 7097 7097 */ 7098 - wiphy_delayed_work_cancel(sdata->local->hw.wiphy, 7098 + wiphy_hrtimer_work_cancel(sdata->local->hw.wiphy, 7099 7099 &sdata->u.mgd.ttlm_work); 7100 7100 } else if (sdata->u.mgd.ttlm_info.active) { 7101 7101 /* if no TID-to-link element, set to default mapping in ··· 7130 7130 7131 7131 if (ttlm_info.switch_time) { 7132 7132 u16 beacon_ts_tu, st_tu, delay; 7133 - u32 delay_jiffies; 7133 + u64 delay_usec; 7134 7134 u64 mask; 7135 7135 7136 7136 /* The t2l map switch time is indicated with a partial ··· 7152 7152 if (delay > IEEE80211_ADV_TTLM_ST_UNDERFLOW) 7153 7153 return; 7154 7154 7155 - delay_jiffies = TU_TO_JIFFIES(delay); 7155 + delay_usec = ieee80211_tu_to_usec(delay); 7156 7156 7157 7157 /* Link switching can take time, so schedule it 7158 7158 * 100ms before to be ready on time 7159 7159 */ 7160 - if (delay_jiffies > IEEE80211_ADV_TTLM_SAFETY_BUFFER_MS) 7161 - delay_jiffies -= 7160 + if (delay_usec > IEEE80211_ADV_TTLM_SAFETY_BUFFER_MS) 7161 + delay_usec -= 7162 7162 IEEE80211_ADV_TTLM_SAFETY_BUFFER_MS; 7163 7163 else 7164 - delay_jiffies = 0; 7164 + delay_usec = 0; 7165 7165 7166 7166 sdata->u.mgd.ttlm_info = ttlm_info; 7167 - wiphy_delayed_work_cancel(sdata->local->hw.wiphy, 7167 + wiphy_hrtimer_work_cancel(sdata->local->hw.wiphy, 7168 7168 &sdata->u.mgd.ttlm_work); 7169 - wiphy_delayed_work_queue(sdata->local->hw.wiphy, 7169 + wiphy_hrtimer_work_queue(sdata->local->hw.wiphy, 7170 7170 &sdata->u.mgd.ttlm_work, 7171 - delay_jiffies); 7171 + us_to_ktime(delay_usec)); 7172 7172 return; 7173 7173 } 7174 7174 } ··· 8793 8793 ieee80211_csa_connection_drop_work); 8794 8794 wiphy_delayed_work_init(&ifmgd->tdls_peer_del_work, 8795 8795 ieee80211_tdls_peer_del_work); 8796 - wiphy_delayed_work_init(&ifmgd->ml_reconf_work, 8796 + wiphy_hrtimer_work_init(&ifmgd->ml_reconf_work, 8797 8797 ieee80211_ml_reconf_work); 8798 8798 wiphy_delayed_work_init(&ifmgd->reconf.wk, 8799 8799 ieee80211_ml_sta_reconf_timeout); ··· 8802 8802 timer_setup(&ifmgd->conn_mon_timer, ieee80211_sta_conn_mon_timer, 0); 8803 8803 wiphy_delayed_work_init(&ifmgd->tx_tspec_wk, 8804 8804 ieee80211_sta_handle_tspec_ac_params_wk); 8805 - wiphy_delayed_work_init(&ifmgd->ttlm_work, 8805 + wiphy_hrtimer_work_init(&ifmgd->ttlm_work, 8806 8806 ieee80211_tid_to_link_map_work); 8807 8807 wiphy_delayed_work_init(&ifmgd->neg_ttlm_timeout_work, 8808 8808 ieee80211_neg_ttlm_timeout_work); ··· 8849 8849 else 8850 8850 link->u.mgd.req_smps = IEEE80211_SMPS_OFF; 8851 8851 8852 - wiphy_delayed_work_init(&link->u.mgd.csa.switch_work, 8852 + wiphy_hrtimer_work_init(&link->u.mgd.csa.switch_work, 8853 8853 ieee80211_csa_switch_work); 8854 8854 8855 8855 ieee80211_clear_tpe(&link->conf->tpe); ··· 10064 10064 &link->u.mgd.request_smps_work); 10065 10065 wiphy_work_cancel(link->sdata->local->hw.wiphy, 10066 10066 &link->u.mgd.recalc_smps); 10067 - wiphy_delayed_work_cancel(link->sdata->local->hw.wiphy, 10067 + wiphy_hrtimer_work_cancel(link->sdata->local->hw.wiphy, 10068 10068 &link->u.mgd.csa.switch_work); 10069 10069 } 10070 10070
+7 -3
net/mac80211/rx.c
··· 5360 5360 if (WARN_ON(!local->started)) 5361 5361 goto drop; 5362 5362 5363 - if (likely(!(status->flag & RX_FLAG_FAILED_PLCP_CRC))) { 5363 + if (likely(!(status->flag & RX_FLAG_FAILED_PLCP_CRC) && 5364 + !(status->flag & RX_FLAG_NO_PSDU && 5365 + status->zero_length_psdu_type == 5366 + IEEE80211_RADIOTAP_ZERO_LEN_PSDU_NOT_CAPTURED))) { 5364 5367 /* 5365 - * Validate the rate, unless a PLCP error means that 5366 - * we probably can't have a valid rate here anyway. 5368 + * Validate the rate, unless there was a PLCP error which may 5369 + * have an invalid rate or the PSDU was not capture and may be 5370 + * missing rate information. 5367 5371 */ 5368 5372 5369 5373 switch (status->encoding) {
+4 -2
net/mptcp/protocol.c
··· 61 61 62 62 static const struct proto_ops *mptcp_fallback_tcp_ops(const struct sock *sk) 63 63 { 64 + unsigned short family = READ_ONCE(sk->sk_family); 65 + 64 66 #if IS_ENABLED(CONFIG_MPTCP_IPV6) 65 - if (sk->sk_prot == &tcpv6_prot) 67 + if (family == AF_INET6) 66 68 return &inet6_stream_ops; 67 69 #endif 68 - WARN_ON_ONCE(sk->sk_prot != &tcp_prot); 70 + WARN_ON_ONCE(family != AF_INET); 69 71 return &inet_stream_ops; 70 72 } 71 73
+8
net/mptcp/subflow.c
··· 2144 2144 tcp_prot_override = tcp_prot; 2145 2145 tcp_prot_override.release_cb = tcp_release_cb_override; 2146 2146 tcp_prot_override.diag_destroy = tcp_abort_override; 2147 + #ifdef CONFIG_BPF_SYSCALL 2148 + /* Disable sockmap processing for subflows */ 2149 + tcp_prot_override.psock_update_sk_prot = NULL; 2150 + #endif 2147 2151 2148 2152 #if IS_ENABLED(CONFIG_MPTCP_IPV6) 2149 2153 /* In struct mptcp_subflow_request_sock, we assume the TCP request sock ··· 2184 2180 tcpv6_prot_override = tcpv6_prot; 2185 2181 tcpv6_prot_override.release_cb = tcp_release_cb_override; 2186 2182 tcpv6_prot_override.diag_destroy = tcp_abort_override; 2183 + #ifdef CONFIG_BPF_SYSCALL 2184 + /* Disable sockmap processing for subflows */ 2185 + tcpv6_prot_override.psock_update_sk_prot = NULL; 2186 + #endif 2187 2187 #endif 2188 2188 2189 2189 mptcp_diag_subflow_init(&subflow_ulp_ops);
+2 -4
net/sched/act_bpf.c
··· 47 47 filter = rcu_dereference(prog->filter); 48 48 if (at_ingress) { 49 49 __skb_push(skb, skb->mac_len); 50 - bpf_compute_data_pointers(skb); 51 - filter_res = bpf_prog_run(filter, skb); 50 + filter_res = bpf_prog_run_data_pointers(filter, skb); 52 51 __skb_pull(skb, skb->mac_len); 53 52 } else { 54 - bpf_compute_data_pointers(skb); 55 - filter_res = bpf_prog_run(filter, skb); 53 + filter_res = bpf_prog_run_data_pointers(filter, skb); 56 54 } 57 55 if (unlikely(!skb->tstamp && skb->tstamp_type)) 58 56 skb->tstamp_type = SKB_CLOCK_REALTIME;
+7 -5
net/sched/act_connmark.c
··· 195 195 const struct tcf_connmark_info *ci = to_connmark(a); 196 196 unsigned char *b = skb_tail_pointer(skb); 197 197 const struct tcf_connmark_parms *parms; 198 - struct tc_connmark opt = { 199 - .index = ci->tcf_index, 200 - .refcnt = refcount_read(&ci->tcf_refcnt) - ref, 201 - .bindcnt = atomic_read(&ci->tcf_bindcnt) - bind, 202 - }; 198 + struct tc_connmark opt; 203 199 struct tcf_t t; 200 + 201 + memset(&opt, 0, sizeof(opt)); 202 + 203 + opt.index = ci->tcf_index; 204 + opt.refcnt = refcount_read(&ci->tcf_refcnt) - ref; 205 + opt.bindcnt = atomic_read(&ci->tcf_bindcnt) - bind; 204 206 205 207 rcu_read_lock(); 206 208 parms = rcu_dereference(ci->parms);
+7 -5
net/sched/act_ife.c
··· 644 644 unsigned char *b = skb_tail_pointer(skb); 645 645 struct tcf_ife_info *ife = to_ife(a); 646 646 struct tcf_ife_params *p; 647 - struct tc_ife opt = { 648 - .index = ife->tcf_index, 649 - .refcnt = refcount_read(&ife->tcf_refcnt) - ref, 650 - .bindcnt = atomic_read(&ife->tcf_bindcnt) - bind, 651 - }; 647 + struct tc_ife opt; 652 648 struct tcf_t t; 649 + 650 + memset(&opt, 0, sizeof(opt)); 651 + 652 + opt.index = ife->tcf_index, 653 + opt.refcnt = refcount_read(&ife->tcf_refcnt) - ref, 654 + opt.bindcnt = atomic_read(&ife->tcf_bindcnt) - bind, 653 655 654 656 spin_lock_bh(&ife->tcf_lock); 655 657 opt.action = ife->tcf_action;
+2 -4
net/sched/cls_bpf.c
··· 97 97 } else if (at_ingress) { 98 98 /* It is safe to push/pull even if skb_shared() */ 99 99 __skb_push(skb, skb->mac_len); 100 - bpf_compute_data_pointers(skb); 101 - filter_res = bpf_prog_run(prog->filter, skb); 100 + filter_res = bpf_prog_run_data_pointers(prog->filter, skb); 102 101 __skb_pull(skb, skb->mac_len); 103 102 } else { 104 - bpf_compute_data_pointers(skb); 105 - filter_res = bpf_prog_run(prog->filter, skb); 103 + filter_res = bpf_prog_run_data_pointers(prog->filter, skb); 106 104 } 107 105 if (unlikely(!skb->tstamp && skb->tstamp_type)) 108 106 skb->tstamp_type = SKB_CLOCK_REALTIME;
+5
net/sched/sch_api.c
··· 1599 1599 NL_SET_ERR_MSG(extack, "Failed to find specified qdisc"); 1600 1600 return -ENOENT; 1601 1601 } 1602 + if (p->flags & TCQ_F_INGRESS) { 1603 + NL_SET_ERR_MSG(extack, 1604 + "Cannot add children to ingress/clsact qdisc"); 1605 + return -EOPNOTSUPP; 1606 + } 1602 1607 q = qdisc_leaf(p, clid, extack); 1603 1608 if (IS_ERR(q)) 1604 1609 return PTR_ERR(q);
+10 -7
net/sched/sch_generic.c
··· 180 180 static void try_bulk_dequeue_skb(struct Qdisc *q, 181 181 struct sk_buff *skb, 182 182 const struct netdev_queue *txq, 183 - int *packets) 183 + int *packets, int budget) 184 184 { 185 185 int bytelimit = qdisc_avail_bulklimit(txq) - skb->len; 186 + int cnt = 0; 186 187 187 188 while (bytelimit > 0) { 188 189 struct sk_buff *nskb = q->dequeue(q); ··· 194 193 bytelimit -= nskb->len; /* covers GSO len */ 195 194 skb->next = nskb; 196 195 skb = nskb; 197 - (*packets)++; /* GSO counts as one pkt */ 196 + if (++cnt >= budget) 197 + break; 198 198 } 199 + (*packets) += cnt; 199 200 skb_mark_not_on_list(skb); 200 201 } 201 202 ··· 231 228 * A requeued skb (via q->gso_skb) can also be a SKB list. 232 229 */ 233 230 static struct sk_buff *dequeue_skb(struct Qdisc *q, bool *validate, 234 - int *packets) 231 + int *packets, int budget) 235 232 { 236 233 const struct netdev_queue *txq = q->dev_queue; 237 234 struct sk_buff *skb = NULL; ··· 298 295 if (skb) { 299 296 bulk: 300 297 if (qdisc_may_bulk(q)) 301 - try_bulk_dequeue_skb(q, skb, txq, packets); 298 + try_bulk_dequeue_skb(q, skb, txq, packets, budget); 302 299 else 303 300 try_bulk_dequeue_skb_slow(q, skb, packets); 304 301 } ··· 390 387 * >0 - queue is not empty. 391 388 * 392 389 */ 393 - static inline bool qdisc_restart(struct Qdisc *q, int *packets) 390 + static inline bool qdisc_restart(struct Qdisc *q, int *packets, int budget) 394 391 { 395 392 spinlock_t *root_lock = NULL; 396 393 struct netdev_queue *txq; ··· 399 396 bool validate; 400 397 401 398 /* Dequeue packet */ 402 - skb = dequeue_skb(q, &validate, packets); 399 + skb = dequeue_skb(q, &validate, packets, budget); 403 400 if (unlikely(!skb)) 404 401 return false; 405 402 ··· 417 414 int quota = READ_ONCE(net_hotdata.dev_tx_weight); 418 415 int packets; 419 416 420 - while (qdisc_restart(q, &packets)) { 417 + while (qdisc_restart(q, &packets, quota)) { 421 418 quota -= packets; 422 419 if (quota <= 0) { 423 420 if (q->flags & TCQ_F_NOLOCK)
+17 -6
net/sctp/diag.c
··· 73 73 struct nlattr *attr; 74 74 void *info = NULL; 75 75 76 + rcu_read_lock(); 76 77 list_for_each_entry_rcu(laddr, address_list, list) 77 78 addrcnt++; 79 + rcu_read_unlock(); 78 80 79 81 attr = nla_reserve(skb, INET_DIAG_LOCALS, addrlen * addrcnt); 80 82 if (!attr) 81 83 return -EMSGSIZE; 82 84 83 85 info = nla_data(attr); 86 + rcu_read_lock(); 84 87 list_for_each_entry_rcu(laddr, address_list, list) { 85 88 memcpy(info, &laddr->a, sizeof(laddr->a)); 86 89 memset(info + sizeof(laddr->a), 0, addrlen - sizeof(laddr->a)); 87 90 info += addrlen; 91 + 92 + if (!--addrcnt) 93 + break; 88 94 } 95 + rcu_read_unlock(); 89 96 90 97 return 0; 91 98 } ··· 230 223 bool net_admin; 231 224 }; 232 225 233 - static size_t inet_assoc_attr_size(struct sctp_association *asoc) 226 + static size_t inet_assoc_attr_size(struct sock *sk, 227 + struct sctp_association *asoc) 234 228 { 235 229 int addrlen = sizeof(struct sockaddr_storage); 236 230 int addrcnt = 0; 237 231 struct sctp_sockaddr_entry *laddr; 238 232 239 233 list_for_each_entry_rcu(laddr, &asoc->base.bind_addr.address_list, 240 - list) 234 + list, lockdep_sock_is_held(sk)) 241 235 addrcnt++; 242 236 243 237 return nla_total_size(sizeof(struct sctp_info)) ··· 264 256 if (err) 265 257 return err; 266 258 267 - rep = nlmsg_new(inet_assoc_attr_size(assoc), GFP_KERNEL); 268 - if (!rep) 269 - return -ENOMEM; 270 - 271 259 lock_sock(sk); 260 + 261 + rep = nlmsg_new(inet_assoc_attr_size(sk, assoc), GFP_KERNEL); 262 + if (!rep) { 263 + release_sock(sk); 264 + return -ENOMEM; 265 + } 266 + 272 267 if (ep != assoc->ep) { 273 268 err = -EAGAIN; 274 269 goto out;
+15 -19
net/sctp/transport.c
··· 37 37 /* 1st Level Abstractions. */ 38 38 39 39 /* Initialize a new transport from provided memory. */ 40 - static struct sctp_transport *sctp_transport_init(struct net *net, 41 - struct sctp_transport *peer, 42 - const union sctp_addr *addr, 43 - gfp_t gfp) 40 + static void sctp_transport_init(struct net *net, 41 + struct sctp_transport *peer, 42 + const union sctp_addr *addr, 43 + gfp_t gfp) 44 44 { 45 45 /* Copy in the address. */ 46 46 peer->af_specific = sctp_get_af_specific(addr->sa.sa_family); ··· 83 83 get_random_bytes(&peer->hb_nonce, sizeof(peer->hb_nonce)); 84 84 85 85 refcount_set(&peer->refcnt, 1); 86 - 87 - return peer; 88 86 } 89 87 90 88 /* Allocate and initialize a new transport. */ ··· 94 96 95 97 transport = kzalloc(sizeof(*transport), gfp); 96 98 if (!transport) 97 - goto fail; 99 + return NULL; 98 100 99 - if (!sctp_transport_init(net, transport, addr, gfp)) 100 - goto fail_init; 101 + sctp_transport_init(net, transport, addr, gfp); 101 102 102 103 SCTP_DBG_OBJCNT_INC(transport); 103 104 104 105 return transport; 105 - 106 - fail_init: 107 - kfree(transport); 108 - 109 - fail: 110 - return NULL; 111 106 } 112 107 113 108 /* This transport is no longer needed. Free up if possible, or ··· 486 495 487 496 if (tp->rttvar || tp->srtt) { 488 497 struct net *net = tp->asoc->base.net; 498 + unsigned int rto_beta, rto_alpha; 489 499 /* 6.3.1 C3) When a new RTT measurement R' is made, set 490 500 * RTTVAR <- (1 - RTO.Beta) * RTTVAR + RTO.Beta * |SRTT - R'| 491 501 * SRTT <- (1 - RTO.Alpha) * SRTT + RTO.Alpha * R' ··· 498 506 * For example, assuming the default value of RTO.Alpha of 499 507 * 1/8, rto_alpha would be expressed as 3. 500 508 */ 501 - tp->rttvar = tp->rttvar - (tp->rttvar >> net->sctp.rto_beta) 502 - + (((__u32)abs((__s64)tp->srtt - (__s64)rtt)) >> net->sctp.rto_beta); 503 - tp->srtt = tp->srtt - (tp->srtt >> net->sctp.rto_alpha) 504 - + (rtt >> net->sctp.rto_alpha); 509 + rto_beta = READ_ONCE(net->sctp.rto_beta); 510 + if (rto_beta < 32) 511 + tp->rttvar = tp->rttvar - (tp->rttvar >> rto_beta) 512 + + (((__u32)abs((__s64)tp->srtt - (__s64)rtt)) >> rto_beta); 513 + rto_alpha = READ_ONCE(net->sctp.rto_alpha); 514 + if (rto_alpha < 32) 515 + tp->srtt = tp->srtt - (tp->srtt >> rto_alpha) 516 + + (rtt >> rto_alpha); 505 517 } else { 506 518 /* 6.3.1 C2) When the first RTT measurement R is made, set 507 519 * SRTT <- R, RTTVAR <- R/2.
+1
net/smc/smc_clc.c
··· 890 890 return SMC_CLC_DECL_CNFERR; 891 891 } 892 892 pclc_base->hdr.typev1 = SMC_TYPE_N; 893 + ini->smc_type_v1 = SMC_TYPE_N; 893 894 } else { 894 895 pclc_base->iparea_offset = htons(sizeof(*pclc_smcd)); 895 896 plen += sizeof(*pclc_prfx) +
+1 -1
net/strparser/strparser.c
··· 238 238 strp_parser_err(strp, -EMSGSIZE, desc); 239 239 break; 240 240 } else if (len <= (ssize_t)head->len - 241 - skb->len - stm->strp.offset) { 241 + (ssize_t)skb->len - stm->strp.offset) { 242 242 /* Length must be into new skb (and also 243 243 * greater than zero) 244 244 */
+1 -2
net/sunrpc/Kconfig
··· 18 18 19 19 config RPCSEC_GSS_KRB5 20 20 tristate "Secure RPC: Kerberos V mechanism" 21 - depends on SUNRPC 21 + depends on SUNRPC && CRYPTO 22 22 default y 23 23 select SUNRPC_GSS 24 - select CRYPTO 25 24 select CRYPTO_SKCIPHER 26 25 select CRYPTO_HASH 27 26 help
+2
net/tipc/net.c
··· 145 145 { 146 146 struct tipc_net *tn = container_of(work, struct tipc_net, work); 147 147 148 + rtnl_lock(); 148 149 tipc_net_finalize(tipc_link_net(tn->bcl), tn->trial_addr); 150 + rtnl_unlock(); 149 151 } 150 152 151 153 void tipc_net_stop(struct net *net)
+11 -3
net/unix/garbage.c
··· 145 145 }; 146 146 147 147 static unsigned long unix_vertex_unvisited_index = UNIX_VERTEX_INDEX_MARK1; 148 + static unsigned long unix_vertex_max_scc_index = UNIX_VERTEX_INDEX_START; 148 149 149 150 static void unix_add_edge(struct scm_fp_list *fpl, struct unix_edge *edge) 150 151 { ··· 154 153 if (!vertex) { 155 154 vertex = list_first_entry(&fpl->vertices, typeof(*vertex), entry); 156 155 vertex->index = unix_vertex_unvisited_index; 156 + vertex->scc_index = ++unix_vertex_max_scc_index; 157 157 vertex->out_degree = 0; 158 158 INIT_LIST_HEAD(&vertex->edges); 159 159 INIT_LIST_HEAD(&vertex->scc_entry); ··· 491 489 scc_dead = unix_vertex_dead(v); 492 490 } 493 491 494 - if (scc_dead) 492 + if (scc_dead) { 495 493 unix_collect_skb(&scc, hitlist); 496 - else if (!unix_graph_maybe_cyclic) 497 - unix_graph_maybe_cyclic = unix_scc_cyclic(&scc); 494 + } else { 495 + if (unix_vertex_max_scc_index < vertex->scc_index) 496 + unix_vertex_max_scc_index = vertex->scc_index; 497 + 498 + if (!unix_graph_maybe_cyclic) 499 + unix_graph_maybe_cyclic = unix_scc_cyclic(&scc); 500 + } 498 501 499 502 list_del(&scc); 500 503 } ··· 514 507 unsigned long last_index = UNIX_VERTEX_INDEX_START; 515 508 516 509 unix_graph_maybe_cyclic = false; 510 + unix_vertex_max_scc_index = UNIX_VERTEX_INDEX_START; 517 511 518 512 /* Visit every vertex exactly once. 519 513 * __unix_walk_scc() moves visited vertices to unix_visited_vertices.
+56
net/wireless/core.c
··· 1787 1787 } 1788 1788 EXPORT_SYMBOL_GPL(wiphy_delayed_work_pending); 1789 1789 1790 + enum hrtimer_restart wiphy_hrtimer_work_timer(struct hrtimer *t) 1791 + { 1792 + struct wiphy_hrtimer_work *hrwork = 1793 + container_of(t, struct wiphy_hrtimer_work, timer); 1794 + 1795 + wiphy_work_queue(hrwork->wiphy, &hrwork->work); 1796 + 1797 + return HRTIMER_NORESTART; 1798 + } 1799 + EXPORT_SYMBOL_GPL(wiphy_hrtimer_work_timer); 1800 + 1801 + void wiphy_hrtimer_work_queue(struct wiphy *wiphy, 1802 + struct wiphy_hrtimer_work *hrwork, 1803 + ktime_t delay) 1804 + { 1805 + trace_wiphy_hrtimer_work_queue(wiphy, &hrwork->work, delay); 1806 + 1807 + if (!delay) { 1808 + hrtimer_cancel(&hrwork->timer); 1809 + wiphy_work_queue(wiphy, &hrwork->work); 1810 + return; 1811 + } 1812 + 1813 + hrwork->wiphy = wiphy; 1814 + hrtimer_start_range_ns(&hrwork->timer, delay, 1815 + 1000 * NSEC_PER_USEC, HRTIMER_MODE_REL); 1816 + } 1817 + EXPORT_SYMBOL_GPL(wiphy_hrtimer_work_queue); 1818 + 1819 + void wiphy_hrtimer_work_cancel(struct wiphy *wiphy, 1820 + struct wiphy_hrtimer_work *hrwork) 1821 + { 1822 + lockdep_assert_held(&wiphy->mtx); 1823 + 1824 + hrtimer_cancel(&hrwork->timer); 1825 + wiphy_work_cancel(wiphy, &hrwork->work); 1826 + } 1827 + EXPORT_SYMBOL_GPL(wiphy_hrtimer_work_cancel); 1828 + 1829 + void wiphy_hrtimer_work_flush(struct wiphy *wiphy, 1830 + struct wiphy_hrtimer_work *hrwork) 1831 + { 1832 + lockdep_assert_held(&wiphy->mtx); 1833 + 1834 + hrtimer_cancel(&hrwork->timer); 1835 + wiphy_work_flush(wiphy, &hrwork->work); 1836 + } 1837 + EXPORT_SYMBOL_GPL(wiphy_hrtimer_work_flush); 1838 + 1839 + bool wiphy_hrtimer_work_pending(struct wiphy *wiphy, 1840 + struct wiphy_hrtimer_work *hrwork) 1841 + { 1842 + return hrtimer_is_queued(&hrwork->timer); 1843 + } 1844 + EXPORT_SYMBOL_GPL(wiphy_hrtimer_work_pending); 1845 + 1790 1846 static int __init cfg80211_init(void) 1791 1847 { 1792 1848 int err;
+21
net/wireless/trace.h
··· 304 304 __entry->delay) 305 305 ); 306 306 307 + TRACE_EVENT(wiphy_hrtimer_work_queue, 308 + TP_PROTO(struct wiphy *wiphy, struct wiphy_work *work, 309 + ktime_t delay), 310 + TP_ARGS(wiphy, work, delay), 311 + TP_STRUCT__entry( 312 + WIPHY_ENTRY 313 + __field(void *, instance) 314 + __field(void *, func) 315 + __field(ktime_t, delay) 316 + ), 317 + TP_fast_assign( 318 + WIPHY_ASSIGN; 319 + __entry->instance = work; 320 + __entry->func = work->func; 321 + __entry->delay = delay; 322 + ), 323 + TP_printk(WIPHY_PR_FMT " instance=%p func=%pS delay=%llu", 324 + WIPHY_PR_ARG, __entry->instance, __entry->func, 325 + __entry->delay) 326 + ); 327 + 307 328 TRACE_EVENT(wiphy_work_worker_start, 308 329 TP_PROTO(struct wiphy *wiphy), 309 330 TP_ARGS(wiphy),
+15 -2
rust/Makefile
··· 69 69 # the time being (https://github.com/rust-lang/rust/issues/144521). 70 70 rustdoc_modifiers_workaround := $(if $(call rustc-min-version,108800),-Cunsafe-allow-abi-mismatch=fixed-x18) 71 71 72 + # Similarly, for doctests (https://github.com/rust-lang/rust/issues/146465). 73 + doctests_modifiers_workaround := $(rustdoc_modifiers_workaround)$(if $(call rustc-min-version,109100),$(comma)sanitizer) 74 + 72 75 # `rustc` recognizes `--remap-path-prefix` since 1.26.0, but `rustdoc` only 73 76 # since Rust 1.81.0. Moreover, `rustdoc` ICEs on out-of-tree builds since Rust 74 77 # 1.82.0 (https://github.com/rust-lang/rust/issues/138520). Thus workaround both ··· 130 127 rustdoc-core: $(RUST_LIB_SRC)/core/src/lib.rs rustdoc-clean FORCE 131 128 +$(call if_changed,rustdoc) 132 129 130 + # Even if `rustdoc` targets are not kernel objects, they should still be 131 + # treated as such so that we pass the same flags. Otherwise, for instance, 132 + # `rustdoc` will complain about missing sanitizer flags causing an ABI mismatch. 133 + rustdoc-compiler_builtins: private is-kernel-object := y 133 134 rustdoc-compiler_builtins: $(src)/compiler_builtins.rs rustdoc-core FORCE 134 135 +$(call if_changed,rustdoc) 135 136 137 + rustdoc-ffi: private is-kernel-object := y 136 138 rustdoc-ffi: $(src)/ffi.rs rustdoc-core FORCE 137 139 +$(call if_changed,rustdoc) 138 140 ··· 155 147 rustdoc-macros FORCE 156 148 +$(call if_changed,rustdoc) 157 149 150 + rustdoc-kernel: private is-kernel-object := y 158 151 rustdoc-kernel: private rustc_target_flags = --extern ffi --extern pin_init \ 159 152 --extern build_error --extern macros \ 160 153 --extern bindings --extern uapi ··· 239 230 --extern bindings --extern uapi \ 240 231 --no-run --crate-name kernel -Zunstable-options \ 241 232 --sysroot=/dev/null \ 242 - $(rustdoc_modifiers_workaround) \ 233 + $(doctests_modifiers_workaround) \ 243 234 --test-builder $(objtree)/scripts/rustdoc_test_builder \ 244 235 $< $(rustdoc_test_kernel_quiet); \ 245 236 $(objtree)/scripts/rustdoc_test_gen ··· 298 289 -fno-inline-functions-called-once -fsanitize=bounds-strict \ 299 290 -fstrict-flex-arrays=% -fmin-function-alignment=% \ 300 291 -fzero-init-padding-bits=% -mno-fdpic \ 301 - --param=% --param asan-% 292 + --param=% --param asan-% -fno-isolate-erroneous-paths-dereference 302 293 303 294 # Derived from `scripts/Makefile.clang`. 304 295 BINDGEN_TARGET_x86 := x86_64-linux-gnu ··· 531 522 $(obj)/$(libpin_init_internal_name) $(obj)/$(libmacros_name) FORCE 532 523 +$(call if_changed_rule,rustc_library) 533 524 525 + # Even if normally `build_error` is not a kernel object, it should still be 526 + # treated as such so that we pass the same flags. Otherwise, for instance, 527 + # `rustc` will complain about missing sanitizer flags causing an ABI mismatch. 528 + $(obj)/build_error.o: private is-kernel-object := y 534 529 $(obj)/build_error.o: private skip_gendwarfksyms = 1 535 530 $(obj)/build_error.o: $(src)/build_error.rs $(obj)/compiler_builtins.o FORCE 536 531 +$(call if_changed_rule,rustc_library)
+1 -1
rust/kernel/devres.rs
··· 103 103 /// 104 104 /// # Invariants 105 105 /// 106 - /// [`Self::inner`] is guaranteed to be initialized and is always accessed read-only. 106 + /// `Self::inner` is guaranteed to be initialized and is always accessed read-only. 107 107 #[pin_data(PinnedDrop)] 108 108 pub struct Devres<T: Send> { 109 109 dev: ARef<Device>,
+1 -1
rust/kernel/sync/condvar.rs
··· 36 36 /// spuriously. 37 37 /// 38 38 /// Instances of [`CondVar`] need a lock class and to be pinned. The recommended way to create such 39 - /// instances is with the [`pin_init`](crate::pin_init!) and [`new_condvar`] macros. 39 + /// instances is with the [`pin_init`](pin_init::pin_init!) and [`new_condvar`] macros. 40 40 /// 41 41 /// # Examples 42 42 ///
+1 -1
scripts/Makefile.build
··· 167 167 endif 168 168 169 169 ifneq ($(KBUILD_EXTRA_WARN),) 170 - cmd_checkdoc = PYTHONDONTWRITEBYTECODE=1 $(KERNELDOC) -none $(KDOCFLAGS) \ 170 + cmd_checkdoc = PYTHONDONTWRITEBYTECODE=1 $(PYTHON3) $(KERNELDOC) -none $(KDOCFLAGS) \ 171 171 $(if $(findstring 2, $(KBUILD_EXTRA_WARN)), -Wall) \ 172 172 $< 173 173 endif
+14 -1
scripts/Makefile.vmlinux
··· 102 102 # modules.builtin.modinfo 103 103 # --------------------------------------------------------------------------- 104 104 105 + # .modinfo in vmlinux.unstripped is aligned to 8 bytes for compatibility with 106 + # tools that expect vmlinux to have sufficiently aligned sections but the 107 + # additional bytes used for padding .modinfo to satisfy this requirement break 108 + # certain versions of kmod with 109 + # 110 + # depmod: ERROR: kmod_builtin_iter_next: unexpected string without modname prefix 111 + # 112 + # Strip the trailing padding bytes after extracting .modinfo to comply with 113 + # what kmod expects to parse. 114 + quiet_cmd_modules_builtin_modinfo = GEN $@ 115 + cmd_modules_builtin_modinfo = $(cmd_objcopy); \ 116 + sed -i 's/\x00\+$$/\x00/g' $@ 117 + 105 118 OBJCOPYFLAGS_modules.builtin.modinfo := -j .modinfo -O binary 106 119 107 120 targets += modules.builtin.modinfo 108 121 modules.builtin.modinfo: vmlinux.unstripped FORCE 109 - $(call if_changed,objcopy) 122 + $(call if_changed,modules_builtin_modinfo) 110 123 111 124 # modules.builtin 112 125 # ---------------------------------------------------------------------------
+8 -6
scripts/decode_stacktrace.sh
··· 277 277 fi 278 278 done 279 279 280 - if [[ ${words[$last]} =~ ^[0-9a-f]+\] ]]; then 281 - words[$last-1]="${words[$last-1]} ${words[$last]}" 282 - unset words[$last] spaces[$last] 283 - last=$(( $last - 1 )) 284 - fi 285 - 286 280 # Extract info after the symbol if present. E.g.: 287 281 # func_name+0x54/0x80 (P) 288 282 # ^^^ ··· 285 291 local info_str="" 286 292 if [[ ${words[$last]} =~ \([A-Z]*\) ]]; then 287 293 info_str=${words[$last]} 294 + unset words[$last] spaces[$last] 295 + last=$(( $last - 1 )) 296 + fi 297 + 298 + # Join module name with its build id if present, as these were 299 + # split during tokenization (e.g. "[module" and "modbuildid]"). 300 + if [[ ${words[$last]} =~ ^[0-9a-f]+\] ]]; then 301 + words[$last-1]="${words[$last-1]} ${words[$last]}" 288 302 unset words[$last] spaces[$last] 289 303 last=$(( $last - 1 )) 290 304 fi
+2 -1
scripts/gendwarfksyms/gendwarfksyms.c
··· 138 138 error("no input files?"); 139 139 } 140 140 141 - symbol_read_exports(stdin); 141 + if (!symbol_read_exports(stdin)) 142 + return 0; 142 143 143 144 if (symtypes_file) { 144 145 symfile = fopen(symtypes_file, "w");
+1 -1
scripts/gendwarfksyms/gendwarfksyms.h
··· 123 123 typedef void (*symbol_callback_t)(struct symbol *, void *arg); 124 124 125 125 bool is_symbol_ptr(const char *name); 126 - void symbol_read_exports(FILE *file); 126 + int symbol_read_exports(FILE *file); 127 127 void symbol_read_symtab(int fd); 128 128 struct symbol *symbol_get(const char *name); 129 129 void symbol_set_ptr(struct symbol *sym, Dwarf_Die *ptr);
+3 -1
scripts/gendwarfksyms/symbols.c
··· 128 128 return for_each(name, NULL, NULL) > 0; 129 129 } 130 130 131 - void symbol_read_exports(FILE *file) 131 + int symbol_read_exports(FILE *file) 132 132 { 133 133 struct symbol *sym; 134 134 char *line = NULL; ··· 159 159 160 160 free(line); 161 161 debug("%d exported symbols", nsym); 162 + 163 + return nsym; 162 164 } 163 165 164 166 static void get_symbol(struct symbol *sym, void *arg)
+2 -2
sound/firewire/dice/dice-extension.c
··· 116 116 break; 117 117 118 118 base_offset += EXT_APP_STREAM_ENTRIES; 119 - stream_count = be32_to_cpu(reg[0]); 119 + stream_count = min_t(unsigned int, be32_to_cpu(reg[0]), MAX_STREAMS); 120 120 err = read_stream_entries(dice, section_addr, base_offset, 121 121 stream_count, mode, 122 122 dice->tx_pcm_chs, ··· 125 125 break; 126 126 127 127 base_offset += stream_count * EXT_APP_STREAM_ENTRY_SIZE; 128 - stream_count = be32_to_cpu(reg[1]); 128 + stream_count = min_t(unsigned int, be32_to_cpu(reg[1]), MAX_STREAMS); 129 129 err = read_stream_entries(dice, section_addr, base_offset, 130 130 stream_count, 131 131 mode, dice->rx_pcm_chs,
+2
sound/hda/codecs/realtek/alc269.c
··· 6597 6597 SND_PCI_QUIRK(0x103c, 0x8a4f, "HP Victus 15-fa0xxx (MB 8A4F)", ALC245_FIXUP_HP_MUTE_LED_COEFBIT), 6598 6598 SND_PCI_QUIRK(0x103c, 0x8a6e, "HP EDNA 360", ALC287_FIXUP_CS35L41_I2C_4), 6599 6599 SND_PCI_QUIRK(0x103c, 0x8a74, "HP ProBook 440 G8 Notebook PC", ALC236_FIXUP_HP_GPIO_LED), 6600 + SND_PCI_QUIRK(0x103c, 0x8a75, "HP ProBook 450 G8 Notebook PC", ALC236_FIXUP_HP_GPIO_LED), 6600 6601 SND_PCI_QUIRK(0x103c, 0x8a78, "HP Dev One", ALC285_FIXUP_HP_LIMIT_INT_MIC_BOOST), 6601 6602 SND_PCI_QUIRK(0x103c, 0x8aa0, "HP ProBook 440 G9 (MB 8A9E)", ALC236_FIXUP_HP_GPIO_LED), 6602 6603 SND_PCI_QUIRK(0x103c, 0x8aa3, "HP ProBook 450 G9 (MB 8AA1)", ALC236_FIXUP_HP_GPIO_LED), ··· 6645 6644 SND_PCI_QUIRK(0x103c, 0x8bc8, "HP Victus 15-fa1xxx", ALC245_FIXUP_HP_MUTE_LED_COEFBIT), 6646 6645 SND_PCI_QUIRK(0x103c, 0x8bcd, "HP Omen 16-xd0xxx", ALC245_FIXUP_HP_MUTE_LED_V1_COEFBIT), 6647 6646 SND_PCI_QUIRK(0x103c, 0x8bd4, "HP Victus 16-s0xxx (MB 8BD4)", ALC245_FIXUP_HP_MUTE_LED_COEFBIT), 6647 + SND_PCI_QUIRK(0x103c, 0x8bd6, "HP Pavilion Aero Laptop 13z-be200", ALC287_FIXUP_HP_GPIO_LED), 6648 6648 SND_PCI_QUIRK(0x103c, 0x8bdd, "HP Envy 17", ALC287_FIXUP_CS35L41_I2C_2), 6649 6649 SND_PCI_QUIRK(0x103c, 0x8bde, "HP Envy 17", ALC287_FIXUP_CS35L41_I2C_2), 6650 6650 SND_PCI_QUIRK(0x103c, 0x8bdf, "HP Envy 15", ALC287_FIXUP_CS35L41_I2C_2),
+1
sound/soc/codecs/Kconfig
··· 2310 2310 tristate "WCD9340/WCD9341 Codec" 2311 2311 depends on COMMON_CLK 2312 2312 depends on SLIMBUS 2313 + depends on SOUNDWIRE || !SOUNDWIRE 2313 2314 select REGMAP_IRQ 2314 2315 select REGMAP_SLIMBUS 2315 2316 select SND_SOC_WCD_CLASSH
+18 -3
sound/soc/codecs/pm4125.c
··· 1551 1551 struct device_link *devlink; 1552 1552 int ret; 1553 1553 1554 + /* Initialize device pointers to NULL for safe cleanup */ 1555 + pm4125->rxdev = NULL; 1556 + pm4125->txdev = NULL; 1557 + 1554 1558 /* Give the soundwire subdevices some more time to settle */ 1555 1559 usleep_range(15000, 15010); 1556 1560 ··· 1578 1574 if (!pm4125->txdev) { 1579 1575 dev_err(dev, "could not find txslave with matching of node\n"); 1580 1576 ret = -EINVAL; 1581 - goto error_unbind_all; 1577 + goto error_put_rx; 1582 1578 } 1583 1579 1584 1580 pm4125->sdw_priv[AIF1_CAP] = dev_get_drvdata(pm4125->txdev); ··· 1588 1584 if (!pm4125->tx_sdw_dev) { 1589 1585 dev_err(dev, "could not get txslave with matching of dev\n"); 1590 1586 ret = -EINVAL; 1591 - goto error_unbind_all; 1587 + goto error_put_tx; 1592 1588 } 1593 1589 1594 1590 /* ··· 1600 1596 if (!devlink) { 1601 1597 dev_err(dev, "Could not devlink TX and RX\n"); 1602 1598 ret = -EINVAL; 1603 - goto error_unbind_all; 1599 + goto error_put_tx; 1604 1600 } 1605 1601 1606 1602 devlink = device_link_add(dev, pm4125->txdev, ··· 1654 1650 device_link_remove(dev, pm4125->txdev); 1655 1651 link_remove_rx_tx: 1656 1652 device_link_remove(pm4125->rxdev, pm4125->txdev); 1653 + error_put_tx: 1654 + put_device(pm4125->txdev); 1655 + error_put_rx: 1656 + put_device(pm4125->rxdev); 1657 1657 error_unbind_all: 1658 1658 component_unbind_all(dev, pm4125); 1659 1659 return ret; ··· 1671 1663 device_link_remove(dev, pm4125->txdev); 1672 1664 device_link_remove(dev, pm4125->rxdev); 1673 1665 device_link_remove(pm4125->rxdev, pm4125->txdev); 1666 + 1667 + /* Release device references acquired in bind */ 1668 + if (pm4125->txdev) 1669 + put_device(pm4125->txdev); 1670 + if (pm4125->rxdev) 1671 + put_device(pm4125->rxdev); 1672 + 1674 1673 component_unbind_all(dev, pm4125); 1675 1674 } 1676 1675
+1 -1
sound/soc/codecs/tas2781-comlib-i2c.c
··· 320 320 for (i = 0; i < tas_dev->ndev; i++) { 321 321 ret = tasdevice_dev_write(tas_dev, i, 322 322 TASDEVICE_REG_SWRESET, 323 - tas_dev->chip_id >= TAS5825 ? 323 + tas_dev->chip_id >= TAS5802 ? 324 324 TAS5825_REG_SWRESET_RESET : 325 325 TASDEVICE_REG_SWRESET_RESET); 326 326 if (ret < 0)
+1 -1
sound/soc/codecs/tas2781-i2c.c
··· 1391 1391 1392 1392 /* 1393 1393 * Alloc kcontrol via devm_kzalloc(), which don't manually 1394 - * free the kcontrol。 1394 + * free the kcontrol. 1395 1395 */ 1396 1396 cali_ctrls = devm_kcalloc(priv->dev, nctrls, 1397 1397 sizeof(cali_ctrls[0]), GFP_KERNEL);
+34 -9
sound/soc/codecs/wcd937x.c
··· 2748 2748 wcd937x->rxdev = of_sdw_find_device_by_node(wcd937x->rxnode); 2749 2749 if (!wcd937x->rxdev) { 2750 2750 dev_err(dev, "could not find slave with matching of node\n"); 2751 - return -EINVAL; 2751 + ret = -EINVAL; 2752 + goto err_component_unbind; 2752 2753 } 2753 2754 2754 2755 wcd937x->sdw_priv[AIF1_PB] = dev_get_drvdata(wcd937x->rxdev); ··· 2758 2757 wcd937x->txdev = of_sdw_find_device_by_node(wcd937x->txnode); 2759 2758 if (!wcd937x->txdev) { 2760 2759 dev_err(dev, "could not find txslave with matching of node\n"); 2761 - return -EINVAL; 2760 + ret = -EINVAL; 2761 + goto err_put_rxdev; 2762 2762 } 2763 2763 2764 2764 wcd937x->sdw_priv[AIF1_CAP] = dev_get_drvdata(wcd937x->txdev); ··· 2767 2765 wcd937x->tx_sdw_dev = dev_to_sdw_dev(wcd937x->txdev); 2768 2766 if (!wcd937x->tx_sdw_dev) { 2769 2767 dev_err(dev, "could not get txslave with matching of dev\n"); 2770 - return -EINVAL; 2768 + ret = -EINVAL; 2769 + goto err_put_txdev; 2771 2770 } 2772 2771 2773 2772 /* ··· 2778 2775 if (!device_link_add(wcd937x->rxdev, wcd937x->txdev, 2779 2776 DL_FLAG_STATELESS | DL_FLAG_PM_RUNTIME)) { 2780 2777 dev_err(dev, "Could not devlink TX and RX\n"); 2781 - return -EINVAL; 2778 + ret = -EINVAL; 2779 + goto err_put_txdev; 2782 2780 } 2783 2781 2784 2782 if (!device_link_add(dev, wcd937x->txdev, 2785 2783 DL_FLAG_STATELESS | DL_FLAG_PM_RUNTIME)) { 2786 2784 dev_err(dev, "Could not devlink WCD and TX\n"); 2787 - return -EINVAL; 2785 + ret = -EINVAL; 2786 + goto err_remove_link1; 2788 2787 } 2789 2788 2790 2789 if (!device_link_add(dev, wcd937x->rxdev, 2791 2790 DL_FLAG_STATELESS | DL_FLAG_PM_RUNTIME)) { 2792 2791 dev_err(dev, "Could not devlink WCD and RX\n"); 2793 - return -EINVAL; 2792 + ret = -EINVAL; 2793 + goto err_remove_link2; 2794 2794 } 2795 2795 2796 2796 wcd937x->regmap = wcd937x->sdw_priv[AIF1_CAP]->regmap; 2797 2797 if (!wcd937x->regmap) { 2798 2798 dev_err(dev, "could not get TX device regmap\n"); 2799 - return -EINVAL; 2799 + ret = -EINVAL; 2800 + goto err_remove_link3; 2800 2801 } 2801 2802 2802 2803 ret = wcd937x_irq_init(wcd937x, dev); 2803 2804 if (ret) { 2804 2805 dev_err(dev, "IRQ init failed: %d\n", ret); 2805 - return ret; 2806 + goto err_remove_link3; 2806 2807 } 2807 2808 2808 2809 wcd937x->sdw_priv[AIF1_PB]->slave_irq = wcd937x->virq; ··· 2816 2809 2817 2810 ret = snd_soc_register_component(dev, &soc_codec_dev_wcd937x, 2818 2811 wcd937x_dais, ARRAY_SIZE(wcd937x_dais)); 2819 - if (ret) 2812 + if (ret) { 2820 2813 dev_err(dev, "Codec registration failed\n"); 2814 + goto err_remove_link3; 2815 + } 2821 2816 2817 + return ret; 2818 + 2819 + err_remove_link3: 2820 + device_link_remove(dev, wcd937x->rxdev); 2821 + err_remove_link2: 2822 + device_link_remove(dev, wcd937x->txdev); 2823 + err_remove_link1: 2824 + device_link_remove(wcd937x->rxdev, wcd937x->txdev); 2825 + err_put_txdev: 2826 + put_device(wcd937x->txdev); 2827 + err_put_rxdev: 2828 + put_device(wcd937x->rxdev); 2829 + err_component_unbind: 2830 + component_unbind_all(dev, wcd937x); 2822 2831 return ret; 2823 2832 } 2824 2833 ··· 2848 2825 device_link_remove(wcd937x->rxdev, wcd937x->txdev); 2849 2826 component_unbind_all(dev, wcd937x); 2850 2827 mutex_destroy(&wcd937x->micb_lock); 2828 + put_device(wcd937x->txdev); 2829 + put_device(wcd937x->rxdev); 2851 2830 } 2852 2831 2853 2832 static const struct component_master_ops wcd937x_comp_ops = {
+1 -1
sound/soc/fsl/fsl_xcvr.c
··· 1421 1421 bitrev32(val); 1422 1422 } 1423 1423 /* clear CS control register */ 1424 - memset_io(reg_ctrl, 0, sizeof(val)); 1424 + writel_relaxed(0, reg_ctrl); 1425 1425 } 1426 1426 } else { 1427 1427 regmap_read(xcvr->regmap, FSL_XCVR_RX_CS_DATA_0,
+47 -17
sound/soc/renesas/rz-ssi.c
··· 13 13 #include <linux/module.h> 14 14 #include <linux/pm_runtime.h> 15 15 #include <linux/reset.h> 16 + #include <sound/pcm_params.h> 16 17 #include <sound/soc.h> 17 18 18 19 /* REGISTER OFFSET */ ··· 88 87 int dma_buffer_pos; /* The address for the next DMA descriptor */ 89 88 int completed_dma_buf_pos; /* The address of the last completed DMA descriptor. */ 90 89 int period_counter; /* for keeping track of periods transferred */ 91 - int sample_width; 92 90 int buffer_pos; /* current frame position in the buffer */ 93 91 int running; /* 0=stopped, 1=running */ 94 92 ··· 132 132 bool lrckp_fsync_fall; /* LR clock polarity (SSICR.LRCKP) */ 133 133 bool bckp_rise; /* Bit clock polarity (SSICR.BCKP) */ 134 134 bool dma_rt; 135 + 136 + struct { 137 + bool tx_active; 138 + bool rx_active; 139 + bool one_stream_triggered; 140 + } dup; 135 141 136 142 /* Full duplex communication support */ 137 143 struct { ··· 217 211 static void rz_ssi_stream_init(struct rz_ssi_stream *strm, 218 212 struct snd_pcm_substream *substream) 219 213 { 220 - struct snd_pcm_runtime *runtime = substream->runtime; 221 - 222 214 rz_ssi_set_substream(strm, substream); 223 - strm->sample_width = samples_to_bytes(runtime, 1); 224 215 strm->dma_buffer_pos = 0; 225 216 strm->completed_dma_buf_pos = 0; 226 217 strm->period_counter = 0; ··· 335 332 bool is_full_duplex; 336 333 u32 ssicr, ssifcr; 337 334 338 - is_full_duplex = rz_ssi_is_stream_running(&ssi->playback) || 339 - rz_ssi_is_stream_running(&ssi->capture); 335 + is_full_duplex = ssi->dup.tx_active && ssi->dup.rx_active; 340 336 ssicr = rz_ssi_reg_readl(ssi, SSICR); 341 337 ssifcr = rz_ssi_reg_readl(ssi, SSIFCR); 342 338 if (!is_full_duplex) { 343 339 ssifcr &= ~0xF; 344 - } else { 340 + } else if (ssi->dup.one_stream_triggered) { 345 341 rz_ssi_reg_mask_setl(ssi, SSICR, SSICR_TEN | SSICR_REN, 0); 346 342 rz_ssi_set_idle(ssi); 347 343 ssifcr &= ~SSIFCR_FIFO_RST; ··· 376 374 SSISR_RUIRQ), 0); 377 375 378 376 strm->running = 1; 379 - if (is_full_duplex) 380 - ssicr |= SSICR_TEN | SSICR_REN; 381 - else 377 + if (!is_full_duplex) { 382 378 ssicr |= is_play ? SSICR_TEN : SSICR_REN; 383 - 384 - rz_ssi_reg_writel(ssi, SSICR, ssicr); 379 + rz_ssi_reg_writel(ssi, SSICR, ssicr); 380 + } else if (ssi->dup.one_stream_triggered) { 381 + ssicr |= SSICR_TEN | SSICR_REN; 382 + rz_ssi_reg_writel(ssi, SSICR, ssicr); 383 + ssi->dup.one_stream_triggered = false; 384 + } else { 385 + ssi->dup.one_stream_triggered = true; 386 + } 385 387 386 388 return 0; 387 389 } ··· 921 915 return 0; 922 916 } 923 917 918 + static int rz_ssi_startup(struct snd_pcm_substream *substream, 919 + struct snd_soc_dai *dai) 920 + { 921 + struct rz_ssi_priv *ssi = snd_soc_dai_get_drvdata(dai); 922 + 923 + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) 924 + ssi->dup.tx_active = true; 925 + else 926 + ssi->dup.rx_active = true; 927 + 928 + return 0; 929 + } 930 + 931 + static void rz_ssi_shutdown(struct snd_pcm_substream *substream, 932 + struct snd_soc_dai *dai) 933 + { 934 + struct rz_ssi_priv *ssi = snd_soc_dai_get_drvdata(dai); 935 + 936 + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) 937 + ssi->dup.tx_active = false; 938 + else 939 + ssi->dup.rx_active = false; 940 + } 941 + 924 942 static bool rz_ssi_is_valid_hw_params(struct rz_ssi_priv *ssi, unsigned int rate, 925 943 unsigned int channels, 926 944 unsigned int sample_width, ··· 975 945 struct snd_soc_dai *dai) 976 946 { 977 947 struct rz_ssi_priv *ssi = snd_soc_dai_get_drvdata(dai); 978 - struct rz_ssi_stream *strm = rz_ssi_stream_get(ssi, substream); 979 948 unsigned int sample_bits = hw_param_interval(params, 980 949 SNDRV_PCM_HW_PARAM_SAMPLE_BITS)->min; 950 + unsigned int sample_width = params_width(params); 981 951 unsigned int channels = params_channels(params); 982 952 unsigned int rate = params_rate(params); 983 953 int ret; ··· 996 966 997 967 if (rz_ssi_is_stream_running(&ssi->playback) || 998 968 rz_ssi_is_stream_running(&ssi->capture)) { 999 - if (rz_ssi_is_valid_hw_params(ssi, rate, channels, 1000 - strm->sample_width, sample_bits)) 969 + if (rz_ssi_is_valid_hw_params(ssi, rate, channels, sample_width, sample_bits)) 1001 970 return 0; 1002 971 1003 972 dev_err(ssi->dev, "Full duplex needs same HW params\n"); 1004 973 return -EINVAL; 1005 974 } 1006 975 1007 - rz_ssi_cache_hw_params(ssi, rate, channels, strm->sample_width, 1008 - sample_bits); 976 + rz_ssi_cache_hw_params(ssi, rate, channels, sample_width, sample_bits); 1009 977 1010 978 ret = rz_ssi_swreset(ssi); 1011 979 if (ret) ··· 1013 985 } 1014 986 1015 987 static const struct snd_soc_dai_ops rz_ssi_dai_ops = { 988 + .startup = rz_ssi_startup, 989 + .shutdown = rz_ssi_shutdown, 1016 990 .trigger = rz_ssi_dai_trigger, 1017 991 .set_fmt = rz_ssi_dai_set_fmt, 1018 992 .hw_params = rz_ssi_dai_hw_params,
+1 -1
sound/usb/mixer.c
··· 921 921 { 922 922 struct uac_clock_source_descriptor *d = p1; 923 923 924 - term->type = UAC3_CLOCK_SOURCE << 16; /* virtual type */ 924 + term->type = UAC2_CLOCK_SOURCE << 16; /* virtual type */ 925 925 term->id = id; 926 926 term->name = d->iClockSource; 927 927 return 0;
+5
tools/arch/x86/include/asm/cpufeatures.h
··· 444 444 #define X86_FEATURE_VM_PAGE_FLUSH (19*32+ 2) /* VM Page Flush MSR is supported */ 445 445 #define X86_FEATURE_SEV_ES (19*32+ 3) /* "sev_es" Secure Encrypted Virtualization - Encrypted State */ 446 446 #define X86_FEATURE_SEV_SNP (19*32+ 4) /* "sev_snp" Secure Encrypted Virtualization - Secure Nested Paging */ 447 + #define X86_FEATURE_SNP_SECURE_TSC (19*32+ 8) /* SEV-SNP Secure TSC */ 447 448 #define X86_FEATURE_V_TSC_AUX (19*32+ 9) /* Virtual TSC_AUX */ 448 449 #define X86_FEATURE_SME_COHERENT (19*32+10) /* hardware-enforced cache coherency */ 449 450 #define X86_FEATURE_DEBUG_SWAP (19*32+14) /* "debug_swap" SEV-ES full debug state swap support */ ··· 496 495 #define X86_FEATURE_TSA_SQ_NO (21*32+11) /* AMD CPU not vulnerable to TSA-SQ */ 497 496 #define X86_FEATURE_TSA_L1_NO (21*32+12) /* AMD CPU not vulnerable to TSA-L1 */ 498 497 #define X86_FEATURE_CLEAR_CPU_BUF_VM (21*32+13) /* Clear CPU buffers using VERW before VMRUN */ 498 + #define X86_FEATURE_IBPB_EXIT_TO_USER (21*32+14) /* Use IBPB on exit-to-userspace, see VMSCAPE bug */ 499 + #define X86_FEATURE_ABMC (21*32+15) /* Assignable Bandwidth Monitoring Counters */ 500 + #define X86_FEATURE_MSR_IMM (21*32+16) /* MSR immediate form instructions */ 499 501 500 502 /* 501 503 * BUG word(s) ··· 555 551 #define X86_BUG_ITS X86_BUG( 1*32+ 7) /* "its" CPU is affected by Indirect Target Selection */ 556 552 #define X86_BUG_ITS_NATIVE_ONLY X86_BUG( 1*32+ 8) /* "its_native_only" CPU is affected by ITS, VMX is not affected */ 557 553 #define X86_BUG_TSA X86_BUG( 1*32+ 9) /* "tsa" CPU is affected by Transient Scheduler Attacks */ 554 + #define X86_BUG_VMSCAPE X86_BUG( 1*32+10) /* "vmscape" CPU is affected by VMSCAPE attacks from guests */ 558 555 #endif /* _ASM_X86_CPUFEATURES_H */
+19 -1
tools/arch/x86/include/asm/msr-index.h
··· 315 315 #define PERF_CAP_PT_IDX 16 316 316 317 317 #define MSR_PEBS_LD_LAT_THRESHOLD 0x000003f6 318 + 319 + #define PERF_CAP_LBR_FMT 0x3f 318 320 #define PERF_CAP_PEBS_TRAP BIT_ULL(6) 319 321 #define PERF_CAP_ARCH_REG BIT_ULL(7) 320 322 #define PERF_CAP_PEBS_FORMAT 0xf00 323 + #define PERF_CAP_FW_WRITES BIT_ULL(13) 321 324 #define PERF_CAP_PEBS_BASELINE BIT_ULL(14) 322 325 #define PERF_CAP_PEBS_TIMING_INFO BIT_ULL(17) 323 326 #define PERF_CAP_PEBS_MASK (PERF_CAP_PEBS_TRAP | PERF_CAP_ARCH_REG | \ ··· 636 633 #define MSR_AMD_PPIN 0xc00102f1 637 634 #define MSR_AMD64_CPUID_FN_7 0xc0011002 638 635 #define MSR_AMD64_CPUID_FN_1 0xc0011004 636 + 637 + #define MSR_AMD64_CPUID_EXT_FEAT 0xc0011005 638 + #define MSR_AMD64_CPUID_EXT_FEAT_TOPOEXT_BIT 54 639 + #define MSR_AMD64_CPUID_EXT_FEAT_TOPOEXT BIT_ULL(MSR_AMD64_CPUID_EXT_FEAT_TOPOEXT_BIT) 640 + 639 641 #define MSR_AMD64_LS_CFG 0xc0011020 640 642 #define MSR_AMD64_DC_CFG 0xc0011022 641 643 #define MSR_AMD64_TW_CFG 0xc0011023 ··· 709 701 #define MSR_AMD64_SNP_VMSA_REG_PROT BIT_ULL(MSR_AMD64_SNP_VMSA_REG_PROT_BIT) 710 702 #define MSR_AMD64_SNP_SMT_PROT_BIT 17 711 703 #define MSR_AMD64_SNP_SMT_PROT BIT_ULL(MSR_AMD64_SNP_SMT_PROT_BIT) 712 - #define MSR_AMD64_SNP_RESV_BIT 18 704 + #define MSR_AMD64_SNP_SECURE_AVIC_BIT 18 705 + #define MSR_AMD64_SNP_SECURE_AVIC BIT_ULL(MSR_AMD64_SNP_SECURE_AVIC_BIT) 706 + #define MSR_AMD64_SNP_RESV_BIT 19 713 707 #define MSR_AMD64_SNP_RESERVED_MASK GENMASK_ULL(63, MSR_AMD64_SNP_RESV_BIT) 708 + #define MSR_AMD64_SAVIC_CONTROL 0xc0010138 709 + #define MSR_AMD64_SAVIC_EN_BIT 0 710 + #define MSR_AMD64_SAVIC_EN BIT_ULL(MSR_AMD64_SAVIC_EN_BIT) 711 + #define MSR_AMD64_SAVIC_ALLOWEDNMI_BIT 1 712 + #define MSR_AMD64_SAVIC_ALLOWEDNMI BIT_ULL(MSR_AMD64_SAVIC_ALLOWEDNMI_BIT) 714 713 #define MSR_AMD64_RMP_BASE 0xc0010132 715 714 #define MSR_AMD64_RMP_END 0xc0010133 716 715 #define MSR_AMD64_RMP_CFG 0xc0010136 ··· 750 735 #define MSR_AMD64_PERF_CNTR_GLOBAL_STATUS 0xc0000300 751 736 #define MSR_AMD64_PERF_CNTR_GLOBAL_CTL 0xc0000301 752 737 #define MSR_AMD64_PERF_CNTR_GLOBAL_STATUS_CLR 0xc0000302 738 + #define MSR_AMD64_PERF_CNTR_GLOBAL_STATUS_SET 0xc0000303 753 739 754 740 /* AMD Hardware Feedback Support MSRs */ 755 741 #define MSR_AMD_WORKLOAD_CLASS_CONFIG 0xc0000500 ··· 1241 1225 /* - AMD: */ 1242 1226 #define MSR_IA32_MBA_BW_BASE 0xc0000200 1243 1227 #define MSR_IA32_SMBA_BW_BASE 0xc0000280 1228 + #define MSR_IA32_L3_QOS_ABMC_CFG 0xc00003fd 1229 + #define MSR_IA32_L3_QOS_EXT_CFG 0xc00003ff 1244 1230 #define MSR_IA32_EVT_CFG_BASE 0xc0000400 1245 1231 1246 1232 /* AMD-V MSRs */
+34
tools/arch/x86/include/uapi/asm/kvm.h
··· 35 35 #define MC_VECTOR 18 36 36 #define XM_VECTOR 19 37 37 #define VE_VECTOR 20 38 + #define CP_VECTOR 21 39 + 40 + #define HV_VECTOR 28 41 + #define VC_VECTOR 29 42 + #define SX_VECTOR 30 38 43 39 44 /* Select x86 specific features in <linux/kvm.h> */ 40 45 #define __KVM_HAVE_PIT ··· 415 410 struct kvm_xcr xcrs[KVM_MAX_XCRS]; 416 411 __u64 padding[16]; 417 412 }; 413 + 414 + #define KVM_X86_REG_TYPE_MSR 2 415 + #define KVM_X86_REG_TYPE_KVM 3 416 + 417 + #define KVM_X86_KVM_REG_SIZE(reg) \ 418 + ({ \ 419 + reg == KVM_REG_GUEST_SSP ? KVM_REG_SIZE_U64 : 0; \ 420 + }) 421 + 422 + #define KVM_X86_REG_TYPE_SIZE(type, reg) \ 423 + ({ \ 424 + __u64 type_size = (__u64)type << 32; \ 425 + \ 426 + type_size |= type == KVM_X86_REG_TYPE_MSR ? KVM_REG_SIZE_U64 : \ 427 + type == KVM_X86_REG_TYPE_KVM ? KVM_X86_KVM_REG_SIZE(reg) : \ 428 + 0; \ 429 + type_size; \ 430 + }) 431 + 432 + #define KVM_X86_REG_ID(type, index) \ 433 + (KVM_REG_X86 | KVM_X86_REG_TYPE_SIZE(type, index) | index) 434 + 435 + #define KVM_X86_REG_MSR(index) \ 436 + KVM_X86_REG_ID(KVM_X86_REG_TYPE_MSR, index) 437 + #define KVM_X86_REG_KVM(index) \ 438 + KVM_X86_REG_ID(KVM_X86_REG_TYPE_KVM, index) 439 + 440 + /* KVM-defined registers starting from 0 */ 441 + #define KVM_REG_GUEST_SSP 0 418 442 419 443 #define KVM_SYNC_X86_REGS (1UL << 0) 420 444 #define KVM_SYNC_X86_SREGS (1UL << 1)
+4
tools/arch/x86/include/uapi/asm/svm.h
··· 118 118 #define SVM_VMGEXIT_AP_CREATE 1 119 119 #define SVM_VMGEXIT_AP_DESTROY 2 120 120 #define SVM_VMGEXIT_SNP_RUN_VMPL 0x80000018 121 + #define SVM_VMGEXIT_SAVIC 0x8000001a 122 + #define SVM_VMGEXIT_SAVIC_REGISTER_GPA 0 123 + #define SVM_VMGEXIT_SAVIC_UNREGISTER_GPA 1 124 + #define SVM_VMGEXIT_SAVIC_SELF_GPA ~0ULL 121 125 #define SVM_VMGEXIT_HV_FEATURES 0x8000fffd 122 126 #define SVM_VMGEXIT_TERM_REQUEST 0x8000fffe 123 127 #define SVM_VMGEXIT_TERM_REASON(reason_set, reason_code) \
+6 -1
tools/arch/x86/include/uapi/asm/vmx.h
··· 93 93 #define EXIT_REASON_TPAUSE 68 94 94 #define EXIT_REASON_BUS_LOCK 74 95 95 #define EXIT_REASON_NOTIFY 75 96 + #define EXIT_REASON_SEAMCALL 76 96 97 #define EXIT_REASON_TDCALL 77 98 + #define EXIT_REASON_MSR_READ_IMM 84 99 + #define EXIT_REASON_MSR_WRITE_IMM 85 97 100 98 101 #define VMX_EXIT_REASONS \ 99 102 { EXIT_REASON_EXCEPTION_NMI, "EXCEPTION_NMI" }, \ ··· 161 158 { EXIT_REASON_TPAUSE, "TPAUSE" }, \ 162 159 { EXIT_REASON_BUS_LOCK, "BUS_LOCK" }, \ 163 160 { EXIT_REASON_NOTIFY, "NOTIFY" }, \ 164 - { EXIT_REASON_TDCALL, "TDCALL" } 161 + { EXIT_REASON_TDCALL, "TDCALL" }, \ 162 + { EXIT_REASON_MSR_READ_IMM, "MSR_READ_IMM" }, \ 163 + { EXIT_REASON_MSR_WRITE_IMM, "MSR_WRITE_IMM" } 165 164 166 165 #define VMX_EXIT_REASON_FLAGS \ 167 166 { VMX_EXIT_REASONS_FAILED_VMENTRY, "FAILED_VMENTRY" }
+1 -1
tools/bpf/bpftool/Documentation/bpftool-prog.rst
··· 182 182 183 183 bpftool prog tracelog { stdout | stderr } *PROG* 184 184 Dump the BPF stream of the program. BPF programs can write to these streams 185 - at runtime with the **bpf_stream_vprintk**\ () kfunc. The kernel may write 185 + at runtime with the **bpf_stream_vprintk_impl**\ () kfunc. The kernel may write 186 186 error messages to the standard error stream. This facility should be used 187 187 only for debugging purposes. 188 188
+2 -2
tools/build/feature/Makefile
··· 107 107 __BUILD = $(CC) $(CFLAGS) -MD -Wall -Werror -o $@ $(patsubst %.bin,%.c,$(@F)) $(LDFLAGS) 108 108 BUILD = $(__BUILD) > $(@:.bin=.make.output) 2>&1 109 109 BUILD_BFD = $(BUILD) -DPACKAGE='"perf"' -lbfd -ldl 110 - BUILD_ALL = $(BUILD) -fstack-protector-all -O2 -D_FORTIFY_SOURCE=2 -ldw -lelf -lnuma -lelf -lslang $(FLAGS_PERL_EMBED) $(FLAGS_PYTHON_EMBED) -DPACKAGE='"perf"' -lbfd -ldl -lz -llzma -lzstd 110 + BUILD_ALL = $(BUILD) -fstack-protector-all -O2 -D_FORTIFY_SOURCE=2 -ldw -lelf -lnuma -lelf -lslang $(FLAGS_PERL_EMBED) $(FLAGS_PYTHON_EMBED) -ldl -lz -llzma -lzstd 111 111 112 112 __BUILDXX = $(CXX) $(CXXFLAGS) -MD -Wall -Werror -o $@ $(patsubst %.bin,%.cpp,$(@F)) $(LDFLAGS) 113 113 BUILDXX = $(__BUILDXX) > $(@:.bin=.make.output) 2>&1 ··· 115 115 ############################### 116 116 117 117 $(OUTPUT)test-all.bin: 118 - $(BUILD_ALL) || $(BUILD_ALL) -lopcodes -liberty 118 + $(BUILD_ALL) 119 119 120 120 $(OUTPUT)test-hello.bin: 121 121 $(BUILD)
+1 -1
tools/include/asm-generic/bitops/__fls.h
··· 10 10 * 11 11 * Undefined if no set bit exists, so code should check against 0 first. 12 12 */ 13 - static __always_inline unsigned int generic___fls(unsigned long word) 13 + static __always_inline __attribute_const__ unsigned int generic___fls(unsigned long word) 14 14 { 15 15 unsigned int num = BITS_PER_LONG - 1; 16 16
+1 -1
tools/include/asm-generic/bitops/fls.h
··· 10 10 * Note fls(0) = 0, fls(1) = 1, fls(0x80000000) = 32. 11 11 */ 12 12 13 - static __always_inline int generic_fls(unsigned int x) 13 + static __always_inline __attribute_const__ int generic_fls(unsigned int x) 14 14 { 15 15 int r = 32; 16 16
+2 -2
tools/include/asm-generic/bitops/fls64.h
··· 16 16 * at position 64. 17 17 */ 18 18 #if BITS_PER_LONG == 32 19 - static __always_inline int fls64(__u64 x) 19 + static __always_inline __attribute_const__ int fls64(__u64 x) 20 20 { 21 21 __u32 h = x >> 32; 22 22 if (h) ··· 24 24 return fls(x); 25 25 } 26 26 #elif BITS_PER_LONG == 64 27 - static __always_inline int fls64(__u64 x) 27 + static __always_inline __attribute_const__ int fls64(__u64 x) 28 28 { 29 29 if (x == 0) 30 30 return 0;
+51 -12
tools/include/uapi/drm/drm.h
··· 597 597 int drm_dd_minor; 598 598 }; 599 599 600 - /* DRM_IOCTL_GEM_CLOSE ioctl argument type */ 600 + /** 601 + * struct drm_gem_close - Argument for &DRM_IOCTL_GEM_CLOSE ioctl. 602 + * @handle: Handle of the object to be closed. 603 + * @pad: Padding. 604 + * 605 + * Releases the handle to an mm object. 606 + */ 601 607 struct drm_gem_close { 602 - /** Handle of the object to be closed. */ 603 608 __u32 handle; 604 609 __u32 pad; 605 610 }; 606 611 607 - /* DRM_IOCTL_GEM_FLINK ioctl argument type */ 612 + /** 613 + * struct drm_gem_flink - Argument for &DRM_IOCTL_GEM_FLINK ioctl. 614 + * @handle: Handle for the object being named. 615 + * @name: Returned global name. 616 + * 617 + * Create a global name for an object, returning the name. 618 + * 619 + * Note that the name does not hold a reference; when the object 620 + * is freed, the name goes away. 621 + */ 608 622 struct drm_gem_flink { 609 - /** Handle for the object being named */ 610 623 __u32 handle; 611 - 612 - /** Returned global name */ 613 624 __u32 name; 614 625 }; 615 626 616 - /* DRM_IOCTL_GEM_OPEN ioctl argument type */ 627 + /** 628 + * struct drm_gem_open - Argument for &DRM_IOCTL_GEM_OPEN ioctl. 629 + * @name: Name of object being opened. 630 + * @handle: Returned handle for the object. 631 + * @size: Returned size of the object 632 + * 633 + * Open an object using the global name, returning a handle and the size. 634 + * 635 + * This handle (of course) holds a reference to the object, so the object 636 + * will not go away until the handle is deleted. 637 + */ 617 638 struct drm_gem_open { 618 - /** Name of object being opened */ 619 639 __u32 name; 620 - 621 - /** Returned handle for the object */ 622 640 __u32 handle; 623 - 624 - /** Returned size of the object */ 625 641 __u64 size; 642 + }; 643 + 644 + /** 645 + * struct drm_gem_change_handle - Argument for &DRM_IOCTL_GEM_CHANGE_HANDLE ioctl. 646 + * @handle: The handle of a gem object. 647 + * @new_handle: An available gem handle. 648 + * 649 + * This ioctl changes the handle of a GEM object to the specified one. 650 + * The new handle must be unused. On success the old handle is closed 651 + * and all further IOCTL should refer to the new handle only. 652 + * Calls to DRM_IOCTL_PRIME_FD_TO_HANDLE will return the new handle. 653 + */ 654 + struct drm_gem_change_handle { 655 + __u32 handle; 656 + __u32 new_handle; 626 657 }; 627 658 628 659 /** ··· 1339 1308 * The call will fail if the name contains whitespaces or non-printable chars. 1340 1309 */ 1341 1310 #define DRM_IOCTL_SET_CLIENT_NAME DRM_IOWR(0xD1, struct drm_set_client_name) 1311 + 1312 + /** 1313 + * DRM_IOCTL_GEM_CHANGE_HANDLE - Move an object to a different handle 1314 + * 1315 + * Some applications (notably CRIU) need objects to have specific gem handles. 1316 + * This ioctl changes the object at one gem handle to use a new gem handle. 1317 + */ 1318 + #define DRM_IOCTL_GEM_CHANGE_HANDLE DRM_IOWR(0xD2, struct drm_gem_change_handle) 1342 1319 1343 1320 /* 1344 1321 * Device specific ioctls should only be in their respective headers
+3
tools/include/uapi/linux/kvm.h
··· 962 962 #define KVM_CAP_ARM_EL2_E2H0 241 963 963 #define KVM_CAP_RISCV_MP_STATE_RESET 242 964 964 #define KVM_CAP_ARM_CACHEABLE_PFNMAP_SUPPORTED 243 965 + #define KVM_CAP_GUEST_MEMFD_FLAGS 244 965 966 966 967 struct kvm_irq_routing_irqchip { 967 968 __u32 irqchip; ··· 1599 1598 #define KVM_MEMORY_ATTRIBUTE_PRIVATE (1ULL << 3) 1600 1599 1601 1600 #define KVM_CREATE_GUEST_MEMFD _IOWR(KVMIO, 0xd4, struct kvm_create_guest_memfd) 1601 + #define GUEST_MEMFD_FLAG_MMAP (1ULL << 0) 1602 + #define GUEST_MEMFD_FLAG_INIT_SHARED (1ULL << 1) 1602 1603 1603 1604 struct kvm_create_guest_memfd { 1604 1605 __u64 size;
+13 -13
tools/lib/bpf/bpf_helpers.h
··· 315 315 ___param, sizeof(___param)); \ 316 316 }) 317 317 318 - extern int bpf_stream_vprintk(int stream_id, const char *fmt__str, const void *args, 319 - __u32 len__sz, void *aux__prog) __weak __ksym; 318 + extern int bpf_stream_vprintk_impl(int stream_id, const char *fmt__str, const void *args, 319 + __u32 len__sz, void *aux__prog) __weak __ksym; 320 320 321 - #define bpf_stream_printk(stream_id, fmt, args...) \ 322 - ({ \ 323 - static const char ___fmt[] = fmt; \ 324 - unsigned long long ___param[___bpf_narg(args)]; \ 325 - \ 326 - _Pragma("GCC diagnostic push") \ 327 - _Pragma("GCC diagnostic ignored \"-Wint-conversion\"") \ 328 - ___bpf_fill(___param, args); \ 329 - _Pragma("GCC diagnostic pop") \ 330 - \ 331 - bpf_stream_vprintk(stream_id, ___fmt, ___param, sizeof(___param), NULL);\ 321 + #define bpf_stream_printk(stream_id, fmt, args...) \ 322 + ({ \ 323 + static const char ___fmt[] = fmt; \ 324 + unsigned long long ___param[___bpf_narg(args)]; \ 325 + \ 326 + _Pragma("GCC diagnostic push") \ 327 + _Pragma("GCC diagnostic ignored \"-Wint-conversion\"") \ 328 + ___bpf_fill(___param, args); \ 329 + _Pragma("GCC diagnostic pop") \ 330 + \ 331 + bpf_stream_vprintk_impl(stream_id, ___fmt, ___param, sizeof(___param), NULL); \ 332 332 }) 333 333 334 334 /* Use __bpf_printk when bpf_printk call has 3 or fewer fmt args
+12
tools/net/ynl/pyynl/ynl_gen_c.py
··· 861 861 return [f"{member} = {self.c_name};", 862 862 f"{presence} = n_{self.c_name};"] 863 863 864 + def free_needs_iter(self): 865 + return self.sub_type == 'nest' 866 + 867 + def _free_lines(self, ri, var, ref): 868 + lines = [] 869 + if self.sub_type == 'nest': 870 + lines += [ 871 + f"for (i = 0; i < {var}->{ref}_count.{self.c_name}; i++)", 872 + f'{self.nested_render_name}_free(&{var}->{ref}{self.c_name}[i]);', 873 + ] 874 + lines += f"free({var}->{ref}{self.c_name});", 875 + return lines 864 876 865 877 class TypeNestTypeValue(Type): 866 878 def _complex_member_type(self, ri):
+2 -3
tools/perf/Makefile.config
··· 354 354 355 355 FEATURE_CHECK_LDFLAGS-libaio = -lrt 356 356 357 - FEATURE_CHECK_LDFLAGS-disassembler-four-args = -lbfd -lopcodes -ldl 358 - FEATURE_CHECK_LDFLAGS-disassembler-init-styled = -lbfd -lopcodes -ldl 359 - 360 357 CORE_CFLAGS += -fno-omit-frame-pointer 361 358 CORE_CFLAGS += -Wall 362 359 CORE_CFLAGS += -Wextra ··· 927 930 928 931 ifeq ($(feature-libbfd), 1) 929 932 EXTLIBS += -lbfd -lopcodes 933 + FEATURE_CHECK_LDFLAGS-disassembler-four-args = -lbfd -lopcodes -ldl 934 + FEATURE_CHECK_LDFLAGS-disassembler-init-styled = -lbfd -lopcodes -ldl 930 935 else 931 936 # we are on a system that requires -liberty and (maybe) -lz 932 937 # to link against -lbfd; test each case individually here
+1
tools/perf/arch/x86/entry/syscalls/syscall_64.tbl
··· 345 345 333 common io_pgetevents sys_io_pgetevents 346 346 334 common rseq sys_rseq 347 347 335 common uretprobe sys_uretprobe 348 + 336 common uprobe sys_uprobe 348 349 # don't use numbers 387 through 423, add new calls after the last 349 350 # 'common' entry 350 351 424 common pidfd_send_signal sys_pidfd_send_signal
+2
tools/perf/builtin-lock.c
··· 1867 1867 eops.sample = process_sample_event; 1868 1868 eops.comm = perf_event__process_comm; 1869 1869 eops.mmap = perf_event__process_mmap; 1870 + eops.mmap2 = perf_event__process_mmap2; 1870 1871 eops.namespaces = perf_event__process_namespaces; 1871 1872 eops.tracing_data = perf_event__process_tracing_data; 1872 1873 session = perf_session__new(&data, &eops); ··· 2024 2023 eops.sample = process_sample_event; 2025 2024 eops.comm = perf_event__process_comm; 2026 2025 eops.mmap = perf_event__process_mmap; 2026 + eops.mmap2 = perf_event__process_mmap2; 2027 2027 eops.tracing_data = perf_event__process_tracing_data; 2028 2028 2029 2029 perf_env__init(&host_env);
+9 -5
tools/perf/tests/shell/lock_contention.sh
··· 13 13 rm -f ${perfdata} 14 14 rm -f ${result} 15 15 rm -f ${errout} 16 - trap - EXIT TERM INT 16 + trap - EXIT TERM INT ERR 17 17 } 18 18 19 19 trap_cleanup() { 20 + if (( $? == 139 )); then #SIGSEGV 21 + err=1 22 + fi 20 23 echo "Unexpected signal in ${FUNCNAME[1]}" 21 24 cleanup 22 25 exit ${err} 23 26 } 24 - trap trap_cleanup EXIT TERM INT 27 + trap trap_cleanup EXIT TERM INT ERR 25 28 26 29 check() { 27 30 if [ "$(id -u)" != 0 ]; then ··· 148 145 fi 149 146 150 147 # the perf lock contention output goes to the stderr 151 - perf lock con -a -b -g -E 1 -q -- perf bench sched messaging -p > /dev/null 2> ${result} 148 + perf lock con -a -b --lock-cgroup -E 1 -q -- perf bench sched messaging -p > /dev/null 2> ${result} 152 149 if [ "$(cat "${result}" | wc -l)" != "1" ]; then 153 150 echo "[Fail] BPF result count is not 1:" "$(cat "${result}" | wc -l)" 154 151 err=1 ··· 274 271 return 275 272 fi 276 273 277 - perf lock con -a -b -g -E 1 -F wait_total -q -- perf bench sched messaging -p > /dev/null 2> ${result} 274 + perf lock con -a -b --lock-cgroup -E 1 -F wait_total -q -- perf bench sched messaging -p > /dev/null 2> ${result} 278 275 if [ "$(cat "${result}" | wc -l)" != "1" ]; then 279 276 echo "[Fail] BPF result should have a cgroup result:" "$(cat "${result}")" 280 277 err=1 ··· 282 279 fi 283 280 284 281 cgroup=$(cat "${result}" | awk '{ print $3 }') 285 - perf lock con -a -b -g -E 1 -G "${cgroup}" -q -- perf bench sched messaging -p > /dev/null 2> ${result} 282 + perf lock con -a -b --lock-cgroup -E 1 -G "${cgroup}" -q -- perf bench sched messaging -p > /dev/null 2> ${result} 286 283 if [ "$(cat "${result}" | wc -l)" != "1" ]; then 287 284 echo "[Fail] BPF result should have a result with cgroup filter:" "$(cat "${cgroup}")" 288 285 err=1 ··· 341 338 test_cgroup_filter 342 339 test_csv_output 343 340 341 + cleanup 344 342 exit ${err}
+1
tools/perf/trace/beauty/include/uapi/linux/fcntl.h
··· 111 111 #define PIDFD_SELF_THREAD_GROUP -10001 /* Current thread group leader. */ 112 112 113 113 #define FD_PIDFS_ROOT -10002 /* Root of the pidfs filesystem */ 114 + #define FD_NSFS_ROOT -10003 /* Root of the nsfs filesystem */ 114 115 #define FD_INVALID -10009 /* Invalid file descriptor: -10000 - EBADF = -10009 */ 115 116 116 117 /* Generic flags for the *at(2) family of syscalls. */
+4 -1
tools/perf/trace/beauty/include/uapi/linux/fs.h
··· 430 430 /* buffered IO that drops the cache after reading or writing data */ 431 431 #define RWF_DONTCACHE ((__force __kernel_rwf_t)0x00000080) 432 432 433 + /* prevent pipe and socket writes from raising SIGPIPE */ 434 + #define RWF_NOSIGNAL ((__force __kernel_rwf_t)0x00000100) 435 + 433 436 /* mask of flags supported by the kernel */ 434 437 #define RWF_SUPPORTED (RWF_HIPRI | RWF_DSYNC | RWF_SYNC | RWF_NOWAIT |\ 435 438 RWF_APPEND | RWF_NOAPPEND | RWF_ATOMIC |\ 436 - RWF_DONTCACHE) 439 + RWF_DONTCACHE | RWF_NOSIGNAL) 437 440 438 441 #define PROCFS_IOCTL_MAGIC 'f' 439 442
+10
tools/perf/trace/beauty/include/uapi/linux/prctl.h
··· 177 177 178 178 #define PR_GET_TID_ADDRESS 40 179 179 180 + /* 181 + * Flags for PR_SET_THP_DISABLE are only applicable when disabling. Bit 0 182 + * is reserved, so PR_GET_THP_DISABLE can return "1 | flags", to effectively 183 + * return "1" when no flags were specified for PR_SET_THP_DISABLE. 184 + */ 180 185 #define PR_SET_THP_DISABLE 41 186 + /* 187 + * Don't disable THPs when explicitly advised (e.g., MADV_HUGEPAGE / 188 + * VM_HUGEPAGE, MADV_COLLAPSE). 189 + */ 190 + # define PR_THP_DISABLE_EXCEPT_ADVISED (1 << 1) 181 191 #define PR_GET_THP_DISABLE 42 182 192 183 193 /*
+2 -8
tools/perf/util/header.c
··· 1022 1022 1023 1023 down_read(&env->bpf_progs.lock); 1024 1024 1025 - if (env->bpf_progs.infos_cnt == 0) 1026 - goto out; 1027 - 1028 1025 ret = do_write(ff, &env->bpf_progs.infos_cnt, 1029 1026 sizeof(env->bpf_progs.infos_cnt)); 1030 - if (ret < 0) 1027 + if (ret < 0 || env->bpf_progs.infos_cnt == 0) 1031 1028 goto out; 1032 1029 1033 1030 root = &env->bpf_progs.infos; ··· 1064 1067 1065 1068 down_read(&env->bpf_progs.lock); 1066 1069 1067 - if (env->bpf_progs.btfs_cnt == 0) 1068 - goto out; 1069 - 1070 1070 ret = do_write(ff, &env->bpf_progs.btfs_cnt, 1071 1071 sizeof(env->bpf_progs.btfs_cnt)); 1072 1072 1073 - if (ret < 0) 1073 + if (ret < 0 || env->bpf_progs.btfs_cnt == 0) 1074 1074 goto out; 1075 1075 1076 1076 root = &env->bpf_progs.btfs;
+38
tools/perf/util/libbfd.c
··· 38 38 asymbol **syms; 39 39 }; 40 40 41 + static bool perf_bfd_lock(void *bfd_mutex) 42 + { 43 + mutex_lock(bfd_mutex); 44 + return true; 45 + } 46 + 47 + static bool perf_bfd_unlock(void *bfd_mutex) 48 + { 49 + mutex_unlock(bfd_mutex); 50 + return true; 51 + } 52 + 53 + static void perf_bfd_init(void) 54 + { 55 + static struct mutex bfd_mutex; 56 + 57 + mutex_init_recursive(&bfd_mutex); 58 + 59 + if (bfd_init() != BFD_INIT_MAGIC) { 60 + pr_err("Error initializing libbfd\n"); 61 + return; 62 + } 63 + if (!bfd_thread_init(perf_bfd_lock, perf_bfd_unlock, &bfd_mutex)) 64 + pr_err("Error initializing libbfd threading\n"); 65 + } 66 + 67 + static void ensure_bfd_init(void) 68 + { 69 + static pthread_once_t bfd_init_once = PTHREAD_ONCE_INIT; 70 + 71 + pthread_once(&bfd_init_once, perf_bfd_init); 72 + } 73 + 41 74 static int bfd_error(const char *string) 42 75 { 43 76 const char *errmsg; ··· 165 132 bfd *abfd; 166 133 struct a2l_data *a2l = NULL; 167 134 135 + ensure_bfd_init(); 168 136 abfd = bfd_openr(path, NULL); 169 137 if (abfd == NULL) 170 138 return NULL; ··· 322 288 bfd *abfd; 323 289 u64 start, len; 324 290 291 + ensure_bfd_init(); 325 292 abfd = bfd_openr(debugfile, NULL); 326 293 if (!abfd) 327 294 return -1; ··· 428 393 if (fd < 0) 429 394 return -1; 430 395 396 + ensure_bfd_init(); 431 397 abfd = bfd_fdopenr(filename, /*target=*/NULL, fd); 432 398 if (!abfd) 433 399 return -1; ··· 457 421 asection *section; 458 422 bfd *abfd; 459 423 424 + ensure_bfd_init(); 460 425 abfd = bfd_openr(filename, NULL); 461 426 if (!abfd) 462 427 return -1; ··· 517 480 memset(tpath, 0, sizeof(tpath)); 518 481 perf_exe(tpath, sizeof(tpath)); 519 482 483 + ensure_bfd_init(); 520 484 bfdf = bfd_openr(tpath, NULL); 521 485 if (bfdf == NULL) 522 486 abort();
+10 -4
tools/perf/util/mutex.c
··· 17 17 18 18 #define CHECK_ERR(err) check_err(__func__, err) 19 19 20 - static void __mutex_init(struct mutex *mtx, bool pshared) 20 + static void __mutex_init(struct mutex *mtx, bool pshared, bool recursive) 21 21 { 22 22 pthread_mutexattr_t attr; 23 23 ··· 27 27 /* In normal builds enable error checking, such as recursive usage. */ 28 28 CHECK_ERR(pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK)); 29 29 #endif 30 + if (recursive) 31 + CHECK_ERR(pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE)); 30 32 if (pshared) 31 33 CHECK_ERR(pthread_mutexattr_setpshared(&attr, PTHREAD_PROCESS_SHARED)); 32 - 33 34 CHECK_ERR(pthread_mutex_init(&mtx->lock, &attr)); 34 35 CHECK_ERR(pthread_mutexattr_destroy(&attr)); 35 36 } 36 37 37 38 void mutex_init(struct mutex *mtx) 38 39 { 39 - __mutex_init(mtx, /*pshared=*/false); 40 + __mutex_init(mtx, /*pshared=*/false, /*recursive=*/false); 40 41 } 41 42 42 43 void mutex_init_pshared(struct mutex *mtx) 43 44 { 44 - __mutex_init(mtx, /*pshared=*/true); 45 + __mutex_init(mtx, /*pshared=*/true, /*recursive=*/false); 46 + } 47 + 48 + void mutex_init_recursive(struct mutex *mtx) 49 + { 50 + __mutex_init(mtx, /*pshared=*/false, /*recursive=*/true); 45 51 } 46 52 47 53 void mutex_destroy(struct mutex *mtx)
+2
tools/perf/util/mutex.h
··· 104 104 * process-private attribute. 105 105 */ 106 106 void mutex_init_pshared(struct mutex *mtx); 107 + /* Initializes a mutex that may be recursively held on the same thread. */ 108 + void mutex_init_recursive(struct mutex *mtx); 107 109 void mutex_destroy(struct mutex *mtx); 108 110 109 111 void mutex_lock(struct mutex *mtx) EXCLUSIVE_LOCK_FUNCTION(*mtx);
+5 -1
tools/perf/util/symbol.c
··· 112 112 // 'N' first seen in: 113 113 // ffffffff9b35d130 N __pfx__RNCINvNtNtNtCsbDUBuN8AbD4_4core4iter8adapters3map12map_try_foldjNtCs6vVzKs5jPr6_12drm_panic_qr7VersionuINtNtNtBa_3ops12control_flow11ControlFlowB10_ENcB10_0NCINvNvNtNtNtB8_6traits8iterator8Iterator4find5checkB10_NCNvMB12_B10_13from_segments0E0E0B12_ 114 114 // a seemingly Rust mangled name 115 + // Ditto for '1': 116 + // root@x1:~# grep ' 1 ' /proc/kallsyms 117 + // ffffffffb098bc00 1 __pfx__RNCINvNtNtNtCsfwaGRd4cjqE_4core4iter8adapters3map12map_try_foldjNtCskFudTml27HW_12drm_panic_qr7VersionuINtNtNtBa_3ops12control_flow11ControlFlowB10_ENcB10_0NCINvNvNtNtNtB8_6traits8iterator8Iterator4find5checkB10_NCNvMB12_B10_13from_segments0E0E0B12_ 118 + // ffffffffb098bc10 1 _RNCINvNtNtNtCsfwaGRd4cjqE_4core4iter8adapters3map12map_try_foldjNtCskFudTml27HW_12drm_panic_qr7VersionuINtNtNtBa_3ops12control_flow11ControlFlowB10_ENcB10_0NCINvNvNtNtNtB8_6traits8iterator8Iterator4find5checkB10_NCNvMB12_B10_13from_segments0E0E0B12_ 115 119 char symbol_type = toupper(__symbol_type); 116 120 return symbol_type == 'T' || symbol_type == 'W' || symbol_type == 'D' || symbol_type == 'B' || 117 - __symbol_type == 'u' || __symbol_type == 'l' || __symbol_type == 'N'; 121 + __symbol_type == 'u' || __symbol_type == 'l' || __symbol_type == 'N' || __symbol_type == '1'; 118 122 } 119 123 120 124 static int prefix_underscores_count(const char *str)
+3
tools/testing/selftests/bpf/config
··· 50 50 CONFIG_IPV6_TUNNEL=y 51 51 CONFIG_KEYS=y 52 52 CONFIG_LIRC=y 53 + CONFIG_LIVEPATCH=y 53 54 CONFIG_LWTUNNEL=y 54 55 CONFIG_MODULE_SIG=y 55 56 CONFIG_MODULE_SRCVERSION_ALL=y ··· 112 111 CONFIG_NF_NAT=y 113 112 CONFIG_PACKET=y 114 113 CONFIG_RC_CORE=y 114 + CONFIG_SAMPLES=y 115 + CONFIG_SAMPLE_LIVEPATCH=m 115 116 CONFIG_SECURITY=y 116 117 CONFIG_SECURITYFS=y 117 118 CONFIG_SYN_COOKIES=y
+107
tools/testing/selftests/bpf/prog_tests/livepatch_trampoline.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + /* Copyright (c) 2025 Meta Platforms, Inc. and affiliates. */ 3 + 4 + #include <test_progs.h> 5 + #include "testing_helpers.h" 6 + #include "livepatch_trampoline.skel.h" 7 + 8 + static int load_livepatch(void) 9 + { 10 + char path[4096]; 11 + 12 + /* CI will set KBUILD_OUTPUT */ 13 + snprintf(path, sizeof(path), "%s/samples/livepatch/livepatch-sample.ko", 14 + getenv("KBUILD_OUTPUT") ? : "../../../.."); 15 + 16 + return load_module(path, env_verbosity > VERBOSE_NONE); 17 + } 18 + 19 + static void unload_livepatch(void) 20 + { 21 + /* Disable the livepatch before unloading the module */ 22 + system("echo 0 > /sys/kernel/livepatch/livepatch_sample/enabled"); 23 + 24 + unload_module("livepatch_sample", env_verbosity > VERBOSE_NONE); 25 + } 26 + 27 + static void read_proc_cmdline(void) 28 + { 29 + char buf[4096]; 30 + int fd, ret; 31 + 32 + fd = open("/proc/cmdline", O_RDONLY); 33 + if (!ASSERT_OK_FD(fd, "open /proc/cmdline")) 34 + return; 35 + 36 + ret = read(fd, buf, sizeof(buf)); 37 + if (!ASSERT_GT(ret, 0, "read /proc/cmdline")) 38 + goto out; 39 + 40 + ASSERT_OK(strncmp(buf, "this has been live patched", 26), "strncmp"); 41 + 42 + out: 43 + close(fd); 44 + } 45 + 46 + static void __test_livepatch_trampoline(bool fexit_first) 47 + { 48 + struct livepatch_trampoline *skel = NULL; 49 + int err; 50 + 51 + skel = livepatch_trampoline__open_and_load(); 52 + if (!ASSERT_OK_PTR(skel, "skel_open_and_load")) 53 + goto out; 54 + 55 + skel->bss->my_pid = getpid(); 56 + 57 + if (!fexit_first) { 58 + /* fentry program is loaded first by default */ 59 + err = livepatch_trampoline__attach(skel); 60 + if (!ASSERT_OK(err, "skel_attach")) 61 + goto out; 62 + } else { 63 + /* Manually load fexit program first. */ 64 + skel->links.fexit_cmdline = bpf_program__attach(skel->progs.fexit_cmdline); 65 + if (!ASSERT_OK_PTR(skel->links.fexit_cmdline, "attach_fexit")) 66 + goto out; 67 + 68 + skel->links.fentry_cmdline = bpf_program__attach(skel->progs.fentry_cmdline); 69 + if (!ASSERT_OK_PTR(skel->links.fentry_cmdline, "attach_fentry")) 70 + goto out; 71 + } 72 + 73 + read_proc_cmdline(); 74 + 75 + ASSERT_EQ(skel->bss->fentry_hit, 1, "fentry_hit"); 76 + ASSERT_EQ(skel->bss->fexit_hit, 1, "fexit_hit"); 77 + out: 78 + livepatch_trampoline__destroy(skel); 79 + } 80 + 81 + void test_livepatch_trampoline(void) 82 + { 83 + int retry_cnt = 0; 84 + 85 + retry: 86 + if (load_livepatch()) { 87 + if (retry_cnt) { 88 + ASSERT_OK(1, "load_livepatch"); 89 + goto out; 90 + } 91 + /* 92 + * Something else (previous run of the same test?) loaded 93 + * the KLP module. Unload the KLP module and retry. 94 + */ 95 + unload_livepatch(); 96 + retry_cnt++; 97 + goto retry; 98 + } 99 + 100 + if (test__start_subtest("fentry_first")) 101 + __test_livepatch_trampoline(false); 102 + 103 + if (test__start_subtest("fexit_first")) 104 + __test_livepatch_trampoline(true); 105 + out: 106 + unload_livepatch(); 107 + }
+140
tools/testing/selftests/bpf/prog_tests/mptcp.c
··· 6 6 #include <netinet/in.h> 7 7 #include <test_progs.h> 8 8 #include <unistd.h> 9 + #include <errno.h> 9 10 #include "cgroup_helpers.h" 10 11 #include "network_helpers.h" 11 12 #include "mptcp_sock.skel.h" 12 13 #include "mptcpify.skel.h" 13 14 #include "mptcp_subflow.skel.h" 15 + #include "mptcp_sockmap.skel.h" 14 16 15 17 #define NS_TEST "mptcp_ns" 16 18 #define ADDR_1 "10.0.1.1" ··· 438 436 close(cgroup_fd); 439 437 } 440 438 439 + /* Test sockmap on MPTCP server handling non-mp-capable clients. */ 440 + static void test_sockmap_with_mptcp_fallback(struct mptcp_sockmap *skel) 441 + { 442 + int listen_fd = -1, client_fd1 = -1, client_fd2 = -1; 443 + int server_fd1 = -1, server_fd2 = -1, sent, recvd; 444 + char snd[9] = "123456789"; 445 + char rcv[10]; 446 + 447 + /* start server with MPTCP enabled */ 448 + listen_fd = start_mptcp_server(AF_INET, NULL, 0, 0); 449 + if (!ASSERT_OK_FD(listen_fd, "sockmap-fb:start_mptcp_server")) 450 + return; 451 + 452 + skel->bss->trace_port = ntohs(get_socket_local_port(listen_fd)); 453 + skel->bss->sk_index = 0; 454 + /* create client without MPTCP enabled */ 455 + client_fd1 = connect_to_fd_opts(listen_fd, NULL); 456 + if (!ASSERT_OK_FD(client_fd1, "sockmap-fb:connect_to_fd")) 457 + goto end; 458 + 459 + server_fd1 = accept(listen_fd, NULL, 0); 460 + skel->bss->sk_index = 1; 461 + client_fd2 = connect_to_fd_opts(listen_fd, NULL); 462 + if (!ASSERT_OK_FD(client_fd2, "sockmap-fb:connect_to_fd")) 463 + goto end; 464 + 465 + server_fd2 = accept(listen_fd, NULL, 0); 466 + /* test normal redirect behavior: data sent by client_fd1 can be 467 + * received by client_fd2 468 + */ 469 + skel->bss->redirect_idx = 1; 470 + sent = send(client_fd1, snd, sizeof(snd), 0); 471 + if (!ASSERT_EQ(sent, sizeof(snd), "sockmap-fb:send(client_fd1)")) 472 + goto end; 473 + 474 + /* try to recv more bytes to avoid truncation check */ 475 + recvd = recv(client_fd2, rcv, sizeof(rcv), 0); 476 + if (!ASSERT_EQ(recvd, sizeof(snd), "sockmap-fb:recv(client_fd2)")) 477 + goto end; 478 + 479 + end: 480 + if (client_fd1 >= 0) 481 + close(client_fd1); 482 + if (client_fd2 >= 0) 483 + close(client_fd2); 484 + if (server_fd1 >= 0) 485 + close(server_fd1); 486 + if (server_fd2 >= 0) 487 + close(server_fd2); 488 + close(listen_fd); 489 + } 490 + 491 + /* Test sockmap rejection of MPTCP sockets - both server and client sides. */ 492 + static void test_sockmap_reject_mptcp(struct mptcp_sockmap *skel) 493 + { 494 + int listen_fd = -1, server_fd = -1, client_fd1 = -1; 495 + int err, zero = 0; 496 + 497 + /* start server with MPTCP enabled */ 498 + listen_fd = start_mptcp_server(AF_INET, NULL, 0, 0); 499 + if (!ASSERT_OK_FD(listen_fd, "start_mptcp_server")) 500 + return; 501 + 502 + skel->bss->trace_port = ntohs(get_socket_local_port(listen_fd)); 503 + skel->bss->sk_index = 0; 504 + /* create client with MPTCP enabled */ 505 + client_fd1 = connect_to_fd(listen_fd, 0); 506 + if (!ASSERT_OK_FD(client_fd1, "connect_to_fd client_fd1")) 507 + goto end; 508 + 509 + /* bpf_sock_map_update() called from sockops should reject MPTCP sk */ 510 + if (!ASSERT_EQ(skel->bss->helper_ret, -EOPNOTSUPP, "should reject")) 511 + goto end; 512 + 513 + server_fd = accept(listen_fd, NULL, 0); 514 + err = bpf_map_update_elem(bpf_map__fd(skel->maps.sock_map), 515 + &zero, &server_fd, BPF_NOEXIST); 516 + if (!ASSERT_EQ(err, -EOPNOTSUPP, "server should be disallowed")) 517 + goto end; 518 + 519 + /* MPTCP client should also be disallowed */ 520 + err = bpf_map_update_elem(bpf_map__fd(skel->maps.sock_map), 521 + &zero, &client_fd1, BPF_NOEXIST); 522 + if (!ASSERT_EQ(err, -EOPNOTSUPP, "client should be disallowed")) 523 + goto end; 524 + end: 525 + if (client_fd1 >= 0) 526 + close(client_fd1); 527 + if (server_fd >= 0) 528 + close(server_fd); 529 + close(listen_fd); 530 + } 531 + 532 + static void test_mptcp_sockmap(void) 533 + { 534 + struct mptcp_sockmap *skel; 535 + struct netns_obj *netns; 536 + int cgroup_fd, err; 537 + 538 + cgroup_fd = test__join_cgroup("/mptcp_sockmap"); 539 + if (!ASSERT_OK_FD(cgroup_fd, "join_cgroup: mptcp_sockmap")) 540 + return; 541 + 542 + skel = mptcp_sockmap__open_and_load(); 543 + if (!ASSERT_OK_PTR(skel, "skel_open_load: mptcp_sockmap")) 544 + goto close_cgroup; 545 + 546 + skel->links.mptcp_sockmap_inject = 547 + bpf_program__attach_cgroup(skel->progs.mptcp_sockmap_inject, cgroup_fd); 548 + if (!ASSERT_OK_PTR(skel->links.mptcp_sockmap_inject, "attach sockmap")) 549 + goto skel_destroy; 550 + 551 + err = bpf_prog_attach(bpf_program__fd(skel->progs.mptcp_sockmap_redirect), 552 + bpf_map__fd(skel->maps.sock_map), 553 + BPF_SK_SKB_STREAM_VERDICT, 0); 554 + if (!ASSERT_OK(err, "bpf_prog_attach stream verdict")) 555 + goto skel_destroy; 556 + 557 + netns = netns_new(NS_TEST, true); 558 + if (!ASSERT_OK_PTR(netns, "netns_new: mptcp_sockmap")) 559 + goto skel_destroy; 560 + 561 + if (endpoint_init("subflow") < 0) 562 + goto close_netns; 563 + 564 + test_sockmap_with_mptcp_fallback(skel); 565 + test_sockmap_reject_mptcp(skel); 566 + 567 + close_netns: 568 + netns_free(netns); 569 + skel_destroy: 570 + mptcp_sockmap__destroy(skel); 571 + close_cgroup: 572 + close(cgroup_fd); 573 + } 574 + 441 575 void test_mptcp(void) 442 576 { 443 577 if (test__start_subtest("base")) ··· 582 444 test_mptcpify(); 583 445 if (test__start_subtest("subflow")) 584 446 test_subflow(); 447 + if (test__start_subtest("sockmap")) 448 + test_mptcp_sockmap(); 585 449 }
+150
tools/testing/selftests/bpf/prog_tests/stacktrace_ips.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + #include <test_progs.h> 3 + #include "stacktrace_ips.skel.h" 4 + 5 + #ifdef __x86_64__ 6 + static int check_stacktrace_ips(int fd, __u32 key, int cnt, ...) 7 + { 8 + __u64 ips[PERF_MAX_STACK_DEPTH]; 9 + struct ksyms *ksyms = NULL; 10 + int i, err = 0; 11 + va_list args; 12 + 13 + /* sorted by addr */ 14 + ksyms = load_kallsyms_local(); 15 + if (!ASSERT_OK_PTR(ksyms, "load_kallsyms_local")) 16 + return -1; 17 + 18 + /* unlikely, but... */ 19 + if (!ASSERT_LT(cnt, PERF_MAX_STACK_DEPTH, "check_max")) 20 + return -1; 21 + 22 + err = bpf_map_lookup_elem(fd, &key, ips); 23 + if (err) 24 + goto out; 25 + 26 + /* 27 + * Compare all symbols provided via arguments with stacktrace ips, 28 + * and their related symbol addresses.t 29 + */ 30 + va_start(args, cnt); 31 + 32 + for (i = 0; i < cnt; i++) { 33 + unsigned long val; 34 + struct ksym *ksym; 35 + 36 + val = va_arg(args, unsigned long); 37 + ksym = ksym_search_local(ksyms, ips[i]); 38 + if (!ASSERT_OK_PTR(ksym, "ksym_search_local")) 39 + break; 40 + ASSERT_EQ(ksym->addr, val, "stack_cmp"); 41 + } 42 + 43 + va_end(args); 44 + 45 + out: 46 + free_kallsyms_local(ksyms); 47 + return err; 48 + } 49 + 50 + static void test_stacktrace_ips_kprobe_multi(bool retprobe) 51 + { 52 + LIBBPF_OPTS(bpf_kprobe_multi_opts, opts, 53 + .retprobe = retprobe 54 + ); 55 + LIBBPF_OPTS(bpf_test_run_opts, topts); 56 + struct stacktrace_ips *skel; 57 + 58 + skel = stacktrace_ips__open_and_load(); 59 + if (!ASSERT_OK_PTR(skel, "stacktrace_ips__open_and_load")) 60 + return; 61 + 62 + if (!skel->kconfig->CONFIG_UNWINDER_ORC) { 63 + test__skip(); 64 + goto cleanup; 65 + } 66 + 67 + skel->links.kprobe_multi_test = bpf_program__attach_kprobe_multi_opts( 68 + skel->progs.kprobe_multi_test, 69 + "bpf_testmod_stacktrace_test", &opts); 70 + if (!ASSERT_OK_PTR(skel->links.kprobe_multi_test, "bpf_program__attach_kprobe_multi_opts")) 71 + goto cleanup; 72 + 73 + trigger_module_test_read(1); 74 + 75 + load_kallsyms(); 76 + 77 + check_stacktrace_ips(bpf_map__fd(skel->maps.stackmap), skel->bss->stack_key, 4, 78 + ksym_get_addr("bpf_testmod_stacktrace_test_3"), 79 + ksym_get_addr("bpf_testmod_stacktrace_test_2"), 80 + ksym_get_addr("bpf_testmod_stacktrace_test_1"), 81 + ksym_get_addr("bpf_testmod_test_read")); 82 + 83 + cleanup: 84 + stacktrace_ips__destroy(skel); 85 + } 86 + 87 + static void test_stacktrace_ips_raw_tp(void) 88 + { 89 + __u32 info_len = sizeof(struct bpf_prog_info); 90 + LIBBPF_OPTS(bpf_test_run_opts, topts); 91 + struct bpf_prog_info info = {}; 92 + struct stacktrace_ips *skel; 93 + __u64 bpf_prog_ksym = 0; 94 + int err; 95 + 96 + skel = stacktrace_ips__open_and_load(); 97 + if (!ASSERT_OK_PTR(skel, "stacktrace_ips__open_and_load")) 98 + return; 99 + 100 + if (!skel->kconfig->CONFIG_UNWINDER_ORC) { 101 + test__skip(); 102 + goto cleanup; 103 + } 104 + 105 + skel->links.rawtp_test = bpf_program__attach_raw_tracepoint( 106 + skel->progs.rawtp_test, 107 + "bpf_testmod_test_read"); 108 + if (!ASSERT_OK_PTR(skel->links.rawtp_test, "bpf_program__attach_raw_tracepoint")) 109 + goto cleanup; 110 + 111 + /* get bpf program address */ 112 + info.jited_ksyms = ptr_to_u64(&bpf_prog_ksym); 113 + info.nr_jited_ksyms = 1; 114 + err = bpf_prog_get_info_by_fd(bpf_program__fd(skel->progs.rawtp_test), 115 + &info, &info_len); 116 + if (!ASSERT_OK(err, "bpf_prog_get_info_by_fd")) 117 + goto cleanup; 118 + 119 + trigger_module_test_read(1); 120 + 121 + load_kallsyms(); 122 + 123 + check_stacktrace_ips(bpf_map__fd(skel->maps.stackmap), skel->bss->stack_key, 2, 124 + bpf_prog_ksym, 125 + ksym_get_addr("bpf_trace_run2")); 126 + 127 + cleanup: 128 + stacktrace_ips__destroy(skel); 129 + } 130 + 131 + static void __test_stacktrace_ips(void) 132 + { 133 + if (test__start_subtest("kprobe_multi")) 134 + test_stacktrace_ips_kprobe_multi(false); 135 + if (test__start_subtest("kretprobe_multi")) 136 + test_stacktrace_ips_kprobe_multi(true); 137 + if (test__start_subtest("raw_tp")) 138 + test_stacktrace_ips_raw_tp(); 139 + } 140 + #else 141 + static void __test_stacktrace_ips(void) 142 + { 143 + test__skip(); 144 + } 145 + #endif 146 + 147 + void test_stacktrace_ips(void) 148 + { 149 + __test_stacktrace_ips(); 150 + }
+53
tools/testing/selftests/bpf/progs/iters_looping.c
··· 161 161 162 162 return 0; 163 163 } 164 + 165 + __used 166 + static void iterator_with_diff_stack_depth(int x) 167 + { 168 + struct bpf_iter_num iter; 169 + 170 + asm volatile ( 171 + "if r1 == 42 goto 0f;" 172 + "*(u64 *)(r10 - 128) = 0;" 173 + "0:" 174 + /* create iterator */ 175 + "r1 = %[iter];" 176 + "r2 = 0;" 177 + "r3 = 10;" 178 + "call %[bpf_iter_num_new];" 179 + "1:" 180 + /* consume next item */ 181 + "r1 = %[iter];" 182 + "call %[bpf_iter_num_next];" 183 + "if r0 == 0 goto 2f;" 184 + "goto 1b;" 185 + "2:" 186 + /* destroy iterator */ 187 + "r1 = %[iter];" 188 + "call %[bpf_iter_num_destroy];" 189 + : 190 + : __imm_ptr(iter), ITER_HELPERS 191 + : __clobber_common, "r6" 192 + ); 193 + } 194 + 195 + SEC("socket") 196 + __success 197 + __naked int widening_stack_size_bug(void *ctx) 198 + { 199 + /* 200 + * Depending on iterator_with_diff_stack_depth() parameter value, 201 + * subprogram stack depth is either 8 or 128 bytes. Arrange values so 202 + * that it is 128 on a first call and 8 on a second. This triggered a 203 + * bug in verifier's widen_imprecise_scalars() logic. 204 + */ 205 + asm volatile ( 206 + "r6 = 0;" 207 + "r1 = 0;" 208 + "1:" 209 + "call iterator_with_diff_stack_depth;" 210 + "r1 = 42;" 211 + "r6 += 1;" 212 + "if r6 < 2 goto 1b;" 213 + "r0 = 0;" 214 + "exit;" 215 + ::: __clobber_all); 216 + }
+30
tools/testing/selftests/bpf/progs/livepatch_trampoline.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + /* Copyright (c) 2025 Meta Platforms, Inc. and affiliates. */ 3 + 4 + #include <linux/bpf.h> 5 + #include <bpf/bpf_helpers.h> 6 + #include <bpf/bpf_tracing.h> 7 + 8 + int fentry_hit; 9 + int fexit_hit; 10 + int my_pid; 11 + 12 + SEC("fentry/cmdline_proc_show") 13 + int BPF_PROG(fentry_cmdline) 14 + { 15 + if (my_pid != (bpf_get_current_pid_tgid() >> 32)) 16 + return 0; 17 + 18 + fentry_hit = 1; 19 + return 0; 20 + } 21 + 22 + SEC("fexit/cmdline_proc_show") 23 + int BPF_PROG(fexit_cmdline) 24 + { 25 + if (my_pid != (bpf_get_current_pid_tgid() >> 32)) 26 + return 0; 27 + 28 + fexit_hit = 1; 29 + return 0; 30 + }
+43
tools/testing/selftests/bpf/progs/mptcp_sockmap.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + 3 + #include "bpf_tracing_net.h" 4 + 5 + char _license[] SEC("license") = "GPL"; 6 + 7 + int sk_index; 8 + int redirect_idx; 9 + int trace_port; 10 + int helper_ret; 11 + struct { 12 + __uint(type, BPF_MAP_TYPE_SOCKMAP); 13 + __uint(key_size, sizeof(__u32)); 14 + __uint(value_size, sizeof(__u32)); 15 + __uint(max_entries, 100); 16 + } sock_map SEC(".maps"); 17 + 18 + SEC("sockops") 19 + int mptcp_sockmap_inject(struct bpf_sock_ops *skops) 20 + { 21 + struct bpf_sock *sk; 22 + 23 + /* only accept specified connection */ 24 + if (skops->local_port != trace_port || 25 + skops->op != BPF_SOCK_OPS_PASSIVE_ESTABLISHED_CB) 26 + return 1; 27 + 28 + sk = skops->sk; 29 + if (!sk) 30 + return 1; 31 + 32 + /* update sk handler */ 33 + helper_ret = bpf_sock_map_update(skops, &sock_map, &sk_index, BPF_NOEXIST); 34 + 35 + return 1; 36 + } 37 + 38 + SEC("sk_skb/stream_verdict") 39 + int mptcp_sockmap_redirect(struct __sk_buff *skb) 40 + { 41 + /* redirect skb to the sk under sock_map[redirect_idx] */ 42 + return bpf_sk_redirect_map(skb, &sock_map, redirect_idx, 0); 43 + }
+49
tools/testing/selftests/bpf/progs/stacktrace_ips.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + // Copyright (c) 2018 Facebook 3 + 4 + #include <vmlinux.h> 5 + #include <bpf/bpf_helpers.h> 6 + #include <bpf/bpf_tracing.h> 7 + 8 + #ifndef PERF_MAX_STACK_DEPTH 9 + #define PERF_MAX_STACK_DEPTH 127 10 + #endif 11 + 12 + typedef __u64 stack_trace_t[PERF_MAX_STACK_DEPTH]; 13 + 14 + struct { 15 + __uint(type, BPF_MAP_TYPE_STACK_TRACE); 16 + __uint(max_entries, 16384); 17 + __type(key, __u32); 18 + __type(value, stack_trace_t); 19 + } stackmap SEC(".maps"); 20 + 21 + extern bool CONFIG_UNWINDER_ORC __kconfig __weak; 22 + 23 + /* 24 + * This function is here to have CONFIG_UNWINDER_ORC 25 + * used and added to object BTF. 26 + */ 27 + int unused(void) 28 + { 29 + return CONFIG_UNWINDER_ORC ? 0 : 1; 30 + } 31 + 32 + __u32 stack_key; 33 + 34 + SEC("kprobe.multi") 35 + int kprobe_multi_test(struct pt_regs *ctx) 36 + { 37 + stack_key = bpf_get_stackid(ctx, &stackmap, 0); 38 + return 0; 39 + } 40 + 41 + SEC("raw_tp/bpf_testmod_test_read") 42 + int rawtp_test(void *ctx) 43 + { 44 + /* Skip ebpf program entry in the stack. */ 45 + stack_key = bpf_get_stackid(ctx, &stackmap, 0); 46 + return 0; 47 + } 48 + 49 + char _license[] SEC("license") = "GPL";
+3 -3
tools/testing/selftests/bpf/progs/stream_fail.c
··· 10 10 __failure __msg("Possibly NULL pointer passed") 11 11 int stream_vprintk_null_arg(void *ctx) 12 12 { 13 - bpf_stream_vprintk(BPF_STDOUT, "", NULL, 0, NULL); 13 + bpf_stream_vprintk_impl(BPF_STDOUT, "", NULL, 0, NULL); 14 14 return 0; 15 15 } 16 16 ··· 18 18 __failure __msg("R3 type=scalar expected=") 19 19 int stream_vprintk_scalar_arg(void *ctx) 20 20 { 21 - bpf_stream_vprintk(BPF_STDOUT, "", (void *)46, 0, NULL); 21 + bpf_stream_vprintk_impl(BPF_STDOUT, "", (void *)46, 0, NULL); 22 22 return 0; 23 23 } 24 24 ··· 26 26 __failure __msg("arg#1 doesn't point to a const string") 27 27 int stream_vprintk_string_arg(void *ctx) 28 28 { 29 - bpf_stream_vprintk(BPF_STDOUT, ctx, NULL, 0, NULL); 29 + bpf_stream_vprintk_impl(BPF_STDOUT, ctx, NULL, 0, NULL); 30 30 return 0; 31 31 } 32 32
+3 -3
tools/testing/selftests/bpf/progs/task_work.c
··· 66 66 if (!work) 67 67 return 0; 68 68 69 - bpf_task_work_schedule_resume(task, &work->tw, &hmap, process_work, NULL); 69 + bpf_task_work_schedule_resume_impl(task, &work->tw, &hmap, process_work, NULL); 70 70 return 0; 71 71 } 72 72 ··· 80 80 work = bpf_map_lookup_elem(&arrmap, &key); 81 81 if (!work) 82 82 return 0; 83 - bpf_task_work_schedule_signal(task, &work->tw, &arrmap, process_work, NULL); 83 + bpf_task_work_schedule_signal_impl(task, &work->tw, &arrmap, process_work, NULL); 84 84 return 0; 85 85 } 86 86 ··· 102 102 work = bpf_map_lookup_elem(&lrumap, &key); 103 103 if (!work || work->data[0]) 104 104 return 0; 105 - bpf_task_work_schedule_resume(task, &work->tw, &lrumap, process_work, NULL); 105 + bpf_task_work_schedule_resume_impl(task, &work->tw, &lrumap, process_work, NULL); 106 106 return 0; 107 107 }
+4 -4
tools/testing/selftests/bpf/progs/task_work_fail.c
··· 53 53 work = bpf_map_lookup_elem(&arrmap, &key); 54 54 if (!work) 55 55 return 0; 56 - bpf_task_work_schedule_resume(task, &work->tw, &hmap, process_work, NULL); 56 + bpf_task_work_schedule_resume_impl(task, &work->tw, &hmap, process_work, NULL); 57 57 return 0; 58 58 } 59 59 ··· 65 65 struct bpf_task_work tw; 66 66 67 67 task = bpf_get_current_task_btf(); 68 - bpf_task_work_schedule_resume(task, &tw, &hmap, process_work, NULL); 68 + bpf_task_work_schedule_resume_impl(task, &tw, &hmap, process_work, NULL); 69 69 return 0; 70 70 } 71 71 ··· 76 76 struct task_struct *task; 77 77 78 78 task = bpf_get_current_task_btf(); 79 - bpf_task_work_schedule_resume(task, NULL, &hmap, process_work, NULL); 79 + bpf_task_work_schedule_resume_impl(task, NULL, &hmap, process_work, NULL); 80 80 return 0; 81 81 } 82 82 ··· 91 91 work = bpf_map_lookup_elem(&arrmap, &key); 92 92 if (!work) 93 93 return 0; 94 - bpf_task_work_schedule_resume(task, &work->tw, NULL, process_work, NULL); 94 + bpf_task_work_schedule_resume_impl(task, &work->tw, NULL, process_work, NULL); 95 95 return 0; 96 96 }
+2 -2
tools/testing/selftests/bpf/progs/task_work_stress.c
··· 51 51 if (!work) 52 52 return 0; 53 53 } 54 - err = bpf_task_work_schedule_signal(bpf_get_current_task_btf(), &work->tw, &hmap, 55 - process_work, NULL); 54 + err = bpf_task_work_schedule_signal_impl(bpf_get_current_task_btf(), &work->tw, &hmap, 55 + process_work, NULL); 56 56 if (err) 57 57 __sync_fetch_and_add(&schedule_error, 1); 58 58 else
+26
tools/testing/selftests/bpf/test_kmods/bpf_testmod.c
··· 417 417 return a + (long)b + c + d + (long)e + f + g + h + i + j + k; 418 418 } 419 419 420 + noinline void bpf_testmod_stacktrace_test(void) 421 + { 422 + /* used for stacktrace test as attach function */ 423 + asm volatile (""); 424 + } 425 + 426 + noinline void bpf_testmod_stacktrace_test_3(void) 427 + { 428 + bpf_testmod_stacktrace_test(); 429 + asm volatile (""); 430 + } 431 + 432 + noinline void bpf_testmod_stacktrace_test_2(void) 433 + { 434 + bpf_testmod_stacktrace_test_3(); 435 + asm volatile (""); 436 + } 437 + 438 + noinline void bpf_testmod_stacktrace_test_1(void) 439 + { 440 + bpf_testmod_stacktrace_test_2(); 441 + asm volatile (""); 442 + } 443 + 420 444 int bpf_testmod_fentry_ok; 421 445 422 446 noinline ssize_t ··· 520 496 bpf_testmod_fentry_test11(16, (void *)17, 18, 19, (void *)20, 521 497 21, 22, 23, 24, 25, 26) != 231) 522 498 goto out; 499 + 500 + bpf_testmod_stacktrace_test_1(); 523 501 524 502 bpf_testmod_fentry_ok = 1; 525 503 out:
+1
tools/testing/selftests/drivers/net/Makefile
··· 18 18 netcons_fragmented_msg.sh \ 19 19 netcons_overflow.sh \ 20 20 netcons_sysdata.sh \ 21 + netcons_torture.sh \ 21 22 netpoll_basic.py \ 22 23 ping.py \ 23 24 psp.py \
+2
tools/testing/selftests/drivers/net/bonding/Makefile
··· 14 14 dev_addr_lists.sh \ 15 15 mode-1-recovery-updelay.sh \ 16 16 mode-2-recovery-updelay.sh \ 17 + netcons_over_bonding.sh \ 17 18 # end of TEST_PROGS 18 19 19 20 TEST_FILES := \ ··· 25 24 26 25 TEST_INCLUDES := \ 27 26 ../../../net/lib.sh \ 27 + ../lib/sh/lib_netcons.sh \ 28 28 ../../../net/forwarding/lib.sh \ 29 29 # end of TEST_INCLUDES 30 30
+4
tools/testing/selftests/drivers/net/bonding/config
··· 1 1 CONFIG_BONDING=y 2 2 CONFIG_BRIDGE=y 3 + CONFIG_CONFIGFS_FS=y 3 4 CONFIG_DUMMY=y 4 5 CONFIG_INET_ESP=y 5 6 CONFIG_INET_ESP_OFFLOAD=y ··· 10 9 CONFIG_NET_ACT_GACT=y 11 10 CONFIG_NET_CLS_FLOWER=y 12 11 CONFIG_NET_CLS_MATCHALL=m 12 + CONFIG_NETCONSOLE=m 13 + CONFIG_NETCONSOLE_DYNAMIC=y 14 + CONFIG_NETCONSOLE_EXTENDED_LOG=y 13 15 CONFIG_NETDEVSIM=m 14 16 CONFIG_NET_SCH_INGRESS=y 15 17 CONFIG_NLMON=y
+361
tools/testing/selftests/drivers/net/bonding/netcons_over_bonding.sh
··· 1 + #!/usr/bin/env bash 2 + # SPDX-License-Identifier: GPL-2.0 3 + # 4 + # This selftest exercises trying to have multiple netpoll users at the same 5 + # time. 6 + # 7 + # This selftest has multiple smalls test inside, and the goal is to 8 + # get interfaces with bonding and netconsole in different orders in order 9 + # to catch any possible issue. 10 + # 11 + # The main test composes of four interfaces being created using netdevsim; two 12 + # of them are bonded to serve as the netconsole's transmit interface. The 13 + # remaining two interfaces are similarly bonded and assigned to a separate 14 + # network namespace, which acts as the receive interface, where socat monitors 15 + # for incoming messages. 16 + # 17 + # A netconsole message is then sent to ensure it is properly received across 18 + # this configuration. 19 + # 20 + # Later, run a few other tests, to make sure that bonding and netconsole 21 + # cannot coexist. 22 + # 23 + # The test's objective is to exercise netpoll usage when managed simultaneously 24 + # by multiple subsystems (netconsole and bonding). 25 + # 26 + # Author: Breno Leitao <leitao@debian.org> 27 + 28 + set -euo pipefail 29 + 30 + SCRIPTDIR=$(dirname "$(readlink -e "${BASH_SOURCE[0]}")") 31 + 32 + source "${SCRIPTDIR}"/../lib/sh/lib_netcons.sh 33 + 34 + modprobe netdevsim 2> /dev/null || true 35 + modprobe netconsole 2> /dev/null || true 36 + modprobe bonding 2> /dev/null || true 37 + modprobe veth 2> /dev/null || true 38 + 39 + # The content of kmsg will be save to the following file 40 + OUTPUT_FILE="/tmp/${TARGET}" 41 + 42 + # Check for basic system dependency and exit if not found 43 + check_for_dependencies 44 + # Set current loglevel to KERN_INFO(6), and default to KERN_NOTICE(5) 45 + echo "6 5" > /proc/sys/kernel/printk 46 + # Remove the namespace, interfaces and netconsole target on exit 47 + trap cleanup_bond EXIT 48 + 49 + FORMAT="extended" 50 + IP_VERSION="ipv4" 51 + VETH0="veth"$(( RANDOM % 256)) 52 + VETH1="veth"$((256 + RANDOM % 256)) 53 + TXNS="" 54 + RXNS="" 55 + 56 + # Create "bond_tx_XX" and "bond_rx_XX" interfaces, and set DSTIF and SRCIF with 57 + # the bonding interfaces 58 + function setup_bonding_ifaces() { 59 + local RAND=$(( RANDOM % 100 )) 60 + BOND_TX_MAIN_IF="bond_tx_$RAND" 61 + BOND_RX_MAIN_IF="bond_rx_$RAND" 62 + 63 + # Setup TX 64 + if ! ip -n "${TXNS}" link add "${BOND_TX_MAIN_IF}" type bond mode balance-rr 65 + then 66 + echo "Failed to create bond TX interface. Is CONFIG_BONDING set?" >&2 67 + # only clean nsim ifaces and namespace. Nothing else has been 68 + # initialized 69 + cleanup_bond_nsim 70 + trap - EXIT 71 + exit "${ksft_skip}" 72 + fi 73 + 74 + # create_netdevsim() got the interface up, but it needs to be down 75 + # before being enslaved. 76 + ip -n "${TXNS}" \ 77 + link set "${BOND_TX1_SLAVE_IF}" down 78 + ip -n "${TXNS}" \ 79 + link set "${BOND_TX2_SLAVE_IF}" down 80 + ip -n "${TXNS}" \ 81 + link set "${BOND_TX1_SLAVE_IF}" master "${BOND_TX_MAIN_IF}" 82 + ip -n "${TXNS}" \ 83 + link set "${BOND_TX2_SLAVE_IF}" master "${BOND_TX_MAIN_IF}" 84 + ip -n "${TXNS}" \ 85 + link set "${BOND_TX_MAIN_IF}" up 86 + 87 + # Setup RX 88 + ip -n "${RXNS}" \ 89 + link add "${BOND_RX_MAIN_IF}" type bond mode balance-rr 90 + ip -n "${RXNS}" \ 91 + link set "${BOND_RX1_SLAVE_IF}" down 92 + ip -n "${RXNS}" \ 93 + link set "${BOND_RX2_SLAVE_IF}" down 94 + ip -n "${RXNS}" \ 95 + link set "${BOND_RX1_SLAVE_IF}" master "${BOND_RX_MAIN_IF}" 96 + ip -n "${RXNS}" \ 97 + link set "${BOND_RX2_SLAVE_IF}" master "${BOND_RX_MAIN_IF}" 98 + ip -n "${RXNS}" \ 99 + link set "${BOND_RX_MAIN_IF}" up 100 + 101 + export DSTIF="${BOND_RX_MAIN_IF}" 102 + export SRCIF="${BOND_TX_MAIN_IF}" 103 + } 104 + 105 + # Create 4 netdevsim interfaces. Two of them will be bound to TX bonding iface 106 + # and the other two will be bond to the RX interface (on the other namespace) 107 + function create_ifaces_bond() { 108 + BOND_TX1_SLAVE_IF=$(create_netdevsim "${NSIM_BOND_TX_1}" "${TXNS}") 109 + BOND_TX2_SLAVE_IF=$(create_netdevsim "${NSIM_BOND_TX_2}" "${TXNS}") 110 + BOND_RX1_SLAVE_IF=$(create_netdevsim "${NSIM_BOND_RX_1}" "${RXNS}") 111 + BOND_RX2_SLAVE_IF=$(create_netdevsim "${NSIM_BOND_RX_2}" "${RXNS}") 112 + } 113 + 114 + # netdevsim link BOND_TX to BOND_RX interfaces 115 + function link_ifaces_bond() { 116 + local BOND_TX1_SLAVE_IFIDX 117 + local BOND_TX2_SLAVE_IFIDX 118 + local BOND_RX1_SLAVE_IFIDX 119 + local BOND_RX2_SLAVE_IFIDX 120 + local TXNS_FD 121 + local RXNS_FD 122 + 123 + BOND_TX1_SLAVE_IFIDX=$(ip netns exec "${TXNS}" \ 124 + cat /sys/class/net/"$BOND_TX1_SLAVE_IF"/ifindex) 125 + BOND_TX2_SLAVE_IFIDX=$(ip netns exec "${TXNS}" \ 126 + cat /sys/class/net/"$BOND_TX2_SLAVE_IF"/ifindex) 127 + BOND_RX1_SLAVE_IFIDX=$(ip netns exec "${RXNS}" \ 128 + cat /sys/class/net/"$BOND_RX1_SLAVE_IF"/ifindex) 129 + BOND_RX2_SLAVE_IFIDX=$(ip netns exec "${RXNS}" \ 130 + cat /sys/class/net/"$BOND_RX2_SLAVE_IF"/ifindex) 131 + 132 + exec {TXNS_FD}</var/run/netns/"${TXNS}" 133 + exec {RXNS_FD}</var/run/netns/"${RXNS}" 134 + 135 + # Linking TX ifaces to the RX ones (on the other namespace) 136 + echo "${TXNS_FD}:$BOND_TX1_SLAVE_IFIDX $RXNS_FD:$BOND_RX1_SLAVE_IFIDX" \ 137 + > "$NSIM_DEV_SYS_LINK" 138 + echo "${TXNS_FD}:$BOND_TX2_SLAVE_IFIDX $RXNS_FD:$BOND_RX2_SLAVE_IFIDX" \ 139 + > "$NSIM_DEV_SYS_LINK" 140 + 141 + exec {TXNS_FD}<&- 142 + exec {RXNS_FD}<&- 143 + } 144 + 145 + function create_all_ifaces() { 146 + # setup_ns function is coming from lib.sh 147 + setup_ns TXNS RXNS 148 + export NAMESPACE="${RXNS}" 149 + 150 + # Create two interfaces for RX and two for TX 151 + create_ifaces_bond 152 + # Link netlink ifaces 153 + link_ifaces_bond 154 + } 155 + 156 + # configure DSTIF and SRCIF IPs 157 + function configure_ifaces_ips() { 158 + local IP_VERSION=${1:-"ipv4"} 159 + select_ipv4_or_ipv6 "${IP_VERSION}" 160 + 161 + ip -n "${RXNS}" addr add "${DSTIP}"/24 dev "${DSTIF}" 162 + ip -n "${RXNS}" link set "${DSTIF}" up 163 + 164 + ip -n "${TXNS}" addr add "${SRCIP}"/24 dev "${SRCIF}" 165 + ip -n "${TXNS}" link set "${SRCIF}" up 166 + } 167 + 168 + function test_enable_netpoll_on_enslaved_iface() { 169 + echo 0 > "${NETCONS_PATH}"/enabled 170 + 171 + # At this stage, BOND_TX1_SLAVE_IF is enslaved to BOND_TX_MAIN_IF, and 172 + # linked to BOND_RX1_SLAVE_IF inside the namespace. 173 + echo "${BOND_TX1_SLAVE_IF}" > "${NETCONS_PATH}"/dev_name 174 + 175 + # This should fail with the following message in dmesg: 176 + # netpoll: netconsole: ethX is a slave device, aborting 177 + set +e 178 + enable_netcons_ns 2> /dev/null 179 + set -e 180 + 181 + if [[ $(cat "${NETCONS_PATH}"/enabled) -eq 1 ]] 182 + then 183 + echo "test failed: Bonding and netpoll cannot co-exists." >&2 184 + exit "${ksft_fail}" 185 + fi 186 + } 187 + 188 + function test_delete_bond_and_reenable_target() { 189 + ip -n "${TXNS}" \ 190 + link delete "${BOND_TX_MAIN_IF}" type bond 191 + 192 + # BOND_TX1_SLAVE_IF is not attached to a bond interface anymore 193 + # netpoll can be plugged in there 194 + echo "${BOND_TX1_SLAVE_IF}" > "${NETCONS_PATH}"/dev_name 195 + 196 + # this should work, since the interface is not enslaved 197 + enable_netcons_ns 198 + 199 + if [[ $(cat "${NETCONS_PATH}"/enabled) -eq 0 ]] 200 + then 201 + echo "test failed: Unable to start netpoll on an unbond iface." >&2 202 + exit "${ksft_fail}" 203 + fi 204 + } 205 + 206 + # Send a netconsole message to the netconsole target 207 + function test_send_netcons_msg_through_bond_iface() { 208 + # Listen for netconsole port inside the namespace and 209 + # destination interface 210 + listen_port_and_save_to "${OUTPUT_FILE}" "${IP_VERSION}" & 211 + # Wait for socat to start and listen to the port. 212 + wait_for_port "${RXNS}" "${PORT}" "${IP_VERSION}" 213 + # Send the message 214 + echo "${MSG}: ${TARGET}" > /dev/kmsg 215 + # Wait until socat saves the file to disk 216 + busywait "${BUSYWAIT_TIMEOUT}" test -s "${OUTPUT_FILE}" 217 + # Make sure the message was received in the dst part 218 + # and exit 219 + validate_result "${OUTPUT_FILE}" "${FORMAT}" 220 + # kill socat in case it is still running 221 + pkill_socat 222 + } 223 + 224 + # BOND_TX1_SLAVE_IF has netconsole enabled on it, bind it to BOND_TX_MAIN_IF. 225 + # Given BOND_TX_MAIN_IF was deleted, recreate it first 226 + function test_enslave_netcons_enabled_iface { 227 + # netconsole got disabled while the interface was down 228 + if [[ $(cat "${NETCONS_PATH}"/enabled) -eq 0 ]] 229 + then 230 + echo "test failed: netconsole expected to be enabled against BOND_TX1_SLAVE_IF" >&2 231 + exit "${ksft_fail}" 232 + fi 233 + 234 + # recreate the bonding iface. it got deleted by previous 235 + # test (test_delete_bond_and_reenable_target) 236 + ip -n "${TXNS}" \ 237 + link add "${BOND_TX_MAIN_IF}" type bond mode balance-rr 238 + 239 + # sub-interface need to be down before attaching to bonding 240 + # This will also disable netconsole. 241 + ip -n "${TXNS}" \ 242 + link set "${BOND_TX1_SLAVE_IF}" down 243 + ip -n "${TXNS}" \ 244 + link set "${BOND_TX1_SLAVE_IF}" master "${BOND_TX_MAIN_IF}" 245 + ip -n "${TXNS}" \ 246 + link set "${BOND_TX_MAIN_IF}" up 247 + 248 + # netconsole got disabled while the interface was down 249 + if [[ $(cat "${NETCONS_PATH}"/enabled) -eq 1 ]] 250 + then 251 + echo "test failed: Device is part of a bond iface, cannot have netcons enabled" >&2 252 + exit "${ksft_fail}" 253 + fi 254 + } 255 + 256 + # Get netconsole enabled on a bonding interface and attach a second 257 + # sub-interface. 258 + function test_enslave_iface_to_bond { 259 + # BOND_TX_MAIN_IF has only BOND_TX1_SLAVE_IF right now 260 + echo "${BOND_TX_MAIN_IF}" > "${NETCONS_PATH}"/dev_name 261 + enable_netcons_ns 262 + 263 + # netcons is attached to bond0 and BOND_TX1_SLAVE_IF is 264 + # part of BOND_TX_MAIN_IF. Attach BOND_TX2_SLAVE_IF to BOND_TX_MAIN_IF. 265 + ip -n "${TXNS}" \ 266 + link set "${BOND_TX2_SLAVE_IF}" master "${BOND_TX_MAIN_IF}" 267 + if [[ $(cat "${NETCONS_PATH}"/enabled) -eq 0 ]] 268 + then 269 + echo "test failed: Netconsole should be enabled on bonding interface. Failed" >&2 270 + exit "${ksft_fail}" 271 + fi 272 + } 273 + 274 + function test_enslave_iff_disabled_netpoll_iface { 275 + local ret 276 + 277 + # Create two interfaces. veth interfaces it known to have 278 + # IFF_DISABLE_NETPOLL set 279 + if ! ip link add "${VETH0}" type veth peer name "${VETH1}" 280 + then 281 + echo "Failed to create veth TX interface. Is CONFIG_VETH set?" >&2 282 + exit "${ksft_skip}" 283 + fi 284 + set +e 285 + # This will print RTNETLINK answers: Device or resource busy 286 + ip link set "${VETH0}" master "${BOND_TX_MAIN_IF}" 2> /dev/null 287 + ret=$? 288 + set -e 289 + if [[ $ret -eq 0 ]] 290 + then 291 + echo "test failed: veth interface could not be enslaved" 292 + exit "${ksft_fail}" 293 + fi 294 + } 295 + 296 + # Given that netconsole picks the current net namespace, we need to enable it 297 + # from inside the TXNS namespace 298 + function enable_netcons_ns() { 299 + ip netns exec "${TXNS}" sh -c \ 300 + "mount -t configfs configfs /sys/kernel/config && echo 1 > $NETCONS_PATH/enabled" 301 + } 302 + 303 + #################### 304 + # Tests start here # 305 + #################### 306 + 307 + # Create regular interfaces using netdevsim and link them 308 + create_all_ifaces 309 + 310 + # Setup the bonding interfaces 311 + # BOND_RX_MAIN_IF has BOND_RX{1,2}_SLAVE_IF 312 + # BOND_TX_MAIN_IF has BOND_TX{1,2}_SLAVE_IF 313 + setup_bonding_ifaces 314 + 315 + # Configure the ips as BOND_RX1_SLAVE_IF and BOND_TX1_SLAVE_IF 316 + configure_ifaces_ips "${IP_VERSION}" 317 + 318 + _create_dynamic_target "${FORMAT}" "${NETCONS_PATH}" 319 + enable_netcons_ns 320 + set_user_data 321 + 322 + # Test #1 : Create an bonding interface and attach netpoll into 323 + # the bonding interface. Netconsole/netpoll should work on 324 + # the bonding interface. 325 + test_send_netcons_msg_through_bond_iface 326 + echo "test #1: netpoll on bonding interface worked. Test passed" >&2 327 + 328 + # Test #2: Attach netpoll to an enslaved interface 329 + # Try to attach netpoll to an enslaved sub-interface (while still being part of 330 + # a bonding interface), which shouldn't be allowed 331 + test_enable_netpoll_on_enslaved_iface 332 + echo "test #2: netpoll correctly rejected enslaved interface (expected behavior). Test passed." >&2 333 + 334 + # Test #3: Unplug the sub-interface from bond and enable netconsole 335 + # Detach the interface from a bonding interface and attach netpoll again 336 + test_delete_bond_and_reenable_target 337 + echo "test #3: Able to attach to an unbound interface. Test passed." >&2 338 + 339 + # Test #4: Enslave a sub-interface that had netconsole enabled 340 + # Try to enslave an interface that has netconsole/netpoll enabled. 341 + # Previous test has netconsole enabled in BOND_TX1_SLAVE_IF, try to enslave it 342 + test_enslave_netcons_enabled_iface 343 + echo "test #4: Enslaving an interface with netpoll attached. Test passed." >&2 344 + 345 + # Test #5: Enslave a sub-interface to a bonding interface 346 + # Enslave an interface to a bond interface that has netpoll attached 347 + # At this stage, BOND_TX_MAIN_IF is created and BOND_TX1_SLAVE_IF is part of 348 + # it. Netconsole is currently disabled 349 + test_enslave_iface_to_bond 350 + echo "test #5: Enslaving an interface to bond+netpoll. Test passed." >&2 351 + 352 + # Test #6: Enslave a IFF_DISABLE_NETPOLL sub-interface to a bonding interface 353 + # At this stage, BOND_TX_MAIN_IF has both sub interface and netconsole is 354 + # enabled. This test will try to enslave an a veth (IFF_DISABLE_NETPOLL) interface 355 + # and it should fail, with netpoll: veth0 doesn't support polling 356 + test_enslave_iff_disabled_netpoll_iface 357 + echo "test #6: Enslaving IFF_DISABLE_NETPOLL ifaces to bond iface is not supported. Test passed." >&2 358 + 359 + cleanup_bond 360 + trap - EXIT 361 + exit "${EXIT_STATUS}"
+63 -15
tools/testing/selftests/drivers/net/lib/sh/lib_netcons.sh
··· 11 11 LIBDIR=$(dirname "$(readlink -e "${BASH_SOURCE[0]}")") 12 12 13 13 SRCIF="" # to be populated later 14 + SRCIP="" # to be populated later 14 15 SRCIP4="192.0.2.1" 15 16 SRCIP6="fc00::1" 16 17 DSTIF="" # to be populated later 18 + DSTIP="" # to be populated later 17 19 DSTIP4="192.0.2.2" 18 20 DSTIP6="fc00::2" 19 21 ··· 30 28 # NAMESPACE will be populated by setup_ns with a random value 31 29 NAMESPACE="" 32 30 33 - # IDs for netdevsim 31 + # IDs for netdevsim. We either use NSIM_DEV_{1,2}_ID for standard test 32 + # or NSIM_BOND_{T,R}X_{1,2} for the bonding tests. Not both at the 33 + # same time. 34 34 NSIM_DEV_1_ID=$((256 + RANDOM % 256)) 35 35 NSIM_DEV_2_ID=$((512 + RANDOM % 256)) 36 + NSIM_BOND_TX_1=$((768 + RANDOM % 256)) 37 + NSIM_BOND_TX_2=$((1024 + RANDOM % 256)) 38 + NSIM_BOND_RX_1=$((1280 + RANDOM % 256)) 39 + NSIM_BOND_RX_2=$((1536 + RANDOM % 256)) 36 40 NSIM_DEV_SYS_NEW="/sys/bus/netdevsim/new_device" 41 + NSIM_DEV_SYS_LINK="/sys/bus/netdevsim/link_device" 37 42 38 43 # Used to create and delete namespaces 39 44 source "${LIBDIR}"/../../../../net/lib.sh 40 45 41 46 # Create netdevsim interfaces 42 47 create_ifaces() { 43 - 44 48 echo "$NSIM_DEV_2_ID" > "$NSIM_DEV_SYS_NEW" 45 49 echo "$NSIM_DEV_1_ID" > "$NSIM_DEV_SYS_NEW" 46 50 udevadm settle 2> /dev/null || true ··· 121 113 configure_ip 122 114 } 123 115 124 - function create_dynamic_target() { 125 - local FORMAT=${1:-"extended"} 116 + function _create_dynamic_target() { 117 + local FORMAT="${1:?FORMAT parameter required}" 118 + local NCPATH="${2:?NCPATH parameter required}" 126 119 127 120 DSTMAC=$(ip netns exec "${NAMESPACE}" \ 128 121 ip link show "${DSTIF}" | awk '/ether/ {print $2}') 129 122 130 123 # Create a dynamic target 131 - mkdir "${NETCONS_PATH}" 124 + mkdir "${NCPATH}" 132 125 133 - echo "${DSTIP}" > "${NETCONS_PATH}"/remote_ip 134 - echo "${SRCIP}" > "${NETCONS_PATH}"/local_ip 135 - echo "${DSTMAC}" > "${NETCONS_PATH}"/remote_mac 136 - echo "${SRCIF}" > "${NETCONS_PATH}"/dev_name 126 + echo "${DSTIP}" > "${NCPATH}"/remote_ip 127 + echo "${SRCIP}" > "${NCPATH}"/local_ip 128 + echo "${DSTMAC}" > "${NCPATH}"/remote_mac 129 + echo "${SRCIF}" > "${NCPATH}"/dev_name 137 130 138 131 if [ "${FORMAT}" == "basic" ] 139 132 then 140 133 # Basic target does not support release 141 - echo 0 > "${NETCONS_PATH}"/release 142 - echo 0 > "${NETCONS_PATH}"/extended 134 + echo 0 > "${NCPATH}"/release 135 + echo 0 > "${NCPATH}"/extended 143 136 elif [ "${FORMAT}" == "extended" ] 144 137 then 145 - echo 1 > "${NETCONS_PATH}"/extended 138 + echo 1 > "${NCPATH}"/extended 146 139 fi 140 + } 147 141 148 - echo 1 > "${NETCONS_PATH}"/enabled 142 + function create_dynamic_target() { 143 + local FORMAT=${1:-"extended"} 144 + local NCPATH=${2:-"$NETCONS_PATH"} 145 + _create_dynamic_target "${FORMAT}" "${NCPATH}" 146 + 147 + echo 1 > "${NCPATH}"/enabled 149 148 150 149 # This will make sure that the kernel was able to 151 150 # load the netconsole driver configuration. The console message ··· 200 185 echo "${DEFAULT_PRINTK_VALUES}" > /proc/sys/kernel/printk 201 186 } 202 187 203 - function cleanup() { 188 + function cleanup_netcons() { 204 189 # delete netconsole dynamic reconfiguration 205 - echo 0 > "${NETCONS_PATH}"/enabled 190 + # do not fail if the target is already disabled 191 + if [[ ! -d "${NETCONS_PATH}" ]] 192 + then 193 + # in some cases this is called before netcons path is created 194 + return 195 + fi 196 + if [[ $(cat "${NETCONS_PATH}"/enabled) != 0 ]] 197 + then 198 + echo 0 > "${NETCONS_PATH}"/enabled || true 199 + fi 206 200 # Remove all the keys that got created during the selftest 207 201 find "${NETCONS_PATH}/userdata/" -mindepth 1 -type d -delete 208 202 # Remove the configfs entry 209 203 rmdir "${NETCONS_PATH}" 204 + } 210 205 206 + function cleanup() { 207 + cleanup_netcons 211 208 do_cleanup 212 209 } 213 210 ··· 395 368 # otherwise the packet could be missed, and the test will fail. Happens 396 369 # more frequently on IPv6 397 370 sleep 1 371 + } 372 + 373 + # Clean up netdevsim ifaces created for bonding test 374 + function cleanup_bond_nsim() { 375 + ip -n "${TXNS}" \ 376 + link delete "${BOND_TX_MAIN_IF}" type bond || true 377 + ip -n "${RXNS}" \ 378 + link delete "${BOND_RX_MAIN_IF}" type bond || true 379 + 380 + cleanup_netdevsim "$NSIM_BOND_TX_1" 381 + cleanup_netdevsim "$NSIM_BOND_TX_2" 382 + cleanup_netdevsim "$NSIM_BOND_RX_1" 383 + cleanup_netdevsim "$NSIM_BOND_RX_2" 384 + } 385 + 386 + # cleanup tests that use bonding interfaces 387 + function cleanup_bond() { 388 + cleanup_netcons 389 + cleanup_bond_nsim 390 + cleanup_all_ns 391 + ip link delete "${VETH0}" || true 398 392 }
+130
tools/testing/selftests/drivers/net/netcons_torture.sh
··· 1 + #!/usr/bin/env bash 2 + # SPDX-License-Identifier: GPL-2.0 3 + 4 + # Repeatedly send kernel messages, toggles netconsole targets on and off, 5 + # creates and deletes targets in parallel, and toggles the source interface to 6 + # simulate stress conditions. 7 + # 8 + # This test aims to verify the robustness of netconsole under dynamic 9 + # configurations and concurrent operations. 10 + # 11 + # The major goal is to run this test with LOCKDEP, Kmemleak and KASAN to make 12 + # sure no issues is reported. 13 + # 14 + # Author: Breno Leitao <leitao@debian.org> 15 + 16 + set -euo pipefail 17 + 18 + SCRIPTDIR=$(dirname "$(readlink -e "${BASH_SOURCE[0]}")") 19 + 20 + source "${SCRIPTDIR}"/lib/sh/lib_netcons.sh 21 + 22 + # Number of times the main loop run 23 + ITERATIONS=${1:-150} 24 + 25 + # Only test extended format 26 + FORMAT="extended" 27 + # And ipv6 only 28 + IP_VERSION="ipv6" 29 + 30 + # Create, enable and delete some targets. 31 + create_and_delete_random_target() { 32 + COUNT=2 33 + RND_PREFIX=$(mktemp -u netcons_rnd_XXXX_) 34 + 35 + if [ -d "${NETCONS_CONFIGFS}/${RND_PREFIX}${COUNT}" ] || \ 36 + [ -d "${NETCONS_CONFIGFS}/${RND_PREFIX}0" ]; then 37 + echo "Function didn't finish yet, skipping it." >&2 38 + return 39 + fi 40 + 41 + # enable COUNT targets 42 + for i in $(seq ${COUNT}) 43 + do 44 + RND_TARGET="${RND_PREFIX}"${i} 45 + RND_TARGET_PATH="${NETCONS_CONFIGFS}"/"${RND_TARGET}" 46 + 47 + # Basic population so the target can come up 48 + _create_dynamic_target "${FORMAT}" "${RND_TARGET_PATH}" 49 + done 50 + 51 + echo "netconsole selftest: ${COUNT} additional targets were created" > /dev/kmsg 52 + # disable them all 53 + for i in $(seq ${COUNT}) 54 + do 55 + RND_TARGET="${RND_PREFIX}"${i} 56 + RND_TARGET_PATH="${NETCONS_CONFIGFS}"/"${RND_TARGET}" 57 + if [[ $(cat "${RND_TARGET_PATH}/enabled") -eq 1 ]] 58 + then 59 + echo 0 > "${RND_TARGET_PATH}"/enabled 60 + fi 61 + rmdir "${RND_TARGET_PATH}" 62 + done 63 + } 64 + 65 + # Disable and enable the target mid-air, while messages 66 + # are being transmitted. 67 + toggle_netcons_target() { 68 + for i in $(seq 2) 69 + do 70 + if [ ! -d "${NETCONS_PATH}" ] 71 + then 72 + break 73 + fi 74 + echo 0 > "${NETCONS_PATH}"/enabled 2> /dev/null || true 75 + # Try to enable a bit harder, given it might fail to enable 76 + # Write to `enabled` might fail depending on the lock, which is 77 + # highly contentious here 78 + for _ in $(seq 5) 79 + do 80 + echo 1 > "${NETCONS_PATH}"/enabled 2> /dev/null || true 81 + done 82 + done 83 + } 84 + 85 + toggle_iface(){ 86 + ip link set "${SRCIF}" down 87 + ip link set "${SRCIF}" up 88 + } 89 + 90 + # Start here 91 + 92 + modprobe netdevsim 2> /dev/null || true 93 + modprobe netconsole 2> /dev/null || true 94 + 95 + # Check for basic system dependency and exit if not found 96 + check_for_dependencies 97 + # Set current loglevel to KERN_INFO(6), and default to KERN_NOTICE(5) 98 + echo "6 5" > /proc/sys/kernel/printk 99 + # Remove the namespace, interfaces and netconsole target on exit 100 + trap cleanup EXIT 101 + # Create one namespace and two interfaces 102 + set_network "${IP_VERSION}" 103 + # Create a dynamic target for netconsole 104 + create_dynamic_target "${FORMAT}" 105 + 106 + for i in $(seq "$ITERATIONS") 107 + do 108 + for _ in $(seq 10) 109 + do 110 + echo "${MSG}: ${TARGET} ${i}" > /dev/kmsg 111 + done 112 + wait 113 + 114 + if (( i % 30 == 0 )); then 115 + toggle_netcons_target & 116 + fi 117 + 118 + if (( i % 50 == 0 )); then 119 + # create some targets, enable them, send msg and disable 120 + # all in a parallel thread 121 + create_and_delete_random_target & 122 + fi 123 + 124 + if (( i % 70 == 0 )); then 125 + toggle_iface & 126 + fi 127 + done 128 + wait 129 + 130 + exit "${EXIT_STATUS}"
+4
tools/testing/selftests/drivers/net/netdevsim/Makefile
··· 20 20 udp_tunnel_nic.sh \ 21 21 # end of TEST_PROGS 22 22 23 + TEST_FILES := \ 24 + ethtool-common.sh 25 + # end of TEST_FILES 26 + 23 27 include ../../../lib.mk
+4
tools/testing/selftests/ftrace/test.d/filter/event-filter-function.tc
··· 20 20 echo 0 > tracing_on 21 21 echo 0 > events/enable 22 22 23 + # Clear functions caused by page cache; run sample_events twice 24 + sample_events 25 + sample_events 26 + 23 27 echo "Get the most frequently calling function" 24 28 echo > trace 25 29 sample_events
+2
tools/testing/selftests/iommu/iommufd.c
··· 2638 2638 ASSERT_EQ(0, ioctl(self->fd, VFIO_IOMMU_MAP_DMA, &map_cmd)); 2639 2639 ASSERT_EQ(0, ioctl(self->fd, VFIO_IOMMU_UNMAP_DMA, &unmap_cmd)); 2640 2640 ASSERT_EQ(BUFFER_SIZE, unmap_cmd.size); 2641 + /* Unmap of empty is success */ 2642 + ASSERT_EQ(0, ioctl(self->fd, VFIO_IOMMU_UNMAP_DMA, &unmap_cmd)); 2641 2643 2642 2644 /* UNMAP_FLAG_ALL requires 0 iova/size */ 2643 2645 ASSERT_EQ(0, ioctl(self->fd, VFIO_IOMMU_MAP_DMA, &map_cmd));
+2 -2
tools/testing/selftests/iommu/iommufd_utils.h
··· 1044 1044 }; 1045 1045 1046 1046 while (nvevents--) { 1047 - if (!ioctl(fd, _IOMMU_TEST_CMD(IOMMU_TEST_OP_TRIGGER_VEVENT), 1048 - &trigger_vevent_cmd)) 1047 + if (ioctl(fd, _IOMMU_TEST_CMD(IOMMU_TEST_OP_TRIGGER_VEVENT), 1048 + &trigger_vevent_cmd)) 1049 1049 return -1; 1050 1050 } 1051 1051 return 0;
+3
tools/testing/selftests/kvm/arm64/get-reg-list.c
··· 63 63 REG_FEAT(HDFGWTR2_EL2, ID_AA64MMFR0_EL1, FGT, FGT2), 64 64 REG_FEAT(ZCR_EL2, ID_AA64PFR0_EL1, SVE, IMP), 65 65 REG_FEAT(SCTLR2_EL1, ID_AA64MMFR3_EL1, SCTLRX, IMP), 66 + REG_FEAT(SCTLR2_EL2, ID_AA64MMFR3_EL1, SCTLRX, IMP), 66 67 REG_FEAT(VDISR_EL2, ID_AA64PFR0_EL1, RAS, IMP), 67 68 REG_FEAT(VSESR_EL2, ID_AA64PFR0_EL1, RAS, IMP), 68 69 REG_FEAT(VNCR_EL2, ID_AA64MMFR4_EL1, NV_frac, NV2_ONLY), 69 70 REG_FEAT(CNTHV_CTL_EL2, ID_AA64MMFR1_EL1, VH, IMP), 70 71 REG_FEAT(CNTHV_CVAL_EL2,ID_AA64MMFR1_EL1, VH, IMP), 72 + REG_FEAT(ZCR_EL2, ID_AA64PFR0_EL1, SVE, IMP), 71 73 }; 72 74 73 75 bool filter_reg(__u64 reg) ··· 720 718 SYS_REG(VMPIDR_EL2), 721 719 SYS_REG(SCTLR_EL2), 722 720 SYS_REG(ACTLR_EL2), 721 + SYS_REG(SCTLR2_EL2), 723 722 SYS_REG(HCR_EL2), 724 723 SYS_REG(MDCR_EL2), 725 724 SYS_REG(CPTR_EL2),
+8 -1
tools/testing/selftests/kvm/lib/arm64/gic_v3_its.c
··· 15 15 #include "gic_v3.h" 16 16 #include "processor.h" 17 17 18 + #define GITS_COLLECTION_TARGET_SHIFT 16 19 + 18 20 static u64 its_read_u64(unsigned long offset) 19 21 { 20 22 return readq_relaxed(GITS_BASE_GVA + offset); ··· 165 163 its_mask_encode(&cmd->raw_cmd[2], col, 15, 0); 166 164 } 167 165 166 + static u64 procnum_to_rdbase(u32 vcpu_id) 167 + { 168 + return vcpu_id << GITS_COLLECTION_TARGET_SHIFT; 169 + } 170 + 168 171 #define GITS_CMDQ_POLL_ITERATIONS 0 169 172 170 173 static void its_send_cmd(void *cmdq_base, struct its_cmd_block *cmd) ··· 224 217 225 218 its_encode_cmd(&cmd, GITS_CMD_MAPC); 226 219 its_encode_collection(&cmd, collection_id); 227 - its_encode_target(&cmd, vcpu_id); 220 + its_encode_target(&cmd, procnum_to_rdbase(vcpu_id)); 228 221 its_encode_valid(&cmd, valid); 229 222 230 223 its_send_cmd(cmdq_base, &cmd);
+2
tools/testing/selftests/net/forwarding/local_termination.sh
··· 176 176 local rcv_dmac=$(mac_get $rcv_if_name) 177 177 local should_receive 178 178 179 + setup_wait 180 + 179 181 tcpdump_start $rcv_if_name 180 182 181 183 mc_route_prepare $send_if_name
+10 -2
tools/testing/selftests/net/gro.c
··· 754 754 static char exthdr_pck[sizeof(buf) + MIN_EXTHDR_SIZE]; 755 755 756 756 create_packet(buf, 0, 0, PAYLOAD_LEN, 0); 757 - add_ipv6_exthdr(buf, exthdr_pck, IPPROTO_HOPOPTS, ext_data1); 757 + add_ipv6_exthdr(buf, exthdr_pck, IPPROTO_DSTOPTS, ext_data1); 758 758 write_packet(fd, exthdr_pck, total_hdr_len + PAYLOAD_LEN + MIN_EXTHDR_SIZE, daddr); 759 759 760 760 create_packet(buf, PAYLOAD_LEN * 1, 0, PAYLOAD_LEN, 0); 761 - add_ipv6_exthdr(buf, exthdr_pck, IPPROTO_HOPOPTS, ext_data2); 761 + add_ipv6_exthdr(buf, exthdr_pck, IPPROTO_DSTOPTS, ext_data2); 762 762 write_packet(fd, exthdr_pck, total_hdr_len + PAYLOAD_LEN + MIN_EXTHDR_SIZE, daddr); 763 763 } 764 764 ··· 989 989 990 990 static void gro_sender(void) 991 991 { 992 + const int fin_delay_us = 100 * 1000; 992 993 static char fin_pkt[MAX_HDR_LEN]; 993 994 struct sockaddr_ll daddr = {}; 994 995 int txfd = -1; ··· 1033 1032 write_packet(txfd, fin_pkt, total_hdr_len, &daddr); 1034 1033 } else if (strcmp(testname, "tcp") == 0) { 1035 1034 send_changed_checksum(txfd, &daddr); 1035 + /* Adding sleep before sending FIN so that it is not 1036 + * received prior to other packets. 1037 + */ 1038 + usleep(fin_delay_us); 1036 1039 write_packet(txfd, fin_pkt, total_hdr_len, &daddr); 1037 1040 1038 1041 send_changed_seq(txfd, &daddr); 1042 + usleep(fin_delay_us); 1039 1043 write_packet(txfd, fin_pkt, total_hdr_len, &daddr); 1040 1044 1041 1045 send_changed_ts(txfd, &daddr); 1046 + usleep(fin_delay_us); 1042 1047 write_packet(txfd, fin_pkt, total_hdr_len, &daddr); 1043 1048 1044 1049 send_diff_opt(txfd, &daddr); 1050 + usleep(fin_delay_us); 1045 1051 write_packet(txfd, fin_pkt, total_hdr_len, &daddr); 1046 1052 } else if (strcmp(testname, "ip") == 0) { 1047 1053 send_changed_ECN(txfd, &daddr);
+13 -5
tools/testing/selftests/net/mptcp/mptcp_connect.c
··· 710 710 711 711 bw = do_rnd_write(peerfd, winfo->buf + winfo->off, winfo->len); 712 712 if (bw < 0) { 713 - if (cfg_rcv_trunc) 714 - return 0; 713 + /* expected reset, continue to read */ 714 + if (cfg_rcv_trunc && 715 + (errno == ECONNRESET || 716 + errno == EPIPE)) { 717 + fds.events &= ~POLLOUT; 718 + continue; 719 + } 720 + 715 721 perror("write"); 716 722 return 111; 717 723 } ··· 743 737 } 744 738 745 739 if (fds.revents & (POLLERR | POLLNVAL)) { 746 - if (cfg_rcv_trunc) 747 - return 0; 740 + if (cfg_rcv_trunc) { 741 + fds.events &= ~(POLLERR | POLLNVAL); 742 + continue; 743 + } 748 744 fprintf(stderr, "Unexpected revents: " 749 745 "POLLERR/POLLNVAL(%x)\n", fds.revents); 750 746 return 5; ··· 1441 1433 */ 1442 1434 if (cfg_truncate < 0) { 1443 1435 cfg_rcv_trunc = true; 1444 - signal(SIGPIPE, handle_signal); 1436 + signal(SIGPIPE, SIG_IGN); 1445 1437 } 1446 1438 break; 1447 1439 case 'j':
+1 -1
tools/testing/selftests/net/mptcp/mptcp_connect.sh
··· 492 492 "than expected (${expect_synrx})" 493 493 retc=1 494 494 fi 495 - if [ ${stat_ackrx_now_l} -lt ${expect_ackrx} ] && [ ${stat_ooo_now} -eq 0 ]; then 495 + if [ ${stat_ackrx_now_l} -lt ${expect_ackrx} ]; then 496 496 if [ ${stat_ooo_now} -eq 0 ]; then 497 497 mptcp_lib_pr_fail "lower MPC ACK rx (${stat_ackrx_now_l})" \ 498 498 "than expected (${expect_ackrx})"
+45 -45
tools/testing/selftests/net/mptcp/mptcp_join.sh
··· 2532 2532 if reset "remove single subflow"; then 2533 2533 pm_nl_set_limits $ns1 0 1 2534 2534 pm_nl_set_limits $ns2 0 1 2535 - pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 2535 + pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow,backup 2536 2536 addr_nr_ns2=-1 speed=slow \ 2537 2537 run_tests $ns1 $ns2 10.0.1.1 2538 2538 chk_join_nr 1 1 1 ··· 2545 2545 if reset "remove multiple subflows"; then 2546 2546 pm_nl_set_limits $ns1 0 2 2547 2547 pm_nl_set_limits $ns2 0 2 2548 - pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow 2549 - pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 2548 + pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow,backup 2549 + pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow,backup 2550 2550 addr_nr_ns2=-2 speed=slow \ 2551 2551 run_tests $ns1 $ns2 10.0.1.1 2552 2552 chk_join_nr 2 2 2 ··· 2557 2557 # single address, remove 2558 2558 if reset "remove single address"; then 2559 2559 pm_nl_set_limits $ns1 0 1 2560 - pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 2560 + pm_nl_add_endpoint $ns1 10.0.2.1 flags signal,backup 2561 2561 pm_nl_set_limits $ns2 1 1 2562 2562 addr_nr_ns1=-1 speed=slow \ 2563 2563 run_tests $ns1 $ns2 10.0.1.1 ··· 2570 2570 # subflow and signal, remove 2571 2571 if reset "remove subflow and signal"; then 2572 2572 pm_nl_set_limits $ns1 0 2 2573 - pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 2573 + pm_nl_add_endpoint $ns1 10.0.2.1 flags signal,backup 2574 2574 pm_nl_set_limits $ns2 1 2 2575 - pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 2575 + pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow,backup 2576 2576 addr_nr_ns1=-1 addr_nr_ns2=-1 speed=slow \ 2577 2577 run_tests $ns1 $ns2 10.0.1.1 2578 2578 chk_join_nr 2 2 2 ··· 2584 2584 # subflows and signal, remove 2585 2585 if reset "remove subflows and signal"; then 2586 2586 pm_nl_set_limits $ns1 0 3 2587 - pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 2587 + pm_nl_add_endpoint $ns1 10.0.2.1 flags signal,backup 2588 2588 pm_nl_set_limits $ns2 1 3 2589 - pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 2590 - pm_nl_add_endpoint $ns2 10.0.4.2 flags subflow 2589 + pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow,backup 2590 + pm_nl_add_endpoint $ns2 10.0.4.2 flags subflow,backup 2591 2591 addr_nr_ns1=-1 addr_nr_ns2=-2 speed=10 \ 2592 2592 run_tests $ns1 $ns2 10.0.1.1 2593 2593 chk_join_nr 3 3 3 ··· 2599 2599 # addresses remove 2600 2600 if reset "remove addresses"; then 2601 2601 pm_nl_set_limits $ns1 3 3 2602 - pm_nl_add_endpoint $ns1 10.0.2.1 flags signal id 250 2603 - pm_nl_add_endpoint $ns1 10.0.3.1 flags signal 2604 - pm_nl_add_endpoint $ns1 10.0.4.1 flags signal 2602 + pm_nl_add_endpoint $ns1 10.0.2.1 flags signal,backup id 250 2603 + pm_nl_add_endpoint $ns1 10.0.3.1 flags signal,backup 2604 + pm_nl_add_endpoint $ns1 10.0.4.1 flags signal,backup 2605 2605 pm_nl_set_limits $ns2 3 3 2606 2606 addr_nr_ns1=-3 speed=10 \ 2607 2607 run_tests $ns1 $ns2 10.0.1.1 ··· 2614 2614 # invalid addresses remove 2615 2615 if reset "remove invalid addresses"; then 2616 2616 pm_nl_set_limits $ns1 3 3 2617 - pm_nl_add_endpoint $ns1 10.0.12.1 flags signal 2617 + pm_nl_add_endpoint $ns1 10.0.12.1 flags signal,backup 2618 2618 # broadcast IP: no packet for this address will be received on ns1 2619 - pm_nl_add_endpoint $ns1 224.0.0.1 flags signal 2620 - pm_nl_add_endpoint $ns1 10.0.3.1 flags signal 2619 + pm_nl_add_endpoint $ns1 224.0.0.1 flags signal,backup 2620 + pm_nl_add_endpoint $ns1 10.0.3.1 flags signal,backup 2621 2621 pm_nl_set_limits $ns2 2 2 2622 2622 addr_nr_ns1=-3 speed=10 \ 2623 2623 run_tests $ns1 $ns2 10.0.1.1 ··· 2631 2631 # subflows and signal, flush 2632 2632 if reset "flush subflows and signal"; then 2633 2633 pm_nl_set_limits $ns1 0 3 2634 - pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 2634 + pm_nl_add_endpoint $ns1 10.0.2.1 flags signal,backup 2635 2635 pm_nl_set_limits $ns2 1 3 2636 - pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 2637 - pm_nl_add_endpoint $ns2 10.0.4.2 flags subflow 2636 + pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow,backup 2637 + pm_nl_add_endpoint $ns2 10.0.4.2 flags subflow,backup 2638 2638 addr_nr_ns1=-8 addr_nr_ns2=-8 speed=slow \ 2639 2639 run_tests $ns1 $ns2 10.0.1.1 2640 2640 chk_join_nr 3 3 3 ··· 2647 2647 if reset "flush subflows"; then 2648 2648 pm_nl_set_limits $ns1 3 3 2649 2649 pm_nl_set_limits $ns2 3 3 2650 - pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow id 150 2651 - pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 2652 - pm_nl_add_endpoint $ns2 10.0.4.2 flags subflow 2650 + pm_nl_add_endpoint $ns2 10.0.2.2 flags subflow,backup id 150 2651 + pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow,backup 2652 + pm_nl_add_endpoint $ns2 10.0.4.2 flags subflow,backup 2653 2653 addr_nr_ns1=-8 addr_nr_ns2=-8 speed=slow \ 2654 2654 run_tests $ns1 $ns2 10.0.1.1 2655 2655 chk_join_nr 3 3 3 ··· 2666 2666 # addresses flush 2667 2667 if reset "flush addresses"; then 2668 2668 pm_nl_set_limits $ns1 3 3 2669 - pm_nl_add_endpoint $ns1 10.0.2.1 flags signal id 250 2670 - pm_nl_add_endpoint $ns1 10.0.3.1 flags signal 2671 - pm_nl_add_endpoint $ns1 10.0.4.1 flags signal 2669 + pm_nl_add_endpoint $ns1 10.0.2.1 flags signal,backup id 250 2670 + pm_nl_add_endpoint $ns1 10.0.3.1 flags signal,backup 2671 + pm_nl_add_endpoint $ns1 10.0.4.1 flags signal,backup 2672 2672 pm_nl_set_limits $ns2 3 3 2673 2673 addr_nr_ns1=-8 addr_nr_ns2=-8 speed=slow \ 2674 2674 run_tests $ns1 $ns2 10.0.1.1 ··· 2681 2681 # invalid addresses flush 2682 2682 if reset "flush invalid addresses"; then 2683 2683 pm_nl_set_limits $ns1 3 3 2684 - pm_nl_add_endpoint $ns1 10.0.12.1 flags signal 2685 - pm_nl_add_endpoint $ns1 10.0.3.1 flags signal 2686 - pm_nl_add_endpoint $ns1 10.0.14.1 flags signal 2684 + pm_nl_add_endpoint $ns1 10.0.12.1 flags signal,backup 2685 + pm_nl_add_endpoint $ns1 10.0.3.1 flags signal,backup 2686 + pm_nl_add_endpoint $ns1 10.0.14.1 flags signal,backup 2687 2687 pm_nl_set_limits $ns2 3 3 2688 2688 addr_nr_ns1=-8 speed=slow \ 2689 2689 run_tests $ns1 $ns2 10.0.1.1 ··· 3806 3806 continue_if mptcp_lib_has_file '/proc/sys/net/mptcp/pm_type'; then 3807 3807 set_userspace_pm $ns1 3808 3808 pm_nl_set_limits $ns2 2 2 3809 - { speed=5 \ 3809 + { test_linkfail=128 speed=5 \ 3810 3810 run_tests $ns1 $ns2 10.0.1.1 & } 2>/dev/null 3811 3811 local tests_pid=$! 3812 3812 wait_mpj $ns1 ··· 3831 3831 chk_mptcp_info subflows 0 subflows 0 3832 3832 chk_subflows_total 1 1 3833 3833 kill_events_pids 3834 - mptcp_lib_kill_wait $tests_pid 3834 + mptcp_lib_kill_group_wait $tests_pid 3835 3835 fi 3836 3836 3837 3837 # userspace pm create destroy subflow ··· 3839 3839 continue_if mptcp_lib_has_file '/proc/sys/net/mptcp/pm_type'; then 3840 3840 set_userspace_pm $ns2 3841 3841 pm_nl_set_limits $ns1 0 1 3842 - { speed=5 \ 3842 + { test_linkfail=128 speed=5 \ 3843 3843 run_tests $ns1 $ns2 10.0.1.1 & } 2>/dev/null 3844 3844 local tests_pid=$! 3845 3845 wait_mpj $ns2 ··· 3859 3859 chk_mptcp_info subflows 0 subflows 0 3860 3860 chk_subflows_total 1 1 3861 3861 kill_events_pids 3862 - mptcp_lib_kill_wait $tests_pid 3862 + mptcp_lib_kill_group_wait $tests_pid 3863 3863 fi 3864 3864 3865 3865 # userspace pm create id 0 subflow ··· 3867 3867 continue_if mptcp_lib_has_file '/proc/sys/net/mptcp/pm_type'; then 3868 3868 set_userspace_pm $ns2 3869 3869 pm_nl_set_limits $ns1 0 1 3870 - { speed=5 \ 3870 + { test_linkfail=128 speed=5 \ 3871 3871 run_tests $ns1 $ns2 10.0.1.1 & } 2>/dev/null 3872 3872 local tests_pid=$! 3873 3873 wait_mpj $ns2 ··· 3880 3880 chk_mptcp_info subflows 1 subflows 1 3881 3881 chk_subflows_total 2 2 3882 3882 kill_events_pids 3883 - mptcp_lib_kill_wait $tests_pid 3883 + mptcp_lib_kill_group_wait $tests_pid 3884 3884 fi 3885 3885 3886 3886 # userspace pm remove initial subflow ··· 3888 3888 continue_if mptcp_lib_has_file '/proc/sys/net/mptcp/pm_type'; then 3889 3889 set_userspace_pm $ns2 3890 3890 pm_nl_set_limits $ns1 0 1 3891 - { speed=5 \ 3891 + { test_linkfail=128 speed=5 \ 3892 3892 run_tests $ns1 $ns2 10.0.1.1 & } 2>/dev/null 3893 3893 local tests_pid=$! 3894 3894 wait_mpj $ns2 ··· 3904 3904 chk_mptcp_info subflows 1 subflows 1 3905 3905 chk_subflows_total 1 1 3906 3906 kill_events_pids 3907 - mptcp_lib_kill_wait $tests_pid 3907 + mptcp_lib_kill_group_wait $tests_pid 3908 3908 fi 3909 3909 3910 3910 # userspace pm send RM_ADDR for ID 0 ··· 3912 3912 continue_if mptcp_lib_has_file '/proc/sys/net/mptcp/pm_type'; then 3913 3913 set_userspace_pm $ns1 3914 3914 pm_nl_set_limits $ns2 1 1 3915 - { speed=5 \ 3915 + { test_linkfail=128 speed=5 \ 3916 3916 run_tests $ns1 $ns2 10.0.1.1 & } 2>/dev/null 3917 3917 local tests_pid=$! 3918 3918 wait_mpj $ns1 ··· 3930 3930 chk_mptcp_info subflows 1 subflows 1 3931 3931 chk_subflows_total 1 1 3932 3932 kill_events_pids 3933 - mptcp_lib_kill_wait $tests_pid 3933 + mptcp_lib_kill_group_wait $tests_pid 3934 3934 fi 3935 3935 } 3936 3936 ··· 3943 3943 pm_nl_set_limits $ns1 2 2 3944 3944 pm_nl_set_limits $ns2 2 2 3945 3945 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 3946 - { speed=slow \ 3946 + { test_linkfail=128 speed=slow \ 3947 3947 run_tests $ns1 $ns2 10.0.1.1 & } 2>/dev/null 3948 3948 local tests_pid=$! 3949 3949 ··· 3960 3960 pm_nl_add_endpoint $ns2 10.0.2.2 flags signal 3961 3961 pm_nl_check_endpoint "modif is allowed" \ 3962 3962 $ns2 10.0.2.2 id 1 flags signal 3963 - mptcp_lib_kill_wait $tests_pid 3963 + mptcp_lib_kill_group_wait $tests_pid 3964 3964 fi 3965 3965 3966 3966 if reset_with_tcp_filter "delete and re-add" ns2 10.0.3.2 REJECT OUTPUT && ··· 3970 3970 pm_nl_set_limits $ns2 0 3 3971 3971 pm_nl_add_endpoint $ns2 10.0.1.2 id 1 dev ns2eth1 flags subflow 3972 3972 pm_nl_add_endpoint $ns2 10.0.2.2 id 2 dev ns2eth2 flags subflow 3973 - { test_linkfail=4 speed=5 \ 3973 + { test_linkfail=128 speed=5 \ 3974 3974 run_tests $ns1 $ns2 10.0.1.1 & } 2>/dev/null 3975 3975 local tests_pid=$! 3976 3976 ··· 4015 4015 chk_mptcp_info subflows 3 subflows 3 4016 4016 done 4017 4017 4018 - mptcp_lib_kill_wait $tests_pid 4018 + mptcp_lib_kill_group_wait $tests_pid 4019 4019 4020 4020 kill_events_pids 4021 4021 chk_evt_nr ns1 MPTCP_LIB_EVENT_LISTENER_CREATED 1 ··· 4048 4048 # broadcast IP: no packet for this address will be received on ns1 4049 4049 pm_nl_add_endpoint $ns1 224.0.0.1 id 2 flags signal 4050 4050 pm_nl_add_endpoint $ns1 10.0.1.1 id 42 flags signal 4051 - { test_linkfail=4 speed=5 \ 4051 + { test_linkfail=128 speed=5 \ 4052 4052 run_tests $ns1 $ns2 10.0.1.1 & } 2>/dev/null 4053 4053 local tests_pid=$! 4054 4054 ··· 4089 4089 wait_mpj $ns2 4090 4090 chk_subflow_nr "after re-re-add ID 0" 3 4091 4091 chk_mptcp_info subflows 3 subflows 3 4092 - mptcp_lib_kill_wait $tests_pid 4092 + mptcp_lib_kill_group_wait $tests_pid 4093 4093 4094 4094 kill_events_pids 4095 4095 chk_evt_nr ns1 MPTCP_LIB_EVENT_LISTENER_CREATED 1 ··· 4121 4121 # broadcast IP: no packet for this address will be received on ns1 4122 4122 pm_nl_add_endpoint $ns1 224.0.0.1 id 2 flags signal 4123 4123 pm_nl_add_endpoint $ns2 10.0.3.2 id 3 flags subflow 4124 - { test_linkfail=4 speed=20 \ 4124 + { test_linkfail=128 speed=20 \ 4125 4125 run_tests $ns1 $ns2 10.0.1.1 & } 2>/dev/null 4126 4126 local tests_pid=$! 4127 4127 ··· 4137 4137 wait_mpj $ns2 4138 4138 pm_nl_add_endpoint $ns1 10.0.3.1 id 2 flags signal 4139 4139 wait_mpj $ns2 4140 - mptcp_lib_kill_wait $tests_pid 4140 + mptcp_lib_kill_group_wait $tests_pid 4141 4141 4142 4142 join_syn_tx=3 join_connect_err=1 \ 4143 4143 chk_join_nr 2 2 2
+21
tools/testing/selftests/net/mptcp/mptcp_lib.sh
··· 350 350 wait "${1}" 2>/dev/null 351 351 } 352 352 353 + # $1: PID 354 + mptcp_lib_pid_list_children() { 355 + local curr="${1}" 356 + # evoke 'ps' only once 357 + local pids="${2:-"$(ps o pid,ppid)"}" 358 + 359 + echo "${curr}" 360 + 361 + local pid 362 + for pid in $(echo "${pids}" | awk "\$2 == ${curr} { print \$1 }"); do 363 + mptcp_lib_pid_list_children "${pid}" "${pids}" 364 + done 365 + } 366 + 367 + # $1: PID 368 + mptcp_lib_kill_group_wait() { 369 + # Some users might not have procps-ng: cannot use "kill -- -PID" 370 + mptcp_lib_pid_list_children "${1}" | xargs -r kill &>/dev/null 371 + wait "${1}" 2>/dev/null 372 + } 373 + 353 374 # $1: IP address 354 375 mptcp_lib_is_v6() { 355 376 [ -z "${1##*:*}" ]
+44
tools/testing/selftests/tc-testing/tc-tests/infra/qdiscs.json
··· 961 961 "teardown": [ 962 962 "$TC qdisc del dev $DUMMY root" 963 963 ] 964 + }, 965 + { 966 + "id": "4989", 967 + "name": "Try to add an fq child to an ingress qdisc", 968 + "category": [ 969 + "qdisc", 970 + "ingress" 971 + ], 972 + "plugins": { 973 + "requires": "nsPlugin" 974 + }, 975 + "setup": [ 976 + "$TC qdisc add dev $DUMMY handle ffff:0 ingress" 977 + ], 978 + "cmdUnderTest": "$TC qdisc add dev $DUMMY parent ffff:0 handle ffe0:0 fq", 979 + "expExitCode": "2", 980 + "verifyCmd": "$TC -j qdisc ls dev $DUMMY handle ffe0:", 981 + "matchJSON": [], 982 + "matchCount": "1", 983 + "teardown": [ 984 + "$TC qdisc del dev $DUMMY ingress" 985 + ] 986 + }, 987 + { 988 + "id": "c2b0", 989 + "name": "Try to add an fq child to a clsact qdisc", 990 + "category": [ 991 + "qdisc", 992 + "ingress" 993 + ], 994 + "plugins": { 995 + "requires": "nsPlugin" 996 + }, 997 + "setup": [ 998 + "$TC qdisc add dev $DUMMY handle ffff:0 clsact" 999 + ], 1000 + "cmdUnderTest": "$TC qdisc add dev $DUMMY parent ffff:0 handle ffe0:0 fq", 1001 + "expExitCode": "2", 1002 + "verifyCmd": "$TC -j qdisc ls dev $DUMMY handle ffe0:", 1003 + "matchJSON": [], 1004 + "matchCount": "1", 1005 + "teardown": [ 1006 + "$TC qdisc del dev $DUMMY clsact" 1007 + ] 964 1008 } 965 1009 ]
+1 -1
tools/testing/selftests/user_events/perf_test.c
··· 236 236 ASSERT_EQ(1 << reg.enable_bit, self->check); 237 237 238 238 /* Ensure write shows up at correct offset */ 239 - ASSERT_NE(-1, write(self->data_fd, &reg.write_index, 239 + ASSERT_NE(-1, write(self->data_fd, (void *)&reg.write_index, 240 240 sizeof(reg.write_index))); 241 241 val = (void *)(((char *)perf_page) + perf_page->data_offset); 242 242 ASSERT_EQ(PERF_RECORD_SAMPLE, *val);
+18 -1
tools/testing/selftests/vfio/lib/include/vfio_util.h
··· 4 4 5 5 #include <fcntl.h> 6 6 #include <string.h> 7 - #include <linux/vfio.h> 7 + 8 + #include <uapi/linux/types.h> 9 + #include <linux/iommufd.h> 8 10 #include <linux/list.h> 9 11 #include <linux/pci_regs.h> 12 + #include <linux/vfio.h> 10 13 11 14 #include "../../../kselftest.h" 12 15 ··· 188 185 struct vfio_pci_driver driver; 189 186 }; 190 187 188 + struct iova_allocator { 189 + struct iommu_iova_range *ranges; 190 + u32 nranges; 191 + u32 range_idx; 192 + u64 range_offset; 193 + }; 194 + 191 195 /* 192 196 * Return the BDF string of the device that the test should use. 193 197 * ··· 215 205 struct vfio_pci_device *vfio_pci_device_init(const char *bdf, const char *iommu_mode); 216 206 void vfio_pci_device_cleanup(struct vfio_pci_device *device); 217 207 void vfio_pci_device_reset(struct vfio_pci_device *device); 208 + 209 + struct iommu_iova_range *vfio_pci_iova_ranges(struct vfio_pci_device *device, 210 + u32 *nranges); 211 + 212 + struct iova_allocator *iova_allocator_init(struct vfio_pci_device *device); 213 + void iova_allocator_cleanup(struct iova_allocator *allocator); 214 + iova_t iova_allocator_alloc(struct iova_allocator *allocator, size_t size); 218 215 219 216 int __vfio_pci_dma_map(struct vfio_pci_device *device, 220 217 struct vfio_dma_region *region);
+245 -1
tools/testing/selftests/vfio/lib/vfio_pci_device.c
··· 12 12 #include <sys/mman.h> 13 13 14 14 #include <uapi/linux/types.h> 15 + #include <linux/iommufd.h> 15 16 #include <linux/limits.h> 16 17 #include <linux/mman.h> 18 + #include <linux/overflow.h> 17 19 #include <linux/types.h> 18 20 #include <linux/vfio.h> 19 - #include <linux/iommufd.h> 20 21 21 22 #include "../../../kselftest.h" 22 23 #include <vfio_util.h> ··· 29 28 int __ret = ioctl((_fd), (_op), (__arg)); \ 30 29 VFIO_ASSERT_EQ(__ret, 0, "ioctl(%s, %s, %s) returned %d\n", #_fd, #_op, #_arg, __ret); \ 31 30 } while (0) 31 + 32 + static struct vfio_info_cap_header *next_cap_hdr(void *buf, u32 bufsz, 33 + u32 *cap_offset) 34 + { 35 + struct vfio_info_cap_header *hdr; 36 + 37 + if (!*cap_offset) 38 + return NULL; 39 + 40 + VFIO_ASSERT_LT(*cap_offset, bufsz); 41 + VFIO_ASSERT_GE(bufsz - *cap_offset, sizeof(*hdr)); 42 + 43 + hdr = (struct vfio_info_cap_header *)((u8 *)buf + *cap_offset); 44 + *cap_offset = hdr->next; 45 + 46 + return hdr; 47 + } 48 + 49 + static struct vfio_info_cap_header *vfio_iommu_info_cap_hdr(struct vfio_iommu_type1_info *info, 50 + u16 cap_id) 51 + { 52 + struct vfio_info_cap_header *hdr; 53 + u32 cap_offset = info->cap_offset; 54 + u32 max_depth; 55 + u32 depth = 0; 56 + 57 + if (!(info->flags & VFIO_IOMMU_INFO_CAPS)) 58 + return NULL; 59 + 60 + if (cap_offset) 61 + VFIO_ASSERT_GE(cap_offset, sizeof(*info)); 62 + 63 + max_depth = (info->argsz - sizeof(*info)) / sizeof(*hdr); 64 + 65 + while ((hdr = next_cap_hdr(info, info->argsz, &cap_offset))) { 66 + depth++; 67 + VFIO_ASSERT_LE(depth, max_depth, "Capability chain contains a cycle\n"); 68 + 69 + if (hdr->id == cap_id) 70 + return hdr; 71 + } 72 + 73 + return NULL; 74 + } 75 + 76 + /* Return buffer including capability chain, if present. Free with free() */ 77 + static struct vfio_iommu_type1_info *vfio_iommu_get_info(struct vfio_pci_device *device) 78 + { 79 + struct vfio_iommu_type1_info *info; 80 + 81 + info = malloc(sizeof(*info)); 82 + VFIO_ASSERT_NOT_NULL(info); 83 + 84 + *info = (struct vfio_iommu_type1_info) { 85 + .argsz = sizeof(*info), 86 + }; 87 + 88 + ioctl_assert(device->container_fd, VFIO_IOMMU_GET_INFO, info); 89 + VFIO_ASSERT_GE(info->argsz, sizeof(*info)); 90 + 91 + info = realloc(info, info->argsz); 92 + VFIO_ASSERT_NOT_NULL(info); 93 + 94 + ioctl_assert(device->container_fd, VFIO_IOMMU_GET_INFO, info); 95 + VFIO_ASSERT_GE(info->argsz, sizeof(*info)); 96 + 97 + return info; 98 + } 99 + 100 + /* 101 + * Return iova ranges for the device's container. Normalize vfio_iommu_type1 to 102 + * report iommufd's iommu_iova_range. Free with free(). 103 + */ 104 + static struct iommu_iova_range *vfio_iommu_iova_ranges(struct vfio_pci_device *device, 105 + u32 *nranges) 106 + { 107 + struct vfio_iommu_type1_info_cap_iova_range *cap_range; 108 + struct vfio_iommu_type1_info *info; 109 + struct vfio_info_cap_header *hdr; 110 + struct iommu_iova_range *ranges = NULL; 111 + 112 + info = vfio_iommu_get_info(device); 113 + hdr = vfio_iommu_info_cap_hdr(info, VFIO_IOMMU_TYPE1_INFO_CAP_IOVA_RANGE); 114 + VFIO_ASSERT_NOT_NULL(hdr); 115 + 116 + cap_range = container_of(hdr, struct vfio_iommu_type1_info_cap_iova_range, header); 117 + VFIO_ASSERT_GT(cap_range->nr_iovas, 0); 118 + 119 + ranges = calloc(cap_range->nr_iovas, sizeof(*ranges)); 120 + VFIO_ASSERT_NOT_NULL(ranges); 121 + 122 + for (u32 i = 0; i < cap_range->nr_iovas; i++) { 123 + ranges[i] = (struct iommu_iova_range){ 124 + .start = cap_range->iova_ranges[i].start, 125 + .last = cap_range->iova_ranges[i].end, 126 + }; 127 + } 128 + 129 + *nranges = cap_range->nr_iovas; 130 + 131 + free(info); 132 + return ranges; 133 + } 134 + 135 + /* Return iova ranges of the device's IOAS. Free with free() */ 136 + static struct iommu_iova_range *iommufd_iova_ranges(struct vfio_pci_device *device, 137 + u32 *nranges) 138 + { 139 + struct iommu_iova_range *ranges; 140 + int ret; 141 + 142 + struct iommu_ioas_iova_ranges query = { 143 + .size = sizeof(query), 144 + .ioas_id = device->ioas_id, 145 + }; 146 + 147 + ret = ioctl(device->iommufd, IOMMU_IOAS_IOVA_RANGES, &query); 148 + VFIO_ASSERT_EQ(ret, -1); 149 + VFIO_ASSERT_EQ(errno, EMSGSIZE); 150 + VFIO_ASSERT_GT(query.num_iovas, 0); 151 + 152 + ranges = calloc(query.num_iovas, sizeof(*ranges)); 153 + VFIO_ASSERT_NOT_NULL(ranges); 154 + 155 + query.allowed_iovas = (uintptr_t)ranges; 156 + 157 + ioctl_assert(device->iommufd, IOMMU_IOAS_IOVA_RANGES, &query); 158 + *nranges = query.num_iovas; 159 + 160 + return ranges; 161 + } 162 + 163 + static int iova_range_comp(const void *a, const void *b) 164 + { 165 + const struct iommu_iova_range *ra = a, *rb = b; 166 + 167 + if (ra->start < rb->start) 168 + return -1; 169 + 170 + if (ra->start > rb->start) 171 + return 1; 172 + 173 + return 0; 174 + } 175 + 176 + /* Return sorted IOVA ranges of the device. Free with free(). */ 177 + struct iommu_iova_range *vfio_pci_iova_ranges(struct vfio_pci_device *device, 178 + u32 *nranges) 179 + { 180 + struct iommu_iova_range *ranges; 181 + 182 + if (device->iommufd) 183 + ranges = iommufd_iova_ranges(device, nranges); 184 + else 185 + ranges = vfio_iommu_iova_ranges(device, nranges); 186 + 187 + if (!ranges) 188 + return NULL; 189 + 190 + VFIO_ASSERT_GT(*nranges, 0); 191 + 192 + /* Sort and check that ranges are sane and non-overlapping */ 193 + qsort(ranges, *nranges, sizeof(*ranges), iova_range_comp); 194 + VFIO_ASSERT_LT(ranges[0].start, ranges[0].last); 195 + 196 + for (u32 i = 1; i < *nranges; i++) { 197 + VFIO_ASSERT_LT(ranges[i].start, ranges[i].last); 198 + VFIO_ASSERT_LT(ranges[i - 1].last, ranges[i].start); 199 + } 200 + 201 + return ranges; 202 + } 203 + 204 + struct iova_allocator *iova_allocator_init(struct vfio_pci_device *device) 205 + { 206 + struct iova_allocator *allocator; 207 + struct iommu_iova_range *ranges; 208 + u32 nranges; 209 + 210 + ranges = vfio_pci_iova_ranges(device, &nranges); 211 + VFIO_ASSERT_NOT_NULL(ranges); 212 + 213 + allocator = malloc(sizeof(*allocator)); 214 + VFIO_ASSERT_NOT_NULL(allocator); 215 + 216 + *allocator = (struct iova_allocator){ 217 + .ranges = ranges, 218 + .nranges = nranges, 219 + .range_idx = 0, 220 + .range_offset = 0, 221 + }; 222 + 223 + return allocator; 224 + } 225 + 226 + void iova_allocator_cleanup(struct iova_allocator *allocator) 227 + { 228 + free(allocator->ranges); 229 + free(allocator); 230 + } 231 + 232 + iova_t iova_allocator_alloc(struct iova_allocator *allocator, size_t size) 233 + { 234 + VFIO_ASSERT_GT(size, 0, "Invalid size arg, zero\n"); 235 + VFIO_ASSERT_EQ(size & (size - 1), 0, "Invalid size arg, non-power-of-2\n"); 236 + 237 + for (;;) { 238 + struct iommu_iova_range *range; 239 + iova_t iova, last; 240 + 241 + VFIO_ASSERT_LT(allocator->range_idx, allocator->nranges, 242 + "IOVA allocator out of space\n"); 243 + 244 + range = &allocator->ranges[allocator->range_idx]; 245 + iova = range->start + allocator->range_offset; 246 + 247 + /* Check for sufficient space at the current offset */ 248 + if (check_add_overflow(iova, size - 1, &last) || 249 + last > range->last) 250 + goto next_range; 251 + 252 + /* Align iova to size */ 253 + iova = last & ~(size - 1); 254 + 255 + /* Check for sufficient space at the aligned iova */ 256 + if (check_add_overflow(iova, size - 1, &last) || 257 + last > range->last) 258 + goto next_range; 259 + 260 + if (last == range->last) { 261 + allocator->range_idx++; 262 + allocator->range_offset = 0; 263 + } else { 264 + allocator->range_offset = last - range->start + 1; 265 + } 266 + 267 + return iova; 268 + 269 + next_range: 270 + allocator->range_idx++; 271 + allocator->range_offset = 0; 272 + } 273 + } 32 274 33 275 iova_t __to_iova(struct vfio_pci_device *device, void *vaddr) 34 276 {
+17 -3
tools/testing/selftests/vfio/vfio_dma_mapping_test.c
··· 3 3 #include <sys/mman.h> 4 4 #include <unistd.h> 5 5 6 + #include <uapi/linux/types.h> 7 + #include <linux/iommufd.h> 6 8 #include <linux/limits.h> 7 9 #include <linux/mman.h> 8 10 #include <linux/sizes.h> ··· 95 93 96 94 FIXTURE(vfio_dma_mapping_test) { 97 95 struct vfio_pci_device *device; 96 + struct iova_allocator *iova_allocator; 98 97 }; 99 98 100 99 FIXTURE_VARIANT(vfio_dma_mapping_test) { ··· 120 117 FIXTURE_SETUP(vfio_dma_mapping_test) 121 118 { 122 119 self->device = vfio_pci_device_init(device_bdf, variant->iommu_mode); 120 + self->iova_allocator = iova_allocator_init(self->device); 123 121 } 124 122 125 123 FIXTURE_TEARDOWN(vfio_dma_mapping_test) 126 124 { 125 + iova_allocator_cleanup(self->iova_allocator); 127 126 vfio_pci_device_cleanup(self->device); 128 127 } 129 128 ··· 147 142 else 148 143 ASSERT_NE(region.vaddr, MAP_FAILED); 149 144 150 - region.iova = (u64)region.vaddr; 145 + region.iova = iova_allocator_alloc(self->iova_allocator, size); 151 146 region.size = size; 152 147 153 148 vfio_pci_dma_map(self->device, &region); ··· 224 219 FIXTURE_SETUP(vfio_dma_map_limit_test) 225 220 { 226 221 struct vfio_dma_region *region = &self->region; 222 + struct iommu_iova_range *ranges; 227 223 u64 region_size = getpagesize(); 224 + iova_t last_iova; 225 + u32 nranges; 228 226 229 227 /* 230 228 * Over-allocate mmap by double the size to provide enough backing vaddr ··· 240 232 MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); 241 233 ASSERT_NE(region->vaddr, MAP_FAILED); 242 234 243 - /* One page prior to the end of address space */ 244 - region->iova = ~(iova_t)0 & ~(region_size - 1); 235 + ranges = vfio_pci_iova_ranges(self->device, &nranges); 236 + VFIO_ASSERT_NOT_NULL(ranges); 237 + last_iova = ranges[nranges - 1].last; 238 + free(ranges); 239 + 240 + /* One page prior to the last iova */ 241 + region->iova = last_iova & ~(region_size - 1); 245 242 region->size = region_size; 246 243 } 247 244 ··· 289 276 struct vfio_dma_region *region = &self->region; 290 277 int rc; 291 278 279 + region->iova = ~(iova_t)0 & ~(region->size - 1); 292 280 region->size = self->mmap_size; 293 281 294 282 rc = __vfio_pci_dma_map(self->device, region);
+8 -4
tools/testing/selftests/vfio/vfio_pci_driver_test.c
··· 19 19 } while (0) 20 20 21 21 static void region_setup(struct vfio_pci_device *device, 22 + struct iova_allocator *iova_allocator, 22 23 struct vfio_dma_region *region, u64 size) 23 24 { 24 25 const int flags = MAP_SHARED | MAP_ANONYMOUS; ··· 30 29 VFIO_ASSERT_NE(vaddr, MAP_FAILED); 31 30 32 31 region->vaddr = vaddr; 33 - region->iova = (u64)vaddr; 32 + region->iova = iova_allocator_alloc(iova_allocator, size); 34 33 region->size = size; 35 34 36 35 vfio_pci_dma_map(device, region); ··· 45 44 46 45 FIXTURE(vfio_pci_driver_test) { 47 46 struct vfio_pci_device *device; 47 + struct iova_allocator *iova_allocator; 48 48 struct vfio_dma_region memcpy_region; 49 49 void *vaddr; 50 50 int msi_fd; ··· 74 72 struct vfio_pci_driver *driver; 75 73 76 74 self->device = vfio_pci_device_init(device_bdf, variant->iommu_mode); 75 + self->iova_allocator = iova_allocator_init(self->device); 77 76 78 77 driver = &self->device->driver; 79 78 80 - region_setup(self->device, &self->memcpy_region, SZ_1G); 81 - region_setup(self->device, &driver->region, SZ_2M); 79 + region_setup(self->device, self->iova_allocator, &self->memcpy_region, SZ_1G); 80 + region_setup(self->device, self->iova_allocator, &driver->region, SZ_2M); 82 81 83 82 /* Any IOVA that doesn't overlap memcpy_region and driver->region. */ 84 - self->unmapped_iova = 8UL * SZ_1G; 83 + self->unmapped_iova = iova_allocator_alloc(self->iova_allocator, SZ_1G); 85 84 86 85 vfio_pci_driver_init(self->device); 87 86 self->msi_fd = self->device->msi_eventfds[driver->msi]; ··· 111 108 region_teardown(self->device, &self->memcpy_region); 112 109 region_teardown(self->device, &driver->region); 113 110 111 + iova_allocator_cleanup(self->iova_allocator); 114 112 vfio_pci_device_cleanup(self->device); 115 113 } 116 114
+4 -4
tools/testing/selftests/vsock/vmtest.sh
··· 389 389 local rc 390 390 391 391 host_oops_cnt_before=$(dmesg | grep -c -i 'Oops') 392 - host_warn_cnt_before=$(dmesg --level=warn | wc -l) 392 + host_warn_cnt_before=$(dmesg --level=warn | grep -c -i 'vsock') 393 393 vm_oops_cnt_before=$(vm_ssh -- dmesg | grep -c -i 'Oops') 394 - vm_warn_cnt_before=$(vm_ssh -- dmesg --level=warn | wc -l) 394 + vm_warn_cnt_before=$(vm_ssh -- dmesg --level=warn | grep -c -i 'vsock') 395 395 396 396 name=$(echo "${1}" | awk '{ print $1 }') 397 397 eval test_"${name}" ··· 403 403 rc=$KSFT_FAIL 404 404 fi 405 405 406 - host_warn_cnt_after=$(dmesg --level=warn | wc -l) 406 + host_warn_cnt_after=$(dmesg --level=warn | grep -c -i 'vsock') 407 407 if [[ ${host_warn_cnt_after} -gt ${host_warn_cnt_before} ]]; then 408 408 echo "FAIL: kernel warning detected on host" | log_host "${name}" 409 409 rc=$KSFT_FAIL ··· 415 415 rc=$KSFT_FAIL 416 416 fi 417 417 418 - vm_warn_cnt_after=$(vm_ssh -- dmesg --level=warn | wc -l) 418 + vm_warn_cnt_after=$(vm_ssh -- dmesg --level=warn | grep -c -i 'vsock') 419 419 if [[ ${vm_warn_cnt_after} -gt ${vm_warn_cnt_before} ]]; then 420 420 echo "FAIL: kernel warning detected on vm" | log_host "${name}" 421 421 rc=$KSFT_FAIL
+1 -1
tools/tracing/latency/latency-collector.c
··· 1725 1725 "-n, --notrace\t\tIf latency is detected, do not print out the content of\n" 1726 1726 "\t\t\tthe trace file to standard output\n\n" 1727 1727 1728 - "-t, --threads NRTHR\tRun NRTHR threads for printing. Default is %d.\n\n" 1728 + "-e, --threads NRTHR\tRun NRTHR threads for printing. Default is %d.\n\n" 1729 1729 1730 1730 "-r, --random\t\tArbitrarily sleep a certain amount of time, default\n" 1731 1731 "\t\t\t%ld ms, before reading the trace file. The\n"
+33 -14
virt/kvm/guest_memfd.c
··· 623 623 return r; 624 624 } 625 625 626 - void kvm_gmem_unbind(struct kvm_memory_slot *slot) 626 + static void __kvm_gmem_unbind(struct kvm_memory_slot *slot, struct kvm_gmem *gmem) 627 627 { 628 628 unsigned long start = slot->gmem.pgoff; 629 629 unsigned long end = start + slot->npages; 630 - struct kvm_gmem *gmem; 631 - struct file *file; 632 630 633 - /* 634 - * Nothing to do if the underlying file was already closed (or is being 635 - * closed right now), kvm_gmem_release() invalidates all bindings. 636 - */ 637 - file = kvm_gmem_get_file(slot); 638 - if (!file) 639 - return; 640 - 641 - gmem = file->private_data; 642 - 643 - filemap_invalidate_lock(file->f_mapping); 644 631 xa_store_range(&gmem->bindings, start, end - 1, NULL, GFP_KERNEL); 645 632 646 633 /* ··· 635 648 * cannot see this memslot. 636 649 */ 637 650 WRITE_ONCE(slot->gmem.file, NULL); 651 + } 652 + 653 + void kvm_gmem_unbind(struct kvm_memory_slot *slot) 654 + { 655 + struct file *file; 656 + 657 + /* 658 + * Nothing to do if the underlying file was _already_ closed, as 659 + * kvm_gmem_release() invalidates and nullifies all bindings. 660 + */ 661 + if (!slot->gmem.file) 662 + return; 663 + 664 + file = kvm_gmem_get_file(slot); 665 + 666 + /* 667 + * However, if the file is _being_ closed, then the bindings need to be 668 + * removed as kvm_gmem_release() might not run until after the memslot 669 + * is freed. Note, modifying the bindings is safe even though the file 670 + * is dying as kvm_gmem_release() nullifies slot->gmem.file under 671 + * slots_lock, and only puts its reference to KVM after destroying all 672 + * bindings. I.e. reaching this point means kvm_gmem_release() hasn't 673 + * yet destroyed the bindings or freed the gmem_file, and can't do so 674 + * until the caller drops slots_lock. 675 + */ 676 + if (!file) { 677 + __kvm_gmem_unbind(slot, slot->gmem.file->private_data); 678 + return; 679 + } 680 + 681 + filemap_invalidate_lock(file->f_mapping); 682 + __kvm_gmem_unbind(slot, file->private_data); 638 683 filemap_invalidate_unlock(file->f_mapping); 639 684 640 685 fput(file);