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 git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net

Cross-merge networking fixes after downstream PR (net-6.14-rc4).

No conflicts or adjacent changes.

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

+3689 -1939
+4
.mailmap
··· 226 226 Felipe W Damasio <felipewd@terra.com.br> 227 227 Felix Kuhling <fxkuehl@gmx.de> 228 228 Felix Moeller <felix@derklecks.de> 229 + Feng Tang <feng.79.tang@gmail.com> <feng.tang@intel.com> 229 230 Fenglin Wu <quic_fenglinw@quicinc.com> <fenglinw@codeaurora.org> 230 231 Filipe Lautert <filipe@icewall.org> 231 232 Finn Thain <fthain@linux-m68k.org> <fthain@telegraphics.com.au> ··· 318 317 Jean Tourrilhes <jt@hpl.hp.com> 319 318 Jeevan Shriram <quic_jshriram@quicinc.com> <jshriram@codeaurora.org> 320 319 Jeff Garzik <jgarzik@pretzel.yyz.us> 320 + Jeff Johnson <jeff.johnson@oss.qualcomm.com> <jjohnson@codeaurora.org> 321 + Jeff Johnson <jeff.johnson@oss.qualcomm.com> <quic_jjohnson@quicinc.com> 321 322 Jeff Layton <jlayton@kernel.org> <jlayton@poochiereds.net> 322 323 Jeff Layton <jlayton@kernel.org> <jlayton@primarydata.com> 323 324 Jeff Layton <jlayton@kernel.org> <jlayton@redhat.com> ··· 534 531 Nicholas Piggin <npiggin@gmail.com> <npiggin@suse.de> 535 532 Nicholas Piggin <npiggin@gmail.com> <nickpiggin@yahoo.com.au> 536 533 Nicholas Piggin <npiggin@gmail.com> <piggin@cyberone.com.au> 534 + Nick Desaulniers <nick.desaulniers+lkml@gmail.com> <ndesaulniers@google.com> 537 535 Nicolas Ferre <nicolas.ferre@microchip.com> <nicolas.ferre@atmel.com> 538 536 Nicolas Pitre <nico@fluxnic.net> <nicolas.pitre@linaro.org> 539 537 Nicolas Pitre <nico@fluxnic.net> <nico@linaro.org>
+1 -1
Documentation/arch/arm64/gcs.rst
··· 37 37 shadow stacks rather than GCS. 38 38 39 39 * Support for GCS is reported to userspace via HWCAP_GCS in the aux vector 40 - AT_HWCAP2 entry. 40 + AT_HWCAP entry. 41 41 42 42 * GCS is enabled per thread. While there is support for disabling GCS 43 43 at runtime this should be done with great care.
+3
Documentation/devicetree/bindings/clock/qcom,gpucc.yaml
··· 8 8 9 9 maintainers: 10 10 - Taniya Das <quic_tdas@quicinc.com> 11 + - Imran Shaik <quic_imrashai@quicinc.com> 11 12 12 13 description: | 13 14 Qualcomm graphics clock control module provides the clocks, resets and power ··· 24 23 include/dt-bindings/clock/qcom,gpucc-sm8150.h 25 24 include/dt-bindings/clock/qcom,gpucc-sm8250.h 26 25 include/dt-bindings/clock/qcom,gpucc-sm8350.h 26 + include/dt-bindings/clock/qcom,qcs8300-gpucc.h 27 27 28 28 properties: 29 29 compatible: 30 30 enum: 31 + - qcom,qcs8300-gpucc 31 32 - qcom,sdm845-gpucc 32 33 - qcom,sa8775p-gpucc 33 34 - qcom,sc7180-gpucc
+5 -1
Documentation/devicetree/bindings/clock/qcom,sa8775p-camcc.yaml
··· 8 8 9 9 maintainers: 10 10 - Taniya Das <quic_tdas@quicinc.com> 11 + - Imran Shaik <quic_imrashai@quicinc.com> 11 12 12 13 description: | 13 14 Qualcomm camera clock control module provides the clocks, resets and power 14 15 domains on SA8775p. 15 16 16 - See also: include/dt-bindings/clock/qcom,sa8775p-camcc.h 17 + See also: 18 + include/dt-bindings/clock/qcom,qcs8300-camcc.h 19 + include/dt-bindings/clock/qcom,sa8775p-camcc.h 17 20 18 21 properties: 19 22 compatible: 20 23 enum: 24 + - qcom,qcs8300-camcc 21 25 - qcom,sa8775p-camcc 22 26 23 27 clocks:
+1
Documentation/devicetree/bindings/clock/qcom,sa8775p-videocc.yaml
··· 18 18 properties: 19 19 compatible: 20 20 enum: 21 + - qcom,qcs8300-videocc 21 22 - qcom,sa8775p-videocc 22 23 23 24 clocks:
+29
Documentation/devicetree/bindings/display/panel/powertip,hx8238a.yaml
··· 1 + # SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/display/panel/powertip,hx8238a.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Powertip Electronic Technology Co. 320 x 240 LCD panel 8 + 9 + maintainers: 10 + - Lukasz Majewski <lukma@denx.de> 11 + 12 + allOf: 13 + - $ref: panel-dpi.yaml# 14 + 15 + properties: 16 + compatible: 17 + items: 18 + - const: powertip,hx8238a 19 + - {} # panel-dpi, but not listed here to avoid false select 20 + 21 + height-mm: true 22 + panel-timing: true 23 + port: true 24 + power-supply: true 25 + width-mm: true 26 + 27 + additionalProperties: false 28 + 29 + ...
+29
Documentation/devicetree/bindings/display/panel/powertip,st7272.yaml
··· 1 + # SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/display/panel/powertip,st7272.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Powertip Electronic Technology Co. 320 x 240 LCD panel 8 + 9 + maintainers: 10 + - Lukasz Majewski <lukma@denx.de> 11 + 12 + allOf: 13 + - $ref: panel-dpi.yaml# 14 + 15 + properties: 16 + compatible: 17 + items: 18 + - const: powertip,st7272 19 + - {} # panel-dpi, but not listed here to avoid false select 20 + 21 + height-mm: true 22 + panel-timing: true 23 + port: true 24 + power-supply: true 25 + width-mm: true 26 + 27 + additionalProperties: false 28 + 29 + ...
+1 -1
Documentation/devicetree/bindings/display/ti/ti,am65x-dss.yaml
··· 23 23 compatible: 24 24 enum: 25 25 - ti,am625-dss 26 - - ti,am62a7,dss 26 + - ti,am62a7-dss 27 27 - ti,am65x-dss 28 28 29 29 reg:
+1
Documentation/devicetree/bindings/nvmem/qcom,qfprom.yaml
··· 36 36 - qcom,qcs404-qfprom 37 37 - qcom,qcs615-qfprom 38 38 - qcom,qcs8300-qfprom 39 + - qcom,sar2130p-qfprom 39 40 - qcom,sc7180-qfprom 40 41 - qcom,sc7280-qfprom 41 42 - qcom,sc8280xp-qfprom
+1 -1
Documentation/devicetree/bindings/regulator/qcom,smd-rpm-regulator.yaml
··· 22 22 Each sub-node is identified using the node's name, with valid values listed 23 23 for each of the pmics below. 24 24 25 - For mp5496, s1, s2 25 + For mp5496, s1, s2, l2, l5 26 26 27 27 For pm2250, s1, s2, s3, s4, l1, l2, l3, l4, l5, l6, l7, l8, l9, l10, l11, 28 28 l12, l13, l14, l15, l16, l17, l18, l19, l20, l21, l22
+6
Documentation/driver-api/infrastructure.rst
··· 41 41 .. kernel-doc:: drivers/base/class.c 42 42 :export: 43 43 44 + .. kernel-doc:: include/linux/device/faux.h 45 + :internal: 46 + 47 + .. kernel-doc:: drivers/base/faux.c 48 + :export: 49 + 44 50 .. kernel-doc:: drivers/base/node.c 45 51 :internal: 46 52
+1 -1
Documentation/process/embargoed-hardware-issues.rst
··· 308 308 309 309 Google Kees Cook <keescook@chromium.org> 310 310 311 - LLVM Nick Desaulniers <ndesaulniers@google.com> 311 + LLVM Nick Desaulniers <nick.desaulniers+lkml@gmail.com> 312 312 ============= ======================================================== 313 313 314 314 If you want your organization to be added to the ambassadors list, please
+1 -1
Documentation/translations/sp_SP/process/embargoed-hardware-issues.rst
··· 287 287 288 288 Google Kees Cook <keescook@chromium.org> 289 289 290 - LLVM Nick Desaulniers <ndesaulniers@google.com> 290 + LLVM Nick Desaulniers <nick.desaulniers+lkml@gmail.com> 291 291 ============= ======================================================== 292 292 293 293 Si quiere que su organización se añada a la lista de embajadores, por
+20 -11
MAINTAINERS
··· 3858 3858 F: Documentation/devicetree/bindings/pwm/adi,axi-pwmgen.yaml 3859 3859 F: drivers/pwm/pwm-axi-pwmgen.c 3860 3860 3861 - AXXIA I2C CONTROLLER 3862 - M: Krzysztof Adamski <krzysztof.adamski@nokia.com> 3863 - L: linux-i2c@vger.kernel.org 3864 - S: Maintained 3865 - F: Documentation/devicetree/bindings/i2c/i2c-axxia.txt 3866 - F: drivers/i2c/busses/i2c-axxia.c 3867 - 3868 3861 AZ6007 DVB DRIVER 3869 3862 M: Mauro Carvalho Chehab <mchehab@kernel.org> 3870 3863 L: linux-media@vger.kernel.org ··· 5655 5662 5656 5663 CLANG/LLVM BUILD SUPPORT 5657 5664 M: Nathan Chancellor <nathan@kernel.org> 5658 - R: Nick Desaulniers <ndesaulniers@google.com> 5665 + R: Nick Desaulniers <nick.desaulniers+lkml@gmail.com> 5659 5666 R: Bill Wendling <morbo@google.com> 5660 5667 R: Justin Stitt <justinstitt@google.com> 5661 5668 L: llvm@lists.linux.dev ··· 7108 7115 F: rust/kernel/device_id.rs 7109 7116 F: rust/kernel/devres.rs 7110 7117 F: rust/kernel/driver.rs 7118 + F: rust/kernel/faux.rs 7111 7119 F: rust/kernel/platform.rs 7112 7120 F: samples/rust/rust_driver_platform.rs 7121 + F: samples/rust/rust_driver_faux.rs 7113 7122 7114 7123 DRIVERS FOR OMAP ADAPTIVE VOLTAGE SCALING (AVS) 7115 7124 M: Nishanth Menon <nm@ti.com> ··· 9829 9834 9830 9835 GOOGLE ETHERNET DRIVERS 9831 9836 M: Jeroen de Borst <jeroendb@google.com> 9832 - M: Praveen Kaligineedi <pkaligineedi@google.com> 9833 - R: Shailend Chand <shailend@google.com> 9837 + M: Harshitha Ramamurthy <hramamurthy@google.com> 9834 9838 L: netdev@vger.kernel.org 9835 9839 S: Maintained 9836 9840 F: Documentation/networking/device_drivers/ethernet/google/gve.rst ··· 10815 10821 F: drivers/tty/hvc/ 10816 10822 10817 10823 I2C ACPI SUPPORT 10818 - M: Mika Westerberg <mika.westerberg@linux.intel.com> 10824 + M: Mika Westerberg <westeri@kernel.org> 10819 10825 L: linux-i2c@vger.kernel.org 10820 10826 L: linux-acpi@vger.kernel.org 10821 10827 S: Maintained ··· 16471 16477 F: tools/testing/selftests/drivers/net/*/ethtool* 16472 16478 K: cable_test 16473 16479 16480 + NETWORKING [ETHTOOL MAC MERGE] 16481 + M: Vladimir Oltean <vladimir.oltean@nxp.com> 16482 + F: net/ethtool/mm.c 16483 + F: tools/testing/selftests/drivers/net/hw/ethtool_mm.sh 16484 + K: ethtool_mm 16485 + 16474 16486 NETWORKING [GENERAL] 16475 16487 M: "David S. Miller" <davem@davemloft.net> 16476 16488 M: Eric Dumazet <edumazet@google.com> ··· 19507 19507 L: dmaengine@vger.kernel.org 19508 19508 S: Supported 19509 19509 F: drivers/dma/qcom/hidma* 19510 + 19511 + QUALCOMM I2C QCOM GENI DRIVER 19512 + M: Mukesh Kumar Savaliya <quic_msavaliy@quicinc.com> 19513 + M: Viken Dadhaniya <quic_vdadhani@quicinc.com> 19514 + L: linux-i2c@vger.kernel.org 19515 + L: linux-arm-msm@vger.kernel.org 19516 + S: Maintained 19517 + F: Documentation/devicetree/bindings/i2c/qcom,i2c-geni-qcom.yaml 19518 + F: drivers/i2c/busses/i2c-qcom-geni.c 19510 19519 19511 19520 QUALCOMM I2C CCI DRIVER 19512 19521 M: Loic Poulain <loic.poulain@linaro.org>
+5 -10
Makefile
··· 2 2 VERSION = 6 3 3 PATCHLEVEL = 14 4 4 SUBLEVEL = 0 5 - EXTRAVERSION = -rc2 5 + EXTRAVERSION = -rc3 6 6 NAME = Baby Opossum Posse 7 7 8 8 # *DOCUMENTATION* ··· 1120 1120 endif 1121 1121 1122 1122 # Align the bit size of userspace programs with the kernel 1123 - KBUILD_USERCFLAGS += $(filter -m32 -m64 --target=%, $(KBUILD_CFLAGS)) 1124 - KBUILD_USERLDFLAGS += $(filter -m32 -m64 --target=%, $(KBUILD_CFLAGS)) 1123 + KBUILD_USERCFLAGS += $(filter -m32 -m64 --target=%, $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS)) 1124 + KBUILD_USERLDFLAGS += $(filter -m32 -m64 --target=%, $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS)) 1125 1125 1126 1126 # make the checker run with the right architecture 1127 1127 CHECKFLAGS += --arch=$(ARCH) ··· 1421 1421 $(Q)$(MAKE) -sC $(srctree)/tools/bpf/resolve_btfids O=$(resolve_btfids_O) clean 1422 1422 endif 1423 1423 1424 - # Clear a bunch of variables before executing the submake 1425 - ifeq ($(quiet),silent_) 1426 - tools_silent=s 1427 - endif 1428 - 1429 1424 tools/: FORCE 1430 1425 $(Q)mkdir -p $(objtree)/tools 1431 - $(Q)$(MAKE) LDFLAGS= MAKEFLAGS="$(tools_silent) $(filter --j% -j,$(MAKEFLAGS))" O=$(abspath $(objtree)) subdir=tools -C $(srctree)/tools/ 1426 + $(Q)$(MAKE) LDFLAGS= O=$(abspath $(objtree)) subdir=tools -C $(srctree)/tools/ 1432 1427 1433 1428 tools/%: FORCE 1434 1429 $(Q)mkdir -p $(objtree)/tools 1435 - $(Q)$(MAKE) LDFLAGS= MAKEFLAGS="$(tools_silent) $(filter --j% -j,$(MAKEFLAGS))" O=$(abspath $(objtree)) subdir=tools -C $(srctree)/tools/ $* 1430 + $(Q)$(MAKE) LDFLAGS= O=$(abspath $(objtree)) subdir=tools -C $(srctree)/tools/ $* 1436 1431 1437 1432 # --------------------------------------------------------------------------- 1438 1433 # Kernel selftest
+1 -1
arch/alpha/include/asm/hwrpb.h
··· 135 135 /* virtual->physical map */ 136 136 unsigned long map_entries; 137 137 unsigned long map_pages; 138 - struct vf_map_struct map[1]; 138 + struct vf_map_struct map[]; 139 139 }; 140 140 141 141 struct memclust_struct {
+2
arch/alpha/include/uapi/asm/ptrace.h
··· 42 42 unsigned long trap_a0; 43 43 unsigned long trap_a1; 44 44 unsigned long trap_a2; 45 + /* This makes the stack 16-byte aligned as GCC expects */ 46 + unsigned long __pad0; 45 47 /* These are saved by PAL-code: */ 46 48 unsigned long ps; 47 49 unsigned long pc;
+4
arch/alpha/kernel/asm-offsets.c
··· 19 19 DEFINE(TI_STATUS, offsetof(struct thread_info, status)); 20 20 BLANK(); 21 21 22 + DEFINE(SP_OFF, offsetof(struct pt_regs, ps)); 22 23 DEFINE(SIZEOF_PT_REGS, sizeof(struct pt_regs)); 24 + BLANK(); 25 + 26 + DEFINE(SWITCH_STACK_SIZE, sizeof(struct switch_stack)); 23 27 BLANK(); 24 28 25 29 DEFINE(HAE_CACHE, offsetof(struct alpha_machine_vector, hae_cache));
+10 -14
arch/alpha/kernel/entry.S
··· 15 15 .set noat 16 16 .cfi_sections .debug_frame 17 17 18 - /* Stack offsets. */ 19 - #define SP_OFF 184 20 - #define SWITCH_STACK_SIZE 64 21 - 22 18 .macro CFI_START_OSF_FRAME func 23 19 .align 4 24 20 .globl \func ··· 194 198 CFI_START_OSF_FRAME entMM 195 199 SAVE_ALL 196 200 /* save $9 - $15 so the inline exception code can manipulate them. */ 197 - subq $sp, 56, $sp 198 - .cfi_adjust_cfa_offset 56 201 + subq $sp, 64, $sp 202 + .cfi_adjust_cfa_offset 64 199 203 stq $9, 0($sp) 200 204 stq $10, 8($sp) 201 205 stq $11, 16($sp) ··· 210 214 .cfi_rel_offset $13, 32 211 215 .cfi_rel_offset $14, 40 212 216 .cfi_rel_offset $15, 48 213 - addq $sp, 56, $19 217 + addq $sp, 64, $19 214 218 /* handle the fault */ 215 219 lda $8, 0x3fff 216 220 bic $sp, $8, $8 ··· 223 227 ldq $13, 32($sp) 224 228 ldq $14, 40($sp) 225 229 ldq $15, 48($sp) 226 - addq $sp, 56, $sp 230 + addq $sp, 64, $sp 227 231 .cfi_restore $9 228 232 .cfi_restore $10 229 233 .cfi_restore $11 ··· 231 235 .cfi_restore $13 232 236 .cfi_restore $14 233 237 .cfi_restore $15 234 - .cfi_adjust_cfa_offset -56 238 + .cfi_adjust_cfa_offset -64 235 239 /* finish up the syscall as normal. */ 236 240 br ret_from_sys_call 237 241 CFI_END_OSF_FRAME entMM ··· 378 382 .cfi_restore $0 379 383 .cfi_adjust_cfa_offset -256 380 384 SAVE_ALL /* setup normal kernel stack */ 381 - lda $sp, -56($sp) 382 - .cfi_adjust_cfa_offset 56 385 + lda $sp, -64($sp) 386 + .cfi_adjust_cfa_offset 64 383 387 stq $9, 0($sp) 384 388 stq $10, 8($sp) 385 389 stq $11, 16($sp) ··· 395 399 .cfi_rel_offset $14, 40 396 400 .cfi_rel_offset $15, 48 397 401 lda $8, 0x3fff 398 - addq $sp, 56, $19 402 + addq $sp, 64, $19 399 403 bic $sp, $8, $8 400 404 jsr $26, do_entUnaUser 401 405 ldq $9, 0($sp) ··· 405 409 ldq $13, 32($sp) 406 410 ldq $14, 40($sp) 407 411 ldq $15, 48($sp) 408 - lda $sp, 56($sp) 412 + lda $sp, 64($sp) 409 413 .cfi_restore $9 410 414 .cfi_restore $10 411 415 .cfi_restore $11 ··· 413 417 .cfi_restore $13 414 418 .cfi_restore $14 415 419 .cfi_restore $15 416 - .cfi_adjust_cfa_offset -56 420 + .cfi_adjust_cfa_offset -64 417 421 br ret_from_sys_call 418 422 CFI_END_OSF_FRAME entUna 419 423
+2 -1
arch/alpha/kernel/pci_iommu.c
··· 13 13 #include <linux/log2.h> 14 14 #include <linux/dma-map-ops.h> 15 15 #include <linux/iommu-helper.h> 16 + #include <linux/string_choices.h> 16 17 17 18 #include <asm/io.h> 18 19 #include <asm/hwrpb.h> ··· 213 212 214 213 /* If both conditions above are met, we are fine. */ 215 214 DBGA("pci_dac_dma_supported %s from %ps\n", 216 - ok ? "yes" : "no", __builtin_return_address(0)); 215 + str_yes_no(ok), __builtin_return_address(0)); 217 216 218 217 return ok; 219 218 }
+1 -1
arch/alpha/kernel/traps.c
··· 649 649 static int unauser_reg_offsets[32] = { 650 650 R(r0), R(r1), R(r2), R(r3), R(r4), R(r5), R(r6), R(r7), R(r8), 651 651 /* r9 ... r15 are stored in front of regs. */ 652 - -56, -48, -40, -32, -24, -16, -8, 652 + -64, -56, -48, -40, -32, -24, -16, /* padding at -8 */ 653 653 R(r16), R(r17), R(r18), 654 654 R(r19), R(r20), R(r21), R(r22), R(r23), R(r24), R(r25), R(r26), 655 655 R(r27), R(r28), R(gp),
+2 -2
arch/alpha/mm/fault.c
··· 78 78 79 79 /* Macro for exception fixup code to access integer registers. */ 80 80 #define dpf_reg(r) \ 81 - (((unsigned long *)regs)[(r) <= 8 ? (r) : (r) <= 15 ? (r)-16 : \ 82 - (r) <= 18 ? (r)+10 : (r)-10]) 81 + (((unsigned long *)regs)[(r) <= 8 ? (r) : (r) <= 15 ? (r)-17 : \ 82 + (r) <= 18 ? (r)+11 : (r)-10]) 83 83 84 84 asmlinkage void 85 85 do_page_fault(unsigned long address, unsigned long mmcsr,
-1
arch/arm64/Kconfig
··· 225 225 select HAVE_FUNCTION_ERROR_INJECTION 226 226 select HAVE_FUNCTION_GRAPH_FREGS 227 227 select HAVE_FUNCTION_GRAPH_TRACER 228 - select HAVE_FUNCTION_GRAPH_RETVAL 229 228 select HAVE_GCC_PLUGINS 230 229 select HAVE_HARDLOCKUP_DETECTOR_PERF if PERF_EVENTS && \ 231 230 HW_PERF_EVENTS && HAVE_PERF_EVENTS_NMI
+4
arch/arm64/Makefile
··· 48 48 KBUILD_CFLAGS += $(call cc-disable-warning, psabi) 49 49 KBUILD_AFLAGS += $(compat_vdso) 50 50 51 + ifeq ($(call test-ge, $(CONFIG_RUSTC_VERSION), 108500),y) 52 + KBUILD_RUSTFLAGS += --target=aarch64-unknown-none-softfloat 53 + else 51 54 KBUILD_RUSTFLAGS += --target=aarch64-unknown-none -Ctarget-feature="-neon" 55 + endif 52 56 53 57 KBUILD_CFLAGS += $(call cc-option,-mabi=lp64) 54 58 KBUILD_AFLAGS += $(call cc-option,-mabi=lp64)
-42
arch/arm64/include/asm/kvm_emulate.h
··· 605 605 __cpacr_to_cptr_set(clr, set));\ 606 606 } while (0) 607 607 608 - static __always_inline void kvm_write_cptr_el2(u64 val) 609 - { 610 - if (has_vhe() || has_hvhe()) 611 - write_sysreg(val, cpacr_el1); 612 - else 613 - write_sysreg(val, cptr_el2); 614 - } 615 - 616 - /* Resets the value of cptr_el2 when returning to the host. */ 617 - static __always_inline void __kvm_reset_cptr_el2(struct kvm *kvm) 618 - { 619 - u64 val; 620 - 621 - if (has_vhe()) { 622 - val = (CPACR_EL1_FPEN | CPACR_EL1_ZEN_EL1EN); 623 - if (cpus_have_final_cap(ARM64_SME)) 624 - val |= CPACR_EL1_SMEN_EL1EN; 625 - } else if (has_hvhe()) { 626 - val = CPACR_EL1_FPEN; 627 - 628 - if (!kvm_has_sve(kvm) || !guest_owns_fp_regs()) 629 - val |= CPACR_EL1_ZEN; 630 - if (cpus_have_final_cap(ARM64_SME)) 631 - val |= CPACR_EL1_SMEN; 632 - } else { 633 - val = CPTR_NVHE_EL2_RES1; 634 - 635 - if (kvm_has_sve(kvm) && guest_owns_fp_regs()) 636 - val |= CPTR_EL2_TZ; 637 - if (!cpus_have_final_cap(ARM64_SME)) 638 - val |= CPTR_EL2_TSM; 639 - } 640 - 641 - kvm_write_cptr_el2(val); 642 - } 643 - 644 - #ifdef __KVM_NVHE_HYPERVISOR__ 645 - #define kvm_reset_cptr_el2(v) __kvm_reset_cptr_el2(kern_hyp_va((v)->kvm)) 646 - #else 647 - #define kvm_reset_cptr_el2(v) __kvm_reset_cptr_el2((v)->kvm) 648 - #endif 649 - 650 608 /* 651 609 * Returns a 'sanitised' view of CPTR_EL2, translating from nVHE to the VHE 652 610 * format if E2H isn't set.
+5 -17
arch/arm64/include/asm/kvm_host.h
··· 100 100 static inline void *pop_hyp_memcache(struct kvm_hyp_memcache *mc, 101 101 void *(*to_va)(phys_addr_t phys)) 102 102 { 103 - phys_addr_t *p = to_va(mc->head); 103 + phys_addr_t *p = to_va(mc->head & PAGE_MASK); 104 104 105 105 if (!mc->nr_pages) 106 106 return NULL; ··· 615 615 struct kvm_host_data { 616 616 #define KVM_HOST_DATA_FLAG_HAS_SPE 0 617 617 #define KVM_HOST_DATA_FLAG_HAS_TRBE 1 618 - #define KVM_HOST_DATA_FLAG_HOST_SVE_ENABLED 2 619 - #define KVM_HOST_DATA_FLAG_HOST_SME_ENABLED 3 620 618 #define KVM_HOST_DATA_FLAG_TRBE_ENABLED 4 621 619 #define KVM_HOST_DATA_FLAG_EL1_TRACING_CONFIGURED 5 622 620 unsigned long flags; ··· 622 624 struct kvm_cpu_context host_ctxt; 623 625 624 626 /* 625 - * All pointers in this union are hyp VA. 627 + * Hyp VA. 626 628 * sve_state is only used in pKVM and if system_supports_sve(). 627 629 */ 628 - union { 629 - struct user_fpsimd_state *fpsimd_state; 630 - struct cpu_sve_state *sve_state; 631 - }; 630 + struct cpu_sve_state *sve_state; 632 631 633 - union { 634 - /* HYP VA pointer to the host storage for FPMR */ 635 - u64 *fpmr_ptr; 636 - /* 637 - * Used by pKVM only, as it needs to provide storage 638 - * for the host 639 - */ 640 - u64 fpmr; 641 - }; 632 + /* Used by pKVM only. */ 633 + u64 fpmr; 642 634 643 635 /* Ownership of the FP regs */ 644 636 enum {
+7 -5
arch/arm64/kernel/cacheinfo.c
··· 101 101 unsigned int level, idx; 102 102 enum cache_type type; 103 103 struct cpu_cacheinfo *this_cpu_ci = get_cpu_cacheinfo(cpu); 104 - struct cacheinfo *this_leaf = this_cpu_ci->info_list; 104 + struct cacheinfo *infos = this_cpu_ci->info_list; 105 105 106 106 for (idx = 0, level = 1; level <= this_cpu_ci->num_levels && 107 - idx < this_cpu_ci->num_leaves; idx++, level++) { 107 + idx < this_cpu_ci->num_leaves; level++) { 108 108 type = get_cache_type(level); 109 109 if (type == CACHE_TYPE_SEPARATE) { 110 - ci_leaf_init(this_leaf++, CACHE_TYPE_DATA, level); 111 - ci_leaf_init(this_leaf++, CACHE_TYPE_INST, level); 110 + if (idx + 1 >= this_cpu_ci->num_leaves) 111 + break; 112 + ci_leaf_init(&infos[idx++], CACHE_TYPE_DATA, level); 113 + ci_leaf_init(&infos[idx++], CACHE_TYPE_INST, level); 112 114 } else { 113 - ci_leaf_init(this_leaf++, type, level); 115 + ci_leaf_init(&infos[idx++], type, level); 114 116 } 115 117 } 116 118 return 0;
+3 -2
arch/arm64/kernel/cpufeature.c
··· 3091 3091 HWCAP_CAP(ID_AA64ISAR0_EL1, TS, FLAGM, CAP_HWCAP, KERNEL_HWCAP_FLAGM), 3092 3092 HWCAP_CAP(ID_AA64ISAR0_EL1, TS, FLAGM2, CAP_HWCAP, KERNEL_HWCAP_FLAGM2), 3093 3093 HWCAP_CAP(ID_AA64ISAR0_EL1, RNDR, IMP, CAP_HWCAP, KERNEL_HWCAP_RNG), 3094 + HWCAP_CAP(ID_AA64ISAR3_EL1, FPRCVT, IMP, CAP_HWCAP, KERNEL_HWCAP_FPRCVT), 3094 3095 HWCAP_CAP(ID_AA64PFR0_EL1, FP, IMP, CAP_HWCAP, KERNEL_HWCAP_FP), 3095 3096 HWCAP_CAP(ID_AA64PFR0_EL1, FP, FP16, CAP_HWCAP, KERNEL_HWCAP_FPHP), 3096 3097 HWCAP_CAP(ID_AA64PFR0_EL1, AdvSIMD, IMP, CAP_HWCAP, KERNEL_HWCAP_ASIMD), ··· 3181 3180 HWCAP_CAP(ID_AA64SMFR0_EL1, SF8FMA, IMP, CAP_HWCAP, KERNEL_HWCAP_SME_SF8FMA), 3182 3181 HWCAP_CAP(ID_AA64SMFR0_EL1, SF8DP4, IMP, CAP_HWCAP, KERNEL_HWCAP_SME_SF8DP4), 3183 3182 HWCAP_CAP(ID_AA64SMFR0_EL1, SF8DP2, IMP, CAP_HWCAP, KERNEL_HWCAP_SME_SF8DP2), 3184 - HWCAP_CAP(ID_AA64SMFR0_EL1, SF8MM8, IMP, CAP_HWCAP, KERNEL_HWCAP_SME_SF8MM8), 3185 - HWCAP_CAP(ID_AA64SMFR0_EL1, SF8MM4, IMP, CAP_HWCAP, KERNEL_HWCAP_SME_SF8MM4), 3186 3183 HWCAP_CAP(ID_AA64SMFR0_EL1, SBitPerm, IMP, CAP_HWCAP, KERNEL_HWCAP_SME_SBITPERM), 3187 3184 HWCAP_CAP(ID_AA64SMFR0_EL1, AES, IMP, CAP_HWCAP, KERNEL_HWCAP_SME_AES), 3188 3185 HWCAP_CAP(ID_AA64SMFR0_EL1, SFEXPA, IMP, CAP_HWCAP, KERNEL_HWCAP_SME_SFEXPA), ··· 3191 3192 HWCAP_CAP(ID_AA64FPFR0_EL1, F8FMA, IMP, CAP_HWCAP, KERNEL_HWCAP_F8FMA), 3192 3193 HWCAP_CAP(ID_AA64FPFR0_EL1, F8DP4, IMP, CAP_HWCAP, KERNEL_HWCAP_F8DP4), 3193 3194 HWCAP_CAP(ID_AA64FPFR0_EL1, F8DP2, IMP, CAP_HWCAP, KERNEL_HWCAP_F8DP2), 3195 + HWCAP_CAP(ID_AA64FPFR0_EL1, F8MM8, IMP, CAP_HWCAP, KERNEL_HWCAP_F8MM8), 3196 + HWCAP_CAP(ID_AA64FPFR0_EL1, F8MM4, IMP, CAP_HWCAP, KERNEL_HWCAP_F8MM4), 3194 3197 HWCAP_CAP(ID_AA64FPFR0_EL1, F8E4M3, IMP, CAP_HWCAP, KERNEL_HWCAP_F8E4M3), 3195 3198 HWCAP_CAP(ID_AA64FPFR0_EL1, F8E5M2, IMP, CAP_HWCAP, KERNEL_HWCAP_F8E5M2), 3196 3199 #ifdef CONFIG_ARM64_POE
-25
arch/arm64/kernel/fpsimd.c
··· 1695 1695 } 1696 1696 1697 1697 /* 1698 - * Called by KVM when entering the guest. 1699 - */ 1700 - void fpsimd_kvm_prepare(void) 1701 - { 1702 - if (!system_supports_sve()) 1703 - return; 1704 - 1705 - /* 1706 - * KVM does not save host SVE state since we can only enter 1707 - * the guest from a syscall so the ABI means that only the 1708 - * non-saved SVE state needs to be saved. If we have left 1709 - * SVE enabled for performance reasons then update the task 1710 - * state to be FPSIMD only. 1711 - */ 1712 - get_cpu_fpsimd_context(); 1713 - 1714 - if (test_and_clear_thread_flag(TIF_SVE)) { 1715 - sve_to_fpsimd(current); 1716 - current->thread.fp_type = FP_STATE_FPSIMD; 1717 - } 1718 - 1719 - put_cpu_fpsimd_context(); 1720 - } 1721 - 1722 - /* 1723 1698 * Associate current's FPSIMD context with this cpu 1724 1699 * The caller must have ownership of the cpu FPSIMD context before calling 1725 1700 * this function.
+10 -12
arch/arm64/kernel/topology.c
··· 194 194 int cpu; 195 195 196 196 /* We are already set since the last insmod of cpufreq driver */ 197 - if (unlikely(cpumask_subset(cpus, amu_fie_cpus))) 197 + if (cpumask_available(amu_fie_cpus) && 198 + unlikely(cpumask_subset(cpus, amu_fie_cpus))) 198 199 return; 199 200 200 - for_each_cpu(cpu, cpus) { 201 + for_each_cpu(cpu, cpus) 201 202 if (!freq_counters_valid(cpu)) 202 203 return; 204 + 205 + if (!cpumask_available(amu_fie_cpus) && 206 + !zalloc_cpumask_var(&amu_fie_cpus, GFP_KERNEL)) { 207 + WARN_ONCE(1, "Failed to allocate FIE cpumask for CPUs[%*pbl]\n", 208 + cpumask_pr_args(cpus)); 209 + return; 203 210 } 204 211 205 212 cpumask_or(amu_fie_cpus, amu_fie_cpus, cpus); ··· 244 237 245 238 static int __init init_amu_fie(void) 246 239 { 247 - int ret; 248 - 249 - if (!zalloc_cpumask_var(&amu_fie_cpus, GFP_KERNEL)) 250 - return -ENOMEM; 251 - 252 - ret = cpufreq_register_notifier(&init_amu_fie_notifier, 240 + return cpufreq_register_notifier(&init_amu_fie_notifier, 253 241 CPUFREQ_POLICY_NOTIFIER); 254 - if (ret) 255 - free_cpumask_var(amu_fie_cpus); 256 - 257 - return ret; 258 242 } 259 243 core_initcall(init_amu_fie); 260 244
+1
arch/arm64/kernel/vdso/vdso.lds.S
··· 41 41 */ 42 42 /DISCARD/ : { 43 43 *(.note.GNU-stack .note.gnu.property) 44 + *(.ARM.attributes) 44 45 } 45 46 .note : { *(.note.*) } :text :note 46 47
+1
arch/arm64/kernel/vmlinux.lds.S
··· 162 162 /DISCARD/ : { 163 163 *(.interp .dynamic) 164 164 *(.dynsym .dynstr .hash .gnu.hash) 165 + *(.ARM.attributes) 165 166 } 166 167 167 168 . = KIMAGE_VADDR;
+7 -9
arch/arm64/kvm/arch_timer.c
··· 447 447 static void kvm_timer_update_irq(struct kvm_vcpu *vcpu, bool new_level, 448 448 struct arch_timer_context *timer_ctx) 449 449 { 450 - int ret; 451 - 452 450 kvm_timer_update_status(timer_ctx, new_level); 453 451 454 452 timer_ctx->irq.level = new_level; 455 453 trace_kvm_timer_update_irq(vcpu->vcpu_id, timer_irq(timer_ctx), 456 454 timer_ctx->irq.level); 457 455 458 - if (!userspace_irqchip(vcpu->kvm)) { 459 - ret = kvm_vgic_inject_irq(vcpu->kvm, vcpu, 460 - timer_irq(timer_ctx), 461 - timer_ctx->irq.level, 462 - timer_ctx); 463 - WARN_ON(ret); 464 - } 456 + if (userspace_irqchip(vcpu->kvm)) 457 + return; 458 + 459 + kvm_vgic_inject_irq(vcpu->kvm, vcpu, 460 + timer_irq(timer_ctx), 461 + timer_ctx->irq.level, 462 + timer_ctx); 465 463 } 466 464 467 465 /* Only called for a fully emulated timer */
-8
arch/arm64/kvm/arm.c
··· 2481 2481 per_cpu_ptr_nvhe_sym(kvm_host_data, cpu)->sve_state = 2482 2482 kern_hyp_va(sve_state); 2483 2483 } 2484 - } else { 2485 - for_each_possible_cpu(cpu) { 2486 - struct user_fpsimd_state *fpsimd_state; 2487 - 2488 - fpsimd_state = &per_cpu_ptr_nvhe_sym(kvm_host_data, cpu)->host_ctxt.fp_regs; 2489 - per_cpu_ptr_nvhe_sym(kvm_host_data, cpu)->fpsimd_state = 2490 - kern_hyp_va(fpsimd_state); 2491 - } 2492 2484 } 2493 2485 } 2494 2486
+9 -98
arch/arm64/kvm/fpsimd.c
··· 54 54 if (!system_supports_fpsimd()) 55 55 return; 56 56 57 - fpsimd_kvm_prepare(); 58 - 59 57 /* 60 - * We will check TIF_FOREIGN_FPSTATE just before entering the 61 - * guest in kvm_arch_vcpu_ctxflush_fp() and override this to 62 - * FP_STATE_FREE if the flag set. 58 + * Ensure that any host FPSIMD/SVE/SME state is saved and unbound such 59 + * that the host kernel is responsible for restoring this state upon 60 + * return to userspace, and the hyp code doesn't need to save anything. 61 + * 62 + * When the host may use SME, fpsimd_save_and_flush_cpu_state() ensures 63 + * that PSTATE.{SM,ZA} == {0,0}. 63 64 */ 64 - *host_data_ptr(fp_owner) = FP_STATE_HOST_OWNED; 65 - *host_data_ptr(fpsimd_state) = kern_hyp_va(&current->thread.uw.fpsimd_state); 66 - *host_data_ptr(fpmr_ptr) = kern_hyp_va(&current->thread.uw.fpmr); 65 + fpsimd_save_and_flush_cpu_state(); 66 + *host_data_ptr(fp_owner) = FP_STATE_FREE; 67 67 68 - host_data_clear_flag(HOST_SVE_ENABLED); 69 - if (read_sysreg(cpacr_el1) & CPACR_EL1_ZEN_EL0EN) 70 - host_data_set_flag(HOST_SVE_ENABLED); 71 - 72 - if (system_supports_sme()) { 73 - host_data_clear_flag(HOST_SME_ENABLED); 74 - if (read_sysreg(cpacr_el1) & CPACR_EL1_SMEN_EL0EN) 75 - host_data_set_flag(HOST_SME_ENABLED); 76 - 77 - /* 78 - * If PSTATE.SM is enabled then save any pending FP 79 - * state and disable PSTATE.SM. If we leave PSTATE.SM 80 - * enabled and the guest does not enable SME via 81 - * CPACR_EL1.SMEN then operations that should be valid 82 - * may generate SME traps from EL1 to EL1 which we 83 - * can't intercept and which would confuse the guest. 84 - * 85 - * Do the same for PSTATE.ZA in the case where there 86 - * is state in the registers which has not already 87 - * been saved, this is very unlikely to happen. 88 - */ 89 - if (read_sysreg_s(SYS_SVCR) & (SVCR_SM_MASK | SVCR_ZA_MASK)) { 90 - *host_data_ptr(fp_owner) = FP_STATE_FREE; 91 - fpsimd_save_and_flush_cpu_state(); 92 - } 93 - } 94 - 95 - /* 96 - * If normal guests gain SME support, maintain this behavior for pKVM 97 - * guests, which don't support SME. 98 - */ 99 - WARN_ON(is_protected_kvm_enabled() && system_supports_sme() && 100 - read_sysreg_s(SYS_SVCR)); 68 + WARN_ON_ONCE(system_supports_sme() && read_sysreg_s(SYS_SVCR)); 101 69 } 102 70 103 71 /* ··· 130 162 131 163 local_irq_save(flags); 132 164 133 - /* 134 - * If we have VHE then the Hyp code will reset CPACR_EL1 to 135 - * the default value and we need to reenable SME. 136 - */ 137 - if (has_vhe() && system_supports_sme()) { 138 - /* Also restore EL0 state seen on entry */ 139 - if (host_data_test_flag(HOST_SME_ENABLED)) 140 - sysreg_clear_set(CPACR_EL1, 0, CPACR_EL1_SMEN); 141 - else 142 - sysreg_clear_set(CPACR_EL1, 143 - CPACR_EL1_SMEN_EL0EN, 144 - CPACR_EL1_SMEN_EL1EN); 145 - isb(); 146 - } 147 - 148 165 if (guest_owns_fp_regs()) { 149 - if (vcpu_has_sve(vcpu)) { 150 - u64 zcr = read_sysreg_el1(SYS_ZCR); 151 - 152 - /* 153 - * If the vCPU is in the hyp context then ZCR_EL1 is 154 - * loaded with its vEL2 counterpart. 155 - */ 156 - __vcpu_sys_reg(vcpu, vcpu_sve_zcr_elx(vcpu)) = zcr; 157 - 158 - /* 159 - * Restore the VL that was saved when bound to the CPU, 160 - * which is the maximum VL for the guest. Because the 161 - * layout of the data when saving the sve state depends 162 - * on the VL, we need to use a consistent (i.e., the 163 - * maximum) VL. 164 - * Note that this means that at guest exit ZCR_EL1 is 165 - * not necessarily the same as on guest entry. 166 - * 167 - * ZCR_EL2 holds the guest hypervisor's VL when running 168 - * a nested guest, which could be smaller than the 169 - * max for the vCPU. Similar to above, we first need to 170 - * switch to a VL consistent with the layout of the 171 - * vCPU's SVE state. KVM support for NV implies VHE, so 172 - * using the ZCR_EL1 alias is safe. 173 - */ 174 - if (!has_vhe() || (vcpu_has_nv(vcpu) && !is_hyp_ctxt(vcpu))) 175 - sve_cond_update_zcr_vq(vcpu_sve_max_vq(vcpu) - 1, 176 - SYS_ZCR_EL1); 177 - } 178 - 179 166 /* 180 167 * Flush (save and invalidate) the fpsimd/sve state so that if 181 168 * the host tries to use fpsimd/sve, it's not using stale data ··· 142 219 * when needed. 143 220 */ 144 221 fpsimd_save_and_flush_cpu_state(); 145 - } else if (has_vhe() && system_supports_sve()) { 146 - /* 147 - * The FPSIMD/SVE state in the CPU has not been touched, and we 148 - * have SVE (and VHE): CPACR_EL1 (alias CPTR_EL2) has been 149 - * reset by kvm_reset_cptr_el2() in the Hyp code, disabling SVE 150 - * for EL0. To avoid spurious traps, restore the trap state 151 - * seen by kvm_arch_vcpu_load_fp(): 152 - */ 153 - if (host_data_test_flag(HOST_SVE_ENABLED)) 154 - sysreg_clear_set(CPACR_EL1, 0, CPACR_EL1_ZEN_EL0EN); 155 - else 156 - sysreg_clear_set(CPACR_EL1, CPACR_EL1_ZEN_EL0EN, 0); 157 222 } 158 223 159 224 local_irq_restore(flags);
+5
arch/arm64/kvm/hyp/entry.S
··· 44 44 alternative_else_nop_endif 45 45 mrs x1, isr_el1 46 46 cbz x1, 1f 47 + 48 + // Ensure that __guest_enter() always provides a context 49 + // synchronization event so that callers don't need ISBs for anything 50 + // that would usually be synchonized by the ERET. 51 + isb 47 52 mov x0, #ARM_EXCEPTION_IRQ 48 53 ret 49 54
+111 -37
arch/arm64/kvm/hyp/include/hyp/switch.h
··· 326 326 return __get_fault_info(vcpu->arch.fault.esr_el2, &vcpu->arch.fault); 327 327 } 328 328 329 - static bool kvm_hyp_handle_mops(struct kvm_vcpu *vcpu, u64 *exit_code) 329 + static inline bool kvm_hyp_handle_mops(struct kvm_vcpu *vcpu, u64 *exit_code) 330 330 { 331 331 *vcpu_pc(vcpu) = read_sysreg_el2(SYS_ELR); 332 332 arm64_mops_reset_regs(vcpu_gp_regs(vcpu), vcpu->arch.fault.esr_el2); ··· 375 375 true); 376 376 } 377 377 378 - static void kvm_hyp_save_fpsimd_host(struct kvm_vcpu *vcpu); 378 + static inline void fpsimd_lazy_switch_to_guest(struct kvm_vcpu *vcpu) 379 + { 380 + u64 zcr_el1, zcr_el2; 381 + 382 + if (!guest_owns_fp_regs()) 383 + return; 384 + 385 + if (vcpu_has_sve(vcpu)) { 386 + /* A guest hypervisor may restrict the effective max VL. */ 387 + if (vcpu_has_nv(vcpu) && !is_hyp_ctxt(vcpu)) 388 + zcr_el2 = __vcpu_sys_reg(vcpu, ZCR_EL2); 389 + else 390 + zcr_el2 = vcpu_sve_max_vq(vcpu) - 1; 391 + 392 + write_sysreg_el2(zcr_el2, SYS_ZCR); 393 + 394 + zcr_el1 = __vcpu_sys_reg(vcpu, vcpu_sve_zcr_elx(vcpu)); 395 + write_sysreg_el1(zcr_el1, SYS_ZCR); 396 + } 397 + } 398 + 399 + static inline void fpsimd_lazy_switch_to_host(struct kvm_vcpu *vcpu) 400 + { 401 + u64 zcr_el1, zcr_el2; 402 + 403 + if (!guest_owns_fp_regs()) 404 + return; 405 + 406 + /* 407 + * When the guest owns the FP regs, we know that guest+hyp traps for 408 + * any FPSIMD/SVE/SME features exposed to the guest have been disabled 409 + * by either fpsimd_lazy_switch_to_guest() or kvm_hyp_handle_fpsimd() 410 + * prior to __guest_entry(). As __guest_entry() guarantees a context 411 + * synchronization event, we don't need an ISB here to avoid taking 412 + * traps for anything that was exposed to the guest. 413 + */ 414 + if (vcpu_has_sve(vcpu)) { 415 + zcr_el1 = read_sysreg_el1(SYS_ZCR); 416 + __vcpu_sys_reg(vcpu, vcpu_sve_zcr_elx(vcpu)) = zcr_el1; 417 + 418 + /* 419 + * The guest's state is always saved using the guest's max VL. 420 + * Ensure that the host has the guest's max VL active such that 421 + * the host can save the guest's state lazily, but don't 422 + * artificially restrict the host to the guest's max VL. 423 + */ 424 + if (has_vhe()) { 425 + zcr_el2 = vcpu_sve_max_vq(vcpu) - 1; 426 + write_sysreg_el2(zcr_el2, SYS_ZCR); 427 + } else { 428 + zcr_el2 = sve_vq_from_vl(kvm_host_sve_max_vl) - 1; 429 + write_sysreg_el2(zcr_el2, SYS_ZCR); 430 + 431 + zcr_el1 = vcpu_sve_max_vq(vcpu) - 1; 432 + write_sysreg_el1(zcr_el1, SYS_ZCR); 433 + } 434 + } 435 + } 436 + 437 + static void kvm_hyp_save_fpsimd_host(struct kvm_vcpu *vcpu) 438 + { 439 + /* 440 + * Non-protected kvm relies on the host restoring its sve state. 441 + * Protected kvm restores the host's sve state as not to reveal that 442 + * fpsimd was used by a guest nor leak upper sve bits. 443 + */ 444 + if (system_supports_sve()) { 445 + __hyp_sve_save_host(); 446 + 447 + /* Re-enable SVE traps if not supported for the guest vcpu. */ 448 + if (!vcpu_has_sve(vcpu)) 449 + cpacr_clear_set(CPACR_EL1_ZEN, 0); 450 + 451 + } else { 452 + __fpsimd_save_state(host_data_ptr(host_ctxt.fp_regs)); 453 + } 454 + 455 + if (kvm_has_fpmr(kern_hyp_va(vcpu->kvm))) 456 + *host_data_ptr(fpmr) = read_sysreg_s(SYS_FPMR); 457 + } 458 + 379 459 380 460 /* 381 461 * We trap the first access to the FP/SIMD to save the host context and ··· 463 383 * If FP/SIMD is not implemented, handle the trap and inject an undefined 464 384 * instruction exception to the guest. Similarly for trapped SVE accesses. 465 385 */ 466 - static bool kvm_hyp_handle_fpsimd(struct kvm_vcpu *vcpu, u64 *exit_code) 386 + static inline bool kvm_hyp_handle_fpsimd(struct kvm_vcpu *vcpu, u64 *exit_code) 467 387 { 468 388 bool sve_guest; 469 389 u8 esr_ec; ··· 505 425 isb(); 506 426 507 427 /* Write out the host state if it's in the registers */ 508 - if (host_owns_fp_regs()) 428 + if (is_protected_kvm_enabled() && host_owns_fp_regs()) 509 429 kvm_hyp_save_fpsimd_host(vcpu); 510 430 511 431 /* Restore the guest state */ ··· 581 501 return true; 582 502 } 583 503 504 + /* Open-coded version of timer_get_offset() to allow for kern_hyp_va() */ 505 + static inline u64 hyp_timer_get_offset(struct arch_timer_context *ctxt) 506 + { 507 + u64 offset = 0; 508 + 509 + if (ctxt->offset.vm_offset) 510 + offset += *kern_hyp_va(ctxt->offset.vm_offset); 511 + if (ctxt->offset.vcpu_offset) 512 + offset += *kern_hyp_va(ctxt->offset.vcpu_offset); 513 + 514 + return offset; 515 + } 516 + 584 517 static inline u64 compute_counter_value(struct arch_timer_context *ctxt) 585 518 { 586 - return arch_timer_read_cntpct_el0() - timer_get_offset(ctxt); 519 + return arch_timer_read_cntpct_el0() - hyp_timer_get_offset(ctxt); 587 520 } 588 521 589 522 static bool kvm_handle_cntxct(struct kvm_vcpu *vcpu) ··· 680 587 return true; 681 588 } 682 589 683 - static bool kvm_hyp_handle_sysreg(struct kvm_vcpu *vcpu, u64 *exit_code) 590 + static inline bool kvm_hyp_handle_sysreg(struct kvm_vcpu *vcpu, u64 *exit_code) 684 591 { 685 592 if (cpus_have_final_cap(ARM64_WORKAROUND_CAVIUM_TX2_219_TVM) && 686 593 handle_tx2_tvm(vcpu)) ··· 700 607 return false; 701 608 } 702 609 703 - static bool kvm_hyp_handle_cp15_32(struct kvm_vcpu *vcpu, u64 *exit_code) 610 + static inline bool kvm_hyp_handle_cp15_32(struct kvm_vcpu *vcpu, u64 *exit_code) 704 611 { 705 612 if (static_branch_unlikely(&vgic_v3_cpuif_trap) && 706 613 __vgic_v3_perform_cpuif_access(vcpu) == 1) ··· 709 616 return false; 710 617 } 711 618 712 - static bool kvm_hyp_handle_memory_fault(struct kvm_vcpu *vcpu, u64 *exit_code) 619 + static inline bool kvm_hyp_handle_memory_fault(struct kvm_vcpu *vcpu, 620 + u64 *exit_code) 713 621 { 714 622 if (!__populate_fault_info(vcpu)) 715 623 return true; 716 624 717 625 return false; 718 626 } 719 - static bool kvm_hyp_handle_iabt_low(struct kvm_vcpu *vcpu, u64 *exit_code) 720 - __alias(kvm_hyp_handle_memory_fault); 721 - static bool kvm_hyp_handle_watchpt_low(struct kvm_vcpu *vcpu, u64 *exit_code) 722 - __alias(kvm_hyp_handle_memory_fault); 627 + #define kvm_hyp_handle_iabt_low kvm_hyp_handle_memory_fault 628 + #define kvm_hyp_handle_watchpt_low kvm_hyp_handle_memory_fault 723 629 724 - static bool kvm_hyp_handle_dabt_low(struct kvm_vcpu *vcpu, u64 *exit_code) 630 + static inline bool kvm_hyp_handle_dabt_low(struct kvm_vcpu *vcpu, u64 *exit_code) 725 631 { 726 632 if (kvm_hyp_handle_memory_fault(vcpu, exit_code)) 727 633 return true; ··· 750 658 751 659 typedef bool (*exit_handler_fn)(struct kvm_vcpu *, u64 *); 752 660 753 - static const exit_handler_fn *kvm_get_exit_handler_array(struct kvm_vcpu *vcpu); 754 - 755 - static void early_exit_filter(struct kvm_vcpu *vcpu, u64 *exit_code); 756 - 757 661 /* 758 662 * Allow the hypervisor to handle the exit with an exit handler if it has one. 759 663 * 760 664 * Returns true if the hypervisor handled the exit, and control should go back 761 665 * to the guest, or false if it hasn't. 762 666 */ 763 - static inline bool kvm_hyp_handle_exit(struct kvm_vcpu *vcpu, u64 *exit_code) 667 + static inline bool kvm_hyp_handle_exit(struct kvm_vcpu *vcpu, u64 *exit_code, 668 + const exit_handler_fn *handlers) 764 669 { 765 - const exit_handler_fn *handlers = kvm_get_exit_handler_array(vcpu); 766 - exit_handler_fn fn; 767 - 768 - fn = handlers[kvm_vcpu_trap_get_class(vcpu)]; 769 - 670 + exit_handler_fn fn = handlers[kvm_vcpu_trap_get_class(vcpu)]; 770 671 if (fn) 771 672 return fn(vcpu, exit_code); 772 673 ··· 789 704 * the guest, false when we should restore the host state and return to the 790 705 * main run loop. 791 706 */ 792 - static inline bool fixup_guest_exit(struct kvm_vcpu *vcpu, u64 *exit_code) 707 + static inline bool __fixup_guest_exit(struct kvm_vcpu *vcpu, u64 *exit_code, 708 + const exit_handler_fn *handlers) 793 709 { 794 - /* 795 - * Save PSTATE early so that we can evaluate the vcpu mode 796 - * early on. 797 - */ 798 - synchronize_vcpu_pstate(vcpu, exit_code); 799 - 800 - /* 801 - * Check whether we want to repaint the state one way or 802 - * another. 803 - */ 804 - early_exit_filter(vcpu, exit_code); 805 - 806 710 if (ARM_EXCEPTION_CODE(*exit_code) != ARM_EXCEPTION_IRQ) 807 711 vcpu->arch.fault.esr_el2 = read_sysreg_el2(SYS_ESR); 808 712 ··· 821 747 goto exit; 822 748 823 749 /* Check if there's an exit handler and allow it to handle the exit. */ 824 - if (kvm_hyp_handle_exit(vcpu, exit_code)) 750 + if (kvm_hyp_handle_exit(vcpu, exit_code, handlers)) 825 751 goto guest; 826 752 exit: 827 753 /* Return to the host kernel and handle the exit */
+7 -8
arch/arm64/kvm/hyp/nvhe/hyp-main.c
··· 5 5 */ 6 6 7 7 #include <hyp/adjust_pc.h> 8 + #include <hyp/switch.h> 8 9 9 10 #include <asm/pgtable-types.h> 10 11 #include <asm/kvm_asm.h> ··· 84 83 if (system_supports_sve()) 85 84 __hyp_sve_restore_host(); 86 85 else 87 - __fpsimd_restore_state(*host_data_ptr(fpsimd_state)); 86 + __fpsimd_restore_state(host_data_ptr(host_ctxt.fp_regs)); 88 87 89 88 if (has_fpmr) 90 89 write_sysreg_s(*host_data_ptr(fpmr), SYS_FPMR); ··· 225 224 226 225 sync_hyp_vcpu(hyp_vcpu); 227 226 } else { 227 + struct kvm_vcpu *vcpu = kern_hyp_va(host_vcpu); 228 + 228 229 /* The host is fully trusted, run its vCPU directly. */ 229 - ret = __kvm_vcpu_run(kern_hyp_va(host_vcpu)); 230 + fpsimd_lazy_switch_to_guest(vcpu); 231 + ret = __kvm_vcpu_run(vcpu); 232 + fpsimd_lazy_switch_to_host(vcpu); 230 233 } 231 234 out: 232 235 cpu_reg(host_ctxt, 1) = ret; ··· 679 674 break; 680 675 case ESR_ELx_EC_SMC64: 681 676 handle_host_smc(host_ctxt); 682 - break; 683 - case ESR_ELx_EC_SVE: 684 - cpacr_clear_set(0, CPACR_EL1_ZEN); 685 - isb(); 686 - sve_cond_update_zcr_vq(sve_vq_from_vl(kvm_host_sve_max_vl) - 1, 687 - SYS_ZCR_EL2); 688 677 break; 689 678 case ESR_ELx_EC_IABT_LOW: 690 679 case ESR_ELx_EC_DABT_LOW:
+41 -35
arch/arm64/kvm/hyp/nvhe/mem_protect.c
··· 943 943 ret = kvm_pgtable_get_leaf(&vm->pgt, ipa, &pte, &level); 944 944 if (ret) 945 945 return ret; 946 - if (level != KVM_PGTABLE_LAST_LEVEL) 947 - return -E2BIG; 948 946 if (!kvm_pte_valid(pte)) 949 947 return -ENOENT; 948 + if (level != KVM_PGTABLE_LAST_LEVEL) 949 + return -E2BIG; 950 950 951 951 state = guest_get_page_state(pte, ipa); 952 952 if (state != PKVM_PAGE_SHARED_BORROWED) ··· 998 998 return ret; 999 999 } 1000 1000 1001 - int __pkvm_host_relax_perms_guest(u64 gfn, struct pkvm_hyp_vcpu *vcpu, enum kvm_pgtable_prot prot) 1001 + static void assert_host_shared_guest(struct pkvm_hyp_vm *vm, u64 ipa) 1002 1002 { 1003 - struct pkvm_hyp_vm *vm = pkvm_hyp_vcpu_to_hyp_vm(vcpu); 1004 - u64 ipa = hyp_pfn_to_phys(gfn); 1005 1003 u64 phys; 1006 1004 int ret; 1007 1005 1008 - if (prot & ~KVM_PGTABLE_PROT_RWX) 1009 - return -EINVAL; 1006 + if (!IS_ENABLED(CONFIG_NVHE_EL2_DEBUG)) 1007 + return; 1010 1008 1011 1009 host_lock_component(); 1012 1010 guest_lock_component(vm); 1013 1011 1014 1012 ret = __check_host_shared_guest(vm, &phys, ipa); 1015 - if (!ret) 1016 - ret = kvm_pgtable_stage2_relax_perms(&vm->pgt, ipa, prot, 0); 1017 1013 1018 1014 guest_unlock_component(vm); 1019 1015 host_unlock_component(); 1016 + 1017 + WARN_ON(ret && ret != -ENOENT); 1018 + } 1019 + 1020 + int __pkvm_host_relax_perms_guest(u64 gfn, struct pkvm_hyp_vcpu *vcpu, enum kvm_pgtable_prot prot) 1021 + { 1022 + struct pkvm_hyp_vm *vm = pkvm_hyp_vcpu_to_hyp_vm(vcpu); 1023 + u64 ipa = hyp_pfn_to_phys(gfn); 1024 + int ret; 1025 + 1026 + if (pkvm_hyp_vm_is_protected(vm)) 1027 + return -EPERM; 1028 + 1029 + if (prot & ~KVM_PGTABLE_PROT_RWX) 1030 + return -EINVAL; 1031 + 1032 + assert_host_shared_guest(vm, ipa); 1033 + guest_lock_component(vm); 1034 + ret = kvm_pgtable_stage2_relax_perms(&vm->pgt, ipa, prot, 0); 1035 + guest_unlock_component(vm); 1020 1036 1021 1037 return ret; 1022 1038 } ··· 1040 1024 int __pkvm_host_wrprotect_guest(u64 gfn, struct pkvm_hyp_vm *vm) 1041 1025 { 1042 1026 u64 ipa = hyp_pfn_to_phys(gfn); 1043 - u64 phys; 1044 1027 int ret; 1045 1028 1046 - host_lock_component(); 1029 + if (pkvm_hyp_vm_is_protected(vm)) 1030 + return -EPERM; 1031 + 1032 + assert_host_shared_guest(vm, ipa); 1047 1033 guest_lock_component(vm); 1048 - 1049 - ret = __check_host_shared_guest(vm, &phys, ipa); 1050 - if (!ret) 1051 - ret = kvm_pgtable_stage2_wrprotect(&vm->pgt, ipa, PAGE_SIZE); 1052 - 1034 + ret = kvm_pgtable_stage2_wrprotect(&vm->pgt, ipa, PAGE_SIZE); 1053 1035 guest_unlock_component(vm); 1054 - host_unlock_component(); 1055 1036 1056 1037 return ret; 1057 1038 } ··· 1056 1043 int __pkvm_host_test_clear_young_guest(u64 gfn, bool mkold, struct pkvm_hyp_vm *vm) 1057 1044 { 1058 1045 u64 ipa = hyp_pfn_to_phys(gfn); 1059 - u64 phys; 1060 1046 int ret; 1061 1047 1062 - host_lock_component(); 1048 + if (pkvm_hyp_vm_is_protected(vm)) 1049 + return -EPERM; 1050 + 1051 + assert_host_shared_guest(vm, ipa); 1063 1052 guest_lock_component(vm); 1064 - 1065 - ret = __check_host_shared_guest(vm, &phys, ipa); 1066 - if (!ret) 1067 - ret = kvm_pgtable_stage2_test_clear_young(&vm->pgt, ipa, PAGE_SIZE, mkold); 1068 - 1053 + ret = kvm_pgtable_stage2_test_clear_young(&vm->pgt, ipa, PAGE_SIZE, mkold); 1069 1054 guest_unlock_component(vm); 1070 - host_unlock_component(); 1071 1055 1072 1056 return ret; 1073 1057 } ··· 1073 1063 { 1074 1064 struct pkvm_hyp_vm *vm = pkvm_hyp_vcpu_to_hyp_vm(vcpu); 1075 1065 u64 ipa = hyp_pfn_to_phys(gfn); 1076 - u64 phys; 1077 - int ret; 1078 1066 1079 - host_lock_component(); 1067 + if (pkvm_hyp_vm_is_protected(vm)) 1068 + return -EPERM; 1069 + 1070 + assert_host_shared_guest(vm, ipa); 1080 1071 guest_lock_component(vm); 1081 - 1082 - ret = __check_host_shared_guest(vm, &phys, ipa); 1083 - if (!ret) 1084 - kvm_pgtable_stage2_mkyoung(&vm->pgt, ipa, 0); 1085 - 1072 + kvm_pgtable_stage2_mkyoung(&vm->pgt, ipa, 0); 1086 1073 guest_unlock_component(vm); 1087 - host_unlock_component(); 1088 1074 1089 - return ret; 1075 + return 0; 1090 1076 }
+45 -44
arch/arm64/kvm/hyp/nvhe/switch.c
··· 39 39 { 40 40 u64 val = CPTR_EL2_TAM; /* Same bit irrespective of E2H */ 41 41 42 + if (!guest_owns_fp_regs()) 43 + __activate_traps_fpsimd32(vcpu); 44 + 42 45 if (has_hvhe()) { 43 46 val |= CPACR_EL1_TTA; 44 47 ··· 50 47 if (vcpu_has_sve(vcpu)) 51 48 val |= CPACR_EL1_ZEN; 52 49 } 50 + 51 + write_sysreg(val, cpacr_el1); 53 52 } else { 54 53 val |= CPTR_EL2_TTA | CPTR_NVHE_EL2_RES1; 55 54 ··· 66 61 67 62 if (!guest_owns_fp_regs()) 68 63 val |= CPTR_EL2_TFP; 64 + 65 + write_sysreg(val, cptr_el2); 69 66 } 67 + } 70 68 71 - if (!guest_owns_fp_regs()) 72 - __activate_traps_fpsimd32(vcpu); 69 + static void __deactivate_cptr_traps(struct kvm_vcpu *vcpu) 70 + { 71 + if (has_hvhe()) { 72 + u64 val = CPACR_EL1_FPEN; 73 73 74 - kvm_write_cptr_el2(val); 74 + if (cpus_have_final_cap(ARM64_SVE)) 75 + val |= CPACR_EL1_ZEN; 76 + if (cpus_have_final_cap(ARM64_SME)) 77 + val |= CPACR_EL1_SMEN; 78 + 79 + write_sysreg(val, cpacr_el1); 80 + } else { 81 + u64 val = CPTR_NVHE_EL2_RES1; 82 + 83 + if (!cpus_have_final_cap(ARM64_SVE)) 84 + val |= CPTR_EL2_TZ; 85 + if (!cpus_have_final_cap(ARM64_SME)) 86 + val |= CPTR_EL2_TSM; 87 + 88 + write_sysreg(val, cptr_el2); 89 + } 75 90 } 76 91 77 92 static void __activate_traps(struct kvm_vcpu *vcpu) ··· 144 119 145 120 write_sysreg(this_cpu_ptr(&kvm_init_params)->hcr_el2, hcr_el2); 146 121 147 - kvm_reset_cptr_el2(vcpu); 122 + __deactivate_cptr_traps(vcpu); 148 123 write_sysreg(__kvm_hyp_host_vector, vbar_el2); 149 124 } 150 125 ··· 217 192 kvm_handle_pvm_sysreg(vcpu, exit_code)); 218 193 } 219 194 220 - static void kvm_hyp_save_fpsimd_host(struct kvm_vcpu *vcpu) 221 - { 222 - /* 223 - * Non-protected kvm relies on the host restoring its sve state. 224 - * Protected kvm restores the host's sve state as not to reveal that 225 - * fpsimd was used by a guest nor leak upper sve bits. 226 - */ 227 - if (unlikely(is_protected_kvm_enabled() && system_supports_sve())) { 228 - __hyp_sve_save_host(); 229 - 230 - /* Re-enable SVE traps if not supported for the guest vcpu. */ 231 - if (!vcpu_has_sve(vcpu)) 232 - cpacr_clear_set(CPACR_EL1_ZEN, 0); 233 - 234 - } else { 235 - __fpsimd_save_state(*host_data_ptr(fpsimd_state)); 236 - } 237 - 238 - if (kvm_has_fpmr(kern_hyp_va(vcpu->kvm))) { 239 - u64 val = read_sysreg_s(SYS_FPMR); 240 - 241 - if (unlikely(is_protected_kvm_enabled())) 242 - *host_data_ptr(fpmr) = val; 243 - else 244 - **host_data_ptr(fpmr_ptr) = val; 245 - } 246 - } 247 - 248 195 static const exit_handler_fn hyp_exit_handlers[] = { 249 196 [0 ... ESR_ELx_EC_MAX] = NULL, 250 197 [ESR_ELx_EC_CP15_32] = kvm_hyp_handle_cp15_32, ··· 248 251 return hyp_exit_handlers; 249 252 } 250 253 251 - /* 252 - * Some guests (e.g., protected VMs) are not be allowed to run in AArch32. 253 - * The ARMv8 architecture does not give the hypervisor a mechanism to prevent a 254 - * guest from dropping to AArch32 EL0 if implemented by the CPU. If the 255 - * hypervisor spots a guest in such a state ensure it is handled, and don't 256 - * trust the host to spot or fix it. The check below is based on the one in 257 - * kvm_arch_vcpu_ioctl_run(). 258 - * 259 - * Returns false if the guest ran in AArch32 when it shouldn't have, and 260 - * thus should exit to the host, or true if a the guest run loop can continue. 261 - */ 262 - static void early_exit_filter(struct kvm_vcpu *vcpu, u64 *exit_code) 254 + static inline bool fixup_guest_exit(struct kvm_vcpu *vcpu, u64 *exit_code) 263 255 { 256 + const exit_handler_fn *handlers = kvm_get_exit_handler_array(vcpu); 257 + 258 + synchronize_vcpu_pstate(vcpu, exit_code); 259 + 260 + /* 261 + * Some guests (e.g., protected VMs) are not be allowed to run in 262 + * AArch32. The ARMv8 architecture does not give the hypervisor a 263 + * mechanism to prevent a guest from dropping to AArch32 EL0 if 264 + * implemented by the CPU. If the hypervisor spots a guest in such a 265 + * state ensure it is handled, and don't trust the host to spot or fix 266 + * it. The check below is based on the one in 267 + * kvm_arch_vcpu_ioctl_run(). 268 + */ 264 269 if (unlikely(vcpu_is_protected(vcpu) && vcpu_mode_is_32bit(vcpu))) { 265 270 /* 266 271 * As we have caught the guest red-handed, decide that it isn't ··· 275 276 *exit_code &= BIT(ARM_EXIT_WITH_SERROR_BIT); 276 277 *exit_code |= ARM_EXCEPTION_IL; 277 278 } 279 + 280 + return __fixup_guest_exit(vcpu, exit_code, handlers); 278 281 } 279 282 280 283 /* Switch to the guest for legacy non-VHE systems */
+19 -14
arch/arm64/kvm/hyp/vhe/switch.c
··· 136 136 write_sysreg(val, cpacr_el1); 137 137 } 138 138 139 + static void __deactivate_cptr_traps(struct kvm_vcpu *vcpu) 140 + { 141 + u64 val = CPACR_EL1_FPEN | CPACR_EL1_ZEN_EL1EN; 142 + 143 + if (cpus_have_final_cap(ARM64_SME)) 144 + val |= CPACR_EL1_SMEN_EL1EN; 145 + 146 + write_sysreg(val, cpacr_el1); 147 + } 148 + 139 149 static void __activate_traps(struct kvm_vcpu *vcpu) 140 150 { 141 151 u64 val; ··· 217 207 */ 218 208 asm(ALTERNATIVE("nop", "isb", ARM64_WORKAROUND_SPECULATIVE_AT)); 219 209 220 - kvm_reset_cptr_el2(vcpu); 210 + __deactivate_cptr_traps(vcpu); 221 211 222 212 if (!arm64_kernel_unmapped_at_el0()) 223 213 host_vectors = __this_cpu_read(this_cpu_vector); ··· 423 413 return true; 424 414 } 425 415 426 - static void kvm_hyp_save_fpsimd_host(struct kvm_vcpu *vcpu) 427 - { 428 - __fpsimd_save_state(*host_data_ptr(fpsimd_state)); 429 - 430 - if (kvm_has_fpmr(vcpu->kvm)) 431 - **host_data_ptr(fpmr_ptr) = read_sysreg_s(SYS_FPMR); 432 - } 433 - 434 416 static bool kvm_hyp_handle_tlbi_el2(struct kvm_vcpu *vcpu, u64 *exit_code) 435 417 { 436 418 int ret = -EINVAL; ··· 540 538 [ESR_ELx_EC_MOPS] = kvm_hyp_handle_mops, 541 539 }; 542 540 543 - static const exit_handler_fn *kvm_get_exit_handler_array(struct kvm_vcpu *vcpu) 541 + static inline bool fixup_guest_exit(struct kvm_vcpu *vcpu, u64 *exit_code) 544 542 { 545 - return hyp_exit_handlers; 546 - } 543 + synchronize_vcpu_pstate(vcpu, exit_code); 547 544 548 - static void early_exit_filter(struct kvm_vcpu *vcpu, u64 *exit_code) 549 - { 550 545 /* 551 546 * If we were in HYP context on entry, adjust the PSTATE view 552 547 * so that the usual helpers work correctly. ··· 563 564 *vcpu_cpsr(vcpu) &= ~(PSR_MODE_MASK | PSR_MODE32_BIT); 564 565 *vcpu_cpsr(vcpu) |= mode; 565 566 } 567 + 568 + return __fixup_guest_exit(vcpu, exit_code, hyp_exit_handlers); 566 569 } 567 570 568 571 /* Switch to the guest for VHE systems running in EL2 */ ··· 578 577 guest_ctxt = &vcpu->arch.ctxt; 579 578 580 579 sysreg_save_host_state_vhe(host_ctxt); 580 + 581 + fpsimd_lazy_switch_to_guest(vcpu); 581 582 582 583 /* 583 584 * Note that ARM erratum 1165522 requires us to configure both stage 1 ··· 604 601 sysreg_save_guest_state_vhe(guest_ctxt); 605 602 606 603 __deactivate_traps(vcpu); 604 + 605 + fpsimd_lazy_switch_to_host(vcpu); 607 606 608 607 sysreg_restore_host_state_vhe(host_ctxt); 609 608
+37 -37
arch/arm64/kvm/vgic/vgic-init.c
··· 34 34 * 35 35 * CPU Interface: 36 36 * 37 - * - kvm_vgic_vcpu_init(): initialization of static data that 38 - * doesn't depend on any sizing information or emulation type. No 39 - * allocation is allowed there. 37 + * - kvm_vgic_vcpu_init(): initialization of static data that doesn't depend 38 + * on any sizing information. Private interrupts are allocated if not 39 + * already allocated at vgic-creation time. 40 40 */ 41 41 42 42 /* EARLY INIT */ ··· 57 57 } 58 58 59 59 /* CREATION */ 60 + 61 + static int vgic_allocate_private_irqs_locked(struct kvm_vcpu *vcpu, u32 type); 60 62 61 63 /** 62 64 * kvm_vgic_create: triggered by the instantiation of the VGIC device by ··· 111 109 112 110 if (atomic_read(&kvm->online_vcpus) > kvm->max_vcpus) { 113 111 ret = -E2BIG; 112 + goto out_unlock; 113 + } 114 + 115 + kvm_for_each_vcpu(i, vcpu, kvm) { 116 + ret = vgic_allocate_private_irqs_locked(vcpu, type); 117 + if (ret) 118 + break; 119 + } 120 + 121 + if (ret) { 122 + kvm_for_each_vcpu(i, vcpu, kvm) { 123 + struct vgic_cpu *vgic_cpu = &vcpu->arch.vgic_cpu; 124 + kfree(vgic_cpu->private_irqs); 125 + vgic_cpu->private_irqs = NULL; 126 + } 127 + 114 128 goto out_unlock; 115 129 } 116 130 ··· 198 180 return 0; 199 181 } 200 182 201 - static int vgic_allocate_private_irqs_locked(struct kvm_vcpu *vcpu) 183 + static int vgic_allocate_private_irqs_locked(struct kvm_vcpu *vcpu, u32 type) 202 184 { 203 185 struct vgic_cpu *vgic_cpu = &vcpu->arch.vgic_cpu; 204 186 int i; ··· 236 218 /* PPIs */ 237 219 irq->config = VGIC_CONFIG_LEVEL; 238 220 } 221 + 222 + switch (type) { 223 + case KVM_DEV_TYPE_ARM_VGIC_V3: 224 + irq->group = 1; 225 + irq->mpidr = kvm_vcpu_get_mpidr_aff(vcpu); 226 + break; 227 + case KVM_DEV_TYPE_ARM_VGIC_V2: 228 + irq->group = 0; 229 + irq->targets = BIT(vcpu->vcpu_id); 230 + break; 231 + } 239 232 } 240 233 241 234 return 0; 242 235 } 243 236 244 - static int vgic_allocate_private_irqs(struct kvm_vcpu *vcpu) 237 + static int vgic_allocate_private_irqs(struct kvm_vcpu *vcpu, u32 type) 245 238 { 246 239 int ret; 247 240 248 241 mutex_lock(&vcpu->kvm->arch.config_lock); 249 - ret = vgic_allocate_private_irqs_locked(vcpu); 242 + ret = vgic_allocate_private_irqs_locked(vcpu, type); 250 243 mutex_unlock(&vcpu->kvm->arch.config_lock); 251 244 252 245 return ret; ··· 287 258 if (!irqchip_in_kernel(vcpu->kvm)) 288 259 return 0; 289 260 290 - ret = vgic_allocate_private_irqs(vcpu); 261 + ret = vgic_allocate_private_irqs(vcpu, dist->vgic_model); 291 262 if (ret) 292 263 return ret; 293 264 ··· 324 295 { 325 296 struct vgic_dist *dist = &kvm->arch.vgic; 326 297 struct kvm_vcpu *vcpu; 327 - int ret = 0, i; 298 + int ret = 0; 328 299 unsigned long idx; 329 300 330 301 lockdep_assert_held(&kvm->arch.config_lock); ··· 343 314 ret = kvm_vgic_dist_init(kvm, dist->nr_spis); 344 315 if (ret) 345 316 goto out; 346 - 347 - /* Initialize groups on CPUs created before the VGIC type was known */ 348 - kvm_for_each_vcpu(idx, vcpu, kvm) { 349 - ret = vgic_allocate_private_irqs_locked(vcpu); 350 - if (ret) 351 - goto out; 352 - 353 - for (i = 0; i < VGIC_NR_PRIVATE_IRQS; i++) { 354 - struct vgic_irq *irq = vgic_get_vcpu_irq(vcpu, i); 355 - 356 - switch (dist->vgic_model) { 357 - case KVM_DEV_TYPE_ARM_VGIC_V3: 358 - irq->group = 1; 359 - irq->mpidr = kvm_vcpu_get_mpidr_aff(vcpu); 360 - break; 361 - case KVM_DEV_TYPE_ARM_VGIC_V2: 362 - irq->group = 0; 363 - irq->targets = 1U << idx; 364 - break; 365 - default: 366 - ret = -EINVAL; 367 - } 368 - 369 - vgic_put_irq(kvm, irq); 370 - 371 - if (ret) 372 - goto out; 373 - } 374 - } 375 317 376 318 /* 377 319 * If we have GICv4.1 enabled, unconditionally request enable the
+7
arch/arm64/mm/trans_pgd.c
··· 162 162 unsigned long next; 163 163 unsigned long addr = start; 164 164 165 + if (pgd_none(READ_ONCE(*dst_pgdp))) { 166 + dst_p4dp = trans_alloc(info); 167 + if (!dst_p4dp) 168 + return -ENOMEM; 169 + pgd_populate(NULL, dst_pgdp, dst_p4dp); 170 + } 171 + 165 172 dst_p4dp = p4d_offset(dst_pgdp, start); 166 173 src_p4dp = p4d_offset(src_pgdp, start); 167 174 do {
+2 -2
arch/mips/include/asm/ptrace.h
··· 27 27 */ 28 28 struct pt_regs { 29 29 #ifdef CONFIG_32BIT 30 - /* Pad bytes for argument save space on the stack. */ 31 - unsigned long pad0[8]; 30 + /* Saved syscall stack arguments; entries 0-3 unused. */ 31 + unsigned long args[8]; 32 32 #endif 33 33 34 34 /* Saved main processor registers. */
+8 -24
arch/mips/include/asm/syscall.h
··· 57 57 static inline void mips_get_syscall_arg(unsigned long *arg, 58 58 struct task_struct *task, struct pt_regs *regs, unsigned int n) 59 59 { 60 - unsigned long usp __maybe_unused = regs->regs[29]; 61 - 60 + #ifdef CONFIG_32BIT 62 61 switch (n) { 63 62 case 0: case 1: case 2: case 3: 64 63 *arg = regs->regs[4 + n]; 65 - 66 64 return; 67 - 68 - #ifdef CONFIG_32BIT 69 65 case 4: case 5: case 6: case 7: 70 - get_user(*arg, (int *)usp + n); 66 + *arg = regs->args[n]; 71 67 return; 72 - #endif 73 - 74 - #ifdef CONFIG_64BIT 75 - case 4: case 5: case 6: case 7: 76 - #ifdef CONFIG_MIPS32_O32 77 - if (test_tsk_thread_flag(task, TIF_32BIT_REGS)) 78 - get_user(*arg, (int *)usp + n); 79 - else 80 - #endif 81 - *arg = regs->regs[4 + n]; 82 - 83 - return; 84 - #endif 85 - 86 - default: 87 - BUG(); 88 68 } 89 - 90 - unreachable(); 69 + #else 70 + *arg = regs->regs[4 + n]; 71 + if ((IS_ENABLED(CONFIG_MIPS32_O32) && 72 + test_tsk_thread_flag(task, TIF_32BIT_REGS))) 73 + *arg = (unsigned int)*arg; 74 + #endif 91 75 } 92 76 93 77 static inline long syscall_get_error(struct task_struct *task,
+6
arch/mips/kernel/asm-offsets.c
··· 27 27 void output_ptreg_defines(void) 28 28 { 29 29 COMMENT("MIPS pt_regs offsets."); 30 + #ifdef CONFIG_32BIT 31 + OFFSET(PT_ARG4, pt_regs, args[4]); 32 + OFFSET(PT_ARG5, pt_regs, args[5]); 33 + OFFSET(PT_ARG6, pt_regs, args[6]); 34 + OFFSET(PT_ARG7, pt_regs, args[7]); 35 + #endif 30 36 OFFSET(PT_R0, pt_regs, regs[0]); 31 37 OFFSET(PT_R1, pt_regs, regs[1]); 32 38 OFFSET(PT_R2, pt_regs, regs[2]);
+4 -4
arch/mips/kernel/scall32-o32.S
··· 64 64 load_a7: user_lw(t8, 28(t0)) # argument #8 from usp 65 65 loads_done: 66 66 67 - sw t5, 16(sp) # argument #5 to ksp 68 - sw t6, 20(sp) # argument #6 to ksp 69 - sw t7, 24(sp) # argument #7 to ksp 70 - sw t8, 28(sp) # argument #8 to ksp 67 + sw t5, PT_ARG4(sp) # argument #5 to ksp 68 + sw t6, PT_ARG5(sp) # argument #6 to ksp 69 + sw t7, PT_ARG6(sp) # argument #7 to ksp 70 + sw t8, PT_ARG7(sp) # argument #8 to ksp 71 71 .set pop 72 72 73 73 .section __ex_table,"a"
+10 -2
arch/powerpc/include/asm/book3s/64/hash-4k.h
··· 77 77 /* 78 78 * With 4K page size the real_pte machinery is all nops. 79 79 */ 80 - #define __real_pte(e, p, o) ((real_pte_t){(e)}) 80 + static inline real_pte_t __real_pte(pte_t pte, pte_t *ptep, int offset) 81 + { 82 + return (real_pte_t){pte}; 83 + } 84 + 81 85 #define __rpte_to_pte(r) ((r).pte) 82 - #define __rpte_to_hidx(r,index) (pte_val(__rpte_to_pte(r)) >> H_PAGE_F_GIX_SHIFT) 86 + 87 + static inline unsigned long __rpte_to_hidx(real_pte_t rpte, unsigned long index) 88 + { 89 + return pte_val(__rpte_to_pte(rpte)) >> H_PAGE_F_GIX_SHIFT; 90 + } 83 91 84 92 #define pte_iterate_hashed_subpages(rpte, psize, va, index, shift) \ 85 93 do { \
+3 -1
arch/powerpc/lib/code-patching.c
··· 108 108 unsigned long addr; 109 109 int err; 110 110 111 - area = get_vm_area(PAGE_SIZE, VM_ALLOC); 111 + area = get_vm_area(PAGE_SIZE, 0); 112 112 if (!area) { 113 113 WARN_ONCE(1, "Failed to create text area for cpu %d\n", 114 114 cpu); ··· 493 493 494 494 orig_mm = start_using_temp_mm(patching_mm); 495 495 496 + kasan_disable_current(); 496 497 err = __patch_instructions(patch_addr, code, len, repeat_instr); 498 + kasan_enable_current(); 497 499 498 500 /* context synchronisation performed by __patch_instructions */ 499 501 stop_using_temp_mm(patching_mm, orig_mm);
-1
arch/s390/configs/debug_defconfig
··· 740 740 CONFIG_IMA_DEFAULT_HASH_SHA256=y 741 741 CONFIG_IMA_WRITE_POLICY=y 742 742 CONFIG_IMA_APPRAISE=y 743 - CONFIG_LSM="yama,loadpin,safesetid,integrity,selinux,smack,tomoyo,apparmor" 744 743 CONFIG_BUG_ON_DATA_CORRUPTION=y 745 744 CONFIG_CRYPTO_USER=m 746 745 # CONFIG_CRYPTO_MANAGER_DISABLE_TESTS is not set
-1
arch/s390/configs/defconfig
··· 725 725 CONFIG_IMA_DEFAULT_HASH_SHA256=y 726 726 CONFIG_IMA_WRITE_POLICY=y 727 727 CONFIG_IMA_APPRAISE=y 728 - CONFIG_LSM="yama,loadpin,safesetid,integrity,selinux,smack,tomoyo,apparmor" 729 728 CONFIG_BUG_ON_DATA_CORRUPTION=y 730 729 CONFIG_CRYPTO_FIPS=y 731 730 CONFIG_CRYPTO_USER=m
-1
arch/s390/configs/zfcpdump_defconfig
··· 62 62 # CONFIG_INOTIFY_USER is not set 63 63 # CONFIG_MISC_FILESYSTEMS is not set 64 64 # CONFIG_NETWORK_FILESYSTEMS is not set 65 - CONFIG_LSM="yama,loadpin,safesetid,integrity" 66 65 # CONFIG_ZLIB_DFLTCC is not set 67 66 CONFIG_XZ_DEC_MICROLZMA=y 68 67 CONFIG_PRINTK_TIME=y
+5 -1
arch/s390/include/asm/bitops.h
··· 53 53 unsigned long mask; 54 54 int cc; 55 55 56 - if (__builtin_constant_p(nr)) { 56 + /* 57 + * With CONFIG_PROFILE_ALL_BRANCHES enabled gcc fails to 58 + * handle __builtin_constant_p() in some cases. 59 + */ 60 + if (!IS_ENABLED(CONFIG_PROFILE_ALL_BRANCHES) && __builtin_constant_p(nr)) { 57 61 addr = (const volatile unsigned char *)ptr; 58 62 addr += (nr ^ (BITS_PER_LONG - BITS_PER_BYTE)) / BITS_PER_BYTE; 59 63 mask = 1UL << (nr & (BITS_PER_BYTE - 1));
+20
arch/s390/pci/pci_bus.c
··· 331 331 return rc; 332 332 } 333 333 334 + static bool zpci_bus_is_isolated_vf(struct zpci_bus *zbus, struct zpci_dev *zdev) 335 + { 336 + struct pci_dev *pdev; 337 + 338 + pdev = zpci_iov_find_parent_pf(zbus, zdev); 339 + if (!pdev) 340 + return true; 341 + pci_dev_put(pdev); 342 + return false; 343 + } 344 + 334 345 int zpci_bus_device_register(struct zpci_dev *zdev, struct pci_ops *ops) 335 346 { 336 347 bool topo_is_tid = zdev->tid_avail; ··· 356 345 357 346 topo = topo_is_tid ? zdev->tid : zdev->pchid; 358 347 zbus = zpci_bus_get(topo, topo_is_tid); 348 + /* 349 + * An isolated VF gets its own domain/bus even if there exists 350 + * a matching domain/bus already 351 + */ 352 + if (zbus && zpci_bus_is_isolated_vf(zbus, zdev)) { 353 + zpci_bus_put(zbus); 354 + zbus = NULL; 355 + } 356 + 359 357 if (!zbus) { 360 358 zbus = zpci_bus_alloc(topo, topo_is_tid); 361 359 if (!zbus)
+42 -14
arch/s390/pci/pci_iov.c
··· 60 60 return 0; 61 61 } 62 62 63 - int zpci_iov_setup_virtfn(struct zpci_bus *zbus, struct pci_dev *virtfn, int vfn) 63 + /** 64 + * zpci_iov_find_parent_pf - Find the parent PF, if any, of the given function 65 + * @zbus: The bus that the PCI function is on, or would be added on 66 + * @zdev: The PCI function 67 + * 68 + * Finds the parent PF, if it exists and is configured, of the given PCI function 69 + * and increments its refcount. Th PF is searched for on the provided bus so the 70 + * caller has to ensure that this is the correct bus to search. This function may 71 + * be used before adding the PCI function to a zbus. 72 + * 73 + * Return: Pointer to the struct pci_dev of the parent PF or NULL if it not 74 + * found. If the function is not a VF or has no RequesterID information, 75 + * NULL is returned as well. 76 + */ 77 + struct pci_dev *zpci_iov_find_parent_pf(struct zpci_bus *zbus, struct zpci_dev *zdev) 64 78 { 65 - int i, cand_devfn; 66 - struct zpci_dev *zdev; 79 + int i, vfid, devfn, cand_devfn; 67 80 struct pci_dev *pdev; 68 - int vfid = vfn - 1; /* Linux' vfid's start at 0 vfn at 1*/ 69 - int rc = 0; 70 81 71 82 if (!zbus->multifunction) 72 - return 0; 73 - 74 - /* If the parent PF for the given VF is also configured in the 83 + return NULL; 84 + /* Non-VFs and VFs without RID available don't have a parent */ 85 + if (!zdev->vfn || !zdev->rid_available) 86 + return NULL; 87 + /* Linux vfid starts at 0 vfn at 1 */ 88 + vfid = zdev->vfn - 1; 89 + devfn = zdev->rid & ZPCI_RID_MASK_DEVFN; 90 + /* 91 + * If the parent PF for the given VF is also configured in the 75 92 * instance, it must be on the same zbus. 76 93 * We can then identify the parent PF by checking what 77 94 * devfn the VF would have if it belonged to that PF using the PF's ··· 102 85 if (!pdev) 103 86 continue; 104 87 cand_devfn = pci_iov_virtfn_devfn(pdev, vfid); 105 - if (cand_devfn == virtfn->devfn) { 106 - rc = zpci_iov_link_virtfn(pdev, virtfn, vfid); 107 - /* balance pci_get_slot() */ 108 - pci_dev_put(pdev); 109 - break; 110 - } 88 + if (cand_devfn == devfn) 89 + return pdev; 111 90 /* balance pci_get_slot() */ 112 91 pci_dev_put(pdev); 113 92 } 93 + } 94 + return NULL; 95 + } 96 + 97 + int zpci_iov_setup_virtfn(struct zpci_bus *zbus, struct pci_dev *virtfn, int vfn) 98 + { 99 + struct zpci_dev *zdev = to_zpci(virtfn); 100 + struct pci_dev *pdev_pf; 101 + int rc = 0; 102 + 103 + pdev_pf = zpci_iov_find_parent_pf(zbus, zdev); 104 + if (pdev_pf) { 105 + /* Linux' vfids start at 0 while zdev->vfn starts at 1 */ 106 + rc = zpci_iov_link_virtfn(pdev_pf, virtfn, zdev->vfn - 1); 107 + pci_dev_put(pdev_pf); 114 108 } 115 109 return rc; 116 110 }
+7
arch/s390/pci/pci_iov.h
··· 19 19 20 20 int zpci_iov_setup_virtfn(struct zpci_bus *zbus, struct pci_dev *virtfn, int vfn); 21 21 22 + struct pci_dev *zpci_iov_find_parent_pf(struct zpci_bus *zbus, struct zpci_dev *zdev); 23 + 22 24 #else /* CONFIG_PCI_IOV */ 23 25 static inline void zpci_iov_remove_virtfn(struct pci_dev *pdev, int vfn) {} 24 26 ··· 29 27 static inline int zpci_iov_setup_virtfn(struct zpci_bus *zbus, struct pci_dev *virtfn, int vfn) 30 28 { 31 29 return 0; 30 + } 31 + 32 + static inline struct pci_dev *zpci_iov_find_parent_pf(struct zpci_bus *zbus, struct zpci_dev *zdev) 33 + { 34 + return NULL; 32 35 } 33 36 #endif /* CONFIG_PCI_IOV */ 34 37 #endif /* __S390_PCI_IOV_h */
+101 -95
arch/um/drivers/virt-pci.c
··· 25 25 #define MAX_IRQ_MSG_SIZE (sizeof(struct virtio_pcidev_msg) + sizeof(u32)) 26 26 #define NUM_IRQ_MSGS 10 27 27 28 - #define HANDLE_NO_FREE(ptr) ((void *)((unsigned long)(ptr) | 1)) 29 - #define HANDLE_IS_NO_FREE(ptr) ((unsigned long)(ptr) & 1) 28 + struct um_pci_message_buffer { 29 + struct virtio_pcidev_msg hdr; 30 + u8 data[8]; 31 + }; 30 32 31 33 struct um_pci_device { 32 34 struct virtio_device *vdev; ··· 37 35 u8 resptr[PCI_STD_NUM_BARS]; 38 36 39 37 struct virtqueue *cmd_vq, *irq_vq; 38 + 39 + #define UM_PCI_WRITE_BUFS 20 40 + struct um_pci_message_buffer bufs[UM_PCI_WRITE_BUFS + 1]; 41 + void *extra_ptrs[UM_PCI_WRITE_BUFS + 1]; 42 + DECLARE_BITMAP(used_bufs, UM_PCI_WRITE_BUFS); 40 43 41 44 #define UM_PCI_STAT_WAITING 0 42 45 unsigned long status; ··· 68 61 static unsigned int um_pci_max_delay_us = 40000; 69 62 module_param_named(max_delay_us, um_pci_max_delay_us, uint, 0644); 70 63 71 - struct um_pci_message_buffer { 72 - struct virtio_pcidev_msg hdr; 73 - u8 data[8]; 74 - }; 64 + static int um_pci_get_buf(struct um_pci_device *dev, bool *posted) 65 + { 66 + int i; 75 67 76 - static struct um_pci_message_buffer __percpu *um_pci_msg_bufs; 68 + for (i = 0; i < UM_PCI_WRITE_BUFS; i++) { 69 + if (!test_and_set_bit(i, dev->used_bufs)) 70 + return i; 71 + } 72 + 73 + *posted = false; 74 + return UM_PCI_WRITE_BUFS; 75 + } 76 + 77 + static void um_pci_free_buf(struct um_pci_device *dev, void *buf) 78 + { 79 + int i; 80 + 81 + if (buf == &dev->bufs[UM_PCI_WRITE_BUFS]) { 82 + kfree(dev->extra_ptrs[UM_PCI_WRITE_BUFS]); 83 + dev->extra_ptrs[UM_PCI_WRITE_BUFS] = NULL; 84 + return; 85 + } 86 + 87 + for (i = 0; i < UM_PCI_WRITE_BUFS; i++) { 88 + if (buf == &dev->bufs[i]) { 89 + kfree(dev->extra_ptrs[i]); 90 + dev->extra_ptrs[i] = NULL; 91 + WARN_ON(!test_and_clear_bit(i, dev->used_bufs)); 92 + return; 93 + } 94 + } 95 + 96 + WARN_ON(1); 97 + } 77 98 78 99 static int um_pci_send_cmd(struct um_pci_device *dev, 79 100 struct virtio_pcidev_msg *cmd, ··· 117 82 }; 118 83 struct um_pci_message_buffer *buf; 119 84 int delay_count = 0; 85 + bool bounce_out; 120 86 int ret, len; 87 + int buf_idx; 121 88 bool posted; 122 89 123 90 if (WARN_ON(cmd_size < sizeof(*cmd) || cmd_size > sizeof(*buf))) ··· 138 101 break; 139 102 } 140 103 141 - buf = get_cpu_var(um_pci_msg_bufs); 142 - if (buf) 143 - memcpy(buf, cmd, cmd_size); 104 + bounce_out = !posted && cmd_size <= sizeof(*cmd) && 105 + out && out_size <= sizeof(buf->data); 144 106 145 - if (posted) { 146 - u8 *ncmd = kmalloc(cmd_size + extra_size, GFP_ATOMIC); 107 + buf_idx = um_pci_get_buf(dev, &posted); 108 + buf = &dev->bufs[buf_idx]; 109 + memcpy(buf, cmd, cmd_size); 147 110 148 - if (ncmd) { 149 - memcpy(ncmd, cmd, cmd_size); 150 - if (extra) 151 - memcpy(ncmd + cmd_size, extra, extra_size); 152 - cmd = (void *)ncmd; 153 - cmd_size += extra_size; 154 - extra = NULL; 155 - extra_size = 0; 156 - } else { 157 - /* try without allocating memory */ 158 - posted = false; 159 - cmd = (void *)buf; 111 + if (posted && extra && extra_size > sizeof(buf) - cmd_size) { 112 + dev->extra_ptrs[buf_idx] = kmemdup(extra, extra_size, 113 + GFP_ATOMIC); 114 + 115 + if (!dev->extra_ptrs[buf_idx]) { 116 + um_pci_free_buf(dev, buf); 117 + return -ENOMEM; 160 118 } 119 + extra = dev->extra_ptrs[buf_idx]; 120 + } else if (extra && extra_size <= sizeof(buf) - cmd_size) { 121 + memcpy((u8 *)buf + cmd_size, extra, extra_size); 122 + cmd_size += extra_size; 123 + extra_size = 0; 124 + extra = NULL; 125 + cmd = (void *)buf; 161 126 } else { 162 127 cmd = (void *)buf; 163 128 } ··· 167 128 sg_init_one(&out_sg, cmd, cmd_size); 168 129 if (extra) 169 130 sg_init_one(&extra_sg, extra, extra_size); 170 - if (out) 131 + /* allow stack for small buffers */ 132 + if (bounce_out) 133 + sg_init_one(&in_sg, buf->data, out_size); 134 + else if (out) 171 135 sg_init_one(&in_sg, out, out_size); 172 136 173 137 /* add to internal virtio queue */ 174 138 ret = virtqueue_add_sgs(dev->cmd_vq, sgs_list, 175 139 extra ? 2 : 1, 176 140 out ? 1 : 0, 177 - posted ? cmd : HANDLE_NO_FREE(cmd), 178 - GFP_ATOMIC); 141 + cmd, GFP_ATOMIC); 179 142 if (ret) { 180 - if (posted) 181 - kfree(cmd); 182 - goto out; 143 + um_pci_free_buf(dev, buf); 144 + return ret; 183 145 } 184 146 185 147 if (posted) { 186 148 virtqueue_kick(dev->cmd_vq); 187 - ret = 0; 188 - goto out; 149 + return 0; 189 150 } 190 151 191 152 /* kick and poll for getting a response on the queue */ 192 153 set_bit(UM_PCI_STAT_WAITING, &dev->status); 193 154 virtqueue_kick(dev->cmd_vq); 155 + ret = 0; 194 156 195 157 while (1) { 196 158 void *completed = virtqueue_get_buf(dev->cmd_vq, &len); 197 159 198 - if (completed == HANDLE_NO_FREE(cmd)) 160 + if (completed == buf) 199 161 break; 200 162 201 - if (completed && !HANDLE_IS_NO_FREE(completed)) 202 - kfree(completed); 163 + if (completed) 164 + um_pci_free_buf(dev, completed); 203 165 204 166 if (WARN_ONCE(virtqueue_is_broken(dev->cmd_vq) || 205 167 ++delay_count > um_pci_max_delay_us, ··· 212 172 } 213 173 clear_bit(UM_PCI_STAT_WAITING, &dev->status); 214 174 215 - out: 216 - put_cpu_var(um_pci_msg_bufs); 175 + if (bounce_out) 176 + memcpy(out, buf->data, out_size); 177 + 178 + um_pci_free_buf(dev, buf); 179 + 217 180 return ret; 218 181 } 219 182 ··· 230 187 .size = size, 231 188 .addr = offset, 232 189 }; 233 - /* buf->data is maximum size - we may only use parts of it */ 234 - struct um_pci_message_buffer *buf; 235 - u8 *data; 236 - unsigned long ret = ULONG_MAX; 237 - size_t bytes = sizeof(buf->data); 190 + /* max 8, we might not use it all */ 191 + u8 data[8]; 238 192 239 193 if (!dev) 240 194 return ULONG_MAX; 241 195 242 - buf = get_cpu_var(um_pci_msg_bufs); 243 - data = buf->data; 244 - 245 - if (buf) 246 - memset(data, 0xff, bytes); 196 + memset(data, 0xff, sizeof(data)); 247 197 248 198 switch (size) { 249 199 case 1: ··· 248 212 break; 249 213 default: 250 214 WARN(1, "invalid config space read size %d\n", size); 251 - goto out; 215 + return ULONG_MAX; 252 216 } 253 217 254 - if (um_pci_send_cmd(dev, &hdr, sizeof(hdr), NULL, 0, data, bytes)) 255 - goto out; 218 + if (um_pci_send_cmd(dev, &hdr, sizeof(hdr), NULL, 0, data, size)) 219 + return ULONG_MAX; 256 220 257 221 switch (size) { 258 222 case 1: 259 - ret = data[0]; 260 - break; 223 + return data[0]; 261 224 case 2: 262 - ret = le16_to_cpup((void *)data); 263 - break; 225 + return le16_to_cpup((void *)data); 264 226 case 4: 265 - ret = le32_to_cpup((void *)data); 266 - break; 227 + return le32_to_cpup((void *)data); 267 228 #ifdef CONFIG_64BIT 268 229 case 8: 269 - ret = le64_to_cpup((void *)data); 270 - break; 230 + return le64_to_cpup((void *)data); 271 231 #endif 272 232 default: 273 - break; 233 + return ULONG_MAX; 274 234 } 275 - 276 - out: 277 - put_cpu_var(um_pci_msg_bufs); 278 - return ret; 279 235 } 280 236 281 237 static void um_pci_cfgspace_write(void *priv, unsigned int offset, int size, ··· 340 312 static unsigned long um_pci_bar_read(void *priv, unsigned int offset, 341 313 int size) 342 314 { 343 - /* buf->data is maximum size - we may only use parts of it */ 344 - struct um_pci_message_buffer *buf; 345 - u8 *data; 346 - unsigned long ret = ULONG_MAX; 347 - 348 - buf = get_cpu_var(um_pci_msg_bufs); 349 - data = buf->data; 315 + /* 8 is maximum size - we may only use parts of it */ 316 + u8 data[8]; 350 317 351 318 switch (size) { 352 319 case 1: ··· 353 330 break; 354 331 default: 355 332 WARN(1, "invalid config space read size %d\n", size); 356 - goto out; 333 + return ULONG_MAX; 357 334 } 358 335 359 336 um_pci_bar_copy_from(priv, data, offset, size); 360 337 361 338 switch (size) { 362 339 case 1: 363 - ret = data[0]; 364 - break; 340 + return data[0]; 365 341 case 2: 366 - ret = le16_to_cpup((void *)data); 367 - break; 342 + return le16_to_cpup((void *)data); 368 343 case 4: 369 - ret = le32_to_cpup((void *)data); 370 - break; 344 + return le32_to_cpup((void *)data); 371 345 #ifdef CONFIG_64BIT 372 346 case 8: 373 - ret = le64_to_cpup((void *)data); 374 - break; 347 + return le64_to_cpup((void *)data); 375 348 #endif 376 349 default: 377 - break; 350 + return ULONG_MAX; 378 351 } 379 - 380 - out: 381 - put_cpu_var(um_pci_msg_bufs); 382 - return ret; 383 352 } 384 353 385 354 static void um_pci_bar_copy_to(void *priv, unsigned int offset, ··· 538 523 if (test_bit(UM_PCI_STAT_WAITING, &dev->status)) 539 524 return; 540 525 541 - while ((cmd = virtqueue_get_buf(vq, &len))) { 542 - if (WARN_ON(HANDLE_IS_NO_FREE(cmd))) 543 - continue; 544 - kfree(cmd); 545 - } 526 + while ((cmd = virtqueue_get_buf(vq, &len))) 527 + um_pci_free_buf(dev, cmd); 546 528 } 547 529 548 530 static void um_pci_irq_vq_cb(struct virtqueue *vq) ··· 1018 1006 "No virtio device ID configured for PCI - no PCI support\n")) 1019 1007 return 0; 1020 1008 1021 - um_pci_msg_bufs = alloc_percpu(struct um_pci_message_buffer); 1022 - if (!um_pci_msg_bufs) 1023 - return -ENOMEM; 1024 - 1025 1009 bridge = pci_alloc_host_bridge(0); 1026 1010 if (!bridge) { 1027 1011 err = -ENOMEM; ··· 1078 1070 pci_free_resource_list(&bridge->windows); 1079 1071 pci_free_host_bridge(bridge); 1080 1072 } 1081 - free_percpu(um_pci_msg_bufs); 1082 1073 return err; 1083 1074 } 1084 1075 module_init(um_pci_init); ··· 1089 1082 irq_domain_remove(um_pci_inner_domain); 1090 1083 pci_free_resource_list(&bridge->windows); 1091 1084 pci_free_host_bridge(bridge); 1092 - free_percpu(um_pci_msg_bufs); 1093 1085 } 1094 1086 module_exit(um_pci_exit);
+4 -4
arch/um/drivers/virtio_uml.c
··· 52 52 struct platform_device *pdev; 53 53 struct virtio_uml_platform_data *pdata; 54 54 55 - spinlock_t sock_lock; 55 + raw_spinlock_t sock_lock; 56 56 int sock, req_fd, irq; 57 57 u64 features; 58 58 u64 protocol_features; ··· 246 246 if (request_ack) 247 247 msg->header.flags |= VHOST_USER_FLAG_NEED_REPLY; 248 248 249 - spin_lock_irqsave(&vu_dev->sock_lock, flags); 249 + raw_spin_lock_irqsave(&vu_dev->sock_lock, flags); 250 250 rc = full_sendmsg_fds(vu_dev->sock, msg, size, fds, num_fds); 251 251 if (rc < 0) 252 252 goto out; ··· 266 266 } 267 267 268 268 out: 269 - spin_unlock_irqrestore(&vu_dev->sock_lock, flags); 269 + raw_spin_unlock_irqrestore(&vu_dev->sock_lock, flags); 270 270 return rc; 271 271 } 272 272 ··· 1239 1239 goto error_free; 1240 1240 vu_dev->sock = rc; 1241 1241 1242 - spin_lock_init(&vu_dev->sock_lock); 1242 + raw_spin_lock_init(&vu_dev->sock_lock); 1243 1243 1244 1244 rc = vhost_user_init(vu_dev); 1245 1245 if (rc)
+47 -32
arch/um/kernel/irq.c
··· 52 52 bool sigio_workaround; 53 53 }; 54 54 55 - static DEFINE_SPINLOCK(irq_lock); 55 + static DEFINE_RAW_SPINLOCK(irq_lock); 56 56 static LIST_HEAD(active_fds); 57 57 static DECLARE_BITMAP(irqs_allocated, UM_LAST_SIGNAL_IRQ); 58 58 static bool irqs_suspended; ··· 257 257 return NULL; 258 258 } 259 259 260 - static void free_irq_entry(struct irq_entry *to_free, bool remove) 260 + static void remove_irq_entry(struct irq_entry *to_free, bool remove) 261 261 { 262 262 if (!to_free) 263 263 return; ··· 265 265 if (remove) 266 266 os_del_epoll_fd(to_free->fd); 267 267 list_del(&to_free->list); 268 - kfree(to_free); 269 268 } 270 269 271 270 static bool update_irq_entry(struct irq_entry *entry) ··· 285 286 return false; 286 287 } 287 288 288 - static void update_or_free_irq_entry(struct irq_entry *entry) 289 + static struct irq_entry *update_or_remove_irq_entry(struct irq_entry *entry) 289 290 { 290 - if (!update_irq_entry(entry)) 291 - free_irq_entry(entry, false); 291 + if (update_irq_entry(entry)) 292 + return NULL; 293 + remove_irq_entry(entry, false); 294 + return entry; 292 295 } 293 296 294 297 static int activate_fd(int irq, int fd, enum um_irq_type type, void *dev_id, 295 298 void (*timetravel_handler)(int, int, void *, 296 299 struct time_travel_event *)) 297 300 { 298 - struct irq_entry *irq_entry; 301 + struct irq_entry *irq_entry, *to_free = NULL; 299 302 int err, events = os_event_mask(type); 300 303 unsigned long flags; 301 304 ··· 305 304 if (err < 0) 306 305 goto out; 307 306 308 - spin_lock_irqsave(&irq_lock, flags); 307 + raw_spin_lock_irqsave(&irq_lock, flags); 309 308 irq_entry = get_irq_entry_by_fd(fd); 310 309 if (irq_entry) { 310 + already: 311 311 /* cannot register the same FD twice with the same type */ 312 312 if (WARN_ON(irq_entry->reg[type].events)) { 313 313 err = -EALREADY; ··· 318 316 /* temporarily disable to avoid IRQ-side locking */ 319 317 os_del_epoll_fd(fd); 320 318 } else { 321 - irq_entry = kzalloc(sizeof(*irq_entry), GFP_ATOMIC); 322 - if (!irq_entry) { 323 - err = -ENOMEM; 324 - goto out_unlock; 319 + struct irq_entry *new; 320 + 321 + /* don't restore interrupts */ 322 + raw_spin_unlock(&irq_lock); 323 + new = kzalloc(sizeof(*irq_entry), GFP_ATOMIC); 324 + if (!new) { 325 + local_irq_restore(flags); 326 + return -ENOMEM; 325 327 } 328 + raw_spin_lock(&irq_lock); 329 + irq_entry = get_irq_entry_by_fd(fd); 330 + if (irq_entry) { 331 + to_free = new; 332 + goto already; 333 + } 334 + irq_entry = new; 326 335 irq_entry->fd = fd; 327 336 list_add_tail(&irq_entry->list, &active_fds); 328 337 maybe_sigio_broken(fd); ··· 352 339 #endif 353 340 354 341 WARN_ON(!update_irq_entry(irq_entry)); 355 - spin_unlock_irqrestore(&irq_lock, flags); 356 - 357 - return 0; 342 + err = 0; 358 343 out_unlock: 359 - spin_unlock_irqrestore(&irq_lock, flags); 344 + raw_spin_unlock_irqrestore(&irq_lock, flags); 360 345 out: 346 + kfree(to_free); 361 347 return err; 362 348 } 363 349 ··· 370 358 struct irq_entry *to_free; 371 359 unsigned long flags; 372 360 373 - spin_lock_irqsave(&irq_lock, flags); 361 + raw_spin_lock_irqsave(&irq_lock, flags); 374 362 to_free = get_irq_entry_by_fd(fd); 375 - free_irq_entry(to_free, true); 376 - spin_unlock_irqrestore(&irq_lock, flags); 363 + remove_irq_entry(to_free, true); 364 + raw_spin_unlock_irqrestore(&irq_lock, flags); 365 + kfree(to_free); 377 366 } 378 367 EXPORT_SYMBOL(free_irq_by_fd); 379 368 380 369 static void free_irq_by_irq_and_dev(unsigned int irq, void *dev) 381 370 { 382 - struct irq_entry *entry; 371 + struct irq_entry *entry, *to_free = NULL; 383 372 unsigned long flags; 384 373 385 - spin_lock_irqsave(&irq_lock, flags); 374 + raw_spin_lock_irqsave(&irq_lock, flags); 386 375 list_for_each_entry(entry, &active_fds, list) { 387 376 enum um_irq_type i; 388 377 ··· 399 386 400 387 os_del_epoll_fd(entry->fd); 401 388 reg->events = 0; 402 - update_or_free_irq_entry(entry); 389 + to_free = update_or_remove_irq_entry(entry); 403 390 goto out; 404 391 } 405 392 } 406 393 out: 407 - spin_unlock_irqrestore(&irq_lock, flags); 394 + raw_spin_unlock_irqrestore(&irq_lock, flags); 395 + kfree(to_free); 408 396 } 409 397 410 398 void deactivate_fd(int fd, int irqnum) ··· 416 402 417 403 os_del_epoll_fd(fd); 418 404 419 - spin_lock_irqsave(&irq_lock, flags); 405 + raw_spin_lock_irqsave(&irq_lock, flags); 420 406 entry = get_irq_entry_by_fd(fd); 421 407 if (!entry) 422 408 goto out; ··· 428 414 entry->reg[i].events = 0; 429 415 } 430 416 431 - update_or_free_irq_entry(entry); 417 + entry = update_or_remove_irq_entry(entry); 432 418 out: 433 - spin_unlock_irqrestore(&irq_lock, flags); 419 + raw_spin_unlock_irqrestore(&irq_lock, flags); 420 + kfree(entry); 434 421 435 422 ignore_sigio_fd(fd); 436 423 } ··· 561 546 562 547 irqs_suspended = true; 563 548 564 - spin_lock_irqsave(&irq_lock, flags); 549 + raw_spin_lock_irqsave(&irq_lock, flags); 565 550 list_for_each_entry(entry, &active_fds, list) { 566 551 enum um_irq_type t; 567 552 bool clear = true; ··· 594 579 !__ignore_sigio_fd(entry->fd); 595 580 } 596 581 } 597 - spin_unlock_irqrestore(&irq_lock, flags); 582 + raw_spin_unlock_irqrestore(&irq_lock, flags); 598 583 } 599 584 600 585 void um_irqs_resume(void) ··· 603 588 unsigned long flags; 604 589 605 590 606 - spin_lock_irqsave(&irq_lock, flags); 591 + raw_spin_lock_irqsave(&irq_lock, flags); 607 592 list_for_each_entry(entry, &active_fds, list) { 608 593 if (entry->suspended) { 609 594 int err = os_set_fd_async(entry->fd); ··· 617 602 } 618 603 } 619 604 } 620 - spin_unlock_irqrestore(&irq_lock, flags); 605 + raw_spin_unlock_irqrestore(&irq_lock, flags); 621 606 622 607 irqs_suspended = false; 623 608 send_sigio_to_self(); ··· 628 613 struct irq_entry *entry; 629 614 unsigned long flags; 630 615 631 - spin_lock_irqsave(&irq_lock, flags); 616 + raw_spin_lock_irqsave(&irq_lock, flags); 632 617 list_for_each_entry(entry, &active_fds, list) { 633 618 enum um_irq_type t; 634 619 ··· 643 628 } 644 629 } 645 630 unlock: 646 - spin_unlock_irqrestore(&irq_lock, flags); 631 + raw_spin_unlock_irqrestore(&irq_lock, flags); 647 632 return 0; 648 633 } 649 634 #else
+9 -1
arch/um/kernel/process.c
··· 191 191 int arch_dup_task_struct(struct task_struct *dst, 192 192 struct task_struct *src) 193 193 { 194 - memcpy(dst, src, arch_task_struct_size); 194 + /* init_task is not dynamically sized (missing FPU state) */ 195 + if (unlikely(src == &init_task)) { 196 + memcpy(dst, src, sizeof(init_task)); 197 + memset((void *)dst + sizeof(init_task), 0, 198 + arch_task_struct_size - sizeof(init_task)); 199 + } else { 200 + memcpy(dst, src, arch_task_struct_size); 201 + } 202 + 195 203 return 0; 196 204 } 197 205
+13 -3
arch/um/os-Linux/skas/process.c
··· 181 181 182 182 static int stub_exe_fd; 183 183 184 + #ifndef CLOSE_RANGE_CLOEXEC 185 + #define CLOSE_RANGE_CLOEXEC (1U << 2) 186 + #endif 187 + 184 188 static int userspace_tramp(void *stack) 185 189 { 186 190 char *const argv[] = { "uml-userspace", NULL }; ··· 206 202 init_data.stub_data_fd = phys_mapping(uml_to_phys(stack), &offset); 207 203 init_data.stub_data_offset = MMAP_OFFSET(offset); 208 204 209 - /* Set CLOEXEC on all FDs and then unset on all memory related FDs */ 210 - close_range(0, ~0U, CLOSE_RANGE_CLOEXEC); 205 + /* 206 + * Avoid leaking unneeded FDs to the stub by setting CLOEXEC on all FDs 207 + * and then unsetting it on all memory related FDs. 208 + * This is not strictly necessary from a safety perspective. 209 + */ 210 + syscall(__NR_close_range, 0, ~0U, CLOSE_RANGE_CLOEXEC); 211 211 212 212 fcntl(init_data.stub_data_fd, F_SETFD, 0); 213 213 for (iomem = iomem_regions; iomem; iomem = iomem->next) ··· 232 224 if (ret != sizeof(init_data)) 233 225 exit(4); 234 226 235 - execveat(stub_exe_fd, "", argv, NULL, AT_EMPTY_PATH); 227 + /* Raw execveat for compatibility with older libc versions */ 228 + syscall(__NR_execveat, stub_exe_fd, (unsigned long)"", 229 + (unsigned long)argv, NULL, AT_EMPTY_PATH); 236 230 237 231 exit(5); 238 232 }
+14 -19
arch/x86/events/intel/core.c
··· 4905 4905 4906 4906 static void update_pmu_cap(struct x86_hybrid_pmu *pmu) 4907 4907 { 4908 - unsigned int sub_bitmaps, eax, ebx, ecx, edx; 4908 + unsigned int cntr, fixed_cntr, ecx, edx; 4909 + union cpuid35_eax eax; 4910 + union cpuid35_ebx ebx; 4909 4911 4910 - cpuid(ARCH_PERFMON_EXT_LEAF, &sub_bitmaps, &ebx, &ecx, &edx); 4912 + cpuid(ARCH_PERFMON_EXT_LEAF, &eax.full, &ebx.full, &ecx, &edx); 4911 4913 4912 - if (ebx & ARCH_PERFMON_EXT_UMASK2) 4914 + if (ebx.split.umask2) 4913 4915 pmu->config_mask |= ARCH_PERFMON_EVENTSEL_UMASK2; 4914 - if (ebx & ARCH_PERFMON_EXT_EQ) 4916 + if (ebx.split.eq) 4915 4917 pmu->config_mask |= ARCH_PERFMON_EVENTSEL_EQ; 4916 4918 4917 - if (sub_bitmaps & ARCH_PERFMON_NUM_COUNTER_LEAF_BIT) { 4919 + if (eax.split.cntr_subleaf) { 4918 4920 cpuid_count(ARCH_PERFMON_EXT_LEAF, ARCH_PERFMON_NUM_COUNTER_LEAF, 4919 - &eax, &ebx, &ecx, &edx); 4920 - pmu->cntr_mask64 = eax; 4921 - pmu->fixed_cntr_mask64 = ebx; 4921 + &cntr, &fixed_cntr, &ecx, &edx); 4922 + pmu->cntr_mask64 = cntr; 4923 + pmu->fixed_cntr_mask64 = fixed_cntr; 4922 4924 } 4923 4925 4924 4926 if (!intel_pmu_broken_perf_cap()) { ··· 4942 4940 pmu->intel_ctrl |= 1ULL << GLOBAL_CTRL_EN_PERF_METRICS; 4943 4941 else 4944 4942 pmu->intel_ctrl &= ~(1ULL << GLOBAL_CTRL_EN_PERF_METRICS); 4945 - 4946 - if (pmu->intel_cap.pebs_output_pt_available) 4947 - pmu->pmu.capabilities |= PERF_PMU_CAP_AUX_OUTPUT; 4948 - else 4949 - pmu->pmu.capabilities &= ~PERF_PMU_CAP_AUX_OUTPUT; 4950 4943 4951 4944 intel_pmu_check_event_constraints(pmu->event_constraints, 4952 4945 pmu->cntr_mask64, ··· 5020 5023 5021 5024 pr_info("%s PMU driver: ", pmu->name); 5022 5025 5023 - if (pmu->intel_cap.pebs_output_pt_available) 5024 - pr_cont("PEBS-via-PT "); 5025 - 5026 5026 pr_cont("\n"); 5027 5027 5028 5028 x86_pmu_show_pmu_cap(&pmu->pmu); ··· 5042 5048 5043 5049 init_debug_store_on_cpu(cpu); 5044 5050 /* 5045 - * Deal with CPUs that don't clear their LBRs on power-up. 5051 + * Deal with CPUs that don't clear their LBRs on power-up, and that may 5052 + * even boot with LBRs enabled. 5046 5053 */ 5054 + if (!static_cpu_has(X86_FEATURE_ARCH_LBR) && x86_pmu.lbr_nr) 5055 + msr_clear_bit(MSR_IA32_DEBUGCTLMSR, DEBUGCTLMSR_LBR_BIT); 5047 5056 intel_pmu_lbr_reset(); 5048 5057 5049 5058 cpuc->lbr_sel = NULL; ··· 6367 6370 pmu->intel_cap.capabilities = x86_pmu.intel_cap.capabilities; 6368 6371 if (pmu->pmu_type & hybrid_small_tiny) { 6369 6372 pmu->intel_cap.perf_metrics = 0; 6370 - pmu->intel_cap.pebs_output_pt_available = 1; 6371 6373 pmu->mid_ack = true; 6372 6374 } else if (pmu->pmu_type & hybrid_big) { 6373 6375 pmu->intel_cap.perf_metrics = 1; 6374 - pmu->intel_cap.pebs_output_pt_available = 0; 6375 6376 pmu->late_ack = true; 6376 6377 } 6377 6378 }
+9 -1
arch/x86/events/intel/ds.c
··· 2578 2578 } 2579 2579 pr_cont("PEBS fmt4%c%s, ", pebs_type, pebs_qual); 2580 2580 2581 - if (!is_hybrid() && x86_pmu.intel_cap.pebs_output_pt_available) { 2581 + /* 2582 + * The PEBS-via-PT is not supported on hybrid platforms, 2583 + * because not all CPUs of a hybrid machine support it. 2584 + * The global x86_pmu.intel_cap, which only contains the 2585 + * common capabilities, is used to check the availability 2586 + * of the feature. The per-PMU pebs_output_pt_available 2587 + * in a hybrid machine should be ignored. 2588 + */ 2589 + if (x86_pmu.intel_cap.pebs_output_pt_available) { 2582 2590 pr_cont("PEBS-via-PT, "); 2583 2591 x86_get_pmu(smp_processor_id())->capabilities |= PERF_PMU_CAP_AUX_OUTPUT; 2584 2592 }
+4 -8
arch/x86/events/rapl.c
··· 370 370 unsigned int rapl_pmu_idx; 371 371 struct rapl_pmus *rapl_pmus; 372 372 373 + /* only look at RAPL events */ 374 + if (event->attr.type != event->pmu->type) 375 + return -ENOENT; 376 + 373 377 /* unsupported modes and filters */ 374 378 if (event->attr.sample_period) /* no sampling */ 375 379 return -EINVAL; ··· 391 387 rapl_pmus_scope = rapl_pmus->pmu.scope; 392 388 393 389 if (rapl_pmus_scope == PERF_PMU_SCOPE_PKG || rapl_pmus_scope == PERF_PMU_SCOPE_DIE) { 394 - /* only look at RAPL package events */ 395 - if (event->attr.type != rapl_pmus_pkg->pmu.type) 396 - return -ENOENT; 397 - 398 390 cfg = array_index_nospec((long)cfg, NR_RAPL_PKG_DOMAINS + 1); 399 391 if (!cfg || cfg >= NR_RAPL_PKG_DOMAINS + 1) 400 392 return -EINVAL; ··· 398 398 bit = cfg - 1; 399 399 event->hw.event_base = rapl_model->rapl_pkg_msrs[bit].msr; 400 400 } else if (rapl_pmus_scope == PERF_PMU_SCOPE_CORE) { 401 - /* only look at RAPL core events */ 402 - if (event->attr.type != rapl_pmus_core->pmu.type) 403 - return -ENOENT; 404 - 405 401 cfg = array_index_nospec((long)cfg, NR_RAPL_CORE_DOMAINS + 1); 406 402 if (!cfg || cfg >= NR_RAPL_PKG_DOMAINS + 1) 407 403 return -EINVAL;
+1
arch/x86/include/asm/kvm-x86-ops.h
··· 48 48 KVM_X86_OP(get_gdt) 49 49 KVM_X86_OP(set_gdt) 50 50 KVM_X86_OP(sync_dirty_debug_regs) 51 + KVM_X86_OP(set_dr6) 51 52 KVM_X86_OP(set_dr7) 52 53 KVM_X86_OP(cache_reg) 53 54 KVM_X86_OP(get_rflags)
+1
arch/x86/include/asm/kvm_host.h
··· 1696 1696 void (*get_gdt)(struct kvm_vcpu *vcpu, struct desc_ptr *dt); 1697 1697 void (*set_gdt)(struct kvm_vcpu *vcpu, struct desc_ptr *dt); 1698 1698 void (*sync_dirty_debug_regs)(struct kvm_vcpu *vcpu); 1699 + void (*set_dr6)(struct kvm_vcpu *vcpu, unsigned long value); 1699 1700 void (*set_dr7)(struct kvm_vcpu *vcpu, unsigned long value); 1700 1701 void (*cache_reg)(struct kvm_vcpu *vcpu, enum kvm_reg reg); 1701 1702 unsigned long (*get_rflags)(struct kvm_vcpu *vcpu);
+2 -1
arch/x86/include/asm/msr-index.h
··· 395 395 #define MSR_IA32_PASID_VALID BIT_ULL(31) 396 396 397 397 /* DEBUGCTLMSR bits (others vary by model): */ 398 - #define DEBUGCTLMSR_LBR (1UL << 0) /* last branch recording */ 398 + #define DEBUGCTLMSR_LBR_BIT 0 /* last branch recording */ 399 + #define DEBUGCTLMSR_LBR (1UL << DEBUGCTLMSR_LBR_BIT) 399 400 #define DEBUGCTLMSR_BTF_SHIFT 1 400 401 #define DEBUGCTLMSR_BTF (1UL << 1) /* single-step on branches */ 401 402 #define DEBUGCTLMSR_BUS_LOCK_DETECT (1UL << 2)
+25 -3
arch/x86/include/asm/perf_event.h
··· 188 188 * detection/enumeration details: 189 189 */ 190 190 #define ARCH_PERFMON_EXT_LEAF 0x00000023 191 - #define ARCH_PERFMON_EXT_UMASK2 0x1 192 - #define ARCH_PERFMON_EXT_EQ 0x2 193 - #define ARCH_PERFMON_NUM_COUNTER_LEAF_BIT 0x1 194 191 #define ARCH_PERFMON_NUM_COUNTER_LEAF 0x1 192 + 193 + union cpuid35_eax { 194 + struct { 195 + unsigned int leaf0:1; 196 + /* Counters Sub-Leaf */ 197 + unsigned int cntr_subleaf:1; 198 + /* Auto Counter Reload Sub-Leaf */ 199 + unsigned int acr_subleaf:1; 200 + /* Events Sub-Leaf */ 201 + unsigned int events_subleaf:1; 202 + unsigned int reserved:28; 203 + } split; 204 + unsigned int full; 205 + }; 206 + 207 + union cpuid35_ebx { 208 + struct { 209 + /* UnitMask2 Supported */ 210 + unsigned int umask2:1; 211 + /* EQ-bit Supported */ 212 + unsigned int eq:1; 213 + unsigned int reserved:30; 214 + } split; 215 + unsigned int full; 216 + }; 195 217 196 218 /* 197 219 * Intel Architectural LBR CPUID detection/enumeration details:
+2
arch/x86/include/asm/sev.h
··· 531 531 532 532 #ifdef CONFIG_KVM_AMD_SEV 533 533 bool snp_probe_rmptable_info(void); 534 + int snp_rmptable_init(void); 534 535 int snp_lookup_rmpentry(u64 pfn, bool *assigned, int *level); 535 536 void snp_dump_hva_rmpentry(unsigned long address); 536 537 int psmash(u64 pfn); ··· 542 541 void snp_fixup_e820_tables(void); 543 542 #else 544 543 static inline bool snp_probe_rmptable_info(void) { return false; } 544 + static inline int snp_rmptable_init(void) { return -ENOSYS; } 545 545 static inline int snp_lookup_rmpentry(u64 pfn, bool *assigned, int *level) { return -ENODEV; } 546 546 static inline void snp_dump_hva_rmpentry(unsigned long address) {} 547 547 static inline int psmash(u64 pfn) { return -ENODEV; }
+5 -1
arch/x86/kvm/hyperv.c
··· 2226 2226 u32 vector; 2227 2227 bool all_cpus; 2228 2228 2229 + if (!lapic_in_kernel(vcpu)) 2230 + return HV_STATUS_INVALID_HYPERCALL_INPUT; 2231 + 2229 2232 if (hc->code == HVCALL_SEND_IPI) { 2230 2233 if (!hc->fast) { 2231 2234 if (unlikely(kvm_read_guest(kvm, hc->ingpa, &send_ipi, ··· 2855 2852 ent->eax |= HV_X64_REMOTE_TLB_FLUSH_RECOMMENDED; 2856 2853 ent->eax |= HV_X64_APIC_ACCESS_RECOMMENDED; 2857 2854 ent->eax |= HV_X64_RELAXED_TIMING_RECOMMENDED; 2858 - ent->eax |= HV_X64_CLUSTER_IPI_RECOMMENDED; 2855 + if (!vcpu || lapic_in_kernel(vcpu)) 2856 + ent->eax |= HV_X64_CLUSTER_IPI_RECOMMENDED; 2859 2857 ent->eax |= HV_X64_EX_PROCESSOR_MASKS_RECOMMENDED; 2860 2858 if (evmcs_ver) 2861 2859 ent->eax |= HV_X64_ENLIGHTENED_VMCS_RECOMMENDED;
+1 -1
arch/x86/kvm/mmu/mmu.c
··· 5540 5540 union kvm_mmu_page_role root_role; 5541 5541 5542 5542 /* NPT requires CR0.PG=1. */ 5543 - WARN_ON_ONCE(cpu_role.base.direct); 5543 + WARN_ON_ONCE(cpu_role.base.direct || !cpu_role.base.guest_mode); 5544 5544 5545 5545 root_role = cpu_role.base; 5546 5546 root_role.level = kvm_mmu_get_tdp_level(vcpu);
+5 -5
arch/x86/kvm/svm/nested.c
··· 646 646 u32 pause_count12; 647 647 u32 pause_thresh12; 648 648 649 + nested_svm_transition_tlb_flush(vcpu); 650 + 651 + /* Enter Guest-Mode */ 652 + enter_guest_mode(vcpu); 653 + 649 654 /* 650 655 * Filled at exit: exit_code, exit_code_hi, exit_info_1, exit_info_2, 651 656 * exit_int_info, exit_int_info_err, next_rip, insn_len, insn_bytes. ··· 766 761 vmcb02->control.pause_filter_thresh = 0; 767 762 } 768 763 } 769 - 770 - nested_svm_transition_tlb_flush(vcpu); 771 - 772 - /* Enter Guest-Mode */ 773 - enter_guest_mode(vcpu); 774 764 775 765 /* 776 766 * Merge guest and host intercepts - must be called with vcpu in
+10
arch/x86/kvm/svm/sev.c
··· 2972 2972 WARN_ON_ONCE(!boot_cpu_has(X86_FEATURE_FLUSHBYASID))) 2973 2973 goto out; 2974 2974 2975 + /* 2976 + * The kernel's initcall infrastructure lacks the ability to express 2977 + * dependencies between initcalls, whereas the modules infrastructure 2978 + * automatically handles dependencies via symbol loading. Ensure the 2979 + * PSP SEV driver is initialized before proceeding if KVM is built-in, 2980 + * as the dependency isn't handled by the initcall infrastructure. 2981 + */ 2982 + if (IS_BUILTIN(CONFIG_KVM_AMD) && sev_module_init()) 2983 + goto out; 2984 + 2975 2985 /* Retrieve SEV CPUID information */ 2976 2986 cpuid(0x8000001f, &eax, &ebx, &ecx, &edx); 2977 2987
+6 -7
arch/x86/kvm/svm/svm.c
··· 1991 1991 svm->asid = sd->next_asid++; 1992 1992 } 1993 1993 1994 - static void svm_set_dr6(struct vcpu_svm *svm, unsigned long value) 1994 + static void svm_set_dr6(struct kvm_vcpu *vcpu, unsigned long value) 1995 1995 { 1996 - struct vmcb *vmcb = svm->vmcb; 1996 + struct vmcb *vmcb = to_svm(vcpu)->vmcb; 1997 1997 1998 - if (svm->vcpu.arch.guest_state_protected) 1998 + if (vcpu->arch.guest_state_protected) 1999 1999 return; 2000 2000 2001 2001 if (unlikely(value != vmcb->save.dr6)) { ··· 4247 4247 * Run with all-zero DR6 unless needed, so that we can get the exact cause 4248 4248 * of a #DB. 4249 4249 */ 4250 - if (unlikely(vcpu->arch.switch_db_regs & KVM_DEBUGREG_WONT_EXIT)) 4251 - svm_set_dr6(svm, vcpu->arch.dr6); 4252 - else 4253 - svm_set_dr6(svm, DR6_ACTIVE_LOW); 4250 + if (likely(!(vcpu->arch.switch_db_regs & KVM_DEBUGREG_WONT_EXIT))) 4251 + svm_set_dr6(vcpu, DR6_ACTIVE_LOW); 4254 4252 4255 4253 clgi(); 4256 4254 kvm_load_guest_xsave_state(vcpu); ··· 5041 5043 .set_idt = svm_set_idt, 5042 5044 .get_gdt = svm_get_gdt, 5043 5045 .set_gdt = svm_set_gdt, 5046 + .set_dr6 = svm_set_dr6, 5044 5047 .set_dr7 = svm_set_dr7, 5045 5048 .sync_dirty_debug_regs = svm_sync_dirty_debug_regs, 5046 5049 .cache_reg = svm_cache_reg,
+1
arch/x86/kvm/vmx/main.c
··· 61 61 .set_idt = vmx_set_idt, 62 62 .get_gdt = vmx_get_gdt, 63 63 .set_gdt = vmx_set_gdt, 64 + .set_dr6 = vmx_set_dr6, 64 65 .set_dr7 = vmx_set_dr7, 65 66 .sync_dirty_debug_regs = vmx_sync_dirty_debug_regs, 66 67 .cache_reg = vmx_cache_reg,
+6 -4
arch/x86/kvm/vmx/vmx.c
··· 5648 5648 set_debugreg(DR6_RESERVED, 6); 5649 5649 } 5650 5650 5651 + void vmx_set_dr6(struct kvm_vcpu *vcpu, unsigned long val) 5652 + { 5653 + lockdep_assert_irqs_disabled(); 5654 + set_debugreg(vcpu->arch.dr6, 6); 5655 + } 5656 + 5651 5657 void vmx_set_dr7(struct kvm_vcpu *vcpu, unsigned long val) 5652 5658 { 5653 5659 vmcs_writel(GUEST_DR7, val); ··· 7422 7416 vmcs_writel(HOST_CR4, cr4); 7423 7417 vmx->loaded_vmcs->host_state.cr4 = cr4; 7424 7418 } 7425 - 7426 - /* When KVM_DEBUGREG_WONT_EXIT, dr6 is accessible in guest. */ 7427 - if (unlikely(vcpu->arch.switch_db_regs & KVM_DEBUGREG_WONT_EXIT)) 7428 - set_debugreg(vcpu->arch.dr6, 6); 7429 7419 7430 7420 /* When single-stepping over STI and MOV SS, we must clear the 7431 7421 * corresponding interruptibility bits in the guest state. Otherwise
+1
arch/x86/kvm/vmx/x86_ops.h
··· 73 73 void vmx_set_idt(struct kvm_vcpu *vcpu, struct desc_ptr *dt); 74 74 void vmx_get_gdt(struct kvm_vcpu *vcpu, struct desc_ptr *dt); 75 75 void vmx_set_gdt(struct kvm_vcpu *vcpu, struct desc_ptr *dt); 76 + void vmx_set_dr6(struct kvm_vcpu *vcpu, unsigned long val); 76 77 void vmx_set_dr7(struct kvm_vcpu *vcpu, unsigned long val); 77 78 void vmx_sync_dirty_debug_regs(struct kvm_vcpu *vcpu); 78 79 void vmx_cache_reg(struct kvm_vcpu *vcpu, enum kvm_reg reg);
+3
arch/x86/kvm/x86.c
··· 10961 10961 set_debugreg(vcpu->arch.eff_db[1], 1); 10962 10962 set_debugreg(vcpu->arch.eff_db[2], 2); 10963 10963 set_debugreg(vcpu->arch.eff_db[3], 3); 10964 + /* When KVM_DEBUGREG_WONT_EXIT, dr6 is accessible in guest. */ 10965 + if (unlikely(vcpu->arch.switch_db_regs & KVM_DEBUGREG_WONT_EXIT)) 10966 + kvm_x86_call(set_dr6)(vcpu, vcpu->arch.dr6); 10964 10967 } else if (unlikely(hw_breakpoint_active())) { 10965 10968 set_debugreg(0, 7); 10966 10969 }
+18 -3
arch/x86/um/os-Linux/registers.c
··· 18 18 #include <registers.h> 19 19 #include <sys/mman.h> 20 20 21 + static unsigned long ptrace_regset; 21 22 unsigned long host_fp_size; 22 23 23 24 int get_fp_registers(int pid, unsigned long *regs) ··· 28 27 .iov_len = host_fp_size, 29 28 }; 30 29 31 - if (ptrace(PTRACE_GETREGSET, pid, NT_X86_XSTATE, &iov) < 0) 30 + if (ptrace(PTRACE_GETREGSET, pid, ptrace_regset, &iov) < 0) 32 31 return -errno; 33 32 return 0; 34 33 } ··· 40 39 .iov_len = host_fp_size, 41 40 }; 42 41 43 - if (ptrace(PTRACE_SETREGSET, pid, NT_X86_XSTATE, &iov) < 0) 42 + if (ptrace(PTRACE_SETREGSET, pid, ptrace_regset, &iov) < 0) 44 43 return -errno; 45 44 return 0; 46 45 } ··· 59 58 return -ENOMEM; 60 59 61 60 /* GDB has x86_xsave_length, which uses x86_cpuid_count */ 62 - ret = ptrace(PTRACE_GETREGSET, pid, NT_X86_XSTATE, &iov); 61 + ptrace_regset = NT_X86_XSTATE; 62 + ret = ptrace(PTRACE_GETREGSET, pid, ptrace_regset, &iov); 63 63 if (ret) 64 64 ret = -errno; 65 + 66 + if (ret == -ENODEV) { 67 + #ifdef CONFIG_X86_32 68 + ptrace_regset = NT_PRXFPREG; 69 + #else 70 + ptrace_regset = NT_PRFPREG; 71 + #endif 72 + iov.iov_len = 2 * 1024 * 1024; 73 + ret = ptrace(PTRACE_GETREGSET, pid, ptrace_regset, &iov); 74 + if (ret) 75 + ret = -errno; 76 + } 77 + 65 78 munmap(iov.iov_base, 2 * 1024 * 1024); 66 79 67 80 host_fp_size = iov.iov_len;
+10 -3
arch/x86/um/signal.c
··· 187 187 * Put magic/size values for userspace. We do not bother to verify them 188 188 * later on, however, userspace needs them should it try to read the 189 189 * XSTATE data. And ptrace does not fill in these parts. 190 + * 191 + * Skip this if we do not have an XSTATE frame. 190 192 */ 193 + if (host_fp_size <= sizeof(to_fp64->fpstate)) 194 + return 0; 195 + 191 196 BUILD_BUG_ON(sizeof(int) != FP_XSTATE_MAGIC2_SIZE); 192 197 #ifdef CONFIG_X86_32 193 198 __put_user(offsetof(struct _fpstate_32, _fxsr_env) + ··· 372 367 int err = 0, sig = ksig->sig; 373 368 unsigned long fp_to; 374 369 375 - frame = (struct rt_sigframe __user *) 376 - round_down(stack_top - sizeof(struct rt_sigframe), 16); 370 + frame = (void __user *)stack_top - sizeof(struct rt_sigframe); 377 371 378 372 /* Add required space for math frame */ 379 - frame = (struct rt_sigframe __user *)((unsigned long)frame - math_size); 373 + frame = (void __user *)((unsigned long)frame - math_size); 374 + 375 + /* ABI requires 16 byte boundary alignment */ 376 + frame = (void __user *)round_down((unsigned long)frame, 16); 380 377 381 378 /* Subtract 128 for a red zone and 8 for proper alignment */ 382 379 frame = (struct rt_sigframe __user *) ((unsigned long) frame - 128 - 8);
+7 -16
arch/x86/virt/svm/sev.c
··· 505 505 * described in the SNP_INIT_EX firmware command description in the SNP 506 506 * firmware ABI spec. 507 507 */ 508 - static int __init snp_rmptable_init(void) 508 + int __init snp_rmptable_init(void) 509 509 { 510 510 unsigned int i; 511 511 u64 val; 512 512 513 - if (!cc_platform_has(CC_ATTR_HOST_SEV_SNP)) 514 - return 0; 513 + if (WARN_ON_ONCE(!cc_platform_has(CC_ATTR_HOST_SEV_SNP))) 514 + return -ENOSYS; 515 515 516 - if (!amd_iommu_snp_en) 517 - goto nosnp; 516 + if (WARN_ON_ONCE(!amd_iommu_snp_en)) 517 + return -ENOSYS; 518 518 519 519 if (!setup_rmptable()) 520 - goto nosnp; 520 + return -ENOSYS; 521 521 522 522 /* 523 523 * Check if SEV-SNP is already enabled, this can happen in case of ··· 530 530 /* Zero out the RMP bookkeeping area */ 531 531 if (!clear_rmptable_bookkeeping()) { 532 532 free_rmp_segment_table(); 533 - goto nosnp; 533 + return -ENOSYS; 534 534 } 535 535 536 536 /* Zero out the RMP entries */ ··· 562 562 crash_kexec_post_notifiers = true; 563 563 564 564 return 0; 565 - 566 - nosnp: 567 - cc_platform_clear(CC_ATTR_HOST_SEV_SNP); 568 - return -ENOSYS; 569 565 } 570 - 571 - /* 572 - * This must be called after the IOMMU has been initialized. 573 - */ 574 - device_initcall(snp_rmptable_init); 575 566 576 567 static void set_rmp_segment_info(unsigned int segment_shift) 577 568 {
+62 -9
arch/x86/xen/mmu_pv.c
··· 111 111 */ 112 112 static DEFINE_SPINLOCK(xen_reservation_lock); 113 113 114 + /* Protected by xen_reservation_lock. */ 115 + #define MIN_CONTIG_ORDER 9 /* 2MB */ 116 + static unsigned int discontig_frames_order = MIN_CONTIG_ORDER; 117 + static unsigned long discontig_frames_early[1UL << MIN_CONTIG_ORDER] __initdata; 118 + static unsigned long *discontig_frames __refdata = discontig_frames_early; 119 + static bool discontig_frames_dyn; 120 + 121 + static int alloc_discontig_frames(unsigned int order) 122 + { 123 + unsigned long *new_array, *old_array; 124 + unsigned int old_order; 125 + unsigned long flags; 126 + 127 + BUG_ON(order < MIN_CONTIG_ORDER); 128 + BUILD_BUG_ON(sizeof(discontig_frames_early) != PAGE_SIZE); 129 + 130 + new_array = (unsigned long *)__get_free_pages(GFP_KERNEL, 131 + order - MIN_CONTIG_ORDER); 132 + if (!new_array) 133 + return -ENOMEM; 134 + 135 + spin_lock_irqsave(&xen_reservation_lock, flags); 136 + 137 + old_order = discontig_frames_order; 138 + 139 + if (order > discontig_frames_order || !discontig_frames_dyn) { 140 + if (!discontig_frames_dyn) 141 + old_array = NULL; 142 + else 143 + old_array = discontig_frames; 144 + 145 + discontig_frames = new_array; 146 + discontig_frames_order = order; 147 + discontig_frames_dyn = true; 148 + } else { 149 + old_array = new_array; 150 + } 151 + 152 + spin_unlock_irqrestore(&xen_reservation_lock, flags); 153 + 154 + free_pages((unsigned long)old_array, old_order - MIN_CONTIG_ORDER); 155 + 156 + return 0; 157 + } 158 + 114 159 /* 115 160 * Note about cr3 (pagetable base) values: 116 161 * ··· 859 814 SetPagePinned(virt_to_page(level3_user_vsyscall)); 860 815 #endif 861 816 xen_pgd_walk(&init_mm, xen_mark_pinned, FIXADDR_TOP); 817 + 818 + if (alloc_discontig_frames(MIN_CONTIG_ORDER)) 819 + BUG(); 862 820 } 863 821 864 822 static void xen_unpin_page(struct mm_struct *mm, struct page *page, ··· 2251 2203 memset(dummy_mapping, 0xff, PAGE_SIZE); 2252 2204 } 2253 2205 2254 - /* Protected by xen_reservation_lock. */ 2255 - #define MAX_CONTIG_ORDER 9 /* 2MB */ 2256 - static unsigned long discontig_frames[1<<MAX_CONTIG_ORDER]; 2257 - 2258 2206 #define VOID_PTE (mfn_pte(0, __pgprot(0))) 2259 2207 static void xen_zap_pfn_range(unsigned long vaddr, unsigned int order, 2260 2208 unsigned long *in_frames, ··· 2367 2323 unsigned int address_bits, 2368 2324 dma_addr_t *dma_handle) 2369 2325 { 2370 - unsigned long *in_frames = discontig_frames, out_frame; 2326 + unsigned long *in_frames, out_frame; 2371 2327 unsigned long flags; 2372 2328 int success; 2373 2329 unsigned long vstart = (unsigned long)phys_to_virt(pstart); 2374 2330 2375 - if (unlikely(order > MAX_CONTIG_ORDER)) 2376 - return -ENOMEM; 2331 + if (unlikely(order > discontig_frames_order)) { 2332 + if (!discontig_frames_dyn) 2333 + return -ENOMEM; 2334 + 2335 + if (alloc_discontig_frames(order)) 2336 + return -ENOMEM; 2337 + } 2377 2338 2378 2339 memset((void *) vstart, 0, PAGE_SIZE << order); 2379 2340 2380 2341 spin_lock_irqsave(&xen_reservation_lock, flags); 2342 + 2343 + in_frames = discontig_frames; 2381 2344 2382 2345 /* 1. Zap current PTEs, remembering MFNs. */ 2383 2346 xen_zap_pfn_range(vstart, order, in_frames, NULL); ··· 2409 2358 2410 2359 void xen_destroy_contiguous_region(phys_addr_t pstart, unsigned int order) 2411 2360 { 2412 - unsigned long *out_frames = discontig_frames, in_frame; 2361 + unsigned long *out_frames, in_frame; 2413 2362 unsigned long flags; 2414 2363 int success; 2415 2364 unsigned long vstart; 2416 2365 2417 - if (unlikely(order > MAX_CONTIG_ORDER)) 2366 + if (unlikely(order > discontig_frames_order)) 2418 2367 return; 2419 2368 2420 2369 vstart = (unsigned long)phys_to_virt(pstart); 2421 2370 memset((void *) vstart, 0, PAGE_SIZE << order); 2422 2371 2423 2372 spin_lock_irqsave(&xen_reservation_lock, flags); 2373 + 2374 + out_frames = discontig_frames; 2424 2375 2425 2376 /* 1. Find start MFN of contiguous extent. */ 2426 2377 in_frame = virt_to_mfn((void *)vstart);
+15 -3
block/partitions/mac.c
··· 53 53 } 54 54 secsize = be16_to_cpu(md->block_size); 55 55 put_dev_sector(sect); 56 + 57 + /* 58 + * If the "block size" is not a power of 2, things get weird - we might 59 + * end up with a partition straddling a sector boundary, so we wouldn't 60 + * be able to read a partition entry with read_part_sector(). 61 + * Real block sizes are probably (?) powers of two, so just require 62 + * that. 63 + */ 64 + if (!is_power_of_2(secsize)) 65 + return -1; 56 66 datasize = round_down(secsize, 512); 57 67 data = read_part_sector(state, datasize / 512, &sect); 58 68 if (!data) 59 69 return -1; 60 70 partoffset = secsize % 512; 61 - if (partoffset + sizeof(*part) > datasize) 71 + if (partoffset + sizeof(*part) > datasize) { 72 + put_dev_sector(sect); 62 73 return -1; 74 + } 63 75 part = (struct mac_partition *) (data + partoffset); 64 76 if (be16_to_cpu(part->signature) != MAC_PARTITION_MAGIC) { 65 77 put_dev_sector(sect); ··· 124 112 int i, l; 125 113 126 114 goodness++; 127 - l = strlen(part->name); 128 - if (strcmp(part->name, "/") == 0) 115 + l = strnlen(part->name, sizeof(part->name)); 116 + if (strncmp(part->name, "/", sizeof(part->name)) == 0) 129 117 goodness++; 130 118 for (i = 0; i <= l - 4; ++i) { 131 119 if (strncasecmp(part->name + i, "root",
+8 -4
drivers/acpi/arm64/gtdt.c
··· 163 163 { 164 164 void *platform_timer; 165 165 struct acpi_table_gtdt *gtdt; 166 - int cnt = 0; 166 + u32 cnt = 0; 167 167 168 168 gtdt = container_of(table, struct acpi_table_gtdt, header); 169 169 acpi_gtdt_desc.gtdt = gtdt; ··· 188 188 cnt++; 189 189 190 190 if (cnt != gtdt->platform_timer_count) { 191 + cnt = min(cnt, gtdt->platform_timer_count); 192 + pr_err(FW_BUG "limiting Platform Timer count to %d\n", cnt); 193 + } 194 + 195 + if (!cnt) { 191 196 acpi_gtdt_desc.platform_timer = NULL; 192 - pr_err(FW_BUG "invalid timer data.\n"); 193 - return -EINVAL; 197 + return 0; 194 198 } 195 199 196 200 if (platform_timer_count) 197 - *platform_timer_count = gtdt->platform_timer_count; 201 + *platform_timer_count = cnt; 198 202 199 203 return 0; 200 204 }
+1 -1
drivers/base/Makefile
··· 6 6 cpu.o firmware.o init.o map.o devres.o \ 7 7 attribute_container.o transport_class.o \ 8 8 topology.o container.o property.o cacheinfo.o \ 9 - swnode.o 9 + swnode.o faux.o 10 10 obj-$(CONFIG_AUXILIARY_BUS) += auxiliary.o 11 11 obj-$(CONFIG_DEVTMPFS) += devtmpfs.o 12 12 obj-y += power/
+1
drivers/base/base.h
··· 137 137 static inline int hypervisor_init(void) { return 0; } 138 138 #endif 139 139 int platform_bus_init(void); 140 + int faux_bus_init(void); 140 141 void cpu_dev_init(void); 141 142 void container_dev_init(void); 142 143 #ifdef CONFIG_AUXILIARY_BUS
+232
drivers/base/faux.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-only 2 + /* 3 + * Copyright (c) 2025 Greg Kroah-Hartman <gregkh@linuxfoundation.org> 4 + * Copyright (c) 2025 The Linux Foundation 5 + * 6 + * A "simple" faux bus that allows devices to be created and added 7 + * automatically to it. This is to be used whenever you need to create a 8 + * device that is not associated with any "real" system resources, and do 9 + * not want to have to deal with a bus/driver binding logic. It is 10 + * intended to be very simple, with only a create and a destroy function 11 + * available. 12 + */ 13 + #include <linux/err.h> 14 + #include <linux/init.h> 15 + #include <linux/slab.h> 16 + #include <linux/string.h> 17 + #include <linux/container_of.h> 18 + #include <linux/device/faux.h> 19 + #include "base.h" 20 + 21 + /* 22 + * Internal wrapper structure so we can hold a pointer to the 23 + * faux_device_ops for this device. 24 + */ 25 + struct faux_object { 26 + struct faux_device faux_dev; 27 + const struct faux_device_ops *faux_ops; 28 + }; 29 + #define to_faux_object(dev) container_of_const(dev, struct faux_object, faux_dev.dev) 30 + 31 + static struct device faux_bus_root = { 32 + .init_name = "faux", 33 + }; 34 + 35 + static int faux_match(struct device *dev, const struct device_driver *drv) 36 + { 37 + /* Match always succeeds, we only have one driver */ 38 + return 1; 39 + } 40 + 41 + static int faux_probe(struct device *dev) 42 + { 43 + struct faux_object *faux_obj = to_faux_object(dev); 44 + struct faux_device *faux_dev = &faux_obj->faux_dev; 45 + const struct faux_device_ops *faux_ops = faux_obj->faux_ops; 46 + int ret = 0; 47 + 48 + if (faux_ops && faux_ops->probe) 49 + ret = faux_ops->probe(faux_dev); 50 + 51 + return ret; 52 + } 53 + 54 + static void faux_remove(struct device *dev) 55 + { 56 + struct faux_object *faux_obj = to_faux_object(dev); 57 + struct faux_device *faux_dev = &faux_obj->faux_dev; 58 + const struct faux_device_ops *faux_ops = faux_obj->faux_ops; 59 + 60 + if (faux_ops && faux_ops->remove) 61 + faux_ops->remove(faux_dev); 62 + } 63 + 64 + static const struct bus_type faux_bus_type = { 65 + .name = "faux", 66 + .match = faux_match, 67 + .probe = faux_probe, 68 + .remove = faux_remove, 69 + }; 70 + 71 + static struct device_driver faux_driver = { 72 + .name = "faux_driver", 73 + .bus = &faux_bus_type, 74 + .probe_type = PROBE_FORCE_SYNCHRONOUS, 75 + }; 76 + 77 + static void faux_device_release(struct device *dev) 78 + { 79 + struct faux_object *faux_obj = to_faux_object(dev); 80 + 81 + kfree(faux_obj); 82 + } 83 + 84 + /** 85 + * faux_device_create_with_groups - Create and register with the driver 86 + * core a faux device and populate the device with an initial 87 + * set of sysfs attributes. 88 + * @name: The name of the device we are adding, must be unique for 89 + * all faux devices. 90 + * @parent: Pointer to a potential parent struct device. If set to 91 + * NULL, the device will be created in the "root" of the faux 92 + * device tree in sysfs. 93 + * @faux_ops: struct faux_device_ops that the new device will call back 94 + * into, can be NULL. 95 + * @groups: The set of sysfs attributes that will be created for this 96 + * device when it is registered with the driver core. 97 + * 98 + * Create a new faux device and register it in the driver core properly. 99 + * If present, callbacks in @faux_ops will be called with the device that 100 + * for the caller to do something with at the proper time given the 101 + * device's lifecycle. 102 + * 103 + * Note, when this function is called, the functions specified in struct 104 + * faux_ops can be called before the function returns, so be prepared for 105 + * everything to be properly initialized before that point in time. 106 + * 107 + * Return: 108 + * * NULL if an error happened with creating the device 109 + * * pointer to a valid struct faux_device that is registered with sysfs 110 + */ 111 + struct faux_device *faux_device_create_with_groups(const char *name, 112 + struct device *parent, 113 + const struct faux_device_ops *faux_ops, 114 + const struct attribute_group **groups) 115 + { 116 + struct faux_object *faux_obj; 117 + struct faux_device *faux_dev; 118 + struct device *dev; 119 + int ret; 120 + 121 + faux_obj = kzalloc(sizeof(*faux_obj), GFP_KERNEL); 122 + if (!faux_obj) 123 + return NULL; 124 + 125 + /* Save off the callbacks so we can use them in the future */ 126 + faux_obj->faux_ops = faux_ops; 127 + 128 + /* Initialize the device portion and register it with the driver core */ 129 + faux_dev = &faux_obj->faux_dev; 130 + dev = &faux_dev->dev; 131 + 132 + device_initialize(dev); 133 + dev->release = faux_device_release; 134 + if (parent) 135 + dev->parent = parent; 136 + else 137 + dev->parent = &faux_bus_root; 138 + dev->bus = &faux_bus_type; 139 + dev->groups = groups; 140 + dev_set_name(dev, "%s", name); 141 + 142 + ret = device_add(dev); 143 + if (ret) { 144 + pr_err("%s: device_add for faux device '%s' failed with %d\n", 145 + __func__, name, ret); 146 + put_device(dev); 147 + return NULL; 148 + } 149 + 150 + return faux_dev; 151 + } 152 + EXPORT_SYMBOL_GPL(faux_device_create_with_groups); 153 + 154 + /** 155 + * faux_device_create - create and register with the driver core a faux device 156 + * @name: The name of the device we are adding, must be unique for all 157 + * faux devices. 158 + * @parent: Pointer to a potential parent struct device. If set to 159 + * NULL, the device will be created in the "root" of the faux 160 + * device tree in sysfs. 161 + * @faux_ops: struct faux_device_ops that the new device will call back 162 + * into, can be NULL. 163 + * 164 + * Create a new faux device and register it in the driver core properly. 165 + * If present, callbacks in @faux_ops will be called with the device that 166 + * for the caller to do something with at the proper time given the 167 + * device's lifecycle. 168 + * 169 + * Note, when this function is called, the functions specified in struct 170 + * faux_ops can be called before the function returns, so be prepared for 171 + * everything to be properly initialized before that point in time. 172 + * 173 + * Return: 174 + * * NULL if an error happened with creating the device 175 + * * pointer to a valid struct faux_device that is registered with sysfs 176 + */ 177 + struct faux_device *faux_device_create(const char *name, 178 + struct device *parent, 179 + const struct faux_device_ops *faux_ops) 180 + { 181 + return faux_device_create_with_groups(name, parent, faux_ops, NULL); 182 + } 183 + EXPORT_SYMBOL_GPL(faux_device_create); 184 + 185 + /** 186 + * faux_device_destroy - destroy a faux device 187 + * @faux_dev: faux device to destroy 188 + * 189 + * Unregisters and cleans up a device that was created with a call to 190 + * faux_device_create() 191 + */ 192 + void faux_device_destroy(struct faux_device *faux_dev) 193 + { 194 + struct device *dev = &faux_dev->dev; 195 + 196 + if (!faux_dev) 197 + return; 198 + 199 + device_del(dev); 200 + 201 + /* The final put_device() will clean up the memory we allocated for this device. */ 202 + put_device(dev); 203 + } 204 + EXPORT_SYMBOL_GPL(faux_device_destroy); 205 + 206 + int __init faux_bus_init(void) 207 + { 208 + int ret; 209 + 210 + ret = device_register(&faux_bus_root); 211 + if (ret) { 212 + put_device(&faux_bus_root); 213 + return ret; 214 + } 215 + 216 + ret = bus_register(&faux_bus_type); 217 + if (ret) 218 + goto error_bus; 219 + 220 + ret = driver_register(&faux_driver); 221 + if (ret) 222 + goto error_driver; 223 + 224 + return ret; 225 + 226 + error_driver: 227 + bus_unregister(&faux_bus_type); 228 + 229 + error_bus: 230 + device_unregister(&faux_bus_root); 231 + return ret; 232 + }
+1
drivers/base/init.c
··· 32 32 /* These are also core pieces, but must come after the 33 33 * core core pieces. 34 34 */ 35 + faux_bus_init(); 35 36 of_core_init(); 36 37 platform_bus_init(); 37 38 auxiliary_bus_init();
+2
drivers/base/regmap/regmap-irq.c
··· 906 906 kfree(d->wake_buf); 907 907 kfree(d->mask_buf_def); 908 908 kfree(d->mask_buf); 909 + kfree(d->main_status_buf); 909 910 kfree(d->status_buf); 910 911 kfree(d->status_reg_buf); 911 912 if (d->config_buf) { ··· 982 981 kfree(d->wake_buf); 983 982 kfree(d->mask_buf_def); 984 983 kfree(d->mask_buf); 984 + kfree(d->main_status_buf); 985 985 kfree(d->status_reg_buf); 986 986 kfree(d->status_buf); 987 987 if (d->config_buf) {
+14
drivers/crypto/ccp/sp-dev.c
··· 19 19 #include <linux/types.h> 20 20 #include <linux/ccp.h> 21 21 22 + #include "sev-dev.h" 22 23 #include "ccp-dev.h" 23 24 #include "sp-dev.h" 24 25 ··· 254 253 static int __init sp_mod_init(void) 255 254 { 256 255 #ifdef CONFIG_X86 256 + static bool initialized; 257 257 int ret; 258 + 259 + if (initialized) 260 + return 0; 258 261 259 262 ret = sp_pci_init(); 260 263 if (ret) ··· 267 262 #ifdef CONFIG_CRYPTO_DEV_SP_PSP 268 263 psp_pci_init(); 269 264 #endif 265 + 266 + initialized = true; 270 267 271 268 return 0; 272 269 #endif ··· 285 278 286 279 return -ENODEV; 287 280 } 281 + 282 + #if IS_BUILTIN(CONFIG_KVM_AMD) && IS_ENABLED(CONFIG_KVM_AMD_SEV) 283 + int __init sev_module_init(void) 284 + { 285 + return sp_mod_init(); 286 + } 287 + #endif 288 288 289 289 static void __exit sp_mod_exit(void) 290 290 {
+14 -3
drivers/dma/tegra210-adma.c
··· 887 887 const struct tegra_adma_chip_data *cdata; 888 888 struct tegra_adma *tdma; 889 889 struct resource *res_page, *res_base; 890 - int ret, i, page_no; 890 + int ret, i; 891 891 892 892 cdata = of_device_get_match_data(&pdev->dev); 893 893 if (!cdata) { ··· 914 914 915 915 res_base = platform_get_resource_byname(pdev, IORESOURCE_MEM, "global"); 916 916 if (res_base) { 917 - page_no = (res_page->start - res_base->start) / cdata->ch_base_offset; 918 - if (page_no <= 0) 917 + resource_size_t page_offset, page_no; 918 + unsigned int ch_base_offset; 919 + 920 + if (res_page->start < res_base->start) 919 921 return -EINVAL; 922 + page_offset = res_page->start - res_base->start; 923 + ch_base_offset = cdata->ch_base_offset; 924 + if (!ch_base_offset) 925 + return -EINVAL; 926 + 927 + page_no = div_u64(page_offset, ch_base_offset); 928 + if (!page_no || page_no > INT_MAX) 929 + return -EINVAL; 930 + 920 931 tdma->ch_page_no = page_no - 1; 921 932 tdma->base_addr = devm_ioremap_resource(&pdev->dev, res_base); 922 933 if (IS_ERR(tdma->base_addr))
+4 -2
drivers/firmware/efi/efi.c
··· 934 934 EFI_MEMORY_WB | EFI_MEMORY_UCE | EFI_MEMORY_RO | 935 935 EFI_MEMORY_WP | EFI_MEMORY_RP | EFI_MEMORY_XP | 936 936 EFI_MEMORY_NV | EFI_MEMORY_SP | EFI_MEMORY_CPU_CRYPTO | 937 - EFI_MEMORY_RUNTIME | EFI_MEMORY_MORE_RELIABLE)) 937 + EFI_MEMORY_MORE_RELIABLE | EFI_MEMORY_HOT_PLUGGABLE | 938 + EFI_MEMORY_RUNTIME)) 938 939 snprintf(pos, size, "|attr=0x%016llx]", 939 940 (unsigned long long)attr); 940 941 else 941 942 snprintf(pos, size, 942 - "|%3s|%2s|%2s|%2s|%2s|%2s|%2s|%2s|%2s|%3s|%2s|%2s|%2s|%2s]", 943 + "|%3s|%2s|%2s|%2s|%2s|%2s|%2s|%2s|%2s|%2s|%3s|%2s|%2s|%2s|%2s]", 943 944 attr & EFI_MEMORY_RUNTIME ? "RUN" : "", 945 + attr & EFI_MEMORY_HOT_PLUGGABLE ? "HP" : "", 944 946 attr & EFI_MEMORY_MORE_RELIABLE ? "MR" : "", 945 947 attr & EFI_MEMORY_CPU_CRYPTO ? "CC" : "", 946 948 attr & EFI_MEMORY_SP ? "SP" : "",
+3
drivers/firmware/efi/libstub/randomalloc.c
··· 25 25 if (md->type != EFI_CONVENTIONAL_MEMORY) 26 26 return 0; 27 27 28 + if (md->attribute & EFI_MEMORY_HOT_PLUGGABLE) 29 + return 0; 30 + 28 31 if (efi_soft_reserve_enabled() && 29 32 (md->attribute & EFI_MEMORY_SP)) 30 33 return 0;
+3
drivers/firmware/efi/libstub/relocate.c
··· 53 53 if (desc->type != EFI_CONVENTIONAL_MEMORY) 54 54 continue; 55 55 56 + if (desc->attribute & EFI_MEMORY_HOT_PLUGGABLE) 57 + continue; 58 + 56 59 if (efi_soft_reserve_enabled() && 57 60 (desc->attribute & EFI_MEMORY_SP)) 58 61 continue;
+58 -13
drivers/gpio/gpio-bcm-kona.c
··· 69 69 struct bcm_kona_gpio_bank { 70 70 int id; 71 71 int irq; 72 + /* 73 + * Used to keep track of lock/unlock operations for each GPIO in the 74 + * bank. 75 + * 76 + * All GPIOs are locked by default (see bcm_kona_gpio_reset), and the 77 + * unlock count for all GPIOs is 0 by default. Each unlock increments 78 + * the counter, and each lock decrements the counter. 79 + * 80 + * The lock function only locks the GPIO once its unlock counter is 81 + * down to 0. This is necessary because the GPIO is unlocked in two 82 + * places in this driver: once for requested GPIOs, and once for 83 + * requested IRQs. Since it is possible for a GPIO to be requested 84 + * as both a GPIO and an IRQ, we need to ensure that we don't lock it 85 + * too early. 86 + */ 87 + u8 gpio_unlock_count[GPIO_PER_BANK]; 72 88 /* Used in the interrupt handler */ 73 89 struct bcm_kona_gpio *kona_gpio; 74 90 }; ··· 102 86 u32 val; 103 87 unsigned long flags; 104 88 int bank_id = GPIO_BANK(gpio); 89 + int bit = GPIO_BIT(gpio); 90 + struct bcm_kona_gpio_bank *bank = &kona_gpio->banks[bank_id]; 105 91 106 - raw_spin_lock_irqsave(&kona_gpio->lock, flags); 92 + if (bank->gpio_unlock_count[bit] == 0) { 93 + dev_err(kona_gpio->gpio_chip.parent, 94 + "Unbalanced locks for GPIO %u\n", gpio); 95 + return; 96 + } 107 97 108 - val = readl(kona_gpio->reg_base + GPIO_PWD_STATUS(bank_id)); 109 - val |= BIT(gpio); 110 - bcm_kona_gpio_write_lock_regs(kona_gpio->reg_base, bank_id, val); 98 + if (--bank->gpio_unlock_count[bit] == 0) { 99 + raw_spin_lock_irqsave(&kona_gpio->lock, flags); 111 100 112 - raw_spin_unlock_irqrestore(&kona_gpio->lock, flags); 101 + val = readl(kona_gpio->reg_base + GPIO_PWD_STATUS(bank_id)); 102 + val |= BIT(bit); 103 + bcm_kona_gpio_write_lock_regs(kona_gpio->reg_base, bank_id, val); 104 + 105 + raw_spin_unlock_irqrestore(&kona_gpio->lock, flags); 106 + } 113 107 } 114 108 115 109 static void bcm_kona_gpio_unlock_gpio(struct bcm_kona_gpio *kona_gpio, ··· 128 102 u32 val; 129 103 unsigned long flags; 130 104 int bank_id = GPIO_BANK(gpio); 105 + int bit = GPIO_BIT(gpio); 106 + struct bcm_kona_gpio_bank *bank = &kona_gpio->banks[bank_id]; 131 107 132 - raw_spin_lock_irqsave(&kona_gpio->lock, flags); 108 + if (bank->gpio_unlock_count[bit] == 0) { 109 + raw_spin_lock_irqsave(&kona_gpio->lock, flags); 133 110 134 - val = readl(kona_gpio->reg_base + GPIO_PWD_STATUS(bank_id)); 135 - val &= ~BIT(gpio); 136 - bcm_kona_gpio_write_lock_regs(kona_gpio->reg_base, bank_id, val); 111 + val = readl(kona_gpio->reg_base + GPIO_PWD_STATUS(bank_id)); 112 + val &= ~BIT(bit); 113 + bcm_kona_gpio_write_lock_regs(kona_gpio->reg_base, bank_id, val); 137 114 138 - raw_spin_unlock_irqrestore(&kona_gpio->lock, flags); 115 + raw_spin_unlock_irqrestore(&kona_gpio->lock, flags); 116 + } 117 + 118 + ++bank->gpio_unlock_count[bit]; 139 119 } 140 120 141 121 static int bcm_kona_gpio_get_dir(struct gpio_chip *chip, unsigned gpio) ··· 392 360 393 361 kona_gpio = irq_data_get_irq_chip_data(d); 394 362 reg_base = kona_gpio->reg_base; 363 + 395 364 raw_spin_lock_irqsave(&kona_gpio->lock, flags); 396 365 397 366 val = readl(reg_base + GPIO_INT_MASK(bank_id)); ··· 415 382 416 383 kona_gpio = irq_data_get_irq_chip_data(d); 417 384 reg_base = kona_gpio->reg_base; 385 + 418 386 raw_spin_lock_irqsave(&kona_gpio->lock, flags); 419 387 420 388 val = readl(reg_base + GPIO_INT_MSKCLR(bank_id)); ··· 511 477 static int bcm_kona_gpio_irq_reqres(struct irq_data *d) 512 478 { 513 479 struct bcm_kona_gpio *kona_gpio = irq_data_get_irq_chip_data(d); 480 + unsigned int gpio = d->hwirq; 514 481 515 - return gpiochip_reqres_irq(&kona_gpio->gpio_chip, d->hwirq); 482 + /* 483 + * We need to unlock the GPIO before any other operations are performed 484 + * on the relevant GPIO configuration registers 485 + */ 486 + bcm_kona_gpio_unlock_gpio(kona_gpio, gpio); 487 + 488 + return gpiochip_reqres_irq(&kona_gpio->gpio_chip, gpio); 516 489 } 517 490 518 491 static void bcm_kona_gpio_irq_relres(struct irq_data *d) 519 492 { 520 493 struct bcm_kona_gpio *kona_gpio = irq_data_get_irq_chip_data(d); 494 + unsigned int gpio = d->hwirq; 521 495 522 - gpiochip_relres_irq(&kona_gpio->gpio_chip, d->hwirq); 496 + /* Once we no longer use it, lock the GPIO again */ 497 + bcm_kona_gpio_lock_gpio(kona_gpio, gpio); 498 + 499 + gpiochip_relres_irq(&kona_gpio->gpio_chip, gpio); 523 500 } 524 501 525 502 static struct irq_chip bcm_gpio_irq_chip = { ··· 659 614 bank->irq = platform_get_irq(pdev, i); 660 615 bank->kona_gpio = kona_gpio; 661 616 if (bank->irq < 0) { 662 - dev_err(dev, "Couldn't get IRQ for bank %d", i); 617 + dev_err(dev, "Couldn't get IRQ for bank %d\n", i); 663 618 ret = -ENOENT; 664 619 goto err_irq_domain; 665 620 }
+12 -3
drivers/gpio/gpio-stmpe.c
··· 191 191 [REG_IE][CSB] = STMPE_IDX_IEGPIOR_CSB, 192 192 [REG_IE][MSB] = STMPE_IDX_IEGPIOR_MSB, 193 193 }; 194 - int i, j; 194 + int ret, i, j; 195 195 196 196 /* 197 197 * STMPE1600: to be able to get IRQ from pins, ··· 199 199 * GPSR or GPCR registers 200 200 */ 201 201 if (stmpe->partnum == STMPE1600) { 202 - stmpe_reg_read(stmpe, stmpe->regs[STMPE_IDX_GPMR_LSB]); 203 - stmpe_reg_read(stmpe, stmpe->regs[STMPE_IDX_GPMR_CSB]); 202 + ret = stmpe_reg_read(stmpe, stmpe->regs[STMPE_IDX_GPMR_LSB]); 203 + if (ret < 0) { 204 + dev_err(stmpe->dev, "Failed to read GPMR_LSB: %d\n", ret); 205 + goto err; 206 + } 207 + ret = stmpe_reg_read(stmpe, stmpe->regs[STMPE_IDX_GPMR_CSB]); 208 + if (ret < 0) { 209 + dev_err(stmpe->dev, "Failed to read GPMR_CSB: %d\n", ret); 210 + goto err; 211 + } 204 212 } 205 213 206 214 for (i = 0; i < CACHE_NR_REGS; i++) { ··· 230 222 } 231 223 } 232 224 225 + err: 233 226 mutex_unlock(&stmpe_gpio->irq_lock); 234 227 } 235 228
+14
drivers/gpio/gpiolib-acpi.c
··· 1689 1689 .ignore_wake = "PNP0C50:00@8", 1690 1690 }, 1691 1691 }, 1692 + { 1693 + /* 1694 + * Spurious wakeups from GPIO 11 1695 + * Found in BIOS 1.04 1696 + * https://gitlab.freedesktop.org/drm/amd/-/issues/3954 1697 + */ 1698 + .matches = { 1699 + DMI_MATCH(DMI_SYS_VENDOR, "Acer"), 1700 + DMI_MATCH(DMI_PRODUCT_FAMILY, "Acer Nitro V 14"), 1701 + }, 1702 + .driver_data = &(struct acpi_gpiolib_dmi_quirk) { 1703 + .ignore_interrupt = "AMDI0030:00@11", 1704 + }, 1705 + }, 1692 1706 {} /* Terminating entry */ 1693 1707 }; 1694 1708
+3 -3
drivers/gpio/gpiolib.c
··· 904 904 } 905 905 906 906 if (gc->ngpio == 0) { 907 - chip_err(gc, "tried to insert a GPIO chip with zero lines\n"); 907 + dev_err(dev, "tried to insert a GPIO chip with zero lines\n"); 908 908 return -EINVAL; 909 909 } 910 910 911 911 if (gc->ngpio > FASTPATH_NGPIO) 912 - chip_warn(gc, "line cnt %u is greater than fast path cnt %u\n", 913 - gc->ngpio, FASTPATH_NGPIO); 912 + dev_warn(dev, "line cnt %u is greater than fast path cnt %u\n", 913 + gc->ngpio, FASTPATH_NGPIO); 914 914 915 915 return 0; 916 916 }
+2 -1
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
··· 120 120 * - 3.58.0 - Add GFX12 DCC support 121 121 * - 3.59.0 - Cleared VRAM 122 122 * - 3.60.0 - Add AMDGPU_TILING_GFX12_DCC_WRITE_COMPRESS_DISABLE (Vulkan requirement) 123 + * - 3.61.0 - Contains fix for RV/PCO compute queues 123 124 */ 124 125 #define KMS_DRIVER_MAJOR 3 125 - #define KMS_DRIVER_MINOR 60 126 + #define KMS_DRIVER_MINOR 61 126 127 #define KMS_DRIVER_PATCHLEVEL 0 127 128 128 129 /*
+3 -2
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
··· 3815 3815 if (err == -ENODEV) { 3816 3816 dev_warn(adev->dev, "cap microcode does not exist, skip\n"); 3817 3817 err = 0; 3818 - goto out; 3818 + } else { 3819 + dev_err(adev->dev, "fail to initialize cap microcode\n"); 3819 3820 } 3820 - dev_err(adev->dev, "fail to initialize cap microcode\n"); 3821 + goto out; 3821 3822 } 3822 3823 3823 3824 info = &adev->firmware.ucode[AMDGPU_UCODE_ID_CAP];
+34 -2
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
··· 7437 7437 amdgpu_ring_write(ring, 0); /* RESERVED field, programmed to zero */ 7438 7438 } 7439 7439 7440 + static void gfx_v9_0_ring_begin_use_compute(struct amdgpu_ring *ring) 7441 + { 7442 + struct amdgpu_device *adev = ring->adev; 7443 + struct amdgpu_ip_block *gfx_block = 7444 + amdgpu_device_ip_get_ip_block(adev, AMD_IP_BLOCK_TYPE_GFX); 7445 + 7446 + amdgpu_gfx_enforce_isolation_ring_begin_use(ring); 7447 + 7448 + /* Raven and PCO APUs seem to have stability issues 7449 + * with compute and gfxoff and gfx pg. Disable gfx pg during 7450 + * submission and allow again afterwards. 7451 + */ 7452 + if (gfx_block && amdgpu_ip_version(adev, GC_HWIP, 0) == IP_VERSION(9, 1, 0)) 7453 + gfx_v9_0_set_powergating_state(gfx_block, AMD_PG_STATE_UNGATE); 7454 + } 7455 + 7456 + static void gfx_v9_0_ring_end_use_compute(struct amdgpu_ring *ring) 7457 + { 7458 + struct amdgpu_device *adev = ring->adev; 7459 + struct amdgpu_ip_block *gfx_block = 7460 + amdgpu_device_ip_get_ip_block(adev, AMD_IP_BLOCK_TYPE_GFX); 7461 + 7462 + /* Raven and PCO APUs seem to have stability issues 7463 + * with compute and gfxoff and gfx pg. Disable gfx pg during 7464 + * submission and allow again afterwards. 7465 + */ 7466 + if (gfx_block && amdgpu_ip_version(adev, GC_HWIP, 0) == IP_VERSION(9, 1, 0)) 7467 + gfx_v9_0_set_powergating_state(gfx_block, AMD_PG_STATE_GATE); 7468 + 7469 + amdgpu_gfx_enforce_isolation_ring_end_use(ring); 7470 + } 7471 + 7440 7472 static const struct amd_ip_funcs gfx_v9_0_ip_funcs = { 7441 7473 .name = "gfx_v9_0", 7442 7474 .early_init = gfx_v9_0_early_init, ··· 7645 7613 .emit_wave_limit = gfx_v9_0_emit_wave_limit, 7646 7614 .reset = gfx_v9_0_reset_kcq, 7647 7615 .emit_cleaner_shader = gfx_v9_0_ring_emit_cleaner_shader, 7648 - .begin_use = amdgpu_gfx_enforce_isolation_ring_begin_use, 7649 - .end_use = amdgpu_gfx_enforce_isolation_ring_end_use, 7616 + .begin_use = gfx_v9_0_ring_begin_use_compute, 7617 + .end_use = gfx_v9_0_ring_end_use_compute, 7650 7618 }; 7651 7619 7652 7620 static const struct amdgpu_ring_funcs gfx_v9_0_ring_funcs_kiq = {
+2 -1
drivers/gpu/drm/amd/amdkfd/cwsr_trap_handler.h
··· 4121 4121 0x0000ffff, 0x8bfe7e7e, 4122 4122 0x8bea6a6a, 0xb97af804, 4123 4123 0xbe804ec2, 0xbf94fffe, 4124 - 0xbe804a6c, 0xbfb10000, 4124 + 0xbe804a6c, 0xbe804ec2, 4125 + 0xbf94fffe, 0xbfb10000, 4125 4126 0xbf9f0000, 0xbf9f0000, 4126 4127 0xbf9f0000, 0xbf9f0000, 4127 4128 0xbf9f0000, 0x00000000,
+4
drivers/gpu/drm/amd/amdkfd/cwsr_trap_handler_gfx12.asm
··· 1049 1049 s_rfe_b64 s_restore_pc_lo //Return to the main shader program and resume execution 1050 1050 1051 1051 L_END_PGM: 1052 + // Make sure that no wave of the workgroup can exit the trap handler 1053 + // before the workgroup barrier state is saved. 1054 + s_barrier_signal -2 1055 + s_barrier_wait -2 1052 1056 s_endpgm_saved 1053 1057 end 1054 1058
+1 -1
drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c
··· 300 300 return 0; 301 301 302 302 free_gang_ctx_bo: 303 - amdgpu_amdkfd_free_gtt_mem(dev->adev, (*q)->gang_ctx_bo); 303 + amdgpu_amdkfd_free_gtt_mem(dev->adev, &(*q)->gang_ctx_bo); 304 304 cleanup: 305 305 uninit_queue(*q); 306 306 *q = NULL;
+1 -1
drivers/gpu/drm/amd/pm/amdgpu_dpm.c
··· 78 78 int ret = 0; 79 79 const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs; 80 80 enum ip_power_state pwr_state = gate ? POWER_STATE_OFF : POWER_STATE_ON; 81 - bool is_vcn = (block_type == AMD_IP_BLOCK_TYPE_UVD || block_type == AMD_IP_BLOCK_TYPE_VCN); 81 + bool is_vcn = block_type == AMD_IP_BLOCK_TYPE_VCN; 82 82 83 83 if (atomic_read(&adev->pm.pwr_state[block_type]) == pwr_state && 84 84 (!is_vcn || adev->vcn.num_vcn_inst == 1)) {
+2 -1
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
··· 612 612 return -EIO; 613 613 } 614 614 615 - if (!smu_table->hardcode_pptable) { 615 + if (!smu_table->hardcode_pptable || smu_table->power_play_table_size < size) { 616 + kfree(smu_table->hardcode_pptable); 616 617 smu_table->hardcode_pptable = kzalloc(size, GFP_KERNEL); 617 618 if (!smu_table->hardcode_pptable) 618 619 return -ENOMEM;
+1 -1
drivers/gpu/drm/display/drm_dp_helper.c
··· 2544 2544 { 2545 2545 u8 bpp_increment_dpcd = dsc_dpcd[DP_DSC_BITS_PER_PIXEL_INC - DP_DSC_SUPPORT]; 2546 2546 2547 - switch (bpp_increment_dpcd) { 2547 + switch (bpp_increment_dpcd & DP_DSC_BITS_PER_PIXEL_MASK) { 2548 2548 case DP_DSC_BITS_PER_PIXEL_1_16: 2549 2549 return 16; 2550 2550 case DP_DSC_BITS_PER_PIXEL_1_8:
+2
drivers/gpu/drm/hisilicon/hibmc/Kconfig
··· 4 4 depends on DRM && PCI 5 5 depends on MMU 6 6 select DRM_CLIENT_SELECTION 7 + select DRM_DISPLAY_HELPER 8 + select DRM_DISPLAY_DP_HELPER 7 9 select DRM_KMS_HELPER 8 10 select DRM_VRAM_HELPER 9 11 select DRM_TTM
+2 -2
drivers/gpu/drm/i915/selftests/i915_gem_gtt.c
··· 168 168 return PTR_ERR(ppgtt); 169 169 170 170 if (!ppgtt->vm.allocate_va_range) 171 - goto err_ppgtt_cleanup; 171 + goto ppgtt_vm_put; 172 172 173 173 /* 174 174 * While we only allocate the page tables here and so we could ··· 236 236 goto retry; 237 237 } 238 238 i915_gem_ww_ctx_fini(&ww); 239 - 239 + ppgtt_vm_put: 240 240 i915_vm_put(&ppgtt->vm); 241 241 return err; 242 242 }
+1
drivers/gpu/drm/panthor/panthor_drv.c
··· 802 802 { 803 803 int prio; 804 804 805 + memset(arg, 0, sizeof(*arg)); 805 806 for (prio = PANTHOR_GROUP_PRIORITY_REALTIME; prio >= 0; prio--) { 806 807 if (!group_priority_permit(file, prio)) 807 808 arg->allowed_mask |= BIT(prio);
+103 -97
drivers/gpu/drm/tests/drm_hdmi_state_helper_test.c
··· 70 70 state = drm_kunit_helper_atomic_state_alloc(test, drm, ctx); 71 71 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, state); 72 72 73 + retry: 73 74 conn_state = drm_atomic_get_connector_state(state, connector); 74 75 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, conn_state); 75 76 76 77 ret = drm_atomic_set_crtc_for_connector(conn_state, crtc); 78 + if (ret == -EDEADLK) { 79 + drm_atomic_state_clear(state); 80 + ret = drm_modeset_backoff(ctx); 81 + if (!ret) 82 + goto retry; 83 + } 77 84 KUNIT_EXPECT_EQ(test, ret, 0); 78 85 79 86 crtc_state = drm_atomic_get_crtc_state(state, crtc); ··· 289 282 8); 290 283 KUNIT_ASSERT_NOT_NULL(test, priv); 291 284 292 - ctx = drm_kunit_helper_acquire_ctx_alloc(test); 293 - KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx); 294 - 285 + drm = &priv->drm; 286 + crtc = priv->crtc; 295 287 conn = &priv->connector; 288 + 296 289 preferred = find_preferred_mode(conn); 297 290 KUNIT_ASSERT_NOT_NULL(test, preferred); 298 291 299 - drm = &priv->drm; 300 - crtc = priv->crtc; 292 + ctx = drm_kunit_helper_acquire_ctx_alloc(test); 293 + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx); 294 + 301 295 ret = light_up_connector(test, drm, crtc, conn, preferred, ctx); 302 296 KUNIT_ASSERT_EQ(test, ret, 0); 303 297 ··· 353 345 8); 354 346 KUNIT_ASSERT_NOT_NULL(test, priv); 355 347 356 - ctx = drm_kunit_helper_acquire_ctx_alloc(test); 357 - KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx); 358 - 348 + drm = &priv->drm; 349 + crtc = priv->crtc; 359 350 conn = &priv->connector; 351 + 360 352 preferred = find_preferred_mode(conn); 361 353 KUNIT_ASSERT_NOT_NULL(test, preferred); 362 354 363 - drm = &priv->drm; 364 - crtc = priv->crtc; 355 + ctx = drm_kunit_helper_acquire_ctx_alloc(test); 356 + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx); 357 + 365 358 ret = light_up_connector(test, drm, crtc, conn, preferred, ctx); 366 359 KUNIT_ASSERT_EQ(test, ret, 0); 367 360 ··· 417 408 8); 418 409 KUNIT_ASSERT_NOT_NULL(test, priv); 419 410 411 + drm = &priv->drm; 412 + crtc = priv->crtc; 420 413 conn = &priv->connector; 421 414 KUNIT_ASSERT_TRUE(test, conn->display_info.is_hdmi); 422 - 423 - ctx = drm_kunit_helper_acquire_ctx_alloc(test); 424 - KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx); 425 415 426 416 preferred = find_preferred_mode(conn); 427 417 KUNIT_ASSERT_NOT_NULL(test, preferred); 428 418 KUNIT_ASSERT_NE(test, drm_match_cea_mode(preferred), 1); 429 419 430 - drm = &priv->drm; 431 - crtc = priv->crtc; 420 + ctx = drm_kunit_helper_acquire_ctx_alloc(test); 421 + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx); 422 + 432 423 ret = light_up_connector(test, drm, crtc, conn, preferred, ctx); 433 424 KUNIT_ASSERT_EQ(test, ret, 0); 434 425 ··· 483 474 mode = drm_kunit_display_mode_from_cea_vic(test, drm, 1); 484 475 KUNIT_ASSERT_NOT_NULL(test, mode); 485 476 486 - drm = &priv->drm; 487 477 crtc = priv->crtc; 488 478 ret = light_up_connector(test, drm, crtc, conn, mode, ctx); 489 479 KUNIT_ASSERT_EQ(test, ret, 0); ··· 528 520 8); 529 521 KUNIT_ASSERT_NOT_NULL(test, priv); 530 522 523 + drm = &priv->drm; 524 + crtc = priv->crtc; 531 525 conn = &priv->connector; 532 526 KUNIT_ASSERT_TRUE(test, conn->display_info.is_hdmi); 533 - 534 - ctx = drm_kunit_helper_acquire_ctx_alloc(test); 535 - KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx); 536 527 537 528 preferred = find_preferred_mode(conn); 538 529 KUNIT_ASSERT_NOT_NULL(test, preferred); 539 530 KUNIT_ASSERT_NE(test, drm_match_cea_mode(preferred), 1); 540 531 541 - drm = &priv->drm; 542 - crtc = priv->crtc; 532 + ctx = drm_kunit_helper_acquire_ctx_alloc(test); 533 + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx); 534 + 543 535 ret = light_up_connector(test, drm, crtc, conn, preferred, ctx); 544 536 KUNIT_ASSERT_EQ(test, ret, 0); 545 537 ··· 596 588 mode = drm_kunit_display_mode_from_cea_vic(test, drm, 1); 597 589 KUNIT_ASSERT_NOT_NULL(test, mode); 598 590 599 - drm = &priv->drm; 600 591 crtc = priv->crtc; 601 592 ret = light_up_connector(test, drm, crtc, conn, mode, ctx); 602 593 KUNIT_ASSERT_EQ(test, ret, 0); ··· 643 636 8); 644 637 KUNIT_ASSERT_NOT_NULL(test, priv); 645 638 639 + drm = &priv->drm; 640 + crtc = priv->crtc; 646 641 conn = &priv->connector; 647 642 KUNIT_ASSERT_TRUE(test, conn->display_info.is_hdmi); 648 - 649 - ctx = drm_kunit_helper_acquire_ctx_alloc(test); 650 - KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx); 651 643 652 644 preferred = find_preferred_mode(conn); 653 645 KUNIT_ASSERT_NOT_NULL(test, preferred); 654 646 KUNIT_ASSERT_NE(test, drm_match_cea_mode(preferred), 1); 655 647 656 - drm = &priv->drm; 657 - crtc = priv->crtc; 648 + ctx = drm_kunit_helper_acquire_ctx_alloc(test); 649 + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx); 650 + 658 651 ret = light_up_connector(test, drm, crtc, conn, preferred, ctx); 659 652 KUNIT_ASSERT_EQ(test, ret, 0); 660 653 ··· 711 704 mode = drm_kunit_display_mode_from_cea_vic(test, drm, 1); 712 705 KUNIT_ASSERT_NOT_NULL(test, mode); 713 706 714 - drm = &priv->drm; 715 707 crtc = priv->crtc; 716 708 ret = light_up_connector(test, drm, crtc, conn, mode, ctx); 717 709 KUNIT_ASSERT_EQ(test, ret, 0); ··· 760 754 10); 761 755 KUNIT_ASSERT_NOT_NULL(test, priv); 762 756 757 + drm = &priv->drm; 758 + crtc = priv->crtc; 763 759 conn = &priv->connector; 764 760 ret = set_connector_edid(test, conn, 765 761 test_edid_hdmi_1080p_rgb_yuv_dc_max_200mhz, 766 762 ARRAY_SIZE(test_edid_hdmi_1080p_rgb_yuv_dc_max_200mhz)); 767 763 KUNIT_ASSERT_GT(test, ret, 0); 768 764 769 - ctx = drm_kunit_helper_acquire_ctx_alloc(test); 770 - KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx); 771 - 772 765 preferred = find_preferred_mode(conn); 773 766 KUNIT_ASSERT_NOT_NULL(test, preferred); 774 767 775 - drm = &priv->drm; 776 - crtc = priv->crtc; 768 + ctx = drm_kunit_helper_acquire_ctx_alloc(test); 769 + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx); 770 + 777 771 ret = light_up_connector(test, drm, crtc, conn, preferred, ctx); 778 772 KUNIT_ASSERT_EQ(test, ret, 0); 779 773 ··· 834 828 10); 835 829 KUNIT_ASSERT_NOT_NULL(test, priv); 836 830 831 + drm = &priv->drm; 832 + crtc = priv->crtc; 837 833 conn = &priv->connector; 838 834 ret = set_connector_edid(test, conn, 839 835 test_edid_hdmi_1080p_rgb_yuv_dc_max_200mhz, 840 836 ARRAY_SIZE(test_edid_hdmi_1080p_rgb_yuv_dc_max_200mhz)); 841 837 KUNIT_ASSERT_GT(test, ret, 0); 842 838 843 - ctx = drm_kunit_helper_acquire_ctx_alloc(test); 844 - KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx); 845 - 846 839 preferred = find_preferred_mode(conn); 847 840 KUNIT_ASSERT_NOT_NULL(test, preferred); 848 841 849 - drm = &priv->drm; 850 - crtc = priv->crtc; 842 + ctx = drm_kunit_helper_acquire_ctx_alloc(test); 843 + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx); 844 + 851 845 ret = light_up_connector(test, drm, crtc, conn, preferred, ctx); 852 846 KUNIT_ASSERT_EQ(test, ret, 0); 853 847 ··· 905 899 12); 906 900 KUNIT_ASSERT_NOT_NULL(test, priv); 907 901 902 + drm = &priv->drm; 903 + crtc = priv->crtc; 908 904 conn = &priv->connector; 909 905 ret = set_connector_edid(test, conn, 910 906 test_edid_dvi_1080p, ··· 916 908 info = &conn->display_info; 917 909 KUNIT_ASSERT_FALSE(test, info->is_hdmi); 918 910 919 - ctx = drm_kunit_helper_acquire_ctx_alloc(test); 920 - KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx); 921 - 922 911 preferred = find_preferred_mode(conn); 923 912 KUNIT_ASSERT_NOT_NULL(test, preferred); 924 913 925 - drm = &priv->drm; 926 - crtc = priv->crtc; 914 + ctx = drm_kunit_helper_acquire_ctx_alloc(test); 915 + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx); 916 + 927 917 ret = light_up_connector(test, drm, crtc, conn, preferred, ctx); 928 918 KUNIT_ASSERT_EQ(test, ret, 0); 929 919 ··· 952 946 8); 953 947 KUNIT_ASSERT_NOT_NULL(test, priv); 954 948 949 + drm = &priv->drm; 950 + crtc = priv->crtc; 955 951 conn = &priv->connector; 956 952 ret = set_connector_edid(test, conn, 957 953 test_edid_hdmi_1080p_rgb_max_200mhz, 958 954 ARRAY_SIZE(test_edid_hdmi_1080p_rgb_max_200mhz)); 959 955 KUNIT_ASSERT_GT(test, ret, 0); 960 956 961 - ctx = drm_kunit_helper_acquire_ctx_alloc(test); 962 - KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx); 963 - 964 957 preferred = find_preferred_mode(conn); 965 958 KUNIT_ASSERT_NOT_NULL(test, preferred); 966 959 KUNIT_ASSERT_FALSE(test, preferred->flags & DRM_MODE_FLAG_DBLCLK); 967 960 968 - drm = &priv->drm; 969 - crtc = priv->crtc; 961 + ctx = drm_kunit_helper_acquire_ctx_alloc(test); 962 + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx); 963 + 970 964 ret = light_up_connector(test, drm, crtc, conn, preferred, ctx); 971 965 KUNIT_ASSERT_EQ(test, ret, 0); 972 966 ··· 999 993 10); 1000 994 KUNIT_ASSERT_NOT_NULL(test, priv); 1001 995 996 + drm = &priv->drm; 997 + crtc = priv->crtc; 1002 998 conn = &priv->connector; 1003 999 ret = set_connector_edid(test, conn, 1004 1000 test_edid_hdmi_1080p_rgb_yuv_dc_max_340mhz, 1005 1001 ARRAY_SIZE(test_edid_hdmi_1080p_rgb_yuv_dc_max_340mhz)); 1006 1002 KUNIT_ASSERT_GT(test, ret, 0); 1007 1003 1008 - ctx = drm_kunit_helper_acquire_ctx_alloc(test); 1009 - KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx); 1010 - 1011 1004 preferred = find_preferred_mode(conn); 1012 1005 KUNIT_ASSERT_NOT_NULL(test, preferred); 1013 1006 KUNIT_ASSERT_FALSE(test, preferred->flags & DRM_MODE_FLAG_DBLCLK); 1014 1007 1015 - drm = &priv->drm; 1016 - crtc = priv->crtc; 1008 + ctx = drm_kunit_helper_acquire_ctx_alloc(test); 1009 + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx); 1010 + 1017 1011 ret = light_up_connector(test, drm, crtc, conn, preferred, ctx); 1018 1012 KUNIT_ASSERT_EQ(test, ret, 0); 1019 1013 ··· 1046 1040 12); 1047 1041 KUNIT_ASSERT_NOT_NULL(test, priv); 1048 1042 1043 + drm = &priv->drm; 1044 + crtc = priv->crtc; 1049 1045 conn = &priv->connector; 1050 1046 ret = set_connector_edid(test, conn, 1051 1047 test_edid_hdmi_1080p_rgb_yuv_dc_max_340mhz, 1052 1048 ARRAY_SIZE(test_edid_hdmi_1080p_rgb_yuv_dc_max_340mhz)); 1053 1049 KUNIT_ASSERT_GT(test, ret, 0); 1054 1050 1055 - ctx = drm_kunit_helper_acquire_ctx_alloc(test); 1056 - KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx); 1057 - 1058 1051 preferred = find_preferred_mode(conn); 1059 1052 KUNIT_ASSERT_NOT_NULL(test, preferred); 1060 1053 KUNIT_ASSERT_FALSE(test, preferred->flags & DRM_MODE_FLAG_DBLCLK); 1061 1054 1062 - drm = &priv->drm; 1063 - crtc = priv->crtc; 1055 + ctx = drm_kunit_helper_acquire_ctx_alloc(test); 1056 + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx); 1057 + 1064 1058 ret = light_up_connector(test, drm, crtc, conn, preferred, ctx); 1065 1059 KUNIT_ASSERT_EQ(test, ret, 0); 1066 1060 ··· 1097 1091 8); 1098 1092 KUNIT_ASSERT_NOT_NULL(test, priv); 1099 1093 1100 - ctx = drm_kunit_helper_acquire_ctx_alloc(test); 1101 - KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx); 1102 - 1094 + drm = &priv->drm; 1095 + crtc = priv->crtc; 1103 1096 conn = &priv->connector; 1097 + 1104 1098 preferred = find_preferred_mode(conn); 1105 1099 KUNIT_ASSERT_NOT_NULL(test, preferred); 1106 1100 1107 - drm = &priv->drm; 1108 - crtc = priv->crtc; 1101 + ctx = drm_kunit_helper_acquire_ctx_alloc(test); 1102 + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx); 1103 + 1109 1104 ret = light_up_connector(test, drm, crtc, conn, preferred, ctx); 1110 1105 KUNIT_ASSERT_EQ(test, ret, 0); 1111 1106 ··· 1154 1147 12); 1155 1148 KUNIT_ASSERT_NOT_NULL(test, priv); 1156 1149 1150 + drm = &priv->drm; 1151 + crtc = priv->crtc; 1157 1152 conn = &priv->connector; 1158 1153 ret = set_connector_edid(test, conn, 1159 1154 test_edid_hdmi_1080p_rgb_yuv_dc_max_200mhz, ··· 1165 1156 info = &conn->display_info; 1166 1157 KUNIT_ASSERT_TRUE(test, info->is_hdmi); 1167 1158 KUNIT_ASSERT_GT(test, info->max_tmds_clock, 0); 1168 - 1169 - ctx = drm_kunit_helper_acquire_ctx_alloc(test); 1170 - KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx); 1171 1159 1172 1160 preferred = find_preferred_mode(conn); 1173 1161 KUNIT_ASSERT_NOT_NULL(test, preferred); ··· 1176 1170 rate = drm_hdmi_compute_mode_clock(preferred, 10, HDMI_COLORSPACE_RGB); 1177 1171 KUNIT_ASSERT_LT(test, rate, info->max_tmds_clock * 1000); 1178 1172 1179 - drm = &priv->drm; 1180 - crtc = priv->crtc; 1173 + ctx = drm_kunit_helper_acquire_ctx_alloc(test); 1174 + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx); 1175 + 1181 1176 ret = light_up_connector(test, drm, crtc, conn, preferred, ctx); 1182 1177 KUNIT_EXPECT_EQ(test, ret, 0); 1183 1178 ··· 1223 1216 12); 1224 1217 KUNIT_ASSERT_NOT_NULL(test, priv); 1225 1218 1219 + drm = &priv->drm; 1220 + crtc = priv->crtc; 1226 1221 conn = &priv->connector; 1227 1222 ret = set_connector_edid(test, conn, 1228 1223 test_edid_hdmi_1080p_rgb_yuv_dc_max_200mhz, ··· 1234 1225 info = &conn->display_info; 1235 1226 KUNIT_ASSERT_TRUE(test, info->is_hdmi); 1236 1227 KUNIT_ASSERT_GT(test, info->max_tmds_clock, 0); 1237 - 1238 - ctx = drm_kunit_helper_acquire_ctx_alloc(test); 1239 - KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx); 1240 1228 1241 1229 preferred = find_preferred_mode(conn); 1242 1230 KUNIT_ASSERT_NOT_NULL(test, preferred); ··· 1248 1242 rate = drm_hdmi_compute_mode_clock(preferred, 12, HDMI_COLORSPACE_YUV422); 1249 1243 KUNIT_ASSERT_LT(test, rate, info->max_tmds_clock * 1000); 1250 1244 1251 - drm = &priv->drm; 1252 - crtc = priv->crtc; 1245 + ctx = drm_kunit_helper_acquire_ctx_alloc(test); 1246 + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx); 1247 + 1253 1248 ret = light_up_connector(test, drm, crtc, conn, preferred, ctx); 1254 1249 KUNIT_EXPECT_EQ(test, ret, 0); 1255 1250 ··· 1297 1290 KUNIT_ASSERT_TRUE(test, info->is_hdmi); 1298 1291 KUNIT_ASSERT_GT(test, info->max_tmds_clock, 0); 1299 1292 1300 - ctx = drm_kunit_helper_acquire_ctx_alloc(test); 1301 - KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx); 1302 - 1303 1293 mode = drm_kunit_display_mode_from_cea_vic(test, drm, 1); 1304 1294 KUNIT_ASSERT_NOT_NULL(test, mode); 1305 1295 ··· 1310 1306 rate = mode->clock * 1500; 1311 1307 KUNIT_ASSERT_LT(test, rate, info->max_tmds_clock * 1000); 1312 1308 1313 - drm = &priv->drm; 1309 + ctx = drm_kunit_helper_acquire_ctx_alloc(test); 1310 + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx); 1311 + 1314 1312 crtc = priv->crtc; 1315 1313 ret = light_up_connector(test, drm, crtc, conn, mode, ctx); 1316 1314 KUNIT_EXPECT_EQ(test, ret, 0); ··· 1346 1340 12); 1347 1341 KUNIT_ASSERT_NOT_NULL(test, priv); 1348 1342 1343 + drm = &priv->drm; 1344 + crtc = priv->crtc; 1349 1345 conn = &priv->connector; 1350 1346 ret = set_connector_edid(test, conn, 1351 1347 test_edid_hdmi_1080p_rgb_yuv_dc_max_200mhz, ··· 1357 1349 info = &conn->display_info; 1358 1350 KUNIT_ASSERT_TRUE(test, info->is_hdmi); 1359 1351 KUNIT_ASSERT_GT(test, info->max_tmds_clock, 0); 1360 - 1361 - ctx = drm_kunit_helper_acquire_ctx_alloc(test); 1362 - KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx); 1363 1352 1364 1353 preferred = find_preferred_mode(conn); 1365 1354 KUNIT_ASSERT_NOT_NULL(test, preferred); ··· 1376 1371 rate = drm_hdmi_compute_mode_clock(preferred, 12, HDMI_COLORSPACE_YUV422); 1377 1372 KUNIT_ASSERT_LT(test, rate, info->max_tmds_clock * 1000); 1378 1373 1379 - drm = &priv->drm; 1380 - crtc = priv->crtc; 1374 + ctx = drm_kunit_helper_acquire_ctx_alloc(test); 1375 + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx); 1376 + 1381 1377 ret = light_up_connector(test, drm, crtc, conn, preferred, ctx); 1382 1378 KUNIT_EXPECT_EQ(test, ret, 0); 1383 1379 ··· 1413 1407 12); 1414 1408 KUNIT_ASSERT_NOT_NULL(test, priv); 1415 1409 1410 + drm = &priv->drm; 1411 + crtc = priv->crtc; 1416 1412 conn = &priv->connector; 1417 1413 ret = set_connector_edid(test, conn, 1418 1414 test_edid_hdmi_1080p_rgb_max_200mhz, ··· 1424 1416 info = &conn->display_info; 1425 1417 KUNIT_ASSERT_TRUE(test, info->is_hdmi); 1426 1418 KUNIT_ASSERT_GT(test, info->max_tmds_clock, 0); 1427 - 1428 - ctx = drm_kunit_helper_acquire_ctx_alloc(test); 1429 - KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx); 1430 1419 1431 1420 preferred = find_preferred_mode(conn); 1432 1421 KUNIT_ASSERT_NOT_NULL(test, preferred); ··· 1443 1438 rate = drm_hdmi_compute_mode_clock(preferred, 12, HDMI_COLORSPACE_YUV422); 1444 1439 KUNIT_ASSERT_LT(test, rate, info->max_tmds_clock * 1000); 1445 1440 1446 - drm = &priv->drm; 1447 - crtc = priv->crtc; 1441 + ctx = drm_kunit_helper_acquire_ctx_alloc(test); 1442 + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx); 1443 + 1448 1444 ret = light_up_connector(test, drm, crtc, conn, preferred, ctx); 1449 1445 KUNIT_EXPECT_EQ(test, ret, 0); 1450 1446 ··· 1479 1473 8); 1480 1474 KUNIT_ASSERT_NOT_NULL(test, priv); 1481 1475 1476 + drm = &priv->drm; 1477 + crtc = priv->crtc; 1482 1478 conn = &priv->connector; 1483 1479 ret = set_connector_edid(test, conn, 1484 1480 test_edid_hdmi_1080p_rgb_yuv_dc_max_340mhz, ··· 1490 1482 info = &conn->display_info; 1491 1483 KUNIT_ASSERT_TRUE(test, info->is_hdmi); 1492 1484 KUNIT_ASSERT_GT(test, info->max_tmds_clock, 0); 1493 - 1494 - ctx = drm_kunit_helper_acquire_ctx_alloc(test); 1495 - KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx); 1496 1485 1497 1486 preferred = find_preferred_mode(conn); 1498 1487 KUNIT_ASSERT_NOT_NULL(test, preferred); ··· 1501 1496 rate = drm_hdmi_compute_mode_clock(preferred, 12, HDMI_COLORSPACE_RGB); 1502 1497 KUNIT_ASSERT_LT(test, rate, info->max_tmds_clock * 1000); 1503 1498 1504 - drm = &priv->drm; 1505 - crtc = priv->crtc; 1499 + ctx = drm_kunit_helper_acquire_ctx_alloc(test); 1500 + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx); 1501 + 1506 1502 ret = light_up_connector(test, drm, crtc, conn, preferred, ctx); 1507 1503 KUNIT_EXPECT_EQ(test, ret, 0); 1508 1504 ··· 1539 1533 12); 1540 1534 KUNIT_ASSERT_NOT_NULL(test, priv); 1541 1535 1536 + drm = &priv->drm; 1537 + crtc = priv->crtc; 1542 1538 conn = &priv->connector; 1543 1539 ret = set_connector_edid(test, conn, 1544 1540 test_edid_hdmi_1080p_rgb_max_340mhz, ··· 1550 1542 info = &conn->display_info; 1551 1543 KUNIT_ASSERT_TRUE(test, info->is_hdmi); 1552 1544 KUNIT_ASSERT_GT(test, info->max_tmds_clock, 0); 1553 - 1554 - ctx = drm_kunit_helper_acquire_ctx_alloc(test); 1555 - KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx); 1556 1545 1557 1546 preferred = find_preferred_mode(conn); 1558 1547 KUNIT_ASSERT_NOT_NULL(test, preferred); ··· 1561 1556 rate = drm_hdmi_compute_mode_clock(preferred, 12, HDMI_COLORSPACE_RGB); 1562 1557 KUNIT_ASSERT_LT(test, rate, info->max_tmds_clock * 1000); 1563 1558 1564 - drm = &priv->drm; 1565 - crtc = priv->crtc; 1559 + ctx = drm_kunit_helper_acquire_ctx_alloc(test); 1560 + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx); 1561 + 1566 1562 ret = light_up_connector(test, drm, crtc, conn, preferred, ctx); 1567 1563 KUNIT_EXPECT_EQ(test, ret, 0); 1568 1564
+1 -1
drivers/gpu/drm/xe/xe_drm_client.c
··· 135 135 XE_WARN_ON(bo->client); 136 136 XE_WARN_ON(!list_empty(&bo->client_link)); 137 137 138 - spin_lock(&client->bos_lock); 139 138 bo->client = xe_drm_client_get(client); 139 + spin_lock(&client->bos_lock); 140 140 list_add_tail(&bo->client_link, &client->bos_list); 141 141 spin_unlock(&client->bos_lock); 142 142 }
+38 -32
drivers/gpu/drm/xe/xe_ttm_stolen_mgr.c
··· 57 57 return GRAPHICS_VERx100(xe) < 1270 && !IS_DGFX(xe); 58 58 } 59 59 60 - static s64 detect_bar2_dgfx(struct xe_device *xe, struct xe_ttm_stolen_mgr *mgr) 61 - { 62 - struct xe_tile *tile = xe_device_get_root_tile(xe); 63 - struct xe_mmio *mmio = xe_root_tile_mmio(xe); 64 - struct pci_dev *pdev = to_pci_dev(xe->drm.dev); 65 - u64 stolen_size; 66 - u64 tile_offset; 67 - u64 tile_size; 68 - 69 - tile_offset = tile->mem.vram.io_start - xe->mem.vram.io_start; 70 - tile_size = tile->mem.vram.actual_physical_size; 71 - 72 - /* Use DSM base address instead for stolen memory */ 73 - mgr->stolen_base = (xe_mmio_read64_2x32(mmio, DSMBASE) & BDSM_MASK) - tile_offset; 74 - if (drm_WARN_ON(&xe->drm, tile_size < mgr->stolen_base)) 75 - return 0; 76 - 77 - stolen_size = tile_size - mgr->stolen_base; 78 - 79 - /* Verify usage fits in the actual resource available */ 80 - if (mgr->stolen_base + stolen_size <= pci_resource_len(pdev, LMEM_BAR)) 81 - mgr->io_base = tile->mem.vram.io_start + mgr->stolen_base; 82 - 83 - /* 84 - * There may be few KB of platform dependent reserved memory at the end 85 - * of vram which is not part of the DSM. Such reserved memory portion is 86 - * always less then DSM granularity so align down the stolen_size to DSM 87 - * granularity to accommodate such reserve vram portion. 88 - */ 89 - return ALIGN_DOWN(stolen_size, SZ_1M); 90 - } 91 - 92 60 static u32 get_wopcm_size(struct xe_device *xe) 93 61 { 94 62 u32 wopcm_size; ··· 78 110 } 79 111 80 112 return wopcm_size; 113 + } 114 + 115 + static s64 detect_bar2_dgfx(struct xe_device *xe, struct xe_ttm_stolen_mgr *mgr) 116 + { 117 + struct xe_tile *tile = xe_device_get_root_tile(xe); 118 + struct xe_mmio *mmio = xe_root_tile_mmio(xe); 119 + struct pci_dev *pdev = to_pci_dev(xe->drm.dev); 120 + u64 stolen_size, wopcm_size; 121 + u64 tile_offset; 122 + u64 tile_size; 123 + 124 + tile_offset = tile->mem.vram.io_start - xe->mem.vram.io_start; 125 + tile_size = tile->mem.vram.actual_physical_size; 126 + 127 + /* Use DSM base address instead for stolen memory */ 128 + mgr->stolen_base = (xe_mmio_read64_2x32(mmio, DSMBASE) & BDSM_MASK) - tile_offset; 129 + if (drm_WARN_ON(&xe->drm, tile_size < mgr->stolen_base)) 130 + return 0; 131 + 132 + /* Carve out the top of DSM as it contains the reserved WOPCM region */ 133 + wopcm_size = get_wopcm_size(xe); 134 + if (drm_WARN_ON(&xe->drm, !wopcm_size)) 135 + return 0; 136 + 137 + stolen_size = tile_size - mgr->stolen_base; 138 + stolen_size -= wopcm_size; 139 + 140 + /* Verify usage fits in the actual resource available */ 141 + if (mgr->stolen_base + stolen_size <= pci_resource_len(pdev, LMEM_BAR)) 142 + mgr->io_base = tile->mem.vram.io_start + mgr->stolen_base; 143 + 144 + /* 145 + * There may be few KB of platform dependent reserved memory at the end 146 + * of vram which is not part of the DSM. Such reserved memory portion is 147 + * always less then DSM granularity so align down the stolen_size to DSM 148 + * granularity to accommodate such reserve vram portion. 149 + */ 150 + return ALIGN_DOWN(stolen_size, SZ_1M); 81 151 } 82 152 83 153 static u32 detect_bar2_integrated(struct xe_device *xe, struct xe_ttm_stolen_mgr *mgr)
+2
drivers/gpu/host1x/dev.c
··· 619 619 goto free_contexts; 620 620 } 621 621 622 + mutex_init(&host->intr_mutex); 623 + 622 624 pm_runtime_enable(&pdev->dev); 623 625 624 626 err = devm_tegra_core_dev_init_opp_table_common(&pdev->dev);
-2
drivers/gpu/host1x/intr.c
··· 104 104 unsigned int id; 105 105 int i, err; 106 106 107 - mutex_init(&host->intr_mutex); 108 - 109 107 for (id = 0; id < host1x_syncpt_nb_pts(host); ++id) { 110 108 struct host1x_syncpt *syncpt = &host->syncpt[id]; 111 109
+1
drivers/iommu/amd/amd_iommu_types.h
··· 175 175 #define CONTROL_GAM_EN 25 176 176 #define CONTROL_GALOG_EN 28 177 177 #define CONTROL_GAINT_EN 29 178 + #define CONTROL_EPH_EN 45 178 179 #define CONTROL_XT_EN 50 179 180 #define CONTROL_INTCAPXT_EN 51 180 181 #define CONTROL_IRTCACHEDIS 59
+34 -4
drivers/iommu/amd/init.c
··· 2653 2653 2654 2654 /* Set IOTLB invalidation timeout to 1s */ 2655 2655 iommu_set_inv_tlb_timeout(iommu, CTRL_INV_TO_1S); 2656 + 2657 + /* Enable Enhanced Peripheral Page Request Handling */ 2658 + if (check_feature(FEATURE_EPHSUP)) 2659 + iommu_feature_enable(iommu, CONTROL_EPH_EN); 2656 2660 } 2657 2661 2658 2662 static void iommu_apply_resume_quirks(struct amd_iommu *iommu) ··· 3198 3194 return true; 3199 3195 } 3200 3196 3201 - static void iommu_snp_enable(void) 3197 + static __init void iommu_snp_enable(void) 3202 3198 { 3203 3199 #ifdef CONFIG_KVM_AMD_SEV 3204 3200 if (!cc_platform_has(CC_ATTR_HOST_SEV_SNP)) ··· 3220 3216 amd_iommu_snp_en = check_feature(FEATURE_SNP); 3221 3217 if (!amd_iommu_snp_en) { 3222 3218 pr_warn("SNP: IOMMU SNP feature not enabled, SNP cannot be supported.\n"); 3219 + goto disable_snp; 3220 + } 3221 + 3222 + /* 3223 + * Enable host SNP support once SNP support is checked on IOMMU. 3224 + */ 3225 + if (snp_rmptable_init()) { 3226 + pr_warn("SNP: RMP initialization failed, SNP cannot be supported.\n"); 3223 3227 goto disable_snp; 3224 3228 } 3225 3229 ··· 3329 3317 break; 3330 3318 ret = state_next(); 3331 3319 } 3320 + 3321 + /* 3322 + * SNP platform initilazation requires IOMMUs to be fully configured. 3323 + * If the SNP support on IOMMUs has NOT been checked, simply mark SNP 3324 + * as unsupported. If the SNP support on IOMMUs has been checked and 3325 + * host SNP support enabled but RMP enforcement has not been enabled 3326 + * in IOMMUs, then the system is in a half-baked state, but can limp 3327 + * along as all memory should be Hypervisor-Owned in the RMP. WARN, 3328 + * but leave SNP as "supported" to avoid confusing the kernel. 3329 + */ 3330 + if (ret && cc_platform_has(CC_ATTR_HOST_SEV_SNP) && 3331 + !WARN_ON_ONCE(amd_iommu_snp_en)) 3332 + cc_platform_clear(CC_ATTR_HOST_SEV_SNP); 3332 3333 3333 3334 return ret; 3334 3335 } ··· 3451 3426 int ret; 3452 3427 3453 3428 if (no_iommu || (iommu_detected && !gart_iommu_aperture)) 3454 - return; 3429 + goto disable_snp; 3455 3430 3456 3431 if (!amd_iommu_sme_check()) 3457 - return; 3432 + goto disable_snp; 3458 3433 3459 3434 ret = iommu_go_to_state(IOMMU_IVRS_DETECTED); 3460 3435 if (ret) 3461 - return; 3436 + goto disable_snp; 3462 3437 3463 3438 amd_iommu_detected = true; 3464 3439 iommu_detected = 1; 3465 3440 x86_init.iommu.iommu_init = amd_iommu_init; 3441 + return; 3442 + 3443 + disable_snp: 3444 + if (cc_platform_has(CC_ATTR_HOST_SEV_SNP)) 3445 + cc_platform_clear(CC_ATTR_HOST_SEV_SNP); 3466 3446 } 3467 3447 3468 3448 /****************************************************************************
+3 -3
drivers/iommu/exynos-iommu.c
··· 249 249 struct list_head clients; /* list of sysmmu_drvdata.domain_node */ 250 250 sysmmu_pte_t *pgtable; /* lv1 page table, 16KB */ 251 251 short *lv2entcnt; /* free lv2 entry counter for each section */ 252 - spinlock_t lock; /* lock for modyfying list of clients */ 252 + spinlock_t lock; /* lock for modifying list of clients */ 253 253 spinlock_t pgtablelock; /* lock for modifying page table @ pgtable */ 254 254 struct iommu_domain domain; /* generic domain data structure */ 255 255 }; ··· 292 292 struct clk *aclk; /* SYSMMU's aclk clock */ 293 293 struct clk *pclk; /* SYSMMU's pclk clock */ 294 294 struct clk *clk_master; /* master's device clock */ 295 - spinlock_t lock; /* lock for modyfying state */ 295 + spinlock_t lock; /* lock for modifying state */ 296 296 bool active; /* current status */ 297 297 struct exynos_iommu_domain *domain; /* domain we belong to */ 298 298 struct list_head domain_node; /* node for domain clients list */ ··· 746 746 ret = devm_request_irq(dev, irq, exynos_sysmmu_irq, 0, 747 747 dev_name(dev), data); 748 748 if (ret) { 749 - dev_err(dev, "Unabled to register handler of irq %d\n", irq); 749 + dev_err(dev, "Unable to register handler of irq %d\n", irq); 750 750 return ret; 751 751 } 752 752
+3 -1
drivers/iommu/intel/prq.c
··· 87 87 struct page_req_dsc *req; 88 88 89 89 req = &iommu->prq[head / sizeof(*req)]; 90 - if (!req->pasid_present || req->pasid != pasid) { 90 + if (req->rid != sid || 91 + (req->pasid_present && pasid != req->pasid) || 92 + (!req->pasid_present && pasid != IOMMU_NO_PASID)) { 91 93 head = (head + sizeof(*req)) & PRQ_RING_MASK; 92 94 continue; 93 95 }
+1
drivers/iommu/io-pgfault.c
··· 478 478 479 479 ops->page_response(dev, iopf, &resp); 480 480 list_del_init(&group->pending_node); 481 + iopf_free_group(group); 481 482 } 482 483 mutex_unlock(&fault_param->lock); 483 484
+1 -1
drivers/iommu/iommu.c
··· 1756 1756 group->id); 1757 1757 1758 1758 /* 1759 - * Try to recover, drivers are allowed to force IDENITY or DMA, IDENTITY 1759 + * Try to recover, drivers are allowed to force IDENTITY or DMA, IDENTITY 1760 1760 * takes precedence. 1761 1761 */ 1762 1762 if (type == IOMMU_DOMAIN_IDENTITY)
+20 -11
drivers/mmc/host/mtk-sd.c
··· 273 273 #define MSDC_PAD_TUNE_CMD2_SEL BIT(21) /* RW */ 274 274 275 275 #define PAD_DS_TUNE_DLY_SEL BIT(0) /* RW */ 276 + #define PAD_DS_TUNE_DLY2_SEL BIT(1) /* RW */ 276 277 #define PAD_DS_TUNE_DLY1 GENMASK(6, 2) /* RW */ 277 278 #define PAD_DS_TUNE_DLY2 GENMASK(11, 7) /* RW */ 278 279 #define PAD_DS_TUNE_DLY3 GENMASK(16, 12) /* RW */ ··· 319 318 320 319 /* EMMC50_PAD_DS_TUNE mask */ 321 320 #define PAD_DS_DLY_SEL BIT(16) /* RW */ 321 + #define PAD_DS_DLY2_SEL BIT(15) /* RW */ 322 322 #define PAD_DS_DLY1 GENMASK(14, 10) /* RW */ 323 323 #define PAD_DS_DLY3 GENMASK(4, 0) /* RW */ 324 324 ··· 2506 2504 static int msdc_prepare_hs400_tuning(struct mmc_host *mmc, struct mmc_ios *ios) 2507 2505 { 2508 2506 struct msdc_host *host = mmc_priv(mmc); 2507 + 2509 2508 host->hs400_mode = true; 2510 2509 2511 - if (host->top_base) 2512 - writel(host->hs400_ds_delay, 2513 - host->top_base + EMMC50_PAD_DS_TUNE); 2514 - else 2515 - writel(host->hs400_ds_delay, host->base + PAD_DS_TUNE); 2510 + if (host->top_base) { 2511 + if (host->hs400_ds_dly3) 2512 + sdr_set_field(host->top_base + EMMC50_PAD_DS_TUNE, 2513 + PAD_DS_DLY3, host->hs400_ds_dly3); 2514 + if (host->hs400_ds_delay) 2515 + writel(host->hs400_ds_delay, 2516 + host->top_base + EMMC50_PAD_DS_TUNE); 2517 + } else { 2518 + if (host->hs400_ds_dly3) 2519 + sdr_set_field(host->base + PAD_DS_TUNE, 2520 + PAD_DS_TUNE_DLY3, host->hs400_ds_dly3); 2521 + if (host->hs400_ds_delay) 2522 + writel(host->hs400_ds_delay, host->base + PAD_DS_TUNE); 2523 + } 2516 2524 /* hs400 mode must set it to 0 */ 2517 2525 sdr_clr_bits(host->base + MSDC_PATCH_BIT2, MSDC_PATCH_BIT2_CFGCRCSTS); 2518 2526 /* to improve read performance, set outstanding to 2 */ ··· 2542 2530 if (host->top_base) { 2543 2531 sdr_set_bits(host->top_base + EMMC50_PAD_DS_TUNE, 2544 2532 PAD_DS_DLY_SEL); 2545 - if (host->hs400_ds_dly3) 2546 - sdr_set_field(host->top_base + EMMC50_PAD_DS_TUNE, 2547 - PAD_DS_DLY3, host->hs400_ds_dly3); 2533 + sdr_clr_bits(host->top_base + EMMC50_PAD_DS_TUNE, 2534 + PAD_DS_DLY2_SEL); 2548 2535 } else { 2549 2536 sdr_set_bits(host->base + PAD_DS_TUNE, PAD_DS_TUNE_DLY_SEL); 2550 - if (host->hs400_ds_dly3) 2551 - sdr_set_field(host->base + PAD_DS_TUNE, 2552 - PAD_DS_TUNE_DLY3, host->hs400_ds_dly3); 2537 + sdr_clr_bits(host->base + PAD_DS_TUNE, PAD_DS_TUNE_DLY2_SEL); 2553 2538 } 2554 2539 2555 2540 host->hs400_tuning = true;
-30
drivers/mmc/host/sdhci_am654.c
··· 155 155 u32 tuning_loop; 156 156 157 157 #define SDHCI_AM654_QUIRK_FORCE_CDTEST BIT(0) 158 - #define SDHCI_AM654_QUIRK_SUPPRESS_V1P8_ENA BIT(1) 159 158 }; 160 159 161 160 struct window { ··· 354 355 sdhci_am654->clkbuf_sel); 355 356 356 357 sdhci_set_clock(host, clock); 357 - } 358 - 359 - static int sdhci_am654_start_signal_voltage_switch(struct mmc_host *mmc, struct mmc_ios *ios) 360 - { 361 - struct sdhci_host *host = mmc_priv(mmc); 362 - struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); 363 - struct sdhci_am654_data *sdhci_am654 = sdhci_pltfm_priv(pltfm_host); 364 - int ret; 365 - 366 - if ((sdhci_am654->quirks & SDHCI_AM654_QUIRK_SUPPRESS_V1P8_ENA) && 367 - ios->signal_voltage == MMC_SIGNAL_VOLTAGE_180) { 368 - if (!IS_ERR(mmc->supply.vqmmc)) { 369 - ret = mmc_regulator_set_vqmmc(mmc, ios); 370 - if (ret < 0) { 371 - pr_err("%s: Switching to 1.8V signalling voltage failed,\n", 372 - mmc_hostname(mmc)); 373 - return -EIO; 374 - } 375 - } 376 - return 0; 377 - } 378 - 379 - return sdhci_start_signal_voltage_switch(mmc, ios); 380 358 } 381 359 382 360 static u8 sdhci_am654_write_power_on(struct sdhci_host *host, u8 val, int reg) ··· 844 868 if (device_property_read_bool(dev, "ti,fails-without-test-cd")) 845 869 sdhci_am654->quirks |= SDHCI_AM654_QUIRK_FORCE_CDTEST; 846 870 847 - /* Suppress v1p8 ena for eMMC and SD with vqmmc supply */ 848 - if (!!of_parse_phandle(dev->of_node, "vmmc-supply", 0) == 849 - !!of_parse_phandle(dev->of_node, "vqmmc-supply", 0)) 850 - sdhci_am654->quirks |= SDHCI_AM654_QUIRK_SUPPRESS_V1P8_ENA; 851 - 852 871 sdhci_get_of_property(pdev); 853 872 854 873 return 0; ··· 940 969 goto err_pltfm_free; 941 970 } 942 971 943 - host->mmc_host_ops.start_signal_voltage_switch = sdhci_am654_start_signal_voltage_switch; 944 972 host->mmc_host_ops.execute_tuning = sdhci_am654_execute_tuning; 945 973 946 974 pm_runtime_get_noresume(dev);
+10
drivers/net/ethernet/google/gve/gve.h
··· 1116 1116 return gve_xdp_tx_queue_id(priv, 0); 1117 1117 } 1118 1118 1119 + static inline bool gve_supports_xdp_xmit(struct gve_priv *priv) 1120 + { 1121 + switch (priv->queue_format) { 1122 + case GVE_GQI_QPL_FORMAT: 1123 + return true; 1124 + default: 1125 + return false; 1126 + } 1127 + } 1128 + 1119 1129 /* gqi napi handler defined in gve_main.c */ 1120 1130 int gve_napi_poll(struct napi_struct *napi, int budget); 1121 1131
+5 -1
drivers/net/ethernet/google/gve/gve_main.c
··· 1903 1903 /* Stop tx queues */ 1904 1904 netif_tx_disable(priv->dev); 1905 1905 1906 + xdp_features_clear_redirect_target(priv->dev); 1907 + 1906 1908 gve_clear_napi_enabled(priv); 1907 1909 gve_clear_report_stats(priv); 1908 1910 ··· 1973 1971 mb(); 1974 1972 napi_schedule(&block->napi); 1975 1973 } 1974 + 1975 + if (priv->num_xdp_queues && gve_supports_xdp_xmit(priv)) 1976 + xdp_features_set_redirect_target(priv->dev, false); 1976 1977 1977 1978 gve_set_napi_enabled(priv); 1978 1979 } ··· 2251 2246 if (priv->queue_format == GVE_GQI_QPL_FORMAT) { 2252 2247 xdp_features = NETDEV_XDP_ACT_BASIC; 2253 2248 xdp_features |= NETDEV_XDP_ACT_REDIRECT; 2254 - xdp_features |= NETDEV_XDP_ACT_NDO_XMIT; 2255 2249 xdp_features |= NETDEV_XDP_ACT_XSK_ZEROCOPY; 2256 2250 } else { 2257 2251 xdp_features = 0;
+3 -1
drivers/net/ethernet/ibm/ibmvnic.c
··· 2408 2408 dma_addr_t data_dma_addr; 2409 2409 struct netdev_queue *txq; 2410 2410 unsigned long lpar_rc; 2411 + unsigned int skblen; 2411 2412 union sub_crq tx_crq; 2412 2413 unsigned int offset; 2413 2414 bool use_scrq_send_direct = false; ··· 2523 2522 tx_buff->skb = skb; 2524 2523 tx_buff->index = bufidx; 2525 2524 tx_buff->pool_index = queue_num; 2525 + skblen = skb->len; 2526 2526 2527 2527 memset(&tx_crq, 0, sizeof(tx_crq)); 2528 2528 tx_crq.v1.first = IBMVNIC_CRQ_CMD; ··· 2616 2614 netif_stop_subqueue(netdev, queue_num); 2617 2615 } 2618 2616 2619 - tx_bytes += skb->len; 2617 + tx_bytes += skblen; 2620 2618 txq_trans_cond_update(txq); 2621 2619 ret = NETDEV_TX_OK; 2622 2620 goto out;
+2
drivers/net/ethernet/netronome/nfp/bpf/cmsg.c
··· 20 20 struct sk_buff *skb; 21 21 22 22 skb = nfp_app_ctrl_msg_alloc(bpf->app, size, GFP_KERNEL); 23 + if (!skb) 24 + return NULL; 23 25 skb_put(skb, size); 24 26 25 27 return skb;
+1
drivers/net/ethernet/xilinx/xilinx_axienet_main.c
··· 3082 3082 3083 3083 lp->phylink_config.dev = &ndev->dev; 3084 3084 lp->phylink_config.type = PHYLINK_NETDEV; 3085 + lp->phylink_config.mac_managed_pm = true; 3085 3086 lp->phylink_config.mac_capabilities = MAC_SYM_PAUSE | MAC_ASYM_PAUSE | 3086 3087 MAC_10FD | MAC_100FD | MAC_1000FD; 3087 3088
+2 -14
drivers/net/geneve.c
··· 1902 1902 { 1903 1903 struct geneve_net *gn = net_generic(net, geneve_net_id); 1904 1904 struct geneve_dev *geneve, *next; 1905 - struct net_device *dev, *aux; 1906 1905 1907 - /* gather any geneve devices that were moved into this ns */ 1908 - for_each_netdev_safe(net, dev, aux) 1909 - if (dev->rtnl_link_ops == &geneve_link_ops) 1910 - unregister_netdevice_queue(dev, head); 1911 - 1912 - /* now gather any other geneve devices that were created in this ns */ 1913 - list_for_each_entry_safe(geneve, next, &gn->geneve_list, next) { 1914 - /* If geneve->dev is in the same netns, it was already added 1915 - * to the list by the previous loop. 1916 - */ 1917 - if (!net_eq(dev_net(geneve->dev), net)) 1918 - unregister_netdevice_queue(geneve->dev, head); 1919 - } 1906 + list_for_each_entry_safe(geneve, next, &gn->geneve_list, next) 1907 + geneve_dellink(geneve->dev, head); 1920 1908 } 1921 1909 1922 1910 static void __net_exit geneve_exit_batch_rtnl(struct list_head *net_list,
-5
drivers/net/gtp.c
··· 2481 2481 list_for_each_entry(net, net_list, exit_list) { 2482 2482 struct gtp_net *gn = net_generic(net, gtp_net_id); 2483 2483 struct gtp_dev *gtp, *gtp_next; 2484 - struct net_device *dev; 2485 - 2486 - for_each_netdev(net, dev) 2487 - if (dev->rtnl_link_ops == &gtp_link_ops) 2488 - gtp_dellink(dev, dev_to_kill); 2489 2484 2490 2485 list_for_each_entry_safe(gtp, gtp_next, &gn->gtp_dev_list, list) 2491 2486 gtp_dellink(gtp->dev, dev_to_kill);
+1 -1
drivers/net/pse-pd/pd692x0.c
··· 1047 1047 if (ret < 0) 1048 1048 return ret; 1049 1049 1050 - return pd692x0_pi_get_pw_from_table(buf.data[2], buf.data[3]); 1050 + return pd692x0_pi_get_pw_from_table(buf.data[0], buf.data[1]); 1051 1051 } 1052 1052 1053 1053 static int pd692x0_pi_set_pw_limit(struct pse_controller_dev *pcdev,
+1 -1
drivers/net/wwan/mhi_wwan_mbim.c
··· 220 220 if (mbim->rx_seq + 1 != le16_to_cpu(nth16->wSequence) && 221 221 (mbim->rx_seq || le16_to_cpu(nth16->wSequence)) && 222 222 !(mbim->rx_seq == 0xffff && !le16_to_cpu(nth16->wSequence))) { 223 - net_err_ratelimited("sequence number glitch prev=%d curr=%d\n", 223 + net_dbg_ratelimited("sequence number glitch prev=%d curr=%d\n", 224 224 mbim->rx_seq, le16_to_cpu(nth16->wSequence)); 225 225 } 226 226 mbim->rx_seq = le16_to_cpu(nth16->wSequence);
+4 -1
drivers/of/address.c
··· 16 16 #include <linux/string.h> 17 17 #include <linux/dma-direct.h> /* for bus_dma_region */ 18 18 19 + #include <kunit/visibility.h> 20 + 19 21 /* Uncomment me to enable of_dump_addr() debugging output */ 20 22 // #define DEBUG 21 23 ··· 185 183 186 184 #endif /* CONFIG_PCI */ 187 185 188 - static int __of_address_resource_bounds(struct resource *r, u64 start, u64 size) 186 + VISIBLE_IF_KUNIT int __of_address_resource_bounds(struct resource *r, u64 start, u64 size) 189 187 { 190 188 if (overflows_type(start, r->start)) 191 189 return -EOVERFLOW; ··· 199 197 200 198 return 0; 201 199 } 200 + EXPORT_SYMBOL_IF_KUNIT(__of_address_resource_bounds); 202 201 203 202 /* 204 203 * of_pci_range_to_resource - Create a resource from an of_pci_range
+4
drivers/of/of_private.h
··· 208 208 static void __maybe_unused of_dump_addr(const char *s, const __be32 *addr, int na) { } 209 209 #endif 210 210 211 + #if IS_ENABLED(CONFIG_KUNIT) 212 + int __of_address_resource_bounds(struct resource *r, u64 start, u64 size); 213 + #endif 214 + 211 215 #endif /* _LINUX_OF_PRIVATE_H */
+118 -1
drivers/of/of_test.c
··· 2 2 /* 3 3 * KUnit tests for OF APIs 4 4 */ 5 + #include <linux/ioport.h> 5 6 #include <linux/module.h> 6 7 #include <linux/of.h> 7 8 ··· 55 54 .init = of_dtb_test_init, 56 55 }; 57 56 57 + struct of_address_resource_bounds_case { 58 + u64 start; 59 + u64 size; 60 + int ret; 61 + 62 + u64 res_start; 63 + u64 res_end; 64 + }; 65 + 66 + static void of_address_resource_bounds_case_desc(const struct of_address_resource_bounds_case *p, 67 + char *name) 68 + { 69 + snprintf(name, KUNIT_PARAM_DESC_SIZE, "start=0x%016llx,size=0x%016llx", p->start, p->size); 70 + } 71 + 72 + static const struct of_address_resource_bounds_case of_address_resource_bounds_cases[] = { 73 + { 74 + .start = 0, 75 + .size = 0, 76 + .ret = 0, 77 + .res_start = 0, 78 + .res_end = -1, 79 + }, 80 + { 81 + .start = 0, 82 + .size = 0x1000, 83 + .ret = 0, 84 + .res_start = 0, 85 + .res_end = 0xfff, 86 + }, 87 + { 88 + .start = 0x1000, 89 + .size = 0, 90 + .ret = 0, 91 + .res_start = 0x1000, 92 + .res_end = 0xfff, 93 + }, 94 + { 95 + .start = 0x1000, 96 + .size = 0x1000, 97 + .ret = 0, 98 + .res_start = 0x1000, 99 + .res_end = 0x1fff, 100 + }, 101 + { 102 + .start = 1, 103 + .size = RESOURCE_SIZE_MAX, 104 + .ret = 0, 105 + .res_start = 1, 106 + .res_end = RESOURCE_SIZE_MAX, 107 + }, 108 + { 109 + .start = RESOURCE_SIZE_MAX, 110 + .size = 1, 111 + .ret = 0, 112 + .res_start = RESOURCE_SIZE_MAX, 113 + .res_end = RESOURCE_SIZE_MAX, 114 + }, 115 + { 116 + .start = 2, 117 + .size = RESOURCE_SIZE_MAX, 118 + .ret = -EOVERFLOW, 119 + }, 120 + { 121 + .start = RESOURCE_SIZE_MAX, 122 + .size = 2, 123 + .ret = -EOVERFLOW, 124 + }, 125 + { 126 + .start = ULL(0x100000000), 127 + .size = 1, 128 + .ret = sizeof(resource_size_t) > sizeof(u32) ? 0 : -EOVERFLOW, 129 + .res_start = ULL(0x100000000), 130 + .res_end = ULL(0x100000000), 131 + }, 132 + { 133 + .start = 0x1000, 134 + .size = 0xffffffff, 135 + .ret = sizeof(resource_size_t) > sizeof(u32) ? 0 : -EOVERFLOW, 136 + .res_start = 0x1000, 137 + .res_end = ULL(0x100000ffe), 138 + }, 139 + }; 140 + 141 + KUNIT_ARRAY_PARAM(of_address_resource_bounds, 142 + of_address_resource_bounds_cases, of_address_resource_bounds_case_desc); 143 + 144 + static void of_address_resource_bounds(struct kunit *test) 145 + { 146 + const struct of_address_resource_bounds_case *param = test->param_value; 147 + struct resource r; /* Intentionally uninitialized */ 148 + int ret; 149 + 150 + if (!IS_ENABLED(CONFIG_OF_ADDRESS)) 151 + kunit_skip(test, "CONFIG_OF_ADDRESS not enabled\n"); 152 + 153 + ret = __of_address_resource_bounds(&r, param->start, param->size); 154 + KUNIT_EXPECT_EQ(test, param->ret, ret); 155 + if (ret == 0) { 156 + KUNIT_EXPECT_EQ(test, (resource_size_t)param->res_start, r.start); 157 + KUNIT_EXPECT_EQ(test, (resource_size_t)param->res_end, r.end); 158 + KUNIT_EXPECT_EQ(test, param->size, resource_size(&r)); 159 + } 160 + } 161 + 162 + static struct kunit_case of_address_test_cases[] = { 163 + KUNIT_CASE_PARAM(of_address_resource_bounds, of_address_resource_bounds_gen_params), 164 + {} 165 + }; 166 + 167 + static struct kunit_suite of_address_suite = { 168 + .name = "of_address", 169 + .test_cases = of_address_test_cases, 170 + }; 171 + 58 172 kunit_test_suites( 59 - &of_dtb_suite, 173 + &of_dtb_suite, &of_address_suite, 60 174 ); 61 175 MODULE_DESCRIPTION("KUnit tests for OF APIs"); 176 + MODULE_IMPORT_NS("EXPORTED_FOR_KUNIT_TESTING"); 62 177 MODULE_LICENSE("GPL");
+3 -2
drivers/pci/probe.c
··· 339 339 return (res->flags & IORESOURCE_MEM_64) ? 1 : 0; 340 340 } 341 341 342 - static void pci_read_bases(struct pci_dev *dev, unsigned int howmany, int rom) 342 + static __always_inline void pci_read_bases(struct pci_dev *dev, 343 + unsigned int howmany, int rom) 343 344 { 344 345 u32 rombar, stdbars[PCI_STD_NUM_BARS]; 345 346 unsigned int pos, reg; 346 347 u16 orig_cmd; 347 348 348 - BUILD_BUG_ON(howmany > PCI_STD_NUM_BARS); 349 + BUILD_BUG_ON(statically_true(howmany > PCI_STD_NUM_BARS)); 349 350 350 351 if (dev->non_compliant_bars) 351 352 return;
+2 -1
drivers/pci/quirks.c
··· 5522 5522 * AMD Matisse USB 3.0 Host Controller 0x149c 5523 5523 * Intel 82579LM Gigabit Ethernet Controller 0x1502 5524 5524 * Intel 82579V Gigabit Ethernet Controller 0x1503 5525 - * 5525 + * Mediatek MT7922 802.11ax PCI Express Wireless Network Adapter 5526 5526 */ 5527 5527 static void quirk_no_flr(struct pci_dev *dev) 5528 5528 { ··· 5534 5534 DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_AMD, 0x7901, quirk_no_flr); 5535 5535 DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x1502, quirk_no_flr); 5536 5536 DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x1503, quirk_no_flr); 5537 + DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_MEDIATEK, 0x0616, quirk_no_flr); 5537 5538 5538 5539 /* FLR may cause the SolidRun SNET DPU (rev 0x1) to hang */ 5539 5540 static void quirk_no_flr_snet(struct pci_dev *dev)
+27 -34
drivers/regulator/core.c
··· 5774 5774 goto clean; 5775 5775 } 5776 5776 5777 - if (config->init_data) { 5778 - /* 5779 - * Providing of_match means the framework is expected to parse 5780 - * DT to get the init_data. This would conflict with provided 5781 - * init_data, if set. Warn if it happens. 5782 - */ 5783 - if (regulator_desc->of_match) 5784 - dev_warn(dev, "Using provided init data - OF match ignored\n"); 5777 + /* 5778 + * DT may override the config->init_data provided if the platform 5779 + * needs to do so. If so, config->init_data is completely ignored. 5780 + */ 5781 + init_data = regulator_of_get_init_data(dev, regulator_desc, config, 5782 + &rdev->dev.of_node); 5785 5783 5784 + /* 5785 + * Sometimes not all resources are probed already so we need to take 5786 + * that into account. This happens most the time if the ena_gpiod comes 5787 + * from a gpio extender or something else. 5788 + */ 5789 + if (PTR_ERR(init_data) == -EPROBE_DEFER) { 5790 + ret = -EPROBE_DEFER; 5791 + goto clean; 5792 + } 5793 + 5794 + /* 5795 + * We need to keep track of any GPIO descriptor coming from the 5796 + * device tree until we have handled it over to the core. If the 5797 + * config that was passed in to this function DOES NOT contain 5798 + * a descriptor, and the config after this call DOES contain 5799 + * a descriptor, we definitely got one from parsing the device 5800 + * tree. 5801 + */ 5802 + if (!cfg->ena_gpiod && config->ena_gpiod) 5803 + dangling_of_gpiod = true; 5804 + if (!init_data) { 5786 5805 init_data = config->init_data; 5787 5806 rdev->dev.of_node = of_node_get(config->of_node); 5788 - 5789 - } else { 5790 - init_data = regulator_of_get_init_data(dev, regulator_desc, 5791 - config, 5792 - &rdev->dev.of_node); 5793 - 5794 - /* 5795 - * Sometimes not all resources are probed already so we need to 5796 - * take that into account. This happens most the time if the 5797 - * ena_gpiod comes from a gpio extender or something else. 5798 - */ 5799 - if (PTR_ERR(init_data) == -EPROBE_DEFER) { 5800 - ret = -EPROBE_DEFER; 5801 - goto clean; 5802 - } 5803 - 5804 - /* 5805 - * We need to keep track of any GPIO descriptor coming from the 5806 - * device tree until we have handled it over to the core. If the 5807 - * config that was passed in to this function DOES NOT contain a 5808 - * descriptor, and the config after this call DOES contain a 5809 - * descriptor, we definitely got one from parsing the device 5810 - * tree. 5811 - */ 5812 - if (!cfg->ena_gpiod && config->ena_gpiod) 5813 - dangling_of_gpiod = true; 5814 5807 } 5815 5808 5816 5809 ww_mutex_init(&rdev->mutex, &regulator_ww_class);
+2 -1
drivers/s390/cio/chp.c
··· 695 695 if (time_after(jiffies, chp_info_expires)) { 696 696 /* Data is too old, update. */ 697 697 rc = sclp_chp_read_info(&chp_info); 698 - chp_info_expires = jiffies + CHP_INFO_UPDATE_INTERVAL ; 698 + if (!rc) 699 + chp_info_expires = jiffies + CHP_INFO_UPDATE_INTERVAL; 699 700 } 700 701 mutex_unlock(&info_lock); 701 702
+12 -2
drivers/s390/net/ism_drv.c
··· 588 588 return ret; 589 589 } 590 590 591 + static void ism_dev_release(struct device *dev) 592 + { 593 + struct ism_dev *ism; 594 + 595 + ism = container_of(dev, struct ism_dev, dev); 596 + 597 + kfree(ism); 598 + } 599 + 591 600 static int ism_probe(struct pci_dev *pdev, const struct pci_device_id *id) 592 601 { 593 602 struct ism_dev *ism; ··· 610 601 dev_set_drvdata(&pdev->dev, ism); 611 602 ism->pdev = pdev; 612 603 ism->dev.parent = &pdev->dev; 604 + ism->dev.release = ism_dev_release; 613 605 device_initialize(&ism->dev); 614 606 dev_set_name(&ism->dev, dev_name(&pdev->dev)); 615 607 ret = device_add(&ism->dev); ··· 647 637 device_del(&ism->dev); 648 638 err_dev: 649 639 dev_set_drvdata(&pdev->dev, NULL); 650 - kfree(ism); 640 + put_device(&ism->dev); 651 641 652 642 return ret; 653 643 } ··· 692 682 pci_disable_device(pdev); 693 683 device_del(&ism->dev); 694 684 dev_set_drvdata(&pdev->dev, NULL); 695 - kfree(ism); 685 + put_device(&ism->dev); 696 686 } 697 687 698 688 static struct pci_driver ism_driver = {
+2 -2
drivers/spi/atmel-quadspi.c
··· 235 235 /** 236 236 * struct atmel_qspi_pcal - Pad Calibration Clock Division 237 237 * @pclk_rate: peripheral clock rate. 238 - * @pclkdiv: calibration clock division. The clock applied to the calibration 239 - * cell is divided by pclkdiv + 1. 238 + * @pclk_div: calibration clock division. The clock applied to the calibration 239 + * cell is divided by pclk_div + 1. 240 240 */ 241 241 struct atmel_qspi_pcal { 242 242 u32 pclk_rate;
+1 -1
drivers/spi/spi-pxa2xx.c
··· 399 399 lpss_ssp_select_cs(spi, config); 400 400 401 401 mask = LPSS_CS_CONTROL_CS_HIGH; 402 - __lpss_ssp_update_priv(drv_data, config->reg_cs_ctrl, mask, enable ? mask : 0); 402 + __lpss_ssp_update_priv(drv_data, config->reg_cs_ctrl, mask, enable ? 0 : mask); 403 403 if (config->cs_clk_stays_gated) { 404 404 /* 405 405 * Changing CS alone when dynamic clock gating is on won't
+3
drivers/spi/spi-sn-f-ospi.c
··· 116 116 117 117 static u32 f_ospi_get_dummy_cycle(const struct spi_mem_op *op) 118 118 { 119 + if (!op->dummy.nbytes) 120 + return 0; 121 + 119 122 return (op->dummy.nbytes * 8) / op->dummy.buswidth; 120 123 } 121 124
-2
drivers/thermal/cpufreq_cooling.c
··· 57 57 * @max_level: maximum cooling level. One less than total number of valid 58 58 * cpufreq frequencies. 59 59 * @em: Reference on the Energy Model of the device 60 - * @cdev: thermal_cooling_device pointer to keep track of the 61 - * registered cooling device. 62 60 * @policy: cpufreq policy. 63 61 * @cooling_ops: cpufreq callbacks to thermal cooling device ops 64 62 * @idle_time: idle time stats
+2
drivers/tty/serial/8250/8250.h
··· 374 374 375 375 #ifdef CONFIG_SERIAL_8250_DMA 376 376 extern int serial8250_tx_dma(struct uart_8250_port *); 377 + extern void serial8250_tx_dma_flush(struct uart_8250_port *); 377 378 extern int serial8250_rx_dma(struct uart_8250_port *); 378 379 extern void serial8250_rx_dma_flush(struct uart_8250_port *); 379 380 extern int serial8250_request_dma(struct uart_8250_port *); ··· 407 406 { 408 407 return -1; 409 408 } 409 + static inline void serial8250_tx_dma_flush(struct uart_8250_port *p) { } 410 410 static inline int serial8250_rx_dma(struct uart_8250_port *p) 411 411 { 412 412 return -1;
+16
drivers/tty/serial/8250/8250_dma.c
··· 149 149 return ret; 150 150 } 151 151 152 + void serial8250_tx_dma_flush(struct uart_8250_port *p) 153 + { 154 + struct uart_8250_dma *dma = p->dma; 155 + 156 + if (!dma->tx_running) 157 + return; 158 + 159 + /* 160 + * kfifo_reset() has been called by the serial core, avoid 161 + * advancing and underflowing in __dma_tx_complete(). 162 + */ 163 + dma->tx_size = 0; 164 + 165 + dmaengine_terminate_async(dma->rxchan); 166 + } 167 + 152 168 int serial8250_rx_dma(struct uart_8250_port *p) 153 169 { 154 170 struct uart_8250_dma *dma = p->dma;
-1
drivers/tty/serial/8250/8250_of.c
··· 110 110 spin_lock_init(&port->lock); 111 111 112 112 if (resource_type(&resource) == IORESOURCE_IO) { 113 - port->iotype = UPIO_PORT; 114 113 port->iobase = resource.start; 115 114 } else { 116 115 port->mapbase = resource.start;
-9
drivers/tty/serial/8250/8250_platform.c
··· 112 112 struct device *dev = &pdev->dev; 113 113 struct uart_8250_port uart = { }; 114 114 struct resource *regs; 115 - unsigned char iotype; 116 115 int ret, line; 117 116 118 117 regs = platform_get_mem_or_io(pdev, 0); ··· 121 122 switch (resource_type(regs)) { 122 123 case IORESOURCE_IO: 123 124 uart.port.iobase = regs->start; 124 - iotype = UPIO_PORT; 125 125 break; 126 126 case IORESOURCE_MEM: 127 127 uart.port.mapbase = regs->start; 128 128 uart.port.mapsize = resource_size(regs); 129 129 uart.port.flags = UPF_IOREMAP; 130 - iotype = UPIO_MEM; 131 130 break; 132 131 default: 133 132 return -EINVAL; ··· 143 146 ret = 0; 144 147 if (ret) 145 148 return ret; 146 - 147 - /* 148 - * The previous call may not set iotype correctly when reg-io-width 149 - * property is absent and it doesn't support IO port resource. 150 - */ 151 - uart.port.iotype = iotype; 152 149 153 150 line = serial8250_register_8250_port(&uart); 154 151 if (line < 0)
-10
drivers/tty/serial/8250/8250_pnp.c
··· 436 436 { 437 437 struct uart_8250_port uart, *port; 438 438 int ret, flags = dev_id->driver_data; 439 - unsigned char iotype; 440 439 long line; 441 440 442 441 if (flags & UNKNOWN_DEV) { ··· 447 448 memset(&uart, 0, sizeof(uart)); 448 449 if ((flags & CIR_PORT) && pnp_port_valid(dev, 2)) { 449 450 uart.port.iobase = pnp_port_start(dev, 2); 450 - iotype = UPIO_PORT; 451 451 } else if (pnp_port_valid(dev, 0)) { 452 452 uart.port.iobase = pnp_port_start(dev, 0); 453 - iotype = UPIO_PORT; 454 453 } else if (pnp_mem_valid(dev, 0)) { 455 454 uart.port.mapbase = pnp_mem_start(dev, 0); 456 455 uart.port.mapsize = pnp_mem_len(dev, 0); 457 - iotype = UPIO_MEM; 458 456 uart.port.flags = UPF_IOREMAP; 459 457 } else 460 458 return -ENODEV; ··· 466 470 ret = 0; 467 471 if (ret) 468 472 return ret; 469 - 470 - /* 471 - * The previous call may not set iotype correctly when reg-io-width 472 - * property is absent and it doesn't support IO port resource. 473 - */ 474 - uart.port.iotype = iotype; 475 473 476 474 if (flags & CIR_PORT) { 477 475 uart.port.flags |= UPF_FIXED_PORT | UPF_FIXED_TYPE;
+9
drivers/tty/serial/8250/8250_port.c
··· 2555 2555 serial8250_do_shutdown(port); 2556 2556 } 2557 2557 2558 + static void serial8250_flush_buffer(struct uart_port *port) 2559 + { 2560 + struct uart_8250_port *up = up_to_u8250p(port); 2561 + 2562 + if (up->dma) 2563 + serial8250_tx_dma_flush(up); 2564 + } 2565 + 2558 2566 static unsigned int serial8250_do_get_divisor(struct uart_port *port, 2559 2567 unsigned int baud, 2560 2568 unsigned int *frac) ··· 3252 3244 .break_ctl = serial8250_break_ctl, 3253 3245 .startup = serial8250_startup, 3254 3246 .shutdown = serial8250_shutdown, 3247 + .flush_buffer = serial8250_flush_buffer, 3255 3248 .set_termios = serial8250_set_termios, 3256 3249 .set_ldisc = serial8250_set_ldisc, 3257 3250 .pm = serial8250_pm,
+1 -1
drivers/tty/serial/sc16is7xx.c
··· 1561 1561 /* Always ask for fixed clock rate from a property. */ 1562 1562 device_property_read_u32(dev, "clock-frequency", &uartclk); 1563 1563 1564 - s->polling = !!irq; 1564 + s->polling = (irq <= 0); 1565 1565 if (s->polling) 1566 1566 dev_dbg(dev, 1567 1567 "No interrupt pin definition, falling back to polling mode\n");
+7 -5
drivers/tty/serial/serial_port.c
··· 173 173 * The caller is responsible to initialize the following fields of the @port 174 174 * ->dev (must be valid) 175 175 * ->flags 176 + * ->iobase 176 177 * ->mapbase 177 178 * ->mapsize 178 179 * ->regshift (if @use_defaults is false) ··· 215 214 /* Read the registers I/O access type (default: MMIO 8-bit) */ 216 215 ret = device_property_read_u32(dev, "reg-io-width", &value); 217 216 if (ret) { 218 - port->iotype = UPIO_MEM; 217 + port->iotype = port->iobase ? UPIO_PORT : UPIO_MEM; 219 218 } else { 220 219 switch (value) { 221 220 case 1: ··· 228 227 port->iotype = device_is_big_endian(dev) ? UPIO_MEM32BE : UPIO_MEM32; 229 228 break; 230 229 default: 231 - if (!use_defaults) { 232 - dev_err(dev, "Unsupported reg-io-width (%u)\n", value); 233 - return -EINVAL; 234 - } 235 230 port->iotype = UPIO_UNKNOWN; 236 231 break; 237 232 } 233 + } 234 + 235 + if (!use_defaults && port->iotype == UPIO_UNKNOWN) { 236 + dev_err(dev, "Unsupported reg-io-width (%u)\n", value); 237 + return -EINVAL; 238 238 } 239 239 240 240 /* Read the address mapping base offset (default: no offset) */
+21 -7
drivers/usb/class/cdc-acm.c
··· 371 371 static void acm_ctrl_irq(struct urb *urb) 372 372 { 373 373 struct acm *acm = urb->context; 374 - struct usb_cdc_notification *dr = urb->transfer_buffer; 374 + struct usb_cdc_notification *dr; 375 375 unsigned int current_size = urb->actual_length; 376 376 unsigned int expected_size, copy_size, alloc_size; 377 377 int retval; ··· 398 398 399 399 usb_mark_last_busy(acm->dev); 400 400 401 - if (acm->nb_index) 401 + if (acm->nb_index == 0) { 402 + /* 403 + * The first chunk of a message must contain at least the 404 + * notification header with the length field, otherwise we 405 + * can't get an expected_size. 406 + */ 407 + if (current_size < sizeof(struct usb_cdc_notification)) { 408 + dev_dbg(&acm->control->dev, "urb too short\n"); 409 + goto exit; 410 + } 411 + dr = urb->transfer_buffer; 412 + } else { 402 413 dr = (struct usb_cdc_notification *)acm->notification_buffer; 403 - 414 + } 404 415 /* size = notification-header + (optional) data */ 405 416 expected_size = sizeof(struct usb_cdc_notification) + 406 417 le16_to_cpu(dr->wLength); 407 418 408 - if (current_size < expected_size) { 419 + if (acm->nb_index != 0 || current_size < expected_size) { 409 420 /* notification is transmitted fragmented, reassemble */ 410 421 if (acm->nb_size < expected_size) { 411 422 u8 *new_buffer; ··· 1738 1727 { USB_DEVICE(0x0870, 0x0001), /* Metricom GS Modem */ 1739 1728 .driver_info = NO_UNION_NORMAL, /* has no union descriptor */ 1740 1729 }, 1741 - { USB_DEVICE(0x045b, 0x023c), /* Renesas USB Download mode */ 1730 + { USB_DEVICE(0x045b, 0x023c), /* Renesas R-Car H3 USB Download mode */ 1742 1731 .driver_info = DISABLE_ECHO, /* Don't echo banner */ 1743 1732 }, 1744 - { USB_DEVICE(0x045b, 0x0248), /* Renesas USB Download mode */ 1733 + { USB_DEVICE(0x045b, 0x0247), /* Renesas R-Car D3 USB Download mode */ 1745 1734 .driver_info = DISABLE_ECHO, /* Don't echo banner */ 1746 1735 }, 1747 - { USB_DEVICE(0x045b, 0x024D), /* Renesas USB Download mode */ 1736 + { USB_DEVICE(0x045b, 0x0248), /* Renesas R-Car M3-N USB Download mode */ 1737 + .driver_info = DISABLE_ECHO, /* Don't echo banner */ 1738 + }, 1739 + { USB_DEVICE(0x045b, 0x024D), /* Renesas R-Car E3 USB Download mode */ 1748 1740 .driver_info = DISABLE_ECHO, /* Don't echo banner */ 1749 1741 }, 1750 1742 { USB_DEVICE(0x0e8d, 0x0003), /* FIREFLY, MediaTek Inc; andrey.arapov@gmail.com */
+12 -2
drivers/usb/core/hub.c
··· 1849 1849 hdev = interface_to_usbdev(intf); 1850 1850 1851 1851 /* 1852 + * The USB 2.0 spec prohibits hubs from having more than one 1853 + * configuration or interface, and we rely on this prohibition. 1854 + * Refuse to accept a device that violates it. 1855 + */ 1856 + if (hdev->descriptor.bNumConfigurations > 1 || 1857 + hdev->actconfig->desc.bNumInterfaces > 1) { 1858 + dev_err(&intf->dev, "Invalid hub with more than one config or interface\n"); 1859 + return -EINVAL; 1860 + } 1861 + 1862 + /* 1852 1863 * Set default autosuspend delay as 0 to speedup bus suspend, 1853 1864 * based on the below considerations: 1854 1865 * ··· 4709 4698 EXPORT_SYMBOL_GPL(usb_ep0_reinit); 4710 4699 4711 4700 #define usb_sndaddr0pipe() (PIPE_CONTROL << 30) 4712 - #define usb_rcvaddr0pipe() ((PIPE_CONTROL << 30) | USB_DIR_IN) 4713 4701 4714 4702 static int hub_set_address(struct usb_device *udev, int devnum) 4715 4703 { ··· 4814 4804 for (i = 0; i < GET_MAXPACKET0_TRIES; ++i) { 4815 4805 /* Start with invalid values in case the transfer fails */ 4816 4806 buf->bDescriptorType = buf->bMaxPacketSize0 = 0; 4817 - rc = usb_control_msg(udev, usb_rcvaddr0pipe(), 4807 + rc = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 4818 4808 USB_REQ_GET_DESCRIPTOR, USB_DIR_IN, 4819 4809 USB_DT_DEVICE << 8, 0, 4820 4810 buf, size,
+6
drivers/usb/core/quirks.c
··· 435 435 { USB_DEVICE(0x0c45, 0x7056), .driver_info = 436 436 USB_QUIRK_IGNORE_REMOTE_WAKEUP }, 437 437 438 + /* Sony Xperia XZ1 Compact (lilac) smartphone in fastboot mode */ 439 + { USB_DEVICE(0x0fce, 0x0dde), .driver_info = USB_QUIRK_NO_LPM }, 440 + 438 441 /* Action Semiconductor flash disk */ 439 442 { USB_DEVICE(0x10d6, 0x2200), .driver_info = 440 443 USB_QUIRK_STRING_FETCH_255 }, ··· 527 524 528 525 /* Blackmagic Design UltraStudio SDI */ 529 526 { USB_DEVICE(0x1edb, 0xbd4f), .driver_info = USB_QUIRK_NO_LPM }, 527 + 528 + /* Teclast disk */ 529 + { USB_DEVICE(0x1f75, 0x0917), .driver_info = USB_QUIRK_NO_LPM }, 530 530 531 531 /* Hauppauge HVR-950q */ 532 532 { USB_DEVICE(0x2040, 0x7200), .driver_info =
+1
drivers/usb/dwc2/gadget.c
··· 4615 4615 spin_lock_irqsave(&hsotg->lock, flags); 4616 4616 4617 4617 hsotg->driver = NULL; 4618 + hsotg->gadget.dev.of_node = NULL; 4618 4619 hsotg->gadget.speed = USB_SPEED_UNKNOWN; 4619 4620 hsotg->enabled = 0; 4620 4621
+1
drivers/usb/dwc3/core.h
··· 717 717 /** 718 718 * struct dwc3_ep - device side endpoint representation 719 719 * @endpoint: usb endpoint 720 + * @nostream_work: work for handling bulk NoStream 720 721 * @cancelled_list: list of cancelled requests for this endpoint 721 722 * @pending_list: list of pending requests for this endpoint 722 723 * @started_list: list of started requests on this endpoint
+34
drivers/usb/dwc3/gadget.c
··· 2629 2629 { 2630 2630 u32 reg; 2631 2631 u32 timeout = 2000; 2632 + u32 saved_config = 0; 2632 2633 2633 2634 if (pm_runtime_suspended(dwc->dev)) 2634 2635 return 0; 2636 + 2637 + /* 2638 + * When operating in USB 2.0 speeds (HS/FS), ensure that 2639 + * GUSB2PHYCFG.ENBLSLPM and GUSB2PHYCFG.SUSPHY are cleared before starting 2640 + * or stopping the controller. This resolves timeout issues that occur 2641 + * during frequent role switches between host and device modes. 2642 + * 2643 + * Save and clear these settings, then restore them after completing the 2644 + * controller start or stop sequence. 2645 + * 2646 + * This solution was discovered through experimentation as it is not 2647 + * mentioned in the dwc3 programming guide. It has been tested on an 2648 + * Exynos platforms. 2649 + */ 2650 + reg = dwc3_readl(dwc->regs, DWC3_GUSB2PHYCFG(0)); 2651 + if (reg & DWC3_GUSB2PHYCFG_SUSPHY) { 2652 + saved_config |= DWC3_GUSB2PHYCFG_SUSPHY; 2653 + reg &= ~DWC3_GUSB2PHYCFG_SUSPHY; 2654 + } 2655 + 2656 + if (reg & DWC3_GUSB2PHYCFG_ENBLSLPM) { 2657 + saved_config |= DWC3_GUSB2PHYCFG_ENBLSLPM; 2658 + reg &= ~DWC3_GUSB2PHYCFG_ENBLSLPM; 2659 + } 2660 + 2661 + if (saved_config) 2662 + dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg); 2635 2663 2636 2664 reg = dwc3_readl(dwc->regs, DWC3_DCTL); 2637 2665 if (is_on) { ··· 2687 2659 reg = dwc3_readl(dwc->regs, DWC3_DSTS); 2688 2660 reg &= DWC3_DSTS_DEVCTRLHLT; 2689 2661 } while (--timeout && !(!is_on ^ !reg)); 2662 + 2663 + if (saved_config) { 2664 + reg = dwc3_readl(dwc->regs, DWC3_GUSB2PHYCFG(0)); 2665 + reg |= saved_config; 2666 + dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg); 2667 + } 2690 2668 2691 2669 if (!timeout) 2692 2670 return -ETIMEDOUT;
+14 -5
drivers/usb/gadget/function/f_midi.c
··· 283 283 /* Our transmit completed. See if there's more to go. 284 284 * f_midi_transmit eats req, don't queue it again. */ 285 285 req->length = 0; 286 - f_midi_transmit(midi); 286 + queue_work(system_highpri_wq, &midi->work); 287 287 return; 288 288 } 289 289 break; ··· 907 907 908 908 status = -ENODEV; 909 909 910 + /* 911 + * Reset wMaxPacketSize with maximum packet size of FS bulk transfer before 912 + * endpoint claim. This ensures that the wMaxPacketSize does not exceed the 913 + * limit during bind retries where configured dwc3 TX/RX FIFO's maxpacket 914 + * size of 512 bytes for IN/OUT endpoints in support HS speed only. 915 + */ 916 + bulk_in_desc.wMaxPacketSize = cpu_to_le16(64); 917 + bulk_out_desc.wMaxPacketSize = cpu_to_le16(64); 918 + 910 919 /* allocate instance-specific endpoints */ 911 920 midi->in_ep = usb_ep_autoconfig(cdev->gadget, &bulk_in_desc); 912 921 if (!midi->in_ep) ··· 1009 1000 } 1010 1001 1011 1002 /* configure the endpoint descriptors ... */ 1012 - ms_out_desc.bLength = USB_DT_MS_ENDPOINT_SIZE(midi->in_ports); 1013 - ms_out_desc.bNumEmbMIDIJack = midi->in_ports; 1003 + ms_out_desc.bLength = USB_DT_MS_ENDPOINT_SIZE(midi->out_ports); 1004 + ms_out_desc.bNumEmbMIDIJack = midi->out_ports; 1014 1005 1015 - ms_in_desc.bLength = USB_DT_MS_ENDPOINT_SIZE(midi->out_ports); 1016 - ms_in_desc.bNumEmbMIDIJack = midi->out_ports; 1006 + ms_in_desc.bLength = USB_DT_MS_ENDPOINT_SIZE(midi->in_ports); 1007 + ms_in_desc.bNumEmbMIDIJack = midi->in_ports; 1017 1008 1018 1009 /* ... and add them to the list */ 1019 1010 endpoint_descriptor_index = i;
+1 -1
drivers/usb/gadget/function/uvc_video.c
··· 818 818 return -EINVAL; 819 819 820 820 /* Allocate a kthread for asynchronous hw submit handler. */ 821 - video->kworker = kthread_create_worker(0, "UVCG"); 821 + video->kworker = kthread_run_worker(0, "UVCG"); 822 822 if (IS_ERR(video->kworker)) { 823 823 uvcg_err(&video->uvc->func, "failed to create UVCG kworker\n"); 824 824 return PTR_ERR(video->kworker);
+1 -1
drivers/usb/gadget/udc/core.c
··· 1543 1543 1544 1544 kobject_uevent(&udc->dev.kobj, KOBJ_REMOVE); 1545 1545 sysfs_remove_link(&udc->dev.kobj, "gadget"); 1546 - flush_work(&gadget->work); 1547 1546 device_del(&gadget->dev); 1547 + flush_work(&gadget->work); 1548 1548 ida_free(&gadget_id_numbers, gadget->id_number); 1549 1549 cancel_work_sync(&udc->vbus_work); 1550 1550 device_unregister(&udc->dev);
+1 -1
drivers/usb/gadget/udc/renesas_usb3.c
··· 310 310 struct list_head queue; 311 311 }; 312 312 313 - #define USB3_EP_NAME_SIZE 8 313 + #define USB3_EP_NAME_SIZE 16 314 314 struct renesas_usb3_ep { 315 315 struct usb_ep ep; 316 316 struct renesas_usb3 *usb3;
+9
drivers/usb/host/pci-quirks.c
··· 958 958 * booting from USB disk or using a usb keyboard 959 959 */ 960 960 hcc_params = readl(base + EHCI_HCC_PARAMS); 961 + 962 + /* LS7A EHCI controller doesn't have extended capabilities, the 963 + * EECP (EHCI Extended Capabilities Pointer) field of HCCPARAMS 964 + * register should be 0x0 but it reads as 0xa0. So clear it to 965 + * avoid error messages on boot. 966 + */ 967 + if (pdev->vendor == PCI_VENDOR_ID_LOONGSON && pdev->device == 0x7a14) 968 + hcc_params &= ~(0xffL << 8); 969 + 961 970 offset = (hcc_params >> 8) & 0xff; 962 971 while (offset && --count) { 963 972 pci_read_config_dword(pdev, offset, &cap);
+4 -3
drivers/usb/host/xhci-pci.c
··· 653 653 } 654 654 EXPORT_SYMBOL_NS_GPL(xhci_pci_common_probe, "xhci"); 655 655 656 - static const struct pci_device_id pci_ids_reject[] = { 657 - /* handled by xhci-pci-renesas */ 656 + /* handled by xhci-pci-renesas if enabled */ 657 + static const struct pci_device_id pci_ids_renesas[] = { 658 658 { PCI_DEVICE(PCI_VENDOR_ID_RENESAS, 0x0014) }, 659 659 { PCI_DEVICE(PCI_VENDOR_ID_RENESAS, 0x0015) }, 660 660 { /* end: all zeroes */ } ··· 662 662 663 663 static int xhci_pci_probe(struct pci_dev *dev, const struct pci_device_id *id) 664 664 { 665 - if (pci_match_id(pci_ids_reject, dev)) 665 + if (IS_ENABLED(CONFIG_USB_XHCI_PCI_RENESAS) && 666 + pci_match_id(pci_ids_renesas, dev)) 666 667 return -ENODEV; 667 668 668 669 return xhci_pci_common_probe(dev, id);
+1 -1
drivers/usb/phy/phy-generic.c
··· 212 212 if (of_property_read_u32(node, "clock-frequency", &clk_rate)) 213 213 clk_rate = 0; 214 214 215 - needs_clk = of_property_read_bool(node, "clocks"); 215 + needs_clk = of_property_present(node, "clocks"); 216 216 } 217 217 nop->gpiod_reset = devm_gpiod_get_optional(dev, "reset", 218 218 GPIOD_ASIS);
+3 -2
drivers/usb/roles/class.c
··· 387 387 dev_set_name(&sw->dev, "%s-role-switch", 388 388 desc->name ? desc->name : dev_name(parent)); 389 389 390 + sw->registered = true; 391 + 390 392 ret = device_register(&sw->dev); 391 393 if (ret) { 394 + sw->registered = false; 392 395 put_device(&sw->dev); 393 396 return ERR_PTR(ret); 394 397 } ··· 401 398 if (ret) 402 399 dev_warn(&sw->dev, "failed to add component\n"); 403 400 } 404 - 405 - sw->registered = true; 406 401 407 402 /* TODO: Symlinks for the host port and the device controller. */ 408 403
+29 -20
drivers/usb/serial/option.c
··· 619 619 /* Luat Air72*U series based on UNISOC UIS8910 uses UNISOC's vendor ID */ 620 620 #define LUAT_PRODUCT_AIR720U 0x4e00 621 621 622 - /* MeiG Smart Technology products */ 623 - #define MEIGSMART_VENDOR_ID 0x2dee 624 - /* MeiG Smart SRM815/SRM825L based on Qualcomm 315 */ 625 - #define MEIGSMART_PRODUCT_SRM825L 0x4d22 626 - /* MeiG Smart SLM320 based on UNISOC UIS8910 */ 627 - #define MEIGSMART_PRODUCT_SLM320 0x4d41 628 - /* MeiG Smart SLM770A based on ASR1803 */ 629 - #define MEIGSMART_PRODUCT_SLM770A 0x4d57 630 - 631 622 /* Device flags */ 632 623 633 624 /* Highest interface number which can be used with NCTRL() and RSVD() */ ··· 1358 1367 .driver_info = NCTRL(2) | RSVD(3) }, 1359 1368 { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x1063, 0xff), /* Telit LN920 (ECM) */ 1360 1369 .driver_info = NCTRL(0) | RSVD(1) }, 1361 - { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x1070, 0xff), /* Telit FN990 (rmnet) */ 1370 + { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x1070, 0xff), /* Telit FN990A (rmnet) */ 1362 1371 .driver_info = NCTRL(0) | RSVD(1) | RSVD(2) }, 1363 - { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x1071, 0xff), /* Telit FN990 (MBIM) */ 1372 + { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x1071, 0xff), /* Telit FN990A (MBIM) */ 1364 1373 .driver_info = NCTRL(0) | RSVD(1) }, 1365 - { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x1072, 0xff), /* Telit FN990 (RNDIS) */ 1374 + { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x1072, 0xff), /* Telit FN990A (RNDIS) */ 1366 1375 .driver_info = NCTRL(2) | RSVD(3) }, 1367 - { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x1073, 0xff), /* Telit FN990 (ECM) */ 1376 + { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x1073, 0xff), /* Telit FN990A (ECM) */ 1368 1377 .driver_info = NCTRL(0) | RSVD(1) }, 1369 - { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x1075, 0xff), /* Telit FN990 (PCIe) */ 1378 + { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x1075, 0xff), /* Telit FN990A (PCIe) */ 1370 1379 .driver_info = RSVD(0) }, 1371 1380 { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x1080, 0xff), /* Telit FE990 (rmnet) */ 1372 1381 .driver_info = NCTRL(0) | RSVD(1) | RSVD(2) }, ··· 1394 1403 .driver_info = RSVD(0) | NCTRL(3) }, 1395 1404 { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x10c8, 0xff), /* Telit FE910C04 (rmnet) */ 1396 1405 .driver_info = RSVD(0) | NCTRL(2) | RSVD(3) | RSVD(4) }, 1406 + { USB_DEVICE_INTERFACE_PROTOCOL(TELIT_VENDOR_ID, 0x10d0, 0x60) }, /* Telit FN990B (rmnet) */ 1407 + { USB_DEVICE_INTERFACE_PROTOCOL(TELIT_VENDOR_ID, 0x10d0, 0x40) }, 1408 + { USB_DEVICE_INTERFACE_PROTOCOL(TELIT_VENDOR_ID, 0x10d0, 0x30), 1409 + .driver_info = NCTRL(5) }, 1410 + { USB_DEVICE_INTERFACE_PROTOCOL(TELIT_VENDOR_ID, 0x10d1, 0x60) }, /* Telit FN990B (MBIM) */ 1411 + { USB_DEVICE_INTERFACE_PROTOCOL(TELIT_VENDOR_ID, 0x10d1, 0x40) }, 1412 + { USB_DEVICE_INTERFACE_PROTOCOL(TELIT_VENDOR_ID, 0x10d1, 0x30), 1413 + .driver_info = NCTRL(6) }, 1414 + { USB_DEVICE_INTERFACE_PROTOCOL(TELIT_VENDOR_ID, 0x10d2, 0x60) }, /* Telit FN990B (RNDIS) */ 1415 + { USB_DEVICE_INTERFACE_PROTOCOL(TELIT_VENDOR_ID, 0x10d2, 0x40) }, 1416 + { USB_DEVICE_INTERFACE_PROTOCOL(TELIT_VENDOR_ID, 0x10d2, 0x30), 1417 + .driver_info = NCTRL(6) }, 1418 + { USB_DEVICE_INTERFACE_PROTOCOL(TELIT_VENDOR_ID, 0x10d3, 0x60) }, /* Telit FN990B (ECM) */ 1419 + { USB_DEVICE_INTERFACE_PROTOCOL(TELIT_VENDOR_ID, 0x10d3, 0x40) }, 1420 + { USB_DEVICE_INTERFACE_PROTOCOL(TELIT_VENDOR_ID, 0x10d3, 0x30), 1421 + .driver_info = NCTRL(6) }, 1397 1422 { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_ME910), 1398 1423 .driver_info = NCTRL(0) | RSVD(1) | RSVD(3) }, 1399 1424 { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_ME910_DUAL_MODEM), ··· 2354 2347 { USB_DEVICE_INTERFACE_CLASS(0x2cb7, 0x0a05, 0xff) }, /* Fibocom FM650-CN (NCM mode) */ 2355 2348 { USB_DEVICE_INTERFACE_CLASS(0x2cb7, 0x0a06, 0xff) }, /* Fibocom FM650-CN (RNDIS mode) */ 2356 2349 { USB_DEVICE_INTERFACE_CLASS(0x2cb7, 0x0a07, 0xff) }, /* Fibocom FM650-CN (MBIM mode) */ 2350 + { USB_DEVICE_AND_INTERFACE_INFO(0x2dee, 0x4d41, 0xff, 0, 0) }, /* MeiG Smart SLM320 */ 2351 + { USB_DEVICE_AND_INTERFACE_INFO(0x2dee, 0x4d57, 0xff, 0, 0) }, /* MeiG Smart SLM770A */ 2352 + { USB_DEVICE_AND_INTERFACE_INFO(0x2dee, 0x4d22, 0xff, 0, 0) }, /* MeiG Smart SRM815 */ 2353 + { USB_DEVICE_AND_INTERFACE_INFO(0x2dee, 0x4d22, 0xff, 0x10, 0x02) }, /* MeiG Smart SLM828 */ 2354 + { USB_DEVICE_AND_INTERFACE_INFO(0x2dee, 0x4d22, 0xff, 0x10, 0x03) }, /* MeiG Smart SLM828 */ 2355 + { USB_DEVICE_AND_INTERFACE_INFO(0x2dee, 0x4d22, 0xff, 0xff, 0x30) }, /* MeiG Smart SRM815 and SRM825L */ 2356 + { USB_DEVICE_AND_INTERFACE_INFO(0x2dee, 0x4d22, 0xff, 0xff, 0x40) }, /* MeiG Smart SRM825L */ 2357 + { USB_DEVICE_AND_INTERFACE_INFO(0x2dee, 0x4d22, 0xff, 0xff, 0x60) }, /* MeiG Smart SRM825L */ 2357 2358 { USB_DEVICE_INTERFACE_CLASS(0x2df3, 0x9d03, 0xff) }, /* LongSung M5710 */ 2358 2359 { USB_DEVICE_INTERFACE_CLASS(0x305a, 0x1404, 0xff) }, /* GosunCn GM500 RNDIS */ 2359 2360 { USB_DEVICE_INTERFACE_CLASS(0x305a, 0x1405, 0xff) }, /* GosunCn GM500 MBIM */ ··· 2418 2403 { USB_DEVICE_AND_INTERFACE_INFO(SIERRA_VENDOR_ID, SIERRA_PRODUCT_EM9191, 0xff, 0, 0) }, 2419 2404 { USB_DEVICE_AND_INTERFACE_INFO(UNISOC_VENDOR_ID, TOZED_PRODUCT_LT70C, 0xff, 0, 0) }, 2420 2405 { USB_DEVICE_AND_INTERFACE_INFO(UNISOC_VENDOR_ID, LUAT_PRODUCT_AIR720U, 0xff, 0, 0) }, 2421 - { USB_DEVICE_AND_INTERFACE_INFO(MEIGSMART_VENDOR_ID, MEIGSMART_PRODUCT_SLM320, 0xff, 0, 0) }, 2422 - { USB_DEVICE_AND_INTERFACE_INFO(MEIGSMART_VENDOR_ID, MEIGSMART_PRODUCT_SLM770A, 0xff, 0, 0) }, 2423 - { USB_DEVICE_AND_INTERFACE_INFO(MEIGSMART_VENDOR_ID, MEIGSMART_PRODUCT_SRM825L, 0xff, 0, 0) }, 2424 - { USB_DEVICE_AND_INTERFACE_INFO(MEIGSMART_VENDOR_ID, MEIGSMART_PRODUCT_SRM825L, 0xff, 0xff, 0x30) }, 2425 - { USB_DEVICE_AND_INTERFACE_INFO(MEIGSMART_VENDOR_ID, MEIGSMART_PRODUCT_SRM825L, 0xff, 0xff, 0x40) }, 2426 - { USB_DEVICE_AND_INTERFACE_INFO(MEIGSMART_VENDOR_ID, MEIGSMART_PRODUCT_SRM825L, 0xff, 0xff, 0x60) }, 2427 2406 { USB_DEVICE_INTERFACE_CLASS(0x1bbb, 0x0530, 0xff), /* TCL IK512 MBIM */ 2428 2407 .driver_info = NCTRL(1) }, 2429 2408 { USB_DEVICE_INTERFACE_CLASS(0x1bbb, 0x0640, 0xff), /* TCL IK512 ECM */
+1 -2
drivers/usb/typec/tcpm/tcpm.c
··· 5591 5591 tcpm_set_auto_vbus_discharge_threshold(port, TYPEC_PWR_MODE_USB, 5592 5592 port->pps_data.active, 0); 5593 5593 tcpm_set_charge(port, false); 5594 - tcpm_set_state(port, hard_reset_state(port), 5595 - port->timings.ps_src_off_time); 5594 + tcpm_set_state(port, ERROR_RECOVERY, port->timings.ps_src_off_time); 5596 5595 break; 5597 5596 case PR_SWAP_SNK_SRC_SOURCE_ON: 5598 5597 tcpm_enable_auto_vbus_discharge(port, true);
+13 -9
drivers/xen/swiotlb-xen.c
··· 74 74 return xen_bus_to_phys(dev, dma_to_phys(dev, dma_addr)); 75 75 } 76 76 77 + static inline bool range_requires_alignment(phys_addr_t p, size_t size) 78 + { 79 + phys_addr_t algn = 1ULL << (get_order(size) + PAGE_SHIFT); 80 + phys_addr_t bus_addr = pfn_to_bfn(XEN_PFN_DOWN(p)) << XEN_PAGE_SHIFT; 81 + 82 + return IS_ALIGNED(p, algn) && !IS_ALIGNED(bus_addr, algn); 83 + } 84 + 77 85 static inline int range_straddles_page_boundary(phys_addr_t p, size_t size) 78 86 { 79 87 unsigned long next_bfn, xen_pfn = XEN_PFN_DOWN(p); 80 88 unsigned int i, nr_pages = XEN_PFN_UP(xen_offset_in_page(p) + size); 81 - phys_addr_t algn = 1ULL << (get_order(size) + PAGE_SHIFT); 82 89 83 90 next_bfn = pfn_to_bfn(xen_pfn); 84 - 85 - /* If buffer is physically aligned, ensure DMA alignment. */ 86 - if (IS_ALIGNED(p, algn) && 87 - !IS_ALIGNED((phys_addr_t)next_bfn << XEN_PAGE_SHIFT, algn)) 88 - return 1; 89 91 90 92 for (i = 1; i < nr_pages; i++) 91 93 if (pfn_to_bfn(++xen_pfn) != ++next_bfn) ··· 113 111 } 114 112 115 113 #ifdef CONFIG_X86 116 - int xen_swiotlb_fixup(void *buf, unsigned long nslabs) 114 + int __init xen_swiotlb_fixup(void *buf, unsigned long nslabs) 117 115 { 118 116 int rc; 119 117 unsigned int order = get_order(IO_TLB_SEGSIZE << IO_TLB_SHIFT); ··· 158 156 159 157 *dma_handle = xen_phys_to_dma(dev, phys); 160 158 if (*dma_handle + size - 1 > dma_mask || 161 - range_straddles_page_boundary(phys, size)) { 159 + range_straddles_page_boundary(phys, size) || 160 + range_requires_alignment(phys, size)) { 162 161 if (xen_create_contiguous_region(phys, order, fls64(dma_mask), 163 162 dma_handle) != 0) 164 163 goto out_free_pages; ··· 185 182 size = ALIGN(size, XEN_PAGE_SIZE); 186 183 187 184 if (WARN_ON_ONCE(dma_handle + size - 1 > dev->coherent_dma_mask) || 188 - WARN_ON_ONCE(range_straddles_page_boundary(phys, size))) 185 + WARN_ON_ONCE(range_straddles_page_boundary(phys, size) || 186 + range_requires_alignment(phys, size))) 189 187 return; 190 188 191 189 if (TestClearPageXenRemapped(virt_to_page(vaddr)))
+2
fs/bcachefs/btree_update_interior.c
··· 681 681 682 682 b = as->old_nodes[i]; 683 683 684 + bch2_trans_begin(trans); 684 685 btree_node_lock_nopath_nofail(trans, &b->c, SIX_LOCK_read); 685 686 seq = b->data ? b->data->keys.seq : 0; 686 687 six_unlock_read(&b->c.lock); 688 + bch2_trans_unlock_long(trans); 687 689 688 690 if (seq == as->old_nodes_seq[i]) 689 691 wait_on_bit_io(&b->flags, BTREE_NODE_write_in_flight_inner,
+31 -47
fs/bcachefs/fsck.c
··· 823 823 struct bch_inode_unpacked inode; 824 824 u32 snapshot; 825 825 u64 count; 826 + u64 i_size; 826 827 }; 827 828 828 829 struct inode_walker { ··· 911 910 if (k.k->p.snapshot != i->snapshot && !is_whiteout) { 912 911 struct inode_walker_entry new = *i; 913 912 914 - new.snapshot = k.k->p.snapshot; 915 - new.count = 0; 913 + new.snapshot = k.k->p.snapshot; 914 + new.count = 0; 915 + new.i_size = 0; 916 916 917 917 struct printbuf buf = PRINTBUF; 918 918 bch2_bkey_val_to_text(&buf, c, k); ··· 1118 1116 return ret; 1119 1117 } 1120 1118 1121 - static int check_directory_size(struct btree_trans *trans, 1122 - struct bch_inode_unpacked *inode_u, 1123 - struct bkey_s_c inode_k, bool *write_inode) 1124 - { 1125 - struct btree_iter iter; 1126 - struct bkey_s_c k; 1127 - u64 new_size = 0; 1128 - int ret; 1129 - 1130 - for_each_btree_key_max_norestart(trans, iter, BTREE_ID_dirents, 1131 - SPOS(inode_k.k->p.offset, 0, inode_k.k->p.snapshot), 1132 - POS(inode_k.k->p.offset, U64_MAX), 1133 - 0, k, ret) { 1134 - if (k.k->type != KEY_TYPE_dirent) 1135 - continue; 1136 - 1137 - struct bkey_s_c_dirent dirent = bkey_s_c_to_dirent(k); 1138 - struct qstr name = bch2_dirent_get_name(dirent); 1139 - 1140 - new_size += dirent_occupied_size(&name); 1141 - } 1142 - bch2_trans_iter_exit(trans, &iter); 1143 - 1144 - if (!ret && inode_u->bi_size != new_size) { 1145 - inode_u->bi_size = new_size; 1146 - *write_inode = true; 1147 - } 1148 - 1149 - return ret; 1150 - } 1151 - 1152 1119 static int check_inode(struct btree_trans *trans, 1153 1120 struct btree_iter *iter, 1154 1121 struct bkey_s_c k, ··· 1305 1334 buf.buf))) { 1306 1335 u.bi_journal_seq = journal_cur_seq(&c->journal); 1307 1336 do_update = true; 1308 - } 1309 - 1310 - if (S_ISDIR(u.bi_mode)) { 1311 - ret = check_directory_size(trans, &u, k, &do_update); 1312 - 1313 - fsck_err_on(ret, 1314 - trans, directory_size_mismatch, 1315 - "directory inode %llu:%u with the mismatch directory size", 1316 - u.bi_inum, k.k->p.snapshot); 1317 - ret = 0; 1318 1337 } 1319 1338 do_update: 1320 1339 if (do_update) { ··· 1978 2017 return ret; 1979 2018 } 1980 2019 1981 - static int check_subdir_count(struct btree_trans *trans, struct inode_walker *w) 2020 + static int check_dir_i_size_notnested(struct btree_trans *trans, struct inode_walker *w) 2021 + { 2022 + struct bch_fs *c = trans->c; 2023 + int ret = 0; 2024 + 2025 + darray_for_each(w->inodes, i) 2026 + if (fsck_err_on(i->inode.bi_size != i->i_size, 2027 + trans, inode_dir_wrong_nlink, 2028 + "directory %llu:%u with wrong i_size: got %llu, should be %llu", 2029 + w->last_pos.inode, i->snapshot, i->inode.bi_size, i->i_size)) { 2030 + i->inode.bi_size = i->i_size; 2031 + ret = bch2_fsck_write_inode(trans, &i->inode); 2032 + if (ret) 2033 + break; 2034 + } 2035 + fsck_err: 2036 + bch_err_fn(c, ret); 2037 + return ret; 2038 + } 2039 + 2040 + static int check_subdir_dirents_count(struct btree_trans *trans, struct inode_walker *w) 1982 2041 { 1983 2042 u32 restart_count = trans->restart_count; 1984 2043 return check_subdir_count_notnested(trans, w) ?: 2044 + check_dir_i_size_notnested(trans, w) ?: 1985 2045 trans_was_restarted(trans, restart_count); 1986 2046 } 1987 2047 ··· 2349 2367 goto out; 2350 2368 2351 2369 if (dir->last_pos.inode != k.k->p.inode && dir->have_inodes) { 2352 - ret = check_subdir_count(trans, dir); 2370 + ret = check_subdir_dirents_count(trans, dir); 2353 2371 if (ret) 2354 2372 goto err; 2355 2373 } ··· 2439 2457 if (ret) 2440 2458 goto err; 2441 2459 2442 - if (d.v->d_type == DT_DIR) 2443 - for_each_visible_inode(c, s, dir, d.k->p.snapshot, i) 2460 + for_each_visible_inode(c, s, dir, d.k->p.snapshot, i) { 2461 + if (d.v->d_type == DT_DIR) 2444 2462 i->count++; 2463 + i->i_size += bkey_bytes(d.k); 2464 + } 2445 2465 out: 2446 2466 err: 2447 2467 fsck_err:
+8 -10
fs/bcachefs/reflink.c
··· 172 172 bool should_commit) 173 173 { 174 174 if (REFLINK_P_ERROR(p.v)) 175 - return -BCH_ERR_missing_indirect_extent; 175 + return 0; 176 176 177 177 struct bch_fs *c = trans->c; 178 178 u64 live_start = REFLINK_P_IDX(p.v); ··· 259 259 return k; 260 260 261 261 if (unlikely(!bkey_extent_is_reflink_data(k.k))) { 262 - bch2_trans_iter_exit(trans, iter); 263 - 264 262 unsigned size = min((u64) k.k->size, 265 263 REFLINK_P_IDX(p.v) + p.k->size + le32_to_cpu(p.v->back_pad) - 266 264 reflink_offset); ··· 266 268 267 269 int ret = bch2_indirect_extent_missing_error(trans, p, reflink_offset, 268 270 k.k->p.offset, should_commit); 269 - if (ret) 271 + if (ret) { 272 + bch2_trans_iter_exit(trans, iter); 270 273 return bkey_s_c_err(ret); 274 + } 271 275 } else if (unlikely(REFLINK_P_ERROR(p.v))) { 272 - bch2_trans_iter_exit(trans, iter); 273 - 274 276 int ret = bch2_indirect_extent_not_missing(trans, p, should_commit); 275 - if (ret) 277 + if (ret) { 278 + bch2_trans_iter_exit(trans, iter); 276 279 return bkey_s_c_err(ret); 280 + } 277 281 } 278 282 279 283 *offset_into_extent = reflink_offset - bkey_start_offset(k.k); ··· 300 300 if (ret) 301 301 return ret; 302 302 303 - if (bkey_deleted(k.k)) { 303 + if (!bkey_refcount_c(k)) { 304 304 if (!(flags & BTREE_TRIGGER_overwrite)) 305 305 ret = -BCH_ERR_missing_indirect_extent; 306 306 goto next; ··· 381 381 not_found: 382 382 if (flags & BTREE_TRIGGER_check_repair) { 383 383 ret = bch2_indirect_extent_missing_error(trans, p, *idx, next_idx, false); 384 - if (ret == -BCH_ERR_missing_indirect_extent) 385 - ret = 0; 386 384 if (ret) 387 385 goto err; 388 386 }
+1 -1
fs/bcachefs/sb-downgrade.c
··· 92 92 BCH_FSCK_ERR_accounting_key_replicas_nr_devs_0, \ 93 93 BCH_FSCK_ERR_accounting_key_junk_at_end) \ 94 94 x(directory_size, \ 95 - BIT_ULL(BCH_RECOVERY_PASS_check_inodes), \ 95 + BIT_ULL(BCH_RECOVERY_PASS_check_dirents), \ 96 96 BCH_FSCK_ERR_directory_size_mismatch) \ 97 97 98 98 #define DOWNGRADE_TABLE() \
+14 -7
fs/netfs/buffered_read.c
··· 155 155 netfs_cache_read_terminated, subreq); 156 156 } 157 157 158 - static void netfs_issue_read(struct netfs_io_request *rreq, 159 - struct netfs_io_subrequest *subreq) 158 + static void netfs_queue_read(struct netfs_io_request *rreq, 159 + struct netfs_io_subrequest *subreq, 160 + bool last_subreq) 160 161 { 161 162 struct netfs_io_stream *stream = &rreq->io_streams[0]; 162 163 ··· 178 177 } 179 178 } 180 179 181 - spin_unlock(&rreq->lock); 180 + if (last_subreq) { 181 + smp_wmb(); /* Write lists before ALL_QUEUED. */ 182 + set_bit(NETFS_RREQ_ALL_QUEUED, &rreq->flags); 183 + } 182 184 185 + spin_unlock(&rreq->lock); 186 + } 187 + 188 + static void netfs_issue_read(struct netfs_io_request *rreq, 189 + struct netfs_io_subrequest *subreq) 190 + { 183 191 switch (subreq->source) { 184 192 case NETFS_DOWNLOAD_FROM_SERVER: 185 193 rreq->netfs_ops->issue_read(subreq); ··· 303 293 } 304 294 size -= slice; 305 295 start += slice; 306 - if (size <= 0) { 307 - smp_wmb(); /* Write lists before ALL_QUEUED. */ 308 - set_bit(NETFS_RREQ_ALL_QUEUED, &rreq->flags); 309 - } 310 296 297 + netfs_queue_read(rreq, subreq, size <= 0); 311 298 netfs_issue_read(rreq, subreq); 312 299 cond_resched(); 313 300 } while (size > 0);
+4
fs/netfs/internal.h
··· 135 135 extern atomic_t netfs_n_rh_write_done; 136 136 extern atomic_t netfs_n_rh_write_failed; 137 137 extern atomic_t netfs_n_rh_write_zskip; 138 + extern atomic_t netfs_n_rh_retry_read_req; 139 + extern atomic_t netfs_n_rh_retry_read_subreq; 138 140 extern atomic_t netfs_n_wh_buffered_write; 139 141 extern atomic_t netfs_n_wh_writethrough; 140 142 extern atomic_t netfs_n_wh_dio_write; ··· 149 147 extern atomic_t netfs_n_wh_write; 150 148 extern atomic_t netfs_n_wh_write_done; 151 149 extern atomic_t netfs_n_wh_write_failed; 150 + extern atomic_t netfs_n_wh_retry_write_req; 151 + extern atomic_t netfs_n_wh_retry_write_subreq; 152 152 extern atomic_t netfs_n_wb_lock_skip; 153 153 extern atomic_t netfs_n_wb_lock_wait; 154 154 extern atomic_t netfs_n_folioq;
+4 -2
fs/netfs/read_collect.c
··· 470 470 */ 471 471 void netfs_wake_read_collector(struct netfs_io_request *rreq) 472 472 { 473 - if (test_bit(NETFS_RREQ_OFFLOAD_COLLECTION, &rreq->flags)) { 473 + if (test_bit(NETFS_RREQ_OFFLOAD_COLLECTION, &rreq->flags) && 474 + !test_bit(NETFS_RREQ_RETRYING, &rreq->flags)) { 474 475 if (!work_pending(&rreq->work)) { 475 476 netfs_get_request(rreq, netfs_rreq_trace_get_work); 476 477 if (!queue_work(system_unbound_wq, &rreq->work)) ··· 587 586 smp_mb__after_atomic(); /* Clear IN_PROGRESS before task state */ 588 587 589 588 /* If we are at the head of the queue, wake up the collector. */ 590 - if (list_is_first(&subreq->rreq_link, &stream->subrequests)) 589 + if (list_is_first(&subreq->rreq_link, &stream->subrequests) || 590 + test_bit(NETFS_RREQ_RETRYING, &rreq->flags)) 591 591 netfs_wake_read_collector(rreq); 592 592 593 593 netfs_put_subrequest(subreq, true, netfs_sreq_trace_put_terminated);
+33 -10
fs/netfs/read_retry.c
··· 14 14 { 15 15 __clear_bit(NETFS_SREQ_MADE_PROGRESS, &subreq->flags); 16 16 __set_bit(NETFS_SREQ_IN_PROGRESS, &subreq->flags); 17 - netfs_get_subrequest(subreq, netfs_sreq_trace_get_resubmit); 17 + netfs_stat(&netfs_n_rh_retry_read_subreq); 18 18 subreq->rreq->netfs_ops->issue_read(subreq); 19 19 } 20 20 ··· 48 48 __clear_bit(NETFS_SREQ_MADE_PROGRESS, &subreq->flags); 49 49 subreq->retry_count++; 50 50 netfs_reset_iter(subreq); 51 + netfs_get_subrequest(subreq, netfs_sreq_trace_get_resubmit); 51 52 netfs_reissue_read(rreq, subreq); 52 53 } 53 54 } ··· 76 75 struct iov_iter source; 77 76 unsigned long long start, len; 78 77 size_t part; 79 - bool boundary = false; 78 + bool boundary = false, subreq_superfluous = false; 80 79 81 80 /* Go through the subreqs and find the next span of contiguous 82 81 * buffer that we then rejig (cifs, for example, needs the ··· 117 116 /* Work through the sublist. */ 118 117 subreq = from; 119 118 list_for_each_entry_from(subreq, &stream->subrequests, rreq_link) { 120 - if (!len) 119 + if (!len) { 120 + subreq_superfluous = true; 121 121 break; 122 + } 122 123 subreq->source = NETFS_DOWNLOAD_FROM_SERVER; 123 124 subreq->start = start - subreq->transferred; 124 125 subreq->len = len + subreq->transferred; ··· 157 154 158 155 netfs_get_subrequest(subreq, netfs_sreq_trace_get_resubmit); 159 156 netfs_reissue_read(rreq, subreq); 160 - if (subreq == to) 157 + if (subreq == to) { 158 + subreq_superfluous = false; 161 159 break; 160 + } 162 161 } 163 162 164 163 /* If we managed to use fewer subreqs, we can discard the 165 164 * excess; if we used the same number, then we're done. 166 165 */ 167 166 if (!len) { 168 - if (subreq == to) 167 + if (!subreq_superfluous) 169 168 continue; 170 169 list_for_each_entry_safe_from(subreq, tmp, 171 170 &stream->subrequests, rreq_link) { 172 - trace_netfs_sreq(subreq, netfs_sreq_trace_discard); 171 + trace_netfs_sreq(subreq, netfs_sreq_trace_superfluous); 173 172 list_del(&subreq->rreq_link); 174 173 netfs_put_subrequest(subreq, false, netfs_sreq_trace_put_done); 175 174 if (subreq == to) ··· 192 187 subreq->source = NETFS_DOWNLOAD_FROM_SERVER; 193 188 subreq->start = start; 194 189 subreq->len = len; 195 - subreq->debug_index = atomic_inc_return(&rreq->subreq_counter); 196 190 subreq->stream_nr = stream->stream_nr; 197 191 subreq->retry_count = 1; 198 192 199 193 trace_netfs_sreq_ref(rreq->debug_id, subreq->debug_index, 200 194 refcount_read(&subreq->ref), 201 195 netfs_sreq_trace_new); 202 - netfs_get_subrequest(subreq, netfs_sreq_trace_get_resubmit); 203 196 204 197 list_add(&subreq->rreq_link, &to->rreq_link); 205 198 to = list_next_entry(to, rreq_link); ··· 259 256 { 260 257 struct netfs_io_subrequest *subreq; 261 258 struct netfs_io_stream *stream = &rreq->io_streams[0]; 259 + DEFINE_WAIT(myself); 260 + 261 + netfs_stat(&netfs_n_rh_retry_read_req); 262 + 263 + set_bit(NETFS_RREQ_RETRYING, &rreq->flags); 262 264 263 265 /* Wait for all outstanding I/O to quiesce before performing retries as 264 266 * we may need to renegotiate the I/O sizes. 265 267 */ 266 268 list_for_each_entry(subreq, &stream->subrequests, rreq_link) { 267 - wait_on_bit(&subreq->flags, NETFS_SREQ_IN_PROGRESS, 268 - TASK_UNINTERRUPTIBLE); 269 + if (!test_bit(NETFS_SREQ_IN_PROGRESS, &subreq->flags)) 270 + continue; 271 + 272 + trace_netfs_rreq(rreq, netfs_rreq_trace_wait_queue); 273 + for (;;) { 274 + prepare_to_wait(&rreq->waitq, &myself, TASK_UNINTERRUPTIBLE); 275 + 276 + if (!test_bit(NETFS_SREQ_IN_PROGRESS, &subreq->flags)) 277 + break; 278 + 279 + trace_netfs_sreq(subreq, netfs_sreq_trace_wait_for); 280 + schedule(); 281 + trace_netfs_rreq(rreq, netfs_rreq_trace_woke_queue); 282 + } 283 + 284 + finish_wait(&rreq->waitq, &myself); 269 285 } 286 + clear_bit(NETFS_RREQ_RETRYING, &rreq->flags); 270 287 271 288 trace_netfs_rreq(rreq, netfs_rreq_trace_resubmit); 272 289 netfs_retry_read_subrequests(rreq);
+9
fs/netfs/stats.c
··· 29 29 atomic_t netfs_n_rh_write_done; 30 30 atomic_t netfs_n_rh_write_failed; 31 31 atomic_t netfs_n_rh_write_zskip; 32 + atomic_t netfs_n_rh_retry_read_req; 33 + atomic_t netfs_n_rh_retry_read_subreq; 32 34 atomic_t netfs_n_wh_buffered_write; 33 35 atomic_t netfs_n_wh_writethrough; 34 36 atomic_t netfs_n_wh_dio_write; ··· 43 41 atomic_t netfs_n_wh_write; 44 42 atomic_t netfs_n_wh_write_done; 45 43 atomic_t netfs_n_wh_write_failed; 44 + atomic_t netfs_n_wh_retry_write_req; 45 + atomic_t netfs_n_wh_retry_write_subreq; 46 46 atomic_t netfs_n_wb_lock_skip; 47 47 atomic_t netfs_n_wb_lock_wait; 48 48 atomic_t netfs_n_folioq; ··· 85 81 atomic_read(&netfs_n_wh_write), 86 82 atomic_read(&netfs_n_wh_write_done), 87 83 atomic_read(&netfs_n_wh_write_failed)); 84 + seq_printf(m, "Retries: rq=%u rs=%u wq=%u ws=%u\n", 85 + atomic_read(&netfs_n_rh_retry_read_req), 86 + atomic_read(&netfs_n_rh_retry_read_subreq), 87 + atomic_read(&netfs_n_wh_retry_write_req), 88 + atomic_read(&netfs_n_wh_retry_write_subreq)); 88 89 seq_printf(m, "Objs : rr=%u sr=%u foq=%u wsc=%u\n", 89 90 atomic_read(&netfs_n_rh_rreq), 90 91 atomic_read(&netfs_n_rh_sreq),
+1
fs/netfs/write_issue.c
··· 253 253 subreq->retry_count++; 254 254 __clear_bit(NETFS_SREQ_MADE_PROGRESS, &subreq->flags); 255 255 __set_bit(NETFS_SREQ_IN_PROGRESS, &subreq->flags); 256 + netfs_stat(&netfs_n_wh_retry_write_subreq); 256 257 netfs_do_issue_write(stream, subreq); 257 258 } 258 259
+2
fs/netfs/write_retry.c
··· 203 203 struct netfs_io_stream *stream; 204 204 int s; 205 205 206 + netfs_stat(&netfs_n_wh_retry_write_req); 207 + 206 208 /* Wait for all outstanding I/O to quiesce before performing retries as 207 209 * we may need to renegotiate the I/O sizes. 208 210 */
+4 -1
fs/proc/vmcore.c
··· 1524 1524 pr_warn_once("Unexpected adding of device dump\n"); 1525 1525 if (vmcore_open) { 1526 1526 ret = -EBUSY; 1527 - goto out_err; 1527 + goto unlock; 1528 1528 } 1529 1529 1530 1530 list_add_tail(&dump->list, &vmcoredd_list); 1531 1531 vmcoredd_update_size(data_size); 1532 1532 mutex_unlock(&vmcore_mutex); 1533 1533 return 0; 1534 + 1535 + unlock: 1536 + mutex_unlock(&vmcore_mutex); 1534 1537 1535 1538 out_err: 1536 1539 vfree(buf);
+3 -3
fs/smb/client/cifsglob.h
··· 253 253 struct cifs_open_info_data { 254 254 bool adjust_tz; 255 255 bool reparse_point; 256 + bool contains_posix_file_info; 256 257 struct { 257 258 /* ioctl response buffer */ 258 259 struct { ··· 1509 1508 struct cifs_io_request { 1510 1509 struct netfs_io_request rreq; 1511 1510 struct cifsFileInfo *cfile; 1512 - struct TCP_Server_Info *server; 1513 1511 pid_t pid; 1514 1512 }; 1515 1513 ··· 2325 2325 struct kvec io_iov[SMB2_IOCTL_IOV_SIZE]; 2326 2326 struct kvec si_iov[SMB2_SET_INFO_IOV_SIZE]; 2327 2327 struct kvec close_iov; 2328 - struct smb2_file_rename_info rename_info; 2329 - struct smb2_file_link_info link_info; 2328 + struct smb2_file_rename_info_hdr rename_info; 2329 + struct smb2_file_link_info_hdr link_info; 2330 2330 struct kvec ea_iov; 2331 2331 }; 2332 2332
+4 -3
fs/smb/client/file.c
··· 147 147 struct netfs_io_request *rreq = subreq->rreq; 148 148 struct cifs_io_subrequest *rdata = container_of(subreq, struct cifs_io_subrequest, subreq); 149 149 struct cifs_io_request *req = container_of(subreq->rreq, struct cifs_io_request, rreq); 150 - struct TCP_Server_Info *server = req->server; 150 + struct TCP_Server_Info *server; 151 151 struct cifs_sb_info *cifs_sb = CIFS_SB(rreq->inode->i_sb); 152 152 size_t size; 153 153 int rc = 0; ··· 156 156 rdata->xid = get_xid(); 157 157 rdata->have_xid = true; 158 158 } 159 + 160 + server = cifs_pick_channel(tlink_tcon(req->cfile->tlink)->ses); 159 161 rdata->server = server; 160 162 161 163 if (cifs_sb->ctx->rsize == 0) ··· 200 198 struct netfs_io_request *rreq = subreq->rreq; 201 199 struct cifs_io_subrequest *rdata = container_of(subreq, struct cifs_io_subrequest, subreq); 202 200 struct cifs_io_request *req = container_of(subreq->rreq, struct cifs_io_request, rreq); 203 - struct TCP_Server_Info *server = req->server; 201 + struct TCP_Server_Info *server = rdata->server; 204 202 int rc = 0; 205 203 206 204 cifs_dbg(FYI, "%s: op=%08x[%x] mapping=%p len=%zu/%zu\n", ··· 268 266 open_file = file->private_data; 269 267 rreq->netfs_priv = file->private_data; 270 268 req->cfile = cifsFileInfo_get(open_file); 271 - req->server = cifs_pick_channel(tlink_tcon(req->cfile->tlink)->ses); 272 269 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_RWPIDFORWARD) 273 270 req->pid = req->cfile->pid; 274 271 } else if (rreq->origin != NETFS_WRITEBACK) {
+15 -2
fs/smb/client/inode.c
··· 1215 1215 rc = server->ops->parse_reparse_point(cifs_sb, 1216 1216 full_path, 1217 1217 iov, data); 1218 + /* 1219 + * If the reparse point was not handled but it is the 1220 + * name surrogate which points to directory, then treat 1221 + * is as a new mount point. Name surrogate reparse point 1222 + * represents another named entity in the system. 1223 + */ 1224 + if (rc == -EOPNOTSUPP && 1225 + IS_REPARSE_TAG_NAME_SURROGATE(data->reparse.tag) && 1226 + (le32_to_cpu(data->fi.Attributes) & ATTR_DIRECTORY)) { 1227 + rc = 0; 1228 + cifs_create_junction_fattr(fattr, sb); 1229 + goto out; 1230 + } 1218 1231 } 1219 1232 1220 1233 if (data->reparse.tag == IO_REPARSE_TAG_SYMLINK && !rc) { ··· 1421 1408 struct cifs_fattr fattr = {}; 1422 1409 int rc; 1423 1410 1424 - if (is_inode_cache_good(*inode)) { 1411 + if (!data && is_inode_cache_good(*inode)) { 1425 1412 cifs_dbg(FYI, "No need to revalidate cached inode sizes\n"); 1426 1413 return 0; 1427 1414 } ··· 1520 1507 struct cifs_fattr fattr = {}; 1521 1508 int rc; 1522 1509 1523 - if (is_inode_cache_good(*inode)) { 1510 + if (!data && is_inode_cache_good(*inode)) { 1524 1511 cifs_dbg(FYI, "No need to revalidate cached inode sizes\n"); 1525 1512 return 0; 1526 1513 }
+2 -3
fs/smb/client/reparse.c
··· 1088 1088 le32_to_cpu(buf->ReparseTag)); 1089 1089 return -EIO; 1090 1090 } 1091 - break; 1091 + return 0; 1092 1092 default: 1093 1093 cifs_tcon_dbg(VFS | ONCE, "unhandled reparse tag: 0x%08x\n", 1094 1094 le32_to_cpu(buf->ReparseTag)); 1095 - break; 1095 + return -EOPNOTSUPP; 1096 1096 } 1097 - return 0; 1098 1097 } 1099 1098 1100 1099 int smb2_parse_reparse_point(struct cifs_sb_info *cifs_sb,
+22 -6
fs/smb/client/reparse.h
··· 99 99 100 100 static inline bool cifs_open_data_reparse(struct cifs_open_info_data *data) 101 101 { 102 - struct smb2_file_all_info *fi = &data->fi; 103 - u32 attrs = le32_to_cpu(fi->Attributes); 102 + u32 attrs; 104 103 bool ret; 105 104 106 - ret = data->reparse_point || (attrs & ATTR_REPARSE); 107 - if (ret) 108 - attrs |= ATTR_REPARSE; 109 - fi->Attributes = cpu_to_le32(attrs); 105 + if (data->contains_posix_file_info) { 106 + struct smb311_posix_qinfo *fi = &data->posix_fi; 107 + 108 + attrs = le32_to_cpu(fi->DosAttributes); 109 + if (data->reparse_point) { 110 + attrs |= ATTR_REPARSE; 111 + fi->DosAttributes = cpu_to_le32(attrs); 112 + } 113 + 114 + } else { 115 + struct smb2_file_all_info *fi = &data->fi; 116 + 117 + attrs = le32_to_cpu(fi->Attributes); 118 + if (data->reparse_point) { 119 + attrs |= ATTR_REPARSE; 120 + fi->Attributes = cpu_to_le32(attrs); 121 + } 122 + } 123 + 124 + ret = attrs & ATTR_REPARSE; 125 + 110 126 return ret; 111 127 } 112 128
+4
fs/smb/client/smb2inode.c
··· 650 650 switch (cmds[i]) { 651 651 case SMB2_OP_QUERY_INFO: 652 652 idata = in_iov[i].iov_base; 653 + idata->contains_posix_file_info = false; 653 654 if (rc == 0 && cfile && cfile->symlink_target) { 654 655 idata->symlink_target = kstrdup(cfile->symlink_target, GFP_KERNEL); 655 656 if (!idata->symlink_target) ··· 674 673 break; 675 674 case SMB2_OP_POSIX_QUERY_INFO: 676 675 idata = in_iov[i].iov_base; 676 + idata->contains_posix_file_info = true; 677 677 if (rc == 0 && cfile && cfile->symlink_target) { 678 678 idata->symlink_target = kstrdup(cfile->symlink_target, GFP_KERNEL); 679 679 if (!idata->symlink_target) ··· 772 770 idata = in_iov[i].iov_base; 773 771 idata->reparse.io.iov = *iov; 774 772 idata->reparse.io.buftype = resp_buftype[i + 1]; 773 + idata->contains_posix_file_info = false; /* BB VERIFY */ 775 774 rbuf = reparse_buf_ptr(iov); 776 775 if (IS_ERR(rbuf)) { 777 776 rc = PTR_ERR(rbuf); ··· 794 791 case SMB2_OP_QUERY_WSL_EA: 795 792 if (!rc) { 796 793 idata = in_iov[i].iov_base; 794 + idata->contains_posix_file_info = false; 797 795 qi_rsp = rsp_iov[i + 1].iov_base; 798 796 data[0] = (u8 *)qi_rsp + le16_to_cpu(qi_rsp->OutputBufferOffset); 799 797 size[0] = le32_to_cpu(qi_rsp->OutputBufferLength);
+2 -1
fs/smb/client/smb2ops.c
··· 1001 1001 if (!data->symlink_target) 1002 1002 return -ENOMEM; 1003 1003 } 1004 + data->contains_posix_file_info = false; 1004 1005 return SMB2_query_info(xid, tcon, fid->persistent_fid, fid->volatile_fid, &data->fi); 1005 1006 } 1006 1007 ··· 5147 5146 FILE_CREATE, CREATE_NOT_DIR | 5148 5147 CREATE_OPTION_SPECIAL, ACL_NO_MODE); 5149 5148 oparms.fid = &fid; 5150 - 5149 + idata.contains_posix_file_info = false; 5151 5150 rc = server->ops->open(xid, &oparms, &oplock, &idata); 5152 5151 if (rc) 5153 5152 goto out;
+20 -10
fs/smb/common/smb2pdu.h
··· 1707 1707 } __packed; /* level 6 Query */ 1708 1708 1709 1709 struct smb2_file_rename_info { /* encoding of request for level 10 */ 1710 - __u8 ReplaceIfExists; /* 1 = replace existing target with new */ 1711 - /* 0 = fail if target already exists */ 1712 - __u8 Reserved[7]; 1713 - __u64 RootDirectory; /* MBZ for network operations (why says spec?) */ 1714 - __le32 FileNameLength; 1710 + /* New members MUST be added within the struct_group() macro below. */ 1711 + __struct_group(smb2_file_rename_info_hdr, __hdr, __packed, 1712 + __u8 ReplaceIfExists; /* 1 = replace existing target with new */ 1713 + /* 0 = fail if target already exists */ 1714 + __u8 Reserved[7]; 1715 + __u64 RootDirectory; /* MBZ for network operations (why says spec?) */ 1716 + __le32 FileNameLength; 1717 + ); 1715 1718 char FileName[]; /* New name to be assigned */ 1716 1719 /* padding - overall struct size must be >= 24 so filename + pad >= 6 */ 1717 1720 } __packed; /* level 10 Set */ 1721 + static_assert(offsetof(struct smb2_file_rename_info, FileName) == sizeof(struct smb2_file_rename_info_hdr), 1722 + "struct member likely outside of __struct_group()"); 1718 1723 1719 1724 struct smb2_file_link_info { /* encoding of request for level 11 */ 1720 - __u8 ReplaceIfExists; /* 1 = replace existing link with new */ 1721 - /* 0 = fail if link already exists */ 1722 - __u8 Reserved[7]; 1723 - __u64 RootDirectory; /* MBZ for network operations (why says spec?) */ 1724 - __le32 FileNameLength; 1725 + /* New members MUST be added within the struct_group() macro below. */ 1726 + __struct_group(smb2_file_link_info_hdr, __hdr, __packed, 1727 + __u8 ReplaceIfExists; /* 1 = replace existing link with new */ 1728 + /* 0 = fail if link already exists */ 1729 + __u8 Reserved[7]; 1730 + __u64 RootDirectory; /* MBZ for network operations (why says spec?) */ 1731 + __le32 FileNameLength; 1732 + ); 1725 1733 char FileName[]; /* Name to be assigned to new link */ 1726 1734 } __packed; /* level 11 Set */ 1735 + static_assert(offsetof(struct smb2_file_link_info, FileName) == sizeof(struct smb2_file_link_info_hdr), 1736 + "struct member likely outside of __struct_group()"); 1727 1737 1728 1738 /* 1729 1739 * This level 18, although with struct with same name is different from cifs
+3
fs/smb/common/smbfsctl.h
··· 159 159 #define IO_REPARSE_TAG_LX_CHR 0x80000025 160 160 #define IO_REPARSE_TAG_LX_BLK 0x80000026 161 161 162 + /* If Name Surrogate Bit is set, the file or directory represents another named entity in the system. */ 163 + #define IS_REPARSE_TAG_NAME_SURROGATE(tag) (!!((tag) & 0x20000000)) 164 + 162 165 /* fsctl flags */ 163 166 /* If Flags is set to this value, the request is an FSCTL not ioctl request */ 164 167 #define SMB2_0_IOCTL_IS_FSCTL 0x00000001
-5
fs/xfs/scrub/common.h
··· 224 224 bool xchk_dir_looks_zapped(struct xfs_inode *dp); 225 225 bool xchk_pptr_looks_zapped(struct xfs_inode *ip); 226 226 227 - #ifdef CONFIG_XFS_ONLINE_REPAIR 228 227 /* Decide if a repair is required. */ 229 228 static inline bool xchk_needs_repair(const struct xfs_scrub_metadata *sm) 230 229 { ··· 243 244 return (sc->sm->sm_flags & XFS_SCRUB_IFLAG_REPAIR) && 244 245 !(sc->flags & XREP_ALREADY_FIXED); 245 246 } 246 - #else 247 - # define xchk_needs_repair(sc) (false) 248 - # define xchk_could_repair(sc) (false) 249 - #endif /* CONFIG_XFS_ONLINE_REPAIR */ 250 247 251 248 int xchk_metadata_inode_forks(struct xfs_scrub *sc); 252 249
+10 -2
fs/xfs/scrub/inode_repair.c
··· 1055 1055 return true; 1056 1056 break; 1057 1057 case S_IFREG: 1058 - if (fmt == XFS_DINODE_FMT_LOCAL) 1058 + switch (fmt) { 1059 + case XFS_DINODE_FMT_LOCAL: 1059 1060 return true; 1060 - fallthrough; 1061 + case XFS_DINODE_FMT_EXTENTS: 1062 + case XFS_DINODE_FMT_BTREE: 1063 + case XFS_DINODE_FMT_META_BTREE: 1064 + break; 1065 + default: 1066 + return true; 1067 + } 1068 + break; 1061 1069 case S_IFLNK: 1062 1070 case S_IFDIR: 1063 1071 switch (fmt) {
+10 -1
fs/xfs/scrub/repair.h
··· 191 191 #else 192 192 193 193 #define xrep_ino_dqattach(sc) (0) 194 - #define xrep_will_attempt(sc) (false) 194 + 195 + /* 196 + * When online repair is not built into the kernel, we still want to attempt 197 + * the repair so that the stub xrep_attempt below will return EOPNOTSUPP. 198 + */ 199 + static inline bool xrep_will_attempt(const struct xfs_scrub *sc) 200 + { 201 + return (sc->sm->sm_flags & XFS_SCRUB_IFLAG_FORCE_REBUILD) || 202 + xchk_needs_repair(sc->sm); 203 + } 195 204 196 205 static inline int 197 206 xrep_attempt(
+12
fs/xfs/scrub/scrub.c
··· 149 149 if (xchk_should_terminate(sc, &error)) 150 150 return error; 151 151 152 + /* 153 + * If the caller is probing to see if repair works but repair isn't 154 + * built into the kernel, return EOPNOTSUPP because that's the signal 155 + * that userspace expects. If online repair is built in, set the 156 + * CORRUPT flag (without any of the usual tracing/logging) to force us 157 + * into xrep_probe. 158 + */ 159 + if (xchk_could_repair(sc)) { 160 + if (!IS_ENABLED(CONFIG_XFS_ONLINE_REPAIR)) 161 + return -EOPNOTSUPP; 162 + sc->sm->sm_flags |= XFS_SCRUB_OFLAG_CORRUPT; 163 + } 152 164 return 0; 153 165 } 154 166
+37 -4
fs/xfs/xfs_aops.c
··· 19 19 #include "xfs_reflink.h" 20 20 #include "xfs_errortag.h" 21 21 #include "xfs_error.h" 22 + #include "xfs_icache.h" 22 23 23 24 struct xfs_writepage_ctx { 24 25 struct iomap_writepage_ctx ctx; ··· 529 528 } 530 529 531 530 static int 532 - xfs_iomap_swapfile_activate( 531 + xfs_vm_swap_activate( 533 532 struct swap_info_struct *sis, 534 533 struct file *swap_file, 535 534 sector_t *span) 536 535 { 537 - sis->bdev = xfs_inode_buftarg(XFS_I(file_inode(swap_file)))->bt_bdev; 536 + struct xfs_inode *ip = XFS_I(file_inode(swap_file)); 537 + 538 + /* 539 + * Swap file activation can race against concurrent shared extent 540 + * removal in files that have been cloned. If this happens, 541 + * iomap_swapfile_iter() can fail because it encountered a shared 542 + * extent even though an operation is in progress to remove those 543 + * shared extents. 544 + * 545 + * This race becomes problematic when we defer extent removal 546 + * operations beyond the end of a syscall (i.e. use async background 547 + * processing algorithms). Users think the extents are no longer 548 + * shared, but iomap_swapfile_iter() still sees them as shared 549 + * because the refcountbt entries for the extents being removed have 550 + * not yet been updated. Hence the swapon call fails unexpectedly. 551 + * 552 + * The race condition is currently most obvious from the unlink() 553 + * operation as extent removal is deferred until after the last 554 + * reference to the inode goes away. We then process the extent 555 + * removal asynchronously, hence triggers the "syscall completed but 556 + * work not done" condition mentioned above. To close this race 557 + * window, we need to flush any pending inodegc operations to ensure 558 + * they have updated the refcountbt records before we try to map the 559 + * swapfile. 560 + */ 561 + xfs_inodegc_flush(ip->i_mount); 562 + 563 + /* 564 + * Direct the swap code to the correct block device when this file 565 + * sits on the RT device. 566 + */ 567 + sis->bdev = xfs_inode_buftarg(ip)->bt_bdev; 568 + 538 569 return iomap_swapfile_activate(sis, swap_file, span, 539 570 &xfs_read_iomap_ops); 540 571 } ··· 582 549 .migrate_folio = filemap_migrate_folio, 583 550 .is_partially_uptodate = iomap_is_partially_uptodate, 584 551 .error_remove_folio = generic_error_remove_folio, 585 - .swap_activate = xfs_iomap_swapfile_activate, 552 + .swap_activate = xfs_vm_swap_activate, 586 553 }; 587 554 588 555 const struct address_space_operations xfs_dax_aops = { 589 556 .writepages = xfs_dax_writepages, 590 557 .dirty_folio = noop_dirty_folio, 591 - .swap_activate = xfs_iomap_swapfile_activate, 558 + .swap_activate = xfs_vm_swap_activate, 592 559 };
+39 -16
fs/xfs/xfs_qm_bhv.c
··· 78 78 } 79 79 } 80 80 81 + STATIC int 82 + xfs_qm_validate_state_change( 83 + struct xfs_mount *mp, 84 + uint uqd, 85 + uint gqd, 86 + uint pqd) 87 + { 88 + int state; 89 + 90 + /* Is quota state changing? */ 91 + state = ((uqd && !XFS_IS_UQUOTA_ON(mp)) || 92 + (!uqd && XFS_IS_UQUOTA_ON(mp)) || 93 + (gqd && !XFS_IS_GQUOTA_ON(mp)) || 94 + (!gqd && XFS_IS_GQUOTA_ON(mp)) || 95 + (pqd && !XFS_IS_PQUOTA_ON(mp)) || 96 + (!pqd && XFS_IS_PQUOTA_ON(mp))); 97 + 98 + return state && 99 + (xfs_dev_is_read_only(mp, "changing quota state") || 100 + xfs_has_norecovery(mp)); 101 + } 102 + 81 103 int 82 104 xfs_qm_newmount( 83 105 xfs_mount_t *mp, ··· 119 97 } 120 98 121 99 /* 122 - * If the device itself is read-only, we can't allow 123 - * the user to change the state of quota on the mount - 124 - * this would generate a transaction on the ro device, 125 - * which would lead to an I/O error and shutdown 100 + * If the device itself is read-only and/or in norecovery 101 + * mode, we can't allow the user to change the state of 102 + * quota on the mount - this would generate a transaction 103 + * on the ro device, which would lead to an I/O error and 104 + * shutdown. 126 105 */ 127 106 128 - if (((uquotaondisk && !XFS_IS_UQUOTA_ON(mp)) || 129 - (!uquotaondisk && XFS_IS_UQUOTA_ON(mp)) || 130 - (gquotaondisk && !XFS_IS_GQUOTA_ON(mp)) || 131 - (!gquotaondisk && XFS_IS_GQUOTA_ON(mp)) || 132 - (pquotaondisk && !XFS_IS_PQUOTA_ON(mp)) || 133 - (!pquotaondisk && XFS_IS_PQUOTA_ON(mp))) && 134 - xfs_dev_is_read_only(mp, "changing quota state")) { 135 - xfs_warn(mp, "please mount with%s%s%s%s.", 136 - (!quotaondisk ? "out quota" : ""), 137 - (uquotaondisk ? " usrquota" : ""), 138 - (gquotaondisk ? " grpquota" : ""), 139 - (pquotaondisk ? " prjquota" : "")); 107 + if (xfs_qm_validate_state_change(mp, uquotaondisk, 108 + gquotaondisk, pquotaondisk)) { 109 + 110 + if (xfs_has_metadir(mp)) 111 + xfs_warn(mp, 112 + "metadir enabled, please mount without any quota mount options"); 113 + else 114 + xfs_warn(mp, "please mount with%s%s%s%s.", 115 + (!quotaondisk ? "out quota" : ""), 116 + (uquotaondisk ? " usrquota" : ""), 117 + (gquotaondisk ? " grpquota" : ""), 118 + (pquotaondisk ? " prjquota" : "")); 140 119 return -EPERM; 141 120 } 142 121
+6 -2
fs/xfs/xfs_super.c
··· 1661 1661 #endif 1662 1662 } 1663 1663 1664 - /* Filesystem claims it needs repair, so refuse the mount. */ 1665 - if (xfs_has_needsrepair(mp)) { 1664 + /* 1665 + * Filesystem claims it needs repair, so refuse the mount unless 1666 + * norecovery is also specified, in which case the filesystem can 1667 + * be mounted with no risk of further damage. 1668 + */ 1669 + if (xfs_has_needsrepair(mp) && !xfs_has_norecovery(mp)) { 1666 1670 xfs_warn(mp, "Filesystem needs repair. Please run xfs_repair."); 1667 1671 error = -EFSCORRUPTED; 1668 1672 goto out_free_sb;
+1
include/drm/display/drm_dp.h
··· 359 359 # define DP_DSC_BITS_PER_PIXEL_1_4 0x2 360 360 # define DP_DSC_BITS_PER_PIXEL_1_2 0x3 361 361 # define DP_DSC_BITS_PER_PIXEL_1_1 0x4 362 + # define DP_DSC_BITS_PER_PIXEL_MASK 0x7 362 363 363 364 #define DP_PSR_SUPPORT 0x070 /* XXX 1.2? */ 364 365 # define DP_PSR_IS_SUPPORTED 1
+16
include/dt-bindings/clock/qcom,qcs8300-camcc.h
··· 1 + /* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */ 2 + /* 3 + * Copyright (c) 2024, Qualcomm Innovation Center, Inc. All rights reserved. 4 + */ 5 + 6 + #ifndef _DT_BINDINGS_CLK_QCOM_QCS8300_CAM_CC_H 7 + #define _DT_BINDINGS_CLK_QCOM_QCS8300_CAM_CC_H 8 + 9 + #include "qcom,sa8775p-camcc.h" 10 + 11 + /* QCS8300 introduces below new clocks compared to SA8775P */ 12 + 13 + /* CAM_CC clocks */ 14 + #define CAM_CC_TITAN_TOP_ACCU_SHIFT_CLK 86 15 + 16 + #endif
+17
include/dt-bindings/clock/qcom,qcs8300-gpucc.h
··· 1 + /* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */ 2 + /* 3 + * Copyright (c) 2024, Qualcomm Innovation Center, Inc. All rights reserved. 4 + */ 5 + 6 + #ifndef _DT_BINDINGS_CLK_QCOM_GPUCC_QCS8300_H 7 + #define _DT_BINDINGS_CLK_QCOM_GPUCC_QCS8300_H 8 + 9 + #include "qcom,sa8775p-gpucc.h" 10 + 11 + /* QCS8300 introduces below new clocks compared to SA8775P */ 12 + 13 + /* GPU_CC clocks */ 14 + #define GPU_CC_CX_ACCU_SHIFT_CLK 23 15 + #define GPU_CC_GX_ACCU_SHIFT_CLK 24 16 + 17 + #endif
+14 -4
include/linux/blk-mq.h
··· 861 861 void (*complete)(struct io_comp_batch *)) 862 862 { 863 863 /* 864 - * blk_mq_end_request_batch() can't end request allocated from 865 - * sched tags 864 + * Check various conditions that exclude batch processing: 865 + * 1) No batch container 866 + * 2) Has scheduler data attached 867 + * 3) Not a passthrough request and end_io set 868 + * 4) Not a passthrough request and an ioerror 866 869 */ 867 - if (!iob || (req->rq_flags & RQF_SCHED_TAGS) || ioerror || 868 - (req->end_io && !blk_rq_is_passthrough(req))) 870 + if (!iob) 869 871 return false; 872 + if (req->rq_flags & RQF_SCHED_TAGS) 873 + return false; 874 + if (!blk_rq_is_passthrough(req)) { 875 + if (req->end_io) 876 + return false; 877 + if (ioerror < 0) 878 + return false; 879 + } 870 880 871 881 if (!iob->complete) 872 882 iob->complete = complete;
+3 -3
include/linux/cgroup-defs.h
··· 71 71 72 72 /* Cgroup is frozen. */ 73 73 CGRP_FROZEN, 74 - 75 - /* Control group has to be killed. */ 76 - CGRP_KILL, 77 74 }; 78 75 79 76 /* cgroup_root->flags */ ··· 457 460 int nr_populated_threaded_children; 458 461 459 462 int nr_threaded_children; /* # of live threaded child cgroups */ 463 + 464 + /* sequence number for cgroup.kill, serialized by css_set_lock. */ 465 + unsigned int kill_seq; 460 466 461 467 struct kernfs_node *kn; /* cgroup kernfs entry */ 462 468 struct cgroup_file procs_file; /* handle for "cgroup.procs" */
+69
include/linux/device/faux.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0-only */ 2 + /* 3 + * Copyright (c) 2025 Greg Kroah-Hartman <gregkh@linuxfoundation.org> 4 + * Copyright (c) 2025 The Linux Foundation 5 + * 6 + * A "simple" faux bus that allows devices to be created and added 7 + * automatically to it. This is to be used whenever you need to create a 8 + * device that is not associated with any "real" system resources, and do 9 + * not want to have to deal with a bus/driver binding logic. It is 10 + * intended to be very simple, with only a create and a destroy function 11 + * available. 12 + */ 13 + #ifndef _FAUX_DEVICE_H_ 14 + #define _FAUX_DEVICE_H_ 15 + 16 + #include <linux/container_of.h> 17 + #include <linux/device.h> 18 + 19 + /** 20 + * struct faux_device - a "faux" device 21 + * @dev: internal struct device of the object 22 + * 23 + * A simple faux device that can be created/destroyed. To be used when a 24 + * driver only needs to have a device to "hang" something off. This can be 25 + * used for downloading firmware or other basic tasks. Use this instead of 26 + * a struct platform_device if the device has no resources assigned to 27 + * it at all. 28 + */ 29 + struct faux_device { 30 + struct device dev; 31 + }; 32 + #define to_faux_device(x) container_of_const((x), struct faux_device, dev) 33 + 34 + /** 35 + * struct faux_device_ops - a set of callbacks for a struct faux_device 36 + * @probe: called when a faux device is probed by the driver core 37 + * before the device is fully bound to the internal faux bus 38 + * code. If probe succeeds, return 0, otherwise return a 39 + * negative error number to stop the probe sequence from 40 + * succeeding. 41 + * @remove: called when a faux device is removed from the system 42 + * 43 + * Both @probe and @remove are optional, if not needed, set to NULL. 44 + */ 45 + struct faux_device_ops { 46 + int (*probe)(struct faux_device *faux_dev); 47 + void (*remove)(struct faux_device *faux_dev); 48 + }; 49 + 50 + struct faux_device *faux_device_create(const char *name, 51 + struct device *parent, 52 + const struct faux_device_ops *faux_ops); 53 + struct faux_device *faux_device_create_with_groups(const char *name, 54 + struct device *parent, 55 + const struct faux_device_ops *faux_ops, 56 + const struct attribute_group **groups); 57 + void faux_device_destroy(struct faux_device *faux_dev); 58 + 59 + static inline void *faux_device_get_drvdata(const struct faux_device *faux_dev) 60 + { 61 + return dev_get_drvdata(&faux_dev->dev); 62 + } 63 + 64 + static inline void faux_device_set_drvdata(struct faux_device *faux_dev, void *data) 65 + { 66 + dev_set_drvdata(&faux_dev->dev, data); 67 + } 68 + 69 + #endif /* _FAUX_DEVICE_H_ */
+16 -15
include/linux/efi.h
··· 114 114 #define EFI_MAX_MEMORY_TYPE 16 115 115 116 116 /* Attribute values: */ 117 - #define EFI_MEMORY_UC ((u64)0x0000000000000001ULL) /* uncached */ 118 - #define EFI_MEMORY_WC ((u64)0x0000000000000002ULL) /* write-coalescing */ 119 - #define EFI_MEMORY_WT ((u64)0x0000000000000004ULL) /* write-through */ 120 - #define EFI_MEMORY_WB ((u64)0x0000000000000008ULL) /* write-back */ 121 - #define EFI_MEMORY_UCE ((u64)0x0000000000000010ULL) /* uncached, exported */ 122 - #define EFI_MEMORY_WP ((u64)0x0000000000001000ULL) /* write-protect */ 123 - #define EFI_MEMORY_RP ((u64)0x0000000000002000ULL) /* read-protect */ 124 - #define EFI_MEMORY_XP ((u64)0x0000000000004000ULL) /* execute-protect */ 125 - #define EFI_MEMORY_NV ((u64)0x0000000000008000ULL) /* non-volatile */ 126 - #define EFI_MEMORY_MORE_RELIABLE \ 127 - ((u64)0x0000000000010000ULL) /* higher reliability */ 128 - #define EFI_MEMORY_RO ((u64)0x0000000000020000ULL) /* read-only */ 129 - #define EFI_MEMORY_SP ((u64)0x0000000000040000ULL) /* soft reserved */ 130 - #define EFI_MEMORY_CPU_CRYPTO ((u64)0x0000000000080000ULL) /* supports encryption */ 131 - #define EFI_MEMORY_RUNTIME ((u64)0x8000000000000000ULL) /* range requires runtime mapping */ 117 + #define EFI_MEMORY_UC BIT_ULL(0) /* uncached */ 118 + #define EFI_MEMORY_WC BIT_ULL(1) /* write-coalescing */ 119 + #define EFI_MEMORY_WT BIT_ULL(2) /* write-through */ 120 + #define EFI_MEMORY_WB BIT_ULL(3) /* write-back */ 121 + #define EFI_MEMORY_UCE BIT_ULL(4) /* uncached, exported */ 122 + #define EFI_MEMORY_WP BIT_ULL(12) /* write-protect */ 123 + #define EFI_MEMORY_RP BIT_ULL(13) /* read-protect */ 124 + #define EFI_MEMORY_XP BIT_ULL(14) /* execute-protect */ 125 + #define EFI_MEMORY_NV BIT_ULL(15) /* non-volatile */ 126 + #define EFI_MEMORY_MORE_RELIABLE BIT_ULL(16) /* higher reliability */ 127 + #define EFI_MEMORY_RO BIT_ULL(17) /* read-only */ 128 + #define EFI_MEMORY_SP BIT_ULL(18) /* soft reserved */ 129 + #define EFI_MEMORY_CPU_CRYPTO BIT_ULL(19) /* supports encryption */ 130 + #define EFI_MEMORY_HOT_PLUGGABLE BIT_ULL(20) /* supports unplugging at runtime */ 131 + #define EFI_MEMORY_RUNTIME BIT_ULL(63) /* range requires runtime mapping */ 132 + 132 133 #define EFI_MEMORY_DESCRIPTOR_VERSION 1 133 134 134 135 #define EFI_PAGE_SHIFT 12
+2 -1
include/linux/netdevice.h
··· 3276 3276 } 3277 3277 3278 3278 int netdev_boot_setup_check(struct net_device *dev); 3279 + struct net_device *dev_getbyhwaddr(struct net *net, unsigned short type, 3280 + const char *hwaddr); 3279 3281 struct net_device *dev_getbyhwaddr_rcu(struct net *net, unsigned short type, 3280 3282 const char *hwaddr); 3281 3283 struct net_device *dev_getfirstbyhwtype(struct net *net, unsigned short type); ··· 4118 4116 gro_result_t napi_gro_receive(struct napi_struct *napi, struct sk_buff *skb); 4119 4117 void napi_gro_flush(struct napi_struct *napi, bool flush_old); 4120 4118 struct sk_buff *napi_get_frags(struct napi_struct *napi); 4121 - void napi_get_frags_check(struct napi_struct *napi); 4122 4119 gro_result_t napi_gro_frags(struct napi_struct *napi); 4123 4120 4124 4121 static inline void napi_free_frags(struct napi_struct *napi)
+1 -1
include/linux/netfs.h
··· 278 278 #define NETFS_RREQ_PAUSE 11 /* Pause subrequest generation */ 279 279 #define NETFS_RREQ_USE_IO_ITER 12 /* Use ->io_iter rather than ->i_pages */ 280 280 #define NETFS_RREQ_ALL_QUEUED 13 /* All subreqs are now queued */ 281 - #define NETFS_RREQ_NEED_RETRY 14 /* Need to try retrying */ 281 + #define NETFS_RREQ_RETRYING 14 /* Set if we're in the retry path */ 282 282 #define NETFS_RREQ_USE_PGPRIV2 31 /* [DEPRECATED] Use PG_private_2 to mark 283 283 * write to cache on read */ 284 284 const struct netfs_request_ops *netfs_ops;
+1
include/linux/pci_ids.h
··· 3134 3134 #define PCI_DEVICE_ID_INTEL_HDA_LNL_P 0xa828 3135 3135 #define PCI_DEVICE_ID_INTEL_S21152BB 0xb152 3136 3136 #define PCI_DEVICE_ID_INTEL_HDA_BMG 0xe2f7 3137 + #define PCI_DEVICE_ID_INTEL_HDA_PTL_H 0xe328 3137 3138 #define PCI_DEVICE_ID_INTEL_HDA_PTL 0xe428 3138 3139 #define PCI_DEVICE_ID_INTEL_HDA_CML_R 0xf0c8 3139 3140 #define PCI_DEVICE_ID_INTEL_HDA_RKL_S 0xf1c8
+9
include/linux/psp-sev.h
··· 815 815 #ifdef CONFIG_CRYPTO_DEV_SP_PSP 816 816 817 817 /** 818 + * sev_module_init - perform PSP SEV module initialization 819 + * 820 + * Returns: 821 + * 0 if the PSP module is successfully initialized 822 + * negative value if the PSP module initialization fails 823 + */ 824 + int sev_module_init(void); 825 + 826 + /** 818 827 * sev_platform_init - perform SEV INIT command 819 828 * 820 829 * @args: struct sev_platform_init_args to pass in arguments
+1
include/linux/sched/task.h
··· 43 43 void *fn_arg; 44 44 struct cgroup *cgrp; 45 45 struct css_set *cset; 46 + unsigned int kill_seq; 46 47 }; 47 48 48 49 /*
+3
include/net/gro.h
··· 11 11 #include <net/udp.h> 12 12 #include <net/hotdata.h> 13 13 14 + /* This should be increased if a protocol with a bigger head is added. */ 15 + #define GRO_MAX_HEAD (MAX_HEADER + 128) 16 + 14 17 struct napi_gro_cb { 15 18 union { 16 19 struct {
+11
include/net/net_namespace.h
··· 297 297 } 298 298 299 299 void net_drop_ns(void *); 300 + void net_passive_dec(struct net *net); 300 301 301 302 #else 302 303 ··· 327 326 } 328 327 329 328 #define net_drop_ns NULL 329 + 330 + static inline void net_passive_dec(struct net *net) 331 + { 332 + refcount_dec(&net->passive); 333 + } 330 334 #endif 335 + 336 + static inline void net_passive_inc(struct net *net) 337 + { 338 + refcount_inc(&net->passive); 339 + } 331 340 332 341 /* Returns true if the netns initialization is completed successfully */ 333 342 static inline bool net_initialized(const struct net *net)
+14
include/net/tcp.h
··· 41 41 #include <net/inet_ecn.h> 42 42 #include <net/dst.h> 43 43 #include <net/mptcp.h> 44 + #include <net/xfrm.h> 44 45 45 46 #include <linux/seq_file.h> 46 47 #include <linux/memcontrol.h> ··· 685 684 void tcp_fin(struct sock *sk); 686 685 void tcp_check_space(struct sock *sk); 687 686 void tcp_sack_compress_send_ack(struct sock *sk); 687 + 688 + static inline void tcp_cleanup_skb(struct sk_buff *skb) 689 + { 690 + skb_dst_drop(skb); 691 + secpath_reset(skb); 692 + } 693 + 694 + static inline void tcp_add_receive_queue(struct sock *sk, struct sk_buff *skb) 695 + { 696 + DEBUG_NET_WARN_ON_ONCE(skb_dst(skb)); 697 + DEBUG_NET_WARN_ON_ONCE(secpath_exists(skb)); 698 + __skb_queue_tail(&sk->sk_receive_queue, skb); 699 + } 688 700 689 701 /* tcp_timer.c */ 690 702 void tcp_init_xmit_timers(struct sock *);
+3 -1
include/trace/events/netfs.h
··· 99 99 EM(netfs_sreq_trace_limited, "LIMIT") \ 100 100 EM(netfs_sreq_trace_need_clear, "N-CLR") \ 101 101 EM(netfs_sreq_trace_partial_read, "PARTR") \ 102 - EM(netfs_sreq_trace_need_retry, "NRTRY") \ 102 + EM(netfs_sreq_trace_need_retry, "ND-RT") \ 103 103 EM(netfs_sreq_trace_prepare, "PREP ") \ 104 104 EM(netfs_sreq_trace_prep_failed, "PRPFL") \ 105 105 EM(netfs_sreq_trace_progress, "PRGRS") \ ··· 108 108 EM(netfs_sreq_trace_short, "SHORT") \ 109 109 EM(netfs_sreq_trace_split, "SPLIT") \ 110 110 EM(netfs_sreq_trace_submit, "SUBMT") \ 111 + EM(netfs_sreq_trace_superfluous, "SPRFL") \ 111 112 EM(netfs_sreq_trace_terminated, "TERM ") \ 113 + EM(netfs_sreq_trace_wait_for, "_WAIT") \ 112 114 EM(netfs_sreq_trace_write, "WRITE") \ 113 115 EM(netfs_sreq_trace_write_skip, "SKIP ") \ 114 116 E_(netfs_sreq_trace_write_term, "WTERM")
+1 -1
include/uapi/linux/taskstats.h
··· 34 34 */ 35 35 36 36 37 - #define TASKSTATS_VERSION 14 37 + #define TASKSTATS_VERSION 15 38 38 #define TS_COMM_LEN 32 /* should be >= TASK_COMM_LEN 39 39 * in linux/sched.h */ 40 40
+1 -1
include/uapi/linux/thermal.h
··· 30 30 THERMAL_GENL_ATTR_TZ, 31 31 THERMAL_GENL_ATTR_TZ_ID, 32 32 THERMAL_GENL_ATTR_TZ_TEMP, 33 - THERMAL_GENL_ATTR_TZ_PREV_TEMP, 34 33 THERMAL_GENL_ATTR_TZ_TRIP, 35 34 THERMAL_GENL_ATTR_TZ_TRIP_ID, 36 35 THERMAL_GENL_ATTR_TZ_TRIP_TYPE, ··· 53 54 THERMAL_GENL_ATTR_THRESHOLD, 54 55 THERMAL_GENL_ATTR_THRESHOLD_TEMP, 55 56 THERMAL_GENL_ATTR_THRESHOLD_DIRECTION, 57 + THERMAL_GENL_ATTR_TZ_PREV_TEMP, 56 58 __THERMAL_GENL_ATTR_MAX, 57 59 }; 58 60 #define THERMAL_GENL_ATTR_MAX (__THERMAL_GENL_ATTR_MAX - 1)
+1 -1
include/uapi/linux/virtio_snd.h
··· 25 25 __le32 streams; 26 26 /* # of available channel maps */ 27 27 __le32 chmaps; 28 - /* # of available control elements */ 28 + /* # of available control elements (if VIRTIO_SND_F_CTLS) */ 29 29 __le32 controls; 30 30 }; 31 31
+12 -4
io_uring/kbuf.c
··· 415 415 } 416 416 } 417 417 418 + static void io_destroy_bl(struct io_ring_ctx *ctx, struct io_buffer_list *bl) 419 + { 420 + scoped_guard(mutex, &ctx->mmap_lock) 421 + WARN_ON_ONCE(xa_erase(&ctx->io_bl_xa, bl->bgid) != bl); 422 + io_put_bl(ctx, bl); 423 + } 424 + 418 425 int io_remove_buffers_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe) 419 426 { 420 427 struct io_provide_buf *p = io_kiocb_to_cmd(req, struct io_provide_buf); ··· 643 636 /* if mapped buffer ring OR classic exists, don't allow */ 644 637 if (bl->flags & IOBL_BUF_RING || !list_empty(&bl->buf_list)) 645 638 return -EEXIST; 646 - } else { 647 - free_bl = bl = kzalloc(sizeof(*bl), GFP_KERNEL); 648 - if (!bl) 649 - return -ENOMEM; 639 + io_destroy_bl(ctx, bl); 650 640 } 641 + 642 + free_bl = bl = kzalloc(sizeof(*bl), GFP_KERNEL); 643 + if (!bl) 644 + return -ENOMEM; 651 645 652 646 mmap_offset = (unsigned long)reg.bgid << IORING_OFF_PBUF_SHIFT; 653 647 ring_size = flex_array_size(br, bufs, reg.ring_entries);
+9 -19
io_uring/uring_cmd.c
··· 54 54 continue; 55 55 56 56 if (cmd->flags & IORING_URING_CMD_CANCELABLE) { 57 - /* ->sqe isn't available if no async data */ 58 - if (!req_has_async_data(req)) 59 - cmd->sqe = NULL; 60 57 file->f_op->uring_cmd(cmd, IO_URING_F_CANCEL | 61 58 IO_URING_F_COMPLETE_DEFER); 62 59 ret = true; ··· 176 179 return -ENOMEM; 177 180 cache->op_data = NULL; 178 181 179 - if (!(req->flags & REQ_F_FORCE_ASYNC)) { 180 - /* defer memcpy until we need it */ 181 - ioucmd->sqe = sqe; 182 - return 0; 183 - } 184 - 182 + /* 183 + * Unconditionally cache the SQE for now - this is only needed for 184 + * requests that go async, but prep handlers must ensure that any 185 + * sqe data is stable beyond prep. Since uring_cmd is special in 186 + * that it doesn't read in per-op data, play it safe and ensure that 187 + * any SQE data is stable beyond prep. This can later get relaxed. 188 + */ 185 189 memcpy(cache->sqes, sqe, uring_sqe_size(req->ctx)); 186 190 ioucmd->sqe = cache->sqes; 187 191 return 0; ··· 247 249 } 248 250 249 251 ret = file->f_op->uring_cmd(ioucmd, issue_flags); 250 - if (ret == -EAGAIN) { 251 - struct io_uring_cmd_data *cache = req->async_data; 252 - 253 - if (ioucmd->sqe != (void *) cache) 254 - memcpy(cache->sqes, ioucmd->sqe, uring_sqe_size(req->ctx)); 255 - return -EAGAIN; 256 - } else if (ret == -EIOCBQUEUED) { 257 - return -EIOCBQUEUED; 258 - } 259 - 252 + if (ret == -EAGAIN || ret == -EIOCBQUEUED) 253 + return ret; 260 254 if (ret < 0) 261 255 req_set_fail(req); 262 256 io_req_uring_cleanup(req, issue_flags);
+9 -9
io_uring/waitid.c
··· 118 118 static void io_waitid_complete(struct io_kiocb *req, int ret) 119 119 { 120 120 struct io_waitid *iw = io_kiocb_to_cmd(req, struct io_waitid); 121 - struct io_tw_state ts = {}; 122 121 123 122 /* anyone completing better be holding a reference */ 124 123 WARN_ON_ONCE(!(atomic_read(&iw->refs) & IO_WAITID_REF_MASK)); ··· 130 131 if (ret < 0) 131 132 req_set_fail(req); 132 133 io_req_set_res(req, ret, 0); 133 - io_req_task_complete(req, &ts); 134 134 } 135 135 136 136 static bool __io_waitid_cancel(struct io_ring_ctx *ctx, struct io_kiocb *req) ··· 151 153 list_del_init(&iwa->wo.child_wait.entry); 152 154 spin_unlock_irq(&iw->head->lock); 153 155 io_waitid_complete(req, -ECANCELED); 156 + io_req_queue_tw_complete(req, -ECANCELED); 154 157 return true; 155 158 } 156 159 ··· 257 258 } 258 259 259 260 io_waitid_complete(req, ret); 261 + io_req_task_complete(req, ts); 260 262 } 261 263 262 264 static int io_waitid_wait(struct wait_queue_entry *wait, unsigned mode, ··· 285 285 int io_waitid_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe) 286 286 { 287 287 struct io_waitid *iw = io_kiocb_to_cmd(req, struct io_waitid); 288 + struct io_waitid_async *iwa; 288 289 289 290 if (sqe->addr || sqe->buf_index || sqe->addr3 || sqe->waitid_flags) 290 291 return -EINVAL; 292 + 293 + iwa = io_uring_alloc_async_data(NULL, req); 294 + if (!unlikely(iwa)) 295 + return -ENOMEM; 296 + iwa->req = req; 291 297 292 298 iw->which = READ_ONCE(sqe->len); 293 299 iw->upid = READ_ONCE(sqe->fd); ··· 305 299 int io_waitid(struct io_kiocb *req, unsigned int issue_flags) 306 300 { 307 301 struct io_waitid *iw = io_kiocb_to_cmd(req, struct io_waitid); 302 + struct io_waitid_async *iwa = req->async_data; 308 303 struct io_ring_ctx *ctx = req->ctx; 309 - struct io_waitid_async *iwa; 310 304 int ret; 311 - 312 - iwa = io_uring_alloc_async_data(NULL, req); 313 - if (!iwa) 314 - return -ENOMEM; 315 - 316 - iwa->req = req; 317 305 318 306 ret = kernel_waitid_prepare(&iwa->wo, iw->which, iw->upid, &iw->info, 319 307 iw->options, NULL);
+84 -50
kernel/acct.c
··· 103 103 atomic_long_t count; 104 104 struct rcu_head rcu; 105 105 struct mutex lock; 106 - int active; 106 + bool active; 107 + bool check_space; 107 108 unsigned long needcheck; 108 109 struct file *file; 109 110 struct pid_namespace *ns; 110 111 struct work_struct work; 111 112 struct completion done; 113 + acct_t ac; 112 114 }; 113 115 114 - static void do_acct_process(struct bsd_acct_struct *acct); 116 + static void fill_ac(struct bsd_acct_struct *acct); 117 + static void acct_write_process(struct bsd_acct_struct *acct); 115 118 116 119 /* 117 120 * Check the amount of free space and suspend/resume accordingly. 118 121 */ 119 - static int check_free_space(struct bsd_acct_struct *acct) 122 + static bool check_free_space(struct bsd_acct_struct *acct) 120 123 { 121 124 struct kstatfs sbuf; 122 125 123 - if (time_is_after_jiffies(acct->needcheck)) 124 - goto out; 126 + if (!acct->check_space) 127 + return acct->active; 125 128 126 129 /* May block */ 127 130 if (vfs_statfs(&acct->file->f_path, &sbuf)) 128 - goto out; 131 + return acct->active; 129 132 130 133 if (acct->active) { 131 134 u64 suspend = sbuf.f_blocks * SUSPEND; 132 135 do_div(suspend, 100); 133 136 if (sbuf.f_bavail <= suspend) { 134 - acct->active = 0; 137 + acct->active = false; 135 138 pr_info("Process accounting paused\n"); 136 139 } 137 140 } else { 138 141 u64 resume = sbuf.f_blocks * RESUME; 139 142 do_div(resume, 100); 140 143 if (sbuf.f_bavail >= resume) { 141 - acct->active = 1; 144 + acct->active = true; 142 145 pr_info("Process accounting resumed\n"); 143 146 } 144 147 } 145 148 146 149 acct->needcheck = jiffies + ACCT_TIMEOUT*HZ; 147 - out: 148 150 return acct->active; 149 151 } 150 152 ··· 191 189 { 192 190 struct bsd_acct_struct *acct = to_acct(pin); 193 191 mutex_lock(&acct->lock); 194 - do_acct_process(acct); 192 + /* 193 + * Fill the accounting struct with the exiting task's info 194 + * before punting to the workqueue. 195 + */ 196 + fill_ac(acct); 195 197 schedule_work(&acct->work); 196 198 wait_for_completion(&acct->done); 197 199 cmpxchg(&acct->ns->bacct, pin, NULL); ··· 208 202 { 209 203 struct bsd_acct_struct *acct = container_of(work, struct bsd_acct_struct, work); 210 204 struct file *file = acct->file; 205 + 206 + /* We were fired by acct_pin_kill() which holds acct->lock. */ 207 + acct_write_process(acct); 211 208 if (file->f_op->flush) 212 209 file->f_op->flush(file, NULL); 213 210 __fput_sync(file); ··· 241 232 kfree(acct); 242 233 filp_close(file, NULL); 243 234 return -EACCES; 235 + } 236 + 237 + /* Exclude kernel kernel internal filesystems. */ 238 + if (file_inode(file)->i_sb->s_flags & (SB_NOUSER | SB_KERNMOUNT)) { 239 + kfree(acct); 240 + filp_close(file, NULL); 241 + return -EINVAL; 242 + } 243 + 244 + /* Exclude procfs and sysfs. */ 245 + if (file_inode(file)->i_sb->s_iflags & SB_I_USERNS_VISIBLE) { 246 + kfree(acct); 247 + filp_close(file, NULL); 248 + return -EINVAL; 244 249 } 245 250 246 251 if (!(file->f_mode & FMODE_CAN_WRITE)) { ··· 453 430 * do_exit() or when switching to a different output file. 454 431 */ 455 432 456 - static void fill_ac(acct_t *ac) 433 + static void fill_ac(struct bsd_acct_struct *acct) 457 434 { 458 435 struct pacct_struct *pacct = &current->signal->pacct; 436 + struct file *file = acct->file; 437 + acct_t *ac = &acct->ac; 459 438 u64 elapsed, run_time; 460 439 time64_t btime; 461 440 struct tty_struct *tty; 441 + 442 + lockdep_assert_held(&acct->lock); 443 + 444 + if (time_is_after_jiffies(acct->needcheck)) { 445 + acct->check_space = false; 446 + 447 + /* Don't fill in @ac if nothing will be written. */ 448 + if (!acct->active) 449 + return; 450 + } else { 451 + acct->check_space = true; 452 + } 462 453 463 454 /* 464 455 * Fill the accounting struct with the needed info as recorded ··· 521 484 ac->ac_majflt = encode_comp_t(pacct->ac_majflt); 522 485 ac->ac_exitcode = pacct->ac_exitcode; 523 486 spin_unlock_irq(&current->sighand->siglock); 524 - } 525 - /* 526 - * do_acct_process does all actual work. Caller holds the reference to file. 527 - */ 528 - static void do_acct_process(struct bsd_acct_struct *acct) 529 - { 530 - acct_t ac; 531 - unsigned long flim; 532 - const struct cred *orig_cred; 533 - struct file *file = acct->file; 534 487 535 - /* 536 - * Accounting records are not subject to resource limits. 537 - */ 538 - flim = rlimit(RLIMIT_FSIZE); 539 - current->signal->rlim[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY; 540 - /* Perform file operations on behalf of whoever enabled accounting */ 541 - orig_cred = override_creds(file->f_cred); 542 - 543 - /* 544 - * First check to see if there is enough free_space to continue 545 - * the process accounting system. 546 - */ 547 - if (!check_free_space(acct)) 548 - goto out; 549 - 550 - fill_ac(&ac); 551 488 /* we really need to bite the bullet and change layout */ 552 - ac.ac_uid = from_kuid_munged(file->f_cred->user_ns, orig_cred->uid); 553 - ac.ac_gid = from_kgid_munged(file->f_cred->user_ns, orig_cred->gid); 489 + ac->ac_uid = from_kuid_munged(file->f_cred->user_ns, current_uid()); 490 + ac->ac_gid = from_kgid_munged(file->f_cred->user_ns, current_gid()); 554 491 #if ACCT_VERSION == 1 || ACCT_VERSION == 2 555 492 /* backward-compatible 16 bit fields */ 556 - ac.ac_uid16 = ac.ac_uid; 557 - ac.ac_gid16 = ac.ac_gid; 493 + ac->ac_uid16 = ac->ac_uid; 494 + ac->ac_gid16 = ac->ac_gid; 558 495 #elif ACCT_VERSION == 3 559 496 { 560 497 struct pid_namespace *ns = acct->ns; 561 498 562 - ac.ac_pid = task_tgid_nr_ns(current, ns); 499 + ac->ac_pid = task_tgid_nr_ns(current, ns); 563 500 rcu_read_lock(); 564 - ac.ac_ppid = task_tgid_nr_ns(rcu_dereference(current->real_parent), 565 - ns); 501 + ac->ac_ppid = task_tgid_nr_ns(rcu_dereference(current->real_parent), ns); 566 502 rcu_read_unlock(); 567 503 } 568 504 #endif 505 + } 506 + 507 + static void acct_write_process(struct bsd_acct_struct *acct) 508 + { 509 + struct file *file = acct->file; 510 + const struct cred *cred; 511 + acct_t *ac = &acct->ac; 512 + 513 + /* Perform file operations on behalf of whoever enabled accounting */ 514 + cred = override_creds(file->f_cred); 515 + 569 516 /* 570 - * Get freeze protection. If the fs is frozen, just skip the write 571 - * as we could deadlock the system otherwise. 517 + * First check to see if there is enough free_space to continue 518 + * the process accounting system. Then get freeze protection. If 519 + * the fs is frozen, just skip the write as we could deadlock 520 + * the system otherwise. 572 521 */ 573 - if (file_start_write_trylock(file)) { 522 + if (check_free_space(acct) && file_start_write_trylock(file)) { 574 523 /* it's been opened O_APPEND, so position is irrelevant */ 575 524 loff_t pos = 0; 576 - __kernel_write(file, &ac, sizeof(acct_t), &pos); 525 + __kernel_write(file, ac, sizeof(acct_t), &pos); 577 526 file_end_write(file); 578 527 } 579 - out: 528 + 529 + revert_creds(cred); 530 + } 531 + 532 + static void do_acct_process(struct bsd_acct_struct *acct) 533 + { 534 + unsigned long flim; 535 + 536 + /* Accounting records are not subject to resource limits. */ 537 + flim = rlimit(RLIMIT_FSIZE); 538 + current->signal->rlim[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY; 539 + fill_ac(acct); 540 + acct_write_process(acct); 580 541 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = flim; 581 - revert_creds(orig_cred); 582 542 } 583 543 584 544 /**
+12 -8
kernel/cgroup/cgroup.c
··· 4013 4013 lockdep_assert_held(&cgroup_mutex); 4014 4014 4015 4015 spin_lock_irq(&css_set_lock); 4016 - set_bit(CGRP_KILL, &cgrp->flags); 4016 + cgrp->kill_seq++; 4017 4017 spin_unlock_irq(&css_set_lock); 4018 4018 4019 4019 css_task_iter_start(&cgrp->self, CSS_TASK_ITER_PROCS | CSS_TASK_ITER_THREADED, &it); ··· 4029 4029 send_sig(SIGKILL, task, 0); 4030 4030 } 4031 4031 css_task_iter_end(&it); 4032 - 4033 - spin_lock_irq(&css_set_lock); 4034 - clear_bit(CGRP_KILL, &cgrp->flags); 4035 - spin_unlock_irq(&css_set_lock); 4036 4032 } 4037 4033 4038 4034 static void cgroup_kill(struct cgroup *cgrp) ··· 6484 6488 spin_lock_irq(&css_set_lock); 6485 6489 cset = task_css_set(current); 6486 6490 get_css_set(cset); 6491 + if (kargs->cgrp) 6492 + kargs->kill_seq = kargs->cgrp->kill_seq; 6493 + else 6494 + kargs->kill_seq = cset->dfl_cgrp->kill_seq; 6487 6495 spin_unlock_irq(&css_set_lock); 6488 6496 6489 6497 if (!(kargs->flags & CLONE_INTO_CGROUP)) { ··· 6668 6668 struct kernel_clone_args *kargs) 6669 6669 __releases(&cgroup_threadgroup_rwsem) __releases(&cgroup_mutex) 6670 6670 { 6671 + unsigned int cgrp_kill_seq = 0; 6671 6672 unsigned long cgrp_flags = 0; 6672 6673 bool kill = false; 6673 6674 struct cgroup_subsys *ss; ··· 6682 6681 6683 6682 /* init tasks are special, only link regular threads */ 6684 6683 if (likely(child->pid)) { 6685 - if (kargs->cgrp) 6684 + if (kargs->cgrp) { 6686 6685 cgrp_flags = kargs->cgrp->flags; 6687 - else 6686 + cgrp_kill_seq = kargs->cgrp->kill_seq; 6687 + } else { 6688 6688 cgrp_flags = cset->dfl_cgrp->flags; 6689 + cgrp_kill_seq = cset->dfl_cgrp->kill_seq; 6690 + } 6689 6691 6690 6692 WARN_ON_ONCE(!list_empty(&child->cg_list)); 6691 6693 cset->nr_tasks++; ··· 6723 6719 * child down right after we finished preparing it for 6724 6720 * userspace. 6725 6721 */ 6726 - kill = test_bit(CGRP_KILL, &cgrp_flags); 6722 + kill = kargs->kill_seq != cgrp_kill_seq; 6727 6723 } 6728 6724 6729 6725 spin_unlock_irq(&css_set_lock);
-1
kernel/cgroup/rstat.c
··· 590 590 591 591 cputime->sum_exec_runtime += user; 592 592 cputime->sum_exec_runtime += sys; 593 - cputime->sum_exec_runtime += cpustat[CPUTIME_STEAL]; 594 593 595 594 #ifdef CONFIG_SCHED_CORE 596 595 bstat->forceidle_sum += cpustat[CPUTIME_FORCEIDLE];
-4
kernel/irq/Kconfig
··· 31 31 config GENERIC_PENDING_IRQ 32 32 bool 33 33 34 - # Deduce delayed migration from top-level interrupt chip flags 35 - config GENERIC_PENDING_IRQ_CHIPFLAGS 36 - bool 37 - 38 34 # Support for generic irq migrating off cpu before the cpu is offline. 39 35 config GENERIC_IRQ_MIGRATION 40 36 bool
+2 -2
kernel/sched/autogroup.c
··· 150 150 * see this thread after that: we can no longer use signal->autogroup. 151 151 * See the PF_EXITING check in task_wants_autogroup(). 152 152 */ 153 - sched_move_task(p); 153 + sched_move_task(p, true); 154 154 } 155 155 156 156 static void ··· 182 182 * sched_autogroup_exit_task(). 183 183 */ 184 184 for_each_thread(p, t) 185 - sched_move_task(t); 185 + sched_move_task(t, true); 186 186 187 187 unlock_task_sighand(p, &flags); 188 188 autogroup_kref_put(prev);
+7 -5
kernel/sched/core.c
··· 1063 1063 struct task_struct *task; 1064 1064 1065 1065 task = container_of(node, struct task_struct, wake_q); 1066 - /* Task can safely be re-inserted now: */ 1067 1066 node = node->next; 1068 - task->wake_q.next = NULL; 1067 + /* pairs with cmpxchg_relaxed() in __wake_q_add() */ 1068 + WRITE_ONCE(task->wake_q.next, NULL); 1069 + /* Task can safely be re-inserted now. */ 1069 1070 1070 1071 /* 1071 1072 * wake_up_process() executes a full barrier, which pairs with ··· 9051 9050 * now. This function just updates tsk->se.cfs_rq and tsk->se.parent to reflect 9052 9051 * its new group. 9053 9052 */ 9054 - void sched_move_task(struct task_struct *tsk) 9053 + void sched_move_task(struct task_struct *tsk, bool for_autogroup) 9055 9054 { 9056 9055 int queued, running, queue_flags = 9057 9056 DEQUEUE_SAVE | DEQUEUE_MOVE | DEQUEUE_NOCLOCK; ··· 9080 9079 put_prev_task(rq, tsk); 9081 9080 9082 9081 sched_change_group(tsk, group); 9083 - scx_move_task(tsk); 9082 + if (!for_autogroup) 9083 + scx_cgroup_move_task(tsk); 9084 9084 9085 9085 if (queued) 9086 9086 enqueue_task(rq, tsk, queue_flags); ··· 9182 9180 struct cgroup_subsys_state *css; 9183 9181 9184 9182 cgroup_taskset_for_each(task, css, tset) 9185 - sched_move_task(task); 9183 + sched_move_task(task, false); 9186 9184 9187 9185 scx_cgroup_finish_attach(); 9188 9186 }
+76 -37
kernel/sched/ext.c
··· 123 123 SCX_OPS_SWITCH_PARTIAL = 1LLU << 3, 124 124 125 125 /* 126 + * A migration disabled task can only execute on its current CPU. By 127 + * default, such tasks are automatically put on the CPU's local DSQ with 128 + * the default slice on enqueue. If this ops flag is set, they also go 129 + * through ops.enqueue(). 130 + * 131 + * A migration disabled task never invokes ops.select_cpu() as it can 132 + * only select the current CPU. Also, p->cpus_ptr will only contain its 133 + * current CPU while p->nr_cpus_allowed keeps tracking p->user_cpus_ptr 134 + * and thus may disagree with cpumask_weight(p->cpus_ptr). 135 + */ 136 + SCX_OPS_ENQ_MIGRATION_DISABLED = 1LLU << 4, 137 + 138 + /* 126 139 * CPU cgroup support flags 127 140 */ 128 141 SCX_OPS_HAS_CGROUP_WEIGHT = 1LLU << 16, /* cpu.weight */ ··· 143 130 SCX_OPS_ALL_FLAGS = SCX_OPS_KEEP_BUILTIN_IDLE | 144 131 SCX_OPS_ENQ_LAST | 145 132 SCX_OPS_ENQ_EXITING | 133 + SCX_OPS_ENQ_MIGRATION_DISABLED | 146 134 SCX_OPS_SWITCH_PARTIAL | 147 135 SCX_OPS_HAS_CGROUP_WEIGHT, 148 136 }; ··· 430 416 431 417 /** 432 418 * @update_idle: Update the idle state of a CPU 433 - * @cpu: CPU to udpate the idle state for 419 + * @cpu: CPU to update the idle state for 434 420 * @idle: whether entering or exiting the idle state 435 421 * 436 422 * This operation is called when @rq's CPU goes or leaves the idle ··· 896 882 897 883 static DEFINE_STATIC_KEY_FALSE(scx_ops_enq_last); 898 884 static DEFINE_STATIC_KEY_FALSE(scx_ops_enq_exiting); 885 + static DEFINE_STATIC_KEY_FALSE(scx_ops_enq_migration_disabled); 899 886 static DEFINE_STATIC_KEY_FALSE(scx_ops_cpu_preempt); 900 887 static DEFINE_STATIC_KEY_FALSE(scx_builtin_idle_enabled); 901 888 ··· 1229 1214 1230 1215 /** 1231 1216 * nldsq_next_task - Iterate to the next task in a non-local DSQ 1232 - * @dsq: user dsq being interated 1217 + * @dsq: user dsq being iterated 1233 1218 * @cur: current position, %NULL to start iteration 1234 1219 * @rev: walk backwards 1235 1220 * ··· 2029 2014 unlikely(p->flags & PF_EXITING)) 2030 2015 goto local; 2031 2016 2017 + /* see %SCX_OPS_ENQ_MIGRATION_DISABLED */ 2018 + if (!static_branch_unlikely(&scx_ops_enq_migration_disabled) && 2019 + is_migration_disabled(p)) 2020 + goto local; 2021 + 2032 2022 if (!SCX_HAS_OP(enqueue)) 2033 2023 goto global; 2034 2024 ··· 2098 2078 2099 2079 /* 2100 2080 * list_add_tail() must be used. scx_ops_bypass() depends on tasks being 2101 - * appened to the runnable_list. 2081 + * appended to the runnable_list. 2102 2082 */ 2103 2083 list_add_tail(&p->scx.runnable_node, &rq->scx.runnable_list); 2104 2084 } ··· 2333 2313 * 2334 2314 * - The BPF scheduler is bypassed while the rq is offline and we can always say 2335 2315 * no to the BPF scheduler initiated migrations while offline. 2316 + * 2317 + * The caller must ensure that @p and @rq are on different CPUs. 2336 2318 */ 2337 2319 static bool task_can_run_on_remote_rq(struct task_struct *p, struct rq *rq, 2338 2320 bool trigger_error) 2339 2321 { 2340 2322 int cpu = cpu_of(rq); 2323 + 2324 + SCHED_WARN_ON(task_cpu(p) == cpu); 2325 + 2326 + /* 2327 + * If @p has migration disabled, @p->cpus_ptr is updated to contain only 2328 + * the pinned CPU in migrate_disable_switch() while @p is being switched 2329 + * out. However, put_prev_task_scx() is called before @p->cpus_ptr is 2330 + * updated and thus another CPU may see @p on a DSQ inbetween leading to 2331 + * @p passing the below task_allowed_on_cpu() check while migration is 2332 + * disabled. 2333 + * 2334 + * Test the migration disabled state first as the race window is narrow 2335 + * and the BPF scheduler failing to check migration disabled state can 2336 + * easily be masked if task_allowed_on_cpu() is done first. 2337 + */ 2338 + if (unlikely(is_migration_disabled(p))) { 2339 + if (trigger_error) 2340 + scx_ops_error("SCX_DSQ_LOCAL[_ON] cannot move migration disabled %s[%d] from CPU %d to %d", 2341 + p->comm, p->pid, task_cpu(p), cpu); 2342 + return false; 2343 + } 2341 2344 2342 2345 /* 2343 2346 * We don't require the BPF scheduler to avoid dispatching to offline ··· 2370 2327 */ 2371 2328 if (!task_allowed_on_cpu(p, cpu)) { 2372 2329 if (trigger_error) 2373 - scx_ops_error("SCX_DSQ_LOCAL[_ON] verdict target cpu %d not allowed for %s[%d]", 2374 - cpu_of(rq), p->comm, p->pid); 2330 + scx_ops_error("SCX_DSQ_LOCAL[_ON] target CPU %d not allowed for %s[%d]", 2331 + cpu, p->comm, p->pid); 2375 2332 return false; 2376 2333 } 2377 - 2378 - if (unlikely(is_migration_disabled(p))) 2379 - return false; 2380 2334 2381 2335 if (!scx_rq_online(rq)) 2382 2336 return false; ··· 2477 2437 2478 2438 if (dst_dsq->id == SCX_DSQ_LOCAL) { 2479 2439 dst_rq = container_of(dst_dsq, struct rq, scx.local_dsq); 2480 - if (!task_can_run_on_remote_rq(p, dst_rq, true)) { 2440 + if (src_rq != dst_rq && 2441 + unlikely(!task_can_run_on_remote_rq(p, dst_rq, true))) { 2481 2442 dst_dsq = find_global_dsq(p); 2482 2443 dst_rq = src_rq; 2483 2444 } ··· 2521 2480 /* 2522 2481 * A poorly behaving BPF scheduler can live-lock the system by e.g. incessantly 2523 2482 * banging on the same DSQ on a large NUMA system to the point where switching 2524 - * to the bypass mode can take a long time. Inject artifical delays while the 2483 + * to the bypass mode can take a long time. Inject artificial delays while the 2525 2484 * bypass mode is switching to guarantee timely completion. 2526 2485 */ 2527 2486 static void scx_ops_breather(struct rq *rq) ··· 2616 2575 { 2617 2576 struct rq *src_rq = task_rq(p); 2618 2577 struct rq *dst_rq = container_of(dst_dsq, struct rq, scx.local_dsq); 2578 + #ifdef CONFIG_SMP 2579 + struct rq *locked_rq = rq; 2580 + #endif 2619 2581 2620 2582 /* 2621 2583 * We're synchronized against dequeue through DISPATCHING. As @p can't ··· 2632 2588 } 2633 2589 2634 2590 #ifdef CONFIG_SMP 2635 - if (unlikely(!task_can_run_on_remote_rq(p, dst_rq, true))) { 2591 + if (src_rq != dst_rq && 2592 + unlikely(!task_can_run_on_remote_rq(p, dst_rq, true))) { 2636 2593 dispatch_enqueue(find_global_dsq(p), p, 2637 2594 enq_flags | SCX_ENQ_CLEAR_OPSS); 2638 2595 return; ··· 2656 2611 atomic_long_set_release(&p->scx.ops_state, SCX_OPSS_NONE); 2657 2612 2658 2613 /* switch to @src_rq lock */ 2659 - if (rq != src_rq) { 2660 - raw_spin_rq_unlock(rq); 2614 + if (locked_rq != src_rq) { 2615 + raw_spin_rq_unlock(locked_rq); 2616 + locked_rq = src_rq; 2661 2617 raw_spin_rq_lock(src_rq); 2662 2618 } 2663 2619 ··· 2676 2630 } else { 2677 2631 move_remote_task_to_local_dsq(p, enq_flags, 2678 2632 src_rq, dst_rq); 2633 + /* task has been moved to dst_rq, which is now locked */ 2634 + locked_rq = dst_rq; 2679 2635 } 2680 2636 2681 2637 /* if the destination CPU is idle, wake it up */ ··· 2686 2638 } 2687 2639 2688 2640 /* switch back to @rq lock */ 2689 - if (rq != dst_rq) { 2690 - raw_spin_rq_unlock(dst_rq); 2641 + if (locked_rq != rq) { 2642 + raw_spin_rq_unlock(locked_rq); 2691 2643 raw_spin_rq_lock(rq); 2692 2644 } 2693 2645 #else /* CONFIG_SMP */ ··· 3192 3144 * 3193 3145 * Unless overridden by ops.core_sched_before(), @p->scx.core_sched_at is used 3194 3146 * to implement the default task ordering. The older the timestamp, the higher 3195 - * prority the task - the global FIFO ordering matching the default scheduling 3147 + * priority the task - the global FIFO ordering matching the default scheduling 3196 3148 * behavior. 3197 3149 * 3198 3150 * When ops.core_sched_before() is enabled, @p->scx.core_sched_at is used to ··· 3899 3851 curr->scx.slice = 0; 3900 3852 touch_core_sched(rq, curr); 3901 3853 } else if (SCX_HAS_OP(tick)) { 3902 - SCX_CALL_OP(SCX_KF_REST, tick, curr); 3854 + SCX_CALL_OP_TASK(SCX_KF_REST, tick, curr); 3903 3855 } 3904 3856 3905 3857 if (!curr->scx.slice) ··· 4046 3998 WARN_ON_ONCE(scx_get_task_state(p) != SCX_TASK_ENABLED); 4047 3999 4048 4000 if (SCX_HAS_OP(disable)) 4049 - SCX_CALL_OP(SCX_KF_REST, disable, p); 4001 + SCX_CALL_OP_TASK(SCX_KF_REST, disable, p); 4050 4002 scx_set_task_state(p, SCX_TASK_READY); 4051 4003 } 4052 4004 ··· 4075 4027 } 4076 4028 4077 4029 if (SCX_HAS_OP(exit_task)) 4078 - SCX_CALL_OP(SCX_KF_REST, exit_task, p, &args); 4030 + SCX_CALL_OP_TASK(SCX_KF_REST, exit_task, p, &args); 4079 4031 scx_set_task_state(p, SCX_TASK_NONE); 4080 4032 } 4081 4033 ··· 4371 4323 return ops_sanitize_err("cgroup_prep_move", ret); 4372 4324 } 4373 4325 4374 - void scx_move_task(struct task_struct *p) 4326 + void scx_cgroup_move_task(struct task_struct *p) 4375 4327 { 4376 4328 if (!scx_cgroup_enabled) 4377 - return; 4378 - 4379 - /* 4380 - * We're called from sched_move_task() which handles both cgroup and 4381 - * autogroup moves. Ignore the latter. 4382 - * 4383 - * Also ignore exiting tasks, because in the exit path tasks transition 4384 - * from the autogroup to the root group, so task_group_is_autogroup() 4385 - * alone isn't able to catch exiting autogroup tasks. This is safe for 4386 - * cgroup_move(), because cgroup migrations never happen for PF_EXITING 4387 - * tasks. 4388 - */ 4389 - if (task_group_is_autogroup(task_group(p)) || (p->flags & PF_EXITING)) 4390 4329 return; 4391 4330 4392 4331 /* ··· 4625 4590 cgroup_warned_missing_idle = false; 4626 4591 4627 4592 /* 4628 - * scx_tg_on/offline() are excluded thorugh scx_cgroup_rwsem. If we walk 4593 + * scx_tg_on/offline() are excluded through scx_cgroup_rwsem. If we walk 4629 4594 * cgroups and init, all online cgroups are initialized. 4630 4595 */ 4631 4596 rcu_read_lock(); ··· 5094 5059 static_branch_disable(&scx_has_op[i]); 5095 5060 static_branch_disable(&scx_ops_enq_last); 5096 5061 static_branch_disable(&scx_ops_enq_exiting); 5062 + static_branch_disable(&scx_ops_enq_migration_disabled); 5097 5063 static_branch_disable(&scx_ops_cpu_preempt); 5098 5064 static_branch_disable(&scx_builtin_idle_enabled); 5099 5065 synchronize_rcu(); ··· 5313 5277 scx_get_task_state(p), p->scx.flags & ~SCX_TASK_STATE_MASK, 5314 5278 p->scx.dsq_flags, ops_state & SCX_OPSS_STATE_MASK, 5315 5279 ops_state >> SCX_OPSS_QSEQ_SHIFT); 5316 - dump_line(s, " sticky/holding_cpu=%d/%d dsq_id=%s dsq_vtime=%llu slice=%llu", 5317 - p->scx.sticky_cpu, p->scx.holding_cpu, dsq_id_buf, 5318 - p->scx.dsq_vtime, p->scx.slice); 5280 + dump_line(s, " sticky/holding_cpu=%d/%d dsq_id=%s", 5281 + p->scx.sticky_cpu, p->scx.holding_cpu, dsq_id_buf); 5282 + dump_line(s, " dsq_vtime=%llu slice=%llu weight=%u", 5283 + p->scx.dsq_vtime, p->scx.slice, p->scx.weight); 5319 5284 dump_line(s, " cpus=%*pb", cpumask_pr_args(p->cpus_ptr)); 5320 5285 5321 5286 if (SCX_HAS_OP(dump_task)) { ··· 5704 5667 5705 5668 if (ops->flags & SCX_OPS_ENQ_EXITING) 5706 5669 static_branch_enable(&scx_ops_enq_exiting); 5670 + if (ops->flags & SCX_OPS_ENQ_MIGRATION_DISABLED) 5671 + static_branch_enable(&scx_ops_enq_migration_disabled); 5707 5672 if (scx_ops.cpu_acquire || scx_ops.cpu_release) 5708 5673 static_branch_enable(&scx_ops_cpu_preempt); 5709 5674
+2 -2
kernel/sched/ext.h
··· 73 73 int scx_tg_online(struct task_group *tg); 74 74 void scx_tg_offline(struct task_group *tg); 75 75 int scx_cgroup_can_attach(struct cgroup_taskset *tset); 76 - void scx_move_task(struct task_struct *p); 76 + void scx_cgroup_move_task(struct task_struct *p); 77 77 void scx_cgroup_finish_attach(void); 78 78 void scx_cgroup_cancel_attach(struct cgroup_taskset *tset); 79 79 void scx_group_set_weight(struct task_group *tg, unsigned long cgrp_weight); ··· 82 82 static inline int scx_tg_online(struct task_group *tg) { return 0; } 83 83 static inline void scx_tg_offline(struct task_group *tg) {} 84 84 static inline int scx_cgroup_can_attach(struct cgroup_taskset *tset) { return 0; } 85 - static inline void scx_move_task(struct task_struct *p) {} 85 + static inline void scx_cgroup_move_task(struct task_struct *p) {} 86 86 static inline void scx_cgroup_finish_attach(void) {} 87 87 static inline void scx_cgroup_cancel_attach(struct cgroup_taskset *tset) {} 88 88 static inline void scx_group_set_weight(struct task_group *tg, unsigned long cgrp_weight) {}
+1 -1
kernel/sched/sched.h
··· 572 572 extern void sched_destroy_group(struct task_group *tg); 573 573 extern void sched_release_group(struct task_group *tg); 574 574 575 - extern void sched_move_task(struct task_struct *tsk); 575 + extern void sched_move_task(struct task_struct *tsk, bool for_autogroup); 576 576 577 577 #ifdef CONFIG_FAIR_GROUP_SCHED 578 578 extern int sched_group_set_shares(struct task_group *tg, unsigned long shares);
+26 -2
kernel/trace/ring_buffer.c
··· 1672 1672 * must be the same. 1673 1673 */ 1674 1674 static bool rb_meta_valid(struct ring_buffer_meta *meta, int cpu, 1675 - struct trace_buffer *buffer, int nr_pages) 1675 + struct trace_buffer *buffer, int nr_pages, 1676 + unsigned long *subbuf_mask) 1676 1677 { 1677 1678 int subbuf_size = PAGE_SIZE; 1678 1679 struct buffer_data_page *subbuf; 1679 1680 unsigned long buffers_start; 1680 1681 unsigned long buffers_end; 1681 1682 int i; 1683 + 1684 + if (!subbuf_mask) 1685 + return false; 1682 1686 1683 1687 /* Check the meta magic and meta struct size */ 1684 1688 if (meta->magic != RING_BUFFER_META_MAGIC || ··· 1716 1712 1717 1713 subbuf = rb_subbufs_from_meta(meta); 1718 1714 1715 + bitmap_clear(subbuf_mask, 0, meta->nr_subbufs); 1716 + 1719 1717 /* Is the meta buffers and the subbufs themselves have correct data? */ 1720 1718 for (i = 0; i < meta->nr_subbufs; i++) { 1721 1719 if (meta->buffers[i] < 0 || ··· 1731 1725 return false; 1732 1726 } 1733 1727 1728 + if (test_bit(meta->buffers[i], subbuf_mask)) { 1729 + pr_info("Ring buffer boot meta [%d] array has duplicates\n", cpu); 1730 + return false; 1731 + } 1732 + 1733 + set_bit(meta->buffers[i], subbuf_mask); 1734 1734 subbuf = (void *)subbuf + subbuf_size; 1735 1735 } 1736 1736 ··· 1850 1838 cpu_buffer->cpu); 1851 1839 goto invalid; 1852 1840 } 1841 + 1842 + /* If the buffer has content, update pages_touched */ 1843 + if (ret) 1844 + local_inc(&cpu_buffer->pages_touched); 1845 + 1853 1846 entries += ret; 1854 1847 entry_bytes += local_read(&head_page->page->commit); 1855 1848 local_set(&cpu_buffer->head_page->entries, ret); ··· 1906 1889 static void rb_range_meta_init(struct trace_buffer *buffer, int nr_pages) 1907 1890 { 1908 1891 struct ring_buffer_meta *meta; 1892 + unsigned long *subbuf_mask; 1909 1893 unsigned long delta; 1910 1894 void *subbuf; 1911 1895 int cpu; 1912 1896 int i; 1897 + 1898 + /* Create a mask to test the subbuf array */ 1899 + subbuf_mask = bitmap_alloc(nr_pages + 1, GFP_KERNEL); 1900 + /* If subbuf_mask fails to allocate, then rb_meta_valid() will return false */ 1913 1901 1914 1902 for (cpu = 0; cpu < nr_cpu_ids; cpu++) { 1915 1903 void *next_meta; 1916 1904 1917 1905 meta = rb_range_meta(buffer, nr_pages, cpu); 1918 1906 1919 - if (rb_meta_valid(meta, cpu, buffer, nr_pages)) { 1907 + if (rb_meta_valid(meta, cpu, buffer, nr_pages, subbuf_mask)) { 1920 1908 /* Make the mappings match the current address */ 1921 1909 subbuf = rb_subbufs_from_meta(meta); 1922 1910 delta = (unsigned long)subbuf - meta->first_buffer; ··· 1965 1943 subbuf += meta->subbuf_size; 1966 1944 } 1967 1945 } 1946 + bitmap_free(subbuf_mask); 1968 1947 } 1969 1948 1970 1949 static void *rbm_start(struct seq_file *m, loff_t *pos) ··· 7149 7126 kfree(cpu_buffer->subbuf_ids); 7150 7127 cpu_buffer->subbuf_ids = NULL; 7151 7128 rb_free_meta_page(cpu_buffer); 7129 + atomic_dec(&cpu_buffer->resize_disabled); 7152 7130 } 7153 7131 7154 7132 unlock:
+5 -7
kernel/trace/trace.c
··· 5977 5977 ssize_t tracing_resize_ring_buffer(struct trace_array *tr, 5978 5978 unsigned long size, int cpu_id) 5979 5979 { 5980 - int ret; 5981 - 5982 5980 guard(mutex)(&trace_types_lock); 5983 5981 5984 5982 if (cpu_id != RING_BUFFER_ALL_CPUS) { ··· 5985 5987 return -EINVAL; 5986 5988 } 5987 5989 5988 - ret = __tracing_resize_ring_buffer(tr, size, cpu_id); 5989 - if (ret < 0) 5990 - ret = -ENOMEM; 5991 - 5992 - return ret; 5990 + return __tracing_resize_ring_buffer(tr, size, cpu_id); 5993 5991 } 5994 5992 5995 5993 static void update_last_data(struct trace_array *tr) ··· 8278 8284 struct ftrace_buffer_info *info = filp->private_data; 8279 8285 struct trace_iterator *iter = &info->iter; 8280 8286 int ret = 0; 8287 + 8288 + /* Currently the boot mapped buffer is not supported for mmap */ 8289 + if (iter->tr->flags & TRACE_ARRAY_FL_BOOT) 8290 + return -ENODEV; 8281 8291 8282 8292 ret = get_snapshot_map(iter->tr); 8283 8293 if (ret)
+6 -6
kernel/workqueue.c
··· 3517 3517 } 3518 3518 3519 3519 /* 3520 - * Put the reference grabbed by send_mayday(). @pool won't 3521 - * go away while we're still attached to it. 3522 - */ 3523 - put_pwq(pwq); 3524 - 3525 - /* 3526 3520 * Leave this pool. Notify regular workers; otherwise, we end up 3527 3521 * with 0 concurrency and stalling the execution. 3528 3522 */ ··· 3525 3531 raw_spin_unlock_irq(&pool->lock); 3526 3532 3527 3533 worker_detach_from_pool(rescuer); 3534 + 3535 + /* 3536 + * Put the reference grabbed by send_mayday(). @pool might 3537 + * go away any time after it. 3538 + */ 3539 + put_pwq_unlocked(pwq); 3528 3540 3529 3541 raw_spin_lock_irq(&wq_mayday_lock); 3530 3542 }
+2 -1
lib/iov_iter.c
··· 1428 1428 struct iovec *iov = *iovp; 1429 1429 ssize_t ret; 1430 1430 1431 + *iovp = NULL; 1432 + 1431 1433 if (compat) 1432 1434 ret = copy_compat_iovec_from_user(iov, uvec, 1); 1433 1435 else ··· 1440 1438 ret = import_ubuf(type, iov->iov_base, iov->iov_len, i); 1441 1439 if (unlikely(ret)) 1442 1440 return ret; 1443 - *iovp = NULL; 1444 1441 return i->count; 1445 1442 } 1446 1443
+8 -7
lib/test_xarray.c
··· 1418 1418 { 1419 1419 XA_STATE(xas, xa, 0); 1420 1420 void *entry; 1421 - unsigned int order; 1421 + int order; 1422 1422 unsigned long index = 1; 1423 1423 unsigned int count = 0; 1424 1424 ··· 1450 1450 xa_destroy(xa); 1451 1451 1452 1452 index = 0; 1453 - for (order = XA_CHUNK_SHIFT; order > 0; order--) { 1453 + for (order = order_limit - 1; order >= 0; order--) { 1454 1454 XA_BUG_ON(xa, xa_store_order(xa, index, order, 1455 1455 xa_mk_index(index), GFP_KERNEL)); 1456 1456 index += 1UL << order; ··· 1462 1462 rcu_read_lock(); 1463 1463 xas_for_each(&xas, entry, ULONG_MAX) { 1464 1464 XA_BUG_ON(xa, entry != xa_mk_index(index)); 1465 - index += 1UL << (XA_CHUNK_SHIFT - count); 1465 + index += 1UL << (order_limit - count - 1); 1466 1466 count++; 1467 1467 } 1468 1468 rcu_read_unlock(); 1469 - XA_BUG_ON(xa, count != XA_CHUNK_SHIFT); 1469 + XA_BUG_ON(xa, count != order_limit); 1470 1470 1471 1471 index = 0; 1472 1472 count = 0; 1473 - xas_set(&xas, XA_CHUNK_SIZE / 2 + 1); 1473 + /* test unaligned index */ 1474 + xas_set(&xas, 1 % (1UL << (order_limit - 1))); 1474 1475 rcu_read_lock(); 1475 1476 xas_for_each(&xas, entry, ULONG_MAX) { 1476 1477 XA_BUG_ON(xa, entry != xa_mk_index(index)); 1477 - index += 1UL << (XA_CHUNK_SHIFT - count); 1478 + index += 1UL << (order_limit - count - 1); 1478 1479 count++; 1479 1480 xas_pause(&xas); 1480 1481 } 1481 1482 rcu_read_unlock(); 1482 - XA_BUG_ON(xa, count != XA_CHUNK_SHIFT); 1483 + XA_BUG_ON(xa, count != order_limit); 1483 1484 1484 1485 xa_destroy(xa); 1485 1486
+1 -1
mm/hugetlb.c
··· 3145 3145 3146 3146 /* do node specific alloc */ 3147 3147 if (nid != NUMA_NO_NODE) { 3148 - m = memblock_alloc_try_nid_raw(huge_page_size(h), huge_page_size(h), 3148 + m = memblock_alloc_exact_nid_raw(huge_page_size(h), huge_page_size(h), 3149 3149 0, MEMBLOCK_ALLOC_ACCESSIBLE, nid); 3150 3150 if (!m) 3151 3151 return 0;
+33 -1
mm/kasan/report.c
··· 370 370 sizeof(init_thread_union.stack)); 371 371 } 372 372 373 + /* 374 + * This function is invoked with report_lock (a raw_spinlock) held. A 375 + * PREEMPT_RT kernel cannot call find_vm_area() as it will acquire a sleeping 376 + * rt_spinlock. 377 + * 378 + * For !RT kernel, the PROVE_RAW_LOCK_NESTING config option will print a 379 + * lockdep warning for this raw_spinlock -> spinlock dependency. This config 380 + * option is enabled by default to ensure better test coverage to expose this 381 + * kind of RT kernel problem. This lockdep splat, however, can be suppressed 382 + * by using DEFINE_WAIT_OVERRIDE_MAP() if it serves a useful purpose and the 383 + * invalid PREEMPT_RT case has been taken care of. 384 + */ 385 + static inline struct vm_struct *kasan_find_vm_area(void *addr) 386 + { 387 + static DEFINE_WAIT_OVERRIDE_MAP(vmalloc_map, LD_WAIT_SLEEP); 388 + struct vm_struct *va; 389 + 390 + if (IS_ENABLED(CONFIG_PREEMPT_RT)) 391 + return NULL; 392 + 393 + /* 394 + * Suppress lockdep warning and fetch vmalloc area of the 395 + * offending address. 396 + */ 397 + lock_map_acquire_try(&vmalloc_map); 398 + va = find_vm_area(addr); 399 + lock_map_release(&vmalloc_map); 400 + return va; 401 + } 402 + 373 403 static void print_address_description(void *addr, u8 tag, 374 404 struct kasan_report_info *info) 375 405 { ··· 429 399 } 430 400 431 401 if (is_vmalloc_addr(addr)) { 432 - struct vm_struct *va = find_vm_area(addr); 402 + struct vm_struct *va = kasan_find_vm_area(addr); 433 403 434 404 if (va) { 435 405 pr_err("The buggy address belongs to the virtual mapping at\n" ··· 439 409 pr_err("\n"); 440 410 441 411 page = vmalloc_to_page(addr); 412 + } else { 413 + pr_err("The buggy address %px belongs to a vmalloc virtual mapping\n", addr); 442 414 } 443 415 } 444 416
+10 -1
mm/madvise.c
··· 933 933 */ 934 934 end = vma->vm_end; 935 935 } 936 - VM_WARN_ON(start >= end); 936 + /* 937 + * If the memory region between start and end was 938 + * originally backed by 4kB pages and then remapped to 939 + * be backed by hugepages while mmap_lock was dropped, 940 + * the adjustment for hugetlb vma above may have rounded 941 + * end down to the start address. 942 + */ 943 + if (start == end) 944 + return 0; 945 + VM_WARN_ON(start > end); 937 946 } 938 947 939 948 if (behavior == MADV_DONTNEED || behavior == MADV_DONTNEED_LOCKED)
+1
mm/memcontrol.c
··· 4166 4166 memcg_memory_event(memcg, MEMCG_OOM); 4167 4167 if (!mem_cgroup_out_of_memory(memcg, GFP_KERNEL, 0)) 4168 4168 break; 4169 + cond_resched(); 4169 4170 } 4170 4171 4171 4172 memcg_wb_domain_size_changed(memcg);
+14 -3
mm/memory.c
··· 1719 1719 pmd_t pmdval; 1720 1720 unsigned long start = addr; 1721 1721 bool can_reclaim_pt = reclaim_pt_is_enabled(start, end, details); 1722 - bool direct_reclaim = false; 1722 + bool direct_reclaim = true; 1723 1723 int nr; 1724 1724 1725 1725 retry: ··· 1734 1734 do { 1735 1735 bool any_skipped = false; 1736 1736 1737 - if (need_resched()) 1737 + if (need_resched()) { 1738 + direct_reclaim = false; 1738 1739 break; 1740 + } 1739 1741 1740 1742 nr = do_zap_pte_range(tlb, vma, pte, addr, end, details, rss, 1741 1743 &force_flush, &force_break, &any_skipped); ··· 1745 1743 can_reclaim_pt = false; 1746 1744 if (unlikely(force_break)) { 1747 1745 addr += nr * PAGE_SIZE; 1746 + direct_reclaim = false; 1748 1747 break; 1749 1748 } 1750 1749 } while (pte += nr, addr += PAGE_SIZE * nr, addr != end); 1751 1750 1752 - if (can_reclaim_pt && addr == end) 1751 + /* 1752 + * Fast path: try to hold the pmd lock and unmap the PTE page. 1753 + * 1754 + * If the pte lock was released midway (retry case), or if the attempt 1755 + * to hold the pmd lock failed, then we need to recheck all pte entries 1756 + * to ensure they are still none, thereby preventing the pte entries 1757 + * from being repopulated by another thread. 1758 + */ 1759 + if (can_reclaim_pt && direct_reclaim && addr == end) 1753 1760 direct_reclaim = try_get_and_clear_pmd(mm, pmd, &pmdval); 1754 1761 1755 1762 add_mm_rss_vec(mm, rss);
+4 -9
mm/migrate_device.c
··· 840 840 dst = src; 841 841 } 842 842 843 + if (!folio_is_zone_device(dst)) 844 + folio_add_lru(dst); 843 845 remove_migration_ptes(src, dst, 0); 844 846 folio_unlock(src); 845 - 846 - if (folio_is_zone_device(src)) 847 - folio_put(src); 848 - else 849 - folio_putback_lru(src); 847 + folio_put(src); 850 848 851 849 if (dst != src) { 852 850 folio_unlock(dst); 853 - if (folio_is_zone_device(dst)) 854 - folio_put(dst); 855 - else 856 - folio_putback_lru(dst); 851 + folio_put(dst); 857 852 } 858 853 } 859 854 }
+16 -19
mm/zswap.c
··· 1445 1445 * main API 1446 1446 **********************************/ 1447 1447 1448 - static ssize_t zswap_store_page(struct page *page, 1449 - struct obj_cgroup *objcg, 1450 - struct zswap_pool *pool) 1448 + static bool zswap_store_page(struct page *page, 1449 + struct obj_cgroup *objcg, 1450 + struct zswap_pool *pool) 1451 1451 { 1452 1452 swp_entry_t page_swpentry = page_swap_entry(page); 1453 1453 struct zswap_entry *entry, *old; ··· 1456 1456 entry = zswap_entry_cache_alloc(GFP_KERNEL, page_to_nid(page)); 1457 1457 if (!entry) { 1458 1458 zswap_reject_kmemcache_fail++; 1459 - return -EINVAL; 1459 + return false; 1460 1460 } 1461 1461 1462 1462 if (!zswap_compress(page, entry, pool)) ··· 1483 1483 1484 1484 /* 1485 1485 * The entry is successfully compressed and stored in the tree, there is 1486 - * no further possibility of failure. Grab refs to the pool and objcg. 1487 - * These refs will be dropped by zswap_entry_free() when the entry is 1488 - * removed from the tree. 1486 + * no further possibility of failure. Grab refs to the pool and objcg, 1487 + * charge zswap memory, and increment zswap_stored_pages. 1488 + * The opposite actions will be performed by zswap_entry_free() 1489 + * when the entry is removed from the tree. 1489 1490 */ 1490 1491 zswap_pool_get(pool); 1491 - if (objcg) 1492 + if (objcg) { 1492 1493 obj_cgroup_get(objcg); 1494 + obj_cgroup_charge_zswap(objcg, entry->length); 1495 + } 1496 + atomic_long_inc(&zswap_stored_pages); 1493 1497 1494 1498 /* 1495 1499 * We finish initializing the entry while it's already in xarray. ··· 1514 1510 zswap_lru_add(&zswap_list_lru, entry); 1515 1511 } 1516 1512 1517 - return entry->length; 1513 + return true; 1518 1514 1519 1515 store_failed: 1520 1516 zpool_free(pool->zpool, entry->handle); 1521 1517 compress_failed: 1522 1518 zswap_entry_cache_free(entry); 1523 - return -EINVAL; 1519 + return false; 1524 1520 } 1525 1521 1526 1522 bool zswap_store(struct folio *folio) ··· 1530 1526 struct obj_cgroup *objcg = NULL; 1531 1527 struct mem_cgroup *memcg = NULL; 1532 1528 struct zswap_pool *pool; 1533 - size_t compressed_bytes = 0; 1534 1529 bool ret = false; 1535 1530 long index; 1536 1531 ··· 1567 1564 1568 1565 for (index = 0; index < nr_pages; ++index) { 1569 1566 struct page *page = folio_page(folio, index); 1570 - ssize_t bytes; 1571 1567 1572 - bytes = zswap_store_page(page, objcg, pool); 1573 - if (bytes < 0) 1568 + if (!zswap_store_page(page, objcg, pool)) 1574 1569 goto put_pool; 1575 - compressed_bytes += bytes; 1576 1570 } 1577 1571 1578 - if (objcg) { 1579 - obj_cgroup_charge_zswap(objcg, compressed_bytes); 1572 + if (objcg) 1580 1573 count_objcg_events(objcg, ZSWPOUT, nr_pages); 1581 - } 1582 1574 1583 - atomic_long_add(nr_pages, &zswap_stored_pages); 1584 1575 count_vm_events(ZSWPOUT, nr_pages); 1585 1576 1586 1577 ret = true;
+97 -11
net/core/dev.c
··· 1122 1122 return ret; 1123 1123 } 1124 1124 1125 + static bool dev_addr_cmp(struct net_device *dev, unsigned short type, 1126 + const char *ha) 1127 + { 1128 + return dev->type == type && !memcmp(dev->dev_addr, ha, dev->addr_len); 1129 + } 1130 + 1125 1131 /** 1126 1132 * dev_getbyhwaddr_rcu - find a device by its hardware address 1127 1133 * @net: the applicable net namespace ··· 1136 1130 * 1137 1131 * Search for an interface by MAC address. Returns NULL if the device 1138 1132 * is not found or a pointer to the device. 1139 - * The caller must hold RCU or RTNL. 1133 + * The caller must hold RCU. 1140 1134 * The returned device has not had its ref count increased 1141 1135 * and the caller must therefore be careful about locking 1142 1136 * ··· 1148 1142 struct net_device *dev; 1149 1143 1150 1144 for_each_netdev_rcu(net, dev) 1151 - if (dev->type == type && 1152 - !memcmp(dev->dev_addr, ha, dev->addr_len)) 1145 + if (dev_addr_cmp(dev, type, ha)) 1153 1146 return dev; 1154 1147 1155 1148 return NULL; 1156 1149 } 1157 1150 EXPORT_SYMBOL(dev_getbyhwaddr_rcu); 1151 + 1152 + /** 1153 + * dev_getbyhwaddr() - find a device by its hardware address 1154 + * @net: the applicable net namespace 1155 + * @type: media type of device 1156 + * @ha: hardware address 1157 + * 1158 + * Similar to dev_getbyhwaddr_rcu(), but the owner needs to hold 1159 + * rtnl_lock. 1160 + * 1161 + * Context: rtnl_lock() must be held. 1162 + * Return: pointer to the net_device, or NULL if not found 1163 + */ 1164 + struct net_device *dev_getbyhwaddr(struct net *net, unsigned short type, 1165 + const char *ha) 1166 + { 1167 + struct net_device *dev; 1168 + 1169 + ASSERT_RTNL(); 1170 + for_each_netdev(net, dev) 1171 + if (dev_addr_cmp(dev, type, ha)) 1172 + return dev; 1173 + 1174 + return NULL; 1175 + } 1176 + EXPORT_SYMBOL(dev_getbyhwaddr); 1158 1177 1159 1178 struct net_device *dev_getfirstbyhwtype(struct net *net, unsigned short type) 1160 1179 { ··· 2102 2071 __register_netdevice_notifier_net(dst_net, nb, true); 2103 2072 } 2104 2073 2074 + static void rtnl_net_dev_lock(struct net_device *dev) 2075 + { 2076 + bool again; 2077 + 2078 + do { 2079 + struct net *net; 2080 + 2081 + again = false; 2082 + 2083 + /* netns might be being dismantled. */ 2084 + rcu_read_lock(); 2085 + net = dev_net_rcu(dev); 2086 + net_passive_inc(net); 2087 + rcu_read_unlock(); 2088 + 2089 + rtnl_net_lock(net); 2090 + 2091 + #ifdef CONFIG_NET_NS 2092 + /* dev might have been moved to another netns. */ 2093 + if (!net_eq(net, rcu_access_pointer(dev->nd_net.net))) { 2094 + rtnl_net_unlock(net); 2095 + net_passive_dec(net); 2096 + again = true; 2097 + } 2098 + #endif 2099 + } while (again); 2100 + } 2101 + 2102 + static void rtnl_net_dev_unlock(struct net_device *dev) 2103 + { 2104 + struct net *net = dev_net(dev); 2105 + 2106 + rtnl_net_unlock(net); 2107 + net_passive_dec(net); 2108 + } 2109 + 2105 2110 int register_netdevice_notifier_dev_net(struct net_device *dev, 2106 2111 struct notifier_block *nb, 2107 2112 struct netdev_net_notifier *nn) 2108 2113 { 2109 2114 struct net *net = dev_net(dev); 2110 2115 int err; 2116 + 2117 + /* rtnl_net_lock() assumes dev is not yet published by 2118 + * register_netdevice(). 2119 + */ 2120 + DEBUG_NET_WARN_ON_ONCE(!list_empty(&dev->dev_list)); 2111 2121 2112 2122 rtnl_net_lock(net); 2113 2123 err = __register_netdevice_notifier_net(net, nb, false); ··· 2166 2094 struct notifier_block *nb, 2167 2095 struct netdev_net_notifier *nn) 2168 2096 { 2169 - struct net *net = dev_net(dev); 2170 2097 int err; 2171 2098 2172 - rtnl_net_lock(net); 2099 + rtnl_net_dev_lock(dev); 2173 2100 list_del(&nn->list); 2174 - err = __unregister_netdevice_notifier_net(net, nb); 2175 - rtnl_net_unlock(net); 2101 + err = __unregister_netdevice_notifier_net(dev_net(dev), nb); 2102 + rtnl_net_dev_unlock(dev); 2176 2103 2177 2104 return err; 2178 2105 } ··· 6994 6923 higher = &pos->dev_list; 6995 6924 } 6996 6925 list_add_rcu(&napi->dev_list, higher); /* adds after higher */ 6926 + } 6927 + 6928 + /* Double check that napi_get_frags() allocates skbs with 6929 + * skb->head being backed by slab, not a page fragment. 6930 + * This is to make sure bug fixed in 3226b158e67c 6931 + * ("net: avoid 32 x truesize under-estimation for tiny skbs") 6932 + * does not accidentally come back. 6933 + */ 6934 + static void napi_get_frags_check(struct napi_struct *napi) 6935 + { 6936 + struct sk_buff *skb; 6937 + 6938 + local_bh_disable(); 6939 + skb = napi_get_frags(napi); 6940 + WARN_ON_ONCE(skb && skb->head_frag); 6941 + napi_free_frags(napi); 6942 + local_bh_enable(); 6997 6943 } 6998 6944 6999 6945 void netif_napi_add_weight_locked(struct net_device *dev, ··· 11989 11901 */ 11990 11902 void unregister_netdev(struct net_device *dev) 11991 11903 { 11992 - struct net *net = dev_net(dev); 11993 - 11994 - rtnl_net_lock(net); 11904 + rtnl_net_dev_lock(dev); 11995 11905 unregister_netdevice(dev); 11996 - rtnl_net_unlock(net); 11906 + rtnl_net_dev_unlock(dev); 11997 11907 } 11998 11908 EXPORT_SYMBOL(unregister_netdev); 11999 11909
+19 -20
net/core/drop_monitor.c
··· 1734 1734 return -ENOSPC; 1735 1735 } 1736 1736 1737 - rc = genl_register_family(&net_drop_monitor_family); 1738 - if (rc) { 1739 - pr_err("Could not create drop monitor netlink family\n"); 1740 - return rc; 1741 - } 1742 - WARN_ON(net_drop_monitor_family.mcgrp_offset != NET_DM_GRP_ALERT); 1743 - 1744 - rc = register_netdevice_notifier(&dropmon_net_notifier); 1745 - if (rc < 0) { 1746 - pr_crit("Failed to register netdevice notifier\n"); 1747 - goto out_unreg; 1748 - } 1749 - 1750 - rc = 0; 1751 - 1752 1737 for_each_possible_cpu(cpu) { 1753 1738 net_dm_cpu_data_init(cpu); 1754 1739 net_dm_hw_cpu_data_init(cpu); 1755 1740 } 1756 1741 1742 + rc = register_netdevice_notifier(&dropmon_net_notifier); 1743 + if (rc < 0) { 1744 + pr_crit("Failed to register netdevice notifier\n"); 1745 + return rc; 1746 + } 1747 + 1748 + rc = genl_register_family(&net_drop_monitor_family); 1749 + if (rc) { 1750 + pr_err("Could not create drop monitor netlink family\n"); 1751 + goto out_unreg; 1752 + } 1753 + WARN_ON(net_drop_monitor_family.mcgrp_offset != NET_DM_GRP_ALERT); 1754 + 1755 + rc = 0; 1756 + 1757 1757 goto out; 1758 1758 1759 1759 out_unreg: 1760 - genl_unregister_family(&net_drop_monitor_family); 1760 + WARN_ON(unregister_netdevice_notifier(&dropmon_net_notifier)); 1761 1761 out: 1762 1762 return rc; 1763 1763 } ··· 1766 1766 { 1767 1767 int cpu; 1768 1768 1769 - BUG_ON(unregister_netdevice_notifier(&dropmon_net_notifier)); 1770 - 1771 1769 /* 1772 1770 * Because of the module_get/put we do in the trace state change path 1773 1771 * we are guaranteed not to have any current users when we get here 1774 1772 */ 1773 + BUG_ON(genl_unregister_family(&net_drop_monitor_family)); 1774 + 1775 + BUG_ON(unregister_netdevice_notifier(&dropmon_net_notifier)); 1775 1776 1776 1777 for_each_possible_cpu(cpu) { 1777 1778 net_dm_hw_cpu_data_fini(cpu); 1778 1779 net_dm_cpu_data_fini(cpu); 1779 1780 } 1780 - 1781 - BUG_ON(genl_unregister_family(&net_drop_monitor_family)); 1782 1781 } 1783 1782 1784 1783 module_init(init_net_drop_monitor);
+29 -20
net/core/flow_dissector.c
··· 853 853 void *target_container, const void *data, 854 854 int nhoff, u8 ip_proto, int hlen) 855 855 { 856 - enum flow_dissector_key_id dissector_ports = FLOW_DISSECTOR_KEY_MAX; 857 - struct flow_dissector_key_ports *key_ports; 856 + struct flow_dissector_key_ports_range *key_ports_range = NULL; 857 + struct flow_dissector_key_ports *key_ports = NULL; 858 + __be32 ports; 858 859 859 860 if (dissector_uses_key(flow_dissector, FLOW_DISSECTOR_KEY_PORTS)) 860 - dissector_ports = FLOW_DISSECTOR_KEY_PORTS; 861 - else if (dissector_uses_key(flow_dissector, 862 - FLOW_DISSECTOR_KEY_PORTS_RANGE)) 863 - dissector_ports = FLOW_DISSECTOR_KEY_PORTS_RANGE; 861 + key_ports = skb_flow_dissector_target(flow_dissector, 862 + FLOW_DISSECTOR_KEY_PORTS, 863 + target_container); 864 864 865 - if (dissector_ports == FLOW_DISSECTOR_KEY_MAX) 865 + if (dissector_uses_key(flow_dissector, FLOW_DISSECTOR_KEY_PORTS_RANGE)) 866 + key_ports_range = skb_flow_dissector_target(flow_dissector, 867 + FLOW_DISSECTOR_KEY_PORTS_RANGE, 868 + target_container); 869 + 870 + if (!key_ports && !key_ports_range) 866 871 return; 867 872 868 - key_ports = skb_flow_dissector_target(flow_dissector, 869 - dissector_ports, 870 - target_container); 871 - key_ports->ports = __skb_flow_get_ports(skb, nhoff, ip_proto, 872 - data, hlen); 873 + ports = __skb_flow_get_ports(skb, nhoff, ip_proto, data, hlen); 874 + 875 + if (key_ports) 876 + key_ports->ports = ports; 877 + 878 + if (key_ports_range) 879 + key_ports_range->tp.ports = ports; 873 880 } 874 881 875 882 static void ··· 931 924 struct flow_dissector *flow_dissector, 932 925 void *target_container) 933 926 { 927 + struct flow_dissector_key_ports_range *key_ports_range = NULL; 934 928 struct flow_dissector_key_ports *key_ports = NULL; 935 929 struct flow_dissector_key_control *key_control; 936 930 struct flow_dissector_key_basic *key_basic; ··· 976 968 key_control->addr_type = FLOW_DISSECTOR_KEY_IPV6_ADDRS; 977 969 } 978 970 979 - if (dissector_uses_key(flow_dissector, FLOW_DISSECTOR_KEY_PORTS)) 971 + if (dissector_uses_key(flow_dissector, FLOW_DISSECTOR_KEY_PORTS)) { 980 972 key_ports = skb_flow_dissector_target(flow_dissector, 981 973 FLOW_DISSECTOR_KEY_PORTS, 982 974 target_container); 983 - else if (dissector_uses_key(flow_dissector, 984 - FLOW_DISSECTOR_KEY_PORTS_RANGE)) 985 - key_ports = skb_flow_dissector_target(flow_dissector, 986 - FLOW_DISSECTOR_KEY_PORTS_RANGE, 987 - target_container); 988 - 989 - if (key_ports) { 990 975 key_ports->src = flow_keys->sport; 991 976 key_ports->dst = flow_keys->dport; 977 + } 978 + if (dissector_uses_key(flow_dissector, 979 + FLOW_DISSECTOR_KEY_PORTS_RANGE)) { 980 + key_ports_range = skb_flow_dissector_target(flow_dissector, 981 + FLOW_DISSECTOR_KEY_PORTS_RANGE, 982 + target_container); 983 + key_ports_range->tp.src = flow_keys->sport; 984 + key_ports_range->tp.dst = flow_keys->dport; 992 985 } 993 986 994 987 if (dissector_uses_key(flow_dissector,
-3
net/core/gro.c
··· 7 7 8 8 #define MAX_GRO_SKBS 8 9 9 10 - /* This should be increased if a protocol with a bigger head is added. */ 11 - #define GRO_MAX_HEAD (MAX_HEADER + 128) 12 - 13 10 static DEFINE_SPINLOCK(offload_lock); 14 11 15 12 /**
+4 -4
net/core/net_namespace.c
··· 464 464 465 465 } 466 466 467 - static void net_free(struct net *net) 467 + void net_passive_dec(struct net *net) 468 468 { 469 469 if (refcount_dec_and_test(&net->passive)) { 470 470 kfree(rcu_access_pointer(net->gen)); ··· 482 482 struct net *net = (struct net *)p; 483 483 484 484 if (net) 485 - net_free(net); 485 + net_passive_dec(net); 486 486 } 487 487 488 488 struct net *copy_net_ns(unsigned long flags, ··· 523 523 key_remove_domain(net->key_domain); 524 524 #endif 525 525 put_user_ns(user_ns); 526 - net_free(net); 526 + net_passive_dec(net); 527 527 dec_ucounts: 528 528 dec_net_namespaces(ucounts); 529 529 return ERR_PTR(rv); ··· 672 672 key_remove_domain(net->key_domain); 673 673 #endif 674 674 put_user_ns(net->user_ns); 675 - net_free(net); 675 + net_passive_dec(net); 676 676 } 677 677 cleanup_net_task = NULL; 678 678 }
+10 -100
net/core/skbuff.c
··· 69 69 #include <net/dst.h> 70 70 #include <net/sock.h> 71 71 #include <net/checksum.h> 72 + #include <net/gro.h> 72 73 #include <net/gso.h> 73 74 #include <net/hotdata.h> 74 75 #include <net/ip6_checksum.h> ··· 96 95 static struct kmem_cache *skbuff_ext_cache __ro_after_init; 97 96 #endif 98 97 99 - #define SKB_SMALL_HEAD_SIZE SKB_HEAD_ALIGN(MAX_TCP_HEADER) 98 + #define GRO_MAX_HEAD_PAD (GRO_MAX_HEAD + NET_SKB_PAD + NET_IP_ALIGN) 99 + #define SKB_SMALL_HEAD_SIZE SKB_HEAD_ALIGN(max(MAX_TCP_HEADER, \ 100 + GRO_MAX_HEAD_PAD)) 100 101 101 102 /* We want SKB_SMALL_HEAD_CACHE_SIZE to not be a power of two. 102 103 * This should ensure that SKB_SMALL_HEAD_HEADROOM is a unique ··· 223 220 #define NAPI_SKB_CACHE_BULK 16 224 221 #define NAPI_SKB_CACHE_HALF (NAPI_SKB_CACHE_SIZE / 2) 225 222 226 - #if PAGE_SIZE == SZ_4K 227 - 228 - #define NAPI_HAS_SMALL_PAGE_FRAG 1 229 - #define NAPI_SMALL_PAGE_PFMEMALLOC(nc) ((nc).pfmemalloc) 230 - 231 - /* specialized page frag allocator using a single order 0 page 232 - * and slicing it into 1K sized fragment. Constrained to systems 233 - * with a very limited amount of 1K fragments fitting a single 234 - * page - to avoid excessive truesize underestimation 235 - */ 236 - 237 - struct page_frag_1k { 238 - void *va; 239 - u16 offset; 240 - bool pfmemalloc; 241 - }; 242 - 243 - static void *page_frag_alloc_1k(struct page_frag_1k *nc, gfp_t gfp) 244 - { 245 - struct page *page; 246 - int offset; 247 - 248 - offset = nc->offset - SZ_1K; 249 - if (likely(offset >= 0)) 250 - goto use_frag; 251 - 252 - page = alloc_pages_node(NUMA_NO_NODE, gfp, 0); 253 - if (!page) 254 - return NULL; 255 - 256 - nc->va = page_address(page); 257 - nc->pfmemalloc = page_is_pfmemalloc(page); 258 - offset = PAGE_SIZE - SZ_1K; 259 - page_ref_add(page, offset / SZ_1K); 260 - 261 - use_frag: 262 - nc->offset = offset; 263 - return nc->va + offset; 264 - } 265 - #else 266 - 267 - /* the small page is actually unused in this build; add dummy helpers 268 - * to please the compiler and avoid later preprocessor's conditionals 269 - */ 270 - #define NAPI_HAS_SMALL_PAGE_FRAG 0 271 - #define NAPI_SMALL_PAGE_PFMEMALLOC(nc) false 272 - 273 - struct page_frag_1k { 274 - }; 275 - 276 - static void *page_frag_alloc_1k(struct page_frag_1k *nc, gfp_t gfp_mask) 277 - { 278 - return NULL; 279 - } 280 - 281 - #endif 282 - 283 223 struct napi_alloc_cache { 284 224 local_lock_t bh_lock; 285 225 struct page_frag_cache page; 286 - struct page_frag_1k page_small; 287 226 unsigned int skb_count; 288 227 void *skb_cache[NAPI_SKB_CACHE_SIZE]; 289 228 }; ··· 234 289 static DEFINE_PER_CPU(struct napi_alloc_cache, napi_alloc_cache) = { 235 290 .bh_lock = INIT_LOCAL_LOCK(bh_lock), 236 291 }; 237 - 238 - /* Double check that napi_get_frags() allocates skbs with 239 - * skb->head being backed by slab, not a page fragment. 240 - * This is to make sure bug fixed in 3226b158e67c 241 - * ("net: avoid 32 x truesize under-estimation for tiny skbs") 242 - * does not accidentally come back. 243 - */ 244 - void napi_get_frags_check(struct napi_struct *napi) 245 - { 246 - struct sk_buff *skb; 247 - 248 - local_bh_disable(); 249 - skb = napi_get_frags(napi); 250 - WARN_ON_ONCE(!NAPI_HAS_SMALL_PAGE_FRAG && skb && skb->head_frag); 251 - napi_free_frags(napi); 252 - local_bh_enable(); 253 - } 254 292 255 293 void *__napi_alloc_frag_align(unsigned int fragsz, unsigned int align_mask) 256 294 { ··· 664 736 /* If requested length is either too small or too big, 665 737 * we use kmalloc() for skb->head allocation. 666 738 */ 667 - if (len <= SKB_WITH_OVERHEAD(1024) || 739 + if (len <= SKB_WITH_OVERHEAD(SKB_SMALL_HEAD_CACHE_SIZE) || 668 740 len > SKB_WITH_OVERHEAD(PAGE_SIZE) || 669 741 (gfp_mask & (__GFP_DIRECT_RECLAIM | GFP_DMA))) { 670 742 skb = __alloc_skb(len, gfp_mask, SKB_ALLOC_RX, NUMA_NO_NODE); ··· 741 813 742 814 /* If requested length is either too small or too big, 743 815 * we use kmalloc() for skb->head allocation. 744 - * When the small frag allocator is available, prefer it over kmalloc 745 - * for small fragments 746 816 */ 747 - if ((!NAPI_HAS_SMALL_PAGE_FRAG && len <= SKB_WITH_OVERHEAD(1024)) || 817 + if (len <= SKB_WITH_OVERHEAD(SKB_SMALL_HEAD_CACHE_SIZE) || 748 818 len > SKB_WITH_OVERHEAD(PAGE_SIZE) || 749 819 (gfp_mask & (__GFP_DIRECT_RECLAIM | GFP_DMA))) { 750 820 skb = __alloc_skb(len, gfp_mask, SKB_ALLOC_RX | SKB_ALLOC_NAPI, ··· 752 826 goto skb_success; 753 827 } 754 828 829 + len = SKB_HEAD_ALIGN(len); 830 + 755 831 if (sk_memalloc_socks()) 756 832 gfp_mask |= __GFP_MEMALLOC; 757 833 758 834 local_lock_nested_bh(&napi_alloc_cache.bh_lock); 759 835 nc = this_cpu_ptr(&napi_alloc_cache); 760 - if (NAPI_HAS_SMALL_PAGE_FRAG && len <= SKB_WITH_OVERHEAD(1024)) { 761 - /* we are artificially inflating the allocation size, but 762 - * that is not as bad as it may look like, as: 763 - * - 'len' less than GRO_MAX_HEAD makes little sense 764 - * - On most systems, larger 'len' values lead to fragment 765 - * size above 512 bytes 766 - * - kmalloc would use the kmalloc-1k slab for such values 767 - * - Builds with smaller GRO_MAX_HEAD will very likely do 768 - * little networking, as that implies no WiFi and no 769 - * tunnels support, and 32 bits arches. 770 - */ 771 - len = SZ_1K; 772 836 773 - data = page_frag_alloc_1k(&nc->page_small, gfp_mask); 774 - pfmemalloc = NAPI_SMALL_PAGE_PFMEMALLOC(nc->page_small); 775 - } else { 776 - len = SKB_HEAD_ALIGN(len); 777 - 778 - data = page_frag_alloc(&nc->page, len, gfp_mask); 779 - pfmemalloc = page_frag_cache_is_pfmemalloc(&nc->page); 780 - } 837 + data = page_frag_alloc(&nc->page, len, gfp_mask); 838 + pfmemalloc = page_frag_cache_is_pfmemalloc(&nc->page); 781 839 local_unlock_nested_bh(&napi_alloc_cache.bh_lock); 782 840 783 841 if (unlikely(!data))
+3
net/core/sock_map.c
··· 541 541 return (1 << sk->sk_state) & (TCPF_ESTABLISHED | TCPF_LISTEN); 542 542 if (sk_is_stream_unix(sk)) 543 543 return (1 << sk->sk_state) & TCPF_ESTABLISHED; 544 + if (sk_is_vsock(sk) && 545 + (sk->sk_type == SOCK_STREAM || sk->sk_type == SOCK_SEQPACKET)) 546 + return (1 << sk->sk_state) & TCPF_ESTABLISHED; 544 547 return true; 545 548 } 546 549
+1 -1
net/ipv4/arp.c
··· 1077 1077 __be32 mask = ((struct sockaddr_in *)&r->arp_netmask)->sin_addr.s_addr; 1078 1078 1079 1079 if (!dev && (r->arp_flags & ATF_COM)) { 1080 - dev = dev_getbyhwaddr_rcu(net, r->arp_ha.sa_family, 1080 + dev = dev_getbyhwaddr(net, r->arp_ha.sa_family, 1081 1081 r->arp_ha.sa_data); 1082 1082 if (!dev) 1083 1083 return -ENODEV;
+2 -2
net/ipv4/tcp_fastopen.c
··· 178 178 if (!skb) 179 179 return; 180 180 181 - skb_dst_drop(skb); 181 + tcp_cleanup_skb(skb); 182 182 /* segs_in has been initialized to 1 in tcp_create_openreq_child(). 183 183 * Hence, reset segs_in to 0 before calling tcp_segs_in() 184 184 * to avoid double counting. Also, tcp_segs_in() expects ··· 195 195 TCP_SKB_CB(skb)->tcp_flags &= ~TCPHDR_SYN; 196 196 197 197 tp->rcv_nxt = TCP_SKB_CB(skb)->end_seq; 198 - __skb_queue_tail(&sk->sk_receive_queue, skb); 198 + tcp_add_receive_queue(sk, skb); 199 199 tp->syn_data_acked = 1; 200 200 201 201 /* u64_stats_update_begin(&tp->syncp) not needed here,
+13 -7
net/ipv4/tcp_input.c
··· 243 243 do_div(val, skb->truesize); 244 244 tcp_sk(sk)->scaling_ratio = val ? val : 1; 245 245 246 - if (old_ratio != tcp_sk(sk)->scaling_ratio) 247 - WRITE_ONCE(tcp_sk(sk)->window_clamp, 248 - tcp_win_from_space(sk, sk->sk_rcvbuf)); 246 + if (old_ratio != tcp_sk(sk)->scaling_ratio) { 247 + struct tcp_sock *tp = tcp_sk(sk); 248 + 249 + val = tcp_win_from_space(sk, sk->sk_rcvbuf); 250 + tcp_set_window_clamp(sk, val); 251 + 252 + if (tp->window_clamp < tp->rcvq_space.space) 253 + tp->rcvq_space.space = tp->window_clamp; 254 + } 249 255 } 250 256 icsk->icsk_ack.rcv_mss = min_t(unsigned int, len, 251 257 tcp_sk(sk)->advmss); ··· 4975 4969 tcp_rcv_nxt_update(tp, TCP_SKB_CB(skb)->end_seq); 4976 4970 fin = TCP_SKB_CB(skb)->tcp_flags & TCPHDR_FIN; 4977 4971 if (!eaten) 4978 - __skb_queue_tail(&sk->sk_receive_queue, skb); 4972 + tcp_add_receive_queue(sk, skb); 4979 4973 else 4980 4974 kfree_skb_partial(skb, fragstolen); 4981 4975 ··· 5167 5161 skb, fragstolen)) ? 1 : 0; 5168 5162 tcp_rcv_nxt_update(tcp_sk(sk), TCP_SKB_CB(skb)->end_seq); 5169 5163 if (!eaten) { 5170 - __skb_queue_tail(&sk->sk_receive_queue, skb); 5164 + tcp_add_receive_queue(sk, skb); 5171 5165 skb_set_owner_r(skb, sk); 5172 5166 } 5173 5167 return eaten; ··· 5250 5244 __kfree_skb(skb); 5251 5245 return; 5252 5246 } 5253 - skb_dst_drop(skb); 5247 + tcp_cleanup_skb(skb); 5254 5248 __skb_pull(skb, tcp_hdr(skb)->doff * 4); 5255 5249 5256 5250 reason = SKB_DROP_REASON_NOT_SPECIFIED; ··· 6231 6225 NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPHPHITS); 6232 6226 6233 6227 /* Bulk data transfer: receiver */ 6234 - skb_dst_drop(skb); 6228 + tcp_cleanup_skb(skb); 6235 6229 __skb_pull(skb, tcp_header_len); 6236 6230 eaten = tcp_queue_rcv(sk, skb, &fragstolen); 6237 6231
+1 -1
net/ipv4/tcp_ipv4.c
··· 2021 2021 */ 2022 2022 skb_condense(skb); 2023 2023 2024 - skb_dst_drop(skb); 2024 + tcp_cleanup_skb(skb); 2025 2025 2026 2026 if (unlikely(tcp_checksum_complete(skb))) { 2027 2027 bh_unlock_sock(sk);
+1 -1
net/sched/cls_api.c
··· 97 97 98 98 err = xa_alloc_cyclic(&tcf_exts_miss_cookies_xa, &n->miss_cookie_base, 99 99 n, xa_limit_32b, &next, GFP_KERNEL); 100 - if (err) 100 + if (err < 0) 101 101 goto err_xa_alloc; 102 102 103 103 exts->miss_cookie_node = n;
+1 -1
net/sctp/stream.c
··· 735 735 * value SHOULD be the smallest TSN not acknowledged by the 736 736 * receiver of the request plus 2^31. 737 737 */ 738 - init_tsn = sctp_tsnmap_get_ctsn(&asoc->peer.tsn_map) + (1 << 31); 738 + init_tsn = sctp_tsnmap_get_ctsn(&asoc->peer.tsn_map) + (1U << 31); 739 739 sctp_tsnmap_init(&asoc->peer.tsn_map, SCTP_TSN_MAP_INITIAL, 740 740 init_tsn, GFP_ATOMIC); 741 741
+3
net/vmw_vsock/af_vsock.c
··· 1189 1189 { 1190 1190 struct vsock_sock *vsk = vsock_sk(sk); 1191 1191 1192 + if (WARN_ON_ONCE(!vsk->transport)) 1193 + return -ENODEV; 1194 + 1192 1195 return vsk->transport->read_skb(vsk, read_actor); 1193 1196 } 1194 1197
+7 -3
net/vmw_vsock/virtio_transport.c
··· 670 670 }; 671 671 int ret; 672 672 673 + mutex_lock(&vsock->rx_lock); 674 + vsock->rx_buf_nr = 0; 675 + vsock->rx_buf_max_nr = 0; 676 + mutex_unlock(&vsock->rx_lock); 677 + 678 + atomic_set(&vsock->queued_replies, 0); 679 + 673 680 ret = virtio_find_vqs(vdev, VSOCK_VQ_MAX, vsock->vqs, vqs_info, NULL); 674 681 if (ret < 0) 675 682 return ret; ··· 786 779 787 780 vsock->vdev = vdev; 788 781 789 - vsock->rx_buf_nr = 0; 790 - vsock->rx_buf_max_nr = 0; 791 - atomic_set(&vsock->queued_replies, 0); 792 782 793 783 mutex_init(&vsock->tx_lock); 794 784 mutex_init(&vsock->rx_lock);
+1 -1
net/vmw_vsock/vsock_bpf.c
··· 87 87 lock_sock(sk); 88 88 vsk = vsock_sk(sk); 89 89 90 - if (!vsk->transport) { 90 + if (WARN_ON_ONCE(!vsk->transport)) { 91 91 copied = -ENODEV; 92 92 goto out; 93 93 }
+1
rust/bindings/bindings_helper.h
··· 11 11 #include <linux/blk_types.h> 12 12 #include <linux/blkdev.h> 13 13 #include <linux/cred.h> 14 + #include <linux/device/faux.h> 14 15 #include <linux/errname.h> 15 16 #include <linux/ethtool.h> 16 17 #include <linux/file.h>
+67
rust/kernel/faux.rs
··· 1 + // SPDX-License-Identifier: GPL-2.0-only 2 + 3 + //! Abstractions for the faux bus. 4 + //! 5 + //! This module provides bindings for working with faux devices in kernel modules. 6 + //! 7 + //! C header: [`include/linux/device/faux.h`] 8 + 9 + use crate::{bindings, device, error::code::*, prelude::*}; 10 + use core::ptr::{addr_of_mut, null, null_mut, NonNull}; 11 + 12 + /// The registration of a faux device. 13 + /// 14 + /// This type represents the registration of a [`struct faux_device`]. When an instance of this type 15 + /// is dropped, its respective faux device will be unregistered from the system. 16 + /// 17 + /// # Invariants 18 + /// 19 + /// `self.0` always holds a valid pointer to an initialized and registered [`struct faux_device`]. 20 + /// 21 + /// [`struct faux_device`]: srctree/include/linux/device/faux.h 22 + #[repr(transparent)] 23 + pub struct Registration(NonNull<bindings::faux_device>); 24 + 25 + impl Registration { 26 + /// Create and register a new faux device with the given name. 27 + pub fn new(name: &CStr) -> Result<Self> { 28 + // SAFETY: 29 + // - `name` is copied by this function into its own storage 30 + // - `faux_ops` is safe to leave NULL according to the C API 31 + let dev = unsafe { bindings::faux_device_create(name.as_char_ptr(), null_mut(), null()) }; 32 + 33 + // The above function will return either a valid device, or NULL on failure 34 + // INVARIANT: The device will remain registered until faux_device_destroy() is called, which 35 + // happens in our Drop implementation. 36 + Ok(Self(NonNull::new(dev).ok_or(ENODEV)?)) 37 + } 38 + 39 + fn as_raw(&self) -> *mut bindings::faux_device { 40 + self.0.as_ptr() 41 + } 42 + } 43 + 44 + impl AsRef<device::Device> for Registration { 45 + fn as_ref(&self) -> &device::Device { 46 + // SAFETY: The underlying `device` in `faux_device` is guaranteed by the C API to be 47 + // a valid initialized `device`. 48 + unsafe { device::Device::as_ref(addr_of_mut!((*self.as_raw()).dev)) } 49 + } 50 + } 51 + 52 + impl Drop for Registration { 53 + fn drop(&mut self) { 54 + // SAFETY: `self.0` is a valid registered faux_device via our type invariants. 55 + unsafe { bindings::faux_device_destroy(self.as_raw()) } 56 + } 57 + } 58 + 59 + // SAFETY: The faux device API is thread-safe as guaranteed by the device core, as long as 60 + // faux_device_destroy() is guaranteed to only be called once - which is guaranteed by our type not 61 + // having Copy/Clone. 62 + unsafe impl Send for Registration {} 63 + 64 + // SAFETY: The faux device API is thread-safe as guaranteed by the device core, as long as 65 + // faux_device_destroy() is guaranteed to only be called once - which is guaranteed by our type not 66 + // having Copy/Clone. 67 + unsafe impl Sync for Registration {}
+1
rust/kernel/lib.rs
··· 46 46 pub mod devres; 47 47 pub mod driver; 48 48 pub mod error; 49 + pub mod faux; 49 50 #[cfg(CONFIG_RUST_FW_LOADER_ABSTRACTIONS)] 50 51 pub mod firmware; 51 52 pub mod fs;
+1 -1
rust/kernel/rbtree.rs
··· 1149 1149 /// # Invariants 1150 1150 /// - `parent` may be null if the new node becomes the root. 1151 1151 /// - `child_field_of_parent` is a valid pointer to the left-child or right-child of `parent`. If `parent` is 1152 - /// null, it is a pointer to the root of the [`RBTree`]. 1152 + /// null, it is a pointer to the root of the [`RBTree`]. 1153 1153 struct RawVacantEntry<'a, K, V> { 1154 1154 rbtree: *mut RBTree<K, V>, 1155 1155 /// The node that will become the parent of the new node if we insert one.
+10
samples/rust/Kconfig
··· 61 61 62 62 If unsure, say N. 63 63 64 + config SAMPLE_RUST_DRIVER_FAUX 65 + tristate "Faux Driver" 66 + help 67 + This option builds the Rust Faux driver sample. 68 + 69 + To compile this as a module, choose M here: 70 + the module will be called rust_driver_faux. 71 + 72 + If unsure, say N. 73 + 64 74 config SAMPLE_RUST_HOSTPROGS 65 75 bool "Host programs" 66 76 help
+1
samples/rust/Makefile
··· 6 6 obj-$(CONFIG_SAMPLE_RUST_PRINT) += rust_print.o 7 7 obj-$(CONFIG_SAMPLE_RUST_DRIVER_PCI) += rust_driver_pci.o 8 8 obj-$(CONFIG_SAMPLE_RUST_DRIVER_PLATFORM) += rust_driver_platform.o 9 + obj-$(CONFIG_SAMPLE_RUST_DRIVER_FAUX) += rust_driver_faux.o 9 10 10 11 rust_print-y := rust_print_main.o rust_print_events.o 11 12
+29
samples/rust/rust_driver_faux.rs
··· 1 + // SPDX-License-Identifier: GPL-2.0-only 2 + 3 + //! Rust faux device sample. 4 + 5 + use kernel::{c_str, faux, prelude::*, Module}; 6 + 7 + module! { 8 + type: SampleModule, 9 + name: "rust_faux_driver", 10 + author: "Lyude Paul", 11 + description: "Rust faux device sample", 12 + license: "GPL", 13 + } 14 + 15 + struct SampleModule { 16 + _reg: faux::Registration, 17 + } 18 + 19 + impl Module for SampleModule { 20 + fn init(_module: &'static ThisModule) -> Result<Self> { 21 + pr_info!("Initialising Rust Faux Device Sample\n"); 22 + 23 + let reg = faux::Registration::new(c_str!("rust-faux-sample-device"))?; 24 + 25 + dev_info!(reg.as_ref(), "Hello from faux device!\n"); 26 + 27 + Ok(Self { _reg: reg }) 28 + } 29 + }
+2 -2
scripts/mod/modpost.c
··· 190 190 191 191 /* 192 192 * Set mod->is_gpl_compatible to true by default. If MODULE_LICENSE() 193 - * is missing, do not check the use for EXPORT_SYMBOL_GPL() becasue 194 - * modpost will exit wiht error anyway. 193 + * is missing, do not check the use for EXPORT_SYMBOL_GPL() because 194 + * modpost will exit with an error anyway. 195 195 */ 196 196 mod->is_gpl_compatible = true; 197 197
+2 -2
scripts/package/install-extmod-build
··· 62 62 # 63 63 # Clear VPATH and srcroot because the source files reside in the output 64 64 # directory. 65 - # shellcheck disable=SC2016 # $(MAKE), $(CC), and $(build) will be expanded by Make 66 - "${MAKE}" run-command KBUILD_RUN_COMMAND='+$(MAKE) HOSTCC="$(CC)" VPATH= srcroot=. $(build)='"${destdir}"/scripts 65 + # shellcheck disable=SC2016 # $(MAKE) and $(build) will be expanded by Make 66 + "${MAKE}" run-command KBUILD_RUN_COMMAND='+$(MAKE) HOSTCC='"${CC}"' VPATH= srcroot=. $(build)='"${destdir}"/scripts 67 67 68 68 rm -f "${destdir}/scripts/Kbuild" 69 69 fi
+1 -2
sound/core/hrtimer.c
··· 66 66 stime = kzalloc(sizeof(*stime), GFP_KERNEL); 67 67 if (!stime) 68 68 return -ENOMEM; 69 - hrtimer_init(&stime->hrt, CLOCK_MONOTONIC, HRTIMER_MODE_REL); 70 69 stime->timer = t; 71 - stime->hrt.function = snd_hrtimer_callback; 70 + hrtimer_setup(&stime->hrt, snd_hrtimer_callback, CLOCK_MONOTONIC, HRTIMER_MODE_REL); 72 71 t->private_data = stime; 73 72 return 0; 74 73 }
+9 -3
sound/core/seq/seq_clientmgr.c
··· 678 678 dest_port->time_real); 679 679 680 680 #if IS_ENABLED(CONFIG_SND_SEQ_UMP) 681 - if (!(dest->filter & SNDRV_SEQ_FILTER_NO_CONVERT)) { 682 - if (snd_seq_ev_is_ump(event)) { 681 + if (snd_seq_ev_is_ump(event)) { 682 + if (!(dest->filter & SNDRV_SEQ_FILTER_NO_CONVERT)) { 683 683 result = snd_seq_deliver_from_ump(client, dest, dest_port, 684 684 event, atomic, hop); 685 685 goto __skip; 686 - } else if (snd_seq_client_is_ump(dest)) { 686 + } else if (dest->type == USER_CLIENT && 687 + !snd_seq_client_is_ump(dest)) { 688 + result = 0; // drop the event 689 + goto __skip; 690 + } 691 + } else if (snd_seq_client_is_ump(dest)) { 692 + if (!(dest->filter & SNDRV_SEQ_FILTER_NO_CONVERT)) { 687 693 result = snd_seq_deliver_to_ump(client, dest, dest_port, 688 694 event, atomic, hop); 689 695 goto __skip;
+1 -2
sound/drivers/dummy.c
··· 457 457 if (!dpcm) 458 458 return -ENOMEM; 459 459 substream->runtime->private_data = dpcm; 460 - hrtimer_init(&dpcm->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_SOFT); 461 - dpcm->timer.function = dummy_hrtimer_callback; 460 + hrtimer_setup(&dpcm->timer, dummy_hrtimer_callback, CLOCK_MONOTONIC, HRTIMER_MODE_REL_SOFT); 462 461 dpcm->substream = substream; 463 462 atomic_set(&dpcm->running, 0); 464 463 return 0;
+1 -2
sound/drivers/pcsp/pcsp.c
··· 103 103 if (devnum != 0) 104 104 return -EINVAL; 105 105 106 - hrtimer_init(&pcsp_chip.timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); 107 - pcsp_chip.timer.function = pcsp_do_timer; 106 + hrtimer_setup(&pcsp_chip.timer, pcsp_do_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); 108 107 109 108 err = snd_devm_card_new(dev, index, id, THIS_MODULE, 0, &card); 110 109 if (err < 0)
+5
sound/hda/intel-dsp-config.c
··· 539 539 .flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC_OR_SOUNDWIRE, 540 540 .device = PCI_DEVICE_ID_INTEL_HDA_PTL, 541 541 }, 542 + { 543 + .flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC_OR_SOUNDWIRE, 544 + .device = PCI_DEVICE_ID_INTEL_HDA_PTL_H, 545 + }, 546 + 542 547 #endif 543 548 544 549 };
+3 -1
sound/pci/hda/hda_codec.c
··· 2470 2470 break; 2471 2471 id = kctl->id; 2472 2472 id.index = spdif_index; 2473 - snd_ctl_rename_id(codec->card, &kctl->id, &id); 2473 + err = snd_ctl_rename_id(codec->card, &kctl->id, &id); 2474 + if (err < 0) 2475 + return err; 2474 2476 } 2475 2477 bus->primary_dig_out_type = HDA_PCM_TYPE_HDMI; 2476 2478 }
+2
sound/pci/hda/hda_intel.c
··· 2496 2496 { PCI_DEVICE_DATA(INTEL, HDA_ARL, AZX_DRIVER_SKL | AZX_DCAPS_INTEL_SKYLAKE) }, 2497 2497 /* Panther Lake */ 2498 2498 { PCI_DEVICE_DATA(INTEL, HDA_PTL, AZX_DRIVER_SKL | AZX_DCAPS_INTEL_LNL) }, 2499 + /* Panther Lake-H */ 2500 + { PCI_DEVICE_DATA(INTEL, HDA_PTL_H, AZX_DRIVER_SKL | AZX_DCAPS_INTEL_LNL) }, 2499 2501 /* Apollolake (Broxton-P) */ 2500 2502 { PCI_DEVICE_DATA(INTEL, HDA_APL, AZX_DRIVER_SKL | AZX_DCAPS_INTEL_BROXTON) }, 2501 2503 /* Gemini-Lake */
+1
sound/pci/hda/patch_conexant.c
··· 1090 1090 SND_PCI_QUIRK(0x103c, 0x814f, "HP ZBook 15u G3", CXT_FIXUP_MUTE_LED_GPIO), 1091 1091 SND_PCI_QUIRK(0x103c, 0x8174, "HP Spectre x360", CXT_FIXUP_HP_SPECTRE), 1092 1092 SND_PCI_QUIRK(0x103c, 0x822e, "HP ProBook 440 G4", CXT_FIXUP_MUTE_LED_GPIO), 1093 + SND_PCI_QUIRK(0x103c, 0x8231, "HP ProBook 450 G4", CXT_FIXUP_MUTE_LED_GPIO), 1093 1094 SND_PCI_QUIRK(0x103c, 0x828c, "HP EliteBook 840 G4", CXT_FIXUP_HP_DOCK), 1094 1095 SND_PCI_QUIRK(0x103c, 0x8299, "HP 800 G3 SFF", CXT_FIXUP_HP_MIC_NO_PRESENCE), 1095 1096 SND_PCI_QUIRK(0x103c, 0x829a, "HP 800 G3 DM", CXT_FIXUP_HP_MIC_NO_PRESENCE),
+6 -6
sound/pci/hda/patch_cs8409-tables.c
··· 121 121 { CS42L42_MIXER_CHA_VOL, 0x3F }, 122 122 { CS42L42_MIXER_CHB_VOL, 0x3F }, 123 123 { CS42L42_MIXER_ADC_VOL, 0x3f }, 124 - { CS42L42_HP_CTL, 0x03 }, 124 + { CS42L42_HP_CTL, 0x0D }, 125 125 { CS42L42_MIC_DET_CTL1, 0xB6 }, 126 126 { CS42L42_TIPSENSE_CTL, 0xC2 }, 127 127 { CS42L42_HS_CLAMP_DISABLE, 0x01 }, ··· 131 131 { CS42L42_RSENSE_CTL3, 0x00 }, 132 132 { CS42L42_TSENSE_CTL, 0x80 }, 133 133 { CS42L42_HS_BIAS_CTL, 0xC0 }, 134 - { CS42L42_PWR_CTL1, 0x02 }, 134 + { CS42L42_PWR_CTL1, 0x02, 10000 }, 135 135 { CS42L42_ADC_OVFL_INT_MASK, 0xff }, 136 136 { CS42L42_MIXER_INT_MASK, 0xff }, 137 137 { CS42L42_SRC_INT_MASK, 0xff }, ··· 315 315 { CS42L42_ASP_TX_SZ_EN, 0x01 }, 316 316 { CS42L42_PWR_CTL1, 0x0A }, 317 317 { CS42L42_PWR_CTL2, 0x84 }, 318 - { CS42L42_HP_CTL, 0x03 }, 318 + { CS42L42_HP_CTL, 0x0D }, 319 319 { CS42L42_MIXER_CHA_VOL, 0x3F }, 320 320 { CS42L42_MIXER_CHB_VOL, 0x3F }, 321 321 { CS42L42_MIXER_ADC_VOL, 0x3f }, ··· 328 328 { CS42L42_RSENSE_CTL3, 0x00 }, 329 329 { CS42L42_TSENSE_CTL, 0x80 }, 330 330 { CS42L42_HS_BIAS_CTL, 0xC0 }, 331 - { CS42L42_PWR_CTL1, 0x02 }, 331 + { CS42L42_PWR_CTL1, 0x02, 10000 }, 332 332 { CS42L42_ADC_OVFL_INT_MASK, 0xff }, 333 333 { CS42L42_MIXER_INT_MASK, 0xff }, 334 334 { CS42L42_SRC_INT_MASK, 0xff }, ··· 371 371 { CS42L42_ASP_TX_SZ_EN, 0x00 }, 372 372 { CS42L42_PWR_CTL1, 0x0E }, 373 373 { CS42L42_PWR_CTL2, 0x84 }, 374 - { CS42L42_HP_CTL, 0x01 }, 374 + { CS42L42_HP_CTL, 0x0D }, 375 375 { CS42L42_MIXER_CHA_VOL, 0x3F }, 376 376 { CS42L42_MIXER_CHB_VOL, 0x3F }, 377 377 { CS42L42_MIXER_ADC_VOL, 0x3f }, ··· 384 384 { CS42L42_RSENSE_CTL3, 0x00 }, 385 385 { CS42L42_TSENSE_CTL, 0x80 }, 386 386 { CS42L42_HS_BIAS_CTL, 0xC0 }, 387 - { CS42L42_PWR_CTL1, 0x06 }, 387 + { CS42L42_PWR_CTL1, 0x06, 10000 }, 388 388 { CS42L42_ADC_OVFL_INT_MASK, 0xff }, 389 389 { CS42L42_MIXER_INT_MASK, 0xff }, 390 390 { CS42L42_SRC_INT_MASK, 0xff },
+16 -10
sound/pci/hda/patch_cs8409.c
··· 346 346 347 347 if (cs8409_i2c_wait_complete(codec) < 0) 348 348 goto error; 349 + /* Certain use cases may require a delay 350 + * after a write operation before proceeding. 351 + */ 352 + if (seq[i].delay) 353 + fsleep(seq[i].delay); 349 354 } 350 355 351 356 mutex_unlock(&spec->i2c_mux); ··· 881 876 { CS42L42_DET_INT_STATUS2, 0x00 }, 882 877 { CS42L42_TSRS_PLUG_STATUS, 0x00 }, 883 878 }; 884 - int fsv_old, fsv_new; 879 + unsigned int fsv; 885 880 886 881 /* Bring CS42L42 out of Reset */ 887 882 spec->gpio_data = snd_hda_codec_read(codec, CS8409_PIN_AFG, 0, AC_VERB_GET_GPIO_DATA, 0); ··· 893 888 894 889 /* Initialize CS42L42 companion codec */ 895 890 cs8409_i2c_bulk_write(cs42l42, cs42l42->init_seq, cs42l42->init_seq_num); 896 - msleep(CS42L42_INIT_TIMEOUT_MS); 897 891 898 892 /* Clear interrupts, by reading interrupt status registers */ 899 893 cs8409_i2c_bulk_read(cs42l42, irq_regs, ARRAY_SIZE(irq_regs)); 900 894 901 - fsv_old = cs8409_i2c_read(cs42l42, CS42L42_HP_CTL); 902 - if (cs42l42->full_scale_vol == CS42L42_FULL_SCALE_VOL_0DB) 903 - fsv_new = fsv_old & ~CS42L42_FULL_SCALE_VOL_MASK; 904 - else 905 - fsv_new = fsv_old & CS42L42_FULL_SCALE_VOL_MASK; 906 - if (fsv_new != fsv_old) 907 - cs8409_i2c_write(cs42l42, CS42L42_HP_CTL, fsv_new); 895 + fsv = cs8409_i2c_read(cs42l42, CS42L42_HP_CTL); 896 + if (cs42l42->full_scale_vol) { 897 + // Set the full scale volume bit 898 + fsv |= CS42L42_FULL_SCALE_VOL_MASK; 899 + cs8409_i2c_write(cs42l42, CS42L42_HP_CTL, fsv); 900 + } 901 + // Unmute analog channels A and B 902 + fsv = (fsv & ~CS42L42_ANA_MUTE_AB); 903 + cs8409_i2c_write(cs42l42, CS42L42_HP_CTL, fsv); 908 904 909 905 /* we have to explicitly allow unsol event handling even during the 910 906 * resume phase so that the jack event is processed properly ··· 926 920 { CS42L42_MIXER_CHA_VOL, 0x3F }, 927 921 { CS42L42_MIXER_ADC_VOL, 0x3F }, 928 922 { CS42L42_MIXER_CHB_VOL, 0x3F }, 929 - { CS42L42_HP_CTL, 0x0F }, 923 + { CS42L42_HP_CTL, 0x0D }, 930 924 { CS42L42_ASP_RX_DAI0_EN, 0x00 }, 931 925 { CS42L42_ASP_CLK_CFG, 0x00 }, 932 926 { CS42L42_PWR_CTL1, 0xFE },
+4 -3
sound/pci/hda/patch_cs8409.h
··· 229 229 #define CS42L42_I2C_SLEEP_US (2000) 230 230 #define CS42L42_PDN_TIMEOUT_US (250000) 231 231 #define CS42L42_PDN_SLEEP_US (2000) 232 - #define CS42L42_INIT_TIMEOUT_MS (45) 232 + #define CS42L42_ANA_MUTE_AB (0x0C) 233 233 #define CS42L42_FULL_SCALE_VOL_MASK (2) 234 - #define CS42L42_FULL_SCALE_VOL_0DB (1) 235 - #define CS42L42_FULL_SCALE_VOL_MINUS6DB (0) 234 + #define CS42L42_FULL_SCALE_VOL_0DB (0) 235 + #define CS42L42_FULL_SCALE_VOL_MINUS6DB (1) 236 236 237 237 /* Dell BULLSEYE / WARLOCK / CYBORG Specific Definitions */ 238 238 ··· 290 290 struct cs8409_i2c_param { 291 291 unsigned int addr; 292 292 unsigned int value; 293 + unsigned int delay; 293 294 }; 294 295 295 296 struct cs8409_cir_param {
+2
sound/pci/hda/patch_realtek.c
··· 3788 3788 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE); 3789 3789 3790 3790 msleep(75); 3791 + alc_update_coef_idx(codec, 0x4a, 3 << 10, 0); 3791 3792 alc_update_coefex_idx(codec, 0x57, 0x04, 0x0007, 0x4); /* Hight power */ 3792 3793 } 3793 3794 } ··· 11046 11045 SND_PCI_QUIRK(0x1d72, 0x1945, "Redmi G", ALC256_FIXUP_ASUS_HEADSET_MIC), 11047 11046 SND_PCI_QUIRK(0x1d72, 0x1947, "RedmiBook Air", ALC255_FIXUP_XIAOMI_HEADSET_MIC), 11048 11047 SND_PCI_QUIRK(0x1f66, 0x0105, "Ayaneo Portable Game Player", ALC287_FIXUP_CS35L41_I2C_2), 11048 + SND_PCI_QUIRK(0x2014, 0x800a, "Positivo ARN50", ALC269_FIXUP_LIMIT_INT_MIC_BOOST), 11049 11049 SND_PCI_QUIRK(0x2782, 0x0214, "VAIO VJFE-CL", ALC269_FIXUP_LIMIT_INT_MIC_BOOST), 11050 11050 SND_PCI_QUIRK(0x2782, 0x0228, "Infinix ZERO BOOK 13", ALC269VB_FIXUP_INFINIX_ZERO_BOOK_13), 11051 11051 SND_PCI_QUIRK(0x2782, 0x0232, "CHUWI CoreBook XPro", ALC269VB_FIXUP_CHUWI_COREBOOK_XPRO),
+14 -13
sound/pci/hda/tas2781_hda_spi.c
··· 912 912 struct tasdevice_priv *tas_priv = context; 913 913 struct tas2781_hda *tas_hda = dev_get_drvdata(tas_priv->dev); 914 914 struct hda_codec *codec = tas_priv->codec; 915 - int i, j, ret; 915 + int i, j, ret, val; 916 916 917 917 pm_runtime_get_sync(tas_priv->dev); 918 918 guard(mutex)(&tas_priv->codec_lock); ··· 981 981 982 982 /* Perform AMP reset before firmware download. */ 983 983 tas_priv->rcabin.profile_cfg_id = TAS2781_PRE_POST_RESET_CFG; 984 - tasdevice_spi_tuning_switch(tas_priv, 0); 985 984 tas2781_spi_reset(tas_priv); 986 985 tas_priv->rcabin.profile_cfg_id = 0; 987 - tasdevice_spi_tuning_switch(tas_priv, 1); 988 986 989 987 tas_priv->fw_state = TASDEVICE_DSP_FW_ALL_OK; 990 - ret = tasdevice_spi_prmg_load(tas_priv, 0); 988 + ret = tasdevice_spi_dev_read(tas_priv, TAS2781_REG_CLK_CONFIG, &val); 989 + if (ret < 0) 990 + goto out; 991 + 992 + if (val == TAS2781_REG_CLK_CONFIG_RESET) 993 + ret = tasdevice_spi_prmg_load(tas_priv, 0); 991 994 if (ret < 0) { 992 995 dev_err(tas_priv->dev, "FW download failed = %d\n", ret); 993 996 goto out; ··· 1004 1001 * If calibrated data occurs error, dsp will still works with default 1005 1002 * calibrated data inside algo. 1006 1003 */ 1007 - tas_priv->save_calibration(tas_priv); 1008 1004 1009 1005 out: 1010 1006 if (fmw) ··· 1162 1160 1163 1161 guard(mutex)(&tas_hda->priv->codec_lock); 1164 1162 1165 - tasdevice_spi_tuning_switch(tas_hda->priv, 1); 1163 + if (tas_hda->priv->playback_started) 1164 + tasdevice_spi_tuning_switch(tas_hda->priv, 1); 1166 1165 1167 1166 tas_hda->priv->cur_book = -1; 1168 1167 tas_hda->priv->cur_conf = -1; ··· 1177 1174 1178 1175 guard(mutex)(&tas_hda->priv->codec_lock); 1179 1176 1180 - tasdevice_spi_tuning_switch(tas_hda->priv, 0); 1177 + if (tas_hda->priv->playback_started) 1178 + tasdevice_spi_tuning_switch(tas_hda->priv, 0); 1181 1179 1182 1180 return 0; 1183 1181 } ··· 1193 1189 return ret; 1194 1190 1195 1191 /* Shutdown chip before system suspend */ 1196 - tasdevice_spi_tuning_switch(tas_hda->priv, 1); 1197 - tas2781_spi_reset(tas_hda->priv); 1198 - /* 1199 - * Reset GPIO may be shared, so cannot reset here. 1200 - * However beyond this point, amps may be powered down. 1201 - */ 1192 + if (tas_hda->priv->playback_started) 1193 + tasdevice_spi_tuning_switch(tas_hda->priv, 1); 1194 + 1202 1195 return 0; 1203 1196 } 1204 1197
+5 -5
sound/pci/hda/tas2781_spi_fwlib.c
··· 2 2 // 3 3 // TAS2781 HDA SPI driver 4 4 // 5 - // Copyright 2024 Texas Instruments, Inc. 5 + // Copyright 2024-2025 Texas Instruments, Inc. 6 6 // 7 7 // Author: Baojun Xu <baojun.xu@ti.com> 8 8 ··· 771 771 switch (subblk_typ) { 772 772 case TASDEVICE_CMD_SING_W: 773 773 subblk_offset = tasdevice_single_byte_wr(tas_priv, 774 - dev_idx & 0x4f, data, sublocksize); 774 + dev_idx & 0x3f, data, sublocksize); 775 775 break; 776 776 case TASDEVICE_CMD_BURST: 777 777 subblk_offset = tasdevice_burst_wr(tas_priv, 778 - dev_idx & 0x4f, data, sublocksize); 778 + dev_idx & 0x3f, data, sublocksize); 779 779 break; 780 780 case TASDEVICE_CMD_DELAY: 781 781 subblk_offset = tasdevice_delay(tas_priv, 782 - dev_idx & 0x4f, data, sublocksize); 782 + dev_idx & 0x3f, data, sublocksize); 783 783 break; 784 784 case TASDEVICE_CMD_FIELD_W: 785 785 subblk_offset = tasdevice_field_wr(tas_priv, 786 - dev_idx & 0x4f, data, sublocksize); 786 + dev_idx & 0x3f, data, sublocksize); 787 787 break; 788 788 default: 789 789 subblk_offset = 2;
+1 -2
sound/sh/sh_dac_audio.c
··· 312 312 313 313 chip->card = card; 314 314 315 - hrtimer_init(&chip->hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); 316 - chip->hrtimer.function = sh_dac_audio_timer; 315 + hrtimer_setup(&chip->hrtimer, sh_dac_audio_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); 317 316 318 317 dac_audio_reset(chip); 319 318 chip->rate = 8000;
+7 -7
sound/soc/codecs/arizona.c
··· 967 967 case ARIZONA_OUT3L_ENA_SHIFT: 968 968 case ARIZONA_OUT3R_ENA_SHIFT: 969 969 priv->out_up_pending++; 970 - priv->out_up_delay += 17; 970 + priv->out_up_delay += 17000; 971 971 break; 972 972 case ARIZONA_OUT4L_ENA_SHIFT: 973 973 case ARIZONA_OUT4R_ENA_SHIFT: ··· 977 977 case WM8997: 978 978 break; 979 979 default: 980 - priv->out_up_delay += 10; 980 + priv->out_up_delay += 10000; 981 981 break; 982 982 } 983 983 break; ··· 999 999 if (!priv->out_up_pending && priv->out_up_delay) { 1000 1000 dev_dbg(component->dev, "Power up delay: %d\n", 1001 1001 priv->out_up_delay); 1002 - msleep(priv->out_up_delay); 1002 + fsleep(priv->out_up_delay); 1003 1003 priv->out_up_delay = 0; 1004 1004 } 1005 1005 break; ··· 1017 1017 case ARIZONA_OUT3L_ENA_SHIFT: 1018 1018 case ARIZONA_OUT3R_ENA_SHIFT: 1019 1019 priv->out_down_pending++; 1020 - priv->out_down_delay++; 1020 + priv->out_down_delay += 1000; 1021 1021 break; 1022 1022 case ARIZONA_OUT4L_ENA_SHIFT: 1023 1023 case ARIZONA_OUT4R_ENA_SHIFT: ··· 1028 1028 break; 1029 1029 case WM8998: 1030 1030 case WM1814: 1031 - priv->out_down_delay += 5; 1031 + priv->out_down_delay += 5000; 1032 1032 break; 1033 1033 default: 1034 - priv->out_down_delay++; 1034 + priv->out_down_delay += 1000; 1035 1035 break; 1036 1036 } 1037 1037 break; ··· 1053 1053 if (!priv->out_down_pending && priv->out_down_delay) { 1054 1054 dev_dbg(component->dev, "Power down delay: %d\n", 1055 1055 priv->out_down_delay); 1056 - msleep(priv->out_down_delay); 1056 + fsleep(priv->out_down_delay); 1057 1057 priv->out_down_delay = 0; 1058 1058 } 1059 1059 break;
+23 -7
sound/soc/codecs/cs35l41.c
··· 1148 1148 return ret; 1149 1149 } 1150 1150 1151 + #ifdef CONFIG_ACPI 1151 1152 static int cs35l41_acpi_get_name(struct cs35l41_private *cs35l41) 1152 1153 { 1153 - acpi_handle handle = ACPI_HANDLE(cs35l41->dev); 1154 + struct acpi_device *adev = ACPI_COMPANION(cs35l41->dev); 1155 + acpi_handle handle = acpi_device_handle(adev); 1156 + const char *hid; 1154 1157 const char *sub; 1155 1158 1156 - /* If there is no ACPI_HANDLE, there is no ACPI for this system, return 0 */ 1157 - if (!handle) 1159 + /* If there is no acpi_device, there is no ACPI for this system, return 0 */ 1160 + if (!adev) 1158 1161 return 0; 1159 1162 1160 1163 sub = acpi_get_subsystem_id(handle); 1161 1164 if (IS_ERR(sub)) { 1162 - /* If bad ACPI, return 0 and fallback to legacy firmware path, otherwise fail */ 1163 - if (PTR_ERR(sub) == -ENODATA) 1164 - return 0; 1165 - else 1165 + /* If no _SUB, fallback to _HID, otherwise fail */ 1166 + if (PTR_ERR(sub) == -ENODATA) { 1167 + hid = acpi_device_hid(adev); 1168 + /* If dummy hid, return 0 and fallback to legacy firmware path */ 1169 + if (!strcmp(hid, "device")) 1170 + return 0; 1171 + sub = kstrdup(hid, GFP_KERNEL); 1172 + if (!sub) 1173 + sub = ERR_PTR(-ENOMEM); 1174 + 1175 + } else 1166 1176 return PTR_ERR(sub); 1167 1177 } 1168 1178 ··· 1181 1171 1182 1172 return 0; 1183 1173 } 1174 + #else 1175 + static int cs35l41_acpi_get_name(struct cs35l41_private *cs35l41) 1176 + { 1177 + return 0; 1178 + } 1179 + #endif /* CONFIG_ACPI */ 1184 1180 1185 1181 int cs35l41_probe(struct cs35l41_private *cs35l41, const struct cs35l41_hw_cfg *hw_cfg) 1186 1182 {
+5 -5
sound/soc/codecs/madera.c
··· 2323 2323 case CS42L92: 2324 2324 case CS47L92: 2325 2325 case CS47L93: 2326 - out_up_delay = 6; 2326 + out_up_delay = 6000; 2327 2327 break; 2328 2328 default: 2329 - out_up_delay = 17; 2329 + out_up_delay = 17000; 2330 2330 break; 2331 2331 } 2332 2332 ··· 2357 2357 case MADERA_OUT3R_ENA_SHIFT: 2358 2358 priv->out_up_pending--; 2359 2359 if (!priv->out_up_pending) { 2360 - msleep(priv->out_up_delay); 2360 + fsleep(priv->out_up_delay); 2361 2361 priv->out_up_delay = 0; 2362 2362 } 2363 2363 break; ··· 2376 2376 case MADERA_OUT3L_ENA_SHIFT: 2377 2377 case MADERA_OUT3R_ENA_SHIFT: 2378 2378 priv->out_down_pending++; 2379 - priv->out_down_delay++; 2379 + priv->out_down_delay += 1000; 2380 2380 break; 2381 2381 default: 2382 2382 break; ··· 2393 2393 case MADERA_OUT3R_ENA_SHIFT: 2394 2394 priv->out_down_pending--; 2395 2395 if (!priv->out_down_pending) { 2396 - msleep(priv->out_down_delay); 2396 + fsleep(priv->out_down_delay); 2397 2397 priv->out_down_delay = 0; 2398 2398 } 2399 2399 break;
+1 -3
sound/soc/codecs/tas2781-i2c.c
··· 2 2 // 3 3 // ALSA SoC Texas Instruments TAS2563/TAS2781 Audio Smart Amplifier 4 4 // 5 - // Copyright (C) 2022 - 2024 Texas Instruments Incorporated 5 + // Copyright (C) 2022 - 2025 Texas Instruments Incorporated 6 6 // https://www.ti.com 7 7 // 8 8 // The TAS2563/TAS2781 driver implements a flexible and configurable ··· 1260 1260 (cali_data->cali_dat_sz_per_dev + 1) + 1 + 15 + 1; 1261 1261 priv->cali_data.total_sz = priv->ndev * 1262 1262 (cali_data->cali_dat_sz_per_dev + 1); 1263 - priv->cali_data.data = devm_kzalloc(priv->dev, 1264 - ext_cali_data->max, GFP_KERNEL); 1265 1263 cali_ctrls[i].name = cali_name; 1266 1264 cali_ctrls[i].iface = SNDRV_CTL_ELEM_IFACE_MIXER; 1267 1265 cali_ctrls[i].info = snd_soc_bytes_info_ext;
+4 -4
sound/soc/codecs/wm5110.c
··· 302 302 } else { 303 303 wseq = wm5110_no_dre_left_enable; 304 304 nregs = ARRAY_SIZE(wm5110_no_dre_left_enable); 305 - priv->out_up_delay += 10; 305 + priv->out_up_delay += 10000; 306 306 } 307 307 break; 308 308 case ARIZONA_OUT1R_ENA_SHIFT: ··· 312 312 } else { 313 313 wseq = wm5110_no_dre_right_enable; 314 314 nregs = ARRAY_SIZE(wm5110_no_dre_right_enable); 315 - priv->out_up_delay += 10; 315 + priv->out_up_delay += 10000; 316 316 } 317 317 break; 318 318 default: ··· 338 338 snd_soc_component_update_bits(component, 339 339 ARIZONA_SPARE_TRIGGERS, 340 340 ARIZONA_WS_TRG1, 0); 341 - priv->out_down_delay += 27; 341 + priv->out_down_delay += 27000; 342 342 } 343 343 break; 344 344 case ARIZONA_OUT1R_ENA_SHIFT: ··· 350 350 snd_soc_component_update_bits(component, 351 351 ARIZONA_SPARE_TRIGGERS, 352 352 ARIZONA_WS_TRG2, 0); 353 - priv->out_down_delay += 27; 353 + priv->out_down_delay += 27000; 354 354 } 355 355 break; 356 356 default:
+2
sound/soc/fsl/fsl_micfil.c
··· 183 183 case QUALITY_VLOW2: 184 184 qsel = MICFIL_QSEL_VLOW2_QUALITY; 185 185 break; 186 + default: 187 + return -EINVAL; 186 188 } 187 189 188 190 return regmap_update_bits(micfil->regmap, REG_MICFIL_CTRL2,
-31
sound/soc/fsl/imx-audmix.c
··· 23 23 struct snd_soc_card card; 24 24 struct platform_device *audmix_pdev; 25 25 struct platform_device *out_pdev; 26 - struct clk *cpu_mclk; 27 26 int num_dai; 28 27 struct snd_soc_dai_link *dai; 29 28 int num_dai_conf; ··· 31 32 struct snd_soc_dapm_route *dapm_routes; 32 33 }; 33 34 34 - static const u32 imx_audmix_rates[] = { 35 - 8000, 12000, 16000, 24000, 32000, 48000, 64000, 96000, 36 - }; 37 - 38 - static const struct snd_pcm_hw_constraint_list imx_audmix_rate_constraints = { 39 - .count = ARRAY_SIZE(imx_audmix_rates), 40 - .list = imx_audmix_rates, 41 - }; 42 - 43 35 static int imx_audmix_fe_startup(struct snd_pcm_substream *substream) 44 36 { 45 - struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream); 46 - struct imx_audmix *priv = snd_soc_card_get_drvdata(rtd->card); 47 37 struct snd_pcm_runtime *runtime = substream->runtime; 48 - struct device *dev = rtd->card->dev; 49 - unsigned long clk_rate = clk_get_rate(priv->cpu_mclk); 50 38 int ret; 51 - 52 - if (clk_rate % 24576000 == 0) { 53 - ret = snd_pcm_hw_constraint_list(runtime, 0, 54 - SNDRV_PCM_HW_PARAM_RATE, 55 - &imx_audmix_rate_constraints); 56 - if (ret < 0) 57 - return ret; 58 - } else { 59 - dev_warn(dev, "mclk may be not supported %lu\n", clk_rate); 60 - } 61 39 62 40 ret = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_CHANNELS, 63 41 1, 8); ··· 298 322 return -EINVAL; 299 323 } 300 324 put_device(&cpu_pdev->dev); 301 - 302 - priv->cpu_mclk = devm_clk_get(&cpu_pdev->dev, "mclk1"); 303 - if (IS_ERR(priv->cpu_mclk)) { 304 - ret = PTR_ERR(priv->cpu_mclk); 305 - dev_err(&cpu_pdev->dev, "failed to get DAI mclk1: %d\n", ret); 306 - return ret; 307 - } 308 325 309 326 priv->audmix_pdev = audmix_pdev; 310 327 priv->out_pdev = cpu_pdev;
+1
sound/soc/generic/simple-card-utils.c
··· 1092 1092 args.np = ep; 1093 1093 dai = snd_soc_get_dai_via_args(&args); 1094 1094 if (dai) { 1095 + dlc->of_node = node; 1095 1096 dlc->dai_name = snd_soc_dai_name_get(dai); 1096 1097 dlc->dai_args = snd_soc_copy_dai_args(dev, &args); 1097 1098 if (!dlc->dai_args)
+35 -6
sound/soc/intel/boards/sof_sdw.c
··· 13 13 #include <linux/soundwire/sdw.h> 14 14 #include <linux/soundwire/sdw_type.h> 15 15 #include <linux/soundwire/sdw_intel.h> 16 + #include <sound/core.h> 16 17 #include <sound/soc-acpi.h> 17 18 #include "sof_sdw_common.h" 18 19 #include "../../codecs/rt711.h" ··· 749 748 }, 750 749 .driver_data = (void *)(SOC_SDW_PCH_DMIC), 751 750 }, 751 + { 752 + .callback = sof_sdw_quirk_cb, 753 + .matches = { 754 + DMI_MATCH(DMI_SYS_VENDOR, "Google"), 755 + DMI_MATCH(DMI_PRODUCT_NAME, "Fatcat"), 756 + }, 757 + .driver_data = (void *)(SOC_SDW_PCH_DMIC | 758 + SOF_BT_OFFLOAD_SSP(2) | 759 + SOF_SSP_BT_OFFLOAD_PRESENT), 760 + }, 752 761 {} 753 762 }; 763 + 764 + static const struct snd_pci_quirk sof_sdw_ssid_quirk_table[] = { 765 + SND_PCI_QUIRK(0x1043, 0x1e13, "ASUS Zenbook S14", SOC_SDW_CODEC_MIC), 766 + {} 767 + }; 768 + 769 + static void sof_sdw_check_ssid_quirk(const struct snd_soc_acpi_mach *mach) 770 + { 771 + const struct snd_pci_quirk *quirk_entry; 772 + 773 + quirk_entry = snd_pci_quirk_lookup_id(mach->mach_params.subsystem_vendor, 774 + mach->mach_params.subsystem_device, 775 + sof_sdw_ssid_quirk_table); 776 + 777 + if (quirk_entry) 778 + sof_sdw_quirk = quirk_entry->value; 779 + } 754 780 755 781 static struct snd_soc_dai_link_component platform_component[] = { 756 782 { ··· 1306 1278 1307 1279 snd_soc_card_set_drvdata(card, ctx); 1308 1280 1281 + if (mach->mach_params.subsystem_id_set) { 1282 + snd_soc_card_set_pci_ssid(card, 1283 + mach->mach_params.subsystem_vendor, 1284 + mach->mach_params.subsystem_device); 1285 + sof_sdw_check_ssid_quirk(mach); 1286 + } 1287 + 1309 1288 dmi_check_system(sof_sdw_quirk_table); 1310 1289 1311 1290 if (quirk_override != -1) { ··· 1327 1292 /* reset amp_num to ensure amp_num++ starts from 0 in each probe */ 1328 1293 for (i = 0; i < ctx->codec_info_list_count; i++) 1329 1294 codec_info_list[i].amp_num = 0; 1330 - 1331 - if (mach->mach_params.subsystem_id_set) { 1332 - snd_soc_card_set_pci_ssid(card, 1333 - mach->mach_params.subsystem_vendor, 1334 - mach->mach_params.subsystem_device); 1335 - } 1336 1295 1337 1296 ret = sof_card_dai_links_create(card); 1338 1297 if (ret < 0)
+1 -1
sound/soc/intel/common/soc-acpi-intel-mtl-match.c
··· 330 330 331 331 static const struct snd_soc_acpi_adr_device rt1318_1_single_adr[] = { 332 332 { 333 - .adr = 0x000130025D131801, 333 + .adr = 0x000130025D131801ull, 334 334 .num_endpoints = 1, 335 335 .endpoints = &single_endpoint, 336 336 .name_prefix = "rt1318-1"
+6 -6
sound/soc/intel/common/soc-acpi-intel-ptl-match.c
··· 251 251 {} 252 252 }; 253 253 254 - static const struct snd_soc_acpi_link_adr lnl_sdw_rt713_vb_l2_rt1320_l13[] = { 254 + static const struct snd_soc_acpi_link_adr ptl_sdw_rt713_vb_l2_rt1320_l13[] = { 255 255 { 256 256 .mask = BIT(2), 257 257 .num_adr = ARRAY_SIZE(rt713_vb_2_adr), ··· 270 270 {} 271 271 }; 272 272 273 - static const struct snd_soc_acpi_link_adr lnl_sdw_rt712_vb_l2_rt1320_l1[] = { 273 + static const struct snd_soc_acpi_link_adr ptl_sdw_rt712_vb_l2_rt1320_l1[] = { 274 274 { 275 275 .mask = BIT(2), 276 276 .num_adr = ARRAY_SIZE(rt712_vb_2_group1_adr), ··· 337 337 }, 338 338 { 339 339 .link_mask = BIT(1) | BIT(2), 340 - .links = lnl_sdw_rt712_vb_l2_rt1320_l1, 340 + .links = ptl_sdw_rt712_vb_l2_rt1320_l1, 341 341 .drv_name = "sof_sdw", 342 342 .machine_check = snd_soc_acpi_intel_sdca_is_device_rt712_vb, 343 - .sof_tplg_filename = "sof-lnl-rt712-l2-rt1320-l1.tplg" 343 + .sof_tplg_filename = "sof-ptl-rt712-l2-rt1320-l1.tplg" 344 344 }, 345 345 { 346 346 .link_mask = BIT(1) | BIT(2) | BIT(3), 347 - .links = lnl_sdw_rt713_vb_l2_rt1320_l13, 347 + .links = ptl_sdw_rt713_vb_l2_rt1320_l13, 348 348 .drv_name = "sof_sdw", 349 349 .machine_check = snd_soc_acpi_intel_sdca_is_device_rt712_vb, 350 - .sof_tplg_filename = "sof-lnl-rt713-l2-rt1320-l13.tplg" 350 + .sof_tplg_filename = "sof-ptl-rt713-l2-rt1320-l13.tplg" 351 351 }, 352 352 {}, 353 353 };
+8 -8
sound/soc/intel/common/soc-acpi-intel-tgl-match.c
··· 658 658 659 659 static const struct snd_soc_acpi_adr_device cs35l56_sdw_eight_1_4_fb_adr[] = { 660 660 { 661 - .adr = 0x00003301fa355601, 661 + .adr = 0x00003301fa355601ull, 662 662 .num_endpoints = ARRAY_SIZE(cs35l56_l_fb_endpoints), 663 663 .endpoints = cs35l56_l_fb_endpoints, 664 664 .name_prefix = "AMP1" 665 665 }, 666 666 { 667 - .adr = 0x00003201fa355601, 667 + .adr = 0x00003201fa355601ull, 668 668 .num_endpoints = ARRAY_SIZE(cs35l56_2_fb_endpoints), 669 669 .endpoints = cs35l56_2_fb_endpoints, 670 670 .name_prefix = "AMP2" 671 671 }, 672 672 { 673 - .adr = 0x00003101fa355601, 673 + .adr = 0x00003101fa355601ull, 674 674 .num_endpoints = ARRAY_SIZE(cs35l56_4_fb_endpoints), 675 675 .endpoints = cs35l56_4_fb_endpoints, 676 676 .name_prefix = "AMP3" 677 677 }, 678 678 { 679 - .adr = 0x00003001fa355601, 679 + .adr = 0x00003001fa355601ull, 680 680 .num_endpoints = ARRAY_SIZE(cs35l56_6_fb_endpoints), 681 681 .endpoints = cs35l56_6_fb_endpoints, 682 682 .name_prefix = "AMP4" ··· 685 685 686 686 static const struct snd_soc_acpi_adr_device cs35l56_sdw_eight_5_8_fb_adr[] = { 687 687 { 688 - .adr = 0x00013701fa355601, 688 + .adr = 0x00013701fa355601ull, 689 689 .num_endpoints = ARRAY_SIZE(cs35l56_r_fb_endpoints), 690 690 .endpoints = cs35l56_r_fb_endpoints, 691 691 .name_prefix = "AMP8" 692 692 }, 693 693 { 694 - .adr = 0x00013601fa355601, 694 + .adr = 0x00013601fa355601ull, 695 695 .num_endpoints = ARRAY_SIZE(cs35l56_3_fb_endpoints), 696 696 .endpoints = cs35l56_3_fb_endpoints, 697 697 .name_prefix = "AMP7" 698 698 }, 699 699 { 700 - .adr = 0x00013501fa355601, 700 + .adr = 0x00013501fa355601ull, 701 701 .num_endpoints = ARRAY_SIZE(cs35l56_5_fb_endpoints), 702 702 .endpoints = cs35l56_5_fb_endpoints, 703 703 .name_prefix = "AMP6" 704 704 }, 705 705 { 706 - .adr = 0x00013401fa355601, 706 + .adr = 0x00013401fa355601ull, 707 707 .num_endpoints = ARRAY_SIZE(cs35l56_7_fb_endpoints), 708 708 .endpoints = cs35l56_7_fb_endpoints, 709 709 .name_prefix = "AMP5"
-14
sound/soc/renesas/rcar/core.c
··· 1770 1770 return 1; 1771 1771 } 1772 1772 1773 - int rsnd_kctrl_accept_runtime(struct rsnd_dai_stream *io) 1774 - { 1775 - struct snd_pcm_runtime *runtime = rsnd_io_to_runtime(io); 1776 - struct rsnd_priv *priv = rsnd_io_to_priv(io); 1777 - struct device *dev = rsnd_priv_to_dev(priv); 1778 - 1779 - if (!runtime) { 1780 - dev_warn(dev, "Can't update kctrl when idle\n"); 1781 - return 0; 1782 - } 1783 - 1784 - return 1; 1785 - } 1786 - 1787 1773 struct rsnd_kctrl_cfg *rsnd_kctrl_init_m(struct rsnd_kctrl_cfg_m *cfg) 1788 1774 { 1789 1775 cfg->cfg.val = cfg->val;
-1
sound/soc/renesas/rcar/rsnd.h
··· 742 742 #define rsnd_kctrl_vals(x) ((x).val) /* = (x).cfg.val[0] */ 743 743 744 744 int rsnd_kctrl_accept_anytime(struct rsnd_dai_stream *io); 745 - int rsnd_kctrl_accept_runtime(struct rsnd_dai_stream *io); 746 745 struct rsnd_kctrl_cfg *rsnd_kctrl_init_m(struct rsnd_kctrl_cfg_m *cfg); 747 746 struct rsnd_kctrl_cfg *rsnd_kctrl_init_s(struct rsnd_kctrl_cfg_s *cfg); 748 747 int rsnd_kctrl_new(struct rsnd_mod *mod,
+93 -23
sound/soc/renesas/rcar/src.c
··· 35 35 struct rsnd_mod *dma; 36 36 struct rsnd_kctrl_cfg_s sen; /* sync convert enable */ 37 37 struct rsnd_kctrl_cfg_s sync; /* sync convert */ 38 + u32 current_sync_rate; 38 39 int irq; 39 40 }; 40 41 ··· 101 100 if (!rsnd_src_sync_is_enabled(mod)) 102 101 return rsnd_io_converted_rate(io); 103 102 104 - convert_rate = src->sync.val; 103 + convert_rate = src->current_sync_rate; 105 104 106 105 if (!convert_rate) 107 106 convert_rate = rsnd_io_converted_rate(io); ··· 202 201 static void rsnd_src_set_convert_rate(struct rsnd_dai_stream *io, 203 202 struct rsnd_mod *mod) 204 203 { 204 + struct snd_pcm_runtime *runtime = rsnd_io_to_runtime(io); 205 + struct rsnd_priv *priv = rsnd_mod_to_priv(mod); 206 + struct rsnd_src *src = rsnd_mod_to_src(mod); 207 + u32 fin, fout, new_rate; 208 + int inc, cnt, rate; 209 + u64 base, val; 210 + 211 + if (!runtime) 212 + return; 213 + 214 + if (!rsnd_src_sync_is_enabled(mod)) 215 + return; 216 + 217 + fin = rsnd_src_get_in_rate(priv, io); 218 + fout = rsnd_src_get_out_rate(priv, io); 219 + 220 + new_rate = src->sync.val; 221 + 222 + if (!new_rate) 223 + new_rate = fout; 224 + 225 + /* Do nothing if no diff */ 226 + if (new_rate == src->current_sync_rate) 227 + return; 228 + 229 + /* 230 + * SRCm_IFSVR::INTIFS can change within 1% 231 + * see 232 + * SRCm_IFSVR::INTIFS Note 233 + */ 234 + inc = fout / 100; 235 + cnt = abs(new_rate - fout) / inc; 236 + if (fout > new_rate) 237 + inc *= -1; 238 + 239 + /* 240 + * After start running SRC, we can update only SRC_IFSVR 241 + * for Synchronous Mode 242 + */ 243 + base = (u64)0x0400000 * fin; 244 + rate = fout; 245 + for (int i = 0; i < cnt; i++) { 246 + val = base; 247 + rate += inc; 248 + do_div(val, rate); 249 + 250 + rsnd_mod_write(mod, SRC_IFSVR, val); 251 + } 252 + val = base; 253 + do_div(val, new_rate); 254 + 255 + rsnd_mod_write(mod, SRC_IFSVR, val); 256 + 257 + /* update current_sync_rate */ 258 + src->current_sync_rate = new_rate; 259 + } 260 + 261 + static void rsnd_src_init_convert_rate(struct rsnd_dai_stream *io, 262 + struct rsnd_mod *mod) 263 + { 264 + struct snd_pcm_runtime *runtime = rsnd_io_to_runtime(io); 205 265 struct rsnd_priv *priv = rsnd_mod_to_priv(mod); 206 266 struct device *dev = rsnd_priv_to_dev(priv); 207 - struct snd_pcm_runtime *runtime = rsnd_io_to_runtime(io); 208 267 int is_play = rsnd_io_is_play(io); 209 268 int use_src = 0; 210 269 u32 fin, fout; 211 - u32 ifscr, fsrate, adinr; 270 + u32 ifscr, adinr; 212 271 u32 cr, route; 213 272 u32 i_busif, o_busif, tmp; 214 273 const u32 *bsdsr_table; ··· 306 245 adinr = rsnd_get_adinr_bit(mod, io) | chan; 307 246 308 247 /* 309 - * SRC_IFSCR / SRC_IFSVR 310 - */ 311 - ifscr = 0; 312 - fsrate = 0; 313 - if (use_src) { 314 - u64 n; 315 - 316 - ifscr = 1; 317 - n = (u64)0x0400000 * fin; 318 - do_div(n, fout); 319 - fsrate = n; 320 - } 321 - 322 - /* 248 + * SRC_IFSCR 323 249 * SRC_SRCCR / SRC_ROUTE_MODE0 324 250 */ 251 + ifscr = 0; 325 252 cr = 0x00011110; 326 253 route = 0x0; 327 254 if (use_src) { 328 255 route = 0x1; 256 + ifscr = 0x1; 329 257 330 258 if (rsnd_src_sync_is_enabled(mod)) { 331 259 cr |= 0x1; ··· 385 335 rsnd_mod_write(mod, SRC_SRCIR, 1); /* initialize */ 386 336 rsnd_mod_write(mod, SRC_ADINR, adinr); 387 337 rsnd_mod_write(mod, SRC_IFSCR, ifscr); 388 - rsnd_mod_write(mod, SRC_IFSVR, fsrate); 389 338 rsnd_mod_write(mod, SRC_SRCCR, cr); 390 339 rsnd_mod_write(mod, SRC_BSDSR, bsdsr_table[idx]); 391 340 rsnd_mod_write(mod, SRC_BSISR, bsisr_table[idx]); ··· 396 347 rsnd_mod_write(mod, SRC_BUSIF_DALIGN, rsnd_get_dalign(mod, io)); 397 348 398 349 rsnd_adg_set_src_timesel_gen2(mod, io, fin, fout); 350 + 351 + /* update SRC_IFSVR */ 352 + rsnd_src_set_convert_rate(io, mod); 399 353 400 354 return; 401 355 ··· 519 467 int ret; 520 468 521 469 /* reset sync convert_rate */ 522 - src->sync.val = 0; 470 + src->sync.val = 471 + src->current_sync_rate = 0; 523 472 524 473 ret = rsnd_mod_power_on(mod); 525 474 if (ret < 0) ··· 528 475 529 476 rsnd_src_activation(mod); 530 477 531 - rsnd_src_set_convert_rate(io, mod); 478 + rsnd_src_init_convert_rate(io, mod); 532 479 533 480 rsnd_src_status_clear(mod); 534 481 ··· 546 493 rsnd_mod_power_off(mod); 547 494 548 495 /* reset sync convert_rate */ 549 - src->sync.val = 0; 496 + src->sync.val = 497 + src->current_sync_rate = 0; 550 498 551 499 return 0; 552 500 } ··· 583 529 rsnd_mod_interrupt(mod, __rsnd_src_interrupt); 584 530 585 531 return IRQ_HANDLED; 532 + } 533 + 534 + static int rsnd_src_kctrl_accept_runtime(struct rsnd_dai_stream *io) 535 + { 536 + struct snd_pcm_runtime *runtime = rsnd_io_to_runtime(io); 537 + 538 + if (!runtime) { 539 + struct rsnd_priv *priv = rsnd_io_to_priv(io); 540 + struct device *dev = rsnd_priv_to_dev(priv); 541 + 542 + dev_warn(dev, "\"SRC Out Rate\" can use during running\n"); 543 + 544 + return 0; 545 + } 546 + 547 + return 1; 586 548 } 587 549 588 550 static int rsnd_src_probe_(struct rsnd_mod *mod, ··· 655 585 "SRC Out Rate Switch" : 656 586 "SRC In Rate Switch", 657 587 rsnd_kctrl_accept_anytime, 658 - rsnd_src_set_convert_rate, 588 + rsnd_src_init_convert_rate, 659 589 &src->sen, 1); 660 590 if (ret < 0) 661 591 return ret; ··· 664 594 rsnd_io_is_play(io) ? 665 595 "SRC Out Rate" : 666 596 "SRC In Rate", 667 - rsnd_kctrl_accept_runtime, 597 + rsnd_src_kctrl_accept_runtime, 668 598 rsnd_src_set_convert_rate, 669 599 &src->sync, 192000); 670 600
+2 -1
sound/soc/renesas/rcar/ssi.c
··· 336 336 return 0; 337 337 338 338 rate_err: 339 - dev_err(dev, "unsupported clock rate\n"); 339 + dev_err(dev, "unsupported clock rate (%d)\n", rate); 340 + 340 341 return ret; 341 342 } 342 343
+2 -2
sound/soc/rockchip/rockchip_i2s_tdm.c
··· 451 451 break; 452 452 case SND_SOC_DAIFMT_DSP_A: 453 453 val = I2S_TXCR_TFS_TDM_PCM; 454 - tdm_val = TDM_SHIFT_CTRL(0); 454 + tdm_val = TDM_SHIFT_CTRL(2); 455 455 break; 456 456 case SND_SOC_DAIFMT_DSP_B: 457 457 val = I2S_TXCR_TFS_TDM_PCM; 458 - tdm_val = TDM_SHIFT_CTRL(2); 458 + tdm_val = TDM_SHIFT_CTRL(4); 459 459 break; 460 460 default: 461 461 ret = -EINVAL;
+17 -8
sound/soc/sof/amd/acp-ipc.c
··· 165 165 int dsp_msg, dsp_ack; 166 166 unsigned int status; 167 167 168 - if (sdev->first_boot && sdev->fw_state != SOF_FW_BOOT_COMPLETE) { 168 + if (unlikely(sdev->first_boot && sdev->fw_state != SOF_FW_BOOT_COMPLETE)) { 169 169 acp_mailbox_read(sdev, sdev->dsp_box.offset, &status, sizeof(status)); 170 + 170 171 if ((status & SOF_IPC_PANIC_MAGIC_MASK) == SOF_IPC_PANIC_MAGIC) { 171 172 snd_sof_dsp_panic(sdev, sdev->dsp_box.offset + sizeof(status), 172 173 true); ··· 189 188 190 189 dsp_ack = snd_sof_dsp_read(sdev, ACP_DSP_BAR, ACP_SCRATCH_REG_0 + dsp_ack_write); 191 190 if (dsp_ack) { 192 - spin_lock_irq(&sdev->ipc_lock); 193 - /* handle immediate reply from DSP core */ 194 - acp_dsp_ipc_get_reply(sdev); 195 - snd_sof_ipc_reply(sdev, 0); 196 - /* set the done bit */ 197 - acp_dsp_ipc_dsp_done(sdev); 198 - spin_unlock_irq(&sdev->ipc_lock); 191 + if (likely(sdev->fw_state == SOF_FW_BOOT_COMPLETE)) { 192 + spin_lock_irq(&sdev->ipc_lock); 193 + 194 + /* handle immediate reply from DSP core */ 195 + acp_dsp_ipc_get_reply(sdev); 196 + snd_sof_ipc_reply(sdev, 0); 197 + /* set the done bit */ 198 + acp_dsp_ipc_dsp_done(sdev); 199 + 200 + spin_unlock_irq(&sdev->ipc_lock); 201 + } else { 202 + dev_dbg_ratelimited(sdev->dev, "IPC reply before FW_BOOT_COMPLETE: %#x\n", 203 + dsp_ack); 204 + } 205 + 199 206 ipc_irq = true; 200 207 } 201 208
+1
sound/soc/sof/amd/acp.c
··· 27 27 static struct acp_quirk_entry quirk_valve_galileo = { 28 28 .signed_fw_image = true, 29 29 .skip_iram_dram_size_mod = true, 30 + .post_fw_run_delay = true, 30 31 }; 31 32 32 33 const struct dmi_system_id acp_sof_quirk_table[] = {
+1
sound/soc/sof/amd/acp.h
··· 220 220 struct acp_quirk_entry { 221 221 bool signed_fw_image; 222 222 bool skip_iram_dram_size_mod; 223 + bool post_fw_run_delay; 223 224 }; 224 225 225 226 /* Common device data struct for ACP devices */
-2
sound/soc/sof/amd/pci-vangogh.c
··· 13 13 14 14 #include <linux/module.h> 15 15 #include <linux/pci.h> 16 - #include <linux/platform_device.h> 17 16 #include <sound/sof.h> 18 17 #include <sound/soc-acpi.h> 19 18 20 - #include "../ops.h" 21 19 #include "../sof-pci-dev.h" 22 20 #include "../../amd/mach-config.h" 23 21 #include "acp.h"
+18 -4
sound/soc/sof/amd/vangogh.c
··· 11 11 * Hardware interface for Audio DSP on Vangogh platform 12 12 */ 13 13 14 - #include <linux/platform_device.h> 14 + #include <linux/delay.h> 15 15 #include <linux/module.h> 16 16 17 - #include "../ops.h" 18 - #include "../sof-audio.h" 19 17 #include "acp.h" 20 - #include "acp-dsp-offset.h" 21 18 22 19 #define I2S_HS_INSTANCE 0 23 20 #define I2S_BT_INSTANCE 1 ··· 133 136 }, 134 137 }; 135 138 139 + static int sof_vangogh_post_fw_run_delay(struct snd_sof_dev *sdev) 140 + { 141 + /* 142 + * Resuming from suspend in some cases my cause the DSP firmware 143 + * to enter an unrecoverable faulty state. Delaying a bit any host 144 + * to DSP transmission right after firmware boot completion seems 145 + * to resolve the issue. 146 + */ 147 + if (!sdev->first_boot) 148 + usleep_range(100, 150); 149 + 150 + return 0; 151 + } 152 + 136 153 /* Vangogh ops */ 137 154 struct snd_sof_dsp_ops sof_vangogh_ops; 138 155 EXPORT_SYMBOL_NS(sof_vangogh_ops, "SND_SOC_SOF_AMD_COMMON"); ··· 168 157 169 158 if (quirks->signed_fw_image) 170 159 sof_vangogh_ops.load_firmware = acp_sof_load_signed_firmware; 160 + 161 + if (quirks->post_fw_run_delay) 162 + sof_vangogh_ops.post_fw_run = sof_vangogh_post_fw_run_delay; 171 163 } 172 164 173 165 return 0;
+1
sound/soc/sof/intel/hda-codec.c
··· 454 454 } 455 455 EXPORT_SYMBOL_NS_GPL(hda_codec_i915_exit, "SND_SOC_SOF_HDA_AUDIO_CODEC_I915"); 456 456 457 + MODULE_SOFTDEP("pre: snd-hda-codec-hdmi"); 457 458 #endif 458 459 459 460 MODULE_LICENSE("Dual BSD/GPL");
+1
sound/soc/sof/intel/pci-ptl.c
··· 50 50 /* PCI IDs */ 51 51 static const struct pci_device_id sof_pci_ids[] = { 52 52 { PCI_DEVICE_DATA(INTEL, HDA_PTL, &ptl_desc) }, /* PTL */ 53 + { PCI_DEVICE_DATA(INTEL, HDA_PTL_H, &ptl_desc) }, /* PTL-H */ 53 54 { 0, } 54 55 }; 55 56 MODULE_DEVICE_TABLE(pci, sof_pci_ids);
+10 -2
sound/soc/sof/ipc4-topology.c
··· 765 765 } 766 766 767 767 list_for_each_entry(w, &sdev->widget_list, list) { 768 - if (w->widget->sname && 768 + struct snd_sof_dai *alh_dai; 769 + 770 + if (!WIDGET_IS_DAI(w->id) || !w->widget->sname || 769 771 strcmp(w->widget->sname, swidget->widget->sname)) 772 + continue; 773 + 774 + alh_dai = w->private; 775 + if (alh_dai->type != SOF_DAI_INTEL_ALH) 770 776 continue; 771 777 772 778 blob->alh_cfg.device_count++; ··· 2067 2061 list_for_each_entry(w, &sdev->widget_list, list) { 2068 2062 u32 node_type; 2069 2063 2070 - if (w->widget->sname && 2064 + if (!WIDGET_IS_DAI(w->id) || !w->widget->sname || 2071 2065 strcmp(w->widget->sname, swidget->widget->sname)) 2072 2066 continue; 2073 2067 2074 2068 dai = w->private; 2069 + if (dai->type != SOF_DAI_INTEL_ALH) 2070 + continue; 2075 2071 alh_copier = (struct sof_ipc4_copier *)dai->private; 2076 2072 alh_data = &alh_copier->data; 2077 2073 node_type = SOF_IPC4_GET_NODE_TYPE(alh_data->gtw_cfg.node_id);
+2
sound/soc/sof/pcm.c
··· 511 511 */ 512 512 } 513 513 514 + spcm->stream[substream->stream].substream = NULL; 515 + 514 516 return 0; 515 517 } 516 518
+5 -1
sound/soc/sof/stream-ipc.c
··· 43 43 return -ESTRPIPE; 44 44 45 45 posn_offset = stream->posn_offset; 46 - } else { 46 + } else if (sps->cstream) { 47 47 48 48 struct sof_compr_stream *sstream = sps->cstream->runtime->private_data; 49 49 ··· 51 51 return -ESTRPIPE; 52 52 53 53 posn_offset = sstream->posn_offset; 54 + 55 + } else { 56 + dev_err(sdev->dev, "%s: No stream opened\n", __func__); 57 + return -EINVAL; 54 58 } 55 59 56 60 snd_sof_dsp_mailbox_read(sdev, posn_offset, p, sz);
+16 -16
tools/accounting/getdelays.c
··· 196 196 197 197 static void print_delayacct(struct taskstats *t) 198 198 { 199 - printf("\n\nCPU %15s%15s%15s%15s%15s%15s\n" 200 - " %15llu%15llu%15llu%15llu%15.3fms%13.6fms\n" 201 - "IO %15s%15s%15s%15s\n" 202 - " %15llu%15llu%15.3fms%13.6fms\n" 203 - "SWAP %15s%15s%15s%15s\n" 204 - " %15llu%15llu%15.3fms%13.6fms\n" 205 - "RECLAIM %12s%15s%15s%15s\n" 206 - " %15llu%15llu%15.3fms%13.6fms\n" 207 - "THRASHING%12s%15s%15s%15s\n" 208 - " %15llu%15llu%15.3fms%13.6fms\n" 209 - "COMPACT %12s%15s%15s%15s\n" 210 - " %15llu%15llu%15.3fms%13.6fms\n" 211 - "WPCOPY %12s%15s%15s%15s\n" 212 - " %15llu%15llu%15.3fms%13.6fms\n" 213 - "IRQ %15s%15s%15s%15s\n" 214 - " %15llu%15llu%15.3fms%13.6fms\n", 199 + printf("\n\nCPU %15s%15s%15s%15s%15s%15s%15s\n" 200 + " %15llu%15llu%15llu%15llu%15.3fms%13.6fms%13.6fms\n" 201 + "IO %15s%15s%15s%15s%15s\n" 202 + " %15llu%15llu%15.3fms%13.6fms%13.6fms\n" 203 + "SWAP %15s%15s%15s%15s%15s\n" 204 + " %15llu%15llu%15.3fms%13.6fms%13.6fms\n" 205 + "RECLAIM %12s%15s%15s%15s%15s\n" 206 + " %15llu%15llu%15.3fms%13.6fms%13.6fms\n" 207 + "THRASHING%12s%15s%15s%15s%15s\n" 208 + " %15llu%15llu%15.3fms%13.6fms%13.6fms\n" 209 + "COMPACT %12s%15s%15s%15s%15s\n" 210 + " %15llu%15llu%15.3fms%13.6fms%13.6fms\n" 211 + "WPCOPY %12s%15s%15s%15s%15s\n" 212 + " %15llu%15llu%15.3fms%13.6fms%13.6fms\n" 213 + "IRQ %15s%15s%15s%15s%15s\n" 214 + " %15llu%15llu%15.3fms%13.6fms%13.6fms\n", 215 215 "count", "real total", "virtual total", 216 216 "delay total", "delay average", "delay max", "delay min", 217 217 (unsigned long long)t->cpu_count,
+2 -2
tools/mm/page-types.c
··· 24 24 #include <signal.h> 25 25 #include <inttypes.h> 26 26 #include <sys/types.h> 27 - #include <sys/errno.h> 28 - #include <sys/fcntl.h> 27 + #include <errno.h> 28 + #include <fcntl.h> 29 29 #include <sys/mount.h> 30 30 #include <sys/statfs.h> 31 31 #include <sys/mman.h>
+11 -1
tools/objtool/check.c
··· 227 227 str_ends_with(func->name, "_4core9panicking18panic_bounds_check") || 228 228 str_ends_with(func->name, "_4core9panicking19assert_failed_inner") || 229 229 str_ends_with(func->name, "_4core9panicking36panic_misaligned_pointer_dereference") || 230 + strstr(func->name, "_4core9panicking13assert_failed") || 230 231 strstr(func->name, "_4core9panicking11panic_const24panic_const_") || 231 232 (strstr(func->name, "_4core5slice5index24slice_") && 232 233 str_ends_with(func->name, "_fail")); ··· 1976 1975 reloc_addend(reloc) == pfunc->offset) 1977 1976 break; 1978 1977 1978 + /* 1979 + * Clang sometimes leaves dangling unused jump table entries 1980 + * which point to the end of the function. Ignore them. 1981 + */ 1982 + if (reloc->sym->sec == pfunc->sec && 1983 + reloc_addend(reloc) == pfunc->offset + pfunc->len) 1984 + goto next; 1985 + 1979 1986 dest_insn = find_insn(file, reloc->sym->sec, reloc_addend(reloc)); 1980 1987 if (!dest_insn) 1981 1988 break; ··· 2001 1992 alt->insn = dest_insn; 2002 1993 alt->next = insn->alts; 2003 1994 insn->alts = alt; 1995 + next: 2004 1996 prev_offset = reloc_offset(reloc); 2005 1997 } 2006 1998 ··· 2274 2264 2275 2265 if (sec->sh.sh_entsize != 8) { 2276 2266 static bool warned = false; 2277 - if (!warned) { 2267 + if (!warned && opts.verbose) { 2278 2268 WARN("%s: dodgy linker, sh_entsize != 8", sec->name); 2279 2269 warned = true; 2280 2270 }
+22 -3
tools/sched_ext/include/scx/common.bpf.h
··· 270 270 #define bpf_obj_new(type) ((type *)bpf_obj_new_impl(bpf_core_type_id_local(type), NULL)) 271 271 #define bpf_obj_drop(kptr) bpf_obj_drop_impl(kptr, NULL) 272 272 273 - void bpf_list_push_front(struct bpf_list_head *head, struct bpf_list_node *node) __ksym; 274 - void bpf_list_push_back(struct bpf_list_head *head, struct bpf_list_node *node) __ksym; 273 + int bpf_list_push_front_impl(struct bpf_list_head *head, 274 + struct bpf_list_node *node, 275 + void *meta, __u64 off) __ksym; 276 + #define bpf_list_push_front(head, node) bpf_list_push_front_impl(head, node, NULL, 0) 277 + 278 + int bpf_list_push_back_impl(struct bpf_list_head *head, 279 + struct bpf_list_node *node, 280 + void *meta, __u64 off) __ksym; 281 + #define bpf_list_push_back(head, node) bpf_list_push_back_impl(head, node, NULL, 0) 282 + 275 283 struct bpf_list_node *bpf_list_pop_front(struct bpf_list_head *head) __ksym; 276 284 struct bpf_list_node *bpf_list_pop_back(struct bpf_list_head *head) __ksym; 277 285 struct bpf_rb_node *bpf_rbtree_remove(struct bpf_rb_root *root, ··· 412 404 return (const struct cpumask *)mask; 413 405 } 414 406 407 + /* 408 + * Return true if task @p cannot migrate to a different CPU, false 409 + * otherwise. 410 + */ 411 + static inline bool is_migration_disabled(const struct task_struct *p) 412 + { 413 + if (bpf_core_field_exists(p->migration_disabled)) 414 + return p->migration_disabled; 415 + return false; 416 + } 417 + 415 418 /* rcu */ 416 419 void bpf_rcu_read_lock(void) __ksym; 417 420 void bpf_rcu_read_unlock(void) __ksym; ··· 440 421 */ 441 422 static inline s64 time_delta(u64 after, u64 before) 442 423 { 443 - return (s64)(after - before) > 0 ? : 0; 424 + return (s64)(after - before) > 0 ? (s64)(after - before) : 0; 444 425 } 445 426 446 427 /**
+6 -1
tools/testing/selftests/bpf/prog_tests/flow_dissector_classification.c
··· 542 542 543 543 static int set_port_drop(int pf, bool multi_port) 544 544 { 545 + char dst_port[16]; 546 + 547 + snprintf(dst_port, sizeof(dst_port), "%d", CFG_PORT_INNER); 548 + 545 549 SYS(fail, "tc qdisc add dev lo ingress"); 546 - SYS(fail_delete_qdisc, "tc filter add %s %s %s %s %s %s %s %s %s %s", 550 + SYS(fail_delete_qdisc, "tc filter add %s %s %s %s %s %s %s %s %s %s %s %s", 547 551 "dev lo", 548 552 "parent FFFF:", 549 553 "protocol", pf == PF_INET6 ? "ipv6" : "ip", ··· 555 551 "flower", 556 552 "ip_proto udp", 557 553 "src_port", multi_port ? "8-10" : "9", 554 + "dst_port", dst_port, 558 555 "action drop"); 559 556 return 0; 560 557
+52 -18
tools/testing/selftests/bpf/prog_tests/sockmap_basic.c
··· 111 111 112 112 static void test_sockmap_vsock_delete_on_close(void) 113 113 { 114 - int err, c, p, map; 115 - const int zero = 0; 116 - 117 - err = create_pair(AF_VSOCK, SOCK_STREAM, &c, &p); 118 - if (!ASSERT_OK(err, "create_pair(AF_VSOCK)")) 119 - return; 114 + int map, c, p, err, zero = 0; 120 115 121 116 map = bpf_map_create(BPF_MAP_TYPE_SOCKMAP, NULL, sizeof(int), 122 117 sizeof(int), 1, NULL); 123 - if (!ASSERT_GE(map, 0, "bpf_map_create")) { 124 - close(c); 125 - goto out; 126 - } 118 + if (!ASSERT_OK_FD(map, "bpf_map_create")) 119 + return; 120 + 121 + err = create_pair(AF_VSOCK, SOCK_STREAM, &c, &p); 122 + if (!ASSERT_OK(err, "create_pair")) 123 + goto close_map; 124 + 125 + if (xbpf_map_update_elem(map, &zero, &c, BPF_NOEXIST)) 126 + goto close_socks; 127 + 128 + xclose(c); 129 + xclose(p); 130 + 131 + err = create_pair(AF_VSOCK, SOCK_STREAM, &c, &p); 132 + if (!ASSERT_OK(err, "create_pair")) 133 + goto close_map; 127 134 128 135 err = bpf_map_update_elem(map, &zero, &c, BPF_NOEXIST); 129 - close(c); 130 - if (!ASSERT_OK(err, "bpf_map_update")) 131 - goto out; 132 - 133 - err = bpf_map_update_elem(map, &zero, &p, BPF_NOEXIST); 134 136 ASSERT_OK(err, "after close(), bpf_map_update"); 135 137 136 - out: 137 - close(p); 138 - close(map); 138 + close_socks: 139 + xclose(c); 140 + xclose(p); 141 + close_map: 142 + xclose(map); 139 143 } 140 144 141 145 static void test_skmsg_helpers(enum bpf_map_type map_type) ··· 1065 1061 test_sockmap_pass_prog__destroy(skel); 1066 1062 } 1067 1063 1064 + static void test_sockmap_vsock_unconnected(void) 1065 + { 1066 + struct sockaddr_storage addr; 1067 + int map, s, zero = 0; 1068 + socklen_t alen; 1069 + 1070 + map = bpf_map_create(BPF_MAP_TYPE_SOCKMAP, NULL, sizeof(int), 1071 + sizeof(int), 1, NULL); 1072 + if (!ASSERT_OK_FD(map, "bpf_map_create")) 1073 + return; 1074 + 1075 + s = xsocket(AF_VSOCK, SOCK_STREAM, 0); 1076 + if (s < 0) 1077 + goto close_map; 1078 + 1079 + /* Fail connect(), but trigger transport assignment. */ 1080 + init_addr_loopback(AF_VSOCK, &addr, &alen); 1081 + if (!ASSERT_ERR(connect(s, sockaddr(&addr), alen), "connect")) 1082 + goto close_sock; 1083 + 1084 + ASSERT_ERR(bpf_map_update_elem(map, &zero, &s, BPF_ANY), "map_update"); 1085 + 1086 + close_sock: 1087 + xclose(s); 1088 + close_map: 1089 + xclose(map); 1090 + } 1091 + 1068 1092 void test_sockmap_basic(void) 1069 1093 { 1070 1094 if (test__start_subtest("sockmap create_update_free")) ··· 1159 1127 test_skmsg_helpers_with_link(BPF_MAP_TYPE_SOCKHASH); 1160 1128 if (test__start_subtest("sockmap skb_verdict vsock poll")) 1161 1129 test_sockmap_skb_verdict_vsock_poll(); 1130 + if (test__start_subtest("sockmap vsock unconnected")) 1131 + test_sockmap_vsock_unconnected(); 1162 1132 }
+1 -1
tools/testing/selftests/cgroup/test_cpuset_v1_hp.sh
··· 1 - #!/bin/sh 1 + #!/bin/bash 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 # 4 4 # Test the special cpuset v1 hotplug case where a cpuset become empty of
+32 -15
tools/testing/selftests/kvm/x86/hyperv_cpuid.c
··· 41 41 return res; 42 42 } 43 43 44 - static void test_hv_cpuid(const struct kvm_cpuid2 *hv_cpuid_entries, 45 - bool evmcs_expected) 44 + static void test_hv_cpuid(struct kvm_vcpu *vcpu, bool evmcs_expected) 46 45 { 46 + const bool has_irqchip = !vcpu || vcpu->vm->has_irqchip; 47 + const struct kvm_cpuid2 *hv_cpuid_entries; 47 48 int i; 48 49 int nent_expected = 10; 49 50 u32 test_val; 51 + 52 + if (vcpu) 53 + hv_cpuid_entries = vcpu_get_supported_hv_cpuid(vcpu); 54 + else 55 + hv_cpuid_entries = kvm_get_supported_hv_cpuid(); 50 56 51 57 TEST_ASSERT(hv_cpuid_entries->nent == nent_expected, 52 58 "KVM_GET_SUPPORTED_HV_CPUID should return %d entries" ··· 86 80 entry->eax, evmcs_expected 87 81 ); 88 82 break; 83 + case 0x40000003: 84 + TEST_ASSERT(has_irqchip || !(entry->edx & BIT(19)), 85 + "\"Direct\" Synthetic Timers should require in-kernel APIC"); 86 + break; 89 87 case 0x40000004: 90 88 test_val = entry->eax & (1UL << 18); 91 89 92 90 TEST_ASSERT(!!test_val == !smt_possible(), 93 91 "NoNonArchitecturalCoreSharing bit" 94 92 " doesn't reflect SMT setting"); 93 + 94 + TEST_ASSERT(has_irqchip || !(entry->eax & BIT(10)), 95 + "Cluster IPI (i.e. SEND_IPI) should require in-kernel APIC"); 95 96 break; 96 97 case 0x4000000A: 97 98 TEST_ASSERT(entry->eax & (1UL << 19), ··· 122 109 * entry->edx); 123 110 */ 124 111 } 112 + 113 + /* 114 + * Note, the CPUID array returned by the system-scoped helper is a one- 115 + * time allocation, i.e. must not be freed. 116 + */ 117 + if (vcpu) 118 + free((void *)hv_cpuid_entries); 125 119 } 126 120 127 - void test_hv_cpuid_e2big(struct kvm_vm *vm, struct kvm_vcpu *vcpu) 121 + static void test_hv_cpuid_e2big(struct kvm_vm *vm, struct kvm_vcpu *vcpu) 128 122 { 129 123 static struct kvm_cpuid2 cpuid = {.nent = 0}; 130 124 int ret; ··· 149 129 int main(int argc, char *argv[]) 150 130 { 151 131 struct kvm_vm *vm; 152 - const struct kvm_cpuid2 *hv_cpuid_entries; 153 132 struct kvm_vcpu *vcpu; 154 133 155 134 TEST_REQUIRE(kvm_has_cap(KVM_CAP_HYPERV_CPUID)); 156 135 157 - vm = vm_create_with_one_vcpu(&vcpu, guest_code); 136 + /* Test the vCPU ioctl without an in-kernel local APIC. */ 137 + vm = vm_create_barebones(); 138 + vcpu = __vm_vcpu_add(vm, 0); 139 + test_hv_cpuid(vcpu, false); 140 + kvm_vm_free(vm); 158 141 159 142 /* Test vCPU ioctl version */ 143 + vm = vm_create_with_one_vcpu(&vcpu, guest_code); 160 144 test_hv_cpuid_e2big(vm, vcpu); 161 - 162 - hv_cpuid_entries = vcpu_get_supported_hv_cpuid(vcpu); 163 - test_hv_cpuid(hv_cpuid_entries, false); 164 - free((void *)hv_cpuid_entries); 145 + test_hv_cpuid(vcpu, false); 165 146 166 147 if (!kvm_cpu_has(X86_FEATURE_VMX) || 167 148 !kvm_has_cap(KVM_CAP_HYPERV_ENLIGHTENED_VMCS)) { ··· 170 149 goto do_sys; 171 150 } 172 151 vcpu_enable_evmcs(vcpu); 173 - hv_cpuid_entries = vcpu_get_supported_hv_cpuid(vcpu); 174 - test_hv_cpuid(hv_cpuid_entries, true); 175 - free((void *)hv_cpuid_entries); 152 + test_hv_cpuid(vcpu, true); 176 153 177 154 do_sys: 178 155 /* Test system ioctl version */ ··· 180 161 } 181 162 182 163 test_hv_cpuid_e2big(vm, NULL); 183 - 184 - hv_cpuid_entries = kvm_get_supported_hv_cpuid(); 185 - test_hv_cpuid(hv_cpuid_entries, kvm_cpu_has(X86_FEATURE_VMX)); 164 + test_hv_cpuid(NULL, kvm_cpu_has(X86_FEATURE_VMX)); 186 165 187 166 out: 188 167 kvm_vm_free(vm);
+1 -1
tools/testing/selftests/mm/run_vmtests.sh
··· 220 220 if test_selected ${CATEGORY}; then 221 221 # On memory constrainted systems some tests can fail to allocate hugepages. 222 222 # perform some cleanup before the test for a higher success rate. 223 - if [ ${CATEGORY} == "thp" ] | [ ${CATEGORY} == "hugetlb" ]; then 223 + if [ ${CATEGORY} == "thp" -o ${CATEGORY} == "hugetlb" ]; then 224 224 echo 3 > /proc/sys/vm/drop_caches 225 225 sleep 2 226 226 echo 1 > /proc/sys/vm/compact_memory
+46
tools/testing/selftests/net/forwarding/tc_flower_port_range.sh
··· 20 20 test_port_range_ipv4_tcp 21 21 test_port_range_ipv6_udp 22 22 test_port_range_ipv6_tcp 23 + test_port_range_ipv4_udp_drop 23 24 " 24 25 25 26 NUM_NETIFS=4 ··· 193 192 local name="IPv6 TCP" 194 193 195 194 __test_port_range $proto $ip_proto $sip $dip $mode "$name" 195 + } 196 + 197 + test_port_range_ipv4_udp_drop() 198 + { 199 + local proto=ipv4 200 + local ip_proto=udp 201 + local sip=192.0.2.1 202 + local dip=192.0.2.2 203 + local mode="-4" 204 + local name="IPv4 UDP Drop" 205 + local dmac=$(mac_get $h2) 206 + local smac=$(mac_get $h1) 207 + local sport_min=2000 208 + local sport_max=3000 209 + local sport_mid=$((sport_min + (sport_max - sport_min) / 2)) 210 + local dport=5000 211 + 212 + RET=0 213 + 214 + tc filter add dev $swp1 ingress protocol $proto handle 101 pref 1 \ 215 + flower src_ip $sip dst_ip $dip ip_proto $ip_proto \ 216 + src_port $sport_min-$sport_max \ 217 + dst_port $dport \ 218 + action drop 219 + 220 + # Test ports outside range - should pass 221 + $MZ $mode $h1 -c 1 -q -p 100 -a $smac -b $dmac -A $sip -B $dip \ 222 + -t $ip_proto "sp=$((sport_min - 1)),dp=$dport" 223 + $MZ $mode $h1 -c 1 -q -p 100 -a $smac -b $dmac -A $sip -B $dip \ 224 + -t $ip_proto "sp=$((sport_max + 1)),dp=$dport" 225 + 226 + # Test ports inside range - should be dropped 227 + $MZ $mode $h1 -c 1 -q -p 100 -a $smac -b $dmac -A $sip -B $dip \ 228 + -t $ip_proto "sp=$sport_min,dp=$dport" 229 + $MZ $mode $h1 -c 1 -q -p 100 -a $smac -b $dmac -A $sip -B $dip \ 230 + -t $ip_proto "sp=$sport_mid,dp=$dport" 231 + $MZ $mode $h1 -c 1 -q -p 100 -a $smac -b $dmac -A $sip -B $dip \ 232 + -t $ip_proto "sp=$sport_max,dp=$dport" 233 + 234 + tc_check_packets "dev $swp1 ingress" 101 3 235 + check_err $? "Filter did not drop the expected number of packets" 236 + 237 + tc filter del dev $swp1 ingress protocol $proto pref 1 handle 101 flower 238 + 239 + log_test "Port range matching - $name" 196 240 } 197 241 198 242 setup_prepare()
+5 -5
tools/testing/selftests/sched_ext/create_dsq.c
··· 14 14 { 15 15 struct create_dsq *skel; 16 16 17 - skel = create_dsq__open_and_load(); 18 - if (!skel) { 19 - SCX_ERR("Failed to open and load skel"); 20 - return SCX_TEST_FAIL; 21 - } 17 + skel = create_dsq__open(); 18 + SCX_FAIL_IF(!skel, "Failed to open"); 19 + SCX_ENUM_INIT(skel); 20 + SCX_FAIL_IF(create_dsq__load(skel), "Failed to load skel"); 21 + 22 22 *ctx = skel; 23 23 24 24 return SCX_TEST_PASS;
+5 -2
tools/testing/selftests/sched_ext/ddsp_bogus_dsq_fail.c
··· 15 15 { 16 16 struct ddsp_bogus_dsq_fail *skel; 17 17 18 - skel = ddsp_bogus_dsq_fail__open_and_load(); 19 - SCX_FAIL_IF(!skel, "Failed to open and load skel"); 18 + skel = ddsp_bogus_dsq_fail__open(); 19 + SCX_FAIL_IF(!skel, "Failed to open"); 20 + SCX_ENUM_INIT(skel); 21 + SCX_FAIL_IF(ddsp_bogus_dsq_fail__load(skel), "Failed to load skel"); 22 + 20 23 *ctx = skel; 21 24 22 25 return SCX_TEST_PASS;
+5 -2
tools/testing/selftests/sched_ext/ddsp_vtimelocal_fail.c
··· 14 14 { 15 15 struct ddsp_vtimelocal_fail *skel; 16 16 17 - skel = ddsp_vtimelocal_fail__open_and_load(); 18 - SCX_FAIL_IF(!skel, "Failed to open and load skel"); 17 + skel = ddsp_vtimelocal_fail__open(); 18 + SCX_FAIL_IF(!skel, "Failed to open"); 19 + SCX_ENUM_INIT(skel); 20 + SCX_FAIL_IF(ddsp_vtimelocal_fail__load(skel), "Failed to load skel"); 21 + 19 22 *ctx = skel; 20 23 21 24 return SCX_TEST_PASS;
+1 -1
tools/testing/selftests/sched_ext/dsp_local_on.bpf.c
··· 43 43 if (!p) 44 44 return; 45 45 46 - if (p->nr_cpus_allowed == nr_cpus) 46 + if (p->nr_cpus_allowed == nr_cpus && !is_migration_disabled(p)) 47 47 target = bpf_get_prandom_u32() % nr_cpus; 48 48 else 49 49 target = scx_bpf_task_cpu(p);
+1
tools/testing/selftests/sched_ext/dsp_local_on.c
··· 15 15 16 16 skel = dsp_local_on__open(); 17 17 SCX_FAIL_IF(!skel, "Failed to open"); 18 + SCX_ENUM_INIT(skel); 18 19 19 20 skel->rodata->nr_cpus = libbpf_num_possible_cpus(); 20 21 SCX_FAIL_IF(dsp_local_on__load(skel), "Failed to load skel");
+5 -5
tools/testing/selftests/sched_ext/enq_last_no_enq_fails.c
··· 15 15 { 16 16 struct enq_last_no_enq_fails *skel; 17 17 18 - skel = enq_last_no_enq_fails__open_and_load(); 19 - if (!skel) { 20 - SCX_ERR("Failed to open and load skel"); 21 - return SCX_TEST_FAIL; 22 - } 18 + skel = enq_last_no_enq_fails__open(); 19 + SCX_FAIL_IF(!skel, "Failed to open"); 20 + SCX_ENUM_INIT(skel); 21 + SCX_FAIL_IF(enq_last_no_enq_fails__load(skel), "Failed to load skel"); 22 + 23 23 *ctx = skel; 24 24 25 25 return SCX_TEST_PASS;
+5 -5
tools/testing/selftests/sched_ext/enq_select_cpu_fails.c
··· 15 15 { 16 16 struct enq_select_cpu_fails *skel; 17 17 18 - skel = enq_select_cpu_fails__open_and_load(); 19 - if (!skel) { 20 - SCX_ERR("Failed to open and load skel"); 21 - return SCX_TEST_FAIL; 22 - } 18 + skel = enq_select_cpu_fails__open(); 19 + SCX_FAIL_IF(!skel, "Failed to open"); 20 + SCX_ENUM_INIT(skel); 21 + SCX_FAIL_IF(enq_select_cpu_fails__load(skel), "Failed to load skel"); 22 + 23 23 *ctx = skel; 24 24 25 25 return SCX_TEST_PASS;
+1
tools/testing/selftests/sched_ext/exit.c
··· 23 23 char buf[16]; 24 24 25 25 skel = exit__open(); 26 + SCX_ENUM_INIT(skel); 26 27 skel->rodata->exit_point = tc; 27 28 exit__load(skel); 28 29 link = bpf_map__attach_struct_ops(skel->maps.exit_ops);
+4 -2
tools/testing/selftests/sched_ext/hotplug.c
··· 49 49 50 50 SCX_ASSERT(is_cpu_online()); 51 51 52 - skel = hotplug__open_and_load(); 53 - SCX_ASSERT(skel); 52 + skel = hotplug__open(); 53 + SCX_FAIL_IF(!skel, "Failed to open"); 54 + SCX_ENUM_INIT(skel); 55 + SCX_FAIL_IF(hotplug__load(skel), "Failed to load skel"); 54 56 55 57 /* Testing the offline -> online path, so go offline before starting */ 56 58 if (onlining)
+9 -18
tools/testing/selftests/sched_ext/init_enable_count.c
··· 15 15 16 16 #define SCHED_EXT 7 17 17 18 - static struct init_enable_count * 19 - open_load_prog(bool global) 20 - { 21 - struct init_enable_count *skel; 22 - 23 - skel = init_enable_count__open(); 24 - SCX_BUG_ON(!skel, "Failed to open skel"); 25 - 26 - if (!global) 27 - skel->struct_ops.init_enable_count_ops->flags |= SCX_OPS_SWITCH_PARTIAL; 28 - 29 - SCX_BUG_ON(init_enable_count__load(skel), "Failed to load skel"); 30 - 31 - return skel; 32 - } 33 - 34 18 static enum scx_test_status run_test(bool global) 35 19 { 36 20 struct init_enable_count *skel; ··· 24 40 struct sched_param param = {}; 25 41 pid_t pids[num_pre_forks]; 26 42 27 - skel = open_load_prog(global); 43 + skel = init_enable_count__open(); 44 + SCX_FAIL_IF(!skel, "Failed to open"); 45 + SCX_ENUM_INIT(skel); 46 + 47 + if (!global) 48 + skel->struct_ops.init_enable_count_ops->flags |= SCX_OPS_SWITCH_PARTIAL; 49 + 50 + SCX_FAIL_IF(init_enable_count__load(skel), "Failed to load skel"); 28 51 29 52 /* 30 53 * Fork a bunch of children before we attach the scheduler so that we ··· 150 159 151 160 struct scx_test init_enable_count = { 152 161 .name = "init_enable_count", 153 - .description = "Verify we do the correct amount of counting of init, " 162 + .description = "Verify we correctly count the occurrences of init, " 154 163 "enable, etc callbacks.", 155 164 .run = run, 156 165 };
+5 -2
tools/testing/selftests/sched_ext/maximal.c
··· 14 14 { 15 15 struct maximal *skel; 16 16 17 - skel = maximal__open_and_load(); 18 - SCX_FAIL_IF(!skel, "Failed to open and load skel"); 17 + skel = maximal__open(); 18 + SCX_FAIL_IF(!skel, "Failed to open"); 19 + SCX_ENUM_INIT(skel); 20 + SCX_FAIL_IF(maximal__load(skel), "Failed to load skel"); 21 + 19 22 *ctx = skel; 20 23 21 24 return SCX_TEST_PASS;
+1 -1
tools/testing/selftests/sched_ext/maybe_null.c
··· 43 43 44 44 struct scx_test maybe_null = { 45 45 .name = "maybe_null", 46 - .description = "Verify if PTR_MAYBE_NULL work for .dispatch", 46 + .description = "Verify if PTR_MAYBE_NULL works for .dispatch", 47 47 .run = run, 48 48 }; 49 49 REGISTER_SCX_TEST(&maybe_null)
+5 -5
tools/testing/selftests/sched_ext/minimal.c
··· 15 15 { 16 16 struct minimal *skel; 17 17 18 - skel = minimal__open_and_load(); 19 - if (!skel) { 20 - SCX_ERR("Failed to open and load skel"); 21 - return SCX_TEST_FAIL; 22 - } 18 + skel = minimal__open(); 19 + SCX_FAIL_IF(!skel, "Failed to open"); 20 + SCX_ENUM_INIT(skel); 21 + SCX_FAIL_IF(minimal__load(skel), "Failed to load skel"); 22 + 23 23 *ctx = skel; 24 24 25 25 return SCX_TEST_PASS;
+5 -5
tools/testing/selftests/sched_ext/prog_run.c
··· 15 15 { 16 16 struct prog_run *skel; 17 17 18 - skel = prog_run__open_and_load(); 19 - if (!skel) { 20 - SCX_ERR("Failed to open and load skel"); 21 - return SCX_TEST_FAIL; 22 - } 18 + skel = prog_run__open(); 19 + SCX_FAIL_IF(!skel, "Failed to open"); 20 + SCX_ENUM_INIT(skel); 21 + SCX_FAIL_IF(prog_run__load(skel), "Failed to load skel"); 22 + 23 23 *ctx = skel; 24 24 25 25 return SCX_TEST_PASS;
+4 -5
tools/testing/selftests/sched_ext/reload_loop.c
··· 18 18 19 19 static enum scx_test_status setup(void **ctx) 20 20 { 21 - skel = maximal__open_and_load(); 22 - if (!skel) { 23 - SCX_ERR("Failed to open and load skel"); 24 - return SCX_TEST_FAIL; 25 - } 21 + skel = maximal__open(); 22 + SCX_FAIL_IF(!skel, "Failed to open"); 23 + SCX_ENUM_INIT(skel); 24 + SCX_FAIL_IF(maximal__load(skel), "Failed to load skel"); 26 25 27 26 return SCX_TEST_PASS; 28 27 }
+5 -2
tools/testing/selftests/sched_ext/select_cpu_dfl.c
··· 17 17 { 18 18 struct select_cpu_dfl *skel; 19 19 20 - skel = select_cpu_dfl__open_and_load(); 21 - SCX_FAIL_IF(!skel, "Failed to open and load skel"); 20 + skel = select_cpu_dfl__open(); 21 + SCX_FAIL_IF(!skel, "Failed to open"); 22 + SCX_ENUM_INIT(skel); 23 + SCX_FAIL_IF(select_cpu_dfl__load(skel), "Failed to load skel"); 24 + 22 25 *ctx = skel; 23 26 24 27 return SCX_TEST_PASS;
+5 -2
tools/testing/selftests/sched_ext/select_cpu_dfl_nodispatch.c
··· 17 17 { 18 18 struct select_cpu_dfl_nodispatch *skel; 19 19 20 - skel = select_cpu_dfl_nodispatch__open_and_load(); 21 - SCX_FAIL_IF(!skel, "Failed to open and load skel"); 20 + skel = select_cpu_dfl_nodispatch__open(); 21 + SCX_FAIL_IF(!skel, "Failed to open"); 22 + SCX_ENUM_INIT(skel); 23 + SCX_FAIL_IF(select_cpu_dfl_nodispatch__load(skel), "Failed to load skel"); 24 + 22 25 *ctx = skel; 23 26 24 27 return SCX_TEST_PASS;
+5 -2
tools/testing/selftests/sched_ext/select_cpu_dispatch.c
··· 17 17 { 18 18 struct select_cpu_dispatch *skel; 19 19 20 - skel = select_cpu_dispatch__open_and_load(); 21 - SCX_FAIL_IF(!skel, "Failed to open and load skel"); 20 + skel = select_cpu_dispatch__open(); 21 + SCX_FAIL_IF(!skel, "Failed to open"); 22 + SCX_ENUM_INIT(skel); 23 + SCX_FAIL_IF(select_cpu_dispatch__load(skel), "Failed to load skel"); 24 + 22 25 *ctx = skel; 23 26 24 27 return SCX_TEST_PASS;
+5 -2
tools/testing/selftests/sched_ext/select_cpu_dispatch_bad_dsq.c
··· 15 15 { 16 16 struct select_cpu_dispatch_bad_dsq *skel; 17 17 18 - skel = select_cpu_dispatch_bad_dsq__open_and_load(); 19 - SCX_FAIL_IF(!skel, "Failed to open and load skel"); 18 + skel = select_cpu_dispatch_bad_dsq__open(); 19 + SCX_FAIL_IF(!skel, "Failed to open"); 20 + SCX_ENUM_INIT(skel); 21 + SCX_FAIL_IF(select_cpu_dispatch_bad_dsq__load(skel), "Failed to load skel"); 22 + 20 23 *ctx = skel; 21 24 22 25 return SCX_TEST_PASS;
+5 -2
tools/testing/selftests/sched_ext/select_cpu_dispatch_dbl_dsp.c
··· 15 15 { 16 16 struct select_cpu_dispatch_dbl_dsp *skel; 17 17 18 - skel = select_cpu_dispatch_dbl_dsp__open_and_load(); 19 - SCX_FAIL_IF(!skel, "Failed to open and load skel"); 18 + skel = select_cpu_dispatch_dbl_dsp__open(); 19 + SCX_FAIL_IF(!skel, "Failed to open"); 20 + SCX_ENUM_INIT(skel); 21 + SCX_FAIL_IF(select_cpu_dispatch_dbl_dsp__load(skel), "Failed to load skel"); 22 + 20 23 *ctx = skel; 21 24 22 25 return SCX_TEST_PASS;
+5 -2
tools/testing/selftests/sched_ext/select_cpu_vtime.c
··· 15 15 { 16 16 struct select_cpu_vtime *skel; 17 17 18 - skel = select_cpu_vtime__open_and_load(); 19 - SCX_FAIL_IF(!skel, "Failed to open and load skel"); 18 + skel = select_cpu_vtime__open(); 19 + SCX_FAIL_IF(!skel, "Failed to open"); 20 + SCX_ENUM_INIT(skel); 21 + SCX_FAIL_IF(select_cpu_vtime__load(skel), "Failed to load skel"); 22 + 20 23 *ctx = skel; 21 24 22 25 return SCX_TEST_PASS;